query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
sequencelengths 0
101
| negative_scores
sequencelengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
---|---|---|---|---|---|---|
this will determine if the box is allowed to be moved, which will ultimately determine if the player is allowed to move | def moveBox(oldX,oldY,newX,newY)
xDirection=newX-oldX
yDirection=newY-oldY
proposedBoxPos=@levelArr[newY+yDirection][newX+xDirection]
case(proposedBoxPos)
when ' ','.'
#this will run when the next possible position of the box is a blank space(' ') or is a box goal ('.')
@levelArr[newY][newX]=' '
@levelArr[newY+yDirection][newX+xDirection]='$'
moveMan(oldX,oldY,newX,newY)
else
#otherwise, abort the process
return
end
replenishBoxGoals
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_valid_move x,y\n return false unless (0..3) === x\n return false unless (0..3) === y\n return @field[x][y].player == 0\n end",
"def is_move_allowed(to_x,to_y) #Checks to see if the move is allowed based on the pieces 'rule'\n allowed=false\n \n x_diff=(to_x-@x).abs\n y_diff=(to_y-@y).abs\n \n if x_diff <=1 && y_diff <=1\n allowed= true\n end\n if x==to_x && y==to_y\n allowed = false\n end\n\n return allowed\n end",
"def no_player_can_move?\n !valid_move?(:black) && !valid_move?(:red)\n end",
"def can_move?\n @max_movement > 0\n end",
"def valid_move_vect?\n valid_passive_move_vect? || valid_aggressive_move_vect?\n end",
"def allowed_move?(vector, starting_rank=nil)\n self.class.allowed_move?(vector, starting_rank)\n end",
"def could_be_valid_move?\n return @board_gfx.is_draggingpiece_valid?\n end",
"def valid_move?\n\t\tvalid_1 = (0..2).include? (@take_from)\n\t\tvalid_2 = (0..2).include? (@move_to)\n\t\tif valid_1 == false || valid_2 == false\n\t\t\tputs \"I'm sorry, please input your move in a 'x,y' format, ensuring that you are selecting numbers between 1 and 3!\"\n\t\t\tmove_input\n\t\telsif @pegs[@take_from][0] == nil\n\t\t\tputs \"I'm sorry, I'm not in the mood for a philosophical debate so let's just agree that you cannot move nothing and you can try again.\"\n\t\t\tmove_input\n\t\tend\n\tend",
"def can_move?( level, x, y )\n return true\n end",
"def valid_move?(robot)\n x_pos = robot.x_position\n y_pos = robot.y_position\n dir = robot.direction\n invalid_east_move = (x_pos == @dimension) && (dir == 'EAST')\n invalid_west_move = x_pos.zero? && (dir == 'WEST')\n invalid_north_move = (y_pos == @dimension) && (dir == 'NORTH')\n invalid_south_move = y_pos.zero? && (dir == 'SOUTH')\n !(invalid_east_move || invalid_west_move || invalid_north_move || invalid_south_move)\n end",
"def can_move?\n return false if @tb_event.nil?\n @tb_event.tb_unit.can_move?\n end",
"def valid_move?(x_des, y_des)\n ( no_x_move?(x_des) && standard_move?(x_des, y_des) ) ||\n ( promotion_move?(x_des, y_des) || pawn_capture_move?(x_des, y_des) )\n end",
"def movable?\n return false if (@type == 2 and @altitude < MAX_ALTITUDE)\n return (not moving?)\n end",
"def valid_moves\n @pad.cells.select { |c| self.can_move?(*c.pos) }\n end",
"def is_move_available?\n self.robot.world.is_move_available?(self.x, self.y)\n end",
"def valid_move?(x, y)\n return false if is_obstructed?(x, y)\n diagonal_move_left?(x, y) || diagonal_move_right?(x,y)\n \n end",
"def can_i_move?(x, y)\n x, y = x.to_i, y.to_i\n ( x >= 0 && x <= dimension.width ) && ( y >= 0 && y <= dimension.height )\n end",
"def valid_move_command?(x,y)\n @tb_event && @tb_event.tb_unit.tb_valid_move?(x,y) && $game_map.tbu_id_xy(x,y) == 0\n end",
"def movable?\n\t\tking = @board.board.select { |square, piece| piece.class == Pieces::King && piece.white == @player.white }.keys[0]\n\t\t[-1,-7,-8,-9,1,7,8,9].each do |spot| \n\t\t\tif square(calc_move(king, spot)) == \" \" || square(king).white != square(calc_move(king, spot)).white \n\t\t\t\treturn true unless getting_into_check?(king, calc_move(king, spot))\n\t\t\tend\n\t\tend\n\t\treturn false\n\tend",
"def valid_move?(new_x, new_y)\n true\n end",
"def can_move?\n counts = ticket_counts\n\n # Performs an optimisation to prevent unnecessary SQL queries\n # Since all nodes support taxi and black tickets, the player may naturally move if they have any\n return true if counts.values_at(:taxi, :black).reduce(&:+) > 0\n\n check_player_can_use_tickets(counts)\n\n publish(:fail, @errors) if @errors.any?\n\n @errors.empty?\n end",
"def valid_move?(position)\n position.between?(0,8) && !position_taken?(position)\n end",
"def movable_direction?\n\t\tif(@location.x == 0 && @direction == :WEST)\n\t\t\tthen false\n\t\telsif(@location.x == @grid-1 && @direction == :EAST)\n\t\t\tthen false\n\t\telsif(@location.y == 0 && @direction == :SOUTH)\n\t\t\tthen false\n\t\telsif(@location.y == @grid-1 && @direction == :NORTH)\n\t\t\tthen false\n\t\telse\n\t\t\ttrue\n\t\tend\n\tend",
"def move_valid?(pos)\n return false unless board.in_bounds?(pos)\n return false if board.occupied?(pos) && board.grid[pos[0]][pos[1]].color == self.color\n true\n end",
"def is_acceptable(move)\n\t\t@@ACCEPTABLE_MOVES.include?(move)\n\tend",
"def can_move?(end_pos)\n return false if end_pos == self.pos\n return false unless on_board?(end_pos)\n return false unless self.pos.vertical_to?(end_pos) || self.pos.horizontal_to?(end_pos)\n return false if own_piece?(@board[end_pos])\n all_moves = self.pos.to(end_pos)\n return false if all_moves.empty?\n return false unless not_blocked?(all_moves)\n return false unless (self.pos - end_pos) != nil && (self.pos - end_pos).two_norm_square == 2\n return false if is_square_in_check?(end_pos, @@opponent_color[self.color])\n return true\n end",
"def legal_move?(x_destination, y_destination)\n x_movement_difference = (x_destination - self.x_pos).abs\n y_movement_difference = (y_destination - self.y_pos).abs\n\n x_movement_difference.between?(0, 1) && y_movement_difference.between?(0, 1)\n end",
"def must_not_castle_across_check\n return true unless @piece_moving and @piece_moving.kind_of?(King)\n return true unless @piece_moving.is_castling_move?( from_coord, to_coord - from_coord, @board ) \n \n interim_square = Position.new(from_coord) + (to_coord - from_coord == [0,2] ? [0,1] : [0,-1] )\n @board.consider_move( Move.new( :from_coord => from_coord, :to_coord => interim_square ) ) do\n if @board.in_check?(@piece_moving.side)\n errors.add_to_base \"You can not castle across a square which is under attack\"\n return false\n end\n end\n end",
"def check_move(direction)\n\n if direction == 0 #up\n if @y < 1\n \n return false\n end\n elsif direction == 1 #down\n if @y > @boundry\n \n return false\n end\n elsif direction == 2 #left\n if @x < 1\n \n return false\n end\n else #right\n\n if @x > @boundry\n \n return false\n end\n\n end\n\n return true\n end",
"def is_move_valid(move)\n @moves.include? move\n end",
"def isValidMoveAvailable()\n\t\tisValidMoveAvailableForDisc(@disc)\n end",
"def isValidMoveAvailable()\n\t\tisValidMoveAvailableForDisc(@disc)\n end",
"def has_possible_moves\n \t\t@mowers.each do |mower|\n \t\t\treturn true if mower.can_move? && !mower.is_going_outside?(lawn_x, lawn_y)\n\t \tend\n \t\treturn false\n \tend",
"def valid_move?(board, index)\n if index.between?(0,8) || !position_taken?(board, index)\nelse \n puts \"That is not a valid move. Please select another box on the board.\"\nend\nend",
"def valid_move?(board, position)\n !position_taken?(board, position) && position.between?(0,8)\nend",
"def blocked(player)\n # check every piece on the board\n (0..23).each do |i|\n # if it's the player's piece check if it can move\n if @myPositions[i].player == player\n\n # if it can move up, down, left, or right then the player isn't blocked\n\t \t\tif @myPositions[i].up != nil && @myPositions[i].up.player == Controller::Player::NEUTRAL\n\t\t\t \treturn false\n end\n\n\t\t \tif @myPositions[i].down != nil && @myPositions[i].down.player == Controller::Player::NEUTRAL\n\t\t\t\t return false\n end\n\n\t\t\t if @myPositions[i].left != nil && @myPositions[i].left.player == Controller::Player::NEUTRAL\n\t\t\t\t return false\n end\n\n\t\t\t if @myPositions[i].right != nil && @myPositions[i].right.player == Controller::Player::NEUTRAL\n\t\t\t\t return false\n end\n end\n end\n\n\t # we must be blocked\n \treturn true\n end",
"def valid_move?(board, position)\n position.between?(0, 8) && !position_taken?(board, position)\nend",
"def validate_command\n if requester != player\n errors.add(:allowed, I18n.t(\"errors.not_authorized\"))\n end\n unless airlift?\n if game.actions_taken == 4\n errors.add(:allowed, I18n.t(\"player_actions.no_actions_left\"))\n end\n if proposal.turn_nr != game.turn_nr\n errors.add(:allowed, I18n.t(\"movement_proposals.expired\"))\n end\n if destination_is_not_a_neighbor? && another_player_is_not_at_destination?\n errors.add(:allowed, I18n.t(\"movement_proposals.not_allowed\"))\n end\n end\n end",
"def can_move_to?(x, y)\n old_x = @object.x\n old_y = @object.y\n @object.move(x, y)\n\n unless @object_pool.world.can_move_to?(x, y)\n terrain = @object_pool.world.world[y][x]\n @object.stats.add_message(\"Bump into a #{terrain.id} #{terrain.symbol} (#{@object.x}, #{@object.y})\")\n return false\n end\n\n @object_pool.same_point_objects(@object.x, @object.y, @object).each do |obj|\n case obj\n when Character\n obj.on_collision(@object)\n return false\n when Item\n break if @object.input.is_a?(AiInput)\n\n obj.on_collision(@object)\n end\n end\n\n true\n ensure\n @object.move(old_x, old_y)\n end",
"def move_available?\n total_available_moves > 0\n end",
"def valid_move?(board, position)\n position_taken?(board, position) == false && position.between?(0, 8) ? true : false\nend",
"def valid_move?(position)\n if !position_taken?(position) && position.between?(0,8)\n true\n else\n false\n end\n end",
"def moves_available?(player)\n !@board.moves(player).empty?\n end",
"def isValidMoveAvailable()\n isValidMoveAvailableForDisc(@disc)\n end",
"def legal_move?(board,from,to)\n\t\treturn false unless super(board,to)\n\t\tfrom_y = from[1]\n\t\tfrom_x = from[0]\n\t\tto_y = to[1]\n\t\tto_x = to[0]\n\t\t#when trying to move diagonally\n\t\tif from_x != to_x\n\t\t\t#checks colour of pawn\n\t\t\tif colour == \"white\"\n\t\t\t\t#checks only 1 vertical move away\n\t\t\t\tif (from_y-to_y) == 1\n\t\t\t\t\treturn true\n\t\t\t\telse\n\t\t\t\t\tputs \"No enemy pawn there\"\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tif (to_y-from_y) == 1\n\t\t\t\t\treturn true\n\t\t\t\telse\n\t\t\t\t\tputs \"No enemy pawn there\"\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t#when trying to move straight\n\t\tif colour == \"white\"\n\t\t\tif from_y == 6\n\t\t\t\tif (from_y-to_y) <= 2 && board.get_piece(to) == \"_\"\n\t\t\t\t\treturn true\n\t\t\t\telse\n\t\t\t\t\tputs \"Can only move 1 or 2 spaces from here and or another piece already there\"\n\t\t\t\t\treturn false\n\t\t\t\tend\t\t\t\t\t\n\t\t\telse\n\t\t\t\tif (from_y-to_y) == 1 && board.get_piece(to) == \"_\"\n\t\t\t\t\treturn true\n\t\t\t\telse\n\t\t\t\t\tputs \"Can only move 1 space from here and or another piece already there\"\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tif from_y == 1\n\t\t\t\tif (to_y-from_y) <= 2 && board.get_piece(to) == \"_\"\n\t\t\t\t\treturn true\n\t\t\t\telse\n\t\t\t\t\tputs \"Can only move 1 or 2 spaces from here and or another piece already there\"\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tif (to_y-from_y) == 1 && board.get_piece(to) == \"_\"\n\t\t\t\t\treturn true\n\t\t\t\telse\n\t\t\t\t\tputs \"Can only move 1 space from here and or another piece already there\"\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def can_move?(direction)\n m = @pusher[:pos_m]\n n = @pusher[:pos_n]\n\n direction = direction.downcase\n\n # Following of the direction, test 2 cells\n if direction == 'u'\n move1 = read_pos(m-1, n)\n move2 = read_pos(m-2, n)\n elsif direction == 'd'\n move1 = read_pos(m+1, n)\n move2 = read_pos(m+2, n)\n elsif direction == 'l'\n move1 = read_pos(m, n-1)\n move2 = read_pos(m, n-2)\n elsif direction == 'r'\n move1 = read_pos(m, n+1)\n move2 = read_pos(m, n+2)\n end\n\n # Check that's not a wall, or two boxes, or one boxes and a wall\n !(move1 == '#' || ((move1 == '*' || move1 == '$') && (move2 == '*' || move2 == '$' || move2 == '#')))\n end",
"def isValidMove(pos)\n\tif pos < 0 || pos > 8\n\t\tprint \"Invalid move. Try again human. \\n\"\n\t\treturn false\n\telsif @bo[pos] == '-' then\n\t\treturn true\n\telse \n\t\treturn false\n\tend\n end",
"def unit_movable?\n return false if @tb_unit.nil?\n @tb_unit.can_move?\n end",
"def valid_move?\n\t\t@table.stays_on_table?(@robot_direction, @x, @y)\n\tend",
"def valid_move?(move)\n new_position = @current_player.position_after_move(move)\n\n if(@players.available_moves(@current_player).include? move)\n if(@mine.mineable?(new_position) && @current_player.tunneler != move)\n @current_player.damage(5, \"bumping into the wall\")\n return false\n elsif(@rubies.ruby_at_position(new_position))\n puts \"Found a ruby! Take it home!\"\n @current_player.load_up(@rubies.ruby_at_position(new_position))\n elsif(@current_player.home?(new_position))\n @current_player.unload_ruby\n end\n return true\n end\n\n false\n end",
"def move_valid_for?(player_id)\n return false if last_player_id == player_id\n\n true\n end",
"def valid_moves\n\n end",
"def check_legal_move(y,x)\n\t\tif y > 7 || y < 0\n\t\t\treturn false\n\t\telsif x > 7 || x < 0\n\t\t\treturn false\n\t\telse\n\t\t\treturn true\n\t\tend\n\tend",
"def valid_move?(input)\n #checks that the attempted move is within the bounds of the game board\n input.between?(0, 8) && !position_taken?(input)\n end",
"def valid_move?(board, position)\n if !(position_taken?(board, position)) && position.between?(0, 8)\n return true\n else\n return false\n end\nend",
"def can_move?(cordx, cordy , x_dest, y_dest)\n\t\t\n\t\tif @pieces == nil \n\t\t\tputs \"No piece at.\"\n\t\telsif x_dest == cordx && y_dest == cordy\n\t\t\tputs \"no change\"\n\t\telsif x_dest > 8 || y_dest > 8\n\t\t\t puts \"Offboard.\"\n\t\telse \n\t\t\t@pieces[cordx][cordy].can_move?(x_dest, y_dest)\n\t\tend\n\tend",
"def tryMove\n if @enemy\n collidesWithPlayer\n else\n collidesWithEnemy\n end\n detectCollision\n end",
"def obstructed?( board, mypos, vector )\n\n return false if @function==:knight\n\n if @function==:pawn && vector[0] != 0 \n dest_piece = board[ mypos ^ vector ]\n\n #TODO Pawn#allowed_moves(board) should provide this case\n return false if board.en_passant_square && (mypos ^ vector)==board.en_passant_square.to_sym\n\n return true unless dest_piece && dest_piece.side != self.side\n end\n\n vector.walk do |step|\n if dest_piece = board[ mypos ^ step ]\n return step != vector || dest_piece.side == self.side\n end\n end\n \n return false\n end",
"def validate_player_move(move)\r\n \r\n #Return a value of false is the square has already been\r\n #selected\r\n return false if move == \"A1\" && $A1 != \" \"\r\n return false if move == \"B1\" && $B1 != \" \"\r\n return false if move == \"C1\" && $C1 != \" \"\r\n return false if move == \"A2\" && $A2 != \" \"\r\n return false if move == \"B2\" && $B2 != \" \"\r\n return false if move == \"C2\" && $C2 != \" \"\r\n return false if move == \"A3\" && $A3 != \" \"\r\n return false if move == \"B3\" && $B3 != \" \"\r\n return false if move == \"C3\" && $C3 != \" \" \r\n \r\n #Return a value of true if the square is available\r\n return true\r\n \r\n end",
"def valid_move?(input)\n (0..8).include?(input) && !position_taken?(input)\n end",
"def valid_move?(board,position)\n valid = nil\n if position >= 0 && position <=8\n case position_taken?(board,position)\n when true\n valid = false\n when false\n valid = true\n end\n end\n\n return valid\nend",
"def move?\n @moving\n end",
"def valid_castling?(new_x, new_y)\n # The right to castle has been lost if the king has moved.\n return false if moved?\n\n # Castling is permitted if the king and the chosen rook are on the player's first rank.\n # Since the king hasn't moved, then y_coord will be the same as the player's first rank.\n return false unless y_coord == new_y\n\n # Castling is not permitted unless the king moves two spaces along the same rank.\n return false unless new_x == 3 || new_x == 7\n\n # Castling is not permitted if the rook has moved, or if there are any obstructions.\n return false unless rook_requirements_met?(new_x, new_y)\n\n # Allows Castling if the squares that the king traverses are not under attack.\n !king_traversal_under_attack?(new_x, new_y)\n end",
"def valid_move?(move_index)\r\n #valid if position is NOT taken\r\n valid = !self.position_taken?(move_index)\r\n if valid == true\r\n if move_index.between?(0,8)\r\n valid = true\r\n else\r\n valid = false\r\n end\r\n end\r\n valid\r\n end",
"def move_is_valid?(position)\n\t\tif @played_positions.index(position)\n\t\t\tresult = false\n\t\telse \n\t\t\t@played_positions << position \n\t\t\tresult = true\n\t\tend\n\t\tresult\n\tend",
"def can_use_move?\n moves = @moveset\n # TODO : Implement all the move conditions\n return moves.any? { |move| move.pp > 0 }\n end",
"def move_possible?(target)\n self != target && # Can't target self\n same_scope?(target) && # can't be in different scopes\n # !(left..right).include?(target.left..target.right) # this needs tested more\n # detect impossible move\n !((left <= target.left && right >= target.left) or (left <= target.right && right >= target.right))\n end",
"def check_move(start_pos, end_pos)\n # p start_pos\n # puts end_pos\n\n if self[[start_pos[0], start_pos[1]]].valid_move?(start_pos, end_pos, self)\n self[[start_pos[0], start_pos[1]]].move(start_pos, end_pos, self)\n end\n end",
"def can_place(position)\n planes.none? do |plane|\n plane.wings.in_horizontal_range(BoundingBox.new(position, position + width, 0, 0))\n end\n end",
"def valid_move?(fir, sec)\n if (sec < 0) || (sec > 8)\n return false\n elsif position_taken?(fir,sec)\n return false\n else\n return true\n end\nend",
"def need_update(member)\n return false if (member.x == @x and member.y == @y) \n return false if player_distance(member) and not @start_moving\n return false if @move_update.empty?\n @start_moving = true\n if @move_update[0] == 'move_left'\n return false if (member.x + 1 == @x and member.y == @y)\n elsif @move_update[0] == 'move_right'\n return false if (member.x - 1 == @x and member.y == @y)\n elsif @move_update[0] == 'move_up'\n return false if (member.y + 1 == @y and member.x == @x)\n elsif @move_update[0] == 'move_down'\n return false if (member.y - 1 == @y and member.x == @x)\n elsif @move_update[0] == 'move_upper_left'\n return false if (member.x + 1 == @x and member.y + 1 == @y)\n elsif @move_update[0] == 'move_upper_right'\n return false if (member.x - 1 == @x and member.y + 1 == @y)\n elsif @move_update[0] == 'move_lower_left'\n return false if (member.x + 1 == @x and member.y - 1 == @y)\n elsif @move_update[0] == 'move_lower_right'\n return false if (member.x - 1 == @x and member.y - 1 == @y)\n end\n return true\n end",
"def valid_move?(board, position)\n position = position.to_i\n return false if !valid_position?(position)\n return false if position_taken?(board, position)\n return true\nend",
"def can_be_blocked?(new_x, new_y)\n game.pieces.where(is_white: !is_white).where.not(x_position: nil, y_position: nil, type: KING).find_each do |piece|\n straight_obstruction_array(new_x, new_y).each do |coords|\n return true if piece.valid_move?(coords.first, coords.last)\n end\n end\n false\n end",
"def valid_move? (board, position)\n position = position.to_i - 1\n (position.between?(0,8)) && (position_taken?(board, position) == false)\nend",
"def valid_move?(board, position)\n if position_taken?(board, position) == false && position.to_i.between?(0,8)\n true\n else\n false\n end\n end",
"def movable?\n return false if @enemy && !@enemy.movable?\n return super\n end",
"def validate_move(world, new_coords)\n true if new_coords[0].between?(0, world.size-1) && new_coords[1].between?(0, world.size-1)\n end",
"def legal_move?(move)\n captured_piece = @board.data[move[0]][move[1]]\n move_current_piece(move)\n king = @king_location || move\n result = safe_king?(king)\n @board.data[move[0]][move[1]] = captured_piece\n result\n end",
"def legal_move?(move)\n captured_piece = @board.data[move[0]][move[1]]\n move_current_piece(move)\n king = @king_location || move\n result = safe_king?(king)\n @board.data[move[0]][move[1]] = captured_piece\n result\n end",
"def valid_move?(number_entered, board)\n number_entered.between?(0, 8) && !(position_taken?(board, number_entered))\nend",
"def movable_moving?\n\n @movable_delta_x&.nonzero? || @movable_delta_y&.nonzero?\n\n end",
"def moving?\n !@start_move\n end",
"def valid_move?( player_input )\n player_input.to_i >= 1 && player_input.to_i <= 9 && !taken?( player_input )\n end",
"def valid_move?(board, index)\nif position_taken?(board, index) == false\n if between?(index) == true\n true\n else\n false\n end\nelse\n false\nend\nend",
"def move?\n return @moving\n end",
"def lock_movements?\n true\n end",
"def valid_move?(player, input)\n\t\t\treturn @board.place_mark(player.mark, input)\t\n\t\tend",
"def validate_move(input)\n if [1,2,3,4,5,6,7,8,9].include?(input) && !player1.include?(input) && !player2.include?(input) \n true\n else\n false\n end\n end",
"def checkSpot(box)\n #validate if the cloud maxwidth isn't violated\n if @maxWidth > 0\n lx = [@ul.x, box.ul.x].min\n rx = [@lr.x, box.lr.x].max\n if((rx - lx) > @maxWidth)\n return false\n end\n end\n \n # validate if the box doesn't overlap other boxes\n ok = true\n for tb in @boxes\n if tb.inPosition && box.overlaps(tb)\n ok = false\n \n break\n end\n end\n return ok\n end",
"def valid_move?(board, position)\n position.to_i.between?(1,9) && !position_taken?(board, position.to_i-1)\nend",
"def movable?\r\n exist? && restriction < 4\r\n end",
"def valid_move?(position)\n index=position.to_i - 1\n index.between?(0, 8) && !(position_taken?(index))\n end",
"def valid_move?(position)\n !taken?(position) && position.to_i >0 && position.to_i <=9\n end",
"def legal_move?(input)\n return false if @board.pieces[input[0]].nil?\n return false if @board.pieces[input[0]].color == other_player.color\n\n # return false if @board.pieces.include?(input[1])\n # return false if @board.pieces[input[1]].color == player.color\n true\n end",
"def validMove(piece, newLocation)\n # piece can move to any empty adjacent space.\n # might need to account for placing pieces. can be counted as a fly move i guess \n\n if newLocation == nil || piece == nil\n return false\n end\n\n # check if its a fly move. \n if @player1.isActive\n if @player1.numPlayedPieces <= 3\n fly = true \n else\n fly = false\n end\n else\n if @player2.numPlayedPieces <= 3\n fly = true \n else\n fly = false\n end\n end\n\n\n #checks if space is empty:\n if newLocation.isEmpty()\n # check if its a fly move\n if fly\n # if its a fly and the target location is empty its allowed. \n return true\n elsif piece.location == nil\n return true\n else\n # should return true if the move is valid.\n return @board.isAdjacent(piece,newLocation)\n end\n else\n # should the space is not empty, the move is invalid\n return false\n end\n\n end",
"def validates_move move\n\t\t!@moves.include?(move) && move.index.between?(1,10)\n\tend",
"def has_possible_moves\n \t\t@mowers.each do |mower|\n \t\t\treturn true if mower.can_move?(lawn_mowers_positions)\n\t \tend\n \t\treturn false\n \tend",
"def valid_move?(position)\n if !position.is_a?(Integer)\n position = position.to_i\n end\n if(position>=1 && position<=@board.length && !position_taken?(position))\n return true\n end\n return false\n end",
"def valid_move?(destination)\n occupant = @board[destination]\n result = false\n if occupant.nil? || (enemy? occupant)\n result = movement_rule(destination)\n end\n\n result\n end",
"def valid_move?(board, position)\n # position = position.to_i \n position.to_i. between?(1, 9) && !position_taken?(board, position.to_i-1)\nend",
"def in_bounds?(move)\n\t\tif move < @board.length && move >= 0\n\t\t\treturn true \n\t\telse \n\t\t\treturn false\n\t\tend \t\t\n\tend"
] | [
"0.7199138",
"0.7148825",
"0.7042504",
"0.6999087",
"0.6953574",
"0.685911",
"0.6841494",
"0.6837268",
"0.68134755",
"0.6741231",
"0.67260826",
"0.67047095",
"0.6675688",
"0.6666348",
"0.66641533",
"0.6645274",
"0.65765107",
"0.6572021",
"0.656637",
"0.6547304",
"0.65370315",
"0.65277153",
"0.6526146",
"0.65054727",
"0.6502306",
"0.64990866",
"0.6494451",
"0.6453278",
"0.644704",
"0.6441774",
"0.64397",
"0.64397",
"0.6425445",
"0.6422666",
"0.6420049",
"0.64176005",
"0.64127713",
"0.64112425",
"0.63989896",
"0.63977516",
"0.63734037",
"0.6367742",
"0.6366224",
"0.6363733",
"0.6358811",
"0.63572687",
"0.6357043",
"0.6339231",
"0.63375026",
"0.63372135",
"0.63199955",
"0.63196975",
"0.63063115",
"0.6305898",
"0.63032967",
"0.6301606",
"0.629594",
"0.6288618",
"0.62880033",
"0.62860787",
"0.62826884",
"0.6280727",
"0.6278286",
"0.6264956",
"0.6257555",
"0.6256709",
"0.6255512",
"0.62535846",
"0.6248602",
"0.623493",
"0.62333167",
"0.6224839",
"0.6220954",
"0.6217897",
"0.62075293",
"0.62068224",
"0.6206684",
"0.6205582",
"0.6205582",
"0.62032133",
"0.6202742",
"0.62023854",
"0.61960906",
"0.61947227",
"0.61918205",
"0.6186878",
"0.6182387",
"0.61819726",
"0.6172009",
"0.61705536",
"0.6167561",
"0.6162796",
"0.6162727",
"0.615622",
"0.6152817",
"0.61519873",
"0.61499375",
"0.6148255",
"0.6140867",
"0.6138095",
"0.6131996"
] | 0.0 | -1 |
creating an array for locateMan, where the 0th element is x across, and the 1st element is y down | def locateMan
yDown=0
@levelArr.each do |y|
xCount=1
y.each do |x|
if x == '@'
return xCount,yDown
end
xCount+=1
end
yDown+=1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def location\n [@posX, @posY, @facing]\n end",
"def cal_pos\n x, y = map_location(@grid_x, @grid_y)\n x += @tile_size/2\n y += @tile_size/2\n [x,y]\n end",
"def get_cell_at_xy(input_array)\n input_array.map do |coord|\n x = coord[0]\n y = coord[1]\n at_coord(x, y)\n end\n end",
"def coords_ahead\n dx = (dir_index - 2).remainder(2).to_i\n dy = (dir_index - 1).remainder(2).to_i\n [posx - dx, posy - dy]\n end",
"def position(y, x)\n [START[0] + (y * SPACING[0]),\n START[1] + (x * SPACING[1])]\n end",
"def position\n return [@x, @y, @heading]\n end",
"def xy(offset_x, offset_y)\n @board[3 * offset_y + offset_x - 4]\n end",
"def position\n [@x, @y]\n end",
"def position\n [x, y]\n end",
"def rectangle_finder(arr)\n # Find the upper left coordinates\n ul_row = arr.index { |row| row.include?(1) }\n ul_col = arr[ul_row].index(1)\n\n # Find the bottom right coordinates from this\n br = bottom_right(arr, [ul_row, ul_col])\n\n # Return the two together\n [[ul_row, ul_col], br]\nend",
"def human_move_to_coord(human_move)\n trad = {\n \"1\" => [0, 0], #upper left corner\n \"2\" => [0, 1],\n \"3\" => [0, 2],\n \"4\" => [1, 0],\n \"5\" => [1, 1],\n \"6\" => [1, 2],\n \"7\" => [2, 0],\n \"8\" => [2, 1],\n \"9\" => [2, 2] # down right corner\n }\n trad[human_move] #return position in our nested array\n end",
"def vision(row_offset, column_offset)\n vision_array[row_radius + row_offset][column_radius + column_offset]\n end",
"def walk(grid, x, y)\n [N, S, E, W].shuffle.each do |dir|\n nx, ny = x + DX[dir], y + DY[dir]\n if nx >= 0 && ny >= 0 && ny < grid.length && nx < grid[ny].length && grid[ny][nx] == 0\n grid[y][x] |= dir\n grid[ny][nx] |= OPPOSITE[dir]\n \n return [nx, ny]\n end\n end\n \n nil\nend",
"def rectilinear_obstruction_array(destination_row, destination_col)\n # Store initial variables\n new_row_position = current_row_index\n new_column_position = current_column_index\n obstruction_array = []\n # Determine horizontalincrements\n if new_row_position == destination_row # protector piece is on same row with king\n # begin moving across column positions\n column_increment = destination_col > new_column_position ? 1 : -1\n new_column_position += column_increment\n while (destination_col - new_column_position).abs > 0\n obstruction_array << [new_row_position, new_column_position]\n new_column_position += column_increment\n end\n elsif new_column_position == destination_col # protector piece is on same column with king\n # begin moving across row positions\n row_increment = destination_row > new_row_position ? 1 : -1\n new_row_position += row_increment\n while (destination_row - new_row_position).abs > 0\n obstruction_array << [new_row_position, new_column_position]\n new_row_position += row_increment\n end\n end\n # return obstruction array (values will be checked later )\n obstruction_array\n end",
"def location(x, y, w, h)\n return x - w/2, y + 20\n end",
"def coordinates\n [@y_location, @x_location]\n end",
"def position\n\t\t[ @x, @y ]\n\tend",
"def build_obstruction_array(x_end, y_end)\n y_change = y_position - y_end\n x_change = x_position - x_end\n\n # Build array squares which piece must move through\n obstruction_array = []\n if x_change.abs == 0 # If it's moving vertically\n (1..(y_change.abs-1)).each do |i|\n obstruction_array << [x_position, y_position - (y_change/y_change.abs) * i]\n end\n elsif y_change.abs == 0 # If horizontally\n (1..(x_change.abs-1)).each do |i| # 7 times do (0..6).each do\n obstruction_array << [x_position - (x_change/x_change.abs) * i, y_position]\n end\n elsif y_change.abs == x_change.abs #if diagonally\n (1..(y_change.abs-1)).each do |i|\n obstruction_array << [x_position - (x_change/x_change.abs) * i, y_position - (y_change/y_change.abs) * i]\n end\n end\n obstruction_array\n end",
"def new_coords(x,y)\n [x % GRID_WIDTH, y % GRID_HEIGHT]\n end",
"def parse\n start_x = 0\n start_y = 0\n\n @maze.each_with_index do |line, index|\n if line.include? 'S'\n start_y = line.index('S')\n start_x = index\n break\n end\n end\n [start_x, start_y]\n end",
"def mine_locations\n mine_array = []\n until mine_array.length == 9\n row = (0..9).to_a.sample\n column = (0..9).to_a.sample\n unless mine_array.include?([row,column])\n mine_array << [row, column]\n end\n end\n mine_array\n end",
"def new_coords(x, y)\n [x % GRID_WIDTH, y % GRID_HEIGHT]\n end",
"def next_position\n return unless placed?\n axis = case direction\n when 'east', 'west'; :x\n when 'north', 'south'; :y\n end\n amount = case direction\n when 'north', 'east'; +1\n when 'south', 'west'; -1\n end\n [@x + (axis == :x ? amount : 0), @y + (axis == :y ? amount : 0)]\n end",
"def index_for(x, y, coordinate_system=:row_col)\n case coordinate_system\n when :row_col\n x * 9 + y\n when :col_row\n y * 9 + x\n when :box\n [0,3,6,27,30,33,54,57,60][x] + [0,1,2,9,10,11,18,19,20][y]\n end\n end",
"def coordinates_to_indices(x, y)\n [x - 1, y - 1]\n end",
"def all_moves_array(initial_x, initial_y)\n\t\tfinal = []\n\t\tx = initial_x + 2\n\t\tfinal << [x, initial_y+1] << [x, initial_y-1]\n\t\tx = initial_x - 2\n\t\tfinal << [x, initial_y+1] << [x, initial_y-1]\n\t\ty = initial_y + 2\n\t\tfinal << [initial_x+1, y] << [initial_x-1, y]\n\t\ty = initial_y - 2\n\t\tfinal << [initial_x+1, y] << [initial_x-1, y]\n\t\tfinal\n\tend",
"def meta_random_location(array)\n @plataforma_meta.x = array[0]\n @plataforma_meta.y = array[1] + 45\n end",
"def discover_points # step 1\r\n x = 0\r\n y = 0\r\n @image_arr.each do |row|\r\n x = 0\r\n row.each do |cell|\r\n if cell == 1 # discovered the cell is 1\r\n @ordinal_arr.push([y,x]) # this is where i push the ordinals.\r\n puts \"#{y},#{x}\"\r\n end\r\n x = x + 1\r\n end\r\n y = y + 1\r\n puts \"\" \r\n end\r\n end",
"def coords\n coord_list = []\n (@x..(@x + @size_x - 1)).each do |i|\n (@y..(@y + @size_y - 1)).each do |j|\n coord = [i, j]\n coord_list << coord\n end\n end\n\n return coord_list\n end",
"def coordinates(image)\n image.each_with_index.flat_map do |row,x|\n (0...row.length).find_all{|i| row[i] == @char }.map{|y| [x,y] }\n end\n end",
"def location(x, y, theta, distance)\n \t return [\n \t x + distance * Math.cos(theta),\n \t y - distance * Math.sin(theta)\n \t ]\n \tend",
"def create_starting_positions\n\t\t[Point.new(BOARD_WIDTH/4, BOARD_HEIGHT/4),\n \t\tPoint.new(3 * BOARD_WIDTH/4, 3 * BOARD_HEIGHT/4),\n\t\tPoint.new(3 * BOARD_WIDTH/4, BOARD_HEIGHT/4),\n\t\tPoint.new(BOARD_WIDTH/4, 3 * BOARD_HEIGHT/4)]\n\tend",
"def marker_coords(marker)\n row = @grid.find_index { |x| x.include?(marker) }\n col = @grid[row].index(marker)\n\n [col, row]\n end",
"def current_pos\n\t\treturn arr = [pos_x, pos_y]\n\tend",
"def get_objects_at_coord(x_location, y_location)\n get_world_array[Matrix.two_to_one(x_location, y_location, @x_size)]\n end",
"def coords(x, y)\n return [x % WIDTH, y % HEIGHT]\n end",
"def hint_idx_to_coord(i)\n j = i % SIZE\n\n if i >= 0 && i < SIZE\n # top\n r = (0..(SIZE-1)).to_a.map{ |a| {x: j, y: a} }\n elsif i >= SIZE && i < (SIZE * 2)\n r = (0..(SIZE-1)).to_a.reverse.map{ |a| {x: a, y: j} }\n elsif i >= (SIZE * 2) && i < (SIZE * 3)\n r = (0..(SIZE-1)).to_a.reverse.map{ |a| {x: (SIZE - 1) - j, y: a} }\n else\n r = (0..(SIZE-1)).to_a.map{ |a| {x: a, y: (SIZE - 1) - j} }\n end\n r\nend",
"def hint_idx_to_coord(i)\n j = i % SIZE\n\n if i >= 0 && i < SIZE\n # top\n r = (0..(SIZE-1)).to_a.map{ |a| {x: j, y: a} }\n elsif i >= SIZE && i < (SIZE * 2)\n r = (0..(SIZE-1)).to_a.reverse.map{ |a| {x: a, y: j} }\n elsif i >= (SIZE * 2) && i < (SIZE * 3)\n r = (0..(SIZE-1)).to_a.reverse.map{ |a| {x: (SIZE - 1) - j, y: a} }\n else\n r = (0..(SIZE-1)).to_a.map{ |a| {x: a, y: (SIZE - 1) - j} }\n end\n r\nend",
"def sun_locations(loc)\r\n range = (@width / 4) - 1\r\n loc1 = loc - range\r\n\tloc2 = loc + range\r\n\tloc1 = (@width + loc1) if loc1 < 1\r\n\tloc2 = loc2 - @width if loc2 > @width\r\n #puts \"\"\r\n\t#puts loc1\r\n\t#puts loc\r\n\t#puts loc2\r\n\t\r\n\t#t = [loc1,loc2]\r\n\t\r\n\tss = []\r\n\tif loc1 < @sun_location\r\n\t [*loc1...(@sun_location)].each do |k|\r\n\t ss << k\r\n\t end\r\n\telsif (@sun_location+1) < loc1\r\n\t [*loc1..@width].each do |k|\r\n\t ss << k\r\n\t end\r\n\t [*1..(@sun_location-1)].each do |k|\r\n\t ss << k\r\n\t end\r\n\tend\r\n\t\r\n\tif @sun_location < loc2\r\n\t [*(@sun_location+1)..loc2].each do |k|\r\n\t ss << k\r\n\t end\r\n\telsif loc2 < @sun_location\r\n\t [*1..loc2].each do |k|\r\n\t ss << k\r\n\t end\r\n\t [*(@sun_location+1)..@width].each do |k|\r\n\t ss << k\r\n\t end\r\n\tend\r\n\t#puts ss\r\n\tss\r\n end",
"def cell_at_point(x, y)\n [x / Entity::WIDTH, y / Entity::HEIGHT ]\n end",
"def carve_walls_from_point(x, y, grid)\n \nend",
"def index(x, y)\n (y - 1) * width + (x - 1)\n end",
"def positions_of_agents\n positions = []\n @figures.each {|f| positions << f.position}\n positions.shift\n positions\n end",
"def mineLocation field\n coords = []\n field.each_index do | i |\n field[i].each_index do | j |\n if field[i][j] == 1\n coords << i\n coords << j\n end\n end\n end\n coords\nend",
"def mineLocation(field)\n row = 0\n column = 0\n field.each_with_index do |array, index|\n row = index if array.include?(1)\n end\n\n field[row].each_with_index do |num, index|\n column = index if num.eql?(1)\n end\n [row, column]\nend",
"def find_position(grid, p_m)\n grid.each_with_index do |row, index|\n @position_x = index\n @position_y = row.index(p_m)\n break if @position_y\n end\n fail \"#{p_m == 'p' ? 'Princess' : 'Bot'} not found\" unless @position_y\n [@position_x, @position_y]\n end",
"def at(x, y)\n @codeGrid[y][x]\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 get_arr_x(x, y) \n x # this coordinate doesn't change\nend",
"def coord2pos(x, y)\n (y % h)*w+(x % w)\n end",
"def asteroid_relative(x,y,grid)\n\tpoints = Hash.new\n\tx_root, y_root = x, y\n\tgrid.each do |(x, y), value|\t\t\n\t\tpoints[[x,y]] = Point.from_offset(x_root, y_root, x, y)\n\tend\n\tpoints\nend",
"def possible_neighbors(y,x)\n # (-1..1).to_a.map do |row_offset|\n # (-1..1).to_a.map do |col_offset|\n # return y - row_offset, x - col_offset\n # end\n # end\n up = y-1\n down = y + 1\n my_row = y\n left = x - 1\n right = x + 1\n my_column = x\n\n [\n [my_row,x-1],[y,x+1], # sides\n [up,x-1], [y-1,x], [y-1,x+1], # top\n [down,x-1], [y+1,x], [y+1,x+1] # bottom\n ]\n end",
"def ramdon_location\n seleccion = @plataformas[rand(@plataformas.length)]\n ubicacion_x = seleccion.x\n ubicacion_y = seleccion.y - 45\n [ubicacion_x, ubicacion_y]\n end",
"def pos\n [posx, posy]\n end",
"def coordinates\n [rand(50), rand(90)]\n end",
"def get_destination\n dest_pos = nil\n (0..(@matrix.length - 1)).each { |x| (0..(@m - 1)).each { |y| dest_pos = Point.new(x, y) if @matrix[x][y] == '*' } }\n dest_pos\n end",
"def position_coordinates(character)\n which_row = []\n which_cell = []\n (0...@n).each { |i| prepare_set(i, character, which_row, which_cell) }\n [which_row, which_cell]\n end",
"def position\n V[x, y]\n end",
"def building_coordinates(x, y, height, width)\n puts\"building #{height}x#{width} at location (#{x},#{y})\"\n coords = Array.new\n (0..width-1).each do |j|\n\n (0..height-1).each do |i|\n\n co = Coordinate.new(x+i,y+j)\n coords.push(co)\n end\n\n end\n puts\"*getBuildingCoordinates* returning array of building coordinates\"\n coords\n end",
"def get_start_position(floor_array) \r\n floor_array.index(\"*\") \r\nend",
"def create_position_array()\n array_2D = []\n array_1D = []\n\n (0...@row).each_with_index do |value, row_index|\n (0...@col).each_with_index { |value, col_index| array_1D.append(value+(row_index*@col)) }\n array_2D.append(array_1D)\n array_1D = []\n end\n\n return array_2D\n end",
"def build_location(building)\n #stom spiral algoritme ofzo\n center = player.command_centers.first\n #spiral_location(building, {:x => center.tile_position_x,\n # :y => center.tile_position_y})\n {:x => center.x.in_build_tiles, :y => center.y.in_build_tiles - 3}\n end",
"def place_robot(x,y,name)\n if (0..max_length).include?(x) && (0..max_height).include?(y)\n self.robot_position[name] = [x,y]\n end\n end",
"def locator2(image)\n result = []\n how_wide = image.first.length\n how_long = image.length\n\n image.each_with_index do |e, i|\n e.each_with_index do |e2, i2|\n next unless e2.zero? && no_overlaps?(result, i, i2)\n answer = {\n corner: [i, i2],\n height: 1,\n width: 1\n }\n result << answer\n\n lookahead = i2 + 1\n until lookahead >= how_wide || e[lookahead] == 1\n answer[:width] += 1\n lookahead += 1\n end\n\n lookdown = i + 1\n until lookdown >= how_long || image[lookdown][i2] == 1\n answer[:height] += 1\n lookdown += 1\n end\n end\n end\n p result\n result\nend",
"def events_xy(x, y)\n result = []\n for event in $game_map.events.values\n result.push(event) if event.pos?(x, y)\n end\n return result\n end",
"def coords; {:x => @x, :y => @y} end",
"def positions(passes) = passes.map { find_position(_1) }",
"def points\n [top_left, top_right, bottom_left, bottom_right]\n end",
"def ai\n axes_for_win = @board.axes_for_sum[(@board.n - 1) * @board.xORo_hash[@player.xORo]]\n move = nil\n pos = nil\n if axes_for_win\n [:row, :col, :d].each do |type|\n if move\n break\n end\n if axes_for_win[type]\n axes_for_win[type].each do |axis, present|\n if present\n move = [type, axis]\n break\n end\n end\n end\n end\n end\n\n if move\n if move == :row\n (0...@board.n).each do |i|\n if @board.empty?(move[1], i)\n pos = [move[1], i]\n break\n end\n end\n elsif move[0] == :col\n (0...@board.n).each do |i|\n if @board.empty?(i, move[1])\n pos = [i, move[1]]\n break\n end\n end\n elsif move[1] == 0\n (0...@board.n).each do |i|\n if @board.empty?(i, i)\n pos = [i, i]\n break\n end\n end\n else\n (0...@board.n).each do |i|\n if @board.empty?(i, @board.n - i - 1)\n pos = [i, @board.n - i - 1]\n end\n end\n end\n pos\n else\n possible_pos = []\n (0...@board.n).each do |i|\n (0...@board.n).each do |j|\n if @board.empty?(i, j)\n possible_pos << [i, j]\n end\n end\n end\n pos = possible_pos.sample\n end\n pos\n end",
"def human_move_to_coordinate(human_move)\n {\n '1' => [0, 0], '2' => [1, 0], '3' => [2, 0],\n '4' => [0, 1], '5' => [1, 1], '6' => [2, 1],\n '7' => [0, 2], '8' => [1, 2], '9' => [2, 2]\n }[human_move]\n end",
"def loc\r\n { x: @mapx,\r\n y: @mapy }\r\n end",
"def [](x, y)\n @pole[x][y]\n end",
"def first_seat(x, y, delta_x, delta_y)\n return nil unless x + delta_x >= 0 && y + delta_y >= 0 && x + delta_x < grid.first.size && y + delta_y < grid.size\n\n if %w[# L].include?(get(x + delta_x, y + delta_y))\n [x + delta_x, y + delta_y]\n else\n first_seat(x + delta_x, y + delta_y, delta_x, delta_y)\n end\n end",
"def [](pos)\n self.grid[pos[1]][pos[0]]\n end",
"def generate_move_from_click(x, y)\n [:spawn, {:x => x, :y => y}]\n end",
"def loc2(x,y)\n TwoDGridLocation.new x, y\nend",
"def sector_a_intfx_coords\n [ [-1.5 * @radius, @radius], [-1.5 * @radius, -@radius], \n [-1.5 * @radius, 3 * @radius], [-3 * @radius, 2 * @radius],\n [-3 * @radius, 0], [-3 * @radius, -2 * @radius],\n [-1.5 * @radius, -3 * @radius] ]\n end",
"def gen_coordinates\n [@gen_x, @gen_y] if generator?\n end",
"def get_target_xy(e_index)\n ## get x and y distance between player and enemy1\n x_distance = ($game_player.real_x * 32 - $Enemies[e_index].mapx) \n y_distance = ($game_player.real_y * 32 - $Enemies[e_index].mapy)\n\n ## calculate weights\n x_weight = x_distance.to_f / (x_distance.to_f.abs + y_distance.to_f.abs)\n y_weight = y_distance.to_f / (x_distance.to_f.abs + y_distance.to_f.abs)\n \n ## scale assuming total distance is 350\n x_distance = x_weight * 350\n y_distance = y_weight * 350\n \n ## return [target_x, target_y] array\n return [$Enemies[e_index].mapx + x_distance, $Enemies[e_index].mapy + y_distance]\n end",
"def coords\n [x, y]\n end",
"def corners\n\t\t[[0,0],[0,@m-1],[@n-1,0],[@n-1,@m-1]]\n\tend",
"def get_position(x, y)\r\n\t\treturn maze[y][x]\r\n\tend",
"def coordinate_list\n @board.each_index.inject([]) do |result,row_index|\n result.concat( \n @board[row_index].each_index.collect do |column_index|\n [row_index + 1, column_index + 1]\n end\n )\n end\n end",
"def idx(x, y)\n tx = x % @width\n ty = y % @height\n idx = tx + ty * @width\n end",
"def field # {{{\n iy = 0\n field = Array.new(3) { |y|\n ix=0\n y = Array.new(3) { |x|\n if move=self.moves.find(:first,:conditions => { :x => ix,:y => iy })\n if move.by_player\n x = 1\n else\n x = 2\n end\n else\n x = 0\n end\n ix+=1\n x\n }\n iy+=1\n y\n }\n end",
"def [](pos)\n x, y = pos\n @grid[x][y] \n end",
"def test_cmds(cmds)\n max_x = 7\n max_y = 3\n cmds.push(\"rect 3x2\")\n cmds.push(\"rotate column x=1 by 1\")\n cmds.push(\"rotate row y=0 by 4\")\n cmds.push(\"rotate column x=1 by 1\")\n screen = Array.new(max_x) { |i| Array.new(max_y) { |i| \".\" }}\nend",
"def getMapIndex(x, y)\n return y * @width + x;\n end",
"def get_moves\n [\n { row: @row + 1, col: @col + 2 },\n { row: @row + 1, col: @col - 2 },\n { row: @row + 2, col: @col + 1 },\n { row: @row + 2, col: @col - 1 },\n { row: @row - 1, col: @col + 2 },\n { row: @row - 1, col: @col - 2 },\n { row: @row - 2, col: @col + 1 },\n { row: @row - 2, col: @col - 1 }\n ].select do |move|\n [:blank_space, :enemy_piece].include? describe_location(move[:row], move[:col])\n end\n end",
"def attacking_coordinates(piece_type = 'Queen')\n attacking_pairs(piece_type).map { |pair| pair.map(&:coordinates) }\n end",
"def new_coord\n [@position, @@move[@direction]].transpose.map { |coord| coord.reduce(:+) }\n end",
"def valid_locations(r, c)\n positions = []\n #top row\n positions << [r - 1, c - 1]\n positions << [r - 1, c]\n positions << [r - 1, c + 1]\n\n #center row\n positions << [r, c-1]\n positions << [r, c + 1]\n\n #bottom row\n positions << [r + 1, c - 1]\n positions << [r + 1, c]\n positions << [r + 1, c + 1]\n \n #array boundry Check on the list of positions to find those that are on the board\n positions.delete_if {|v| v[0] < 0 || v[0] >= row}.delete_if{|v| v[1] < 0 || v[1] >= column}\n return positions\n end",
"def moves_array\n\t\t@field[1]\n\tend",
"def position \n\t\treturn @y,@x\n\tend",
"def to_a\n [left, top, right]\n end",
"def to_a\n [left, top, right]\n end",
"def coordinate_array\n\t\t[latitude,longitude]\n\tend",
"def move_to who, ox, oy, nx, ny\n if oy != nil and ox != nil\n @monster[oy][ox] = nil\n end\n @monster[ny][nx] = who\n return 10, nx, ny\n end",
"def pos(a,b)\n\t\t@mat[a][b]\n\tend",
"def logical_pos(x, y)\n [\n (x / @tile_width).floor,\n (y / @tile_height).floor\n ]\n end"
] | [
"0.6381427",
"0.6282143",
"0.62155336",
"0.6201006",
"0.6173462",
"0.6138358",
"0.6096959",
"0.6088362",
"0.6043062",
"0.60320646",
"0.5939095",
"0.5936157",
"0.5900313",
"0.5886333",
"0.58730876",
"0.58582896",
"0.585681",
"0.5854415",
"0.58192456",
"0.58101594",
"0.5802714",
"0.5796746",
"0.5784606",
"0.57689524",
"0.574611",
"0.5744661",
"0.57270765",
"0.5725944",
"0.5723335",
"0.57232106",
"0.5718539",
"0.5708013",
"0.57061476",
"0.5705065",
"0.5702624",
"0.56982684",
"0.5695443",
"0.5695443",
"0.5693608",
"0.56861746",
"0.5678024",
"0.56724644",
"0.56698537",
"0.56647396",
"0.5643886",
"0.564307",
"0.563507",
"0.5627179",
"0.5624738",
"0.5623483",
"0.5619122",
"0.56178105",
"0.56161",
"0.5615333",
"0.5612072",
"0.5610133",
"0.560973",
"0.5605694",
"0.5599352",
"0.55955374",
"0.55865693",
"0.557009",
"0.5564452",
"0.55637944",
"0.55556864",
"0.5552451",
"0.5542464",
"0.5529406",
"0.5527022",
"0.55231446",
"0.55111694",
"0.55097425",
"0.550614",
"0.54947376",
"0.5492415",
"0.54803777",
"0.547952",
"0.5478636",
"0.5477357",
"0.5474768",
"0.5470494",
"0.54621345",
"0.5456059",
"0.5448083",
"0.5446243",
"0.542883",
"0.54282594",
"0.5427993",
"0.54251397",
"0.54210794",
"0.54191756",
"0.54150283",
"0.54144275",
"0.5413855",
"0.5411853",
"0.5411853",
"0.5411494",
"0.54079723",
"0.54077023",
"0.5400339"
] | 0.6663756 | 0 |
GET /traces/1 GET /traces/1.xml | def show
@trace = Trace.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @trace }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @traces = Trace.all\n\n render json: @traces\n end",
"def test_post_then_get\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n id = last_response.body\n\n get \"/traces/#{id}\"\n check_valid_trace last_response.body\n end",
"def show\n @traces = Trace.find_by(id: params[:id])\n url_string = ''\n response = HTTParty.get(url_string)\n data = {\n \"latitude\": @traces.latitude,\n \"longitude\": @traces.longitude,\n \"elevation\": response.body.to_i\n }\n render json: data\n end",
"def index\n @traces = Trace.all\n url_string = ''\n data = []\n pdist = 0\n plat = @traces.first.latitude\n plon = @traces.first.longitude\n traces = @traces.pluck(:latitude, :longitude).map { |lat, lon| { latitude: lat, longitude: lon } }\n response = HTTParty.post(\n url_string,\n :body => traces.to_json,\n :headers => { 'Content-Type' => 'application/json' }\n )\n @traces.each_with_index do |t,index|\n data << {\n \"latitude\": t.latitude,\n \"longitude\": t.longitude,\n \"distance\": distance([plat,plon],[t.latitude, t.longitude]) + pdist,\n \"elevation\": response[index]\n }\n pdist += distance([plat,plon],[t.latitude, t.longitude])\n plat = t.latitude\n plon = t.longitude\n end\n render json: data\n end",
"def get_trace trace_id\n ensure_service!\n service.get_trace trace_id\n end",
"def index\n @visit_stats = VisitStat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @visit_stats }\n end\n end",
"def new\n @trace = Trace.new(params[:trace])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trace }\n end\n end",
"def sampled_traces(trace_ids)\n result = false\n traces = nil\n ZipkinQuery::Client.with_transport($config) do |client|\n traces = client.tracesExist(trace_ids)\n end\n return traces\nend",
"def new\n @trace = Trace.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trace }\n end\n end",
"def stats\n request :get, \"_stats\"\n end",
"def stats\n request :get, \"_stats\"\n end",
"def show\n @visit_stat = VisitStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @visit_stat }\n end\n end",
"def track\n url = Rails.env.development? ? \"http://localhost:8000/stat\" : \"http://stats.universit.as/stat\"\n RestClient.get(url, :params => {\n :ip => request.remote_ip,\n :title => request.referrer\n })\n render :js => ''\n end",
"def index\n @traffics = Traffic.find(:all, :order => \"created_at\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @traffics }\n end\n end",
"def show\n @service = Service.find(params[:id], :conditions => conditions)\n @alerts = Alert.all({\n :conditions => [\"service_id = ? and severity <> 0\", @service.id]\n })\n params[:date] = Date.today.to_s if params[:date].blank?\n @date_range = parse_date_range params[:date]\n @metric = @service.metric \n now = Time.now\n #now = Time.parse(\"2010-6-10 12:00\") #for test\n d = @metric.history({:start => now - 24*60*60, :finish => now})\n if d.size > 0\n @history_views = @service.history_views\n @history_views.each do |view|\n view.data = d\n end\n end\n d = @metric.current \n if d\n @default_view = @service.default_view\n @default_view.data = d if @default_view\n @current_views = @service.views\n @current_views.each do |view|\n view.data = d\n end\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { \n #render :xml => @service.to_xml(:dasherize => false)\n }\n end\n end",
"def trace!\n request! :trace\n end",
"def show\n \n begin\n @topic_activity_summaries = \n TopicActivitySummary.find_all_by_student_id_and_grade(params[:id], params[:grade])\n rescue Exception => e \n respond_to do |format|\n format.xml { render :xml => errorRsp( e.message) }\n end\n return\n end\n\t \n respond_to do |format|\n format.xml { render :xml => @topic_activity_summaries.to_xml(:dasherize => false) }\n end\n end",
"def raw_stats\n url = URI.parse(stats_url)\n Net::HTTP.start(url.host, url.port) {|http|\n http.request(Net::HTTP::Get.new(url.path))\n }.body\nend",
"def index\n @trace_exceptions = TraceException.all\n end",
"def show\n @traffic = Traffic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @traffic }\n end\n end",
"def show\r\n Connection.switch_data(params[:connection], \"daily\")\r\n @connections = Connection.find(params[:id])\r\n respond_to do |format|\r\n format.html #show.html.erb\r\n format.xml { render :xml => @connections.to_xml(:root => 'records', :children => 'record', :dasherize => false) }\r\n end\r\n end",
"def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end",
"def view(format = \"JSON\")\n raise OwaspZap::WrongFormatException,\"Output format not accepted\" unless [\"JSON\",\"HTML\",\"XML\"].include?(format)\n #http://localhost:8080/JSON/core/view/alerts/?zapapiformat=JSON&baseurl=http%3A%2F%2F192.168.1.113&start=&count=\n url = Addressable::URI.parse \"#{@base}/#{format}/core/view/alerts/\"\n url.query_values = {:zapapiformat=>format,:baseurl=>@target, :apikey=>@api_key}\n str = RestClient::get url.normalize.to_str\n format == \"JSON\" ? JSON.parse(str)[\"alerts\"] : str\n end",
"def show\n @tstat = Tstat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tstat }\n end\n end",
"def rss\n @event = Event.find_by_key(params['id'])\n @histories = @event.histories(:order => 'created_at DESC')\n render :layout => false\n response.headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end",
"def show\n @tracker = Tracker.find(params[:id])\n\n respond_to do |format|\n format.html # show.erb\n format.xml { render :xml => @tracker.to_xml }\n end\n end",
"def show\r\n @position_hist = PositionHist.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.rhtml\r\n format.xml { render :xml => @position_hist.to_xml }\r\n end\r\n end",
"def show\n render json: @trace\n end",
"def history\n rest.get stats_path(:history) do |response|\n response_handler response\n end\n end",
"def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end",
"def show\n @sleep_log = SleepLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sleep_log }\n end\n end",
"def activities_xml(time = nil, filter = nil)\n timestamp = time ? time.to_gnip_bucket_id : 'current'\n if filter\n _name, _endpoint = filter.name, \"#{self.uri}/#{filter.path}/activity/#{timestamp}.xml\"\n else\n _name, _endpoint = self.name, \"#{self.uri}/activity/#{timestamp}.xml\"\n end\n log_action(_name, time, timestamp)\n response, activities_xml = fetch(_endpoint)\n end",
"def stats\n Client.current.get(\"#{resource_url}/stats\")\n end",
"def monitoring_xml()\n return Error.new('ID not defined') if !@pe_id\n\n return @client.call(HOST_METHODS[:monitoring], @pe_id)\n end",
"def show\n @travel_log = TravelLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @travel_log }\n end\n end",
"def show\n @probe = Probe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @probe }\n end\n end",
"def trigger_download_traces(type, opts = {})\n data, _status_code, _headers = trigger_download_traces_with_http_info(type, opts)\n data\n end",
"def show\n @stat = Stat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stat }\n end\n end",
"def show\n @stat = Stat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stat }\n end\n end",
"def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end",
"def index\n @estatus = Estatu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @estatus }\n end\n end",
"def index\n @xml_samples = XmlSample.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @xml_samples }\n format.xml { render xml: @xml_samples }\n end\n end",
"def incident_list(statuspage_id)\n request :method => :get,\n :url => @url + 'incident/list/' + statuspage_id\n end",
"def event_info(event_id, event_type = 'sr:match')\n get(\"sports/en/sport_events/#{event_type}:#{event_id}/timeline.xml\")\n end",
"def telemetry(url)\n get_request(URI(url), true, false)\n end",
"def show\n @log = @client.logs.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @log }\n end\n end",
"def index\n @stats = Stat.where(:match_id => params[:match_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @stats }\n end\n end",
"def show\n @call_log = CallLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @call_log }\n end\n end",
"def destroy\n @trace = Trace.find(params[:id])\n @trace.destroy\n\n respond_to do |format|\n format.html { redirect_to(traces_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @trace = Trace.find(params[:id])\n @trace.destroy\n\n respond_to do |format|\n format.html { redirect_to(traces_url) }\n format.xml { head :ok }\n end\n end",
"def index\n @call_logs = CallLog.accessible_by( current_ability, :index ).order('created_at DESC').page( params[:page] ).per(20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @call_logs }\n end\n end",
"def get(idx=0) \n extra = \"\"\n @extra_args.each do | key, val | \n extra << \"&#{key}=#{val}\"\n end \n self.parse_response(@client.get(\"#{@uri.path}?#{@context_objects[idx].kev}#{extra}\")) \n end",
"def info\n get '/'\n end",
"def show\n @tracker = Tracker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tracker }\n end\n end",
"def create\n @trace = Trace.new(params[:trace])\n\n respond_to do |format|\n if @trace.save\n flash[:notice] = 'Trace was successfully created.'\n format.html { redirect_to :controller => 'members', :action => 'index_simple' }\n format.xml { render :xml => @trace, :status => :created, :location => @trace }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trace.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @rate_change_history = RateChangeHistory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @rate_change_history }\n end\n end",
"def call\n return nil unless scope_layer\n return nil unless context.config.value('timeline_traces')\n\n # Since this request is being stored, update the needed counters\n context.slow_request_policy.stored!(request)\n\n # record the change in memory usage\n mem_delta = ScoutApm::Instruments::Process::ProcessMemory.new(context).rss_to_mb(@request.capture_mem_delta!)\n\n transaction_id = request.transaction_id\n revision = context.environment.git_revision.sha\n start_instant = request.root_layer.start_time\n stop_instant = request.root_layer.stop_time\n type = if request.web?\n \"Web\"\n elsif request.job?\n \"Job\"\n else\n \"Unknown\"\n end\n\n # Create request tags\n #\n tags = {\n :allocations => request.root_layer.total_allocations,\n :mem_delta => mem_delta,\n }.merge(request.context.to_flat_hash)\n\n host = context.environment.hostname\n path = request.annotations[:uri] || \"\"\n code = \"\" # User#index for instance\n\n spans = create_spans(request.root_layer)\n if limited?\n tags[:\"scout.reached_span_cap\"] = true\n end\n\n DetailedTrace.new(\n transaction_id,\n revision,\n host,\n start_instant,\n stop_instant,\n type,\n\n path,\n code,\n\n spans,\n tags\n\n # total_score = 0,\n # percentile_score = 0,\n # age_score = 0,\n # memory_delta_score = 0,\n # memory_allocations_score = 0\n )\n end",
"def make_request_get_response_trend_availible\n @path_trend_availible = '/1.1/trends/available.json'\n @address_trend_availible = URI(\"#{@baseurl}#{@path_trend_availible}\")\n # Set up HTTP. Need ssL to make the connection\n @request_trend_availible = Net::HTTP::Get.new @address_trend_availible.request_uri\n @http = Net::HTTP.new @address_trend_availible.host, @address_trend_availible.port\n @http.use_ssl = true\n @http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n # Issue the request.\n @request_trend_availible.oauth! @http, @consumer_key_country, @access_token_country\n @http.start\n @response_trend_availible = @http.request @request_trend_availible\n @response_trend_availible\n end",
"def show\n @xml_sample = XmlSample.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @xml_sample }\n end\n end",
"def show\n @fires = Kaminari.paginate_array(@severity_level.fires).page(params[:page]).per(20)\n end",
"def show\n @measurement_log = current_account.measurement_logs.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @measurement_log }\n end\n end",
"def request_timestamp(cli,request)\n\t\tprint_status(\"#{cli.peerhost} - #{current_time} - [HTTP GET] - #{request.uri}\")\n\tend",
"def show\n @audit_log = AuditLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @audit_log }\n end\n end",
"def route_xml(route_id, query_params = nil)\n get(\"/routes/#{route_id}/xml\", query_params)\n end",
"def index\n @segment_details = SegmentDetail.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @segment_details }\n end\n end",
"def show\n @threat = Threat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @threat }\n end\n end",
"def trends_available\n get(\"/trends/available.json\")\n end",
"def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\n end",
"def render_health_xml\n render :xml => @results.values, :status => health_response_code\n end",
"def show\n @tso = Tso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tso.to_xml(:except => [ :created_at, :updated_at ]) }\n end\n end",
"def show\n @history_point = HistoryPoint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @history_point }\n end\n end",
"def index\n @pclevels = Pclevel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pclevels }\n end\n end",
"def index\n @tracings = Tracing.all\n end",
"def traces\n trace_store.keys\n end",
"def logs\n ret = @uri.logs\n render plain: ret[:message], status: ret[:status]\n end",
"def show\n @chart = Chart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @chart }\n end\n end",
"def show\n @chart = Chart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @chart }\n end\n end",
"def show\n @project = Project.find(params[:id])\n @sites = @project.spans\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @project }\n end\n end",
"def show\n @employee_position_hist = EmployeePositionHist.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @employee_position_hist.to_xml }\n end\n end",
"def show\n @daily_grr = DailyGrr.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @daily_grr }\n end\n end",
"def show\n @detailed_retrofit = DetailedRetrofit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @detailed_retrofit }\n end\n end",
"def trace(uri, options = T.unsafe(nil)); end",
"def show\n @log = Dmt::SiteLogger::Log.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @log }\n end\n end",
"def get_blockchain_stats\n stats = HTTParty.get(\"http://webbtc.com/stats.json\")\nend",
"def index\n @perf_benchmarks = @app.perf_benchmarks.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @perf_benchmarks }\n end\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 show\n @dailyreport = Dailyreport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @dailyreport }\n end\n end",
"def get_telephony_siptraces_with_http_info(date_start, date_end, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: TelephonyApi.get_telephony_siptraces ...\"\n end\n \n \n # verify the required parameter 'date_start' is set\n fail ArgumentError, \"Missing the required parameter 'date_start' when calling TelephonyApi.get_telephony_siptraces\" if date_start.nil?\n \n \n \n \n \n \n # verify the required parameter 'date_end' is set\n fail ArgumentError, \"Missing the required parameter 'date_end' when calling TelephonyApi.get_telephony_siptraces\" if date_end.nil?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/telephony/siptraces\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'dateStart'] = date_start\n query_params[:'dateEnd'] = date_end\n query_params[:'callId'] = opts[:'call_id'] if opts[:'call_id']\n query_params[:'toUser'] = opts[:'to_user'] if opts[:'to_user']\n query_params[:'fromUser'] = opts[:'from_user'] if opts[:'from_user']\n query_params[:'conversationId'] = opts[:'conversation_id'] if opts[:'conversation_id']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\n data, status_code, headers = @api_client.call_api(:GET, 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 => 'SipSearchResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TelephonyApi#get_telephony_siptraces\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @provider_stats = ProviderStat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @provider_stats }\n end\n end",
"def getinfo\n request :getinfo\n end",
"def create\n @trace = Trace.new(params[:trace])\n\n respond_to do |format|\n if @trace.save\n format.html { redirect_to(@trace, :notice => 'Trace was successfully created.') }\n format.xml { render :xml => @trace, :status => :created, :location => @trace }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trace.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def __trace(method, path, params, body, url, response, json, took, duration)\n trace_url = \"http://localhost:9200/#{path}?pretty\" +\n ( params.empty? ? '' : \"&#{::Faraday::Utils::ParamsHash[params].to_query}\" )\n trace_body = body ? \" -d '#{__convert_to_json(body, :pretty => true)}'\" : ''\n tracer.info \"curl -X #{method.to_s.upcase} '#{trace_url}'#{trace_body}\\n\"\n tracer.debug \"# #{Time.now.iso8601} [#{response.status}] (#{format('%.3f', duration)}s)\\n#\"\n tracer.debug json ? serializer.dump(json, :pretty => true).gsub(/^/, '# ').sub(/\\}$/, \"\\n# }\")+\"\\n\" : \"# #{response.body}\\n\"\n end",
"def show\n @pclevel = Pclevel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pclevel }\n end\n end",
"def index\n \t@clickers = Clicker.all\t\t\t\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @clickers }\n end\n end",
"def show\r\n SignalStrength.switch_data(params[:connection], \"daily\")\r\n #@signal_strengths = SignalStrength.find(params[:id])\r\n #@signal_strengths = SignalStrength.find(:all, :origin=>'94531', :within=>10)\r\n respond_to do |format|\r\n format.html #show.html.erb\r\n format.xml { render :xml => @signal_strengths.to_xml(:dasherize => false) }\r\n end\r\n end",
"def show\n @lab_rack = LabRack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lab_rack }\n end\n end",
"def show\n @service_log = ServiceLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @service_log }\n end\n end",
"def info\n _get(\"/query/dataleaks/info\") { |json| json }\n end",
"def show_rss_log\n pass_query_params\n store_location\n @rss_log = find_or_goto_index(RssLog, params[\"id\"])\n end"
] | [
"0.6214823",
"0.6100431",
"0.6033639",
"0.56212276",
"0.55663943",
"0.55239695",
"0.5498872",
"0.54892373",
"0.54737365",
"0.5434124",
"0.5434124",
"0.5401129",
"0.53968227",
"0.53658843",
"0.5344298",
"0.5342842",
"0.53344697",
"0.53060704",
"0.5285319",
"0.52768576",
"0.52632296",
"0.5254057",
"0.5243564",
"0.52387756",
"0.52366775",
"0.5236016",
"0.5234903",
"0.52320707",
"0.5225223",
"0.52124417",
"0.52002674",
"0.5188249",
"0.516913",
"0.51669365",
"0.5160522",
"0.514947",
"0.5144504",
"0.5139311",
"0.5139311",
"0.51377875",
"0.51263463",
"0.51249856",
"0.5124766",
"0.5124229",
"0.5123594",
"0.51207113",
"0.5119011",
"0.51168007",
"0.51153666",
"0.51119816",
"0.5100474",
"0.50835735",
"0.50815725",
"0.5076215",
"0.5065567",
"0.5058765",
"0.5056782",
"0.5056651",
"0.50565827",
"0.50508195",
"0.50487775",
"0.50415856",
"0.5039235",
"0.50368804",
"0.50340307",
"0.5026447",
"0.5023781",
"0.50235426",
"0.50201863",
"0.50197047",
"0.5013823",
"0.5013736",
"0.49982375",
"0.49940854",
"0.49907953",
"0.49847552",
"0.49847552",
"0.49828",
"0.49800888",
"0.49788994",
"0.49763313",
"0.49760646",
"0.49618962",
"0.49613515",
"0.4959722",
"0.4957924",
"0.49523038",
"0.49509177",
"0.49505687",
"0.49447381",
"0.49405733",
"0.4934997",
"0.4933867",
"0.4933118",
"0.4932768",
"0.493271",
"0.49302188",
"0.4928019",
"0.4927001"
] | 0.6564382 | 0 |
GET /traces/new GET /traces/new.xml | def new
@trace = Trace.new(params[:trace])
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @trace }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @trace = Trace.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trace }\n end\n end",
"def create\n @trace = Trace.new(params[:trace])\n\n respond_to do |format|\n if @trace.save\n format.html { redirect_to(@trace, :notice => 'Trace was successfully created.') }\n format.xml { render :xml => @trace, :status => :created, :location => @trace }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trace.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @trace = Trace.new(params[:trace])\n\n respond_to do |format|\n if @trace.save\n flash[:notice] = 'Trace was successfully created.'\n format.html { redirect_to :controller => 'members', :action => 'index_simple' }\n format.xml { render :xml => @trace, :status => :created, :location => @trace }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trace.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @visit_stat = VisitStat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @visit_stat }\n end\n end",
"def new\n @tstat = Tstat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tstat }\n end\n end",
"def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stat }\n end\n end",
"def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stat }\n end\n end",
"def new\n add_breadcrumb :new\n @visit = Visit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @visit }\n end\n end",
"def new_rest\n @page_usage_event = PageUsageEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page_usage_event }\n end\n end",
"def new_rest\n @entry_instrument = EntryInstrument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_instrument }\n end\n end",
"def new_rest\n @instrument_version = InstrumentVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instrument_version }\n end\n end",
"def new\n @tracker = Tracker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tracker }\n end\n end",
"def new\n @probe = Probe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @probe }\n end\n end",
"def new\n @trail = Trail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trail }\n end\n end",
"def new\n @trail = Trail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trail }\n end\n end",
"def test_post_then_get\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n id = last_response.body\n\n get \"/traces/#{id}\"\n check_valid_trace last_response.body\n end",
"def new\n @history_point = HistoryPoint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @history_point }\n end\n end",
"def show\n @trace = Trace.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @trace }\n end\n end",
"def show\n @trace = Trace.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @trace }\n end\n end",
"def new\n @pushed = Pushed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pushed }\n end\n end",
"def new\n @lookup_pettracer = LookupPettracer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_pettracer }\n end\n end",
"def new\n @lookup_pettracer = LookupPettracer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_pettracer }\n end\n end",
"def new\n @traffic = Traffic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @traffic }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def create_new_traces\n @traces.each do |trace|\n trace_stack = trace.stack_to_render[0]\n unless(trace_stack.func_name.include? '<init>')\n trace_stack_ordered_variable_names = trace_stack.ordered_varnames\n trace_stack_encoded_locals = trace_stack.encoded_locals\n trace_heap = trace.heap\n trace_code = @code[trace.line]\n filtered_trace = filter_trace([\n trace_stack_ordered_variable_names,\n trace_stack_encoded_locals,\n trace_heap,\n trace_code,\n trace.line\n ])\n @new_traces << filtered_trace\n trace_string = Yajl::Encoder.encode(filtered_trace)\n @traces_json_array << trace_string\n @traces_json_string += trace_string + ','\n end\n end\n end",
"def new\n @timeline = Timeline.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @timeline }\n end\n end",
"def new\n @sleep_log = SleepLog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sleep_log }\n end\n end",
"def new\n @threat = Threat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @threat }\n end\n end",
"def new\n @old_point_tag = OldPointTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @old_point_tag }\n end\n end",
"def new\n @checkpoint_removed = CheckpointRemoved.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @checkpoint_removed }\n end\n end",
"def new\n @travel_log = TravelLog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @travel_log }\n end\n end",
"def new\n @pageview = Pageview.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pageview }\n end\n end",
"def new\n expire_page :action => :index\n expire_page :action => :show\n \n @ganglia_graph = GangliaGraph.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ganglia_graph }\n end\n end",
"def new\n @xml_sample = XmlSample.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @xml_sample }\n end\n end",
"def new\n @status = Status.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @status }\n end\n end",
"def new\n @status = Status.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @status }\n end\n end",
"def new\n @status = Status.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @status }\n end\n end",
"def new\n @rate_change_history = RateChangeHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rate_change_history }\n end\n end",
"def new\n logger.debug 'new_some interesting information'\n @comdty = Comdty.new\n setvariables\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comdty }\n end\n end",
"def index\n @traces = Trace.all\n\n render json: @traces\n end",
"def new\n @audit_log = AuditLog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @audit_log }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @get_started_page }\n end\n end",
"def new\n @pclevel = Pclevel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pclevel }\n end\n end",
"def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @newspage = Newspage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newspage }\n end\n end",
"def new\n @track = Track.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @track }\n end\n end",
"def new\n @track = Track.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @track }\n end\n end",
"def new\n @latestinfo = Latestinfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @latestinfo }\n end\n end",
"def new\n @p_stat = PStat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @p_stat }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report }\n end\n end",
"def new\n @explain = Explain.new\n @page = 'new-explain'\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @explain }\n end\n end",
"def new\n @hpt_history = HptHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hpt_history }\n end\n end",
"def new\n @event = Event.find(params[:event_id])\n @point_of_interest = PointOfInterest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @point_of_interest }\n end\n end",
"def new\n @contexts = SHDM::Context.find_all.map{ |v| [ v.context_name.first, v.uri ] }.delete_if{|v| v.first == \"Any\"}\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @index }\n end\n end",
"def new\n @occurence = Occurence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @occurence }\n end\n end",
"def new\n @lookup_source = LookupSource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_source }\n end\n end",
"def new\n @trigger = Trigger.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trigger }\n end\n end",
"def new\n @retain_node = RetainNode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @retain_node }\n format.json { render :json => @retain_node }\n end\n end",
"def new\n @aircraft_history = AircraftHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @aircraft_history }\n end\n end",
"def new\n @projecttrack = Projecttrack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @projecttrack }\n end\n end",
"def new\n @changelog = Changelog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @changelog }\n end\n end",
"def new\n @daily_grr = DailyGrr.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @daily_grr }\n end\n end",
"def new\n @crawler_receive = CrawlerReceive.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @crawler_receive }\n end\n end",
"def new\n @dailyreport = Dailyreport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dailyreport }\n end\n end",
"def new\n @call_log = CallLog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @call_log }\n end\n end",
"def new\n @tso = Tso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tso }\n end\n end",
"def new\n @auditflows_flownode = AuditflowsFlownode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @auditflows_flownode }\n end\n end",
"def new\n @lookup_set = LookupSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_set }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @notifier }\n end\n end",
"def new\n @whitelist = Whitelist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @whitelist }\n end\n end",
"def new\n @tps_report = TpsReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tps_report }\n end\n end",
"def new\n @crawl_result = Crawl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @crawl_result }\n end\n end",
"def new\n @provider_stat = ProviderStat.new\n @provider = Provider.find(params[:id])\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @provider_stat }\n end\n end",
"def new\n @travel_fix = TravelFix.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @travel_fix }\n end\n end",
"def new\n @tracked_action = TrackedAction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tracked_action }\n end\n end",
"def new\n @series = Series.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @series }\n end\n end",
"def new\n @report_line = ReportLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report_line }\n end\n end",
"def new\n @web_info = WebInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @web_info }\n end\n end",
"def new\n @chart = Chart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @chart }\n end\n end",
"def new\n @chart = Chart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @chart }\n end\n end",
"def new\n @page = Page.new(:status => params[:from])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @statusproject = Statusproject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @statusproject }\n end\n end",
"def new\n @twitter_crawler_hash_tag = TwitterCrawlerHashTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @twitter_crawler_hash_tag }\n end\n end",
"def new\n @click_to_talk = ClickToTalk.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @click_to_talk }\n end\n end",
"def new\n @usage_status = UsageStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usage_status }\n end\n end",
"def new\n @lab_rack = LabRack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lab_rack }\n end\n end",
"def new\n @quote_audit = QuoteAudit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @quote_audit }\n end\n end",
"def new\n @segment = Segment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @segment }\n end\n end",
"def new\n @url_migration = UrlMigration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @url_migration }\n end\n end",
"def new\n @travel = Travel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @travel }\n end\n end",
"def new\n @travel = Travel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @travel }\n end\n end",
"def new\n @thred = Thred.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thred }\n end\n end",
"def new\n @config_xml = ConfigXml.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @config_xml }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def new\n @stoppage = Stoppage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stoppage }\n end\n end",
"def new\n @update_log = UpdateLog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @update_log }\n end\n end",
"def new\n @checkpoint = Checkpoint.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @checkpoint }\n end\n end",
"def new\n @path = Path.new({:layer => @layer})\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @path }\n end\n end",
"def new\n @sprint = Sprint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end",
"def new\n @sprint = Sprint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end",
"def new\n @graph_point = GraphPoint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @graph_point }\n end\n end"
] | [
"0.733107",
"0.6416524",
"0.6407681",
"0.62683946",
"0.6206989",
"0.6154043",
"0.6154043",
"0.61399186",
"0.6129796",
"0.6114777",
"0.6091656",
"0.60756296",
"0.60152227",
"0.60088545",
"0.60088545",
"0.6006569",
"0.5967345",
"0.5965664",
"0.59655195",
"0.59530616",
"0.59529865",
"0.59520704",
"0.59386474",
"0.5937279",
"0.5933277",
"0.59177315",
"0.59128106",
"0.5912201",
"0.590548",
"0.58906674",
"0.58886737",
"0.58865917",
"0.5864827",
"0.5849059",
"0.5837116",
"0.5837116",
"0.5837116",
"0.5834447",
"0.58202165",
"0.58102834",
"0.5810055",
"0.5809117",
"0.57977384",
"0.57912153",
"0.5788895",
"0.5787591",
"0.5787591",
"0.57813925",
"0.5777124",
"0.57759017",
"0.57594615",
"0.57535493",
"0.5745322",
"0.57450306",
"0.57433665",
"0.5734298",
"0.5730224",
"0.5727605",
"0.5726484",
"0.5721897",
"0.57208514",
"0.5720219",
"0.5716812",
"0.5712118",
"0.57116055",
"0.57086074",
"0.5708549",
"0.57055086",
"0.5703737",
"0.57036936",
"0.5693583",
"0.5681968",
"0.5681594",
"0.56799173",
"0.5677033",
"0.56738603",
"0.56705976",
"0.56700635",
"0.56669253",
"0.56669253",
"0.56668526",
"0.5662145",
"0.56604487",
"0.56601363",
"0.5658588",
"0.5655478",
"0.56517035",
"0.56513757",
"0.5650574",
"0.565024",
"0.565024",
"0.5648862",
"0.5646466",
"0.564132",
"0.5639678",
"0.5639366",
"0.56304556",
"0.5625578",
"0.5625578",
"0.5622351"
] | 0.727908 | 1 |
POST /traces POST /traces.xml | def create
@trace = Trace.new(params[:trace])
respond_to do |format|
if @trace.save
format.html { redirect_to(@trace, :notice => 'Trace was successfully created.') }
format.xml { render :xml => @trace, :status => :created, :location => @trace }
else
format.html { render :action => "new" }
format.xml { render :xml => @trace.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_post_then_get\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n id = last_response.body\n\n get \"/traces/#{id}\"\n check_valid_trace last_response.body\n end",
"def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end",
"def create\n @trace = Trace.new(params[:trace])\n\n respond_to do |format|\n if @trace.save\n flash[:notice] = 'Trace was successfully created.'\n format.html { redirect_to :controller => 'members', :action => 'index_simple' }\n format.xml { render :xml => @trace, :status => :created, :location => @trace }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trace.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n data = []\n trace_params.each do |p|\n hash = {\n latitude: p[\"latitude\"],\n longitude: p[\"longitude\"]\n }\n data << hash\n end\n\n if Trace.upload_data(data)\n render json: {status: 'OK'}\n else\n render json: @trace.errors, status: :unprocessable_entity\n end\n end",
"def create\n @trace = Trace.new\n if @trace.save\n @trace.import_points(points_data)\n status = :created\n else\n status = :bad_request\n end\n\n render json: @trace, status: status\n end",
"def index\n @traces = Trace.all\n\n render json: @traces\n end",
"def report_spans(spans)\n return unless @state == :announced\n\n path = \"com.instana.plugin.ruby/traces.#{@process[:report_pid]}\"\n uri = URI.parse(\"http://#{@host}:#{@port}/#{path}\")\n req = Net::HTTP::Post.new(uri)\n\n req.body = spans.to_json\n response = make_host_agent_request(req)\n\n if response\n last_trace_response = response.code.to_i\n\n #::Instana.logger.debug \"traces response #{last_trace_response}: #{spans.to_json}\"\n\n if [200, 204].include?(last_trace_response)\n return true\n end\n end\n false\n rescue => e\n Instana.logger.debug \"#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}\"\n Instana.logger.debug e.backtrace.join(\"\\r\\n\")\n end",
"def index\n @traces = Trace.all\n url_string = ''\n data = []\n pdist = 0\n plat = @traces.first.latitude\n plon = @traces.first.longitude\n traces = @traces.pluck(:latitude, :longitude).map { |lat, lon| { latitude: lat, longitude: lon } }\n response = HTTParty.post(\n url_string,\n :body => traces.to_json,\n :headers => { 'Content-Type' => 'application/json' }\n )\n @traces.each_with_index do |t,index|\n data << {\n \"latitude\": t.latitude,\n \"longitude\": t.longitude,\n \"distance\": distance([plat,plon],[t.latitude, t.longitude]) + pdist,\n \"elevation\": response[index]\n }\n pdist += distance([plat,plon],[t.latitude, t.longitude])\n plat = t.latitude\n plon = t.longitude\n end\n render json: data\n end",
"def new\n @trace = Trace.new(params[:trace])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trace }\n end\n end",
"def create\n @trace_exception = TraceException.new(trace_exception_params)\n\n respond_to do |format|\n if @trace_exception.save\n format.html { redirect_to @trace_exception, notice: 'Trace exception was successfully created.' }\n format.json { render :show, status: :created, location: @trace_exception }\n else\n format.html { render :new }\n format.json { render json: @trace_exception.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tracing = Tracing.new(tracing_params)\n\n respond_to do |format|\n if @tracing.save\n format.html { redirect_to @tracing}\n format.json { render action: 'show', status: :created, location: @tracing }\n else\n format.html { render action: 'new' }\n format.json { render json: @tracing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @trace = Trace.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trace }\n end\n end",
"def trace!\n request! :trace\n end",
"def post\n response = HTTParty.post(servlet_url,\n :body => to_xml,\n :headers => { 'Content-Type' => 'application/xml' }\n ).response\n\n return Dhl::Shipment::Response.new(response.body)\n rescue Exception => e\n request_xml = if @to_xml.to_s.size>0\n @to_xml\n else\n '<not generated at time of error>'\n end\n\n response_body = if (response && response.body && response.body.to_s.size > 0)\n response.body\n else\n '<not received at time of error>'\n end\n\n log_level = if e.respond_to?(:log_level)\n e.log_level\n else\n :critical\n end\n\n log_request_and_response_xml(log_level, e, request_xml, response_body )\n raise e\n end",
"def create_new_traces\n @traces.each do |trace|\n trace_stack = trace.stack_to_render[0]\n unless(trace_stack.func_name.include? '<init>')\n trace_stack_ordered_variable_names = trace_stack.ordered_varnames\n trace_stack_encoded_locals = trace_stack.encoded_locals\n trace_heap = trace.heap\n trace_code = @code[trace.line]\n filtered_trace = filter_trace([\n trace_stack_ordered_variable_names,\n trace_stack_encoded_locals,\n trace_heap,\n trace_code,\n trace.line\n ])\n @new_traces << filtered_trace\n trace_string = Yajl::Encoder.encode(filtered_trace)\n @traces_json_array << trace_string\n @traces_json_string += trace_string + ','\n end\n end\n end",
"def send_spans(traces, transport)\n return true if traces.empty?\n\n # Inject hostname if configured to do so\n inject_hostname!(traces) if Datadog.configuration.report_hostname\n\n # Send traces an get a response.\n response = transport.send_traces(traces)\n\n unless response.internal_error?\n @traces_flushed += traces.length unless response.server_error?\n\n # Update priority sampler\n unless priority_sampler.nil? || response.service_rates.nil?\n priority_sampler.update(response.service_rates)\n end\n end\n\n # Return if server error occurred.\n !response.server_error?\n end",
"def send_trace(event)\n assert_permissions(event, ['ntracer'])\n raise OutteError.new \"Sorry, tracing is disabled.\" if !FEATURE_NTRACE\n wait_msg = event.send_message(\"Queued...\") if $mutex[:ntrace].locked?\n $mutex[:ntrace].synchronize do\n wait_msg.delete if !wait_msg.nil?\n level = parse_highscoreable(event.content, mappack: true)\n raise OutteError.new \"Episodes and columns can't be traced\" if !level.is_a?(Levelish)\n map = !level.is_a?(Map) ? MappackLevel.find_by(id: level.id) : level\n raise OutteError.new \"Level data not found\" if map.nil?\n map.trace(event)\n end\nrescue => e\n lex(e, \"Error performing trace.\", event: event)\nend",
"def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def destroy\n @trace = Trace.find(params[:id])\n @trace.destroy\n\n respond_to do |format|\n format.html { redirect_to(traces_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @trace = Trace.find(params[:id])\n @trace.destroy\n\n respond_to do |format|\n format.html { redirect_to(traces_url) }\n format.xml { head :ok }\n end\n end",
"def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end",
"def test_post_invalid\n header 'Content-Type', 'application/json'\n\n json = JSON.generate [{ latitude: 'wrong', longitude: 'wrong' }]\n post('/traces', json, 'CONTENT_TYPE': 'application/json')\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def encode_traces(traces)\n to_send = []\n traces.each do |trace|\n to_send << trace.map(&:to_hash)\n end\n encode(to_send)\n end",
"def post_report dep_name, user, vars, log\n require 'net/http'\n require 'uri'\n\n returning(Net::HTTP.post_form(\n URI.parse('http://gist.github.com/api/v1/xml/new'),\n {\n \"files[from]\" => user,\n \"files[vars.yml]\" => vars,\n \"files[#{dep_name}.log]\" => log.decolorize\n }\n )) do |response|\n report_report_result dep_name, response\n end.is_a? Net::HTTPSuccess\n end",
"def call\n return nil unless scope_layer\n return nil unless context.config.value('timeline_traces')\n\n # Since this request is being stored, update the needed counters\n context.slow_request_policy.stored!(request)\n\n # record the change in memory usage\n mem_delta = ScoutApm::Instruments::Process::ProcessMemory.new(context).rss_to_mb(@request.capture_mem_delta!)\n\n transaction_id = request.transaction_id\n revision = context.environment.git_revision.sha\n start_instant = request.root_layer.start_time\n stop_instant = request.root_layer.stop_time\n type = if request.web?\n \"Web\"\n elsif request.job?\n \"Job\"\n else\n \"Unknown\"\n end\n\n # Create request tags\n #\n tags = {\n :allocations => request.root_layer.total_allocations,\n :mem_delta => mem_delta,\n }.merge(request.context.to_flat_hash)\n\n host = context.environment.hostname\n path = request.annotations[:uri] || \"\"\n code = \"\" # User#index for instance\n\n spans = create_spans(request.root_layer)\n if limited?\n tags[:\"scout.reached_span_cap\"] = true\n end\n\n DetailedTrace.new(\n transaction_id,\n revision,\n host,\n start_instant,\n stop_instant,\n type,\n\n path,\n code,\n\n spans,\n tags\n\n # total_score = 0,\n # percentile_score = 0,\n # age_score = 0,\n # memory_delta_score = 0,\n # memory_allocations_score = 0\n )\n end",
"def create\n\t\turi = URI.parse(Counter::Application.config.simplyurl)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\n\t\trequest = Net::HTTP::Post.new('/offsets.json')\n\t\tputs params\n\t\tputs params.slice(*['custids','acctids','itemids'])\n\t\t\n\t\t# ok, this join stuff is bogus - it encodes properly, but the other side only sees the last element and loses the array type - it's just string\n\t\t# this way, i 'split' it at the other side to recover my array\n\t\t# it should work without the join/split crap, but it doesn't\n\t\trequest.set_form_data({:custids => ( params['custids'] || []).join(','), :acctids => ( params['acctids'] || []).join(','), :itemids => ( params['itemids'] || []).join(','), :amount => params['amount'], :type => params['type']})\n\t\t\n\t\tputs request.body\n\t\t\n\t\tresponse = http.request(request)\n\t\tputs response.body\n\n respond_to do |format|\n format.html { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n format.json { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n end\n end",
"def create\n @tracer = Tracer.new(tracer_params)\n\n respond_to do |format|\n if @tracer.save\n format.html { redirect_to @tracer, notice: \"Tracer was successfully created.\" }\n format.json { render :show, status: :created, location: @tracer }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @tracer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @trace.update(trace_params)\n render :show, status: :ok, location: @trace\n else\n render json: @trace.errors, status: :unprocessable_entity\n end\n end",
"def remove_useless_traces_data(params)\n convert_list_of_json_traces_to_objects(params[0])\n create_new_traces\n @traces_json_string = '[' + @traces_json_string[0...-1] + ']'\n puts @traces_json_string\n end",
"def show\n @trace = Trace.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @trace }\n end\n end",
"def show\n @trace = Trace.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @trace }\n end\n end",
"def report_metrics\n metadata = {\n 'sourcetype' => 'json',\n 'source' => 'chef-handler',\n 'host' => node.hostname,\n 'index' => @index,\n 'check-index' => false\n }\n\n # We're creating a new Hash b/c 'node' and 'all_resources' in run_status\n # are just TOO large.\n event = {\n :failed => run_status.failed?,\n :start_time => run_status.start_time,\n :end_time => run_status.end_time,\n :elapsed_time => run_status.elapsed_time,\n :exception => run_status.formatted_exception\n }.to_json\n\n splunk_post(event, metadata)\n end",
"def show\n @traces = Trace.find_by(id: params[:id])\n url_string = ''\n response = HTTParty.get(url_string)\n data = {\n \"latitude\": @traces.latitude,\n \"longitude\": @traces.longitude,\n \"elevation\": response.body.to_i\n }\n render json: data\n end",
"def create_rest\n @entry_instrument = EntryInstrument.new(params[:entry_instrument])\n\n respond_to do |format|\n if @entry_instrument.save\n flash[:notice] = 'EntryInstrument was successfully created.'\n format.html { redirect_to(@entry_instrument) }\n format.xml { render :xml => @entry_instrument, :status => :created, :location => @entry_instrument }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @entry_instrument.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def __trace(method, path, params, body, url, response, json, took, duration)\n trace_url = \"http://localhost:9200/#{path}?pretty\" +\n ( params.empty? ? '' : \"&#{::Faraday::Utils::ParamsHash[params].to_query}\" )\n trace_body = body ? \" -d '#{__convert_to_json(body, :pretty => true)}'\" : ''\n tracer.info \"curl -X #{method.to_s.upcase} '#{trace_url}'#{trace_body}\\n\"\n tracer.debug \"# #{Time.now.iso8601} [#{response.status}] (#{format('%.3f', duration)}s)\\n#\"\n tracer.debug json ? serializer.dump(json, :pretty => true).gsub(/^/, '# ').sub(/\\}$/, \"\\n# }\")+\"\\n\" : \"# #{response.body}\\n\"\n end",
"def create\n @stash_element = StashElement.new(stash_element_params)\n puts @stash_element.inspect\n\n respond_to do |format|\n if @stash_element.save\n format.html { redirect_to controller: 'post', action: 'new_post', notice: 'Success'}\n format.json { render :show, status: :created, location: @stash_element }\n else\n format.html { redirect_to controller: 'post', action: 'new_post', notice: 'Failure'}\n format.json { render json: @stash_element.errors, status: :unprocessable_entity }\n end\n end\n end",
"def report_backtrace\n metadata = {\n 'sourcetype' => 'chef-handler-backtrace',\n 'source' => 'chef-handler',\n 'host' => node.hostname,\n 'index' => @index,\n 'check-index' => false\n }\n event = Array(run_status.backtrace).join(\"\\n\")\n\n splunk_post(event, metadata)\n end",
"def create\n @detailed_retrofit = DetailedRetrofit.new(params[:detailed_retrofit])\n\n respond_to do |format|\n if @detailed_retrofit.save\n format.html { redirect_to(@detailed_retrofit, :notice => 'Detailed retrofit was successfully created.') }\n format.xml { render :xml => @detailed_retrofit, :status => :created, :location => @detailed_retrofit }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @detailed_retrofit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def create\n @mouse_rack = MouseRack.new(mouse_rack_params)\n\n respond_to do |format|\n if @mouse_rack.save\n format.html { redirect_to @mouse_rack, notice: 'Mouse rack was successfully created.' }\n format.json { render :show, status: :created, location: @mouse_rack }\n else\n format.html { render :new }\n format.json { render json: @mouse_rack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def send_spans(traces, transport)\n return true if traces.empty?\n\n # Send traces and get responses\n responses = transport.send_traces(traces)\n\n # Tally up successful flushes\n responses.reject { |x| x.internal_error? || x.server_error? }.each do |response|\n @traces_flushed += response.trace_count\n end\n\n events.after_send.publish(self, responses)\n\n # Return if server error occurred.\n !responses.find(&:server_error?)\n end",
"def create\n @trend = Trend.new(params[:trend])\n\n respond_to do |format|\n if @trend.save\n format.html { redirect_to @trend, :notice => 'Trend was successfully created.' }\n format.json { render :json => @trend, :status => :created, :location => @trend }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @trend.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def trace_params\n params.require(:_json).map do |p|\n p.permit(:latitude, :longitude)\n end\n end",
"def test_report_compatibility_with_old_report_format\n FakeWeb.register_uri(:post, \"http://#{@host}/transactions.xml\",\n :status => ['200', 'OK'])\n\n transactions = [{ :app_id => 'app_id_1',\n :usage => { 'hits' => 1 },\n :timestamp => '2016-07-18 15:42:17 0200' },\n { :app_id => 'app_id_2',\n :usage => { 'hits' => 2 },\n :timestamp => '2016-07-19 15:42:17 0200' },\n { :app_id => 'app_id_3',\n :usage => { 'hits' => 3 },\n :timestamp => '2016-07-20 15:42:17 0200' }]\n\n @client.report(*transactions)\n\n request = FakeWeb.last_request\n\n payload = {\n 'transactions[0][app_id]' => 'app_id_1',\n 'transactions[0][timestamp]' => '2016-07-18 15:42:17 0200',\n 'transactions[0][usage][hits]' => '1',\n 'transactions[1][app_id]' => 'app_id_2',\n 'transactions[1][timestamp]' => '2016-07-19 15:42:17 0200',\n 'transactions[1][usage][hits]' => '2',\n 'transactions[2][app_id]' => 'app_id_3',\n 'transactions[2][timestamp]' => '2016-07-20 15:42:17 0200',\n 'transactions[2][usage][hits]' => '3',\n 'provider_key' => '1234abcd'\n }\n\n assert_equal URI.encode_www_form(payload), request.body\n end",
"def create\n @visit_stat = VisitStat.new(params[:visit_stat])\n\n respond_to do |format|\n if @visit_stat.save\n format.html { redirect_to([:scaffold, @visit_stat], :notice => 'Visit stat was successfully created.') }\n format.xml { render :xml => @visit_stat, :status => :created, :location => @visit_stat }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @visit_stat.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def get_telephony_siptraces_with_http_info(date_start, date_end, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: TelephonyApi.get_telephony_siptraces ...\"\n end\n \n \n # verify the required parameter 'date_start' is set\n fail ArgumentError, \"Missing the required parameter 'date_start' when calling TelephonyApi.get_telephony_siptraces\" if date_start.nil?\n \n \n \n \n \n \n # verify the required parameter 'date_end' is set\n fail ArgumentError, \"Missing the required parameter 'date_end' when calling TelephonyApi.get_telephony_siptraces\" if date_end.nil?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/telephony/siptraces\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'dateStart'] = date_start\n query_params[:'dateEnd'] = date_end\n query_params[:'callId'] = opts[:'call_id'] if opts[:'call_id']\n query_params[:'toUser'] = opts[:'to_user'] if opts[:'to_user']\n query_params[:'fromUser'] = opts[:'from_user'] if opts[:'from_user']\n query_params[:'conversationId'] = opts[:'conversation_id'] if opts[:'conversation_id']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\n data, status_code, headers = @api_client.call_api(:GET, 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 => 'SipSearchResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TelephonyApi#get_telephony_siptraces\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def set_trace\n @trace = Trace.find(params[:id])\n end",
"def create\n @audit_trail = AuditTrail.new(audit_trail_params)\n\n respond_to do |format|\n if @audit_trail.save\n format.html { redirect_to @audit_trail, notice: \"Audit trail was successfully created.\" }\n format.json { render :show, status: :created, location: @audit_trail }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @audit_trail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def create\n @page_trail = PageTrail.new(page_trail_params)\n\n respond_to do |format|\n if @page_trail.save\n format.html { redirect_to @page_trail, notice: 'Page trail was successfully created.' }\n format.json { render :show, status: :created, location: @page_trail }\n else\n format.html { render :new }\n format.json { render json: @page_trail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_rest\n @page_usage_event = PageUsageEvent.new(params[:page_usage_event])\n\n respond_to do |format|\n if @page_usage_event.save\n flash[:notice] = 'PageUsageEvent was successfully created.'\n format.html { redirect_to(@page_usage_event) }\n format.xml { render :xml => @page_usage_event, :status => :created, :location => @page_usage_event }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @page_usage_event.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def format!\n return unless trace\n return trace unless root_span\n\n # Because the trace API does not support\n # trace metadata, we must put our trace\n # metadata on the root span. This \"root span\"\n # is needed by the agent/API to ingest the trace.\n\n # Apply generic trace tags. Any more specific value will be overridden\n # by the subsequent calls below.\n set_trace_tags!\n\n set_resource!\n\n tag_agent_sample_rate!\n tag_hostname!\n tag_lang!\n tag_origin!\n tag_process_id!\n tag_rule_sample_rate!\n tag_runtime_id!\n tag_rate_limiter_rate!\n tag_sample_rate!\n tag_sampling_decision_maker!\n tag_high_order_trace_id!\n tag_sampling_priority!\n tag_profiling_enabled!\n\n trace\n end",
"def posttestrail(runId, caseId, statusId, versionId, elapsedseconds)\r\n\r\n uri = \"http://testrailgw.jupiter.bbc.co.uk/?action=add_result_for_case&run_id=#{runId}&case_id=#{caseId}&status_id=#{statusId}&version=#{versionId}&elapsed_seconds=#{elapsedseconds}&sharedSecret=thI5iSourSHAREDsecret\"\r\n #uri = \"http://testrailgw.jupiter.bbc.co.uk/?action=add_result_for_case&run_id=110324&case_id=665022&status_id=1&version=Test&elapsed_seconds=12&sharedSecret=thI5iSourSHAREDsecret\"\r\n\r\n uri = uri.gsub(\" \", \"%20\")\r\n xml_data = open(uri).read\r\n if(xml_data.include? '\"test_id\":')\r\n recorded = xml_data.split('\"test_id\":')[1]\r\n testID = recorded.split(',\"status_id\"')[0]\r\n puts \"TestID:\"+testID\r\n else\r\n puts xml_data\r\n fail \"Cannot Post result to Testrail, check Webservice\"\r\n end\r\n\r\n timeStamp = Time.now.strftime (\"posted at %H:%M %d/%m/%Y\")\r\n files = \"//zgbwcfs3005.jupiter.bbc.co.uk/QA/Jenkins/Jupiter/ICETEAresultupdatelog.txt\"\r\n f = File.open(files,'a')\r\n f.write \"#{testID} #{timeStamp}\"\r\n f.close\r\nend",
"def post_evaluate(excon, body)\n excon.request(\n method: :post,\n path: '/evaluate',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend",
"def start_trace( request )\n t0 = Time.now\n\n inject_request_headers( request ) if cross_app_enabled?\n segment = stats_engine.push_scope( :http_request, t0 )\n\n return t0, segment\n rescue => err\n NewRelic::Agent.logger.error \"Uncaught exception while tracing HTTP request\", err\n return t0, nil\n end",
"def to_xml\n xml = \"<status data=\\\"#{@data.to_s}\\\">\"\n xml += \"<local>#{@local}</local>\"\n xml += \"<situacao>#{@situacao}</situacao>\"\n xml += \"<detalhes>#{@detalhes}</detalhes>\"\n xml += \"</status>\"\n end",
"def post_xml_64(xml=:example_response)\n post \"/auth/saml/callback\", {'SAMLResponse' => load_xml_64(xml)}\nend",
"def create\n @trend = Trend.new(params[:trend])\n\n respond_to do |format|\n if @trend.save\n format.html { redirect_to @trend, notice: 'Trend was successfully created.' }\n format.json { render json: @trend, status: :created, location: @trend }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params[:traceroute].each do |tr|\n Traceroute.create(:server => tr[:server], :local_ip => tr[:local_ip], :stdout => tr[:stdout], :stderr => tr[:stderr], :exit_status => tr[:exit_status], :timestamp => tr[:timestamp])\n end\n\n\n\n #puts \"hello #{params}\"\n #@hello = params\n #@hello.map { |k,v| puts \"#{k} is #{v}\" }\n #traceroute_params.each do |v|\n # traceroute = Traceroute.create(v)\n #end\n\n respond_to do |format|\n format.all { render :nothing => true, :status => 200 }\n end\n #@traceroute = Traceroute.new(params)\n\n #respond_to do |format|\n # if @traceroute.save\n # format.html { redirect_to @traceroute, notice: 'Traceroute was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @traceroute }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @traceroute.errors, status: :unprocessable_entity }\n # end\n #end\n end",
"def show\n render json: @trace\n end",
"def trigger_download_traces(type, opts = {})\n data, _status_code, _headers = trigger_download_traces_with_http_info(type, opts)\n data\n end",
"def postSignal( entity_id, country, gen_id, signal_type, data_type, inactive_reason, inactive_description, feedback)\n params = Hash.new\n params['entity_id'] = entity_id\n params['country'] = country\n params['gen_id'] = gen_id\n params['signal_type'] = signal_type\n params['data_type'] = data_type\n params['inactive_reason'] = inactive_reason\n params['inactive_description'] = inactive_description\n params['feedback'] = feedback\n return doCurl(\"post\",\"/signal\",params)\n end",
"def create\n @threat = Threat.new(params[:threat])\n\n respond_to do |format|\n if @threat.save\n format.html { redirect_to(@threat, :notice => 'Threat was successfully created.') }\n format.xml { render :xml => @threat, :status => :created, :location => @threat }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @threat.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def tracing_params\n params.require(:tracing).permit(:project_id, :descripcion)\n end",
"def log(data)\n t = Thread.new do\n uri = URI(\"http://logs-01.loggly.com/inputs/.../tag/ost/\")\n req = Net::HTTP::Post.new(uri)\n req['content-type'] = \"content-type:application/x-www-form-urlencoded\"\n req.body = data.to_json\n res = Net::HTTP.start(uri.hostname, uri.port) {|http|\n http.request(req)\n }\n end\nend",
"def create\n @heartbeat = Heartbeat.new(heartbeat_params)\n\n if @heartbeat.save\n render json: @heartbeat, status: :created, location: @heartbeat\n else\n render json: @heartbeat.errors, status: :unprocessable_entity\n end\n end",
"def create\n @trail = Trail.new(trail_params)\n\n respond_to do |format|\n if @trail.save\n format.html { redirect_to @trail, notice: 'Trail was successfully created.' }\n format.json { render :show, status: :created, location: @trail }\n else\n format.html { render :new }\n format.json { render json: @trail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @node_incident = NodeIncident.new(params[:node_incident])\n\n respond_to do |format|\n if @node_incident.save\n format.html { redirect_to @node_incident, :notice => 'Node incident was successfully created.' }\n format.json { render :json => @node_incident, :status => :created, :location => @node_incident }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @node_incident.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @deposit_threshold = DepositThreshold.new(params[:deposit_threshold])\n\n respond_to do |format|\n if @deposit_threshold.save\n format.html { redirect_to(@deposit_threshold, :notice => 'DepositThreshold was successfully created.') }\n format.xml { render :xml => @deposit_threshold, :status => :created, :location => @deposit_threshold }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @deposit_threshold.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def submit_report(json, cookbookname)\n data = File.read(json)\n uri = URI.parse($SPEC_ENDPOINT)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = uri.scheme == \"https\"\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(\"/api/reports\")\n request.add_field('Content-Type', 'application/json')\n request.body = {\n :spec_result => data,\n :hostname => `hostname`.chomp,\n :cookbook_name => cookbookname\n }.to_json\n response = http.request(request)\n end",
"def create\n @trax = Trax.new(trax_params)\n\n respond_to do |format|\n if @trax.save\n format.html { redirect_to @trax, notice: 'Trax was successfully created.' }\n format.json { render :show, status: :created, location: @trax }\n else\n format.html { render :new }\n format.json { render json: @trax.errors, status: :unprocessable_entity }\n end\n end\n end",
"def http_report(request, _response)\n path = request.path\n\n root_element_name = Box.new('')\n result = @server.xml.parse(request.body, request.url, root_element_name)\n root_element_name = root_element_name.value\n\n if @server.emit('report', [root_element_name, result, path])\n # If emit returned true, it means the report was not supported\n fail Exception::ReportNotSupported\n end\n\n # Sending back false will interupt the event chain and tell the server\n # we've handled this method.\n false\n end",
"def create\n #vicious hack. sorry to whoever is reading this even me again.\n if params[:chart]\n redirect_to :action => :index, :params => params[:chart]\n return\n end\n @sleep = Sleep.new(params[:sleep])\n @sleep.user_id = session[:user_id]\n\n respond_to do |format|\n if @sleep.save\n flash[:notice] = 'Sleep was successfully created.'\n format.html { redirect_to(@sleep) }\n format.xml { render :xml => @sleep, :status => :created, :location => @sleep }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sleep.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new_rest\n @entry_instrument = EntryInstrument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_instrument }\n end\n end",
"def update\n @trace.import_points(points_data)\n @trace.reload\n\n render json: @trace\n end",
"def create\n @trail = Trail.new(params[:trail])\n\n respond_to do |format|\n if @trail.save\n format.html { redirect_to @trail, notice: 'Trail was successfully created.' }\n format.json { render json: @trail, status: :created, location: @trail }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @trace_exceptions = TraceException.all\n end",
"def create\n @trail = Trail.new(trail_params)\n\n respond_to do |format|\n if @trail.save\n format.html { redirect_to @trail, notice: 'Trail was successfully created.' }\n format.json { render action: 'show', status: :created, location: @trail }\n else\n format.html { render action: 'new' }\n format.json { render json: @trail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def trigger_download_traces_with_http_info(type, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SystemsApi.trigger_download_traces ...'\n end\n # verify the required parameter 'type' is set\n if @api_client.config.client_side_validation && type.nil?\n fail ArgumentError, \"Missing the required parameter 'type' when calling SystemsApi.trigger_download_traces\"\n end\n # verify enum value\n allowable_values = [\"interface\", \"core\", \"data_mining\", \"fuse\", \"library_manager\", \"manager\", \"watchdog\", \"system\", \"all\"]\n if @api_client.config.client_side_validation && !allowable_values.include?(type)\n fail ArgumentError, \"invalid value for \\\"type\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/systems/download_traces'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'type'] = type\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', 'queued', 'working', 'failed'])\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] || 'ActiveJobStatus' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\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(:PUT, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SystemsApi#trigger_download_traces\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def send_request( xml )\n write( xml )\n read\n end",
"def create\r\n @position_hist = PositionHist.new(params[:position_hist])\r\n\r\n respond_to do |format|\r\n if @position_hist.save\r\n flash[:notice] = 'PositionHist was successfully created.'\r\n format.html { redirect_to position_hist_url(@position_hist) }\r\n format.xml { head :created, :location => position_hist_url(@position_hist) }\r\n else\r\n format.html { render :action => \"new\" }\r\n format.xml { render :xml => @position_hist.errors.to_xml }\r\n end\r\n end\r\n end",
"def new_rest\n @page_usage_event = PageUsageEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page_usage_event }\n end\n end",
"def create\n @rescue_time_chart = RescueTimeChart.new(rescue_time_chart_params)\n\n respond_to do |format|\n if @rescue_time_chart.save\n format.html { redirect_to @rescue_time_chart, notice: 'Rescue time chart was successfully created.' }\n format.json { render action: 'show', status: :created, location: @rescue_time_chart }\n else\n format.html { render action: 'new' }\n format.json { render json: @rescue_time_chart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post endpoint, data\n do_request :post, endpoint, data\n end",
"def postEntityOpening_times( entity_id, monday, tuesday, wednesday, thursday, friday, saturday, sunday, closed, closed_public_holidays)\n params = Hash.new\n params['entity_id'] = entity_id\n params['monday'] = monday\n params['tuesday'] = tuesday\n params['wednesday'] = wednesday\n params['thursday'] = thursday\n params['friday'] = friday\n params['saturday'] = saturday\n params['sunday'] = sunday\n params['closed'] = closed\n params['closed_public_holidays'] = closed_public_holidays\n return doCurl(\"post\",\"/entity/opening_times\",params)\n end",
"def create\n @context = Monitoring::Context.new(monitoring_params)\n\n respond_to do |format|\n if @context.save\n format.html { redirect_to @context }\n format.json { render json: @context, status: :created }\n else\n format.html { render :new }\n format.json { render json: @context.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @threshold = Threshold.new(params[:threshold])\n\n respond_to do |format|\n if @threshold.save\n format.html { redirect_to @threshold, notice: 'Threshold was successfully created.' }\n format.json { render json: @threshold, status: :created, location: @threshold }\n else\n format.html { render action: \"new\" }\n format.json { render json: @threshold.errors, status: :unprocessable_entity }\n end\n end\n end",
"def emit_flood(event, time, sink)\n data = {\n \"time\": time.to_s,\n \"id\": event[\"site_no\"] + time.to_s.gsub(\" \", \"\"),\n \"type\": \"flood\",\n \"lat\": event[\"dec_lat_va\"],\n \"long\": event[\"dec_long_va\"],\n # \"measure\": (event[\"stage\"] - event[\"floodstage\"].to_f).round(2), # Something's wrong with the API, changing for now until fixed\n \"measure\": event[\"flow\"],\n \"metadata\": event.to_json\n }\n\n puts \"data: #{data}\"\n\n @logger.info(\"Sending message to #{sink}\")\n r = HTTParty.post(sink, \n :headers => {\n 'Content-Type' => 'text/plain',\n 'ce-specversion' => '0.2',\n 'ce-type' => 'dev.knative.naturalevent.flood',\n 'ce-source' => 'dev.knative.flood'\n },\n :body => data.to_json\n )\n\n if r.code != 200 or r.code != 202\n @logger.error(\"Error! #{r.code} - #{r}\")\n @logger.error(\"Body: #{r.body}\")\n end\nend",
"def analyse\n begin\n response = resource[\"/analyse/#{app}\"].post(nil)\n rescue RestClient::InternalServerError\n display \"An error has occurred.\"\n end\n display response.to_s\n end",
"def process_ath9_crash(params)\n url = @@conf['register_url']\n crash_dump_path = @@conf['crash_dump_path']\n \tnodeid = params[:nodeid]\n \ttstmp = Time.at params[:tstmp].to_i\n \tdmesg = params[:dmesg]\n \tnow = Time.now.to_i\n\n \tFile.open(\"#{crash_dump_path}/#{now}.log\",\"w\") do |f|\n \t\tf.puts \"Node: #{nodeid} - at: #{tstmp}\\n\"\n \t\tf.puts dmesg\n \tend\n \tNet::HTTP.post_form URI(\"#{url}/watchdog_bites\"), \n \t\t{ \"node_id\" => nodeid, \"dmesg\" => dmesg, \"tstmp\" => params[:tstmp], 'submission_stmp' => now }\n end",
"def post_outcome_request\n raise IMS::LTI::InvalidLTIConfigError, \"\" unless has_required_attributes?\n\n res = post_service_request(@lis_outcome_service_url,\n 'application/xml',\n generate_request_xml)\n\n @outcome_response = extend_outcome_response(OutcomeResponse.new)\n @outcome_response.process_post_response(res)\n end",
"def create\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n cv = ChecklistenVorlage.new({\n objekt_id: cvNode.xpath('objekt_id').text.to_s, \n bezeichner: cvNode.xpath('bezeichner').text.to_s, \n version: cvNode.xpath('version').text.to_s.to_i, \n inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool \n })\n cv.save\n\n cvNode.xpath('checklisten_eintrags/checklisten_eintrag').each do |ceNode|\n ce = ChecklistenEintrag.new({\n checklisten_vorlage_id: cv.id,\n bezeichner: ceNode.xpath('bezeichner').text.to_s,\n was: ceNode.xpath('was').text.to_s,\n wann: ceNode.xpath('wann').text.to_s,\n typ: ceNode.xpath('typ').text.to_s.to_i,\n position: ceNode.xpath('position').text.to_s.to_i\n })\n ce.save\n end\n\n respond_to do |format|\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n end\n end",
"def create\n @tstat = Tstat.new(params[:tstat])\n\n respond_to do |format|\n if @tstat.save\n flash[:notice] = 'Tstat was successfully created.'\n format.html { redirect_to(@tstat) }\n format.xml { render :xml => @tstat, :status => :created, :location => @tstat }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tstat.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @trace = Trace.find(params[:id])\n\n respond_to do |format|\n if @trace.update_attributes(params[:trace])\n format.html { redirect_to(@trace, :notice => 'Trace was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @trace.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @stack = Stack.new(stack_params)\n\n if @stack.save\n render json: @stack, status: :created, location: @stack\n else\n render json: @stack.errors, status: :unprocessable_entity\n end\n end",
"def create\n @traceroute = Traceroute.new(traceroute_params)\n\n respond_to do |format|\n if @traceroute.save\n flash[:notice] = 'traceroute was successfully created.'\n format.html { redirect_to @traceroute, notice: 'Traceroute was successfully created.' }\n format.json { render action: 'show', status: :created, location: @traceroute }\n else\n format.html { render action: 'new' }\n format.json { render json: @traceroute.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lookup_pettracer = LookupPettracer.new(params[:lookup_pettracer])\n\n respond_to do |format|\n if @lookup_pettracer.save\n format.html { redirect_to(@lookup_pettracer, :notice => 'Lookup pettracer was successfully created.') }\n format.xml { render :xml => @lookup_pettracer, :status => :created, :location => @lookup_pettracer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lookup_pettracer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def send_stats\n first_time = @prev_stat.empty?\n stats = build_request\n @stat.keys.each { |k| stats[k] = @stat[k] - @prev_stat[k] }\n @prev_stat.replace(@stat)\n # These should be reported as absolute values\n [:mt, :ma, :mc].each {|k| @prev_stat[k] = 0}\n return if first_time\n\n req = Net::HTTP::Post.new('/')\n req.set_form_data(stats)\n res = Net::HTTP.start(API, use_ssl: true) { |http| http.request(req) }\n unless res.is_a?(Net::HTTPOK)\n STDERR.puts \"Error sending stat: #{res.message}\"\n end\n res\n end",
"def post_incident(payload)\n begin\n payload_json = JSON.dump(payload)\n resp = pagerduty.incidents_api.post(payload_json, :content_type => :json)\n answer = JSON.parse(resp, :symbolize_names => true)\n log.debug(\"POST to incidents, payload=#{payload.inspect}, response=#{answer}\")\n answer\n rescue Exception => e\n log.error(\"Failed to post to incident API: #{payload.inspect}.\"+\n \"\\nError: #{e.message}\")\n raise RuntimeError.new(\"Problem talking to PagerDuty incidents:\"+\n \" #{e.message}\\nRequest was #{payload.inspect}\")\n end\n end",
"def create\n @early_warning_report = EarlyWarningReport.new(early_warning_report_params)\n @early_warning_report.sms_status = 'Sending'\n recievers = early_warning_report_params['recieviers']\n level = early_warning_report_params['level']\n respond_to do |format|\n if @early_warning_report.save\n send_sms(recievers,level)\n\n format.html { redirect_to @early_warning_report, notice: 'Early warning report was successfully created and SMS sent' }\n format.json { render :show, status: :created, location: @early_warning_report }\n else\n format.html { render :new }\n format.json { render json: @early_warning_report.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6692415",
"0.6669374",
"0.6325361",
"0.5938512",
"0.5909333",
"0.57289594",
"0.57259846",
"0.56932604",
"0.56564623",
"0.5651693",
"0.5634122",
"0.553403",
"0.54249704",
"0.5368843",
"0.5315113",
"0.5280669",
"0.51258254",
"0.5042592",
"0.5033409",
"0.5029465",
"0.5018457",
"0.50045395",
"0.49686757",
"0.4958138",
"0.4927971",
"0.49133977",
"0.49090773",
"0.48699054",
"0.48637825",
"0.48520654",
"0.48514646",
"0.48450756",
"0.4839909",
"0.48202267",
"0.4807788",
"0.4793705",
"0.47864965",
"0.47751755",
"0.47735947",
"0.47707736",
"0.4758141",
"0.4722411",
"0.47220898",
"0.4717401",
"0.47109646",
"0.4671131",
"0.46628293",
"0.46578783",
"0.46529558",
"0.4649648",
"0.46464399",
"0.4645193",
"0.46405187",
"0.4631056",
"0.46192312",
"0.46188527",
"0.46170673",
"0.46158153",
"0.46104455",
"0.46095124",
"0.46050528",
"0.45970947",
"0.4579036",
"0.4571603",
"0.45696843",
"0.45671448",
"0.45662823",
"0.45634666",
"0.45624402",
"0.45570198",
"0.45530102",
"0.4552994",
"0.45443118",
"0.45418206",
"0.45405185",
"0.4538771",
"0.4538027",
"0.4534943",
"0.45339575",
"0.45305502",
"0.45206088",
"0.4519219",
"0.45128208",
"0.4507054",
"0.45049754",
"0.4504069",
"0.4503372",
"0.45028067",
"0.45002827",
"0.44986567",
"0.44921792",
"0.44890696",
"0.4487308",
"0.4473378",
"0.44724172",
"0.44719538",
"0.44700307",
"0.44660047",
"0.4464669",
"0.44646582"
] | 0.65364623 | 2 |
PUT /traces/1 PUT /traces/1.xml | def update
@trace = Trace.find(params[:id])
respond_to do |format|
if @trace.update_attributes(params[:trace])
format.html { redirect_to(@trace, :notice => 'Trace was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @trace.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end",
"def update\n if @trace.update(trace_params)\n render :show, status: :ok, location: @trace\n else\n render json: @trace.errors, status: :unprocessable_entity\n end\n end",
"def test_post_then_get\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n id = last_response.body\n\n get \"/traces/#{id}\"\n check_valid_trace last_response.body\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def create\n @trace = Trace.new(params[:trace])\n\n respond_to do |format|\n if @trace.save\n format.html { redirect_to(@trace, :notice => 'Trace was successfully created.') }\n format.xml { render :xml => @trace, :status => :created, :location => @trace }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trace.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tracing.update(tracing_params)\n format.html { redirect_to @tracing }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tracing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trace.import_points(points_data)\n @trace.reload\n\n render json: @trace\n end",
"def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end",
"def create\n @trace = Trace.new(params[:trace])\n\n respond_to do |format|\n if @trace.save\n flash[:notice] = 'Trace was successfully created.'\n format.html { redirect_to :controller => 'members', :action => 'index_simple' }\n format.xml { render :xml => @trace, :status => :created, :location => @trace }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trace.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def destroy\n @trace = Trace.find(params[:id])\n @trace.destroy\n\n respond_to do |format|\n format.html { redirect_to(traces_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @trace = Trace.find(params[:id])\n @trace.destroy\n\n respond_to do |format|\n format.html { redirect_to(traces_url) }\n format.xml { head :ok }\n end\n end",
"def update_xml\n self.xml= dumpRouteAsXml\n self.save\n end",
"def set_trace\n @trace = Trace.find(params[:id])\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @tracer.update(tracer_params)\n format.html { redirect_to @tracer, notice: \"Tracer was successfully updated.\" }\n format.json { render :show, status: :ok, location: @tracer }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tracer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put_datastream(pid, dsID, xml)\n uri = URI.parse(@fedora + '/objects/' + pid + '/datastreams/' + dsID ) \n RestClient.put(uri.to_s, xml, :content_type => \"application/xml\")\n rescue => e\n e.response \n end",
"def update_rest\n @page_usage_event = PageUsageEvent.find(params[:id])\n\n respond_to do |format|\n if @page_usage_event.update_attributes(params[:page_usage_event])\n flash[:notice] = 'PageUsageEvent was successfully updated.'\n format.html { redirect_to(@page_usage_event) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page_usage_event.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @node_rack = @object\n\n respond_to do |format|\n if @node_rack.update_attributes(params[:node_rack])\n flash[:notice] = 'NodeRack was successfully updated.'\n format.html { redirect_to node_rack_url(@node_rack) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node_rack.errors.to_xml, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @visit_stat = VisitStat.find(params[:id])\n\n respond_to do |format|\n if @visit_stat.update_attributes(params[:visit_stat])\n format.html { redirect_to([:scaffold, @visit_stat], :notice => 'Visit stat was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @visit_stat.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_rest\n @entry_instrument = EntryInstrument.find(params[:id])\n\n respond_to do |format|\n if @entry_instrument.update_attributes(params[:entry_instrument])\n flash[:notice] = 'EntryInstrument was successfully updated.'\n format.html { redirect_to(@entry_instrument) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_instrument.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trace_exception.update(trace_exception_params)\n format.html { redirect_to @trace_exception, notice: 'Trace exception was successfully updated.' }\n format.json { render :show, status: :ok, location: @trace_exception }\n else\n format.html { render :edit }\n format.json { render json: @trace_exception.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save\n @client.patch(@endpoint, :content=>@changed)\n return nil\n end",
"def update\n id = params[:id]\n @physical_rack = PhysicalRack.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @physical_rack.attributes = params[:physical_rack]\n @physical_rack.audits << Audit.new(source: 'controller', action: 'update', admin_user: current_user)\n respond_to do |format|\n if @physical_rack.save\n format.html { redirect_to @physical_rack, notice: 'Physical rack was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @physical_rack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trace = Trace.new\n if @trace.save\n @trace.import_points(points_data)\n status = :created\n else\n status = :bad_request\n end\n\n render json: @trace, status: status\n end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend",
"def update\n @logstash = Logstash.find(params[:id])\n\n respond_to do |format|\n if @logstash.update_attributes(params[:logstash])\n format.html { redirect_to @logstash, notice: 'Logstash was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @logstash.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_should_update_project_via_API_XML\r\n get \"/logout\"\r\n put \"/projects/1.xml\", :project => {:user_id => 1,\r\n :url => 'http://www.apiproject.com',\r\n :name => 'API Project',\r\n :description => 'API Project Desc' }\r\n assert_response 401\r\n end",
"def test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end",
"def show\n @trace = Trace.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @trace }\n end\n end",
"def show\n @trace = Trace.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @trace }\n end\n end",
"def update\n @graph.update_attributes_from_request(update_params)\n head :no_content\n end",
"def update_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n\n respond_to do |format|\n if @instrument_version.update_attributes(params[:instrument_version])\n flash[:notice] = 'InstrumentVersion was successfully updated.'\n format.html { redirect_to(@instrument_version) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instrument_version.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def trigger_download_traces_with_http_info(type, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SystemsApi.trigger_download_traces ...'\n end\n # verify the required parameter 'type' is set\n if @api_client.config.client_side_validation && type.nil?\n fail ArgumentError, \"Missing the required parameter 'type' when calling SystemsApi.trigger_download_traces\"\n end\n # verify enum value\n allowable_values = [\"interface\", \"core\", \"data_mining\", \"fuse\", \"library_manager\", \"manager\", \"watchdog\", \"system\", \"all\"]\n if @api_client.config.client_side_validation && !allowable_values.include?(type)\n fail ArgumentError, \"invalid value for \\\"type\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/systems/download_traces'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'type'] = type\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', 'queued', 'working', 'failed'])\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] || 'ActiveJobStatus' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\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(:PUT, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SystemsApi#trigger_download_traces\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update\n @lab_rack = LabRack.find(params[:id])\n\n respond_to do |format|\n if @lab_rack.update_attributes(params[:lab_rack])\n format.html { redirect_to(@lab_rack, :notice => 'Lab rack was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lab_rack.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit_stacks(stack_id, name, description, tangle_alias)\n payload = {\n 'name' => name,\n 'description' => description,\n 'tangle_alias' => tangle_alias\n }\n @conn.put(\"/api/v1/stacks/#{stack_id}\", payload.to_json)\n end",
"def update\n @node_incident = NodeIncident.find(params[:id])\n\n respond_to do |format|\n if @node_incident.update_attributes(params[:node_incident])\n format.html { redirect_to @node_incident, :notice => 'Node incident was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @node_incident.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n data = []\n trace_params.each do |p|\n hash = {\n latitude: p[\"latitude\"],\n longitude: p[\"longitude\"]\n }\n data << hash\n end\n\n if Trace.upload_data(data)\n render json: {status: 'OK'}\n else\n render json: @trace.errors, status: :unprocessable_entity\n end\n end",
"def update\n @trace = Trace.find(params[:id])\n params[:trace][:step_ids] = \"\"\n params[:trace][:step_ids] = params[:step_list].join(\",\") if params[:step_list]\n \n #將課程紀錄存入session,以便快速新增課程紀錄\n set_auto_history_session( params[:trace][:last_class_date], params[:trace][:last_class_teacher], params[:trace][:last_class_title], params[:trace][:class_type], params[:trace][:aid], params[:trace][:is_public_class] )\n #如果有输入生活类别,则自动新增一笔记录到生活管理表\n if !params[:param_change][:param_id].empty?\n create_new_param_change params \n end\n respond_to do |format|\n if @trace.update_attributes(params[:trace])\n flash[:notice] = \"追蹤紀錄更新成功! ( #{session[:class_date]} : #{session[:class_teacher]} : #{class_type_arr.rassoc(params[:trace][:class_type])[0]} : #{session[:class_title]} )\"\n # format.html { redirect_to :controller => 'histories', :action => 'index_by_month_peroid' }\n format.html { redirect_to_index }\n # format.html { redirect_to :action => \"edit\" }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @trace.errors, :status => :unprocessable_entity }\n end\n end\n \n end",
"def update\n @xml_sample = XmlSample.find(params[:id])\n \n respond_to do |format|\n format.html do\n @xml_sample = XmlSample.update_attributes(params[:xml_sample])\n if @xml_sample.save\n return redirect_to @xml_sample, notice: 'Xml sample was successfully updated.'\n else\n return render action: \"new\"\n end\n end\n format.xml do\n rexml = REXML::Document.new(params[\"xml\"])\n attr = Hash.from_xml(rexml.to_s)\n if @xml_sample.update_attributes(attr[\"xmlsample\"])\n xml = {msg: \"complete\", status: \"OK\"}.to_xml\n else\n xml = {msg: \"failed\", status: \"NG\"}.to_xml\n end\n return render xml: xml\n end\n end\n end",
"def update\n @consensu = Consensu.find(params[:id])\n\n respond_to do |format|\n if @consensu.update_attributes(params[:consensu])\n format.html { redirect_to @consensu, notice: 'Consensu was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @consensu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @trace = Trace.new(params[:trace])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trace }\n end\n end",
"def updateStatus\n\n storyURI = @details['Assets']['Asset']['href']\n\n statusXml = '<Asset>\n <Attribute name=\"Custom_JIRAIntStatus\" act=\"set\">' + @mapping.SendToJiraMap['Resolved in JIRA'] + '</Attribute>\n </Asset>'\n\n r_status = self.class.post(\"#{storyURI}\", :body => statusXml,\n :headers => {\"content_type\" => \"application/xml\"}, :verify => false)\n\n if r_status['Error']\n p r_status['Error']\n else\n @persist.updateDefectStatus(@story)\n return 1\n end\n return 0\n end",
"def update\n @heartbeat = Heartbeat.find(params[:id])\n\n respond_to do |format|\n if @heartbeat.update_attributes(params[:heartbeat])\n format.html { redirect_to @heartbeat, notice: 'Heartbeat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @heartbeat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.path)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n end",
"def test_should_update_link_via_API_XML\r\n get \"/logout\"\r\n put \"/links/1.xml\", :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response 401\r\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n @outline = Outline.find(params[:id])\n\n respond_to do |format|\n if @outline.update_attributes(params[:outline])\n flash[:notice] = 'Outline was successfully updated.'\n format.html { redirect_to(@outline) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @outline.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @timeline = Timeline.find(params[:id])\n\n respond_to do |format|\n if @timeline.update_attributes(params[:timeline])\n flash[:notice] = 'Timeline was successfully updated.'\n format.html { redirect_to([:admin, @timeline]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @timeline.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_ntrace(event)\n # Ensure only those allowed can do this\n assert_permissions(event, ['ntracer'])\n\n # Fetch attached file and perform integrity checks\n files = event.message.attachments.select{ |a| a.filename == 'ntrace.py' }\n raise OutteError.new \"File #{verbatim('ntrace.py')} not found in the attachments\" if files.size == 0\n raise OutteError.new \"Too many #{verbatim('ntrace.py')} files found in the attachments\" if files.size > 1\n file = files.first\n raise OutteError.new \"The ntrace file provided is too big\" if file.size > 1024 ** 2\n res = Net::HTTP.get(URI(file.url))\n raise OutteError.new \"The received ntrace file is corrupt\" if res.size != file.size\n\n # Update file\n old_date = File.mtime(PATH_NTRACE) rescue nil\n old_size = File.size(PATH_NTRACE) rescue nil\n File.binwrite(PATH_NTRACE, res)\n new_date = File.mtime(PATH_NTRACE) rescue nil\n new_size = File.size(PATH_NTRACE) rescue nil\n event << (new_date.nil? ? 'Failed to update ntrace.' : \"ntrace updated successfully.\")\n versions = ''\n versions << \"Old version: #{old_date.strftime('%Y/%m/%d %H:%M:%S')} (#{old_size} bytes)\\n\" if !old_date.nil?\n versions << \"New version: #{new_date.strftime('%Y/%m/%d %H:%M:%S')} (#{new_size} bytes)\\n\" if !new_date.nil?\n event << format_block(versions)\n\n Thread.new { ld(\"#{event.user.name} updated ntrace:\\n#{format_block(versions)}\") }\nrescue => e\n lex(e, \"Error updating ntrace.\", event: event)\nend",
"def update\n respond_to do |format|\n if @mouse_rack.update(mouse_rack_params)\n format.html { redirect_to @mouse_rack, notice: 'Mouse rack was successfully updated.' }\n format.json { render :show, status: :ok, location: @mouse_rack }\n else\n format.html { render :edit }\n format.json { render json: @mouse_rack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance/{tenantId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def create\n @tracing = Tracing.new(tracing_params)\n\n respond_to do |format|\n if @tracing.save\n format.html { redirect_to @tracing}\n format.json { render action: 'show', status: :created, location: @tracing }\n else\n format.html { render action: 'new' }\n format.json { render json: @tracing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}/volumes\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.request_uri)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n\n end",
"def edit_xml(path, &block)\n write path, xml(path).tap(&block).to_s\n end",
"def solveticket(assigneeid, ticketidxml)\n\n raise ArgumentError.new(\"no assignee is present\") if assigneeid.empty?\n raise ArgumentError.new(\"ticketid is present text provided\") if ticketidxml.empty?\n\n xml = createsolvedticketxml(assigneeid)\n\n begin\n resource = RestClient::Resource.new @hostname, @username, @password\n url = 'tickets/'+ ticketidxml\n httpresponse = resource[url].put xml.to_s, :content_type => 'application/xml', :accept => '*/*'\n processresponse(httpresponse) # call success handler\n rescue => e\n processerror(e) # call error handler\n end\n\n end",
"def update\n @trail = Trail.find(params[:id])\n\n respond_to do |format|\n if @trail.update_attributes(params[:trail])\n format.html { redirect_to @trail, notice: 'Trail was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trail = Trail.find(params[:id])\n\n respond_to do |format|\n if @trail.update_attributes(params[:trail])\n format.html { redirect_to @trail, notice: 'Trail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>])\n\n respond_to do |format|\n if @<%= file_name %>.save\n flash[:notice] = '<%= class_name %> was successfully created.'\n format.html { redirect_to(@<%= file_name %>) }\n format.xml { render :xml => @<%= file_name %>, :status => :created, :location => @<%= file_name %> }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }\n end\n end\n end\n\n # PUT /<%= table_name %>/1\n # PUT /<%= table_name %>/1.xml\n def update\n @<%= file_name %> = <%= class_name %>.find(params[:id])\n\n respond_to do |format|\n if @<%= file_name %>.update_attributes(params[:<%= file_name %>])\n flash[:notice] = '<%= class_name %> was successfully updated.'\n format.html { redirect_to(@<%= file_name %>) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }\n end\n end\n end\n\n # DELETE /<%= table_name %>/1\n # DELETE /<%= table_name %>/1.xml\n def destroy\n @<%= file_name %> = <%= class_name %>.find(params[:id])\n @<%= file_name %>.destroy\n\n respond_to do |format|\n format.html { redirect_to(<%= table_name %>_url) }\n format.xml { head :ok }\n end\n end\n\n # PUT /<%= table_name %>/1/audit\n # PUT /<%= table_name %>/1.xml/audit\n def audit\n @<%= file_name %> = <%= class_name %>.find(params[:id])\n @formlog = Formlog.new(params[:formlog])\n @auditflows_form = flow_get_auditflows_form(@formlog) # 获得表单-审核流程对应,没有对应(自检)时获得新的对应(未存入数据库)\n if @auditflows_form.auditflows_flownode || flow_is_need_action_on_flow(@<%= file_name %>, params[:button_name])\n # 设定审核操作相关值\n @formlog, @auditflows_form, @<%= file_name %> = flow_set_rec_log_and_status(@formlog, @auditflows_form, @<%= file_name %>)\n else # 审核流程已经结束\n flash[:notice] = \"审核流程已结束,请勿重复操作!\"\n render :action => \"show\"\n return\n end\n\n respond_to do |format|\n begin\n <%= class_name %>.transaction do\n @formlog.save!\n @auditflows_form.save!\n @<%= file_name %>.save!\n flash[:notice] = '审核完成.'\n format.html { redirect_to(@<%= file_name %>) }\n format.xml { render :xml => @formlog, :status => :created, :location => @formlog }\n end\n rescue\n format.html { render :action => \"audit_self\" }\n format.xml { render :xml => @formlog.errors, :status => :unprocessable_entity }\n end\n end\n end\n\n # get /<%= table_name %>/1/audit_self\n def audit_self\n @<%= file_name %> = <%= class_name %>.find(params[:id])\n @button_name, @button_name_cn = params[:button_name], params[:button_name_cn]\n if not flow_is_need_action_on_flow(@<%= file_name %>, @button_name) # 是否为当前要操作的节点\n flash[:notice] = '操作流程不允许'\n render :action => \"show\"\n return\n end\n @formlog = flow_get_new_formlog(@<%= file_name %>)\n end\n\nend",
"def test_should_update_invite_via_API_XML\r\n get \"/logout\"\r\n put \"/invites/1.xml\", :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => 'test@email.com',\r\n :user_id => 1 }\r\n assert_response 401\r\n end",
"def new\n @trace = Trace.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trace }\n end\n end",
"def update\n @sti = Sti.find(params[:id])\n\n respond_to do |format|\n if @sti.update_attributes(params[:sti])\n flash[:notice] = 'Sti was successfully updated.'\n format.html { redirect_to(@sti) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sti.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\r\n @position_hist = PositionHist.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @position_hist.update_attributes(params[:position_hist])\r\n flash[:notice] = 'PositionHist was successfully updated.'\r\n format.html { redirect_to position_hist_url(@position_hist) }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n format.xml { render :xml => @position_hist.errors.to_xml }\r\n end\r\n end\r\n end",
"def set_tracing\n @tracing = Tracing.find(params[:id])\n end",
"def update\n @old_point_tag = OldPointTag.find(params[:id])\n\n respond_to do |format|\n if @old_point_tag.update_attributes(params[:old_point_tag])\n format.html { redirect_to(@old_point_tag, :notice => 'Old point tag was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @old_point_tag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end",
"def set_trace_school_id\n unless [:post, :put].include?(request.method) then\n return render(:text => 'Method not allowed', :status => 405)\n end\n @trace = @current_project.trace.find(params[:id])\n @trace.school_id = params[:value]\n @trace.save\n render :text => CGI::escapeHTML(@trace.school.name)\n end",
"def trace!\n request! :trace\n end",
"def update\n @tstat = Tstat.find(params[:id])\n\n respond_to do |format|\n if @tstat.update_attributes(params[:tstat])\n flash[:notice] = 'Tstat was successfully updated.'\n format.html { redirect_to(edit_tstat_url(@tstat)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tstat.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @heartbeat = Heartbeat.find(params[:id])\n\n if @heartbeat.update(heartbeat_params)\n head :no_content\n else\n render json: @heartbeat.errors, status: :unprocessable_entity\n end\n end",
"def update\n @trend = Trend.find(params[:id])\n\n respond_to do |format|\n if @trend.update_attributes(params[:trend])\n format.html { redirect_to @trend, :notice => 'Trend was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @trend.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @heatspot = Heatspot.find(params[:id])\n flash[:notice] = 'Heatspot was successfully updated.' if @heatspot.update_attributes(params[:heatspot])\n \n redirect_to @heatmap\n end",
"def update\n @stack = Stack.find(params[:id])\n\n if @stack.update(stack_params)\n head :no_content\n else\n render json: @stack.errors, status: :unprocessable_entity\n end\n end",
"def update\n @server_rack = ServerRack.find(params[:id])\n\n respond_to do |format|\n if @server_rack.update_attributes(params[:server_rack])\n format.html { redirect_to(@server_rack, :notice => 'Server rack was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @server_rack.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @incident = Incident.find(params[:id])\n\n respond_to do |format|\n if @incident.update_attributes(params[:incident])\n format.html { redirect_to(@incident) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @incident.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tip.update(tips_params)\n json_response(@tip)\n end",
"def update\n @detailed_retrofit = DetailedRetrofit.find(params[:id])\n\n respond_to do |format|\n if @detailed_retrofit.update_attributes(params[:detailed_retrofit])\n format.html { redirect_to(@detailed_retrofit, :notice => 'Detailed retrofit was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @detailed_retrofit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_story_with_caliber_traces(story_oid, req_name, traces_text)\n update_fields = {}\n update_fields[$caliber_req_traces_field_name] = traces_text\n begin\n @rally.update(\"hierarchicalrequirement\", story_oid, update_fields)\n rescue => ex\n @logger.error \"Error occurred attempting to Import Caliber Traces to Rally UserStory: OID=#{story_oid};\"\n @logger.error ex.message\n @logger.error ex.backtrace\n end\nend",
"def update\n @node = Node.scopied.find(params[:id])\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n format.html { redirect_to(@node, :notice => 'Node was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tso = Tso.find(params[:id])\n\n respond_to do |format|\n if @tso.update_attributes(params[:tso])\n flash[:notice] = 'Tso was successfully updated.'\n format.html { redirect_to(@tso) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tso.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @traceroute.update(traceroute_params)\n format.html { redirect_to @traceroute, notice: 'Traceroute was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @traceroute.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @traceroute.update(traceroute_params)\n format.html { redirect_to @traceroute, notice: 'Traceroute was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @traceroute.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @hit = Hit.find(params[:id])\n\n respond_to do |format|\n if @hit.update_attributes(params[:hit])\n format.html { redirect_to @hit, notice: 'Hit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n name = Server.find(params[:id]).name\n n = Neography::Node.find('servers', 'name', name)\n n.name = server_params[:name]\n n.add_to_index('servers', 'name', server_params[:name]) #TODO: is this necessary?\n if @server.update(server_params)\n format.html { redirect_to @server, notice: 'Server was successfully updated.' }\n format.json { render :show, status: :ok, location: @server }\n else\n format.html { render :edit }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def incident_update(statuspage_id, incident_id, incident_details, current_status, current_state, notifications = 0, message_subject = \"Status Notification\")\n data = get_notify(notifications)\n data['statuspage_id'] = statuspage_id\n data['incident_id'] = incident_id\n data['incident_details'] = incident_details\n data['current_status'] = current_status\n data['current_state'] = current_state\n data['message_subject'] = message_subject\n\n request :method => :post,\n :url => @url + 'incident/update',\n :payload => data\n end",
"def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end",
"def update\n @trend = Trend.find(params[:id])\n\n respond_to do |format|\n if @trend.update_attributes(params[:trend])\n format.html { redirect_to @trend, notice: 'Trend was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_story_with_caliber_traces(story_oid, req_name, traces_text)\n\n @logger.info \"Updating Rally Story ObjectID: #{story_oid} with Caliber Traces from Requirement: #{req_name}\"\n\n update_fields = {}\n update_fields[$caliber_trace_field_name] = traces_text\n begin\n @rally.update(\"hierarchicalrequirement\", story_oid, update_fields)\n @logger.info \"Successfully Imported Caliber Traces for Rally Story: ObjectID #{story_oid}.\"\n rescue => ex\n @logger.error \"Error occurred attempting to Import Caliber Traces to Rally Story: ObjectID #{story_oid}.\"\n @logger.error ex.message\n @logger.error ex.backtrace\n end\nend",
"def update\n @fault_type = FaultType.find(params[:id])\n\n respond_to do |format|\n if @fault_type.update_attributes(params[:fault_type])\n format.html { redirect_to(@fault_type, :notice => 'FaultType was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @fault_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trail.update(trail_params)\n format.html { redirect_to @trail, notice: 'Trail was successfully updated.' }\n format.json { render :show, status: :ok, location: @trail }\n else\n format.html { render :edit }\n format.json { render json: @trail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @traces = Trace.all\n\n render json: @traces\n end",
"def update\n @estagio = Estagio.find(params[:id])\n\n respond_to do |format|\n if @estagio.update_attributes(params[:estagio])\n flash[:notice] = 'Estagio was successfully updated.'\n format.html { redirect_to(@estagio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estagio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @segment = Segment.find(params[:id])\n\n respond_to do |format|\n if @segment.update_attributes(params[:segment])\n flash[:notice] = 'Segment was successfully updated.'\n format.html { redirect_to(@segment) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @segment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end",
"def update\n @snap = Snap.find(params[:id])\n\n respond_to do |format|\n if @snap.update_attributes(params[:snap])\n format.html { redirect_to(@snap, :notice => 'Snap was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @snap.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @checkpoint = Checkpoint.find(params[:id])\n respond_to do |format|\n if @checkpoint.update_attributes(params[:checkpoint])\n ##format.html { redirect_to(@checkpoint, :notice => 'Checkpoint was successfully updated.') }\n ##format.xml { head :ok }\n format.html { redirect_to(:action => :index) }\n format.xml { redirect_to(:action => :index) }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @checkpoint.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(uri, payload)\n url = \"#{@config[:base_url]}#{@config[:rest_path]}/#{extract_pid(uri)}\"\n request = Request.new(\n \"Put\", url, payload.to_s, {\n \"Accept\" => \"application/json\",\n \"Content-Type\" => \"application/json\",\n \"Content-Length\" => \"nnnn\",\n @auth_header => @token\n }\n )\n response = request.perform\n response\n end",
"def update(index_name, payload)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = \"application/json\"\n req.body = payload.to_json\n @client.send_http(req, true, ['200'])\n end",
"def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end"
] | [
"0.6835423",
"0.60055846",
"0.5863916",
"0.55920285",
"0.558591",
"0.55336314",
"0.55016124",
"0.54899234",
"0.54840225",
"0.53827286",
"0.5276518",
"0.52729386",
"0.52646047",
"0.51118666",
"0.5062133",
"0.50550354",
"0.5046644",
"0.5031522",
"0.5015565",
"0.49722326",
"0.49496406",
"0.49386686",
"0.4928379",
"0.49237445",
"0.49123445",
"0.49010044",
"0.48847592",
"0.48728618",
"0.4862036",
"0.48333648",
"0.48329648",
"0.48271486",
"0.48163986",
"0.4814686",
"0.48053834",
"0.47843495",
"0.47829857",
"0.47815788",
"0.47786772",
"0.4776933",
"0.4774116",
"0.47523013",
"0.4751615",
"0.47406036",
"0.4733124",
"0.47234195",
"0.47224352",
"0.4712462",
"0.47124276",
"0.47063044",
"0.4704737",
"0.47033396",
"0.46996632",
"0.46976635",
"0.46914667",
"0.46871033",
"0.46844298",
"0.4682181",
"0.46755236",
"0.46587193",
"0.4656018",
"0.46529952",
"0.46518996",
"0.4641257",
"0.46369117",
"0.46354347",
"0.46317568",
"0.4626646",
"0.46196792",
"0.4617178",
"0.46065497",
"0.46051383",
"0.45994267",
"0.45985398",
"0.4595044",
"0.45919746",
"0.45910662",
"0.45857963",
"0.45846918",
"0.45845765",
"0.45837674",
"0.45816824",
"0.45798817",
"0.45685574",
"0.45658788",
"0.45653144",
"0.45645317",
"0.45607466",
"0.45597985",
"0.45596552",
"0.4557765",
"0.45555186",
"0.4554071",
"0.45536855",
"0.45519817",
"0.4551946",
"0.45516673",
"0.455151",
"0.4549547",
"0.45493487"
] | 0.61566895 | 1 |
DELETE /traces/1 DELETE /traces/1.xml | def destroy
@trace = Trace.find(params[:id])
@trace.destroy
respond_to do |format|
format.html { redirect_to(traces_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def destroy\n @trace.destroy\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end",
"def report_delete(id)\r\n\t\tpost= { \"token\" => @token, \"report\" => id } \r\n\t\tdocxml=nessus_request('report/delete', post)\r\n\t\treturn docxml\r\n\tend",
"def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def destroy\n @visit_stat = VisitStat.find(params[:id])\n @visit_stat.destroy\n\n respond_to do |format|\n format.html { redirect_to(scaffold_visit_stats_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @segment = Segment.find(params[:id])\n @segment.destroy\n\n respond_to do |format|\n format.html { redirect_to(worldreach_segments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @deposit_threshold = DepositThreshold.find(params[:id])\n @deposit_threshold.destroy\n\n respond_to do |format|\n format.html { redirect_to(deposit_thresholds_url) }\n format.xml { head :ok }\n end\n end",
"def delete_analysis(analysis_id); rest_delete(\"#{link('analyses')}/#{analysis_id}\"); nil; end",
"def destroy\n @path = Path.find(params[:id])\n @path.destroy\n\n respond_to do |format|\n format.html { redirect_to(layer_url) }\n format.xml { head :ok }\n end\n end",
"def delete(name)\n @ctx.delete(@path + name)\n end",
"def destroy\n @audit_log = AuditLog.find(params[:id])\n @audit_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(audit_logs_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n\t\tdb.execute{ \"delete edge #{ref_name} #{rrid}\" }\n\tend",
"def destroy\n @tracing.destroy\n respond_to do |format|\n format.html { redirect_to tracings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sleep_log = SleepLog.find(params[:id])\n @sleep_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(sleep_logs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @diagram = Diagram.find(params[:id])\n @diagram.destroy\n\n respond_to do |format|\n format.html { redirect_to(diagrams_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @report_line = ReportLine.find(params[:id])\n @report_line.destroy\n\n respond_to do |format|\n format.html { redirect_to(report_lines_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n expire_page :action => :index\n expire_page :action => :show\n \n @ganglia_graph = GangliaGraph.get(params[:id])\n @ganglia_graph.destroy\n\n respond_to do |format|\n format.html { redirect_to(ganglia_graphs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @xml_sample = XmlSample.find(params[:id])\n @xml_sample.destroy\n\n respond_to do |format|\n format.html { redirect_to xml_samples_url }\n format.xml do\n xml = {msg: \"complete\", status: \"OK\"}.to_xml\n return render xml: xml\n end\n end\n end",
"def destroy\n @segment_detail = SegmentDetail.find(params[:id])\n @segment_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to(segment_details_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pageview = Pageview.find(params[:id])\n @pageview.destroy\n\n respond_to do |format|\n format.html { redirect_to(pageviews_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @lab_rack = LabRack.find(params[:id])\n @lab_rack.destroy\n\n respond_to do |format|\n format.html { redirect_to(lab_racks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stat = Stat.find(params[:id])\n @stat.destroy\n\n respond_to do |format|\n format.html { redirect_to(stats_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stat = Stat.find(params[:id])\n @stat.destroy\n\n respond_to do |format|\n format.html { redirect_to(stats_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @logstash = Logstash.find(params[:id])\n @logstash.destroy\n\n respond_to do |format|\n format.html { redirect_to logstashes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tstat = Tstat.find(params[:id])\n @tstat.destroy\n\n respond_to do |format|\n format.html { redirect_to(tstats_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @log = @client.logs.find(params[:id])\n @log.destroy\n\n respond_to do |format|\n format.html { redirect_to(client_url(@client)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @node = Node.scopied.find(params[:id])\n @node.kill\n\n respond_to do |format|\n format.html { redirect_to(nodes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @probe = Probe.find(params[:id])\n @probe.destroy\n\n respond_to do |format|\n format.html { redirect_to(probes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @snap = Snap.find(params[:id])\n @snap.destroy\n\n respond_to do |format|\n format.html { redirect_to(snaps_url) }\n format.xml { head :ok }\n end\n end",
"def delete_snapshot(snapshot_id)\n end",
"def destroy\n @threshold = Threshold.find(params[:id])\n @threshold.destroy\n\n respond_to do |format|\n format.html { redirect_to thresholds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @auditflows_flownode = AuditflowsFlownode.find(params[:id])\n @auditflows_flownode.destroy\n\n respond_to do |format|\n format.html { redirect_to(auditflows_flownodes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dlog = Dlog.find(params[:id])\n @dlog.destroy\n\n respond_to do |format|\n format.html { redirect_to(dlogs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dailyreport = Dailyreport.find(params[:id])\n @dailyreport.destroy\n\n respond_to do |format|\n format.html { redirect_to(dailyreports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @action_log = ActionLog.find(params[:id])\n @action_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(action_logs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @hdfs_path = HdfsPath.find(params[:id])\n @hdfs_path.destroy\n\n respond_to do |format|\n format.html { redirect_to hdfs_paths_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @measurement_log = current_account.measurement_logs.find(params[:id])\n @measurement_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(measurement_logs_url) }\n format.xml { head :ok }\n end\n end",
"def incident_delete(statuspage_id, incident_id)\n data = {}\n data['statuspage_id'] = statuspage_id\n data['incident_id'] = incident_id\n\n request :method => :post,\n :url => @url + 'incident/delete',\n :payload => data\n end",
"def destroy\r\n @position_hist = PositionHist.find(params[:id])\r\n @position_hist.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to position_hists_url }\r\n format.xml { head :ok }\r\n end\r\n end",
"def report_delete(id)\n\t\t\tpost= { \"token\" => @token, \"report\" => id }\n\t\t\tdocxml = nil\n\t\t\tdocxml=nessus_request('report/delete', post)\n\t\t\tif docxml.nil?\n\t\t\t\treturn\n\t\t\tend\n\t\t\treturn docxml\n\t\tend",
"def destroy\n Audit.find(params[:id]).destroy\n head :no_content\n end",
"def destroy\n @checkpoint_removed = CheckpointRemoved.find(params[:id])\n @checkpoint_removed.destroy\n\n respond_to do |format|\n format.html { redirect_to(checkpoint_removeds_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @travel_log = TravelLog.find(params[:id])\n @travel_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(travel_logs_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @consensu = Consensu.find(params[:id])\n @consensu.destroy\n\n respond_to do |format|\n format.html { redirect_to consensus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @node_config = NodeConfig.destroy(params[:id])\n xml=@node_config.to_xml\n json=@node_config.to_json\n @node_config.destroy\n\n respond_to do |format|\n format.html { redirect_to(node_configs_url) }\n format.json { render :json => json}\n format.xml { render :xml => xml}\n end\n end",
"def destroy\n @call_log = CallLog.find(params[:id])\n @call_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(call_logs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @snapshot.destroy\n\n respond_to do |format|\n format.html { redirect_to(snapshots_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @daily_statistic = DailyStatistic.find(params[:id])\n @daily_statistic.destroy\n\n head :no_content\n end",
"def destroy\n @update_log = UpdateLog.find(params[:id])\n @update_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(update_logs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @trace_exception.destroy\n respond_to do |format|\n format.html { redirect_to trace_exceptions_url, notice: 'Trace exception was successfully destroyed.' }\n format.json { head :no_content }\n end\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 delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @stat.destroy\n\n head :no_content\n end",
"def destroy\n @crawl_request = CrawlRequest.find(params[:id])\n @crawl_request.destroy\n\n head :no_content\n end",
"def destroy\n @crawl_request = CrawlRequest.find(params[:id])\n @crawl_request.destroy\n\n head :no_content\n end",
"def destroy\n @history_log = HistoryLog.find(params[:id])\n @history_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(history_logs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @t1 = T1.find(params[:id])\n @t1.destroy\n\n respond_to do |format|\n format.html { redirect_to(t1s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user_testcase_xref = UserTestcaseXref.find(params[:id])\n @user_testcase_xref.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_testcase_xrefs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @heartbeat.destroy\n\n head :no_content\n end",
"def destroy\n @dataset.destroy\n\n respond_to do |wants|\n wants.html { redirect_to(datasets_url) }\n wants.xml { head :ok }\n end\n end",
"def destroy\n @prd_threshold = PrdThreshold.find(params[:id])\n @prd_threshold.destroy\n\n respond_to do |format|\n format.html { redirect_to(prd_thresholds_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @visit = Visit.find(params[:id])\n @visit.destroy\n\n respond_to do |format|\n format.html { redirect_to(visits_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to(datasets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @server_rack = ServerRack.find(params[:id])\n @server_rack.destroy\n\n respond_to do |format|\n format.html { redirect_to(server_racks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @configattribincl.destroy\n respond_to do |format|\n format.html { redirect_to configattribs_path, notice: 'Configattribincl Threshold is reset to default.' }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @dataset = Dataset.find(params[:id])\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to(datasets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dataset = Dataset.find(params[:id])\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to(datasets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @traffic = Traffic.find(params[:id])\n @traffic.destroy\n\n respond_to do |format|\n format.html { redirect_to(traffics_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @estatu = Estatu.find(params[:id])\n @estatu.destroy\n\n respond_to do |format|\n format.html { redirect_to(estatus_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @heartbeat = Heartbeat.find(params[:id])\n @heartbeat.destroy\n\n respond_to do |format|\n format.html { redirect_to heartbeats_url }\n format.json { head :no_content }\n end\n end",
"def delete uri\n @change_semaphore.synchronize do\n filename = uri_to_file(uri)\n library.delete filename\n # Remove diagnostics for deleted files\n send_notification \"textDocument/publishDiagnostics\", {\n uri: uri,\n diagnostics: []\n }\n end\n end",
"def destroy\n @chart = Chart.find(params[:id])\n @chart.chartnodes.destroy_all\n @chart.destroy\n\n respond_to do |format|\n format.html { redirect_to charts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @flat_happening = FlatHappening.find(params[:id])\n @flat_happening.destroy\n\n head :no_content\n end",
"def destroy\n @aspect = Aspect.find(params[:id])\n @aspect.destroy\n\n respond_to do |format|\n format.html { redirect_to(aspects_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n status = @trace.destroy ? :ok : :bad_request\n\n render json: @trace, status: status\n end",
"def destroy\n @svg_file = Cmtool::SvgFile.find(params[:id])\n @svg_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(cmtool.svg_files_url, notice: I18n.t('cmtool.action.destroy.successful', model: Cmtool::SvgFile.model_name.human)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dataset = Dataset.find(params[:id])\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to datasets_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @fixturestat = Fixturestat.find(params[:id])\n @fixturestat.destroy\n\n respond_to do |format|\n format.html { redirect_to fixturestats_url }\n format.json { head :no_content }\n end\n end",
"def destroy_rest\n @entry_instrument = EntryInstrument.find(params[:id])\n @entry_instrument.destroy\n\n respond_to do |format|\n format.html { redirect_to(entry_instruments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @monitor_record = MonitorRecord.find(params[:id])\n @monitor_record.destroy\n\n respond_to do |format|\n format.html { redirect_to(monitor_records_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @report2 = Report2.find(params[:id])\n @report2.destroy\n\n respond_to do |format|\n format.html { redirect_to(report2s_url) }\n format.xml { head :ok }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @inpatientdailyreport = Inpatientdailyreport.find(params[:id])\n @inpatientdailyreport.destroy\n\n respond_to do |format|\n format.html { redirect_to(inpatientdailyreports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @quote_audit = QuoteAudit.find(params[:id])\n @quote_audit.destroy\n\n respond_to do |format|\n format.html { redirect_to(quote_audits_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @activity = Activity.find(params[:id])\n @activity.destroy\n\n respond_to do |format|\n format.html { redirect_to :action => :plan_chart }\n format.xml { head :ok }\n end\n end",
"def destroy\n @visit.destroy\n\n head :no_content\n end",
"def destroy\n @analysis = Analysis.find(params[:id])\n @analysis.destroy\n\n respond_to do |format|\n format.html { redirect_to(analyses_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @analysis = Analysis.find(params[:id])\n @analysis.destroy\n\n respond_to do |format|\n format.html { redirect_to(analyses_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tagline = Tagline.find(params[:id])\n @tagline.destroy\n\n respond_to do |format|\n format.html { redirect_to(taglines_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @chart = Chart.find(params[:id])\n @chart.destroy\n\n respond_to do |format|\n format.html { redirect_to(charts_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @markup = Markup.find(params[:id])\n @markup.destroy\n\n respond_to do |format|\n format.html { redirect_to [@parent, :markups] }\n format.xml { head :ok }\n end\n end",
"def destroy\n @segmento = Segmento.find(params[:id])\n @segmento.destroy\n\n respond_to do |format|\n format.html { redirect_to(segmentos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @threat = Threat.find(params[:id])\n @threat.destroy\n\n respond_to do |format|\n format.html { redirect_to(threats_url) }\n format.xml { head :ok }\n end\n end"
] | [
"0.70515364",
"0.63895845",
"0.60920775",
"0.60506153",
"0.60361624",
"0.60091126",
"0.59992844",
"0.59912455",
"0.5844168",
"0.58360606",
"0.57954866",
"0.5791484",
"0.57795537",
"0.57717574",
"0.5738916",
"0.57241696",
"0.57216364",
"0.5721081",
"0.5709976",
"0.56974405",
"0.5695659",
"0.5686697",
"0.5683044",
"0.56823653",
"0.5668881",
"0.5668881",
"0.56679374",
"0.56633455",
"0.56578034",
"0.56566584",
"0.5652688",
"0.5646921",
"0.5644381",
"0.56362927",
"0.56299025",
"0.5626709",
"0.56258005",
"0.5623102",
"0.56229407",
"0.56172585",
"0.5615493",
"0.5614462",
"0.56121236",
"0.5600355",
"0.5595009",
"0.55891675",
"0.55879575",
"0.5584889",
"0.5581637",
"0.55744374",
"0.5574207",
"0.5572651",
"0.55698735",
"0.55680907",
"0.5562549",
"0.5562374",
"0.5561445",
"0.5560221",
"0.5560221",
"0.555762",
"0.5556378",
"0.55545497",
"0.55531895",
"0.5552821",
"0.5545665",
"0.55415374",
"0.5540057",
"0.5539151",
"0.55368924",
"0.55346215",
"0.55336326",
"0.55336326",
"0.5533369",
"0.553234",
"0.5518054",
"0.55131125",
"0.5511071",
"0.5506174",
"0.5505571",
"0.55019754",
"0.54972225",
"0.54861134",
"0.54850763",
"0.548451",
"0.5482048",
"0.54794294",
"0.54687756",
"0.54672873",
"0.5467117",
"0.5465165",
"0.5462946",
"0.54554623",
"0.54554623",
"0.54539657",
"0.5450846",
"0.5448744",
"0.54446673",
"0.5442531",
"0.54422885"
] | 0.71903116 | 1 |
GET /studenttests GET /studenttests.json | def index
@studenttests = Studenttest.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @student_test = StudentTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_test }\n end\n end",
"def my_students(query={})\n self.simple_client.get(\"/api/v1/students?#{query.to_query}\")\n end",
"def index\n @students = Student.all\n render json: @students\n end",
"def index\n render status: :ok, json: @tests\n end",
"def get_student\n @student = Student.find(params[:std_id])\n render json: @student\n end",
"def get_students\n @course = Course.find(params[:course_id])\n\n render json: @course.students\n end",
"def index\n puts render json: @user.students, each_serializer: UserSerializer\n end",
"def new\n @student_test = StudentTest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student_test }\n end\n end",
"def listing\n tests = Test.where( user_id: test_params[:user_id] )\n all = TestSerializer.new.all_test(tests)\n return render json: all.as_json\n end",
"def show\n render json: @student\n end",
"def school_students(query={})\n self.simple_client.get(\"/api/v1/schools/my/students?#{query.to_query}\")\n end",
"def index\n @students = Student.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @students }\n end\n end",
"def index\n @students = Student.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @students }\n end\n end",
"def index\n @students = Student.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @students }\n end\n end",
"def index\n @student_entities = StudentEntity.all\n render json: @student_entities, status: :ok\n end",
"def index\n @tests = Test.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tests }\n end\n end",
"def index\n @students = Student.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @students }\n end\n end",
"def index\n @students = Student.all\n respond_to do |format|\n\t\t\tformat.html { render :index }\n\t\t\tformat.json { render json: Oj.dump(@students) }\n\t\tend\n end",
"def show\n @assessment_practice_test = AssessmentPracticeTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json:@assessment_practice_test }\n end\n end",
"def index\n @software_tests = SoftwareTest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @software_tests }\n end\n end",
"def index\n @student_profiles = StudentProfile.all \n render json: @student_profiles\n end",
"def index\n render status: :ok, json: @test_guide_scenarios\n end",
"def index\n @assessment_practice_tests = AssessmentPracticeTest.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@assessment_practice_tests }\n end\n end",
"def test\n get(\"/help/test.json\")\n end",
"def test\n get(\"/help/test.json\")\n end",
"def index\n @online_students = OnlineStudent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @online_students }\n end\n end",
"def index\n render status: :ok, json: @test_guide_scenario_sas\n end",
"def index\n @students = current_user.groups[0].students\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @students }\n end\n end",
"def index\n json = HTTParty.get(\"https://api.typeform.com/v1/form/WaIffL?key=f486f2db8f1249c077a08b582bc3efe0a2617668\").body\n\n @jsontests = JSON.parse(json)\n\n end",
"def show\n @student = User.find params[:id]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @student }\n end\n end",
"def set_test\n @tests = Test.by_student_id params[:student_id]\n end",
"def index\n\n @dtests = Dtest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dtests }\n end\n end",
"def show\n @test_suite = TestSuite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_suite }\n end\n end",
"def index\n @assessment_insti_tests = AssessmentInstiTest.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@assessment_insti_tests }\n end\n end",
"def test_get_skills_route\n render :json => get_profile_skills_for_profile(\"https://www.linkedin.com/in/marissamayer\").to_json\n end",
"def students\n student_size = User.all.length\n current_offset = (params[:payload][:pagenumber] - 1)*10\n direction = params[:payload][:direction]\n\n respond_to do |format|\n format.json {\n if current_offset + direction < student_size && current_offset + direction >= 0\n offset = current_offset + direction\n @students = User.all.offset(offset).take(10) \n render :json => @students\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n\tend",
"def students\n @course = Course.find(params[:id])\n\t\t@students = @course.students\n\t\t@other_students = Student.find(:all, :conditions => [\"id not in (select student_id from courses_students where course_id=?)\", @course.id])\n\n respond_to do |format|\n format.html # students.html.erb\n format.json { render :json => @students }\n end\n end",
"def sample_students_json\n raise Exceptions::EducatorNotAuthorized unless current_educator.can_set_districtwide_access?\n\n seed = params.fetch(:seed, '42').to_i\n n = params.fetch(:n, '40').to_i\n authorized_sample_students = authorized do\n Student.active.sample(n, random: Random.new(seed))\n end\n sample_students_json = authorized_sample_students.as_json({\n only: [:id, :grade, :first_name, :last_name],\n include: {\n school: {\n only: [:id, :name, :school_type]\n }\n }\n })\n render json: {\n sample_students: sample_students_json\n }\n end",
"def show\n respond_to do |format|\n format.json {\n\n @student = User.find_by_id(params[:id])\n\n if @student\n render :json => @student\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n end",
"def index\n @student_types = StudentType.all\n\n render json: @student_types\n end",
"def index\n @students = Student.all\n respond_to do |format|\n format.html\n format.json {render json: StudentsDatatable.new(view_context)}\n end\n end",
"def index\n if request.format == \"json\"\n @students = Student.all.order(:last_name)\n end\n end",
"def show\n student = Student.find(params[:id])\n render json: student\nend",
"def show\n @test_summary = TestSummary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_summary }\n end\n end",
"def index\n @title = \"Studies\"\n\n respond_to do |format|\n format.html do\n @my_studies = Study.with_user(current_user.netid)\n end\n format.json do\n render :json => Study.with_user(current_user.netid).to_json\n end\n end\n end",
"def index\n render json: @test_module.test_questions, status: :ok\n end",
"def index\n @student_sources = StudentSource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @student_sources }\n end\n end",
"def show\n @enrolled_student = EnrolledStudent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enrolled_student }\n end\n end",
"def index\n @testers = Tester.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @testers }\n end\n end",
"def index\n @students = Student.paginate(page: params[:page], per_page: 2)\n #respond_with(@students)\n respond_to do |format|\n format.json {render json: {\"students\": @students}}\n format.html #index.html.erb\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def index\n @tests = @subject.tests.all\n end",
"def show\n student = Student.find(params[:id])\n\n render json: {status: 'SUCCESS', message:\"Student listed with name #{student.name}\", data:student}, status: :ok\n end",
"def show\n @assessment_insti_test = AssessmentInstiTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json:@assessment_insti_test }\n end\n end",
"def show\n @section_test = SectionTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section_test }\n end\n end",
"def index\n # We will be creating a new student object to use with Register URL form\n @student = Student.new \n @students = Student.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @urls }\n end\n end",
"def show\n @tester = Tester.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tester }\n end\n end",
"def index\n @dairy_plans = DairyPlan.where(:student_id => @student.id)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dairy_plans }\n end\n end",
"def show\n @student = Student.find(params[:id])\n @times = times\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n # @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n @software_test = SoftwareTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @software_test }\n end\n end",
"def show\n student = StudentEntity.find_by(id: params[:id])\n if student.present?\n render json: student, staus: :ok\n else\n render json: {msg: \"not found\"}, staus: :not_found\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @student }\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @student }\n end\n end",
"def show\n render status: :ok, json: @test_guide_scenario_sa\n end",
"def show\n @team_test = TeamTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team_test }\n end\n end",
"def show\n @student_user = StudentUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_user }\n end\n end",
"def index\n @testtests = Testtest.all\n end",
"def show\n @indexstudent = Indexstudent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indexstudent }\n end\n end",
"def test_student_locked_out\n # Index\n get_as @student, :index\n assert_response :missing\n\n # Edit\n get_as @student, :edit\n assert_response :missing\n\n # Update\n get_as @student, :update\n assert_response :missing\n\n # Create\n get_as @student, :create\n assert_response :missing\n\n # Download Student List\n get_as @student, :download_student_list\n assert_response :missing\n\n # Upload Student List (Get)\n get_as @student, :index\n assert_response :missing\n\n # Upload Student List (Post)\n post_as @student, :index\n assert_response :missing\n\n end",
"def index\n @test_stalls = TestStall.all\n end",
"def create\n @student_test = StudentTest.new(params[:student_test])\n\n respond_to do |format|\n if @student_test.save\n format.html { redirect_to @student_test, notice: 'Student test was successfully created.' }\n format.json { render json: @student_test, status: :created, location: @student_test }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n render json: @student_type\n end",
"def show\n render status: :ok, json: @test\n end",
"def index\n @studies = Study.all\n #render json: @studies\n end",
"def show\n @student_major = StudentMajor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_major }\n end\n end",
"def index\n @students = Student.all\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @students.pluck(:id, :firstname, :lastname) }\n end\n end",
"def student\n\n\t\tif(params[:student_user_id].eql?('null') || params[:classroom_id].eql?('null') )\n\t\t\trender json: {status: \"error\", error: \"invalid-student-user-or-classroom\"}\n\t\telse\n\t\t\tstudent = StudentUser.joins(:classrooms)\n\t\t\t\t.joins(\"inner join teacher_users t on classrooms.teacher_user_id = t.id\")\n\t\t\t\t.where(\"t.id = ?\", @current_teacher_user.id)\n\t\t\t\t.where(\"classrooms.id = ?\", params[:classroom_id])\n\t\t\t\t.where(\"student_users.id = ?\" , params[:student_user_id])\n\t\t\t\t.first\n\n\t\t\tif(!student.nil?)\n\t\t\t\tstudent = student.as_json\n\t\t\t\tstudent.delete(\"salt\")\n\t\t student.delete(\"password_digest\")\n\t\t student.delete(\"oauth_expires_at\")\n\t\t student.delete(\"oauth_token\")\n\t\t student.delete(\"updated_at\")\n\t\t student.delete(\"create_at\")\n\n\t\t\t\trender json: {status: \"success\", student: student}\n\t\t\t\n\t\t\telse\n\n\t\t\t\trender json: {status: \"error\", error: \"invalid-student-user-or-classroom\"}\n\n\t\t\tend\n\t\tend\n\t\t\n\t\t\n\tend",
"def index\n @user_tests = UserTest.all\n end",
"def show\n render status: :ok, json: @test_guide_scenario\n end",
"def show\n @course = Course.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n student = Student.find(params[:id])\n render json: { status: '200', message: \"Loaded Student with id #{params[:id]}\", data: student }, status: :ok\n rescue ActiveRecord::RecordNotFound\n render json: { status: '404', error: \"No Student with id #{params[:id]}\", data: student }, status: :not_found\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 @subject_class = @test.subject_class\n @students = @test.subject_class.students.order(:name)\n @test_questions = @test.test_questions\n @test_question = TestQuestion.new\n @test_question.test_id = @test.id\n end",
"def show\n @testcase = Testcase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @testcase }\n end\n end",
"def show\n respond_to do |format|\n format.html\n format.json {render json: @student, serializer: StudentSerializer, include: '**'}\n end\n end",
"def show\n @test_result = TestResult.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_result }\n end\n end",
"def search\n results = @test.search(test_params)\n return render json: {results: results, total: results.total_entries}\n end",
"def index\n @employer_studies = @university.employer_studies.page(params[:page])\n @studies = @employer_studies\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employer_studies }\n end\n end",
"def set_studenttest\n @studenttest = Studenttest.find(params[:id])\n end",
"def index\n permitted_to! :inspect, Problem.find(params[:problem_id])\n @test_sets = TestSet.where(:problem_id => params[:problem_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @test_sets }\n end\n end",
"def show\n @online_student = OnlineStudent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @online_student }\n end\n end",
"def index\n @user = User.find(session[:user_id])\n @schools = @user.schools\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @schools }\n end\n end"
] | [
"0.7342745",
"0.6774699",
"0.6741088",
"0.67029816",
"0.66744035",
"0.66239357",
"0.65891767",
"0.6573441",
"0.65558666",
"0.6547281",
"0.64935964",
"0.64917266",
"0.64917266",
"0.64890325",
"0.64645094",
"0.64582145",
"0.6453144",
"0.634893",
"0.632752",
"0.6314565",
"0.6306",
"0.62763155",
"0.6253224",
"0.6240134",
"0.6240134",
"0.6224529",
"0.6181731",
"0.61735624",
"0.61691964",
"0.61653197",
"0.6131852",
"0.61259276",
"0.61106116",
"0.6103687",
"0.6095011",
"0.6094484",
"0.60929805",
"0.60893065",
"0.6074361",
"0.60724163",
"0.60717976",
"0.60690814",
"0.60555357",
"0.6055031",
"0.60493225",
"0.60477257",
"0.60370344",
"0.60362977",
"0.60307235",
"0.60227174",
"0.60205525",
"0.60205525",
"0.60205525",
"0.60205525",
"0.60205525",
"0.60205525",
"0.60205525",
"0.60205525",
"0.6017609",
"0.60168755",
"0.60133827",
"0.60124594",
"0.6001167",
"0.59999377",
"0.59988976",
"0.5992207",
"0.5985746",
"0.5980154",
"0.5972651",
"0.59653234",
"0.59653234",
"0.5962731",
"0.59458476",
"0.594243",
"0.59421897",
"0.5936533",
"0.5930525",
"0.59242815",
"0.5923379",
"0.59177196",
"0.59075606",
"0.5904705",
"0.5903475",
"0.59022975",
"0.5900715",
"0.5892382",
"0.58899593",
"0.5888678",
"0.58788073",
"0.5873814",
"0.58566904",
"0.58514297",
"0.5844226",
"0.58399445",
"0.5839325",
"0.58353025",
"0.5833822",
"0.58333945",
"0.5833344",
"0.5832012"
] | 0.7141873 | 1 |
GET /studenttests/1 GET /studenttests/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @student_test = StudentTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_test }\n end\n end",
"def get_student\n @student = Student.find(params[:std_id])\n render json: @student\n end",
"def index\n @studenttests = Studenttest.all\n end",
"def new\n @student_test = StudentTest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student_test }\n end\n end",
"def index\n @students = Student.all\n render json: @students\n end",
"def my_students(query={})\n self.simple_client.get(\"/api/v1/students?#{query.to_query}\")\n end",
"def index\n render status: :ok, json: @tests\n end",
"def show\n @assessment_practice_test = AssessmentPracticeTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json:@assessment_practice_test }\n end\n end",
"def show\n render json: @student\n end",
"def get_students\n @course = Course.find(params[:course_id])\n\n render json: @course.students\n end",
"def index\n @tests = Test.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tests }\n end\n end",
"def index\n puts render json: @user.students, each_serializer: UserSerializer\n end",
"def show\n @test_summary = TestSummary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_summary }\n end\n end",
"def index\n @students = Student.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @students }\n end\n end",
"def index\n @students = Student.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @students }\n end\n end",
"def index\n @students = Student.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @students }\n end\n end",
"def listing\n tests = Test.where( user_id: test_params[:user_id] )\n all = TestSerializer.new.all_test(tests)\n return render json: all.as_json\n end",
"def show\n @test_suite = TestSuite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_suite }\n end\n end",
"def index\n @students = Student.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @students }\n end\n end",
"def show\n student = Student.find(params[:id])\n render json: student\nend",
"def show\n @student = User.find params[:id]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @student }\n end\n end",
"def index\n @assessment_practice_tests = AssessmentPracticeTest.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@assessment_practice_tests }\n end\n end",
"def show\n @testcase = Testcase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @testcase }\n end\n end",
"def show\n @assessment_insti_test = AssessmentInstiTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json:@assessment_insti_test }\n end\n end",
"def get_one\n test_data = @test.get_one\n return render json: test_data\n end",
"def show\n @tester = Tester.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tester }\n end\n end",
"def show\n @section_test = SectionTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section_test }\n end\n end",
"def show\n respond_to do |format|\n format.json {\n\n @student = User.find_by_id(params[:id])\n\n if @student\n render :json => @student\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n end",
"def show\n @indexstudent = Indexstudent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indexstudent }\n end\n end",
"def show\n @test = Test.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test }\n end\n end",
"def index\n @student_entities = StudentEntity.all\n render json: @student_entities, status: :ok\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n @test = LoadTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test }\n end\n end",
"def index\n @student_profiles = StudentProfile.all \n render json: @student_profiles\n end",
"def show\n @student = Student.find(params[:id])\n @times = times\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n @test_result = TestResult.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_result }\n end\n end",
"def index\n @assessment_insti_tests = AssessmentInstiTest.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@assessment_insti_tests }\n end\n end",
"def school_students(query={})\n self.simple_client.get(\"/api/v1/schools/my/students?#{query.to_query}\")\n end",
"def show\n # @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def index\n @software_tests = SoftwareTest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @software_tests }\n end\n end",
"def show\n student = Student.find(params[:id])\n\n render json: {status: 'SUCCESS', message:\"Student listed with name #{student.name}\", data:student}, status: :ok\n end",
"def show\n @software_test = SoftwareTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @software_test }\n end\n end",
"def show\r\n @student1 = Student1.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @student1 }\r\n end\r\n end",
"def test\n get(\"/help/test.json\")\n end",
"def test\n get(\"/help/test.json\")\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @student }\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @student }\n end\n end",
"def index\n json = HTTParty.get(\"https://api.typeform.com/v1/form/WaIffL?key=f486f2db8f1249c077a08b582bc3efe0a2617668\").body\n\n @jsontests = JSON.parse(json)\n\n end",
"def index\n @students = Student.all\n respond_to do |format|\n\t\t\tformat.html { render :index }\n\t\t\tformat.json { render json: Oj.dump(@students) }\n\t\tend\n end",
"def show\n @student_major = StudentMajor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_major }\n end\n end",
"def show\n @team_test = TeamTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team_test }\n end\n end",
"def index\n render status: :ok, json: @test_guide_scenarios\n end",
"def show\n student = Student.find(params[:id])\n render json: { status: '200', message: \"Loaded Student with id #{params[:id]}\", data: student }, status: :ok\n rescue ActiveRecord::RecordNotFound\n render json: { status: '404', error: \"No Student with id #{params[:id]}\", data: student }, status: :not_found\n end",
"def index\n render status: :ok, json: @test_guide_scenario_sas\n end",
"def show\n student = StudentEntity.find_by(id: params[:id])\n if student.present?\n render json: student, staus: :ok\n else\n render json: {msg: \"not found\"}, staus: :not_found\n end\n end",
"def show\n @study = Study.find(params[:id])\n render json: @study\n end",
"def show\n @test_run = TestRun.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_run }\n end\n end",
"def set_test\n @tests = Test.by_student_id params[:student_id]\n end",
"def index\n\n @dtests = Dtest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dtests }\n end\n end",
"def show\n @usertest = Usertest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @usertest }\n end\n end",
"def show\n @enrolled_student = EnrolledStudent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enrolled_student }\n end\n end",
"def show\n @testis = Teste.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @testis }\n end\n end",
"def show\n @student_user = StudentUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_user }\n end\n end",
"def show\n @student = Student.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n \n \n format.json { render json: @student }\n end\n end",
"def show\n @course = Course.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def index\n permitted_to! :inspect, Problem.find(params[:problem_id])\n @test_sets = TestSet.where(:problem_id => params[:problem_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @test_sets }\n end\n end",
"def index\n @students = current_user.groups[0].students\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @students }\n end\n end",
"def show\n @studentset = Studentset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @studentset }\n end\n end",
"def index\n render json: @test_module.test_questions, status: :ok\n end",
"def show\n render status: :ok, json: @test\n end",
"def show\n render json: @student_type\n end",
"def index\n @title = \"Studies\"\n\n respond_to do |format|\n format.html do\n @my_studies = Study.with_user(current_user.netid)\n end\n format.json do\n render :json => Study.with_user(current_user.netid).to_json\n end\n end\n end",
"def show\n render status: :ok, json: @test_guide_scenario_sa\n end",
"def index\n @online_students = OnlineStudent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @online_students }\n end\n end",
"def index\n if request.format == \"json\"\n @students = Student.all.order(:last_name)\n end\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 index\n @students = Student.paginate(page: params[:page], per_page: 2)\n #respond_with(@students)\n respond_to do |format|\n format.json {render json: {\"students\": @students}}\n format.html #index.html.erb\n end\n end",
"def show\n @test10 = Test10.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test10 }\n end\n end",
"def index\n @student_types = StudentType.all\n\n render json: @student_types\n end",
"def index\n @testers = Tester.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @testers }\n end\n end",
"def show\n render json: @test\n end",
"def index\n @dairy_plans = DairyPlan.where(:student_id => @student.id)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dairy_plans }\n end\n end",
"def index\n @students = Student.all\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @students.pluck(:id, :firstname, :lastname) }\n end\n end",
"def index\n @students = Student.all\n respond_to do |format|\n format.html\n format.json {render json: StudentsDatatable.new(view_context)}\n end\n end",
"def index\n @studies = Study.all\n #render json: @studies\n end",
"def index\n @student_sources = StudentSource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @student_sources }\n end\n end",
"def index\n # We will be creating a new student object to use with Register URL form\n @student = Student.new \n @students = Student.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @urls }\n end\n end",
"def students\n student_size = User.all.length\n current_offset = (params[:payload][:pagenumber] - 1)*10\n direction = params[:payload][:direction]\n\n respond_to do |format|\n format.json {\n if current_offset + direction < student_size && current_offset + direction >= 0\n offset = current_offset + direction\n @students = User.all.offset(offset).take(10) \n render :json => @students\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n\tend",
"def student_show\n @course = Course.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n \n end",
"def show\n render status: :ok, json: @test_guide_scenario\n end",
"def show\n @studentgrade = Studentgrade.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @studentgrade }\n end\n end",
"def show\n @student_sub_course = StudentSubCourse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_sub_course }\n end\n end",
"def show\n @subject_class = @test.subject_class\n @students = @test.subject_class.students.order(:name)\n @test_questions = @test.test_questions\n @test_question = TestQuestion.new\n @test_question.test_id = @test.id\n end",
"def show\n respond_to do |format|\n format.html\n format.json {render json: @student, serializer: StudentSerializer, include: '**'}\n end\n end"
] | [
"0.75577104",
"0.69995546",
"0.69687235",
"0.6698824",
"0.6685507",
"0.66854626",
"0.6656588",
"0.6654055",
"0.659521",
"0.65585995",
"0.6549385",
"0.6519743",
"0.6498389",
"0.6468148",
"0.6468148",
"0.64577466",
"0.64571905",
"0.6453235",
"0.6426115",
"0.64200556",
"0.6395126",
"0.6394051",
"0.6393142",
"0.639122",
"0.6386457",
"0.63511324",
"0.6335006",
"0.6327659",
"0.6320953",
"0.63192314",
"0.6316262",
"0.6296241",
"0.6296241",
"0.6296241",
"0.6296241",
"0.6296241",
"0.6296241",
"0.6296241",
"0.6296241",
"0.62903684",
"0.62889785",
"0.6288332",
"0.62857336",
"0.62784594",
"0.62773746",
"0.62710035",
"0.62691194",
"0.62669945",
"0.62607014",
"0.62429273",
"0.6242925",
"0.6242925",
"0.6238167",
"0.6238167",
"0.6215584",
"0.6213816",
"0.62056273",
"0.6200825",
"0.61949",
"0.6189329",
"0.61882937",
"0.6185811",
"0.61772156",
"0.6168348",
"0.61498064",
"0.6149506",
"0.614081",
"0.6133291",
"0.61247534",
"0.61156064",
"0.6114884",
"0.61118746",
"0.61040795",
"0.6101897",
"0.6088792",
"0.608858",
"0.60853815",
"0.6084663",
"0.6083827",
"0.6077128",
"0.60768765",
"0.60709196",
"0.606883",
"0.606669",
"0.6064963",
"0.60605603",
"0.604957",
"0.6036308",
"0.6035065",
"0.60255885",
"0.6024394",
"0.6023226",
"0.6007911",
"0.5994956",
"0.5994219",
"0.5991739",
"0.59901553",
"0.5989191",
"0.5985202",
"0.59824556",
"0.59728175"
] | 0.0 | -1 |
POST /studenttests POST /studenttests.json | def create
@studenttest = Studenttest.new(studenttest_params)
respond_to do |format|
if @studenttest.save
format.html { redirect_to @studenttest, notice: 'Studenttest was successfully created.' }
format.json { render :show, status: :created, location: @studenttest }
else
format.html { render :new }
format.json { render json: @studenttest.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @student_test = StudentTest.new(params[:student_test])\n\n respond_to do |format|\n if @student_test.save\n format.html { redirect_to @student_test, notice: 'Student test was successfully created.' }\n format.json { render json: @student_test, status: :created, location: @student_test }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_params\n params.permit(:test_name, :date, :grade, :student_id)\n end",
"def test_params\n params.permit(:id, :student_id)\n end",
"def create\n @test = Test.new(test_params)\n if @test.is_online \n @test.status = \"Not Started\" \n else\n @test.status = \"Ended\" \n end\n respond_to do |format|\n if @test.save \n\n @students = @test.subject_class.students #create student test result and set to zero to be edited by instructor\n \n @students.each do |student|\n result = TestResult.new(test_id: @test.id, student_id: student.id, score: 0, status: TestResult::STATUS_LIST[0], last_time_online: Date.today, time_finished: Date.today, reason: TestResult::REASON_LIST[3])\n if result.save\n puts \"==============================================\"\n puts \"test result created\"\n puts \"==============================================\"\n else\n puts \"==============================================\"\n puts result.errors.full_messages\n puts \"==============================================\"\n \n end\n \n \n end \n\n format.html { redirect_to @test, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @student_test = StudentTest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @student_test }\n end\n end",
"def v2_tests_post(test_detail, opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: TestsApi#v2_tests_post ...\"\n end\n \n # verify the required parameter 'test_detail' is set\n fail \"Missing the required parameter 'test_detail' when calling v2_tests_post\" if test_detail.nil?\n \n # resource path\n path = \"/v2/tests\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json', 'text/json', 'application/xml', 'text/xml']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(test_detail)\n \n\n auth_names = []\n result = @api_client.call_api(:POST, 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 => 'TestSummary')\n if Configuration.debugging\n Configuration.logger.debug \"API called: TestsApi#v2_tests_post. Result: #{result.inspect}\"\n end\n return result\n end",
"def create\n @student = Student.new(student_params)\n\n if @student.save\n render json: @student, status: :created\n else\n render json: @student.errors, status: :unprocessable_entity\n end\n end",
"def create\n @test = Test.create!(test_params)\n\n render json: @test\n end",
"def studenttest_params\n params.require(:studenttest).permit(:name, :lastname, :birthday)\n end",
"def create\n @testsuite = Testsuite.new(testsuite_params)\n\n respond_to do |format|\n if @testsuite.save\n format.html { redirect_to @testsuite, notice: 'Testsuite was successfully created.' }\n format.json { render :show, status: :created, location: @testsuite }\n else\n format.html { render :new }\n format.json { render json: @testsuite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @testtest = Testtest.new(testtest_params)\n\n respond_to do |format|\n if @testtest.save\n format.html { redirect_to @testtest, notice: 'Testtest was successfully created.' }\n format.json { render :show, status: :created, location: @testtest }\n else\n format.html { render :new }\n format.json { render json: @testtest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @studenttests = Studenttest.all\n end",
"def create\n course = Course.find(params[:course_id])\n student = Student.find_by(dni: params[:student_id])\n @enroll = Enroll.new( student: student, course: course)\n TestCourse.of(course).each do |tc|\n Score.create( student: student, test_id: tc.test_id, value: -2)\n end\n \n respond_to do |format|\n if @enroll.save\n format.html { redirect_to course_enrolls_path(course), notice: 'Enroll was successfully created.' }\n format.json { render :show, status: :created, location: course_enrolls_path(course) }\n else\n format.html { render :new }\n format.json { render json: @enroll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test = current_user.tests.build(test_params)\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to thank_you_path, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_test\n @tests = Test.by_student_id params[:student_id]\n end",
"def create\n @user_test = UserTest.new(user_test_params)\n\n respond_to do |format|\n if @user_test.save\n format.html { redirect_to admin_user_tests_path, notice: 'User test was successfully created.' }\n format.json { render :show, status: :created, location: @user_test }\n else\n format.html { render :new }\n format.json { render json: @user_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test = @subject.tests.new(params[:test])\n if @test.save\n redirect_to user_subject_tests_path\n else\n render :action => \"new\"\n end\n end",
"def create\n @test_detail = TestDetail.new(test_detail_params)\n\n respond_to do |format|\n if @test_detail.save\n format.html { redirect_to @test_detail, notice: 'Test detail was successfully created.' }\n format.json { render :show, status: :created, location: @test_detail }\n else\n format.html { render :new }\n format.json { render json: @test_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @jsontest = Jsontest.new(jsontest_params)\n\n respond_to do |format|\n if @jsontest.save\n format.html { redirect_to @jsontest, notice: 'Jsontest was successfully created.' }\n format.json { render :show, status: :created, location: @jsontest }\n else\n format.html { render :new }\n format.json { render json: @jsontest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test = Test.new(test_params)\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to @test, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test = Test.new(test_params)\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to @test, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test = Test.new(test_params)\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to @test, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test = Test.new(test_params)\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to @test, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test = Test.new(test_params)\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to @test, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test = Test.new(test_params)\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to @test, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @smoke_test = SmokeTest.new(params[:smoke_test])\n\n respond_to do |format|\n if @smoke_test.save\n format.html { redirect_to(@smoke_test, :notice => 'Smoke test was successfully created.') }\n format.json { render :json => @smoke_test, :status => :created, :location => @smoke_test }\n format.xml { render :xml => @smoke_test, :status => :created, :location => @smoke_test }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @smoke_test.errors, :status => :unprocessable_entity }\n format.xml { render :xml => @smoke_test.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n if @student.save\n render :show, status: :created, location: @student\n else\n render json: @student.errors, status: :unprocessable_entity\n end\n end",
"def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, :notice => 'Student was successfully created.' }\n format.json { render :json => @student, :status => :created, :location => @student }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @student.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, :notice => 'Student was successfully created.' }\n format.json { render :json => @student, :status => :created, :location => @student }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @student.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end",
"def create\n @testcase = Testcase.new(params[:testcase])\n\n respond_to do |format|\n if @testcase.save\n format.html { redirect_to @testcase, :notice => 'Test was successfully created.' }\n format.json { render :json => @testcase, :status => :created, :location => @test }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @testcase.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @test = Test.new(params[:test])\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to @test, notice: 'Test was successfully created.' }\n format.json { render json: @test, status: :created, location: @test }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n teacher_exclusive\n @test = Test.create title: params[:title], test_date: params[:test_date], subject_id: params[:subject_id],teacher_id: @current_user.id\n\n respond_to do |format|\n if @test.save\n format.html { redirect_to @test, notice: \"L'épreuve a été créée\"}\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to root_path, notice: 'Student details were successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test_suite = TestSuite.new(params[:test_suite])\n\n respond_to do |format|\n if @test_suite.save\n format.html { redirect_to @test_suite, notice: 'Test suite was successfully created.' }\n format.json { render json: @test_suite, status: :created, location: @test_suite }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test_suite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @section_test = SectionTest.new(params[:section_test])\n\n respond_to do |format|\n if @section_test.save\n format.html { redirect_to @section_test, notice: 'Section test was successfully created.' }\n format.json { render json: @section_test, status: :created, location: @section_test }\n else\n format.html { render action: \"new\" }\n format.json { render json: @section_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_post_success_with_param\n post \"/\", {:data => @test_obj} do |response|\n assert response.ok?, \"Create test object failed\"\n assert_equal response.body, @test_obj.to_json, \"Did not get @test_obj back\"\n end\n end",
"def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = current_user.students.create(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Registro Exitoso.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test_suite = TestSuite.new(test_suite_params)\n\n respond_to do |format|\n if @test_suite.save\n format.html { redirect_to @test_suite, notice: 'Test suite was successfully created.' }\n format.json { render :show, status: :created, location: @test_suite }\n else\n format.html { render :new }\n format.json { render json: @test_suite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: \"Student was successfully created.\" }\n format.json { render json :show, status: :created, location: @student }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_suite_params\n params.require(:test_suite).permit(:student_id, :testing_id, :started_at, :finished_at)\n end",
"def create\n # @student = Student.new(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @software_test = SoftwareTest.new(params[:software_test])\n\n respond_to do |format|\n if @software_test.save\n format.html { redirect_to @software_test, notice: 'Software test was successfully created.' }\n format.json { render json: @software_test, status: :created, location: @software_test }\n else\n format.html { render action: \"new\" }\n format.json { render json: @software_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @usertest = Usertest.new(params[:usertest])\n\n respond_to do |format|\n if @usertest.save\n format.html { redirect_to @usertest, notice: 'Usertest was successfully created.' }\n format.json { render json: @usertest, status: :created, location: @usertest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @usertest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = current_user.students.build(params[:student])\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to root_url, notice: 'Student was successfully created.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @enrolled_student = EnrolledStudent.new(params[:enrolled_student])\n\n respond_to do |format|\n if @enrolled_student.save\n format.html { redirect_to @enrolled_student, notice: 'Enrolled student was successfully created.' }\n format.json { render json: @enrolled_student, status: :created, location: @enrolled_student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @enrolled_student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @studanswer = Studanswer.new(studanswer_params)\n\n respond_to do |format|\n if @studanswer.save\n format.html { redirect_to @studanswer, notice: 'Studanswer was successfully created.' }\n format.json { render :show, status: :created, location: @studanswer }\n else\n format.html { render :new }\n format.json { render json: @studanswer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ststu = Ststu.new(ststu_params)\n\n respond_to do |format|\n if @ststu.save\n format.html { redirect_to @ststu, notice: 'Ststu was successfully created.' }\n format.json { render :show, status: :created, location: @ststu }\n else\n format.html { render :new }\n format.json { render json: @ststu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student,\n notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors,\n status: :unprocessable_entity }\n end\n end\n end",
"def create\n @class_test = ClassTest.new(class_test_params)\n @class_test.school_branch = current_school_branch\n @class_test.creator = current_teacher || current_entity\n\n respond_to do |format|\n if @class_test.save\n format.html { redirect_to @class_test, notice: 'Class test was successfully created.' }\n format.json { render :show, status: :created, location: @class_test }\n else\n format.html { render :new }\n format.json { render json: @class_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n unless current_user.instructor\n render :nothing => true, :status => :unauthorized\n end\n \n # create team\n team = Team.create(name: params[:team_name], course: $selected_course)\n\n # add students to teams\n student_ids = params[:student_ids]\n student_ids.each do |student_id|\n StudentTeam.create(student_id: student_id, team: team)\n end\n\n render json: { success: true }\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render action: 'show', status: :created, location: @student }\n else\n format.html { render action: 'new' }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render action: 'show', status: :created, location: @student }\n else\n format.html { render action: 'new' }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tp = params[:student]\n\t\thash = { :original_name => p['original_name'], :sort_name => Student.make_sort_name(p['original_name']), :other_name => p['other_name'],\n\t\t\t:gender => p['gender'] == 'Male' ? 'M' : 'F', :born => VagueDate.factory(p['born']).to_s, :died => VagueDate.factory(p['died']).to_s,\n\t\t\t:home_town => p['home_town']['town'], :home_state => p['home_town']['state'], :home_country => p['home_town']['country'],\n\t\t\t:biographical_notes => p['biographical_notes'], :quotes => p['quotes'], :additional_notes => p['additional_notes'], :private_notes => p['private_notes'], :is_stub => 0\n\t\t}\n\n\t\t@student = Student.new(hash)\n\t\t@student.generate_unique_name()\n\n\t\trespond_to do |format|\n\t\t\tif @student.save\n\t\t\t\tmarriages = parse_array(p['marriage'])\n\t\t\t\tmarriages.each {|marriage|\n\t\t\t\t\tif !marriage['name'].blank?\n\t\t\t\t\t\tMarriage.create_marriage(@student, { :name => marriage['name'] }, marriage['date'])\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\t\tresidences = parse_array(p['residence'])\n\t\t\t\tresidences.each {|residence|\n\t\t\t\t\tif !residence.blank?\n\t\t\t\t\t\tStudentResidence.create_residence(@student, residence)\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\t\tBrowse.student_changed(@student, nil)\n\t\t\t\tsolr().add_object(@student.to_solr())\n\n\t\t\t\tformat.html { redirect_to(@student, :notice => 'The student was successfully created.') }\n\t\t\telse\n\t\t\t\tformat.html {\n\t\t\t\t\t@page_title = 'Student'\n\t\t\t\t\tnew_setup()\n\t\t\t\t\trender :action => \"new\"\n\t\t\t\t}\n\t\t\tend\n\t\tend\n\tend",
"def test_params\n params.require(:test).permit(:name, :date, :teacher_id)\n end",
"def create\n @student = Student.find(params[:student_id])\n @inschool = @student.inschools.create(params[:inschool])\n\n respond_to do |format|\n if @inschool.save\n StudentMailer.mailer_inschool(@student, @inschool).deliver\n format.html { redirect_to :back, notice: 'Inschool was successfully created and an email sent was sent to the teacher.' }\n format.json { render json: @inschool, status: :created, location: @inschool }\n else\n format.html { render action: \"new\" }\n format.json { render json: @inschool.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student_entity = StudentEntity.new(student_entity_params)\n\n respond_to do |format|\n if @student_entity.save\n format.json { render :show, status: :created, location: @student_entity }\n else\n format.json { render json: @student_entity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = current_user.students.build(student_params)\n @student.status = 'imcomplete'\n respond_to do |format|\n if @student.save\n format.html { redirect_to students_url, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.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 create\n validate_student(student_params)\n begin\n student = Student.create!(student_params)\n\n render json: {status: 'SUCCESS', message:\"Student registered Successfully with name #{student.name}\", data:student.reload}, status: :ok\n rescue => error\n render json: {message: error}\n end\n end",
"def create\n result = Test.new.create_test(test_params)\n if result\n return render json: {message: 'Test was created succesfully', error: false }\n else\n return render json: {message: 'Error: Test was not created succesfully', error: true }\n end\n end",
"def create\n\n @student_instrument = StudentInstrument.new(params[:student_instrument])\n\n @student = Student.find(params[:student_instrument][:student_id])\n\n respond_to do |format|\n if @student_instrument.save\n format.html { redirect_to @student, notice: 'Instrument was successfully added.' }\n format.json { render json: @student, status: :created, location: @student }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @indexstudent = Indexstudent.new(params[:indexstudent])\n\n respond_to do |format|\n if @indexstudent.save\n format.html { redirect_to @indexstudent, notice: 'Indexstudent was successfully created.' }\n format.json { render json: @indexstudent, status: :created, location: @indexstudent }\n else\n format.html { render action: \"new\" }\n format.json { render json: @indexstudent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @applicant_test = @applicant.applicant_tests.new(applicant_test_params)\n\n respond_to do |format|\n if @applicant_test.save\n format.html { redirect_to applicant_url(@applicant), notice: \"Test Agregado Correctamente.\" }\n format.json { render :show, status: :created, location: applicant_url(@applicant) }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @applicant_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @studen = Studen.new(studen_params)\n\n respond_to do |format|\n if @studen.save\n format.html { redirect_to @studen, notice: 'Studen was successfully created.' }\n format.json { render :show, status: :created, location: @studen }\n else\n format.html { render :new }\n format.json { render json: @studen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test_datum = TestDatum.new(test_datum_params)\n\n respond_to do |format|\n if @test_datum.save\n format.html { redirect_to @test_datum, notice: 'Test datum was successfully created.' }\n format.json { render :show, status: :created, location: @test_datum }\n else\n format.html { render :new }\n format.json { render json: @test_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @studentgrade = Studentgrade.new(params[:student])\n\n respond_to do |format|\n if @studentgrade.save\n format.html { redirect_to @studentgrade, notice: 'Student was successfully created.' }\n format.json { render json: @studentgrade, status: :created, location: @studentgrade }\n else\n format.html { render action: \"new\" }\n format.json { render json: @studentgrade.errors, status: :unprocessable_entity }\n end\n end\n end",
"def testing_params\n params.require(:testing).permit(:student_id, :test_id, :percent_Right, :num_of_right_options, :num_of_quest,\n assem_questions_attributes: [:id, :quest_body, :right, assem_answers_attributes: [\n :id, :ans_body, :right, :weight\n ], assem_options_attributes: [\n :id, :ans_body, :right, :weight, :student_id\n ]])\n end",
"def create\n @manage_student = Manage::Student.new(manage_student_params)\n\n respond_to do |format|\n if @manage_student.save\n format.html { redirect_to @manage_student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @manage_student }\n else\n format.html { render :new }\n format.json { render json: @manage_student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_studenttest\n @studenttest = Studenttest.find(params[:id])\n end",
"def destroy\n @student_test = StudentTest.find(params[:id])\n @student_test.destroy\n\n respond_to do |format|\n format.html { redirect_to student_tests_url }\n format.json { head :ok }\n end\n end",
"def create\n @performance_test = PerformanceTest.new(params[:performance_test])\n\n respond_to do |format|\n if @performance_test.save\n format.html { redirect_to @performance_test, :notice => 'Performance test was successfully created.' }\n format.json { render :json => @performance_test, :status => :created, :location => @performance_test }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @performance_test.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_student = Admin::Student.new(admin_student_params)\n\n respond_to do |format|\n if @admin_student.save\n format.html { redirect_to @admin_student, notice: \"Student was successfully created.\" }\n format.json { render :show, status: :created, location: @admin_student }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @admin_student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = @school.students.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to manage_school_school_path(@school), notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def testing_params\n params.require(:testing).permit(:requiredtests, :name, :customer, :description, :supplier, :supplierrefferenceno, :leadtime, :testdate, :results, :retestdate, :reresults, :cost, :trackingsheet)\n end",
"def create\n @student = Student.new(student_params)\n @student.kundenstatus = 1\n @student.percentage = 1\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @student_test = StudentTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_test }\n end\n end",
"def create\n @medical_test = MedicalTest.new(medical_test_params)\n\n respond_to do |format|\n if @medical_test.save\n format.html { redirect_to @medical_test, notice: 'Medical test was successfully created.' }\n format.json { render :show, status: :created, location: @medical_test }\n else\n format.html { render :new }\n format.json { render json: @medical_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @exam_student = ExamStudent.new\n if params[:user_id]\n @exam_student.user_id = params[:user_id]\n end\n if params[:exam_id]\n @exam_student.exam_id = params[:exam_id]\n end\n if params[:status]\n @exam_student.status = params[:status]\n end\n\n respond_to do |format|\n if @exam_student.save\n format.html { redirect_to exams_url, notice: 'Prijavili ste ispit.' }\n format.json { render :show, status: :created, location: @exam_student }\n else\n format.html { render :new }\n format.json { render json: @exam_student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test10 = Test10.new(params[:test10])\n\n respond_to do |format|\n if @test10.save\n format.html { redirect_to @test10, notice: 'Test10 was successfully created.' }\n format.json { render json: @test10, status: :created, location: @test10 }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test10.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.7313287",
"0.65778613",
"0.64818156",
"0.6481537",
"0.637193",
"0.6324752",
"0.63236153",
"0.6302043",
"0.61968744",
"0.618197",
"0.6168903",
"0.6164026",
"0.61461747",
"0.61207753",
"0.6107524",
"0.6096397",
"0.6054729",
"0.603553",
"0.6033991",
"0.6025285",
"0.6025285",
"0.6025285",
"0.6025285",
"0.6025285",
"0.6025285",
"0.5991213",
"0.59819484",
"0.5975227",
"0.5975227",
"0.59603894",
"0.5957696",
"0.59500784",
"0.594836",
"0.59326947",
"0.5931045",
"0.5916002",
"0.5913153",
"0.5907743",
"0.5907743",
"0.5907743",
"0.5907743",
"0.5907743",
"0.5907743",
"0.5907743",
"0.58995193",
"0.5898764",
"0.5889616",
"0.5885072",
"0.58552045",
"0.58545834",
"0.58332825",
"0.58323246",
"0.58323246",
"0.58323246",
"0.58323246",
"0.58323246",
"0.58323246",
"0.58323246",
"0.58323246",
"0.58323246",
"0.58323246",
"0.58323246",
"0.583105",
"0.5822698",
"0.5818271",
"0.5815926",
"0.581208",
"0.57992744",
"0.5786433",
"0.5783715",
"0.57799035",
"0.57784057",
"0.5762567",
"0.5760293",
"0.57589304",
"0.5758056",
"0.5757118",
"0.5740171",
"0.57388234",
"0.572793",
"0.5727629",
"0.5719846",
"0.5718465",
"0.5715665",
"0.57126474",
"0.5711279",
"0.57081807",
"0.57068443",
"0.5696551",
"0.56910145",
"0.5690668",
"0.568932",
"0.5689234",
"0.568541",
"0.56796974",
"0.56780326",
"0.5675259",
"0.56747353",
"0.56743324",
"0.56725025"
] | 0.7105652 | 1 |
PATCH/PUT /studenttests/1 PATCH/PUT /studenttests/1.json | def update
respond_to do |format|
if @studenttest.update(studenttest_params)
format.html { redirect_to @studenttest, notice: 'Studenttest was successfully updated.' }
format.json { render :show, status: :ok, location: @studenttest }
else
format.html { render :edit }
format.json { render json: @studenttest.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @student_test = StudentTest.find(params[:id])\n\n respond_to do |format|\n if @student_test.update_attributes(params[:student_test])\n format.html { redirect_to @student_test, notice: 'Student test was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @student.update(student_params)\n render json: @student\n else\n render json: @student.errors, status: :unprocessable_entity\n end\n end",
"def update\n @test = Test.find(params[:id])\n\n respond_to do |format|\n if @test.update_attributes(params[:test])\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to root_path, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @section_test = SectionTest.find(params[:id])\n\n respond_to do |format|\n if @section_test.update_attributes(params[:section_test])\n format.html { redirect_to @section_test, notice: 'Section test was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @section_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test_detail.update(test_detail_params)\n format.html { redirect_to @test_detail, notice: 'Test detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_detail }\n else\n format.html { render :edit }\n format.json { render json: @test_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @testtest.update(testtest_params)\n format.html { redirect_to @testtest, notice: 'Testtest was successfully updated.' }\n format.json { render :show, status: :ok, location: @testtest }\n else\n format.html { render :edit }\n format.json { render json: @testtest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tester = Tester.find(params[:id])\n\n respond_to do |format|\n if @tester.update_attributes(params[:tester])\n format.html { redirect_to @tester, notice: 'Tester was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tester.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tester = Tester.find(params[:id])\n\n respond_to do |format|\n if @tester.update_attributes(params[:tester])\n format.html { redirect_to @tester, notice: 'Tester was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tester.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test10 = Test10.find(params[:id])\n\n respond_to do |format|\n if @test10.update_attributes(params[:test10])\n format.html { redirect_to @test10, notice: 'Test10 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test10.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @testsuite.update(testsuite_params)\n format.html { redirect_to @testsuite, notice: 'Testsuite was successfully updated.' }\n format.json { render :show, status: :ok, location: @testsuite }\n else\n format.html { render :edit }\n format.json { render json: @testsuite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @testcase = Testcase.find(params[:id])\n\n respond_to do |format|\n if @testcase.update_attributes(params[:testcase])\n format.html { redirect_to @testcase, :notice => 'Test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @testcase.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @team_test = TeamTest.find(params[:id])\n\n respond_to do |format|\n if @team_test.update_attributes(params[:team_test])\n format.html { redirect_to @team_test, notice: 'Team test was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @test.update(test_params)\n render status: :ok, json: @test\n else\n self.send(:edit)\n end\n end",
"def update\n respond_to do |format|\n if @tests_specification.update(tests_specification_params)\n format.html { redirect_to edit_tests_specification_path(@tests_specification), notice: \"Tests specification was successfully updated.\" }\n format.json { render :show, status: :ok, location: @tests_specification }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tests_specification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to students_path, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, :notice => 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @student.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, :notice => 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @student.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @testing_.update(testing__params)\n format.html { redirect_to @testing_, notice: 'Testing was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @testing_.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test1.update(test1_params)\n format.html { redirect_to @test1, notice: \"Test1 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @test1 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @test1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to patient_path(@test.patient), notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test = @subject.tests.find_by_id(params[:id])\n if @test.update_attributes(params[:test])\n redirect_to user_subject_tests_path\n else\n render :action => \"edit\"\n end\n end",
"def update\n @student = User::Student.find(params[:id])\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to user_student_path(@user, @student), notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: user_student_path(@user, @student) }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @testis = Teste.find(params[:id])\n\n respond_to do |format|\n if @testis.update_attributes(params[:testis])\n format.html { redirect_to @testis, notice: 'Teste was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @testis.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_update_successful\n data = {\n firstname: \"Anh\",\n lastname: \"Hoang\",\n avatar: \"avatar.png\",\n address: \"111D Ly Chinh Thang\",\n city: \"Ho Chi Minh\",\n email: \"anh@gmallds.sl\",\n mobile: \"0309433343545\",\n gender: 1,\n birthday: \"1991/10/10\"\n }\n\n user_id = 28\n expected = 200\n uri = URI.parse('http://localhost:3000/v1/users/'+user_id.to_s)\n\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def update\n respond_to do |format|\n @test.update_question_details(test_params)\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @usertest = Usertest.find(params[:id])\n\n respond_to do |format|\n if @usertest.update_attributes(params[:usertest])\n format.html { redirect_to @usertest, notice: 'Usertest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @usertest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n begin\n student = Student.find(params[:id])\n student.update_attributes!(student_params)\n\n render json: {status: 'SUCCESS', message:\"Student updated Successfully with name #{student.name}\", data:student}, status: :ok\n rescue => error\n render json: {status: 'ERROR', message:'Student Update failed!', data:error}, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @exam_student.update(exam_student_params)\n format.html { redirect_to @exam_student, notice: 'Exam student was successfully updated.' }\n format.json { render :show, status: :ok, location: @exam_student }\n else\n format.html { render :edit }\n format.json { render json: @exam_student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @smoke_test = SmokeTest.find(params[:id])\n\n if not params[:smoke_test][:test_suite_ids] and not params[:smoke_test][:config_templates]\n @smoke_test.config_templates.clear\n @smoke_test.test_suites.clear\n end\n respond_to do |format|\n if @smoke_test.update_attributes(params[:smoke_test])\n\n @smoke_test.test_suites.clear if @smoke_test.test_suites.size == 0\n format.html { redirect_to(@smoke_test, :notice => 'Smoke test was successfully updated.') }\n format.json { render :json => @smoke_test, :status => :ok }\n format.xml { render :xml => @smoke_test, :status => :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @smoke_test.errors, :status => :unprocessable_entity }\n format.xml { render :xml => @smoke_test.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @jsontest.update(jsontest_params)\n format.html { redirect_to @jsontest, notice: 'Jsontest was successfully updated.' }\n format.json { render :show, status: :ok, location: @jsontest }\n else\n format.html { render :edit }\n format.json { render json: @jsontest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test_set = TestSet.find(params[:id])\n permitted_to! :update, @test_set.problem\n respond_to do |format|\n if @test_set.update_attributes(permitted_params)\n format.html { redirect_to @test_set, :notice => 'Test set was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @test_set.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @student_major = StudentMajor.find(params[:id])\n\n respond_to do |format|\n if @student_major.update_attributes(student_major_params)\n format.html { redirect_to @student_major, notice: 'Student major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student_major.errors, status: :unprocessable_entity }\n end\n end\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 @test_test = TestTest.find(params[:id])\n\n respond_to do |format|\n if @test_test.update_attributes(params[:test_test])\n format.html { redirect_to(@test_test, :notice => 'TestTest was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @test_test.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @test_guide_scenario_sa.update(test_guide_scenario_sa_params)\n render status: :ok, json: @test_guide_scenario_sa\n else\n self.send(:edit)\n end\n end",
"def update\n @test_suite = TestSuite.find(params[:id])\n\n respond_to do |format|\n if @test_suite.update_attributes(params[:test_suite])\n format.html { redirect_to @test_suite, notice: 'Test suite was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test_suite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @student.update(student_params)\n render :show, status: :ok, location: @student\n else\n render json: @student.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @student_entity.update(student_entity_params)\n format.json { render :show, status: :ok, location: @student_entity }\n else\n format.json { render json: @student_entity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @student = current_user.teacher.students.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student])\n StdTeacher.where(\"idStd = ? AND idTeacher = ?\", @student.id, current_user.teacher.id).update_all(idGroup: @student.idGroup)\n format.html { redirect_to students_path, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fixit_test.update(fixit_test_params)\n format.html { redirect_to @fixit_test, notice: 'Fixit test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @fixit_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @test.update(test_params)\n respond_to do |format|\n format.html { redirect_to admin_tests_path }\n format.json { render :show, status: :ok, location: admin_tests_path }\n end\n else\n respond_to do |format|\n format.html { render :edit, notice: \"Please do you test again. An unexpected error has occured!\" }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end \n end",
"def test_update_unsuccessful\n data = {\n firstname: \"\",\n lastname: \"Hoang\",\n avatar: \"avatar.png\",\n address: \"111D Ly Chinh Thang\",\n city: \"Ho Chi Minh\",\n email: \"anh@gmallds.sl\",\n mobile: \"0309433343545\",\n gender: 1,\n birthday: \"1991/10/10\"\n }\n\n user_id = 28\n expected = 1002\n uri = URI.parse('http://localhost:3000/v1/users/'+user_id.to_s)\n\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def update\r\n @student1 = Student1.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @student1.update_attributes(params[:student1])\r\n format.html { redirect_to @student1, notice: 'Student1 was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @student1.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to students_url, notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @indexstudent = Indexstudent.find(params[:id])\n\n respond_to do |format|\n if @indexstudent.update_attributes(params[:indexstudent])\n format.html { redirect_to @indexstudent, notice: 'Indexstudent was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @indexstudent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: \"Student was successfully updated.\" }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: \"Student was successfully updated.\" }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: \"Student was successfully updated.\" }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @case_test.update(case_test_params)\n format.html { redirect_to @case_test, notice: 'Case test was successfully updated.' }\n format.json { render :show, status: :ok, location: @case_test }\n else\n format.html { render :edit }\n format.json { render json: @case_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test_user = TestUser.find(params[:id])\n\n respond_to do |format|\n if @test_user.update_attributes(params[:test_user])\n format.html { redirect_to @test_user, notice: 'Test user was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test = LoadTest.find(params[:id])\n\n respond_to do |format|\n if @test.update_attributes(params[:load_test])\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student, notice: 'Estudiante ha sido satisfactoriamente actualizado.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @performance_test = PerformanceTest.find(params[:id])\n\n respond_to do |format|\n if @performance_test.update_attributes(params[:performance_test])\n format.html { redirect_to @performance_test, :notice => 'Performance test was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @performance_test.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @jquery_test.update(jquery_test_params)\n format.html { redirect_to @jquery_test, notice: 'Jquery test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @jquery_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to @student,\n notice: 'Student was successfully updated.' }\n format.json { render :show, status: :ok, location: @student }\n else\n format.html { render :edit }\n format.json { render json: @student.errors,\n status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @student.update(student_params)\n format.html { redirect_to admin_student_path(@student), notice: 'student was successfully updated.' }\n format.json { render action: 'show', status: :updated, location: @student }\n #format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test_suite.update(test_suite_params)\n format.html { redirect_to @test_suite, notice: 'Test suite was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_suite }\n else\n format.html { render :edit }\n format.json { render json: @test_suite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_test.update(user_test_params)\n format.html { redirect_to admin_user_tests_path, notice: 'User test was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_test }\n else\n format.html { render :edit }\n format.json { render json: @user_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tktest = Tktest.find(params[:id])\n\n respond_to do |format|\n if @tktest.update_attributes(params[:tktest])\n format.html { redirect_to @tktest, notice: 'Tktest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tktest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @student_user = StudentUser.find(params[:id])\n\n respond_to do |format|\n if @student_user.update_attributes(params[:student_user])\n format.html { redirect_to @student_user, notice: 'Student user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @studentset = Studentset.find(params[:id])\n\n respond_to do |format|\n if @studentset.update_attributes(params[:studentset])\n format.html { redirect_to @studentset, notice: 'Studentset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @studentset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n student = Student.find(params[:id])\n if student.update(student_params)\n render json: { status: '200', message: \"Updated Student with id #{params[:id]}\", data: student }, status: :ok\n else\n render json: { status: '422', error: 'Student not updated', data: student.errors }, status: :unprocessable_entity\n end\n rescue ActiveRecord::RecordNotFound\n render json: { status: '404', error: \"No Student with id #{params[:id]}\", data: student }, status: :not_found\n end",
"def update\n respond_to do |format|\n if @test_stuff.update(test_stuff_params)\n format.html { redirect_to @test_stuff, notice: 'Test stuff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @test_stuff.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test_case.update(test_case_params)\n TestMailer.admin_test_updated_email(@test_case).deliver\n \n format.html { redirect_to @test_case, notice: 'Your test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @test_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @what_test.update(what_test_params)\n format.html { redirect_to @what_test, notice: 'What test was successfully updated.' }\n format.json { render :show, status: :ok, location: @what_test }\n else\n format.html { render :edit }\n format.json { render json: @what_test.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.72673965",
"0.6570896",
"0.65522385",
"0.64222735",
"0.6384512",
"0.63650024",
"0.63650024",
"0.63650024",
"0.63650024",
"0.63650024",
"0.63650024",
"0.63650024",
"0.6357426",
"0.63539463",
"0.6352404",
"0.63210696",
"0.63210696",
"0.63161266",
"0.631607",
"0.630436",
"0.6299261",
"0.62789845",
"0.6272319",
"0.62575895",
"0.625725",
"0.625725",
"0.6254702",
"0.62544835",
"0.6241195",
"0.6237229",
"0.6233584",
"0.6233584",
"0.6233584",
"0.6233584",
"0.6233584",
"0.6224341",
"0.6222756",
"0.62218904",
"0.620031",
"0.61971176",
"0.6196519",
"0.61964756",
"0.6189755",
"0.61842597",
"0.61842597",
"0.61842597",
"0.6183755",
"0.61744004",
"0.617085",
"0.616275",
"0.61533254",
"0.6140016",
"0.61369264",
"0.6124055",
"0.61200744",
"0.61198246",
"0.6113065",
"0.6107646",
"0.6107471",
"0.61052144",
"0.6090616",
"0.6078552",
"0.6078552",
"0.6078552",
"0.6078552",
"0.6078552",
"0.6078552",
"0.6078552",
"0.6078552",
"0.6078552",
"0.6078552",
"0.6078552",
"0.6078552",
"0.6078552",
"0.6078552",
"0.6078552",
"0.6078552",
"0.6078552",
"0.60752225",
"0.606628",
"0.6065707",
"0.6065707",
"0.6065707",
"0.60649544",
"0.60641724",
"0.60605705",
"0.605298",
"0.6047384",
"0.60440284",
"0.6040348",
"0.60310525",
"0.6023588",
"0.6018338",
"0.6013895",
"0.60007435",
"0.60005975",
"0.59978664",
"0.5979348",
"0.5976264",
"0.5971333"
] | 0.6956709 | 1 |
DELETE /studenttests/1 DELETE /studenttests/1.json | def destroy
@studenttest.destroy
respond_to do |format|
format.html { redirect_to studenttests_url, notice: 'Studenttest was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @student_test = StudentTest.find(params[:id])\n @student_test.destroy\n\n respond_to do |format|\n format.html { redirect_to student_tests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @test = Test.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.delete\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @section_test = SectionTest.find(params[:id])\n @section_test.destroy\n\n respond_to do |format|\n format.html { redirect_to section_tests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @usertest = Usertest.find(params[:id])\n @usertest.destroy\n\n respond_to do |format|\n format.html { redirect_to usertests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test = LoadTest.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to load_tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @smoke_test = SmokeTest.find(params[:id])\n @smoke_test.destroy\n\n respond_to do |format|\n format.html { redirect_to(smoke_tests_url) }\n format.json { head :ok }\n format.xml { head :ok }\n end\n end",
"def destroy\n @testtest.destroy\n respond_to do |format|\n format.html { redirect_to testtests_url, notice: 'Testtest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Prueba eliminada exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @student_entity.destroy\n render json: {msg: 'deleted successfully'}, status: 200\n end",
"def destroy\n @test_summary = TestSummary.find(params[:id])\n @test_summary.destroy\n\n respond_to do |format|\n format.html { redirect_to test_summaries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testing_.destroy\n respond_to do |format|\n format.html { redirect_to testing_s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to students_path }\n format.json { head :no_content }\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def destroy\n student.destroy\n respond_to do |format|\n format.html { redirect_to admin_students_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @indexstudent = Indexstudent.find(params[:id])\n @indexstudent.destroy\n\n respond_to do |format|\n format.html { redirect_to indexstudents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_detail.destroy\n respond_to do |format|\n format.html { redirect_to test_details_url, notice: 'Test detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test1.destroy\n respond_to do |format|\n format.html { redirect_to test1s_url, notice: \"Test1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jsontest.destroy\n respond_to do |format|\n format.html { redirect_to jsontests_url, notice: 'Jsontest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test = Test.find_by_id(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to user_subject_tests_path }\n format.xml { head :ok }\n end\n end",
"def destroy\n @exam_student.destroy\n respond_to do |format|\n format.html { redirect_to exams_url, notice: 'Odjavili ste ispit.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testis = Teste.find(params[:id])\n @testis.destroy\n\n respond_to do |format|\n format.html { redirect_to testes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testcase = Testcase.find(params[:id])\n @testcase.destroy\n\n respond_to do |format|\n format.html { redirect_to testcases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n teacher_exclusive\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: \"L'épreuve a été supprimée\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_test = TestTest.find(params[:id])\n @test_test.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_tests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: \"Student was successfully deleted.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: \"Student was successfully removed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @student1 = Student1.find(params[:id])\r\n @student1.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to student1s_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @dojo_student = DojoStudent.find(params[:id])\n @dojo_student.destroy\n\n respond_to do |format|\n format.html { redirect_to dojo_students_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test = Mg::Test.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to(mg_tests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @test_case.destroy\n respond_to do |format|\n format.html { redirect_to test_cases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student = Student.find(params[:id])\n @student.destroy\n\n respond_to do |format|\n format.html { redirect_to login_index_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url(subject_class_id: @test.subject_class_id), notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_suite = TestSuite.find(params[:id])\n @test_suite.destroy\n\n respond_to do |format|\n format.html { redirect_to test_suites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n Student.delete(params[:id])\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @dtest = Dtest.find(params[:id])\n @dtest.destroy\n\n respond_to do |format|\n format.html { redirect_to dtests_url, notice: t(:dest_test) }\n format.json { head :no_content }\n end\n end",
"def delete\n if @test.destroy\n return render json: { message: 'Test was removed succesfully.', error: false }\n else\n return render json: { message: 'Error :Something went wrong. Test was not removed.', error: true }\n end\n end",
"def destroy\n @test_stall.destroy\n respond_to do |format|\n format.html { redirect_to test_stalls_url, notice: 'Test stall was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Se borró el registro de alumna satisfactoriamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testsuite.destroy\n respond_to do |format|\n format.html { redirect_to testsuites_url, notice: 'Testsuite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testdb = Testdb.find(params[:id])\n @testdb.destroy\n\n respond_to do |format|\n format.html { redirect_to testdbs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student = Student.find(params[:student_id])\n @lunchdetention = Lunchdetention.find(params[:id])\n @lunchdetention.destroy\n\n respond_to do |format|\n format.html { redirect_to student_url(@student) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @class_student.destroy\n respond_to do |format|\n format.html { redirect_to class_students_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to import_students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tktest = Tktest.find(params[:id])\n @tktest.destroy\n\n respond_to do |format|\n format.html { redirect_to tktests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_test = Admin::Test.find(params[:id])\n @admin_test.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_tests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @test_datum.destroy\n respond_to do |format|\n format.html { redirect_to test_data_url, notice: 'Test datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to user_students_url(@user), notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: \"Student was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: \"Student was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: \"Student was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test = TkdTest.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to(:action => :index) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student.destroy\n respond_to do |format|\n format.html { redirect_to students_url, notice: 'Student was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.79265225",
"0.7243113",
"0.72413415",
"0.7187567",
"0.7187567",
"0.70800036",
"0.7045642",
"0.7038258",
"0.70323914",
"0.70323914",
"0.70323914",
"0.70323914",
"0.7028767",
"0.7025695",
"0.7012168",
"0.6995361",
"0.6992316",
"0.6985116",
"0.69729567",
"0.69553304",
"0.69553304",
"0.69553304",
"0.69553304",
"0.69553304",
"0.69553304",
"0.69553304",
"0.69553304",
"0.6953408",
"0.6951535",
"0.6951535",
"0.6951535",
"0.6951535",
"0.6951535",
"0.6951535",
"0.6951535",
"0.6950674",
"0.6948556",
"0.69377047",
"0.69367045",
"0.6936333",
"0.69350934",
"0.69318664",
"0.69285953",
"0.6923643",
"0.6923263",
"0.6922523",
"0.69149816",
"0.69089794",
"0.6900972",
"0.68946975",
"0.6890864",
"0.68890965",
"0.6876528",
"0.68674487",
"0.68557066",
"0.68506587",
"0.6838134",
"0.6833491",
"0.682785",
"0.6810143",
"0.68070316",
"0.68011934",
"0.6799177",
"0.6799029",
"0.6797402",
"0.6788734",
"0.6786007",
"0.67837375",
"0.6778154",
"0.6768325",
"0.67602545",
"0.6759016",
"0.6756535",
"0.67525095",
"0.67525095",
"0.67525095",
"0.6752383",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849",
"0.6749849"
] | 0.75891656 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_studenttest
@studenttest = Studenttest.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 |
Never trust parameters from the scary internet, only allow the white list through. | def studenttest_params
params.require(:studenttest).permit(:name, :lastname, :birthday)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_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 allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\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 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 user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\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 whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\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 safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\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 whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; 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 quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"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 url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\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 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 url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] | 0.0 | -1 |
This method is called by the specialized implementations upon tree creation. Initialization parameters can include: an array of branches to add one or several trees to copy (will be merged if multiple) | def initialize(*params)
super(*params) # Delegates to Plexus.
@_options = (params.pop if params.last.is_a? Hash) || {}
_delay { alias has_branch? has_edge? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_branch\n @tree_class.new\n end",
"def branches\n @branches ||= build_branches\n end",
"def build_branches\n branches_collection(coverage[:branches] || {})\n end",
"def build_tree(arr)\n\tend",
"def initialize(height, branching_factor, approx)\n @height = height #get inputs\n @height_count = height\n @branching_factor = branching_factor#get inputs\n @approx = approx#get inputs\n @node_array = []#initialise empty array of nodes\n @node_type = true # set to build daughters first\n get_t_value#get random t_value\n @root_node = RootNode.new\n @root_node.t_value = @t_value # give starting t value to buid tree from\n @node_array << @root_node# to be checked in further building of tree\n build_connecting_nodes(@root_node,@branching_factor)#build first daughters\n @node_type = !@node_type #change to enter next values of interior nodes\n @height_count = @height_count-1 #one layer done\n build_rest_of_tree()\n end",
"def initialize(arr=[])\n @tree = []\n @tree.push(:dummy_head)\n 0.upto(arr.size-1) do |i|\n push(arr[i])\n end\n end",
"def build_tree(arr)\n @root = Node.new(arr.shift)\n arr.each { |data| insert_data(data, @root) }\n end",
"def initialize(left=SternBrocot::Fraction.new(0,1), right=SternBrocot::Fraction.new(1,0), depth=0)\n @left = left\n @right = right\n @depth = depth\n @tree = Array.new(depth)\n end",
"def initialize(arry = [])\n @base = arry.collect{|el| el } # poor man's clone\n @tree_hash = run_layers\n end",
"def build_tree_2(data_array)\n root = nil\n \n data_array.each do |elem|\n node = insert_node(root, nil, elem) \n\troot ||= node\n end\n \n root\nend",
"def create_branches(repo)\n @branch_names.collect {|branch_name| \n Branch.new(branch_name ,Grit::Commit.find_all(repo, branch_name).sort_by { |k| k.authored_date}.reverse)}\n end",
"def build_tree(array)\n\t\t@root = Node.new(array.shift)\n\t\tarray.each { |value| add_node(value, @root)}\n\tend",
"def initialize(root_dir, module_set, data)\n @module_set = module_set\n @name = data[:name]\n @root = FilePath.new(root_dir, @name).canonicalize\n @compiler_version = data[:compiler_version] \n @aspectj = data[:aspectj] || false\n @dependencies = data[:dependencies] || [ ]\n\n assert(\"Root ('#{@root.to_s}') must be an absolute path\") { @root.absolute? }\n assert(\"Root ('#{@root.to_s}') must exist, and be a directory\") { FileTest.directory?(@root.to_s) }\n assert(\"Compiler version must be specified.\") { ! @compiler_version.nil? }\n \n @subtrees = [ ]\n # Run through all the factories and add a new subtree for each one.\n BuildSubtreeFactory::ALL_BUILD_SUBTREE_FACTORIES.each { |factory| @subtrees << factory.create(self) }\n end",
"def build_tree(array)\n\t\t@root = Node.new(array[0])\n\t\ttemp_root = @root\n\n\t\tarray[1..-1].each do |node_value|\n\t\t\tinsert_node(node_value, temp_root)\n\t\tend\n\tend",
"def branches; end",
"def initialize(tree={})\n tree.each do |k,v|\n @node_name = k\n @children = v.map {|sk,sv| Tree.new({sk => sv}) }\n end\n end",
"def build_tree(arr)\n @root = insert_node(nil, arr.shift)\n arr.each { |value| insert_node(@root, value) }\n end",
"def setup_test_tree\n @root << @child1\n @root << @child2\n @root << @child3 << @child4\n end",
"def set_branch_tree\n @branch_tree = BranchTree.find(params[:id])\n end",
"def branch(left, right)\n left,right = [left,right].sort_by{|n| n.x}\n if nodes = selected.branch(left, right)\n index = @branches.index( self.selected )\n @branches.delete_at index\n @branches.insert index, *nodes\n self.selected = @selected_node.children.first\n end\n end",
"def plant_a_tree\n new_tree = [OrangeTree.new]\n @tree_array = @tree_array + new_tree\n end",
"def build_tree(ary)\n # If the array is sorted, the tree will not be balanced\n ary.shuffle!\n ary.each { |item| insert(item) }\n end",
"def build\n from_branches + from_tags + from_refs\n end",
"def build_tree array\n\t\t@root = Node.new array[0]\n\t\t@nodes += 1\n\t\tarray[1..-1].each do |var|\n\t\t\tinsert(@root,var)\n\t\tend\n\tend",
"def create_balanced_copy_subtree(elements:)\n return nil if elements.empty?\n\n\n centre_ix = (elements.size / 2).floor\n return Node.new(\n elements[centre_ix][0],\n elements[centre_ix][1],\n create_balanced_copy_subtree(elements: elements[0...(centre_ix)]),\n create_balanced_copy_subtree(elements: elements[(centre_ix+1)..-1]),\n )\n end",
"def build_tree(data_array)\n @root = nil # overwrites tree, even if array is empty\n data_array.each_with_index do |data, index|\n if index == 0\n @root = Node.new(data)\n else\n set_next_node(data)\n end\n end\n end",
"def initialize (tree, parent = nil, id = \"\") # id - DEBUG\n @tree = tree\n @parent = parent\n @children = []\n @data = []\n @bounding_box = Rectangle.new(tree.dimension)\n @id = id # DEBUG\n end",
"def test_branch\n #puts \"---------------test_branch-----------------\"\n t1= nil\n t2 = nil\n t11 = nil\n t12 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.branch do \n t11 = b.add(Thing11.new)\n t12 = b.add(Thing12.new)\n end\n t2 = b.add(Thing2.new)\n end\n\n r = Thing.links([t1,t2,t11,t12])\n assert_equal 4, r.size\n assert r.include? [t1,t11]\n assert r.include? [t1,t12]\n assert r.include? [t11,t2]\n assert r.include? [t12,t2]\n end",
"def build_tree(array, left=0, right=array.length-1)\n \n# base case\n return if left > right\n\n# from smallest to largest\n array = merge_sort(array)\n\n# middle index, make this the first node\n index_mid = left + (right-left) / 2 \n node = Node.new(array[index_mid]) \n \n# i think it's making the left node (smaller), & right (larger)\n# looks like it is recursion\n node.left_child = build_tree(array, left, index_mid-1) \n node.right_child = build_tree(array, index_mid+1, right) \n\n @tree = node\n @tree\n end",
"def create_branch(name:, precondition: Any, extractor: IDENTITY, destructure: false, default: false)\n Qo::Branches::Branch.create(\n name: name,\n precondition: precondition,\n extractor: extractor,\n destructure: destructure,\n default: default\n )\n end",
"def build_branch(branch, params = {}, body = {})\n CircleCi.request(conf, \"#{base_path}/tree/#{branch}\", params).post(body)\n end",
"def initialize(arr)\n @value = arr.sort.uniq\n @root = build_tree(value)\n end",
"def add_branch(widget_array, branches)\n score_hash = @scorer.get_score_hash(widget_array)\n score = @scorer.get_total_score(score_hash)\n added = false\n branches_index = 0\n if score_hash[@main_requirement_label] >= 0\n while !added && branches_index < branches.length do\n better_value=@scorer.get_better_score(score, branches[branches_index][1])\n if better_value == :equal || better_value == :first\n branches.insert(branches_index, [score_hash, score, widget_array])\n added = true\n end\n branches_index += 1\n end\n branches.push([score_hash, score, widget_array]) unless added\n end\n end",
"def structure_reform(curNode, addNode)\n # reset branches for reform\n @branches = []\n @branch_count = 0\n # puts 'before cleanup'\n # lNode.print_tree\n # rNode.print_tree\n # rNode.print_tree\n # remove_PH_node(lNode)\n # remove_PH_node(rNode)\n # remove_PH_node(curNode)\n # puts 'after cleanup'\n # curNode.print_tree\n # addNode.print_tree\n # rNode.print_tree\n curChildren = curNode.children.count == 0 ? [curNode] : curNode.children\n addChildren = addNode.children.count == 0 ? [addNode] : addNode.children\n count = 0\n # p 'lnode'\n # pp lChildren\n # p 'rnode'\n curChildren.each do |ln|\n curNode.remove!(ln)\n addChildren.each do |rn|\n # p '--------------'\n # p 'ln'\n # ln.print_tree\n # p 'rn'\n # rn.print_tree\n # binding.pry\n # phName=\"PH#{@branch_count}\"\n # ph =Tree::TreeNode.new(phName, '')\n ln_append = ln.detached_subtree_copy\n # p 'ln_append before'\n # ln_append.print_tree\n append_to_end(ln_append, rn)\n # p 'ln_append'\n # ln_append.print_tree\n # ph<<ln_append #unless curNode==newNode\n ln_append = add_branch(ln_append)\n # p 'ln_append after'\n # ln_append.print_tree\n curNode << ln_append\n # p 'ph'\n # ph.print_tree\n # p 'curNode'\n # curNode.print_tree\n end\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 init\n for i in 0...@tree.size\n @tree[i] = 0\n end\n end",
"def create\n @tree=Tree.find(params[:branch][:tree_id])\n if @tree\n @branch = Branch.new()\n @branch.private=params[:branch][:private]\n @branch.name=params[:branch][:name]\n @branch.tree=@tree\n @latest_tip=@branch.tips.latest.first\n respond_to do |format|\n if @branch.save\n admin=Affiliation::Administration.new\n admin.user=current_user\n admin.entity=@branch\n admin.save\n #@branch.memberships.create({:user => current_user, :admin => true}, :as => :admin)\n format.html { redirect_to tree_branch_url @tree,@branch, notice: 'Branch was successfully created.' }\n format.json\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @branch.errors, status: :unprocessable_entity }\n format.js { render action: \"new\",status: :unprocessable_entity }\n end\n end\n else\n render :json => {:error=>\"not found\"},:status => 404\n end\n end",
"def initialize(tree, options={})\n @tree = tree\n @options = options\n end",
"def initialize(hsh, opener, content = nil)\n if content\n @hash_id, @opener = hsh, opener\n @type = 'tree'\n @content = content\n else\n super(hsh, opener)\n end\n parse!\n end",
"def build_tree(data)\n @root = Node.new(data[0])\n data.shift\n data.each { |value| @root.insert(value) }\n end",
"def build_tree(array)\n tree = TreeNode.new(array[0], 0)\n (1..array.length-1).each {|i|\n insert_into_tree(tree, array[i], i)\n }\n tree\nend",
"def create\n @branch_tree = BranchTree.new(branch_tree_params)\n\n respond_to do |format|\n if @branch_tree.save\n format.html { redirect_to @branch_tree, notice: 'Branch tree was successfully created.' }\n format.json { render :show, status: :created, location: @branch_tree }\n else\n format.html { render :new }\n format.json { render json: @branch_tree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def initialize_copy( original )\n\t\t\t@template = original.template\n\t\t\t@options = original.options.dup\n\t\t\t@tree = @tree.map( &:dup )\n\t\t\t@node_stack = [ @tree ]\n\t\t\t@include_stack = original.include_stack.dup\n\t\tend",
"def root_branches\n @root_branches = branches.select(&:root?)\n end",
"def initialize(payload, children = []) #initialize the creation of the Tree with the attributes\n @payload = payload #payload and children. Sets Children to an empty array\n @children = children\n end",
"def initialize( template, options={} )\n\t\t\t@template = template\n\t\t\t@options = options.dup\n\t\t\t@tree = []\n\t\t\t@node_stack = [ @tree ]\n\t\t\t@include_stack = []\n\t\tend",
"def random_tree\n\t\t#range of possible angle separations between branches\n\t\t#big range seems to be ok, 30 to 60 works nice\n\t\t$angle_of_separation = (30..60).to_a\n\t\t#range of possible shrinkage values, will have a decimal in front of it\n\t\t#shrink determines how short each branch is\n\t\t$shrink_range = (4..6).to_a\n\t\t#split determines how many levels of branches there are\n\t\t#below 5 makes a pretty weak tree\n\t\t#above 7 makes a big blob of black\n\t\t$split_range = (5..7).to_a\n\t\t\n\t\t#Determines how many branches the current one splits off into\n\t\t$num_splits = rand(4)+2\n\t\t\n\t\t#how long the \"trunk\" is, height is 600\n\t\t#this gets ugly above 250\n\t\t$trunk = (150..250).to_a\n\t\t\n\t\t#pick a random number from the split range to be used as the number of splits\n\t\t$split_range = $split_range[rand($split_range.length)]\n\t\t#as a decimal, find the factor we will multiply future branches by\n\t\t@shrink = \"0.#{$shrink_range[rand($shrink_range.length)]}\".to_f\n\t\t#pick a random value for the angle of separation from the range\n\t\t$angle_of_separation = $angle_of_separation[rand($angle_of_separation.length)]\n\t\t\n\t\t#make a multidimensional array for branches\n\t\t@branches = []\n\t\t#start at the bottom, but not all the way down\n\t\t#move @x to the top of the trunk, ready for next branches\n\t\t@branches << [ [[@x, Height - @bot_margin], [@x, Height - $trunk[rand($trunk.length)]]] ] \n\t\t\n\t\tputs \"This output is from Random Tree\"\n\t\tputs \"Number of splits: #{$num_splits}\"\n\t\tputs \"Angle of separation: #{$angle_of_separation}\"\n\t\tputs \"Shrink range: #{$shrink_range[0]} to #{$shrink_range[$shrink_range.length-1]}\"\n\t\tputs \"Split range: #{$split_range}\"\n\t\tputs \"Initial branch length: #{$trunk[0]} to #{$trunk[$trunk.length-1]}\"\n\t\t\n\t end",
"def create\r\n if @current_shop.branches_count >= @current_shop.max_branches_count\r\n flash[:error] = t('You have no authories to create more branch.')\r\n redirect_to backend_shop_branches_path(@current_shop.slug)\r\n else\r\n @branch = @current_shop.branches.build(branch_params.except(:supported_order_types, :supported_scratchpad_order_types, :supported_send_sms_order_types))\r\n @branch.supported_order_types = params[:branch][:supported_order_types].nil? ?\r\n nil: params[:branch][:supported_order_types].select{|type| Order::order_types_array.index(type).present? }.join(',')\r\n @branch.supported_scratchpad_order_types = params[:branch][:supported_scratchpad_order_types].nil? ?\r\n nil: params[:branch][:supported_scratchpad_order_types].select{|type| Order::order_types_array.index(type).present? }.join(',')\r\n @branch.supported_send_sms_order_types = params[:branch][:supported_send_sms_order_types].nil? ?\r\n nil: params[:branch][:supported_send_sms_order_types].select{|type| Order::order_types_array.index(type).present? }.join(',')\r\n #@branch = @current_shop.branches.build(branch_params)\r\n respond_to do |format|\r\n if @branch.save\r\n format.html { redirect_to backend_shop_branch_branch_steps_path(@current_shop.slug, @branch) + \"/detail_info\" }\r\n format.json { render action: 'show', status: :created, location: @branch }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @branch.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end\r\n end",
"def create_branch(_base_branch, _new_branch)\n puts 'TODO: Implement Git.create_branch'\n end",
"def initialize(tree=nil)\n @visited = [] \n @tree = tree\n end",
"def initialize_copy(list)\n @nodes = @nodes.map { |node|\n node2 = node.clone\n node2.parent = self\n node2\n }\n end",
"def create_tree(father,tree)\n tree.each do |name|\n n = Meta::create_class(father, name[0], name[1])\n create_tree(n, name[2])\n end\nend",
"def build_branch(branch, params = {}, body = {})\n CircleCi.request(@conf, \"/project/#{username}/#{project}/tree/#{branch}\", params).post(body)\n end",
"def build_tree\n c1 = ComponentNode.new(110)\n c2 = ComponentNode.new(20)\n c3 = ComponentNode.new(20)\n c4 = ComponentNode.new(150)\n c5 = ComponentNode.new(80)\n c6 = ComponentNode.new(120, [c1, c2, c3])\n c7 = ComponentNode.new(180, [c4, c5])\n return(ComponentNode.new(200, [c6, c7]))\n end",
"def build_tree_arbitrary(arr)\n node = Node.new(arr[0])\n queue = [node]\n @root = node\n i = 0\n\n until queue.empty?\n node = queue.shift\n children = node_children(node, i, arr)\n queue.concat(children)\n i += 2\n end\n end",
"def new_branch_in(folder, levels = nil)\n return if flat?\n\n raise Errors::BranchError.new(dir: folder.path) if folder == terminal\n\n raise TreeLimitExceededError.new(tree: self) if folder.count >= folder_limit\n\n levels ||= levels_below folder\n new_branch = new_paths_in folder, levels\n @folders = folders[0..folders.index(folder)].concat new_branch\n folders.last.create!\n end",
"def initialize\n @use_tree_model = :self\n @default_taxonomy_require_both = true\n end",
"def initialize(sort_order)\n @nodes = TreeMoveCalculator.create_tree_nodes(sort_order)\n end",
"def clone_branch( )\n raise \"only support taxon root\" unless self.root?\n #raise \"only copy taxon from design site\" unless taxon.site.design?\n #raise \"taxon exists in current site\" if self.class.exists(:permalink=>self.permalink)\n cloned_branch = nil\n current_site_id = Spree::Site.current.id\n #maybe clone taxon from other site\n Spree::MultiSiteSystem.with_context_free_taxon{\n #copy from http://stackoverflow.com/questions/866528/how-to-best-copy-clone-an-entire-nested-set-from-a-root-element-down-with-new-tr\n new_taxonomy = self.taxonomy.dup\n new_taxonomy.site_id = current_site_id\n # should not save new_taxonomy here, or new_taxonomy.root.site_id is not current site id\n h = { self => self.custom_duplicate } #we start at the root\n ordered = self.descendants\n #clone subitems\n ordered.each do |item|\n h[item] = item.custom_duplicate\n end\n #resolve relations\n ordered.each do |item|\n cloned = h[item]\n item_parent = h[item.parent]\n item_parent.children << cloned if item_parent\n # handle icon\n end\n h.values.each{|cloned|\n cloned.site_id = new_taxonomy.site_id\n cloned.taxonomy = new_taxonomy\n }\n new_taxonomy.root = h[self]\n cloned_branch = h[self]\n }\n cloned_branch\n end",
"def setup\n @root = Tree::TreeNode.new(\"ROOT\", \"Root Node\")\n\n @child1 = Tree::TreeNode.new(\"Child1\", \"Child Node 1\")\n @child2 = Tree::TreeNode.new(\"Child2\", \"Child Node 2\")\n @child3 = Tree::TreeNode.new(\"Child3\", \"Child Node 3\")\n @child4 = Tree::TreeNode.new(\"Child4\", \"Grand Child 1\")\n @child5 = Tree::TreeNode.new(\"Child5\", \"Child Node 4\")\n\n end",
"def copy_tree\n new_car = if car.kind_of? Cons\n car.copy_tree\n else\n car\n end\n new_cdr = if cdr.kind_of? Cons\n cdr.copy_tree\n else\n cdr\n end\n Cons[new_car,new_cdr]\n end",
"def build_tree(arr)\n #arr.shuffle!\n arr.each do |x|\n if @root == nil\n @root = Node.new(x)\n else\n current_node = @root\n until current_node == nil\n if x < current_node.value\n parent = current_node\n direction = \"left\"\n current_node = current_node.left_child\n elsif x > current_node.value\n parent = current_node\n direction = \"right\"\n current_node = current_node.right_child\n end\n end\n if direction == \"left\"\n parent.left_child = Node.new(x)\n elsif direction == \"right\"\n parent.right_child = Node.new(x)\n end\n end\n end\n end",
"def init_simple_tree\n @root_org = Org.create(name: 'root')\n @lv1_child_org = Org.create(name: 'lv1')\n @lv1_child_org2 = Org.create(name: 'lv1-2')\n @lv2_child_org = Org.create(name: 'lv2')\n @lv2_child_org2 = Org.create(name: 'lv2-2')\n @lv2_child_org3 = Org.create(name: 'lv2-3')\n @lv2_child_org4 = Org.create(name: 'lv2-4')\n @lv3_child_org = Org.create(name: 'lv3')\n @lv3_child_org2 = Org.create(name: 'lv3-2')\n @lv4_child_org = Org.create(name: 'lv4')\n @lv4_child_org2 = Org.create(name: 'lv4-2')\n @lv5_child_org = Org.create(name: 'lv5')\n @lv5_child_org2 = Org.create(name: 'lv5-2')\n\n current_time = Time.now\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @root_org.id,\n distance: 0,\n start_time: 10.minutes.ago(current_time),\n end_time: 1000.years.from_now,\n scope_name: 'default'\n )\n\n # 10 minutes ago\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org.id,\n distance: 1,\n start_time: 10.minutes.ago(current_time),\n end_time: current_time,\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv1_child_org.id,\n distance: 2,\n start_time: 10.minutes.ago(current_time),\n end_time: current_time,\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv1_child_org.id,\n distance: 1,\n start_time: 10.minutes.ago(current_time),\n end_time: current_time,\n scope_name: 'default'\n )\n\n # now\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv1_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv1_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv2_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv2_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org3.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org2.id,\n child_id: @lv2_child_org3.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org4.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org2.id,\n child_id: @lv2_child_org4.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv3_child_org.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv3_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv3_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv4_child_org.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv4_child_org.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv4_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org.id,\n child_id: @lv4_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv5_child_org.id,\n distance: 5,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv4_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv3_child_org2.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv3_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org2.id,\n child_id: @lv3_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv4_child_org2.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv4_child_org2.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org2.id,\n child_id: @lv4_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org2.id,\n child_id: @lv4_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv5_child_org2.id,\n distance: 5,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv5_child_org2.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org2.id,\n child_id: @lv5_child_org2.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org2.id,\n child_id: @lv5_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv4_child_org2.id,\n child_id: @lv5_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\nend",
"def initialize(root_node=[0,0])\n @root_node = PolyTreeNode.new(root_node)\n @considered_pos = [@root_node.value]\n self.build_move_tree # goes here?\n end",
"def initialize(data_array)\n raise Exception.new(\"parameter should be an Array of data!\") unless data_array.is_a?(Array)\n\n self.root = nil\n\n data_array.each do |data|\n self.insert(data)\n end\n end",
"def build(*nodes, attributes: {}, infos: nil, recursive: true)\n\t\t\tnodes.each do |node|\n\t\t\t\tcase node\n\t\t\t\twhen Hash\n\t\t\t\t\tnode.each do |name,children|\n\t\t\t\t\t\tadd_node(name,children: [*children], attributes: attributes, infos: infos, recursive: recursive)\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tadd_node(node, attributes: attributes, infos: infos, recursive: recursive)\n\t\t\t\tend\n\t\t\tend\n\t\t\tself\n\t\tend",
"def build_tree(arr)\n #take array, turn into bt with node objs\n return nil if arr.empty?\n\n mid = (arr.size - 1)/2\n current_node = Node.new(arr[mid])\n\n current_node.left = build_tree(arr[0...mid])\n current_node.right = build_tree(arr[(mid+1)..-1])\n \n current_node\n end",
"def grow_tree(root, nodes, adopt_fn)\n kids = nodes.select { |w| adopt_fn.call(root, w) }\n branches = kids.map { |k| grow_tree(k, nodes - [root], adopt_fn) }\n { root => branches.reduce(&:merge) }\nend",
"def dup\n self_dup = BranchNode.new(@name)\n each_child { |child| self_dup.add_child(child.dup) }\n self_dup\n end",
"def initialize(tree_hash)\n tree_hash.each do |k, v|\n @node_name = k\n @children = get_children_from(v)\n end\n end",
"def buildTree(node,arr)\n node.value = arr.shift\n size = (arr.size/2.0).round\n if size > 0\n left, right = arr.each_slice( size ).to_a\n if left and left.count > 0\n node.left = TreeNode.new\n buildTree(node.left, left)\n end\n if right and right.count > 0\n node.right = TreeNode.new\n buildTree(node.right, right)\n end\n end\nend",
"def branches_collection(given_branches, root_id = nil)\n @branches_collection ||= []\n given_branches.each do |branch_args_sym, value|\n branch_args = extract_branch_args(branch_args_sym.to_s)\n branch_args << root_id\n branch = SourceFile::Branch.new(*branch_args)\n\n if value.is_a?(Integer)\n branch.coverage = value\n else\n branches_collection(value, branch.id)\n end\n\n @branches_collection << branch\n end\n @branches_collection\n end",
"def initialize_copy(_original)\n new_children = {}\n @children.each do |child_name, child_group|\n new_children[child_name] = []\n child_group.each do |child|\n cloned_child = child.clone\n cloned_child.parent = self\n # cloned_child.root = @root\n new_children[child_name] << cloned_child\n end\n end\n @children = new_children\n end",
"def initial_setup\n # set initial values of vert_pos and sum\n vert_pos = 0\n @sum = @tree[0][0]\n\n # set initial children nodes\n @initial_child_1 = @tree[1][0]\n @initial_child_2 = @tree[1][1]\n end",
"def branch(**new_options)\n if self.is_a?(Builder)\n options = self.options\n else\n options = DEFAULT_OPTIONS.merge(processor: self::Processor)\n end\n\n options = options.merge(new_options) do |key, old_value, new_value|\n case key\n when :loader, :saver then old_value.merge(new_value)\n when :operations then old_value + new_value\n else new_value\n end\n end\n\n Builder.new(options.freeze)\n end",
"def initialize(*args)\n @nodes = args.first || []\n @nodes = @nodes.nodes if @nodes.respond_to?(:nodes)\n @nodes.each {|node| node.parent = self }\n end",
"def produce_tree(ary); end",
"def build_tree(item_list = @sorted_list,root_node = nil)\n #sorted root sorts and removes duplicates from the item list\n if (item_list[0] == nil)\n return nil\n else\n start = 0\n end_of_item_list = item_list.length - 1\n mid = (start + item_list.length) / 2\n #set the root node then start creating a tree node for the left and right side of the array\n #Then after that branch is created attach it to the correct position\n root_node = Node.new(item_list[item_list.length/2])\n root_node.right = build_tree(item_list[0,mid],root_node) \n root_node.left = build_tree(item_list[mid+1,end_of_item_list],root_node)\n return root_node\n end\n \n end",
"def initialize(map=nil)\n if map == nil\n @tree = BinarySearchTree.new\n return\n end\n @tree = map.dup_tree\n end",
"def branch_tree_params\n params.require(:branch_tree).permit(:full_name, :name, :digital_name, :address, :branch_tree_id, :level)\n end",
"def build_tree(arr)\n\ntree = []\n\ntree.push(Node.new(arr[0]))\n\n arr[1..-1].each do |i|\n new_node = Node.new(i)\n\n condition = false\n current = tree[0]\n until condition == true\n if i > current.value && current.find_right_child.count == 0\n new_node.create_parent(current)\n current.create_right_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i < current.value && current.find_left_child.count == 0\n new_node.create_parent(current)\n current.create_left_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i > current.value && current.find_right_child.count == 1\n current = current.find_right_child[0]\n elsif i < current.value && current.find_left_child.count == 1\n current = current.find_left_child[0]\n end\n end\n end\n tree\nend",
"def initialize( item )\n self.item = item\n @left_subtree = nil\n @right_subtree = nil\n end",
"def create_new_tree_with_blobs(oauth_token, file_information, sha_base_tree)\n client = Octokit::Client.new(access_token: oauth_token)\n blob_information = []\n file_information.each do |file|\n # This mode property on this hash represents the file mode for a GitHub tree. \n # The mode is 100644 for a file blob. See https://developer.github.com/v3/git/trees/ for more information\n blob_information << { path: file[:path],\n mode: '100644',\n type: 'blob',\n sha: file[:blob_sha] }\n end\n client.create_tree(full_repo_name, blob_information, base_tree: sha_base_tree)[:sha]\n end",
"def initialize(country_name, region_name, city_name)\n @country_name = country_name\n @region_name = region_name\n @city_name = city_name\n @tree = {}\n @tree['count'] = 0\n end",
"def merge_trees(t1, t2)\n return t2 if t1 == nil\n return t1 if t2 == nil\n value = t1.val += t2.val\n new = TreeNode.new(value)\n new.left = merge_trees(t1.left, t2.left)\n new.right = merge_trees(t1.right, t2.right)\n return new\nend",
"def initialize(tree = nil)\n # creates an undirected adjacency list graph\n @pathway = Bio::Pathway.new([], true)\n @root = nil\n @options = {}\n _init_cache\n self.concat(tree) if tree\n end",
"def trees\n @trees ||= ApiFactory.new 'GitData::Trees'\n end",
"def branch(target, options = {})\n branches << Branch.new(target, options)\n end",
"def test_empty_branch\n #puts \"---------------test_branch-----------------\"\n t1 = t2 = nil\n GraphBuilder::Builder.build do |b|\n t1 = b.add(Thing1.new)\n b.branch do \n end\n t2 = b.add(Thing2.new)\n end\n\n r = Thing.links([t1,t2])\n assert_equal 1, r.size\n assert r.include? [t1,t2]\n end",
"def construct_tree(arr)\n root = TreeNode.new(arr.shift)\n xtd = [root]\n while !xtd.empty? && !arr.empty?\n cur_node = xtd.shift\n a, b = arr.shift(2) # doesn't matter if arr.size < 2. in this case, a, b might be nil\n cur_node.left = a.nil? ? nil : TreeNode.new(a)\n cur_node.right = b.nil? ? nil : TreeNode.new(b)\n xtd << cur_node.left unless cur_node.left.nil?\n xtd << cur_node.right unless cur_node.right.nil?\n end\n root\nend",
"def post_initialize(args)\n begin\n specify_children()\n specify_attributes()\n if(!args.nil?)\n if(args.is_a?(Hash))\n if(args.has_key? :children)\n bulk_children(args[:children])\n end\n if(args.has_key? :attributes)\n #puts \"Has attributes\"\n args[:attributes].keys.each do |a|\n #puts \"Writing attribute:\", a\n @attributes[a] = args[:attributes][a] #TODO, this should have better error checking in it, like is a field required but is passed nil?\n end\n end\n if(args.has_key? :text)\n #puts \"Added text\", args[:text]\n @text = args[:text]\n else\n #TODO #put error that the proper hash keys were not identified.\n end\n end\n else\n #TODO give some indication that no arguments were provided\n end\n #TODO - make this active only on a boolean, possibly filter\n delete_unwanted_children()\n rescue => error\n puts \"Could not create the BuildingSync element properly.\"\n puts error.inspect, error.backtrace\n end\n end",
"def initialize (params = {})\n @parent1 = params.fetch(:Parent1, 'parent 1 unknown')\n @parent2 = params.fetch(:Parent2, 'parent 2 unknown')\n @f2_wild = params.fetch(:F2_Wild, 'f2 wild unknown')\n @f2_p1 = params.fetch(:F2_P1, 'f2-p1 unknown')\n @f2_p2 = params.fetch(:F2_P2, 'f2-p2 unknown')\n @f2_p1p2 = params.fetch(:F2_P1P2, 'f2-p1p2 unknown')\n #I call the method linked genes, to check if the two genes represented in this object are linked\n linked_genes @parent1, @parent2, @f2_wild, @f2_p1, @f2_p2, @f2_p1p2\n @@hybridcross_array << self #Each time we add an object, it goes into gene_array\n end",
"def recurse_nodes(parent_names, source_tmp_geo_area)\n if parent_names.count > 1\n parents = parent_names.dup # Tricky! \n name = parents.shift\n puts \"building internal node: #{name} : #{parents} \"\n add_item(\n name: name,\n parent_names: parents,\n source_table: source_tmp_geo_area.source_table,\n source_table_gid: source_tmp_geo_area.source_table_gid,\n is_internal_node: true\n )\n recurse_nodes(parents, source_tmp_geo_area)\n end\n end",
"def initialize(leaf_count, nodes)\n @leaf_count = leaf_count\n @nodes = nodes\n end",
"def generate_tree\n root =\tTreeNode.new(3)\n root.left =\tTreeNode.new(9)\n right = \t\tTreeNode.new(20)\n right.left = \tTreeNode.new(15)\n right.right = TreeNode.new(7)\n root.right = \tright\n root\nend",
"def initialize(*nodes, attributes: {}, infos: nil)\n\t\t\t@nodes=[]\n\t\t\t# a node can be a Hash or a Node\n\t\t\t# so nodes really is a list of subgraphs\n\t\t\tbuild(*nodes, attributes: attributes, infos: infos)\n\t\tend",
"def tree\n @tree ||= build_tree\n end",
"def initialize_branch\t\n\t\tif params[:branch_id]\n\t\t\tbranch_id = params[:branch_id]\n\t\telse\n\t\t\tbranch_id = current_profile.user_profile.branch.id #Assuming only teachers are able to create events now.\n\t\tend\n \t\t@branch = Branch.find(branch_id)\n\tend",
"def initialize(parent = nil, leaves = [], defer_update = false)\n @parent = parent\n @level = (parent ? parent.level + 1 : 0)\n @children = []\n leaves.each {|leaf| add_leaf(leaf)}\n update_shash unless defer_update\n end",
"def add_tree_data_to_ops(ops)\n ops.each do |op|\n op[:node_hash] = @tree[op[:node]] if op[:op] == :load\n end\n ops\n end",
"def create_branch_point( *elements )\n return Util::ExpressionForms::BranchPoint.new( *elements )\n end"
] | [
"0.691574",
"0.6246609",
"0.61717546",
"0.61243355",
"0.60841304",
"0.59614336",
"0.59594506",
"0.59445596",
"0.5912075",
"0.5849564",
"0.5803994",
"0.5802572",
"0.57915556",
"0.57899034",
"0.57891446",
"0.57454455",
"0.5689306",
"0.56851363",
"0.5685125",
"0.568016",
"0.5655624",
"0.56539816",
"0.56247246",
"0.56070065",
"0.560597",
"0.55870444",
"0.5577477",
"0.55610347",
"0.55558443",
"0.5547752",
"0.5544026",
"0.5533735",
"0.55264497",
"0.5516354",
"0.55114937",
"0.5502341",
"0.54974747",
"0.5496928",
"0.54964936",
"0.5494328",
"0.5491231",
"0.54822683",
"0.54808563",
"0.5479564",
"0.547233",
"0.5472025",
"0.5468754",
"0.5465498",
"0.5463582",
"0.54497725",
"0.5441958",
"0.54401547",
"0.54371005",
"0.5433876",
"0.54303086",
"0.54293525",
"0.5422156",
"0.54189867",
"0.54124266",
"0.5411191",
"0.54006416",
"0.53745836",
"0.5362723",
"0.5358169",
"0.5357433",
"0.53494406",
"0.5346796",
"0.5338371",
"0.53364825",
"0.5334741",
"0.5324313",
"0.53199595",
"0.5313251",
"0.53106445",
"0.53090024",
"0.5308061",
"0.53063375",
"0.53003585",
"0.5297233",
"0.52960324",
"0.5285167",
"0.5272352",
"0.5269599",
"0.5267654",
"0.52670825",
"0.52633274",
"0.5260106",
"0.52582085",
"0.5251601",
"0.525155",
"0.5248713",
"0.5228074",
"0.5225278",
"0.5211021",
"0.52103746",
"0.5207388",
"0.52072376",
"0.52071655",
"0.5196824",
"0.51967686",
"0.5195073"
] | 0.0 | -1 |
Checks whether the tree is really a valid tree, that is if the following conditions are fulfilled: undirected acyclic connected | def valid?
super && !directed?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_tree?\n true\n end",
"def valid_tree?\n false\n end",
"def valid_tree?\n true\n end",
"def valid_tree?\n true\n end",
"def tree_nodes_valid?\n (root_tree_node.present? || top_nav_node_info_cd.zero?) &&\n (branch_tree_node.present? || sub_nav_node_info_cd.zero?) &&\n (leaf_tree_node.present? || trd_nav_node_info_cd.zero?)\n end",
"def is_valid_tree(tree)\n\nend",
"def is_valid?\n leaf_nodes = each_leaf\n leaf_nodes.map(&:is_closed?).reduce(&:&)\n end",
"def valid_tree(current_node)\n return true if current_node.nil?\n\n return false if current_node.left != nil && current_node.left.key > current_node.key\n\n return false if current_node.right != nil && current_node.right.key < current_node.key\n\n return valid_tree(current_node.right) && valid_tree(current_node.left)\n end",
"def valid?\n inner_root.children.detect{|node| node.valid? == false} == nil # should be explicitely nil !!\n end",
"def inconsistent_node?(node)\n return true if !root ||\n !node\n return false if node.tree_node?\n v2 = node.v2?\n return true unless !v2 || node.depth != 0\n return false if v2 == v2?\n\n #state = INVALID\n return true\n end",
"def valid?\n return true unless applicable?\n\n inclusive = spec['inclusive']\n\n case inclusive\n when true, false\n nodes.size > 0\n else\n in_nodes = tree.select(inclusive)\n nodes.size == 0 or in_nodes.size > 0\n end\n end",
"def valid_bst?(root)\n if in_order_traversal(root).sort == in_order_traversal(root)\n return true\n else\n return false\n end\n end",
"def test_node_starts_with_empty_branches\n node = Node.new(50, \"movie a\")\n refute node.left_node\n refute node.right_node\n end",
"def verify_non_destructive\n # Obviously non-destructive because we have a linear path.\n return if ancestor == @local_parent || ancestor == remote\n \n # At this point, they obviously are crossing a branch.\n \n if @local_parent.branch == remote.branch\n # Here's how this work: if you want to cross a *revision history branch* (not\n # a named branch), you have to do a branch merge. So that's not allowed.\n #\n # If dirty, print a special message about your changes\n if working_changeset.changed_files.any? || working_changeset.deleted.any?\n raise abort(\"crosses branches (use 'hg merge' or \"+\n \"'hg update -C' to discard changes)\")\n end\n # Otherwise, just let them know they can't cross branches.\n raise abort(\"crosses branches (use 'hg merge' or 'hg update -C')\")\n elsif working_changeset.changed_files.any? || working_changeset.deleted.any?\n # They're crossing to a named branch, but have a dirty working dir. not allowed.\n raise abort(\"crosses named branches (use 'hg update -C'\"+\n \" to discard changes)\")\n else\n # They just want to switch to a named branch. That's ok, as long as they\n # have no uncommitted changes.\n @overwrite = true\n end\n end",
"def is_valid(node = @current_node)\n\t\treturn node != nil\n\tend",
"def is_well_formed?\n\t\t\treturn self.node_stack.length == 1\n\t\tend",
"def is_leaf?\n self.left_child == nil and\n self.right_child == nil\n end",
"def validate_tree_kind\n if parent_id\n if kind != parent.kind\n err_on(:kind, 'different_kind_from_parent')\n end\n end\n end",
"def validate\n if (depth != parent.depth+1)\n no(\"#{short} has bad depth\")\n end\n ui.puts \"#{indent}ok (depth: #{depth})#{short}\"\n end",
"def valid?\n ((ca.cached_amount >= ca.sum_of_children) ||\n (ca.sum_of_children == 0 && children.empty?)) &&\n children.detect{|node| node.valid? == false} == nil # should be explicitely nil !!\n end",
"def is_valid_binary_tree(root)\n if !root\n return;\n end\n if root && root.left\n if root.val <= root.left.val\n raise Exception.new \"In binary tree the root value must be greater than its left child. Current root #{root.val} left child#{left.right.val}\"\n end\n end\n if root && root.right\n if root.val >= root.right.val\n raise Exception.new \"In binary tree the root value must be less than its right child. Current root #{root.val} right child #{root.right.val}\"\n end\n end\n\n is_valid_binary_tree(root.left)\n is_valid_binary_tree(root.right)\n end",
"def verify_parent_is_not_descendant\n unless self[tree_parent_id_field].nil?\n errors.add(:base, I18n.t(:cyclic, :scope => [:mongo_mapper, :errors, :messages, :tree])) if self.descendants.include?(parent)\n end\n end",
"def leaf?\n left.nil? && right.nil?\n end",
"def leaf_node?(tree_node)\n tree_node.left.nil? && tree_node.right.nil?\nend",
"def valid?\n has_children? and children.inject(true) { |result, el| result and el.valid? }\n end",
"def verify\n 1.upto(@leaf_count - 1) do |node|\n next if @nodes[node] ==\n HashTree.node_hash(node, @nodes[HashTree.left_child(node)],\n @nodes[HashTree.right_child(node)])\n raise \"Tree integrity verification failed\" \n end\n self\n end",
"def leaf?\n self.children.size == 0\n end",
"def leaf?; false end",
"def is_a_leaf?\n self.left_child.nil? && self.right_child.nil?\n end",
"def terminal? u\n raise UndefinedNode, \"Not a node of this tree.\" unless has_node? u\n return true if (1..2).include? nodes.size\n degree(u) == 1\n end",
"def _is_root_node?\n @nodes.size == 1\n end",
"def allowed_type?(parent_node); end",
"def validate\n return false unless ( @graph.nodes.has_key? @source.name and @graph.nodes.has_key? @destination.name )\n true\n end",
"def no_children?(node)\n return true unless node\n node.left.nil? && node.right.nil?\n end",
"def leaf?\n !node?\n end",
"def nested?\n @nodes.any?\n end",
"def valid?\n acyclic? and connected?\n end",
"def no_children(node)\n return true if node.left.nil? && node.right.nil?\n false\n end",
"def equal_by_tree?(graph_obj1, graph_obj2)\n check_pre((graph_obj?(graph_obj1) and graph_obj?(graph_obj2)))\n if (not equal_by_dim?(graph_obj1, graph_obj2)) then false\n elsif graph_obj1.union1d? and graph_obj2.union1d? then equal_by_tree?(graph_obj1.left, graph_obj2.left) and \n equal_by_tree?(graph_obj1.right, graph_obj2.right)\n# elsif (range1d?(graph_obj1) and range1d?(graph_obj2)) or\n# (point1d?(graph_obj1) and point1d?(graph_obj2)) then (graph_obj1 == graph_obj2)\n elsif graph_obj1.union2d? and graph_obj2.union2d? then equal_by_tree?(graph_obj1.left, graph_obj2.left) and \n equal_by_tree?(graph_obj1.right, graph_obj2.right)\n elsif (graph_obj1.range2d? and graph_obj2.range2d?) or \n (graph_obj1.point2d? and graph_obj2.point2d?) or\n (range1d?(graph_obj1) and range1d?(graph_obj2)) or\n (point1d?(graph_obj1) and point1d?(graph_obj2)) then true\n \n# (graph_obj1.x_range == graph_obj2.x_range) and\n# (graph_obj1.y_range == graph_obj2.y_range)\n# elsif (graph_obj1.point2d? and graph_obj2.point2d?) then (graph_obj1.x == graph_obj2.x) and (graph_obj1.y == graph_obj2.y)\n else false\n end\nend",
"def is_leaf\n return @left == nil\n end",
"def children_are_leaves?\n unless leaf?\n @children[0].leaf?\n end\n end",
"def is_subtree(root)\n\nend",
"def branch_is_empty?(node)\n children = node.children.dup\n return true if children.nil?\n\n # test for only-child situation\n first_born = children.shift\n if children.empty?\n if first_born == n0(:continue)\n return true\n else\n return false\n end\n end\n\n # if only 2 children, check qualificataions, else done and return false\n next_born = children.shift\n if children.empty?\n if (first_born.type == :continue && next_born.type == :set_result) ||\n (first_born.type == :set_result && next_born.type == :continue)\n return true\n end\n end\n false\n end",
"def unknown?\n !root? && !child?\n end",
"def unknown?\n !root? && !child?\n end",
"def unknown?\n !root? && !child?\n end",
"def hierarchical?\n false\n end",
"def validate!\n fail '-- error: nil elements detected' unless nodes.all? && edges.all?\n\n unless nodes.all?(&:name)\n causer = nodes.detect{|e| !e.name}\n fail \"-- error: node without name @#{causer}\"\n end\n end",
"def nodes?\r\n\t\treturn !h? || (h? && root?)\r\n\tend",
"def leaf?\n true\n end",
"def valid_links\n\t\tself.links.select {|l| l.parent_id != nil && l.child_id != nil}\n\tend",
"def leaf?(r)\n r.children.empty?\n end",
"def convertable?(node)\n while(node = node.parent) do\n return false if SKIP.include?(node.name)\n end\n true\n end",
"def is_balanced?\n diff = (self.left.depth - self.right.depth).abs\n if diff <= 1\n true\n else\n false\n end\n end",
"def valid_child(le)\n\t\t\treturn false\n\t\tend",
"def is_node?(); @type == GRT_NODE; end",
"def super_balanced(tree)\n if !tree\n return true\n end\n \n depths = []\n nodes = []\n nodes.push([tree, 0])\n \n while !nodes.empty?\n node, depth = nodes.pop\n \n if !node.left && !node.right\n if !depths.include? depth\n depths.push(depth)\n \n if (depths.length > 2) || (depths.length == 2 && (depths[0] - depths[1]).abs > 1)\n return false\n end\n \n end\n else\n if node.left\n nodes.push([node.left, depth+1])\n end\n if node.right\n nodes.push([node.right, depth+1])\n end\n end\n end\n \n return true \nend",
"def balanced?\n difference_left_right = @root.left_child.depth - @root.right_child.depth\n difference_left_right.between?(-1, 1)\n end",
"def root?\n self.depth.zero?\n end",
"def root?\n self.depth.zero?\n end",
"def test_depth_value_not_exist\n @tree.insert(\"c\")\n refute_equal 0, @tree.depth_of?(\"a\")\n end",
"def leaf?\n @children.length.zero?\n end",
"def all_roots_valid?\n if acts_as_nested_set_options[:scope]\n roots.group_by{|record| scope_column_names.collect{|col| record.send(col.to_sym)}}.all? do |scope, grouped_roots|\n each_root_valid?(grouped_roots)\n end\n else\n each_root_valid?(roots)\n end\n end",
"def isTreeSymmetric(t)\n return true if t.nil?\n return sym?(t.left, t.right)\nend",
"def has_children?(tree_node)\n tree_node.left || tree_node.right\n end",
"def balanced?\n # tree is balanced if the difference between left and right depths is within 1\n (Tree.depth(root.left) - Tree.depth(root.right)).abs <= 1\n end",
"def validate\n validate_root\n validate_associated\n valid?\n end",
"def leaf?\n children.empty?\n end",
"def test_connected_false \n \ttest_neighbor = Node.new(4, \"d\")\n\n \tassert_nil @n.connected?\n end",
"def invalid_leaf?\n if valid_flag\n errors.add(:valid_flag, '契約中のリーフは削除できません。')\n return false\n end\n end",
"def asgn_left?\n OP_ASSIGN.include?(parent_type) && parent.node.children.first.equal?(node)\n end",
"def leaf?\n leaves.count == 0\n end",
"def alt_valid_bst?\n self.to_ll.sorted?\n end",
"def is_valid_bst(root)\r\n return true if root.nil?\r\n inorder_values = inorder_traversal(root)\r\n\r\n (1...inorder_values.size).each do |idx|\r\n return false if inorder_values[idx] <= inorder_values[idx-1]\r\n end\r\n\r\n return true\r\nend",
"def leaf?\n @children.empty?\n end",
"def hasChildren\n if (@left == nil) && (@right == nil)\n return 0\n elsif (@left != nil) && (@right != nil)\n return 2\n else\n return 1\n end\n end",
"def sane_ancestry?\n ancestry.nil? || (ancestry.to_s =~ Ancestry::ANCESTRY_PATTERN && !ancestor_ids.include?(self.id)) \n end",
"def valid_children\n allowed_children_and_descendants.select {|child| child.allowed_parent?(self)}\n end",
"def is_nodetype?(); @type == GRT_NODETYPE; end",
"def equal_by_tree?(g1, g2)\n check_pre((\n (graph_obj?(g1)) and\n (graph_obj?(g2))\n ))\n\n if not equal_by_dim?(g1, g2)\n return false\n end\n\n if comp_shape?(g1) and comp_shape?(g2)\n return (equal_by_tree?(g1.left, g2.left) and equal_by_tree?(g1.right, g2.right))\n elsif g1.range2d? and g2.range2d?\n return (equal_by_tree?(g1.x_range, g2.x_range) and equal_by_tree?(g1.y_range, g2.y_range))\n elsif g1.range1d? and g2.range1d?\n return (\n (g1.first == g2.first) and\n (g1.last == g2.last)\n )\n else\n return false\n end\nend",
"def balanced?(tree_root)\n return true unless tree_root\n depths = []\n nodes = []\n nodes << [tree_root, 0]\n until nodes.empty?\n node, depth = nodes.pop\n if !node.left && !node.right\n unless depths.include?(depth)\n depths.push(depth)\n if depths.length > 2 || depths.length == 2 && (depths[0] - depths[1]).abs > 1\n return false\n end\n end\n else\n nodes << [node.left, depth + 1] if node.left\n nodes << [node.right, depth + 1] if node.right\n end\n end\n true\nend",
"def leaf?\n right - left == 1\n end",
"def is_circular?\n max_level = 0\n each_ancestor { |_, level| max_level = [max_level, level].max }\n each_descendant { |_, level| max_level = [max_level, level].max }\n max_level == RECURSION_DEPTH_LIMIT\n end",
"def include_root?\n min_depth == 0\n end",
"def test_has_node_dummy_with_obj\n nonexistent_node = Node.new(1, [2])\n refute @graph.node?(nonexistent_node)\n end",
"def test_new_tree_empty_root\n assert_equal nil, @tree.root\n end",
"def isSubtree(t1, t2)\n return true if t2.nil?\n return false if t1.nil?\n\n return true if(isIdentical(t1, t2))\n\n (isSubtree(t1.left, t2) || isSubtree(t1.right, t2))\nend",
"def is_balanced(tree_root)\n depths = [] # we short-circuit as soon as we find more than 2\n \n # we'll treat this array as a stack that will store pairs [node, depth]\n nodes = []\n nodes.push([tree_root, 0])\n \n while !nodes.empty?\n # pop a node and its depth from top of stack\n node, depth = nodes.pop\n \n # case: we found a leaf\n if !node.left && !node.right\n \n # we only care if it's a new depth\n if !depths.include? depth\n depths.push(depth)\n \n # two ways we might now have an unbalanced tree\n # 1. more than 2 different leaf depths\n # 2. 2 leaf depths that are more than 1 apart\n if (depths.length > 2) || \\\n (depths.length == 2 && (depths[0] - depths[1]).abs > 1)\n return false\n end\n end\n # case: this isn't a leaf - keep stepping down\n else\n if node.left\n nodes.push([node.left, depth + 1])\n end\n if node.right\n nodes.push([node.right, depth + 1])\n end\n end\n end\n return true\n \nend",
"def validate\n site = JSON.parse(RestClient.get(\"http://reddit.com/r/#{subreddit}/.json\"))\n if site[\"data\"][\"children\"].empty?\n false\n else\n true\n end\n end",
"def valid?\n arcs.each do |arc|\n source_transition = find_transition(arc.source_id)\n source_place = find_place(arc.source_id)\n target_transition = find_transition(arc.target_id)\n target_place = find_place(arc.target_id)\n\n # arc from transition to place\n cond1 = not(source_transition.nil?) && not(target_place.nil?)\n\n # arc from place to transition\n cond2 = not(source_place.nil?) && not(target_transition.nil?)\n\n unless cond1 or cond2\n return false\n end\n end\n\n return true\n end",
"def success?\n [\n original_source,\n original_node,\n generated_source,\n generated_node\n ].all?(&:right?) && generated_node.from_right.==(original_node.from_right)\n end",
"def root?\n depth == 1\n end",
"def valid?\n return false unless @paths.count > 1\n @paths.each do |p|\n return false unless p.valid?\n end\n true\n end",
"def clean_up_closed_if_depth_bound_reached\n if @n.depth == DEPTH_BOUND\n clean_up_closed(@n)\n true\n end\n false\n end",
"def is_balanced_binary_tree?(root)\n is_balanced_rec(root) != -1\nend",
"def has_children?\n !leaf?\n end",
"def undirected?\n @undirected ? true : false\n end",
"def invalid_child?(child)\n false\n end",
"def invalid_child?(child)\n false\n end",
"def invalid_child?(child)\n false\n end"
] | [
"0.81485015",
"0.7981112",
"0.7959057",
"0.7959057",
"0.7629024",
"0.71501994",
"0.69527376",
"0.6856072",
"0.66898006",
"0.66111857",
"0.65457964",
"0.6363072",
"0.6257565",
"0.62017035",
"0.6181386",
"0.6147313",
"0.6130815",
"0.6113278",
"0.61035365",
"0.610086",
"0.6083943",
"0.607248",
"0.6000712",
"0.59953517",
"0.59951365",
"0.5993104",
"0.599091",
"0.5990719",
"0.5987542",
"0.5966653",
"0.5957501",
"0.5929123",
"0.59283125",
"0.5925419",
"0.5920612",
"0.58941305",
"0.58812624",
"0.587329",
"0.58507717",
"0.5814859",
"0.5804581",
"0.58028215",
"0.5796474",
"0.57946223",
"0.57946223",
"0.57946223",
"0.5789358",
"0.5784411",
"0.5779038",
"0.5778036",
"0.57602",
"0.57559896",
"0.57518536",
"0.5738159",
"0.57023937",
"0.5683048",
"0.56757087",
"0.5671626",
"0.56607145",
"0.56607145",
"0.56506187",
"0.5636262",
"0.56354564",
"0.5635049",
"0.56217104",
"0.5619147",
"0.5618463",
"0.5615991",
"0.56141806",
"0.56102675",
"0.5596701",
"0.55919385",
"0.5584194",
"0.55808467",
"0.55723095",
"0.5564498",
"0.5562595",
"0.555821",
"0.55513823",
"0.55504274",
"0.5545045",
"0.5543186",
"0.5542141",
"0.5541769",
"0.5531169",
"0.55295944",
"0.5518072",
"0.5511627",
"0.5510473",
"0.5508956",
"0.5506524",
"0.5503217",
"0.5502563",
"0.5488708",
"0.5487535",
"0.5473618",
"0.54728615",
"0.54726326",
"0.54726326",
"0.54726326"
] | 0.6481792 | 11 |
show method is default | def destroy
@my_posting = Posting.find(params[:id])
@my_posting.destroy
redirect_to "/"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n\t\t end",
"def show ; end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end"
] | [
"0.8790902",
"0.8790902",
"0.8790902",
"0.8790902",
"0.8790902",
"0.8790902",
"0.8790902",
"0.8790902",
"0.8790902",
"0.87746966",
"0.86819065",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.8665737",
"0.86384374",
"0.8638341",
"0.8638341",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306",
"0.86369306"
] | 0.0 | -1 |
include devise helper methods | def setup
@admin = users(:admin)
@user = users(:user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def devise_controller?; end",
"def devise_mappings; end",
"def devise_modules_hook!; end",
"def current_user\n #super the main class of devise current_user\n super || guest_user\n end",
"def devise_parameter_sanitizer; end",
"def devise_scope(scope); end",
"def user_authentication\n end",
"def current_user\n # if a user is logged in we just use devise's implementation.\n super || guest_user\n end",
"def devise_mapping\n @devise_mapping ||= Devise.mappings[:user]\n end",
"def devise_mapping\n @devise_mapping ||= Devise.mappings[:user]\n end",
"def devise_mapping\n @devise_mapping ||= Devise.mappings[:user]\n end",
"def user_provider; end",
"def sign_in\n\n end",
"def show\n render layout: 'devise_layout' if current_user.present? && current_user.admin?\n end",
"def devise_mapping\n @devise_mapping ||= request.env[\"devise.mapping\"]\n end",
"def sign_in\n trait()\n end",
"def sign_in\n end",
"def options\n render \"devise/shared/_links\"\n end",
"def sign_in\n\tend",
"def auth_methods; end",
"def fetch_details_from_devise\n self.username = 'devise_user'\n self.save\n end",
"def sign_in\n trait\n end",
"def signin\n end",
"def add_values_application_controller\n inject_into_class \"app/controllers/application_controller.rb\", \"ApplicationController\" do\n \" helper_method :current_user \\n \" +\n \" after_filter :path \\n\"+\n \" private \\n\" +\n \" def current_user \\n\" +\n \" table_name = Rails.application.config.devise_model_name.titlecase \\n\"+\n \" @table_name = table_name.constantize \\n\"+\n \" @current_user ||= @table_name.find(session[:user_id]) if session[:user_id] \\n\\n\" +\n \" end \\n\\n\" +\n \" def path \\n\"+\n \" path= request.path \\n\"+\n \" notice = request.flash[:notice] \\n\"+\n \" @devise_model_name = Rails.application.config.devise_model_name \\n\"+\n \" if path == '/'+@devise_model_name+'s/sign_up' && notice == 'This is one time process' \\n\"+\n \" count =+ 1 \\n\"+\n \" if count == 1 \\n\"+\n \" session[:last_get_url] = '1' \\n\"+\n \" end \\n\"+\n \" else \\n\"+\n \" count = 0 \\n\"+\n \" session[:last_get_url] = '0' \\n\"+\n \" end \\n\"+\n \" end \\n\\n\"+\n \" def after_sign_in_path_for(current_user) \\n\"+\n \" last_get_url = session[:last_get_url] \\n\"+\n \" if session[:last_get_url].to_s == '1' \\n\"+\n \" @devise_model_name = Rails.application.config.devise_model_name \\n\"+\n \" table_name = Rails.application.config.devise_model_name.titlecase \\n\"+\n \" @table_name = table_name.constantize\\n\"+\n \" @user = @table_name.find_by_id(current_user) \\n \" +\n \" @socialAccounts = SocialAccount.find_by_user_id(@user.id.to_s) \\n\\n\"+\n \" if @socialAccounts \\n \"+\n \" session[:user_id] = @user.id \\n\"+\n \" sign_in(@user) \\n\"+\n \" return root_path \\n\"+\n \" else \\n\"+\n \" @newaccount = SocialAccount.new \\n\"+\n \" @newaccount.user_id = @user.id \\n\"+\n \" @newaccount.provider = session[:auth_provider] \\n\"+\n \" @newaccount.uid = session[:auth_uid] \\n\"+\n \" @newaccount.account_name = session[:auth_account_name] \\n\"+\n \" @newaccount.save! \\n\"+\n \" session[:user_id] = @user.id \\n\"+\n \" sign_in(@user) \\n\"+\n \" return root_path \\n\"+\n \" end \\n\"+\n \" else \\n\"+\n \" session.delete(:auth_provider) \\n\"+\n \" session.delete(:auth_uid) \\n\"+\n \" session.delete(:auth_account_name) \\n\"+\n \" return root_path \\n\"+\n \" end \\n\"+\n \" end \\n\\n\"\n end #EO inject_into_class\n end",
"def auth\n end",
"def auth\n end",
"def email_login\n end",
"def capable_login_auth?; end",
"def add_users\n # Install Devise\n generate \"devise:install\"\n\n # Configure Devise\n environment \"config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }\",\n env: 'development'\n route \"root to: 'home#index'\"\n\n # Devise notices are installed via Bootstrap\n generate \"devise:views:bootstrapped\"\n\n # Create Devise User\n generate :devise, \"User\",\n \"name\",\n \"admin:boolean\"\n\n # Set admin default to false\n in_root do\n migration = Dir.glob(\"db/migrate/*\").max_by{ |f| File.mtime(f) }\n gsub_file migration, /:admin/, \":admin, default: false\"\n end\n\n requirement = Gem::Requirement.new(\"> 5.2\")\n rails_version = Gem::Version.new(Rails::VERSION::STRING)\n\n if requirement.satisfied_by? rails_version\n gsub_file \"config/initializers/devise.rb\",\n / # config.secret_key = .+/,\n \" config.secret_key = Rails.application.credentials.secret_key_base\"\n end\n\n # Add Devise masqueradable to users\n inject_into_file(\"app/models/user.rb\", \"masqueradable, :\", after: \"devise :\")\nend",
"def current_user\n # super: don't change anything, i just want the exact same behavior \n # as in the method that we are overriding\n\n # what this line means is that if the user is logged in, super is true,\n # then call super treat everything normal, and ignore right hand side\n # if super == false, call right hand side\n\n # super comes from devise class\n # meanwhile the r.h.s comes from open struct class\n super || guest_user\n end",
"def development_auth\n @user = User.from_params(development_user_params)\n check_invite(@user)\n handle_sign_in(@user, \"development\")\n end",
"def signed_in_user\n #call and check on method signed_in from session helper if not user login\n unless signed_in?\n #show message to the user\n flash[:danger]=\"Please sign in\"\n #link to sign in page\n redirect_to signin_url\n end\n end",
"def user_app_data\n\t\t# assign devise user as instance variable\n\t\t@user = devise_current_user\n\tend",
"def skip_pundit?\n devise_controller?\n end",
"def authen_method_guest!()\n @authen_method = TAC_PLUS_AUTHEN_METH_GUEST\n end",
"def devise_install(&block)\n if block_given?\n Devise.setup do |config|\n block.call config\n end\n end\n end",
"def send_devise_notification(notification, *args); end",
"def resource_name\n devise_mapping.name\n end",
"def authenticates_access\n include InstanceMethods\n end",
"def password\n Devise.friendly_token[0, 20]\n end",
"def user_key\n send(Devise.authentication_keys.first)\n end",
"def user_key\n send(Devise.authentication_keys.first)\n end",
"def logged_in\r\n end",
"def fetchable_fields\n super - [:password, :password_confirmation]\n # if (context[:current_user].guest)\n # super - [:email]\n # else\n # super\n # end\n end",
"def active_for_authentication?; end",
"def active_for_authentication?; end",
"def ensure_signed_up!\n # current_user\n end",
"def resource_class\n devise_mapping.to\n end",
"def show\n # @has_password = current_user.has_password?\n # @has_email = current_user.authentications.emails.active.any?\n end",
"def show\n # @has_password = current_user.has_password?\n # @has_email = current_user.authentications.emails.active.any?\n end",
"def authenticate_user_devise!\n raise Errors::AuthorizationError, 'Token authentication is not correct' unless current_user_devise\n end",
"def update_devise_rb\n inject_into_file 'config/initializers/devise.rb', after: \"config.sign_out_via = :delete\\n\" do <<-'RUBY'\n\n # Config Social Keys to create the SignUps\n config.sign_out_via = :get\n config.omniauth :facebook, ENV[\"FACEBOOK_KEY\"], ENV[\"FACEBOOK_SECRET\"], { :scope => 'email, offline_access', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}\n config.omniauth :twitter, ENV[\"TWITTER_KEY\"], ENV[\"TWITTER_SECRET\"], { :scope => 'r_fullprofile, r_emailaddress', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}\n config.omniauth :linkedin, ENV[\"LINKEDIN_KEY\"], ENV[\"LINKEDIN_SECRET\"], { :scope => 'r_fullprofile r_emailaddress', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}\n config.omniauth :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: \"user, public_repo\"\n config.omniauth :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], {}\n\n RUBY\n end\n\n puts 'Check your config/initializers/devise.rb which was updated to have the Social Keys used (OmniAuth linked to devise)'.colorize(:light_green)\n puts 'UPDATE your config/initializers/devise.rb if you need more data from the user, CHANGING the: SCOPE'.colorize(:light_yellow)\n end",
"def custom_user_auth\n\t\t\tunless student_signed_in? || admin_signed_in?\n\t\t\t\tredirect_to root_path, notice: \"You have to sign in.\"\n\t\t\tend\n\t\tend",
"def ensure_password\n self.password ||= Devise.friendly_token[0,20]\n end",
"def helpers; end",
"def helpers; end",
"def helpers; end",
"def sign_in\n current_session || sign_user_in\nend",
"def available_email_login?\n true\nend",
"def signin_dropdown\n view_context.multiauth_dropdown(\"Sign In\")\n end",
"def signed_in_user\n #Method signed_in? defined in app/helpers/sessions_helper.rb\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in? #notice :\"Please sign in\" = flash[:notice] = \"Please sign in\"\n end",
"def signed_in_user\n #Method signed_in? defined in app/helpers/sessions_helper.rb\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in? #notice :\"Please sign in\" = flash[:notice] = \"Please sign in\"\n end",
"def log_in_as(user) # with devise gem\n if integration_test?\n include Devise::Test::IntegrationHelpers\n else\n sign_in(user, scope: :user)\n end\n login_as(user, :scope => user)\n end",
"def allowed_auth_methods; end",
"def signup_info\n end",
"def apply_devise_schema(name, type, options={})\n raise NotImplementedError\n end",
"def sign_in_local\n __log_activity\n __debug_route\n end",
"def authentication_profile\n super\n end",
"def authenticate_user\n current_user\n end",
"def devise_ip_authentication(mapping, controllers)\n resource :ip_authentication, only: %i(show), path: mapping.path_names[:ip_authentication],\n controller: controllers[:ip_authentications]\n end",
"def login_helper(style = '')\n if current_user.is_a? GuestUser\n _span(link_to('Register', new_user_registration_path, class: style)) +\n _span(link_to('Login', new_user_session_path, class: style))\n else\n _span(link_to('Logout', destroy_user_session_path, method: :delete, class: style))\n end\n end",
"def authentication_method\n super\n end",
"def current_user\n \tsuper || guest_user\n \t#Super quiere decir que exactamente con los valores \n \t#del metodo original sin cambiar nada\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:email, :password) }\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :password, :password_confirmation) }\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:email, :password, :password_confirmation, :current_password) }\n end",
"def user; end",
"def user; end",
"def determine_current_user_helper\n current_user_helper = options[\"current-user-helper\"].presence ||\n ask(\"What will be the current_user helper called in your app? [current_user]\").presence ||\n :current_user\n\n puts \"Defining cadenero_user method inside ApplicationController...\"\n\n cadenero_user_method = %Q{\n def cadenero_user\n #{current_user_helper}\n end\n helper_method :cadenero_user\n\n}\n\n inject_into_file(\"#{Rails.root}/app/controllers/application_controller.rb\",\n cadenero_user_method,\n :after => \"ActionController::API\\n\")\n\n end",
"def auth_options\n # Use Devise's first authentication method (e.g. email or username) to\n # get the sign in parameter\n authn_method = serialize_options(resource)[:methods].first\n authn_value = sign_in_params[authn_method]\n\n # Look for a user matching that email/username\n user = resource_class.find_for_authentication(authn_method => authn_value)\n\n super.merge(\n sign_in_params: sign_in_params.except(\"password\"),\n user: user\n )\n end",
"def warden; end",
"def warden; end",
"def warden; end",
"def devise_mail(record, action, opts = T.unsafe(nil), &block); end",
"def add_discerner_user_method\n current_user_helper = options[\"current-user-helper\"].presence ||\n ask(\"What is the current_user helper called in your app? [current_user]\").presence ||\n 'current_user if defined?(current_user)'\n puts \"Defining discerner_user method inside ApplicationController...\"\n\n discerner_user_method = %Q{\n def discerner_user\n #{current_user_helper}\n end\n helper_method :discerner_user\n}\n inject_into_file(\"#{Rails.root}/app/controllers/application_controller.rb\",\n discerner_user_method,\n after: \"ActionController::Base\\n\", force: false)\n end",
"def helpers\n ApplicationController.helpers\n end",
"def helpers\n ApplicationController.helpers\n end",
"def auth(value); end",
"def access_control\n \n end",
"def logged_in_as\n user = User.find session[:user_id]\n \"Logged in as #{user.email}\"\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_in) do |user_params|\n user_params.permit(:email, :password, :remember_me)\n end\n\n devise_parameter_sanitizer.permit(:sign_up) do |user_params|\n user_params.permit(:email, :password, :password_confirmation)\n end\n end",
"def client_sign_up\n\n end",
"def clean_up_passwords; end",
"def devise_i18n_options(options)\n options[:scope] = \"devise.registrations\"\n options\n end",
"def user\n end",
"def current_or_guest_user\n Rails.logger.warn(\"current_or_guest_user is DEPRECATED - just use current_user\") \n current_user\n end",
"def sign_in_user user\n @request.env[\"devise.mapping\"] = Devise.mappings[:user]\n sign_in user\n end",
"def auth_store; end",
"def email\n login\n end",
"def devise(*modules)\n # hack to get around Neo4j's requirement to index before uniqueness validation\n index :email, :type => :exact if modules.include?(:validatable)\n super\n end",
"def instruct_user!\n end",
"def enable_devise_user(view)\n without_partial_double_verification do\n allow(view).to receive(:resource) { User.new }\n allow(view).to receive(:resource_class) { User }\n allow(view).to receive(:resource_name) { :user }\n allow(view).to receive(:devise_mapping) { Devise.mappings[:user] }\n end\n end",
"def authorization; end"
] | [
"0.7576859",
"0.7219472",
"0.7157984",
"0.6675184",
"0.6668521",
"0.6640306",
"0.66053385",
"0.6424436",
"0.62998796",
"0.62998796",
"0.62998796",
"0.62581426",
"0.6153387",
"0.6149502",
"0.6124568",
"0.61117995",
"0.6107976",
"0.6087983",
"0.60797405",
"0.6054703",
"0.6038416",
"0.6025379",
"0.59774506",
"0.5933254",
"0.5906633",
"0.5906633",
"0.58673006",
"0.5863225",
"0.58620214",
"0.5854801",
"0.58199966",
"0.58123654",
"0.5807563",
"0.58040243",
"0.57916266",
"0.5768789",
"0.57644755",
"0.57628745",
"0.5762219",
"0.5761295",
"0.57512796",
"0.57512796",
"0.5740277",
"0.5739466",
"0.57361656",
"0.57361656",
"0.57136506",
"0.56934035",
"0.5682872",
"0.5682872",
"0.5671153",
"0.5661136",
"0.56599957",
"0.56575155",
"0.5642394",
"0.5642394",
"0.5642394",
"0.56280005",
"0.56268644",
"0.5602291",
"0.559381",
"0.559381",
"0.5592927",
"0.5588373",
"0.55880105",
"0.5580119",
"0.55596817",
"0.5547938",
"0.55477285",
"0.5540287",
"0.5534931",
"0.55213046",
"0.5521053",
"0.5517068",
"0.551291",
"0.551291",
"0.5508741",
"0.55069625",
"0.55064034",
"0.55064034",
"0.55064034",
"0.54978",
"0.5495763",
"0.54917455",
"0.54917455",
"0.5479895",
"0.5479322",
"0.54759914",
"0.54757786",
"0.54652673",
"0.546413",
"0.54623395",
"0.54586786",
"0.5458564",
"0.54462093",
"0.5442216",
"0.5434563",
"0.54274756",
"0.5425168",
"0.5418753",
"0.5418704"
] | 0.0 | -1 |
Parses the commandline arguments and runs the executable. Calls `Kernelexit` at the end, so it never returns. | def parse!
begin
@opts = OptionParser.new(&method(:set_opts))
@opts.parse!(@args)
@options
rescue Exception => e
raise e if e.is_a?(SystemExit)
$stderr.puts e.message
exit 1
end
exit 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run\n begin\n raise TooManyArgumentsError.new(@arguments) if @arguments.length > 1\n \n print_version if @options.version?\n scan if @options.scan?\n rename_given_file unless @arguments.empty?\n run_gui if @arguments.empty?\n \n raise Error\n rescue => e\n puts e.to_s\n \n exit(1)\n end\n end",
"def run\n if arguments = parse_arguments\n begin\n process(arguments)\n rescue RuntimeError => ex\n Console.puts ex.message, :red\n exit 1\n end\n else\n if show_help?\n show_help(nil, Console.width).each do |line|\n Console.puts line, :cyan\n end\n else\n show_usage(nil, Console.width).each do |line|\n Console.puts line, :yellow\n end\n end\n exit 2\n end\n end",
"def run\n standard_exception_handling do\n handle_env(ENV)\n handle_options(ARGV)\n config.cmdline = CmdlineBuilder.new(config, Dir.pwd, $0, ENV)\n @output_stream.puts config.output\n end\n end",
"def run(argv)\n options = parse(argv)\n invoke!(options.to_h)\n end",
"def run\n code = 0\n opt = OptionParser.new\n define_options(opt)\n default_options(opt)\n define_exit_codes(opt)\n argv = opt.parse!\n\n if @help\n puts_msg(opt.help)\n\n else\n begin\n main(argv)\n rescue Exception => e\n arr = @@exit_code_map[e.class]\n code = arr ? arr[0] : 1\n puts_err e.to_s\n puts_err \"[ERROR]\"\n end\n end\n\n exit(code)\n end",
"def run\n testable = Parser.new(@argv).parse\n Executor.new(testable).execute\n end",
"def command_line\r\n ARGV.each do |arg|\r\n if arg == \"instructions\"\r\n instructions\r\n elsif arg == \"calculator\"\r\n ask_for_digits\r\n else\r\n \r\n end\r\n end\r\n \r\n end",
"def run\n\n if parsed_options? && arguments_valid? \n process_arguments \n process_command\n else\n output_usage\n end\n\n end",
"def _run(argv = [])\n execute(parse_options(argv))\n end",
"def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n if process_arguments == false\n return\n end\n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end",
"def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n output_options if @options.verbose\n process_arguments \n start\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n else\n output_usage\n end \n end",
"def run\n unless parsed_options? && arguments_valid? \n output_usage and return\n end\n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n end",
"def run\n if parsed_options? && arguments_valid? \n process_arguments \n process_command\n else\n output_usage\n end\n end",
"def run\n\t\tif parsed_options? && arguments_valid?\n\t\t\toutput_options if @options[:verbose]\n\t\t\toutput_arguments if @options[:verbose]\n\t\t\tprocess_arguments\n\t\t\tprocess_command\n\t\telse\n\t\t\toutput_usage\n\t\tend\n\tend",
"def run\n if parsed_options? && arguments_valid?\n log \"Start at #{DateTime.now}\\n\"\n output_options\n\n process_arguments\n process_command\n log \"Finished at #{DateTime.now}\"\n else\n output_usage\n end\n end",
"def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n\n process_arguments \n process_command\n\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n\n else\n output_usage\n end\n end",
"def run(argv = ARGV)\n parser.parse(argv)\n end",
"def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end",
"def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end",
"def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end",
"def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end",
"def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end",
"def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end",
"def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\\n\\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n os \n process_command\n \n puts \"\\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end",
"def run\n setup_options\n\n if parse_options?\n\n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n\n show_effective_options if @options.verbose\n\n # do_work(WordAnalyzer)\n\n # example alternate analyzer implementation\n do_work(AdaptiveWordAnalyzer)\n\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n\n 0 # happy shell exit code\n else\n show_help\n end\n end",
"def run(argv = ARGV)\n #p [:argv, argv]\n begin\n # cheating\n if argv.include?('-h') or argv.include?('--help')\n puts help_text\n else\n app = from_argv(argv)\n app.run\n end\n rescue Exception => e\n if exit_status == 0\n exit_status 1\n end\n puts \"\\nERROR: #{e}\"\n ensure\n exit(exit_status)\n end\n end",
"def run\n\n\t\tif parsed_options? && arguments_valid?\n\n\t\t puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n\n\t\t output_options if @options.verbose # [Optional]\n\n\t\t process_arguments\n\t\t process_command\n\n\t\t puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n\n\t\telse\n\t\t output_usage\n\t\tend\n\n\tend",
"def run\n\n if parsed_options? && arguments_valid? \n\n puts \"Start at #{Time.new.to_s}\\n\\n\" if @options.verbose\n\n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n\n puts \"\\nFinished at #{Time.new.to_s}\" if @options.verbose\n\n else\n output_usage\n end\n\n end",
"def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\\\n\\\\n\" if @options.verbose\n\n process_arguments \n process_command\n \n puts \"\\\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end",
"def run(argv)\n # parse and analyze the command line\n options = Trollop::with_standard_exception_handling @args_parser do\n opts = @args_parser.parse(argv)\n\n raise Trollop::CommandlineError.new \"Too many arguments\" if argv.length > 1\n \n opts\n end\n \n path = (argv.shift or '.')\n \n Dir.chdir(path) do\n #include CRake\n load(options.input)\n end\n \n code = gen_cmake_code\n \n puts code # tem for debugging\n \n write_cmake_lists\n \n puts 'Calling CMake...'\n call_cmake\n end",
"def run \n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\"\n process_arguments(@validoptions.args)\n puts \"Finished at #{DateTime.now}\"\n else\n raise BoilerMakerErr.new(\"Could not parse options. An unknown error has ocurred.\")\n exit $!\n end\n end",
"def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\" if @options.verbose\n output_options if @options.verbose # [Optional]\n process_arguments\n # add parameters\n args = {}\n # TODO: use correct syntax for set\n args[:verbose] = @options.verbose if @options.verbose\n args[:input] = @options.input if @options.input\n args[:output] = @options.output if @options.output\n args[:map_name] = @options.map_name if @options.map_name\n args[:not_installed] = @options.cwd if @options.cwd\n \n program = Guy.new args\n program.work\n puts \"Finished at #{DateTime.now}\" if @options.verbose\n else\n output_usage\n end \n end",
"def main\n if system(ARGV.join(\" \"))\n exit 0\n else\n main\n end\nend",
"def run\n if options_valid? && option_combinations_valid? \n process_arguments \n process_command\n else\n output_usage\n end\n end",
"def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\\\\n\\\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\\\nFinished at #{DateTime.now}\" if @options.verbose\n else\n output_usage\n end\n end",
"def run\n if parsed_options? && arguments_valid?\n log \"Start at #{DateTime.now}\\n\"\n output_options\n process_command\n log \"Finished at #{DateTime.now}\"\n else\n output_usage\n end\n end",
"def run\n if parsed_options? && arguments_valid?\n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n output_options if @options.verbose\n\n process_command\n\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n else\n output_usage\n end\n end",
"def run\n @arguments = ArgumentParser.get_arguments VALID_ARGUMENTS\n print_help if (@arguments[:options][:help])\n print_version if (@arguments[:options][:version])\n if (@arguments[:keywords][:export])\n handle_export\n elsif (@arguments[:keywords][:import])\n handle_import\n else\n print_help\n end\n end",
"def run(arguments)\n config = Configuration.load_applicable\n run_command(config, arguments)\n\n ExitCodes::OK\n rescue => ex\n ErrorHandler.new(@ui).handle(ex)\n end",
"def run\n if !options_parsed?() || !options_valid?()\n @stderr.puts(\"\")\n output_usage(@stderr)\n return 1\n end\n return run_real()\nend",
"def run\n # puts \"parsed_options? >>> #{parsed_options?}\"\n # puts \"arguments_valid? >>> #{arguments_valid?}\"\n if parsed_options? && arguments_valid?\n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n process_arguments\n \n output_options if @options.verbose # [Optional]\n \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end",
"def run(args)\n opts = parse_options(args)\n unless @end_program\n crawler = Spiderman::Crawler.new(opts)\n crawler.crawl\n end\n end",
"def run\n begin\n process_arguments\n rescue ArgumentError\n output_usage\n end\n end",
"def run\n # puts arguments_valid?\n if parsed_options?\n puts \"Start at #{DateTime.now}\" if verbose?\n\n output_options if verbose?\n\n process_command\n\n puts \"\\nFinished at #{DateTime.now}\" if verbose?\n else\n puts 'The options passed are not valid!'\n end\n end",
"def run\n if parsed_options? && arguments_valid? \n process_arguments \n process_command\n else\n output_options\n end\n end",
"def run(args)\n safely_mkdir(MAIN_DIR)\n safely_mkdir(MOD_DIR)\n safely_mkdir(PACK_DIR)\n\n return HELP_TEXT if args.include?('-h') || args.include?('--help')\n return VERSION if args.include?('-v') || args.include?('--version')\n\n case args[0]\n when 'help'\n return HELP_COMMANDS[args[1].to_sym] if HELP_COMMANDS.key?(args[1].to_sym)\n return HELP_TEXT\n when 'fetch'\n return CommandFetch.run(args[1])\n when 'manifest'\n return CommandFetch.install_manifest(args[1])\n when 'installmod'\n return CommandInstall.run_mod(args[1])\n when 'installpack'\n return CommandInstall.run_pack(args[1]).to_s # remove\n else\n end\n end",
"def run\n \n if parsed_options? && arguments_valid?\n \n output_options if @options.verbose # [Optional]\n \n process_arguments\n \n # run as import_nsw_candidates -p \"data/postcodes_2010nsw.csv\" -c\n postcode_parser = ParsePostcodeNSW.new()\n postcode_parser.parse(@options.postcodes)\n \n candidate_parser = ParseCandidateNSW.new()\n candidate_parser.parse(@options.candidates)\n \n else\n output_usage\n end\n \n end",
"def run!(options = {})\n run_option_parser.parse!(ARGV.dup) unless ARGV.empty?\n @running = true\n super(options)\n end",
"def run(argv)\n _run(argv)\n rescue Quickl::Error => ex\n handle_error(ex)\n end",
"def parse(args)\n @args = args\n @instruction = args.join(' ')\n until @args.empty?\n arg = @args[0]\n if @instructions.key? arg\n @args.shift\n buff = args_extract(arg, @instructions[arg][0])\n @to_exec << [arg, buff]\n else\n bad_argument_exit(arg)\n end\n end\n run\n end",
"def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n output_options if @options.verbose # [Optional]\n process_arguments \n process_command\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n else\n Trollop::die \"user error, replace user and continue\"\n end\n end",
"def run(arguments)\n run_command(arguments)\n\n ExitCodes::OK\n rescue => ex\n ErrorHandler.new(@ui).handle(ex)\n end",
"def run!\n trace = false\n require_program :version, :description\n\n global_option('-h', '--help', 'Help on any command', :hide => true)\n global_option('--version', 'Display version information', :hide => true)\n\n # special case --debug so all commands can output relevant info on it\n $terminal.debug = options_parse_debug\n\n # special case --trace because we need to use it in the runner\n trace = options_parse_trace\n\n # special case --version so it is processed before an invalid command\n options_parse_version\n\n # help is a special branch prior to command execution\n options_parse_help\n\n unless trace\n begin\n run_active_command\n rescue InvalidCommandError => e\n run_help(provided_arguments)\n rescue \\\n OptionParser::InvalidOption => e\n RHC::Helpers.error e.message\n 1\n rescue \\\n ArgumentError,\n OptionParser::ParseError => e\n\n help_bindings = CommandHelpBindings.new(active_command, commands, self)\n usage = RHC::HelpFormatter.new(self).render_command_syntax(help_bindings)\n message = case e\n when OptionParser::AmbiguousOption\n \"The option #{e.args.join(' ')} is ambiguous. You will need to specify the entire option.\"\n else\n e.message\n end\n\n RHC::Helpers.error message\n say \"#{usage}\"\n 1\n rescue RHC::Exception, RHC::Rest::Exception => e\n RHC::Helpers.error e.message\n e.code.nil? ? 128 : [1, (e.code || 1).to_i].max\n end\n else\n run_active_command\n end\n end",
"def parse_command_line args\n args.options do |opt|\n opt.on(\"rutema v#{Version::STRING}\")\n opt.on(\"Options:\")\n opt.on(\"--config FILE\", \"-c FILE\",String,\"Loads the configuration from FILE\") { |config_file| @config_file=config_file}\n opt.on(\"--check\",\"Runs just the suite setup test\"){@check=true}\n #opt.on(\"--step\",\"Runs test cases step by step\"){@step=true}\n opt.on(\"--silent\",\"Suppresses console output (only for the default reporters)\") { @silent=true}\n opt.on(\"--bare\",\"No default reporters whatsoever\") { @bare=true}\n #opt.on(\"--color\",\"Adds color to the Console reporter\") { @color=true}\n opt.on(\"-v\", \"--version\",\"Displays the version\") { $stdout.puts(\"rutema v#{Version::STRING}\");exit 0 }\n opt.on(\"--help\", \"-h\", \"-?\", \"This text\") { $stdout.puts opt; exit 0 }\n opt.on(\"--debug\", \"-d\", \"Turn on debug messages\") { $DEBUG=true }\n opt.on(\"You can provide a specification filename in order to run a single test\")\n opt.parse!\n #and now the rest\n unless @config_file\n puts \"No configuration file defined!\\n\"\n $stdout.puts opt \n exit 1\n end\n if !args.empty?\n @test_identifier=args.shift\n end\n end\n end",
"def run(argv)\n load_tasks\n\n if argv.empty?\n print_help\n else\n build_task(argv).run\n end\n end",
"def checkCommandLine\r\n if ARGV.length != 2\r\n puts \"\\nUsage: sum <fileName> <numThreads>\\n\\n\"\r\n exit(1)\r\n end\r\nend",
"def initialize(argv = [])\n @debug = $DEBUG\n @verbose = $VERBOSE\n @version_requested = false\n\n opt = OptionParser.new\n opt.banner = 'Usage: peeek [switches] [--] [programfile] [arguments]'\n opt.summary_indent = ' ' * 2\n opt.summary_width = 15\n\n @working_directory = nil\n\n opt.on('-Cdirectory', 'cd to directory before executing your script') do |directory|\n @working_directory = directory\n end\n\n opt.on('-d', '--debug', 'set debugging flags (set $DEBUG to true)') do\n @debug = true\n @verbose = verbose_by(VERBOSE)\n end\n\n commands = []\n\n opt.on(\"-e 'command'\", \"one line of script. Several -e's allowed. Omit [programfile]\") do |command|\n commands << command\n end\n\n if self.class.encoding_options_enabled?\n @external_encoding = Encoding.default_external\n @internal_encoding = Encoding.default_internal\n\n opt.on('-Eex[:in]', '--encoding=ex[:in]', 'specify the default external and internal character encodings') do |encodings|\n external_encoding, internal_encoding = parse_encodings(encodings)\n @external_encoding = external_encoding if external_encoding\n @internal_encoding = internal_encoding\n end\n end\n\n @hook_targets = []\n\n opt.on('-Hstring', 'object and method name that is target of hook') do |string|\n hook_spec = Hook::Specifier.parse(string)\n @hook_targets << hook_spec unless @hook_targets.include?(hook_spec)\n end\n\n @directories_to_load = []\n\n opt.on('-Idirectory', 'specify $LOAD_PATH directory (may be used more than once)') do |directory|\n @directories_to_load << directory unless @directories_to_load.include?(directory)\n end\n\n @required_libraries = []\n\n opt.on('-rlibrary', 'require the library before executing your script') do |library|\n @required_libraries << library unless @required_libraries.include?(library)\n end\n\n opt.on('-v', 'print version number, then turn on verbose mode') do\n @version_requested = true\n @verbose = verbose_by(VERBOSE)\n end\n\n opt.on('-w', '--verbose', 'turn warnings on for your script') do\n @verbose = verbose_by(VERBOSE)\n end\n\n level_strings = [:SILENCE, :MEDIUM, :VERBOSE].map do |const_name|\n \"#{self.class.const_get(const_name)}=#{const_name.to_s.downcase}\"\n end\n\n opt.on(\"-W[level=#{VERBOSE}]\", \"set warning level; #{level_strings * ', '}\", Integer) do |level|\n @verbose = verbose_by(level || VERBOSE)\n end\n\n @continued = true\n\n opt.on('--version', 'print the version') do\n @version_requested = true\n @continued = false\n end\n\n opt.on_tail('-h', '--help', 'show this message') do\n raise Help, opt.help\n end\n\n @arguments = opt.order(argv)\n @command = commands * '; '\n end",
"def run(args = ARGV, disable_usage_message = false)\n # TODO: signal handling of some kind?\n\n result, matched = _run(args.dup)\n\n if !matched && !disable_usage_message\n usage\n end\n\n result\n rescue RuntimeError => e\n if @rescue_errors\n $stderr.puts \"A runtime error occured: #{e.message.strip}\"\n nil\n else\n raise e\n end\n end",
"def run(argv)\n arguments = parse(argv)\n return if @quit\n\n Wright.activate_dry_run if @dry_run\n Wright.log.level = @log_level if @log_level\n @main.extend Wright::DSL\n\n run_script(arguments)\n end",
"def run(args = [], runtime_options = {})\r\n begin\r\n parse!(args.dup, runtime_options)\r\n rescue OptionParser::InvalidOption => e\r\n # Don't cry, script. Generators want what you think is invalid.\r\n end\r\n\r\n # Generator name is the only required option.\r\n unless options[:generator]\r\n usage if args.empty?\r\n options[:generator] ||= args.shift\r\n end\r\n\r\n # Look up generator instance and invoke command on it.\r\n Rails::Generator::Base.instance(options[:generator], args, options).command(options[:command]).invoke!\r\n rescue => e\r\n puts e\r\n puts \" #{e.backtrace.join(\"\\n \")}\\n\" if options[:backtrace]\r\n raise SystemExit\r\n end",
"def run(*args)\n cli.run(*args)\n end",
"def cli(commandline_arguments)\n CLITest.new(BIN_P).run(commandline_arguments)\n end",
"def run(argv)\n arguments = parse(argv)\n return if quit\n\n Wright.activate_dry_run if dry_run\n Wright.log.level = log_level if log_level\n main.extend Wright::DSL\n requires.each { |r| require r }\n\n run_script(arguments)\n end",
"def run\n \n if parsed_options?\n \n process_command\n end\n \n end",
"def call(*args)\n puts parser.help\n exit 1\n end",
"def run\r\n return puts(\"usage example: glimmer run tictactoe\") unless @name\r\n # Search for the filename (and add the .rb extension if not provided), and run it\r\n if File.exist?(\"#{@name}#{'.rb' unless @name =~ /.rb$/}\")\r\n command = \"#{JRUBY_COMMAND} \\\"#{@name.gsub(/\\\\/, '/')}#{'.rb' unless @name =~ /.rb$/}\\\"\"\r\n else\r\n # Search for all installed samples and try to run of those\r\n command = \"#{JRUBY_COMMAND} \\\"#{SAMPLES_PATH}/#{fetch_app(@name)}.rb\\\"\"\r\n end\r\n puts \"Starting the application with following command:\"\r\n puts command\r\n system command\r\n end",
"def go_with_args(argv=[])\n catch(:exit_err) { catch(:exit_zero) { @cli_obj.go(argv) } }\n end",
"def main(args=[])\n if args.empty?\n puts @prog_list.keys.sort.join(\", \")\n else\n puts \"Game Lessons Launcher, Args = [#{args.join(\",\")}]\"\n require @prog_list[args[0]]\n end\n rescue GamesLessonNotFoundError\n puts \"The program #{args[0]} was not found.\"\n end",
"def check_command_line\n if (!ARGV[0].nil? && ARGV[0].downcase == \"test\")\n @test = true\n elsif(ARGV.length < 2)\n puts \"USAGE: ruby main.rb <users_csv_file> <businesses_csv_file>\"\n puts \"OR\"\n puts \"USAGE: ruby main.rb test\"\n exit 1\n end\nend",
"def run args\n if host.nil?\n fail_with \"This system is not supported.\"\n elsif (task.verb = extract_verb(args)).nil?\n fail_with \"Not sure what you meant.\"\n else\n parse_cmdline task.verb, args\n send \"handle_#{task.verb.def.name}\", task.verb\n end\n ensure\n Base.threads.each &:join\n end",
"def run\n begin\n parse_options\n rescue UnsupportedOption\n exit 1\n end\n\n dir = @options[:directory]\n Dir.chdir(dir) if dir\n\n prune_bundler if prune_bundler?\n\n set_rack_environment\n\n if clustered?\n @events.formatter = Events::PidFormatter.new\n @options[:logger] = @events\n\n @runner = Cluster.new(self)\n else\n @runner = Single.new(self)\n end\n\n setup_signals\n set_process_title\n\n @status = :run\n\n @runner.run\n\n case @status\n when :halt\n log \"* Stopping immediately!\"\n when :run, :stop\n graceful_stop\n when :restart\n log \"* Restarting...\"\n @runner.before_restart\n restart!\n when :exit\n # nothing\n end\n end",
"def execute\n if options[:version]\n self.console.puts \"traject version #{Traject::VERSION}\"\n return true\n end\n if options[:help]\n self.console.puts slop.to_s\n return true\n end\n\n\n (options[:load_path] || []).each do |path|\n $LOAD_PATH << path unless $LOAD_PATH.include? path\n end\n\n arg_check!\n\n self.indexer = initialize_indexer!\n\n ######\n # SAFE TO LOG to indexer.logger starting here, after indexer is set up from conf files\n # with logging config.\n #####\n\n indexer.logger.info(\"traject (#{Traject::VERSION}) executing with: `#{orig_argv.join(' ')}`\")\n\n # Okay, actual command process! All command_ methods should return true\n # on success, or false on failure.\n result =\n case options[:command]\n when \"process\"\n (io, filename) = get_input_io(self.remaining_argv)\n indexer.settings['command_line.filename'] = filename if filename\n indexer.process(io)\n when \"marcout\"\n (io, filename) = get_input_io(self.remaining_argv)\n indexer.settings['command_line.filename'] = filename if filename\n command_marcout!(io)\n when \"commit\"\n command_commit!\n else\n raise ArgumentError.new(\"Unrecognized traject command: #{options[:command]}\")\n end\n\n return result\n rescue Exception => e\n # Try to log unexpected exceptions if possible\n indexer && indexer.logger && indexer.logger.fatal(\"Traject::CommandLine: Unexpected exception, terminating execution: #{Traject::Util.exception_to_log_message(e)}\") rescue nil\n raise e\n end",
"def run\n write_parameter_file\n Tandem.run_commandline_application\n end",
"def run(arguments)\n parse(arguments)\n configure\n execute\n end",
"def run(*args)\n if args.empty? || (args.size == 1 && %w(-h --help).include?(args.first))\n puts help\n else\n sparkline = Sparkline.new(args.map(&:to_f))\n puts sparkline.to_s\n end\n end",
"def main(command_line_options=ARGV)\n parser = Slop::Parser.new cli_flags\n arguments = parse_arguments(command_line_options, parser)\n\n if arguments.key?(:ce) || arguments.key?(:ci) || arguments.key?(:h)\n if arguments.key?(:ci)\n\n end\n if arguments.key?(:ce)\n\n end\n if arguments.key?(:h)\n puts cli_flags\n end\n exit\n end\n\n elsif set?(arguments, :port)\n puts portquiz arguments[:port]\n elsif set?(arguments, :down)\n puts is_it_up arguments[:down]\n end",
"def cli(commandline_arguments)\n CLITest.new(BINARY).run(commandline_arguments)\n end",
"def parse_command_line\n prepend_environment_options\n options = options_with_defaults\n\n OptionParser.new do |parser|\n\n parser.on(\"-h\", \"--help\", \"Show help\") do |_help_requested|\n ARGV << 'h' # pass on the request to the command processor\n options.suppress_command_line_validation = true\n end\n\n parser.on('-i', '--input_dir DIR',\n \"Input directory containing source data files, default: '#{DEFAULT_INPUT_DIR}'\") do |v|\n options.input_dir = File.expand_path(v)\n end\n\n parser.on('-o', '--output_dir DIR',\n \"Output directory to which report files will be written, default: '#{DEFAULT_OUTPUT_DIR}'\") do |v|\n options.output_dir = File.expand_path(v)\n end\n\n parser.on('-r', '--receipt_dir DIR',\n \"Directory root from which to find receipt filespecs, default: '#{DEFAULT_RECEIPT_DIR}'\") do |v|\n options.receipt_dir = File.expand_path(v)\n end\n\n parser.on('-s', '--shell', 'Start interactive shell') do |v|\n options.interactive_mode = true\n end\n\n parser.on('-v', '--[no-]verbose', 'Verbose mode') do |v|\n options.verbose_mode = v\n end\n\n parser.on('-y', '--[no-]say', 'Say error messages.') do |v|\n options.say = v\n end\n\n parser.on('', '--[no-]receipts', 'Include report on existing and missing receipts.') do |v|\n options.do_receipts = v\n end\n end.parse!\n\n if options.verbose_mode\n puts \"Run Options:\"\n ap options.to_h\n end\n\n options\n end",
"def main(argv)\n # override this; no default action in main\n end",
"def main(*args)\n #puts self.class # TODO: fix help\n raise NoCommandError\n end",
"def run(args)\n # force immediate output\n $stdout.sync = true\n\n # setup logging\n Giblog.setup\n\n # Parse cmd line\n cmdline = CmdLineParser.new args\n Giblog.logger.debug { \"cmd line args: #{cmdline.args}\" }\n\n exit_code = execute_conversion(cmdline)\n Giblog.logger.info { \"Giblish is done!\" } if exit_code.zero?\n exit_code\n end",
"def run\n\n if parsed_options? && arguments_valid? && client_configured?\n\n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n\n output_options if @options.verbose # [Optional]\n\n process_arguments\n process_command\n\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n\n else\n output_usage\n end\n\n end",
"def run\n input = OptionParser.new do |opts|\n opts.banner = \"Usage: #{File.basename($0)} [options]\"\n\n opts.on(\"--debug\", \"Turn on debugging output.\") do |debug|\n $DEBUG = @options[:debug] = debug\n end\n\n opts.on(\"-n <path>\", \"--new\", \"Create a new Corrupt application.\") do |path|\n @options[:path] = path\n end\n\n opts.on(\"-v\", \"--version\", \"Print the version.\") do |v|\n output(Corrupt.to_version)\n exit\n end\n end\n\n begin\n @argv << '--help' if @argv.empty?\n input.parse!(@argv)\n take_action!\n rescue OptionParser::InvalidOption => error\n error(\"#{error}\\nTry passing '--help'\")\n rescue OptionParser::MissingArgument => error\n error(\"#{error}\\nTry passing '--help'\")\n end\n end",
"def go(argv)\n logger.debug(\"Using args passed in: #{argv.inspect}\")\n\n cmd = nil\n\n @optparse = OptionParser.new do |opts|\n cmd = super(argv, opts, @config)\n\n opts.on('-v', '--version', 'Print the version') do\n puts \"#{name} #{version}\"\n abort\n end\n end\n\n @optparse.parse!(argv)\n\n logger.debug(\"Parsed config: #{@config.inspect}\")\n\n cmd.execute(argv, @config)\n end",
"def do_as_i_said\n if ARGV.length == 0\n puts $usage\n exit\n elsif ARGV[0] == \"-h\"\n\n arguments = ARGV.dup\n \n if arguments.length > 2\n arguments.slice!(2..(arguments.length - 1))\n end\n \n parse_command_line(arguments)\n \n else\n arguments = ARGV.dup\n command = split_arguments! arguments\n \n # Prevent space character from being considered as a separator.\n arguments.map! do |arg|\n if arg == \" \"\n '\" \"'\n else\n arg\n end\n end\n \n exec(\"#{$current_directory}/gimmicode-#{command} #{arguments.join(\" \")}\")\n end\nend",
"def parse_command_line(args)\n test_configuration = {}\n\n option_parser = OptionParser.new do |opts|\n opts.banner = 'Usage: run-tests.rb [options]'\n opts.separator 'Specific options:'\n\n opts.on('--blinkr', 'Execute broken link checks') do |opt|\n test_configuration[:blinkr] = opt\n end\n\n opts.on('--dcp', 'Execute dcp broken link checks') do |opt|\n test_configuration[:dcp] = opt\n end\n\n opts.on('--base-url RHD_BASE_URL', String, 'Run the tests against the specified host e.g http://developers.stage.redhat.com') do |host|\n test_configuration[:base_url] = host\n end\n\n opts.on('-c CONFIG_FILE', 'specify the config.yaml file for broken link checks') do |opt|\n test_configuration[:config] = opt\n end\n\n opts.on('--ignore-internal', \"Ignore internal URL's\") do |opt|\n test_configuration[:ignore_internal] = opt\n end\n\n opts.on('--ignore-external', \"Ignore external URL's\") do |opt|\n test_configuration[:ignore_external] = opt\n end\n\n opts.on('--ignore-ssl', 'Disable SSL certificate checking for staging environments') do |opt|\n test_configuration[:ignore_ssl] = opt\n end\n\n #\n # Options supporting the execution of the tests within Docker\n #\n opts.on('--use-docker', 'Run the specified test type using Docker') do\n test_configuration[:docker] = true\n end\n\n opts.on_tail('-h', '--help', 'Show this message') do\n puts opts\n Kernel.exit(1)\n end\n end\n\n begin\n option_parser.parse!(args)\n rescue OptionParser::InvalidOption => e\n puts e\n option_parser.parse(%w(-h))\n end\n bind_test_type_environment_variable(test_configuration)\n build_test_execution_command(test_configuration)\n test_configuration\n end",
"def run(args)\n if not defined? Trepan::PROG_SCRIPT\n errmsg \"Don't know name of debugged program\"\n return\n end\n prog_script = Trepan::PROG_SCRIPT\n if not defined? Trepan::PROG_UNRESOLVED_SCRIPT\n # FIXME? Should ask for confirmation? \n msg \"Debugger was not called from the outset...\"\n trepan8_script = prog_script\n else \n trepan8_script = Trepan::PROG_UNRESOLVED_SCRIPT\n end\n begin\n Dir.chdir(Trepan::INITIAL_DIR)\n rescue\n print \"Failed to change initial directory #{Trepan::INITIAL_DIR}\"\n end\n if not File.exist?(File.expand_path(prog_script))\n errmsg \"Ruby program #{prog_script} doesn't exist\\n\"\n return\n end\n if not File.executable?(prog_script) and trepan8_script == prog_script\n msg \"Ruby program #{prog_script} doesn't seem to be executable...\"\n msg \"We'll add a call to Ruby.\\n\"\n ruby = begin defined?(Gem) ? Gem.ruby : \"ruby\" rescue \"ruby\" end\n trepan8_script = \"#{ruby} -I#{$:.join(' -I')} #{prog_script}\"\n else\n trepan8_script += ' '\n end\n if args.size == 1\n if not defined? Trepan::OldCommand.settings[:argv]\n errmsg \"Arguments have not been set. Use 'set args' to set them.\"\n return\n else\n argv = Trepan::OldCommand.settings[:argv]\n end\n else\n argv = [prog_script] + args[1..-1]\n end\n args = argv.join(' ')\n \n # An execv would be preferable to the \"exec\" below.\n cmd = trepan8_script + args\n msg \"Re exec'ing:\\n\\t#{cmd}\"\n exec cmd\n rescue Errno::EOPNOTSUPP\n msg \"Restart command is not available at this time.\"\n end",
"def call\n banner \"Starting Polytrix (v#{Polytrix::VERSION})\"\n elapsed = Benchmark.measure do\n setup\n tests = parse_subcommand(args.shift, args.shift)\n implementors = tests.map(&:implementor).uniq\n if IMPLEMENTOR_ACTIONS.include? action # actions on implementors\n run_action(action, implementors)\n else # actions on tests\n run_action(action, tests)\n end\n end\n banner \"Polytrix is finished. #{Util.duration(elapsed.real)}\"\n end",
"def run(args)\n ret = DEFAULTS.merge({})\n\n # create option parser\n o = ::OptionParser.new do |o|\n o.banner = \"Usage: #@app [options]\"\n o.separator \" \"\n\n # add command-line options\n o.separator \"Options:\"\n\n o.on('-A', '--allow USER', 'Allow Jabber subscription from USER.') do |v|\n add_allowed(ret, v)\n end\n\n o.on('-c', '--config FILE', 'Use configuration file FILE.') do |v|\n Joggle::ConfigParser.run(v) do |key, val|\n if key == 'engine.allow'\n add_allowed(ret, val)\n elsif key == 'engine.update.range'\n add_update_range(ret, val)\n else\n ret[key] = val\n end\n end\n end\n\n o.on('-D', '--daemon', 'Run as daemon (in background).') do |v|\n ret['cli.daemon'] = true\n end\n\n o.on('--foreground', 'Run in foreground (the default).') do |v|\n ret['cli.daemon'] = false\n end\n\n o.on('-L', '--log-level LEVEL', 'Set log level to LEVEL.') do |v|\n ret['runner.log.level'] = v\n end\n\n o.on('-l', '--log FILE', 'Log to FILE.') do |v|\n ret['runner.log.path'] = v\n end\n\n o.on('-p', '--password PASS', 'Jabber password (INSECURE!).') do |v|\n ret['jabber.pass'] = v\n end\n\n o.on('-s', '--store FILE', 'Use FILE as backing store.') do |v|\n ret['runner.store.path'] = v\n end\n\n o.on('-u', '--username USER', 'Jabber username.') do |v|\n ret['jabber.user'] = v\n end\n\n o.separator ' '\n\n o.on_tail('-v', '--version', 'Print version string.') do\n puts \"Joggle %s, by %s\" % [\n Joggle::VERSION,\n 'Paul Duncan <pabs@pablotron.org>',\n ]\n exit\n end\n\n o.on_tail('-h', '--help', 'Print help information.') do\n puts o\n exit\n end\n end\n\n # parse arguments\n o.parse(args)\n\n # return results\n ret\n end",
"def process_args\n args = @args.dup\n @options[:operands] = nil\n unless args.length >= 2\n puts @opts\n exit 1\n end\n @options[:operands] = args.shift(2)\n @options[:output_filename] = args.shift unless args.empty?\n @options[:output] ||= @options[:output_filename] || $stdout\n\n run\n end",
"def setup\n begin\n @options = OptParser.parse(ARGV)\n rescue ParserExceptions::MissingArgument\n exit(1)\n end\n\n end",
"def parse_command_line\n OptionParser.new do |opts|\n opts.banner = \"Usage: ruby #{$0} [options]\"\n\n opts.on_head(\"-h\", \"--help\", \"Show this help message\") do\n puts opts\n exit\n end\n\n opts.on(\"-v\", \"--verbose\", \"Show all progress messages (INFO, DEBUG, WARNING, ERROR)\") do\n Logger.verbose = true\n end\n\n opts.on(\"-q\", \"--quiet\", \"Only show WARNING and ERROR messages\") do\n Logger.quiet = true\n end\n\n opts.on(\"--console\", \"Open up a console to query the source via rbgccxml\") do\n @requesting_console = true\n end\n\n opts.on(\"--clean\", \"Force a complete clean and rebuild of this extension\") do\n @force_rebuild = true\n end\n\n end.parse!\n end",
"def run(*args, verbosity: 0, delegated_from: nil)\n tool, remaining = ContextualError.capture(\"Error finding tool definition\") do\n @loader.lookup(args.flatten)\n end\n ContextualError.capture_path(\n \"Error during tool execution!\", tool.source_info&.source_path,\n tool_name: tool.full_name, tool_args: remaining\n ) do\n default_data = {\n Context::Key::VERBOSITY => verbosity,\n Context::Key::DELEGATED_FROM => delegated_from,\n }\n run_tool(tool, remaining, default_data)\n end\n rescue ContextualError, ::Interrupt => e\n @error_handler.call(e).to_i\n end",
"def start\n return if initialized\n puts copyright\n argv = ARGV\n ARGV.clear\n IRB.start\n ARGV.replace(argv)\n end",
"def __main__(args)\n Fifa::Task.new($opts = parse(args[1..-1])).exec\n exit(1) if Fifa::Logger.errors?\nend",
"def run_from_command_line\n handle_exceptions do\n remotes.load\n handle_options\n execute_command_from_command_line\n end\n end",
"def invoke(argv)\n system(\n argv.join(' ')\n )\n end",
"def run!\n @opts = slop_parse\n @skip = @opts[:skip] || []\n\n display_version if @opts[:v]\n run_checks\n end",
"def gentest argv\n argv = argv.dup\n @both = false\n process_opts(argv) if /^-/ =~ argv.first\n\n @service_controller = deduce_services_controller\n @ui = Hipe::IndentingStream.new($stdout,'')\n file = argv.shift\n mod = deduce_module_from_file file\n mod.spec.invocation_name = File.basename(file)\n get_actuals mod, argv\n @ui.indent!.indent!\n go_app(mod, file)\n go_desc(mod, file) do\n go_exp\n go_act(mod, argv)\n end\n exit(0) # rake is annoying\n end",
"def main(argv = ARGV)\n retval = 1 # Program exit status; zero means success, non-zero means error\n if argv.empty?\n $stderr.puts USAGE\n else\n dict = AnagramDictionary.new\n word = argv.join.strip\n word.upcase_letters.partitions do |partition|\n candidates = partition.collect { |letters| dict.lookup(letters.join) }\n if candidates.all? { |words| !words.empty? }\n puts candidates.collect { |words| words.join(' ') }.join(' | ')\n retval = 0\n end\n end\n end\n retval\nend"
] | [
"0.68332916",
"0.66638947",
"0.6479788",
"0.64607114",
"0.6454007",
"0.6442641",
"0.64321524",
"0.64225435",
"0.6417517",
"0.63770175",
"0.6362033",
"0.63367075",
"0.632113",
"0.63196343",
"0.63014275",
"0.6293867",
"0.62918633",
"0.6280793",
"0.6280793",
"0.6280793",
"0.6280793",
"0.6280793",
"0.6280793",
"0.62657213",
"0.62653524",
"0.6252863",
"0.6247417",
"0.62301284",
"0.6220703",
"0.6217964",
"0.6215571",
"0.6197629",
"0.6192459",
"0.61783016",
"0.61696404",
"0.61378735",
"0.6131824",
"0.6130593",
"0.61216223",
"0.6086851",
"0.6085523",
"0.60794795",
"0.6060168",
"0.5986622",
"0.5977767",
"0.5973736",
"0.59721965",
"0.5965956",
"0.59651536",
"0.5951164",
"0.59500074",
"0.5931682",
"0.5928474",
"0.5877245",
"0.58624315",
"0.58251363",
"0.58143216",
"0.58132625",
"0.5777026",
"0.5767166",
"0.5766156",
"0.57621706",
"0.57424396",
"0.5726045",
"0.5708403",
"0.57073164",
"0.56895447",
"0.5689515",
"0.568818",
"0.5687888",
"0.56862885",
"0.56859684",
"0.5678206",
"0.56760484",
"0.56710744",
"0.5664835",
"0.5656265",
"0.56517637",
"0.56410366",
"0.5637912",
"0.5633571",
"0.5622302",
"0.5611392",
"0.55982566",
"0.5594859",
"0.5589192",
"0.5586891",
"0.5583211",
"0.5577118",
"0.55761707",
"0.5573456",
"0.55658156",
"0.55645704",
"0.5541322",
"0.5538982",
"0.5535964",
"0.5533664",
"0.55311346",
"0.55291265",
"0.552403"
] | 0.5775854 | 59 |
Tells optparse how to parse the arguments available for all executables. This is meant to be overridden by subclasses so they can add their own options. | def set_opts(opts)
opts.on_tail("-?", "-h", "--help", "Show this message") do
puts opts
exit
end
opts.on_tail("-v", "--version", "Print version") do
puts("TXPRails #{::TXPRails.version[:string]}")
exit
end
opts.on('--rails RAILS_DIR', "Install TXPRails from the Gem to a Rails project") do |dir|
original_dir = dir
dir = File.join(dir, 'vendor', 'plugins')
unless File.exists?(dir)
puts "Directory #{dir} doesn't exist"
exit
end
dir = File.join(dir, 'txprails')
if File.exists?(dir)
print "Directory #{dir} already exists, overwrite [y/N]? "
exit if gets !~ /y/i
FileUtils.rm_rf(dir)
end
begin
Dir.mkdir(dir)
rescue SystemCallError
puts "Cannot create #{dir}"
exit
end
File.open(File.join(dir, 'init.rb'), 'w') do |file|
file << File.read(File.dirname(__FILE__) + "/../init_rails.rb")
end
puts "Haml plugin added to #{original_dir}"
exit
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_opts\n option_parser.parse(@argv)\n end",
"def parse_opts\n if parse_argv\n apply_options\n true\n end\n end",
"def parse_options(opts, args); end",
"def optparse_args\n if short\n [\"--#{name}\", \"-#{short}\", desc, :REQUIRED]\n else\n [\"--#{name}\", desc, :REQUIRED]\n end\n end",
"def parse\n # The options specified on the command line will be collected in *options*.\n # We set default values here.\n OptionParser.new { |options| parse_options options}.parse!(@args)\n @options\n end",
"def parse\n @opts = OptionParser.new { |opts| process_opts(opts) }\n @opts.parse!(@args)\n\n process_args\n\n @options\n end",
"def parseArgs\n forceDefaultMode=false\n opts = GetoptLong.new(\n [\"-h\", \"--help\", GetoptLong::NO_ARGUMENT],\n [\"-f\", \"--file\", GetoptLong::REQUIRED_ARGUMENT],\n [\"--st\", \"--statements\", GetoptLong::REQUIRED_ARGUMENT],\n [\"-s\", \"--size\", GetoptLong::REQUIRED_ARGUMENT],\n [\"-d\", \"--default\", GetoptLong::NO_ARGUMENT],\n [\"-o\", \"--outer-control\", GetoptLong::NO_ARGUMENT],\n [\"-p\", \"--package\", GetoptLong::REQUIRED_ARGUMENT],\n [\"-n\", \"--main-class-name\", GetoptLong::REQUIRED_ARGUMENT])\n opts.each do |opt, arg|\n case opt\n when \"-f\"\n parseConfFile(arg)\n when \"-s\"\n @max_size = arg.to_i()\n when \"--st\"\n @max_stmts = arg.to_i()\n when \"-d\"\n forceDefaultMode = true\n when \"-o\"\n @outer_control = true\n when \"-p\"\n @package = arg.to_s\n when \"-n\"\n @mainClassName = arg.to_s\n end\n end\n if ARGV.length > 0\n error(\"Invalid arguments\")\n end\n @mode = 'default' if forceDefaultMode\n end",
"def parse_options!(args)\n option_parser.parse!(args)\n\n if args.empty?\n abort(\"You must give exactly one command to execute.\")\n else\n @options.command = args.join(\" \")\n end\n end",
"def parse_options\n set_defaults\n unless parsed_options? && arguments_valid?\n output_usage\n exit 1\n end\n end",
"def parse arguments\n begin\n @option_parser.parse! arguments\n rescue StandardError => e\n puts @option_parser\n puts\n puts e.message\n exit(-1)\n end\n\n @options\n end",
"def parse(args)\n begin \n opt_parser.parse!(args)\n rescue ::OptionParser::InvalidOption => e\n puts help\n exit(1)\n end\n options\n end",
"def parse!( args )\n @args = args\n @options.grep!(args)\n end",
"def parse!\n begin\n @opts = OptionParser.new(&method(:set_opts))\n @opts.parse!(@args)\n @options\n rescue Exception => e\n raise e if e.is_a?(SystemExit)\n\n $stderr.puts e.message\n exit 1\n end\n exit 0\n end",
"def parse_options=(_arg0); end",
"def parse_options=(_arg0); end",
"def parse(args)\n optparser = new_option_parser\n optparser.parse!(args)\n abort_missing_options(optparser)\n @options\n end",
"def parse(args)\n arg_list = arg_groups(args)\n options = DEFAULT_OPTIONS.dup\n options[:exclude] += default_excludes\n options[:locations] = arg_list.shift\n\n arg_list.reject(&:empty?).each do |set|\n flag, *args = set\n args.map! { |arg| arg.delete(\"/\") } # \"log/\" => \"log\"\n\n case flag\n when '-f', '--flags' then options[:flags] += args\n when '-e', '--exclude' then options[:exclude] += args\n else puts \"Unknown argument: #{flag}\"\n end\n end\n\n options\n end",
"def parse\n # parse flag arguments\n @oparse.parse!(@argv) rescue(bail_args($!))\n @parsed=true\n\n # the overriding class may implement additional arguments from here\n end",
"def parse_options(args = ARGV)\n default_gem_path = File.join(Dir.home, '.autoproj', 'gems')\n self.private_bundler = default_gem_path\n self.private_gems = default_gem_path\n self.private_autoproj = default_gem_path\n\n options = OptionParser.new do |opt|\n opt.on '--local', 'do not access the network (may fail)' do\n @local = true\n end\n opt.on '--public', \"install gems in the default RubyGems locations. Consider using this if you don't have a v1 install anymore\" do\n self.private_bundler = false\n self.private_autoproj = false\n self.private_gems = false\n end\n opt.on '--private-bundler[=PATH]', 'install bundler locally in the workspace' do |path|\n self.private_bundler = path || true\n end\n opt.on '--private-autoproj[=PATH]', 'install autoproj locally in the workspace' do |path|\n self.private_autoproj = path || true\n end\n opt.on '--private-gems[=PATH]', 'install gems locally in the prefix directory' do |path|\n self.private_gems = path || true\n end\n opt.on '--private[=PATH]', \"whether bundler, autoproj and the workspace gems should be installed locally in the workspace. This is the default, with a path of #{default_gem_path}\" do |path|\n self.private_bundler = path || true\n self.private_autoproj = path || true\n self.private_gems = path || true\n end\n opt.on '--version=VERSION_CONSTRAINT', String, 'use the provided string as a version constraint for autoproj' do |version|\n @gemfile = default_gemfile_contents(version)\n end\n opt.on '--gemfile=PATH', String, 'use the given Gemfile to install autoproj instead of the default' do |path|\n @gemfile = File.read(path)\n end\n opt.on '--prefer-os-independent-packages', 'prefer OS-independent packages (such as a RubyGem) over their OS-packaged equivalent (e.g. the thor gem vs. the ruby-thor debian package)' do\n @prefer_indep_over_os_packages = true\n end\n opt.on '--[no-]color', 'do not use colored output (enabled by default if the terminal supports it)' do |color|\n if color then autoproj_options << \"--color\"\n else autoproj_options << '--no-color'\n end\n end\n opt.on '--[no-]progress', 'do not use progress output (enabled by default if the terminal supports it)' do |color|\n if color then autoproj_options << \"--progress\"\n else autoproj_options << '--no-progress'\n end\n end\n end\n args = options.parse(ARGV)\n autoproj_options + args\n end",
"def process_arguments\n @args << \"-h\" if(@args.length < 1)\n \n opts_parse = OptionParser.new do |opts|\n opts.on('-f','--file FILE','use the following local file') {|file| @options.file = File.expand_path(file)}\n opts.on('-p','--parse PARSE',\"sets which set of sider files to download #{@@sections.join(\"|\")}\") {|parse| @options.parse = parse}\n opts.on('-d','--download','download the file to be parsed') {@options.download = true}\n opts.on('-o','--output DIR','set the output directory') {|directory| @options.output = File.expand_path(directory)}\n opts.on('-h','--help',\"prints the help\"){puts opts; exit!}\n end\n \n opts_parse.parse!(@args) rescue raise \"There was an error processing command line arguments use -h to see help\"\n end",
"def parse_options(argv)\n arguments = [\n [:rspec, \"--rspec\", \"RSpec mode\"],\n [:helper, \"--helper\", \"Helper file to load before tests start\", String],\n [:quiet, \"--quiet\", \"Quiet\"],\n [:no_fixtures, \"--no-fixtures\", \"Do not load fixtures\"],\n [:no_ar, \"--no-ar\", \"Disable ActiveRecord logic\"],\n [:merge_coverage, \"--merge-coverage\", \"Merge base code coverage into indvidual files coverage, great for SingleCov\"],\n [\n :record_runtime,\n \"--record-runtime=MODE\",\n \"\\n Record test runtime:\\n\" <<\n \" simple = write to disk at --runtime-log)\\n\" <<\n \" amend = write from multiple remote workers via http://github.com/grosser/amend, needs TRAVIS_REPO_SLUG & TRAVIS_BUILD_NUMBER\",\n String\n ],\n [:runtime_log, \"--runtime-log=FILE\", \"File to store runtime log in or runtime.log\", String],\n [:group, \"--group=NUM\", \"What group this is (use with --groups / starts at 1)\", Integer],\n [:groups, \"--groups=NUM\", \"How many groups there are in total (use with --group)\", Integer],\n [:version, \"--version\", \"Show version\"],\n [:help, \"--help\", \"Show help\"]\n ]\n\n options = arguments.each_with_object({}) do |(setting, flag, _, type), all|\n all[setting] = delete_argv(flag.split('=', 2)[0], argv, type: type)\n end\n\n # show version\n if options.fetch(:version)\n puts VERSION\n exit 0\n end\n\n # # show help\n if options[:help]\n parser = OptionParser.new(\"forking-test-runner folder [options]\", 32, '') do |opts|\n arguments.each do |_, flag, desc, type|\n opts.on(flag, desc, type)\n end\n end\n puts parser\n exit 0\n end\n\n # check if we can use merge_coverage\n if options.fetch(:merge_coverage)\n require 'coverage'\n abort \"merge_coverage does not work on Ruby prior to 2.3 due to the lack of the Coverage.peek_result method\" unless Coverage.method_defined?(:peek_result)\n klass = (class << Coverage; self; end)\n klass.prepend CoverageCapture\n end\n\n # all remaining non-flag options until the next flag must be tests\n next_flag = argv.index { |arg| arg.start_with?(\"-\") } || argv.size\n tests = argv.slice!(0, next_flag)\n abort \"No tests or folders found in arguments\" if tests.empty?\n tests.each { |t| abort \"Unable to find #{t}\" unless File.exist?(t) }\n\n [options, tests]\n end",
"def parse_opt(args)\n valid_opts = %w{--version -v --install -i --help -h\n --complete -c --bookmark -b --search -s}\n\n nextarg = args.shift\n errormsg = 'Error: '.red + \"unrecognized option #{nextarg}\"\n pexit errormsg, 1 if ! (valid_opts.include? nextarg)\n\n # forced bookmarking\n if nextarg == '--bookmark' || nextarg == '-b'\n if args.first.nil?\n pexit 'Error: '.red + 'booker --bookmark expects bookmark id', 1\n else\n open_bookmark args\n end\n end\n\n # autocompletion\n if nextarg == '--complete' || nextarg == '-c'\n allargs = args.join(' ')\n bm = Bookmarks.new(allargs)\n bm.autocomplete\n end\n\n # installation\n if nextarg == '--install' || nextarg == '-i'\n if !args.empty?\n install(args)\n else # do everything\n install(%w{completion config bookmarks})\n end\n end\n\n # forced searching\n if nextarg == '--search' || nextarg == '-s'\n pexit '--search requires an argument', 1 if args.empty?\n allargs = args.join(' ')\n open_search allargs\n end\n\n # print version information\n version if nextarg == '--version' || nextarg == '-v'\n\n # needs some help\n helper if nextarg == '--help' || nextarg == '-h'\n\n exit 0 # dont parse_arg\n end",
"def parse_options!(argv)\n HighLine.use_color = false if !STDOUT.tty? && !ENV.has_key?(\"AUTOTEST\")\n\n OptionParser.new do |opts|\n opts.banner = \"Usage: montage [config file path] [options]\"\n\n opts.on('-c', '--[no-]color', '--[no-]colour',\n 'Enables and disables colour output.') do |color|\n HighLine.use_color = color\n end\n\n opts.on('-f', '--force',\n 'Regenerate sprites even if no changes have been made.') do\n Montage::Commands.config[:force] = true\n end\n\n # opts.on('-q', '--quiet',\n # 'Tell Montage to shut up. No messages sent to STDOUT.') do\n # Montage::Commands.config[:quiet] = true\n # end\n\n opts.on_tail(\"-h\", \"--help\", \"Shows this message.\") do\n say BLANK\n say opts.to_s\n exit\n end\n\n opts.on_tail(\"--version\", \"Print the current Montage version.\") do\n say BLANK\n say \"Montage v#{Montage::VERSION}\"\n exit\n end\n end.parse!(argv)\n\n argv\n end",
"def optparse!(argv) # rubocop:disable Metrics/MethodLength\n options = Options.new\n option_parser = OptionParser.new do |parser|\n parser.banner = \"Usage: #{parser.program_name} [options]\"\n parser.on('-hHOST', '--host=HOST', 'Coursemology host to connect to') do |host|\n options.host = host\n end\n\n parser.on('-tTOKEN', '--api-token=TOKEN') do |token|\n options.api_token = token\n end\n\n parser.on('-uUSER', '--api-user-email=USER') do |user|\n options.api_user_email = user\n end\n\n parser.on('-o', '--one-shot') do\n options.one_shot = true\n end\n end\n\n option_parser.parse!(argv)\n options\n end",
"def parse_options\n @opt_parser = OptionParser.new do |opts|\n opts.banner = \"\"\n\n opts.separator \"patchkit-tools #{@program_name}\"\n\n opts.separator \"\"\n\n opts.separator \"Description:\"\n\n opts.separator opts.summary_indent + @program_description\n\n opts.separator \"\"\n\n opts.separator \"Usage:\"\n\n @program_usages.each do |program_usage|\n opts.separator opts.summary_indent + \"patchkit-tools #{@program_name} #{program_usage}\"\n end\n\n opts.separator opts.summary_indent + \"patchkit-tools #{@program_name} --help\"\n\n opts.separator \"\"\n\n end\n\n yield @opt_parser\n\n @opt_parser.separator \"\"\n\n @opt_parser.separator \"Common\"\n\n unless @opts_defined.include? :host\n option('host', value: true, required: false, description: 'Hostname (format: patchkit.net)')\n end\n\n unless @opts_defined.include? :https\n option('https', value: true, required: false, description: 'Use HTTPS (false)')\n end\n\n @opt_parser.on(\"-h\", \"--help\", \"outputs a usage message and exit\") do\n puts @opt_parser\n exit\n end\n\n @opt_parser.separator \"\"\n\n @opt_parser.parse!(ARGV)\n\n @opts_required.each do |opt|\n raise CommandLineError, \"Missing required option --#{opt}\" unless @opts_used.include? opt\n end\n end",
"def parse_options(args) # :nodoc:\n global_options,command,options,arguments = parse_options_helper(args.clone,Hash.new,nil,Hash.new,Array.new)\n flags.each { |name,flag| global_options[name] = flag.default_value if !global_options[name] }\n command.flags.each { |name,flag| options[name] = flag.default_value if !options[name] }\n return [global_options,command,options,arguments]\n end",
"def parse_args\n options = {}\n optparse = OptionParser.new do|opts|\n # Set a banner\n opts.banner = \"Usage: harness.rb [-c || --config ] FILE [-d || --testdir] DIR\"\n\n options[:testdir] = nil\n opts.on( '-d', '--testdir DIR', 'Execute tests in DIR' ) do|dir|\n options[:testdir] = dir\n end\n options[:config] = nil\n opts.on( '-c', '--config FILE', 'Use configuration FILE' ) do|file|\n options[:config] = file\n end\n\n opts.on( '-h', '--help', 'Display this screen' ) do\n puts opts\n exit\n end\n end\n optparse.parse!\n return options\nend",
"def parse_options(args) # :nodoc:\n option_parser_class = self.class.const_get(\"#{options[:subcommand_option_handling_strategy].to_s.capitalize}CommandOptionParser\")\n OptionParsingResult.new.tap { |parsing_result|\n parsing_result.arguments = args\n parsing_result = @global_option_parser.parse!(parsing_result)\n option_parser_class.new(@accepts).parse!(parsing_result, options[:argument_handling_strategy], options[:autocomplete])\n }\n end",
"def parse_arguments\n options = {}\n parser = OptionParser.new do |opts|\n opts.on(\"-d\", \"--dir DIR\", \"absolute or relative path of the directory\") do |arg|\n options[:dir] = arg\n end\n\n opts.on(\"-p\", \"--pattern PATTERN\", \"search pattern - can contain asterisk(*) as wildcard\") do |arg|\n options[:pattern] = arg\n end\n end\n parser.parse!\n [options, parser]\nend",
"def parse_options\n @cl_non_options = @cl_parser.parse(ARGV)\n end",
"def parse!(argv)\n\t\t$log.debug(\"#{self.class}.#{__method__}('#{argv.join(\" \")}'#{block_given? ? ',&block' : ''})\")\n\t\tif (argv.size == 0)\n\t\t\traise OptionParser::InvalidArgument, \"No arguments specified.\"\n\t\tend\n\n\t\t# @options is used to store recognized command-line args\n\t\t@options = Hash.new\n\t\twhile arg = argv.shift\n\t\t\tcase arg\n\t\t\twhen \"-cmd\"\n\t\t\t\t@command = argv.shift\n\t\t\twhen \"-debug\"\n\t\t\t\t$log.level = Logger::DEBUG\n\t\t\t\t$logerr.level = Logger::DEBUG\n\t\t\twhen \"-opt\"\n\t\t\t\t@options[:dataset] = argv.shift\n\t\t\twhen \"-path\"\n\t\t\t\t@options[:path] = argv.shift\n\t\t\twhen \"-target\"\n\t\t\t\t@options[:target] = argv.shift\n\t\t\twhen \"-log\"\n\t\t\t\tlevel = $log.level\n\t\t\t\tlog_path = argv.shift\n\t\t\t\t$log = Logger.new(log_path)\n\t\t\t\t$log.level = level\n\t\t\t\t$logerr = Logger.new(log_path)\n\t\t\t\t$logerr.level = level\n\t\t\telse\n\t\t\t\targv.unshift(arg)\n\t\t\t\tif block_given?\n\t\t\t\t\tunless (argv = yield(argv))\n\t\t\t\t\t\traise OptionParser::InvalidArgument, \"Unknown argument.\"\n\t\t\t\t\tend\n\t\t\t\telse break\n\t\t\t\tend\n\t\t\tend\t\t\n\t\tend\n\t\traise OptionParser::InvalidArgument, \"No command specified.\" unless @command\n\t\tunless (self.class::COMMANDS.include?(@command) && self.respond_to?(@command))\n\t\t\traise OptionParser::InvalidArgument, \"Unknown command '#{@command}' specified.\"\n\t\tend\n\t\treturn argv\n\tend",
"def parse_options(opts=nil)\n # make sure optparse doesn't use POSIXLY_CORRECT parsing\n ENV[\"POSIXLY_CORRECT\"] = nil\n\n # Creating a shallow copy of the arguments so the OptionParser\n # doesn't destroy the originals.\n argv = @argv.dup\n\n # Default opts to a blank optionparser if none is given\n opts ||= OptionParser.new\n\n # Add the help option, which must be on every command.\n opts.on_tail(\"-h\", \"--help\", \"Print this help\") do\n safe_puts(opts.help)\n return nil\n end\n\n opts.parse!(argv)\n return argv\n rescue OptionParser::InvalidOption, OptionParser::MissingArgument\n raise Errors::CLIInvalidOptions, help: opts.help.chomp\n end",
"def process_argv!\n args = ARGV.dup\n self.rest = []\n @unknown_argvs = []\n until args.empty? do\n arg = args.shift\n case\n # end of options parsing\n when arg == '--'\n self.rest += args\n break\n # --param=val or --param\n when arg =~ /\\A--([\\w\\-\\.]+)(?:=(.*))?\\z/\n param, val = [$1, $2]\n warn \"Configliere uses _underscores not dashes for params\" if param.include?('-')\n @unknown_argvs << param.to_sym if (not has_definition?(param))\n self[param] = parse_value(val)\n # -abc\n when arg =~ /\\A-(\\w\\w+)\\z/\n $1.each_char do |flag|\n param = find_param_for_flag(flag)\n unless param then @unknown_argvs << flag ; next ; end\n self[param] = true\n end\n # -a val\n when arg =~ /\\A-(\\w)\\z/\n flag = find_param_for_flag($1)\n unless flag then @unknown_argvs << flag ; next ; end\n if (not args.empty?) && (args.first !~ /\\A-/)\n val = args.shift\n else\n val = nil\n end\n self[flag] = parse_value(val)\n # -a=val\n when arg =~ /\\A-(\\w)=(.*)\\z/\n flag, val = [find_param_for_flag($1), $2]\n unless flag then @unknown_argvs << flag ; next ; end\n self[flag] = parse_value(val)\n else\n self.rest << arg\n end\n end\n @unknown_argvs.uniq!\n end",
"def parse_arguments\n OptionParser.new do |parser|\n # parser.banner = \"Usage: init.rb -c <integer>\"\n parser.on(\"-c\", \"--count COUNT\", Integer, \"Specify number of uuid's to generate\") do |c|\n @options[:count] = c\n end\n parser.on(\"-f\", \"--file FILE\", \"Specify path to save csv file example -f '/path/to/file.csv'\") do |path|\n @options[:path] = path\n end\n end.parse!\n end",
"def parse(argv=ARGV)\n argv = Array(argv)\n\n while @parse and entry = argv.shift\n # collect everything that is not an option\n if entry[0] != ?-\n @on_extra[entry]\n next\n end\n\n # this is a long option\n if entry[1] == ?-\n opt, arg = entry.split \"=\"\n process argv, entry, opt, arg\n next\n end\n\n # disambiguate short option group from short option with argument\n opt, arg, rest = split entry, 2\n\n # process first option\n option = process argv, entry, opt, arg\n next unless option and not option.arg?\n\n # process the rest of the options\n while rest.size > 0\n opt, arg, rest = split rest, 1\n opt = \"-\" + opt\n option = process argv, opt, opt, arg\n break if option.arg?\n end\n end\n\n @extra\n rescue ParseError => e\n puts self\n puts e\n exit 1\n end",
"def parse\n @opts = OptionParser.new(&method(:set_opts))\n @opts.parse!(@args)\n\n process_result\n\n @options\n end",
"def parse_options\n options = {}\n\n optparse = OptionParser.new do |opts|\n opts.banner = \"Usage: #{File.basename($0)} [-h|--help] <attrname>|all|report\"\n\n # Help\n opts.on('-h', '--help', 'Display usage information') do\n usage\n exit\n end\n end\n\n optparse.parse!\nend",
"def parse\n # Parse all arguments first\n option_parser.parse!(arguments)\n\n # Get the first argument, this is our command\n cmd = arguments.pop\n raise OptionParser::MissingArgument, 'command' unless cmd\n\n # Set the command if it's present\n options.command = cmd.to_sym\n end",
"def parse(argv)\n parser, options = parse_main(argv)\n\n # Options that are mutually-exclusive with everything else.\n options = {:help => true} if options[:help]\n options = {:version => true} if options[:version]\n\n validate_options!(options)\n\n @options = options\n @help_text = parser.to_s\n\n self\n end",
"def options args = ARGV, *a, &b\n @p = Parser.new(*a, &b)\n begin\n vals = @p.parse args\n args.clear\n @p.leftovers.each { |l| args << l }\n vals\n rescue CommandlineError => e\n $stderr.puts \"Error: #{e.message}.\"\n $stderr.puts \"Try --help for help.\"\n exit(-1)\n rescue HelpNeeded\n @p.educate\n exit\n rescue VersionNeeded\n puts @p.version\n exit\n end\n end",
"def parse_args\n @args.extend OptionParser::Arguable\n opts = @args.getopts('cdDi:lm:n:o:s:St:uvVz')\n @nsocks = opts['s'] ? opts['s'].to_i : 1\n @max_idle = opts['i'] ? opts['i'].to_i : DEFAULT_MAX_IDLE\n @max_use = opts['m'] ? opts['m'].to_i : DEFAULT_MAX_USE\n $VERBOSE = true if opts['v']\n end",
"def parse_args(argv)\n @args ||= nil\n raise \"#{class_name}.initialize failed to call super!\" unless\n args.is_a?(Hash)\n\n #\n # if this CLI has boolean arguments which can immediately\n # precede the non-option arguments (ie those arguments which\n # don't begin with '--'), those booleans need to be declared.\n # otherwise when parsing the boolean argument, we'll mistake\n # the boolean as an option with a value:\n #\n # foo.rb --boolean firstnonoption\n #\n # becomes args = {:boolean => 'firstnonoption'}.\n #\n booleans = {}\n booleans = Hash[*(boolean_args.map { |a| [a,1] }.flatten)] if\n self.respond_to? :boolean_args\n\n skipped = []\n while argv.length > 0 do\n unless argv[0] =~ /^--?/\n skipped.push argv.shift\n\n else\n # shift the argument name out of argv\n argname = argv.shift.sub(/^--?/, '').downcase\n raise ArgumentError, \"expected: --ARGNAME; got: '#{argname.inspect}'\" unless\n argname.is_str?\n\n # strip trailing '-' then convert remaining '-' to '_'\n argsym = argname.sub(/-+$/, '').gsub(/-+/, '_').to_sym\n\n if booleans[argsym] or (argv.length < 1) or (argv[0] =~ /^--?/)\n # a boolean argument whose value is false when the argument ends with '-'\n args[argsym] = (argname =~ /-$/) ? false : true\n else\n # named argument\n args[argsym] = argv.shift\n end\n end\n end\n\n self.argv = skipped || []\n\n usage if args[:help] or args[:usage]\n end",
"def parse_options()\n\n options = {}\n\n ARGV.each_index do |index|\n case $*[index]\n when '-m' then options[:auto_connect] = false\n when '-v' then options[:verbose] = true\n when '-q' then options[:verbose] = false\n when '-t' then options[:log_truncate] = true\n when '-r' then options[:log_response] = false\n else\n ::Twiga.say_warn \"unknown option: #{arg}\"\n end # case\n\n $*.delete_at(index) # remove from command line\n\n end # do each cmd line arg\n \n return Kinokero::Cloudprint::DEFAULT_OPTIONS.merge(options)\n\n end",
"def process_options\n options.delete_if { |x,y| y.nil? }\n if options.empty?\n puts @optparse \n exit 0\n end\n options.each do |x,y|\n begin\n if y.to_s.match('^-')\n raise BoilerMakerErr.new(\"Bad args: \\\"#{y}\\\" is not a valid arg to option, \\\"--#{x}\\\". Use the -h flag for syntax help.\")\n end\n rescue => error\n puts error.message + \"\\n\"\n exit 1\n end\n end\n end",
"def parse_arguments\n @cmd_line_arguments = {}\n\n @options = OptionParser.new do |opt|\n opt.on('-C', '--change-dir DIR', 'Change working directory to DIR') do |directory|\n @cmd_line_arguments[:working_directory] = directory\n end\n\n opt.on('-d', '--debug', 'Debug mode') do\n @cmd_line_arguments[:debug] = true\n end\n\n opt.on('-e', '--environment NAME', 'set environment to NAME') do |environment|\n @cmd_line_arguments[:environment] = environment\n end\n\n opt.on('-G', '--generate-json', 'Generate json files, which are commited to api') do\n @cmd_line_arguments[:generate_json_file] = true\n @cmd_line_arguments[:action] ||= :generate\n end\n\n opt.on('--generate-report', 'Generate report csv in output directory') do\n @cmd_line_arguments[:generate_report] = true\n end\n\n opt.on('-g', '--group NAME[,NAME]', Array, 'set groups') do |groups|\n @cmd_line_arguments[:groups] ||= []\n @cmd_line_arguments[:groups] += groups\n end\n\n opt.on('-j', '--job JOB[,JOB,...]', Array, 'Limit action to JOB, which is a regexpression') do |jobs|\n @selected_jobs += jobs\n end\n\n opt.on('-l', '--list', 'List available jobs') do\n @cmd_line_arguments[:action] = :list\n end\n\n opt.on('-p', '--project NAME', 'set project') do |project|\n @cmd_line_arguments[:project] = project\n end\n\n opt.on('-o', '--output-directory DIR', 'generate json file into DIR directory', 'default: ' + @config.output_directory) do |directory|\n @cmd_line_arguments[:output_directory] = directory\n end\n\n opt.on('-q', '--quiet', 'be quiet') do\n @cmd_line_arguments[:quiet] = true\n end\n\n opt.on('-r', '--run', 'Run all configured jobs or all jobs passed with -j') do\n @cmd_line_arguments[:action] = :run\n end\n\n opt.on('-R', '--report', 'show report') do\n @cmd_line_arguments[:report] = true\n end\n\n opt.on('-s', '--save-response', 'save respone in output directory') do\n @cmd_line_arguments[:save_response] = true\n end\n\n opt.separator \"\n\n Examples:\n # List all available jobs\n #{File.basename $0} -l\n\n # List all available jobs in a specific directory\n #{File.basename $0} -C api-helper -p LISU -l\n\n # Run all configured jobs\n #{File.basename $0} -r\n\n # Run all configured jobs and show a report\n #{File.basename $0} -r --report\n\n # Run all configured jobs in a specific directory\n #{File.basename $0} -C api-helper -p LISU -r\n\n # Run Job_A and Job_B, which must configured in project.yml or group.yml\n #{File.basename $0} -r -j Job_A -j Job_B\n\n # Run all Jobs, which beginn with JOB\n #{File.basename $0} -r -j JOB.*\n\n # Run all Jobs, which contains with JOB\n #{File.basename $0} -r -j .*JOB.*\n\n # Generate json files, which are going to be requested, for all configured jobs\n #{File.basename $0} -G\n\n # Generate json file, which are going to be requested, for Job_A\n #{File.basename $0} -G -j Job_A\n\n # Run jobs for delti group and generate json files\n #{File.basename $0} -r -G -g delti\n\n Available template macros:\n\n Variables and Responses:\n response('<job_name>', '<name>') - return value from the response of a job (see examples)\n response('<job_name>', - return value from the response of a job in another group (must be run before)\n '<name>',\n group: '<group_name>')\n var('<name>', - return variable defined in Job in Vars section.\n default: nil, when default is set (not nil) and variable is undefined, return default\n ignore_error: false) when variable is undefined, do not throw an error\n\n Date and Time:\n now() - returns today (now) in seconds\n yesterday() - returns yesterday in iso8601\n time([<day_shift>[, format: <format>]]) - returns time in specificied format\n defaults: day_shift = 0, format = :seconds\n format:\n :seconds : return time in seconds\n :iso8601 : return timestamp in iso8601\n :iso8601utc : return timestamp in iso8601 (utc)\n\n Examples:\n # get variable test\n var('test')\n\n # get value pdfToken from register response\n response('Delti_Create_DE', 'pdfToken')\n\n # get value pdfToken from register response, where job name is defined as variable in cancel job\n response(var('CreateJob'), 'pdfToken')\n\n # get value token from GenerateToken response in group auth\n response('GenerateToken', 'token', group: 'auth')\n\n # return time of today in seconds\n time()\n\n # return timestamp of today in iso8601\n time(format: :iso8601)\n\n # return timestamp of yesterday in iso8601\n time(-1, format: :iso8601)\n\n # return timestamp of last year in iso8601\n time(-365, format: :iso8601)\n\n # return timestamp of tomorrow in iso8601\n time(1, format: :iso8601)\n\n # return credential\n credential('PROJECT_NAME_username')\n\n # return basic auth header value\n basicauth('PROJECT_NAME_username', 'PROJECT_NAME_password')\n \"\n end\n @options.parse!\n\n @config.insert 0, '<command_line>', @cmd_line_arguments\n\n unless File.directory?(@config.output_directory)\n Dir.mkdir @config.output_directory\n end\n\n Dir.chdir @config.working_directory\n end",
"def parse_options(args) # :nodoc:\n args_clone = args.clone\n global_options = {}\n command = nil\n command_options = {}\n remaining_args = nil\n\n global_options,command_name,args = parse_global_options(OptionParserFactory.new(@flags,@switches,@accepts), args)\n @flags.each do |name,flag|\n global_options[name] = flag.default_value unless global_options[name]\n end\n\n command_name ||= @default_command || :help\n command = find_command(command_name)\n if Array(command).empty?\n raise UnknownCommand.new(\"Unknown command '#{command_name}'\")\n elsif command.kind_of? Array\n raise UnknownCommand.new(\"Ambiguous command '#{command_name}'. It matches #{command.sort.join(',')}\")\n end\n\n command_options,args = parse_command_options(OptionParserFactory.new(command.flags,command.switches,@accepts),\n command,\n args)\n\n command.flags.each do |name,flag|\n command_options[name] = flag.default_value unless command_options[name]\n end\n command.switches.each do |name,switch|\n command_options[name] = switch.default_value unless command_options[name]\n end\n\n [global_options,command,command_options,args]\n end",
"def setup_options\n @parser.banner = BANNER\n\n @parser.on('-V', '--version', 'display version and exit') { show_version }\n @parser.on('-h', '--help', 'display help and exit') { show_help }\n @parser.on('-f', '--files=[file1.txt file2.txt ...]', Array, 'text files to read') { |o| @options.files = o }\n @parser.on('-n', '--number=NUM', Integer, 'number of results to show [default = 100]') do |n|\n @options.number = n\n end\n @parser.on('-v', '--verbose', 'verbose output') { @options.verbose = true }\n end",
"def initialize(argv)\n op = option_parser\n op.parse!(argv)\n check_options\n end",
"def getopt_args\n if short\n [[\"--#{name}\", \"-#{short}\", GetoptLong::REQUIRED_ARGUMENT]]\n else\n [[\"--#{name}\", GetoptLong::REQUIRED_ARGUMENT]]\n end\n end",
"def parse_command_line\n prepend_environment_options\n options = options_with_defaults\n\n OptionParser.new do |parser|\n\n parser.on(\"-h\", \"--help\", \"Show help\") do |_help_requested|\n ARGV << 'h' # pass on the request to the command processor\n options.suppress_command_line_validation = true\n end\n\n parser.on('-i', '--input_dir DIR',\n \"Input directory containing source data files, default: '#{DEFAULT_INPUT_DIR}'\") do |v|\n options.input_dir = File.expand_path(v)\n end\n\n parser.on('-o', '--output_dir DIR',\n \"Output directory to which report files will be written, default: '#{DEFAULT_OUTPUT_DIR}'\") do |v|\n options.output_dir = File.expand_path(v)\n end\n\n parser.on('-r', '--receipt_dir DIR',\n \"Directory root from which to find receipt filespecs, default: '#{DEFAULT_RECEIPT_DIR}'\") do |v|\n options.receipt_dir = File.expand_path(v)\n end\n\n parser.on('-s', '--shell', 'Start interactive shell') do |v|\n options.interactive_mode = true\n end\n\n parser.on('-v', '--[no-]verbose', 'Verbose mode') do |v|\n options.verbose_mode = v\n end\n\n parser.on('-y', '--[no-]say', 'Say error messages.') do |v|\n options.say = v\n end\n\n parser.on('', '--[no-]receipts', 'Include report on existing and missing receipts.') do |v|\n options.do_receipts = v\n end\n end.parse!\n\n if options.verbose_mode\n puts \"Run Options:\"\n ap options.to_h\n end\n\n options\n end",
"def parse_options(args)\n\t\t\t\tbegin\n\t\t\t\t\t@options['output'] = :stdout\n\t\t\t\t\t@options['verbose'] = false\n\t\t\t\t\t@options['rescan'] = false\n\t\t\t\t\t@options[:timeout] = 25\n\t\t\t\t\t@options[:directory] = nil\n\n\t\t\t\t\topts = OptionParser.new do |opt|\n\t\t\t\t\t\topt.banner = \"#{APP_NAME} v#{VERSION}\\nJacob Hammack\\n#{HOME_PAGE}\\n\\n\"\n\t\t\t\t\t\topt.banner << \"Usage: #{APP_NAME} <options>\"\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator('File Options')\n\n\t\t\t\t\t\topt.on('-h HASH', '--search-hash HASH', 'Searches a single hash on virustotal.com') do |hash|\n\t\t\t\t\t\t\t@hashes.push(hash)\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-r HASH[,HASH]', '--rescan-hash HASH[,HASH]', 'Requests a rescan of a single hash, or multiple hashes (comma separated), by virustotal.com') do |hash|\n\t\t\t\t\t\t\t@options['rescan'] = true\n\t\t\t\t\t\t\t@hashes.push(hash)\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-f FILE', '--search-hash-file FILE', 'Searches each hash in a file of hashes on virustotal.com') do |file|\n\t\t\t\t\t\t\tif File.exists?(file)\n\t\t\t\t\t\t\t\tputs \"[+] Adding file #{file}\" if @options['verbose']\n\t\t\t\t\t\t\t\t@files_of_hashes.push(file)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tputs \"[!] #{file} does not exist, please check your input!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-u FILE', '--upload-file FILE', 'Uploads a file to virustotal.com for analysis') do |file|\n\t\t\t\t\t\t\tif File.exists?(file)\n\t\t\t\t\t\t\t\tputs \"[+] Adding file #{file}\" if @options['verbose']\n\t\t\t\t\t\t\t\t@uploads.push(file)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tputs \"[!] #{file} does not exist, please check your input!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator(\"Url Options\")\n\n\t\t\t\t\t\topt.on('-s SITE', '--search-site SITE', 'Searches for a single url on virustotal.com') { |site|\n\t\t\t\t\t\t\t@sites.push(site)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator('Output Options')\n\n\t\t\t\t\t\topt.on('-j', '--json-output', 'Print results as json to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :json\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-x', '--xml-output', 'Print results as xml to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :xml\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-y', '--yaml-output', 'Print results as yaml to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :yaml\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('--stdout-output', 'Print results as normal text line to stdout, this is default') do\n\t\t\t\t\t\t\t@options['output'] = :stdout\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator ''\n\t\t\t\t\t\topt.separator 'Advanced Options'\n\n\t\t\t\t\t\topt.on('-c', '--create-config', 'Creates a skeleton config file to use') do\n\t\t\t\t\t\t\tcreate_config\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-d DIRECTORY', '--directory', 'Scans a directory recursively for files and submits the hashes') do |directory|\n\t\t\t\t\t\t\t@options[:directory] = directory\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-p PROXY', '--proxy-server', 'Uses a specified proxy server') do |proxy|\n\t\t\t\t\t\t\t@options['proxy'] = proxy\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('--[no-]verbose', 'Print verbose information') do |v|\n\t\t\t\t\t\t\t@options['verbose'] = v\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator ''\n\t\t\t\t\t\topt.separator 'Other Options'\n\n\t\t\t\t\t\topt.on('-v', '--version', 'Shows application version information') do\n\t\t\t\t\t\t\tputs \"#{APP_NAME} - #{VERSION}\"\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on_tail('-?', '--help', 'Show this message') { |help|\n\t\t\t\t\t\t\tputs opt.to_s + \"\\n\"\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\n\t\t\t\t\tif ARGV.length != 0\n\t\t\t\t\t\topts.parse!\n\t\t\t\t\telse\n\t\t\t\t\t\tputs opts.to_s + \"\\n\"\n\t\t\t\t\t\texit\n\t\t\t\t\tend\n\t\t\t\trescue OptionParser::MissingArgument\n\t\t\t\t\tputs opts.to_s + \"\\n\"\n\t\t\t\t\texit\n\t\t\t\tend\n\t\t\tend",
"def parse_arguments\n @command_line_options = {}\n @config.insert 0, '<command_line>', @command_line_options\n\n @options = OptionParser.new do |opts|\n opts.on('-a', '--application STRING', 'set application name') do |application|\n @command_line_options[:application] = application\n end\n\n opts.on('-d', '--destination DIR', 'set destination directory', \"default: #{@config[:destination_directory]}\") do |directory|\n @command_line_options[:destination_directory] = directory\n end\n\n opts.on('-n', '--dryrun', 'do not switch') do\n @command_line_options[:dryrun] = true\n end\n\n opts.on('-V', '--version STRING', 'set application version to deploy') do |version|\n @command_line_options[:version] = version\n end\n end\n @options.parse!\n end",
"def parse_args\n options = {}\n optparse = OptionParser.new do|opts|\n # Set a banner\n opts.banner = \"Usage: harness.rb [options...]\"\n\n options[:tests] = []\n opts.on( '-t', '--tests DIR/FILE', 'Execute tests in DIR or FILE (defaults to \"./tests\")' ) do|dir|\n options[:tests] << dir\n end\n\n options[:type] = 'skip'\n opts.on('--type TYPE', 'Select puppet install type (pe, git, skip) - default \"skip\"') do\n |type|\n unless File.directory?(\"setup/#{type}\") then\n puts \"Sorry, #{type} is not a known setup type!\"\n exit 1\n end\n options[:type] = type\n end\n\n options[:puppet] = 'git://github.com/puppetlabs/puppet.git#HEAD'\n opts.on('-p', '--puppet URI', 'Select puppet git install URI',\n \" #{options[:puppet]}\",\n \" - URI and revision, default HEAD\",\n \" just giving the revision is also supported\"\n ) do |value|\n options[:type] = 'git'\n options[:puppet] = value\n end\n\n options[:facter] = 'git://github.com/puppetlabs/facter.git#HEAD'\n opts.on('-f', '--facter URI', 'Select facter git install URI',\n \" #{options[:facter]}\",\n \" - otherwise, as per the puppet argument\"\n ) do |value|\n options[:type] = 'git'\n options[:facter] = value\n end\n\n options[:config] = nil\n opts.on( '-c', '--config FILE', 'Use configuration FILE' ) do|file|\n options[:config] = file\n end\n\n opts.on( '-d', '--dry-run', \"Just report what would be done on the targets\" ) do |file|\n $dry_run = true\n end\n\n options[:mrpropper] = FALSE\n opts.on( '--mrpropper', 'Clean hosts' ) do\n puts \"Cleaning Hosts of old install\"\n options[:mrpropper] = TRUE\n end\n\n options[:stdout_only] = FALSE\n opts.on('-s', '--stdout-only', 'log output to STDOUT but no files') do\n puts \"Will log to STDOUT, not files...\"\n options[:stdout_only] = TRUE\n end\n\n options[:quiet] = false\n opts.on('-q', '--quiet', 'don\\'t log output to STDOUT') do\n options[:quiet] = true\n end\n\n opts.on( '-h', '--help', 'Display this screen' ) do\n puts opts\n exit\n end\n end\n optparse.parse!\n return options\nend",
"def parse_command_line_args(args)\n opts = OptionParser.new do |opts|\n opts.banner = 'Usage: tbibtools [OPTIONS] [FILES] < IN > OUT'\n opts.separator ''\n opts.separator 'tbibtools is a free software with ABSOLUTELY NO WARRANTY under'\n opts.separator 'the terms of the GNU General Public License version 2 or newer.'\n opts.separator ''\n \n opts.on('-c', '--config=FILE', String, 'Configuration file') do |value|\n @configuration.config value\n end\n\n opts.on('-e', '--regexp=REGEXP', String, 'Display entries matching the regexp') do |value|\n @configuration.filter Regexp.new(value)\n end\n\n opts.on('-f', '--format=STRING', String, 'Re-format entries (order matters)') do |value|\n @configuration.format *value.split(/,/)\n end\n\n opts.on('--[no-]formatted', 'Unformatted output') do |bool|\n unless bool\n @configuration.entry_format = []\n @configuration.entry_format_default = []\n end\n end\n\n opts.on('-i', '--[no-]case-sensitive', 'Case insensitive') do |bool|\n @configuration.sort_case bool\n end\n \n opts.on('-l', '--format-list=[STRING]', String, 'Format string for list (implies --ls)') do |value|\n @configuration.shortcut_ls\n @configuration.list_format value if value\n end\n\n opts.on('--ls', 'Synonym for: -f list,stripPrelude (\"list\" implies \"unwrap\")') do |bool|\n @configuration.shortcut_ls if bool\n end\n\n opts.on('-o', '--output=FILE', String, 'Output file') do |value|\n @configuration.output value\n end\n\n opts.on('-P', '--strip-prelude', 'Strip the prelude: same as -f stripPrelude but helps to maintain the original formatting') do |bool|\n @configuration.strip_prelude\n end\n\n opts.on('-q', '--query=FIELD=REGEXP', String, 'Show entries for which field matches the regexp') do |value|\n field, rx = value.split(/=/, 2)\n @configuration.query field => Regexp.new(rx, Regexp::IGNORECASE)\n end\n\n opts.on('-s', '--sort=STRING', String, 'Sort (default: sort by key; key = _id, type = _type)') do |value|\n @configuration.sort_key value\n end\n\n opts.on('-S', '--[no-]expand-strings', 'Replace/expand strings') do |bool|\n @configuration.expand_strings bool\n end\n\n opts.on('--strip=FIELDS', String, 'Ignore/strip fields') do |value|\n @configuration.strip value.split(/,/)\n end\n\n opts.on('-u', '--unsorted', 'Unsorted output') do |bool|\n @configuration.sort_key nil\n end\n\n opts.separator ''\n opts.separator 'Other Options:'\n \n opts.on('--debug', Integer, 'Show debug messages') do |v|\n $DEBUG = true\n $VERBOSE = true\n end\n \n opts.on('-v', '--verbose', 'Run verbosely') do |v|\n $VERBOSE = true\n end\n \n opts.on('-h', '--help', 'Show this message') do\n puts opts\n exit 1\n end\n\n opts.separator ''\n opts.separator 'Available formats:'\n format_rx = /^(format|preprocess|head|body|tail)_/\n format_names = (['nnIsYear', 'sortCrossref', 'downcaseType', 'upcaseType'] + \n @configuration.methods.find_all{|m| m =~ format_rx}.collect{|m| m.sub(format_rx, '')}).uniq.sort.join(', ')\n opts.separator format_names\n\n opts.separator ''\n opts.separator 'Known format shortcuts:'\n acc = []\n @configuration.methods.find_all{|m| m =~ /^shortcut_/}.sort.each do |meth|\n fn = meth.sub(/^shortcut_/, '')\n fs = @configuration.send(meth, acc)\n opts.separator \"#{fn}: #{fs.join(',')}\"\n end\n end\n @configuration.input *opts.parse!(args)\n self\n end",
"def get_options\n ARGV.options { |opt|\n opt.banner = \"Usage: ruby #{__FILE__} [options] \"\n\n opt.on(\"--help\", \"What you see right now\"){ puts opt; exit 0}\n\n #Try testing with this\n #ruby __FILE__ -x -c -s test\n opt.on(\"-x\", \"parse arguments and show Usage\") {|@quit|}\n\n opt.on(\"--doc=DIRECTORY\", String, \"Output rdoc (Ruby HTML documentation) into directory\"){|dir|\n system(\"rdoc -o #{dir} #{__FILE__}\")\n }\n\n opt.on(\"--verbose\", \"-v\", \"print intermediate steps to STDERR\"){|@verbose|}\n\n opt.on(\"--schema\", \"-S\", \"Use Schema i.e. XSD rather than XML document\"){|@opt_schema|}\n\n opt.on_tail(\"By default splits data according to opt_filter, \",\n \"Subset plots on #{@opt_subset}. Will not create histograms\")\n\n opt.parse!\n } or exit(1);\n\n if @quit\n pp self\n (print ARGV.options; exit)\n end\n\n rescue NameError => err\n STDERR.puts \"ERROR: #{err}\"\n exit 1\n rescue => err\n STDERR.puts \"ERROR: #{err}\"\n exit 1\n end",
"def parse_command_line\n OptionParser.new do |opts|\n opts.banner = \"Usage: ruby #{$0} [options]\"\n\n opts.on_head(\"-h\", \"--help\", \"Show this help message\") do\n puts opts\n exit\n end\n\n opts.on(\"-v\", \"--verbose\", \"Show all progress messages (INFO, DEBUG, WARNING, ERROR)\") do\n Logger.verbose = true\n end\n\n opts.on(\"-q\", \"--quiet\", \"Only show WARNING and ERROR messages\") do\n Logger.quiet = true\n end\n\n opts.on(\"--console\", \"Open up a console to query the source via rbgccxml\") do\n @requesting_console = true\n end\n\n opts.on(\"--clean\", \"Force a complete clean and rebuild of this extension\") do\n @force_rebuild = true\n end\n\n end.parse!\n end",
"def accept_args(args)\n while /^-+(.+)/ === args[0]\n option = args.shift\n option_method_name = \"option_#{$1}\"\n unless respond_to?(option_method_name)\n raise UsageException, \"Unrecognised option: #{option}\"\n end\n option_method = method(option_method_name)\n parameters = []\n option_method.arity.times { parameters << args.shift }\n option_method.call(*parameters)\n end\n @targets = args\n self\n end",
"def optParse\n OptionParser.new do |o|\n o.on('-v', 'Be more verbose.') { |i|\n self[:verbose] += 1\n }\n o.on('-V', '--version', 'Show version & exit.') { |i|\n puts Meta::VERSION\n exit EX_OK\n }\n o.on('--config NAME',\n \"Set a config name or file\",\n \"(default is #{@conf[:config_name]}).\") {|arg|\n @conf[:config_name] = arg\n }\n o.on('--config-dirs', 'Show possible config locations.') {\n mark = false\n @conf[:config_dirs].each { |idx|\n f = Pathname(idx) + @conf[:config_name]\n if File.file?(f) && !mark\n puts \"* #{f}\"\n mark = true\n else\n puts \" #{f}\"\n end\n }\n exit EX_OK\n }\n\n yield o if block_given?\n o.banner = @conf[:banner]\n\n env = nil\n env = ENV[@conf[:config_env]].shellsplit if ENV.key?(@conf[:config_env])\n\n begin\n [env, ARGV].each { |i| o.parse!(i) if i }\n rescue\n CliUtils.errx EX_USAGE, $!.to_s\n end\n end\n end",
"def parse_options(argv=ARGV)\n argv = argv.dup\n argv = guess_and_switchify_arguments(argv)\n @opt_parser = OptionParser.new do |opts| \n # Set the banner\n opts.banner = banner \n \n # Create new options\n options_arguments.each do |opt_key, opt_val| \n opt_args = build_option_arguments(opt_val)\n \n opt_method = case opt_val[:on]\n when :on\n :on\n when :tail\n :on_tail\n when :head\n :on_head\n else\n raise ArgumentError, \"You must pass :on, :tail, or :head to :on\"\n end\n\n parse_block = \\\n Proc.new() do |*c|\n if c.empty? || c == [nil]\n c = true\n config[opt_key] = (opt_val[:proc] && opt_val[:proc].call(c)) || c\n else\n c = c.first\n config[opt_key] = (opt_val[:proc] && opt_val[:proc].call(c)) || c\n end\n puts filter_options_summary(opts.to_s) if opt_val[:show_options]\n exit opt_val[:exit] if opt_val[:exit]\n end\n\n # opts.send(:on, *[opt_method,*opt_args, parse_block])\n opt_args.unshift opt_method\n opt_args << parse_block\n opts.send(*opt_args)\n end\n end\n\n @opt_parser.summary_indent = @summary_indent if @summary_indent\n @opt_parser.summary_width = @summary_width if @summary_width\n\n @opt_parser.parse!(argv)\n @filtered_argv = argv\n\n # Deal with any required values\n fail = nil\n options_arguments.each do |opt_key, opt_value|\n next unless config[opt_key]\n # next if config[opt_key] == opt_value[:default]\n\n reqargs = []\n case opt_value[:requires]\n when nil\n when Proc\n begin\n result = opt_value[:requires].call(config)\n rescue \n reqargs << $!.message\n end\n reqargs << result if result.class == String\n when Array,Symbol\n required_opts = [opt_value[:requires]].flatten\n required_opts.each do |required_opt|\n reqargs << required_opt.to_sym unless config[required_opt.to_sym]\n end\n\n reqargs.map! do |opt|\n arg = (options_arguments[opt][:long_strip] || options_arguments[opt][:short_strip]).dup\n arg.gsub!(/^-+/,\"\") if arguments.keys.include?(opt)\n arg\n end\n end\n unless reqargs.empty?\n fail = true\n opt = (opt_value[:long_strip] || opt_value[:short_strip]).dup\n opt.gsub!(/^-+/,\"\") if arguments.keys.include?(opt_key)\n puts \"You must supply #{reqargs.join(\", \")} with #{opt}!\"\n end\n\n end\n if fail\n puts filter_options_summary(@opt_parser.to_s)\n exit 2\n end\n\n argv\n end",
"def setup\n begin\n @options = OptParser.parse(ARGV)\n rescue ParserExceptions::MissingArgument\n exit(1)\n end\n\n end",
"def parse(args)\n @options = args\n end",
"def parse_options(args)\n \n dopts = Spiderman::Crawler::DEFAULT_OPTS\n options = Hash.new\n\n opt_parser = OptionParser.new do |opts|\n opts.banner = 'Usage: spiderman [options]'\n opts.separator \"\"\n opts.separator \"Default values are given in parenthesis\"\n opts.separator \"\"\n opts.separator \"Specific options:\"\n\n opts.on(\"--url URL\", \"Setting the Base URL. (#{dopts[:base_url_string]})\") do |url|\n if url !~ Spiderman::Scraper::VALID_URL\n raise OptionParser::InvalidArgument, \"supports only http/https URLs\"\n end\n options[:base_url_string] = url\n end\n\n opts.on(\"--site\", \"-s\", \"Crawl single site only. (#{dopts[:site_only]})\") do\n options[:site_only] = true\n end\n\n opts.on(\"--depth N\", \"-d N\", Numeric, \"Maximum crawl depth, counting the Base URL. (#{dopts[:max_crawl_depth]})\") do |max_crawl_depth|\n if !(max_crawl_depth > 0)\n raise OptionParser::InvalidArgument, \"supports only numbers > 0\"\n end\n options[:max_crawl_depth] = max_crawl_depth\n end\n\n opts.on(\"--urls N\", \"-u N\", Numeric, \"Maximum number of urls to discover (#{dopts[:max_urls]})\") do |max_urls|\n if !(max_urls > 0)\n raise OptionParser::InvalidArgument, \"supports only numbers > 0\"\n end\n options[:max_urls] = max_urls\n end\n\n opts.separator \"\"\n opts.separator \"Common options:\"\n\n opts.on_tail('--verbose', \"Verbose output. (#{dopts[:verbose]})\") do\n options[:verbose] = true\n end\n\n opts.on_tail('--help', '-h', 'Show this message') do\n puts opts\n @end_program=true\n return\n end\n\n opts.on_tail('--version', '-v', 'Show version') do\n puts \"#{APPNAME}: version #{VERSION}\"\n @end_program=true\n return\n end\n end\n\n begin\n opt_parser.parse!(args)\n rescue => ex\n puts ex\n @end_program = true\n end\n\n options\n end",
"def parse!(*args)\n # it is actually # def parse(argv = default_argv, into: nil)\n argv = [args].flatten() # args[0].flatten\n #help_wanted = argv.find {|arg| arg == \"--help\" || arg == \"-h\" }\n help_wanted = (argv.last == \"--help\" || argv.last == \"-h\") ? argv.last : nil\n begin\n return super(*args)\n rescue OptionParser::ParseError => e\n # last arg is --help\n # maybe they just got the Try --help message and its on the end\n # so strip all option arguments to avoid OptionParser::InvalidOption, etc.\n # this is not ideal, it means you cannot pass these strings as the last argument to your command.\n if help_wanted\n argv = argv.reject {|arg| arg =~ /^\\-+/ }\n argv << help_wanted\n return super(argv)\n else\n e.optparse = self\n raise e\n end\n \n end\n end",
"def parse\n parser.parse(ARGV)\n @options\n rescue OptionParser::InvalidOption => e\n puts e\n puts parser\n #p @options\n exit(1)\n end",
"def parse_command_line(args)\n all_opts = OptionParser.new do |opts|\n opts.banner = \"Usage: #{PROGRAM_NAME} [OPTIONS] PASSWORD\"\n opts.separator ''\n\n opts.on(\n '-t',\n '--load-timeout [TIMEOUT_SECONDS]',\n Integer,\n 'Timeout in seconds to wait for',\n 'gitlab-rails console to load',\n 'and process the change.',\n \"Defaults to #{DEFAULT_LOAD_TIMEOUT} seconds.\"\n ) do |timeout|\n @options.load_timeout = timeout\n end\n\n opts.on(\n '-v',\n '--verbose',\n 'Print out debug info when processing.'\n ) do\n @options.debug = true\n end\n\n opts.on(\n '-h',\n '--help',\n 'Help Message'\n ) do\n puts opts\n @options.help_requested = true\n end\n end\n\n all_opts.parse!(args)\n\n unless @options.help_requested\n fail('ERROR: You must specify the password to set') if (ARGV.length < 1)\n\n @options.password = ARGV[0]\n fail('ERROR: Password cannot be empty') if @options.password.strip.empty?\n end\n end",
"def parse_options(opts)\n opts.separator \"\"\n opts.separator \"Installation options:\"\n\n # Convert symbols to strings\n tmp = {}\n @dir.each { |k,v| tmp[k.to_s] = v }\n\n tmp.sort.each do |k, v|\n opts.on('--' + k + ' [DIRECTORY]', \"TODO describe this [#{v}]\") do |arg|\n @dir[k.to_sym] = arg\n end\n end\n\n end",
"def parse(args)\n # The options specified on the command line will be collected in\n # *options*.\n @options = ScriptOptions.new\n\n @args = OptionParser.new do |parser|\n @options.define_options(parser)\n parser.parse!(args)\n end\n\n @options\n end",
"def parse(args)\n @options = {}\n @options[:command] = :scan # Default command is to scan for lints\n\n OptionParser.new do |parser|\n parser.banner = \"Usage: #{@application.executable_name} [options] [file1, file2, ...]\"\n\n add_linter_options parser\n add_file_options parser\n add_misc_options parser\n add_info_options parser\n end.parse!(args)\n\n # Any remaining arguments are assumed to be files that should be linted\n @options[:included_paths] = args\n\n @options\n rescue OptionParser::InvalidOption => ex\n raise InvalidCliOptionError,\n \"#{ex.message}\\nRun `#{@application.executable_name} --help` to \" \\\n 'see a list of available options.'\n end",
"def setup_options\n parser = OptionParser.new do |o|\n o.banner = 'Usage: bundle exec qpush-server [options]'\n\n o.on('-c', '--config PATH', 'Load PATH for config file') do |arg|\n load(arg)\n Server.log.info(\"* Server config: #{arg}\")\n end\n\n o.on('-h', '--help', 'Prints this help') { puts o && exit }\n end\n parser.parse!(@argv)\n end",
"def processCommandLineOptions\n if ARGV\n ARGV.each do |arg|\n if arg.index('=')\n setting, value = arg.split('=')\n setting = setting.chomp\n value = value.chomp.strip\n if setting == 'logLevel'\n value = value.upcase.gsub(/\\'/,'')\n level = LEVELS_TEXT.index(value.upcase)\n @currentLogLevel = level if level\n elsif setting == 'consoleLogging'\n @consoleLogging = value.downcase == 'true'\n elsif setting == 'logfile'\n @currentFileName = File.expand_path(value)\n end\n end\n end\n end\n end",
"def parse(argv = [])\n @option_parser.parse!(argv)\n\n options.each do |option|\n if option.required? and !option.has_value?\n Shebang.error(\"The -#{option.short} option is required\")\n end\n end\n\n return argv\n end",
"def parse_command_line()\n opts = GetoptLong.new(\n [ \"--input-file\" , \"-i\", GetoptLong::REQUIRED_ARGUMENT ],\n [ \"--verbose\" , \"-v\", GetoptLong::NO_ARGUMENT ]\n )\n #----------------------------- defaults\n\n opts.each do |opt, arg|\n if (opt == \"--input-file\" ) ; $input_file = arg\n elsif (opt == \"--verbose\" ) ; $verbose = 1\n end\n\n if ($verbose != 0) ; puts \"Option: #{opt}, arg #{arg.inspect}\" ; end\n end\nend",
"def validate_and_parse_options\n # Checking ARGV validity *before* parse_options because parse_options\n # mangles ARGV in some situations\n if no_command_given?\n print_help_and_exit(1, NO_COMMAND_GIVEN)\n elsif no_subcommand_given?\n if (want_help? || want_version?)\n print_help_and_exit\n else\n print_help_and_exit(2, NO_COMMAND_GIVEN)\n end\n end\n end",
"def parse_options(opts=nil)\n # Creating a shallow copy of the arguments so the OptionParser\n # doesn't destroy the originals.\n argv = @argv.dup\n\n # Default opts to a blank optionparser if none is given\n opts ||= OptionParser.new\n\n # Add the help option, which must be on every command.\n opts.on_tail(\"-h\", \"--help\", \"Print this help\") do\n safe_puts(opts.help)\n return nil\n end\n\n opts.parse!(argv)\n return argv\n rescue OptionParser::InvalidOption\n raise Errors::CLIInvalidOptions, help: opts.help.chomp\n end",
"def parse_options\nmain_opts = %w(jadd cadd jgadd cgadd wadd sum list ausgleich)\nbetrag_opts = %w(jadd cadd jgadd cgadd wadd)\n\n\tusage if ARGV.size < 1\n\n\toptions = {:modus => ARGV.shift}\n\n\tusage unless main_opts.include?(options[:modus])\n\n\tif betrag_opts.include?(options[:modus])\n\t\tusage if ARGV.size < 1\n\t\toptions[:betrag] = ARGV.shift.to_f\n\t\toptions[:tags] = sanitize_tags(ARGV)\n\n\t\toptions[:jahr] = Time.now.year\n\t\toptions[:monat] = Time.now.month\n\telsif options[:modus] == \"sum\" || options[:modus] == \"list\"\n\t\t#usage if ARGV.size < 1\n\t\toptions[:name] = parse_name\n\t\toptions[:jahr], options[:monat] = parse_date\n\telsif options[:modus] == \"ausgleich\"\n\t\toptions[:jahr], options[:monat] = parse_date\n\tend\n\n\treturn options\nend",
"def parse_options(argv, options)\n\toptions[:extra_plugins] = []\n\topt_parser = OptionParser.new do |opts|\n\t\topts.banner = \"Usage: make.rb [options]\"\n\t\topts.separator \"\"\n\t\topts.separator \"Common Options:\"\n\t\topts.on(\"-o\", \"--output DIRECTORY\", \"Binaries output directory (override SR_BIN_DIR)\") { |v| options[:output] = v }\n\t\topts.on(\"-p\", \"--platform PLATFORM\", \"Platform to target (#{$platforms.join(\", \")}, #{$platform_aliases.keys.join(\", \")})\") { |v| options[:platform] = v }\n\t\topts.on(\"-c\", \"--config CONFIGURATION\", \"Build configuration to use (#{$configs.join(\", \")})\") { |v| options[:config] = v }\n\t\topts.on(\"-e\", \"--devenv ENVIRONMENT\", \"Development environment to use (#{$devenvs.join(\", \")})\") { |v| options[:devenv] = v }\n\t\topts.on(\"-t\", \"--target TARGET\", \"Target project to build (default is all)\") { |v| options[:target] = v }\n\t\topts.on(\"-r\", \"--rebuild\", \"Clean all output targets before build\") { |v| options[:rebuild] = v }\n\t\topts.on(\"-x\", \"--clean\", \"Clean all output targets only\") { |v| options[:clean] = v }\n\t\topts.on(\"-g\", \"--[no-]generate\", \"Generate project files (default)\") { |v| options[:generate] = v }\n\t\topts.on(\"-b\", \"--[no-]build\", \"Launch a build of generated project files (default)\") { |v| options[:build] = v }\n\t\topts.on(\"-z\", \"--[no-]debug-info\", \"Enable debug information in all configurations (default)\") { |v| options[:debug_info] = v }\n\t\topts.on(\"--[no-]engine\", \"Enable Engine target\") { |v| options[:engine] = v }\n\t\topts.on(\"--[no-]editor\", \"Enable Editor target\") { |v| options[:editor] = v }\n\t\topts.separator \"\"\n\t\topts.separator \"Other Options:\"\n\t\topts.on(\"-k\", \"--kill\", \"Kill running processes\") { |v| options[:kill] = v }\n\t\topts.on(\"-u\", \"--[no-]update\", \"Update library directory with latest versions (default)\") { |v| options[:update] = v }\n\t\topts.on(\"-v\", \"--[no-]verbose\", \"Print detailed build informations\") { |v| options[:verbose] = v }\n\t\topts.on(\"--distrib\", \"Bundle your plugin for distribution\") { |v| options[:distrib] = v }\n\t\topts.on(\"--pause\", \"Pause system on completion or error\") { |v| options[:pause] = v }\n\t\topts.on(\"-h\", \"--help\", \"Prints this help\") do\n\t\t\tputs opts\n\t\t\texit 1\n\t\tend\n\tend\n\n\t# Parse options\n\tbegin\n\t\topt_parser.parse(argv)\n\trescue OptionParser::ParseError => e\n\t\tputs e\n\t\tputs\n\t\tputs opt_parser\n\t\texit 1\n\tend\n\n\treturn opt_parser\nend",
"def program_options\n [\n # The values of the array are,\n # [long_option, short_option and parameter, description, code to execute]\n ['--google', '-g', \"Format for Google blogger.\",\n lambda { |value| options.google = true }\n ],\n ['--jayway', '-j', \"Format for Jayway blog.\",\n lambda { |value| options.jayway = true }\n ],\n ['--utf', '-u', \"Include meta charset utf8\",\n lambda { |value| options.utf = true }\n ],\n ['--stylesheet', '-s', \"Add a stylesheet, md.css\",\n lambda { |value| options.stylesheet = true }\n ],\n ['--verbose', '-v', \"Log to standard output.\",\n lambda { |value| options.verbose = true }\n ],\n ['--version', '-V', \"Display the program version.\",\n lambda { |value|\n puts \"#{program_name}, version #{PROGRAM_VERSION}\"\n exit\n }\n ]\n ]\nend",
"def parse_options(opts, args)\n reset\n opts.parse!(args)\n rescue OptionParser::ParseError => err\n kill unrecognized_option(err)\n end",
"def parse!(argv=ARGV)\n argv = Shellwords.shellwords(argv) if argv.kind_of?(String)\n\n registry.each do |option|\n if assign_defaults && option.respond_to?(:assign_default)\n option.assign_default(config)\n end\n end\n\n args = []\n while !argv.empty?\n arg = argv.shift\n\n # add the remaining args and break\n # for the option break\n if option_break === arg\n argv.unshift(arg) if preserve_option_break\n break\n end\n\n # determine if the arg is an option\n unless option?(arg)\n args << arg\n next\n end\n\n flag, value = arg, nil\n\n # try the flag directly\n unless option = @options[flag]\n\n # then try --opt=value syntax\n flag, value = flag.split('=', 2)\n\n # then try -ovalue syntax\n if value.nil? && flag[1] != ?-\n flag, value = flag[0, 2], flag[2, flag.length - 2]\n end\n\n unless option = @options[flag]\n raise \"unknown option: #{flag}\"\n end\n end\n\n option.parse(flag, value, argv, config)\n end\n\n args.concat(argv)\n argv.replace(args)\n\n block_given? ? yield(argv, config) : argv\n end",
"def parse_cmdline(o)\n cmd_opts = GetoptLong.new(\n ['--cluster', '-c', GetoptLong::REQUIRED_ARGUMENT],\n ['--pool', '-p', GetoptLong::REQUIRED_ARGUMENT],\n ['--end', '-e', GetoptLong::REQUIRED_ARGUMENT],\n ['--help', '-h', GetoptLong::NO_ARGUMENT],\n ['--output', '-o', GetoptLong::REQUIRED_ARGUMENT],\n ['--start', '-s', GetoptLong::REQUIRED_ARGUMENT],\n ['--utc', '-u', GetoptLong::REQUIRED_ARGUMENT],\n ['--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT],\n ['--version', '-V', GetoptLong::OPTIONAL_ARGUMENT]\n )\n cmd_opts.each do |opt, arg|\n case opt\n when '--cluster'\n o[:cluster] = arg\n when '--pool'\n o[:pool] = arg\n when '--end'\n if check_iso_date(arg)\n o[:end] = Time.parse(\"#{arg}T00:00:00Z\")\n o[:current] = false\n else\n STDERR.puts \"argument --start invalid (given #{arg})\"\n exit 1\n end\n when '--help'\n puts <<-EOF\n#{$PROGRAM_NAME} [OPTIONS]\n\n-c, --cluster: Mandatory argument to depict which cluster the accounting\n information belongs to - is also part of output\n-h, --help: Show this help message\n-o, --output: Place results into this directory\n-v, --verbose: Be more verbose about what is happening\n note, prepending # to ensure it does not mangle output\n-V, --version: Output version string\n\nYou can specify the query range by specifying either\n-u, --utc: Run query for specified UTC date (YYYY-MM-DD)\nor\n-s, --start: start query at UTC date YYYY-MM-DD (start of day, i.e. 00:00:00)\n-e, --end: stop query at UTC date YYYY-MM-DD (end of day, i.e. 23:59:59,\n ignoring leap seconds\n\nPlease note that these -u and (-s/-e) are mutually exclusive and -u\nimplies -s/-e set to the same date.\n\nIf no date is given it will be the previous full UTC day prior to the\nscript's run time (a.k.a. now).\n\nEOF\n exit 0\n when '--output'\n o[:output] = File.expand_path(arg)\n when '--start'\n if check_iso_date(arg)\n o[:start] = Time.parse(\"#{arg}T00:00:00Z\")\n o[:current] = false\n else\n STDERR.puts \"argument --start invalid (given #{arg})\"\n exit 1\n end\n when '--utc'\n if check_iso_date(arg)\n o[:utc] = Time.parse(\"#{arg}T00:00:00Z\")\n o[:current] = false\n else\n STDERR.puts \"argument --utc invalid (given #{arg})\"\n exit 1\n end\n when '--verbose'\n o[:verbose] = 42\n when '--version'\n puts \"This is ldg-accounting-collector version\\n#{VERSION}\"\n exit 1\n else\n STDERR.puts \"unrecognized option #{arg}\"\n end\n end\nend",
"def parse_other_args(opts, options)\n opts.on('-q', '--offline-queueing') do\n options[:offline_queueing] = true\n end\n\n opts.on('-F', '--filter-params [PARAMS}') do |params|\n options[:filter_params] = params.split(/\\s*,\\s*/)\n end\n\n opts.on('--help') do\n puts Usage.scan(__FILE__)\n exit\n end\n end",
"def parse_options\n options = {}\n case ARGV[1]\n when '-e'\n options[:e] = ARGV[2]\n when '-d'\n options[:d] = ARGV[2]\n end\n options\nend",
"def parse_options_helper(args,global_options,command,command_options,arguments) # :nodoc:\n non_flag_i = find_non_flag_index(args)\n all_flags = false\n if non_flag_i == 0\n # no flags\n if !command\n command_name = args.shift\n command = find_command(command_name)\n raise UnknownCommand.new(\"Unknown command '#{command_name}'\") if !command\n return parse_options_helper(args,\n global_options,\n command,\n Hash.new,\n arguments)\n elsif((index = flag_switch_index(args)) >= 0)\n try_me = args[0..index-1]\n rest = args[index..args.length]\n new_args = rest + try_me\n return parse_options_helper(new_args,\n global_options,\n command,\n Hash.new,\n arguments)\n else\n return global_options,command,command_options,arguments + args\n end\n elsif non_flag_i == -1\n all_flags = true\n end\n\n try_me = args[0..non_flag_i]\n rest = args[(non_flag_i+1)..args.length]\n if all_flags\n try_me = args\n rest = []\n end\n\n # Suck up whatever options we can\n switch_hash = switches\n flag_hash = flags\n options = global_options\n if command\n switch_hash = command.switches\n flag_hash = command.flags\n options = command_options\n end\n\n switch_hash.each do |name,switch|\n value = switch.get_value!(try_me)\n options[name] = value if !options[name]\n end\n\n flag_hash.each do |name,flag|\n value = flag.get_value!(try_me)\n # So, there's a case where the first time we request the value for a flag,\n # we get the default and not the user-provided value. The next time we request\n # it, we want to override it with the real value.\n # HOWEVER, sometimes this happens in reverse, so we want to err on taking the\n # user-provided, non-default value where possible.\n if value\n if options[name]\n options[name] = value if options[name] == flag.default_value\n else\n options[name] = value\n end\n end\n end\n\n if try_me.empty?\n return [global_options,command,command_options,arguments] if rest.empty?\n # If we have no more options we've parsed them all\n # and rest may have more\n return parse_options_helper(rest,global_options,command,command_options,arguments)\n else\n if command\n check = rest\n check = rest + try_me if all_flags\n check.each() do |arg|\n if arg =~ /^\\-\\-$/\n try_me.delete arg\n break\n end\n raise UnknownCommandArgument.new(\"Unknown option #{arg}\",command) if arg =~ /^\\-/\n end\n return [global_options,command,command_options,try_me + rest]\n else\n # Now we have our command name\n command_name = try_me.shift\n raise UnknownGlobalArgument.new(\"Unknown option #{command_name}\") if command_name =~ /^\\-/\n\n command = find_command(command_name)\n raise UnknownCommand.new(\"Unknown command '#{command_name}'\") if !command\n\n return parse_options_helper(rest,\n global_options,\n command,\n Hash.new,\n arguments)\n end\n end\n end",
"def parse_initial_options argv\n parse_args argv do |argv, remaining_args, arg|\n argv.unshift arg\n :break\n end\n end",
"def parse_options(argv=ARGV)\n argv = argv.dup\n @opt_parser = OptionParser.new do |opts| \n # Set the banner\n opts.banner = banner \n \n # Create new options\n options.sort { |a, b| a[0].to_s <=> b[0].to_s }.each do |opt_key, opt_val| \n opt_args = build_option_arguments(opt_val)\n \n opt_method = case opt_val[:on]\n when :on\n :on\n when :tail\n :on_tail\n when :head\n :on_head\n else\n raise ArgumentError, \"You must pass :on, :tail, or :head to :on\"\n end\n \n parse_block = case opt_val[:boolean]\n when true\n Proc.new() do\n config[opt_key] = (opt_val[:proc] && opt_val[:proc].call(true)) || true\n puts opts if opt_val[:show_options]\n exit opt_val[:exit] if opt_val[:exit]\n end\n when false\n Proc.new() do |c|\n config[opt_key] = (opt_val[:proc] && opt_val[:proc].call(c)) || c\n puts opts if opt_val[:show_options]\n exit opt_val[:exit] if opt_val[:exit]\n end\n end\n \n full_opt = [ opt_method ]\n opt_args.inject(full_opt) { |memo, arg| memo << arg; memo }\n full_opt << parse_block\n opts.send(*full_opt)\n end\n end\n @opt_parser.parse!(argv)\n \n # Deal with any required values\n options.each do |opt_key, opt_value|\n if opt_value[:required] && ! config[opt_key]\n reqarg = opt_value[:short] || opt_value[:long]\n puts \"You must supply #{reqarg}!\"\n puts @opt_parser\n exit 2\n end\n end\n \n argv\n end",
"def process_argv!\n args = ARGV.dup\n self.rest = []\n until args.empty? do\n arg = args.shift\n case\n when arg == '--'\n self.rest += args\n break\n when arg =~ /\\A--([\\w\\-\\.]+)(?:=(.*))?\\z/\n param, val = [$1, $2]\n param.gsub!(/\\-/, '.') # translate --scoped-flag to --scoped.flag\n param = param.to_sym unless (param =~ /\\./) # symbolize non-scoped keys\n if val == nil then val = true # --flag option on its own means 'set that option'\n elsif val == '' then val = nil end # --flag='' the explicit empty string means nil\n self[param] = val\n when arg =~ /\\A-(\\w+)\\z/\n $1.each_char do |flag|\n param = param_with_flag(flag)\n self[param] = true if param\n end\n else\n self.rest << arg\n end\n end\n end",
"def parse\n opts = OptionParser.new(&method(:set_options))\n opts.parse!(@args)\n return login if @login\n puts opts.help\n end",
"def initialize(given_args=ARGV)\n @options, @arguments, @extras = self.class.parse_options!(given_args)\n end",
"def parseoptions\n $PRETEND = $COLOR = false\n asked_args = false\n ARGV.options {|oparser|\n oparser.banner = \"Usage: #$0 [options] [tests ...]\\n\"\n\n oparser.on( \"--help\", \"-h\", _(\"Show this message\" )) {\n $stderr.puts oparser\n exit!(0)\n }\n\n oparser.on( \"--debug\", \"-d\", _(\"Turn debugging on\") ) {\n $DEBUG = true\n }\n\n oparser.on( \"--color\", \"-C\", _(\"Enable coloration of the output\") ) {\n $COLOR = true\n }\n\n oparser.on( \"--menu\", \"-m\", _(\"Create a menu for test selection\") ) {\n asked_args = true\n }\n\n oparser.on( \"--show-tests\", \"-s\", _(\"Show a list of available tests\") ) {\n header _(\"Possible tests:\") + \"\\n\\n\"\n $TESTS.each {|name,info|\n message \"#{name} \"\n display \"- For #{info['title'].downcase.gsub(/:/,'')}\\n\"\n }\n exit!(0)\n }\n\n oparser.parse!\n }\n args = []\n if asked_args\n clear\n args << menu( _(\"Please choose from these available tests:\").dup,\n _(\"Which test would you like to run?\").dup,\n *$TESTS.keys )\n end\n return args + ARGV\nend",
"def parse_options\n @options = {}\n @optparse = OptionParser.new do |opts|\n opts.banner = \"Usage: moa-getfacl [options] <object-name> ...\\n\\n Object Store ACL Listing\\n\\n\"\n\n # @options[:numeric] = false\n # opts.on( '-n', 'Display user IDs numerically' ) do\n # @options[:numeric] = true\n # end\n\n opts.on( '-?', '--help', 'Display this screen' ) do\n puts opts\n exit 0\n end\n end\n\n @optparse.parse!\nend",
"def parse_options(args)\n opt_parser = OptionParser.new do |opts|\n # Set a banner, displayed at the top\n # of the help screen.\n opts.banner = 'Usage: k9 [options] [<filename.rb>]'\n # Define the options, and what they do\n options[:version] = false\n opts.on('-v', '--version', 'JRubyArt Version') do\n options[:version] = true\n end\n\n options[:install] = false\n opts.on('-i', '--install', 'Installs jruby-complete and examples') do\n options[:install] = true\n end\n\n options[:check] = false\n opts.on('-?', '--check', 'Prints configuration') do\n options[:check] = true\n end\n\n options[:app] = false\n opts.on('-a', '--app', 'Export as app NOT IMPLEMENTED YET') do\n options[:export] = true\n end\n\n options[:watch] = false\n opts.on('-w', '--watch', 'Watch/run the sketch') do\n options[:watch] = true\n end\n\n options[:run] = false\n opts.on('-r', '--run', 'Run the sketch') do\n options[:run] = true\n end\n\n options[:live] = false\n opts.on('-l', '--live', 'As above, with pry console bound to Processing.app') do\n options[:live] = true\n end\n\n options[:create] = false\n opts.on('-c', '--create', 'Create new outline sketch') do\n options[:create] = true\n end\n\n # This displays the help screen, all programs are\n # assumed to have this option.\n opts.on('-h', '--help', 'Display this screen') do\n puts opts\n exit\n end\n end\n @argc = opt_parser.parse(args)\n @filename = argc.shift\n end",
"def parse_options(args)\n config = {}\n deprecated_args = []\n flag = /^--/\n\n args.size.times do\n break if args.empty?\n peek = args.first\n next unless peek && (peek.match(flag) || peek.match(/=/))\n arg = args.shift\n peek = args.first\n key = arg\n if key.match(/=/)\n deprecated_args << key unless key.match(flag)\n key, value = key.split('=', 2)\n elsif peek.nil? || peek.match(flag)\n value = true\n else\n value = args.shift\n end\n value = true if value == 'true'\n config[key.sub(flag, '')] = value\n\n if !deprecated_args.empty?\n out_string = deprecated_args.map{|a| \"--#{a}\"}.join(' ')\n display(\"Warning: non-unix style params have been deprecated, use #{out_string} instead\")\n end\n end\n\n config\n end",
"def run_option_parser\n @run_option_parser ||= begin\n require 'optparse'\n OptionParser.new do |op|\n op.on('-x') { set :lock, true }\n op.on('-e env') { |val| set :environment, val.to_sym }\n op.on('-s server') { |val| set :server, val }\n op.on('-p port') { |val| set :port, val.to_i }\n end \n end\n end",
"def parse_yardopts_options(*args)\n opts = OptionParser.new\n opts.base.long.clear # HACK: why are --help and --version defined?\n yardopts_options(opts)\n begin\n opts.parse(args)\n rescue OptionParser::ParseError => err\n idx = args.index(err.args.first)\n args = args[(idx + 1)..-1]\n args.shift while args.first && args.first[0, 1] != '-'\n retry\n end\n end",
"def parse_args\n\t\t@args = @args_a.each_slice(2).to_a.inject({}) { |h, k| h[k[0]] = k[1]; h }\n\t\tkeys = @skeys + @lkeys\n\t\t@args.each do |k, v|\n\t\t\tif !keys.include?(k)\n\t\t\t\tputs \"Unknown option `#{k}'\"\n\t\t\t\texit\n\t\t\tend\n\n\t\t\tif keys.include?(v)\n\t\t\t\tputs \"Missing values for `#{k}' and `#{v}'\"\n\t\t\t\texit\n\t\t\tend\n\n\t\t\tif v != nil\n\t\t\t\tif v.start_with?('-')\n\t\t\t\t\tputs \"Warning: Value of `#{k}' appears to be a flag\"\n\t\t\t\tend\n\n\t\t\t\tif @static.has_key?(k)\n\t\t\t\t\tif !@static[k].include?(v)\n\t\t\t\t\t\tputs \"Unknown option `#{v}' for `#{k}'\"\n\t\t\t\t\t\texit\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t\n\t\tif remove_keys(@no_vals).has_blank?\n\t\t\tputs \"Missing argument(s)\"\n\t\t\texit\n\t\tend\t\t\t\n\tend",
"def parse_command_line args\n args.options do |opt|\n opt.on(\"rutema v#{Version::STRING}\")\n opt.on(\"Options:\")\n opt.on(\"--config FILE\", \"-c FILE\",String,\"Loads the configuration from FILE\") { |config_file| @config_file=config_file}\n opt.on(\"--check\",\"Runs just the suite setup test\"){@check=true}\n #opt.on(\"--step\",\"Runs test cases step by step\"){@step=true}\n opt.on(\"--silent\",\"Suppresses console output (only for the default reporters)\") { @silent=true}\n opt.on(\"--bare\",\"No default reporters whatsoever\") { @bare=true}\n #opt.on(\"--color\",\"Adds color to the Console reporter\") { @color=true}\n opt.on(\"-v\", \"--version\",\"Displays the version\") { $stdout.puts(\"rutema v#{Version::STRING}\");exit 0 }\n opt.on(\"--help\", \"-h\", \"-?\", \"This text\") { $stdout.puts opt; exit 0 }\n opt.on(\"--debug\", \"-d\", \"Turn on debug messages\") { $DEBUG=true }\n opt.on(\"You can provide a specification filename in order to run a single test\")\n opt.parse!\n #and now the rest\n unless @config_file\n puts \"No configuration file defined!\\n\"\n $stdout.puts opt \n exit 1\n end\n if !args.empty?\n @test_identifier=args.shift\n end\n end\n end",
"def parse_options\n opts = Slop.parse(help: true, strict: true) do\n banner \"Usage: fixexts [options]\"\n\n # on 'c', 'codecs', 'List the availiable codecs'\n # on 'u=', 'use', 'Tool to use (ffmpeg, mencoder)', default: \"ffmpeg\"\n end\n\n [opts, ARGV]\nend",
"def parse_yardopts_options(*args); end",
"def parse_options(opts=nil, argv=nil)\n # Creating a shallow copy of the arguments so the OptionParser\n # doesn't destroy the originals.\n argv ||= $argv.dup\n\n # Default opts to a blank optionparser if none is given\n opts ||= OptionParser.new\n\n # Add the help option, which must be on every command.\n opts.on_tail('-h', '--help', 'Print this help') do\n safe_puts(opts.help)\n return nil\n end\n\n opts.parse!(argv)\n return argv\nrescue OptionParser::InvalidOption, OptionParser::MissingArgument\n raise \"Error: Invalid CLI option, #{opts.help.chomp}\"\nend",
"def parse(args)\n @options = Options.new\n @args = OptionParser.new do |parser|\n @options.define_options(parser)\n begin\n parser.parse!(args)\n rescue OptionParser::InvalidOption => e\n puts e.message\n exit\n end\n end\n @options\n rescue OptionParser::MissingArgument => e\n puts e.message\n exit\n end",
"def parse_options(argv, env)\n argv_copy = argv.dup\n opts = parse_global_options!(argv_copy, env)\n subcommand = parse_subcommand!(argv_copy)\n opts[:subcommand] = subcommand\n sub_opts = parse_subcommand_options!(subcommand, argv_copy, env)\n opts.merge!(sub_opts)\n opts\n end"
] | [
"0.7472496",
"0.7272251",
"0.726024",
"0.70750475",
"0.7013277",
"0.6992019",
"0.69448227",
"0.693979",
"0.69206727",
"0.6917643",
"0.6903173",
"0.6861814",
"0.68046296",
"0.67599016",
"0.67599016",
"0.67512107",
"0.6736139",
"0.67022526",
"0.6683321",
"0.6647732",
"0.6639775",
"0.663611",
"0.6635176",
"0.66289",
"0.66245764",
"0.66229635",
"0.6601175",
"0.658331",
"0.65831995",
"0.6581417",
"0.6575592",
"0.6573939",
"0.6549364",
"0.6539193",
"0.65231115",
"0.6520362",
"0.6517387",
"0.64883304",
"0.64794284",
"0.64734596",
"0.6464361",
"0.6462726",
"0.64617187",
"0.64470226",
"0.64443177",
"0.6426411",
"0.6419808",
"0.6400068",
"0.6396161",
"0.63923824",
"0.63900006",
"0.6386154",
"0.63846916",
"0.63832474",
"0.6377505",
"0.636175",
"0.635924",
"0.63528204",
"0.63486147",
"0.63437295",
"0.6343299",
"0.63413477",
"0.632713",
"0.6327105",
"0.63240623",
"0.63212645",
"0.6316294",
"0.63104254",
"0.629755",
"0.6294581",
"0.6270722",
"0.6269904",
"0.62684554",
"0.6267399",
"0.6265561",
"0.6262776",
"0.62537616",
"0.62478673",
"0.6247315",
"0.6241469",
"0.6241016",
"0.6239379",
"0.62380904",
"0.6222343",
"0.6216093",
"0.6211686",
"0.62038636",
"0.620368",
"0.6201725",
"0.6185892",
"0.61858916",
"0.61812854",
"0.61772877",
"0.616425",
"0.6162702",
"0.6158264",
"0.6152844",
"0.6151727",
"0.61508197",
"0.6148999",
"0.61467206"
] | 0.0 | -1 |
Depth first search for the longest simple path starting from 'node' Simple path means a path that doesn't contain any duplicate edges Note: I'm not suing the definition of simply connected based on no duplicate nodes | def search(node)
longest_path = 0
if (@paths[node])
@paths[node].each_index do |next_idx|
next_node = @paths[node][next_idx]
@paths[node].delete_at(next_idx)
tmp = 1 + search(next_node)
@paths[node].insert(next_idx,next_node)
if (longest_path < tmp)
longest_path = tmp
end
end
end
return longest_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def depth_first_search(node)\n return if node.nil?\n node.visit\n node.connections.each do |conn|\n depth_first_search(conn) unless conn.visited\n end\nend",
"def depth_first_search!(node)\n node.marked = true\n node.type = \"M\"\n node.adj.each do |n|\n if n.marked == false\n depth_first_search(n)\n end\n end\n end",
"def depth_first_graph(node, visited = [])\n if !visited.include? node\n visited.push(node)\n output = node.data.to_s + \" \"\n output += node.connections.map do |connection|\n depth_first_graph(connection, visited)\n end.join(\"\")\n end\n output\nend",
"def path_finder(start_node=START_NODE, goal_node=GOAL_NODE)\n\t\n\t# INITIALIZE\n\tvalid = valid_nodes # largest set\n\treachable = [start_node] # nodes we can reach from current node\n\texplored = [] # nodes we've already considered\n\t# nodes reachable, valid, and not explored\n\topen_nodes = valid.select{|node| reachable.include?(node)}.select{|node| !explored.include?(node)} \n\t# record node path {node => previous_node}\n\tnodes_path = {start_node => nil} \n\t\n\twhile !open_nodes.empty?\n # node = choose_node(reachable)\n\t\tnode = open_nodes.sample # random node in open_nodes\n\t\t\n\t\treturn build_path(goal_node, nodes_path) if node==goal_node # STOP if reached goal! \n \n # Don't repeat ourselves.\n reachable.delete(node) # remove current node from reachable\n explored.push(node) # add node to explored\n \n # What nodes are now open from this node?\n # Adjacent, not in explored, and valid (not an obstacle and in maze)\n new_reachable = (get_adjacent_nodes(node) - explored) & valid\n\t\t# ADD new nodes to reachable\n new_reachable.each do |adj_node|\n if !reachable.include?(adj_node)\n # adjacent.previous = node # Remember how we got there.\n nodes_path[adj_node] = node # {[0,3] => [0,2]}\n reachable << adj_node\n end\n end\n \n\t\t# REFRESH OPEN NODES\n open_nodes = valid.select{|node| reachable.include?(node)}.select{|node| !explored.include?(node)} \n \n end\n \n\treturn nil # open_nodes empty - no path found\nend",
"def depth_first(node, visited = Set.new())\n return nil if visited.include?(node.val)\n\n puts node.val\n visited.add(node.val)\n\n node.neighbors.each do |neighbor|\n depth_first(neighbor, visited);\n end\nend",
"def find_shortest_path(initial_node, final_node)\n\t\tunless @nodes.include?(initial_node) && @nodes.include?(final_node)\n\t\t raise(\"Either of the nodes not found in the Graph\") \n\t\tend\n\t\tdistance = {}\n\t previous = {}\n\t\tdistance[initial_node] = 0 # Distance from initial_node to initial_node\n\t previous[initial_node] = nil\n\t\tnodes_counted = @nodes\n\t\t\t\n\t\tnodes_counted.each do |n|\n\t\t if n != initial_node \n\t\t\t distance[n] = Float::INFINITY # Unknown distance function from initial_node to final_node\n\t\t\t previous[n] = nil \t # Previous node in optimal path from initial_node\n\t\t\tend\n\t\tend\n\n\t\tuntil nodes_counted.empty? \n\t\t\n\t\t\tu = distance.select{|k,v| nodes_counted.include?(k)}.min_by{|k,v| v}.first # Source node in first case\n\t\t\tbreak if (distance[u] == Float::INFINITY)\n\t\t\tnodes_counted.delete(u)\n\t\t\t\n\t\t\t@paths[u].keys.each do |v|\n\t\t\t\talt = distance[u] + @paths[u][v]\n\t\t\t\tif alt < distance[v] # A shorter path to v has been found\n\t\t\t\t\tdistance[v] = alt\n\t\t\t\t\tprevious[v] = u\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t \n\t\tpath = []\n\t\tcurrent = final_node\n\t\twhile current\n\t\t\tpath.unshift(current)\n\t\t\tcurrent = previous[current]\n\t\tend\n \n\t\treturn distance[final_node], path\n\n\tend",
"def longest_path_1(edges)\nend",
"def find_shortest_path(start_node, end_node)\n\n\t\tif (!start_node || !end_node)\n\t\t\traise \"start and end nodes must be specified\"\n\t\tend\n\n\t\tqueue = Hash[@edges.keys.map { |k| [k, nil] }]\n\t\tqueue[start_node] = 0\n\n\t\tdistances = queue.dup\n\t\tcrumbs = {}\n\n\t\twhile queue.size > 0\n\n\t\t\texpanded_node = get_min(queue)\n\n\t\t\t# Check if the current path to each neighbor of the expanded_node\n\t\t\t# is shorter than the path currently stored on the distances hash\n\t\t\t@edges[expanded_node].each do |node, edge|\n\n\t\t\t\tif distances[expanded_node]\n\t\t\t\t\n\t\t\t\t\tcurrent_path_distance = distances[expanded_node] + edge.weight\n\n\t\t\t\t\t# The distance to node is shorter via the current path or the distance to node hasn't yet been computed.\n\t\t\t\t\t# Either way, the distance from start_node->node is updated with the current distance (since it is shorter)\n\t\t\t\t\tif (!distances[node] || current_path_distance < distances[node])\n\t\t\t\t\t\tdistances[node], queue[node] = current_path_distance, current_path_distance\n\t\t\t\t\t\tcrumbs[node] = expanded_node\n\t\t\t\t\tend\n\n\t\t\t\tend\n\n\t\t\tend\n\n\t\t\tqueue.delete(expanded_node)\n\n\t\tend\n\n\t\t# List of edges representing the shortest path from start_node to end_node\n\t\tshortest_path = []\n\t\tcurrent_node = end_node\n\n\t\twhile (current_node && current_node != start_node && crumbs.size > 0)\n\t\t\tprevious_node = crumbs[current_node]\n\t\t\tif (previous_node)\n\t\t\t\tshortest_path << @edges[previous_node][current_node]\n\t\t\t\tcrumbs.delete(current_node)\n\t\t\tend\n\t\t\tcurrent_node = previous_node\n\t\tend\n\n\t\treturn shortest_path.reverse\n\n\tend",
"def shortest_path_to(node)\n return nil if @previous_nodes[node].nil?\n\n nodes = [node]\n while previous_node = @previous_nodes[nodes[0]] do\n nodes.unshift(previous_node)\n end\n\n nodes\n end",
"def dfs(start_node)\n s = []\n visited = Set.new\n\n s.push(start_node)\n\n while !s.empty?\n current_node = s.shift\n next if visited.include?(current_node)\n visited.add(current_node)\n current_node.neighbors.each do |n|\n s.push(n)\n end\n puts current_node.name\n p s.map(&:name)\n p visited.map(&:name)\n end\nend",
"def build_paths(start)\n step = 0\n visited = []\n unvisited = [[board_node_by_location(start),step]]\n \n while !unvisited.empty?\n node = unvisited[0][0]\n step = unvisited[0][1] + 1\n \n node.neighbors.each do |x|\n if not_visited(board_node_by_location(x),visited, unvisited)\n unvisited << [board_node_by_location(x),step]\n end\n end\n visited << unvisited.shift\n end\n return visited\nend",
"def depth_first_search_winston(goal_vertex)\n return [self] if self == goal_vertex\n @stack = [], @explored = {}\n @stack << [self]\n @explored[self.label] = true\n while @stack\n path = @stack.pop\n path.last.edges.reverse_each { |edge|\n unless @explored.has_key? edge.label\n @explored[edge.label] = true\n new_path = path.dup.push(edge)\n edge == goal_vertex ? (return new_path) : @stack << new_path\n end\n }\n end\n end",
"def fill(node)\n filled_so_far = Array.new\n nodes_hash = Hash.new\n already_seen = Hash.new\n queue = [node]\n while (not queue.empty?)\n next_node = queue.shift\n next if already_seen[next_node]\n already_seen[next_node] = true\n @paths[next_node].each do |next_next_node|\n if (next_next_node == next_node)\n # special case. we consider a node connected to itself to be strongly connected\n nodes_hash[next_node] = true\n elsif (find(next_next_node,next_node)) \n # make sure there is a reverse path\n queue << next_next_node\n nodes_hash[next_node] = true\n nodes_hash[next_next_node] = true\n end\n end\n end\n nodes = nodes_hash.keys\n @paths.each do |k,v|\n if nodes.include?(k)\n v.each do |v|\n if nodes.include?(v)\n filled_so_far << [k,v]\n end\n end\n end\n end\n return filled_so_far\n end",
"def fill(node)\n filled_so_far = Array.new\n nodes_hash = Hash.new\n already_seen = Hash.new\n queue = [node]\n while (not queue.empty?)\n next_node = queue.shift\n next if already_seen[next_node]\n already_seen[next_node] = true\n @paths[next_node].each do |next_next_node|\n if (next_next_node == next_node)\n # special case. we consider a node connected to itself to be strongly connected\n nodes_hash[next_node] = true\n elsif (find(next_next_node,next_node)) \n # make sure there is a reverse path\n queue << next_next_node\n nodes_hash[next_node] = true\n nodes_hash[next_next_node] = true\n end\n end\n end\n nodes = nodes_hash.keys\n @paths.each do |k,v|\n if nodes.include?(k)\n v.each do |v|\n if nodes.include?(v)\n filled_so_far << [k,v]\n end\n end\n end\n end\n return filled_so_far\n end",
"def shortest_path_to_all_nodes(initial)\n initial.distance = 0\n\n current = initial\n loop do\n unvisited.delete(current)\n\n calculate_neighbor_shortest_distances(current)\n\n return graph.vertices if no_reachable_nodes\n\n current = unvisited.min_by(&:distance)\n end\n end",
"def find_shortest_path(rolling_node)\n\n @backtrack = []\n @backtrack << @goal_node\n\n # iterate until we arrive at the start node\n while rolling_node[:prev] != nil do\n temp_node = @node_list.find { |hash| hash[:id] == rolling_node[:prev] }\n @backtrack << temp_node[:id]\n rolling_node = temp_node\n end\n\n # create a table with the 1d and the 2d array node values\n @shortest_path = []\n\n @backtrack.each do |p|\n @shortest_path << [p, @table_convert[p]]\n @shortest_path_coords << @table_convert[p][1]\n end\n end",
"def ids_recursive(vertex, goal_vertex, depth, max_depth)\n @stack.push(vertex) # Add vertex to frontier\n return 1 if vertex == goal_vertex # If goal_vertex is reached, return 1. ! Not necessarily shortest path !\n @stack.pop() && return if depth == max_depth\n @explored[vertex.label] = true # Mark vertex as being explored\n depth = depth + 1\n vertex.edges.each { |edge| # Expand current vertex\n unless @explored.has_key? edge.label # If already explored, then ignore the vertex\n return 1 if ids_recursive(edge, goal_vertex, depth, max_depth) == 1 # Recursively do depth_first on the vertices\n end\n }\n @stack.pop() #Backtracking so popping the vertex from the stack\n end",
"def dfs_recursive(vertex, goal_vertex)\n @stack.push(vertex) # Add vertex to frontier\n return 1 if vertex == goal_vertex # If goal_vertex is reached, return 1. ! Not necessarily shortest path !\n @explored[vertex.label] = true # Mark vertex as being explored\n vertex.edges.each { |edge| # Expand current vertex\n unless @explored.has_key? edge.label # If already explored, then ignore the vertex\n return 1 if dfs_recursive(edge, goal_vertex) == 1 # Recursively do depth_first on the vertices\n end\n }\n @stack.pop() #Backtracking so popping the vertex from the stack\n end",
"def shortest_paths(source)\n level = 0\n nextlevel = [source]\n seen = { source => level }\n pred = { source => [] }\n until nextlevel.empty?\n level += 1\n thislevel = nextlevel\n nextlevel = []\n thislevel.each do |v|\n neighbors_of(v).each do |w|\n next if (seen.keys.include? w) && (seen[w] != level)\n unless seen.keys.include? w\n pred[w] = []\n seen[w] = level\n nextlevel << w\n end\n pred[w] << v\n end\n end\n end\n [pred, seen]\n end",
"def route?(graph, node)\n graph.depth_first_search(graph.starting_vertex, node)\nend",
"def shortest_path(start_node, end_node, graph)\n adjacent_edges = graph.select{ | edge | edge[NODES].include?(start_node) }\n remaining_edges = graph - adjacent_edges\n shortest_path = Path.new\n adjacent_edges.each do | edge |\n path = Path.new [edge]\n neighbor_node = (edge[NODES] - [start_node])[0] # ['A', 'B'] - ['A'] => ['B']\n unless neighbor_node == end_node\n path_ahead = shortest_path(neighbor_node, end_node, remaining_edges)\n (path_ahead.empty?)? path.clear : path.concat(path_ahead)\n end \n shortest_path = path if path.distance < shortest_path.distance\n end\n shortest_path\n end",
"def shortest_path(from_x, from_y, to_x, to_y)\n @visited = Array.new(@matrix.size) { Array.new(@matrix.first.size) { false } }\n @farthest_node = nil\n queue = Queue.new\n queue << Node.new(from_x, from_y, 0)\n\n while !queue.empty? do\n node = queue.pop\n\n if !@farthest_node || node.dist > @farthest_node.dist\n @farthest_node =node\n end\n\n if node.x == to_x && node.y == to_y\n # We pathed to the target\n target_node = node\n break\n end\n [[-1,0],[1,0],[0,1],[0,-1]].each do |dir|\n x = node.x + dir[0]\n y = node.y + dir[1]\n if is_valid?(x, y)\n @visited[y][x] = true\n queue.push(Node.new(x, y, node.dist + 1, node))\n end\n end\n end\n\n # We didn't find a path to the target\n return nil unless target_node\n\n # Trace back the journey\n journey = []\n journey.push [node.x,node.y]\n while !node.parent.nil? do\n node = node.parent\n journey.push [node.x,node.y]\n end\n journey.reverse.drop(1)\n end",
"def lesstrips_dfs(start, finish, max_distance, distance, visited, path, paths, cycles)\n adj_vertices(visited.last, adj_lists).each do |vertex|\n print \"Visited stack: #{visited}, Next vertex: #{vertex}\\n\"\n totald = distance + dist(visited.last, vertex)\n\n if visited.last == finish && cycles != \"NO CYCLES EXIST\"\n\n # try adding cycles\n\n visited_before_cycles = visited\n # picks expanded cycles that begin with finish vertex\n ec = expanded_cycles(cycles).select{|c| c.first == finish}\n\n # keep adding cycles till we reach max distance\n ec.each do |cycle1|\n visited, paths, break_loop = try_cycles(visited, cycle1, paths, 0, max_distance)\n visited1 = visited\n\n ec.each do |cycle2|\n begin\n visited, paths, break_loop = try_cycles(visited, cycle2, paths, 0, max_distance)\n end until break_loop\n visited = visited1\n end\n\n visited = visited_before_cycles\n end\n\n elsif !visited.include?(vertex) && totald != \"NO SUCH ROUTE\" && totald < max_distance\n visited << vertex\n path = visited\n distance = totald\n\n if vertex == finish\n paths << path\n print \"\\n*** Path: #{path}, Length: #{path_length(path)}\\n\\n\"\n visited.pop\n break\n end\n\n lesstrips_dfs(start, finish, max_distance, distance, visited, path, paths, cycles)\n visited.pop\n visited.pop if visited.size.between?(2, 3)\n visited = [start] if visited == []\n end\n end\n paths.size\n end",
"def compute_shortest_path\n update_distance_of_all_edges_to(Float::INFINITY)\n @distance_to[@source_node] = 0\n\n # The prioriy queue holds a node and its distance from the source node.\n @pq.insert(@source_node, 0)\n while @pq.any?\n node = @pq.remove_min\n node.adjacent_edges.each do |adj_edge|\n relax(adj_edge)\n end\n end\n end",
"def depth_first_search\n visited = {}\n timestamp = {}\n tree_edges = {}\n back_edges = {}\n cross_edges = {}\n forward_edges = {}\n count = 0\n\n # begin workaround removing depencency to order of Hash#each\n if @index.empty? then\n preference_of_nodes = nil\n else\n preference_of_nodes = {}.merge(@index)\n i = preference_of_nodes.values.max\n @graph.each_key do |node0|\n preference_of_nodes[node0] ||= (i += 1)\n end\n end\n # end workaround removing depencency to order of Hash#each\n\n dfs_visit = Proc.new { |from|\n visited[from] = true\n timestamp[from] = [count += 1]\n ary = @graph[from].keys\n # begin workaround removing depencency to order of Hash#each\n if preference_of_nodes then\n ary = ary.sort_by { |node0| preference_of_nodes[node0] }\n end\n # end workaround removing depencency to order of Hash#each\n ary.each do |to|\n if visited[to]\n if timestamp[to].size > 1\n if timestamp[from].first < timestamp[to].first\n \t# forward edge (black)\n \tp \"#{from} -> #{to} : forward edge\" if $DEBUG\n \tforward_edges[from] = to\n else\n \t# cross edge (black)\n \tp \"#{from} -> #{to} : cross edge\" if $DEBUG\n \tcross_edges[from] = to\n end\n else\n # back edge (gray)\n p \"#{from} -> #{to} : back edge\" if $DEBUG\n back_edges[from] = to\n end\n else\n # tree edge (white)\n p \"#{from} -> #{to} : tree edge\" if $DEBUG\n tree_edges[to] = from\n dfs_visit.call(to)\n end\n end\n timestamp[from].push(count += 1)\n }\n\n ary = @graph.keys\n # begin workaround removing depencency to order of Hash#each\n if preference_of_nodes then\n ary = ary.sort_by { |node0| preference_of_nodes[node0] }\n end\n # end workaround removing depencency to order of Hash#each\n ary.each do |node|\n unless visited[node]\n dfs_visit.call(node)\n end\n end\n return timestamp, tree_edges, back_edges, cross_edges, forward_edges\n end",
"def depth_first_search_recursive(source)\n visited.add(source)\n\n source.neighbors.each do |neighbor|\n unless visited.include?(neighbor)\n depth_first_search_recursive(neighbor)\n meta[neighbor] = source\n end\n end\n end",
"def shortest_path(nodes, starting, ending)\n queue = [starting]\n previous = {}\n previous[starting] = nil\n while !queue.empty?\n p queue\n last_node = queue.pop\n if last_node == ending\n path = []\n while previous[last_node]\n path.unshift(last_node)\n last_node = previous[last_node]\n end\n path.unshift(starting)\n return path\n end\n if neighbors = nodes[last_node]\n neighbors.each do |neighbor|\n unless previous.has_key?(neighbor)\n queue.unshift(neighbor) \n previous[neighbor] = last_node\n end\n end\n end\n end\nend",
"def dfs1(graph, start_vertex)\n\tstack = [start_vertex]\n\tvisited = []\n\n\tuntil stack.empty?\n\t\tcurr_vertex = stack[-1]\n\n\t\tif !graph[curr_vertex] || graph[curr_vertex][0] \n\t\t\t$finishing_time += 1\n\t\t\t$magic_order[$finishing_time] = curr_vertex\n\t\t\tstack.pop\n\t\telse\n\t\t\tmore = []\n\t\t\tgraph[curr_vertex][0] = true\n\n\t\t\tif graph[curr_vertex][2..-1]\n\t\t\t\tgraph[curr_vertex][2..-1].each do |edge|\n\t\t\t\t\tif !graph[edge] && !visited.include?(edge)\n\t\t\t\t\t\tmore << edge\n\t\t\t\t\t\tvisited << edge\n\t\t\t\t\telsif !graph[edge]\n\t\t\t\t\t\tnext\n\t\t\t\t\telsif !graph[edge][0]\n\t\t\t\t\t\tmore << edge \n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tif more.empty?\n\t\t\t\t$finishing_time += 1\n\t\t\t\t$magic_order[$finishing_time] = curr_vertex\n\t\t\t\tstack.pop\n\t\t\telse\n\t\t\t\tstack.concat(more)\n\t\t\tend\n\t\tend\n\tend\nend",
"def search(start, goal)\n openset = Set.new\n closedset = Set.new\n current = start\n\n if @maximize_cost # serves to invert the comparison\n openset_min_max = openset.method(:max_by)\n flip = -1\n else\n openset_min_max = openset.method(:min_by)\n flip = 1\n end\n\n openset.add(current)\n while not openset.empty?\n current = openset_min_max.call{|o| o.g + o.h }\n if current == goal\n path = []\n while current.parent\n path << current\n current = current.parent\n end\n path << current\n return path.reverse\n end\n openset.delete(current)\n closedset.add(current)\n @graph[current].each do |node|\n next if closedset.include? node\n\n if openset.include? node\n new_g = current.g + current.move_cost(node)\n if (node.g - new_g) * flip > 0\n node.g = new_g\n node.parent = current\n end\n else\n node.g = current.g + current.move_cost(node)\n node.h = heuristic(node, start, goal)\n node.parent = current\n openset.add(node)\n end\n end\n end\n return nil\n end",
"def build_path(start, end_pos)\n node = Node.new(start[0], start[1])\n target = Node.new(end_pos[0], end_pos[1])\n visited_nodes = []\n next_moves = [node]\n until next_moves.empty? do\n node = next_moves.shift\n puts \"Current node: #{node.x}, #{node.y}\"\n if node.x == target.x && node.y == target.y \n return node\n end\n visited_nodes.push(node)\n node.moves = get_moves(node)\n node.moves.reject do |square|\n visited_nodes.include?(square)\n end\n node.moves.each do |move| \n next_moves.push(move)\n end\n end\n return node\nend",
"def find_path(start_node, end_node, grid)\n start_node = sanitize(start_node)\n end_node = sanitize(end_node)\n if grid.nil?\n [start_node]\n else\n _max_x = grid.max_x\n _max_y = grid.max_y\n\n @current_grid = grid.inner_grid.clone\n\n raise 'max_x & max_y required' unless _max_x && _max_y\n\n _start_node = start_node.clone\n _end_node = end_node.clone\n\n heuristic = @heuristic.new(_end_node, @weight)\n\n _start_node[:f] = 0 # sum of g and h\n _start_node[:g] = 0 # steps to start node\n _start_node[:h] = nil # steps to end node\n _start_node[:opened] = true\n\n # use heap or tree for better perf\n open = []\n open.push _start_node\n\n while !open.empty? do\n _current_node = open.pop\n\n _current_node[:closed] = true\n @current_grid[node_to_a(_current_node)] = _current_node\n\n if node_to_a(_current_node) == node_to_a(_end_node)\n return final_path(_current_node)\n end\n\n new_g = _current_node[:g] + 1\n\n x = _current_node[:x]\n y = _current_node[:y]\n\n neighbors = []\n\n neighbors << [x-1, y] if x > 0\n neighbors << [x, y-1] if y > 0\n neighbors << [x+1, y] if x < _max_x-1\n neighbors << [x, y+1] if y < _max_y-1\n\n _neighbors = neighbors.map do |position|\n node = @current_grid[position]\n if node.nil? || node[:walkable]\n node ||= {}\n @current_grid[position] = node.merge({\n x: position.first,\n y: position[1],\n closed: false,\n opened: false\n })\n end\n end.compact\n\n _neighbors.each do |neighbor|\n if (!neighbor[:opened] || new_g < neighbor[:g])\n neighbor[:g] = new_g\n neighbor[:h] ||= heuristic.h(neighbor)\n neighbor[:f] = neighbor[:g] + neighbor[:h]\n neighbor[:parent] = node_to_a(_current_node)\n\n if (!neighbor[:opened])\n open.push neighbor\n neighbor[:opened] = true\n else\n # ???\n puts \"got here some how!!!\"\n end\n end\n end\n\n open.sort_by! {|i| [-i[:f], -i[:h]]}\n # grid_p\n end\n end\n end",
"def dfs(list)\n s = []\n visited = Set.new\n\n s.push(start_node)\n\n while !s.empty?\n current_node = s.shift\n next if visited.include?(current_node)\n visited.add(current_node)\n current_node.neighbors.each do |n|\n s.push(n)\n end\n puts current_node.name\n p s.map(&:name)\n p visited.map(&:name)\n end\nend",
"def find_path(start, goal)\n raise \"loc1 must not be the same as loc2\" if start == goal\n\n # Using A* path-finding algorithm\n # See pseudocode here: https://en.wikipedia.org/wiki/A*_search_algorithm\n # https://www.redblobgames.com/pathfinding/a-star/introduction.html\n # NOTE that this is overkill for this problem...\n open_set = Set.new([start])\n came_from = {}\n\n # Default value of \"Infinity\", but we can just use nil\n g_score = {}\n g_score[start] = 0\n\n # f_score = g_score[node] + h_score[node]\n # This uses both current best path (g score) aka similar to Djikstra's algorithm,\n # plus the heuristic score.\n f_score = {}\n # g_score[start] is 0, so not included here\n f_score[start] = h_score(start, goal)\n\n # Note that we add d_score as the weight of the edge, but in our\n # case, we consider all edges equally, so hardcode 1\n d_score = 1\n\n until open_set.empty? do\n # Node in open set with lowest f score (would ideally use PriorityQueue)\n current = open_set.min_by { |node| f_score[node] }\n\n if current == goal\n return reconstruct_path(came_from, current)\n end\n\n open_set.delete(current)\n\n valid_neighbours(current).each do |neighbour_loc|\n tentative_g_score = g_score[current] + d_score\n if g_score[neighbour_loc].nil? || tentative_g_score < g_score[neighbour_loc]\n # This path to neighbor is better than any previous one. Record it!\n came_from[neighbour_loc] = current\n g_score[neighbour_loc] = tentative_g_score\n f_score[neighbour_loc] = g_score[neighbour_loc] + h_score(neighbour_loc, goal)\n if !open_set.include?(neighbour_loc)\n open_set << neighbour_loc\n end\n end\n end\n end\n\n raise \"error, no path found!\"\n end",
"def shortest_path\n initial_position_obj = { position: start_position, source: {} }\n\n knights_path = [initial_position_obj]\n\n while knights_path.present?\n current_position = knights_path.shift\n\n position = current_position[:position]\n\n if position == end_position\n return path_to_destination(current_position, initial_position_obj)\n end\n\n add_possible_destination(position, current_position, knights_path)\n end\n end",
"def findShortestPathsFromNode(root)\n # Clear graph for search\n @nodes.each do |node|\n node.setVisited false\n end\n\n # But (of course) we start with a node, so let's say it's been visited\n\n root.setVisited true\n\n # Set up the root of the tree\n treeRoot = TElement.new(root, nil)\n # Set up parents vector (just treeRoot) and leaves (empty)\n parents = []\n parents.push treeRoot\n leaves = []\n # indicates whether to keep going\n continuing = true\n # todo: this is going to look rather different in Ruby! double-check w/ original java\n while (continuing)\n children = []\n continuing = false\n parents.each do |parent| \n parentNode = parent.node\n puts \"Doing parent: #{parentNode} \" \n parentNode.getEdges.each do |edge|\n puts \"Doing edge(s): #{edge} \" \n childNode = edge.getOtherNode parentNode\n if childNode.notVisited\n \t childNode.setVisited true \n puts \"visited: #{childNode}\"\n child = TElement.new (childNode, parent, edge)\n leaves.push child\n children.push child\n continuing = true\n end\n\t parents = children\n\tend\n end\n end\n #puts \"returning: #{leaves}\"\n return leaves \n end",
"def kruskal\n # initialize\n rel = self.to_relations.sort{|a, b| a <=> b}\n index = []\n for i in 0 .. (rel.size - 1) do\n for j in (i + 1) .. (rel.size - 1) do\n if rel[i] == rel[j]\n index << j\n end\n end\n end\n index.sort{|x, y| y<=>x}.each do |idx|\n rel[idx, 1] = []\n end\n mst = []\n seen = Hash.new()\n @graph.each_key do |x|\n seen[x] = nil\n end\n i = 1\n # initialize end\n\n rel.each do |r|\n if seen[r.node[0]] == nil\n seen[r.node[0]] = 0\n end\n if seen[r.node[1]] == nil\n seen[r.node[1]] = 0\n end\n if seen[r.node[0]] == seen[r.node[1]] && seen[r.node[0]] == 0\n mst << r\n seen[r.node[0]] = i\n seen[r.node[1]] = i\n elsif seen[r.node[0]] != seen[r.node[1]]\n mst << r\n v1 = seen[r.node[0]].dup\n v2 = seen[r.node[1]].dup\n seen.each do |k, v|\n if v == v1 || v == v2\n seen[k] = i\n end\n end\n end\n i += 1\n end\n return Pathway.new(mst)\n end",
"def shortest_path_lengths(source)\n seen = {}\n level = 0\n nextlevel = { source => 1 }\n until nextlevel.empty?\n thislevel = nextlevel\n nextlevel = {}\n thislevel.each do |v, _|\n if seen[v].nil?\n seen[v] = level\n nextlevel.update(neighbors_of(v).map { |w| [w, nil] }.to_h)\n end\n end\n level += 1\n end\n seen\n end",
"def dfs\n visited = {}\n vertexes.keys.each {|v| visited[v] = false}\n unvisited = find_first_unvisited visited\n search_results = []\n until unvisited.is_nothing?\n #find a depth first search tree and hash containing the order that each node is visited\n dpst = explore(unvisited.from_just)\n if dpst.is_nothing?\n return Nothing.new\n else\n dpst = dpst.from_just\n end\n if search_results.empty?\n search_results.push dpst\n else\n search_results.each_with_index do |result, i|\n tree = dpst[:tree]\n found = false\n result.each do |v|\n if tree[v] and result.length < tree.keys.length\n results[i] = dpst\n found = true\n break\n end\n end\n break if found\n end\n end\n # Mark each point in the path as visited\n dpst[:visit_order].each do |k|\n visited[k] = true\n end\n unvisited = find_first_unvisited visited\n end\n search_results\n end",
"def seek_from_node(starting_node)\n puts \"seek started from node #{starting_node.inspect}...\"\n \n # -- PART I -- (starting from one node for now...) \n visited_nodes = grow_basic_path([ starting_node ])\n \n puts \"got basic path of length #{visited_nodes.length}, moving on to IIa)...\"\n \n # -- PART II a) --\n if visited_nodes.length < nodes.length\n target_nodes = extract_target_nodes_from_path(visited_nodes)\n \n while target_nodes.length > 0\n puts \"TNL: #{target_nodes.length}\"\n visited_nodes = restructure_path(visited_nodes, target_nodes)\n target_nodes = extract_target_nodes_from_path(visited_nodes)\n end\n end\n \n puts \"...done, moving on to IIb)...\"\n \n # -- PART II b) --\n if visited_nodes.length < nodes.length\n visited_nodes = trim_and_extend_path(visited_nodes)\n end\n \n puts \"...done, moving on to IIc)...\"\n \n # -- PART II c) --\n if visited_nodes.length < nodes.length\n visited_nodes = trim_and_extend_path(visited_nodes.reverse)\n end\n \n # -- PART III --\n results = {}\n \n if visited_nodes.length < nodes.length \n results[:path] = visited_nodes\n else\n results[:tour] = visited_nodes\n \n cycle_starts = connected_to(visited_nodes.first).map do |node|\n visited_nodes[visited_nodes.index(node) - 1]\n end\n cycle_ends = connected_to(visited_nodes.last)\n \n (cycle_starts & cycle_ends).each do |node|\n index = visited_nodes.index(node)\n \n circuit = visited_nodes[0..index] + [ visited_nodes.last ]\n circuit += visited_nodes[(index + 1 - visited_nodes.length)..-2].reverse\n \n results[:cycles] ||= []\n results[:cycles] << circuit\n end\n end\n \n results\n end",
"def path_to(node)\n return unless @visited.include?(node)\n path = []\n while(node != @node) do\n path.unshift(node) \n node = @edge_to[node]\n end\n path.unshift(@node)\n end",
"def find_path(start, target)\n node = build_path(start, target)\n path = [node]\n until node.next_node.nil? do\n node = node.next_node\n path.push(node)\n end\n path = path.reverse\n puts \"You made it in #{path.length} moves. Here is your path: \"\n path.each do |node|\n puts \"[#{node.x}], [#{node.y}]\"\n end\nend",
"def solve\n graph = Graph.create(words, WordNode)\n graph.connect_nodes(:one_char_diff)\n\n end_node = graph.nodes_hash[end_word]\n start_node = graph.nodes_hash[start_word]\n start_node.cost = 0\n\n heap = Containers::Heap.new { |a, b| (a.cost <=> b.cost) == -1 }\n graph.nodes_hash.each do |k, v|\n heap.push v\n end\n\n puts heap.size\n # puts \"is empty?#{heap.empty?}\"\n until heap.empty? do\n current_node = heap.pop\n puts current_node.value, current_node.cost\n # puts current_node == end_node\n # puts current_node.value, end_node.value\n return graph.path(end_node) if current_node == end_node\n\n current_node.connected_nodes.each do |node|\n\n # puts node.visited\n unless node.visited\n cost = current_node.cost + 1\n if cost < node.cost\n node.cost = cost\n node.parent = current_node\n # puts \"changed parent\"\n # puts node.parent\n end\n end\n end\n\n current_node.visited = true\n end\n end",
"def search_dfs(node, target, visited)\n return if visited[node] == true\n return node if node == target\n visited[node] = true\n res = nil\n @graph[node].each do |nabe|\n if !visited[nabe]\n if (res = search_dfs(nabe, target, visited)) == target\n break\n end\n end\n end\n res\n end",
"def depth_first_search\n visited = {}\n timestamp = {}\n tree_edges = {}\n back_edges = {}\n cross_edges = {}\n forward_edges = {}\n count = 0\n\n dfs_visit = Proc.new { |from|\n\tvisited[from] = true\n\ttimestamp[from] = [count += 1]\n\t@graph[from].each_key do |to|\n\t if visited[to]\n\t if timestamp[to].size > 1\n\t if timestamp[from].first < timestamp[to].first\n\t\t# forward edge (black)\n\t\tp \"#{from} -> #{to} : forward edge\" if $DEBUG\n\t\tforward_edges[from] = to\n\t else\n\t\t# cross edge (black)\n\t\tp \"#{from} -> #{to} : cross edge\" if $DEBUG\n\t\tcross_edges[from] = to\n\t end\n\t else\n\t # back edge (gray)\n\t p \"#{from} -> #{to} : back edge\" if $DEBUG\n\t back_edges[from] = to\n\t end\n\t else\n\t # tree edge (white)\n\t p \"#{from} -> #{to} : tree edge\" if $DEBUG\n\t tree_edges[to] = from\n\t dfs_visit.call(to)\n\t end\n\tend\n\ttimestamp[from].push(count += 1)\n }\n\n @graph.each_key do |node|\n\tunless visited[node]\n\t dfs_visit.call(node)\n\tend\n end\n return timestamp, tree_edges, back_edges, cross_edges, forward_edges\n end",
"def guide(from, to, unit_type=nil, max_depth=400)\n return nil if @map.blocked?(from, unit_type) || @map.blocked?(to, unit_type)\n from_element = PathElement.new(from)\n from_element.dist_from = @map.distance(from,to)\n open = PriorityQueue.new { |x, y| (x <=> y) == -1 }\n open.push from_element, from_element.rating\n closed = SplayTreeMap.new\n step = 0\n \n until open.empty? || step > max_depth\n step += 1\n \n current_element = open.pop\n @nodes_considered += 1\n \n loc = current_element.location\n if @map.cost(loc,to) == 0\n path = []\n until current_element.parent.nil?\n path.unshift current_element\n current_element = current_element.parent\n end\n\n return path\n else\n closed.push loc, current_element\n @map.neighbors(loc).each do |next_door|\n next if closed.has_key? next_door\n\n el = PathElement.new(next_door,current_element)\n\n if @map.blocked? next_door, unit_type\n closed.push el.location, el\n else\n current_rating = current_element.cost_to + @map.cost(loc, next_door)\n\n # add to open\n el.cost_to = current_rating\n el.dist_from = @map.distance(next_door,to)\n \n open.push el, el.rating\n end\n end\n end\n end\n nil\n end",
"def depth_first_search(find,tree)\n current = tree[0]\n answer = \"\"\n stack = [tree[0]]\n visited = [tree[0]]\n \n condition = false\n until condition == true\n connections = [current.find_right_child[0],current.find_left_child[0]].compact\n puts current.value\n puts connections.count\n puts \"---\"\n \n if current.value == find\n answer = current\n condition = true\n elsif visited.count == tree.count\n answer = nil\n condition = true\n else\n if connections.count < 1\n stack.pop\n current = stack[-1]\n elsif connections.count == 1\n if visited.include?(connections[0])\n stack.pop\n current = stack[-1]\n else\n current = connections[0]\n stack.push(current)\n visited.push(current)\n end\n else\n if visited.include?(connections[0]) && visited.include?(connections[1])\n stack.pop\n current = stack[-1]\n elsif !visited.include?(connections[0])\n current = connections[0]\n stack.push(current)\n visited.push(current)\n else\n current = connections[1]\n stack.push(current)\n visited.push(current)\n end\n end\n end\n end\n puts answer ? answer : \"Value not found!\"\n puts answer.value if answer != nil\nend",
"def find_path\n current_node = @cells_visited.last\n while current_node.parent != nil do\n @solved_path << current_node.cell\n current_node = current_node.parent\n end\n @solved_path << current_node.cell\n end",
"def bradth_first_search_colors(start_vertex, stop_vertex)\n queue = Array.new()\n queue << search_vertex(start_vertex)\n until queue.empty?\n temp_vertex = queue.shift()\n break if temp_vertex.value == stop_vertex #found stop condition\n vertex_edges = temp_vertex.edges.head\n until vertex_edges == nil\n current_vertex = search_vertex(vertex_edges.value)\n if current_vertex.color == 'white'\n current_vertex.color = 'gray' #indicates that shorter path is available if found again\n current_vertex.distance = temp_vertex.distance + 1\n current_vertex.parent = temp_vertex.value\n queue << current_vertex\n end\n vertex_edges = vertex_edges.link\n end\n temp_vertex.color = 'black' #completly explored tree\n end\n graph_traversal(start_vertex, stop_vertex)\n end",
"def dfs(initial)\n nodes, seen = Set.new, Set.new\n stack = Array(initial).reverse\n\n while node = stack.pop\n if seen.include?(node)\n nodes.add(node)\n else\n seen.add(node)\n stack.push(node)\n stack.concat(Array(yield node).reverse)\n end\n end\n\n nodes\n end",
"def depth_first_full(graph)\n visited = Set.new()\n graph.keys.each do |node|\n _depth_first(node, graph, visited)\n end\nend",
"def shortest_path_between_nodes(initial, destination)\n initial.distance = 0\n\n current = initial\n loop do\n # at the destination node, stop calculating\n break if current == destination\n\n unvisited.delete(current)\n\n calculate_neighbor_shortest_distances(current)\n\n return nil if no_reachable_nodes\n\n current = unvisited.min_by(&:distance)\n end\n\n destination.path\n end",
"def guide(from, to, unit_type=nil, max_depth=400)\n return nil if @map.blocked?(from, unit_type) || @map.blocked?(to, unit_type)\n from_element = PathElement.new(from)\n from_element.dist_from = @map.distance(from,to)\n open = PrioritySet.new\n open.push from_element, from_element.rating\n closed = SplayTreeMap.new\n step = 0\n\n until open.empty? || step > max_depth\n step += 1\n\n current_element = open.pop\n @nodes_considered += 1\n\n loc = current_element.location\n if @map.cost(loc,to) == 0\n path = []\n until current_element.parent.nil?\n path.unshift current_element\n current_element = current_element.parent\n end\n\n return path\n else\n closed.push loc, current_element\n @map.neighbors(loc).each do |next_door|\n if closed.has_key? next_door\n next\n end\n \n el = PathElement.new(next_door,current_element)\n\n if @map.blocked? next_door, unit_type\n closed.push el.location, el\n else\n current_rating = current_element.cost_to + @map.cost(loc, next_door)\n\n # add to open\n el.cost_to = current_rating\n el.dist_from = @map.distance(next_door,to)\n el.reset_rating\n\n open.push el, el.rating\n end\n end\n end\n end\n nil\n end",
"def non_deterministic_recursive(vertex, goal_vertex)\n @stack.push(vertex) # Add vertex to frontier\n return 1 if vertex == goal_vertex # If goal_vertex is reached, return 1. ! Not necessarily shortest path !\n @explored[vertex.label] = true # Mark vertex as being explored\n vertex.edges.shuffle!.each { |edge| # Expand current vertex\n unless @explored.has_key? edge.label # If already explored, then ignore the vertex\n return 1 if non_deterministic_recursive(edge, goal_vertex) == 1 # Recursively do depth_first on the vertices\n end\n }\n @stack.pop() #Backtracking so popping the vertex from the stack\n end",
"def bfs_shortest_path(node1, node2)\n distance, route = breadth_first_search(node1)\n step = distance[node2]\n node = node2\n path = [ node2 ]\n while node != node1 and route[node]\n node = route[node]\n path.unshift(node)\n end\n return step, path\n end",
"def dijkstra\n # Intialise the algorithom if first run\n init_dijkstra if empty_path?\n\n # Stop the execution if all the nides have been reached\n return path if completed_path?\n\n # Make sure that all the weights are updated\n current_node[:node].adjacent_nodes.values.each do |node|\n @pool << node.merge(\n from: current_node[:node],\n weight: node[:weight] + current_node[:weight]\n )\n end\n\n # Sort the pool of nodes/edges by weight so to be able to grab the smallest\n # weight.\n pool.sort_by! { |edge| edge[:weight] }\n\n # Pick the next untouched node by shifting the nodes in the pool starting\n # from the smallest to the greatest.\n next_node = nil\n loop do\n next_node = pool.shift\n break unless values_in_path.include?(next_node[:node].value)\n end\n\n # Push the next step (from -> to) in the path\n @path << \"#{next_node[:from].value} ==> #{next_node[:node].value}\"\n\n # Track the node as seen\n @values_in_path += [next_node[:node].value, current_node[:node].value]\n\n # Update the current node\n @current_node = next_node\n\n # Keep the execution going\n dijkstra\n end",
"def findShortest(graph_nodes, graph_from, graph_to, ids, val)\n return -1 if ids.count(val)<=1 # no two nodes with color val\n dmin = graph_nodes\n num_edges = graph_from.length\n neighbors = {}\n 0.upto(num_edges-1) do |i|\n if neighbors[graph_from[i]]\n neighbors[graph_from[i]] << graph_to[i]\n else\n neighbors[graph_from[i]] = [graph_to[i]]\n end\n if neighbors[graph_to[i]]\n neighbors[graph_to[i]] << graph_from[i]\n else\n neighbors[graph_to[i]] = [graph_from[i]]\n end\n end\n p neighbors\n ids.each_with_index do |v,i|\n if v == val\n # zero-base index to one-base index \n source_node = i+1\n # look for others using bfs (stop looking if distance > dmin)\n queue = []\n visited = []\n backtrace = {}\n queue << source_node\n while !(queue.empty?)\n current_node = queue.shift\n visited << current_node\n if (current_node!=source_node) && (ids[current_node-1]==val)\n puts \"we are here!\"\n # how did I get here? backtrace\n hops = 0\n trace_node = current_node\n while (trace_node!=source_node)\n trace_node = backtrace[trace_node]\n hops +=1\n end\n if hops < dmin\n dmin = hops\n end\n break\n end\n neighbors[current_node].each do |xnode|\n if !(visited.include?(xnode))\n queue << xnode\n backtrace[xnode] = current_node\n end\n end\n end\n p visited\n end\n end\n if dmin == graph_nodes\n return -1\n else\n return dmin\n end\nend",
"def get_path(s, e, maze)\n if maze[s[0]][s[1]] == 1 || # found a wall or visited area\n s[0] < 0 || s[1] < 0 || # top or left edge\n s[0] >= maze.length || s[1] >= maze[0].length # bottom or right edge\n\n path = nil\n\n elsif s[0] == e[0] && s[1] == e[1] # exit spot\n\n path = [s]\n\n else\n\n maze[s[0]][s[1]] = 1 # visit current node\n path =\n get_path([s[0] - 1, s[1]], e, maze) ||\n get_path([s[0], s[1] + 1], e, maze) ||\n get_path([s[0], s[1] - 1], e, maze) ||\n get_path([s[0] + 1, s[1]], e, maze)\n\n path << s unless path.nil?\n\n end\n \n return path\nend",
"def kruskal\n # initialize\n rel = self.to_relations.sort{|a, b| a <=> b}\n index = []\n for i in 0 .. (rel.size - 1) do\n for j in (i + 1) .. (rel.size - 1) do\n if rel[i] == rel[j]\n index << j\n end\n end\n end\n index.sort{|x, y| y<=>x}.each do |i|\n rel[i, 1] = []\n end\n mst = []\n seen = Hash.new()\n @graph.each_key do |x|\n seen[x] = nil\n end\n i = 1\n # initialize end\n\n rel.each do |r|\n if seen[r.node[0]] == nil\n seen[r.node[0]] = 0\n end\n if seen[r.node[1]] == nil\n seen[r.node[1]] = 0\n end\n if seen[r.node[0]] == seen[r.node[1]] && seen[r.node[0]] == 0\n mst << r\n seen[r.node[0]] = i\n seen[r.node[1]] = i\n elsif seen[r.node[0]] != seen[r.node[1]]\n mst << r\n v1 = seen[r.node[0]].dup\n v2 = seen[r.node[1]].dup\n seen.each do |k, v|\n if v == v1 || v == v2\n seen[k] = i\n end\n end\n end\n i += 1\n end\n return Pathway.new(mst)\n end",
"def shortest_path(start, finish)\n queue << [start, 0]\n loop do\n break if queue.empty?\n vertex, d = queue.pop\n graph[*vertex] = d\n break if vertex == finish\n enqueue_neighbours(*vertex, d + 1)\n end\n queue.clear\n !blank?(finish) ? build_path(start, finish) : []\n end",
"def dfs(node, visited, component = [])\n visited << node\n component << node.object\n\n node.adjacents.each do |adjacent_node|\n dfs(adjacent_node, visited, component) unless visited.include?(adjacent_node)\n end\n end",
"def dijkstras(start=@vertices.keys.sort[0],goal=nil)\n\t\t# Set of visited nodes\n\t\tvisited = []\n\n\t\t# Step 1 \n\t\t# - Start node weighs 0\n\t\t# - Set all other to infinity its done in constructor already\n\t\t@vertices[start] = 0\n\n\t\t# Step 2 \n\t\t# - Set initial node as current\n\t\t# - Mark all nodes unvisited except start node\n\t\tunvisited = @vertices.keys - [start]\n\t\tcurrent = start\n\n\t\twhile(!unvisited.empty?)\n\t\t\t# Step 3\n\t\t\t# - Consider all neighbors of current node\n\t\t\t# - Calculate distance cost: current path weight + edge weight\n\t\t\t# - Update distance if this distance is less than recorded distance\n\t\t\t\n\t\t\t@map[current].each do |neighbor|\n\t\t\t\tnext if visited.include?(neighbor.to)\n\t\t\t\tweight = @vertices[current] + neighbor.weight.to_i\n\t\t\t\tif weight < @vertices[neighbor.to]\n\t\t\t\t\t@vertices[neighbor.to] = weight\n\t\t\t\t\t@prev[neighbor.to] = current\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# Step 4\n\t\t\t# - Add current node to visited\n\t\t\t# - Remove current node from unvisited\n\t\t\tvisited << current\n\t\t\tunvisited -= [current]\n\n\t\t\t# Find the smallest weighted node\n\t\t\tcurrent = unvisited.collect { |node| [@vertices[node],node] }\n\t\t\tcurrent.empty? ? current = @infinity : current = current.min[1]\n\n\t\t\t# Step 5\n\t\t\t# - If goal is in visited, stop\n\t\t\t# - If full traversal without a goal? \n\t\t\t# \tCheck for infinity weighted node\n\t\t\tif visited.include? goal\t\t\n\t\t\t\tpath(goal)\n\t\t\t\treturn\n\t\t\tend\n\t\t\tbreak if current == @infinity\n\t\tend\n\t\t\n\t\t# Print all shortest paths\n\t\tputs \"Initial Node: #{start}\"\n\t\tvisited.each do |x|\n\t\t\tpath(x)\n\t\t\tputs\n\t\tend\n\tend",
"def shortest_path_to(dest_node)\n return unless has_path_to?(dest_node)\n path = []\n while (dest_node != @node) do\n path.unshift(dest_node)\n dest_node = @edge_to[dest_node]\n end\n path.unshift(@node)\n end",
"def dfs(start_vertex, &block)\n start_vertex.gray!\n @time += 1\n start_vertex.discovery = @time\n start_vertex.get_connections.each do |next_vertex|\n if next_vertex.white?\n next_vertex.predecessor = start_vertex\n dfs(next_vertex, &block)\n end\n end\n start_vertex.black!\n @time += 1\n start_vertex.finish = @time\n yield start_vertex if block_given?\n end",
"def shortest_paths(s)\n @source = s\n dijkstra s\n puts \"Source: #{@source}\"\n @nodes.each do |dest|\n puts \"\\nTarget: #{dest}\"\n print_path dest\n if @d[dest] != @INFINITY\n puts \"\\nDistance: #{@d[dest]}\"\n else\n puts \"\\nNO PATH\"\n end\n end\n end",
"def find(start,last)\n next_nodes = Array.new\n next_nodes << start\n visited = {}\n while (not next_nodes.empty?)\n next_node = next_nodes.shift\n next if visited[next_node]\n visited[next_node] = true\n return true if next_node == last\n @paths[next_node].map do |x| next_nodes << x end\n end\n return false\n end",
"def breadth_first_search_winston(goal_vertex)\n return [self] if self == goal_vertex\n @queue = []\n @explored = {}\n @queue << [self]\n @explored[self.label] = true\n while @queue\n path = @queue.pop\n path.last.edges.reverse_each{ |edge|\n unless @explored.has_key? edge.label\n @explored[edge.label] = true\n new_path = path.dup.push(edge)\n edge == goal_vertex ? (return new_path) : @queue.unshift(new_path)\n end\n }\n end\n end",
"def build_graph(node = @root)\n node.make_knights(@target)\n if node.connected_knights.empty?\n return\n else\n node.connected_knights.each do |knight|\n build_graph(knight)\n end\n end\n end",
"def dfs(node)\n preorder, visited = [], []\n dfs_visit(node, visited, preorder)\n preorder\nend",
"def dijkstras(start=@vertices.keys.sort[0],goal=nil)\n\t\t# Set of visited nodes\n\t\tvisited = []\n\n\t\t# Step 1 \n\t\t# - Start node weighs 0\n\t\t# - Set all other to infinity its done in constructor already\n\t\t@vertices[start] = 0\n\n\t\t# Step 2 \n\t\t# - Set initial node as current\n\t\t# - Mark all nodes unvisited except start node\n\t\tunvisited = @vertices.keys - [start]\n\t\tcurrent = start\n\n\t\twhile(!unvisited.empty?)\n\t\t\t# Step 3\n\t\t\t# - Consider all neighbors of current node\n\t\t\t# - Calculate distance cost: current path weight + edge weight\n\t\t\t# - Update distance if this distance is less than recorded distance\n\t\t\t\n\t\t\t@map[current].each do |neighbor|\n\t\t\t\tnext if visited.include?(neighbor.to)\n\t\t\t\tweight = @vertices[current] + neighbor.weight.to_i\n\t\t\t\tif weight < @vertices[neighbor.to]\n\t\t\t\t\t@vertices[neighbor.to] = weight\n\t\t\t\t\t@prev[neighbor.to] = current\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# Step 4\n\t\t\t# - Add current node to visited\n\t\t\t# - Remove current node from unvisited\n\t\t\tvisited << current\n\t\t\tunvisited -= [current]\n\n\t\t\t# Find the smallest weighted node, could use a PQueue instead\n\t\t\tsmallest = @infinity\n\t\t\tcurrent = @infinity\n\t\t\tunvisited.each do |node|\n\t\t\t\tif @vertices[node] < smallest\n\t\t\t\t\tsmallest = @vertices[node]\n\t\t\t\t\t# Step 6\n\t\t\t\t\t# - Set smallest weighted node as current node, continue\n\t\t\t\t\tcurrent = node\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# Step 5\n\t\t\t# - If goal is in visited, stop\n\t\t\t# - If full traversal without a goal? \n\t\t\t# \tCheck for infinity weighted node\n\t\t\tif visited.include? goal\t\t\n\t\t\t\tpath(goal)\n\t\t\t\treturn\n\t\t\tend\n\t\t\tbreak if current == @infinity\n\t\tend\n\t\t\n\t\t# Print all shortest paths\n\t\tputs \"Initial Node: #{start}\"\n\t\tvisited.each do |x|\n\t\t\tpath(x)\n\t\t\tputs\n\t\tend\n\tend",
"def build_path(start, finish)\n path = [finish]\n loop do\n vertex = path.last\n d = graph[*vertex]\n neighbours = get_neighbours(*vertex)\n next_vertex = neighbours.select{|n_vert| graph[*n_vert] == d - 1}.first\n path << next_vertex if next_vertex\n break if vertex == start\n end\n path\n end",
"def make_paths\n visited = {}\n path = []\n return path if @nmap.empty? || @nnmap.empty?\n\n # 0 is false\n @nmap.each do |k, _|\n visited[k] = 0\n end\n\n # for each node that is not an end node to an end node\n @nnmap.each do |s, _|\n # if s is an end node\n @paths << [s] if @ends.include? s\n\n # for each end node as desintation\n @ends.each do |d|\n get_allpaths(s, d, visited, path)\n end\n end\n @paths.sort_by(&:length).reverse\n end",
"def find_paths(current_node, target_node, current_path=[])\n \tcurrent_path.push(current_node)\n \tif current_node == target_node\n \t\t@found_paths.push(current_path.dup)\n \telse\n \t\t@adjacency_list[current_node].each do |child|\n \t\t\tfind_paths(child, target_node, current_path)\n \t\tend\n \tend\n \tcurrent_path.pop\n end",
"def solve_dijkstra\n\n unvisited_set = @unvisited_set.dup\n\n # create a queue for nodes to check\n @queue = []\n current_node = @start_node\n @queue << current_node\n\n # Stop If there are no unvisited nodes or the queue is empty\n while unvisited_set.size > 0 && @queue.size > 0 do\n\n # set the current node as visited and remove it from the unvisited set\n current_node = @queue.shift\n\n # remove visited node from the list of unvisited nodes\n unvisited_set.delete(current_node)\n\n # find the current node's neighbours and add them to the queue\n rolling_node = @node_list.find { |hash| hash[:id] == current_node }\n rolling_node[:neighs].each do |p|\n # only add them if they are unvisited and they are not in the queue\n if unvisited_set.index(p) && !@queue.include?(p)\n @queue << p\n # set the previous node as the current for its neighbours\n change_node = @node_list.find { |hash| hash[:id] == p }\n change_node[:prev] = current_node\n # increase the distance of each node visited\n change_node[:dist] = rolling_node[:dist] + @step\n end\n end\n\n if current_node == @goal_node\n find_shortest_path(rolling_node)\n break\n end\n end\n return @shortest_path_coords\n end",
"def paths_to(node)\n find_paths do\n find { |n| n == node }\n end\n end",
"def depth_first_search(adj_matrix, source_index, end_index)\n node_stack = [source_index]\n # The code uses a forever loop and then breaks when we encounter certain conditions.\n loop do\n curr_node = node_stack.pop\n return false if curr_node == nil\n return true if curr_node == end_index\n\n # Out of the adjacency matrix, pick the “children” of curr_node by checking the 1’s in the adjacency matrix\n children = (0..adj_matrix.length-1).to_a.select do |i| \n adj_matrix[curr_node][i] == 1\n end\n \n # Take those nodes and push them onto the end of the stack\n node_stack = node_stack + children\n end\n end",
"def return_shortest_path(from)\r\n\r\n queue = Queue.new\r\n queue << from\r\n from.distance = 0\r\n while(!queue.empty?)\r\n v= queue.pop\r\n count=0\r\n adjDir = find_adjacent_rooms(v.roomObject)\r\n while(count < adjDir.length)\r\n w = @vertices[v.roomObject.return_title(adjDir[count])]\r\n\r\n if(w.distance==Float::INFINITY)\r\n w.distance = v.distance + 1\r\n w.path = v.path + \" \" + adjDir[count].to_s()\r\n queue << w\r\n end\r\n count = count + 1\r\n end\r\n count=0\r\n end\r\n\r\n end",
"def visit(node, target, visited = [], path = [node.data])\n # Terminal states:\n if node.data == target\n # 1. If node.data is equal to target return the path\n return path\n else\n # If the node hasn't been visited then\n if !visited.include? node\n # Push the node in visited (so it wont be visited again)\n visited.push(node)\n # Traverse through each node in the node's connections\n node.connections.each do |connection|\n # Push to path the corresponding data\n path.push(connection.data)\n # Return a recursive call to the method with this particular connection as 1st argument\n # target as 2nd and then current versions of visited and path as 3rd an fourth args\n return visit(connection, target, visited, path)\n end\n end\n end\nend",
"def path_finder \n until queue.empty? \n current_node = queue.shift()\n generate_neighbours(current_node)\n current_node.neighbour_nodes.each do |neighbour|\n track_visited(current_node, neighbour)\n correct_node?(neighbour) ? (return neighbour.visited) : (queue << neighbour)\n end\n end\n end",
"def shortest_length(start, finish)\n infinity = (2**(0.size * 8 - 2) - 1) # max Fixnum integer value\n distances = {} # smallest distance from starting vertex to this one\n previous = {}\n cyclic = start == finish # true if starting vertex = ending vertex\n loops = 0 # useful for cyclic path\n vertex_pq = PriorityQueue.new\n\n adj_lists.each do |vertex|\n vname = vertex.name\n if vname == start\n distances[vname] = 0\n vertex_pq.enq(vname, 0)\n else\n distances[vname] = infinity\n vertex_pq.enq(vname, infinity)\n end\n previous[vname] = nil\n end\n\n while vertex_pq\n loops += 1\n # if cyclic, pretend starting vertex is unvisited. put it back in queue.\n if cyclic && loops == 2\n vertex_pq.enq(start, infinity)\n distances[start] = infinity\n end\n # vertex currently being checked. picks closest one first.\n current = vertex_pq.deq\n vname = current.keys.first\n\n # if we've arrived at final vertex, return shortest distance\n # if cyclic, skip this code during first loop\n if vname == finish && loops > 1\n shortest_path = []\n vname2 = vname\n while previous[vname2]\n shortest_path << vname2\n vname2 = previous[vname2]\n previous[start] = nil if cyclic # pretend starting vertex is unvisited\n end\n shortest_path = [start] + shortest_path.reverse\n print \"Shortest path: #{shortest_path}, Length = #{path_length(shortest_path)}\\n\"\n return distances[finish]\n end\n\n # leave if we never get to final vertex\n break if vname == nil || distances[vname] == infinity\n\n adj_vertices(vname, adj_lists).each do |vertex|\n alt_distance = distances[vname] + dist(vname, vertex)\n # if total distance to neighbor < last minimum total distance\n # to neighbor, replace it with this new distance\n if alt_distance < distances[vertex]\n distances[vertex] = alt_distance\n previous[vertex] = vname\n vertex_pq.enq(vertex, alt_distance)\n end\n end\n end\n\n end",
"def dfs_traversal(source_vertex)\n\n @visited[source_vertex] = true;\n\n @adjacent_list[source_vertex].each do |i|\n dfs_traversal(i) if !@visited[i]\n end\n\n end",
"def dfs_tree_from_vertex(start)\n tree_from_vertex(start, :dfs)\n end",
"def dfs_helper(start_node)\n\n ret_list = [start_node.value]\n # Your code here\n start_node.visited = true\n start_node.edges.each do |edge|\n unless edge.node_to.visited\n ret_list += dfs_helper(edge.node_to)\n end\n end\n return ret_list\n end",
"def dfs\n visited = Hash.new(false)\n @v.each do |vertex| \n visited.merge(explore(vertex)) if !visited[vertex]\n end\n return visited\n end",
"def min_depth(root)\n return 0 if root.nil?\n\n node_stack = [[root, 1]]\n shortest_path_seen = nil\n until node_stack.empty?\n current_node, current_depth = node_stack.pop\n\n if !current_node.left && !current_node.right\n if shortest_path_seen.nil? || current_depth < shortest_path_seen\n shortest_path_seen = current_depth\n end\n else\n node_stack.push([current_node.left, current_depth + 1]) if current_node.left\n node_stack.push([current_node.right, current_depth + 1]) if current_node.right\n end\n end\n shortest_path_seen\nend",
"def dijkstra_shortest_path(start, finish)\n visited, unvisited = Array.new, Array.new\n distances = Hash.new\n\n distances[start] = 0\n unvisited << start\n\n # find the distance\n while not unvisited.empty?\n curr_node = unvisited.pop\n visited << curr_node\n get_edges(curr_node).each do |edge| \n if visited.find_index(edge.out_vertex) == nil\n unvisited.unshift(edge.out_vertex) if unvisited.find_index(edge.out_vertex) == nil\n curr_distance, min_distance = distances[curr_node], distances[edge.out_vertex] || 1.0 / 0.0\n if curr_distance + edge.distance < min_distance\n distances[edge.out_vertex] = curr_distance + edge.distance\n end\n end\n end\n end\n\n # figure out the path\n previous = finish\n path = Array.new() \n path << previous\n while distances[previous] != 0\n get_edges(previous).each do |edge|\n if previous != edge.in_vertex && distances[edge.in_vertex] + edge.distance == distances[previous]\n previous = edge.in_vertex\n path << previous\n break\n end\n end\n end\n \n return distances[finish], path.reverse\n end",
"def bfs(start, goal = :goalNode?)\n require 'set'\n visited = Set.new\n frontier = []\n frontier << start\n\n until frontier.empty?\n current = frontier.shift\n\n next if visited.include? current\n visited << current\n\n found = false\n found = if block_given?\n yield(current)\n else\n send(goal, current)\n end\n\n if !found\n current.connections.each do |node|\n frontier << node\n end\n else\n return current\n end\n end\n :goal_node_not_found\nend",
"def solve_maze\n matrix = @maze[:matrix] # get matrix from maze hash\n exit_found = false # exit not found yet\n room = Room.new(@maze[:start_x], @maze[:start_y], nil) # create new room from start position\n queue = Queue.new # queue to store the current working nodes' children\n queue << room # add the new room to queue\n\n # if path not found and queue not empty\n while !queue.empty? && !exit_found\n room = queue.pop # get the next room to search for a path\n x = room.x\n y = room.y\n if (x == @maze[:stop_x] && y == @maze[:stop_y]) # if found\n exit_found = true\n else # if not found\n matrix[y][x] = '*' # Mark node as visited sto we do not check it again (bfs algorithm)\n\n # push to queue the children of node room. We are pushing the up, down, left or right room if they are not a wall and we\n # we haven't visited them yet\n queue << Room.new(x+1,y,room) if open_room(x+1,y,matrix) and !visited(x+1, y, matrix)\n queue << Room.new(x-1,y,room) if open_room(x-1,y,matrix) and !visited(x-1,y,matrix)\n queue << Room.new(x,y+1,room) if open_room(x,y+1,matrix) and !visited(x, y+1, matrix)\n queue << Room.new(x,y-1,room) if open_room(x,y-1,matrix) and !visited(x, y-1, matrix)\n end\n end\n\n # if goal found store the last room to @maze[:path]. The last room has a reference(:parent) to the previous room. So we can trace the path\n if exit_found\n @status.found = true\n @maze[:path] = room\n else\n @status.found = false\n end\n\n # yields x, y coordinates of path starting from goal to start\n def yield_path\n room = @maze[:path]\n while room.parent\n yield room.x, room.y\n room = room.parent\n end\n end\n\n # get an array of path\n def path_array\n path = []\n yield_path do |x, y|\n path << [x,y]\n end\n path.reverse\n end\n end",
"def extract_target_nodes_from_path(visited_nodes)\n connected_to(visited_nodes.last).select do |node|\n i = visited_nodes.index(node) \n i && (unvisited_neighbours_of(visited_nodes[i + 1], visited_nodes).length > 0)\n end\n end",
"def path(x, y)\r\n\t\t# If x or y are on the edge, meaning they have only one path, return 1\r\n\t\tif (x == 0 || y == 0)\r\n\t\t\treturn 1\r\n\t\r\n\t\t# If in the middle of the square, check to see if sum of paths for node already calculated?\r\n\t\telse\r\n\t\t\t# If so, return calculated sum of paths for node\r\n\t\t\tif @node[x][y] != 0\r\n\t\t\t\treturn @node[x][y]\r\n\t\t\t\t\r\n\t\t\t# Otherwise, set node[x][y] to sum of paths for connected nodes through recursion\r\n\t\t\t# Return newly calculated node[x][y]\r\n\t\t\telse\r\n\t\t\t\t@node[x][y] = path(x-1, y) + path(x, y-1)\r\n\t\t\t\treturn @node[x][y]\r\n\t\t\tend\r\n\t\tend\t\r\n\tend",
"def bfs(target)\n visited = {}\n @graph.keys.each { |key| visited[key] = false }\n node = @graph.keys[0]\n queue = Queue.new\n queue << node\n while !(queue.length == 0)\n visited[node] = true\n puts \"node is #{node}\"\n return node if node == target\n @graph[node].each do |nabe|\n queue << nabe unless visited[nabe] == true\n end\n node = queue.pop\n end\n end",
"def dfs(node, target)\n return nil if (node.nil?) \n return node if (node.val == target) \n left = dfs(node.left, target)\n right = dfs(node.right, target)\n left || right\nend",
"def find_max_path_length_recursively\n if self.outgoing_edges.exists?\n available_path_lengths = self.next_vertices.map do |vertex|\n [vertex.id, 1 + vertex.find_max_path_length_recursively]\n end\n longest = available_path_lengths.max{|a,b| a[1] <=> b[1]}[1]\n return longest\n else\n return 0;\n end\n end",
"def longest_path_from_segment(segment, visited_segments = [])\n visited_segments << segment\n unvisited_segments = unvisited_connected_segments(segment, visited_segments)\n return visited_segments if unvisited_segments.empty?\n further_visited_segments = unvisited_segments.map do |next_segment|\n longest_path_from_segment(next_segment, visited_segments.dup)\n end\n further_visited_segments.max_by(&:length)\n end",
"def depth_first(node, target)\n if node.children\n node.children.each do |child|\n depth_first(child, target)\n end\n end\n return 'Found your target' if node.payload == target\n 'No luck'\nend",
"def search_jps\n open_list = [@nodes[@route.start_id]]\n close_list = []\n goal = @nodes[@route.goal_id]\n\n until open_list.empty?\n n = open_list.min_by { |node| @route.estimated_cost(node) }\n if n == goal\n @route.found = true\n break\n end\n\n close_list.push( open_list.delete(n) )\n\n adjacents_of_n = n.pruned_neighbors(@route.parent(n))\n adjacents_of_n.keys.each do |m|\n j = jump(n, clamp(m.x - n.x, -1, 1), clamp(m.y - n.y, -1, 1))\n next if j == nil or close_list.include?(j)\n h = @heuristic.call(j, goal)\n new_real_cost_j = @route.real_cost(n) + Math.sqrt((n.x-j.x)**2 + (n.y-j.y)**2) # g\n new_estimated_cost_j = new_real_cost_j + h # f = g + h\n if open_list.include?(j)\n # If estimated costs are equal then use real costs for more precise comparison (or we may get less optimal path).\n next if new_estimated_cost_j > @route.estimated_cost(j)\n next if new_estimated_cost_j == @route.estimated_cost(j) && new_real_cost_j >= @route.real_cost(j)\n @route.record(j, n, new_real_cost_j, h)\n else\n open_list.push(j)\n @route.record(j, n, new_real_cost_j, h)\n end\n @visited << j.id unless @visited.include? j.id # stats\n end\n @search_iter += 1 # stats\n end\n end",
"def find_path(char)\n # get pixel movement rate\n pix = $BlizzABS.pixel\n # use request\n request = @request[char]\n # if no nodes to test\n if request.open.size == 0\n # abort testing for this character\n @request.delete(char)\n # resets state\n char.ai.state = (char.ai.state == Invalid ? Return : Ready)\n # stop execution\n return []\n end\n # found\n found = false\n # find minimal key\n key = request.open.keys.min {|a, b|\n Math.hypot(a[0] - request.tx, a[1] - request.ty) <=>\n Math.hypot(b[0] - request.tx, b[1] - request.ty)}\n # this node is now logged as checked\n request.closed[key[0], key[1]] = request.open[key]\n # remove this node from the pending array\n request.open.delete(key)\n # iterate through all possible directions with relative offsets\n Cache::PathDirs.each {|dir|\n # coordinates of new position\n kx, ky = key[0] + dir[0], key[1] + dir[1]\n # if new coordinates are destination\n if kx == request.tx && ky == request.ty\n # the new node was checked\n request.closed[kx, ky] = dir[2]\n # path was found\n found = true\n # stop checking\n break\n # if new node not checked yet and coordinates are passable\n elsif request.closed[kx, ky] == 0 &&\n char.passable?(key[0] * pix, key[1] * pix, dir[2])\n # add new node to be checked\n request.open[[kx, ky]] = dir[2]\n end}\n # stop execution except if found path\n return nil unless found\n # backtrack the path\n result = request.backtrack\n # finish testing for this character\n @request.delete(char)\n # resets state\n char.ai.state = (char.ai.state == Invalid ? Return : Ready)\n # return movement command array\n return result\n end",
"def dfs(tree, target)\n\n node_stack = [ ]\n\n #push root\n node_stack.push(tree[0])\n\n # can also set current_node and do `while current_node`\n while node_stack.length > 0\n\n # pop first\n node = node_stack.pop\n\n # then do or look for something, generally w conditional\n if node == target\n return true\n else\n # seems multiple ways to do, but doing right before left\n # makes sense to me, even though most do left before right.\n # With my way, the left is pop'd first and you go down left\n # side first\n\n #### BELOW IS NOT RIGHT -- THERE HAS TO BE SOME RECURSSION HERE\n # This actually is starting to make sense: https://github.com/brianstorti/ruby-graph-algorithms/blob/master/depth_first_search/depth_first_search.rb\n #http://haozeng.github.io/blog/2014/01/05/trees-in-ruby/\n #https://github.com/breadoliveoilsalt/depth-first-search-lab-v-000/blob/solution/index.js\n if node.left\n node_stack.push(node.left)\n end\n if node.right\n node_stack.push(node.right)\n end\n end\n end\n\n return false\n\nend",
"def find_shortest_path(exclude_path_with_tile = nil)\n node = find_end_tile(exclude_path_with_tile)\n return [@start_tile, @end_tile] if node.nil?\n expand_path(node)\n end",
"def dfs(target)\n return self if self.value == target\n # debugger\n self.children.each do |node|\n dfs(node)\n # if node.value == target\n # return node\n # else\n # node.dfs(target)\n # end\n end\n return nil if self.children.empty?\n p new_arr\n end"
] | [
"0.6996769",
"0.6797798",
"0.6789873",
"0.6686385",
"0.6575007",
"0.65383977",
"0.64992005",
"0.64012295",
"0.63809913",
"0.6352742",
"0.62899816",
"0.6271176",
"0.62113756",
"0.62113756",
"0.6207053",
"0.619099",
"0.6189835",
"0.6187292",
"0.6179531",
"0.6177912",
"0.6144253",
"0.6126501",
"0.60761005",
"0.6066644",
"0.604644",
"0.6006643",
"0.60004944",
"0.5998756",
"0.5990658",
"0.5988273",
"0.5987409",
"0.5984271",
"0.59645",
"0.5959356",
"0.59124327",
"0.59058994",
"0.589635",
"0.58931565",
"0.5891847",
"0.5889806",
"0.58878523",
"0.58842623",
"0.5882505",
"0.58729345",
"0.5872757",
"0.5859092",
"0.5856407",
"0.58497447",
"0.5849677",
"0.5843901",
"0.58336115",
"0.5832335",
"0.58310455",
"0.5826909",
"0.58089274",
"0.57910585",
"0.57873434",
"0.57651925",
"0.57566977",
"0.5737863",
"0.5737095",
"0.57337505",
"0.57329535",
"0.57306904",
"0.5730137",
"0.5723905",
"0.5722552",
"0.5705051",
"0.57043266",
"0.5693312",
"0.56904644",
"0.5687503",
"0.5684247",
"0.56689173",
"0.56542104",
"0.56527275",
"0.5650531",
"0.5642933",
"0.56351036",
"0.5632556",
"0.5628732",
"0.5624085",
"0.5622227",
"0.56173694",
"0.56098413",
"0.5606342",
"0.5605694",
"0.5605102",
"0.56036556",
"0.559308",
"0.5591555",
"0.5577042",
"0.5563571",
"0.55574965",
"0.5550964",
"0.55473834",
"0.55450153",
"0.5542597",
"0.5532403"
] | 0.6577683 | 5 |
find whether there is a path from node start to last | def find(start,last)
next_nodes = Array.new
next_nodes << start
visited = {}
while (not next_nodes.empty?)
next_node = next_nodes.shift
next if visited[next_node]
visited[next_node] = true
return true if next_node == last
@paths[next_node].map do |x| next_nodes << x end
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def completed_path?\n path.size == nodes.size - 1\n end",
"def has_path_to?(end_node)\n @visited.include?(end_node)\n end",
"def path_exists?(edges, start, finish) \n nodes = edges[start].keys\n touchedNodes = nodes + [start]\n newNodes = nodes\n\n until newNodes.length == 0\n return true if touchedNodes.include?(finish)\n newNodes = []\n nodes.each do |node|\n newNodes += edges[node].keys - touchedNodes\n end\n touchedNodes += newNodes\n nodes = newNodes\n end\n false\n end",
"def has_path_to?(node)\n @visited.include?(node)\n end",
"def adjacent_in_path?(start,destination,path)\n adjacent = start.adjacent.include?(destination)\n return adjacent unless path\n if path.index(start) && path.index(destination) && (path.index(start) - path.index(destination)).abs == 1\n adjacent\n else\n false\n end\n end",
"def has_path_to(node)\n\t\t@visited.include?(node)\n\tend",
"def find_path(end_pos)\n node = root_node.dfs(end_pos)\n\n self.trace_path_back(node)\n end",
"def finished?(paths)\n paths.each do |path|\n if path.last == @final_position\n @path = path[1..-1]\n end\n end\n @path\n end",
"def path?(p)\n p.each_cons(2){|x|\n unless edge?(x[0],x[1])\n return false\n end\n }\n return true\n end",
"def path_below_self?(old_path, new_path)\n return (new_path.index(old_path) != nil)\n end",
"def find_path(root, p, path)\n return false unless root\n path.push(root)\n return true if root.val == p.val || find_path(root.left, p, path) || find_path(root.right, p, path)\n path.pop\n false\nend",
"def has_path?(path)\n !node_for(path).nil?\n end",
"def route_between?(start_node, end_node)\n queue = BasicQueue.new\n queue.enqueue(start_node)\n until queue.empty?\n node = queue.dequeue\n return true if node == end_node\n node.children.each do |child|\n # Mark the children so that we don't end up in a loop\n queue.enqueue(child) unless child.marked?\n child.marked = true\n end\n end\n false\nend",
"def child_path?(root, target)\n return false if target.size < root.size\n\n target[0...root.size] == root &&\n (target.size == root.size || target[root.size] == '/')\nend",
"def tile_has_path?(tile, exits)\n tile.paths.each do |path|\n if path.exits.size == 2\n # Case 1: simple path from edge to edge\n return true if (path.exits - exits).empty?\n elsif exits.include?(path.exits.first)\n # Case 2: path from edge to node => follow paths out of node\n target_exit = exits.find { |x| x != path.exits.first }\n node = path.nodes.first\n node.paths.each do |node_path|\n next if node_path == path\n\n return true if node_path.exits.first == target_exit\n end\n end\n end\n false\n end",
"def hasChild?\n @path.size > 1\n end",
"def find_path(end_pos)\n path = [@root_node]\n valid_moves = KnightPathFinder.valid_moves(@root_node)\n valid_moves.each do |move|\n @move_tree.add_child(move)\n end\n \n if @move_tree.bfs(end_pos) == end_pos\n path << end_pos\n else \n end\n\n end",
"def stoppable?(initial_s)\n total_paths(initial_s) > 0\n end",
"def find_path(end_pos)\n trace_path_back(@root.dfs(end_pos))\n\n end",
"def find_path(end_pos)\n # self.dfs(target)\n end_node = root_node.bfs(end_pos)\n trace_path_back(end_node).map { |node| node.value }.reverse!\n end",
"def trace_path_back(end_node)\n path = []\n\n current_node = end_node\n until current_node.nil?\n path << current_node\n current_node = current_node.parent\n end\n\n path\n end",
"def route?(graph, node)\n graph.depth_first_search(graph.starting_vertex, node)\nend",
"def path?(from_id, to_id)\n from = find_vert(from_id)\n to = find_vert(to_id)\n visted = []\n letters = ''\n return dfs_search(from, to, visted, letters)\n end",
"def find_path(end_pos)\n end_node = root_node.dfs(end_pos)\n trace_path_back(end_node)\n .reverse\n .map(&:value)\n end",
"def in_path?(path); end",
"def find_path(start, target)\n node = build_path(start, target)\n path = [node]\n until node.next_node.nil? do\n node = node.next_node\n path.push(node)\n end\n path = path.reverse\n puts \"You made it in #{path.length} moves. Here is your path: \"\n path.each do |node|\n puts \"[#{node.x}], [#{node.y}]\"\n end\nend",
"def find_path(end_pos)\n end_node = root_node.dfs(end_pos)\n\n trace_path_back(end_node)\n .reverse\n .map(&:value)\n end",
"def clear_path? start_square, end_square\n if horizontal?(start_square, end_square)\n clear_path_horizontal?(start_square, end_square)\n elsif vertical?(start_square, end_square)\n clear_path_vertical?(start_square, end_square)\n else\n map = board_scan(start_square)\n next_square = map[end_square.name][:predecessor]\n until next_square == start_square\n if next_square.piece != nil\n return false\n else\n next_square = map[next_square.name][:predecessor]\n end\n end\n true\n end\n\n end",
"def has_path?(v)\n @visited[v]\n end",
"def descends_from? path, base\n if base == path\n 0\n elsif base == SLASH\n (path.start_with? SLASH) && 1\n else\n (path.start_with? base + SLASH) && (base.length + 1)\n end\n end",
"def current?\n @node.current_path == path\n end",
"def in_path?\r\n self.aln_path_id.nil? ? false : true\r\n end",
"def path?(point, direction)\n @paths[point] & direction != 0\n end",
"def path_open?(index)\n\t\treturn element_props(index)['open-path']\n\tend",
"def path?\n !path.empty?\n end",
"def get_path(str)\n child_node = @children[str[0]] || raise(NotFound)\n return [child_node.end_of_word?] if str.length == 1\n [child_node.end_of_word?].concat child_node.get_path(str[1..-1])\n end",
"def trace_path_back(end_pos)\n last_node = self.find_path(end_pos)\n return \"we can't find the end pos\" if last_node == nil\n path_arr = [last_node.pos]\n\n until last_node.parent == nil\n path_arr << last_node.parent.pos\n last_node = last_node.parent\n end\n\n path_arr.reverse\n end",
"def valid_path? unit, path\n path.inject(@units[unit].location) do |p,c|\n return false unless adjacent?(p, c) && can_path_through(*c)\n c\n end\n true\n end",
"def find_path(coords)\n return false if dead_end?(coords)\n\n if goal_found?(coords)\n @path << coords\n return true\n end\n\n # This cell may actually be part of the solution, let's check\n @path << coords\n return true if valid_move_available?(coords)\n\n # Since we got here, this cell can't be part of the solution\n @path.pop\n false\n end",
"def build_path(start, finish)\n path = [finish]\n loop do\n vertex = path.last\n d = graph[*vertex]\n neighbours = get_neighbours(*vertex)\n next_vertex = neighbours.select{|n_vert| graph[*n_vert] == d - 1}.first\n path << next_vertex if next_vertex\n break if vertex == start\n end\n path\n end",
"def find_path(target)\n queue = [root_node]\n until queue.empty?\n p current_node = queue.shift\n p queue\n return current_node if current_node.value == target\n current_node.children.each do |child|\n queue << child\n end\n end\n nil\nend",
"def get_path(node, root)\r\n path = []\r\n until path.last == root.current_case\r\n path << node.current_case\r\n node = node.parent\r\n end\r\n\r\n puts \"You made it in #{path.size - 1} moves! Here's your path:\"\r\n path.reverse.each { |c| puts c.inspect }\r\n end",
"def shorter_path_exist?(yx, steps, keys_to_go, visited)\n steps >= (visited[[yx, keys_to_go]] || Float::INFINITY)\n end",
"def connects_to_beginning?(node_id)\n (node_id == @begin_node_id and !@begin_node_direction) or\n (node_id == @end_node_id and @end_node_direction)\n end",
"def is_last_segment_of_flight?\n return true if sibling_segments.empty?\n sibling_segments.sort_by {|segment| segment.index }.reverse.first == self\n end",
"def find_path(start_node, end_node, grid)\n start_node = sanitize(start_node)\n end_node = sanitize(end_node)\n if grid.nil?\n [start_node]\n else\n _max_x = grid.max_x\n _max_y = grid.max_y\n\n @current_grid = grid.inner_grid.clone\n\n raise 'max_x & max_y required' unless _max_x && _max_y\n\n _start_node = start_node.clone\n _end_node = end_node.clone\n\n heuristic = @heuristic.new(_end_node, @weight)\n\n _start_node[:f] = 0 # sum of g and h\n _start_node[:g] = 0 # steps to start node\n _start_node[:h] = nil # steps to end node\n _start_node[:opened] = true\n\n # use heap or tree for better perf\n open = []\n open.push _start_node\n\n while !open.empty? do\n _current_node = open.pop\n\n _current_node[:closed] = true\n @current_grid[node_to_a(_current_node)] = _current_node\n\n if node_to_a(_current_node) == node_to_a(_end_node)\n return final_path(_current_node)\n end\n\n new_g = _current_node[:g] + 1\n\n x = _current_node[:x]\n y = _current_node[:y]\n\n neighbors = []\n\n neighbors << [x-1, y] if x > 0\n neighbors << [x, y-1] if y > 0\n neighbors << [x+1, y] if x < _max_x-1\n neighbors << [x, y+1] if y < _max_y-1\n\n _neighbors = neighbors.map do |position|\n node = @current_grid[position]\n if node.nil? || node[:walkable]\n node ||= {}\n @current_grid[position] = node.merge({\n x: position.first,\n y: position[1],\n closed: false,\n opened: false\n })\n end\n end.compact\n\n _neighbors.each do |neighbor|\n if (!neighbor[:opened] || new_g < neighbor[:g])\n neighbor[:g] = new_g\n neighbor[:h] ||= heuristic.h(neighbor)\n neighbor[:f] = neighbor[:g] + neighbor[:h]\n neighbor[:parent] = node_to_a(_current_node)\n\n if (!neighbor[:opened])\n open.push neighbor\n neighbor[:opened] = true\n else\n # ???\n puts \"got here some how!!!\"\n end\n end\n end\n\n open.sort_by! {|i| [-i[:f], -i[:h]]}\n # grid_p\n end\n end\n end",
"def relative?\n\t\tpath[0] == 47\n\tend",
"def is_pathway?(x, y)\n @maze[x][y] == '_' or is_exit?(Cell.new(x, y, []))\n end",
"def last?\n if tree.columns.counter_cache? && parent\n parent.children.size == position\n else\n !right_sibling\n end\n end",
"def match?(offset, path)\n @routes[offset..-1].find do |route|\n route.regexp === path || (path.end_with?(\"/\") && route.regexp === path[0..-2])\n end\n end",
"def get_path(s, e, maze)\n if maze[s[0]][s[1]] == 1 || # found a wall or visited area\n s[0] < 0 || s[1] < 0 || # top or left edge\n s[0] >= maze.length || s[1] >= maze[0].length # bottom or right edge\n\n path = nil\n\n elsif s[0] == e[0] && s[1] == e[1] # exit spot\n\n path = [s]\n\n else\n\n maze[s[0]][s[1]] = 1 # visit current node\n path =\n get_path([s[0] - 1, s[1]], e, maze) ||\n get_path([s[0], s[1] + 1], e, maze) ||\n get_path([s[0], s[1] - 1], e, maze) ||\n get_path([s[0] + 1, s[1]], e, maze)\n\n path << s unless path.nil?\n\n end\n \n return path\nend",
"def has_infinite_loop?(path = [])\n\t\t\tself.survey.node_maps.select { |i| i.parent == self && !i.marked_for_destruction? }.each { |i|\n\t\t\t\t# Detect infinite loop\n\t\t\t\tif path.include?(self.node) || i.has_infinite_loop?(path.clone.push(self.node))\n\t\t\t\t\treturn true\n\t\t\t\tend\n\t\t\t}\n\t\t\tpath.include?(self.node)\n\t\tend",
"def has?(path)\n return (@root.is_a?(Hash) && @root.has_key?(path)) if path.is_a?(Symbol)\n\n path = path.to_s.split('.') unless path.is_a?(Array)\n node = @root\n path.each { |key|\n if node.is_a?(Hash)\n key = key.to_sym\n return false unless node.has_key?(key)\n node = node[key]\n elsif node.is_a?(Array)\n i = key.to_i\n return false if 0 == i && '0' != key && 0 != key\n len = node.length\n return false unless -len <= i && i < len\n node = node[i]\n else\n return false\n end\n }\n true\n end",
"def find_path(cell, &block)\n current_cell = cell\n begin\n current_cell = yield(current_cell)\n return current_cell if is_intersection?(current_cell)\n end while is_navigable_space?(current_cell)\n nil\n end",
"def leaf?\n @succ.length == 0\n end",
"def empty?\n PathExpression.range(expression)[0].nil?\n end",
"def find_path(goal = @maze.find_end)\n path = [goal]\n spot = goal\n until @branching_paths[spot] == nil\n path << @branching_paths[spot]\n spot = @branching_paths[spot]\n end\n path\n end",
"def find_path(end_pos)\n end_node = self.root_node.dfs(end_pos)\n final_arr = trace_back(end_node).map{ |el| el.value }\n final_arr.reverse\n end",
"def has_path_sum(root, sum)\n return false if !root\n path_helper(root, 0, sum)\nend",
"def circular_reference?(path)\n path.include?(\"#{escaped_pointer}/\")\n end",
"def path_from_to(a, b)\n # Work with the fixed anchors of the nodes because that's where the\n # control flow is fixed to.\n\n a = fixed_anchor(a)\n b = fixed_anchor(b)\n\n # We're going to do a depth-first search starting with the first node\n # and we're going to see if we can find the second node. We keep a stack\n # of nodes that we need to visit, and a set of nodes that we've already\n # visited so that we don't visit nodes more than once. We pop a node\n # off the stack, return if it was the node we were looking for, or move\n # on if we've already visited it, if not we push the outputs of the node\n # to visit next.\n\n worklist = [a]\n considered = Set.new\n until worklist.empty?\n node = worklist.pop\n return true if node == b\n if considered.add?(node)\n worklist.push *node.outputs.control_edges.to_nodes\n end\n end\n\n # We traversed the whole graph accessible from the first node and didn't\n # find the second one.\n\n false\n end",
"def exist?(str)\n return end_of_word? if str.empty? # terminal condition\n child_node = @children[str[0]]\n return false unless child_node # there is no path with the given string\n child_node.exist? str[1..-1] # recursively call itself on the child node\n end",
"def paths_to(node)\n find_paths do\n find { |n| n == node }\n end\n end",
"def hierarchical?\n if @path\n true\n else\n false\n end\n end",
"def points_to? path\n href = @tag.scan(/href=\\\"([^\"]*)\\\"/)[0][0] rescue nil\n return false unless href\n unless href.start_with? '/'\n href = URI(href).send :path_query rescue nil\n end\n href == path\n end",
"def include?(node)\n @pathway.graph[node] ? true : false\n end",
"def segmented_path?\n path.split('/').any? { |s| s[0] == ':' }\n end",
"def last?\n !right_sibling\n end",
"def end_of_path?(dir, root = nil)\n dir.nil? || dir.empty? || dir == '.' || dir == root\n end",
"def find_path(start, chargers, builtin)\n chargers = chargers.dup\n current_jolt = start\n chargers << builtin\n chargers.sort.each do |charger|\n difference = charger - current_jolt\n return false if difference > 3\n\n current_jolt = charger\n end\n true\n end",
"def sub_path_to_end(remove_from_front)\n count = remove_from_front\n p = self\n while (not p.nil?) && count > 0 do\n count -= 1\n p = p.remainder\n end\n p\n end",
"def open_path?(start,finish)\n start_piece = piece_at(start)\n end_piece = piece_at(finish)\n #debugger\n return false if end_piece and end_piece.color == start_piece.color\n\n sy, sx = start\n fy, fx = finish\n #check horizontals\n if sy == fy\n minx = [sx,fx].min\n maxx = [sx,fx].max\n ((minx + 1)...maxx).each do |new_x|\n return false if !@board[sy][new_x].nil?\n end\n end\n\n #check verticals\n if sx == fx\n miny = [sy,fy].min\n maxy = [sy,fy].max\n ((miny + 1)...maxy).each do |new_y|\n return false if !@board[new_y][sx].nil?\n end\n end\n\n #check diags\n if (sx - fx).abs == (sy - fy).abs\n miny = [sy,fy].min\n maxy = [sy,fy].max\n #down right\n if ((sx < fx) == (sy < fy))\n new_x = [sx,fx].min\n ((miny+1)...maxy).each_with_index do |new_y, d|\n return false if !@board[new_y][new_x + d + 1].nil?\n end\n #down left\n else\n new_x = [sx,fx].max\n ((miny+1)...maxy).each_with_index do |new_y, d|\n return false if !@board[new_y][new_x - d - 1].nil?\n end\n end\n end\n true\n end",
"def current_path_starts_with?(path)\n @ctx.path_with_slashes(@ctx.current_path).start_with?(@ctx.path_with_slashes(path))\n end",
"def connects_to_end?(node_id)\n (node_id == @begin_node_id and @begin_node_direction) or\n (node_id == @end_node_id and !@end_node_direction)\n end",
"def each()\n @path.each do |node_id|\n unless (node_id == @path.last or node_id == path[-2])\n yield node_id \n end\n end\n end",
"def connects_beginning_to_end?(first_node_id, second_node_id)\n (first_node_id == @begin_node_id and second_node_id == @end_node_id and\n @begin_node_direction == false and @end_node_direction == false) or\n (first_node_id == @end_node_id and second_node_id = @begin_node_id and\n @begin_node_direction == true and @end_node_direction == true)\n end",
"def pathfind begTile, endTile\n @traveled_tiles = [begTile]\n @current_tiles = [begTile]\n @next_tiles = Array.new\n #iterate through the maze one movement at a time, hard stop when all tiles have been exhausted\n while (!@current_tiles.include? endTile) && @traveled_tiles.length < @maze.size\n @current_tiles.each do |tile|\n (get_adjacent_floors tile).each do |next_tile|\n #makes sure no tiles are double counted, the first to hit will always be the shortest\n if (next_tile.is_floor) && (!@next_tiles.include? next_tile) && (!@traveled_tiles.include? next_tile)\n @next_tiles.push next_tile\n next_tile.previous_tile tile\n end\n end\n end\n @traveled_tiles.concat @next_tiles\n @current_tiles = @next_tiles.dup\n @next_tiles.clear\n end\n endTile.get_path\n end",
"def decode_path(goal_node)\n path = []\n until goal_node.nil?\n path.unshift goal_node\n goal_node = goal_node.previous\n end\n return path\nend",
"def empty_path?\n path.empty?\n end",
"def is_path?(); @type == GRT_PATH; end",
"def find_path(char)\n # get pixel movement rate\n pix = $BlizzABS.pixel\n # use request\n request = @request[char]\n # if no nodes to test\n if request.open.size == 0\n # abort testing for this character\n @request.delete(char)\n # resets state\n char.ai.state = (char.ai.state == Invalid ? Return : Ready)\n # stop execution\n return []\n end\n # found\n found = false\n # find minimal key\n key = request.open.keys.min {|a, b|\n Math.hypot(a[0] - request.tx, a[1] - request.ty) <=>\n Math.hypot(b[0] - request.tx, b[1] - request.ty)}\n # this node is now logged as checked\n request.closed[key[0], key[1]] = request.open[key]\n # remove this node from the pending array\n request.open.delete(key)\n # iterate through all possible directions with relative offsets\n Cache::PathDirs.each {|dir|\n # coordinates of new position\n kx, ky = key[0] + dir[0], key[1] + dir[1]\n # if new coordinates are destination\n if kx == request.tx && ky == request.ty\n # the new node was checked\n request.closed[kx, ky] = dir[2]\n # path was found\n found = true\n # stop checking\n break\n # if new node not checked yet and coordinates are passable\n elsif request.closed[kx, ky] == 0 &&\n char.passable?(key[0] * pix, key[1] * pix, dir[2])\n # add new node to be checked\n request.open[[kx, ky]] = dir[2]\n end}\n # stop execution except if found path\n return nil unless found\n # backtrack the path\n result = request.backtrack\n # finish testing for this character\n @request.delete(char)\n # resets state\n char.ai.state = (char.ai.state == Invalid ? Return : Ready)\n # return movement command array\n return result\n end",
"def empty?\n @path.size == 0\n end",
"def scanned_node?(node); end",
"def path?(val)\n !!(val =~ /\\A\\//)\n end",
"def calc_path\n endpoint = grid.target\n while endpoint\n search.path[endpoint] = true\n endpoint = search.came_from[endpoint]\n end\n end",
"def next\r\n # if the path is empty attempt create the first path element \r\n if @path.empty?\r\n ords = get_data @base\r\n if ords.empty?\r\n # if the base ordering has no related orderings to traverse\r\n # return false \r\n return nil\r\n else\r\n #otherwise create the path element \r\n @path << IteratorPathElement.new(ords[0])\r\n return ords[0] \r\n end \r\n else\r\n # The path is not empty, we have to advance to the next element\r\n cur_elem = @path[-1]\r\n # We use the depth-first algorithm, check whether we can deepen first\r\n ords = get_data(cur_elem.cur_ordering)\r\n unless ords.empty?\r\n # deepen the path\r\n @path << IteratorPathElement.new(ords[0])\r\n return ords[0]\r\n else\r\n # move to next element\r\n \r\n # remove path elements which have enumerated already all their children \r\n until cur_elem.has_more?\r\n @path.pop\r\n if @path.empty?\r\n return nil\r\n end\r\n cur_elem = @path[-1]\r\n end\r\n \r\n #actually move to the next sibling element\r\n return cur_element.next\r\n end\r\n end\r\n end",
"def is_direct_path item\n\t\t!item.nil? and !item[3] and item[1] == @zero_pathitem\n\tend",
"def build_path(start, end_pos)\n node = Node.new(start[0], start[1])\n target = Node.new(end_pos[0], end_pos[1])\n visited_nodes = []\n next_moves = [node]\n until next_moves.empty? do\n node = next_moves.shift\n puts \"Current node: #{node.x}, #{node.y}\"\n if node.x == target.x && node.y == target.y \n return node\n end\n visited_nodes.push(node)\n node.moves = get_moves(node)\n node.moves.reject do |square|\n visited_nodes.include?(square)\n end\n node.moves.each do |move| \n next_moves.push(move)\n end\n end\n return node\nend",
"def connects_beginning_to_beginning?(first_node_id, second_node_id)\n (first_node_id == @begin_node_id and second_node_id == @end_node_id and\n @begin_node_direction == false and @end_node_direction == true) or\n (first_node_id == @end_node_id and second_node_id = @begin_node_id and\n @begin_node_direction == false and @end_node_direction == true)\n end",
"def next_child_in_path(start_node_index, end_node_index)\n next_child = end_node_index\n while parent_index(end_node_index) != start_node_index\n end_node_index = parent_index(end_node_index)\n next_child = end_node_index\n end \n next_child\n end",
"def find_path(paths = [[@position]])\n if not @path and finished?(paths)\n return @path\n else\n new_paths = []\n change = false\n paths.each do |path|\n possible_positions?(path).each do |position|\n new_paths << path.dup.push(position)\n change = true\n end\n end\n find_path(new_paths) if change\n end\n end",
"def path(start,predicate)\n array = Array.new\n start.each { |elem|\n array.push(elem)\n if predicate.call(elem)\n return array\n end\n }\n nil\n end",
"def has_next\n return !(self.next_node.nil?)\n end",
"def find_bottom_path(cell)\n find_path(cell) { | cell | bottom_cell(cell) }\n end",
"def next(node)\n @path[@path.index(node) + 1]\n end",
"def path?\n !!@path\n end",
"def path?\n !!@path\n end",
"def get_path_by_names(start, stop)\n s1 = get_node(start)\n s2 = get_node(stop)\n if s1 != nil && s2 != nil\n return get_path(s1, s2)\n end\n Array.new \n end",
"def trace_path_back(node)\n node.path_values.reverse\n end",
"def empty_path?\n super || remaining_path == '/'\n end"
] | [
"0.7689254",
"0.7613609",
"0.73372984",
"0.68381256",
"0.68094456",
"0.67136925",
"0.66374946",
"0.6562556",
"0.6544726",
"0.65369296",
"0.65261626",
"0.6514396",
"0.6495075",
"0.64752203",
"0.64050233",
"0.6394061",
"0.6357536",
"0.6310814",
"0.63036186",
"0.62605834",
"0.62530315",
"0.62400925",
"0.62368715",
"0.6236117",
"0.62285423",
"0.6189642",
"0.61792284",
"0.61678195",
"0.6134036",
"0.6133338",
"0.61254513",
"0.6111134",
"0.61092806",
"0.61092085",
"0.6107303",
"0.6049298",
"0.6047959",
"0.601589",
"0.59890836",
"0.59825665",
"0.59646404",
"0.5952211",
"0.5946175",
"0.59320664",
"0.59258693",
"0.5914648",
"0.590425",
"0.5897982",
"0.58864456",
"0.5882958",
"0.5879265",
"0.5877749",
"0.58633226",
"0.5862851",
"0.584931",
"0.58460313",
"0.5845578",
"0.58445686",
"0.58434737",
"0.5836756",
"0.5820606",
"0.58043766",
"0.579755",
"0.5797496",
"0.57908815",
"0.57882464",
"0.57864946",
"0.578573",
"0.57851595",
"0.57818437",
"0.5775912",
"0.5775364",
"0.57699883",
"0.5758453",
"0.575644",
"0.5756387",
"0.57492816",
"0.57327986",
"0.5727662",
"0.57271224",
"0.57257235",
"0.5706481",
"0.57002515",
"0.5699884",
"0.5690316",
"0.56878215",
"0.5686545",
"0.5685405",
"0.56816757",
"0.56777173",
"0.56753707",
"0.56746113",
"0.5671832",
"0.56627804",
"0.5662132",
"0.5649181",
"0.5649181",
"0.56482875",
"0.56320834",
"0.5631751"
] | 0.7417204 | 2 |
Flood fill to find the largest strongly connected component starting from node Strongly connected means that there is a path from u>v and from v>u | def fill(node)
filled_so_far = Array.new
nodes_hash = Hash.new
already_seen = Hash.new
queue = [node]
while (not queue.empty?)
next_node = queue.shift
next if already_seen[next_node]
already_seen[next_node] = true
@paths[next_node].each do |next_next_node|
if (next_next_node == next_node)
# special case. we consider a node connected to itself to be strongly connected
nodes_hash[next_node] = true
elsif (find(next_next_node,next_node))
# make sure there is a reverse path
queue << next_next_node
nodes_hash[next_node] = true
nodes_hash[next_next_node] = true
end
end
end
nodes = nodes_hash.keys
@paths.each do |k,v|
if nodes.include?(k)
v.each do |v|
if nodes.include?(v)
filled_so_far << [k,v]
end
end
end
end
return filled_so_far
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findShortest(graph_nodes, graph_from, graph_to, ids, val)\n return -1 if ids.count(val)<=1 # no two nodes with color val\n dmin = graph_nodes\n num_edges = graph_from.length\n neighbors = {}\n 0.upto(num_edges-1) do |i|\n if neighbors[graph_from[i]]\n neighbors[graph_from[i]] << graph_to[i]\n else\n neighbors[graph_from[i]] = [graph_to[i]]\n end\n if neighbors[graph_to[i]]\n neighbors[graph_to[i]] << graph_from[i]\n else\n neighbors[graph_to[i]] = [graph_from[i]]\n end\n end\n p neighbors\n ids.each_with_index do |v,i|\n if v == val\n # zero-base index to one-base index \n source_node = i+1\n # look for others using bfs (stop looking if distance > dmin)\n queue = []\n visited = []\n backtrace = {}\n queue << source_node\n while !(queue.empty?)\n current_node = queue.shift\n visited << current_node\n if (current_node!=source_node) && (ids[current_node-1]==val)\n puts \"we are here!\"\n # how did I get here? backtrace\n hops = 0\n trace_node = current_node\n while (trace_node!=source_node)\n trace_node = backtrace[trace_node]\n hops +=1\n end\n if hops < dmin\n dmin = hops\n end\n break\n end\n neighbors[current_node].each do |xnode|\n if !(visited.include?(xnode))\n queue << xnode\n backtrace[xnode] = current_node\n end\n end\n end\n p visited\n end\n end\n if dmin == graph_nodes\n return -1\n else\n return dmin\n end\nend",
"def floodfill(x, y, color)\n if @pixels[y-1][x-1] != color\n @pixels[y-1][x-1] = color\n floodfill(x+1, y, color)\n floodfill(x-1, y, color)\n floodfill(x, y + 1, color)\n floodfill(x, y - 1, color)\n end\n end",
"def flood_fill(map, basin, row, col)\n return unless map.in_bounds?(row, col)\n\n basin.add([row, col])\n\n val = map.at(row, col)\n [[-1, 0], [1, 0], [0, -1], [0, 1]].each do |dr, dc|\n r = row + dr\n c = col + dc\n next if basin.include?([r, c])\n\n other_val = map.at(r, c)\n flood_fill(map, basin, r, c) if other_val && other_val >= (val - 1)\n end\n end",
"def matte_floodfill(x, y)\n f = copy\n f.alpha(OpaqueAlphaChannel) unless f.alpha?\n target = f.pixel_color(x, y)\n f.matte_flood_fill(target, x, y, FloodfillMethod, alpha: TransparentAlpha)\n end",
"def dfs(graph, v)\n @visited[v] = true\n w = nil\n @component[v] = @nb\n graph.adj(v).each do |e|\n w = e.to\n dfs(graph, w) if not @visited[w]\n end\n end",
"def bradth_first_search_colors(start_vertex, stop_vertex)\n queue = Array.new()\n queue << search_vertex(start_vertex)\n until queue.empty?\n temp_vertex = queue.shift()\n break if temp_vertex.value == stop_vertex #found stop condition\n vertex_edges = temp_vertex.edges.head\n until vertex_edges == nil\n current_vertex = search_vertex(vertex_edges.value)\n if current_vertex.color == 'white'\n current_vertex.color = 'gray' #indicates that shorter path is available if found again\n current_vertex.distance = temp_vertex.distance + 1\n current_vertex.parent = temp_vertex.value\n queue << current_vertex\n end\n vertex_edges = vertex_edges.link\n end\n temp_vertex.color = 'black' #completly explored tree\n end\n graph_traversal(start_vertex, stop_vertex)\n end",
"def DFSb(v, vf) #wyszukiwanie mostow w grafie\n $d[v] = $cv\n low = $cv\n $cv = $cv + 1\n 0.upto($n-1) do |i|\n if $a[v][i] > 0 and i != vf\n if $d[i] == 0\n temp = DFSb(i, v)\n low = temp if temp < low\n else\n low = $d[i] if $d[i] < low\n end\n end\n end\n if vf > -1 and low == $d[v]\n $a[vf][v] = 2\n $a[v][vf] = 2\n end\n return low\nend",
"def floodFill(col, row)\r\n (col > @columns-1 || col < 0 || row > @rows-1 || row < 0) && return #Returns if the tile index is outside of the grid bounds.\r\n @tile[col][row].revealed && return #Returns if the tile is already revealed.\r\n\r\n @tile[col][row].revealed = true #Marks the tile as revealed.\r\n @hiddenCount -= 1\r\n adjacent = @tile[col][row].adjacent #Gets the adjacent count for the tile.\r\n\r\n #Reveal the adjacent count of the tile.\r\n old = @tile[col][row].btn\r\n newStyle = old.style.dup\r\n old.parent.before(old) do\r\n @btn = button(adjacent.to_s, newStyle)\r\n end\r\n old.remove\r\n\r\n #Recursively calls flood fill for the surrounding tiles.\r\n if (@tile[col][row].adjacent == 0)\r\n floodFill(col+1,row+1)\r\n floodFill(col+1,row)\r\n floodFill(col+1,row-1)\r\n floodFill(col,row+1)\r\n floodFill(col,row-1)\r\n floodFill(col-1,row+1)\r\n floodFill(col-1,row)\r\n floodFill(col-1,row-1)\r\n end\r\n\r\nend",
"def strongly_connected_components\n\t\t@explored_nodes = Array.new(size, false)\n\t\t@finishing_time_arr = Array.new(size)\n\t\t@scc = Array.new\n\t\t@dfs_queue = Array.new\n\t\t@finishing_time_queue = Array.new\n\t\t@finishing_time = 0\n\t\tcalculate_finishing_time\n\t\t@leaders = scc_call_order\n\t\tcalculate_scc\n\t\tputs \"#{@scc.map(&:count).sort.reverse.take(5)}\"\n\tend",
"def flood_fill(image, sr, sc, new_color)\r\n queue = [[sr, sc]]\r\n old_color = image[sr][sc]\r\n until queue.empty? do \r\n start = queue.pop\r\n x, y = start\r\n image[x][y] = new_color\r\n queue << [x, y+1] if y+1 < image[x].length && image[x][y+1] == old_color\r\n queue << [x, y-1] if y-1 >= 0 && image[x][y-1] == old_color\r\n queue << [x+1, y] if x+1 < image.length && image[x+1][y] == old_color\r\n queue << [x-1, y] if x-1 >= 0 && image[x-1][y] == old_color\r\n end\r\n image\r\nend",
"def fill_neighbouring(x, y, color)\n # tmp var to store the original color of the targeted pixel\n original_color = grid[y.to_i - 1][x.to_i - 1]\n\n # Color the original pixel as a starting point\n color_pixel(x, y, color)\n\n # Find all neighbours that match the original color\n find_neighbours(x.to_i - 1, y.to_i - 1, original_color, color)\n end",
"def bfs(source)\n color = {}\n prev = {}\n dist = {}\n @vertices.each do |v|\n color[v] = \"white\"\n prev[v] = nil\n dist[v] = -1\n end\n color[source] = \"grey\"\n dist[source] = 0\n queue = []\n queue.push source\n while !queue.empty?\n v = queue.pop\n (@edges[v] || []).each do |edge|\n adj = edge.to\n if color[adj] == \"white\"\n color[adj] = \"grey\"\n dist[adj] = dist[v] + 1\n prev[adj] = v\n queue.push adj\n end\n end\n color[v] = \"black\"\n end\n [prev, dist]\n end",
"def bfs( start, &block )\n start.distance = 0\n start.predecessor = nil\n start.gray!\n vq = Queue.new()\n vq.enqueue(start)\n while vq.size > 0\n current = vq.dequeue()\n current.get_connections.each do |nbr|\n if nbr.white?\n nbr.gray!\n nbr.distance = current.distance + 1\n nbr.predecessor = current\n vq.enqueue(nbr)\n end\n end\n current.black!\n yield current if block_given?\n end\n # clean up vertices attributes set during bfs\n @vertices.keys.each do |key|\n @vertices[key].distance = nil\n @vertices[key].predecessor = nil\n @vertices[key].color = nil\n end\n end",
"def colour_graoh(colors, graph)\n graph.nodes.each do |node|\n \n all_neighbouring_colors = []\n \n node.neighbours.each do |neighbour|\n all_neighbouring_colors << neighbour.color if !all_neighbouring_colors.include?(neighbour.color)\n end\n \n colors.each do |color|\n node.color = color if !all_neighbouring_colors.include?(color)\n break\n end\nend",
"def flood_fill(matrix, x, y ,z)\n\n # Bounds check\n if [x,y,z].select{|n| n<0 || n>=matrix.length}.size > 0\n return\n end\n # Do nothing check\n if ['X','Z'].include?(matrix[x][y][z])\n return\n end\n # To fill check\n if matrix[x][y][z] ==\"Y\"\n matrix[x][y][z] = \"Z\"\n puts \"#{x},#{y},#{z}\"\n end\n # Recurrsive call\n for x_d in -1..1\n for y_d in -1..1\n for z_d in -1..1\n if x+x_d!=x && y+y_d!=0 && z+z_d!=0\n flood_fill(matrix, x+x_d, y+y_d, z+z_d)\n end\n end\n end\n end\nend",
"def dfs(i, j, visited, m, group)\n # These arrays are used to get row and\n # column numbers of 4 neighbours\n # of a given cell\n rowNbr = [-1, 0, 0, 1]\n colNbr = [ 0, -1, 1, 0]\n\n # Mark this cell as visited\n visited[i][j] = true\n group += 1\n #puts \"dfs #{i}, #{j} group:#{group}\"\n # Recurse for all connected neighbours\n 0.upto(4 - 1) do |k|\n if isSafe(i + rowNbr[k], j + colNbr[k], visited, m)\n # puts \"k:#{k} i:#{i + rowNbr[k]}, j:#{j + colNbr[k]}\"\n group = dfs(i + rowNbr[k], j + colNbr[k], visited, m, group)\n end\n end\n #puts \"RETURN:#{group}\"\n return group\nend",
"def flood_fill(x, y, color)\n x_i, y_i = pixel_to_index(x, y)\n original_color = bitmap[y_i][x_i]\n flood_fill_helper(x, y, original_color, color)\n end",
"def fill_with_oxygen\n BFS.max_depth(Finder.new(@map.oxygen_pos, @map))\n end",
"def dfs(start_vertex, &block)\n start_vertex.gray!\n @time += 1\n start_vertex.discovery = @time\n start_vertex.get_connections.each do |next_vertex|\n if next_vertex.white?\n next_vertex.predecessor = start_vertex\n dfs(next_vertex, &block)\n end\n end\n start_vertex.black!\n @time += 1\n start_vertex.finish = @time\n yield start_vertex if block_given?\n end",
"def dfs(node ,max)\n return if node.nil?\n if node.val >= max\n @count += 1\n max = node.val\n end\n dfs(node.left, max)\n dfs(node.right, max)\nend",
"def min_cost(costs)\n prev_color_path1 = 0\n prev_color_path2 = 1\n path1 = costs[0][prev_color_path1]\n path2 = costs[0][prev_color_path2]\n \n if costs[0][2] < path1\n if path1 < path2\n path2 = path1\n prev_color_path2 = prev_color_path1\n path1 = costs[0][2]\n prev_color_path1 = 2\n end\n elsif costs[0][2] < path2\n if path2 < path1\n path1 = path2\n prev_color_path1 = prev_color_path2\n path2 = costs[0][2]\n prev_color_path2 = 2\n end\n end\n\n costs[1..-1].each do |cost|\n min1 = nil\n min1idx = nil\n # for first path\n cost.each_with_index do |amt, idx|\n next if idx == prev_color_path1\n if min1\n if amt < min1\n min1 = amt\n prev_color_path1 = idx\n else\n next\n end\n else\n min1 = amt\n min1idx = idx\n end\n end\n path1 += min1\n\n \n min2 = nil\n min2idx = nil\n # for second path\n cost.each_with_index do |amt, idx|\n next if idx == prev_color_path2\n if min2\n if amt < min2\n min2 = amt\n prev_color_path2 = idx\n else\n next\n end\n else\n min2 = amt\n min2idx = idx\n end\n end\n \n path2 += min2\n end\n\n path1 < path2 ? path1 : path2\nend",
"def find_path(source, target, map)\n @main_loop_count = 0\n\n max_y = map.size - 1\n max_x = map[0].size - 1\n target_x = target[0]\n target_y = target[1]\n # target heuristic is 0\n target = [target_x, target_y, 0]\n\n # Sets up the search to begin from the source\n source = source.dup.push((target_x - source[0]).abs + (target_y - source[1]).abs)\n came_from = {}\n came_from[source] = nil\n frontier = [source]\n\n # Until the target is found or there are no more cells to explore from\n until came_from.has_key?(target) || frontier.empty?\n @main_loop_count += 1\n\n # Take the next frontier cell\n new_frontier = frontier.shift\n\n # Find the adjacent neighbors\n adjacent_neighbors = []\n\n # Gets all the valid adjacent_neighbors into the array\n # From southern neighbor, clockwise\n nfx = new_frontier[0]\n nfy = new_frontier[1]\n adjacent_neighbors << [nfx , nfy - 1, (target_x - nfx).abs + (target_y - nfy + 1).abs] unless nfy == 0\n adjacent_neighbors << [nfx - 1, nfy - 1, (target_x - nfx + 1).abs + (target_y - nfy + 1).abs] unless nfx == 0 || nfy == 0\n adjacent_neighbors << [nfx - 1, nfy , (target_x - nfx + 1).abs + (target_y - nfy).abs] unless nfx == 0\n adjacent_neighbors << [nfx - 1, nfy + 1, (target_x - nfx + 1).abs + (target_y - nfy - 1).abs] unless nfx == 0 || nfy == max_y\n adjacent_neighbors << [nfx , nfy + 1, (target_x - nfx).abs + (target_y - nfy - 1).abs] unless nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy + 1, (target_x - nfx - 1).abs + (target_y - nfy - 1).abs] unless nfx == max_x || nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy , (target_x - nfx - 1).abs + (target_y - nfy).abs] unless nfx == max_x\n adjacent_neighbors << [nfx + 1, nfy - 1, (target_x - nfx - 1).abs + (target_y - nfy + 1).abs] unless nfx == max_x || nfy == 0\n\n new_neighbors = adjacent_neighbors.select do |neighbor|\n # That have not been visited and are not walls\n unless came_from.has_key?(neighbor) || map[neighbor[1]][neighbor[0]] != '.'\n # Add them to the frontier and mark them as visited\n # frontier << neighbor\n came_from[neighbor] = new_frontier\n end\n end\n\n # Sort the frontier so cells that are close to the target are then prioritized\n if new_neighbors.length > 0\n new_neighbors = merge_sort(new_neighbors)\n if frontier.length > 0 && new_neighbors[0][2] >= frontier[0][2]\n frontier = merge_sort(new_neighbors.concat(frontier))\n else\n frontier = new_neighbors.concat(frontier)\n end\n end\n end\n\n # If the search found the target\n if came_from.has_key?(target)\n # Calculates the path between the target and star for the greedy search\n # Only called when the greedy search finds the target\n path = []\n next_endpoint = came_from[target]\n while next_endpoint\n path << [next_endpoint[0], next_endpoint[1]]\n next_endpoint = came_from[next_endpoint]\n end\n path\n else\n return nil\n end\n end",
"def longest_path_1(edges)\nend",
"def problem_107\n if false\n net = [ \"-,16,12,21,-,-,-\", \"16,-,-,17,20,-,-\", \"12,-,-,28,-,31,-\",\n \"21,17,28,-,18,19,23\", \"-,20,-,18,-,-,11\", \"-,-,31,19,-,-,27\",\n \"-,-,-,23,11,27,-\" ]\n net.map! {|line| line.split(/,/).map {|i| i == '-' ? nil : i.to_i}}\n else\n net = []\n open(\"network.txt\").each do |line|\n net << line.chomp.split(/,/).map {|i| i == '-' ? nil : i.to_i}\n end\n end\n\n # Reformat into an array of nodes, with the their connections\n nodes = Hash.new {|h,k| h[k] = Hash.new }\n net.each_with_index do |row,i| # Each nodes is connected to...\n row.each_index do |col| # For each possible connection....\n # Add the node we are connected to and the cost\n nodes[i][col] = row[col] if row[col]\n end\n end\n\n initial = nodes.reduce(0) do |a,row|\n row[1].reduce(a) {|aa,p| aa + p[1] }\n end / 2\n # add to the 'borg' that is node0\n node0,node0_links = nodes.shift\n ans = []\n node0_contains = Hash.new\n node0_contains[node0] = true\n\n # What we do select the lowest link, the 'merge' it into node0, repeat\n while nodes.length > 0\n n,v = node0_links.min {|a,b| a[1] <=> b[1]}\n ans << [n,v] # Save the link for the answer\n node0_contains[n] = true # add to the 'borg' that is node0\n nodes[n].each_pair do |k,a| # Now merge in new poin, update vertexs\n next if node0_contains[k]\n node0_links[k] = [a, node0_links[k] || 1_000_000].min\n end\n nodes.delete(n) # Remove from free nodes\n node0_links.delete(n) # Remove from vertexes to resolve\n end\n\n now = ans.reduce(0) {|a,v| a + v[1]}\n puts \"initial = #{initial}\"\n puts \"now = #{now}\"\n initial - now\nend",
"def best_colour\n build_block_list\n\n edges = []\n\n @tl_list.each do |col, row|\n neighbours(col, row).each do |c, r|\n col = @blocks[r][c]\n edges << [col, c, r] if col != @tlc && !edges.include?([col, c, r])\n end\n end\n\n max_colour_count(edges)\n end",
"def find_order_bfs\n queue = []\n @num_courses.times { |v| queue.push(v) if @in_degrees[v].zero? } # 入度为0的全都放入\n\n visited = []\n until queue.empty?\n node_key = queue.shift\n\n visited.unshift(node_key) # 注意顺序\n\n @nodes[node_key]&.each do |neighbor|\n @in_degrees[neighbor] -= 1\n queue.push(neighbor) if @in_degrees[neighbor].zero?\n end\n end\n\n visited.size == @num_courses ? visited : []\n end",
"def bfs(starting_node, target_value)\n queue = [starting_node]\n checked_nodes = Set.new\n\n until queue.empty?\n current = queue.shift\n unless checked_nodes.include?(current)\n checked_nodes.add(current)\n return current if current.value == target_value\n queue += current.neighbors\n end\n end\n nil\nend",
"def bfs(starting_node, target_value)\n queue = [starting_node]\n visited = Set.new()\n\n starting_node.neighbors.each do |neighb_nodes|\n\n return queue.first.value if queue.first.value == target_value\n\n visited.add(queue.shift) \n\n queue.push(neighb_nodes) unless visited.include?(neighb_nodes)\n \n end\n nil\nend",
"def floodfill(pixel, target_color, replacement_color)\n return unless pixel\n return if pixel.color == replacement_color\n return if pixel.color != target_color\n return if target_color != BLANK_COLOR && @pixel_lock # don't replace non-blank pixels with color if pixels are locked\n\n pixel.color = replacement_color\n @canvas_changed = true\n\n # UP\n _pixel = get_pixel_at(pixel.x, pixel.y - @grid_pixel_size)\n floodfill(_pixel, target_color, replacement_color)\n\n # DOWN\n _pixel = get_pixel_at(pixel.x, pixel.y + @grid_pixel_size)\n floodfill(_pixel, target_color, replacement_color)\n\n # LEFT\n _pixel = get_pixel_at(pixel.x - @grid_pixel_size, pixel.y)\n floodfill(_pixel, target_color, replacement_color)\n\n # RIGHT\n _pixel = get_pixel_at(pixel.x + @grid_pixel_size, pixel.y)\n floodfill(_pixel, target_color, replacement_color)\n end",
"def color_floodfill(x, y, fill)\n target = pixel_color(x, y)\n color_flood_fill(target, fill, x, y, Magick::FloodfillMethod)\n end",
"def build_graph(node = @root)\n node.make_knights(@target)\n if node.connected_knights.empty?\n return\n else\n node.connected_knights.each do |knight|\n build_graph(knight)\n end\n end\n end",
"def bfs(starting_node, target_value)\n visited = Set.new()\n queue = [starting_node]\n until queue.empty?\n dequeued = queue.shift\n return dequeued if dequeued.val == target_value\n visited.add(dequeued)\n dequeued.neighbors.each do |neighbor|\n queue << neighbor unless visited.include?(neighbor)\n end\n end\n nil\nend",
"def flood4 x, y, new_color, old_color = nil\n color = get(x,y)\n old_color ||= color\n return if x < 1 || y < 1 || x > @width || y > @height || color == new_color || color != old_color\n\n set x, y, new_color\n\t\tflood4 x+1, y, new_color, old_color\n\t\tflood4 x-1, y, new_color, old_color\n\t\tflood4 x, y+1, new_color, old_color\n\t\tflood4 x, y-1, new_color, old_color\n end",
"def bfs_graph(graph, target, visited = Set.new)\n graph.graph.each do |g|\n val = bfs_helper(g, target, visited)\n if (!val.nil?)\n return val\n end\n end\n nil\nend",
"def test_05\n @dg = DiGraph.new([0,7],[1,9],[1,4],[7,4],[7,0],[7,9],[3,7],[9,4],[9,7],[9,9],[4,1],[4,4],[4,7])\n @paths = Hash.new\n @paths[0] = [7]\n @paths[1] = [9,4]\n @paths[7] = [4,0,9]\n @paths[3] = [7]\n @paths[9] = [4,7,9]\n @paths[4] = [1,4,7]\n @nodes = @paths.keys\n received_dg = @dg.strongly_connected_component_including_node(0);\n filled_dg = DiGraph.new(*fill(0));\n if (not filled_dg.equal?(received_dg))\n puts \"test_05 failed...\"\n puts \"DiGraph => #{@dg.to_s}\"\n puts \"node => 0\"\n puts \"expected => #{filled_dg.to_s}\"\n puts \"received => #{received_dg.to_s}\"\n end\n assert_equal(true,filled_dg.equal?(received_dg))\n end",
"def guide(from, to, unit_type=nil, max_depth=400)\n return nil if @map.blocked?(from, unit_type) || @map.blocked?(to, unit_type)\n from_element = PathElement.new(from)\n from_element.dist_from = @map.distance(from,to)\n open = PrioritySet.new\n open.push from_element, from_element.rating\n closed = SplayTreeMap.new\n step = 0\n\n until open.empty? || step > max_depth\n step += 1\n\n current_element = open.pop\n @nodes_considered += 1\n\n loc = current_element.location\n if @map.cost(loc,to) == 0\n path = []\n until current_element.parent.nil?\n path.unshift current_element\n current_element = current_element.parent\n end\n\n return path\n else\n closed.push loc, current_element\n @map.neighbors(loc).each do |next_door|\n if closed.has_key? next_door\n next\n end\n \n el = PathElement.new(next_door,current_element)\n\n if @map.blocked? next_door, unit_type\n closed.push el.location, el\n else\n current_rating = current_element.cost_to + @map.cost(loc, next_door)\n\n # add to open\n el.cost_to = current_rating\n el.dist_from = @map.distance(next_door,to)\n el.reset_rating\n\n open.push el, el.rating\n end\n end\n end\n end\n nil\n end",
"def find_reachable_adjacents\n\t\tfind_all_adjacents.select { |p| (is_free?(p) && !@closed.include?(p)) }\n\tend",
"def guide(from, to, unit_type=nil, max_depth=400)\n return nil if @map.blocked?(from, unit_type) || @map.blocked?(to, unit_type)\n from_element = PathElement.new(from)\n from_element.dist_from = @map.distance(from,to)\n open = PriorityQueue.new { |x, y| (x <=> y) == -1 }\n open.push from_element, from_element.rating\n closed = SplayTreeMap.new\n step = 0\n \n until open.empty? || step > max_depth\n step += 1\n \n current_element = open.pop\n @nodes_considered += 1\n \n loc = current_element.location\n if @map.cost(loc,to) == 0\n path = []\n until current_element.parent.nil?\n path.unshift current_element\n current_element = current_element.parent\n end\n\n return path\n else\n closed.push loc, current_element\n @map.neighbors(loc).each do |next_door|\n next if closed.has_key? next_door\n\n el = PathElement.new(next_door,current_element)\n\n if @map.blocked? next_door, unit_type\n closed.push el.location, el\n else\n current_rating = current_element.cost_to + @map.cost(loc, next_door)\n\n # add to open\n el.cost_to = current_rating\n el.dist_from = @map.distance(next_door,to)\n \n open.push el, el.rating\n end\n end\n end\n end\n nil\n end",
"def identify_neighbours\n @x.times{ |r|\n @y.times{|c| \n #+1,+1 0,+1 +1,0\n @mat[r][c].add_neighbour @mat[r+1][c+1] unless @mat[r+1].nil? || @mat[r+1][c+1].nil?\n @mat[r][c].add_neighbour @mat[r][c+1] unless @mat[r].nil? || @mat[r][c+1].nil?\n @mat[r][c].add_neighbour @mat[r+1][c] unless @mat[r+1].nil? || @mat[r+1][c].nil?\n \n #-1,-1 0,-1 -1,0\n @mat[r][c].add_neighbour @mat[r-1][c-1] unless @mat[r-1].nil? || @mat[r-1][c-1].nil?\n @mat[r][c].add_neighbour @mat[r-1][c] unless @mat[r-1].nil? || @mat[r-1][c].nil?\n @mat[r][c].add_neighbour @mat[r][c-1] unless @mat[r].nil? || @mat[r][c-1].nil?\n \n #+1,-1 -1,+1\n @mat[r][c].add_neighbour @mat[r-1][c+1] unless @mat[r-1].nil? || @mat[r-1][c+1].nil?\n @mat[r][c].add_neighbour @mat[r+1][c-1] unless @mat[r+1].nil? || @mat[r+1][c-1].nil?\n \n }\n \n } \n end",
"def generate_full required_depth \n generate( [:cyclic], required_depth )\n end",
"def test_06\n @dg = DiGraph.new([5,9],[0,3],[3,8],[8,9],[9,0])\n @paths = Hash.new\n @paths[5] = [9]\n @paths[0] = [3]\n @paths[3] = [8]\n @paths[8] = [9]\n @paths[9] = [0]\n @nodes = @paths.keys\n received_dg = @dg.strongly_connected_component_including_node(0);\n filled_dg = DiGraph.new(*fill(0));\n if (not filled_dg.equal?(received_dg))\n puts \"test_06 failed...\"\n puts \"DiGraph => #{@dg.to_s}\"\n puts \"node => 0\"\n puts \"expected => #{filled_dg.to_s}\"\n puts \"received => #{received_dg.to_s}\"\n end\n assert_equal(true,filled_dg.equal?(received_dg))\n end",
"def bfs(starting_node, target_value)\n return starting_node if starting_node.value == target_value\n queue = [starting_node]\n until queue.empty?\n queue += starting_node.neighbors\n queue.each { |neighbor| bfs(neighbor, tar) }\n end\n nil\nend",
"def depth_first_search\n visited = {}\n timestamp = {}\n tree_edges = {}\n back_edges = {}\n cross_edges = {}\n forward_edges = {}\n count = 0\n\n # begin workaround removing depencency to order of Hash#each\n if @index.empty? then\n preference_of_nodes = nil\n else\n preference_of_nodes = {}.merge(@index)\n i = preference_of_nodes.values.max\n @graph.each_key do |node0|\n preference_of_nodes[node0] ||= (i += 1)\n end\n end\n # end workaround removing depencency to order of Hash#each\n\n dfs_visit = Proc.new { |from|\n visited[from] = true\n timestamp[from] = [count += 1]\n ary = @graph[from].keys\n # begin workaround removing depencency to order of Hash#each\n if preference_of_nodes then\n ary = ary.sort_by { |node0| preference_of_nodes[node0] }\n end\n # end workaround removing depencency to order of Hash#each\n ary.each do |to|\n if visited[to]\n if timestamp[to].size > 1\n if timestamp[from].first < timestamp[to].first\n \t# forward edge (black)\n \tp \"#{from} -> #{to} : forward edge\" if $DEBUG\n \tforward_edges[from] = to\n else\n \t# cross edge (black)\n \tp \"#{from} -> #{to} : cross edge\" if $DEBUG\n \tcross_edges[from] = to\n end\n else\n # back edge (gray)\n p \"#{from} -> #{to} : back edge\" if $DEBUG\n back_edges[from] = to\n end\n else\n # tree edge (white)\n p \"#{from} -> #{to} : tree edge\" if $DEBUG\n tree_edges[to] = from\n dfs_visit.call(to)\n end\n end\n timestamp[from].push(count += 1)\n }\n\n ary = @graph.keys\n # begin workaround removing depencency to order of Hash#each\n if preference_of_nodes then\n ary = ary.sort_by { |node0| preference_of_nodes[node0] }\n end\n # end workaround removing depencency to order of Hash#each\n ary.each do |node|\n unless visited[node]\n dfs_visit.call(node)\n end\n end\n return timestamp, tree_edges, back_edges, cross_edges, forward_edges\n end",
"def dfs_recursive(vertex, goal_vertex)\n @stack.push(vertex) # Add vertex to frontier\n return 1 if vertex == goal_vertex # If goal_vertex is reached, return 1. ! Not necessarily shortest path !\n @explored[vertex.label] = true # Mark vertex as being explored\n vertex.edges.each { |edge| # Expand current vertex\n unless @explored.has_key? edge.label # If already explored, then ignore the vertex\n return 1 if dfs_recursive(edge, goal_vertex) == 1 # Recursively do depth_first on the vertices\n end\n }\n @stack.pop() #Backtracking so popping the vertex from the stack\n end",
"def fewest_edges(start, finish)\n queue = [start]\n path, dequeue = [], []\n visited, distance, previous = {}, {}, {}\n infinity = (2**(0.size * 8 - 2) - 1) # max Fixnum integer value\n adj_lists.each do |v|\n visited[v.name] = false\n distance[v.name] = infinity\n previous[v.name] = nil\n end\n distance[start] = 0\n cyclic = start == finish # if start/end with same vertex\n visited[start] = true if !cyclic\n loops = 0\n\n while !queue.empty?\n loops += 1\n current = queue.shift # queue is FIFO\n dequeue << current # array of dequeued vertices\n puts \"\\ncurrent = #{current}, queue = #{queue}\"\n\n if current == finish\n break if !cyclic\n break if loops > 1 # if cyclic\n end\n\n adj_vertices(current, adj_lists).each do |adj_vertex|\n if !visited[adj_vertex]\n visited[adj_vertex] = true\n queue << adj_vertex\n distance[adj_vertex] = distance[current] + 1\n previous[adj_vertex] = current\n puts \"adjacent vertex = #{adj_vertex}, queue = #{queue}\"\n # print \"visited = #{visited}\\n\"\n # print \"distance = #{distance}\\n\"\n end\n end\n end\n print_graph\n print \"Dequeued vertices: #{dequeue}\\n\"\n path = [finish]\n vname = finish\n while previous[vname]\n path << previous[vname]\n vname = previous[vname]\n previous[start] = nil if cyclic\n end\n path = path.reverse\n puts \"\\nShortest distance from #{start} to #{finish}: #{distance[finish]} edges.\"\n print \"Path: #{path}\\n\\n\"\n\n distance[finish]\n end",
"def compute(source, num_nodes)\n x = [source]\n source.length = 0\n until x.length == num_nodes\n min_edge = nil\n min_distance = Float::INFINITY\n x.each do |xnode|\n xnode.outgoing_edges.each do |xedge|\n next if xedge.visited?\n curr_distance = xnode.length + xedge.distance\n if curr_distance <= min_distance\n min_distance = curr_distance\n min_edge = xedge\n end\n end\n end\n min_edge.head.length = min_distance\n x << min_edge.head\n end\n x\nend",
"def bfs(target)\n visited = {}\n @graph.keys.each { |key| visited[key] = false }\n node = @graph.keys[0]\n queue = Queue.new\n queue << node\n while !(queue.length == 0)\n visited[node] = true\n puts \"node is #{node}\"\n return node if node == target\n @graph[node].each do |nabe|\n queue << nabe unless visited[nabe] == true\n end\n node = queue.pop\n end\n end",
"def omit_degree_2_nodes\r\n # add all nodes into a queue\r\n # queue = put all nodes from @nodes into the queue\r\n # puts \"#{@vertices}\"\r\n queue = Queue.new\r\n @vertices.each do |node|\r\n queue << node\r\n end\r\n\r\n # iterate through all nodes until queue is not empty\r\n while ! queue.empty?\r\n # take the first node number from the queue\r\n # i = queue.deque()\r\n # take the first node itself\r\n node=queue.pop\r\n\r\n # puts \"osm_id=#{node.osm_id} degree=#{node.degree}\"\r\n # puts \"node neighbours #{node.neighbours}\"\r\n # do anything only iff this node's degree == 2\r\n if node.degree == 2\r\n # take the node's neighbours and the two edges going from the node\r\n # we would like to shrink these two edges into only one while isolating\r\n # the _node_\r\n v1_nr = node.neighbours[0]\r\n e1_nr = node.edges[0]\r\n v2_nr = node.neighbours[1]\r\n e2_nr = node.edges[1]\r\n\r\n #puts \"actual node: #{node.osm_id} , actual neighbours #{v1_nr} , #{v1_nr}\"\r\n #puts \"neigbours of #{node.osm_id}: #{v1_nr.osm_id} #{v2_nr.osm_id}\" if (node.neighbours.length==2)\r\n next if node.neighbours.length!=2\r\n\r\n # IMPORTANT!\r\n # however, if there was a cycle, which means that the node's neighbours\r\n # ARE already connected, do nothing and leave this degree-2-node _i_ as\r\n # it is!\r\n\r\n #puts \"are connected #{v1_nr}, #{v2_nr} of #{node.osm_id}?\"\r\n next if are_connected(v1_nr, v2_nr, node.osm_id)\r\n\r\n #puts \"handling #{node.osm_id} - has 2 and is not cyclic, going to delete neighbours!\"\r\n #puts \"cur_node is: #{node.osm_id}\"\r\n\r\n #puts \"# this is not needed, but just for sure: record the neighbours' degrees before the shrinkage\"\r\n #v1_deg = v1_nr.degree ; v2_deg = v2_nr.degree\r\n #puts \" -> neighbours degree: v1:#{v1_deg} v2:#{v2_deg}\"\r\n\r\n #puts \"# record the neighbours' OSM/id, for future use\"\r\n #v1_osm = v1_nr.osm_id ; v2_osm = v2_nr.osm_id\r\n #puts \" -> v1_osm: #{v1_osm} deg: #{v1_deg} :: v2_osm #{v2_osm} deg: #{v2_deg}\"\r\n\r\n #puts \"# invalidate the two edges -- particularly, do not output them into Graphviz output\"\r\n e1_nr.invalidate\r\n e2_nr.invalidate\r\n e_distance=e1_nr.time_distance+e2_nr.time_distance\r\n\r\n #puts \" -> invalidated edges - #{e1_nr} #{e1_nr.osm_from}-#{e1_nr.osm_to}(#{e1_nr.is_valid}) #{e2_nr} #{e2_nr.osm_from}-#{e2_nr.osm_to}(#{e2_nr.is_valid})\"\r\n #puts \"# disconnect the triple v1--i--v2, i.e. leave out the neighbours from\r\n # the nodes' own neighbours' lists\"\r\n #ns=[] ; v1_nr.neighbours.each do |n| ns << \"#{n.osm_id}\" end; puts \"old v1 neighbours : #{ns}\"\r\n #ns=[] ; v2_nr.neighbours.each do |n| ns << \"#{n.osm_id}\" end; puts \"old v2 neighbours : #{ns}\"\r\n #ns=[] ; node.neighbours.each do |n| ns << \"#{n.osm_id}\" end; puts \"old v neighbours : #{ns}\"\r\n\r\n node.disconnect_neighbour(v1_nr)\r\n node.disconnect_neighbour(v2_nr)\r\n v2_nr.disconnect_neighbour(node)\r\n v1_nr.disconnect_neighbour(node)\r\n node.invalidate\r\n\r\n #puts \"Disconnect edges from nodes\"\r\n #ns=[] ; v1_nr.edges.each do |n| ns << \"#{n.osm_from}-#{n.osm_to}(#{n.is_valid})\" end; puts \" -> old v1 neighbours : #{ns}\"\r\n #ns=[] ; v2_nr.edges.each do |n| ns << \"#{n.osm_from}-#{n.osm_to}(#{n.is_valid})\" end; puts \" -> old v2 neighbours : #{ns}\"\r\n v1_nr.disconnect_edge(e1_nr)\r\n v2_nr.disconnect_edge(e2_nr)\r\n\r\n #puts \" # create a new edge going from v1 into v2 (it does not matter in which direction, it is anyway an artificial/virtual edge\"\r\n # save this Edge into the array @edges\r\n v_nr = @vertices.length\r\n e = Edge.new(v1_nr.osm_id, v2_nr.osm_id, 0, v_nr, e1_nr.name, e1_nr.maxspeed, e1_nr.is_oneway, e_distance)\r\n\r\n #puts (\"new edge from #{v1_nr.osm_id} to #{v2_nr.osm_id}\")\r\n @edges.push(e)\r\n\r\n #puts \"#add edge to vertex\"\r\n #ns=[] ; v1_nr.edges.each do |n| ns << \"#{n.osm_from}-#{n.osm_to}(#{n.is_valid})\" end; puts \"old v1 edges : #{ns}\"\r\n #ns=[] ; v2_nr.edges.each do |n| ns << \"#{n.osm_from}-#{n.osm_to}(#{n.is_valid})\" end; puts \"old v2 edges : #{ns}\"\r\n v1_nr.add_edge(e)\r\n v2_nr.add_edge(e)\r\n\r\n #add linkeds to vetexes\r\n v1_nr.connect_neighbour(v2_nr)\r\n v2_nr.connect_neighbour(v1_nr)\r\n end\r\n end\r\n end",
"def test_07\n @dg = DiGraph.new([0,0],[6,0],[6,8],[2,6],[8,8],[3,4],[3,2],[3,9],[9,4],[9,6],[4,3],[4,8])\n @paths = Hash.new\n @paths[0] = [0]\n @paths[6] = [0,8]\n @paths[2] = [6]\n @paths[8] = [8]\n @paths[3] = [4,2,9]\n @paths[9] = [4,6]\n @paths[4] = [3,8]\n @nodes = @paths.keys\n received_dg = @dg.strongly_connected_component_including_node(6);\n filled_dg = DiGraph.new(*fill(6));\n if (not filled_dg.equal?(received_dg))\n puts \"test_07 failed...\"\n puts \"DiGraph => #{@dg.to_s}\"\n puts \"node => 6\"\n puts \"expected => #{filled_dg.to_s}\"\n puts \"received => #{received_dg.to_s}\"\n end\n assert_equal(true,filled_dg.equal?(received_dg))\n end",
"def count(g, u, v)\n g.vertices.each do |v|\n v.data = 0\n v.parent = nil\n end\n\n dfs_count(g, u, v)\n v.data\nend",
"def oxygen_fill\n discover_map\n\n # Location + level\n oxygen_locations = [[@map.oxygen_location, 0]]\n visited = Set.new(@map.oxygen_location)\n\n max_level = -1\n\n until oxygen_locations.empty?\n loc, level = oxygen_locations.shift\n max_level = [max_level, level].max\n\n @map.points[loc] = :oxygen\n @map.display if @display\n\n @map.valid_neighbours(loc).each do |neighbour_loc|\n next if visited.include?(neighbour_loc)\n\n oxygen_locations << [neighbour_loc, level + 1]\n visited << neighbour_loc\n end\n end\n\n max_level\n end",
"def dfs(node, discovery_time, parent)\n puts \"Enter dfs: node=#{node}, discovery_time=#{discovery_time}, parent=#{parent};\" if @d\n # if the low is not yet discovered for this onde\n if @n == @lows[node]\n # 2. default it tot the depth or discovery time of this node.\n @lows[node] = discovery_time # ! looks like here.\n # iterate over neighbors.\n puts \"Working iwth #{node} and #{@graph[node].inspect};\" if @d\n @graph[node].each do |neighbor|\n # all neightbos except parent.\n next if neighbor == parent\n exptected = discovery_time + 1\n actual = dfs(neighbor, exptected, node)\n if actual >= exptected\n @critical.push([node,neighbor])\n end\n @lows[node] = actual if actual < @lows[node]\n end\n end\n return @lows[node]\nend",
"def bridge\n visited = {}\n disc = [Float::INFINITY] * @V\n low = [Float::INFINITY] * @V\n parent = [-1] * @V\n (0...@V).each{|u|\n bridgeUtil(u, visited, parent, low, disc)\n }\n @answer\n\n end",
"def bfs(graph, starting_point)\n q = Queue.new()\n q.enq(starting_point)\n visited = [] \n loop do \n node = q.deq\n visited.push(node) unless visited.include?(node) \n graph.values[node].each{ |x| q.enq(x) }\n break if visited.length == graph.length\n end \n visited\n end",
"def path_finder(start_node=START_NODE, goal_node=GOAL_NODE)\n\t\n\t# INITIALIZE\n\tvalid = valid_nodes # largest set\n\treachable = [start_node] # nodes we can reach from current node\n\texplored = [] # nodes we've already considered\n\t# nodes reachable, valid, and not explored\n\topen_nodes = valid.select{|node| reachable.include?(node)}.select{|node| !explored.include?(node)} \n\t# record node path {node => previous_node}\n\tnodes_path = {start_node => nil} \n\t\n\twhile !open_nodes.empty?\n # node = choose_node(reachable)\n\t\tnode = open_nodes.sample # random node in open_nodes\n\t\t\n\t\treturn build_path(goal_node, nodes_path) if node==goal_node # STOP if reached goal! \n \n # Don't repeat ourselves.\n reachable.delete(node) # remove current node from reachable\n explored.push(node) # add node to explored\n \n # What nodes are now open from this node?\n # Adjacent, not in explored, and valid (not an obstacle and in maze)\n new_reachable = (get_adjacent_nodes(node) - explored) & valid\n\t\t# ADD new nodes to reachable\n new_reachable.each do |adj_node|\n if !reachable.include?(adj_node)\n # adjacent.previous = node # Remember how we got there.\n nodes_path[adj_node] = node # {[0,3] => [0,2]}\n reachable << adj_node\n end\n end\n \n\t\t# REFRESH OPEN NODES\n open_nodes = valid.select{|node| reachable.include?(node)}.select{|node| !explored.include?(node)} \n \n end\n \n\treturn nil # open_nodes empty - no path found\nend",
"def findMaximum(weights)\n\t\n\tputs \"Weights\" if DEBUG_OUTPUT\n\tprintMatrix(weights) if DEBUG_OUTPUT\n\t# l(x) == l[x]\n\t\t\n\teq = EqualityGraph.new(weights)\n\teq.generateLabelFunctions()\n\t\n\t#Generate equality graph\n\t\n\teq.generateEqualityGraph()\n\t\n\t#Pick an abitrary matching in the equality subgraph\n\t\n\teq_match = MatchGraph.new(eq.x_vertices, eq.y_vertices)\n\t\n\teq.initialMatch(eq_match)\t\n\t\n\tputs \"Equality Match\\n#{eq_match.to_s}\" if DEBUG_OUTPUT\n\t\n\t#puts \"Is Equality Match perfect? #{eq_match.isPerfectMatch}\" if DEBUG_OUTPUT\n\t\t\t\n\tuntil(eq_match.isPerfectMatch)\n\t\t#Pick a free vertex in X\n\t\tfreeX = eq_match.get_free_x_vertex\n\t\t\n\t\teq_match.alt_tree_x_nodes.push(freeX)\n\t\t\t\n\t\tputs \"\\nMAJOR STEP Picked a free X: #{freeX}\" if DEBUG_OUTPUT\n\t\t\n\t\ts_vertices = [ freeX ]\n\t\tt_vertices = Array.new\n\t\t\n\t\t#Though sets s and t should be enough, will keep track of the alternating paths \n\t\t#originating at freeX\n\t\t\n\t\t\n\t\ts_neighbors = eq.get_neighbors_of_x_vertices(s_vertices).to_set\n\t\t\n\t\ts_neighbors_not_in_t = s_neighbors.to_a\n\t\t\n\t\tuntil(false)\n\t\t\tputs \"S = #{s_vertices.to_a} N(S) = #{s_neighbors.to_a} T= #{t_vertices.to_a}\" if DEBUG_OUTPUT\n\t\t\t\t\n\t\t\tif s_neighbors.size == t_vertices.size\n\t\t\t\tputs \"\\nSTEP No more s_neighbors to process, growing eq\" if DEBUG_OUTPUT\n\t\t\t\told_size = s_neighbors.size\n\t\t\t\t\n\t\t\t\teq.growEqualityGraph(s_vertices, t_vertices, s_neighbors, s_neighbors_not_in_t)\n\t\t\t\t\n\t\t\t\traise \"s neighbors did not increase\" if s_neighbors.size <= old_size\t\t\t\t\t\t\n\t\t\telse\n\t\t\t\tputs \"\\nSTEP Picking a new Y not yet in T from S neighbors\" if DEBUG_OUTPUT\n\t\t\t\t#pick y\n\t\t\t\ty = s_neighbors_not_in_t.pop #(s_neighbors - t_vertices).find { true } \n\t\t\t\tif eq_match.is_y_vertex_free(y)\n\t\t\t\t\t#Reset S and T\n\t\t\t\t\traise \"T and S are out of wack\" if s_vertices.size != t_vertices.size + 1\t\t\t\t\t\n\t\t\t\t\teq_match = growMatch(y, eq_match, eq, freeX)\n\t\t\t\t\tputs \"Grew match Equality Graph was #{eq}\" if DEBUG_OUTPUT\n\t\t\t\t\tbreak\n\t\t\t\telse\n\t\t\t\t\tputs \"y[#{y}] is matched\" if DEBUG_OUTPUT\n\t\t\t\t\tnew_s_node = growTree(s_vertices, t_vertices, y, eq, eq_match)\n\t\t\t\t\t\n\t\t\t\t\tnew_s_neighbors = eq.get_neighbors_of_x_vertices( [new_s_node] )# - t_vertices\n\t\t\t\t\ts_neighbors.merge( new_s_neighbors )\n\t\t\t\t\t#new_s_neighbors could intesect with t\n\t\t\t\t\ts_neighbors_not_in_t = (s_neighbors - t_vertices).to_a\n\t\t\t\tend\n\t\t\tend \n\t\tend\n\tend\n\t\n\tputs \"Sum is #{eq_match.sumEdgeWeights(weights)}\" if DEBUG_OUTPUT\n\t\n\treturn eq_match.sumEdgeWeights(weights)\nend",
"def bfs(graph, s)\n queue = [s]\n @visited[s] = true\n @dist[s] = 0\n w = nil\n while not queue.empty?\n w = queue.delete_at(0)\n graph.adj(v).each do |edge|\n w = edge.to\n if not @visited[w]\n @path[w] = v\n @dist[w] = @dist[v] + 1\n @visited[w] = true\n queue << w\n end\n end\n end\n end",
"def shortest_path(from_x, from_y, to_x, to_y)\n @visited = Array.new(@matrix.size) { Array.new(@matrix.first.size) { false } }\n @farthest_node = nil\n queue = Queue.new\n queue << Node.new(from_x, from_y, 0)\n\n while !queue.empty? do\n node = queue.pop\n\n if !@farthest_node || node.dist > @farthest_node.dist\n @farthest_node =node\n end\n\n if node.x == to_x && node.y == to_y\n # We pathed to the target\n target_node = node\n break\n end\n [[-1,0],[1,0],[0,1],[0,-1]].each do |dir|\n x = node.x + dir[0]\n y = node.y + dir[1]\n if is_valid?(x, y)\n @visited[y][x] = true\n queue.push(Node.new(x, y, node.dist + 1, node))\n end\n end\n end\n\n # We didn't find a path to the target\n return nil unless target_node\n\n # Trace back the journey\n journey = []\n journey.push [node.x,node.y]\n while !node.parent.nil? do\n node = node.parent\n journey.push [node.x,node.y]\n end\n journey.reverse.drop(1)\n end",
"def max_matching(left, right)\n g = Graph.new\n left.each do |v|\n g.add_vertex v\n end\n right.each do |v|\n g.add_vertex v\n end\n source = Vertex.new \"source\"\n g.add_vertex source\n sink = Vertex.new \"sink\"\n g.add_vertex sink\n capacity_table = {\n source => {},\n sink => {}\n }\n left.each do |v| \n g.add_edge Edge.new(source, v)\n capacity_table[source][v] = 1\n capacity_table[v] ||= {}\n end\n right.each do |v|\n g.add_edge Edge.new(v, sink)\n capacity_table[v] ||= {}\n capacity_table[v][sink] = 1\n end\n left.each do |v1|\n right.each do |v2|\n edge = @edges[v1].find { |e| e.to == v2 }\n if edge\n g.add_edge Edge.new(v1, v2)\n capacity_table[v1] ||= {}\n capacity_table[v1][v2] = 1\n end\n end\n end\n flow_table = g.max_flow(source, sink, capacity_table)\n flow_table.delete source\n flow_table.delete sink\n result = []\n flow_table.keys.each do |v1|\n flow_table[v1].delete sink\n flow_table[v1].keys.each do |v2|\n result << [v1, v2] if flow_table[v1][v2] == 1\n end\n end\n result\n end",
"def solve_bfs(initial, final)\n\tunvisited = [initial]\n\tvisited = Set.new unvisited\n\n\twhile not unvisited.empty?\n\t\tc = unvisited[0]\n\t\tunvisited.delete_at 0\n\n\t\treturn c.n_moves if c.eql? final\n\t\tneighbours = c.moves.select { |x| not visited.include? x }\n\t\tunvisited.concat(neighbours)\n\t\tvisited.merge neighbours\n\tend\n\tNO_SOLUTION\nend",
"def lesstrips_dfs(start, finish, max_distance, distance, visited, path, paths, cycles)\n adj_vertices(visited.last, adj_lists).each do |vertex|\n print \"Visited stack: #{visited}, Next vertex: #{vertex}\\n\"\n totald = distance + dist(visited.last, vertex)\n\n if visited.last == finish && cycles != \"NO CYCLES EXIST\"\n\n # try adding cycles\n\n visited_before_cycles = visited\n # picks expanded cycles that begin with finish vertex\n ec = expanded_cycles(cycles).select{|c| c.first == finish}\n\n # keep adding cycles till we reach max distance\n ec.each do |cycle1|\n visited, paths, break_loop = try_cycles(visited, cycle1, paths, 0, max_distance)\n visited1 = visited\n\n ec.each do |cycle2|\n begin\n visited, paths, break_loop = try_cycles(visited, cycle2, paths, 0, max_distance)\n end until break_loop\n visited = visited1\n end\n\n visited = visited_before_cycles\n end\n\n elsif !visited.include?(vertex) && totald != \"NO SUCH ROUTE\" && totald < max_distance\n visited << vertex\n path = visited\n distance = totald\n\n if vertex == finish\n paths << path\n print \"\\n*** Path: #{path}, Length: #{path_length(path)}\\n\\n\"\n visited.pop\n break\n end\n\n lesstrips_dfs(start, finish, max_distance, distance, visited, path, paths, cycles)\n visited.pop\n visited.pop if visited.size.between?(2, 3)\n visited = [start] if visited == []\n end\n end\n paths.size\n end",
"def incomplete_graph(n, completeness)\n g = GraphMatching::Graph::WeightedGraph.new\n 0.upto(n - 1) do |i| g.add_vertex(i) end\n max_weight = ((1..n - 1).reduce(:+).to_f * completeness).to_i + 1\n 0.upto(n - 2) do |i|\n (i + 1).upto(n - 1) do |j|\n next unless rand < completeness\n g.add_edge(i, j)\n w = rand(max_weight)\n g.set_w([i, j], w)\n end\n end\n g\nend",
"def dfs_graph(graph, target, visited = Set.new)\n graph.graph.each do |g|\n val = dfs_helper(g, target, visited)\n if (!val.nil?)\n return val\n end\n end\n nil\nend",
"def dfs1(graph, start_vertex)\n\tstack = [start_vertex]\n\tvisited = []\n\n\tuntil stack.empty?\n\t\tcurr_vertex = stack[-1]\n\n\t\tif !graph[curr_vertex] || graph[curr_vertex][0] \n\t\t\t$finishing_time += 1\n\t\t\t$magic_order[$finishing_time] = curr_vertex\n\t\t\tstack.pop\n\t\telse\n\t\t\tmore = []\n\t\t\tgraph[curr_vertex][0] = true\n\n\t\t\tif graph[curr_vertex][2..-1]\n\t\t\t\tgraph[curr_vertex][2..-1].each do |edge|\n\t\t\t\t\tif !graph[edge] && !visited.include?(edge)\n\t\t\t\t\t\tmore << edge\n\t\t\t\t\t\tvisited << edge\n\t\t\t\t\telsif !graph[edge]\n\t\t\t\t\t\tnext\n\t\t\t\t\telsif !graph[edge][0]\n\t\t\t\t\t\tmore << edge \n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tif more.empty?\n\t\t\t\t$finishing_time += 1\n\t\t\t\t$magic_order[$finishing_time] = curr_vertex\n\t\t\t\tstack.pop\n\t\t\telse\n\t\t\t\tstack.concat(more)\n\t\t\tend\n\t\tend\n\tend\nend",
"def bfs(graph, s)\n queue = [s]\n @visited[s] = true\n @dist[s] = 0\n w = nil\n while not queue.empty?\n w = queue.delete_at(0)\n graph.adj(v).each do |edge|\n w = edge.other(v)\n if not @visited[w]\n @path[w] = v\n @dist[w] = @dist[v] + 1\n @visited[w] = true\n queue << w\n end\n end\n end\n end",
"def path_layers limit=100\n layers = []\n\n remaining = @nodes.dup\n\n loop do\n raise 'Exceeded threshold of 100, graph contains loop!' if limit == 0\n break if remaining.empty?\n layer = []\n DirectedAdjacentGraph.reverse(remaining).each_pair do |dest_val, dest_node|\n if dest_node.empty?\n layer.push dest_val\n remaining.delete dest_val\n end\n end\n layers.push layer\n limit -= 1\n end\n\n layers\n end",
"def non_deterministic_recursive(vertex, goal_vertex)\n @stack.push(vertex) # Add vertex to frontier\n return 1 if vertex == goal_vertex # If goal_vertex is reached, return 1. ! Not necessarily shortest path !\n @explored[vertex.label] = true # Mark vertex as being explored\n vertex.edges.shuffle!.each { |edge| # Expand current vertex\n unless @explored.has_key? edge.label # If already explored, then ignore the vertex\n return 1 if non_deterministic_recursive(edge, goal_vertex) == 1 # Recursively do depth_first on the vertices\n end\n }\n @stack.pop() #Backtracking so popping the vertex from the stack\n end",
"def maximal_non_branching_paths(graph)\n <<-DOC\n A node v in a directed graph Graph is called a 1-in-1-out node if its indegree and outdegree are both equal to 1, \n i.e., in(v) = out(v) = 1. We can rephrase the definition of a \"maximal non-branching path\" from the main text \n as a path whose internal nodes are 1-in-1-out nodes and whose initial and final nodes are not 1-in-1-out nodes. \n Also, note that the definition from the main text does not handle the special case when Graph has a connected \n component that is an isolated cycle, in which all nodes are 1-in-1-out nodes.\n\n The MaximalNonBranchingPaths pseudocode below generates all non-branching paths in a graph. \n It iterates through all nodes of the graph that are not 1-in-1-out nodes and generates all non-branching \n paths starting at each such node. In a final step, MaximalNonBranchingPaths finds all isolated cycles in the graph.\n\n MaximalNonBranchingPaths(Graph)\n Paths ← empty list\n for each node v in Graph\n if v is not a 1-in-1-out node\n if out(v) > 0\n for each outgoing edge (v, w) from v\n NonBranchingPath ← the path consisting of the single edge (v, w)\n while w is a 1-in-1-out node\n extend NonBranchingPath by the outgoing edge (w, u) from w \n w ← u\n add NonBranchingPath to the set Paths\n for each isolated cycle Cycle in Graph\n add Cycle to Paths\n return Paths \n DOC\n\n paths = []\n\n in_degrees = {}\n out_degrees = {}\n # Calculating the indegree and outdegree for each node\n graph.values.flatten.each do |val|\n in_degrees[val] = 0 unless in_degrees.has_key?(val)\n in_degrees[val] += 1\n end\n graph.keys.each do |val|\n out_degrees[val] = graph[val].length\n end\n\n non_branch_path = \"\"\n\n one_in_one_out_nodes = []\n in_degrees.each do |k,v|\n if v == 1\n one_in_one_out_nodes << k if (out_degrees[k] == 1)\n end\n end\n\n # puts one_in_one_out_nodes\n nodes = []\n nodes = graph.keys\n graph.values.flatten.each {|v| nodes << v}\n nodes.uniq!\n\n v_index = 0\n loop do\n break if v_index == nodes.length\n v = nodes[v_index]\n\n if (one_in_one_out_nodes.include?(v))\n v_index += 1\n next\n else\n if (out_degrees[v] && (out_degrees[v] > 0))\n loop do\n break unless graph[v]\n break if graph[v].empty?\n w = graph[v][0]\n non_branch_path = v\n non_branch_path += w[-1]\n graph[v].delete_at(graph[v].index(w))\n graph.delete(v) if graph[v].length == 0\n while (w && graph[w] && in_degrees[w] && out_degrees[w] && in_degrees[w] == 1 && out_degrees[w] == 1) do\n u = graph[w][0]\n non_branch_path += u[-1]\n graph.delete(w)\n w = u\n end\n paths << non_branch_path\n # puts \"path:\" + non_branch_path\n non_branch_path = \"\"\n end\n else\n v_index += 1\n next\n end\n end\n v_index += 1\n end\n # puts paths\n paths.sort\n end",
"def connected?\n is_visited = []\n dfs(0) { |v,w| is_visited[w] = true }\n 0.upto(vertices-1) { |i| return false unless is_visited[i] }\n true\n end",
"def one_level\n improvement = false\n nb_passes = 0\n cur_mod = @graph.modularity\n new_mod = cur_mod\n begin\n cur_mod = new_mod\n nb_moves = 0\n nb_passes += 1\n @graph.nodes.shuffle.each do |node|\n orig_community = @graph.get_community node\n\n neighbour_communities = @graph.get_neighbour_comms node\n\n @graph.remove_node node, orig_community\n\n\n best_community = orig_community\n max_gain = 0.0\n\n neighbour_communities.each do |comm|\n mod_gain = @graph.modularity_gain node, comm\n if mod_gain > max_gain\n max_gain = mod_gain\n best_community = comm\n end\n end\n if best_community != orig_community\n nb_moves += 1\n improvement = true\n end\n\n @graph.insert_node node, best_community\n\n @graph.garbage_collect orig_community\n\n end\n new_mod = @graph.modularity\n end while nb_moves > 0 and new_mod - cur_mod >= MIN_INCREASE\n return improvement\n end",
"def fill_until(grid, target)\n limit = grid.size - 1\n # Four sides to do:\n # a b c\n # d • e\n # f g h\n\n # Right:\n (limit-1).downto(0) do |x|\n grid[x][limit] = [\n grid[x-1][limit-1].to_i, # a\n grid[x ][limit-1].to_i, # d\n grid[x+1][limit-1].to_i, # f\n grid[x+1][limit ].to_i, # g\n ].sum\n return grid[x][limit] if grid[x][limit] > target\n end\n\n # Top:\n (limit-1).downto(0) do |y|\n grid[0][y] = [\n grid[0 ][y+1].to_i, # e\n y.zero? ? 0 : grid[0+1][y-1].to_i, # f\n grid[0+1][y ].to_i, # g\n grid[0+1][y+1].to_i, # h\n ].sum\n return grid[0][y] if grid[0][y] > target\n end\n\n # Left:\n 1.upto(limit) do |x|\n grid[x][0] = [\n grid[x-1][0 ].to_i, # b\n grid[x-1][0+1].to_i, # c\n grid[x ][0+1].to_i, # e\n x == limit ? 0 : grid[x+1][0+1].to_i, # h\n ].sum\n return grid[x][0] if grid[x][0] > target\n end\n\n # Bottom:\n 1.upto(limit) do |y|\n grid[limit][y] = [\n y.zero? ? 0 : grid[limit-1][y-1].to_i, # a\n grid[limit-1][y ].to_i, # b\n grid[limit-1][y+1].to_i, # c\n y.zero? ? 0 : grid[limit ][y-1].to_i, # d\n ].sum\n return grid[limit][y] if grid[limit][y] > target\n end\n\n expand! grid\n fill_until(grid, target)\nend",
"def shortest_path_to_all_nodes(initial)\n initial.distance = 0\n\n current = initial\n loop do\n unvisited.delete(current)\n\n calculate_neighbor_shortest_distances(current)\n\n return graph.vertices if no_reachable_nodes\n\n current = unvisited.min_by(&:distance)\n end\n end",
"def bfs(start_node_num)\n node = find_node(start_node_num)\n _clear_visited\n ret_list = [node.value]\n # Your code here\n q = Queue.new\n q << node\n node.visited = true\n\n until q.empty?\n current = q.pop\n current.edges.each do |edge|\n next if edge.node_to.visited\n q << edge.node_to\n edge.node_to.visited = true\n ret_list << edge.node_to.value\n end\n end\n\n return ret_list\n end",
"def greedy2_fill!(remaining_partitions)\n remaining_partitions.each do |src_partition|\n src_partition.sites.each do |site|\n\n smallest_bin = self.update_bin_sizes!.min\n target_partition = smallest_bin.list[src_partition.name]\n if target_partition.nil?\n smallest_bin.add!([Partition.new(src_partition.name, [site], src_partition.tree)])\n else\n target_partition.incr_add_sites!([site])\n end\n\n end\n end\n end",
"def fill_poly(canvas, points, color)\n min_y = 1_000_000\n max_y = -1_000_000\n points.each do |x,y|\n min_y = y if y < min_y\n max_y = y if y > max_y\n end\n\n min_y = clamp(min_y, 0, canvas.height-1)\n max_y = clamp(max_y, 0, canvas.height-1)\n\n min_y.floor.upto(max_y.ceil) do |y|\n nodes = []\n\n prev = points.last\n points.each do |point|\n if point[1] < y && prev[1] >= y || prev[1] < y && point[1] >= y\n nodes << (point[0] + (y - point[1]).to_f / (prev[1] - point[1]) * (prev[0] - point[0]))\n end\n prev = point\n end\n\n next if nodes.empty?\n nodes.sort!\n\n prev = nil\n 0.step(nodes.length-1, 2) do |a|\n x1, x2 = nodes[a], nodes[a+1]\n x1, x2 = x2, x1 if x1 > x2\n next if x1 < 0 || x2 >= canvas.width\n x1.ceil.upto(x2.floor) do |x|\n canvas.point(x, y, color)\n end\n end\n end\n end",
"def paint_fill(screen, point, new_color)\n seen = {}\n old_color = color(point, screen)\n to_fill = [point]\n\n until to_fill.empty? do\n current_point = to_fill.shift\n screen[current_point[0]][current_point[1]] = new_color\n neighbors(current_point, screen.length, screen.first.length).each do |neighbor|\n if !seen[neighbor] && color(neighbor, screen) == old_color\n to_fill.push(neighbor)\n seen[neighbor] = true\n end\n end\n end\n\n render screen\nend",
"def black_nodes(nodes, adjacency_list)\n blacks = []\n \n while nodes != []\n \n # get the node with the lowest degree\n black = nodes.min do |n,m| \n adjacency_list[n-1].length <=> adjacency_list[m-1].length\n end\n\n # delete the node and the node's neighbors from the list of possible\n # black nodes\n nodes -= adjacency_list[black-1] << black\n\n # delete the node's neighbors from all the other neighbors\n # this removes the blackened node and it's neighbors from the graph\n adjacency_list.map! {|l| l - adjacency_list[black-1] }\n\n # add the blackened node to the list of black nodes\n blacks << black\n end\n\n blacks.sort \nend",
"def detect_cycle_in_graph(edges)\nend",
"def build_assignment_graph(layer)\n\t\th = @via_positions.length\n\t\tfail if (h == 0) || h.odd?\n\t\tfail if @start_node.pads.min < 0 || @start_node.pads.max >= @layer_count\n\t\tfail if @end_node.pads.min < 0 || @end_node.pads.max >= @layer_count\n\t\tvia_count = h / 2\n\t\tputs via_count\n\t\tlayers = 0..(@layer_count - 1) \n\t\tcolums = 0..(via_count * 2) # F O F O F for via_count == 2 \n\t\t#vp = @via_positions.dup # x,y pairs\n\t\t#vp.unshift(@start_node.y)\n\t\t#vp.unshift(@start_node.x)\n\t\tvp = [@start_node.x, @start_node.y] + @via_positions\n\t\tm = Array.new(@layer_count){Array.new(via_count * 2 + 1)}\n\t\tfor i in colums # from T back to S\n\t\t\tif i.even?\n\t\t\t\ty = vp.pop\n\t\t\t\tx = vp.pop\n\t\t\tend\n\t\t\tfor j in layers\n\t\t\t\tl = Array.new\n\t\t\t\tif i.even? # forward\n\t\t\t\t\tk = i + 1\n\t\t\t\t\twhile k > 0\n\t\t\t\t\t\tk -= 2\n\t\t\t\t\t\tif k == -1 # link forward node to T node\n\t\t\t\t\t\t\tl << @end_node if @end_node.pads.include?(j)\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tif (h = m[j][k])\n\t\t\t\t\t\t\t\tl << h # link to up/down node \n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\tunless l.empty?\n\t\t\t\t\t\tm[j][i] = F_node.new(x, y, j, l)\n\t\t\t\t\t\tl.each{|el|\n\t\t\t\t\t\t#unless @segment_list.index{|m| m.x1 == && m.y1 == el.y1 & m.x2 == el.x2 && m.y2 == el.y2}\n\t\t\t\t\t\t\t@segment_list << Segment.new(x, y, el.x, el.y)\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\t\t\t\telse #up/down\n\t\t\t\t\tfor k in layers do\n\t\t\t\t\t\tif (k != j) && (h = m[k][i - 1])\n\t\t\t\t\t\t\tl << h\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\tunless l.empty?\n\t\t\t\t\t\tm[j][i] = V_node.new(x, y, j, l)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t#puts @segment_list.length\n\t\t@segment_list.uniq!{|el| [el.x1, el.y1, el.x2, el.y2]}\n\t\tputs @segment_list.length\n\t\t@all_intersecting_segments = Array.new\n\t\t@segment_list.each{|el|\n\t\t\t@all_intersecting_segments += el.intersecting_segments\n\t\t}\n\t\t@all_intersecting_segments.uniq!\n\n\t\tfor j in layers\n\t\t\tif (h = m[j][-1]) && @start_node.pads.include?(j)\n\t\t\t\t@start_node.next << h\n\t\t\tend\n\t\tend\n\tend",
"def build_paths(start)\n step = 0\n visited = []\n unvisited = [[board_node_by_location(start),step]]\n \n while !unvisited.empty?\n node = unvisited[0][0]\n step = unvisited[0][1] + 1\n \n node.neighbors.each do |x|\n if not_visited(board_node_by_location(x),visited, unvisited)\n unvisited << [board_node_by_location(x),step]\n end\n end\n visited << unvisited.shift\n end\n return visited\nend",
"def cut_edge(user, threshold)\n edge_count = followees_of(user).length + followers_of(user).length\n # @depth += 1\n # puts \"#{@depth}, #{edge_count}\" if edge_count != 0\n if edge_count == 0\n # @depth -= 1\n return\n end\n\n if edge_count < threshold\n for i in 0...followees_of(user).count do\n followee = followees_of(user).first\n unless !followee\n # puts followee\n delete_edge(user, followee)\n cut_edge(followee, threshold)\n end\n end\n for i in 0...followers_of(user).count do\n follower = followers_of(user).first\n unless !follower\n # puts follower\n delete_edge(follower, user)\n cut_edge(follower, threshold)\n end\n end\n # followees_of(user).each do |followee|\n # delete_edge(user, followee)\n # # cut_edge(followee, threshold)\n # end\n # followers_of(user).each do |follower|\n # delete_edge(follower, user)\n # # cut_edge(follower, threshold)\n # end\n # puts \"#{user}, #{followees_of(user).length + followers_of(user).length}\"\n # puts followees_of(user).length + followers_of(user).length\n end\n # @depth -= 1\n end",
"def on_filled_hole(node)\n # first node is the goal abstract value\n idx = @selection.shift + 1\n node.children[idx]\n end",
"def unique_paths_with_obstacles(obstacle_grid)\n return 0 if obstacle_grid.empty?\n n = obstacle_grid.size\n m = obstacle_grid[0].size\n dp = Array.new(m, 0)\n dp[0] = 1\n (0..n-1).each do |r|\n (0..m-1).each do |c|\n if obstacle_grid[r][c] == 1\n dp[c] = 0\n elsif c > 0\n dp[c] += dp[c - 1]\n end\n end\n end\n dp[m - 1]\nend",
"def create_node_consistent_board(input,xblks, yblks)\n dim = input.length\n\n board = []\n open = []\n closed = []\n\n \t#initial configuration assigns each cell all possible values and lists all cells as open\n for x in 0..dim-1\n \t\tboard[x] = []\n\t for y in 0..dim-1\n\n\t\t board[x][y] = (1..dim).to_a\n\t\t open[open.length] = []\n open[open.length-1].concat( [x,y])\n\t end\n end\n\n for x in 0..dim-1\n\t for y in 0..dim-1\n\t\t inval = input[x][y]\n\t\t if (inval != 0)\n\n\t\t\t #assigns cell and removes cell from open list,\n \t\t\t\t# and removes value from cells involved in\n\t\t\t #constraints with this one\n\t\t\t if (!assign_spot(board,open,x, y, inval, xblks, yblks))\n\t\t\t\t #puts \"INVALID SUDOKU BOARD\", x, y, inval\n \t\t\t\t\tprint_board(board)\n\t\t\t\t return false\n\t\t\t end\n\t\t end\n \t\tend\n end\n boardhash = [board, open]\n if (board != false)\n \tboardhash = make_arc_consistent(board, open, closed, xblks, yblks)\n end\n if (boardhash == false)\n return false\n end\n\n\n return [boardhash[0], boardhash[1], boardhash[2]]\n\n end",
"def dfs_traversal(source_vertex)\n\n @visited[source_vertex] = true;\n\n @adjacent_list[source_vertex].each do |i|\n dfs_traversal(i) if !@visited[i]\n end\n\n end",
"def ids_recursive(vertex, goal_vertex, depth, max_depth)\n @stack.push(vertex) # Add vertex to frontier\n return 1 if vertex == goal_vertex # If goal_vertex is reached, return 1. ! Not necessarily shortest path !\n @stack.pop() && return if depth == max_depth\n @explored[vertex.label] = true # Mark vertex as being explored\n depth = depth + 1\n vertex.edges.each { |edge| # Expand current vertex\n unless @explored.has_key? edge.label # If already explored, then ignore the vertex\n return 1 if ids_recursive(edge, goal_vertex, depth, max_depth) == 1 # Recursively do depth_first on the vertices\n end\n }\n @stack.pop() #Backtracking so popping the vertex from the stack\n end",
"def restructure_path(visited_nodes, target_nodes) \n candidate_nodes = target_nodes.map do |target_node|\n following_node = visited_nodes[visited_nodes.index(target_node) + 1]\n \n unvisited_neighbours_of(following_node, visited_nodes).map { |neighbour|\n [ [target_node, neighbour], unvisited_neighbours_of(neighbour, visited_nodes).length ]\n }\n end.flatten(1)\n \n if candidate_nodes.length > 0 \n maximal_unvisited_count = candidate_nodes.map(&:last).max\n \n pivot_node, additional_node = candidate_nodes.rassoc(maximal_unvisited_count).first\n pivot_index = visited_nodes.index(pivot_node)\n \n visited_nodes = visited_nodes[0..pivot_index] + visited_nodes[(pivot_index + 1)..-1].reverse\n visited_nodes << additional_node\n end\n \n visited_nodes = grow_basic_path(visited_nodes)\n end",
"def fully_connected?(root_node, count)\n visited = [root_node]\n to_visit = [root_node]\n \n while !to_visit.empty?\n current_node = to_visit.shift\n\n current_node.children.each do |node|\n if !visited.include?(node)\n visited << node\n to_visit << node # get children next cycle\n end\n end\n end\n\n puts visited.count == count\nend",
"def bfs(g,s)\r\n q = []\r\n dists = Hash.new(Float::INFINITY)\r\n curr = s\r\n dists[curr] = 0\r\n \r\n #q += g[curr].each_index.select {|v| v != s && !dists.include?(v) && g[curr][v] == 1 }.map {|v| [curr,v] }\r\n g[curr].each.with_index {|e,v| q.push [curr,v] if v != s && e == 1 && !dists.include?(v)}\r\n while q.size > 0\r\n \tprev,curr = q.shift\r\n dists[curr] = [6 + dists[prev],dists[curr]].min\r\n #q += g[curr].each_index.select {|v| v != s && !dists.include?(v) && g[curr][v] == 1 }.map {|v| [curr,v] }\r\n g[curr].each.with_index {|e,v| q.push [curr,v] if v != s && e == 1 && !dists.include?(v)}\r\n #prev,curr = q.shift\r\n end\r\n \r\n return dists\r\nend",
"def hard(input)\n graph = Graph.from(input)\n components = []\n vertices = Set.new(graph.vertices)\n until vertices.empty?\n start = vertices.first\n component = graph_walk(graph, start)\n components << component\n vertices = vertices.difference(component)\n end\n components.length\nend",
"def fr_to_br\n a = 0\n x = 0\n edge4 = [nil] * 4\n\n BR.downto(UR).each do |j|\n ep = edge_permutation[j]\n if FR <= ep && ep <= BR # use range? faster?\n a += n_choose_k(11 - j, x + 1)\n edge4[3 - x] = edge_permutation[j] # CORNER_SIZE?\n x += 1\n end\n end\n\n b = 0\n 3.downto(1).each do |j| # range? CORNER_SIZE?\n k = 0\n while edge4[j] != (j + 8) # ????\n edge4 = rotateLeft(edge4, 0, j) # BLAAAAA\n k += 1\n end\n b = (j + 1) * b + k\n end\n\n (24 * a + b) & 0xffff # where does 24 come from?\n end",
"def bfs\r\n q = Queue.new\r\n visited = Set.new\r\n\r\n q << [0, panda]\r\n visited << panda\r\n\r\n until q.empty?\r\n level, current_panda = q.shift\r\n unvisited = @members[current_panda].select { |v| !visited.include? v }\r\n unvisited.each do |v|\r\n q << [level + 1, v]\r\n visited << v\r\n end\r\n end\r\n end",
"def bfs(v)\n raise ArgumentError, \"No such vertex\" if v < 0 or vertices <= v\n queue = LinkedQueue.new\n is_visited = []\n queue.enter(Edge.new(-1,v))\n while !queue.empty? do\n edge = queue.leave\n next if is_visited[edge.w]\n yield edge.v,edge.w\n is_visited[edge.w] = true\n each_edge(edge.w) do |w,x|\n queue.enter(Edge.new(w,x)) if !is_visited[x]\n end\n end\n end",
"def out_neighbors(vertex)\n\tend",
"def topological_sort(vertices)\n order = []\n explored = Set.new \n\n vertices.each do |vertex|\n dfs!(order, explored, vertex) unless explored.include?(vertex)\n end \n\n order \n\nend",
"def find_orfs_in_graph(graph, initial_paths, minimum_orf_length=nil,\n range=nil, max_gapfill_paths=nil, max_cycles=nil)\n\n problems = find_all_problems(graph,\n initial_paths,\n :range => range\n )\n\n find_orfs_from_problems(problems, {\n :min_orf_length => minimum_orf_length,\n :max_gapfill_paths => max_gapfill_paths,\n :max_cycles => max_cycles,\n })\n end",
"def create_full_graph(spec_edges)\n create_sub_graph(spec_edges, $game_map.width+$game_map.height)\n end",
"def social_distance_to user_id\n\n fake_test_data = {\n 1 => [5,6],\n 5 => [1],\n 6 => [1,7,8],\n 7 => [6],\n 8 => [6, 9, 12],\n 9 => [8],\n 12 => [13, 8],\n 13 => [12,14],\n 14 => [13]\n }\n\n start_id = 1\n end_id = user_id\n\n get_vertices = lambda { |x|\n fake_test_data[x] || []\n }\n\n a = start_id\n b = end_id\n marked = Set.new # keep track of checked vertices\n depth_a = get_vertices.call a\n depth_b = get_vertices.call b\n # check for distance=1 here, next checks will be for a common vertex in-between\n return 1 if b.in? depth_a\n distance = 2\n next_depth_a = []\n next_depth_b = []\n while depth_a.size > 0 && depth_b.size > 0\n # first check for even distances\n return distance if (depth_a & depth_b).size > 0\n distance += 1\n # get full front on next depth (all connected vertices of all vertices on this depth)\n depth_a.each do |aa|\n unless aa.in? marked\n next_depth_a += get_vertices.call aa\n marked.add(aa)\n end\n end\n # ... same for the other end\n depth_b.each do |bb|\n unless bb.in? marked\n next_depth_b += get_vertices.call bb\n marked.add(bb)\n end\n end\n depth_a = next_depth_a\n # second check with only one front moved forward (otherwise we might \"jump over\" the common vertex)\n return distance if (depth_a & depth_b).size > 0\n distance += 1\n depth_b = next_depth_b\n next_depth_a = next_depth_b = []\n end\nend",
"def augment_path!()\n # Find smallest uncovered element\n e_min = nil\n @cost_matrix.each_with_index{|row,r|\n next if @rows_covered[r]\n row.each_with_index{|e,c|\n next if @cols_covered[c]\n next if e == IMPOSSIBLE\n e_min ||= e\n e_min = e if e < e_min\n }\n }\n\n # Add min element to each covered row\n @rows_covered.each_with_index{|status,r|\n next if !status\n @cost_matrix[r].map!{|e| e + e_min}\n }\n\n # Subtract min element from each uncovered column\n @cols_covered.each_with_index{|status,c|\n next if status\n @cost_matrix.set_col!(c, @cost_matrix.col(c).map{|e| e - e_min})\n }\n return 4\n end"
] | [
"0.61022514",
"0.5984173",
"0.58644605",
"0.58266485",
"0.5819249",
"0.58173627",
"0.58066255",
"0.5785303",
"0.5783612",
"0.5778778",
"0.5766235",
"0.57561964",
"0.57544965",
"0.5744193",
"0.5743905",
"0.5739453",
"0.56765485",
"0.5663361",
"0.56591034",
"0.56219923",
"0.55563945",
"0.55555415",
"0.5518551",
"0.54835665",
"0.5482542",
"0.5458082",
"0.5448003",
"0.5442335",
"0.542937",
"0.5418977",
"0.53994405",
"0.53941834",
"0.53893864",
"0.5375014",
"0.537097",
"0.53625757",
"0.53622603",
"0.5355545",
"0.5350778",
"0.5350287",
"0.53366613",
"0.5309213",
"0.5307336",
"0.52884954",
"0.5285255",
"0.5277975",
"0.5277195",
"0.52761817",
"0.52674925",
"0.5265551",
"0.52528167",
"0.5249447",
"0.5239839",
"0.52350324",
"0.5227345",
"0.5226421",
"0.52194697",
"0.52109265",
"0.5208526",
"0.5198804",
"0.51875365",
"0.5170579",
"0.5167324",
"0.5161194",
"0.5160747",
"0.5158454",
"0.51582944",
"0.5154084",
"0.51495606",
"0.51396686",
"0.5135847",
"0.5127785",
"0.5123518",
"0.51227",
"0.5119625",
"0.51102006",
"0.51097757",
"0.5104986",
"0.5091351",
"0.50868905",
"0.5073962",
"0.5067677",
"0.50569624",
"0.5055124",
"0.5052903",
"0.5049525",
"0.5042108",
"0.5037509",
"0.50354254",
"0.5029455",
"0.5028149",
"0.5027167",
"0.50240684",
"0.50106984",
"0.50071424",
"0.5005861",
"0.49927038",
"0.49915463",
"0.49906993"
] | 0.56913644 | 17 |
Bug found using this test case | def test_05
@dg = DiGraph.new([0,7],[1,9],[1,4],[7,4],[7,0],[7,9],[3,7],[9,4],[9,7],[9,9],[4,1],[4,4],[4,7])
@paths = Hash.new
@paths[0] = [7]
@paths[1] = [9,4]
@paths[7] = [4,0,9]
@paths[3] = [7]
@paths[9] = [4,7,9]
@paths[4] = [1,4,7]
@nodes = @paths.keys
received_dg = @dg.strongly_connected_component_including_node(0);
filled_dg = DiGraph.new(*fill(0));
if (not filled_dg.equal?(received_dg))
puts "test_05 failed..."
puts "DiGraph => #{@dg.to_s}"
puts "node => 0"
puts "expected => #{filled_dg.to_s}"
puts "received => #{received_dg.to_s}"
end
assert_equal(true,filled_dg.equal?(received_dg))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def bug\n end",
"def internship_passed; end",
"def __dummy_test__\n end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def spec; end",
"def spec; end",
"def probers; end",
"def test_0_dummy\n\t\tend",
"def missed?; end",
"def schubert; end",
"def test_location_change_invalid_old\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Hash Crossing\"; end\r\n assert_raises('Invalid old index!') { @g.location_change(location, -1 , 1)}\r\n end",
"def missing?; end",
"def missing; end",
"def ibu; end",
"def used?; end",
"def fail\n\t\t# throw up this code and feed plezi your own lines :)\n\t\traise \"Plezi raising hell!\"\n\tend",
"def failures; end",
"def failures; end",
"def failures; end",
"def big_bad; end",
"def test_location_change_invalid_new\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Hash Crossing\"; end\r\n assert_raises('Invalid index!') { @g.location_change(location, 0, 7)}\r\n end",
"def culprit\n @culprit\n end",
"def issn; end",
"def self_test; end",
"def self_test; end",
"def miss_reason; end",
"def refutal()\n end",
"def awaken!\n\t\traise 'Not implemented'\n\tend",
"def internal; end",
"def usable?; end",
"def tell()\n #This is a stub, used for indexing\n end",
"def test_cannot_castle_if_king_has_moved\n # TODO\n end",
"def cause; end",
"def cause; end",
"def continued_exception; end",
"def berlioz; end",
"def missing?; false; end",
"def my_array_finding_method(source, thing_to_find)\n # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def original_result; end",
"def internal?; end",
"def anchored; end",
"def test_location_change_string_old\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Hash Crossing\"; end\r\n assert_raises('old_index must be an integer!') { @g.location_change(location, 'a', 1)}\r\n end",
"def running_test_case; end",
"def test_source_get()\n One::EmailDirect::Facade.source_add(@credentials, @source_get[:name], @source_get[:description])\n\n\n # 1.\n result = One::EmailDirect::Facade.source_get(@credentials, @source_get[:name])\n assert result.has_key? :element_id\n assert result.has_key? :element_name\n assert result.has_key? :description\n result.delete(:element_id)\n expected = {\n :element_name => @source_get[:name],\n :description => @source_get[:description]\n }\n assert_equal expected, result\n\n\n # 2.\n assert_nil One::EmailDirect::Facade.source_get(@credentials, 'inexistent')\n end",
"def incomplete\r\n\r\n end",
"def same; end",
"def trd; end",
"def ignores; end",
"def diagnostic; end",
"def suivre; end",
"def terpene; end",
"def skipped; end",
"def identify; end",
"def pass; end",
"def pass; end",
"def test_12e\r\n db = build\r\n\r\n r = db.fetch('image-1.jpg',:height => 102,:resize => false)\r\n assert r.nil?\r\n\r\n db.not_found_image = 'image-2.jpg'\r\n db.use_not_found = true\r\n\r\n r = db.fetch('image-1.jpg',:height => 102,:resize => false)\r\n assert_equal r,(File.join(db.root,'h','102','image-2.jpg')).to_s\r\n #assert File.exists?(File.join(db.root,'h','102','image-2.jpg'))\r\n# TODO: 27-Jun-2010\r\n assert(/image-2.jpg/===r)\r\n\r\n db.use_not_found = false\r\n#debugger\r\n r = db.fetch('image-1.jpg',:height => 102,:resize => false)\r\n assert r.nil?\r\n end",
"def isolated; end",
"def isolated; end",
"def implementation; end",
"def implementation; end",
"def checks; end",
"def reason; end",
"def reason; end",
"def upc_e; end",
"def expected_value; end",
"def expected_value; end",
"def test_ut_diff_source_code_02\n assert_equal(1,@diff_source_code_1.diff_result_id)\n assert_equal(1,@diff_source_code_1.original_file_id)\n assert_equal(1,@diff_source_code_1.diff_file_id)\n assert_equal(nil,@diff_source_code_1.added_lines)\n assert_equal(\"7;8;9;25;390;396;397;400;404\",@diff_source_code_1.deleted_lines)\n assert_equal(\"1,1;2,2;3,3;4,4;6,6;10,10;11,11;12,12;13,13;14,14;15,15;\",@diff_source_code_1.common_lines)\n end",
"def test_source_add()\n # 1. create a new source\n One::EmailDirect::Facade.source_add(@credentials, @source_add[:name], @source_add[:description])\n result = get_single_source(@source_add[:name])\n expected = {\n :element_name => @source_add[:name],\n :description => @source_add[:description]\n }\n\n assert_not_nil result\n result.delete(:element_id)\n assert_equal expected, result\n\n\n # 2. create a new source with a previously used name\n assert_raises One::EmailDirect::EmailDirectException do\n One::EmailDirect::Facade.source_add(@credentials, @source_add[:name], @source_add[:description])\n end\n end",
"def test_cyclic\n end",
"def version_mismatch_detected\n end",
"def testing\n # ...\n end",
"def test_prev_hash_correct_true\n assert @bv.prev_hash_correct?(0, \"abcd\", \"abcd\")\n end",
"def verdi; end",
"def celebration; end",
"def covered?; end",
"def weber; end",
"def initialize\n @broken = false\n end",
"def test_location_change_string_new\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Hash Crossing\"; end\r\n assert_raises('index must be an integer!') { @g.location_change(location, 0, 'a')}\r\n end",
"def semact?; false; end",
"def remaining; end",
"def test_extract_data_06\n OriginalSourceCode.destroy_all\n file = original_files(:original_files_002)\n assert file.extract_data(file.normal_result_id)\n original_source_code_1 = OriginalSourceCode.find(:all,\n :conditions => {\n :original_file_id => file.id,\n :line_number => 1,\n :line_content => \"\\t/*\\r\",\n :error_line => 1}\n )\n assert_not_equal [],original_source_code_1\n original_source_code_2 = OriginalSourceCode.find(:all,\n :conditions => {\n :original_file_id =>file.id,\n :line_number => 2,\n :line_content => \"\\t File:\\r\",\n :error_line => 0}\n )\n assert_not_equal [],original_source_code_2\n end",
"def test_hack\n assert(true)\n end",
"def test_that_grid_generation_is_accurate\n end",
"def test_current_idx\n \t@sequence.next\n \tassert_equal(@sequence.current_idx, 0)\n @sequence.next\n assert_equal(@sequence.current_idx, 1)\n end",
"def test_generate_offset_return_value\n offset_generator = OffsetGenerator.new(260317)\n assert_equal String, offset_generator.generate_offset(\"a\").class\n assert_equal 1, offset_generator.generate_offset(\"a\").length\n #assert_equal \"FailingValue\", offset_generator.generate_offset(\"a\")\n #assert_equal \"FailingValue\", offset_generator.generate_offset(\"b\")\n #assert_equal \"FailingValue\", offset_generator.generate_offset(\"c\")\n #assert_equal \"FailingValue\", offset_generator.generate_offset(\"d\")\n end",
"def test_unknown_cause\n assert_equal \"unknown cause (this is probably a bug in Mocktail)\",\n @subject.recreate(Signature.new(\n positional_params: Params.new(all: [:a], required: [:a]),\n positional_args: [1],\n keyword_params: Params.new(all: []),\n keyword_args: {}\n ))\n end",
"def hiss; end",
"def offences_by; end",
"def assertions; end",
"def assertions; end",
"def valid; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end"
] | [
"0.6767296",
"0.62264943",
"0.600941",
"0.5921807",
"0.58881867",
"0.58881867",
"0.58881867",
"0.58881867",
"0.5798754",
"0.5798754",
"0.57515544",
"0.57446426",
"0.5731531",
"0.56717753",
"0.55894893",
"0.5568649",
"0.55508506",
"0.5546685",
"0.5544533",
"0.5512657",
"0.5504222",
"0.5504222",
"0.5504222",
"0.54935485",
"0.548296",
"0.5464426",
"0.545469",
"0.5443827",
"0.5443827",
"0.54249907",
"0.5418933",
"0.54173934",
"0.5385053",
"0.536417",
"0.53485656",
"0.5346321",
"0.53076667",
"0.53076667",
"0.53072506",
"0.5298208",
"0.52981067",
"0.52817875",
"0.5281274",
"0.52692944",
"0.52638125",
"0.5249848",
"0.5236961",
"0.5228831",
"0.52084774",
"0.52053106",
"0.5202573",
"0.519564",
"0.519274",
"0.51906973",
"0.51866627",
"0.5185738",
"0.51839006",
"0.51790935",
"0.51790935",
"0.517601",
"0.5162037",
"0.5162037",
"0.5161146",
"0.5161146",
"0.5160719",
"0.5156143",
"0.5156143",
"0.51473737",
"0.51471686",
"0.51471686",
"0.51441514",
"0.5137053",
"0.5128727",
"0.51277584",
"0.5125066",
"0.5122636",
"0.5121422",
"0.5116498",
"0.5112584",
"0.51050717",
"0.5102132",
"0.5100529",
"0.5096027",
"0.5091372",
"0.5089218",
"0.50830245",
"0.50818586",
"0.5080292",
"0.50772697",
"0.50763494",
"0.5075761",
"0.5074944",
"0.50715137",
"0.50715137",
"0.5069645",
"0.50668687",
"0.50668687",
"0.50668687",
"0.50668687",
"0.50668687",
"0.50668687"
] | 0.0 | -1 |
Bug found using this test case | def test_06
@dg = DiGraph.new([5,9],[0,3],[3,8],[8,9],[9,0])
@paths = Hash.new
@paths[5] = [9]
@paths[0] = [3]
@paths[3] = [8]
@paths[8] = [9]
@paths[9] = [0]
@nodes = @paths.keys
received_dg = @dg.strongly_connected_component_including_node(0);
filled_dg = DiGraph.new(*fill(0));
if (not filled_dg.equal?(received_dg))
puts "test_06 failed..."
puts "DiGraph => #{@dg.to_s}"
puts "node => 0"
puts "expected => #{filled_dg.to_s}"
puts "received => #{received_dg.to_s}"
end
assert_equal(true,filled_dg.equal?(received_dg))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def bug\n end",
"def internship_passed; end",
"def __dummy_test__\n end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def spec; end",
"def spec; end",
"def probers; end",
"def test_0_dummy\n\t\tend",
"def missed?; end",
"def schubert; end",
"def test_location_change_invalid_old\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Hash Crossing\"; end\r\n assert_raises('Invalid old index!') { @g.location_change(location, -1 , 1)}\r\n end",
"def missing?; end",
"def missing; end",
"def ibu; end",
"def used?; end",
"def fail\n\t\t# throw up this code and feed plezi your own lines :)\n\t\traise \"Plezi raising hell!\"\n\tend",
"def failures; end",
"def failures; end",
"def failures; end",
"def big_bad; end",
"def test_location_change_invalid_new\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Hash Crossing\"; end\r\n assert_raises('Invalid index!') { @g.location_change(location, 0, 7)}\r\n end",
"def culprit\n @culprit\n end",
"def issn; end",
"def self_test; end",
"def self_test; end",
"def miss_reason; end",
"def refutal()\n end",
"def awaken!\n\t\traise 'Not implemented'\n\tend",
"def internal; end",
"def usable?; end",
"def tell()\n #This is a stub, used for indexing\n end",
"def test_cannot_castle_if_king_has_moved\n # TODO\n end",
"def cause; end",
"def cause; end",
"def continued_exception; end",
"def missing?; false; end",
"def berlioz; end",
"def my_array_finding_method(source, thing_to_find)\n # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def original_result; end",
"def internal?; end",
"def anchored; end",
"def test_location_change_string_old\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Hash Crossing\"; end\r\n assert_raises('old_index must be an integer!') { @g.location_change(location, 'a', 1)}\r\n end",
"def running_test_case; end",
"def test_source_get()\n One::EmailDirect::Facade.source_add(@credentials, @source_get[:name], @source_get[:description])\n\n\n # 1.\n result = One::EmailDirect::Facade.source_get(@credentials, @source_get[:name])\n assert result.has_key? :element_id\n assert result.has_key? :element_name\n assert result.has_key? :description\n result.delete(:element_id)\n expected = {\n :element_name => @source_get[:name],\n :description => @source_get[:description]\n }\n assert_equal expected, result\n\n\n # 2.\n assert_nil One::EmailDirect::Facade.source_get(@credentials, 'inexistent')\n end",
"def incomplete\r\n\r\n end",
"def same; end",
"def trd; end",
"def ignores; end",
"def diagnostic; end",
"def suivre; end",
"def terpene; end",
"def skipped; end",
"def identify; end",
"def pass; end",
"def pass; end",
"def test_12e\r\n db = build\r\n\r\n r = db.fetch('image-1.jpg',:height => 102,:resize => false)\r\n assert r.nil?\r\n\r\n db.not_found_image = 'image-2.jpg'\r\n db.use_not_found = true\r\n\r\n r = db.fetch('image-1.jpg',:height => 102,:resize => false)\r\n assert_equal r,(File.join(db.root,'h','102','image-2.jpg')).to_s\r\n #assert File.exists?(File.join(db.root,'h','102','image-2.jpg'))\r\n# TODO: 27-Jun-2010\r\n assert(/image-2.jpg/===r)\r\n\r\n db.use_not_found = false\r\n#debugger\r\n r = db.fetch('image-1.jpg',:height => 102,:resize => false)\r\n assert r.nil?\r\n end",
"def isolated; end",
"def isolated; end",
"def implementation; end",
"def implementation; end",
"def checks; end",
"def reason; end",
"def reason; end",
"def expected_value; end",
"def expected_value; end",
"def upc_e; end",
"def test_ut_diff_source_code_02\n assert_equal(1,@diff_source_code_1.diff_result_id)\n assert_equal(1,@diff_source_code_1.original_file_id)\n assert_equal(1,@diff_source_code_1.diff_file_id)\n assert_equal(nil,@diff_source_code_1.added_lines)\n assert_equal(\"7;8;9;25;390;396;397;400;404\",@diff_source_code_1.deleted_lines)\n assert_equal(\"1,1;2,2;3,3;4,4;6,6;10,10;11,11;12,12;13,13;14,14;15,15;\",@diff_source_code_1.common_lines)\n end",
"def test_source_add()\n # 1. create a new source\n One::EmailDirect::Facade.source_add(@credentials, @source_add[:name], @source_add[:description])\n result = get_single_source(@source_add[:name])\n expected = {\n :element_name => @source_add[:name],\n :description => @source_add[:description]\n }\n\n assert_not_nil result\n result.delete(:element_id)\n assert_equal expected, result\n\n\n # 2. create a new source with a previously used name\n assert_raises One::EmailDirect::EmailDirectException do\n One::EmailDirect::Facade.source_add(@credentials, @source_add[:name], @source_add[:description])\n end\n end",
"def test_cyclic\n end",
"def version_mismatch_detected\n end",
"def testing\n # ...\n end",
"def test_prev_hash_correct_true\n assert @bv.prev_hash_correct?(0, \"abcd\", \"abcd\")\n end",
"def verdi; end",
"def celebration; end",
"def covered?; end",
"def weber; end",
"def initialize\n @broken = false\n end",
"def test_location_change_string_new\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Hash Crossing\"; end\r\n assert_raises('index must be an integer!') { @g.location_change(location, 0, 'a')}\r\n end",
"def semact?; false; end",
"def remaining; end",
"def test_extract_data_06\n OriginalSourceCode.destroy_all\n file = original_files(:original_files_002)\n assert file.extract_data(file.normal_result_id)\n original_source_code_1 = OriginalSourceCode.find(:all,\n :conditions => {\n :original_file_id => file.id,\n :line_number => 1,\n :line_content => \"\\t/*\\r\",\n :error_line => 1}\n )\n assert_not_equal [],original_source_code_1\n original_source_code_2 = OriginalSourceCode.find(:all,\n :conditions => {\n :original_file_id =>file.id,\n :line_number => 2,\n :line_content => \"\\t File:\\r\",\n :error_line => 0}\n )\n assert_not_equal [],original_source_code_2\n end",
"def test_hack\n assert(true)\n end",
"def test_that_grid_generation_is_accurate\n end",
"def test_current_idx\n \t@sequence.next\n \tassert_equal(@sequence.current_idx, 0)\n @sequence.next\n assert_equal(@sequence.current_idx, 1)\n end",
"def test_generate_offset_return_value\n offset_generator = OffsetGenerator.new(260317)\n assert_equal String, offset_generator.generate_offset(\"a\").class\n assert_equal 1, offset_generator.generate_offset(\"a\").length\n #assert_equal \"FailingValue\", offset_generator.generate_offset(\"a\")\n #assert_equal \"FailingValue\", offset_generator.generate_offset(\"b\")\n #assert_equal \"FailingValue\", offset_generator.generate_offset(\"c\")\n #assert_equal \"FailingValue\", offset_generator.generate_offset(\"d\")\n end",
"def test_unknown_cause\n assert_equal \"unknown cause (this is probably a bug in Mocktail)\",\n @subject.recreate(Signature.new(\n positional_params: Params.new(all: [:a], required: [:a]),\n positional_args: [1],\n keyword_params: Params.new(all: []),\n keyword_args: {}\n ))\n end",
"def hiss; end",
"def offences_by; end",
"def assertions; end",
"def assertions; end",
"def valid; end",
"def test_srch_back_for_nonexist_pattern\n @buffer = Buffer.new 'Now is the time for all good men to come to the aid of their country'\n @buffer.fin\n @buffer.srch_back 'xxyyzz'\n assert_eq '', @buffer.at\n end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end"
] | [
"0.6766784",
"0.62270457",
"0.6009193",
"0.5921741",
"0.58877975",
"0.58877975",
"0.58877975",
"0.58877975",
"0.5798168",
"0.5798168",
"0.5750772",
"0.5744431",
"0.57310957",
"0.5671328",
"0.5589977",
"0.5568493",
"0.55509824",
"0.55467534",
"0.5543746",
"0.551302",
"0.5503979",
"0.5503979",
"0.5503979",
"0.5493487",
"0.5483444",
"0.54643047",
"0.5454533",
"0.54436255",
"0.54436255",
"0.54247904",
"0.54188627",
"0.54178154",
"0.538481",
"0.5363589",
"0.5348394",
"0.5346852",
"0.53080887",
"0.53080887",
"0.5307423",
"0.5298015",
"0.529763",
"0.5282253",
"0.528142",
"0.526888",
"0.5263804",
"0.5250305",
"0.523645",
"0.52290475",
"0.52086985",
"0.52055156",
"0.5202602",
"0.5195489",
"0.51921576",
"0.5190468",
"0.5186641",
"0.5185602",
"0.5183377",
"0.51787436",
"0.51787436",
"0.517638",
"0.5162127",
"0.5162127",
"0.51609045",
"0.51609045",
"0.5159987",
"0.5155481",
"0.5155481",
"0.5147611",
"0.5147611",
"0.5147417",
"0.5144165",
"0.5137718",
"0.51295894",
"0.51285356",
"0.51252276",
"0.5123353",
"0.5121025",
"0.51160926",
"0.5112451",
"0.51047736",
"0.5101834",
"0.5100898",
"0.50958776",
"0.5091169",
"0.50890964",
"0.5083486",
"0.5082928",
"0.5080426",
"0.50773567",
"0.5077246",
"0.5075334",
"0.50745296",
"0.50718486",
"0.50718486",
"0.5069579",
"0.50661504",
"0.506599",
"0.506599",
"0.506599",
"0.506599",
"0.506599"
] | 0.0 | -1 |
Bug found using this test case | def test_07
@dg = DiGraph.new([0,0],[6,0],[6,8],[2,6],[8,8],[3,4],[3,2],[3,9],[9,4],[9,6],[4,3],[4,8])
@paths = Hash.new
@paths[0] = [0]
@paths[6] = [0,8]
@paths[2] = [6]
@paths[8] = [8]
@paths[3] = [4,2,9]
@paths[9] = [4,6]
@paths[4] = [3,8]
@nodes = @paths.keys
received_dg = @dg.strongly_connected_component_including_node(6);
filled_dg = DiGraph.new(*fill(6));
if (not filled_dg.equal?(received_dg))
puts "test_07 failed..."
puts "DiGraph => #{@dg.to_s}"
puts "node => 6"
puts "expected => #{filled_dg.to_s}"
puts "received => #{received_dg.to_s}"
end
assert_equal(true,filled_dg.equal?(received_dg))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def bug\n end",
"def internship_passed; end",
"def __dummy_test__\n end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def spec; end",
"def spec; end",
"def probers; end",
"def test_0_dummy\n\t\tend",
"def missed?; end",
"def schubert; end",
"def test_location_change_invalid_old\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Hash Crossing\"; end\r\n assert_raises('Invalid old index!') { @g.location_change(location, -1 , 1)}\r\n end",
"def missing?; end",
"def missing; end",
"def ibu; end",
"def used?; end",
"def fail\n\t\t# throw up this code and feed plezi your own lines :)\n\t\traise \"Plezi raising hell!\"\n\tend",
"def failures; end",
"def failures; end",
"def failures; end",
"def big_bad; end",
"def test_location_change_invalid_new\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Hash Crossing\"; end\r\n assert_raises('Invalid index!') { @g.location_change(location, 0, 7)}\r\n end",
"def culprit\n @culprit\n end",
"def issn; end",
"def self_test; end",
"def self_test; end",
"def miss_reason; end",
"def refutal()\n end",
"def awaken!\n\t\traise 'Not implemented'\n\tend",
"def internal; end",
"def usable?; end",
"def tell()\n #This is a stub, used for indexing\n end",
"def test_cannot_castle_if_king_has_moved\n # TODO\n end",
"def cause; end",
"def cause; end",
"def continued_exception; end",
"def missing?; false; end",
"def berlioz; end",
"def my_array_finding_method(source, thing_to_find)\n # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def original_result; end",
"def internal?; end",
"def anchored; end",
"def test_location_change_string_old\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Hash Crossing\"; end\r\n assert_raises('old_index must be an integer!') { @g.location_change(location, 'a', 1)}\r\n end",
"def running_test_case; end",
"def test_source_get()\n One::EmailDirect::Facade.source_add(@credentials, @source_get[:name], @source_get[:description])\n\n\n # 1.\n result = One::EmailDirect::Facade.source_get(@credentials, @source_get[:name])\n assert result.has_key? :element_id\n assert result.has_key? :element_name\n assert result.has_key? :description\n result.delete(:element_id)\n expected = {\n :element_name => @source_get[:name],\n :description => @source_get[:description]\n }\n assert_equal expected, result\n\n\n # 2.\n assert_nil One::EmailDirect::Facade.source_get(@credentials, 'inexistent')\n end",
"def incomplete\r\n\r\n end",
"def same; end",
"def trd; end",
"def ignores; end",
"def diagnostic; end",
"def suivre; end",
"def terpene; end",
"def skipped; end",
"def identify; end",
"def pass; end",
"def pass; end",
"def test_12e\r\n db = build\r\n\r\n r = db.fetch('image-1.jpg',:height => 102,:resize => false)\r\n assert r.nil?\r\n\r\n db.not_found_image = 'image-2.jpg'\r\n db.use_not_found = true\r\n\r\n r = db.fetch('image-1.jpg',:height => 102,:resize => false)\r\n assert_equal r,(File.join(db.root,'h','102','image-2.jpg')).to_s\r\n #assert File.exists?(File.join(db.root,'h','102','image-2.jpg'))\r\n# TODO: 27-Jun-2010\r\n assert(/image-2.jpg/===r)\r\n\r\n db.use_not_found = false\r\n#debugger\r\n r = db.fetch('image-1.jpg',:height => 102,:resize => false)\r\n assert r.nil?\r\n end",
"def isolated; end",
"def isolated; end",
"def implementation; end",
"def implementation; end",
"def checks; end",
"def reason; end",
"def reason; end",
"def expected_value; end",
"def expected_value; end",
"def upc_e; end",
"def test_ut_diff_source_code_02\n assert_equal(1,@diff_source_code_1.diff_result_id)\n assert_equal(1,@diff_source_code_1.original_file_id)\n assert_equal(1,@diff_source_code_1.diff_file_id)\n assert_equal(nil,@diff_source_code_1.added_lines)\n assert_equal(\"7;8;9;25;390;396;397;400;404\",@diff_source_code_1.deleted_lines)\n assert_equal(\"1,1;2,2;3,3;4,4;6,6;10,10;11,11;12,12;13,13;14,14;15,15;\",@diff_source_code_1.common_lines)\n end",
"def test_source_add()\n # 1. create a new source\n One::EmailDirect::Facade.source_add(@credentials, @source_add[:name], @source_add[:description])\n result = get_single_source(@source_add[:name])\n expected = {\n :element_name => @source_add[:name],\n :description => @source_add[:description]\n }\n\n assert_not_nil result\n result.delete(:element_id)\n assert_equal expected, result\n\n\n # 2. create a new source with a previously used name\n assert_raises One::EmailDirect::EmailDirectException do\n One::EmailDirect::Facade.source_add(@credentials, @source_add[:name], @source_add[:description])\n end\n end",
"def test_cyclic\n end",
"def version_mismatch_detected\n end",
"def testing\n # ...\n end",
"def test_prev_hash_correct_true\n assert @bv.prev_hash_correct?(0, \"abcd\", \"abcd\")\n end",
"def verdi; end",
"def celebration; end",
"def covered?; end",
"def weber; end",
"def initialize\n @broken = false\n end",
"def test_location_change_string_new\r\n location = Minitest::Mock.new(\"test_location_arr\")\r\n def location.get_id(index); \"Hash Crossing\"; end\r\n assert_raises('index must be an integer!') { @g.location_change(location, 0, 'a')}\r\n end",
"def semact?; false; end",
"def remaining; end",
"def test_extract_data_06\n OriginalSourceCode.destroy_all\n file = original_files(:original_files_002)\n assert file.extract_data(file.normal_result_id)\n original_source_code_1 = OriginalSourceCode.find(:all,\n :conditions => {\n :original_file_id => file.id,\n :line_number => 1,\n :line_content => \"\\t/*\\r\",\n :error_line => 1}\n )\n assert_not_equal [],original_source_code_1\n original_source_code_2 = OriginalSourceCode.find(:all,\n :conditions => {\n :original_file_id =>file.id,\n :line_number => 2,\n :line_content => \"\\t File:\\r\",\n :error_line => 0}\n )\n assert_not_equal [],original_source_code_2\n end",
"def test_hack\n assert(true)\n end",
"def test_that_grid_generation_is_accurate\n end",
"def test_current_idx\n \t@sequence.next\n \tassert_equal(@sequence.current_idx, 0)\n @sequence.next\n assert_equal(@sequence.current_idx, 1)\n end",
"def test_generate_offset_return_value\n offset_generator = OffsetGenerator.new(260317)\n assert_equal String, offset_generator.generate_offset(\"a\").class\n assert_equal 1, offset_generator.generate_offset(\"a\").length\n #assert_equal \"FailingValue\", offset_generator.generate_offset(\"a\")\n #assert_equal \"FailingValue\", offset_generator.generate_offset(\"b\")\n #assert_equal \"FailingValue\", offset_generator.generate_offset(\"c\")\n #assert_equal \"FailingValue\", offset_generator.generate_offset(\"d\")\n end",
"def test_unknown_cause\n assert_equal \"unknown cause (this is probably a bug in Mocktail)\",\n @subject.recreate(Signature.new(\n positional_params: Params.new(all: [:a], required: [:a]),\n positional_args: [1],\n keyword_params: Params.new(all: []),\n keyword_args: {}\n ))\n end",
"def hiss; end",
"def offences_by; end",
"def assertions; end",
"def assertions; end",
"def valid; end",
"def test_srch_back_for_nonexist_pattern\n @buffer = Buffer.new 'Now is the time for all good men to come to the aid of their country'\n @buffer.fin\n @buffer.srch_back 'xxyyzz'\n assert_eq '', @buffer.at\n end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end"
] | [
"0.6766784",
"0.62270457",
"0.6009193",
"0.5921741",
"0.58877975",
"0.58877975",
"0.58877975",
"0.58877975",
"0.5798168",
"0.5798168",
"0.5750772",
"0.5744431",
"0.57310957",
"0.5671328",
"0.5589977",
"0.5568493",
"0.55509824",
"0.55467534",
"0.5543746",
"0.551302",
"0.5503979",
"0.5503979",
"0.5503979",
"0.5493487",
"0.5483444",
"0.54643047",
"0.5454533",
"0.54436255",
"0.54436255",
"0.54247904",
"0.54188627",
"0.54178154",
"0.538481",
"0.5363589",
"0.5348394",
"0.5346852",
"0.53080887",
"0.53080887",
"0.5307423",
"0.5298015",
"0.529763",
"0.5282253",
"0.528142",
"0.526888",
"0.5263804",
"0.5250305",
"0.523645",
"0.52290475",
"0.52086985",
"0.52055156",
"0.5202602",
"0.5195489",
"0.51921576",
"0.5190468",
"0.5186641",
"0.5185602",
"0.5183377",
"0.51787436",
"0.51787436",
"0.517638",
"0.5162127",
"0.5162127",
"0.51609045",
"0.51609045",
"0.5159987",
"0.5155481",
"0.5155481",
"0.5147611",
"0.5147611",
"0.5147417",
"0.5144165",
"0.5137718",
"0.51295894",
"0.51285356",
"0.51252276",
"0.5123353",
"0.5121025",
"0.51160926",
"0.5112451",
"0.51047736",
"0.5101834",
"0.5100898",
"0.50958776",
"0.5091169",
"0.50890964",
"0.5083486",
"0.5082928",
"0.5080426",
"0.50773567",
"0.5077246",
"0.5075334",
"0.50745296",
"0.50718486",
"0.50718486",
"0.5069579",
"0.50661504",
"0.506599",
"0.506599",
"0.506599",
"0.506599",
"0.506599"
] | 0.0 | -1 |
Have the function LongestWord(sen) take the sen parameter being passed and return the largest word in the string. If there are two or more words that are the same length, return the first word from the string with that length. Ignore punctuation and assume sen will not be empty. | def longest_word(sen)
words = sen.split
words.map! { |word| word.delete('^A-Za-z1-9_\'') }
longest = words.first
words.each_with_index do |word, idx|
next if idx >= words.size - 1
longest = longest.size < words[idx + 1].size ? words[idx + 1] : longest
end
longest
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def LongestWord(sen)\n str = sen.split(\" \")\n longest_word = str[0]\n str.each do |word|\n word.sub(/[\\w\\s]/, '')\n if longest_word.length < word.length\n longest_word = word\n end\n end\n longest_word\nend",
"def LongestWord(sen)\n arr = sen.split(' ')\n longest = arr[0]\n arr.each do |word|\n if word.length > longest.length\n longest = word\n end\n end\n return longest\nend",
"def LongestWord(sen)\n\tarr = sen.gsub(/[^a-zA-Z]+/m, ' ').strip.split(\" \")\n\tcounter = \"\" \n\t\tarr.each do |word|\n\t\t\tif word.length >= counter.length \n\t\t\t\tcounter = word \n\t\t\tend\n\t\tend\n\t\tcounter\nend",
"def LongestWord(sen)\n longest = \"\"\n sen.scan(/\\w+/) do |word|\n if word.length > longest.length\n longest = word\n end\n end\n \n return longest\nend",
"def LongestWord(sen)\n arr = sen.split(\" \")\n arr.sort! { |a, b| b.length <=> a.length }\n arr[0]\n\nend",
"def longestWord(sen)\n\tarray = []\n\tsen.gsub!(/[^0-9a-zA-Z\\s]/i, '')\n\tsen = sen.split(' ')\n\tsen.each {|word| array.push(word)}\n\tarray.sort! { |x,y| y.length <=> x.length }\n\treturn array.first\nend",
"def LongestWord(sen)\n words = sen.split(' ').map do |i|\n /[a-zA-Z0-9]+/.match(i)\n end\n\n longest = words.max_by.each do |i|\n i.to_s.length\n end\n\n longest\n\nend",
"def longest_word (sen)\n i = 0\n while i < sen.length do\n # negated regex boolean\n if sen[i] !~ /[a-z]|\\s/\n sen.slice!(i)\n else\n sen[i]\n i += 1\n end\n end\n return sen.split(\" \").max_by(&:length).length\nend",
"def LongestWord(str)\n words = str.split.map { |s| s.gsub(/\\W/, '') }\n longest = words [0]\n words.each { |word| longest = word if word.length > longest.length }\n longest\nend",
"def get_the_longest_word(str)\n str.split(\" \").sort! {|s, l| l.length <=> s.length}[0]\nend",
"def longest_word(sen)\n tmp_arr = sen.split(\" \")\n tmp_longest = 0\n tmp_arr.each do |i|\n tmp_longest = i.size if i.size > tmp_longest\n end\n\n tmp_arr.select { |i| i.size == tmp_longest }.first\nend",
"def get_the_shortest_word(str)\n words = str.split()\n return words.max\nend",
"def longest_word(str)\n longest_word = \"\"\n words = str.split(' ')\n\n words.each do |word|\n if word.length > longest_word.length\n longest_word = word\n end\n end\n return longest_word\nend",
"def longest_word(sentence)\n words = sentence.split(\"\\s\")\n \n max_word = nil\n for word in words do\n if max_word == nil \n max_word = word\n elsif word.length > max_word.length \n max_word = word\n end\n end\n \n return max_word\nend",
"def longest_word(sentence)\n words = sentence.split(\"\") #This automically creates a new array with the string split already right?\n idx = 0\n # initially the longest word is empty\n \n longest_w = ''\n \n # We will loop over the current word.\n \n while idx < words.length\n if (words[idx].length > longest_w.length)\n longest_w = words[idx]\n else \n longest_w = longest_w\n end\n \n idx = idx + 1\n end\n \n return longest_w\nend",
"def find_longest_word(sentence)\n words = sentence.downcase.tr(\"^a-z\", \" \").split\n longest = \"\"\n words.each do |word|\n if word.length > longest.length\n longest = word\n end\n end\n return longest\n\nend",
"def get_the_shortest_word(str)\n str.split(\" \").sort! {|s, l| s.length <=> l.length}[0]\nend",
"def longest_word(string)\n\t\n\tsplitted_string = string.split(\" \")\n\tword_length = []\n\t\n\tsplitted_string.each { |word| word_length << word.length }\n\t\n\tmax = word_length.max\n\tidx = word_length.index(max)\n\tsplitted_string[idx]\n\t\nend",
"def find_longest_word(sentence)\n # removes special characters | sorts by length | reverses to start with the longest\n longest = sentence.split(/\\W+/).sort_by { |word| word.length }.reverse!\n longest[0]\nend",
"def longest_word(string_of_words)\n # Give me back the longest word!\n longest = \"\"\n string_of_words.split(\" \").each do | word |\n if longest.length <= word.length\n longest = word\n end\n end\n return longest\nend",
"def longest_word(sentence)\n result = \"\"\n sentence.split.each do |word|\n if word.length > result.length\n result = word\n end\n end\nresult\nend",
"def longest_word(sentence)\n\t\n\tarr = sentence.split(\" \")\n\tarr = []\n\tlongest = \"\"\n\t\n\tarr.each do |word|\n\tlongest = word if longest.length < word.length\t\n end\n return longest\nend",
"def longest_word(sentence)\n words = sentence.split\n words.sort_by!(&:length)\n words[-1]\nend",
"def find_longest_word(input)\n array = input.split(\" \")\n array.sort! { |x, y| y.length <=> x.length }\n array[0]\nend",
"def longest_word(sentence)\n longestWord = \"\" #holds word\n words = sentence.split(' ') #split sentence into array of words.\n\n words.each do |word| #loop through array of words\n if word.length > longestWord.length #if the word the loop is on is greater than the longest word.. \n longestWord = word #set the longest word to that word.\n end\n end\n return longestWord #return longest word\nend",
"def longest_word(sentence)\n\tarr = sentence.split(\" \")\n\tp arr\n\titer = 0\n\twhile iter < arr.length\n\t\tlongest_word = nil\n\t\tcurrent_word = arr[iter]\n\t\tif longest_word == nil\n\t\t\tlongest_word = current_word\n\t\telsif longest_word.length < current_word.length\n\t\t\tlongest_word = current_word\n\t\tend\n\t\titer+=1\n\tend\n\treturn longest_word\nend",
"def get_the_longest_word(str)\n words = str.split()\n longest = [0, \"\"]\n\n for word in words\n if word.length > longest[0]\n longest[0] = word.length\n longest[1] = word\n end\n end\n\n print(longest[1])\n return longest[1]\nend",
"def longest_word(str)\r\n\r\n # temporary variables created\r\n word_length = 0\r\n longest_word = \"\"\r\n\r\n # checks length of each word\r\n str.split(\" \").each {|word|\r\n\r\n if word.length >= word_length\r\n word_length = word.length\r\n longest_word = word\r\n end\r\n\r\n }\r\n\r\n longest_word\r\nend",
"def longest_word(sentence)\n word_arr = sentence.split\n longest = word_arr.shift\n \n word_arr.each do |word|\n longest = word if word.length >= longest.length\n end\n\n longest\nend",
"def longest_word(sentence)\n words = sentence.split(\" \") # words = \"hello, you, motherfucker\"\n\n idx = 0\n while idx < words.length # 0 < 3\n current_word = words[idx] # current_word = words[0]\n\n longest_word = \"\" # set initial longest_word as empty string.\n if current_word.length > longest_word.length\n longest_word = current_word\n end\n\n idx += 1\n end\n return longest_word\nend",
"def old_longest_word(str)\n words = str.split\n longest_word = \"\"\n\n words.each do |word|\n if word.length > longest_word.length\n longest_word = word\n end\n end\n\n longest_word\nend",
"def longest_word(string_of_words)\n\tas_arr = string_of_words.split(\" \")\n\tlengths = as_arr.map {|string| string.length}\n\tmax_length = lengths.max\n return as_arr.reverse.detect {|string| string.length === max_length}\nend",
"def find_longest_word(input_string)\n array = input_string.split(\" \")\n array.max_by {|word| word.length}\nend",
"def find_longest_word(string)\n sentence = string.split\n longest_word = \"\"\n sentence.each do |word|\n word.gsub!(/\\W/, \"\") # filters out non alphanumeric\n longest_word = word if word.length >= longest_word.length\n end\n longest_word\nend",
"def longest(string)\n if string.class == String\n words = string.split(' ').sort_by! {|word| word.length}\n words.last\n else\n nil\n end\nend",
"def longest_string(list_of_words)\n if list_of_words.length > 0\n longest_word = list_of_words[0]\n for word in list_of_words\n if word.length > longest_word.length\n longest_word = word\n end\n end\n return longest_word\n end\nend",
"def find_short(s)\n l = s.split(\" \").min_by { |x| x.length}.length\n return l #l: length of the shortest word\nend",
"def longest_word(phrase)\n longestWord = \"\"\n longestWordLength = 0\n \n wordArray = phrase.split(\" \")\n wordArray.each do |word|\n if word.length > longestWordLength\n longestWord = word\n longestWordLength = word.length\n end\n end\n return longestWord\nend",
"def longest_two_words(string)\n string.delete!(',.?:;\"!\"')\n word_arr = string.split(\" \").sort_by { |word| word.length }.reverse!\n word_arr[0..1]\nend",
"def longest_word(sentence)\nend",
"def longest_word(sentence)\nend",
"def find_short(s)\n return s.split(' ').min_by{|word| word.length}.length\nend",
"def longest_string(list_of_words)\n if list_of_words == []\n return nil\n elsif list_of_words == ['']\n return ''\n elsif list_of_words.length == 1\n return list_of_words[0]\n elsif\n sorted_words = list_of_words.sort_by { |x| x.length}\n return sorted_words[-1]\n end\nend",
"def longest_string(list_of_words)\n\tif list_of_words.size == []\n\t\treturn nil\n\telsif list_of_words.size == 1\n\t\treturn list_of_words[0]\n\telsif list_of_words.size >= 2\n\t\tlist_of_words.sort_by! {|word| word.length}\n\t\treturn list_of_words.last\n\tend\nend",
"def longest_two_words(string)\n string.split(\" \").sort_by { |word| word.length }[-2..-1]\nend",
"def longest_string(list_of_words)\n longest = list_of_words[0]\n list_of_words.each do |x|\n if x.length >= longest.length\n longest = x\n end\n end\n if list_of_words.empty?\n return nil\n end\nreturn longest\nend",
"def longest_two_words(string)\n string.gsub(/[[:punct:]]/, '').split.sort_by(&:length)[-2..-1]\nend",
"def longest_string(list_of_words)\n list_of_word = list_of_words.sort_by { |x| x.length }\n return list_of_word[-1]\nend",
"def find_longest_word(sentence)\n words = sentence.split\n # x = 0\n # y = words[x]\n z = words[0]\n\n words.each do |word|\n\n if word.length > z.length\n z = word\n end\n # x += 1\n end\n z\nend",
"def longest_two_words(string)\n string.split.sort_by { |word| word.length }[-2..-1]\nend",
"def longest_two_words(string)\n string.split.sort_by { |word| word.length }[-2..-1]\nend",
"def longest_word(sentence)\n\n arr = sentence.split\n idx = arr.length\n cmp = []\n\n n = idx\n while n >= 0\n\n word = arr[n].to_s\n word_length_string = word.length\n word_length_integer = word_length_string.to_i\n cmp.unshift(word_length_integer)\n\n n = n - 1\n end\n\n n = 0\n longest_length = 0\n position = 0\n while n < cmp.length\n if cmp[n] > longest_length\n longest_length = cmp[n]\n position = n\n end\n n = n + 1\n end\n\nreturn arr[position]\n\nend",
"def find_longest_word(string)\n array = string.split(\" \")\n p array\n array.max_by(&:length) \nend",
"def longest_two_words(string)\n string.delete!(\",.:;?!\")\n string.split.sort_by {|x|x.length}[-2..-1]\n\nend",
"def longest_string(list_of_words)\n\tif list_of_words == []\n\t\treturn nil\n\telsif list_of_words == [\" \"]\n\t\treturn \" \"\n\telse\n\t\tstring_length = []\n\t\tlist_of_words.each do |string|\n\t\t\t string_length.push string.length\n\t\tend\n\t\tlist_of_words.each do |string|\n\t\t\tif string_length.max == string.length\n\t\t\t\treturn string\n\t\t\tend\n\t\tend\n\n\tend\n\nend",
"def longest_two_words(string)\n words = string.split(\" \")\n words.sort_by! {|x| x.length }\n words[-2..-1]\nend",
"def longest_string(list_of_words)\n if list_of_words.size != 0\n longest_str = list_of_words.max_by{|a| a.size}\n return longest_str\n else\n end\nend",
"def longest_word(sentence)\n\n#split sentence in words kept in array words \nwords = sentence.split(\" \")\n\n# sets up empty variable longest_word (is this not definted already...?)\nlongest_word = nil \n\n#sets up counter, sets equal to 0 \nwords_idx = 0 \n\n#sets up while statement, constrains loops \nwhile words_idx < words.length\n#defines current words as word position in array based on counter \ncurrent_word = words[words_idx]\n\n#if the longest word is nil (it is, set equal to nil above)\nif longest_word == nil \n #then the longest word is whatever position you are at \n longest_word == current_word\n \n #if the longest word length (nil?) is less than the length of current word length \n #(remember current word is at position word_idx)\n elsif longest_word.length < current_word.length\nlongest_word = current_word \nend\n\nwords_idx += 1 \nend \n\nreturn longest_word\nend",
"def longest_word(str)\n arr = str.split()\n sortedArr = arr.sort_by!(&:length).reverse! \n p sortedArr[0]\nend",
"def longest_string(list_of_words)\n # Your code goes here!\n longest = list_of_words[0]\n\n list_of_words.each { |word| \n if word.length > longest.length\n longest = word\n end\n }\n\n return longest\nend",
"def longest_string(list_of_words)\n # length = list_of_words.length\n if list_of_words == []\n return nil\n else\n return list_of_words.max_by { |x| x.length }\n end\nend",
"def longest_string(list_of_words)\n\treturn list_of_words.max {|x,y| x.length <=> y.length}\nend",
"def longest_string(list_of_words)\n # Your code goes here!\n if list_of_words.length == 0 then return nil\n end\n longest_word = list_of_words.max_by { |x| x.length }\n return longest_word\nend",
"def find_short(s)\n # your code here\n the_1st_array = s.split(\" \")\n this_counts = []\n i = 0\n while i < the_1st_array.count\n this_counts.push(the_1st_array[i].length)\n i+=1\n end\n l = this_counts.min\n return l # l: length of the shortest word\nend",
"def longest_string(str)\n str = str.split(\" \")\n longest = 0\n for st in str do\n if st.length > longest\n longest = st.length\n end\n end\n return longest\nend",
"def longest_two_words(string)\n arr = string.split(' ')\n sorted = arr.sort_by {|str| str.length}\n sorted[-2..-1]\nend",
"def longest_string(list_of_words)\n i=0\n long_string=list_of_words[0]\n list_of_words.each do\n if list_of_words[i].length>long_string.length\n long_string=list_of_words[i]\n end\n i+=1\n end\n return long_string\nend",
"def longest_string(list_of_words)\n list_of_words.max { |a,b| a.size <=> b.size }\n\nend",
"def longest_word(sentence)\r\n arr = sentence.split\r\n arr_length = arr.length\r\n puts(\"Array length: \" + arr_length.to_s)\r\n idx1 = 0\r\n idx2=idx1 + 1\r\n str_length1 = 0\r\n str_length2 = 0\r\n biggest = 0\r\n if arr_length == 1\r\n return arr[0]\r\n end\r\n while idx1 < arr_length\r\n while idx2 < arr_length\r\n str_length1 = arr[idx1].length\r\n str_length2 = arr[idx2].length\r\n # puts(str_length1)\r\n # puts(str_length2)\r\n if(str_length1 > str_length2)\r\n biggest = arr[idx1]\r\n idx1 = idx1 + 1\r\n idx2 = idx2 + 1\r\n # puts(biggest)\r\n else\r\n biggest = arr[idx2]\r\n idx1 = idx1 + 1\r\n idx2 = idx2 + 1\r\n # puts(biggest)\r\n end\r\n end\r\n return biggest\r\n end\r\nend",
"def longest_string(list_of_words)\n\tif list_of_words.length == 0\n\t\treturn nil\n\tend\n\ti = list_of_words[0]\n\tj = 1\n\twhile j <= list_of_words.length - 1 do\n\t\tif i.length < list_of_words[j].length\n\t\t\ti = list_of_words[j]\n\t\tend\n\t\tj = j + 1\n\tend\n\treturn i\nend",
"def longest_string(list_of_words)\n index = 0\n counter = 1\n if list_of_words == []\n return nil\n end\n until counter == list_of_words.length\n if list_of_words[index].length > list_of_words[counter].length\n counter += 1\n else\n index = counter\n counter += 1\n end\n end\n return list_of_words[index]\nend",
"def longest(str)\n count = 0\n str.split(\" \").each {|word| count = word.length if word.length > count}\n p count\nend",
"def longest_string(list_of_words)\n # Your code goes here!\n if list_of_words.length == 0\n \treturn nil\n end\n var = list_of_words[0]\n for i in 1 ... list_of_words.length\n \tif i == list_of_words.length\n \t\treturn var\n \telsif var.length < list_of_words[i].length\n \t\tvar = list_of_words[i]\n \tend\n \ti+=1\n end\n return var\nend",
"def longest_two_words(string)\n str_arr = string.split.sort_by {|el| el.length}\n [str_arr[-2],str_arr[-1]]\nend",
"def longest_two_words(string)\n arr = string.split.sort_by(&:length)\n [arr[-1], arr[-2]]\nend",
"def longest_sentence(string)\n sentences = string.split(/[.?!]/)\n sentences.sort_by! { |sentence| sentence.split(' ').size }\n\n sentences.last.split(' ').size\nend",
"def find_short(sentence)\n word_array = sentence.split\n\n word_array.sort! do |word_a, word_b|\n word_a.length <=> word_b.length\n end\n\n return word_array.first.length\nend",
"def longest_string(list_of_words)\n # Your code goes here!\n\n return list_of_words.max_by {|word| word.length}\n\n # max = nil\n #\n # if list_of_words == []\n # return max\n # else\n # max = list_of_words[0]\n # for i in 0...list_of_words.length\n # if list_of_words[i].length > max.length\n # max = list_of_words[i]\n # end\n # end\n # end\n #\n # return max\nend",
"def longest_two_words(string)\n string = string.delete(\".,\")\n words = string.split(\" \")\n words.sort_by {|word| word.length}[-2..-1]\n\nend",
"def longest_sentence(str)\n str.gsub(/[?!]/, '.').split('.').sort_by { |sentence| sentence.length }.pop.split.length\nend",
"def longest_string(list_of_words)\n longest = nil\n list_of_words.each do |words|\n if longest.nil? || longest.length < words.length\n longest = words\n end\n end\nlongest\nend",
"def longest_two_words(string)\n sorted = string.split.sort_by {|word| word.length}\n [sorted[-2], sorted[-1]]\nend",
"def find_short(s)\n return s.split(\" \").map { |word| word.length }.min\nend",
"def longest_string(list_of_words)\n list_of_words.max { |a, b| a.length <=> b.length }\n end",
"def longest_string(list_of_words)\n\tif list_of_words==[]\n\t\tnil\n\telse\n\t\tlist_of_words.max_by {|x| x.length}\n\tend\nend",
"def linear_longest_word(arr)\n max_length=0\n max_str=arr[0]\n arr.each do |str| \n curr_length=str.length\n if curr_length>max_length\n max_length=curr_length\n max_str=str\n end\n end\n max_str\nend",
"def longest_string(list_of_words)\n longestword = list_of_words.pop\n\n\n while list_of_words.count > 0 do\n word = list_of_words.pop\n if longestword.length < word.length\n longestword = word\n end\n end\n p longestword\nend",
"def find_short(s)\n # input is string\n # convert string to array\n converted = s.split(\" \") # gives us an array of words\n # order elements of array by length\n sorted_by_length = converted.sort_by {|x| x.length}\n # returns an array of words sorted by length\n # return the first element in array\n return sorted_by_length[0].length\n \nend",
"def longest_string(list_of_words)\n if list_of_words == []\n p nil\n else\n words_and_lengths = {}\n list_of_words.each do |word|\n words_and_lengths[word.length] = word\n end\n p words_and_lengths\n longest_length = list_of_words[0].length\n words_and_lengths.each do|length, word|\n if length > longest_length\n longest_length = length\n end\n end\n p words_and_lengths[longest_length]\n end\nend",
"def longest_string(list_of_words)\n long_string = list_of_words[0]\n counter = 0\n while counter < list_of_words.length\n if long_string.length < list_of_words[counter].length\n long_string = list_of_words[counter]\n end\n counter += 1\n end\n p long_string\n #return list_of_words.sort {|x,y| y.length <=> x.length}[0]\nend",
"def longest_string(arr)\n arr.max_by { |word| word.length }\nend",
"def longest (string)\n length_string = getlength(string)\n string.each do |word|\n if word.length == length_string.max\n puts word\n end\n end\nend",
"def longest_string(list_of_words)\n long_string = list_of_words[0]\n list_of_words.each do |measure|\n if long_string.size < measure.size\n long_string = measure\n end\n\n end\n p long_string\nend",
"def length_of_last_word(s)\n split_string = s.split\n split_string[-1] ? split_string[-1].length : 0\nend",
"def shortest_string(list_of_words)\n return nil if no_string?(list_of_words)\n return list_of_words[0] if one_string?(list_of_words)\n \telse\n \t\tfirst_word = list_of_words[0]\n \t\tx = 1\n \t\twhile x < list_of_words.length\n \t\t\tif first_word.length > list_of_words[x].length\n \t\t\t\tfirst_word = list_of_words[x]\n \t\t\tend\n \t\t\tx += 1\n \t\tend\n \t\treturn first_word\nend",
"def length_of_last_word(string1)\n # Breakdown the sentence into words\n words = string1.split(\" \")\n\n # Recognize the last word in the sentence (making sure there is a sentence, and it has values)\n # Retrieve the number of characters in the last word\n if words.length != 0 && words != 0\n last = words[(words.size)-1].length\n return last\n else\n return 0\n end\n\nend",
"def shortest_string(list_of_words)\n if list_of_words == []\n \treturn nil\n else\n \tcounter = 0\n \tshortest_word = ''\n \tshorest_word_length = list_of_words[0].length\n \twhile counter < list_of_words.length\n \t\tif shorest_word_length >= list_of_words[counter].length\n \t\t\tshortest_word = list_of_words[counter]\n \t\tend\n \tcounter += 1\n \tend\n end\n return shortest_word\nend",
"def longest_string(list_of_words)\n initial = list_of_words.kind_of?(Array) && list_of_words[0] != nil ? '' : nil\n\nreturn initial if initial == nil\n\nfor i in 0...list_of_words.length\n curr_val = list_of_words[i] if list_of_words[i].instance_of? String\n puts list_of_words[i].length\n initial = curr_val if i == 0 || initial.length < curr_val.length\nend\n\ninitial\nend",
"def length_of_last_word(s)\n new_s = s.split(\" \")\n if new_s == []\n return 0\n else\n new_s[-1].size\n end\nend",
"def lengthOfLastWord(s)\n lastWordLength = 0\n if s.length == 0 \n return lastWordLength\n end\n\n s.chars.reverse_each { |x| \n if x != ' '\n lastWordLength += 1\n elsif lastWordLength != 0\n return lastWordLength\n end\n }\n lastWordLength\nend"
] | [
"0.896335",
"0.8898313",
"0.88247263",
"0.87739486",
"0.8490838",
"0.84627956",
"0.837038",
"0.8263723",
"0.8261048",
"0.8164274",
"0.8097665",
"0.80245733",
"0.79955196",
"0.7969295",
"0.79236513",
"0.7911946",
"0.7903026",
"0.7902575",
"0.7897251",
"0.78526926",
"0.78202397",
"0.78091705",
"0.7807706",
"0.77998286",
"0.77937883",
"0.7781077",
"0.77772045",
"0.7762224",
"0.7727369",
"0.7669476",
"0.7662983",
"0.76555747",
"0.76428705",
"0.75578946",
"0.7531277",
"0.7510548",
"0.7447425",
"0.7410466",
"0.7400967",
"0.7399281",
"0.7399281",
"0.73607236",
"0.7326417",
"0.7303304",
"0.7291858",
"0.72907233",
"0.7278327",
"0.72769886",
"0.7259615",
"0.72552276",
"0.72552276",
"0.7253866",
"0.7246359",
"0.7215924",
"0.7202807",
"0.71949345",
"0.7190923",
"0.7169666",
"0.7167399",
"0.7152922",
"0.71515363",
"0.71513695",
"0.7125492",
"0.7118842",
"0.71067214",
"0.71036977",
"0.71036",
"0.71025115",
"0.70814186",
"0.7078883",
"0.7075012",
"0.70374954",
"0.7032254",
"0.7019922",
"0.7015288",
"0.7009559",
"0.7003391",
"0.70032066",
"0.6993899",
"0.6987083",
"0.69855565",
"0.6979236",
"0.6967373",
"0.6955463",
"0.6950163",
"0.6938434",
"0.691031",
"0.6881965",
"0.6879279",
"0.6867489",
"0.6867267",
"0.6847241",
"0.68414223",
"0.6838362",
"0.68128103",
"0.67972517",
"0.679069",
"0.678985",
"0.67638355",
"0.67553824"
] | 0.8614654 | 4 |
add some books into inventory | def purchase_books(newbooks)
newbooks.each {|book, number| inventory[book] = number}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addBook(book)\n\t\tinventories.create(book_id: book.id)\n\tend",
"def add_book(book)\n current_item = line_items.find_by(book_id: book.id)\n if current_item\n current_item.quantity +=1\n else\n current_item = line_items.build(book_id: book.id)\n end\n current_item\n end",
"def add_to_inventory(item)\n @inventory.push(item)\n update\n end",
"def add(num)\n #item = '9781133049791'\n item = num.fetch(\"isbn\")\n if !Book.pluck(:isbn).include?(item)\n @res = Amazon::Ecs.item_search(item, { :search_index => 'All', :response_group => 'Medium' })\n @res.items.each do |book|\n @db = Book.create\n @db.isbn = item\n @db.author = book.get('ItemAttributes/Author')\n @db.name = book.get('ItemAttributes/Title')\n @db.edition = book.get('ItemAttributes/Edition').to_i\n @db.retail_price = ((book.get('ItemAttributes/ListPrice/Amount').to_f/100)*3.65).to_i\n @db.description = book.get('EditorialReviews/EditorialReview/Content')\n @db.photo = book.get('LargeImage/URL')\n @db.save\n end\n end\n @thisBook = Book.find(:all, :conditions => {:isbn => item})\n redirect_to @thisBook\n end",
"def add_book_to_inventory_by_book_title(new_book_title)\n new_book_array =\n {\n title: new_book_title,\n rental_details: {\n student_name: \"\",\n date: \"\"\n }\n }\n new_book_title != @title\n @inventory.push(new_book_array)\nend",
"def add_book(book)\n\t\t@books.push(book)\t\n\tend",
"def add(book)\n\t\t @books << book\n\tend",
"def add_book(book)\n @books << book\n end",
"def add_book(book)\n @books.push(book)\n puts \"You've added '#{book.title}' to the Library.\"\n puts \"You know have \" + @books.length.to_s + \" books in the Library.\"\n end",
"def add_books(books)\n books.each do |book|\n @books.push(book)\n end\n end",
"def add_book(book)\n @books << book\n puts \"Added \" + book.title + \" to the library.\"\n end",
"def add( book )\n @books.add( Books::Book.new( book ))\n end",
"def load_inventory(library, book, stock)\n inventory = Inventory.add_book_to_library(library, book, stock)\n puts \"#{library.name} has a stock of #{stock} of #{book.title}\"\nend",
"def add_my_books(book)\n\t\t@my_books << book.title\n\tend",
"def add_item(barcode, name, price)\n @barcodes << barcode\n @names << name\n @prices << price\n end",
"def add_book(book)\n @books.push(book)\n end",
"def add_to_inventory(price, description)\n\t\tself.items << Item.new(price, description)\n\tend",
"def add_book(book)\n\t\t@books << book\n\t\t@book_status[book.title] = book.get_status\n\tend",
"def create\n # Check if this book is in the system\n @book = Book.find_by(id: book_item_params[:book_id])\n if @book == nil \n # Meaning this book is not added to database and \n # book_item_params[:id] is Goodread id\n @book = save_goodreads_book(book_item_params[:book_id])\n book_item_params[:book_id] = @book.id\n end\n # Check if this book_item already in this shelf\n shelf = Shelf.find(book_item_params[:shelf_id])\n @book_item = shelf.book_items.new(book_item_params)\n \n if shelf.save!\n flash[:success] = \"Book item was successfully created.\"\n redirect_to current_user\n else\n flash[:error] = \"Cannot add book to Bookshelf\"\n redirect_to current_user\n end\n end",
"def create\n if book_item_params[:quantity].to_i > 0 \n @book = Book.find(book_item_params[:book_id]) if !book_item_params[:book_id].blank?\n if @book.blank? \n @book = Book.find_or_create_by(goodreads_id: book_item_params[:goodreads_id])\n @book.update_goodreads_info\n end\n # Check if this book_item already in this shelf\n @book_item = BookItem.find_or_create_by(shelf_id: book_item_params[:shelf_id], book_id: @book.id)\n @book_item.quantity = book_item_params[:quantity]\n @book_item.available_count = book_item_params[:quantity]\n \n if @book_item.save!\n flash[:success] = \"You got a book.\"\n else\n flash[:error] = \"Something wrong.\"\n flash[:error] = @book_item.errors.full_messages.to_sentence\n end\n else \n book_id = (book_item_params[:book_id] || Book.find_by(goodreads_id: book_item_params[:goodreads_id].to_i).presence.try(:id))\n @book_items = BookItem.where(\"shelf_id = ? AND book_id = ?\", book_item_params[:shelf_id], book_id) if book_id.present?\n if @book_items.present?\n @book_items.destroy_all \n flash[:warning] = \"Book removed.\"\n else\n flash[:warning] = \"Mission impossible.\"\n end\n end\n redirect_to :back\n end",
"def add_book(book_title)\n @books << {\n title: book_title,\n rental_details: {\n student_name: \"\",\n date: \"\"\n }\n }\n end",
"def add_to_inventory(item)\n @items << item\n equip(item)\n items_weight\n end",
"def add_item(inventory, item, quantity)\n\tinventory[item] = quantity\n\t@full_inventory = inventory\n\t#this is what updates your inventory with the new item & quantity.\nend",
"def add_book(book)\n self.book_lists.create(:book_id => book.id)\n end",
"def add_book(title)\n new_book = {\n title: title,\n rental_details: {\n student_name: \"\",\n date: \"\"\n }\n }\n @books.push(new_book)\n return @books.length\n end",
"def put_item_in_inventory(input)\n\n if find_item_by_id(input).canBePickedUp\n unless @inventory.include?(input)\n @inventory << input\n slow_type(\"\\nYou have picked up the #{find_item_by_id(input).name}.\")\n end\n\n else\n slow_type(\"You cannot pick up this item\")\n end\n end",
"def add_read_book(book)\n self.read_books.create(:read_book_id => book.id)\n end",
"def add_book author, title\n books = @books[author]\n if books\n if books.include? title\n puts \"That book is already in the system\"\n else\n books << title\n end\n else\n puts \"No such author\"\n end\n end",
"def add(beer)\n \t$catalogue << beer\n end",
"def add_pet_to_stock(pet_shop, new_pet)\n pet_shop [:pets].push (new_pet)\nend",
"def rebook item, book\n if (item.price > 0)\n # item represents new aggr_order with price\n item.order_book = book unless item.order_book\n book.add item # добавляем в стакан\n else\n # item clears previous aggr_order for given price\n item.order_book = nil\n end\n end",
"def add_pet_to_stock(pet_shop, new_pet)\n pet_shop[:pets] << new_pet\nend",
"def add_new_library_book\n\t\tputs \"To add new book to library, You need to enter book name and book's author name\"\n\t\tprint \"\\tEnter New Book name:\"\n\t\tnew_book_name=gets.chomp\n\t\tprint \"\\tEnter Author name:\"\n\t\tnew_book_author_name=gets.chomp\n\t\t@last_book_id=@last_book_id+1\n\t\tbook=Book.new(@last_book_id,new_book_name,new_book_author_name,-1)\n\t\t@books.push(book)\n\t\tputs \"New book '#{new_book_name}' has been added to library with book ID #{@last_book_id}\"\n\tend",
"def add_book(quantity)\n \n #increase the quantity and available for loaning\n self.quantity += quantity\n self.available += quantity\n\n #save the model\n self.save\n end",
"def add_book(book)\n if book.is_a? Book # This test does not work as intended. I get a NameError undefined local variable.\n @books << book\n puts \"#{book.title} by #{book.author} has been added to the library.\"\n else\n puts \"That is not a book. Try again.\"\n end\n end",
"def add_to_basket\n if Basket.exists?(user_id: params[:user_id], book_id: params[:book_id])\n @basket = Basket.find_by(user_id: params[:user_id], book_id: params[:book_id])\n @basket.increment!(:amount)\n else\n Basket.create(user_id: params[:user_id], book_id: params[:book_id], amount: 1)\n end\n redirect_to my_basket_path(params[:user_id])\n end",
"def add_item(item)\n item = Item.find item unless item.is_a? Item\n $logger.debug{\"#{self} add #{item}\"}\n items << item\n inventory << item.id\n item\n end",
"def create\n id = params[:id].to_i\n qty = params[:qty].to_i\n \n cart_books = session[:cart].map { |c| c[0] }\n \n if cart_books.include?(id)\n session[:cart][cart_books.index(id)] = [id, qty]\n else\n session[:cart] << [id, qty]\n end\n \n # @cart_qty = session[:cart][cart_books.index(id)][1].to_i\n \n redirect_back(fallback_location: root_path)\n \n # logger.debug(\"Cart Create triggered\")\n # logger.debug(\"Adding book id #{params[:id]}\")\n end",
"def add_book(book)\n binding.pry\n self.books << book\n book.author = self\n end",
"def save_to_inventory\n @user = User.find(params[:id])\n @item = Item.find(1)\n @user.items.push(@item)\n end",
"def add_to_inventory(category, product, quantity, price, refid)\n @inventory = {\n category => [\n product: product,\n quantity: quantity,\n price: price,\n refid: refid\n ]\n}\nend",
"def add_pet_to_stock(pet_shop, new_pet)\n pet_shop[:pets].push(new_pet)\nend",
"def add_pet_to_stock(pet_shop, new_pet)\n pet_shop[:pets].push(new_pet)\nend",
"def add_pet_to_stock(pet_shop, new_pet)\n pet_shop[:pets].push(new_pet)\nend",
"def add_pet_to_stock(pet_shop, new_pet)\n pet_shop[:pets].push(new_pet)\nend",
"def add_pet_to_stock(pet_shop, new_pet)\n pet_shop[:pets].push(new_pet)\nend",
"def add_pet_to_stock(shop, new_pet)\n shop[:pets] << new_pet\nend",
"def add_book_google\n book = Book.create(book_params)\n \n if book.valid?\n #Book was added to library\n #Add book to users bookshelf\n user = User.find_by_id(params[:user_id])\n \n shelf = user.bookshelves.first\n shelf.books << book\n \n shelf = user.bookshelves.first\n pp shelf.shelfitems\n \n if params[:finished] == \"true\"\n shelf.shelfitems.last.finished = true\n #shelf.shelfitems.last\n shelf.shelfitems.last.save\n end\n #si.finished = params[:finished]\n #si.save\n \n render json: {msg: \"Successfully created \" + book.title, shelf: shelf.books}, :status => :created\n else\n render json: {e: \"Error creating book\"}, :status => :error\n end\n end",
"def add_pet_to_stock(shop, new_pet)\n shop[:pets] << new_pet\nend",
"def lend_books(books, user)\n\t\tif @users.include? user then\n\t\t\tbooks.uniq.each do |book| \n\t\t\t\tif inventory[book] > 0 then\n\t\t\t\t\tinventory[book] -= 1\n\t\t\t\t\tadd_a_record(user, book)\n\t\t\t\telse\n\t\t\t\t\tputs \"Sorry, <#{book.title}> is unavailable.\"\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def add_book(book_title_str)\n # is the book not already present in @books list?\n for book_hash in @books\n if book_hash[:title] == book_title_str\n return \"Such book is already in the library\"\n end\n end\n\n new_book = {\n title: book_title_str,\n rental_details: {\n student_name: \"\",\n date: \"\"\n }}\n\n @books.push(new_book)\n\n end",
"def add_pet_to_stock(shop, new_pet)\n shop[:pets].push(new_pet)\nend",
"def add_item(item)\n item.item_number = @@item_number\n @@item_number += 1\n @grocery_item << item\n\n # starting the logic for finding out what type of item it is and if it will be\n # allowed to be taxed. < -- Continue here\n if @grocery_item.item_type == \"books\"\n\n end\n\n\n\nend",
"def add_pet_to_stock(shop_name, new_pet)\n shop_name[:pets] << new_pet\nend",
"def inInventory?(book)\n\t\tbooks.include?(book)\n\tend",
"def add_item(title, price, quantity=1)\n self.total += price * quantity\n #quantity amount of times it'll add the title to the items array\n quantity.times {items << title}\n self.last_transaction = price * quantity\n end",
"def book_inventory\n\t\t@library = Library.find(params[:id])\n\t\t\n\t\tif params[:title_search]\n\t\t\t@inventory = Inventory.joins(:book).where(\"library_id = ? and books.title like ?\", @library.id, \"#{params[:title_search]}%\")\n\t\t\t\n\t\telsif params[:isbn_search]\n\t\t\t@inventory = Inventory.joins(:book).where(\"library_id = ? and books.isbn = ?\", @library.id, params[:isbn_search])\n\n\t\telse\n\t\t\t@inventory = Inventory.where(\"library_id = ?\", @library.id)\n\t\tend\n\n\t\t#redirect_to books_library_path(@inventory)\n\tend",
"def add_pet_to_stock(petshop,new_pet)\n petshop[:pets].push(new_pet)\n return petshop\n end",
"def add_pet_to_stock(pet_shop, pet)\n pet_shop[:pets].push(pet)\nend",
"def add_pet_to_stock(shop, pet)\n shop[:pets] << pet\nend",
"def add_item(item)\n @inventory.push(item)\n if item.include? \"weapon\"\n @weapon = item\n end\n end",
"def brief_vendor_add_item\n brief = Brief.find(params[:brief_id])\n brief_vendor = brief.brief_vendors.find_by_org_id(params[:vendor_id])\n brief_vendor.items << Item.new{|r| r.parent_id = params[:item_id]}\n\n redirect_to(cheil_brief_vendor_items_path(params[:brief_id],params[:vendor_id])) \n end",
"def add_book\n print \"What is the name of the book you would like to add? \"\n name = gets.chomp\n print \"What is the type of the book you would like to add? \"\n type = gets.chomp\n case type\n when \"paper book\"\n PaperBook.new(name, type)\n @books << [name, type]\n puts \"You have added #{name}!\"\n when \"ebook\"\n Ebook.new(name, type)\n @books << [name, type]\n puts \"You have added #{name}!\"\n when \"audiobook\"\n Audiobook.new(name, type)\n @books << [name, type]\n puts \"You have added #{name}!\"\n else\n puts \"That's not a book format we recognize.\"\n end\n end",
"def add_item(item_list, item, qty)\r\n item_list[item] = qty\r\n item_list\r\nend",
"def add_item (title, price, quantity = 1)\n i = 0\n while i < quantity\n @items << title\n i += 1\n end\n my_price = price * quantity\n @transactions << my_price\n @total += (price * quantity)\n end",
"def approve_items(with_product)\n items = InventoryItem.where(name: name, unit_id: unit_id, category_id: category_id).where(\"type is null and product_id is null\").where(\"id <> ?\", id)\n items << self\n items.each do |item|\n item.name = \"#{with_product.name} \"#(#{with_product.unit_name})\"\n item.unit_id = with_product.unit_id\n item.product_id = with_product.id\n item.save(:validate => false)\n end\n end",
"def addBooks()\n ch = 1\n while ch == 1\n puts \"Enter Book Title: \"\n title = gets\n puts \"Enter Book Author: \"\n author = gets\n puts \"Enter Publication: \"\n publication = gets\n puts \"Enter Rack number: \"\n rack_no = gets\n puts \"Enter publication year: \"\n year = gets\n puts \"Total number of copies: \"\n total_copies = gets\n\n @@bookid_count+=1\n \n book = Book.new(@@bookid_count, title, author, publication, year, rack_no, total_copies, total_copies)\n @books.push(book)\n\n puts \"Add more books? Enter 1 or 0. YES=1, NO=0 \"\n ch = gets.to_i\n end\n end",
"def set_book\n @book = Book.find(params[:id])\n @cartitems = @book.cartitems\n end",
"def add_item (title, price, quantity = 1)\n # adds purchase price to total\n @total += price * quantity\n # Adds proper quanity of item to cart\n count = 0\n while count < quantity\n @items << title\n count += 1\n end\n # keeps track of last_added item\n @last_transaction[:item] = title\n @last_transaction[:price] = price\n @last_transaction[:quantity] = quantity\n\n end",
"def add_book(title)\n \nend",
"def add_pet_to_stock(pet_shop, new_pet)\n pet_shop[:pets].push(new_pet)\n return pet_shop[:pets].count()\nend",
"def inc_books\n\t\t@books += 1\n\tend",
"def add_item(title, price, quantity=1) \n self.total += price * quantity\n quantity.times do\n items << title \n end\n self.last_transaction = price * quantity\n\n end",
"def add_pet_to_stock(shop, new_pet)\n return shop[:pets].push(new_pet)\nend",
"def add_item (grocery_list, grocery_item)\n grocery_list.store(grocery_item, 0)\nend",
"def add_item(hash,item)\n hash[:inventory].push(item)\nend",
"def add_to_listbooks\n self.isbn.each do |isbn|\n book = Listbook.find_or_create_by(isbn: isbn)\n self.listbooks << book unless self.listbooks.include? book\n book.save!\n end\n self.pinned_isbn.each do |isbn|\n book = Listbook.find_or_create_by(isbn: isbn)\n self.listbooks << book unless self.listbooks.include? book\n book.save!\n end\n\n self.listbooks.uniq!\n end",
"def add_item(grocery_list, item, qty)\n grocery_list[item] = qty \n grocery_list\nend",
"def add_book\n\tputs \"\\nTo add a new book please enter the following requested information:\\n\"\n\tprint \"Book Title \"\n\ttitle = gets.chomp\n\tprint \"Book Author \"\n\tauthor = gets.chomp\n\tprint \"Book ISBN \"\n\tisbn = gets.chomp\n\tprint \"Book Home Library \"\n\tlibrary_id = gets.chomp.to_i\n\tlibrary_id = verify_library_exists(library_id)\n\tBook.create(title: title, author: author, isbn: isbn, library_id: library_id)\nend",
"def add_pet_to_stock (pet_shop, new_pet)\nreturn pet_shop[:pets].push (new_pet)\nend",
"def add_pet_to_stock(shop,new_animal)\n shop[:pets] << new_animal\nend",
"def add_item(item_name, grocery_list, quantity=1)\n grocery_list[item_name] = quantity\n grocery_list\n end",
"def add_item (grocery, item_name, quantity)\n grocery[item_name] = quantity\n display_list(grocery)\n end",
"def update(list, item, qty)\n add_item(list, item, qty)\nend",
"def add_item(item, grocery_bag, quantity = 1)\n grocery_bag[item] = quantity\n print grocery_bag\nend",
"def build_inventory\n add_to_inventory(\"cats\", 4, 50.0)\n add_to_inventory(\"dogs\", 10, 150.0)\n add_to_inventory(\"unicorn\", 1, 1000.0)\nend",
"def create\n @book = params[:book]\n add(@book)\n end",
"def add_to_shelf(shelf, book_id)\n\t\toptions = {\"book_id\" => book_id, \"shelf\" => shelf}\n\t\tdata = oauth_request(\"/shelf/add_to_shelf.xml\", options, method = \"post\")\t\n\t\treturn data\n\tend",
"def add_to_cookbook(recipe)\n @cookbook.push(recipe)\n end",
"def item_create\n @brief = Brief.find(params[:brief_id])\n @brief_vendor = @brief.brief_vendors.find_by_org_id(@cur_user.org_id)\n invalid_op unless @brief_vendor\n @brief_vendor.items << Item.new(params[:item]){|r|r.kind = params[:kind]}\n redirect_to vendor_show_brief_path(@brief)\n end",
"def update_inventory\n response = LcboApiHelper.get_all \"inventories\", [\"product_id=#{number}\", \"where_not=is_dead\"]\n\n response.each do |inventory|\n lcbo_updated_on = inventory[\"updated_on\"].to_date\n next if Inventory.exists?(lcbo_updated_on: lcbo_updated_on, store_id: inventory['store_id'], product: self)\n Inventory.create(\n product: self,\n store_id: inventory['store_id'],\n quantity: inventory[\"quantity\"],\n lcbo_updated_on: lcbo_updated_on,\n lcbo_updated_at: Time.parse(inventory[\"updated_at\"]).getutc\n )\n end\n end",
"def add_item(title, amount, quantity=1)\n self.total += amount * quantity\n quantity.times do\n items << title\n end\n self.last_transaction = amount * quantity\n end",
"def store_book(shelf_num, book)\n\t\tif shelf_num > @shelves.length - 1 && shelf_num < 0\n\t\t\tputs \"Shelf does not exist\"\n\t\telse\n\t\t\t@shelves[shelf_num].add_book(book)\n\t\t\tbook.enshelf(shelf_num)\n\t\tend\n\tend",
"def add_pet_to_stock( pet_shop, new_pet )\n\n return pet_shop[:pets].push( new_pet )\n\nend",
"def add(product)\n items.create(product: product)\n end",
"def add_item(list,item_name, qty)\n list[item_name] = qty\nend",
"def test_add_book__A\n\n new_book = \"50_adventures_in_ruby_programming\"\n\n @library1.add_book(new_book)\n\n # Check last book in catalogue = book added\n\n assert_equal(new_book, @library1.books.last[:title])\n\n end",
"def add_item(new_item)\n item = Item.new(new_item)\n items.push(item)\n end",
"def add_pet_to_stock(pet_shop,new_customer)\n pet_shop[:pets]<<new_customer\n return\nend",
"def add_units(qty)\n qty.to_i.times do\n #create item\n item = supply_items.new\n item.status = SupplyItem::STATUS_AVAILABLE\n item.save\n end\n end"
] | [
"0.7751378",
"0.75770247",
"0.7140081",
"0.71239245",
"0.70976305",
"0.70146227",
"0.70124143",
"0.6956679",
"0.69466984",
"0.69409853",
"0.6938078",
"0.6936585",
"0.6927334",
"0.6874041",
"0.68431854",
"0.6842158",
"0.6809074",
"0.67954046",
"0.67708445",
"0.67566246",
"0.6722815",
"0.6721547",
"0.66340244",
"0.66024804",
"0.652883",
"0.64951026",
"0.6490927",
"0.6482257",
"0.6457038",
"0.64378506",
"0.6429489",
"0.6358077",
"0.6346277",
"0.633045",
"0.6309771",
"0.6308038",
"0.6296043",
"0.62855226",
"0.627986",
"0.62794304",
"0.6268624",
"0.6260206",
"0.6260206",
"0.6260206",
"0.6260206",
"0.6260206",
"0.62490195",
"0.6247845",
"0.6228244",
"0.6218962",
"0.6210718",
"0.6209743",
"0.6179952",
"0.6174641",
"0.61619186",
"0.6159991",
"0.6151468",
"0.6149816",
"0.61370564",
"0.61247426",
"0.61036605",
"0.61000365",
"0.6094565",
"0.6094148",
"0.60887027",
"0.6086259",
"0.60812783",
"0.60754704",
"0.6062332",
"0.60593486",
"0.6055895",
"0.6032383",
"0.60232204",
"0.6020602",
"0.6016025",
"0.60026807",
"0.59922576",
"0.5985763",
"0.59762573",
"0.59739995",
"0.5964871",
"0.59634286",
"0.5962944",
"0.59600264",
"0.59565824",
"0.5951098",
"0.5948008",
"0.59475225",
"0.5942942",
"0.59408677",
"0.5937123",
"0.5936725",
"0.59244156",
"0.59146124",
"0.5912255",
"0.5908654",
"0.5907509",
"0.590649",
"0.59011674",
"0.5900744"
] | 0.7760547 | 0 |
A user can only borrow one for each kind of books. | def lend_books(books, user)
if @users.include? user then
books.uniq.each do |book|
if inventory[book] > 0 then
inventory[book] -= 1
add_a_record(user, book)
else
puts "Sorry, <#{book.title}> is unavailable."
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def borrow(book_id, user_id)\r\n @@books.each do |book|\r\n @@users.each do |user|\r\n if book.bookID == book_id && user.userID == user_id\r\n if book.status == \"available\"\r\n book.borrower = (user.fname+\" \"+user.lname)\r\n book.status = \"borrowed\"\r\n user.bookBorrowed = book.title\r\n puts(\"\\nFollowing user has borrowed the following book: \")\r\n puts(\"User : #{user.inspect}\")\r\n puts(\"Book : #{book.inspect}\")\r\n else\r\n puts \"\\nSorry! the selected book #{book.bookID} is currently not available and cannot be lend to #{user.userID}; \\nbecause it is borrowed by user : #{book.borrower}\" end\r\n end\r\n end\r\n end\r\n end",
"def borrowBook()\n puts \"Enter the user name: \"\n user_name = gets.chomp\n\n # check if the user name is valid\n if isUserValid?(user_name)\n then\n # check if the user's book limit is exceeded\n if !isUserBookLimitExceeded?(user_name)\n then\n puts \"\\nEnter the book to be borrowed: \"\n book_name = gets.chomp\n # check if the requested book is available\n if isBookAvailable?(book_name)\n then\n puts \"The book is available!\\n\"\n # add the book to the user's list of borrowed books\n updateUserBooks(user_name, book_name)\n # decrement the number of available copies\n updateBookCopies(book_name)\n # display the details\n displayLibraryDetails()\n else\n # error message\n puts \"Sorry! This book is not available!\"\n end\n else\n # error message\n puts \"Book limit exceeded!\"\n end\n else\n # error message\n puts \"Invalid user!!\"\n end\n end",
"def borrow\n @book.borrow(@user)\n render json: { object: 'Loan' }, status: :created\n rescue Exceptions::NoBookCopies\n # Not available copies for a new loan:\n render json: { object: 'Book'}, status: :conflict if @book.available == 0\n rescue Exceptions::LowAccountBalance\n # User haven't enougth balance:\n render json: { object: 'User'}, status: :conflict if @user.amount - @book.fee < 0\n end",
"def borrow\n # This instance method is how a book is taken out of the library. Otherwise, use current_due_date to set the due_date of the book and move it from the collection of available books to the collection of books on loan, then return true.\n # This method should use lent_out? to check if the book is already on loan,\n if self.lent_out? == false\n @@due_date = Book.current_due_date\n @@on_shelf.delete(self)\n @@on_loan << self\n return true\n else\n return false\n end\n\n end",
"def borrower\n end",
"def check_out(user, book)\n# .borrowerd_books refers to the \"getter/setter\" methods defined in the Borrower class which enables\n# us to retrieve the books in the @borrowed_books array and add new ones as well. .length checks the\n# length of the the @borrowered_books array.\n if user.borrowed_books.length >= 2\n#\n puts \"Sorry, the user is only able to check out two books.\"\n return\n end\n# .status refers to the \"getter/setter\" method that retrieves and sets the instance variable @status. \n if book.status == \"available\"\n user.borrowed_books << book\n book.status = \"unavailable\"\n book.borrower = user\n else\n puts \"Sorry, that book is unavailable.\"\n end\n end",
"def borrow\n @book = Book.find(params[:book_id])\n @book.is_borrowed = true\n @book.user = current_user\n @book.save\n redirect_to request.referrer, notice: \"You're being redirected\"\n #Todo: Update user log \n end",
"def check_ownership\n redirect_to books_path, alert: I18n.t(\"books.not_owner\") if current_user.id != @book.user_id\n # equivaut a:\n # if current_user.id != @book.user_id\n # flash[:alert]= \"Vous n'etes pas le proprietaire de ce livre\"\n # redirect_to books_path\n # end\n end",
"def borrow(book)\n\t\t@checked_out_books << book\n\tend",
"def borrow_books(*books)\n\t\tbooks.each do |book|\n\t\t\tif self.books.include?(book)\n\t\t\t\tputs \"#{self.name} has already checked this book out!\"\n\t\t\telse\n\t\t\t\tself.books << book\n\t\t\tend\n\t\tend\n\tend",
"def check_out(user, book)\n if user.borrowed_books.length == 2\n puts \"Sorry #{user.name}, you have already checked out two books.\"\n return \n end\n\n if book.status == \"available\"\n book.borrower = user\n user.borrowed_books.push(book)\n book.status = \"checked out\"\n puts \"#{user.name} checked out '#{book.title}' by #{book.author}.\"\n elsif book.status == \"checked out\"\n puts \"Sorry '#{book.title}' is checked out by another library member.\"\n else\n puts \"Sorry, that book is not available\"\n return \n end\n end",
"def check_non_author\n book = Book.find(params[:id])\n if book.user_id != current_user.id\n redirect_to books_path, alert: \"You are not main author of this book. Access denied\"\n end\n end",
"def check_in(book)\n book.status = \"available\"\n book.borrower.borrowed_books.delete(book.borrower.borrowed_books[book])\n end",
"def get_borrower(book_id)\n #Runs through all books in the library and finds the one\n #that matches the id, then looks at the borrower\n #Currently no error protection if the book isn't borrowed\n @books.each do |book|\n return book.borrower.first.name if book.id == book_id\n end\n end",
"def bookable_must_be_bookable\n if bookable.present? && !bookable.class.bookable?\n errors.add(:bookable, T.er('booking.bookable_must_be_bookable', model: bookable.class.to_s))\n end\n end",
"def loan\n # retrieve the book objet to be loaned\n @book = Book.friendly.find(params[:id])\n # check if the book is available\n if @book.available?\n @book.status = Book.statuses[:borrowed]\n @book.save\n # redirect to book show page with a success message\n redirect_to store_show_path, notice: 'You have successfully borrowed this book'\n else\n # redirect to book show page with an error message\n redirect_to store_show_path, alert: 'This book is not available, you can not borrow this'\n end\n end",
"def borrow\n if self.lent_out? == true\n# self. is a class method\n return false\n else\n self.due_date = Book.current_due_date\n @@on_shelf.delete(self)\n# Deletes due date since book is returned\n @@on_loan << self\n# This adds the book back to the shelf if it reaches the due date\n return true\n end\n end",
"def user_is_owner?\n current_cookbook.is_owner?(current_user)\n end",
"def borrowable_items\n# items.where(\"borrower_id = 0\")\n Item.all.where(\"borrower_id = 0 and lender_id != :owner\", {owner: self.id})\n end",
"def check_out(user, book)\n if user.borrowed_books_count == 2\n puts \"Sorry, that user already has two books checked out.\"\n elsif book.status == \"checked out\"\n puts \"Sorry, that book in not available.\"\n else\n book.borrower = user\n user.borrowed_books.push(book)\n book.status = \"checked out\"\n puts \"#{user.name} has now checked out #{book.title} by #{book.author}.\"\n end\n end",
"def check_out(user, book)\n if user.books.length == 2\n puts \"This library patron already has two books checked out!\"\n return\n end\n if book.checked_out == false\n book.checked_out = true\n book.current_patron = user\n user.books << book\n puts \"Library patron #{user.name} has checked out \\\"#{book.title}.\\\"\"\n else\n puts \"Sorry, this books has already been checked out.\"\n end\n end",
"def checkout(user, book)\n if user.can_rent_books? && book.status = \"available\"\n book.status = \"checked out\"\n book.due_date = Time.now + (7*24*60*60)\n user.checkout_book(book)\n else\n puts \"Sorry, that book can't be checked out.\"\n end\n end",
"def show\n user_type = session[:user_type]\n case user_type\n when ApplicationController::TYPE_STUDENT\n check = BookRequest.check_if_authorised?(user_type, current_user.id, params[:id])\n if (check == false)\n flash[:notice] = \"You are not authorised to perform this action\"\n redirect_to root_path\n end\n when ApplicationController::TYPE_LIBRARIAN\n check = BookRequest.check_if_authorised?(user_type, current_user.library_id, params[:id])\n if (check == false)\n flash[:notice] = \"You are not authorised to perform this action\"\n redirect_to root_path\n end\n when ApplicationController::TYPE_ADMIN\n # admin can see any book request\n end\n end",
"def borrow_to(user)\n ActiveRecord::Base.transaction do\n borrow\n rivals = Borrowing.current_applied_for(print_book_id)\n .where(receiver_id: user.id)\n rivals.each(&:cancel)\n print_book.update holder_id: receiver.id\n\n save!\n end\n end",
"def check_if_user\n render text: \"Fuck you user\", status: 403 unless current_user.id == @book.user_id || current_user.rank_id == 2\n end",
"def cookbook_owner?\n if current_cookbook && current_user.id != current_cookbook.owner.id\n redirect_to sections_path, alert: \"As a Contributor you may only access the \\\"Recipes\\\" and \\\"Preview\\\" pages for the cookbook.\"\n end\n end",
"def borrowed_books\n @books.each do |book| \n if book.status == \"unavailable\"\n# book refers to an instance of the class \"book\". .title refers to the\n# \"getter\" method we created in class Book that retrieves the value of\n# instance variable, @title, which was passed a value from an instance of \n# the class Book.\n# .borrower refers to the \"getter/setter\" method(s) which retrieve and set\n# the value of @borrower is set in the check_out method (set to user)\n puts \"The book #{book.title} has been checked out by #{book.borrower.name}\"\n end\n end\n end",
"def user_is_contributor?\n !current_cookbook.is_owner?(current_user)\n end",
"def borrow_to(user)\n ActiveRecord::Base.transaction do\n borrow\n rivals = Sharing.current_applied_for(print_book_id)\n .where(receiver_id: user.id)\n rivals.each(&:cancel)\n\n last_sharing = Sharing.find_by id: print_book.last_deal_id\n last_sharing&.finish\n print_book.update holder_id: receiver.id, last_deal_id: id\n\n save!\n end\n end",
"def select\n @cookbook = Cookbook.find params[:id]\n user_is_owner = current_user.owns_cookbook(@cookbook)\n user_is_contributor = current_user.contributes_to(@cookbook)\n\n # Verify the user is authorized to work on this cookbook.\n if @cookbook && (user_is_owner || user_is_contributor)\n \n # User must have a paid account to work on its cookbooks\n # (Contributor wasn't allowed to create cookbooks but due to a bug some contributors may have cookbooks to works on)\n if has_contributor_plan? && user_is_owner\n redirect_to upgrade_account_path(current_user.id), alert: \"You must have a paid membership to work on your own cookbooks\"\n return\n end\n\n load_user_cookbook @cookbook\n\n # Alert the user it will not be able to work on this cookbook if its owner has expired.\n if current_cookbook.owner.expired?\n if user_is_owner\n flash[:alert] = \"Because your membership has expired you can no longer work on your cookbooks.\"\n elsif user_is_contributor\n flash[:alert] = \"The owner of this cookbook's membership has expired. They will have to extend it for you to gain access to this cookbook.\"\n end\n end\n redirect_to templates_path\n else\n redirect_to cookbooks_path, alert: \"Unable to select cookbook. Either it doesn't exist or you have no permission accessing it.\"\n end\n end",
"def rent_book(book)\n if book.is_free?\n book.check_out\n books_rented.push(book)\n end\n\n end",
"def check_coauthor\n coauthors = Coauthor.where(\"book_id = ? AND user_id=?\",params[:id],current_user.id)\n book = Book.where(\"id = ? AND user_id = ?\",params[:id],current_user.id)\n if book.empty? #if user is author of book\n if coauthors.empty? #if user is coauthor of book\n redirect_to books_path, alert: \"You are not author/coauthor of this book. Access denied.\"\n end\n end\n end",
"def borrowed_books\n @books.each do |book|\n if book.status == \"checked out\" \n puts \"'#{book.title}' is checked out to #{book.borrower.name}\" \n end\n end\n end",
"def current_user_has_book?(book)\n current_user.books.find_by(identifier: book.identifier)\n end",
"def show\n if @book.available? && @book.user != current_user && current_user\n @books_to_exchange = current_user.books.select { |f| f.available? }\n else\n @books_to_exchange = Book.none\n end\n @can_exchange = @books_to_exchange.any?\n end",
"def check_in(book)\n if book.status == \"checked out\"\n puts \"'#{book.title}' has been checked back in by #{book.borrower.name}\" \n book.status = \"available\"\n book.borrower.borrowed_books.delete(book)\n else\n puts \"'#{book.title}' is already checked in.\"\n end\n end",
"def borrow(currentuser)\n self.borrower ? self.borrower = nil : self.borrower = currentuser.email\n save\n log(currentuser)\n end",
"def set_borrowed_book\n @borrowed_book = BorrowedBook.find(params[:id])\n end",
"def set_borrowed_book\n @borrowed_book = BorrowedBook.find(params[:id])\n end",
"def set_borrowed_book\n @borrowed_book = BorrowedBook.find(params[:id])\n end",
"def borrowed_books\n @books.each do |book|\n if book.status == \"checked out\"\n puts \"#{book.title} by #{book.author}: Checked out by #{book.borrower.name}.\"\n end\n end\n end",
"def prolong\n @borrow = Borrow.find(params[:id])\n @user = User.find_by reader_id: @borrow.reader.id\n end",
"def check_out(borrower, book)\n if borrower.borrowed_books.size == 2\n puts \"Sorry, \" + borrower.name + \", you cannot check out any more books until you return one.\"\n elsif (book.status == \"Checked out\") \n puts \"Sorry, \" + borrower.name + \", that book is not available.\"\n else\n borrower.borrowed_books_count = borrower.borrowed_books_count + 1\n book.status = \"Checked out\"\n borrower.borrowed_books << book\n book.borrower = borrower\n puts borrower.name + \" has checked out \" + book.title + \".\"\n return borrower\n end\n end",
"def borrowed_books\n @books.each do |book|\n if book.status == \"Checked out\"\n puts book.title + \" is currently checked out.\" \n puts \"Go talk to \" + book.borrower.name + \".\"\n end\n end\n end",
"def can_precheck_borrow_direct?(request)\n return false unless @use_bd_api\n\n isbn(request).present?\n end",
"def check_out(book,user)\n\t\tif user.book_count > 2\n\t\t\tputs \"Sorry! You can't check out any more books.\"\n\t\telsif user.checked_out_books.any? { |book| book.overdue? == true}\n\t\t\tputs \"Sorry! You have an overdue book.\"\n\t\telsif book.status == \"available\" \n\t\t\tbook.due_date = Time.now + (7*24*3600)\n user.checked_out_books << book\n\t\t\tuser.borrow(book)\n book.status = \"checked out\"\n\t\t\tputs \"You have checked out #{book.title}.\"\n\t\telse \n\t\t\tputs \"#{book.title} is checked out. Please check back soon.\"\n\t\tend\n\tend",
"def check_in(book, user)\n # Check if book is already checked out\n if book.status == \"checked out\" || book.status == \"overdue\"\n book.status = \"available\"\n\n # Remove from user's checked out book array\n user.checked_out_books.delete_if { |e| e == book }\n user.overdue_books.delete_if {|e| e == book }\n \n # Reset the check out and due dates to nothing\n book.check_out_date = nil\n book.due_date = nil\n \n # Remove from the library's checked out and overdue arrays.\n @checked_out.delete_if { |e| e == book }\n @overdue.delete_if { |e| e == book }\n\n # Remove the user who checked out the book\n book.who_checked = nil\n \n # Error message for book that is not checked out.\n elsif book.status == \"available\"\n puts \"This book is not checked out\"\n \n # Allows lost books to be returned.\n elsif book.status == \"lost\"\n book.status = \"available\"\n puts \"Thanks for bringing #{book.title} back!\"\n \n # Malformed input or malfunctioning method error message.\n else\n puts \"There is something wrong with the book you've tried to check out. This is an error message. Sorry.\"\n end\n end",
"def check_buyable\n raise PermissionDeniedError, \"出品したアイテムはサポートできません\" if @item.owner?(current_user)\n end",
"def is_book?()\n end",
"def borrowing_params\n params.require(:borrowing).permit(:user_id, :book_id, :magazine_id)\n end",
"def require_same_user\n if current_user != @recipe.chef and !current_user.admin?\n flash[:danger] = \"You can only edit your own recipes\"\n redirect_to recipes_path\n end\n \n end",
"def updateUserBooks(user_name, book_name)\n @users.each do |user|\n if user.name == user_name\n then\n user.books_borrowed.push(book_name)\n puts \"USER DETAILS:\"\n puts \"------------------------------------------\"\n puts \"ID: \" + user.id.to_s\n puts \"Name: \" + user.name\n puts \"Address: \" + user.address\n puts \"Book Limit: \" + user.book_limit.to_s\n puts \"Books Borrowed:\"\n puts user.books_borrowed\n puts \"------------------------------------------\"\n end\n end\n end",
"def isUserBookLimitExceeded?(user_name)\n user_record = @users.find do |user|\n user.name == user_name\n end\n if user_record.books_borrowed.length >= user_record.book_limit\n then return true\n end\n false\n end",
"def owned_by? a_user\n a_user == program.moderator\n end",
"def borrowed_books\n @books.select { |book| book.status == 'checked_out' }\n end",
"def borrowed_books\n @borrowed_books\n end",
"def borrowed_books\n @borrowed_books\n end",
"def validate_ownership\n buyer_items.each { |item| item.validate_owner seller }\n seller_items.each { |item| item.validate_owner buyer }\n end",
"def check_out(book)\n if @checked_books.count < 3\n @checked_books.add book\n true\n else\n \"Could not add book id: #{book.get_id}, max no of books (3) reached.\"\n false\n end\n end",
"def set_borrow\n @borrow = Borrow.find(params[:id])\n end",
"def check_out_book(book_id, borrower)\n #Runs through each book in the library\n @books.each do |book|\n #If the book's id matches the id of the checkout id,\n #tries to check the book out\n if book.id == book_id && book.check_out(borrower)\n borrower.checked_out << book\n return book\n end\n end\n #If no match is found, returns nil\n return nil\n end",
"def eligible_owners\n User.where('users.id != ?', @cookbook.user_id)\n end",
"def borrow_params\n params.require(:borrow).permit(:user_id, :soluongmuon, :indentify_id,:book_id, :mode, :mode1)\n end",
"def show\n user_type = session[:user_type]\n case user_type\n when ApplicationController::TYPE_STUDENT\n check = BookHistory.check_if_authorised?(user_type, current_user.id, params[:id])\n if (check == false)\n flash[:notice] = \"You are not authorised to perform this action\"\n redirect_to root_path\n end\n when ApplicationController::TYPE_LIBRARIAN\n check = BookHistory.check_if_authorised?(user_type, current_user.library_id, params[:id])\n if (check == false)\n flash[:notice] = \"You are not authorised to perform this action\"\n redirect_to root_path\n end\n when ApplicationController::TYPE_ADMIN\n # admin can see any book history\n end\n end",
"def can_buy_beer?(person)\nend",
"def create\n @loan = Loan.new(loan_params)\n @book = Book.find_by( params[:book_id] )\n\n respond_to do |format|\n if @loan.save\n format.html { redirect_to @loan, notice: 'Book successfully borrowed' }\n format.json { render :show, status: :created, location: @loan }\n else\n format.html { redirect_to books_path, alert: 'Book not available' }\n end\n end\n end",
"def check_in(book,user)\n\n\t\tif book.status == \"available\"\n\t\t\tputs \"This book is not available for check in.\"\n\t\telse \n\t\t\tuser.checked_out_books.delete(book)\n book.status = \"available\"\t\n\t\t\tputs \"Thank you! #{book.title} is now checked in.\"\n\t\tend\n\tend",
"def books\n @books ||= current_user.books\n end",
"def pay_owner(rental)\n # make credit operation on balanced\n balanced.credit(rental)\n\n # account it on subledger\n subledger.credit(rental)\n end",
"def borrowed_books\n\t\tputs \"Borrowed Books:\"\n\t\t@book_status.each { |k, v| puts \"#{k}\" if v == \"checked_out\" }\n\tend",
"def new\n @boat = Boat.find(params[:boat_id])\n @booking = Booking.new\n authorize @booking\n end",
"def set_book\n @book = current_user.books.find(params[:id])\n end",
"def check_out_book\n\tselect = make_selection.to_i\n\tselect = verify_book_exists(select)\n\tb = Book.find(select)\n\tif b.patron_id.nil?\n\t\tputs \"\\nPlease select patron that would like to check out book\\n\"\n\t\tshow_all_patrons\n\t\tselect = make_selection.to_i\n\t\tselect = verify_patron_exists(select)\n\t\tb.update_attributes(patron_id: select)\n\telse\n\t\tputs \"\\nThis book is already checked out\\n\"\n\tend\nend",
"def borrowed_book_params\n params.require(:borrowed_book).permit(:book_id, :user_id, :returning_at)\n end",
"def check_out(book, user)\n user.overdue_update\n\n # Check the number of books a user has checked out\n if user.checked_out_books.length >= 2\n puts \"You have too many books checked out. You must return at least one book before you can check out another book.\"\n\n # Check if the user has overdue books\n elsif user.overdue_books.any? \n puts \"You have overdue books! No new books for you! Return your overdue books to be allowed to check out new books.\"\n \n # Check out the book\n elsif book.status == \"available\"\n book.status = \"checked out\"\n user.checked_out_books << book\n book.check_out_date = Time.now\n book.due_date = book.check_out_date + ((60*60*24)*7)\n @checked_out << book\n book.who_checked = user.name\n puts \"#{book.title} has been checked out by #{book.who_checked}. Enjoy!\"\n \n else\n puts \"You have discovered a problem with the check_out method! Sorry!\"\n end\n end",
"def owner?(user_asking)\n user_asking.in? company.owners\n end",
"def book_once_aday\n errors.add(:user, 'Guest can book only once a day') if booked_in_same_day?\n end",
"def owner_only_offers_reward?\n self.rewards_count == 1 && self.rewards.visible[0].sender == self.person\n end",
"def find_borrowership\n @borrowership = @car.borrowerships.find(params[:id])\n authorize @borrowership\n end",
"def check_out(book)\n puts \"#{self.get_name} does not have a library card\" unless @library.members.member?(self.get_name)\n\n if @books_out.length < BOOK_LIMIT\n books_out << book\n end\n\n end",
"def is_allowed_to_edit?(person)\n if person.id == item_owner.id && status.eql?(\"pending_owner\")\n return true\n elsif person.id != item_owner.id && status.eql?(\"pending_reserver\")\n return true\n end\n return false \n end",
"def check_in(book)\n end",
"def is_owned_by?(user_id)\n self.user_id == user_id\n end",
"def\n check_out(book)\n\n puts \"#{self.get_name} does not have a library card\" unless @library.members.member?(self.get_name)\n\n if @books_out.length < BOOK_LIMIT\n books_out << book\n end\n\n end",
"def new\n logger.debug \"new transaction\"\n #@transaction = Transaction.new\n #check login\n if(user_signed_in?)\n logger.debug params\n #check book\n book = Book.find(:first, :conditions => {:id =>params[:id]})\n if(!book)\n respond_to do |format|\n format.html { redirect_to home_path, notice: 'Invalid Book.' }\n end\n return;\n end\n #check current_quantity\n if (!book.current_quantity)\n #book.current_quantity = book.quantity\n book.update_attributes(:current_quantity=>book.quantity)\n #book.save\n end\n #check user\n if(!current_user.books_borrow)\n current_user.update_attributes(:books_borrow => 0)\n end\n if(!current_user.can_borrow_more )# FIX ME if use admin control\n logger.debug \"borrow enough books, can't borrow anymore\"\n redirect_to \"/books/view?topic=#{book.type}&id=#{book.id}\";\n return;\n end\n #check old transaction new\n if (current_user.is_borrowed(book.id))\n logger.debug \"already borrow\"\n redirect_to \"/books/view?topic=#{book.type}&id=#{book.id}\";\n return;\n end\n #check old transaction old\n #old_transactions = Transaction.find(:all, :conditions => {:book_id=>book.id, :user_id=>current_user.id})\n #old_transactions.each do |old_transaction|\n # if(old_transaction.status == 1)#borrow but haven't return\n # redirect_to \"/books/view?topic=#{book.type}&id=#{book.id}\";\n #FIX ME, redirect to already borrow page\n # return;\n # end\n # end\n if (book.current_quantity > 0)\n @transaction = Transaction.new();\n @transaction.book_id = book.id;\n @transaction.user_id = current_user.id;\n @transaction.day_borrow = Date.today.to_s;\n @transaction.day_return = (Date.current+14).to_s;\n @transaction.status = 1 ;#dang muon\n @transaction.save;\n #current_quantity increase\n book.current_quantity -=1;\n book.save;\n #user borrow book increase\n current_user.update_attributes(:books_borrow => current_user.books_borrow+1)\n\n redirect_to \"/books/view?topic=#{book.type}&id=#{book.id}\";\n return;\n end\n else\n respond_to do |format|\n format.html { redirect_to new_user_session_path, notice: 'You must login first.' }\n end\n # redirect_to new_user_session_path\n return;\n end\n redirect_to \"/\";\n return;\n # respond_to do |format|\n #format.html # new.html.erb\n # format.json { render json: @transaction }\n # end\n end",
"def create\n @borrowed_book = BorrowedBook.new(borrowed_book_params)\n respond_to do |format|\n if @borrowed_book.save\n borrow(@borrowed_book)\n format.html { redirect_to @borrowed_book, notice: 'Borrowed book was successfully created.' }\n format.json { render :show, status: :created, location: @borrowed_book }\n else\n format.html { render :new }\n format.json { render json: @borrowed_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = current_user\n if verify_admin || verify_librarian\n @book = Book.new(book_params)\n @book.nums_request = 0\n @book.library = @user.library if (@user.role == 'librarian')\n @book.is_delete = false\n @book.nums_borrowed = 0\n @library = Library.find_by_name(@book.library)\n @book.university = @library.university\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n\n end\n end\n else\n redirect_to books_url, notice: 'Unauthorized action!'\n\n end\n end",
"def user_can_write(user)\n if (self.writing? or self.rejected?) and (self.user == user or self.book.project.owner == user or user.id == 1) then\n return true\n else\n return false\n end\n end",
"def check_booking_user\n if current_user.id != @booking.user.id\n redirect_to bookings_path, notice: \"Cannot view a booking belonging to another user.\"\n end\n end",
"def create\n @book = Book.find_by_id(params[:book_id])\n # check to see if there is enough copies of the book\n if @book.total_in_library > 0\n @reservation = @user.reservations.new\n @reservation.user_id = @user.id\n @reservation.book_id = @book.id\n if @reservation.save && @book.update(total_in_library: @book.total_in_library - 1)\n redirect_to reservations_path, notice: \"#{@book.title} has been reserved\"\n else\n redirect_to book_path(@book), notice: \"Problems reserving #{@book.title}\"\n end\n else # if not enough copies return back to the show page of the book\n redirect_to book_path(@book), notice: \"Not enough copies of #{@book.title} to reserve\"\n end\n end",
"def recipe_owner\n unless recipe_owner?(current_user, @recipe)\n render json: { errors: [\"User not authorized to modify recipe that doesn't belong to them\"] }, status: :bad_request\n end\n end",
"def book\n return direct_book if item_type == 'book' || item_type == 'package'\n group && group.book\n end",
"def check_in_book(book)\n borrower = book.check_in\n #Removes the book from the borrower's checked out array\n borrower.first.checked_out.delete(book)\n end",
"def checkout\n flag = 0 \n book = Book.find(params[:id])\n @user = User.where(:email => params[:isbn])\n @books=Book.all\n @books.each do|book|\n if (book.Lastuser == current_user.email) \n flag = 1 \n flash[:notice] = 'You have another book checked out already' \n end\n end\n if flag == 0 \n book = Book.find(params[:id])\n book.Status = !book.Status \n book.Lastuser = current_user.email\n book.save\n History.create(:book_isbn => book.ISBN, :user_email => current_user.email, :book_title => book.Title, :book_author => book.Authors, :checkout_time => DateTime.now)\n flash[:notice] = 'Book was sucessfully checked out' \n end \n redirect_to book_path(book) \n end",
"def check_book_availability\n if self.book.book_copies.unassigned_copies.where(is_active: true).count < 1\n errors.add(:base, \"Book out of stock\")\n end\n end",
"def check_out_by(user)\n borrowed_by.push(user)\n end",
"def check_in(book)\n @book = book\n end",
"def sell_restaurant(restaurant, buyer)\n if restaurant_owner.include?(restaurant)\n #Then can sell to buyer / new restaurant owner \n Restaurant_owner.new(name, age)\n else #if current user does not own restaurant\n buyer_to_update = self.restaurant_owner.find { |buyer| buyer.restaurant == restaraunt_owner}\n buyer_to_update = restaraunt_owner\n end \n end",
"def borrowed?\n return false if activities.empty?\n activities.take.borrowing? \n end",
"def set_borrower\n @borrower = Borrower.find(params[:id])\n end",
"def create\n @book = Book.new(book_params)\n\n respond_to do |format|\n if @book.save\n\n params[:book][:author_id].each do |item| # A block of code to set current note sharing options with other users\n if (!item.blank?)\n @NewBookAuthor = AuthorsBook.new(:book_id => @book.id, :author_id => item)\n @NewBookAuthor.save\n end\n end\n\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.71628296",
"0.68416333",
"0.6751122",
"0.6643782",
"0.65890825",
"0.6433646",
"0.64299554",
"0.63787955",
"0.63297313",
"0.62262493",
"0.6147137",
"0.61120266",
"0.60172224",
"0.60103166",
"0.6007617",
"0.5996478",
"0.5983993",
"0.5955166",
"0.5933927",
"0.5920414",
"0.59170216",
"0.5881819",
"0.5860611",
"0.585154",
"0.58495235",
"0.58376825",
"0.58353454",
"0.5832818",
"0.57975173",
"0.5791089",
"0.57479197",
"0.57338303",
"0.5727034",
"0.5722889",
"0.5718766",
"0.5717246",
"0.5712905",
"0.5711865",
"0.5711865",
"0.5711865",
"0.5711204",
"0.5696331",
"0.56845087",
"0.5660581",
"0.5659547",
"0.56039244",
"0.55986524",
"0.5587882",
"0.5586183",
"0.5583073",
"0.55741674",
"0.5567056",
"0.55376416",
"0.5525998",
"0.5525703",
"0.55249465",
"0.55249465",
"0.5516892",
"0.5512797",
"0.55017006",
"0.5492151",
"0.54816884",
"0.5480938",
"0.54586256",
"0.54530007",
"0.5441781",
"0.54408634",
"0.54393256",
"0.5434295",
"0.543408",
"0.5418077",
"0.5402542",
"0.54013854",
"0.53989047",
"0.53985953",
"0.53853154",
"0.53803974",
"0.53789693",
"0.5370727",
"0.5355631",
"0.53461874",
"0.5340419",
"0.53354895",
"0.53299475",
"0.53262234",
"0.5325964",
"0.53113425",
"0.5311016",
"0.5300964",
"0.5295002",
"0.528686",
"0.5276016",
"0.5263201",
"0.5260819",
"0.5258573",
"0.5258049",
"0.52565277",
"0.5255273",
"0.52533585",
"0.5251907",
"0.5244259"
] | 0.0 | -1 |
Return a book to the library. | def return_books(books, user)
if @users.include? user then
(@records.select {|record| !record.has_return && record.user_id.eql?(user.id)}).each do |record|
books.uniq.each do |book|
if book.isbn == record.book_isbn then
inventory[book] += 1
record.has_return = true
puts "Successfully return <#{book.title}> to the library"
end
end
end
check_records(user)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def book\n fetch('harry_potter.books')\n end",
"def return_book\n\t\tselect = make_selection.to_i\n\t\tselect = verify_book_exists(select)\n\t\tb = Book.find(select)\n\t\tpatron_id = nil\n\t\tb.update_attributes(patron_id: patron_id)\nend",
"def book\n sql = \"SELECT * FROM books WHERE books.id = $1\"\n values = [@book_id]\n book_data = SqlRunner.run(sql, values)\n book = Book.map_items(book_data).first\n return book\n end",
"def book(id)\n\t\t\tresponse = request('/book/show', :id => id)\n\t\t\tHashie::Mash.new(response['book'])\n\t\tend",
"def get_book( book_id )\n response = if book_id.to_s.length >= 10\n Amazon::Ecs.item_lookup( book_id, :id_type => 'ISBN', :search_index => 'Books', \n :response_group => 'Large,Reviews,Similarities,AlternateVersions' )\n else\n Amazon::Ecs.item_lookup( book_id, :response_group => 'Large,Reviews,Similarities' )\n end\n response.items.each do |item|\n binding = item.get('ItemAttributes/Binding')\n next if binding.match(/Kindle/i)\n return Book.new( item )\n end\n return nil\n end",
"def get_books()\n @books_out\n end",
"def get_books()\n @books_out\n end",
"def retrieve_book\n @book = Book.find(params[:book_id])\n end",
"def return_book(title)\n # find book instance by title\n searched_book = Book.find_by(title: title)\n # change book.available to true\n searched_book.update_column(:available, true)\n # checks to see if title is in checkouts and .checked_out == true then changes checkout.checked_out to false\n self.checkouts.find{|checkout| checkout.book.title == title && checkout.checked_out == true}.update_column(:checked_out, false)\n end",
"def returnbook\n @books = Book.all \n end",
"def copywrite(book)\n BookAuthor.new(self, book)\n end",
"def book\n return direct_book if item_type == 'book' || item_type == 'package'\n group && group.book\n end",
"def set_library_book\n @library_book = Library::Book.find(params[:id])\n end",
"def get_book(book_num)\n return @books_list[book_num]\n end",
"def get_book\n @book = Book.where(id: params[:book_id]).first\n end",
"def convert_to_book\n book = Book.new(title:self.title)\n self.destroy\n book.save\n return book\n end",
"def get_book(book_isbn)\n plsql.books.first :book_isbn => book_isbn\n end",
"def get_book\n return input_title = @inventory\n end",
"def book\n @book = Book.published.find(params[:id])\n render json: @book\n end",
"def order_book(params)\n Client.current.get(\"#{resource_url}/book\", params)\n end",
"def add_book(book)\n @books << book\n puts \"Added \" + book.title + \" to the library.\"\n end",
"def book\n @books=Book.all\n @book=Book.find(params[:id])\n end",
"def get_book( book_id )\n response = if book_id.to_s.length >= 10\n Amazon::Ecs.item_lookup( book_id, :id_type => 'ISBN', :search_index => 'Books', :response_group => 'Large,Reviews,Similarities' )\n else\n Amazon::Ecs.item_lookup( book_id, :response_group => 'Large,Reviews,Similarities' )\n end\n response.items.each do |item|\n binding = item.get('ItemAttributes/Binding')\n next if binding.match(/Kindle/i)\n return parse_item( item )\n end\n end",
"def book\n response = request(:book, {\n \"currentInvoiceHandle\" => handle.to_hash\n })\n\n # Find the created Invoice\n session.invoices.find(response[:number])\n end",
"def odsa_books\n inst_books\n end",
"def add_book(book_title)\n @books << {\n title: book_title,\n rental_details: {\n student_name: \"\",\n date: \"\"\n }\n }\n end",
"def show\n @librarybook = Librarybook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @librarybook }\n end\n end",
"def addBook(book)\n\t\tinventories.create(book_id: book.id)\n\tend",
"def show\n @library = Library.find(Book.find(params[:id]).library_id)\n end",
"def book\n @library_location = 2\n super\n end",
"def create\n @librarybook = Librarybook.new(params[:librarybook])\n\n respond_to do |format|\n if @librarybook.save\n format.html { redirect_to(@librarybook, :notice => 'Librarybook was successfully created.') }\n format.xml { render :xml => @librarybook, :status => :created, :location => @librarybook }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @librarybook.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def book!(booker, opts={})\n booker.book!(self, opts)\n end",
"def create\n @library_book = current_user.books.new(library_book_params)\n\n respond_to do |format|\n if @library_book.save\n format.html { redirect_to @library_book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @library_book }\n else\n format.html { render :new }\n format.json { render json: @library_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n\t\t@book = Book.new\n\tend",
"def set_library_book\n @library_book = LibraryBook.find(params[:id])\n end",
"def book_by_title(title)\n\t\t\tresponse = request('/book/title', :title => title)\n\t\t\tHashie::Mash.new(response['book'])\n\t\tend",
"def new\n @librarybook = Librarybook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @librarybook }\n end\n end",
"def create\n @library_book = LibraryBook.new(params[:library_book])\n\n respond_to do |format|\n if @library_book.save\n format.html { redirect_to @library_book, notice: 'Library book was successfully created.' }\n format.json { render json: @library_book, status: :created, location: @library_book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @library_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @library_book = LibraryBook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @library_book }\n end\n end",
"def display_resource(book)\n book.title\n end",
"def load_book\n @book = Book.find(params[:id])\n end",
"def find_book\n\t@book = Book.find(params[:id])\nend",
"def new\n @book = Book.new\n \n end",
"def return_book(book)\n\t\tif self.books.include?(book)\n\t\t\tputs \"Returned #{book.title}\"\n\t\t\tself.books.delete(book)\n\t\telse\n\t\t\tputs \"#{self.name} could not return this book as they no longer have it!\"\n\t\tend\n\tend",
"def booker_new\n end",
"def books \n @books\n end",
"def book\n 'Book' if record.leader[6] == 'a' && record.leader[7] == 'm' && local_formats.include?('Archives/Manuscripts')\n end",
"def new\n @book = Book.new\n end",
"def new\n @book = Book.new\n end",
"def create\n @library_book = LibraryBook.new(library_book_params)\n\n respond_to do |format|\n if @library_book.save\n format.html { redirect_to @library_book, notice: 'Library book was successfully created.' }\n format.json { render :show, status: :created, location: @library_book }\n else\n format.html { render :new }\n format.json { render json: @library_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lib_book = LibBook.new(lib_book_params)\n\n respond_to do |format|\n if @lib_book.save\n format.html { redirect_to university_library_lib_books_path, notice: 'Lib book was successfully created.' }\n format.json { render :show, status: :created, location: @lib_book }\n else\n format.html { render :new }\n format.json { render json: @lib_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n Rails.logger = Logger.new(STDOUT)\n logger.debug \"params passed is #{book_params}\"\n @book.is_deleted = false\n\n if !@current_librarian.nil?\n @book[:library_id] = @current_librarian.library_id\n @book[:associated_library] = @current_librarian.library.name\n end\n\n respond_to do |format|\n if @book.save\n logger.debug \"Book saved with id #{@book.id}\"\n format.html { redirect_to @book, notice: 'Book was successfully added.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_library_book_return\n\t\tputs \"To return a book,\"\n\t\tprint \" Enter Book Id :\"\n\t\ttarget_book_id=gets.to_i\n\t\tif is_book_exist_in_library?(target_book_id)\tthen\n\t\t\tif is_book_available_in_library?(target_book_id) then\n\t\t\t\tputs \"\\tBook is not issued to any one.It is already available in library\"\n\t\t\telse\n\t\t\t\tmark_return(target_book_id)\n\t\t\t\tputs \"\\tBook successfully marked as Return\"\n\t\t\tend\n\t\telse\n\t\t\tputs \"\\tNo such book with #{target_book_id} rergistered in library\"\t\t\n\t\tend\n\tend",
"def new\n @book = Book.new\n\n do_response @book\n end",
"def create\n\t\tclient = Goodreads::Client.new(api_key: \"rSkvvZY8Wx27zcj4AfHA\", api_secret: \"S5WOpmY8pVtaEu1IwNn51DBafjoEIbjuxZdE6sNM\")\n\t\tbook = client.book_by_isbn(book_params[:isbn])\n\t\t@book = Book.new(book_params)\n\n#\t\tputs book.title\n#\t\tputs book.description\n#\t\tputs book.work.original_title\n#\t\tputs book.num_pages\n#\t\tputs book.authors.author.name\n#\t\tputs book.publisher\n\n\t\t@book.titlelong = book.title\n\t\t@book.description = strip_tags(book.description)\n\t\tputs @book.description#.gsub(/<br\\s*\\?>/, '')\n\t\t@book.title = book.work.original_title\n\t\t@book.pages = book.num_pages\n\t\t@book.bookrating = book.average_rating\n\t\t@book.author = book.authors.author.name\n\t\t@book.publisher = book.publisher\n\n\t\t#book.search(\"9780545790352\", 5)\n\t\t#puts book.books.first.get_title\n\t\t#@show = Show.new(show_params)\n\t\t#@show.title = result[\"original_name\"]\n\t\t#@show.description = result[\"overview\"]\n\t\t#@show.seasons = result[\"number_of_seasons\"]\n\t\t#@show.episodes = result[\"number_of_episodes\"]\n\t\t#@show.episoderuntime = result[\"episode_run_time\"].dig(0)\n\t\t#@show.showrating = result[\"vote_average\"]\n\t\t#@show.airdate = result[\"first_air_date\"]\n\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add( book )\n @books.add( Books::Book.new( book ))\n end",
"def add_book(book)\n @books << book\n end",
"def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n flash[:notice] = 'Book was successfully created.'\n format.html { redirect_to book_url(@book) }\n format.xml { head :created, :location => book_url(@book) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors.to_xml }\n end\n end\n end",
"def set_lib_book\n @lib_book = LibBook.find(params[:id])\n end",
"def create\n\t@book = Book.new(book_params)\n\tif @book.save\n\t\tredirect_to root_path\n\telse\n\t\trender 'new'\n\tend\nend",
"def create\n @book = params[:book]\n add(@book)\n end",
"def title\n\t\t@book\n\tend",
"def create\n\t\t@book = Book.new(book_params)\n\t\t@book.save\n\t\tredirect_to books_path\n\tend",
"def fetch_book_info\n url = \"#{BASE_URL}/#{book_id}\"\n resp = RestClient::Request.execute(url: url, method: \"GET\")\n resp_obj = JSON.parse(resp)\n\n {\n id: book_id,\n title: resp_obj[\"volumeInfo\"][\"title\"],\n author: resp_obj[\"volumeInfo\"][\"authors\"][0],\n image: resp_obj[\"volumeInfo\"][\"imageLinks\"] ? resp_obj[\"volumeInfo\"][\"imageLinks\"][\"thumbnail\"] : DEFAULT_IMAGE\n }\n end",
"def new\n @book = Book.new\n end",
"def new\n @book = Book.new\n end",
"def new\n @book = Book.new\n end",
"def new\n @book = Book.new\n end",
"def new\n @book = Book.new\n end",
"def new\n @book = Book.new\n end",
"def new\n @book = Book.new\n end",
"def show\n\t\t@book=Book.find(params[:id])\n\tend",
"def book_info_goodreads_library\n client = Goodreads::Client.new(Goodreads.configuration)\n results = client.book_by_title(params[:q])\n rescue\n []\n end",
"def create\n\n @book = Book.new(book_params)\n book = GoogleBooks.search('isbn:'+@book.ISBN.to_s)\n first_book = book.first\n @book.name = first_book.title\n @book.publication_year = first_book.published_date\n @book.author= first_book.authors_array[0]\n\n category_name = first_book.categories.split(\",\")[0]\n category = Category.where(name: category_name ).take\n\n if(category == nil)\n category = Category.new(:name=>category_name)\n category.save\n end\n\n @book.category_id = category.id\n\n\n\n\n\n respond_to do |format|\n @book_search = Book.where(ISBN: @book.ISBN).take\n\n if(@book_search != nil)\n book_library_search = BookLibraryRelation.where(book_id: @book_search.id , library_id: current_admin.library_id).take\n msg ='Book is already in library'\n if(book_library_search == nil)\n @book_library = BookLibraryRelation.new(:book_id=>@book_search.id,:library_id=> current_admin.library_id)\n @book_library.save\n msg = 'Book was successfully created'\n end\n format.html { redirect_to @book_search, notice: msg }\n format.json { render :show, status: :created, location: @book_search }\n else\n\n if @book.save\n @book_library = BookLibraryRelation.new(:book_id=>@book.id,:library_id=> current_admin.library_id)\n @book_library.save\n\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n if is_admin?\n @book = get_book\n else\n go_home\n end\n\n go_home if !@book\n\n respond_to do |format|\n if @book.save\n flash[:notice] = 'Book was successfully created.'\n format.html { redirect_to(@book) }\n format.xml { render :xml => @book, :status => :created, :location => @book }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def book(params)\n Ciirus::Commands::Booking.new(credentials).call(params)\n end",
"def first_book\n Book.find(:first)\n end",
"def create\n\t\t@books = Book.new(params [:book])\n\n\t\t@books.save\n\n\t\t#redirects to \"show\" method\n\t\tredirect_to @books\n\tend",
"def set_book\n @book = Book.friendly.find(params[:id])\n end",
"def book(params)\n client = jsonrpc(ENDPOINT)\n result = client.invoke(\"PlaceBookingV1\", reservation_details(params))\n\n if result.success?\n parse_book_response(params, result.value)\n else\n result\n end\n end",
"def write_book(title,num_pages)\n # THIS PARTICULAR author\n # self\n # WRITE A NEW book\n book = Book.new(title,self,num_pages)\n #code\n end",
"def new\n @book = Book.new\n end",
"def get_books\n unless self.scraped\n page = Nokogiri::HTML(open(self.url), nil, \"iso-8859-1\")\n item_elements = page.css(\".g-span7when-wide\")\n item_elements.each do |item|\n book_data = {}\n book_data[:title] = item.at_css(\".a-link-normal\").text.strip\n book_data[:author] = item.at_css(\".a-size-small\").text.split(\"by\")[-1].strip\n book_data[:price] = item.at_css(\".a-color-price\").text.strip\n book_data[:price] = \"N/A\" unless book_data[:price].include?(\"$\")\n book_data[:asin] = item.at_css(\".a-link-normal\")[\"href\"].split(\"/\")[2].strip.split(\"?\")[0]\n self.books << Book.new(book_data)\n end\n self.last_scraped = Time.now\n self.scraped = true\n end\n end",
"def return_user_books(input)\n @books = GoogleBooks::API.search(@input, :count => 5)\n @books.each do |book|\n if !(book.title.nil? || book.authors.nil? || book.publisher.nil?)\n puts book.title, book.authors, book.publisher, \"\\n\"\n end\n end\n\n def save_book_title\n puts \"If you would like to save a book to your reading list, please type the title of the book you'd like to save.\" .blue\n get_user_book_input(@input)\n book_input = @input\n if book_to_save = @books.find{|book| book.title == book_input }\n GoogleLib::Google_library.all << book_input\n else\n puts \"Please enter a valid title\"\n save_book_title\n end\n end\n end",
"def create\n @api_book = Api::Book.new(api_book_params)\n\n if @api_book.save\n render json: @api_book, status: :created, location: @api_book\n else\n render json: @api_book.errors, status: :unprocessable_entity\n end\n end",
"def create\n @book = Book.new(get_book_with_api(book_params[:title]))\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: '本を新規登録しました。' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_publisher #returns for a specific object/instance of type Book\n puts \"I'm in the get publisher instance method\"\n end",
"def book_by_isbn(isbn)\n\t\t\tresponse = request('/book/isbn', :isbn => isbn)\n\t\t\tHashie::Mash.new(response['book'])\t\t\t\t\n\t\tend",
"def create\n #raise params.inspect\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n flash[:notice] = t('book.title2')+\" \"+t('created')\n format.html { redirect_to(@book) }\n format.xml { render :xml => @book, :status => :created, :location => @book }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n if @book.save\n redirect_to book_path(@book)\n #based on the routes (@ localhost.../routes, or rakes route, we can use the defined path as opposed to a link)\n else\n render 'new'\n #goes back to the new method if the book is not saved\n end\n end",
"def new\n @library_book = LibraryBook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @library_book }\n end\n end",
"def create\n\t\t@book = Book.new(params[:book])\n\t\t@book.user = current_user\n\n\t\trespond_to do |format|\n\t\t\tif @book.save\n\t\t\t\tformat.html { redirect_to @book, :notice => 'Book was successfully created.' }\n\t\t\t\tformat.json { render :json => @book, :status => :created, :location => @book }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.json { render :json => @book.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n flash[:notice] = 'Book was successfully created.'\n format.html { redirect_to(@book) }\n format.xml { render :xml => @book, :status => :created, :location => @book }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n flash[:notice] = 'Book was successfully created.'\n format.html { redirect_to(@book) }\n format.xml { render :xml => @book, :status => :created, :location => @book }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n flash[:notice] = 'Book was successfully created.'\n format.html { redirect_to(@book) }\n format.xml { render :xml => @book, :status => :created, :location => @book }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @book = Book.find(params[:id])\n end",
"def show\n @book = Book.find(params[:id])\n end",
"def show\n @book = Book.find(params[:id])\n end",
"def show\n @book = Book.find(params[:id])\n end",
"def show\n @book = Book.find(params[:id])\n end",
"def show\n @book = Book.find(params[:id])\n end"
] | [
"0.77180934",
"0.7081529",
"0.7010487",
"0.68856025",
"0.67969453",
"0.67892164",
"0.67892164",
"0.6716013",
"0.6636221",
"0.6635891",
"0.66128635",
"0.65825385",
"0.6545766",
"0.65425885",
"0.6538816",
"0.6533374",
"0.65168685",
"0.6478277",
"0.6473248",
"0.64567584",
"0.6451787",
"0.64504814",
"0.642885",
"0.6425304",
"0.6411555",
"0.6375658",
"0.6353122",
"0.6342565",
"0.6322974",
"0.63141143",
"0.63103396",
"0.6309109",
"0.6268663",
"0.62534636",
"0.6253381",
"0.62460905",
"0.6237428",
"0.62295103",
"0.6217765",
"0.621106",
"0.6202201",
"0.6199104",
"0.6197547",
"0.61920506",
"0.61828876",
"0.6181721",
"0.6155698",
"0.6146303",
"0.6146303",
"0.61382335",
"0.6132144",
"0.6124326",
"0.6121849",
"0.6114092",
"0.61084265",
"0.60963666",
"0.60883117",
"0.6083171",
"0.60644037",
"0.6047079",
"0.60457706",
"0.6045427",
"0.60355717",
"0.60334194",
"0.602953",
"0.602953",
"0.602953",
"0.602953",
"0.602953",
"0.602953",
"0.602953",
"0.60283476",
"0.60269177",
"0.60221803",
"0.6015254",
"0.6002464",
"0.6001719",
"0.59985983",
"0.5997555",
"0.5995982",
"0.59926474",
"0.59852326",
"0.5983007",
"0.59739465",
"0.59732944",
"0.59726983",
"0.596302",
"0.5962362",
"0.59592867",
"0.5953643",
"0.5953431",
"0.5952013",
"0.5950909",
"0.5950909",
"0.5950909",
"0.5945066",
"0.5945066",
"0.5945066",
"0.5945066",
"0.5945066",
"0.5945066"
] | 0.0 | -1 |
Create a new record for current transaction One record is created for one book. Every user can only borrow a book for 60 days. | def add_a_record(user, book)
now = DateTime.now.to_date
borrow_days = 60
due = now + borrow_days
@records << Record.new(user.id, book.isbn, now, due)
puts "Successfully lend <#{book.title}> to #{user.name}. Due:#{due}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n book_id = params[:book_id]\n book_title = params[:book_title]\n borrowerid = params[:borrowerid]\n borrowdate = params[:borrow_date]\n returndate = params[:return_date]\n @borrowtable = Borrowtable.new(:bookid => book_id, :bookname => book_title, :borrowerid => borrowerid,\n :borrowdate => borrowdate, :returndate => returndate)\n\n @borrowtable.student = current_user.student\n\n historyborrowtable = Historyborrowtable.new(:bookid => book_id, :bookname => book_title, :borrowerid => borrowerid,\n :borrowdate => borrowdate, :returndate => \"未归还\")\n\n historyborrowtable.student = current_user.student\n historyborrowtable.save!\n\n\n student = Student.find(borrowerid)\n\n book = Book.find(book_id)\n book.state = \"已借阅\"\n book.save!\n\n respond_to do |format|\n if @borrowtable.save\n format.html { redirect_to @borrowtable, notice: '借阅成功!' }\n format.json { render :show, status: :created, location: @borrowtable }\n else\n format.html { render :new }\n format.json { render json: @borrowtable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.find_by_id(params[:book_id])\n # check to see if there is enough copies of the book\n if @book.total_in_library > 0\n @reservation = @user.reservations.new\n @reservation.user_id = @user.id\n @reservation.book_id = @book.id\n if @reservation.save && @book.update(total_in_library: @book.total_in_library - 1)\n redirect_to reservations_path, notice: \"#{@book.title} has been reserved\"\n else\n redirect_to book_path(@book), notice: \"Problems reserving #{@book.title}\"\n end\n else # if not enough copies return back to the show page of the book\n redirect_to book_path(@book), notice: \"Not enough copies of #{@book.title} to reserve\"\n end\n end",
"def new\n logger.debug \"new transaction\"\n #@transaction = Transaction.new\n #check login\n if(user_signed_in?)\n logger.debug params\n #check book\n book = Book.find(:first, :conditions => {:id =>params[:id]})\n if(!book)\n respond_to do |format|\n format.html { redirect_to home_path, notice: 'Invalid Book.' }\n end\n return;\n end\n #check current_quantity\n if (!book.current_quantity)\n #book.current_quantity = book.quantity\n book.update_attributes(:current_quantity=>book.quantity)\n #book.save\n end\n #check user\n if(!current_user.books_borrow)\n current_user.update_attributes(:books_borrow => 0)\n end\n if(!current_user.can_borrow_more )# FIX ME if use admin control\n logger.debug \"borrow enough books, can't borrow anymore\"\n redirect_to \"/books/view?topic=#{book.type}&id=#{book.id}\";\n return;\n end\n #check old transaction new\n if (current_user.is_borrowed(book.id))\n logger.debug \"already borrow\"\n redirect_to \"/books/view?topic=#{book.type}&id=#{book.id}\";\n return;\n end\n #check old transaction old\n #old_transactions = Transaction.find(:all, :conditions => {:book_id=>book.id, :user_id=>current_user.id})\n #old_transactions.each do |old_transaction|\n # if(old_transaction.status == 1)#borrow but haven't return\n # redirect_to \"/books/view?topic=#{book.type}&id=#{book.id}\";\n #FIX ME, redirect to already borrow page\n # return;\n # end\n # end\n if (book.current_quantity > 0)\n @transaction = Transaction.new();\n @transaction.book_id = book.id;\n @transaction.user_id = current_user.id;\n @transaction.day_borrow = Date.today.to_s;\n @transaction.day_return = (Date.current+14).to_s;\n @transaction.status = 1 ;#dang muon\n @transaction.save;\n #current_quantity increase\n book.current_quantity -=1;\n book.save;\n #user borrow book increase\n current_user.update_attributes(:books_borrow => current_user.books_borrow+1)\n\n redirect_to \"/books/view?topic=#{book.type}&id=#{book.id}\";\n return;\n end\n else\n respond_to do |format|\n format.html { redirect_to new_user_session_path, notice: 'You must login first.' }\n end\n # redirect_to new_user_session_path\n return;\n end\n redirect_to \"/\";\n return;\n # respond_to do |format|\n #format.html # new.html.erb\n # format.json { render json: @transaction }\n # end\n end",
"def create\n @transaction = Transaction.new(transaction_params)\n\n respond_to do |format|\n if @transaction.save\n\t\t\t\t@transaction.holding.calc_book_val() if @transaction.holding\n format.html { redirect_to @transaction, notice: 'Transaction was successfully created.' }\n format.json { render action: 'show', status: :created, location: @transaction }\n else\n format.html { render action: 'new' }\n format.json { render json: @transaction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = current_user.books.build(book_params)\n if @book.save\n flash[:notice] = \"Book Created Succesfully\"\n redirect_to @book\n else\n redirect_to new_book_path\n flash[:alert] = \"Something wrong with your book parameters.\"\n end\n end",
"def create \n bparams = booking_params\n bparams[:created_by] = User.find_by_name(session[:user])\n bparams[:date] = Date.strptime(session[:date], \"%d.%m.%Y\")\n \n bparams[:accounting_number] = Booking.where(account_id: bparams[:account_id]).map {|b| b.accounting_number}.compact.max.to_i+1\n \n @booking = Booking.new(bparams)\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to :back, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def reserved\n @book = Book.find(params[:book_id])\n @reservation = Reservation.new(\n user_id: current_user.id,\n book_id: @book.id,\n price: @book.price\n )\n @reservation.save!\n end",
"def create_booking(table)\n booking = Booking.new(table_id: table.id,\n start_time: @start_date,\n end_time: @end_date,\n length: params[:hours],\n user_id: current_user.id)\n booking.table = table\n booking.save\n end",
"def create\n @user = current_user\n @book = Book.new(book_params)\n @book.owner = @user\n \n respond_to do |format|\n if @book.save\n BookMailer.book_created(@user).deliver_now\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_new_booking_oct(customer, space)\n new_booking = Booking.new\n new_booking.user = customer\n new_booking.space = space\n new_booking.date_start = DateTime.strptime(\"10/14/2019\", \"%m/%d/%Y\")\n new_booking.date_end = DateTime.strptime(\"10/14/2019\", \"%m/%d/%Y\")\n return new_booking\nend",
"def create\n begin\n @book = current_user.writings.create!(params[:book])\n rescue Exception => e\n render 'new', error: @book.errors.full_messages\n end\n\n redirect_to @book\n end",
"def create\n puts \"------params create #{params.inspect}\"\n # @booking = current_user.bookings.create(booking_params)\n # redirect_to @booking.item, notice: \"Your booking has been created...\"\n @item = Item.find(params[:item_id])\n @booking = @item.bookings.build(booking_params)\n\n @booking.user = current_user\n\n if params[:commit] == 'Book'\n puts @booking.start_date.strftime(\"%Y-%m-%d\").inspect\n @start_date = @booking.start_date.strftime(\"%Y-%m-%d\")\n @end_date = @booking.end_date.strftime(\"%Y-%m-%d\")\n\n found = false\n @all_bookings = Booking.all\n\n @all_bookings.each do |booking|\n if booking.has_paid == TRUE\n start_date= booking.start_date.strftime(\"%Y-%m-%d\")\n end_date = booking.end_date.strftime(\"%Y-%m-%d\")\n if @start_date.between?(start_date, end_date) || @end_date.between?(start_date, end_date)\n if booking.item_id == @booking.item_id\n found = true\n end\n end\n end\n end\n\n if found == true\n redirect_to request.referrer, notice: \"This dress is already booked for this period.\"\n else\n @booking.save!\n redirect_to edit_item_booking_url(@item,@booking), notice: \"You have booked the dress successfully. Please contact owner to fix a time for trial or directly proceed with payment.\"\n end\n end\n\n if params[:commit] == 'Pay'\n respond_to do |format|\n if @booking.save && params[:commit] == 'Pay'\n format.html { redirect_to item_booking_url(@item,@booking), notice: 'Invoice' }\n format.json { render :show, status: :created, location: @booking }\n # f.json { render action: 'show', status: :created, location: @step }\n else\n format.html { render action: 'new' }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n\n end\n end\n\n end",
"def create\n @transaction = current_user.transactions.build(transaction_params)\n # if @holding_id.nil?\n # byebug\n # @holding = Transaction.find_holding(current_user, :symbol)\n # if @holding.blank?\n # @holding = Holding.create(symbol: transaction_params[:symbol], \n # quantity: transaction_params[:quantity], cost_basis: transaction_params[:price],\n # avg_price: transaction_params[:amount])\n # end\n # @transaction.holding_id = @holding.id\n # end\n # Transaction.build_description\n # @transaction = current_user.transactions.build(transaction_params)\n # #@transaction = Transaction.new(transaction_params)\n\n respond_to do |format|\n if @transaction.save\n format.html { redirect_to @transaction, notice: 'Transaction was successfully created.' }\n format.json { render :show, status: :created, location: @transaction }\n else\n format.html { render :new }\n format.json { render json: @transaction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_transaction\n category = FinanceTransactionCategory.find_by_name('Donation')\n transaction = category.finance_transactions.create(title: donor\\\n , description: description, amount: amount\\\n , transaction_date: transaction_date)\n update(finance_transaction_id: transaction.id)\n end",
"def create\n\t\t@book = Book.new(book_params)\n\t\t@book.save\n\t\tredirect_to books_path\n\tend",
"def create\n @borrowed_book = BorrowedBook.new(borrowed_book_params)\n respond_to do |format|\n if @borrowed_book.save\n borrow(@borrowed_book)\n format.html { redirect_to @borrowed_book, notice: 'Borrowed book was successfully created.' }\n format.json { render :show, status: :created, location: @borrowed_book }\n else\n format.html { render :new }\n format.json { render json: @borrowed_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = params[:book]\n add(@book)\n end",
"def create\n # checkin_date = session[:booking][:checkin]\n # checkout_date = session[:booking][:checkout]\n # room_type_id = session[:booking][:room_type_id]\n checkin_date = params[:booking][:checkin]\n checkout_date = params[:booking][:checkout]\n room_type_id = params[:booking][:room_type]\n\n days = (checkout_date.to_date - checkin_date.to_date).to_i\n \n #@room = Room.where(\"room_type_id = ? AND (id NOT IN (?))\", room_type_id, Booking.joins(:room_occupation).where(\"start_at >= ? OR end_at <= ?\", checkin_date, checkout_date).select(:room_id) ).first\n #@room = Room.where(\"room_type_id = ?\", room_type_id).first\n @room = Room.empty_rooms(checkin_date, checkout_date).where(:room_type_id => room_type_id).first\n \n if @room.nil?\n redirect_to :back, :alert => \"No room avalible\"\n return\n end\n \n Payment.transaction do\n visit_params = Hash.new()\n visit_params[:customer_id] = current_user.id\n visit_params[:should_checkin_at] = checkin_date\n visit_params[:should_checkout_at] = checkout_date\n visit_params[:rate] = @room.base_rate\n visit_params[:room_id] = @room.id\n visit_params[:days] = days\n\n @visit = Visit.new(visit_params)\n @visit.save\n\n date = checkin_date.to_date\n while(date < checkout_date.to_date)\n occupancy_params = Hash.new()\n occupancy_params[:date] = date\n occupancy_params[:room_id] = @room.id\n occupancy_params[:visit_id] = @visit.id\n @occupance = Occupancy.new(occupancy_params)\n @occupance.save\n date = date + 1.day\n end\n\n @payment = current_user.build_payment(payment_params)\n @payment.price = (@room.base_rate * days).to_f\n @payment.visit_id = @visit.id\n @payment.save\n \n end\n redirect_to payment_path(@payment)\n\n end",
"def create\n @book = Book.new(book_params)\n @book.Time = Time.now\n @book.UpTime = Time.now\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: '新しい書籍が登録されました。' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_loan\n book = Book.find(params[:book_id])\n book_loan = Log.create!(user: current_user, book: book, classification: Log.classifications[:book_loan],\n date: DateTime.now, due_date: 3.weeks.from_now)\n render json: book_loan, book_loan: true, status: :created\n end",
"def create\n @book_params = params[:book]\n @date = Date.new(@book_params[\"published_date(1i)\"].to_i, @book_params[\"published_date(2i)\"].to_i, @book_params[\"published_date(3i)\"].to_i)\n @book = Book.new(title: @book_params[:title], author: @book_params[:author], genre: @book_params[:genre], price: @book_params[:price], published_date: @date)\n \n if @book.save\n redirect_to root_path, notice: \"The book \\\"#{@book.title}\\\" has been ADDED!\"\n else\n render :new\n end\n end",
"def create_books\n transaction {\n 150.times do\n Book.create(\n title: rand_name,\n author: rand_record(Author),\n publisher: rand_record(Publisher)\n )\n end\n }\n create_message Book\nend",
"def create\n @book = Book.find(params[:id])\n authorize @book, :rent?\n @rental = Rental.create(book: @book, user: current_user)\n\n if @rental.save\n redirect_to books_url, notice: 'Book was successfully rented.'\n else\n redirect_to books_url, notice: 'Could not rent a book'\n end\n end",
"def create\n @loan = Loan.new(loan_params)\n @book = Book.find_by( params[:book_id] )\n\n respond_to do |format|\n if @loan.save\n format.html { redirect_to @loan, notice: 'Book successfully borrowed' }\n format.json { render :show, status: :created, location: @loan }\n else\n format.html { redirect_to books_path, alert: 'Book not available' }\n end\n end\n end",
"def create\n temp = transaction_params\n temp[:user_id] = current_user.id\n temp[:borrow_date] = DateTime.now\n \n to_borrow = MovieItem.find_by(id: temp[:movie_item_id])\n @transaction = ItemTransaction.new(temp)\n respond_to do |format|\n if is_suspended?\n fomat.html { render :new }\n format.json {render json: {message: \"User account is suspended!\"}, status: :unprocessable_entity }\n elsif to_borrow.nil?\n format.html { render :new }\n format.json { render json: {message: \"Invalid Movie Item ID!\"}, status: :unprocessable_entity }\n elsif (ItemTransaction.where(user_id: current_user.id, return_date: nil).count > 3)\n format.html { render :new }\n format.json { render json: {message: \"You may only borrow up to 3 movies at a time!\"}, status: :unprocessable_entity }\n elsif !to_borrow.in_store? \n format.html { render :new }\n format.json { render json: {message: \"Movie Item is unavailable!\"}, status: :unprocessable_entity }\n else\n if @transaction.save\n to_borrow.update_attribute(:in_store, false)\n format.html { redirect_to @transaction, notice: 'Transaction was successfully created.' }\n format.json { render json: {message: \"Borrowed successfully!\"}, status: :created }\n else\n format.html { render :new }\n format.json { render json: @transaction.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n # @reservation = Reservation.new(reservation_params)\n @reservation = current_user.reservations.create!(reservation_params)\n\n respond_to do |format|\n if @reservation.save\n format.html { redirect_to @reservation, notice: 'Reservation was successfully created.' }\n format.json { render :show, status: :created, location: @reservation }\n else\n format.html { render :new }\n format.json { render json: @reservation.errors, status: :unprocessable_entity }\n end\n end\n # current_user.book! @reservation\n end",
"def create\n @user = current_user\n @book = current_user.books.new(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render action: 'show', status: :created, location: @book }\n else\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @booking = Booking.new(booking_params)\n \n unless params[:subject_id].empty?\n @subject = Subject.find(params[:subject_id])\n end\n # TODO date and time validation\n begin\n date = (params['date_part'] + \" \" + params['time_part']).to_datetime\n rescue ArgumentError\n @booking.errors.add(:date, \"is invalid\")\n date = Date.new\n end\n @booking.booking_date = date\n # TODO: Refactor for admin booking creation\n @booking.shared = params[\"shared\"]\n @booking.subject = @subject\n # Add this customer as owner. \n @booking.creator = current_user.customer\n @booking.customers << current_user.customer\n @booking.booked_customers.first.number_students = params[:booking][:booked_customers][:number_students]\n @booking.period = 2\n \n # Create closed booking if customer came from searching or enquiring.\n if params[:presenter_id].present?\n presenter = Presenter.find(params[:presenter_id])\n if presenter.available? @booking.booking_date, @booking.duration_minutes\n @booking.chosen_presenter = Presenter.find(params[:presenter_id])\n @booking.rate = presenter.rate\n @booking.creator = current_user.customer\n else\n @booking.errors.add(:presenter, \"is not available at this time\")\n end\n end \n \n if @booking.save\n # Only send messages to customers if booking is shared\n @message = \"A new #{@booking.subject.name} booking has been created that you may be interested in.\"\n if @booking.shared?\n Notification.notify_applicable_users(current_user, @booking, \"customer\", booking_path(@booking), @message, :interested_booking)\n end\n # Only send messages to presenters if booking is open\n if @booking.chosen_presenter.nil?\n Notification.notify_applicable_users(current_user, @booking, \"presenter\", booking_path(@booking), @message, :interested_booking)\n end\n Notification.notify_admin(\"A new booking has been created\", booking_path(@booking), :booking)\n\n # Add booking to booked customers\n current_user.customer.created_bookings << @booking\n\n #clear search session \n session[:search_params] = nil\n redirect_to @booking\n else\n @date_part = params['date_part']\n @time_part = params['time_part']\n render :new\n end\n\n end",
"def create\n @transaction = Transaction.new(transaction_params)\n @num = 1\n while Transaction.where([\"transaction_id = ?\", @num]).size > 0\n @num = @num + 1\n end\n @transaction.transaction_id = @num\n @transaction.user_email = current_user.email\n respond_to do |format|\n if @transaction.save\n format.html { redirect_to @transaction, notice: 'Transaction was successfully created.' }\n format.json { render :show, status: :created, location: @transaction }\n else\n format.html { render :new }\n format.json { render json: @transaction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @booking = current_user.bookings.build(booking_params)\n @booking.user = current_user\n logger = MyLogger.instance\n logger.logInformation(\"A new booking made for: \" + @booking.cut)\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n getBookId = Book.where(name:@book.name)\n getBookId.each do |id_book|\n params[:amount_code].each do |value|\n Amount.new(code: value, book_id: id_book.id, active: 0).save\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n if @book.save\n flash[:notice] = \"Book record successfully created\"\n redirect_to books_url\n else\n render \"new\"\n end\n end",
"def create\n @book = current_user.books.new(book_params)\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book=Book.new(book_params)\n @book.status=\"submitted\"\n create!\n end",
"def new\n\n\t \t@book = Book.new\n\t \tif params[:book]\n\n\t \t\t@book = Book.new(book_params)\n\n\t \t\t# lay id nguoi dang logi ngan vao owner_id de xac nhan chinh chu\n\t \t\t@book[:owner_id] = current_user.id\n\n\t \t\tif @book.save\n\n\t \t\t\tflash[:success] = \"Saved book!\"\n\t \t\t\tredirect_to '/books'\n\t \t\tend\n\t \tend\n \tend",
"def create\n @rate = Rate.new(rate_params)\n @rate.user_id = current_user.id\n @rate.book_id = params[:book_id]\n respond_to do |format|\n if @rate.save\n format.html { redirect_to Book.find(params[:book_id]), notice: 'Rate was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def create_transaction(amount, fine)\n student = self.student\n collection = finance_fee_collection\n category = FinanceTransactionCategory.find_by_name('Fees')\n t = category.finance_transactions.new\n t.title = \"#{student.first_name + ' ' + student.last_name}\"\n t.description = \"#{collection.name + ' ' + collection.start_date.to_s}\"\n t.amount = amount\n t.transaction_date = Date.today\n t.student_id = student.id\n t.finance_fee_id = id\n t.fine_included = fine\n t.save\n end",
"def create\n @book = Book.new(params[:book])\n user_session = UserSession.new\n user_session.current_user.books << @book\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # @book = Book.new(params[:book])\n\n @user = User.find(current_user.id)\n @book = Book.new(params[:book])\n @book.user_id = @user.id\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = current_user.books.build(book_params)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n @book.save\n redirect_to root_path\n end",
"def create\n @user = current_user\n if verify_admin || verify_librarian\n @book = Book.new(book_params)\n @book.nums_request = 0\n @book.library = @user.library if (@user.role == 'librarian')\n @book.is_delete = false\n @book.nums_borrowed = 0\n @library = Library.find_by_name(@book.library)\n @book.university = @library.university\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n\n end\n end\n else\n redirect_to books_url, notice: 'Unauthorized action!'\n\n end\n end",
"def create\n @transaction = current_user.transactions.new(params[:transaction])\n \n respond_to do |format|\n if @transaction.save\n format.html { redirect_to transactions_path, notice: 'Transaction was successfully created.' }\n else\n format.html { render action: \"new\" }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n @book.user_id = current_user.id\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to(@book) }\n format.xml { render :xml => @book, :status => :created, :location => @book }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @book.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(params[:book])\n @book.user_id = current_user.id\n # can alternatively use:\n # @book = current_user.books.build(params[:book])\n\n # I used the below code before I had added before_create to book model\n # client = Goodreads.new\n # book_info = client.book_by_isbn(params[:book][:isbn])\n # @book.title = book_info.title if @book.title.blank?\n \n\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n @book.user_id = current_user.id\n @book.save\n respond_with(@book, :flash => true)\n end",
"def create\n auction_voucher = Auction::Event.find_by(id: auction_voucher_params[:event_id])\n if auction_voucher && auction_voucher.ended_at > Time.now && auction_voucher.published == true\n ActiveRecord::Base.transaction do\n if auction_voucher_params[:user_id].split(\",\").length > 1\n auction_voucher_params[:user_id].split(\",\").each do |id|\n @auction_voucher = Auction::Voucher.create(:user_id => id,:event_id => auction_voucher_params[:event_id] ,:obtained_at => Time.now)\n end\n else\n @auction_voucher = Auction::Voucher.create(:user_id => auction_voucher_params[:user_id],:event_id => auction_voucher_params[:event_id] ,:obtained_at => Time.now)\n end\n end\n if @auction_voucher\n flash_msg('success', \"发放优惠券成功\", 'index')\n else\n flash_msg('danger', \"发放优惠券失败\", 'new')\n end\n else\n flash_msg('danger', \"发放优惠券失败!id 为#{auction_voucher_params[:event_id]}的券种不存在,或已过期,或未发布\", 'new')\n end\n end",
"def create\n flash[:success] = 'Added new Book...!'\n redirect_to :new_user_book, {user_id: @current_user}\n # @book = Book.new(book_params)\n #\n # respond_to do |format|\n # if @book.save\n # format.html { redirect_to @book, notice: 'Book was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @book }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @book.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create_booking(params)\n credentials = Concierge::Credentials.for(\"SAW\")\n SAW::Client.new(credentials).book(params)\n end",
"def create_bid\n @instrument.bids.create!(user: current_user, price: @instrument.price)\n end",
"def create\n @book = Book.new(book_params)\n\n if @book.save\n redirect_to root_path, notice: 'Book was successfully created.'\n else\n render :new, status: :unprocessable_entity\n end\n end",
"def create\n @borrowed_book = BorrowedBook.new(borrowed_book_params)\n\n respond_to do |format|\n if @borrowed_book.save\n format.html { redirect_to @borrowed_book, notice: \"Borrowed book was successfully created.\" }\n format.json { render :show, status: :created, location: @borrowed_book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @borrowed_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @borrow = Borrow.new(params[:borrow])\n\n respond_to do |format|\n if @borrow.save\n flash[:notice] = 'Borrow was successfully created.'\n format.html { redirect_to(@borrow) }\n format.xml { render :xml => @borrow, :status => :created, :location => @borrow }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @borrow.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_new_booking_sep(customer, space)\n new_booking = Booking.new\n new_booking.user = customer\n new_booking.space = space\n new_booking.date_start = DateTime.strptime(\"09/01/2019\", \"%m/%d/%Y\")\n new_booking.date_end = DateTime.strptime(\"09/02/2019\", \"%m/%d/%Y\")\n return new_booking\nend",
"def create\n @borrow = Borrow.new(params[:borrow])\n\n respond_to do |format|\n if @borrow.save\n format.html { redirect_to @borrow, notice: 'Borrow was successfully created.' }\n format.json { render json: @borrow, status: :created, location: @borrow }\n else\n format.html { render action: \"new\" }\n format.json { render json: @borrow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # Check if this book is in the system\n @book = Book.find_by(id: book_item_params[:book_id])\n if @book == nil \n # Meaning this book is not added to database and \n # book_item_params[:id] is Goodread id\n @book = save_goodreads_book(book_item_params[:book_id])\n book_item_params[:book_id] = @book.id\n end\n # Check if this book_item already in this shelf\n shelf = Shelf.find(book_item_params[:shelf_id])\n @book_item = shelf.book_items.new(book_item_params)\n \n if shelf.save!\n flash[:success] = \"Book item was successfully created.\"\n redirect_to current_user\n else\n flash[:error] = \"Cannot add book to Bookshelf\"\n redirect_to current_user\n end\n end",
"def create\n @booking = @instrument.bookings.new(booking_params)\n @booking.user = current_user\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: t('.success') }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @transaction = @account.transactions.build(params[:transaction])\n @transaction.created_at = Time.now\n if @transaction.recur_id != nil\n @transaction.doc_number = nil\n @recurring = @account.recurrings.find(@transaction.recur_id)\n @transaction.description = @recurring.name\n if @recurring.transaction_type == 'Withdrawal'\n @transaction.wamount = @recurring.amount\n @transaction.damount = nil\n else\n @transaction.damount = @recurring.amount\n @transaction.wamount = nil\n end\n end\n respond_to do |format|\n if @transaction.save\n # do bucket allocation\n if @transaction.recur_id != nil\n @recurring.rbuckets.each do |r|\n @tbucket = Tbucket.new\n @tbucket.abucket_id = r.abucket_id\n @tbucket.transaction_id = @transaction.id\n if @recurring.transaction_type == 'Withdrawal'\n @tbucket.wamount = r.amount\n else\n @tbucket.damount = r.amount\n end\n @tbucket.save\n end\n end\n flash[:notice] = 'Transaction was successfully created.'\n format.html { redirect_to(account_transactions_path(@account)) }\n format.xml { render :xml => @transaction, :status => :created, :location => @transaction }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @transaction.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @currency = Currency.first\n \n @transaction_history = TransactionHistory.new(transaction_history_params)\n @transaction_history.user_id = current_user.id\n respond_to do |format|\n if @transaction_history.save\n format.html { redirect_to @transaction_history, notice: 'Transaction history was successfully created.' }\n format.json { render :show, status: :created, location: @transaction_history }\n else\n format.html { render :new }\n format.json { render json: @transaction_history.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t# Set up the new bid\n\t\t@bid = Bid.new\n\t\t@bid.amount = (bid_params[:amount].to_f * 100).to_i # Convert to integer and handle input with or without cents\n\t\t@time = Time.now\n\t\t@bid.bid_time = @time\n\t\t@bid.user_id = @current_user.id\n\t\t@bid.auction_id = session[:auction_id]\n\n\t\t# Fetch the auction and its associated bids\n\t\t@auction = Auction.find(session[:auction_id])\n\t\t@existing_bids = Bid.where(:auction_id => session[:auction_id])\n\n\t\t# Add the auction to the bidder's watch list\n\t\t@watcher = Watcher.new\n\t\t@watcher.auction_id = session[:auction_id]\n\t\t@watcher.user_id = @current_user.id\n\t\t\n\t\t# Create a new bid history entry\n\t\t@bid_history = BidHistory.new\n\n\t\tif @auction.status == 'live'\n\t\t\tif @auction.user_id == @current_user.id\n\t\t\t\tflash.notice = 'You cannot bid on your own auction'\n\t\t\t\tredirect_to auction_path(session[:auction_id]) and return\n\t\t\telse\n\t\t\t\tif @bid.amount\n\t\t\t\t\tif @existing_bids.length == 0\n\t\t\t\t\t\tif @bid.amount >= @auction.start_price\n\t\t\t\t\t\t\t@auction.current_bid = @auction.start_price\n\t\t\t\t\t\t\t@bid_history.amount = @auction.current_bid\n\t\t\t\t\t\t\t@bid_history.bid_time = @time\n\t\t\t\t\t\t\t@bid_history.username = @current_user.username\n\t\t\t\t\t\t\t@bid_history.auction_id = session[:auction_id]\n\t\t\t\t\t\t\t@bid_history.save\n\t\t\t\t\t\t\t@auction.save\n\t\t\t\t\t\t\tflash.notice = 'You are the first bidder'\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tflash.notice = 'Bid must be at least equal to the starting price'\n\t\t\t\t\t\t\trender :new and return\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\t@highest_bid = Utilities.get_highest_bid(@existing_bids)\n\t\t\t\t\t\tif @highest_bid.user_id == @current_user.id\n\t\t\t\t\t\t\tif @bid.amount > @highest_bid.amount\n\t\t\t\t\t\t\t\tflash.notice = \"You have increased your maximum bid to #{Utilities.convert_to_price(@bid.amount)}\"\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tflash.notice = \"The amount entered needs to be higher than your last maximum bid, please enter an amount greater than #{Utilities.convert_to_price(@highest_bid.amount)}\"\n\t\t\t\t\t\t\t\trender :new and return\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tif @bid.amount > @highest_bid.amount # There is a new high bidder\n\t\t\t\t\t\t\t\t@auction.current_bid = @highest_bid.amount + INCREMENT\n\t\t\t\t\t\t\t\t@bid_history.amount = @auction.current_bid\n\t\t\t\t\t\t\t\t@bid_history.bid_time = @time\n\t\t\t\t\t\t\t\t@bid_history.username = @current_user.username\n\t\t\t\t\t\t\t\t@bid_history.auction_id = session[:auction_id]\n\t\t\t\t\t\t\t\t@bid_history.save\n\t\t\t\t\t\t\t\t@auction.save\n\t\t\t\t\t\t\t\tflash.notice = \"You are now the high bidder, your maximum bid is #{Utilities.convert_to_price(@bid.amount)}\"\n\t\t\t\t\t\t\telsif @bid.amount <= @highest_bid.amount && @bid.amount > @auction.current_bid\n\t\t\t\t\t\t\t\t# The bid should increase by the challenging bidder plus the increment\n\t\t\t\t\t\t\t\tif @highest_bid.amount - @bid.amount < INCREMENT # Do not want to push the high bid over by less than the INCREMENT as this would increase the maximum bid without asking the high bidder to approve\n\t\t\t\t\t\t\t\t\t@auction.current_bid = @highest_bid.amount\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t@auction.current_bid = @bid.amount + INCREMENT\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t@bid_history.amount = @auction.current_bid\n\t\t\t\t\t\t\t\t@bid_history.bid_time = @time\n\t\t\t\t\t\t\t\t@bid_history.username = @current_user.username\n\t\t\t\t\t\t\t\t@bid_history.auction_id = session[:auction_id]\n\t\t\t\t\t\t\t\t@bid_history.save\n\t\t\t\t\t\t\t\t@auction.save\n\t\t\t\t\t\t\t\tflash.notice = 'You were outbid, please enter a higher amount'\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tflash.notice = 'Bid too low, please enter a higher amount'\n\t\t\t\t\t\t\t\trender :new and return\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tflash.notice = 'No amount entered, please try again'\n\t\t\t\t\trender :new and return\n\t\t\t\tend\n\n\t\t\t\tif @bid.save\n\t\t\t\t\t@watcher.save\n\t\t\t\t\tredirect_to auction_path(session[:auction_id])\n\t\t\t\telse\n\t\t\t\t\tflash.notice = 'Bid not entered, please try again'\n\t\t\t\t\trender :new and return\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tflash.notice = 'Sorry, bidding for this auction has ended'\n\t\t\tredirect_to auction_path(session[:auction_id])\n\t\tend\n\n\tend",
"def create_balance\n if account_balance_id == nil\n account_amount = (self.net_price * self.quantity) * -1\n create_balance = AccountBalance.new(date: self.purchase.date, gl_account_id: self.gl_account_id, amount: account_amount, user_id: self.user_id)\n create_balance.save!\n self.account_balance_id = create_balance.id\n else\n update_balance\n end\n end",
"def create\n @transaction = Transaction.new(transaction_params)\n @transaction.stamp = Time.now\n\n respond_to do |format|\n if @transaction.save\n @transaction.customer.lastmodified = @transaction.stamp\n @transaction.customer.balance = @transaction.customer.balance + @transaction.amount\n @transaction.customer.save\n\n format.html { redirect_to @transaction.customer }\n format.json { render :show, status: :created, location: @transaction }\n else\n format.html { render :new }\n format.json { render json: @transaction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_transaction\n Transaction.new(\n player,\n [director_certificate],\n @game.initial_offering,\n [@par_price * director_certificate.num_shares]\n )\n end",
"def create\n @book = Book.new(book_params.merge(user_id:current_user.id))\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n \n @booktitle = Book.find_by_title(book_params[:title])\n if Book.where(:title => book_params[:title]).present?\n @book = Book.find(@booktitle.id)\n @book.count = @book.count + book_params[:count].to_i\n else\n if !(Author.where(:name => book_params[:author_name]).present?)\n @author = Author.create(:name => book_params[:author_name],\n :category => book_params[:category])\n end\n @book = Book.new(book_params)\n @book.author_id = Author.find_by_name(book_params[:author_name]).id\n end\n\n \n respond_to do |format|\n if @book.save\n \n format.json { render json: @book, status: :created, location: @book }\n else\n \n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @book = Book.new(params[:book])\r\n p current_user.id\r\n @book.user_id = current_user._id\r\n\r\n respond_to do |format|\r\n if @book.save\r\n format.html { redirect_to books_url }\r\n format.json { render json: @book, status: :created, location: @book }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @book.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @book = Book.find(book_request_params[:book_id])\n @account = Account.find(params[:account_id])\n @book_request = BookRequest.new(book: @book, reader: @account, holder: @book.account)\n respond_to do |format|\n if @book_request.save\n format.json {\n render json:\n {\n book_id: @book_request.book_id,\n book_request_state: @book_request.state_name\n }\n }\n else\n format.json { render json: @book_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @booking = Booking.new\n @booking.ride = @ride\n @booking.user = current_user\n @booking.booking_status = 'pending'\n if @booking.save!\n redirect_to dashboard_path\n else\n render :new\n end\n end",
"def create \n \n # Check to see if the user is registered/logged in\n if current_user.nil?\n session[:user_book] = params\n # Redirect the user to register/login\n redirect_to new_user_session_path \n \n else \n\n @user_book = UserBook.new(params[:user_book])\n @user_book = current_user.user_books.build(params[:user_book])\n\n respond_to do |format|\n if @user_book.save\n format.html { redirect_to new_user_book_path, notice: 'Your book was successfully added. You may add more books or go back to your shelf.' } #redirect_to @user_book\n format.json { render json: @user_book, status: :created, location: @user_book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_book.errors, status: :unprocessable_entity }\n end\n end\n end \nend",
"def create\n book = Book.create(params[:book])\n redirect_to(book)\n end",
"def created_book(book)\n @book = book\n mail to: \"yossishalem@gmail.com\", subject: 'NerEzion - new book created'\n end",
"def create\n book_id = params[:book_id]\n book_title = params[:book_title]\n damage_date = params[:damage_date]\n borrower_id = params[:borrower_id]\n level = damagebook_params[:level]\n @damagebook = Damagebook.new(:bookid => book_id, :bookname => book_title, :date => damage_date, :level => level )\n unaffirmedbook = Unaffirmedbook.find_by bookid: book_id\n unaffirmedbook.destroy\n book = Book.find(book_id)\n book.state = \"已损坏\"\n book.save!\n student = Student.find(borrower_id)\n student.credit = student.credit - 10\n student.save!\n\n respond_to do |format|\n if @damagebook.save\n format.html { redirect_to @damagebook, notice: '成功加入损坏图书列表!' }\n format.json { render :show, status: :created, location: @damagebook }\n else\n format.html { render :new }\n format.json { render json: @damagebook.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n @book.user = current_user\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n @book.user = current_user\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @transaction = @transactions.build(transaction_params)\n @transaction.account = current_user.account\n if @transaction.save\n redirect_to @transaction, notice: \"#{@transaction.transaction_type_name} was successfully placed.\"\n else\n render :new \n end\n end",
"def create_booking(params)\n credentials = Concierge::Credentials.for(supplier_name)\n RentalsUnited::Client.new(credentials).book(params)\n end",
"def create\n @borrow_history = BorrowHistory.new(borrow_history_params)\n\n respond_to do |format|\n if @borrow_history.save\n format.html { redirect_to @borrow_history, notice: 'Borrow history was successfully created.' }\n format.json { render :show, status: :created, location: @borrow_history }\n else\n format.html { render :new }\n format.json { render json: @borrow_history.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # Check for dates/times overlapping\n puts current_user[:id], \"CURRENT USER\"\n overlap = Booking.where('end_date > ? AND start_date < ?', booking_params[:start_date], booking_params[:end_date])\n\n # If room is free, create booking\n if overlap.length.zero? \n booking = Booking.create!(booking_params)\n render json: { status: 'SUCCESS', message: 'Booking created', data: booking }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Cannot create booking, date already booked' }, status: :unprocessable_entity\n end\n end",
"def create\n @books = Book.all\n @book = current_user.books.new(book_params)\n if @book.save\n redirect_to book_path(@book), notice: 'Book was successfully created.'\n else\n puts @book.errors.full_messages\n render :index, notice: 'error'\n\n end\n end",
"def checkin\n @book = Book.find_by_id(params[:id])\n if( @book.nil?)\n redirect_to root_path , notice:\"Book not found\"\n return\n end\n @book_transaction = BookTransaction.new\n\n end",
"def create\n @book = Book.new(book_params)\n\n # 書籍情報を取得\n get_info\n\n if @res.present? && !@res.has_error? && @res.total_results != 0\n @book.isbn = @res.first_item.get('ItemAttributes/ISBN')\n @book.asin = @res.first_item.get('ASIN')\n @book.title = @res.first_item.get('ItemAttributes/Title')\n @book.publisher = @res.first_item.get('ItemAttributes/Manufacturer')\n @book.author = @res.first_item.get('ItemAttributes/Author')\n @book.description = @res.first_item.get('EditorialReviews/EditorialReview/Content')\n @book.image = @res.first_item.get('MediumImage/URL')\n @book.publish_date = @res.first_item.get('ItemAttributes/PublicationDate')\n @book.number_of_pages = @res.first_item.get('ItemAttributes/NumberOfPages')\n @book.price = @res.first_item.get('ItemAttributes/ListPrice/Amount')\n\n # 取得したISBNが登録されてない場合のみ、取得した書籍を登録する\n @find_book = Book.find_by(isbn: @book.isbn)\n if @find_book.nil?\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: @book.title + ' を新規登録しました。' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to @find_book, notice: @book.title + ' は既に登録されています。' }\n format.json { render :show, status: :created, location: @find_book }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to books_url, notice: '本が見つかりませんでした。' }\n format.json { head :no_content }\n end\n end\n end",
"def create\n @book = current_user.books.new(book_params)\n respond_to do |format|\n if @book.save\n WishListWorker.perform_async(@book.id) # for background wishlist processing\n format.html { redirect_to @book, notice: 'Book was successfully created.' }\n format.json { render action: 'show', status: :created, location: @book }\n else\n format.html { render action: 'new' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tbooking = Booking.new(booking_params)\n\n\t if booking.save\n\t \tPeekBooker.use_a_boat(booking.size, booking.timeslot_id)\n\t \tPeekBooker.delete_overlap_assignments(booking.timeslot_id)\n\t \tPeekBooker.upd_availability(booking.timeslot_id)\n\t \t\n\t \trender json: booking, status: 201\n\t end\n\tend",
"def new\n @transaction = @transactions.build\n end",
"def create\n flag=0\n @@bookinfomail = Booking.new(booking_params)\n @booking = Booking.new(booking_params)\n @user=User.find(session[:user_id])\n if not @user.Admin\n # debugger\n @booking.name = User.find(session[:user_id]).email\n flag=1\n end\n #name is in fact the email of the person who books the room (By Lei Zhang)\n @booking.bookday=Time.new\n #<begin> edit by Lei Zhang\n starttime_string = booking_params[:starttime]\n if starttime_string.length == 4\n starttime_string = \"0\" + starttime_string\n end\n endtime_string = booking_params[:endtime]\n if endtime_string.length == 4\n endtime_string = \"0\" + endtime_string\n end\n \n @booking.endtime = Time.parse(\"%04d-%02d-%02d %s:00\" %[booking_params[\"date(1i)\"], booking_params[\"date(2i)\"], booking_params[\"date(3i)\"], endtime_string])\n @booking.starttime = Time.parse(\"%04d-%02d-%02d %s:00\" %[booking_params[\"date(1i)\"], booking_params[\"date(2i)\"], booking_params[\"date(3i)\"], starttime_string])\n #debugger\n #<end> edited by Lei Zhang\n #--------------\n @bookingrecord=Booking.where(\"room_id= ? and date = ?\",booking_params[:room_id],@booking.date)\n @record=Booking.where(\"name=? and date = ?\", @booking.name,@booking.date)\n #-------------\n #<begin> edited by Lei Zhang\n #debugger\n duration = @booking.endtime - @booking.starttime\n if ((duration/1800 > 4) || (duration<=0))\n flash[:danger] = \"Cannot book for more that 2 hours or less than 0 hours\"\n redirect_to bookings_path\n elsif not (timeconstrain(@bookingrecord,@booking))\n flash[:danger] = \"The room is booked during that period. Try another room or another time\"\n redirect_to bookings_path\n elsif (@booking.starttime <= Time.new) ||((Time.parse(@booking.date.strftime('%Y-%m-%d'))-Time.parse(Time.new.strftime('%Y-%m-%d'))).round/(3600*24)>7)\n flash[:danger] = \"The time period is not correct\"\n redirect_to bookings_path\n elsif (flag==1)&&( not (bookroom_constrain(@record,@booking.starttime,@booking.endtime)))\n flash[:danger] = \"A library member can reserve only one room at a particular date and time\"\n redirect_to bookings_path\n else\n # respond_to do |format|\n # if @booking.save\n # format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n # format.json { render :show, status: :created, location: @booking }\n # else\n # format.html { render :new }\n # format.json { render json: @booking.errors, status: :unprocessable_entity }\n # end\n # end\n if @booking.save\n #debugger\n flash[:success] = \"Room successfully booked\"\n # redirect_to bookings_path\n # redirect_to bookings_path\n redirect_to send_mail_path\n else\n flash[:danger] = \"Cannot book room now. Please try again later\"\n redirect_to bookings_path\n end\n end\n end",
"def creation_params\n params['user_id'] = current_user.id\n params.require(%i[book_id from to])\n params.permit(:book_id, :user_id, :from, :to)\n end",
"def create\n @transaction = Transaction.new(transaction_params)\n\n # rollback all db records once one fail\n transaction = @transaction.transaction do\n amount = transaction_params.dig(:amount).to_d\n @transaction.user.apply_withdrawal(amount)\n @transaction.transaction_with.apply_deposite(amount)\n # create a second transaction record for depoiste, this record useful for\n # history\n Transaction.create(\n amount: @transaction.amount, user: @transaction.transaction_with,\n transaction_state: 'deposite', transaction_with: @transaction.user\n )\n @transaction.save\n end\n\n respond_to do |format|\n if transaction\n format.html { redirect_to @transaction, notice: 'Transaction was successfully created.' }\n format.json { render :show, status: :created, location: @transaction }\n else\n format.html { render :new }\n format.json { render json: @transaction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @loan = Loan.new(params[:loan])\n book = Book.find(params[:loan]['book_id'])\n if book.format == 'Physical'\n helper_book_true book\n @loan.return_date = Date.today + 7\n else \n @loan.return_date = '9999-09-09'.to_date\n end\n respond_to do |format|\n if @loan.save\n format.html { redirect_to @loan, notice: 'Loan was successfully created.' }\n format.json { render json: @loan, status: :created, location: @loan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @booking = Booking.new(booking_params)\n @room = Room.where(\"roomno = ?\", @booking.roomno)\n if @room.nil? or @room.empty?\n flash[:notice] = \"Room not found !\"\n render 'bookings/new' and return\n end\n if current_user.usertype != \"Admin\" and current_user.usertype != 'Super Admin'\n @user = User.where(\"email LIKE ?\", @booking.booked_user)\n else\n @user = User.where(\"email LIKE ?\", @booking.booked_user)\n if @user.nil? or @user.empty?\n flash[:notice] = \"User not found !\"\n render 'bookings/new' and return\n end\n end\n if @booking.starttime.past?\n flash[:notice] = \"You cannot book for the day before today !\"\n render 'bookings/new' and return\n end\n if (@booking.starttime-7.days).future?\n flash[:notice] = \"You cannot book for a day i.e 7 days after today !\"\n render 'bookings/new' and return\n end\n @current_bookings = Booking.where(\"roomno = ? and ? <= endtime and starttime <= ? \", @booking.roomno,\n @booking.starttime, @booking.endtime)\n if not @current_bookings.nil? and not @current_bookings.empty?\n puts @current_bookings.first.starttime\n puts @current_bookings.first.roomno\n flash[:notice] = \"This room is not available at this time. There is another booking which starts at #{@current_bookings.first.starttime} \"\n render 'bookings/new' and return\n end\n if @booking.starttime > @booking.endtime\n flash[:notice] = \"Booking start time can't be greater than end time\"\n render 'bookings/new' and return\n end\n\n if @booking.starttime + 2.hours < @booking.endtime\n flash[:notice] = \"Booking can be made only for 2 hours at a time\"\n render 'bookings/new' and return\n end\n @booking.room_id = @room.first.id\n @booking.user_id = @user.first.id\n flash[:notice] = \"#{@booking.user_id}\"\n @newroom = Room.find(@booking.room_id)\n BookingMailer.booking_email(@booking.starttime,@booking.endtime,@booking.booked_user,@booking.roomno,@newroom.building).deliver_now!\n emails=params[:emails]\n values=emails.split(\",\")\n values.each do |value|\n BookingMailer.booking_email(@booking.starttime,@booking.endtime,value,@booking.roomno,@newroom.building).deliver_now!\n end\n respond_to do |format|\n\n if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def create\n @booking = Booking.new(booking_params)\n @booking.save\n redirect_to action: \"index\"\n end",
"def create_record(model, *args)\n record = new_record(model, *args)\n record.save!\n record.reload\n record\n end",
"def create\n @library_book = current_user.books.new(library_book_params)\n\n respond_to do |format|\n if @library_book.save\n format.html { redirect_to @library_book, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @library_book }\n else\n format.html { render :new }\n format.json { render json: @library_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n\t\t@book = Book.new\n\tend",
"def create\n\t\t@book = Book.new(params[:book])\n\t\t@book.user = current_user\n\n\t\trespond_to do |format|\n\t\t\tif @book.save\n\t\t\t\tformat.html { redirect_to @book, :notice => 'Book was successfully created.' }\n\t\t\t\tformat.json { render :json => @book, :status => :created, :location => @book }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.json { render :json => @book.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @booking = Booking.new(params[:booking].except(:contact))\n logger.debug(@booking.id)\n @booking.amount = 0\n if @booking.save\n @contact = @booking.create_contact(params[:booking][:contact])\n if @contact.save\n redirect_to \"/bookings/#{@booking.id}/rooms/new?no_of_rooms=#{params[:rooms]}\"\n else\n @booking.destroy\n render action: 'new'\n end\n else\n render action: 'new'\n end\n end",
"def create\n\t\t@book = current_user.books.build(book_params)\n\t\t#to associate book with category id\n\t\t@book.category_id = params[:category_id]\n\t\tif @book.save \n\t\t\tredirect_to root_path\n\t\telse\n\t\t\trender 'new'\n\t\tend\n\tend",
"def create\n @borrowed_book = BorrowedBook.new(borrowed_book_params)\n\n respond_to do |format|\n if @borrowed_book.save\n format.html { redirect_to @borrowed_book, notice: 'The book was successfully checked out.' }\n format.json { render :show, status: :created, location: @borrowed_book }\n else\n @borrowers = Borrower.order('name ASC')\n @borrower_count = Borrower.count\n format.html { render :new }\n format.json { render json: @borrowed_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n check = 0\n @booking_history = BookingHistory.new(booking_history_params)\n # @booked_list = BookingHistory.all\n #@booked_entry = @booked_list.select do |bh|\n # bh.room_num == @booking_history.room_num && bh.date == Date.today + 7.days\n #end\n @room_details = LibraryRoom.find_by_number(@booking_history.room_num)\n @booking_history.building = @room_details.building\n @booking_history.size = @room_details.size\n @booked_entry = BookingHistory.where(\"room_num = ? AND date = ?\",@booking_history.room_num,@booking_history.date ).order(:start_t)\n\n @booked_entry.each do |entry|\n if entry != nil\n then\n\n if (((@booking_history.end_t <= entry.start_t)\\\n || (@booking_history.start_t >= entry.end_t))\\\n && ((@booking_history.start_t == @booking_history.end_t - 1) || (@booking_history.start_t == @booking_history.end_t - 2 )))\n then\n check = 0\n else\n check = 1\n end\n end\n end\n\n\n\n respond_to do |format|\n if check ==0\n if (@booking_history.save)\n flash[:notice] = \"Booking was successfully created. Booking id #{@booking_history.id}\"\n format.html { redirect_to booking_histories_path}\n # format.json { render :show, status: :created, location: @booking_history }\n else\n flash[:notice] = \"Booking was failed. Booking id #{@booking_history.id}\"\n format.html { redirect_to booking_histories_path }\n # format.json { render json: @booking_history.errors, status: :unprocessable_entity }\n end\n else\n if((@booking_history.start_t == @booking_history.end_t - 1) || (@booking_history.start_t == @booking_history.end_t - 2 ))\n flash[:notice] = \"Cannot book for more than 2 hours\"\n else\n flash[:notice] = \"Booking failed due to time conflict. Booking id #{@booking_history.id}\"\n end\n format.html { redirect_to booking_histories_path }\n end\n\n end\n end",
"def create\n @book = Book.new(book_params_create)\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to @book, notice: '添加成功!' }\n format.json { render :show, status: :created, location: @book }\n else\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def borrow\n @book = Book.find(params[:book_id])\n @book.is_borrowed = true\n @book.user = current_user\n @book.save\n redirect_to request.referrer, notice: \"You're being redirected\"\n #Todo: Update user log \n end"
] | [
"0.69769645",
"0.69267875",
"0.6913721",
"0.65632766",
"0.6509955",
"0.6485653",
"0.64737046",
"0.64623195",
"0.6437323",
"0.6433015",
"0.6413216",
"0.6384438",
"0.63746494",
"0.6355107",
"0.6324764",
"0.6317695",
"0.6309435",
"0.63090104",
"0.6304816",
"0.63032097",
"0.6279817",
"0.627878",
"0.62501204",
"0.6249174",
"0.6240555",
"0.6236197",
"0.62359154",
"0.62279135",
"0.62198037",
"0.6216257",
"0.6209718",
"0.62094694",
"0.6203295",
"0.6197729",
"0.61868834",
"0.61861247",
"0.61776644",
"0.6167281",
"0.6166028",
"0.61640716",
"0.6162149",
"0.6152389",
"0.6151344",
"0.6146872",
"0.61411524",
"0.6140623",
"0.61347073",
"0.6132803",
"0.6129372",
"0.6127434",
"0.6121718",
"0.6113591",
"0.6109358",
"0.60901684",
"0.60857916",
"0.6058873",
"0.6058869",
"0.6052487",
"0.60506976",
"0.60492885",
"0.6047993",
"0.6047086",
"0.6037113",
"0.60367614",
"0.60322875",
"0.6028694",
"0.6017336",
"0.6016999",
"0.60148",
"0.60054946",
"0.60038316",
"0.60009384",
"0.600083",
"0.5999399",
"0.59982777",
"0.59901255",
"0.59884053",
"0.5980971",
"0.59742457",
"0.59713596",
"0.59709287",
"0.596777",
"0.596774",
"0.5960238",
"0.5958699",
"0.5955688",
"0.5954455",
"0.5950541",
"0.5942743",
"0.5937319",
"0.59366125",
"0.59324515",
"0.5932083",
"0.59309417",
"0.5924506",
"0.5922073",
"0.5922051",
"0.5919806",
"0.591814",
"0.5913218"
] | 0.71910864 | 0 |
Print out the inventory | def inventory_to_s
puts "------------------inventory----------------"
inventory.each {|book, number| puts "Remain #{number} for <#{book.title}>"}
puts "-------------------------------------------"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_inventory\n print \"Current gold in pouch: #{@gold}.\\n\\n\"\n\n if @inventory.empty?\n print \"#{@name}'s inventory is empty!\\n\\n\"\n return\n end\n\n puts \"#{@name}'s inventory:\"\n @inventory.each do |couple|\n puts \"* #{couple.first.name} (#{couple.second})\"\n end\n print \"\\n\"\n end",
"def print_inventory\n print \"Current gold in pouch: #{@gold}.\\n\\n\"\n\n if (@inventory.empty?)\n puts \"#{@name}'s inventory is empty!\"\n else\n puts \"#{@name}'s inventory:\"\n\n @inventory.each do |couple|\n puts couple.first.name + \" (#{couple.second})\"\n end\n end\n\n print \"\\n\"\n end",
"def print_inventory\n @inventory.each do |couple|\n puts couple.first.name + \" (#{couple.second})\"\n end\n print \"\\n\"\n end",
"def inventory\n\t\tputs \"Items: #{@player.getItemsName}\" \n\t\tputs \"Food: #{@player.getFoodName}\" \n\tend",
"def show_inventory\n puts \"The following items are currently held in inventory:\n\n #{@inventory}\"\nend",
"def inventory\n\tputs \"you have the following items: \"\n\tputs @inventory\nend",
"def print_inventory\n @player.print_inventory\n end",
"def list_inventory\n\n # print the table header\n @gc.d_print(\"Inventory:\")\n\n # print each item with some indent\n @inventory.each do |object|\n @gc.display(\" > #{object.get_name}\")\n end\n\n # if there is nothing in the player's inventory, say so\n if @inventory.length == 0\n @gc.display(\" - Nothing\")\n end\n\n end",
"def show_inventory\n\t\tempty = String.new\n\t\tempty = \"empty pockets\" if @player.inventory.size == 0\n\t\tputs \"\\nYou have: \" + @player.inventory.join(\", \") + empty\n\tend",
"def inventory()\n\tputs \"Je hebt de volgende items:\"\n\tputs @inventory\nend",
"def display_inventory\n system('clear')\n inventory = self.items\n if inventory.count == 0\n puts \"Your inventory is empty.\"\n else \n inventory.reload.map do |item|\n puts \"#{item.name}: #{item.description}\"\n end\n end\n end",
"def print_inventory inventory\n\tinventory.each_with_index do |items, index|\n\tputs \"#{index+1}\" + \".\" + \"#{items[0]}\" + \"-\" + \"#{items[1]}\"\nend\nend",
"def show_inventory\n puts \"we have:\"\n puts \"douwe egberts\"\n puts \"nespresso\"\n puts \"senseo\"\n puts \"Choose a product\"\nend",
"def display_item_inventory\n if item_inventory.length == 0\n \"You haven't picked up any items yet.\"\n else\n items_on_hand = item_inventory.join(\" & \")\n \"Right now, you have a \" + items_on_hand\n end\n end",
"def print_items\n @items.each do |item|\n puts item.name + \" (#{item.price} gold)\"\n end\n print \"\\n\"\n end",
"def inventory_view(inventory)\r\n \r\n system 'clear'\r\n \r\n # Presents all inventory items to user using the display_method\r\n begin\r\n sub_categories = []\r\n inventory.each { |hash| sub_categories << hash['sub_cat'] }\r\n string_in_line(\" Current Inventory \".colorize(:light_green), 114) ; puts\r\n sub_categories.uniq.each{ |i| display_method(inventory, i) }\r\n rescue NoMethodError\r\n puts \"You don't have any inventory items to view. Add some before using this function.\"\r\n return \"No items in inventory\"\r\n end\r\n\r\n end",
"def show_contents_of_the_cart\n puts \"You currently have the following items:\n\n #{@inventory}\n\n Total cart value: €#{@total_cart_value}\n \"\nend",
"def brief_inventory\n puts \"SEED BAGS IN INVENTORY\".colorize(:yellow)\n seed_bag_inventory_hash.each do |crop_name, amount|\n puts \"#{crop_name}\".upcase.bold + \" x#{amount}\"\n end\n #=> TURNIP x4\n #=> TOMATO x1\n end",
"def inventory_screen\n setup_location if !@location_id || !@location_name\n clear_screen\n puts \"Inventory mode | #{@location_name} | #{@product_type} \"\n puts \"\"\n puts \"\"\n @items.each do |i|\n puts \"#{i.amount}\\t#{i.barcode}\\t#{i.name}\\t#{i.best_before_date}\\t#{i.price}\\t#{i.open_string}\"\n end\n puts \"\"\n puts \"Scan barcode (b for edit last best before, c for commit, l for locations, p for price, o open amount, r for remove last row, q for quantity of last, q! for quit)\"\n case input = gets.strip\n when \"\"\n when \"b\"\n @items.last.query_best_before unless @items.size == 0\n when \"c\"\n @items.each do |i|\n commit(i)\n end\n @items = []\n when \"l\"\n setup_location\n when \"m\"\n @items.last.query_price unless @items.size == 0\n when \"o\"\n @items.last.toggle_open unless @items.size == 0\n when \"r\"\n @items.pop\n when \"q\"\n @items.last.query_quantity unless @items.size == 0\n when \"q!\"\n exit\n else\n check(input)\n end\n end",
"def print_items\n if @items.empty?\n print NO_ITEMS_MESSAGE\n else\n print WARES_MESSAGE\n @items.each { |item| puts \"#{item.name} (#{item.price} gold)\" }\n print \"\\n\"\n end\n end",
"def show\n @inventory = @npc.inventory\n @items = Item.all\n end",
"def print_items\n @items.each { |item| print \"#{item} \"}\n puts \"\\n\"\n end",
"def show_inventory\n\t\t\treturn @player_data_db.execute( \"select * from inventory\" )\n\t\tend",
"def brief_inventory\n self.seed_bag_count_hash(0).each do |crop_name, amount|\n puts \"#{crop_name}\".upcase.bold + \" x#{amount}\"\n end\n #=> TURNIP x4\n #=> TOMATO x1\n end",
"def show\n puts @name\n puts @quantity\n end",
"def print_item_list\n @current_items.each_with_index do |item, item_no|\n puts \"Item #{item_no+1}\"\n puts \"----------------\"\n puts \"Item Name: #{item.name}\"\n puts \"----------------\"\n end\n end",
"def printItem\n print @category,\", \"\n print @batteryLife,\", \"\n print @modelNum,\", \"\n print @color,\", \"\n print @manufacturer,\", \"\n print @status,\", \"\n print @yearBuilt,\", \"\n print @price,\", \"\n print @features\n end",
"def current_list_of_jams\n puts \"\\nInventory List ATM:\"\n @inventory_list.each do |item, count|\n puts \" #{item} - quantity: #{count}\"\n end\n end",
"def print_items\n puts print_line\n puts print_date\n puts print_title\n puts print_line\n puts print_header\n puts print_line\n items.each_with_index do |item, index_no|\n puts item.print_item_details(index_no)\n end\n puts print_line\n end",
"def show_store_inventory_item(locations,products,itemid)\n #Loop through Stores Location Id List\n puts \"====== STORE INVENTORY CHECK ===Id: #{itemid}=====\"\n ind = 0\n for locid in @location_list\n prod_list = locations[ind][1].product_list\n prod_list.each do | product_id, quantity |\n pquery = Utils::product_name_query(product_id,products)\n pname = pquery[0]\n price = pquery[1]\n if (itemid == product_id)\n puts \"Location: #{locid}, Product Id: #{product_id}, Product Name: #{pname}, Price: $#{price}, Quantity: #{quantity}\"\n end\n end\n ind += 1 #update index\n end #for\n end",
"def show_store_inventory(locations,products)\n #Loop through Stores Location Id List\n puts \"====== STORE INVENTORY CHECK ========\"\n ind = 0\n for locid in @location_list\n prod_list = locations[ind][1].product_list\n prod_list.each do | product_id, quantity |\n pquery = Utils::product_name_query(product_id,products)\n pname = pquery[0]\n price = pquery[1]\n puts \"Location: #{locid}, Product Id: #{product_id}, Product Name: #{pname}, Price: $#{price}, Quantity: #{quantity}\"\n end\n ind += 1 #update index\n end #for\n end",
"def inventory\n items = @purchase.inventory!\n flash.notice = [t(:inventorized) ,items ,t(:items)].join(\" \")\n redirect_to purchase_path(@purchase)\n end",
"def worthInventory\n total_worth = 0\n @@products.each_with_index { |p, i|\n prod_worth = (p.price * p.units)\n total_worth = total_worth + prod_worth\n\n puts \"#{i + 1} : #{p.name} - #{p.units} at INR Rs.#{p.price} each : INR Rs.#{prod_worth}\"\n }\n\n puts \"--\" * 20\n puts \"Total Inventory Worth : INR Rs.#{total_worth}\"\n puts \"--\" * 20\n end",
"def print_backpack_list\n output = []\n output << \"Melinda, here's your packing list!\"\n output << \"Day: #{@attributes[:day_of_week]}, Weather: #{@attributes[:weather]}\"\n output << \"\"\n\n @items.each do |item|\n output << \"- #{item}\"\n end\n output.join(\"\\n\")\n end",
"def print_menu\n self.menu_items.each do |item|\n p \"#{item.dish_name.upcase} 😋 $#{item.price}\"\n end\n end",
"def pretty_in_print(list)\n puts \"---------------------------------------\"\n puts \"These are the items we are gonna buy\"\n list.each {|item, qty| puts \"#{qty} pieces of #{item}\" }\nend",
"def print_item\n return values\n end",
"def print\n puts <<~RECEIPT\n #{parsed_items.join(\"\\n\")}\n\n Sales Taxes: #{total_sales_tax}\n Total: #{total_price}\n RECEIPT\n end",
"def show\n\t\t\n\t\t#Show total items and prices\n\t\tputs \"\\nShopping list: \"\n @list_products.each {|key, val| print val, \" \", key, \" \",productsMarket[key], \"$\\n\"} \n\tend",
"def display_cart(cart)\n cart.each do |item, quantity|\n puts item.to_s + ' (' + quantity.to_s + ')'\n end\nend",
"def print(list)\n puts \"***This is your grocery list:***\"\n list.each do |item,quantity|\n puts \"-#{quantity} #{item}\"\n end\nend",
"def print_list\n @list.each { |item, qty| puts \"#{qty} #{item}\" }\n end",
"def print_list\n @list.each { |item, qty| puts \"#{qty} #{item}\" }\n end",
"def print_items\n return values\n end",
"def print_item_list(item_list)\r\n item_list.each { |item, qty| puts \"- #{item} : #{qty}\" }\r\nend",
"def print_menu\n MENU.each do |i| \n # in general, avoid printing things.\n # Return them instead and let the code that called it\n # to return it\n puts \"#{i[:name]} costs #{i[:price]}\"\n end\n end",
"def report_print_items\n $report_file.puts print_line\n $report_file.puts print_date\n $report_file.puts print_title\n $report_file.puts print_line\n $report_file.puts print_header\n $report_file.puts print_line\n items.each_with_index do |item, index_no|\n $report_file.puts item.print_item_details(index_no)\n end\n $report_file.puts print_line\n end",
"def show_all()\n if @items.length == 0\n puts \"Shopping list is empty...\"\n else\n @items.each_index{\n |i|\n puts \"#{i+1} - #{@items[i].to_s}\"\n }\n end\n end",
"def display_list(list_items)\n title = \"Shopping List:\"\n puts title\n puts \"-\" * title.length\n list_items.each do |item_name, item_qty|\n puts \"#{item_qty}x - #{item_name}\"\n end\n\nend",
"def listing_items\n @products.each do |item|\n puts \"item: #{item[:name]} \\n reference_number: #{item[:reference_number]} \\n price: #{item[:price]}\"\nend\nend",
"def available_inventory\n return self.inventory\n end",
"def output_for items\n output = \"\"\n items.each_with_index do |item, position|\n output += \"#{position + 1}) #{item.type.capitalize}: #{item.details}\\n\"\n end\n output # Return the output to print (well, put) it\n end",
"def print_pretty(grocery_list)\r\n\tgrocery_list.each do |item, quantity| \r\n\t\tputs \"you bought #{quantity} #{item}\"\r\n\tend\r\nend",
"def look(player)\n return \"You cannot see while you are blind\" if player.blind?\n players = Array.new\n mobs = Array.new\n things = Array.new\n exits = Array.new\n add_to_desc = String.new\n\n @inventory.each do |item|\n\n #some objects can modify the rooms description as well.\n if item.show_in_look\n add_to_desc << \" \" << item.show_in_look if item.show_in_look != \"\"\n end\n\n if item.is_a?(Player) and item != player and item.visible\n if item.pose\n players << \"<player>#{item.name}</player>, #{item.pose}#{item.short_desc ? ' - ' + item.short_desc : ''}\"\n else\n players << \"<player>#{item.name}</player>#{item.short_desc ? ' - ' + item.short_desc : ''}\"\n end\n elsif item.is_a?(Exit) and item.visible\n if item.can? :open and item.closed?\n exits << \"<exit>#{item.alt_names[0]}</exit> (closed)\"\n elsif item.can? :open and item.open?\n exits << \"<exit>#{item.alt_names[0]}</exit> (open)\"\n else\n exits << (\"<exit>#{item.alt_names[0]}</exit>\" || \"[Improperly named exit]\")\n end\n elsif item != player and item.visible\n if not item.quantity.nil? and item.quantity > 1\n quantity = item.quantity\n else\n quantity = item.article\n end\n\n idents = [\"<identifier>#{item.generic}</identifier>\"]\n idents += item.alt_names.map() {|e| \"<identifier>\" + e + \"</identifier>\"}\n idents = idents.join(', ')\n if item.can? :alive and item.alive\n mobs << \"<mob>#{item.name}</mob> [#{idents}]\"\n elsif item.can? :pose and item.pose\n things << \"<object>#{item.name}</object> [#{idents}] (#{item.pose})#{item.short_desc ? ' - ' + item.short_desc : ''}\"\n else\n things << \"<object>#{item.name}</object> [#{idents}]#{item.short_desc ? ' - ' + item.short_desc : ''}\"\n end\n end\n end\n\n #What to show if there are no exits.\n if exits.empty?\n exits << \"none\"\n else\n exits.sort!\n end\n\n if players.empty?\n players = \"\"\n else\n players = \"The following #{players.length <= 1 ? 'player is' : 'players are'} here:\\n#{players.list(@inventory, :expanded)}\\n\"\n end\n\n if mobs.empty?\n mobs = \"\"\n else\n mobs = \"The following #{mobs.length <= 1 ? 'mob is' : 'mobs are'} here:\\n#{mobs.list(@inventory, :expanded)}\\n\"\n end\n\n if things.empty?\n things = \"\"\n else\n things = \"There are the following items in the room:\\n#{things.list(@inventory, :expanded)}\\n\"\n end\n\n info = \"You find some things unusual about this place:\\n\"\n info += \" Type: \" + self.terrain_type.name + \"\\n\"\n self.flags.values.each do |f|\n if f.can_see? player\n info += \" #{f.affect_desc}\\n\"\n end\n end\n info += \"\\n\"\n\n \"<roomtitle>#{@name}</roomtitle>\\n\\n#{(@short_desc || '') + add_to_desc}\\n\\n[Exits: #{exits.list}]\\n\\n#{info}#{players}#{mobs}#{things}\"\n end",
"def print_inovice\n\tputs \"\\n----------------------------------\"\n\tputs \"| Item | Quantity | Total Price |\"\n\tputs \"----------------------------------\"\n\tsingletn_example.items_per_invoice.each do |item, quantity|\n\t\tputs \"| #{item} | #{quantity} | #{singletn_example.calculate_total_price(item, quantity)} |\"\n\t\tend\n\tputs \"----------------------------------\"\n\tputs \"\\nYou bought #{singletn_example.items_to_buy} items, and the total price is #{singletn_example.total_price}\"\nend",
"def print_list(shopping_list)\n puts \"SHOPPING LIST:\"\n shopping_list.each do |item, qty|\n puts \"-#{item} ---> #{qty}\"\n end\n\nend",
"def inventory\n return @inventory\n end",
"def print\n\t\tif self.length == 0\n\t\t\tputs \"empty\"\n\t\telse\n\t\t\tself.each { |item| puts item.data }\n\t\tend\n\tend",
"def display_order_contents\n\t\t@orders.each {|item| print item, \" -- \"}\n\tend",
"def list_inventory_debug\n render :action => 'debug'\n end",
"def print(hash)\r\n\thash.each do |key, value|\r\n puts \"Item: #{key} Quantity: #{value}\"\r\nend\r\nend",
"def all\n puts header\n puts output_for @items\n end",
"def print_list\n\t puts \"\"\n\t puts \"\"\n\t\tputs \"#{@list_name}\"\n\t\tprint \"-\" * 40\n\t\t@grocery_list.each {|k, v| puts \"#{k} #{v}\"}\n\t\tputs \"\"\n\t\tget_item\n\tend",
"def print_products\n\treturn \"\n ____ _ _ \n | _ \\\\ _ __ ___ __| |_ _ ___| |_ ___ \n | |_) | '__/ _ \\\\ / _` | | | |/ __| __/ __|\n | __/| | | (_) | (_| | |_| | (__| |_\\\\__ \\\\\n |_| |_| \\\\___/ \\\\__,_|\\\\__,_|\\\\___|\\\\__|___/\\n\\n\"\n\nend",
"def pretty_list(list)\n\tlist.each { |item_name, item_quantity|\n\t\tputs \"You will need to purchase #{item_quantity} of #{item_name}.\"\n\t}\nend",
"def print_item(item, spent)\n\tputs \"You added #{item.item} to your order.\"\n\tputs \"You've spent $#{(spent).round(2)}\\n\\n\"\nend",
"def print_commands\n puts \"Your available commands are: \".green\n puts \"go take use help backpack quit\\n\\n\"\n puts \"Directions:\".green\n @current_room.print_exits\n if @current_room.has_items?\n # Room has items in it\n puts \"\\nItems available: \".colorize(:green)\n @current_room.print_items\n puts \"\\n\"\n else\n puts \"\\nThere are no items in this room\".green\n puts \"\\n\"\n end\n end",
"def show_state\n return puts \"#{super} et une arme de niveau \\\"#{@weapon_level}\\\"\"\n end",
"def list_print(hash_items)\n printf(\"%20s%20s\\n\", '---------------','---------------')\n printf(\"%20s%20s\\n\", 'Item','Quantity')\n printf(\"%20s%20s\\n\", '---------------','---------------')\n\n hash_items.each do |x,y|\n printf(\"%20s%20s\\n\", x.upcase, y)\n end\n\nend",
"def print_item\n return \"Title: #{@title}; Description: #{@description}; Is Done: #{@is_done}\"\n end",
"def inventory=(value)\n @inventory = value\n end",
"def print_list(list)\n puts \"List: #{list['name']}\"\n print_separator\n\n list[\"items\"].each do |item|\n puts \"\\tItem: \" + item['name'] + \"\\t\\t\\t\" +\n \"quantity: \" + item['quantity'].to_s\n end\n\n print_separator\nend",
"def available_inventory\n object.check_inventory\n end",
"def print\n\t\tif self.length == 0\n\t\t\tputs \"empty\"\n\t\telse\n\t\t\tself.full_scan { |item| puts item.data }\n\t\tend\n\tend",
"def print\n\t\tif self.length == 0\n\t\t\tputs \"empty\"\n\t\telse\n\t\t\tself.full_scan { |item| puts item.data }\n\t\tend\n\tend",
"def print(list)\n# steps: \n\t# make a new string\n\tstring = \"This is the shopping list: \\n\"\n\t# iterate through the list\n\tlist.each do |item, quantity|\n\t\t# add the items and quantities to the string and end with a newline\n\t\tstring = string + \"#{item}: #{quantity} \\n\"\n\tend\n# output: the string\n\tputs string\nend",
"def print(list)\n list.each do |item, number|\n puts \"Need to purchase: #{item} -- #{number}\"\n end\nend",
"def print_list(list)\r\n puts \"Your current grocery list\"\r\n puts \"---------------------------\"\r\n list.each do |item, quantity|\r\n puts \"#{item}: #{quantity}\"\r\n end \r\nend",
"def print_console_products_ascii\n\tputs products_ascii\nend",
"def dump\n info \"販売価格:#{@sell_price},買取価格:#{@purchase_price},利益:#{@yield}\\n\"\n #ap \"販売価格:#{@sell_price}\\n買取価格:#{@purchase_price}\\n利益:#{@yield}\\n\"\n end",
"def inventory()\n\t\tInventory.new(@db, 'sgt-structure:' + @id + ':inv')\n\tend",
"def display_product\n STDOUT.puts \"--\"*50\n STDOUT.puts \"title: \\t\\t#{$title}\"\n STDOUT.puts \"seller: \\t#{$seller}\"\n STDOUT.puts \"price: \\t\\t#{$price}\"\n STDOUT.puts \"stars: \\t\\t#{$stars}\"\n STDOUT.puts \"reviews: \\t#{$reviews}\"\n STDOUT.puts \"image url: \\t#{$image_href}\"\n STDOUT.puts \"product url: \\t#{$url}\"\n end",
"def print_deal_cards\n puts \"-----------\"\n puts \"Cards Dealt\"\n puts \"-----------\"\n end",
"def prettyPrint\n\t\tputs \"'#{@name}' : #{@ingredient.length} ingredients\"\n\n\t\tfor i in 0..@ingredient.length-1\n\t\t\tputs \" #{@ingredient[i].amount} #{@ingredient[i].units} #{@ingredient[i].name}\"\n\t\tend\n\n\t\tif @garnish\n\t\t\tputs \" Garnish with #{@garnish}\"\n\t\tend\n\tend",
"def print_list(food_list)\n food_list.each do |item_name, quantity|\n puts \"You have the following item #{item_name}, qty: #{quantity}.\"\n end\nend",
"def print_list(list_name)\n# for each array element, print the item name and quantity\n list_name.each { |list_item| puts \"#{list_item[:item_name]}\" + ': ' + \"#{list_item[:quantity]}\"}\n# Wish the shopper good luck.\n puts \"Happy Shopping!\"\n list_name\nend",
"def pretty_list(hash)\r\n puts \"Grocery List:\"\r\n puts \" \"\r\n hash.each do |item_name, quantity|\r\n puts \"#{item_name}: #{quantity}\"\r\n end\r\nend",
"def print_list(list)\n\tputs \"This is what you need to buy:\"\n\tputs \"--------------------\"\n\tlist.each do |item, quantity|\n\t\tputs \" #{item} : #{quantity}\"\n\tend\n\tputs \"--------------------\"\nend",
"def see(arg)\n\t puts \"-------------Groceries list-------\"\n\t puts\n\targ.each {|key, value| puts \"Item: #{key} \\t\\t quantity: #{value}\" }\n\tputs\n\tputs \"----------------------------------\"\nend",
"def report\r\n\t\tputs \"Item Number #@@item_number\"\r\n\t\tputs \"Level : #@level\"\r\n\t\tputs \"Strength = #@strength\"\r\n\t\tputs \"Agility = #@agility\"\r\n\t\tputs \"Health = #@health\"\r\n\t\tputs \"Mana = #@mana\"\r\n\t\tputs\" \"\r\n\tend",
"def print_products\n$report_file.puts \"\n\n | | | |\n _ __ _ __ ___ __| |_ _ ___| |_ ___\n| '_ \\\\| '__/ _ \\\\ / _` | | | |/ __| __/ __|\n| |_) | | | (_) | (_| | |_| | (__| |_\\\\__ \\\\\n| .__/|_| \\\\___/ \\\\__,_|\\\\__,_|\\\\___|\\\\__|___/\n| |\n|_|\n\t \t\t\t\t\t\t\t\t\t\"\nend",
"def look_pretty(list)\n puts \"Here is your grocery list:\"\n list.each { |item, quantity| puts \"#{item}: #{quantity}\" }\nend",
"def print_list\n $list.each {|list_item| puts \"#{list_item[:quantity]} #{list_item[:item]}\"}\nend",
"def checkout_shopping_cart\n\tputs \"------------------------------------ ITEMS PURCHASED ------------------------------------\"\n\n\t# Displays all the items\n\t@shopping_cart.items.each_with_index do |item, index|\n\t\t# Displays the item\n\t\tputs \"(#{index+1}) Name: #{item.name} \\n\"\n\t\tputs \"Price: $#{item.price}\\n\"\n\t\tputs \"Shipping Cost: $#{item.shipping_cost}\\n \\n\"\n\tend\n\tputs \"-----------------------------------------------------------------------------------------\"\n\tputs \"TOTAL Price: $#{@shopping_cart.total_price}\"\n\tputs \"TOTAL Shipping Cost: $#{@shopping_cart.total_shipping_cost}\"\n\tputs \"-----------------------------------------------------------------------------------------\"\n\tputs \"GRAND TOTAL: $#{@shopping_cart.total_cost}\"\n\tputs \"-----------------------------------------------------------------------------------------\\n\"\nend",
"def display_info_detailed(locations,products)\n puts \"\\n=======STORE INFO===========\"\n puts \"Store ID: #{@id}\"\n puts \"Store Name: #{@name}\"\n puts \"Description: #{@description}\"\n puts \"Location List: #{@location_list}\"\n #Detailed Breakdown\n show_store_inventory(locations,products)\n end",
"def printItem\n if @status\n \"Title: \" + @title + \", Description: \" + @description + \", Status: Done, Due Date: \" + @dueDate\n else\n \"Title: \" + @title + \", Description: \" + @description + \", Status: Not Done, Due Date: \" + @dueDate\n end\n end",
"def receipt\r\n if self.qty >= 1\r\n puts \"#{self.drink} x#{self.qty} @ $#{'%.2f' % self.price} each: $#{'%.2f' % self.total_cost}\"\r\n end\r\n end",
"def print_in_table(inventory)\n # the following figures out the maximum length of the item string\n item_spacing = 0\n inventory.each do |item, quantity|\n item_spacing = item.length\n if item_spacing < item.length\n item_spacing = item.length\n end\n end\n\n #the following prints it using the spacing calculated above\n puts \"ITEM:\".ljust(item_spacing+1) + \"| QUANTITY:\"\n inventory = inventory.sort_by { |item, quantity| item}\n inventory.each do |item, quantity|\n puts item.split.map(&:capitalize).join(' ').ljust(item_spacing+1) + \"| #{quantity}\"\n end\nend",
"def print_cart\n\t\tputs \"----- #{@user}'s Shopping Cart -----\"\n\t\tif @cart.length > 0\n\t\t\t@cart.each do |item|\n\t\t\t\tputs \"> #{item}\"\n\t\t\tend\n\t\telse\n\t\t\tputs \"Your shopping list is empty.\"\n\t\tend\n\t\tputs \"--------------------------------\"\n\tend",
"def print_list\r\n puts \"Here is your current grocery list:\"\r\n $grocery_list.each do |item, quantity|\r\n puts \"There are #{quantity} items of type #{item}\" if quantity > 1\r\n puts \"There is #{quantity} item of type #{item}\" if quantity == 1\r\n puts \"There is no #{item}\" if quantity == 0\r\n end\r\nend"
] | [
"0.8691387",
"0.850271",
"0.83751404",
"0.83042043",
"0.81267023",
"0.81070507",
"0.8087145",
"0.79579186",
"0.79470086",
"0.7941801",
"0.7832741",
"0.7729665",
"0.75657713",
"0.7492231",
"0.7403818",
"0.739407",
"0.7339213",
"0.7316211",
"0.7301596",
"0.72886515",
"0.7209996",
"0.71471816",
"0.7125652",
"0.70667636",
"0.7003692",
"0.68877393",
"0.6815725",
"0.67389685",
"0.66972166",
"0.665799",
"0.66347206",
"0.6625994",
"0.6606884",
"0.66001266",
"0.6529373",
"0.65061957",
"0.6497072",
"0.64861447",
"0.64530975",
"0.642786",
"0.64111227",
"0.6405105",
"0.6405105",
"0.6387548",
"0.6376793",
"0.63734245",
"0.63555557",
"0.63458663",
"0.6345499",
"0.6314114",
"0.6294606",
"0.6290809",
"0.62848365",
"0.6261942",
"0.62606543",
"0.62543213",
"0.6232004",
"0.62311363",
"0.6209455",
"0.6208328",
"0.6196255",
"0.61930627",
"0.61905414",
"0.6186172",
"0.6182859",
"0.6150814",
"0.6146281",
"0.61440057",
"0.6143826",
"0.6134344",
"0.6132731",
"0.61208606",
"0.611949",
"0.6107975",
"0.6107975",
"0.61024785",
"0.6101589",
"0.60805655",
"0.6079336",
"0.6079218",
"0.6078459",
"0.6074328",
"0.6072881",
"0.6069929",
"0.6069422",
"0.60633445",
"0.6063134",
"0.604278",
"0.60390157",
"0.60378265",
"0.6036982",
"0.6036355",
"0.6035546",
"0.6034951",
"0.6029477",
"0.6027341",
"0.60267764",
"0.6020043",
"0.60149014",
"0.60145175"
] | 0.8147413 | 4 |
Check records of a user. | def check_records(user)
@records.select{|record| !record.has_return && record.user_id == user.id}.each do |record|
@inventory.each do |book,value|
if book.isbn == record.book_isbn then
puts "=> Warning! \n"
puts "#{user.name} borrowed <#{book.title}> on #{record.borrow_date}, #{user.name} has to return it before #{record.due}."
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_check(resource)\n return true unless self[:name] == \"user\"\n return true unless self[:unless_system_user]\n\n resource[:audit] = :uid\n\n return false if system_users.include?(resource[:name])\n\n current_values = resource.retrieve_resource\n current_values[resource.property(:uid)] > self[:unless_system_user]\n end",
"def kon_user_account_checking\n user_array = User.kon_search(params[:name])\n if user_array.length \n end\n end",
"def check_record; end",
"def checkUser(user)\n\treturn getAllUsersWithRoster().include?(user)\nend",
"def user_exist?(id)\n DB[:users].select.where(:id=>id).all\nend",
"def user_check(id)\n check_user = User.find(id)\n if check_user != current_user\n flash[:notice] = \"You can only modify your own user information.\"\n redirect_to user_path(user)\n end\n end",
"def user_check(id)\n check_user = User.find(id)\n if check_user != current_user\n flash[:notice] = \"You can only modify your own user information.\"\n redirect_to user_path(check_user)\n end\n end",
"def find_user\n self.user_lookup_failed = false\n unless self.user_ids.blank?\n my_users = User.scoped.extending(QueryHelper::WhereIn).where_in('id', self.user_ids)\n unless my_users.blank?\n self.users = my_users\n else\n self.user_lookup_failed = true\n end\n end\n # be sure the call back returns true or else the call will fail with no error message\n # from the validation loop\n return true\n end",
"def checkUser(userName)\n @users = User.all\n @users.each do |user|\n if user[\"userName\"] == userName\n return user\n end\n end\n return false\n end",
"def check\n api.get_user\n end",
"def isUserValid?(user_name)\n @users.each do |user|\n if user.name == user_name\n then\n print \"User found!\"\n return true\n end\n end\n false\n end",
"def user_can_access_files user\n recordings.each do |recording|\n return true if recording.update_common_work_ids.include? user.id\n end\n return false\n end",
"def valid_user?(user_id)\n user_ids.include?(user_id)\nend",
"def checkUser(id)\n results = HTTParty.get(\"http://192.168.99.101:4051/users/search_user?id=\" + id.to_s)\n return results\n end",
"def check\n user = Account.find_by(email: params[:user_email].downcase)\n if user.nil?\n flash.alert = \"User does not exist please signup.\"\n redirect_to \"/login\"\n else\n redirect = login_compare(user,params[:user_password])\n redirect_to redirect\n end\n end",
"def User?(_Id, _Pwd)\r\n _Flag = 0\r\n _Users = YAML.load(File.read(\"_User_Info.yml\"))\r\n #puts \"_Users: #{_Users}\"\r\n if !(_Users)\r\n else\r\n\r\n _Users.each do |user|\r\n if user.has_value?(_Id.to_i) && user.has_value?(_Pwd)\r\n _Flag = 1 #existing user with matching password\r\n puts \"Welcome back #{user[:Name]}!!\"\r\n end\r\n end\r\n end\r\n return _Flag\r\nend",
"def check\n user = ARGV.shift\n Trollop::options do\n banner \"tickspot check [user@email.com]\"\n end\n emails = user || @tickspot.users.collect { |u| u.email }\n\n day = Date.today\n @p.header \"Hours Logged for \"+day.strftime(\"%d %b %Y\")\n emails.each do |email|\n h = @tickspot.entries(day, day, :user_email => email).collect { |e|\n e.hours.to_f\n }.sum\n @p.puts sprintf(\"%.2f hours logged by %s\", h, email)\n end\n end",
"def user_exists(name)\n self.all.any?{|user| user.name == name}\n end",
"def user_attempted?(u_id)\n self.attempts.where(:user_id => u_id).any?\n end",
"def do_you_owe_checker (record)\n\t\tRegister.register_for_payment(record.receiver_id, record.user_id).first.nil?\n end",
"def editable_by user\n recordings.each do |recording|\n return true if recording.update_common_work_ids.include? user.id\n end\n return false\n end",
"def isIn(user)\n \n isIn = false\n @userList.getcontents.each { |users| \n \n if(user == users)\n isIn = true\n break\n end\n \n }\n return isIn\n end",
"def checkData(iUserID, iComment)\n # Nothing to test\n end",
"def show\n @users = User.where(validate_status: 1)\n end",
"def index\n puts \"index params = #{params}\"\n if params[:user_id]\n @recordings = current_user.recordings\n else\n flash[:notice] = \"You can only view recordings from your account.\"\n redirect_to user_path(current_user)\n end\n end",
"def validate_user\n\n cache_data = CacheManagement::User.new([@user_id]).fetch\n @user = cache_data[@user_id]\n\n return validation_error(\n 'e_sam_2',\n 'invalid_api_params',\n ['invalid_user_id'],\n GlobalConstant::ErrorAction.default\n ) if @user.blank?\n\n return error_with_data(\n 'e_sam_3',\n 'user_not_verified',\n GlobalConstant::ErrorAction.default,\n {}\n ) if @user[:properties].exclude?(GlobalConstant::User.is_user_verified_property)\n\n success\n\n end",
"def check_init\n\t\tu = User.find_by(jive_id: params[:user])\n\t\tif u and u.jive_id > 0\n\t\t\trespond({ status: 0, message: \"User exists\", user: u, client: u.client })\n\t\telsif u\n\t\t\tif u.jive_id > 0\n\t\t\t\trespond({ status: 1, error: \"User is not in DB.\" })\n\t\t\telse\n\t\t\t\trespond({ status: 1, error: \"User needs a Jive ID.\" })\n\t\t\tend\n\t\telse\n\t\t\trespond({ status: 1, error: \"User not found.\" })\n\t\tend\n\tend",
"def user_attempted?(u_id)\n self.attempts.where(user_id: u_id).any?\n end",
"def all\n \n user_id = params[:user_id]\n key = params[:key]\n \n if User.find(user_id) and (@user = User.find(user_id)) and @user.key == key \n \n @tests = Test.all\n @root_path = root_path\n \n else\n redirect_to root_path + 'msgs/error' \n end \n \nend",
"def verify_users(test_data)\n users = test_data[UseOfCollections::USER_GRP.name] || [UseOfCollections.empty_user]\n users.each_with_index do |user, index|\n verify_values_match(user[UseOfCollections::USER.name], element_value(user_name_input index))\n verify_values_match(user[UseOfCollections::USER_INSTITUTION_ROLE.name], element_value(user_type_input index))\n verify_values_match(user[UseOfCollections::USER_UOC_ROLE.name], element_value(user_role_input index))\n verify_values_match(user[UseOfCollections::USER_INSTITUTION.name], element_value(user_institution_input index))\n end\n end",
"def checkUser\n if validUser\n return true\n else\n flash[:alert] = \"Unauthorized Access!!\"\n redirect_to profile_path(current_user)\n end\n end",
"def ensure_user_created\n if User.find_by_ldap_uid(ldap_user.uid)\n Rails.logger.debug(\"User in user table.\")\n true\n else\n Rails.logger.debug(\"User not in user table, redirecting to new user form.\")\n redirect_to(new_users_url) and return\n end\n end",
"def user_checks\n current_user = @current_package.user\n current_ability = Ability.new(current_user)\n errors = []\n errors = check_current_user(current_user, errors)\n return errors unless errors.empty?\n errors << \"User does not exist in the system: #{@current_package.manifest.email}.\" if current_user.nil?\n errors << \"User #{current_user.user_key} does not have permission to add items to collection: #{collection.name}.\" unless current_ability.can?(:read, collection)\n errors\n end",
"def made_request?(user)\n all_users.include?(user)\n end",
"def user?(user)\n user.blank? and return false\n unless user.is_a?(UserInfo) # user is supposed to be given by its id.\n user = UserInfo.find(user.to_i)\n end\n user.is_a?(UserInfo) \n end",
"def check_user\n @user = User.find(params[:user_id])\n redirect_to root_path unless current_user == @user\n end",
"def user_exists?(name)\n @users.member?(name)\n end",
"def validate_profile(params)\n db = connect_to_db()\n db.results_as_hash = true\n\n result = db.execute('SELECT id FROM users where id=?', params[\"id\"].to_i)\n\n if !result.empty?()\n return true\n else\n return false\n end\n end",
"def fetch_and_validate_user\n @user = User.using_client_shard(client: @client).where(client_id: @client_id, email: @email).is_active.first\n return error_with_identifier('invalid_api_params',\n 'um_u_c_ve_2',\n ['user_already_present']\n ) if @user.present?\n\n success\n end",
"def user_exists(user)\n @users.key?(user)\n end",
"def verify_users(test_data)\n users = test_data[CoreUseOfCollectionsData::USER_GRP.name] || [CoreUseOfCollectionsData.empty_user]\n users.each_with_index do |user, index|\n verify_values_match(user[CoreUseOfCollectionsData::USER.name], element_value(user_name_input index))\n verify_values_match(user[CoreUseOfCollectionsData::USER_INSTITUTION_ROLE.name], element_value(user_type_input index))\n verify_values_match(user[CoreUseOfCollectionsData::USER_UOC_ROLE.name], element_value(user_role_input index))\n verify_values_match(user[CoreUseOfCollectionsData::USER_INSTITUTION.name], element_value(user_institution_input index))\n end\n end",
"def user_conforms?(user)\n @rule.call(user)\n end",
"def login_check(params, user_id)\n db=SQLite3::Database.new('db/database.db')\n\n db.results_as_hash = true\n result = db.execute(\"SELECT * FROM users\")\n\n params[\"User_id\"] = user_id\n\n k = 0\n \n while k <= result.length - 1\n if params[\"User_id\"] == result[k][0]\n params[\"logged_in\"] = true\n break\n else\n params[\"logged_in\"] = false\n end\n \n k += 1\n end\n\n return params[\"logged_in\"]\n end",
"def check_user\n status = {}\n if params[:referrer].include? '@'\n if referrer = User.where(\"LOWER(email) = ?\", params[:referrer].downcase).first\n if referrer.id.to_s != params[:user_id]\n status = { message: 'User is valid.', valid: true, referrer_id: referrer.id}\n else\n status = { message: 'You cannot refer yourself.', valid: false }\n end\n else\n status = {message: 'User with this email doesn\\'t exist.', valid: false}\n end\n else\n if referrer = User.where(\"LOWER(identifier) = ?\", params[:referrer].downcase).first\n if referrer.id.to_s != params[:user_id]\n status = { message: 'User is valid.', valid: true, referrer_id: referrer.id}\n else\n status = { message: 'You cannot refer yourself.', valid: false }\n end\n else\n status = { message: 'User with this identifier doesn\\'t exist.', valid: false}\n end\n end\n render json: status\n end",
"def userexist \n\t\tdatadb = Register.where(name: params[:name], emailid: params[:email], password: params[:pass]).first\n \n if datadb.present? \n render json: [{message: 'user validate'}]\n else\n render json: [{message: 'user not validate'}]\n\tend\n\t\t\n\tend",
"def does_user_exist(username)\n # note :db_column_name syntax like \"params[:id]\"\n user = Account.find_by(:user_name => username)\n if user\n return true\n else\n return false\n end\nend",
"def user_exists(user)\n users.include? user\n end",
"def ifMember(group_id,user_id)\n GroupUser.where(:group_id => group_id, :user_id => user_id).exists? #change to current_user_id \n end",
"def take_checkpoint\n puts \"*** USER TAKING CHECKPOINT ***\"\n invalid = false\n \n begin\n @checkpoint_user = CheckpointUser.find(params[:id]) \n puts \"invalid checkpoint_user - bad ID!\"\n rescue ActiveRecord::RecordNotFound \n invalid = true \n end\n \n if (!invalid && @checkpoint_user.is_complete?) then invalid = true end\n \n if (invalid || (current_user.id != @checkpoint_user.user_id))\n puts \"checkpoint ID mismatch: actual #{current_user.id} expected: #{@checkpoint_user.user_id}}!\"\n flash[:error] = \"You cannot access this checkpoint.\"\n redirect_to checkpoints_path\n else\n # these objects go to the view\n @responses = @checkpoint_user.responses.all\n puts @responses\n end\n end",
"def regischeck(db,user_id,chat_id)\n query = \"SELECT * FROM users WHERE user_id=#{user_id} AND chat_id=#{chat_id}\" \n rs = db.execute(query)\n\n if rs.length > 0\n return true\n else\n raise \"Id #{user_id} is not registered in this chat room!\"\n end\nend",
"def user?(user)\n self.user_id == user.id if user\n end",
"def user?(user)\n self.user_id == user.id if user\n end",
"def user?(user)\n self.user_id == user.id if user\n end",
"def does_user_exist (username)\n user = Account.find_by(:user_name=> username)\n if user\n return true\n else\n return false\n end\nend",
"def is_existing_user(db, username)\n username_arr = db.execute(\"SELECT username FROM users\")\n username_arr.each do |user|\n if user[0] == username\n return true\n end\n end\n return false\nend",
"def user?(user)\n user.id == self.user_id if user\n end",
"def user_result_picked(picks, user_id, record_abbr)\n picks.each { |pick|\n return true if pick.user_id == user_id && pick.my_record_abbreviation == record_abbr\n }\n return false\n end",
"def view_record\n\tfound = false\n\tputs \"\\n\"\n\tprint \"First Name: \"\n\tfname = gets.chomp.upcase\n\tprint \"Last Name: \"\n\tlname = gets.chomp.upcase\n\t\n\t@personnel.each do |a|\n\t\tif a.fname == fname && a.lname == lname\n\t\t\tfound = true\n\t\tend\n\tend\n\n\tif found == true\n\t\taccount_view(fname,lname)\n\telsif @count < 3 \n\t\t@count += 1\n\t\tputs \"Account not found. Please try again.\"\n\t\taccount_menu\n\telse\n\t\tputs \"Too many login attempts. Please contact customer service.\"\n\t\tmain_menu\n\tend\nend",
"def new_user_available(useremail)\n result = @connection.exec(\"SELECT * FROM Users WHERE useremail='#{useremail}';\")\n if result.num_tuples.zero?\n true\n else\n false\n end\n end",
"def does_user_exist(username)\n user = Account.find_by(:user_name => username)\n if user\n return true\n else\n return false\n end\nend",
"def user?(jid)\n users.include?(jid.to_s.downcase)\n end",
"def user?(user)\n users.include? user\n end",
"def _user? name\n\t\tuid = DB[:_user].filter(:name => name).get(:uid)\n\t\tuid ? true : false\n\tend",
"def checkForUser(loginUser)\n @users = User.all\n\n @users.each do |user|\n if user[\"userName\"] == loginUser[\"userName\"] && user[\"password\"] == loginUser[\"password\"]\n return user\n end\n end\n return false\n\n end",
"def user?(user, team_id)\n if TeamsUser.where(team_id: team_id, user_id: user.id).first\n true\n else\n false\n end\n end",
"def check_user\n @user = authenticate(@campaign.user_id, request.path, nil)\n end",
"def does_user_exist?(username)\n user = UsersModel.find_by(:name => username.to_s)\n if user\n return true\n else\n return false\n end\nend",
"def show?\n user.id == record.id || user.administrator?\n end",
"def check_user\n unless current_user.nil?\n return if current_user.admin?\n @activity = current_user.activities.find_by_id(params[:id])\n end\n if @activity.nil?\n flash[:error] = \"权限不足\"\n redirect_to Activity.find(params[:id])\n end\n end",
"def verify_correct_user\n @user = User.find(params[:id])\n # current_user is a function defined in sessions_helper\n if not @user == current_user\n flash[:danger] = \"Unauthorized Access.\"\n redirect_to listings_path\n end\n end",
"def search_users\n unless @current_admin.is_super_admin\n unless @current_admin.privilages.include? '1'\n flash[:authority_error]=\"You are not authorized to navigate to this page \"\n redirect_to admin_index_path\n empty_user_id\n return\n end\n end\n empty_user_id\n @check=0\n @searched_user=User.new\n end",
"def permitted?(table, user)\n if user.is_a?(User)\n group_user_ids(table).include?(user.id)\n elsif !user\n group_ids(table).include?(UserGroup.all_users.id)\n elsif user.try(:to_i)&.nonzero?\n group_user_ids(table).include?(user.to_i)\n else\n raise(ArgumentError.new(\"Was expecting User instance, id or nil.\"))\n end\n end",
"def read_by?(user)\n\t user and self.readers.find_by_id(user.id)\n end",
"def completed_user?(user)\n \n incomplete = false;\n self.design_checks.each do | dsn_chk |\n section = dsn_chk.check.section\n if ( self.is_self_audit? && dsn_chk.designer_result == \"None\" )\n auditor = self.audit_teammates.detect { |tmate| \n tmate.section_id == section.id && tmate.self? }\n elsif ( self.is_peer_audit? && dsn_chk.auditor_result == \"None\" )\n auditor = self.audit_teammates.detect { |tmate| \n tmate.section_id == section.id && !tmate.self? }\n end\n if auditor.id == @logged_in_user.id \n incomplete = true\n end\n end\n ! incomplete\n \n end",
"def find_user?(username, users)\n users.each do |user|\n if user[0] == username\n puts user[0]\n return true\n end\n end\n return false\nend",
"def has_user?(user)\n self.users.include?(user)\n end",
"def user_test(users, level)\n\tres = Array.new\n\tlength = users.length\n\tputs 'starting user_test, length is ' + length.to_s\n\ttest_i = 0\n\tusers.each do |person|\n\t\tleft = length - test_i\n\t\tputs left.to_s + ' left'\n\t\ttmp = person['id'].to_s\n\t\tresponse = TOKEN.get('/v2/users/' + tmp).parsed\n\t\tif ((response['cursus_users'].length > 0) && (response['cursus_users'][0]['level'] >= level))\n\t\t\tres.push(person)\n\t\tend\n\t\ttest_i += 1\n\tend\n\treturn res\nend",
"def user_exists?(user)\n @users.key?(user)\n end",
"def show\n @user = Helpers.show_each_user(params[:id])\n check_user_nil('Success', 'User does not exist', @user)\n end",
"def check_found_user(u, path)\n if u.nil?\n @msg.add(:error, \"Counld not find the user.\");\n render(path);\n return false;\n end\n return true;\n end",
"def user_meets_criteria?(user)\n user.credits > 0\n end",
"def permisos?(id)\n if DeviceUser.where(id_user: id.to_s, id_dispositivo: self.id.to_s).count > 0\n\n return true\n end\n\n return false\n\n end",
"def validate_profile_edit_get(session, params)\n db = connect_to_db()\n db.results_as_hash = true\n\n result = db.execute('SELECT id FROM users where id=?', params[\"id\"].to_i)\n\n if result[0][0] == session[\"user_id\"]\n return true\n else\n return false\n end\n end",
"def verify_user(uid)\n begin\n RestClient.get construct_url(\"user/verify/#{uid}\")\n true\n rescue RestClient::BadRequest => e\n @last_error = e.http_body\n @last_error_code = e.http_code\n false\n end\n end",
"def user_read?(user_id)\n return false if user_id.nil?\n\n load_from_server if fault?\n\n @read.include?(user_id)\n end",
"def check_access_control_all\n @user = User.find(params[:user_id])\n\n response_access_denied unless current_user.has_role?(:admin) || current_user.id == @user.id\n rescue\n response_access_denied\n end",
"def check_user_recorded_show\n show = Show.find(params[:id])\n if !current_user.user_has_show(show)\n flash[:notice] = \"You can only modify information for shows that you have recorded.\"\n redirect_to show_path(show)\n end\n end",
"def user_already_has_item_with_name?(record)\n user_item_names(record).include?(record.name.downcase)\n end",
"def user_details_complete(user)\n\n user_details_fields_presence = []\n\n user_details_fields_presence.push(user.name.present?)\n user_details_fields_presence.push(user.date_of_birth.present?)\n user_details_fields_presence.push(\n (\n user.line1.present? &&\n user.townCity.present? &&\n user.county.present? &&\n user.postcode.present?\n )\n )\n\n user_details_fields_presence.all?\n\n end",
"def user_access_create\n check_user_access(params[:user_id])\n end",
"def user_access_create\n check_user_access(params[:user_id])\n end",
"def check_all_records\n models.each do |model|\n begin\n # TODO: Can we filter based on those records that are already present in the 'invalid_records' table - especially since they have been re-verified in the method before?\n model.find_each(batch_size: Checker.batch_size) do |record|\n invalid_record!(record) unless record.valid?\n end\n rescue => e\n # Rescue from exceptions (table does not exists,\n # deserialization error, ...)\n puts e.message\n puts \"Skipping validations for #{model}\"\n end\n end\n end",
"def checkCurrentUserEmployee(empleado)\n \t\tif current_user.empleado_id == empleado.id\n \t\t\treturn true\n \t\tend\n \tend",
"def hasuser? username\n\t\t@cf.usermanager.user? username\t\t\n\tend",
"def verify_user_for_changes!\n\n unless @item.editable_by_user?(auth_user)\n status_error = @item.errors[:status].present? ? @item.errors[:status].join(' ') : nil\n flash[:error] = status_error || \"You do not have permission to the item.\"\n redirect_back(items_path) && return\n\n else\n if ItemPhoto.over_the_limit?(@item)\n flash[:notice] = \"The images over the limit will be discarded.\"\n end\n end\n\n end",
"def check\n \n end",
"def check\n \n end",
"def member?(user)\n user_ids.include?(user.id)\n end",
"def show\n check_user\n end",
"def has_user?(name, options={})\n run(\"id #{name}\").success?\n end"
] | [
"0.63647467",
"0.63553554",
"0.6290373",
"0.61673236",
"0.615817",
"0.6141064",
"0.61370826",
"0.611401",
"0.6047428",
"0.6017651",
"0.6003659",
"0.6002102",
"0.599394",
"0.59900594",
"0.5970619",
"0.5958268",
"0.59244865",
"0.5921791",
"0.5911777",
"0.59102124",
"0.58602285",
"0.5829512",
"0.58200026",
"0.5816433",
"0.5809658",
"0.5806161",
"0.5793489",
"0.5786682",
"0.57820326",
"0.577704",
"0.5776425",
"0.5764517",
"0.5761913",
"0.5756957",
"0.57452756",
"0.5740243",
"0.5738425",
"0.57378477",
"0.5716941",
"0.571468",
"0.5703789",
"0.57023424",
"0.56992185",
"0.56942856",
"0.5690117",
"0.5686998",
"0.5684951",
"0.5677943",
"0.5673592",
"0.56725466",
"0.5663574",
"0.5663574",
"0.5663574",
"0.5662773",
"0.56613195",
"0.56418943",
"0.5640223",
"0.56277364",
"0.5625192",
"0.5606528",
"0.56062573",
"0.5603584",
"0.5596741",
"0.5595804",
"0.5592877",
"0.55841595",
"0.5583573",
"0.5582923",
"0.55784094",
"0.5574811",
"0.5571137",
"0.5567379",
"0.55667007",
"0.55658674",
"0.55643135",
"0.5563817",
"0.5557139",
"0.55520993",
"0.5550954",
"0.55504763",
"0.5550426",
"0.55416906",
"0.5537141",
"0.5532682",
"0.55303067",
"0.5527786",
"0.5524532",
"0.5519161",
"0.5517962",
"0.55179536",
"0.55179536",
"0.5516528",
"0.5507804",
"0.55052024",
"0.550088",
"0.55003554",
"0.55003554",
"0.54995275",
"0.5498561",
"0.54949886"
] | 0.6952754 | 0 |
Write a method, is_prime? You have to determine what are the arguments required for is_prime The method should be used to determine if a number is a prime number recursively. | def is_prime?
#Your code here
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_prime?(num)\nend",
"def is_prime?(num)\n\nend",
"def is_prime?(number)\n\nend",
"def is_prime?(number)\n\nend",
"def is_prime?(num)\n # Write your code here\nend",
"def is_prime?(n)\n end",
"def prime?(arg)\n Prime.prime?(arg)\nend",
"def prime?(int)\n \nend",
"def is_prime(x)\n return true if x.prime? == true\n else false\nend",
"def prime?(n)\n\tPrime.prime?(n)\nend",
"def is_prime?(num)\n return false if num == 1\n return true if num == 2 \n (2..Math.sqrt(num)+1).each do |x|\n return false if num%x == 0\n end\n true\nend",
"def is_prime?(num)\n if !is_integer?(num)\n return false\n elsif num <= 1\n return false\n else\n (2..(num-1)).each do |el|\n if num % el == 0\n return false\n end\n end\n end\n return true\nend",
"def is_prime?(number,divisor = 2)\r\n\t#code here \r\n\tif (number == 2) \r\n\t\treturn true \r\n\telsif (number < 2)\r\n\t\treturn false \r\n elsif (number % divisor == 0) \r\n return false\r\n elsif ( divisor * divisor > number) \r\n return true \r\n end\r\n is_prime?(number , divisor + 1)\r\nend",
"def is_prime?(n)\n root = Math.sqrt(n)\n return false if n < 2\n return true if n < 4\n return false if n %2 == 0\n return true if n < 9\n return false if n % 3 == 0\n i = 5\n while i < root\n return false if n % i == 0\n return false if n % (i + 2) == 0\n i += 6\n end\n return true\nend",
"def is_prime? (number)\n return false if number < 1\n 2.upto(Math.sqrt(number)) do |x|\n return false if number % x == 0\n end \n true\nend",
"def is_prime?(i)\r\n 2.upto(Math.sqrt(i).to_i) {|j|\r\n return false if i % j == 0\r\n }\r\n true\r\nend",
"def prime?\n Prime.prime?(self)\n end",
"def is_prime?(n)\n (2...n).each { |factor| return false if n % factor == 0 } \n n > 1\nend",
"def is_prime?(num)\n 2.upto(num / 2) do |n|\n return false if num % n == 0\n end\n true\nend",
"def is_prime?(num)\n 2.upto(num-1) do |i|\n return false if num%i==0\n end\n true\nend",
"def is_prime?(num)\n\n return false if num <= 1\n return true if num == 2\n\n i = 2\n while i < num\n return false if num % i == 0\n i += 1\n end\n\n true\n\nend",
"def is_prime?(n)\n 2.upto(Math.sqrt(n).to_i) { |num| return false if n % num == 0 }\n n == 1 ? false : true\nend",
"def is_prime?(num)\n (2...num).none? { |div| num % div == 0 }\nend",
"def is_prime?(num)\n if !num.is_a?(Integer) || ( num.class == Float && !num.nan? && num == num.floor ) || num <= 1\n false\n else\n (2...num).each do |i|\n if num % i == 0\n return false\n end\n end\n true\n end\nend",
"def ruby_prime(num)\n if num.prime? == true\n puts \"#{num} is prime.\"\n else puts \"#{num} is not prime.\"\n end\nend",
"def is_prime?(number)\n (2...number).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\n \nend",
"def is_prime?(num)\n (2..(num/2)).each { |divisor| return false if num % divisor == 0 }\n true\nend",
"def is_prime?(num)\n return 2 if num == 2\n (2...num).each do |n|\n return false if num % n == 0\n end\n true\nend",
"def is_prime?(num)\n (2..num/2).none?{|el| num % el == 0}\nend",
"def is_prime?(number)\r\n (2...number).each do |n|\r\n return false if number % n == 0\r\n end\r\n true\r\nend",
"def isprime(n)\n if n == 1\n return false\n elsif n == 2\n return true\n else\n (2..Math.sqrt(n).ceil).each { |e| n % e == 0 ? (return false) : next }\n return true\n end\nend",
"def is_prime?(num)\n return false if num < 2\n (2...num).each do |i|\n return false if num%i == 0\n end\n return true\nend",
"def isprime?(num)\n\n return false if num<2\n\n (2...num).each do |factor|\n return false if num % factor == 0\n end\n\n return true\n\nend",
"def is_prime?(num)\n (2...num).each {|el| return false if num % el == 0}\n true\nend",
"def is_prime?(num)\n\n return false if num<2\n\n (2...num).none? {|factor| num%factor == 0}\n\nend",
"def is_prime?(num)\n return if num <= 1\n (2..Math.sqrt(num)).none? { |i| (num % i).zero? }\nend",
"def is_prime?(number)\n return true if number == 2\n 2.upto(number/2) do |x|\n return false if number%x == 0\n end\n return true\nend",
"def is_prime?(num)\n return false if num < 2\n (2...num).each { |factor| return false if num % factor == 0}\n true\nend",
"def is_prime?(num)\n (2...num).none? { |el| num % el == 0 }\nend",
"def is_prime?(num)\n (2..num / 2).each do |n|\n return false if num % n == 0\n end\n true\nend",
"def is_prime?(n)\n if n<=1 || n % 1 != 0 then\n return false\n else\n for d in 2..(n - 1)\n if (n % d) == 0\n return false\n end\n end\n true\n end\nend",
"def is_prime?(num)\nreturn false if num < 2\n\n(2...num).none? { |num2| num % num2 == 0}\nend",
"def is_prime?(num)\n (2..(num - 1)).each do |divisor|\n return false if num % divisor == 0\n end\n\n true\nend",
"def is_prime?(n) \n Math.sqrt(n).to_i.downto(2).each do |i| \n return false if n % i == 0\n end\nend",
"def is_prime?(num)\n (2...num).each do |el|\n return false if num % el == 0\n end\n true\nend",
"def is_prime?(num)\n Math.sqrt(num).floor.downto(2).each do |i|\n false if num % i == 0\n end\n true\nend",
"def is_prime?(num)\n (2..num-1).each do |x|\n return false if num % x == 0\n end\n true\nend",
"def is_prime?(num)\n (2...num).each do |i|\n return false if num % i == 0\n end\n true\nend",
"def is_prime?(number)\n (2..(number - 1)).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\nend",
"def is_prime?(number)\n (2..(number - 1)).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\nend",
"def is_prime?(number)\n (2..(number - 1)).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\nend",
"def is_prime?(num)\n (2...num).none? { |n| num % n == 0 }\nend",
"def is_prime?(num)\n return true if num == 1\n (2...num).all? {|i| (num % i) != 0}\nend",
"def is_prime?(num)\n return false if num <2\n return (2..num/2).none? {|i| num%i==0}\nend",
"def is_prime?(num)\n for i in (2..Math.sqrt(num))\n return false if num % i == 0\n end\n true\nend",
"def is_prime?(num)\n return false if num < 2\n (2...num).none? { |factor| num % factor == 0 }\nend",
"def is_prime?(num)\n return false if num < 2\n (2...num).none? { |factor| num % factor == 0 }\nend",
"def is_prime?(num)\n return false if num < 2\n (2...num).none? { |factor| num % factor == 0 }\nend",
"def is_prime?\n return false if num <= 1\n Math.sqrt(num).to_i.downto(2).each {|i| return false if num % i == 0}\n true\nend",
"def is_prime?(num)\n return false if num <= 1\n\n (2...num).each do |fact|\n return false if num % fact == 0\n end\n\n true\nend",
"def is_prime?(num)\n if num == 2 || num == 3 || num == 5\n return true\n elsif num % 2 == 0 || num % 3 == 0 || num % 5 == 0\n return false\n else\n return true\n end\nend",
"def is_prime?(x)\r\n if x == 1\r\n return false\r\n end\r\n for n in (1..Math.sqrt(x).ceil)\r\n if x%n == 0 \r\n if n != 1 && n != x\r\n return false\r\n end\r\n end\r\n end\r\n return true\r\nend",
"def is_prime?(num)\n return false if num < 2\n\n (2...num).each do |i|\n return false if num % i == 0\n end\n true \nend",
"def prime? (number)\n if number == 2\n return true\n elsif number < 2\n return false\n else\n for num in 2..Math.sqrt(number)\n if number % num == 0\n return false\n else\n return true\n end\n end\n end\nend",
"def is_prime?(num)\n (2...num).none? {|i| num % i == 0}\nend",
"def is_prime?(number)\n\n if (number > 1) && (number % 2 != 0) && (number % 3 != 0) && (number % (number-1) != 0) || (number == 2) || (number == 3)\n return true\n else\n return false\n end\nend",
"def prime?(n)\n primes(n).size == 1\nend",
"def is_prime?(number)\n factors = (2...(number))\n if number == 2 || number == 3\n return true\n elsif number == 0 || number == 1\n return false\n elsif factors.any? {|factor| number % factor == 0 }\n return false\n else return true\n end\nend",
"def is_prime?\n return true if self == 2\n return false if self < 3\n for divisor in 2..(Math.sqrt(self).to_i)\n return false if self%divisor == 0\n end\n true\n end",
"def is_prime?(number)\n remainders = (2...number).map { |d| number % d}\n !remainders.include?(0) && number > 1\nend",
"def is_prime?(number)\r\n if number <= 1\r\n # only numbers > 1 can be prime.\r\n return false\r\n end\r\n\r\n idx = 2\r\n while idx < number\r\n if (number % idx) == 0\r\n return false\r\n end\r\n\r\n idx += 1\r\n end\r\n\r\n return true\r\nend",
"def is_prime?(num)\n return false if num == 1 #added gaurd clause after watching walkthrough\n (2..(num - 1)).select do |x| #refactored to remove range variable\n return false if num % x == 0\n end\n return true #moved the this return to solve is_prime?(2) while watching video\nend",
"def is_prime?(num)\n (2...num).each do |i|\n if num % i == 0\n return false\n end\n end\n num > 2\nend",
"def is_prime?(n)\n return false if n == 1\n (2..n-1).each do |divisor|\n return false if n % divisor == 0\n end\n true\nend",
"def is_prime?(n)\n if n <= 1\n return false\n elsif n == 2\n return true\n else\n (2..(n-1)).each do |num|\n if n % num == 0\n return false\n end\n end\n end\n return true\nend",
"def is_prime?(number)\n return false if number < 2\n (2...number).to_a.none?{ |integer| number % integer == 0 }\nend",
"def is_prime?(num)\n return true if num == 1 || num == 2\n return false if num % 2 == 0\n int = 3\n while int <= Math::sqrt(num)\n return false if num % int == 0\n int += 2\n end\n true\nend",
"def is_prime?(num)\n return false if num.even?\n for i in (2..((num/2.round) + 1))\n return false if num % i == 0\n end\n return true\nend",
"def is_prime?(num)\n return false if num.even?\n for i in (2..((num/2.round) + 1))\n return false if num % i == 0\n end\n return true\nend",
"def prime?(num)\n if num == 2\n true\n elsif num > 1 && num % num == 0 && num % 1 == 0 && !(2 .. (num - 1)).to_a.any?{|number| num % number == 0}\n true\n else\n false\n end\nend",
"def prime?(num)\n factors(num) == [1, num]\nend",
"def prime?(num) \n return false if !num.integer? #integer is # that is not a fraction\n return false if num < 2\n return true if num == 2\n (2..num-1).each {|int| return false if num % int == 0}\n true\nend",
"def prime?( number )\n self.class.prime? number\n end",
"def is_prime?(num)\n (2...num).each do |n|\n if num % n == 0\n return false\n end\n end\n true\nend",
"def is_prime(number)\n if number == 1\n return true\n end\n 2.upto(number) do |x|\n if (number % x == 0) && (number != x)\n return false\n end\n end\n return true\nend",
"def is_prime?(num)\n return false if num < 2\n \n (2...num).each do |i|\n return false if num % i == 0\n end\n true\nend",
"def is_prime?(num)\n i = 2\n while i < num\n return false if num % i == 0\n i+=1\n end\n true\nend",
"def is_prime?(num)\n i = 2\n while i < num\n return false if num % i == 0\n i+=1\n end\n true\nend",
"def prime?(number)\n\nreturn false if number < 2\n\n (2...number).each do |x|\n return false if number % x == 0\n end\nreturn true\n\nend",
"def prime?(num)\n Math.sqrt(num).to_i.downto(2).each { |i| return false if (num % i).zero? }\n true\nend",
"def is_prime?(num)\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n true\nend",
"def is_prime_number(num)\n (2...num).all? {|n| num % n != 0}# has factors\nend",
"def is_prime?(integer)\n return false if integer == 1\n (2...integer).to_a.all? {|num| integer % num != 0}\nend",
"def is_prime?(number)\n if number <= 1\n return false\n end\n\n i = 2\n while i < number\n if (number % i) == 0\n return false\n end\n i += 1\n end\n return true\nend",
"def is_prime?(number)\n (2..(number-1)).each do |divisor| # this is a range (2..number -1)\n return false if number % divisor == 0\n end\n true # code intentionally, return true, otherwise it would return a truthy value anyway but that's not the point\nend",
"def prime?(num)\n if 0 == num or 1 == num\n return false\n else\n return (2..Math.sqrt(num)).all? { |x| num % x != 0}\n end\nend",
"def is_prime? n\n x = n -1\n while x > 1\n return false if (n % x).zero?\n x -= 1\n end\n true\nend",
"def is_prime?(num)\r\n (2..(num ** 0.5).to_i).each {|factor| return false if num % factor == 0 && num != factor} # no need to check above square root\r\n true\r\nend",
"def is_prime?(num)\n for i in (2...num/2)\n if num % i == 0\n return false\n end\n end\n return true\nend",
"def is_prime?(number)\n (2...number).each do |factor|\n if number % factor == 0\n return false\n end\n end\n return true\nend"
] | [
"0.83943486",
"0.836582",
"0.83246696",
"0.83246696",
"0.8283293",
"0.82549274",
"0.8091258",
"0.80871874",
"0.80385745",
"0.79345393",
"0.7886125",
"0.7881939",
"0.78589314",
"0.7831226",
"0.7829843",
"0.7825355",
"0.7824195",
"0.7797287",
"0.77783936",
"0.7771088",
"0.7764832",
"0.7764678",
"0.77333575",
"0.7729548",
"0.7716655",
"0.7711727",
"0.7701286",
"0.7697984",
"0.76951677",
"0.76901513",
"0.76860636",
"0.7680712",
"0.7678329",
"0.7672992",
"0.7671242",
"0.76694894",
"0.7669074",
"0.7666147",
"0.7654695",
"0.7651256",
"0.7650803",
"0.7647404",
"0.76371753",
"0.76367176",
"0.763519",
"0.7629264",
"0.7627433",
"0.7621741",
"0.7620853",
"0.7620853",
"0.7620853",
"0.7619867",
"0.7616237",
"0.7616082",
"0.76005197",
"0.75990963",
"0.75990963",
"0.75990963",
"0.75916225",
"0.75859493",
"0.75854784",
"0.758421",
"0.75723624",
"0.75691044",
"0.7566017",
"0.75644153",
"0.7561857",
"0.75569993",
"0.7555415",
"0.7554613",
"0.7553479",
"0.7548852",
"0.7547783",
"0.754438",
"0.75440913",
"0.75440365",
"0.7539881",
"0.7538794",
"0.7538794",
"0.7533208",
"0.752904",
"0.7526603",
"0.7518821",
"0.7515079",
"0.7514957",
"0.75120354",
"0.7504436",
"0.7504436",
"0.7494691",
"0.7493419",
"0.7493116",
"0.74904144",
"0.7489865",
"0.7483453",
"0.74812484",
"0.7481187",
"0.7477831",
"0.7475931",
"0.7467221",
"0.74665725"
] | 0.80926824 | 6 |
GET /comments/1 GET /comments/1.json | def show
@idea = Idea.find(params[:idea_id])
@comments = @idea.comments
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comments\n client.get(\"/#{id}/comments\")\n end",
"def comments\n @list.client.get(\"#{url}/comments\")\n end",
"def comments\n @list.client.get(\"#{url}/comments\")\n end",
"def comments\n @article = Article.find(params[:id])\n @comments = @article.comments\n\n respond_to do |format|\n format.html \n format.json { render json: @comments, status: :ok }\n end\n end",
"def show\n comment = Comment.find(params[:id])\n render json: comment, status: 200\n end",
"def comments; rest_query(:comment); end",
"def comments\n render json: @post.comments\n end",
"def show\n @comment = Comment.find(params[:id])\n render json:@comment\n end",
"def show\n user = User.find_by({token: env['HTTP_TOKEN']})\n render json: user.comments.find(params[:id])\n end",
"def show\n # comment = Comment.find_comment\n render json: @comment\n end",
"def show\n comment = Comment.find_by(id: params[:id])\n render json: comment\n end",
"def show\n @comment = @commentable.comments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n comment = Comment.find(params[:id])\n render json: comment, status: :ok\n end",
"def show\n @comments = @post.comments\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def index\n @comments = @commentable.comments\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def index\n comments = @project.comments\n render json: comments\n end",
"def index\n @post = Post.find_by_id(params[:post_id])\n if @post.nil?\n return render json: { error: \"Post not found\" }, status: :not_found\n end\n render json: @post.comments,status: 200\n end",
"def index\n @comments = DiscussionComment.all\n render json: @comments\n end",
"def show\n @comment1 = Comment1.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment1 }\n end\n end",
"def get_comment(comment_id)\n get(\"comments/#{comment_id}\")\n end",
"def index\n @comments = Comment.all\n render json: @comments\n end",
"def index\n if params[:comment_id].nil?\n render json: {\n comments: @card.comments.paginate(page: params[:page], per_page: 3)\n }, statues: :ok\n else\n @comment = Comment.find(params[:comment_id])\n render json: {\n comment: @comment,\n replaies: @comment.replaies.paginate(page: params[:page], per_page: 3)\n }, statues: :ok\n end\n end",
"def list\n comments = Comment.where(post: @post)\n render json: comments, status: 200\n end",
"def show\n @comment = @posting.comments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def index\n #@comments = Comment.all\n comments = @blog.comments\n render json: comments, status: :ok\n end",
"def show\n @post = Post.find(params[:id])\n @comments = Comment.where(:post_id => params[:id]).order(\"id desc\")\n @comments = @comments.page(params[:page]).per(20)\n @comment = Comment.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n render json: comment\n end",
"def show\n render json: @comment\n end",
"def GetComments id,params = {}\n\n params = params.merge(path: \"tickets/#{id}/comments.json\")\n APICall(params)\n\n end",
"def index\n comments = @post.comments\n render json: { comments: comments }\n #loop through comments and find first and last name by user_id\n #User.find....etc\n end",
"def show\n @comment = Comment.find(params[:id])\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def all_comments\n render :json => User.find(params[:user_id]).comments\n end",
"def get_comment\n @comment = Comment.find(params[:id])\n end",
"def comment\n Comment.find(params[:id])\n end",
"def show\n @comment = Comment.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n \tend\n end",
"def index\n @comments = Comment.where('user_id = ?', current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def comments_for(url)\n get_data(\"comments/show/#{FORMAT}?url=#{url}\")\n end",
"def comments(options={})\n parse_comments(request(singular(id) + \"comments\", options))\n end",
"def index\n @comments = Comment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def index\n @comments = Comment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def index\n @comments = Comment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comments }\n end\n end",
"def show\n render json: { comment: @comment, replaies: @comment.replaies }, status: :ok\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @comment }\n end\n end",
"def show\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @comment }\n end\n end",
"def index\n logger.info(\"comments got index! #{params}\");\n @comments = Comment.find_by_post_id(params[:post_id])\n respond_with @comments\n end",
"def details(id, params = {})\n wrike.execute(:get, api_url(\"comments/#{id}\"), params)\n end",
"def comments\n Birdman::ApiPaginatedCollection.new(\"movies/#{id}/comments\")\n end",
"def show\n @post = Post.find(params[:id])\n @comments = @post.comments.order('created_at DESC')\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @comments = Recipe.find(params[:recipe_id]).comments.all\n @comment = Recipe.find(params[:recipe_id]).comments.find(params[:id]) \n if @comment \n respond_to do |f|\n f.html {render :index}\n f.json {render json: @comment}\n end\n else\n @comments\n respond_to do |f|\n f.html {render :index}\n f.json {render json: @comments}\n end\n end\n end",
"def show\n @comments = @servidor.comments.order(\"id DESC\").page(params[:page]).per(3)\n end",
"def index\n @post = Post.find(params[:post_id])\n @comments = @post.comments\n\n render json: @comments, include: ['user']\n end",
"def comment(options)\n get(\"/content/items/#{options.delete(:item)}/comments/#{options[:id]}\",options)\n end",
"def show\n @comment = @song.comments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def show\n @comment = Comment.find_by_permalink(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment }\n end\n end",
"def index\n @comments = @entry.comments\n respond_with(@comments)\n end",
"def index\n @comments = @post.comments.order(created_at: :desc)\n render json: @comments, status: :ok\n\n end",
"def show\n @post = Post.find(params[:id], include: :comments, order: 'comments.id')\n @comment = Comment.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n render json: @comment, status: :ok\n\n end",
"def show\n @new_comment = Comment.build_from(@post, \"\")\n\n render json: @post, status: 200\n\n\n end",
"def show\n recipe = Recipe.find_by_id(params[:id])\n\n respond_to do |format|\n if recipe\n @comments = []\n comments = recipe.comments\n for comment in comments\n comment_user = comment.user\n @comments << { :user => comment_user, :profile_picture => comment_user.profile_picture.url, :comment => comment }\n end\n\n format.json { render :json => @comments }\n else\n format.json { render :status => 404, :json => { :message => \"No such Recipe\"}}\n end\n end\n end",
"def index\n @comments = @complaint.comments\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @comments }\n format.js\n end\n end",
"def index\n comments = list.comments.desc(:created_at)\n comments = comments[5, (comments.length-1)]\n\n render json: comments\n end",
"def show\n @comments = Comment.where(post_id: params[:id])\n end",
"def gist_comments(id)\n get \"/gists/#{id}/comments\"\n end",
"def show\n logger.info(\"comments got show! #{params}\");\n @comments = Comment.find_by_post_id(params[:post_id])\n respond_with @comments\n end",
"def index\n event = Event.find(params[:event_id])\n render json: event.comments, status: :ok\n end",
"def comments\n expose Challenge.comments(@oauth_token, params[:challenge_id].strip)\n end",
"def show\n if @comment.nil?\n render json: {error: \"Not Found\"}, status: :not_found\n else\n render json: @comment, status: :ok\n end\n end",
"def get_comments(user_name)\n uri = create_api_uri(@@base_uri, user_name, 'getComments')\n return get(uri)\n end",
"def index\n @comments = Comment.order(\"created_at DESC\")\n render json: @comments, status: :ok\n end",
"def index\n if params[:_post_id]\n post_comments = PostComment.where(post_id: params[:_post_id])\n render json: post_comments.as_json(\n include: { user: { only: [:name, :id] } },\n except: [:post_id, :user_id]),\n status: :ok\n else\n render json: @current_user.post_comments.as_json(\n include: { post: { only: [:title, :id, :excerpt] } },\n except: [:user_id, :post_id]),\n status: :ok\n end\n end",
"def view_comment\n @comment = Comment.find(params[:id])\n end",
"def show\n @comment_relationship = CommentRelationship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comment_relationship }\n end\n end",
"def index\n @comments = @commentable.comments\n end",
"def index\n # @post = Post.find(params[:post_id])\n @comments = @post.comments\n end",
"def show\n @comment = @complaint.comments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @comment }\n format.js\n end\n end",
"def show\n @messages_comment = MessagesComment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @messages_comment }\n end\n end",
"def show\n #@post = Post.find(params[:id])\n @comment = Comment.new\n @comment_container_id_prefix = COMMENT_CONTAINER_ID_PREFIX\n respond_to do |format|\n format.html\n format.json { render json: @post, except: :updated_at, :include => {:user => {:only => [:name]}}}\n end\n end"
] | [
"0.8281809",
"0.7442966",
"0.7442966",
"0.7435585",
"0.74057704",
"0.7305289",
"0.7283902",
"0.7258409",
"0.7255485",
"0.72482485",
"0.7243032",
"0.72200114",
"0.72188604",
"0.7218659",
"0.7174758",
"0.71585846",
"0.7157486",
"0.7119247",
"0.7116642",
"0.7101369",
"0.71012545",
"0.7094372",
"0.7077762",
"0.70612174",
"0.704785",
"0.70424336",
"0.7028",
"0.7010792",
"0.69918513",
"0.697462",
"0.69613624",
"0.6953748",
"0.6952556",
"0.6914137",
"0.6913151",
"0.6906844",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6898053",
"0.6897756",
"0.68828076",
"0.68790096",
"0.68672353",
"0.68672353",
"0.68672353",
"0.6865213",
"0.6861355",
"0.6861355",
"0.6861355",
"0.68576676",
"0.6856359",
"0.6851801",
"0.6829165",
"0.68227893",
"0.6805682",
"0.6803945",
"0.6794961",
"0.6787622",
"0.6783587",
"0.67659736",
"0.6765638",
"0.6758855",
"0.67456573",
"0.6740276",
"0.6724782",
"0.6720965",
"0.6713441",
"0.67054147",
"0.66968524",
"0.66918206",
"0.66881704",
"0.6684134",
"0.6682118",
"0.6669427",
"0.6669092",
"0.6633138",
"0.6625229",
"0.6620361",
"0.6619765",
"0.66194123",
"0.6618856",
"0.66188467",
"0.6613919"
] | 0.0 | -1 |
POST /comments POST /comments.json | def create
@idea = Idea.find(params[:idea_id])
@comment = @idea.comments.new(comment_params)
@comment.user_id = current_user.id
@comment.user = current_user
if
@comment.save
redirect_to @idea
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @comment = @post.comments.new(comment_params)\n if @comment.save\n render json: @comment, status: :created\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n\n end",
"def comment options={}\n client.post(\"/#{id}/comments\", options)\n end",
"def create\n post = Post.find(params[:post_id])\n @comment = post.comments.new(comment_params)\n if @comment.save\n render json: {\n data: @comment\n }\n else\n render json: {\n errors: @comment.errors\n }\n end\n end",
"def create\n puts params.to_json\n @post = Post.find(params[:comment][:post_id])\n @comment = @post.comments.build(comment_params)\n if @comment.save\n redirect_to root_path\n end\n end",
"def create\n comment = Comment.new(comment_params)\n\n post = Post.find(params[:comment][:post_id])\n post.data[\"comments\"] = post.data[\"comments\"] + 1\n\n if comment.save && post.save\n render json: {\n status: \"success\",\n data: {\n comment: comment.as_json(include: {\n user: {\n only: [:id, :name, :avatar]\n }\n }),\n comments: post.data[\"comments\"]\n }\n }, status: :ok\n else\n render json: comment.errors, status: 404\n end\n end",
"def create\n @comment = Comment.new(params[:comment])\n @comment.save\n respond_with(@post, @comment)\n end",
"def create\n json_create_and_sanitize(comment_params, Comment)\n end",
"def create\n comment = Comment.new(create_params)\n comment.post = @post\n if comment.save\n render json: comment, status: 200\n else\n render json: comment.errors, status: 403\n end\n\n end",
"def create\n # get the post\n @post = Post.find_by_id(params[:post_id])\n if @post.nil?\n return render json: { error: \"Post not found\" }, status: :not_found\n end\n # create post to comment\n @comment = @post.comments.create(body: params[:body])\n # associate comment before save(comment cannot be saved without user_id)\n @comment.user = @current_user\n # save comment\n if @comment.save\n render json: @comment, status: :ok\n else\n render json: { errors: { status: \"400\",\n title: \"Bad request\",\n details: @comment.errors\n }\n }, status: :bad_request\n end\n end",
"def create\n @new_comment = post.comments.new(comment_params)\n @new_comment.user = current_user\n\n respond_to do |format|\n if @new_comment.save\n format.html { redirect_to post, notice: I18n.t('controllers.comments.created') }\n format.json { render :show, status: :created, location: post }\n else\n format.html { redirect_to post, alert: I18n.t('controllers.comments.error') }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new({user_id: params[:user_id], announcement_id: params[:announcement_id], description: params[:description]})\n @comment.save\n render json:@comment\n end",
"def create\n @comment = @noticia.comments.create(comment_params)\n\n if @comment.save\n render json: @comment, status: :created\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def create\n #if @user && @user.posts.include(@post)\n @comment = @post.comments.create!(comment_params)\n json_response(@comment, :created)\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.json { render :show, status: :created, location: @comment }\n else\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = current_user.comments.new(comment_params)\n @comment.user_id = current_user.id\n if @comment.save\n render json: @comment\n else\n render :json => @comment.errors\n end\n end",
"def create\n comment = @project.comments.build(comment_params)\n\n if comment.save\n render json: comment \n else\n render json: { message: 'Error: Failed to add comment.'}\n end\n end",
"def create\n @comment = @user.comments.build(@json['comment'])\n update_values :@comment, @json['comment']\n end",
"def create\n @post = Post.where(id: params[:post_id]).first\n @comment = @post.comments.new(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @post, 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 comments\n render json: @post.comments\n end",
"def create\n @blogpost = Blogpost.find(params[:blogpost_id])\n\n @comment = @blogpost.comments.create(comment_params)\n render json: @comment\n end",
"def create\n @comment = Comment.new(comment_params)\n respond_to do |format|\n if @comment.save\n format.json {\n render json: {status:0, msg:\"success\"} \n }\n else\n \tformat.json { \n render json: {status:-1, msg:\"failed\"} \n }\n end\n end\n end",
"def create\n @radio = Radio.find(params[:radio_id])\n comment = @radio.comments.create({:body => params[:comment], :user_id => current_user.id});\n respond_to do |format|\n format.json { render :json => to_commentDTO(comment), :status => :ok }\n end\n end",
"def create\n @comment = Comment.new(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to comments_url, 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 session = UserSession.find_by_authentication_token(params[:authentication_token])\n user = session.user\n \n respond_to do |format|\n if user\n @comment = Comment.new(:user_id => user.id, :recipe_id => params[:recipe_id], :text => params[:text])\n \n if @comment.save\n recipe = Recipe.find_by_id([params[:recipe_id]])\n\n @comments = recipe.fetch_comments\n format.json { render :json => { :comments => @comments, :message => \"success\"} }\n else\n format.json { render :status => 500, :json => { :message => \"There was an error uploading your comment.\" }}\n end\n else\n format.json { render :json => { :message => \"Invalid authentication token\"}} \n end\n end\n end",
"def create\n @comment = Comment.new(post_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to root_path, notice: 'Post was successfully created.' }\n format.json { render root_path, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.find(params[:post_id])\n @comment = @post.comments.build(params[:comment])\n respond_to do |format|\n if @comment.save\n format.json { render :json => @comment }\n else\n format.json { render :json => @comment.errors, :status => :unprocessable_entity}\n end\n end\n #respond_with(@post,@post.comments.create(params[:comment]))\n end",
"def comments\n client.get(\"/#{id}/comments\")\n end",
"def create\n \tnew_comment = params.require(:comment).permit(:body)\n \tpost = Post.find(params[:post_id])\n \tcomment = post.comments.create(new_comment)\n\n \tredirect_to post_comment_path(post, comment)\n end",
"def create\n @comment = @secret.comments.build(comment_params)\n @comment.user_id = current_user.id.to_s\n if @comment.save\n comment = CommentModel.new(@comment, current_user)\n render json: comment\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n @comment.user_id = @current_user.json_hash[:id]\n @comment.dinner_id = params[:id]\n if @comment.valid?\n @comment.save\n render json: @comment.comment_info\n else\n puts @comment.errors.messages.inspect\n render status: :bad_request, json: {\n errors: @comment.errors.messages\n }\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n @comment.user = current_user\n if @comment.save\n render json: @comment\n # redirect_to recipe_path(@comment.recipe.id, @comment)\n else\n render \"recipes/show\"\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.create(content: params[:content])\n current_user.comments << @comment\n current_user.save\n\n idea = Idea.find(params[:ideaId])\n idea.comments << @comment\n idea.comments.order(\"created_at DESC\")\n idea.save\n respond_to do |format|\n format.json {render json: @comment}\n end\n end",
"def create\n @comment = Comment.new(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to admin_comments_url, 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 = current_user.comments.build(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to \"/posts/#{@comment.post_id}\" }\n format.json { render :show, status: :created, location: @comment }\n else\n errors = @comment.errors.full_messages.join('! ')\n format.html { redirect_to \"/posts/#{@comment.post_id}\", alert: \"Comment was failly created!\\n#{errors}!\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n\n\n end",
"def create\n @comment = @parent.comments.new(params[:comment])\n @comment.user_id = session[:user_id]\n\n respond_to do |format|\n if @comment.save\n @comment.update_post\n format.html { redirect_to post_path(@comment.post), 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(comment_params)\n\n respond_to do |format|\n if @comment.save\n post_comment(@comment)\n format.html { redirect_to @comment.article, notice: 'Comment was successfully created.' }\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 create\n @comment = Comment.new(\n name: params[:name],\n content: params[:content],\n post: Post.find(params[:post_id])\n )\n # @comment = Comment.new(comment_params)\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment.post, notice: \"comment was created.\" }\n else\n puts @comment.errors\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 create\n #@comment = Comment.new(comment_params)\n @comment = @blog.comments.new(comment_params)\n \n if @comment.save\n render json: @comment, status: :created\n else\n render json: {\n error: @comment.errors.full_messages\n }, status: :unprocessable_entity\n end\n end",
"def create\n @comment = @post.comments.build(comment_params)\n @comment.user_id = current_user.id\n @comment.post_id = @post.id\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @post, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_comments\n end",
"def create_comments\n end",
"def create_comments\n end",
"def create\n @comment = Comment.new(comment_params)\n @post = Post.find(@comment.post_id)\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @post, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new\n @comment.content = params[:content]\n @comment.post_id = params[:post_id]\n @comment.user_id = current_user.id\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to root_path, notice: \"Comment was successfully created.\" }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { redirect_to root_path, notice: \"Por favor añada contenido a su comentario.\" }\n end\n end\n end",
"def create\n comment = Comment.new(params[:comment])\n @entry.comments << comment if comment.valid?\n respond_with(comment, location: redirect_to_index)\n end",
"def create\n\n \t\t\t@comment = Comment.new comment_params\n\n @comment.user_id = current_user.id\n\n \t\t\tif @comment.save\n\n \t\t\t\trender json: @comment,status: :created\n\n \t\t\telse\n\n \t\t\t\trender json: {error: true,errors: @comment.errors},status: :unprocessable_entity\n\n \t\t\tend\n\n \t\tend",
"def show\n @new_comment = Comment.build_from(@post, \"\")\n\n render json: @post, status: 200\n\n\n end",
"def create\n if params.present?\n Comment.create(name: params[:author], description: params[:text], rating: params[:rating])\n end\n render json: {success: \"Sucessfully Commented\"}\n end",
"def create_comment\n unless user_signed_in?\n render status: 403, json: { message: 'Please sign in to add a comment.' }\n end\n\n comment_params = params.permit(:content, :id)\n new_comment = Comment.create!(\n content: comment_params.require(:content),\n post_id: comment_params.require(:id),\n user_id: current_user.id\n )\n render status: :created, json: new_comment\n end",
"def create\n @comment = Comment.new(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment.generic_item, :notice => t('notice.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\r\n\t\t#create new comment\r\n\t\t@comment = Comment.new(comment_params)\r\n\t\tif @comment.save\r\n\t\t\t#if save success send js handles the rest\r\n\t\t\t@post = @comment.post\r\n\t\t\trespond_to :js\r\n\t\telse\r\n\t\t\t# if fails alert user\r\n\t\t\tflash[:alert] = \"Something went wrong\"\r\n\t\tend\r\n\tend",
"def create\n @comment = Comment.new(params[:comment])\n @posts = Post.find_all_by_id(@comment.post_id)\n @comment.user_id = session[:user_logged_in]\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @posts, 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]) #has a hash called comment, passes initial values\n\n respond_to do |format|\n if @comment.save # Goes in here and saves it to the DB\n format.html { redirect_to @comment, 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 :authenticate_user!\n @comment = Comment.create!(comment_params)\n respond_with @comment\n end",
"def create\n @comment = current_user.comments.build(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment, 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 = @repository.comments.new(params.require(:comment).permit(:body))\n @comment.author = current_user\n authorize @comment\n\n if @comment.save\n respond_with(@comment)\n else\n respond_with @comment.errors, status: :unprocessable_entity\n end\n end",
"def create\n @comment = @idea.comments.build(comment_params)\n @comment.user = current_user\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @idea, notice: 'Your comment has been recorded' }\n format.json { render action: 'show', status: :created, comment: @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_comment(comment)\n post_params = {\n :body => comment.post_json,\n :headers => Logan::Client.headers.merge({'Content-Type' => 'application/json'})\n }\n\n response = Logan::Client.post \"/projects/#{@project_id}/todos/#{@id}/comments.json\", post_params\n Logan::Comment.new response\n end",
"def comment_params\n if request.format.json?\n return params.permit(:post_id, :body)\n end\n params.require(:comment).permit(:user_id, :post_id, :body)\n end",
"def create\n @post = Post.find(params[:post_id])\n @comment = @post.comments.create(params[:comment])\n @comment.researcher = logged_in_researcher\n\n if @comment.save\n respond_to do |format|\n format.html { redirect_to post_path(@post), :notice => \"Comment was successfully added.\" }\n format.xml { render :xml => @comment, :status => :created, :location => @comment}\n format.json { render :json=> @comment, :status => :created, :location => @comment}\n end\n else\n respond_to do |format|\n format.html { redirect_to post_path(@post), :alert => \"Failed to add comment: #{@comment.errors.full_messages.join(', ')}\" }\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n format.json { render :json=> @comment.errors, :status => :unprocessable_entity }\n end \n end\n end",
"def create\n @comment = @question.comments.create(comment_params)\n redirect_to question_path(@question)\n end",
"def post_comment(comment, poi=\"4f4f4c27d4374e800100001d\")\n uri = URI.parse(\"http://mashweb.fokus.fraunhofer.de:3008/api/comment\")\n response = Net::HTTP.post_form(uri, {\n :title => 'Autocomment',\n :body => comment\n })\n end",
"def create\n @comment = Comment.new(params[:comment])\n\t\t@comment.user_id = session[:userid]\n @comment.save\n\t\trespond_with @comment, :location => @comment.post\n end",
"def create\n @comment = @issue.comments.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @issue_path, notice: 'Comment is succesfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@comment = Comment.new()\n\t\t@comment.comment = params[:comment] \n\t\t@comment.user = current_user\n\t\t@comment.save\n\t\t\n\t\t@resource_comment = ResourceComment.new()\n\t\t@resource_comment.resource_path = params[:path]\n\t\t@resource_comment.comment_id = @comment.id\n\t\t@resource_comment.save\n\t\tif(@resource_comment)\n\t\t\trespond_with(@comment)\n\t\telse\n\t\t\trender json: {error: \"something went wrong while creating resource comment\"}\n\t\tend\n end",
"def create\n comment = Comment.new(params[:comment])\n @articles_comments_service.create_comment(comment)\n end",
"def create\n @user = User.find(params[:user_id])\n @comment = @user.comments.build(params[:comment])\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to user_path(@user.id), notice: 'Your comment has been submitted' }\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_node = CommentNode.new(params[:comment_node])\n\n respond_to do |format|\n if @comment_node.save\n format.html { redirect_to @comment_node, :notice => 'Comment node was successfully created.' }\n format.json { render :json => @comment_node, :status => :created, :location => @comment_node }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @comment_node.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = current_user.comments.new(comment_params)\n @comment.post_id = params['post_id']\n # @comment.parent_id = params[:parent_id]\n\n respond_to do |format|\n if @comment.save\n flash[:notice] = t('comment.create_success_mesg')\n @post = Post.find(params['post_id'])\n @all_comments = @post.comments.paginate(page: params[:page])\n format.html\n format.json { render :show, status: :created, location: @comment }\n format.js\n else\n flash[:notice] = t('comment.create_unsuccessful_msg')\n format.html\n format.json {\n render json: @comment.errors, status: :unprocessable_entity\n }\n format.js \n end\n end\n end",
"def create\n @post = Post.find(params[:post_id])\n @comment = @post.comments.create(comment_params)\n redirect_to post_path(@post)\n end",
"def post_comment(request)\n data, _status_code, _headers = post_comment_with_http_info(request)\n request_token if _status_code == 401\n data\n end",
"def comment #create comment\n comment = Comment.new\n if comment.create_comment(params[:body], params[:video_id])#calling create_comment method of Comment model\n respond_with do |format|\n format.json {render :json => {:success => true, :message => \"comment successfully posted\"}}\n end\n else\n respond_with do |format|\n format.json {render :json => {:success => false}}\n end\n end\n end",
"def index\n post = Post.find(params[:post_id])\n comments = post.comments.order(updated_at: :desc)\n @comment = Comment.new\n\n @comments = comments.map do |comment|\n {\n content: comment.content,\n created_at: comment.created_at.strftime('%Y-%m-%d %H:%M:%S')\n }\n end\n\n render json: {\n data: {\n comments: @comments,\n new_comment: @comment,\n }\n }\n end",
"def new_comment(name, discussion_id)\n response = self.class.post(\n @@base_uri + @@comments_uri,\n body: {\"comment\":{\"body\":name,\"discussion_id\":discussion_id,\"document_ids\":[]}}.to_json,\n headers: @headers\n )\n return response\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 create\n @post = Post.find(params[:post_id])\n @comment = @post.comments.create!(comment_params)\n\n redirect_to post_path(@post)\n end",
"def create\n @comment = Comment.new(comment_params)\n @comment.save\n end",
"def create\n @comment = @post.comments.build(params[:comment])\n \n respond_to do |format|\n if @comment.save\n flash[:notice] = 'Post was successfully created.'\n format.html { redirect_to(posts_url) }\n format.xml { render :xml => @comment, :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 update\n user = User.find_by({token: env['HTTP_TOKEN']})\n comment = user.comments.find(params[:id])\n comment.update(comment_params)\n render json: comment\n end",
"def comments\n @article = Article.find(params[:id])\n @comments = @article.comments\n\n respond_to do |format|\n format.html \n format.json { render json: @comments, status: :ok }\n end\n end",
"def add\n @comment = Comment.new(params[:comment])\n\n respond_to do |format|\n if @comment.save\n # format.html { redirect_to comments_url, 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 @task_comment = Task::Comment.new(task_comment_params)\n\n respond_to do |format|\n if @task_comment.save\n format.html { redirect_to @task_comment, notice: \"Comment was successfully created.\" }\n format.json { render :show, status: :created, location: @task_comment }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @task_comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.find(params[:post_id])\n @comment = @post.comments.new(comment_params)\n @comment.user_id = current_user.id\n @comment.save\n\n respond_to do |format|\n format.js\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment.article, notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { render :new }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @article.comments << Comment.new(comment_params)\n\n respond_to do |format|\n if @article.save\n format.html { redirect_to article_show_path(@article), notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @article }\n else\n format.html { render :new }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @commentable = find_commentable\n @comment = @commentable.comments.build(params[:comment]) do |comment|\n comment.access = current_access\n end\n if @comment.save\n flash.now[:notice] = t('comment.added')\n Rails.logger.info @comment.inspect\n @counter = @commentable.comments.count\n respond_with @comment\n else\n Rails.logger.info @comment.errors.messages\n flash.now[:error] = t('comment.added.error')\n end\n end",
"def create\n \t# collects nested attributes, for post & comment, from params\n new_post = params.require(:post).permit(:body, :link, comments_attributes: [:body])\n\n \tpost = Post.create(new_post)\n \tredirect_to post_path(post.id)\n end",
"def comment_creation_params\n params.require(:comment).permit(:cardset_id, :card_id, :user_id, :user_name, :posttime, :body, :status)\n end",
"def new\n @comment = @commentable.comments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def create \n @comment = @post.comments.new(params[:comment])\n @comment.user_id = current_user.id\n respond_to do |format|\n if @comment.save\n format.js { \n flash[:notice] = 'Comment was successfully created.' \n }\n else\n format.js { \n flash[:error] = @comment.errors.full_messages.join('<br/>')\n }\n end\n end\n @comments = @post.comments.created_at_order\n end",
"def create_comment\n @user = User.find(params[:user_id])\n @message = Message.find(params[:message_id])\n @comment = @message.comments.create(params.permit(:content))\n @comment.user = @user\n @comment.user_name = @user.id\n @comment.user_avatar = @user.id\n\n if @comment.save\n response = { \"code\" => 1, \"msg\" => \"Comment Created Successfully\" }\n else\n response = { \"code\" => 0, \"msg\" => \"Comment Can't be created\" }\n end\n\n render json: response\n end",
"def add_new_comment\n\t# Get the object that you want to comment\n\tcommentable = Post.find(params[:id])\n\n\t# Create a comment with the user submitted content\n\tcomment = Comment.new(comment_params)\n\t# Add the comment\n\tcommentable.comments << comment\n\t@comments = commentable.comments\n respond_to do |format|\n\t format.html { redirect_to root_path }\n\t format.js\n\tend\n end",
"def create\n @post = Post.find params[:id]\n @comment = @post.comments.create comment_params\n @comment.user_id = current_user.id\n\n if @comment.save\n redirect_to \"/post/\" + params[:id]\n else\n flash[:danger] = \"No success\"\n redirect_to \"/\"\n end\n end",
"def create\n @comment = @parent.comments.build(comment_params_with_user)\n authorize @comment\n\n if @comment.save\n CommentCreatedMailJob.perform_later(@comment)\n render json: @comment, serializer: CommentSerializer, status: :created\n else\n render_error :unprocessable_entity, @comment.errors\n end\n end",
"def comment_params\n params.require(:comment).permit(:body, :request_id)\n end",
"def create\n @comment = @secret.comments.build(comment_params)\n @comment.user_id = @user.id\n respond_to do |format|\n if @comment.save\n format.html { redirect_to [@user, @secret], notice: 'Secret was successfully created.' }\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 create\n @submission = Submission.find(params[:submission_id])\n @scomment = @submission.comments.build(comment_params)\n if @scomment.save\n render json: @scomment.as_json(except: [:updated_at]), status: :created\n else\n render json: @scomment.errors, status: :unprocessable_entity\n end\n #@comment.user = current_user\n\n #respond_to do |format|\n # if comment_params[:title].present? && comment_params[:body].present?\n # if @comment.save\n # format.html { redirect_to @submission, notice: 'Comment was successfully created.' }\n # #format.json { render :show, status: :created, location: @comment }\n # else\n # format.html { render :new }\n # #format.json { render json: @comment.errors, status: :unprocessable_entity }\n # end\n # else\n # format.html { redirect_to @submission, notice: 'Debe llenar los campos.' }\n # end\n #end\n end"
] | [
"0.7513323",
"0.7423756",
"0.7375538",
"0.72369885",
"0.72065747",
"0.70876884",
"0.7068213",
"0.7055196",
"0.7050029",
"0.6991239",
"0.69830215",
"0.69673634",
"0.69590974",
"0.6911419",
"0.6910673",
"0.6874636",
"0.687359",
"0.6824285",
"0.6813097",
"0.6789313",
"0.67860657",
"0.6763718",
"0.67238677",
"0.67197055",
"0.67140144",
"0.67043275",
"0.66832227",
"0.6672003",
"0.6667767",
"0.6651656",
"0.66488475",
"0.66451526",
"0.66451526",
"0.66451526",
"0.66451526",
"0.66209877",
"0.6608888",
"0.6591759",
"0.6586176",
"0.65818197",
"0.6577647",
"0.65651274",
"0.6553228",
"0.655173",
"0.655173",
"0.655173",
"0.65389335",
"0.6538368",
"0.65361595",
"0.6514428",
"0.6497118",
"0.6493406",
"0.6491472",
"0.64800125",
"0.6473095",
"0.6459762",
"0.6431631",
"0.64248",
"0.6417662",
"0.6400027",
"0.63980633",
"0.6388188",
"0.638604",
"0.6385191",
"0.6383738",
"0.63756245",
"0.63722587",
"0.6370667",
"0.63660914",
"0.6363395",
"0.63301545",
"0.6323072",
"0.63229525",
"0.6301043",
"0.62955076",
"0.6293081",
"0.6286732",
"0.6284625",
"0.6279098",
"0.6275098",
"0.62699413",
"0.6265843",
"0.6262213",
"0.6254964",
"0.6249603",
"0.62479144",
"0.6247775",
"0.6246232",
"0.62417716",
"0.6234337",
"0.62341875",
"0.62341547",
"0.62299824",
"0.6225405",
"0.622521",
"0.62234855",
"0.6212677",
"0.62102187",
"0.6208082",
"0.6200627",
"0.61996573"
] | 0.0 | -1 |
PATCH/PUT /comments/1 PATCH/PUT /comments/1.json DELETE /comments/1 DELETE /comments/1.json | def destroy
@comment = Comment.find(params[:id])
@comment.destroy
respond_to do |format|
format.html { redirect_to comments_url, notice: 'Comment was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_comments\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete_comment1\n params[:comment].each { |key, value|\n comment=Comment.find(key)\n if !comment.nil?\n k comment.destroy\n end\n }\n redirect_to requirements_path\n end",
"def destroy\n @comment1 = Comment1.find(params[:id])\n @comment1.destroy\n\n respond_to do |format|\n format.html { redirect_to comment1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = @commentable.comments.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def update\n json_update_and_sanitize(comment, comment_params, Comment)\n end",
"def update_comment\n if params[:commit]==\"Save\"\n params[:comment].each { |key, value|\n comment=Comment.find(:all, :conditions=>[\"id=?\", key])\n if !comment.empty?\n comment[0].update_attributes(:title=>value)\n end\n }\n elsif params[:commit]==\"Cancel\"\n params[:comment].each { |key, value|\n comment=Comment.find(key)\n if !comment.nil?\n comment.destroy\n end\n }\n end\n redirect_to requirements_path\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n# @comment.delete_empty_notes\n @comment.set_flag(params[:flag])\n format.html { redirect_to homework_comments_url(), notice: 'Comment was successfully updated.' }\n format.js {render :index}\n format.json { render :show, status: :ok, location: @comment }\n else\n format.html { render :edit }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n comment = Comment.find(params[:id])\n if current_user.id == comment.user_id\n post = comment.post\n post.data['comments'] = post.data['comments'] - 1\n if comment.destroy && post.save\n render json: {status: \"success\", data: {id: Integer(params[:id]), comments: post.data['comments']}}, status: :ok\n else\n render json: {status: \"failure\", data: nil}, status: 404\n end\n\n else\n render json: {status: \"failure\", data: nil}, status: 404\n end\n end",
"def update\n user = User.find_by({token: env['HTTP_TOKEN']})\n comment = user.comments.find(params[:id])\n comment.update(comment_params)\n render json: comment\n end",
"def destroy\n\n @comment.destroy\n render json: @comment, status: :ok\n\n end",
"def destroy\n if @commentable.comments.find(params[:id]).destroy\n render json: { success: true }\n end\n end",
"def destroy\n @user = UserSession.user_by_authentication_token(params[:authentication_token])\n @recipe = Recipe.find_by_id(params[:recipe_id])\n\n @comment = Comment.find_by_id(params[:id])\n\n respond_to do |format|\n if @comment.user == @user and @recipe\n @comment.destroy\n @comments = @recipe.fetch_comments\n format.json { render :json => { :comments => @comments, :message => \"success\" }}\n else\n format.json { render :json => { :message => \"failure\"}}\n end \n end\n end",
"def update\n @comment = Comment.find(params[:id])\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.json { render :json => @comment }\n else\n format.json { render :json => @comment.errors, :status => :unprocessable_entity}\n end\n end\n #respond_with(@post,@post.comments.update(params[:id],params[:comment]))\n end",
"def destroy\n\n if @comment.destroy\n\n render json: {comment: {id: params[:id].to_i}},status: :ok\n\n else\n\n render json: {error: true,errors: @comment.errors},status: :unprocessable_entity\n\n end\n\n \t\tend",
"def destroy\n @comments = Comment.where(question_id: @question.id)\n @comments.each do |comment|\n comment.destroy\n end\n @question.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n \n respond_to do |format|\n format.xml { head :ok }\n format.json { head :ok } \n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment1.destroy\n respond_to do |format|\n format.html { redirect_to comment1s_url, notice: 'Comment1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:comment_id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n render json:@comment\n end",
"def update\n if @comment.update(comment_params)\n head :no_content\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @comment.update(comment_params)\n head :no_content\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to project_sprint_user_story_comments_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @comment.nil?\n render json: {error: \"Not found\"}, status: :not_found\n else\n @comment.destroy\n render json: @comment, status: :ok\n\n end\n end",
"def delete_comment user\n edit_comment user, nil\n end",
"def update\n\n if @comment.update(comment_params)\n render json: @comment, status: :ok\n else\n render json: @comment.errors, status: :unprocessable_entity\n\n end\n\n\n end",
"def destroy\n @comment_complaint.destroy\n respond_to do |format|\n format.html { redirect_to comment_complaints_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n unless @comment.present?\n @comment.destroy\n end\n\n respond_to do |format|\n format.html { redirect_to admin_comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find_by(id: params[:id])\n @user = @comment.user\n\n return false unless authorized_user?(@user.id)\n\n if @comment.destroy\n render 'api/comments/destroy.json.jbuilder'\n else\n render json: @comment.errors.full_messages, status: 422\n end\n\n end",
"def update\n @comment = Comment.find(params[:comment_id])\n @comment.update(comment_params)\n render json: @comment\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def update\n #respond_to do |format|\n if @comment.update(comment_params)\n render json: @comment.as_json(except: [:updated_at]), status: :ok\n else\n # format.html { render :edit }\n render json: @comment.errors, status: :unprocessable_entity\n # end\n end\n end",
"def destroy\n @comment = @repository.comments.find(params[:id])\n authorize @comment\n @comment.destroy\n respond_with @comment\n end",
"def comments\n client.get(\"/#{id}/comments\")\n end",
"def update\n comment = Comment.find(params[:id])\n if comment.update(params_comment)\n render json: comment, status: 200\n else\n render json: comment.errors, status: 422\n end\n\n end",
"def comment_aux(action, opts)\n\n unless action == \"destroy\"\n\n data = LibXML::XML::Parser.string(request.raw_post).parse\n\n comment = parse_element(data, :text, '/comment/comment')\n subject = parse_element(data, :resource, '/comment/subject')\n end\n\n # Obtain object\n\n case action\n when 'create';\n return rest_response(401, :reason => \"Not authorised to create a comment\") unless Authorization.check('create', Comment, opts[:user], subject)\n\n ob = Comment.new(:user => opts[:user])\n when 'view', 'edit', 'destroy';\n ob, error = obtain_rest_resource('Comment', opts[:query]['id'], opts[:query]['version'], opts[:user], action)\n else\n raise \"Invalid action '#{action}'\"\n end\n\n return error if ob.nil? # appropriate rest response already given\n\n if action == \"destroy\"\n\n ob.destroy\n\n else\n\n ob.comment = comment if comment\n\n if subject\n return rest_response(400, :reason => \"Specified resource does not support comments\") unless [Blob, Network, Pack, Workflow].include?(subject.class)\n return rest_response(401, :reason => \"Not authorised to add a comment to the specified resource\") unless Authorization.check(action, Comment, opts[:user], subject)\n ob.commentable = subject\n end\n\n # Start of curation hack\n\n def match_tag_name(name)\n\n name.sub!(/^c:/, '')\n\n matches = []\n\n Conf.curation_types.each do |type|\n matches.push type if type.starts_with?(name)\n end\n\n return matches[0] if matches.length == 1\n end\n\n if comment[0..1].downcase == 'c:' && opts[:user] && subject &&\n Conf.curators.include?(opts[:user].username)\n\n comment = comment[2..-1].strip\n\n lines = comment.split(\"\\n\")\n events = []\n failed = false\n\n lines.each do |line|\n\n line.strip!\n\n bits = line.split(\";\")\n\n if bits.length > 1\n details = bits[1..-1].join(\";\")\n else\n details = nil\n end\n\n if bits.length > 0\n bits[0].split(\",\").each do |bit|\n\n bit.downcase!\n bit.strip!\n\n curation_type = match_tag_name(bit)\n\n if curation_type\n events.push(CurationEvent.new(:category => curation_type,\n :object => subject, :user => opts[:user], :details => details))\n else\n failed = true\n end\n end\n end\n end\n\n if failed\n return rest_response(400, :reason => 'Unrecognised curation term')\n end\n\n events.each do |event|\n event.save\n end\n\n subject.solr_index\n\n return rest_get_request(ob, opts[:user], { \"id\" => ob.id.to_s })\n end\n\n # End of curation hack\n\n success = ob.save\n\n if success\n case action\n when \"create\"; Activity.create(:subject => opts[:user], :action => 'create', :objekt => ob)\n when \"edit\"; Activity.create(:subject => opts[:user], :action => 'edit', :objekt => ob)\n end\n end\n\n return rest_response(400, :object => ob) unless success\n end\n\n rest_get_request(ob, opts[:user], { \"id\" => ob.id.to_s })\nend",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n respond_with(@post, @comment)\n end",
"def destroy\n comment_status = @comment.comment_status\n respond_to do |format|\n if !@comment.destroy\n format.json { render :json=>report_error(@comment)}\n format.html { redirect_to @comment, :alert => 'Failure deleting comment.' }\n else\n format.json { render :json=>{}}\n end\n end\n end",
"def destroy\r\n @comment = Comment.find(obfuscate_decrypt(params[:id], session))\r\n\t\t@commentable = @comment.commentable\r\n @comment.comment_options.each do |co|\r\n co.destroy\r\n end\r\n\t\t@comment.destroy\r\n\r\n\t\trespond_to do |format|\r\n @comment_option_lookups = CommentOptionLookup.order\r\n\t\t\tformat.html { redirect_to :back }\r\n\t\t\tformat.json { head :ok }\r\n\t\t\tformat.js\r\n\t\tend\r\n\tend",
"def update\n @comment = Comment.find(params[:id])\n authorize @comment\n if @comment.update(comment_params)\n render 'api/v1/comments/show', status: :success\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def destroy\n puts \"Inside destroy. Comment id is \"+params[:id].to_s\n #puts \"Post id is \"+params[:postid].to_s\n @comment = Comment.find(params[:id])\n @comment.destroy\n @posts = Post.find_by_id(params[:postid])\n\n respond_to do |format|\n format.html { redirect_to @posts }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to post_path(@comment.post) }\n format.json { head :no_content }\n end\n end",
"def update\n authorize [:api, :v1, @requesting_object]\n ticket = ServiceTicket.where(\n client_key: params['avatar_key'],\n id: params['id']\n ).first\n if params['comment_text']\n ticket.comments << Comment.new(author: params['avatar_name'],\n text: params['comment_text'])\n end\n ticket.update(status: params['status']) if params['status']\n render json: { message: 'OK' }, status: :ok\n end",
"def update\n @comment = Comment.find(params[:id])\n @comment.user_id = params[:user_id]\n @comment.announcement_id = params[:announcement_id]\n @comment.description = params[:description]\n @comment.save\n render json:@comment\n end",
"def destroy\n @comment10.destroy\n respond_to do |format|\n format.html { redirect_to comment10s_url, notice: 'Comment10 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n \t@comment.in_recycling = true\n \n if (can? :delete, @comment)\n \tif @comment.save\n \t\trespond_to do |format|\n \t\t format.html { redirect_to it_category_content_url(@comment.content.category.it, \n \t\t @comment.content.category, @comment.content) }\n \t\t format.json { head :ok }\n \t\tend\n \tend\n \tend\n end",
"def update\n if @comment.update(comment_params)\n render json: @comment, status: :ok\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def bulk_delete_comments\n comment_ids_string = params[:ids]\n comment_ids = eval(comment_ids_string)\n\n comment_ids.each do |id|\n comment = Comment.find(id.to_i)\n if !comment.nil?\n comment.destroy\n\n end\n\n end\n\n head :no_content\n\n end",
"def update\n respond_to do |format|\n if @comment1.update(comment1_params)\n format.html { redirect_to @comment1, notice: 'Comment1 was successfully updated.' }\n format.json { render :show, status: :ok, location: @comment1 }\n else\n format.html { render :edit }\n format.json { render json: @comment1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @comment6.destroy\n respond_to do |format|\n format.html { redirect_to comment6s_url, notice: 'Comment6 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def rm_update path, data, msg\n\n re = rm_request path, data, 'PUT'\n puts re.body\n chk (re.code!='200'), msg + \"\\n#{re.code} #{re.msg}\\n\\n\"\n return true\n\nend",
"def destroy\n @dish_comment = @dish.dish_comments.find(params[:id])\n @dish_comment.destroy\n\n respond_to do |format|\n format.html { redirect_to dish_comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t@post = Post.find(@comment.post_id)\n\n @comment.destroy\n\t@post.update_attribute(:nComments, @post.comments.count)\n respond_to do |format|\n format.html { redirect_to @comment.post, notice: 'Comment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @doi.updates.each do |update|\n update.destroy\n end\n @doi.comments.each do |comment|\n comment.destroy\n end\n @doi.destroy\n respond_to do |format|\n format.html { redirect_to dois_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n redirect_to \"/home/index\"\n #@comment = Comment.find(params[:id])\n #respond_to do |format|\n #format.html { redirect_to comments_url }\n #format.json { head :ok }\n #end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to homework_comments_url, notice: 'Comment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@comment = current_user.\n\t\t\tprojects.find(params[:project_id]).\n\t\t\ttasks.find(params[:task_id]).\n\t\t\tcomments.find(params[:id]).destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to post_url(@comment.post_id) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to_commentable(@comment, false) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @talk_comment = TalkComment.find(params[:id])\n @talk_comment.destroy\n\n respond_to do |format|\n format.html { redirect_to talk_comments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n head :no_content\n end",
"def destroy\n @comment.destroy\n head :no_content\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 update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { render :json => {:comment => @comment, :status => 200} }\n else\n format.html { render :edit }\n format.json { render :json => {:comment => @comment, :status => 400 } }\n end\n end\n end",
"def update\n @comment1 = Comment1.find(params[:id])\n\n respond_to do |format|\n if @comment1.update_attributes(params[:comment1])\n format.html { redirect_to @comment1, notice: 'Comment1 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comment1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n comment = Comment.find(params[:id])\n if comment.destroy\n render json: {destroyed: true}\n end\n end",
"def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.xml { head :ok }\n format.json { head :ok } \n else\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n format.json { render :json => @comment.errors, :status => :unprocessable_entity } \n end\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to post_comments_url, notice: \"Comment was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def refresh!\n body = get(\"/comments/#{id}.json\").body\n @comments = client.object_from_body(body[1])\n deep_merge!(body[0])\n end",
"def destroy\n @comment = @posting.comments.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n #@comment.create_activity :destroy, owner: current_user\n format.html { redirect_to root_url }\n format.json { head :no_content }\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 respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to polymorphic_path([@section, @commentable, :comments]), notice: 'Comment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(comments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_comments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n\t\trespond_with @comment, :location => @comment.post\n end"
] | [
"0.6488403",
"0.6398444",
"0.63851017",
"0.6352142",
"0.6344028",
"0.6324272",
"0.63089526",
"0.630499",
"0.6295087",
"0.6268955",
"0.6251883",
"0.62483746",
"0.62459433",
"0.6244871",
"0.6228032",
"0.61714435",
"0.61684746",
"0.6163004",
"0.6163004",
"0.6163004",
"0.6140432",
"0.61383927",
"0.6134477",
"0.6134477",
"0.6134477",
"0.61214393",
"0.61193645",
"0.61189896",
"0.61189896",
"0.6117681",
"0.61095345",
"0.61075467",
"0.61075467",
"0.61075467",
"0.61075467",
"0.61075467",
"0.61075467",
"0.61075467",
"0.61075467",
"0.61075467",
"0.61075467",
"0.61075467",
"0.61075467",
"0.61075467",
"0.61075467",
"0.61075467",
"0.60970515",
"0.60765886",
"0.6072615",
"0.60643953",
"0.6055877",
"0.60334915",
"0.6028906",
"0.6019136",
"0.60054463",
"0.60043806",
"0.6002646",
"0.5995679",
"0.598489",
"0.5977592",
"0.59755355",
"0.5961973",
"0.5957327",
"0.59432185",
"0.59373707",
"0.59357166",
"0.593503",
"0.59336364",
"0.59290695",
"0.5928442",
"0.5916971",
"0.591416",
"0.5911998",
"0.59106505",
"0.5909585",
"0.59042394",
"0.5899127",
"0.58975196",
"0.5890858",
"0.58901834",
"0.5886194",
"0.5884657",
"0.5879479",
"0.5875773",
"0.5875773",
"0.5875565",
"0.58688015",
"0.5867246",
"0.5866278",
"0.58632857",
"0.586268",
"0.58601075",
"0.585777",
"0.58575547",
"0.5853307",
"0.5853307",
"0.5853307",
"0.585317",
"0.58531564",
"0.58519214",
"0.585007"
] | 0.0 | -1 |
Use callbacks to share common setup or constraints between action Never trust parameters from the scary internet, only allow the white list through. | def comment_params
params.require(:comment).permit(:body, :parent_id, :user_id, :idea_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_setup; end",
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def before_action \n end",
"def before_setup\n # do nothing by default\n end",
"def before_filter; 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 pre_validation\n\n end",
"def before_run; end",
"def _before_validation\n end",
"def pre_validation\n\n\n end",
"def before_bootstrap\n end",
"def before_bootstrap; end",
"def before_validation_callback\n end",
"def form_setup\n\tend",
"def setup\n # override this if needed\n end",
"def action_hook; 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 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 setup\n\t\t# Do nothing\n\tend",
"def setup\n\t\t# Do nothing\n\tend",
"def expected_permitted_parameter_names; end",
"def before_request\n end",
"def pre_authorize_cb; end",
"def setup_controller_for_warden; end",
"def setup\n # override and do something appropriate\n end",
"def pre_authorize_cb=(_arg0); end",
"def before_players_ready\r\n end",
"def configure_permitted_parameters\n\t\t[:sign_up, :account_update].each do |action|\n\t\tdevise_parameter_sanitizer.for(action).push(:admin)\n\t\tend\n\tend",
"def on_before_load\n end",
"def after_view_setup\n end",
"def configure_permitted_parameters\n # added all the user parameters with email, password and password_confirmation, because this method overrides devise's controller\n \t\tdevise_parameter_sanitizer.permit(:sign_up) {|u| u.permit(:name,:user_name,:email,:password,:password_confirmation, :country, :city,:remote_avatar_url) }\n devise_parameter_sanitizer.permit(:account_update) {|u| u.permit(:remote_avatar_url,:remove_avatar,:avatar, :name,:user_name,:email,:password,:password_confirmation,:current_password, :country, :city) }\n #devise_parameter_sanitizer.for(:sign_up) << :name\n #devise_parameter_sanitizer.for(:sign_up) << :user_name\n #devise_parameter_sanitizer.for(:sign_up) << :country\n #devise_parameter_sanitizer.for(:sign_up) << :city\n\n\n #devise_parameter_sanitizer.for(:account_update) << :name\n\n #devise_parameter_sanitizer.for(:account_update) {|u| u.permit(:user_name, :name, :email, :country, :city)}\n\tend",
"def post_setup\n end",
"def allow_params_authentication!; end",
"def my_action_params\n params.require(:my_action).permit(:name, :url, :active, :provider_id)\n end",
"def initialize_before_opts\n end",
"def on_pre_request( request ); end",
"def setup_params\n params.require(:setup).permit(:tab_id, :jamma, :kick_harness, :button_layout, :region, :position)\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:dealer_code,\n :password,\n :password_confirmation,\n :remember_me) }\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:dealer_code,\n :password,\n :remember_me) }\n end",
"def setup\n\t\tend",
"def setup\n\t\tend",
"def on_pre_request( request )\n end",
"def before_resolution\n end",
"def handle_unverified_request\n unless action_name == \"fire_object_search\" || action_name == \"fire_populate_drop_down\" \n super\n end\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) << [:name, :terms_and_conditions]\n devise_parameter_sanitizer.for(:account_update) << :name\n\n return unless user_signed_in?\n\n # Confirmed users cannot update their email address\n devise_parameter_sanitizer.for(:account_update).delete(:email) if current_user.confirmed_at?\n end",
"def prepare_for_action\n # #don't save stuff between requests\n NotRelational::RepositoryFactory.instance.clear_session_cache\n @@page_blurbs =Set.new\n @renderer_params={}\n $current_weblab=nil\n @current_user=nil\n @displayed_blurb_names=Set.new\n # if BannedIp.is_banned?(request.remote_ip)\n # head(401)\n # return\n # end\n\n prepare_language_for_action\n prepare_powerbar_for_action\n prepare_rendermode_for_action\n prepare_weblab_for_action\n\n\n self.page_title=\"Rengine\"\n self.no_wrap=false\n return true\n end",
"def define_action_hook; 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 before_dispatch(env); end",
"def action_enable\n end",
"def setup(_context)\n end",
"def min_up_members_action\n super\n end",
"def before\n end",
"def determine_valid_action\n\n end",
"def prepare\n remember_remember_me\n remember_signup_flow_type\n remember_signup_flow_origin_type\n remember_signup_flow_destination\n remember_signup_flow_network\n redirect_to auth_path(params[:network] || 'facebook')\n end",
"def configure_permitted_parameters\n\t\tadded_attrs = [:first_name, :last_name, :description, :skills, :email, :password, :password_confirmation, :remember_me]\n\t\tdevise_parameter_sanitizer.permit :sign_up, keys: added_attrs\n\t\tdevise_parameter_sanitizer.permit :account_update, keys: added_attrs\n\t\tdevise_parameter_sanitizer.permit :login, keys: added_attrs\n\tend",
"def configure_permitted_parameters\n #sign in\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:username, :email) }\n\n #sign up\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :fname, :lname, :company, :phonecountrycode, :officephone, :mobilephone, :anonymous, :address, :latitude, :longitude, :dealertype, :hospitaltype, :orthopedictype, :imagingcentertype, :drofficetype, :urgenttype, :painmanagementtype, :veterinarytype, :chiropractictype, :podiatrytype, :dentaltype, :email, :password, :password_confirmation) }\n\n #edit user\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :fname, :lname, :company, :phonecountrycode, :officephone, :mobilephone, :anonymous, :address, :latitude, :longitude, :dealertype, :hospitaltype, :orthopedictype, :imagingcentertype, :drofficetype, :urgenttype, :painmanagementtype, :veterinarytype, :chiropractictype, :podiatrytype, :dentaltype, :email, :password, :password_confirmation, :current_password) }\n\n=begin\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(username: [], fname: [],\tlname: [],\tcompany: [],\tphonecountrycode: [],\tofficephone: [],\tmobilephone: [], anonymous: [],\taddress: [], latitude: [], longitude: [], \tdealertype: [], hospitaltype: [], orthopedictype: [], imagingcentertype: [], drofficetype: [], urgenttype: [], painmanagementtype: [], veterinarytype: [], chiropractictype: [], podiatrytype: [], dentaltype: [], :email, :password, :password_confirmation) }\n=end\n\n end",
"def before_perform\n end",
"def configure_permitted_parameters\n extra_keys = [:avatar, :name, :time_zone]\n signup_keys = extra_keys + [:terms_of_service]\n devise_parameter_sanitizer.permit(:sign_up, keys: signup_keys)\n devise_parameter_sanitizer.permit(:account_update, keys: extra_keys)\n devise_parameter_sanitizer.permit(:accept_invitation, keys: extra_keys)\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :password, :fname, :lname, :username, :birthday, :image, :newsletter, :language) }\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:email, :password, :fname, :lname, :username, :birthday, :image, :description, :phoneNumber, :facebook, :twitter, :googlePlus, :newsletter, :language) }\n end",
"def check_params; true; 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 configure_permitted_parameters\n added_attrs = [:email, :password, :password_confirmation, :name, :description, :age, :gender,\n :favorite_movie, :favorite_food, :favorite_song, :job_title, :hobbies, :school, :social_media_link,\n :snap_chat_name, :allow_male, :allow_female, :allow_other]\n devise_parameter_sanitizer.permit :sign_up, keys: added_attrs\n devise_parameter_sanitizer.permit :account_update, keys: added_attrs\n end",
"def default_param_whitelist\n [\"mode\"]\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 configure_permitted_parameters\n\n devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(:name, :email, :phone_number, :password, :remember_me)}\n devise_parameter_sanitizer.permit(:sign_in) { |u| u.permit(:name, :email, :password, :remember_me)}\n devise_parameter_sanitizer.permit(:account_update) { |u| u.permit(:name, :email, :password, :remember_me)}\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:first_name, :surname, :email, :role_id, :job_grade, :line_manager, :admin, :password, :password_confirmation) }\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:first_name, :surname, :email, :password, :remember_me) }\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:first_name, :surname, :email, :role_id, :line_manager, :admin, :password, :password_confirmation, :current_password) }\n\tend",
"def setup()\n setupParamListTable(getConf(:paramList)) ;\n super() ;\n end",
"def after_setup\n # do nothing by default\n end",
"def before_configuration_tasks \n end",
"def configure_permitted_parameters\n extra_keys = [:avatar, :name, :time_zone, :preferred_language]\n signup_keys = extra_keys + [:terms_of_service, :invite, owned_accounts_attributes: [:name]]\n devise_parameter_sanitizer.permit(:sign_up, keys: signup_keys)\n devise_parameter_sanitizer.permit(:account_update, keys: extra_keys)\n devise_parameter_sanitizer.permit(:accept_invitation, keys: extra_keys)\n end",
"def set_caller_params\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def valid_params_request?; end",
"def before_validate\n self.active = true if self.active.nil?\n self.name = code if self.name.nil?\n self.debug = 0 if self.debug.nil?\n end",
"def valid_options\n super | [ :controller_matches ]\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:first_name, :last_name, :email, :password, :password_confirmation) }\n \tdevise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:first_name, :last_name, :email, :password) }\n \tdevise_parameter_sanitizer.for(:account_update) { |u| u.permit(:first_name, :last_name, :email, :password, :password_confirmation) }\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :username, :first_name, :last_name, :birthday, :password, :password_confirmation, :remember_me) }\n devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :username, :email, :password, :remember_me) }\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :first_name, :last_name, :age, :country_code, :language_first, :language_second, :sex, :address, :birthday, :password, :password_confirmation, :current_password) }\n end",
"def before_processing\n end",
"def configure_permitted_params\n\t\tdevise_parameter_sanitizer.for(:sign_up) do |u|\n\t\t\tu.permit(:first_name, :last_name, :company_name, :email, :password, :password_confirmation)\n\t\tend\n\t\tdevise_parameter_sanitizer.for(:sign_in) do |u|\n\t\t\tu.permit(:email, :password, :remember_me)\n\t\tend\n\t\tdevise_parameter_sanitizer.for(:account_update) do |u|\n\t\t\tu.permit(:first_name, :last_name, :company_name, :email, :password, :password_confirmation, :current_password)\n\t\tend\n\tend",
"def configure_permitted_parameters\n \tdevise_parameter_sanitizer.for(:sign_up) << :first_name << :last_name << :office_location << :office_country << :office_city << :company\n \tdevise_parameter_sanitizer.for(:account_update) << :first_name << :last_name << :office_location << :office_country << :office_city << :company\n end",
"def verify_parameter\n set_swimmer\n unless @swimmer\n flash[:error] = I18n.t(:invalid_action_request)\n redirect_back( fallback_location: root_path ) and return\n end\n set_goggle_cups\n end",
"def before\n\t\t\ttrue\n\t\tend",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:first_name,:last_name,:profile_name,:email, :password) }\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:first_name,:last_name,:profile_name,:email, :password) }\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:first_name,:last_name,:profile_name,:email, :password) }\n end",
"def setup\n # this method gets called before *each* omniauth endpoint call, so try to avoid logging when we're returning from\n # oauth'ing\n unless stored_register_redirect\n reg_redirect = params[:r]\n reg_redirect ||= request.referer if params[:ot] && (params[:ot] == \"far\") # facebook auth referral\n store_register_redirect(reg_redirect)\n end\n\n unless stored_auth_redirect\n auth_redirect = params[:r]\n auth_redirect ||= root_path if params[:state] && (params[:state] == 'w')\n store_auth_redirect(auth_redirect)\n end\n\n remember_remember_me\n remember_signup_flow_scope\n remember_signup_flow_type\n remember_signup_flow_origin_type\n remember_signup_flow_destination\n remember_signup_flow_network\n render :text => \"Setup complete.\", :status => 404\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) do |u|\n u.permit(:email, :password, :password_confirmation, :current_password, :time_zone)\n end\n devise_parameter_sanitizer.for(:account_update) {\n |u| u.permit(\n :crop_x, :crop_y, :crop_w, :crop_h,:level, :pictures, :gallery, :avatar, :occupation, :level_id, :type, :birthdate, :description, :gender, :phonenumber, :firstname, :lastname, :email, :password, :password_confirmation, :current_password, :accepts_post_payments, :time_zone\n ) }\n end",
"def callback_phase\n super\n end",
"def required_defaults; end",
"def set_min_up_members_action(opts)\n opts = check_params(opts,[:min_up_actions])\n super(opts)\n end",
"def prepare_params\n self.email = self.email.downcase\n end",
"def before_dispatch(_env)\n end",
"def setup; end",
"def before_create()\n end",
"def valid_for_params_auth?; end",
"def param_whitelist\n [:role, :title]\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) do |u|\n u.permit(:name, :heard_how,\n :email, :password, :password_confirmation, :subscribed)\n end\n devise_parameter_sanitizer.for(:account_update) do |u|\n u.permit(:name,\n :email, :password, :password_confirmation, :current_password, :subscribed)\n end\n end",
"def before_all\n super if defined?(super)\n end",
"def do_adapter_specific_setup; end",
"def before_rodauth\n rails_verify_authenticity_token\n super\n end",
"def before\n end",
"def after_validate\n end"
] | [
"0.6105329",
"0.5951854",
"0.5890952",
"0.587356",
"0.5622538",
"0.5599444",
"0.5599444",
"0.55656695",
"0.5533773",
"0.55317533",
"0.5505655",
"0.5471736",
"0.5467662",
"0.54446685",
"0.54280174",
"0.5415846",
"0.5412756",
"0.5409124",
"0.53936976",
"0.53926057",
"0.53926057",
"0.5382398",
"0.5358707",
"0.5350431",
"0.5347299",
"0.53303313",
"0.53075635",
"0.5302805",
"0.5283343",
"0.52693",
"0.52648395",
"0.5254327",
"0.521904",
"0.52061564",
"0.5186799",
"0.5169714",
"0.5158738",
"0.5147511",
"0.514123",
"0.5135131",
"0.5135131",
"0.51337487",
"0.51335645",
"0.5133429",
"0.51253664",
"0.5103656",
"0.50975686",
"0.5093294",
"0.50884604",
"0.5082762",
"0.5073365",
"0.5071622",
"0.5068364",
"0.50638807",
"0.5055905",
"0.5052554",
"0.5050707",
"0.50492615",
"0.50452816",
"0.5044001",
"0.5041934",
"0.5024649",
"0.502332",
"0.50229615",
"0.50179684",
"0.5017085",
"0.501153",
"0.50066674",
"0.50053596",
"0.4995734",
"0.49872538",
"0.49863285",
"0.49855262",
"0.49847353",
"0.49818885",
"0.49775225",
"0.49762577",
"0.49751604",
"0.49744925",
"0.49696723",
"0.4968967",
"0.49684244",
"0.4967819",
"0.49672237",
"0.49640727",
"0.49433014",
"0.49391097",
"0.49385053",
"0.49367055",
"0.49342954",
"0.49308416",
"0.49292538",
"0.49249923",
"0.49230373",
"0.49217948",
"0.49184123",
"0.49180308",
"0.49161148",
"0.4912269",
"0.49097407",
"0.49079633"
] | 0.0 | -1 |
save new status of event order | def update_status
authorize @event_order
begin
raise "Please enter the transaction id." unless params[:transaction_id].present? if (@event_order.pending? || @event_order.failure?)
ApplicationRecord.transaction do
update_event_order_status(params[:status])
@event_order.after_manual_status_update(params[:transaction_id])
@event_order.update_columns(reg_ref_number: "manual_"+@event_order.reg_ref_number) if @event_order.success?
end
rescue SyException, AASM::InvalidTransition => e
@message = e.message
if @event_order.errors.present?
error = @event_order.errors.messages.first
@message = error.is_a?(Array) ? error.flatten.join(' ') : error
end
rescue Exception => e
@message = e.message
end
@message.present? ? flash[:error] = @message : flash[:success] = "Status Updated Successfully."
respond_to do |format|
format.js
format.html{ redirect_back(fallback_location: proc { root_path }) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(event)\n data = {\n agenda: Agenda.file,\n owner: @owner,\n text: @text,\n pmc: @pmc,\n date: @date,\n status: @status\n }\n\n @disabled = true\n post 'status', data do |pending|\n jQuery('#updateStatusForm').modal(:hide)\n @disabled = false\n Pending.load pending\n end\n end",
"def update_order_status\n order.delivery_status = status\n order.save\n end",
"def after_save_new_order\n end",
"def save_status status\n\t\n\t\t@db.rpush @type, status\n\t\n\tend",
"def update_order_state\n if self.status_changed?\n self.order.update_attributes(:state => self.status)\n end\n end",
"def mark_contract_event_as_processed\n @contract_event_obj.status = GlobalConstant::ContractEvent.processed_status\n @contract_event_obj.save!\n end",
"def making_status_update\n order_detail = OrderDetail.find(params[:id])\n order_detail.update(order_detail_params)\n redirect_to admin_order_path(order_detail.order_id)\n end",
"def set_to_ordered\n self.status = \"ordered\"\n self.save\n end",
"def ship_order\n self.update_attributes(status: 2)\n end",
"def mark_as(status)\n self.status = status\n self.save\n end",
"def save!\r\n ret = nil\r\n case self.status\r\n when :new\r\n ret = new!\r\n when :old\r\n ret = @srv.update(self.feed, self.to_s)\r\n raise EventUpdateFailed, ret.body unless ret.code == \"200\"\r\n when :deleted\r\n raise EventDeleteFailed, \"already deleted\"\r\n else\r\n raise StandardError, \"invalid inner status\"\r\n end\r\n load_xml(ret.body)\r\n end",
"def save\n MoxiworksPlatform::Event.update(self.to_hash)\n end",
"def order_status_changed(order)\n @order_callbacks.each do |c|\n c.call(order)\n end\n end",
"def notifications\n order = Spree::Order.find_by_number(params[:order_id])\n\n order.payment_state =\n case params[:transaction_status]\n when \"expired\", \"cancel\"\n \"failed\"\n when \"pending\"\n \"pending\"\n when \"capture\"\n \"processing\"\n when \"settlement\"\n \"completed\"\n end\n\n order.save\n head 200\n end",
"def set_status\n\t \t#establecer status en BD\n\t \tself.status = \"created\"\n\t \tself.save #para que se guarde\n\t end",
"def process!\n self.status = 'Generado'\n save\n end",
"def save_cart\n \tself.status = 'saved'\n \tself.save\n end",
"def save(*)\n if status = super\n changes_applied\n end\n status\n end",
"def update\n @order = Order.find(params[:id])\n @order.status = params[:order][:status]\n @order.update(order_params)\n if @order.status = \"入金確認\"\n @order.order_details.each do |order_detail|\n order_detail.update(making_status: 1)\n end\n end\n redirect_back(fallback_location: admin_orders_path)\n end",
"def save_event(event)\n @events.push(event)\n end",
"def save\n REDIS.zadd :event, id, date unless exist?\n end",
"def update\n status = params[:order][:status]\n order = Order.find(params[:id])\n if order.status != status\n attribute = (status + ' at').gsub(/\\s+/, '_').to_sym\n params[:order][attribute] = Time.now if order.respond_to?(attribute)\n end\n super do |format|\n redirect_to orders_path and return if resource.valid?\n end\n end",
"def save(*)\n if (status = super)\n changes_applied\n end\n\n status\n end",
"def set_event_order\n @event_order = EventOrder.find(params[:id])\n end",
"def persist status\n\t\t@dao.save_status status\n\tend",
"def saveStatus _obj, _args\n \"_obj saveStatus _args;\" \n end",
"def mark_as_delivered\n order = Order.find(params[:id])\n order.delivered_at = DateTime.now\n order.save!\n redirect_to orders_path\n end",
"def save_event?(event)\n event.save\n end",
"def set_order_status\n @order_status = OrderStatus.find(params[:id])\n end",
"def update\n @order = Order.find(params[:id])\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n @order.add_event \"Изменён пользователем #{User.find_by_id(session[:user_id]).login}\"\n format.html { redirect_to(order_url(@order), :notice => 'Order was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def change_status\n\n res = RResponse.new\n\n order = Order.find_by_id(params[:id])\n order.shipping_status_id = params[\"shipping_status_id\"]\n begin\n order.save\n res.success = true\n res.msg = 'Changed order status to \"' + order.status.name + '\"'\n\n # log this\n type = OrderLogType.find_by_name('status')\n log = OrderLog.create(:account_id => current_user.account.id, :order_log_type_id => type.id, :order_id => order.id, :subject => 'Order Status', :msg => res.msg)\n res.add_action(RAction.new({\n :component_id => 'order-log-' + params[:id],\n :success => true,\n :data => {:log => log.to_a}\n })) \n end\n\n respond(res)\n\n end",
"def save\n this_event = FedoraAccessEvent.new\n this_event.pid = pid\n this_event.agent = agent.truncate(254)\n this_event.event = event\n this_event.location = ip_format(ip)\n this_event.event_time = event_time\n this_event.save\n end",
"def save_beginning_status user_id\n self.payment_status = PTE::PaymentStatus.processing\n self.user_id = user_id\n self.transaction_time = Time.now\n self.save\n end",
"def store_status(id, status, expiration = nil)\n store_for_id id, {status: status}, expiration\n end",
"def save_region_order(new_order)\n new_order.each_with_index do |region_id, i|\n region = Region.find(region_id)\n region.sequence = i+1\n region.save!\n end\n end",
"def save_region_order(new_order)\n new_order.each_with_index do |region_id, i|\n region = Region.find(region_id)\n region.sequence = i+1\n region.save!\n end\n end",
"def accept \n order = Order.find(params[:orderid])\n order.status = \"Accepted\"\n order.save!\n if order.artwork.sold == false\n order.artwork.toggle!(:sold)\n end\n Order.find_all_by_artwork_id(order.artwork.id).each do |f|\n if f.status != \"Accepted\"\n f.status = \"Declined\"\n f.save!\n end\n end\n redirect_to [:admin, User.find(params[:id])]\n end",
"def update_order_status(order, status)\n id = order.is_a?(String) ? order : order.id\n path = \"/checkout/orders/#{id}\"\n\n response = execute_request(path, {status: status})\n order.status = status unless order.is_a?(String)\n\n response\n end",
"def update_status(status)\n self.status = status\n self.save! validate: false\n end",
"def mark_order_complete\n order_params = (driver_order_params)\n order_params[:payable_attributes][:driver_id] = current_user.customer_id\n if @order.single?\n if( (Time.now >= Time.parse(@order.place_date + ' ' + @order.timeslot.start) || true) && (@order.pending? ) && @order.update(order_params) )\n render json: @order, status: 200\n else\n render json: {'errorrs': ['Order can not be completed']}, status: :unprocessable_entity\n end\n else\n if(@order.update(order_params))\n render json: @order, status: 200\n else\n render json: {'errorrs': ['Order can not be completed']}, status: :unprocessable_entity\n end\n end\n end",
"def create\n\n # Set default status to new order\n @order = Order.new(order_params.merge({\"status\" => \"Ordering\"}))\n\n # Check duplicate of order from product\n @order_check = Order.where(product: @order.product, brand: @order.brand).count(:id)\n\n # Update history after request new order\n @history = History.new({\"order_code\" => SecureRandom.hex, \"brand\" => @order.brand, \"product\" => @order.product, \"amount\" => @order.amount})\n\n @history.save\n\n respond_to do |format|\n\n # Order duplication check\n if @order_check == 0\n\n # Set notice after order save action\n if @order.save\n format.html { redirect_to orders_path, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n else\n # Select exist order to update amount\n @order_update = Order.where(product: @order.product, brand: @order.brand).take\n\n # Set notice after order update action\n if @order_update.update({\"amount\" => @order_update.amount + @order.amount})\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def update\n if @transferred_event_order.update(transferred_event_order_params)\n format.html { redirect_to @transferred_event_order, notice: 'Transferred event order was successfully updated.' }\n format.json { render :show, status: :ok, location: @transferred_event_order }\n else\n format.html { render :edit }\n format.json { render json: @transferred_event_order.errors, status: :unprocessable_entity }\n end\n end",
"def enter_pending\n update_attribute(:status, :pending)\n end",
"def perform\n Magento2::Api.configure('dz4xnhhgfsfuyj00g6bkel0jq6mwdak2', 'hhjnlf59qh2m7an9sdpfcu0o9nox78y6', 'ie5iafduhqs1dydynidsjki582oti17w', 'mva5hldj17elic6muxmf53fq7zmm7xl5', \"https://mall2door.net\")\n orders = Magento2::Api.get(\"/rest/en/V1/orders\", {searchCriteria: 'all' })\n all_orders = orders[:items]\n all_orders.each do |order|\n unless order[:status].present?\n order_id = order[:increment_id]\n id = order[:entity_id]\n status = order[:state]\n params = {\n entity_id: id,\n increment_id: order_id,\n status: status,\n }\n if status\n Magento2::Api.put(\"/rest/en/V1/orders/create\", {entity: params})\n end\n end\n end\n end",
"def save_event(event)\n method = event.new_event? ? :post : :put\n body = event.use_quickadd? ? nil : event.to_json\n notifications = \"sendNotifications=#{event.send_notifications?}\"\n query_string = if event.use_quickadd?\n \"/quickAdd?#{notifications}&text=#{event.title}\"\n elsif event.new_event?\n \"?#{notifications}\"\n else # update existing event.\n \"/#{event.id}?#{notifications}\"\n end\n\n send_events_request(query_string, method, body)\n end",
"def update_status(status)\n @status = status\n @last_status_change = Time.now\n update_statusfile\n end",
"def done!(status = 0)\n @completed_at = Time.now\n @exitstatus = status\n save\n end",
"def update\n @order_detail = OrderDetail.find(params[:id])\n @order = Order.find(@order_detail.order_id)\n if params[:order_detail][:production_status] == \"in_production\"\n @order.order_status = \"in_production\"\n @order.save\n end\n if @order_detail.update(order_detail_params)\n count_production_completed = 0\n @order.order_details.each do |order_detail|\n if order_detail.production_status == \"production_completed\"\n count_production_completed += 1\n end\n end\n if @order.order_details.count == count_production_completed\n @order.order_status = \"preparing_for_shipping\"\n @order.save\n end\n redirect_to admin_order_path(@order)\n else\n redirect_to admin_order_path(@order)\n end\n end",
"def save(meta = {})\n dirty_events = @_dirty_events\n version = persisted_version\n\n unit_of_work.handle_save(proc do\n event_store.append_events(id, self.class.name, dirty_events, version)\n SaveReciept.new(id, self.class, dirty_events, meta)\n end)\n\n @_dirty_events = []\n @_aggregate.instance_variable_set(:@persisted_version, local_version)\n\n self\n end",
"def update_order(result)\n create_asendia_shipment_record(result['Status'], result['Error'])\n @transaction_id = result['ParcelId']\n @tracking_number = nil\n shipment = @order.shipment\n shipment.tracking = @tracking_number\n shipment.save\n shipment.ship!\n @order.line_items.each do |line_item|\n @success_orders << [\"#{@order.number}, #{line_item.sku}, #{@tracking_number}, #{@transaction_id}, #{line_item.quantity}, #{@order.completed_at}, #{(@order.ship_address.country.try(:name) || '').delete(',')}\"]\n end\n end",
"def set_new_state_after_notify(was_successful, event, status)\n unless status.attending?\n if was_successful\n if event.event?\n status.not_responded!\n else\n status.delivered!\n end\n else\n status.not_delivered!\n end\n status.save\n end\n end",
"def transmogrify\n\t\tassign_value_of_changed_status\n\t\tupdate_attributes(last_sent: DateTime.now)\n\n\tend",
"def save_event(event)\n method = (event.id == nil || event.id == '') ? :post : :put\n query_string = (method == :put) ? \"/#{event.id}\" : ''\n @connection.send(Addressable::URI.parse(events_url + query_string), method, event.to_xml)\n end",
"def complete!\n self.status = 'completed'\n self.save\n end",
"def add_status_change(post, action, transaction, options, extended = true)\n post[:szDesiredStatus] = action\n post[:szTransactionId] = transaction\n post[:szNewOrderNumber] = sanitize_order_id(options[:order_id]) unless options[:order_id].blank?\n \n if extended and status_extended_valid?(options)\n action += 'EX'\n add_invoice(post, options)\n add_address(post, options)\n end\n end",
"def create\r\n @order = Order.new(order_params)\r\n @order.status = false\r\n @order.order_state = true\r\n respond_to do |format|\r\n if @order.save\r\n format.html { redirect_to '/order_details/' + @order.id.to_s, notice: 'Órden creada correctamente' }\r\n format.json { render :show, status: :created, location: @order }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @order.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def save\n if persisted?\n change_status\n else\n create_new_location\n end\n end",
"def save_new\n self.completed = false\n save\n end",
"def orders_details_auto_status_changer(order)\n if order.read_attribute_before_type_cast(:status) == 1\n order.orders_details.each do |order_detail|\n order_detail.update(making_status: 1)\n end\n end\n end",
"def quest_status_changed\n $game_party.quests.add_to_sort_array(:change, @id) \n $game_system.last_quest_id = @id if QuestData::OPEN_TO_LAST_CHANGED_QUEST\n end",
"def save_order_data \n @order.customer_id = @customer.id \n @order.external_code = @parsed['id']\n @order.store_id = @parsed['store_id']\n @order.sub_total = @parsed['total_amount']\n @order.delivery_fee = @parsed['total_shipping']\n @order.total_shipping = @parsed['total_shipping']\n @order.total = @parsed['total_amount_with_shipping']\n @order.country = @parsed['shipping']['receiver_address']['country']['id']\n @order.state = @parsed['shipping']['receiver_address']['state']['name']\n @order.city = @parsed['shipping']['receiver_address']['city']['name']\n @order.district = @parsed['shipping']['receiver_address']['neighborhood']['name']\n @order.street = @parsed['shipping']['receiver_address']['street_name']\n @order.complement = @parsed['shipping']['receiver_address']['comment']\n @order.latitude = @parsed['shipping']['receiver_address']['latitude']\n @order.longitude = @parsed['shipping']['receiver_address']['longitude']\n @order.dt_order_create = @parsed['date_created']\n @order.postal_code = @parsed['shipping']['receiver_address']['zip_code']\n @order.number = @parsed['shipping']['receiver_address']['street_number']\n @order.save\n end",
"def create\n @order = Order.new(order_params)\n @order.status = \"Pending\"\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def return_order\n @order = Order.find(params[:id])\n @order.order_status_code_id = 9\n @order.save\n flash[:notice] = \"Order has been marked as returned.\"\n redirect_to :action => 'show', :id => @order.id\n end",
"def save_event(event)\n Event.create do |t|\n t.place = event[:place]\n t.date = event[:date]\n t.time = event[:time]\n t.keywords = event[:keywords]\n t.username = event[:username]\n t.tweet_id = event[:id]\n end\n end",
"def activate\n self.status = 'current'\n self.save\n end",
"def process_order!(options)\n options['product'].create_eventbooking(options['model'])\n end",
"def save\n case event.event_type\n when 'enter' then enter\n when 'leave' then leave\n else logger.info \"Unsupported event_type: #{event.event_type}\"\n end\n end",
"def success\n @order.user_id = current_user.id\n @order.seller_id = @listing.user_id\n @order.title = @listing.title\n @order.description = @listing.description\n @order.condition = @listing.condition\n @order.category = @listing.category\n @order.price = @listing.price\n @order.save\n end",
"def update_status status\n @job.set({\n custom_status: status,\n pinged_at: Time.now\n })\n end",
"def put(invoice_number, invoice_sequence)\n #xml = order_update_template % { status: status.to_i }\n #put_request(t_url(:order, order_id), xml)\n end",
"def create\n event = Event.find_by_id(params[:event_id])\n amount = 0.0\n order = Order.create!(event:event, total_amount:amount.to_f, order_number: Order.generate_number)\n order.reload\n order.calculate_total\n respond_with order\n end",
"def order_complete\n load_order\n if @order.state == 'canceled' \n flash[\"notice\"] = 'This order has been canceled - do not process it!'\n elsif @order.packed_at.blank? && (@current_retailer && @current_retailer.id == @order.retailer_id)\n \t@order.update_attribute(:packed_at, Time.now)\n end\n redirect_to admin_order_url(@order)\n end",
"def update_order_item\n \n end",
"def status_updated\n new_status = params[:new_status]\n id = params[:id]\n application = EventApplication.find_by(user_id: id)\n application.status = new_status\n application.save(:validate => false)\n flash[:success] = \"Status successfully updated.\"\n\n redirect_to event_application_path(application)\n\n\n\n # Send email when status changes.\n if new_status == 'accepted'\n UserMailer.accepted_email(application.user).deliver_now\n elsif new_status == 'denied'\n UserMailer.denied_email(application.user).deliver_now\n else\n UserMailer.waitlisted_email(application.user).deliver_now\n end\n end",
"def finalize!\n update_attribute(:completed_at, Time.now)\n InventoryUnit.assign_opening_inventory(self)\n # lock any optional adjustments (coupon promotions, etc.)\n adjustments.optional.each { |adjustment| adjustment.update_attribute(\"locked\", true) }\n\t\n envia_correos_notific # Envío de correos...\n\n self.state_events.create({\n :previous_state => \"cart\",\n :next_state => \"complete\",\n :name => \"order\" ,\n :user_id => (User.respond_to?(:current) && User.current.try(:id)) || self.user_id\n })\n end",
"def ready\n order = current_user.restaurant.orders.find(params[:id])\n order.update(status: 4)\n render json: {is_success: true}, status: :ok\n end",
"def update_invoice_status\n invoices = self.invoices\n invoices.each do |invoice|\n invoice.received = true\n invoice.save\n end\n end",
"def complete_order_service\n\n order_service = OrderService.find(params[:order_service_id])\n order_service.completed = true\n order_service.save\n\n completed = true\n order_service.order.order_services.each do |order_service|\n if !order_service.completed\n completed = false\n end\n end\n if completed\n order_service.order.status = true\n order_service.order.save\n end\n \n redirect_to order_path(order_service.order.id)\n end",
"def fired_event(event)\n history << event\n\t update_task_status(event)\n end",
"def update_status\n save_csv\n end",
"def status=(new_status)\n self.last_status = status\n\n self.setValue new_status, forKey: 'status'\n end",
"def update_job_status(status)\n @csv_report_job.status = status\n @csv_report_job.save!\n end",
"def update!\n update_totals\n update_payment_state\n # update_adjustments\n # update totals a second time in case updated adjustments have an effect on the total\n update_totals\n \n update_attributes_without_callbacks({\n :state => \"complete\"\n }) \n \n logger.info 'UPDATED ORDER'\n # update_hooks.each { |hook| self.send hook }\n end",
"def handle_status_change\n return nil unless self.new_status.present?\n self.status = self.new_status\n if self.new_status == 'active'\n # the user wants to make the ad active now so push out the inactive and deletion dates\n self.inactive_date = Time.now + 2.months\n self.delete_date = Time.now + 4.months\n elsif self.new_status == 'inactive'\n # the user wants to make the ad inactive now so make the inactive date to day and deletion in 2 months\n self.inactive_date = Time.now\n self.delete_date = Time.now + 2.months\n end\n end",
"def save(*)\n call_hooks 'save' do\n # Existing object implies update in place\n action = 'add'\n set_auto_date_field 'created_at'\n if @new_record\n do_insert\n else\n do_update\n set_auto_date_field 'updated_at'\n action = 'update'\n end\n @new_record = false\n @dirty = false\n self.class.issue_notification(self, :action => action)\n end\n end",
"def attend_event(event, status = :pending)\n a = Attendance.where(user_id: self.id, event_id: event.id).first_or_create\n a.status = status\n a.save\n end",
"def save_edited_details\n RoutingSheetDetail.transaction do\n @routing_sheet_id = -1\n $routing_sheets_details.each do |detail|\n @who_received=params['who_received_' + ($routing_sheets_details.index(detail) + 1).to_s]\n @reason_id=params['reason_id_' + ($routing_sheets_details.index(detail) + 1).to_s]\n @to_route = params['to_route_' + ($routing_sheets_details.index(detail) + 1).to_s]\n @detail_to_update=detail\n @product=Product.where(id: detail.product_id).first\n valid_received=/^\\D{4,35}$/.match(@who_received)\n if(!valid_received.nil?) \n ##Actualizo el detalle\n @detail_to_update.update_attribute(:who_received, @who_received)\n @detail_to_update.update_attribute(:received,'s') ## s= fue recibido el producto\n ##Actualizo el estado del producto a \"Entregado\" y la fecha en que recibio el producto\n \n @product.update_attribute(:product_state_id,ProductState.recibido) ## id 6=\"Recibido\" ProductState.where(\"state_name='Recibido'\").first.id\n @product.update_attribute(:received_at, @product.format_admission_date)\n else\n #Actualizo el motivo por el cual no se entrego el producto\n #En caso de que el motivo sea \"Producto Extraviado en el reparto\n #actualizo el estado del producto a extraviado, sino a \"No recibido\"\n @detail_to_update.update_attribute(:reason_id, @reason_id)\n \n if @reason_id.to_i == 14 # Rason de \"Producto Extraviado\"\n @product.update_attribute(:product_state_id,ProductState.extraviado) ## id 4= Extraviado\n else \n if @reason_id.to_i == 15 # Rason de \"Cancelado a pedido del cliente\"\n @product.update_attribute(:product_state_id,ProductState.devuelto ) ## id 3= Devuelto\n else\n ## Si se marco la opcion para volver a rutear a \"no\", entonces coloco el estado a \"no recibido\"\n if @to_route.to_s == \"no\"\n @product.update_attribute(:product_state_id,ProductState.no_recibido) ## id 7= No recibido \n else\n # Si se marco a \"si\", este producto cambia su estado a \"Pendiente\", y puede volver a rutearse\n @product.update_attribute(:product_state_id,ProductState.pendiente)\n end\n end\n end\n end\n \n ##Obtengo el id de la hoja de ruta \n @routing_sheet_id=detail.routing_sheet_id\n end\n if(@routing_sheet_id != -1)\n @routing_sheet=RoutingSheet.where(id: @routing_sheet_id).first\n ##Cambio el estado de la hoja de ruta a procesado.\n @routing_sheet.update_attribute(:routing_sheet_state_id, 2 ) ## id 2 =\"Procesado\"\n end\n end\n respond_to do |format|\n format.html { redirect_to @routing_sheet, notice: 'Los detalles se actualizaron correctamente' }\n format.json { render json: @routing_sheet, status: :created, location: @routing_sheet }\n end\n end",
"def update\n @event = Event.shod(params[:event_id])\n if @event.create_event(params[:batches], params[:departments])\n flash[:notice] = 'Event confirmation successfully'\n redirect_to calender_index_path\n end\n end",
"def set_state_save\n @customer = Customer.find(customer_id)\n\n Order.find(id).update_column(:state_id, @customer.state_id)\n end",
"def save\n event = params\n # This assumes that all keys exists. Yay no error handling...\n toSave = Event.new(update_type: event[:event],\n start_time: event[:payload][:event][:start_time_pretty],\n end_time: event[:payload][:event][:end_time_pretty],\n location: event[:payload][:event][:location],\n invitee_name: event[:payload][:invitee][:name],\n duration: event[:payload][:event_type][:duration],\n event_kind: event[:payload][:event_type][:kind])\n toSave.save\n render json: {}, status: 200\n end",
"def save\n @saved = @state\n end",
"def complete_order_step(order, order_step)\n original_state = order.state\n order.state = order_step\n\n if !order.next\n order.state = original_state\n order.save(validate: false) # store data from paypal. user will be redirect to 'personal' tab\n end\n end",
"def update_status\n case @part.status\n when 'Unstarted'\n @part.status = 'Started'\n @part.user = current_user\n @part.bitbucket.post_user(current_user.email) if @part.name == 'Prototype'\n @part.create_activity key: 'part.started', owner: current_user\n @part.start_rep_points\n when 'Started'\n @part.status = 'Finished'\n @part.create_activity key: 'part.finished', owner: current_user\n when 'Finished' \n @part.status = 'In Review'\n @part.create_activity key: 'part.in_review', owner: current_user\n when 'In Review'\n @part.status = 'Accepted'\n @part.accepted_rep_points\n @part.create_activity key: 'part.accepted', owner: current_user\n end\n @part.save\n redirect_to :back\n end",
"def save_changed\n save changed: true\n end",
"def save\n response = send_calendar_request(\"/\", :post, {:summary => @summary}.to_json) \n update_after_save(response)\n end",
"def lent_out\n\tupdate_attributes(status: 'Lent Out')\nend",
"def set_order\n @order = current_order\n\n if @order.new_record?\n @order.save!\n session[:order_id] = @order.id\n end\n end",
"def update\n if @order.single?\n if( (Time.now + 1.hour <= Time.parse(@order.place_date + ' ' + @order.timeslot.start)) && (!@order.completed? ) && @order.update(update_order_params) )\n render json: @order, status: 200\n else\n render json: {'errorrs': ['Order can not be updated']}, status: :unprocessable_entity\n end\n else\n if(@order.update(update_order_params))\n render json: @order, status: 200\n else\n render json: {'errorrs': ['Order can not be updated']}, status: :unprocessable_entity\n end\n end\n end",
"def create\n token_ok, token_error = helpers.API_validate_token(request)\n if not token_ok\n render json: {message: token_error }, status: 401\n else\n\n # Get the order ID\n order_id = params[:order_id].to_i\n\n # Save the order event data\n begin\n order_event_data = OrderEvent.new\n order_event_data.event_id = params['eventId']\n order_event_data.user_id = params['userId']\n order_event_data.order_id = order_id\n order_event_data.scope = params['scope']\n order_event_data.observations = params['observations']\n order_event_data.save!\n\n respond_to do |format|\n format.json { render json: {message: 'Event saved.'} }\n end\n\n rescue => e\n puts \"Error #{e.class}: #{e.message}\"\n puts \"ERROR BACKTRACE:\"\n puts e.backtrace\n respond_to do |format|\n format.json { render json: {message: 'Error saving the event to the order',\n extraMsg: e.message} }\n end\n end\n\n end\n end",
"def orderStatusEdit()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n o = Order.find(params[:id])\n status = o.update(order_status: params[:status])\n render json: {status: status, data: \"\", reason: ''}\n end"
] | [
"0.71798056",
"0.71562916",
"0.6654894",
"0.6650511",
"0.6606601",
"0.64902574",
"0.64076",
"0.6342702",
"0.63323057",
"0.6280147",
"0.6255709",
"0.6254433",
"0.6253874",
"0.62392217",
"0.62138253",
"0.61581093",
"0.6150423",
"0.609832",
"0.6088951",
"0.6060743",
"0.60460055",
"0.60243744",
"0.6016108",
"0.6003534",
"0.5997715",
"0.5991857",
"0.59863514",
"0.59862626",
"0.59554785",
"0.59554666",
"0.5940604",
"0.5926518",
"0.5918111",
"0.5900877",
"0.5886775",
"0.5886775",
"0.5882243",
"0.5874203",
"0.5872636",
"0.5860018",
"0.5858274",
"0.58567864",
"0.5847862",
"0.5842726",
"0.5841779",
"0.5833295",
"0.582986",
"0.58270603",
"0.58239365",
"0.5821967",
"0.580972",
"0.57874393",
"0.5783342",
"0.5771988",
"0.5771159",
"0.576655",
"0.57638866",
"0.57602185",
"0.5754761",
"0.574956",
"0.57444644",
"0.5738309",
"0.5735754",
"0.57307506",
"0.571642",
"0.5710493",
"0.57042575",
"0.5694694",
"0.56930363",
"0.56840587",
"0.56761855",
"0.56699187",
"0.56557786",
"0.5653901",
"0.5653792",
"0.564405",
"0.56400335",
"0.5637846",
"0.5633893",
"0.56145316",
"0.56112194",
"0.5605803",
"0.56056523",
"0.55953324",
"0.55938",
"0.5580986",
"0.55799323",
"0.55780596",
"0.55738986",
"0.5568825",
"0.5565216",
"0.5565141",
"0.5564425",
"0.55641985",
"0.5556914",
"0.55561996",
"0.55539787",
"0.55521566",
"0.5550628",
"0.55470043"
] | 0.6182471 | 15 |
Use callbacks to share common setup or constraints between actions. | def set_event_order
@event_order = EventOrder.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 setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\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 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 workflow\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 setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\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 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 action\n end",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\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 before_action \n end",
"def action\n end",
"def setup\n # override this if needed\n end",
"def matt_custom_action_begin(label); 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 setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def lookup_action; 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 around_hooks; end",
"def release_actions; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def action_target()\n \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 setup(&blk)\n @setup_block = blk\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 callback_phase\n super\n end",
"def advice\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def _handle_action_missing(*args); 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",
"def call\n setup_context\n super\n end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end"
] | [
"0.6163443",
"0.604317",
"0.5943409",
"0.59143174",
"0.5887026",
"0.58335453",
"0.57738566",
"0.5701527",
"0.5701527",
"0.56534666",
"0.5618685",
"0.54237175",
"0.5407991",
"0.5407991",
"0.5407991",
"0.5394463",
"0.5376582",
"0.5355932",
"0.53376216",
"0.5337122",
"0.5329516",
"0.5311442",
"0.52963835",
"0.52955836",
"0.5295297",
"0.5258503",
"0.52442217",
"0.5235414",
"0.5235414",
"0.5235414",
"0.5235414",
"0.5235414",
"0.5234908",
"0.5230927",
"0.52263695",
"0.5222485",
"0.5216462",
"0.52128595",
"0.52070963",
"0.520529",
"0.517586",
"0.5174021",
"0.5172379",
"0.5165636",
"0.5161574",
"0.51556087",
"0.5153217",
"0.5152898",
"0.5151238",
"0.5144674",
"0.51387095",
"0.51342636",
"0.5113545",
"0.51131564",
"0.51131564",
"0.5107665",
"0.5107052",
"0.50908124",
"0.5089785",
"0.50814754",
"0.50807786",
"0.5064482",
"0.5053022",
"0.50526255",
"0.5050246",
"0.5050246",
"0.50329554",
"0.5023997",
"0.5021236",
"0.5014815",
"0.5014393",
"0.4999298",
"0.49990913",
"0.4997733",
"0.49884573",
"0.49884573",
"0.49840933",
"0.49786162",
"0.49784446",
"0.49782816",
"0.49659815",
"0.49655175",
"0.4956222",
"0.49543875",
"0.49536037",
"0.495265",
"0.4951427",
"0.49438462",
"0.49436793",
"0.49335384",
"0.49321616",
"0.49264926",
"0.49247074",
"0.49246994",
"0.49226475",
"0.49194494",
"0.49152806",
"0.49149707",
"0.49149227",
"0.49144953",
"0.49141943"
] | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def event_order_params
params.require(:event_order).permit!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def filtered_parameters; end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n 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 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 param_whitelist\n [:rating, :review]\n end",
"def valid_params?; end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def filter_parameters; end",
"def filter_parameters; end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def check_params; true; end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def list_params\n params.permit(:name)\n end",
"def check_params\n true\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n 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 additional_permitted_params\n []\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def allow_params_authentication!; 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 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 person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end",
"def quote_params\n params.permit!\n end",
"def list_params\n params.permit(:list_name)\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def all_params; end",
"def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end",
"def source_params\n params.require(:source).permit(all_allowed_params)\n end",
"def user_params\n end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end",
"def permitted_params\n @wfd_edit_parameters\n end",
"def user_params\r\n end",
"def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend",
"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 valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def params_permit\n params.permit(:id)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def filter_params\n params.permit(*resource_filter_permitted_params)\n end",
"def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end",
"def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def argument_params\n params.require(:argument).permit(:name)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\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 sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def parameters\n nil\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end",
"def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end",
"def normal_params\n reject{|param, val| param_definitions[param][:internal] }\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 special_device_list_params\n params.require(:special_device_list).permit(:name)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end"
] | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.63804525",
"0.6373396",
"0.6360051",
"0.6355191",
"0.62856233",
"0.627813",
"0.62451434",
"0.6228103",
"0.6224965",
"0.6222941",
"0.6210244",
"0.62077755",
"0.61762565",
"0.61711127",
"0.6168448",
"0.6160164",
"0.61446255",
"0.6134175",
"0.6120522",
"0.6106709",
"0.60981655",
"0.6076113",
"0.60534036",
"0.60410434",
"0.6034582",
"0.6029977",
"0.6019861",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.60184896",
"0.60157263",
"0.6005857",
"0.6003803",
"0.60012573",
"0.59955895",
"0.5994598",
"0.5993604",
"0.5983824",
"0.5983166",
"0.5977431",
"0.597591",
"0.5968824",
"0.5965953",
"0.59647584",
"0.59647584",
"0.59566855",
"0.59506303",
"0.5950375",
"0.59485626",
"0.59440875",
"0.5930872",
"0.5930206",
"0.5925668",
"0.59235454",
"0.5917905",
"0.59164816",
"0.5913821",
"0.59128743",
"0.5906617",
"0.59053683",
"0.59052664",
"0.5901591",
"0.58987755",
"0.5897456",
"0.58970183",
"0.58942604"
] | 0.0 | -1 |
'eventsdestroy' (still needs testing) | def destroy
@event = Event.find(params[:id])
@event.destroy
redirect_to '/events'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy_events\n @events.destroy_all\n end",
"def destroy\r\n @event.destroy\r\n end",
"def reset!\n @events = nil\n end",
"def destroy\n @clock_event.destroy\n end",
"def destroy\n @event.destroy\n end",
"def destroy\n @event.destroy\n end",
"def destroy\n @event.destroy\n end",
"def disposing(ev)\n end",
"def destroy_event_any(id)\n return unless !(ev = @events[id]).nil?\n EventSpawn.clean_self_switches(id)\n ev.set_intp_repr_ev(0)\n \n ev.erase # to hide the graphic\n \n if persistants = $game_system.persistent_events[@map_id]\n persistants.each_with_index{ |ev, i|\n if ev.id == id\n persistants.delete_at(i)\n break\n end\n }\n end\n \n @spawned_event_ids.delete(id) # delete from array\n @events.delete(id) # \" \" hash\n \n refresh\n end",
"def reset\n @events = []\n end",
"def clear_all!\n @events = {}\n end",
"def clear_events!\n @started_events = []\n @succeeded_events = []\n @failed_events = []\n end",
"def clean_temp_evs_helper\n @spawned_event_ids.each{|id| @events.delete(id) unless @events[id].persistent}\n @spawned_event_ids = []\n end",
"def clear_events!\n @all_events = []\n @started_events = []\n @succeeded_events = []\n @failed_events = []\n @published_events = []\n self\n end",
"def clear_events!\n @started_events = []\n @succeeded_events = []\n @failed_events = []\n self\n end",
"def destroy\n @eventtype.events.each do |e|\n e.destroy\n end\n @eventtype.destroy\n respond_to do |format|\n format.html { redirect_to eventtypes_url }\n format.json { head :no_content }\n end\n end",
"def gcdelete_event\n cal_event = Event.find_by(gamecall_tag: self.id)\n cal_event.destroy if cal_event\n end",
"def remove\n if @removed\n # raise \"event #{@event} already removed\"\n puts \"event #{@event} already removed\"\n return\n end\n\n if DEBUG && RUBY_PLATFORM == 'opal'\n @@all_events.delete(self) if @@all_events\n\n `window.total_listeners -= 1;`\n `console.log(\"Rem\", window.total_listeners);`\n end\n\n\n @removed = true\n @klass.remove_listener(@event, self)\n\n # We need to clear these references to free the memory\n @scope_provider = nil\n @callback = nil\n # @klass2 = @klass\n @klass = nil\n # @event = nil\n\n end",
"def destroy\n load_data\n @event.destroy\n clear_zend_cache\n\n respond_to do |format|\n format.html { redirect_to(category_events_url(category)) }\n format.xml { head :ok }\n end\n end",
"def after_destroyed\n end",
"def after_destroy(event)\r\n expire_cache_for(event)\r\n end",
"def remove_temporary_spawned_events\n return if @spawned_event_ids.nil?\n clean_self_switches\n clean_temp_evs_helper\n need_refresh = true\n end",
"def destroy\n\t\trun_callbacks(:destroy) { delete } \n\tend",
"def clear_events!\n @started_events = []\n @succeeded_events = []\n @failed_events = []\n @published_events = []\n self\n end",
"def destroy\n @event.destroy\n \n head :no_content\n end",
"def teardown\n callback(:teardown) do\n notify(:teardown)\n end\n end",
"def destroy\n @event.destroy\n\n head :no_content\n end",
"def destroy\n @event.destroy\n\n head :no_content\n end",
"def destroy\n @event.destroy\n\n head :no_content\n end",
"def destroy\r\n super(@event, 'Post apagado com sucesso', events_url)\r\n end",
"def destroy\n if @event\n @event.destroy\n render :update do |page|\n page << \"$('#calendar').fullCalendar( 'refetchEvents' )\"\n page << \"$('#desc_dialog').dialog('destroy')\" \n end\n end\n end",
"def tear_down; end",
"def destroy\n @event.delay.call_notification(I18n.t('Notification.event_deleted'), I18n.t('Email.event_deleted'))\n @event.destroy\n head :no_content\n end",
"def destroy\n\t\t@event.destroy\n\t\tredirect_to action: :index\n\tend",
"def destroy\n event&.destroy\n render json: { message: 'Event Deleted!' }\n end",
"def destroy_or_tag_as_removed\n if self.events.blank?\n destroy\n else\n self.removed = true\n save!\n end\n end",
"def destroy\n event.events_songs.each do |e|\n e.destroy\n end\n event.destroy\n redirect_to events_url\n end",
"def teardown\r\n end",
"def removeSolvent\n @solvents = nil\n end",
"def cleanup_hook; end",
"def after_destroy(event)\n expire_cache_for(event)\n end",
"def after_destroy(event)\n expire_cache_for(event)\n end",
"def delete\n MoxiworksPlatform::Event.delete(self.to_hash)\n end",
"def destroy\n @event_configurations.destroy\n head :no_content\n end",
"def teardown; end",
"def teardown; end",
"def destroy\n @event.destroy\n\n sync_destroy @event\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def cleanup_expired_events\n cleanup_script(keys: @event_list.key, argv: expires_at)\n end",
"def free_resources\n\t\tunset_vim_event_hooks\n\tend",
"def destroy\n #@event_event.destroy\n @event_event.deleted = true\n dest = @event_event.id\n type = 7 #event_notifications_code\n Notification.clear_notifications(type,dest)\n @event_event.save\n @event_event.user.remove_event\n respond_to do |format|\n format.html { redirect_to admin_event_events_url, notice: 'Event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def clear_common_event\r\n @common_event_id = 0\r\n end",
"def on_cleanup(unit); end",
"def destroy\n \t@expected_event.destroy\n \trespond_to do |format|\n \t\tformat.html { redirect_to expected_events_url }\n \tend\n end",
"def destroy\n @event = Event.find(params[:id])\n\tinitialize_object_and_day \n @event.destroy\n\trender :index\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def destroy\n\t\t@event.destroy\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to events_url }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def after_destroy_hook\n execute_hooks_for(:after, :destroy)\n end",
"def future_single_events_cleanup\n self.single_events.rule_based_in_future.each do |single_event|\n single_event.delete unless schedule.occurs_at? single_event.occurrence\n end\n end",
"def unevent(name)\n Events.remove(name)\n end",
"def clear_common_event\n @common_event_id = 0\n end",
"def destroy\n @event.destroy\n set_event_unique_active Event.first\n respond_to do |format|\n format.html { redirect_to team_events_url, notice: 'Event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def deregister_event_handlers\n\t\tframework.events.remove_session_subscriber(self)\n\tend",
"def teardown\n @appointment = nil\n end",
"def teardown\n end",
"def destroy\n unless @disconnecting\n send_command 'QUIT'\n end\n\n unless @caps == nil\n @caps.destroy\n @caps = nil\n end\n\n Events.delete_for self\n end",
"def off(event_name)\n events.delete(event_name.to_sym)\n end",
"def destroy\n @event = Event.find(params[:id])\n @events = Event.where(event_id: params[:id])\n @events.each.destroy\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def teardown\n\t\t\t\t# Do nothing\n\t\tend",
"def destroy\n @dia_evento.destroy\n end",
"def clear_events() \n while (Gtk.events_pending?)\n Gtk.main_iteration\n end\nend",
"def destroy\n self.timelog_stop_tracking\n \n #Use quit-variable to avoid Gtk-warnings.\n Gtk.main_quit if @quit != true\n @quit = true\n end",
"def delete_this_event_forever\n $env.set_event_delete_state(@event_id)\n $game_map.events[@event_id]&.erase\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def cleanup\n\t\t\tself.framework.events.remove_session_subscriber(self)\n\t\t\tremove_console_dispatcher('notify')\n\t\tend",
"def cleanup\n\t\t\tself.framework.events.remove_session_subscriber(self)\n\t\t\tremove_console_dispatcher('notify')\n\t\tend",
"def teardown\n end",
"def teardown\n end",
"def after_teardown; end"
] | [
"0.75859725",
"0.7464302",
"0.7444678",
"0.7233316",
"0.7232815",
"0.7232815",
"0.7232815",
"0.71593434",
"0.70242894",
"0.69922",
"0.6950243",
"0.69470793",
"0.6945672",
"0.6735936",
"0.6680631",
"0.6668398",
"0.6634904",
"0.6612553",
"0.6602262",
"0.6592811",
"0.65802115",
"0.6570533",
"0.6563191",
"0.6562341",
"0.65505105",
"0.65484667",
"0.6538905",
"0.6538905",
"0.6538905",
"0.6534021",
"0.65143466",
"0.65048087",
"0.65037024",
"0.6466266",
"0.6461497",
"0.6454618",
"0.6453803",
"0.6444962",
"0.64417297",
"0.64414644",
"0.6439228",
"0.6439228",
"0.64325106",
"0.6430148",
"0.6428235",
"0.6428235",
"0.64151716",
"0.64131176",
"0.64114",
"0.6370867",
"0.6363784",
"0.63536835",
"0.6336808",
"0.63316596",
"0.63227403",
"0.63227403",
"0.63227403",
"0.63227403",
"0.63227403",
"0.63227403",
"0.63227403",
"0.63227403",
"0.63206685",
"0.63178164",
"0.63134044",
"0.63125795",
"0.6308032",
"0.6304744",
"0.6302648",
"0.6302268",
"0.62918323",
"0.62907594",
"0.62892026",
"0.62866104",
"0.62861365",
"0.62861365",
"0.62861365",
"0.62861365",
"0.6285788",
"0.6284965",
"0.62741673",
"0.62734026",
"0.62694633",
"0.626666",
"0.626666",
"0.626666",
"0.626666",
"0.626666",
"0.626666",
"0.626666",
"0.626666",
"0.626666",
"0.626666",
"0.626666",
"0.626666",
"0.626666",
"0.62630486",
"0.62630486",
"0.62626785",
"0.62626785",
"0.62593913"
] | 0.0 | -1 |
GET /admin/funcionarios/1 GET /admin/funcionarios/1.json | def show
@funcionario = Funcionario.find(params[:id])
respond_with @funcionario, :location => admin_funcionario_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @funcionario = Funcionario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @funcionario }\n end\n end",
"def index\n @funcionarios = Funcionario.all\n end",
"def index\n @funcionarios = Funcionario.all\n end",
"def index\n @usuario = current_usuario\n @funcionarios = @usuario.local.funcionarios.asc(:nome)\n end",
"def index\n @ferias_funcionarios = FeriasFuncionario.all\n end",
"def index\n @tipo_funcionarios = TipoFuncionario.all\n end",
"def show\n @empresa = Empresa.find(params[:id])\n @vagas = @empresa.vagas\n @funcionarios = nil\n if current_usuario.isCoordenador? or current_usuario.isAdmin?\n @funcionarios = @empresa.gestor\n @funcionarios << @empresa.admin_empresa\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @empresa }\n end\n end",
"def index\n @funcoes = Funcao.all\n end",
"def new\n @funcionario = Funcionario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @funcionario }\n end\n end",
"def index\n @funcionarios = Funcionario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @funcionarios }\n end\n end",
"def index\n @funcionarios = Funcionario.includes(:pessoa, :cargo)\n end",
"def index\n\t\trender json: { prueba: 'Funciona'}\n\tend",
"def index\n @usuarios = Usuario.por_colegio(colegio.id).order(\"nombre\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end",
"def destroy\n @funcionario = Funcionario.find(params[:id])\n @funcionario.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_funcionarios_url }\n format.json { head :no_content }\n end\n end",
"def show\n @funcionalidad = Funcionalidad.find(params[:funcionalidad_id])\n end",
"def index\n @funcionalidads = Funcionalidad.all\n end",
"def show\n @funcionario = Funcionario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @funcionario }\n end\n end",
"def index\n render json: @fiestas\n end",
"def get_ponto\n render json: Usuario.ultimo_ponto(params[:user_id], params[:evento_id]).to_json\n end",
"def create\n @funcionario = Funcionario.new(funcionario_params)\n respond_to do |format|\n if @funcionario.save\n format.html { redirect_to @funcionario, notice: 'Funcionário cadastrado com sucesso' }\n format.json { render :show, status: :created, location: @funcionario }\n else\n format.html { render :new }\n format.json { render json: @funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @realiza = Realiza.new\n @pessoas=Pessoa.select(\"clientes.id,pessoas.nome\").joins(:cliente)\n @funcionarios=Pessoa.select(\"usuarios.id,pessoas.nome\").joins(:usuario)\n #@pessoas=Pessoa.select(\"clientes.id,pessoas.nome\").joins(:clientes)\n #@funcionarios=Pessoa.where(\"id in (?)\",Usuario.select(\"pessoa_id as id\").map(&:id))\n @servicos=Servico.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @realiza and @pessoas and @funcionarios and @servicos}\n end\n end",
"def new\n @funcionario = Funcionario.new\n @funcionario.contato_telefones.build\n respond_with @funcionario, :location => new_admin_funcionario_path\n end",
"def index\n @tipo_usuarios = TipoUsuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tipo_usuarios }\n end\n end",
"def consulta\n fiesta = Fiesta.all\n render json: fiesta\n end",
"def show\n authorize! :read, Registro\n respond_to do |format|\n format.html { redirect_to registros_url}\n format.json { head :no_content }\n end\n end",
"def index\n @futboladas = Futbolada.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @futboladas }\n end\n end",
"def index\n @user_funs = UserFun.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @user_funs }\n end\n end",
"def set_funcionario\n @funcionario = Funcionario.find(params[:id])\n end",
"def set_funcionario\n @funcionario = Funcionario.find(params[:id])\n end",
"def set_funcionario\n @funcionario = Funcionario.find(params[:id])\n end",
"def set_funcionario\n @funcionario = Funcionario.find(params[:id])\n end",
"def show\n @administrativo = Administrativo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @administrativo }\n end\n end",
"def index\n @admin_functions = Admin::Function.all\n end",
"def index\n @familia = Familium.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @familia }\n end\n end",
"def index\n \treclamos = Reclamo.all\n \trender json: reclamos.to_json(include: [:tipo_reclamo, :ubicacion, :user], methods: [:valoracion])\n end",
"def index\n find_dependencias\n respond_to do |format|\n format.html\n format.json { render :json => @dependencias.to_json(:methods => :alias_or_fullname, :only => [:id, :codigo, :nombre])}\n\n end\n end",
"def index\n @fiados = current_user.fiados\n end",
"def index\n authorize! :admin, Coordenador\n \n @coordenadores = Coordenador.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @coordenadores }\n end\n end",
"def index\n if current_user.has_any_role? :admin, :acceso\n respond_to do |format|\n format.html\n format.json { render json: InfoRequestDatatable.new(view_context) }\n end\n else\n redirect_to :root\n end\n end",
"def InfoFarmacia\n \tid = params[:id]\n @farmacias = Farmacium.find_by_sql(\"SELECT nombre, correo, direccion, latitud, longitud, telefono1, telefono2 FROM farmacia where id = #{id}\")\n render json: @farmacias\n end",
"def index\n @usuarios = Usuario.all\n # respond_to do |format|\n # format.html\n # format.json { render :json => @usuarios }\n # end\n end",
"def index\n \n if current_user.tipo == 2\n @receita_medicas = ReceitaMedica.where(:medico_id => current_user.id)\n elsif current_user.tipo == 1\n @receita_medicas = ReceitaMedica.where(:paciente_id => current_user.id)\n elsif current_user.tipo == 3\n @receita_medicas = Venda.receitas_medicas(current_user.id)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @receita_medicas }\n end\n end",
"def index\n @tipo_denuncia = TipoDenuncium.all\n\n render json: @tipo_denuncia\n end",
"def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @funerals }\n end\n end",
"def expiracion\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @usuario }\n end\n end",
"def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end",
"def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end",
"def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end",
"def index\n @funs = Fun.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @funs }\n end\n end",
"def index\n @deporte_usuarios = DeporteUsuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deporte_usuarios }\n end\n end",
"def index\n @seguridad_usuarios = Seguridad::Usuario.order('usuario')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @seguridad_usuarios }\n end\n end",
"def index\n return if !current_user.admin?\n @disfrazs = Disfraz.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @disfrazs }\n end\n end",
"def update\n respond_to do |format|\n if @funcao.update(funcao_params)\n format.html { redirect_to @funcao, notice: 'Funcao was successfully updated.' }\n format.json { render :show, status: :ok, location: @funcao }\n else\n format.html { render :edit }\n format.json { render json: @funcao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @funeral }\n end\n end",
"def create\n @funcao = Funcao.new(funcao_params)\n\n respond_to do |format|\n if @funcao.save\n format.html { redirect_to @funcao, notice: 'Funcao was successfully created.' }\n format.json { render :show, status: :created, location: @funcao }\n else\n format.html { render :new }\n format.json { render json: @funcao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @fulcliente = Fulcliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fulcliente }\n end\n end",
"def destroy\n @funcionario = Funcionario.find(params[:id])\n @funcionario.destroy\n\n respond_to do |format|\n format.html { redirect_to funcionarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @funcionario.destroy\n respond_to do |format|\n format.html { redirect_to funcionarios_url, notice: 'Funcionário apagado.' }\n format.json { head :no_content }\n end\n end",
"def index\n @fonctions = Fonction.all\n end",
"def show\n @conta = Conta.find(params[:id])\n respond_to do |format|\n format.html { render :show }\n format.json { render json: @conta, :include => {\n :movimentos => {\n :include => [:nota, :pessoa],\n :methods => [:favorecido],\n :except => [:created_at, :updated_at]\n }\n },\n :methods => [:saldo]\n }\n end\n end",
"def show\n @lista_contato = ListaContato.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lista_contato }\n end\n end",
"def set_funcao\n @funcao = Funcao.find(params[:id])\n end",
"def set_ferias_funcionario\n @ferias_funcionario = FeriasFuncionario.find(params[:id])\n end",
"def consultarFtp\n #Antes de procesar las ordenes, se actualiza la Bodega\n IniciarBodega.new('grupo7').actualizarBodega\n #Se consulta las ordenes\n ordenesConsultadas= ConsultarPedidosFtp.new.consultarOcsFTP\n render json: ordenesConsultadas\nend",
"def index\n @calificaciones = Calificacion.order('created_at DESC').all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @calificaciones }\n end\n end",
"def index\n @minicursos = Minicurso.all\n\t\t#@minicursos = Minicurso.scoped\n\t\t#@users = Minicurso.inscritos(params[:id]) if params[:id].present?\n\n respond_to do |format|\n\t\t\t format.html # index.html.erb\n\t\t\t format.json { render json: @minicursos }\n end\n end",
"def update\n @funcionario = Funcionario.find(params[:id])\n\n respond_to do |format|\n if @funcionario.update_attributes(params[:funcionario])\n format.html { render :json => {:success => true} }\n format.xml { render :xml => @funcionario, :status => :created, :location => @funcionario }\n else\n format.html { render :json => ( (@funcionario.errors.full_messages.join(\".<br />\").to_s + \".\").to_json ) } unless @funcionario.errors.empty?\n end\n end\n end",
"def index\n @administradors = Administrador.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @administradors }\n end\n end",
"def create\n @funcionario = Funcionario.new(funcionario_params)\n\n respond_to do |format|\n if @funcionario.save\n format.html { redirect_to @funcionario, notice: \"Funcionario was successfully created.\" }\n format.json { render :show, status: :created, location: @funcionario }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @usuario = Usuario.find(params[:id])\n\n render json: @usuario\n end",
"def FarmaciasCercanas\n @farmacias = Farmacium.find_by_sql(\"SELECT id, nombre,latitud, longitud FROM farmacia where correo <> 'ADMIN'\")\n render json: @farmacias\n end",
"def index\n if params[:usuario_producto]\n @usuario = Usuario.find(params[:usuario_id])\n render json: @usuario.productos\n else\n @productos = Producto.all\n render json: @productos\n end\n end",
"def show\n @usuario = Usuario.find(params[:id])\n render json: @usuario\n end",
"def show\n @usuario = Usuario.find(params[:id])\n render json: @usuario\n end",
"def show\n fatura = Fatura.find(params[:id])\n render json: {status: 'SUCCESS', message:'Fatura loaded', data:fatura}, status: :ok\n end",
"def index\n @antecedentes = Antecedente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @antecedentes }\n end\n end",
"def index\n rol = Role.where(:id=>current_user.role).first\n if rol.nombre == \"DN\" or rol.nombre == \"ACRM\"\n @colegiaturas = Colegiatura.all\n else\n @colegiaturas = Colegiatura.where(:sede_id=>current_user.sede)\n end \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @colegiaturas }\n end\n end",
"def update\n @funcionario = Funcionario.find(params[:id])\n\n respond_to do |format|\n if @funcionario.update_attributes(params[:funcionario])\n format.html { redirect_to [:admin, @funcionario], notice: 'Funcionario Atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @odontologia1 = Odontologia1.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @odontologia1 }\n end\n end",
"def index\n @ventas = Venta.order(\"fecha desc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas }\n end\n end",
"def index\n @formatos = Formato.where(ativo: true)\n \t\n render json: @formatos\n end",
"def index\n @perfiles_transacciones = PerfilTransaccion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @perfiles_transacciones }\n end\n end",
"def index\n @funtions = Funtion.all\n end",
"def index\n @fichiers = Fichier.where(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @fichiers }\n end\n end",
"def index\n @listas_contato = ListaContato.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @listas_contato }\n end\n end",
"def index\n @cooperativas = Cooperativa.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cooperativas }\n end\n end",
"def index\n #Cada user puede ver los eventos en los que ha sido elegido como responsable\n #El admin puede verlos todos\n if current_user.admin or current_user.ingeniero\n @gestion_eventos= Gestion::Evento.all if current_user.admin or current_user.ingeniero\n elsif\n @gestion_eventos= Gestion::Evento.where(:usuario_id => current_user.perfil_id) \n end\n respond_to do |format|\n format.html\n format.xml { render xml: @gestion_eventos}\n format.json { render json: @gestion_eventos.map{|u| [\"title\" => \"#{u.titulo} (#{u.descripcion})\", \"url\" => gestion_evento_path(u)]}.flatten}\n end\n end",
"def index\n @foros = Foro.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @foros }\n end\n end",
"def show\n @venta = Venta.find(params[:id])\n\n @domicilios = Domicilio.where(usuario_id: @venta.usuario.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @venta }\n end\n end",
"def index\n @factura = Factura.find(params[:factura_id])\n @renglon_facturas = @factura.renglon_facturas\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @renglon_facturas }\n end\n end",
"def show\r\n render json: @registro_medicion.to_json, status: :ok\r\n end",
"def fd_funcionario_params\n params.require(:fd_funcionario).permit(:nome_funcionario, :desc_telefone, :desc_celular, :data_exclusao, :fd_cargo_id, :fd_endereco_id, :fd_empresa_id)\n end",
"def index\n @usuarios = Usuario.all\n @usuarios_json = @usuarios.to_json\n end",
"def index\n @faturas = Fatura.all\n end",
"def show\n @tipo_usuario = TipoUsuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_usuario }\n end\n end",
"def show\n @solicitud_servicio = SolicitudServicio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @solicitud_servicio }\n end\n end",
"def index\n @fretes = Frete.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fretes }\n end\n end",
"def index\n @ofertas = Oferta.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ofertas }\n end\n end",
"def destroy\n @funcao.destroy\n respond_to do |format|\n format.html { redirect_to funcoes_url, notice: 'Funcao was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n @peticion_servicio_tis = Peticion::ServicioTi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @peticion_servicio_tis }\n end\n end"
] | [
"0.7249679",
"0.70558417",
"0.70558417",
"0.70295674",
"0.6838803",
"0.68160063",
"0.6718118",
"0.66828966",
"0.6593217",
"0.6485803",
"0.645231",
"0.6447877",
"0.63661695",
"0.62970614",
"0.6265304",
"0.623989",
"0.6210647",
"0.6198975",
"0.6187996",
"0.6182959",
"0.6152777",
"0.61489433",
"0.6112884",
"0.6098761",
"0.609424",
"0.6078578",
"0.6061363",
"0.60576004",
"0.60576004",
"0.60576004",
"0.60576004",
"0.6051922",
"0.60422033",
"0.6041911",
"0.6020414",
"0.60086274",
"0.5998955",
"0.59800845",
"0.5977455",
"0.5972606",
"0.59705484",
"0.5968235",
"0.5958954",
"0.59513944",
"0.59505403",
"0.59472996",
"0.59472996",
"0.59472996",
"0.5939215",
"0.5933928",
"0.5929865",
"0.59295106",
"0.59068304",
"0.5895268",
"0.5891672",
"0.5890272",
"0.5886557",
"0.5883208",
"0.5872231",
"0.5868597",
"0.5866872",
"0.5864351",
"0.58569247",
"0.58552134",
"0.5850487",
"0.5848807",
"0.5848146",
"0.58306307",
"0.58236057",
"0.5820981",
"0.5816961",
"0.58121514",
"0.5801143",
"0.5801143",
"0.5793046",
"0.5789919",
"0.5782796",
"0.5781217",
"0.5780086",
"0.5768877",
"0.5755954",
"0.5748899",
"0.57469314",
"0.5745244",
"0.57440233",
"0.57433087",
"0.57385176",
"0.5734662",
"0.5725914",
"0.57221687",
"0.5707836",
"0.57035905",
"0.5703587",
"0.56974846",
"0.5693139",
"0.5688577",
"0.5687397",
"0.56855905",
"0.56822926",
"0.5676207"
] | 0.7101302 | 1 |
GET /admin/funcionarios/new GET /admin/funcionarios/new.json | def new
@funcionario = Funcionario.new
@funcionario.contato_telefones.build
respond_with @funcionario, :location => new_admin_funcionario_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @funcionario = Funcionario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @funcionario }\n end\n end",
"def create\n @tipo_funcionario = TipoFuncionario.new(tipo_funcionario_params)\n\n respond_to do |format|\n if @tipo_funcionario.save\n format.html { redirect_to @tipo_funcionario, notice: 'Tipo funcionario was successfully created.' }\n format.json { render action: 'show', status: :created, location: @tipo_funcionario }\n else\n format.html { render action: 'new' }\n format.json { render json: @tipo_funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @funcionario = Funcionario.new(funcionario_params)\n respond_to do |format|\n if @funcionario.save\n format.html { redirect_to @funcionario, notice: 'Funcionário cadastrado com sucesso' }\n format.json { render :show, status: :created, location: @funcionario }\n else\n format.html { render :new }\n format.json { render json: @funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @funcao = Funcao.new(funcao_params)\n\n respond_to do |format|\n if @funcao.save\n format.html { redirect_to @funcao, notice: 'Funcao was successfully created.' }\n format.json { render :show, status: :created, location: @funcao }\n else\n format.html { render :new }\n format.json { render json: @funcao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @new = true\n @administrativo = Administrativo.new\n @administrativo.build_user\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @administrativo }\n end\n end",
"def new\n @funcionario = Funcionario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @funcionario }\n end\n end",
"def create\n @funcionario = Funcionario.new(funcionario_params)\n\n respond_to do |format|\n if @funcionario.save\n format.html { redirect_to @funcionario, notice: \"Funcionario was successfully created.\" }\n format.json { render :show, status: :created, location: @funcionario }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @funcionario = Funcionario.new(params[:funcionario])\n\n @funcionario.senha = \"padrao\"\n\n respond_to do |format|\n if @funcionario.save\n format.html { redirect_to @funcionario, notice: 'Funcionario was successfully created.' }\n format.json { render json: @funcionario, status: :created, location: @funcionario }\n else\n format.html { render action: \"new\" }\n format.json { render json: @funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @cliente = Cliente.new\n localidad_new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cliente }\n end\n end",
"def create\n @funcionalidad = Funcionalidad.new(funcionalidad_params)\n\n respond_to do |format|\n if @funcionalidad.save\n format.html { redirect_to @funcionalidad, notice: 'Funcionalidad was successfully created.' }\n format.json { render :show, status: :created, location: @funcionalidad }\n else\n format.html { render :new }\n format.json { render json: @funcionalidad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @tipo_usuario = TipoUsuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_usuario }\n end\n end",
"def creacion\n fiesta = Fiesta.new (params[:id])\n if Fiesta.save\n puts \"su fiesta a sido registrada\"\n else \n puts \"su fiesta no a sido registrada\"\n end\n render = json: fiesta \n end",
"def new\n\tadd_breadcrumb \"Nuevo usuario\", :new_usuario_path\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @usuario }\n end\n end",
"def new\n @tecnico = Tecnico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tecnico }\n end\n end",
"def create\n @ferias_funcionario = FeriasFuncionario.new(ferias_funcionario_params)\n\n respond_to do |format|\n if @ferias_funcionario.save\n format.html { redirect_to @ferias_funcionario, notice: 'Ferias funcionario was successfully created.' }\n format.json { render :show, status: :created, location: @ferias_funcionario }\n else\n format.html { render :new }\n format.json { render json: @ferias_funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @funcionario = Funcionario.new(funcionario_params)\n\n\n if @funcionario.save\n flash[:success] = \"Funcionario: #{@funcionario.pessoa.nome} Cadastrado com sucesso!\"\n redirect_to @funcionario\n else\n flash[:danger] = \"Erro ao tentar cadastrar Funcionário!\"\n render :new\n end\n\n end",
"def new\n @fun = Fun.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @fun }\n end\n end",
"def new\n @lista_contato = ListaContato.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lista_contato }\n end\n end",
"def new\n @trnodo = Trnodo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trnodo }\n end\n end",
"def new\n @tipo_convenio = TipoConvenio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_convenio }\n end\n end",
"def new\n @persona_tipo = PersonaTipo.new\n if current_user.is_admin?\n @congresos = Congreso.all(:order => \"nombre\")\n else\n @congresos = current_user.congresos(:order => \"nombre\")\n end\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @persona_tipo }\n end\n end",
"def new\n @tecnico = Tecnico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @tecnico }\n end\n end",
"def new\n @venta = Venta.new(:fecha => Date.today, confirmada: true)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @venta }\n end\n end",
"def new\n @tipo_pensum = TipoPensum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_pensum }\n end\n end",
"def new\n @puntaje = Puntaje.new\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def new\n @puntaje = Puntaje.new\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def new\n @trlocalidad = Trlocalidad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trlocalidad }\n end\n end",
"def new\n @tipo_actividad = TipoActividad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_actividad }\n end\n end",
"def new\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usuario }\n end\n end",
"def new\n @ficha = Ficha.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ficha }\n end\n end",
"def new\n @sistema = Sistema.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sistema }\n end\n end",
"def create\n authorize! :create, Tipo\n @tipo = Tipo.new(tipo_params)\n log(\"Se ha creado la nomina #{@lt}\", 0)\n\n respond_to do |format|\n if @tipo.save\n format.html { redirect_to tipos_path, notice: 'La nómina fue creada exitosamente.' }\n format.json { render :show, status: :created, location: @tipo }\n else\n format.html { render :new }\n format.json { render json: @tipo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @fornecedor_custo = FornecedorCusto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fornecedor_custo }\n end\n end",
"def new\n @tipo_negocio = TipoNegocio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_negocio }\n end\n end",
"def new\n @administrador = Administrador.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @administrador }\n end\n end",
"def new\n @servicio = Servicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @servicio }\n end\n end",
"def new\n @lista = Lista.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lista }\n end\n end",
"def new\n @requerimiento = Requerimiento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @requerimiento }\n end\n end",
"def nuevo\n authorize! :new, Cor1440Gen::Actividad\n if !params[:actividad_id].nil?\n @detfinanciero = Detallefinanciero.new\n @detfinanciero.actividad_id = params[:actividad_id]\n if @detfinanciero.save(validate: false)\n respond_to do |format|\n format.js { render text: @detfinanciero.id.to_s }\n format.json { render json: @detfinanciero.id.to_s, \n status: :created }\n format.html { render inline: @detfinanciero.id.to_s }\n end\n else\n respond_to do |format|\n format.html { \n render inline: \"No pudo crear fuente frecuente: \" +\n \"'#{@detfinanciero.errors.message.to_s}'\" \n }\n format.json { \n render json: @detfinanciero.errors, \n status: :unprocessable_entity \n }\n end\n end\n else\n respond_to do |format|\n format.html { render inline: 'Falta identificacion de la actividad' }\n end\n end\n end",
"def new\n \tauthorize! :new, @palestrante\n @palestrante = Palestrante.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @palestrante }\n end\n end",
"def new\n render :json => @fiestas.push(params[:fiesta])\n end",
"def new\n @prestacion = Prestacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prestacion }\n end\n end",
"def new\n @comentario = Comentario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comentario }\n end\n end",
"def create\n authorize! :create, Tipo\n @tipo = Tipo.new(tipo_params)\n\n\n respond_to do |format|\n if @tipo.save\n format.html { redirect_to tipos_path, notice: '<i class=\"fa fa-check-square fa-lg\"></i> La nómina fue creada exitosamente.' }\n format.json { render :show, status: :created, location: @tipo }\n else\n format.html { render :new }\n format.json { render json: @tipo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @caixa = Caixa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @caixa }\n end\n end",
"def new\n @estatuto = Estatuto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @estatuto }\n end\n end",
"def new\n @producto = Producto.new\n @producto.alimento = true #Para que aparezca un default en el select\n usuarios = Usuario.where(:admin => 0) #Para coleccion del dueño del producto\n prod = Producto.all\n @marcas = get_marcas(prod)\n @fabricantes = get_fabricantes(prod)\n @companias = []\n for elem in usuarios do\n @companias.push([elem.compania, elem.id])\n end\n flash[:accion] = \"Crear Producto\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @producto }\n end\n end",
"def new\n @recurso = Recurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recurso }\n end\n end",
"def new\n @ordinario = Ordinario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ordinario }\n end\n end",
"def new\n @denuncia_tipo = DenunciaTipo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @denuncia_tipo }\n end\n end",
"def new\n @publicidad = Publicidad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @publicidad }\n end\n end",
"def new\n @futbolada = Futbolada.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @futbolada }\n end\n end",
"def new\n @forma_entrega = FormaEntrega.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @forma_entrega }\n end\n end",
"def new\n @paciente = Paciente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @paciente }\n end\n end",
"def new_for_order\n @cliente = Cliente.new\n\n respond_to do |format|\n format.html\n format.json { render json: @cliente }\n end\n end",
"def new\n @empresa = Empresa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @empresa }\n end\n end",
"def new\n @metodo = Metodo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @metodo }\n end\n end",
"def new\n @tipo_atendimento = TipoAtendimento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_atendimento }\n end\n end",
"def new\n @comisaria = Comisaria.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comisaria }\n end\n end",
"def new\n @sezione = Sezione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sezione }\n end\n end",
"def new\n seleccionarMenu(:juzgados)\n @juzgado = Juzgado.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @juzgado }\n end\n end",
"def new\n @zoneamento = Zoneamento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @zoneamento }\n end\n end",
"def new\n @prioridade = Prioridade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prioridade }\n end\n end",
"def new\n @frete = Frete.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @frete }\n end\n end",
"def new\n @estacionamiento = Estacionamiento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @estacionamiento }\n end\n end",
"def new\n @odontologia1 = Odontologia1.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @odontologia1 }\n end\n end",
"def new\n @new = true\n @alumno = Alumno.new\n @alumno.build_user\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @alumno }\n end\n end",
"def new\n @utente = Utente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @utente }\n end\n end",
"def new\n @formulario = Formulario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @formulario }\n end\n end",
"def new\n @calificacion_servicio = CalificacionServicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @calificacion_servicio }\n end\n end",
"def new\n @custo = Custo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @custo }\n end\n end",
"def new\n @categorias_tipo = CatTipo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @categorias_tipo }\n end\n end",
"def new\n @calificacion = Calificacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @calificacion }\n end\n end",
"def new\n @calificacion = Calificacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @calificacion }\n end\n end",
"def new\n @publicidade = Publicidade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @publicidade }\n end\n end",
"def new\n @selecao = Selecao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @selecao }\n end\n end",
"def new\n @peso = Peso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @peso }\n end\n end",
"def new\n @telefononegocio = Telefononegocio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @telefononegocio }\n end\n end",
"def new\n @indicativo = Indicativo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @indicativo }\n end\n end",
"def new\n @actividad = Actividad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @actividad }\n end\n end",
"def new\n @pagamento = Pagamento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pagamento }\n end\n end",
"def new\n @sitio_entrega = SitioEntrega.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sitio_entrega }\n end\n end",
"def new\n authorize! :admin, Coordenador\n \n @coordenador = Coordenador.new\n @coordenador.build_usuario\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @coordenador }\n end\n end",
"def new\n @solicitud_servicio = SolicitudServicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @solicitud_servicio }\n end\n end",
"def new\n @producto = Producto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @producto }\n end\n end",
"def new\n @perfilnegocio = Perfilnegocio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @perfilnegocio }\n end\n end",
"def new\n @prestador = Prestador.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prestador }\n end\n end",
"def new\n @modelo = Modelo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @modelo }\n end\n end",
"def new\r\n @administrateur = Administrateur.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @administrateur }\r\n end\r\n end",
"def new\n @veiculo = Veiculo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @veiculo }\n end\n end",
"def new\n @asociado = Asociado.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @asociado }\n end\n end",
"def new\n @pedido = Pedido.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pedido }\n end\n end",
"def new\n @usuario = User.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usuario }\n end\n end",
"def new\n @contrato = Contrato.new\n\n respond_to do |format|\n format.html { render layout: nil } # new.html.erb\n format.json { render json: @contrato }\n end\n end",
"def new\n @sugerencia = Sugerencia.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @sugerencia }\n end\n end",
"def new\n @colegio = Colegio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @colegio }\n end\n end",
"def new\n @dos = CreateDo.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @dos }\n end \n end",
"def new\n @tenni = Tenni.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tenni }\n end\n end",
"def new\n @dato = Dato.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dato }\n end\n end",
"def new\n @locacao = Locacao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @locacao }\n end\n end"
] | [
"0.79055303",
"0.7298924",
"0.72745794",
"0.7200279",
"0.7192419",
"0.7169684",
"0.71055186",
"0.6987913",
"0.696834",
"0.69390494",
"0.68903315",
"0.68157226",
"0.6777903",
"0.67569673",
"0.6734827",
"0.6729333",
"0.67257786",
"0.67065614",
"0.6702373",
"0.66999155",
"0.6692989",
"0.6692363",
"0.669226",
"0.6690772",
"0.6672698",
"0.6672698",
"0.66626",
"0.6657126",
"0.6651141",
"0.6641337",
"0.66370714",
"0.66365296",
"0.6626308",
"0.662445",
"0.66219556",
"0.6610069",
"0.6604589",
"0.66007626",
"0.6591909",
"0.65912247",
"0.6589549",
"0.65892667",
"0.6589133",
"0.65817404",
"0.6575609",
"0.6574682",
"0.65739113",
"0.6573061",
"0.6568549",
"0.6561681",
"0.6556551",
"0.65490997",
"0.65461624",
"0.65448856",
"0.6543263",
"0.65388757",
"0.6538279",
"0.65276015",
"0.65239257",
"0.65216017",
"0.65212697",
"0.65147537",
"0.6511377",
"0.6493352",
"0.64928746",
"0.64926004",
"0.64910924",
"0.64863116",
"0.6484843",
"0.6484688",
"0.6481916",
"0.64817977",
"0.64814734",
"0.64814734",
"0.6480501",
"0.64782554",
"0.64718926",
"0.64711285",
"0.6468433",
"0.6467735",
"0.6459214",
"0.6454964",
"0.64533484",
"0.6452933",
"0.64526826",
"0.6452043",
"0.64510155",
"0.6450019",
"0.6449866",
"0.6444526",
"0.64360845",
"0.64360464",
"0.6435769",
"0.64355594",
"0.643443",
"0.6433735",
"0.6432992",
"0.6427426",
"0.6425044",
"0.6422774"
] | 0.7700561 | 1 |
POST /admin/funcionarios POST /admin/funcionarios.json | def create
@funcionario = Funcionario.new(params[:funcionario])
if current_user.is_role?(:administrador)
else
@funcionario.user = current_user
end
flash[:notice] = "Funcionario salvo com sucesso!" if @funcionario.save
# respond_with @funcionario, :location => [:admin, @funcionario]
redirect_to admin_funcionarios_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @funcionario = Funcionario.new(funcionario_params)\n respond_to do |format|\n if @funcionario.save\n format.html { redirect_to @funcionario, notice: 'Funcionário cadastrado com sucesso' }\n format.json { render :show, status: :created, location: @funcionario }\n else\n format.html { render :new }\n format.json { render json: @funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @funcionario = Funcionario.new(funcionario_params)\n\n respond_to do |format|\n if @funcionario.save\n format.html { redirect_to @funcionario, notice: \"Funcionario was successfully created.\" }\n format.json { render :show, status: :created, location: @funcionario }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @funcao = Funcao.new(funcao_params)\n\n respond_to do |format|\n if @funcao.save\n format.html { redirect_to @funcao, notice: 'Funcao was successfully created.' }\n format.json { render :show, status: :created, location: @funcao }\n else\n format.html { render :new }\n format.json { render json: @funcao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @funcionario = Funcionario.new(params[:funcionario])\n\n @funcionario.senha = \"padrao\"\n\n respond_to do |format|\n if @funcionario.save\n format.html { redirect_to @funcionario, notice: 'Funcionario was successfully created.' }\n format.json { render json: @funcionario, status: :created, location: @funcionario }\n else\n format.html { render action: \"new\" }\n format.json { render json: @funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipo_funcionario = TipoFuncionario.new(tipo_funcionario_params)\n\n respond_to do |format|\n if @tipo_funcionario.save\n format.html { redirect_to @tipo_funcionario, notice: 'Tipo funcionario was successfully created.' }\n format.json { render action: 'show', status: :created, location: @tipo_funcionario }\n else\n format.html { render action: 'new' }\n format.json { render json: @tipo_funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ferias_funcionario = FeriasFuncionario.new(ferias_funcionario_params)\n\n respond_to do |format|\n if @ferias_funcionario.save\n format.html { redirect_to @ferias_funcionario, notice: 'Ferias funcionario was successfully created.' }\n format.json { render :show, status: :created, location: @ferias_funcionario }\n else\n format.html { render :new }\n format.json { render json: @ferias_funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @funcionalidad = Funcionalidad.new(funcionalidad_params)\n\n respond_to do |format|\n if @funcionalidad.save\n format.html { redirect_to @funcionalidad, notice: 'Funcionalidad was successfully created.' }\n format.json { render :show, status: :created, location: @funcionalidad }\n else\n format.html { render :new }\n format.json { render json: @funcionalidad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def fd_funcionario_params\n params.require(:fd_funcionario).permit(:nome_funcionario, :desc_telefone, :desc_celular, :data_exclusao, :fd_cargo_id, :fd_endereco_id, :fd_empresa_id)\n end",
"def funcionario_params\n params.require(:funcionario).permit(:nome, :email, :password, :password_confirmation)\n end",
"def funcao_params\n params.require(:funcao).permit(:funcao)\n end",
"def funcionario_params\n params.require(:funcionario).permit([:componente_curricular,:nome, :cpf, :cadastro, :classe, :padrao, :turmas, :carga_horaria, :ambiente,:ambiente_nao_docente, :formacao, :ch_em_sala, :cargo, :quadro, :concurso, :area_concurso, :programa, :situacao, :local_id,:local, :disciplina_concurso, :disciplina_atuacao, :municipio_concurso])\n end",
"def ferias_funcionario_params\n params.require(:ferias_funcionario).permit(:funcionario_id, :data_inicio, :data_fim)\n end",
"def funcionario_params\n params.require(:funcionario).permit(:cod, :carteira_trabalho, :salario, :data_admissao, :pessoa_id,\n :cargo_id, :carga_horaria, usuario_attributes: [:email, :password, :funcionario_id, :_destroy],\n pessoa_attributes: [:id, :nome, :cpf, :rg, :data_nascimento, :nome_fantasia, :cnpj, :inscricao_estadual, :data_abertura,\n enderecos_attributes: [:id, :logradouro, :bairro, :numero, :complemento, :cidade_id, :cep, :_destroy],\n fones_attributes: [:id, :numero, :_destroy],\n emails_attributes: [:id, :descricao, :_destroy]])\n end",
"def create\n @funcionario = Funcionario.new(funcionario_params)\n\n\n if @funcionario.save\n flash[:success] = \"Funcionario: #{@funcionario.pessoa.nome} Cadastrado com sucesso!\"\n redirect_to @funcionario\n else\n flash[:danger] = \"Erro ao tentar cadastrar Funcionário!\"\n render :new\n end\n\n end",
"def funcionario_params\n params.require(:funcionario).permit(:pessoa_id, :cargo_id, :salario, :dataContratacao, pessoa_attributes: [:nome, :rua, :bairro, :sexo, :telefone, :email])\n end",
"def create\n\t\tauthorize! :create, AsignacionFuncion\n @asignacion_funcion = AsignacionFuncion.new(asignacion_funcion_params)\n\n respond_to do |format|\n if @asignacion_funcion.save\n\t\t\t\tsesion= Sesion.find_by(usuario_id: current_usuario.id, fechaFin: nil)\n\t\t\t\tTransaccion.create!(\n \t\t\t\tdescripcion: \"Creación asociación rol #{@asignacion_funcion.rol.nombre} al usuario #{@asignacion_funcion.usuario.nombreUsuario}: actual = #{ t @asignacion_funcion.esActual.to_s}\",\n \t\t\t\tsesion_id: sesion.id\n\t\t\t\t)\n format.html { redirect_to @asignacion_funcion\n flash[:success] = 'Asignacion funcion fue creado satisfactoriamente.' }\n format.json { render :show, status: :created, location: @asignacion_funcion }\n else\n format.html { render :new }\n format.json { render json: @asignacion_funcion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @funcionario = Funcionario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @funcionario }\n end\n end",
"def funcionalidad_params\n params.require(:funcionalidad).permit(:descripcion)\n end",
"def new\n @funcionario = Funcionario.new\n @funcionario.contato_telefones.build\n respond_with @funcionario, :location => new_admin_funcionario_path\n end",
"def create\n @admin_function = Admin::Function.new(admin_function_params)\n\n respond_to do |format|\n if @admin_function.save\n format.html { redirect_to @admin_function, notice: 'Function was successfully created.' }\n format.json { render :show, status: :created, location: @admin_function }\n else\n format.html { render :new }\n format.json { render json: @admin_function.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tipo_funcionario_params\n params.require(:tipo_funcionario).permit(:tipo)\n end",
"def create\n @ums_function = Ums::Function.new(ums_function_params)\n\n respond_to do |format|\n if @ums_function.save\n format.html { redirect_to ums.functions_url, notice: '功能创建创建成功.' }\n format.json { render action: 'show', status: :created, location: @ums_function }\n else\n format.html { render action: 'new' , status: :unprocessable_entity}\n format.json { render json: @ums_function.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @funcionarios = Funcionario.all\n end",
"def index\n @funcionarios = Funcionario.all\n end",
"def create\n @funcion_control = FuncionControl.new(funcion_control_params)\n @funcionalidad = Funcionalidad.find(@funcion_control.funcionalidad_id)\n \n respond_to do |format|\n if @funcion_control.save\n format.html { redirect_to funcionalidad_funcion_control_path(@funcionalidad, @funcion_control), notice: 'Registro creado exitosamente.' }\n #format.json { render action: 'show', status: :created, location: @funcion_control }\n \n else\n format.html { render action: 'new' }\n format.json { render json: @funcion_control.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @funcionario = Funcionario.new\n @funcionario.pessoa = PessoaFisica.new\n @funcionario.assign_attributes(funcionario_params)\n if @funcionario.save\n flash[:notice] = \"Funcionario salvo com sucesso\"\n redirect_to actions: \"index\"\n else\n render :new\n end\n end",
"def create\n @func = Func.new(func_params)\n\n respond_to do |format|\n if @func.save\n format.html { redirect_to @func, notice: 'Func was successfully created.' }\n format.json { render :show, status: :created, location: @func }\n else\n format.html { render :new }\n format.json { render json: @func.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n funcionario_new\n respond_to do |format|\n if @user.save\n @rol_usuario=RolUsuario.new(:id_usuario=>@user.id,:id_rol=>params[:id_rol])\n @rol_usuario.save\n format.html { redirect_to @user, notice: 'Los datos del usuario se han creado correctamente.' }\n CustomLogger.info(\"Se ha creado un nuevo Usuario. Datos: Usuario:#{@user.username.inspect},Nueva Contrasena pertenecientes al Funcionario:#{@user.funcionario.nombres.inspect} .Usuario Responsable:#{current_user.funcionario.full_name.inspect}. Fecha y Hora: #{Time.now}\")\n format.json { render json: @user, status: :created, location: @user }\n format.js {}\n else\n format.html { render action: \"new\" }\n CustomLogger.error(\"Error al intentar Crear un Nuevo Usuario. Usuario Responsable:#{current_user.funcionario.full_name.inspect}. Fecha y Hora: #{Time.now}\")\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fonction = current_user.fonctions.build(fonction_params)\n\n respond_to do |format|\n if @fonction.save\n @fonctions = Fonction.all\n format.html { redirect_to @fonction, notice: 'Fonction was successfully created.' }\n format.json { render :show, status: :created, location: @fonction }\n format.js\n else\n format.html { render :new }\n format.json { render json: @fonction.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def index\n @tipo_funcionarios = TipoFuncionario.all\n end",
"def creacion\n fiesta = Fiesta.new (params[:id])\n if Fiesta.save\n puts \"su fiesta a sido registrada\"\n else \n puts \"su fiesta no a sido registrada\"\n end\n render = json: fiesta \n end",
"def create\n @funtion = Funtion.new(funtion_params)\n\n respond_to do |format|\n if @funtion.save\n format.html { redirect_to @funtion, notice: 'Funtion was successfully created.' }\n format.json { render :show, status: :created, location: @funtion }\n else\n format.html { render :new }\n format.json { render json: @funtion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @entrada_saida_func = EntradaSaidaFunc.new(params[:entrada_saida_func])\n\n respond_to do |format|\n if @entrada_saida_func.save\n format.html { redirect_to(@entrada_saida_func, :notice => 'EntradaSaidaFunc was successfully created.') }\n format.xml { render :xml => @entrada_saida_func, :status => :created, :location => @entrada_saida_func }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @entrada_saida_func.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def asignacion_funcion_params\n params.require(:asignacion_funcion).permit(:esActual, :descripcion, :usuario_id, :rol_id)\n end",
"def update\n @funcionario = Funcionario.find(params[:id])\n\n respond_to do |format|\n if @funcionario.update_attributes(params[:funcionario])\n format.html { render :json => {:success => true} }\n format.xml { render :xml => @funcionario, :status => :created, :location => @funcionario }\n else\n format.html { render :json => ( (@funcionario.errors.full_messages.join(\".<br />\").to_s + \".\").to_json ) } unless @funcionario.errors.empty?\n end\n end\n end",
"def create\n @funcionario = Funcionario.new(params[:funcionario])\n file = params[:foto]\n if file\n file.configure(FileClassification::IMAGES::config)\n if file.is_valid?\n if @funcionario.save\n file.file_name = \"#{@funcionario.id.to_s}_#{file.original_filename}\"\n params[:funcionario]['foto'] = file.file_name\n if file.save\n @funcionario.update_attribute(:foto, file.file_name)\n respond_to {|format| format.html { render :json => {:success => true} } }\n else\n @funcionario.destroy\n respond_to {|format| format.html { render :json => {:success => false, :errors => file.errors.join('<br />')} } }\n end\n end\n else\n respond_to {|format| format.html { render :json => {:success => false, :errors => file.errors.join('<br />')} } }\n end\n else\n respond_to do |format|\n if @funcionario.save\n format.html { render :json => {:success => true} }\n format.xml { render :xml => @funcionario, :status => :created, :location => @funcionario }\n else\n format.html { render :json => ( (@funcionario.errors.full_messages.join(\".<br />\").to_s + \".\").to_json ) } unless @funcionario.errors.empty?\n end\n end\n end\n end",
"def update\n respond_to do |format|\n if @funcao.update(funcao_params)\n format.html { redirect_to @funcao, notice: 'Funcao was successfully updated.' }\n format.json { render :show, status: :ok, location: @funcao }\n else\n format.html { render :edit }\n format.json { render json: @funcao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @ferias_funcionarios = FeriasFuncionario.all\n end",
"def destroy\n @funcionario.destroy\n respond_to do |format|\n format.html { redirect_to funcionarios_url, notice: 'Funcionário apagado.' }\n format.json { head :no_content }\n end\n end",
"def create\n params.permit(:pseudo_administrateur, :email_administrateur, :motDePasse_administrateur)\n ajout = AdministrateurService.instance.creerNouveauAdmin(params[:pseudo_administrateur], params[:email_administrateur], params[:motDePasse_administrateur])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\n end",
"def destroy\n @funcionario = Funcionario.find(params[:id])\n @funcionario.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_funcionarios_url }\n format.json { head :no_content }\n end\n end",
"def create\n params[:futbolada][:usuario_id] = current_usuario.id\n @futbolada = Futbolada.new(params[:futbolada])\n\n respond_to do |format|\n if @futbolada.save\n @futbolada.numero = \"#{Time.zone.now.strftime('%Y%m%d%H%M%S')}-#{@futbolada.id}F\"\n @futbolada.save\n StatusServicioSolicitado.servicio_email(current_usuario,@futbolada).deliver\n session[:exito] = \"si\"\n session[:modulo] = \"futbolada\"\n format.html { redirect_to index_url }\n format.json { render json: @futbolada, status: :created, location: @futbolada }\n else\n format.html { render action: \"new\" }\n format.json { render json: @futbolada.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #@funcionario = Funcionario.find(params[:marcacaoponto][:funcionario_id])\n \t #@funcionario.marcar_ponto(\"aowpa\")\n \t #flash[:notice] = 'Ponto Criado!'\n #format.html { redirect_to(marcacaopontos_path) }\n #format.xml { head :ok }\n @marcacaoponto = Marcacaoponto.new(params[:marcacaoponto])\n respond_to do |format|\n if @marcacaoponto.save\n flash[:notice] = 'Marcacao de Ponto criada com sucesso.'\n format.html { redirect_to(marcacaopontos_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @marcacaoponto.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_funcionario\n @funcionario = Funcionario.find(params[:id])\n end",
"def set_funcionario\n @funcionario = Funcionario.find(params[:id])\n end",
"def set_funcionario\n @funcionario = Funcionario.find(params[:id])\n end",
"def set_funcionario\n @funcionario = Funcionario.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @funcionario.update(funcionario_params)\n format.html { redirect_to @funcionario, notice: \"Funcionario was successfully updated.\" }\n format.json { render :show, status: :ok, location: @funcionario }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fun = Fun.new(params[:fun])\n\n respond_to do |format|\n if @fun.save\n format.html { redirect_to @fun, :notice => 'Fun was successfully created.' }\n format.json { render :json => @fun, :status => :created, :location => @fun }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @fun.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @funcoes = Funcao.all\n end",
"def destroy\n @funcao.destroy\n respond_to do |format|\n format.html { redirect_to funcoes_url, notice: 'Funcao was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n @usuario = current_usuario\n @funcionarios = @usuario.local.funcionarios.asc(:nome)\n end",
"def update\n respond_to do |format|\n if @funcionario.update(funcionario_params)\n format.html { redirect_to @funcionario, notice: 'Funcionário atualizado.' }\n format.json { render :show, status: :ok, location: @funcionario }\n else\n format.html { render :edit,:alert=>\"Erros no cadastro, favor checar\" }\n format.json { render json: @funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fun = Fun.new(fun_params)\n\n respond_to do |format|\n if @fun.save\n format.html { redirect_to @fun, notice: 'Fun was successfully created.' }\n format.json { render :show, status: :created, location: @fun }\n else\n format.html { render :new }\n format.json { render json: @fun.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize! :create_almacen,Sigesp::Solicitud \n unidad = session['unidad'] \n return render json: { unidad: \"Esta Unidad Administrativa no tiene Numero de Control \" }, status: :unprocessable_entity if Sigesp::CtrlRequisicion.control_compra(unidad).nil?\n\n @solicitudes = Sigesp::Solicitud.crear_solicitudes_almacen(sigesp_solicitud_alamcen_params)\n @grupoSolicitud = SolicitudGrupo.new\n @solicitudes.each do |solicitud|\n @grupoSolicitud.solicitudes << solicitud \n end\n if @grupoSolicitud.valid? \n @grupoSolicitud.guardar(unidad,current_usuario)\n return render json: { url: sigesp_solicitudsalmacen_path(@grupoSolicitud.solicitudes[0])} \n else\n return render json:@grupoSolicitud.errors ,status: :unprocessable_entity\n end \n end",
"def create\n\t\tauthorize! :create, TipoPrivilegio\n @tipo_privilegio = TipoPrivilegio.new(tipo_privilegio_params)\n\n respond_to do |format|\n if @tipo_privilegio.save\n\t\t\t\t\t\tsesion= Sesion.find_by(usuario_id: current_usuario.id, fechaFin: nil)\n\t\t\t\tTransaccion.create!(\n \t\t\t\tdescripcion: \"Creación del tipo de Privilegio : #{@tipo_privilegio.attributes}\",\n \t\t\t\tsesion_id: sesion.id\n\t\t\t\t)\n format.html { redirect_to @tipo_privilegio\nflash[:success] = 'Tipo privilegio fue creado satisfactoriamente.' }\n format.json { render :show, status: :created, location: @tipo_privilegio }\n else\n format.html { render :new }\n format.json { render json: @tipo_privilegio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @farmaceutico = Farmaceutico.new(farmaceutico_params)\n\n respond_to do |format|\n if @farmaceutico.save\n format.html { redirect_to @farmaceutico, notice: 'Farmaceutico was successfully created.' }\n format.json { render :show, status: :created, location: @farmaceutico }\n else\n format.html { render :new }\n format.json { render json: @farmaceutico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @funcionario.destroy\n respond_to do |format|\n format.html { redirect_to funcionarios_url, notice: \"Funcionario was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def funcion_control_params\n params.require(:funcion_control).permit(:funcionalidad_id, :modelo_id, :accion_id, :control_id)\n end",
"def create\n\n respond_to do |format|\n if @especialidad.save\n format.html { redirect_to @especialidad, notice: 'Servicio creado exitosamente.' }\n format.json { render :show, status: :created, location: @especialidad }\n else\n format.html { render :new }\n format.json { render json: @especialidad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @usuario_prestamo = UsuarioPrestamo.new(usuario_prestamo_params)\n authorize! :crear, @usuario_prestamo\n respond_to do |format|\n if @usuario_prestamo.save\n format.html { redirect_to @usuario_prestamo, notice: 'El usuario de préstamo fue agregado correctamente' }\n format.json { render :show, status: :created, location: @usuario_prestamo }\n else\n format.html { render :new }\n format.json { render json: @usuario_prestamo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @usuario = Usuario.new(usuario_params)\n\n if @usuario.save\n render json: @usuario, status: :created, location: @usuario\n else\n render json: @usuario.errors, status: :unprocessable_entity\n end\n end",
"def create\n @role_funcion = RoleFuncion.new(role_funcion_params)\n respond_to do |format|\n if @role_funcion.save\n format.html { redirect_to @role_funcion }\n format.json { render action: 'show', status: :created, location: @role_funcion }\n else\n format.html { render action: 'new' }\n format.json { render json: @role_funcion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fondo = Fondo.new(fondo_params)\n\n respond_to do |format|\n if @fondo.save\n format.html { redirect_to @fondo, notice: 'Fondo was successfully created.' }\n format.json { render :show, status: :created, location: @fondo }\n else\n format.html { render :new }\n format.json { render json: @fondo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @frasco = Frasco.new(frasco_params)\n\n respond_to do |format|\n if @frasco.save\n format.html { redirect_to @frasco, notice: 'Frasco was successfully created.' }\n format.json { render :show, status: :created, location: @frasco }\n else\n format.html { render :new }\n format.json { render json: @frasco.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @relatorio_pedagogicos = RelatorioPedagogico.all\n authorize @relatorio_pedagogicos\n\n @relatorio_pedagogico = RelatorioPedagogico.new(relatorio_pedagogico_params)\n\n respond_to do |format|\n if @relatorio_pedagogico.save\n format.html { redirect_to @relatorio_pedagogico, notice: 'Relatório pedagógico criado com sucesso!' }\n format.json { render :show, status: :created, location: @relatorio_pedagogico }\n else\n format.html { render :new }\n format.json { render json: @relatorio_pedagogico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @funcionario = Funcionario.find(params[:id])\n\n respond_to do |format|\n if @funcionario.update_attributes(params[:funcionario])\n format.html { redirect_to [:admin, @funcionario], notice: 'Funcionario Atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def role_funcion_params\n params.require(:role_funcion).permit(:role_id, :funcion_id, :funcions)\n end",
"def core_funcional_params\n params.require(:core_funcional).permit(:cdg_funcao, :cdg_ordem, :cdg_funcional, :status, :ref_anomes, :dta_admissao)\n end",
"def create\n @tipo_usuario = TipoUsuario.new(tipo_usuario_params)\n @tipo_usuarios = TipoUsuario.all.paginate(page: params[:page], per_page: 5)\n @action = { title: \"Novo\", button: \"Salvar\"}\n\n respond_to do |format|\n if @tipo_usuario.save\n format.html { redirect_to action: \"new\", notice: 'TIpo Usuário criada com sucesso.' }\n format.json { render :show, status: :created, location: @tipo_usuario }\n else\n format.html { render :new, location: @tipo_usuario}\n format.json { render json: @tipo_usuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sumario = Sumario.new(sumario_params)\n\n respond_to do |format|\n if @sumario.save\n format.html { redirect_to @sumario, notice: 'Sumario was successfully created.' }\n format.json { render :show, status: :created, location: @sumario }\n else\n format.html { render :new }\n format.json { render json: @sumario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @producto = current_user.empresa.productos.new(producto_params)\n\n authorize! :create, @producto\n\n respond_to do |format|\n if @producto.save\n format.html { redirect_to @producto, notice: 'Producto was successfully created.' }\n format.json { render action: 'show', status: :created, location: @producto }\n else\n @unidades = current_user.empresa.unidades.load\n @listadeprecios = current_user.empresa.listadeprecios.load\n format.html { render action: 'new' }\n format.json { render json: @producto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @core_funcional = Core::Funcional.new(core_funcional_params)\n\n respond_to do |format|\n if @core_funcional.save\n format.html { redirect_to @core_funcional, notice: 'Funcional was successfully created.' }\n format.json { render :show, status: :created, location: @core_funcional }\n else\n format.html { render :new }\n format.json { render json: @core_funcional.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @realiza = Realiza.new\n @pessoas=Pessoa.select(\"clientes.id,pessoas.nome\").joins(:cliente)\n @funcionarios=Pessoa.select(\"usuarios.id,pessoas.nome\").joins(:usuario)\n #@pessoas=Pessoa.select(\"clientes.id,pessoas.nome\").joins(:clientes)\n #@funcionarios=Pessoa.where(\"id in (?)\",Usuario.select(\"pessoa_id as id\").map(&:id))\n @servicos=Servico.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @realiza and @pessoas and @funcionarios and @servicos}\n end\n end",
"def create\n @administracao_contrato = Administracao::Contrato.new(administracao_contrato_params)\n\n respond_to do |format|\n if @administracao_contrato.save\n format.html { redirect_to @administracao_contrato, notice: 'Contrato foi criado com sucesso.' }\n format.json { render :show, status: :created, location: @administracao_contrato }\n else\n format.html { render :new }\n format.json { render json: @administracao_contrato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cliente = Cliente.new(params[:cliente])\n localidad_new\n\n respond_to do |format|\n if @cliente.save\n format.html { redirect_to @cliente, notice: 'Los datos del Cliente se han creado correctamente.'}\n CustomLogger.info(\"Se ha creado un nuevo Cliente: Datos: Nombre: #{@cliente.nombre.inspect} , Apellido:#{@cliente.apellido.inspect}, Nro de CI o RUC: #{@cliente.num_identidad.inspect}, Direccion:#{@cliente.direccion.inspect}, Telefono:#{@cliente.telefono.inspect}, Sexo:#{@cliente.sexo.inspect} y Localidad:#{@cliente.localidad.nombre}. Usuario Responsable:#{current_user.funcionario.full_name.inspect}. Fecha y Hora: #{Time.now}\")\n format.json { render json: @cliente, status: :created, location: @cliente }\n format.js {render 'create'}\n else\n format.html { render action: \"new\" }\n CustomLogger.error(\"Error al intentar Crear un Nuevo Cliente. Usuario Responsable:#{current_user.funcionario.full_name.inspect}. Fecha y Hora: #{Time.now}\")\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_ferias_funcionario\n @ferias_funcionario = FeriasFuncionario.find(params[:id])\n end",
"def create\n @user_function = UserFunction.new(params[:user_function])\n\n respond_to do |format|\n if @user_function.save\n flash[:notice] = 'UserFunction was successfully created.'\n format.html { redirect_to([:admin,@user_function]) }\n format.xml { render :xml => @user_function, :status => :created, :location => @user_function }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_function.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def fondo_params\n params.require(:fondo).permit(:nombre, :descripcion, :imagen, :estado)\n end",
"def remuneracao_params\n params.require(:remuneracao).permit(:funcionario_id, :salario)\n end",
"def create\n @tipo_pregunta = TipoPregunta.new(params[:tipo_pregunta])\n\n if @tipo_pregunta.save\n render json: @tipo_pregunta, status: :created, location: @tipo_pregunta\n else\n render json: @tipo_pregunta.errors, status: :unprocessable_entity\n end\n end",
"def create\n @factores_fluctuante = FactoresFluctuante.new(factores_fluctuante_params)\n\n respond_to do |format|\n if @factores_fluctuante.save\n format.html { redirect_to @factores_fluctuante, notice: 'Factores fluctuante was successfully created.' }\n format.json { render :show, status: :created, location: @factores_fluctuante }\n else\n format.html { render :new }\n format.json { render json: @factores_fluctuante.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_funcao\n @funcao = Funcao.find(params[:id])\n end",
"def create\n @servicio = Servicio.new(params[:servicio])\n\n respond_to do |format|\n if @servicio.save\n format.html { redirect_to @servicio, :notice => 'Servicio was successfully created.' }\n format.json { render :json => @servicio, :status => :created, :location => @servicio }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @servicio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @lista = Lista.new(lista_params)\n @lista.usuario_id = current_usuario.id\n @lista.columnas=params[:columnas].join(',')\n\n respond_to do |format|\n if @lista.save\n format.html { redirect_to @lista, notice: 'La lista fue creada satisfactoriamente.' }\n format.json { render action: 'show', status: :created, location: @lista }\n else\n format.html { render action: 'new' }\n format.json { render json: @lista.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n pessoa = Pessoa.new(pessoa_params) \n \n if pessoa.save\n render json: {status: 'SUCCESSO', message:'Usuário cadastrado com sucesso!', data:pessoa},status: :ok\n else\n render json: {status: 'ERRO', message:'Usuário não pode ser cadastrado. Tente novamente mais tarde.', data:pessoa.errors},status: :unprocessable_entity\n end\n end",
"def create\n @usuario = Usuario.new(usuario_params)\n @usuario.nombres = @usuario.nombres.upcase\n @usuario.apellidos = @usuario.apellidos.upcase\n @usuario.salario = 0\n respond_to do |format|\n if @usuario.save\n format.html { redirect_to @usuario, notice: 'El Usuario se ha creado correctamente.' }\n format.json { render :show, status: :created, location: @usuario }\n else\n @div_edit_admin = true\n format.html { render :new }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n \n end",
"def create\n retorno = {erro: \"107\", body: \" \"}\n @usuario = Usuario.new(valid_request?)\n @usuario.status = 1\n if @usuario.mac.blank? \n @usuario.nivel = \"usuario_adm\"\n @usuario.status = 0\n usuario = Usuario.select(:mac).where(\"nivel = 1\").last\n @usuario.mac = (usuario.mac.to_i + 1).to_s\n end\n\n if @usuario.valid?\n if @usuario.save\n retorno = {erro: \"000\", body: {usuario_id: @usuario.id, usuario_nome: @usuario.nome, status: true}}\n end\n end\n #verifica erros na inserção no banco\n if @usuario.errors.any?\n retorno = Usuario.verifica_erro(@usuario.errors.messages)\n end\n render json: retorno.to_json\n end",
"def create\n authorize! :create, Tipo\n @tipo = Tipo.new(tipo_params)\n\n\n respond_to do |format|\n if @tipo.save\n format.html { redirect_to tipos_path, notice: '<i class=\"fa fa-check-square fa-lg\"></i> La nómina fue creada exitosamente.' }\n format.json { render :show, status: :created, location: @tipo }\n else\n format.html { render :new }\n format.json { render json: @tipo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @unite_fonctionnelle = UniteFonctionnelle.new(unite_fonctionnelle_params)\n\n respond_to do |format|\n if @unite_fonctionnelle.save\n format.html { redirect_to @unite_fonctionnelle, notice: 'Unite fonctionnelle was successfully created.' }\n format.json { render :show, status: :created, location: @unite_fonctionnelle }\n else\n format.html { render :new }\n format.json { render json: @unite_fonctionnelle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n self.validar_admin\n @inventario = Inventario.new(inventario_params)\n\n respond_to do |format|\n if @inventario.save\n format.html { redirect_to @inventario, notice: 'Inventario was successfully created.' }\n format.json { render :show, status: :created, location: @inventario }\n else\n format.html { render :new }\n format.json { render json: @inventario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @for_fun = ForFun.new(for_fun_params)\n\n respond_to do |format|\n if @for_fun.save\n format.html { redirect_to @for_fun, notice: 'For fun was successfully created.' }\n format.json { render :show, status: :created, location: @for_fun }\n else\n format.html { render :new }\n format.json { render json: @for_fun.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@usuario = Usuario.find(params[:seguido_id])\n\t\tusuario_actual.seguir(@usuario)\n\t\t\t# respuesta para AJAX\n\t\trespond_to do |formato|\n\t\t\tformato.html { redirect_to @usuario }\n\t\t\tformato.js\n\t\tend\n\tend",
"def index\n @funcionarios = Funcionario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @funcionarios }\n end\n end",
"def destroy\n \n if @funcionario.destroy\n flash[:success] = \"Funcionário excluido com sucesso!\"\n redirect_to funcionarios_path\n end\n \n end",
"def create\n @administracao_relatorios_diario = Administracao::RelatoriosDiario.new(administracao_relatorios_diario_params)\n\n respond_to do |format|\n if @administracao_relatorios_diario.save\n format.html { redirect_to @administracao_relatorios_diario, notice: 'Relatorios diario was successfully created.' }\n format.json { render :show, status: :created, location: @administracao_relatorios_diario }\n else\n format.html { render :new }\n format.json { render json: @administracao_relatorios_diario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def nuevo\n if !params[:caso_id].nil?\n @fprensa = CasoFuenteprensa.new\n @fprensa.id_caso = params[:caso_id]\n @fprensa.fuenteprensa_id = 0\n mdate = Sivel2Gen::CasoFuenteprensa.where(\n id_caso: params[:caso_id]).maximum(:fecha)\n if mdate\n mdate = mdate + 1\n else\n mdate = Sivel2Gen::Caso.where(id: params[:caso_id]).count > 0 ?\n Sivel2Gen::Caso.find(params[:caso_id]).fecha + 2 : Date.today\n end\n @fprensa.fecha = mdate\n if @fprensa.save\n respond_to do |format|\n format.js { render text: @fprensa.id.to_s }\n format.json { render json: @fprensa.id.to_s, \n status: :created }\n format.html { render inline: @fprensa.id.to_s }\n end\n else\n respond_to do |format|\n format.html { \n render inline: \"No pudo guardar fuente frecuente: '#{@fprensa.errors.messages.to_s}'\" }\n format.json { render json: @fprensa.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { render inline: 'Falta identificacion del caso' }\n end\n end\n end",
"def create\n @permiso = Permiso.new(permiso_params)\n\n respond_to do |format|\n if @permiso.save\n format.html { redirect_to permisos_path, notice: 'Permiso fue creado con éxito.' }\n format.json { render :show, status: :created, location: @permiso }\n else\n format.html { render :new }\n format.json { render json: @permiso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_fd_funcionario\n @fd_funcionario = FdFuncionario.find(params[:id])\n end",
"def create\n @oferta = Oferta.new(params[:oferta])\n\n respond_to do |format|\n if @oferta.save\n format.html { redirect_to [:admin, @oferta], :notice => 'Exemplo was successfully created.' }\n format.json { render :json => @oferta, :status => :created, :location => @oferta }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @oferta.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | [
"0.7517975",
"0.7343464",
"0.73300046",
"0.7211747",
"0.7053303",
"0.6952806",
"0.6943883",
"0.6917097",
"0.6854856",
"0.6790179",
"0.66772604",
"0.6671857",
"0.66379964",
"0.6604357",
"0.64879626",
"0.6470288",
"0.6452992",
"0.63931334",
"0.63716483",
"0.6287675",
"0.62430143",
"0.623298",
"0.6179687",
"0.6179687",
"0.6160166",
"0.61558944",
"0.6134133",
"0.61315453",
"0.60772157",
"0.6076193",
"0.60694",
"0.605159",
"0.6047746",
"0.60375875",
"0.6015801",
"0.5987529",
"0.59790516",
"0.5974732",
"0.59645987",
"0.5898146",
"0.5897496",
"0.5889302",
"0.5858379",
"0.5857942",
"0.5857942",
"0.5857942",
"0.5857942",
"0.5850043",
"0.58279073",
"0.5824813",
"0.5817516",
"0.57897",
"0.5776082",
"0.5754713",
"0.5754141",
"0.57494843",
"0.57462114",
"0.57402337",
"0.57309383",
"0.572662",
"0.57203656",
"0.57171524",
"0.5713257",
"0.5712642",
"0.5710595",
"0.5710535",
"0.5706977",
"0.5701467",
"0.5686911",
"0.56866187",
"0.56844836",
"0.56571126",
"0.5652899",
"0.5647907",
"0.5646391",
"0.564597",
"0.5645406",
"0.5641735",
"0.56393576",
"0.56364006",
"0.56314045",
"0.5629689",
"0.5626418",
"0.56243235",
"0.56199163",
"0.5619338",
"0.56176",
"0.5613586",
"0.56135494",
"0.56121224",
"0.5610914",
"0.5610875",
"0.5605186",
"0.5589656",
"0.5574568",
"0.55740064",
"0.5574002",
"0.55698466",
"0.55693936",
"0.55647767"
] | 0.65966755 | 14 |
PUT /admin/funcionarios/1 PUT /admin/funcionarios/1.json | def update
@funcionario = Funcionario.find(params[:id])
respond_to do |format|
if @funcionario.update_attributes(params[:funcionario])
format.html { redirect_to [:admin, @funcionario], notice: 'Funcionario Atualizado com sucesso.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @funcionario.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @funcao.update(funcao_params)\n format.html { redirect_to @funcao, notice: 'Funcao was successfully updated.' }\n format.json { render :show, status: :ok, location: @funcao }\n else\n format.html { render :edit }\n format.json { render json: @funcao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @funcionario = Funcionario.find(params[:id])\n\n respond_to do |format|\n if @funcionario.update_attributes(params[:funcionario])\n format.html { redirect_to @funcionario, notice: 'Funcionario was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @funcionario = Funcionario.find(params[:id])\n\n respond_to do |format|\n if @funcionario.update_attributes(params[:funcionario])\n format.html { render :json => {:success => true} }\n format.xml { render :xml => @funcionario, :status => :created, :location => @funcionario }\n else\n format.html { render :json => ( (@funcionario.errors.full_messages.join(\".<br />\").to_s + \".\").to_json ) } unless @funcionario.errors.empty?\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipo_funcionario.update(tipo_funcionario_params)\n format.html { redirect_to @tipo_funcionario, notice: 'Tipo funcionario was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipo_funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @funcionario.update(funcionario_params)\n format.html { redirect_to @funcionario, notice: \"Funcionario was successfully updated.\" }\n format.json { render :show, status: :ok, location: @funcionario }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @funcionario.update(funcionario_params)\n format.html { redirect_to @funcionario, notice: 'Funcionário atualizado.' }\n format.json { render :show, status: :ok, location: @funcionario }\n else\n format.html { render :edit,:alert=>\"Erros no cadastro, favor checar\" }\n format.json { render json: @funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ferias_funcionario.update(ferias_funcionario_params)\n format.html { redirect_to @ferias_funcionario, notice: 'Ferias funcionario was successfully updated.' }\n format.json { render :show, status: :ok, location: @ferias_funcionario }\n else\n format.html { render :edit }\n format.json { render json: @ferias_funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @funcionalidad.update(funcionalidad_params)\n format.html { redirect_to @funcionalidad, notice: 'Funcionalidad was successfully updated.' }\n format.json { render :show, status: :ok, location: @funcionalidad }\n else\n format.html { render :edit }\n format.json { render json: @funcionalidad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def actualizacion \n fiesta.update (params[:id]) \n render json: fiesta\n end",
"def update\n @funcionario.pessoa = @funcionario.pessoa.specific\n if @funcionario.update(funcionario_params)\n flash[:notice] = \"Funcionario alterado com sucesso\"\n redirect_to @funcionario\n else\n render :edit\n end\n end",
"def update\n\t\tauthorize! :update, AsignacionFuncion\n respond_to do |format|\n if @asignacion_funcion.update(asignacion_funcion_params)\n\t\t\t\t\t\tsesion= Sesion.find_by(usuario_id: current_usuario.id, fechaFin: nil)\n\t\t\t\tTransaccion.create!(\n \t\t\t\tdescripcion: \"Actualizar asociación rol #{@asignacion_funcion.rol.nombre} al usuario #{@asignacion_funcion.usuario.nombreUsuario}: actual = #{ t @asignacion_funcion.esActual.to_s}\",\n \t\t\t\tsesion_id: sesion.id\n\t\t\t\t)\n format.html { redirect_to @asignacion_funcion\n flash[:success] = 'Asignacion funcion fue actualizado satisfactoriamente.' }\n format.json { render :show, status: :ok, location: @asignacion_funcion }\n else\n format.html { render :edit }\n format.json { render json: @asignacion_funcion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, Tipo\n respond_to do |format|\n if @tipo.update(tipo_params)\n log(\"Se ha editado la nomina #{@lt}\", 1)\n format.html { redirect_to tipos_path, notice: 'Los datos de la nómina fueron actualizados exitosamente.' }\n format.json { head :no_content }\n end\n end\n end",
"def update\n @servicio = Servicio.find(params[:id])\n\n respond_to do |format|\n if @servicio.update_attributes(params[:servicio])\n format.html { redirect_to @servicio, :notice => 'Servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @servicio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def pro_farm_update\n respond_to do |format|\n activo = params[:pro_far][:activo_produc]\n farmacia_id = session[:farmacia_id]\n id = params[:id]\n ProFar.where(producto_id: id, farmacium_id:farmacia_id).update_all(activo_produc: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end",
"def update\n\n if @funcionario.update(funcionario_params) && @pessoa.update(funcionario2_params)\n flash[:success] = \"Funcionario #{@funcionario.pessoa.nome} Editado com sucesso!\"\n redirect_to @funcionario\n else\n flash[:danger] = \"Erro ao tentar editar Funcionário!\"\n render :edit\n end\n\n end",
"def update\n respond_to do |format|\n if @admin_function.update(admin_function_params)\n format.html { redirect_to @admin_function, notice: 'Function was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_function }\n else\n format.html { render :edit }\n format.json { render json: @admin_function.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, Concepto\n if params[:concepto][:tipo_ids]\n params[:concepto][:tipo_ids] = params[:concepto][:tipo_ids].map { |k, _v| k }\n else\n params[:concepto][:tipo_ids] = []\n end\n\n respond_to do |format|\n if @concepto.update(concepto_params)\n\n\n format.html { redirect_to @concepto, notice: '<i class=\"fa fa-check-square fa-lg\"></i> Los datos del concepto fueron actualizados exitosamente.' }\n format.json { render :show, status: :ok, location: @concepto }\n else\n format.html { render :edit } if params[:concepto][:tipo_ids]\n format.json { render json: @concepto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :editar, @usuario_prestamo\n respond_to do |format|\n if @usuario_prestamo.update(usuario_prestamo_params)\n format.html { redirect_to @usuario_prestamo, notice: 'La información del usuario de préstamos ha sido modificada correctamente' }\n format.json { render :show, status: :ok, location: @usuario_prestamo }\n else\n format.html { render :edit }\n format.json { render json: @usuario_prestamo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @fio_titulo.update(fio_titulo_params)\r\n format.html { redirect_to fio_titulo_path(@fio_titulo), notice: 'Materia prima atualizada com sucesso.' }\r\n format.json { render :show, status: :ok, location: @fio_titulo }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @fio_titulo.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def set_funcionario\n @funcionario = Funcionario.find(params[:id])\n end",
"def set_funcionario\n @funcionario = Funcionario.find(params[:id])\n end",
"def set_funcionario\n @funcionario = Funcionario.find(params[:id])\n end",
"def set_funcionario\n @funcionario = Funcionario.find(params[:id])\n end",
"def update\n self.validar_admin\n respond_to do |format|\n if @inventario.update(inventario_params)\n format.html { redirect_to @inventario, notice: 'Inventario was successfully updated.' }\n format.json { render :show, status: :ok, location: @inventario }\n else\n format.html { render :edit }\n format.json { render json: @inventario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @entrada_saida_func = EntradaSaidaFunc.find(params[:id])\n\n respond_to do |format|\n if @entrada_saida_func.update_attributes(params[:entrada_saida_func])\n format.html { redirect_to(@entrada_saida_func, :notice => 'EntradaSaidaFunc was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entrada_saida_func.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, Tipo\n respond_to do |format|\n if @tipo.update(tipo_params)\n format.html { redirect_to tipos_path, notice: '<i class=\"fa fa-check-square fa-lg\"></i> Los datos de la nómina fueron actualizados exitosamente.' }\n format.json { head :no_content }\n end\n end\n end",
"def update\n respond_to do |format|\n if @funtion.update(funtion_params)\n format.html { redirect_to @funtion, notice: 'Funtion was successfully updated.' }\n format.json { render :show, status: :ok, location: @funtion }\n else\n format.html { render :edit }\n format.json { render json: @funtion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def activo_update\n respond_to do |format|\n activo = params[:producto][:activo]\n id = params[:id]\n Producto.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end",
"def update\n respond_to do |format|\n if @func.update(func_params)\n format.html { redirect_to @func, notice: 'Func was successfully updated.' }\n format.json { render :show, status: :ok, location: @func }\n else\n format.html { render :edit }\n format.json { render json: @func.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update_almacen,Sigesp::Solicitud\n if @sigesp_solicitud.update(sigesp_solicitud_alamcen_params)\n return render json: { url: sigesp_solicitudsalmacen_path(@sigesp_solicitud)} \n else\n return render json:@sigesp_solicitud.errors ,status: :unprocessable_entity\n end \n end",
"def update\n respond_to do |format|\n if @farmaceutico.update(farmaceutico_params)\n format.html { redirect_to @farmaceutico, notice: 'Farmaceutico was successfully updated.' }\n format.json { render :show, status: :ok, location: @farmaceutico }\n else\n format.html { render :edit }\n format.json { render json: @farmaceutico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n set_funcionario\n if @ordem_servico.update(ordem_servico_params)\n format.html { redirect_to @ordem_servico, notice: t('messages.cadastro_atualizado') }\n format.json { render :show, status: :ok, location: @ordem_servico }\n else\n format.html { render :edit }\n format.json { render json: @ordem_servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @oferta = Oferta.find(params[:id])\n\n respond_to do |format|\n if @oferta.update_attributes(params[:oferta])\n format.html { redirect_to [:admin, @oferta], :notice => 'Exemplo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @oferta.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @solicitud_servicio = SolicitudServicio.find(params[:id])\n\n respond_to do |format|\n if @solicitud_servicio.update_attributes(params[:solicitud_servicio])\n format.html { redirect_to @solicitud_servicio, notice: 'Solicitud servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @solicitud_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @funcionario = Funcionario.new(params[:funcionario])\n\n @funcionario.senha = \"padrao\"\n\n respond_to do |format|\n if @funcionario.save\n format.html { redirect_to @funcionario, notice: 'Funcionario was successfully created.' }\n format.json { render json: @funcionario, status: :created, location: @funcionario }\n else\n format.html { render action: \"new\" }\n format.json { render json: @funcionario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @registro_servicio.update(registro_servicio_params)\n format.html { redirect_to @registro_servicio, notice: 'Servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @registro_servicio }\n else\n format.html { render :edit }\n format.json { render json: @registro_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ums_function.update(ums_function_params)\n format.html { redirect_to ums.functions_url, notice: '功能修改成功' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' , status: :unprocessable_entity}\n format.json { render json: @ums_function.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cliente.update(cliente_params)\n format.html { redirect_to funcionarios_path, notice: 'Cliente alterado com sucesso' }\n format.json { render :show, status: :ok, location: @cliente }\n else\n format.html { render :edit }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n @fc = FuncionControl.new(funcion_control_params)\n @funcionalidad = Funcionalidad.find(@fc.funcionalidad_id)\n \n respond_to do |format|\n if @funcion_control.update(funcion_control_params)\n format.html { redirect_to funcionalidad_funcion_control_path(@funcionalidad, @funcion_control), notice: 'Registro actualizado exitosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @funcion_control.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @foca.update(foca_params)\n format.html { redirect_to @foca, notice: 'Foca atualizada com sucesso.' }\n format.json { render :show, status: :ok, location: @foca }\n else\n format.html { render :edit }\n format.json { render json: @foca.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n retorno = {erro: \"322\" ,body: \"\"}\n if @usuario.update(valid_request?)\n retorno = {erro: \"000\", body: {evento_id: @usuario.id, usuario_nome: @usuario.nome}}\n end\n render json: retorno.to_json\n end",
"def update\n\t\tauthorize! :update, TipoPrivilegio\n respond_to do |format|\n if @tipo_privilegio.update(tipo_privilegio_params)\n\t\t\t\t\t\t\t\t\t\tsesion= Sesion.find_by(usuario_id: current_usuario.id, fechaFin: nil)\n\t\t\t\tTransaccion.create!(\n \t\t\t\tdescripcion: \"Actualización del tipo de privilegio: #{@tipo_privilegio.previous_changes}\" ,\n \t\t\t\tsesion_id: sesion.id\n\t\t\t\t)\n format.html { redirect_to @tipo_privilegio\nflash[:success] = 'Tipo privilegio fue actualizado satisfactoriamente.' }\n format.json { render :show, status: :ok, location: @tipo_privilegio }\n else\n format.html { render :edit }\n format.json { render json: @tipo_privilegio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @oficio.update(oficio_params)\n format.html { redirect_to oficios_url, notice: 'Oficio actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: oficios_url }\n else\n format.html { render :edit }\n format.json { render json: @oficio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @role_funcion.update(role_funcion_params)\n format.html { redirect_to @role_funcion }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @role_funcion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tb_servicio.update(tb_servicio_params)\n format.html { redirect_to @tb_servicio, notice: 'Tb servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @tb_servicio }\n else\n format.html { render :edit }\n format.json { render json: @tb_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, Solicitud\n respond_to do |format|\n if @solicitud.update(solicitud_params)\n format.html { redirect_to solicitudes_path, notice: 'Solicitud actualizada exitosamente.' }\n format.json { render :show, status: :ok, location: solicitudes_path }\n else\n format.html { render :edit }\n format.json { render json: @solicitud.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipo_de_servicio.update(tipo_de_servicio_params)\n format.html { redirect_to @tipo_de_servicio, notice: 'Tipo de servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_de_servicio }\n else\n format.html { render :edit }\n format.json { render json: @tipo_de_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\tauthorize! :index, @user\n\n params[:fichario_ficha][:fone].gsub!(/\\-|\\.|\\/|\\(|\\)| /,\"\")\n params[:fichario_ficha][:celular].gsub!(/\\-|\\.|\\/|\\(|\\)| /,\"\")\n params[:fichario_ficha][:cpf].gsub!(/\\-|\\.|\\/|\\(|\\)| /,\"\")\n params[:fichario_ficha][:pja] = params[:fichario_ficha][:pja].to_date\n params[:fichario_ficha][:entrada] = params[:fichario_ficha][:entrada].to_date\n @fichario_ficha = Fichario::Ficha.find(params[:id])\n\n\n respond_to do |format|\n if @fichario_ficha.update_attributes(params[:fichario_ficha])\n format.html { redirect_to(@fichario_ficha, :notice => 'Ficha foi atualizada com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @fichario_ficha.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def destroy\n @funcionario = Funcionario.find(params[:id])\n @funcionario.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_funcionarios_url }\n format.json { head :no_content }\n end\n end",
"def update\n respond_to do |format|\n if @topico.update(topico_params)\n format.html { redirect_to set_path, notice: 'Tópico atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @topico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n @empresa_servicio = EmpresaServicio.find(params[:id])\n respond_to do |format|\n if @empresa_servicio.update_attributes(params[:empresa_servicio])\n\n format.html { redirect_to empresa_empresa_servicios_path, notice: \"Los datos del servicio fueron actualizados para la empresa #{@empresa_servicio.empresa.nombre_empresa}\"}\n \n else\n format.html { render action: \"edit\" }\n format.json { render json: @empresa_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def activo_update\n respond_to do |format|\n activo = params[:laboratorio][:activo]\n id = params[:id]\n Laboratorio.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end",
"def update\n respond_to do |format|\n if @administracao_contrato.update(administracao_contrato_params)\n format.html { redirect_to @administracao_contrato, notice: 'Contrato foi atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @administracao_contrato }\n else\n format.html { render :edit }\n format.json { render json: @administracao_contrato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def putFactura(oc)\n\n facturax= JSON.parse(HTTP.headers(:\"Content-Type\" => \"application/json\").put(\"http://\"+ $url +\"/facturas/\", :json => {:oc => oc}).to_s, :symbolize_names => true)\n return facturax\n end",
"def update\n authorize! :update, Cargo\n respond_to do |format|\n # if !@cargo.sueldos.where(created_at: Time.now.beginning_of_month..Time.now.end_of_month).empty?\n nuevo = false\n if $quincena == 0\n nuevo = @cargo.sueldos.where(created_at: Time.now.beginning_of_month..(Time.now.beginning_of_month + 14.days)).empty?\n else\n nuevo = @cargo.sueldos.where(created_at: (Time.now.beginning_of_month + 15.days)..Time.now.end_of_month).empty?\n end\n key, value = params[:cargo][:sueldos_attributes].first\n\n if nuevo\n\n viejo = @cargo.sueldos.where(activo: true).last\n\n @cargo.sueldos.update_all(activo: false)\n crear = @cargo.sueldos.new\n crear.monto = params[:cargo][:sueldos_attributes][key][:monto]\n crear.sueldo_integral = params[:cargo][:sueldos_attributes][key][:sueldo_integral]\n\n params[:cargo][:sueldos_attributes][key][:monto] = viejo.monto\n params[:cargo][:sueldos_attributes][key][:sueldo_integral] = viejo.sueldo_integral\n\n end\n if @cargo.update(cargo_params)\n log(\"Se ha actualizado el cargo: #{@lt}\", 1)\n\n format.html { redirect_to @cargo, notice: 'Los datos del cargo fueron actualizados exitosamente.' }\n format.json { render :show, status: :ok, location: @cargo }\n else\n format.html { render :edit }\n format.json { render json: @cargo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @administracao_rota.update(administracao_rota_params)\n format.html { redirect_to @administracao_rota, notice: 'Rota foi atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @administracao_rota }\n else\n format.html { render :edit }\n format.json { render json: @administracao_rota.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n authorize! :update, @producto\n\n respond_to do |format|\n if @producto.update(producto_params)\n format.html { redirect_to productos_url({:page => cookies[:current_page]}), notice: 'Producto was successfully updated.' }\n format.json { head :no_content }\n else\n @unidades = current_user.empresa.unidades.load\n @listadeprecios = current_user.empresa.listadeprecios.load\n format.html { render action: 'edit' }\n format.json { render json: @producto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @servico.update(servico_params)\n format.html { redirect_to servicos_url, notice: 'Serviço atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @servico }\n else\n format.html { render :edit }\n format.json { render json: @servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @usuario = Usuario.find(params[:id])\n\n if @usuario.update(usuario_params)\n head :no_content\n else\n render json: @usuario.errors, status: :unprocessable_entity\n end\n end",
"def update\r\n respond_to do |format|\r\n if @sivic_ministerio.update(sivic_ministerio_params)\r\n format.html { redirect_to @sivic_ministerio, notice: 'Registro alterado com sucesso.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @sivic_ministerio.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n authorize! :update,Beneficiario\n @solicitante= Solicitante.find(params[:solicitante_id])\n @beneficiario = Beneficiario.update(beneficiario_params)\n\n respond_to do |format|\n format.html { redirect_to solicitante_beneficiario_path(@solicitante, params[:id]), notice: 'Beneficiario actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: solicitante_beneficiario_path(@solicitante, @beneficiario) }\n\n end\n end",
"def activo_update\n respond_to do |format|\n activo = params[:presentacion][:activo]\n id = params[:id]\n Presentacion.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end",
"def update\n respond_to do |format|\n if @inventario_cosa.update(inventario_cosa_params)\n format.html { redirect_to @inventario_cosa, notice: 'Inventario cosa was successfully updated.' }\n format.json { render :show, status: :ok, location: @inventario_cosa }\n else\n format.html { render :edit }\n format.json { render json: @inventario_cosa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def fd_funcionario_params\n params.require(:fd_funcionario).permit(:nome_funcionario, :desc_telefone, :desc_celular, :data_exclusao, :fd_cargo_id, :fd_endereco_id, :fd_empresa_id)\n end",
"def update\n #respond_to do |format|\n # if @formulario.update(formulario_params)\n # format.html { redirect_to @formulario, notice: 'Formulario was successfully updated.' }\n # format.json { render :show, status: :ok, location: @formulario }\n # else\n # format.html { render :edit }\n # format.json { render json: @formulario.errors, status: :unprocessable_entity }\n # end\n #end\n manipulacaoControle(@formulario, @formulario.update(formulario_params), 'Formulario', 'updated.', :ok, :edit)\n end",
"def update\n respond_to do |format|\n if @tipoapreensao.update(tipoapreensao_params)\n format.html { redirect_to @tipoapreensao, notice: 'Tipoapreensao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipoapreensao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipo_usuario = TipoUsuario.find(params[:id])\n\n respond_to do |format|\n if @tipo_usuario.update_attributes(params[:tipo_usuario])\n format.html { redirect_to @tipo_usuario, notice: 'Tipo usuario fue actualizado existosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_usuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fonction.update(fonction_params)\n @fonctions = Fonction.all\n format.html { redirect_to @fonction, notice: 'Fonction was successfully updated.' }\n format.json { render :show, status: :ok, location: @fonction }\n format.js\n else\n format.html { render :edit }\n format.json { render json: @fonction.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def update\n @usuario.isAdmin = false unless current_user.isAdmin #bloqueio de atualização de permissão para usuarios que não são admin\n respond_to do |format|\n if @usuario.update(usuario_params)\n format.html { redirect_to (current_user.isAdmin ? usuarios_url : recibos_url), notice: 'Usuário atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @usuario }\n else\n format.html { render :edit }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ficha = Ficha.find(params[:id])\n\n respond_to do |format|\n if @ficha.update_attributes(params[:ficha])\n format.html { redirect_to @ficha, notice: 'Ficha alterada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ficha.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_fd_funcionario\n @fd_funcionario = FdFuncionario.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @asiento_de_servicio.update(asiento_de_servicio_params)\n format.html { redirect_to @asiento_de_servicio, notice: 'Asiento de servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @asiento_de_servicio }\n else\n format.html { render :edit }\n format.json { render json: @asiento_de_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fabrica.update(fabrica_params)\n format.html { redirect_to @fabrica, notice: 'Fabrica was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @fabrica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @solicitacoes_avaliacoes_servico.update(solicitacoes_avaliacoes_servico_params)\n format.html { redirect_to @solicitacoes_avaliacoes_servico, notice: 'Solicitacoes avaliacoes servico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @solicitacoes_avaliacoes_servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @funcionario = Funcionario.new(params[:funcionario])\n if current_user.is_role?(:administrador) \n else\n @funcionario.user = current_user \n end \n flash[:notice] = \"Funcionario salvo com sucesso!\" if @funcionario.save\n # respond_with @funcionario, :location => [:admin, @funcionario]\n redirect_to admin_funcionarios_path\n end",
"def set_funcao\n @funcao = Funcao.find(params[:id])\n end",
"def update\n respond_to do |format|\n if (Servicio.where(id: especialidad_params[:servicio_id]).select(:enable).first.enable)\n if @especialidad.update(especialidad_params)\n format.html { redirect_to @especialidad, notice: 'Servicio actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: @especialidad }\n else\n format.html { render :edit }\n format.json { render json: @especialidad.errors, status: :unprocessable_entity }\n end\n else\n format.html { render :edit }\n format.json { render json: @especialidad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n authorize @contrato\n if @contrato.update(contrato_params)\n format.html { redirect_to @contrato, notice: 'Contrato actualizado.' }\n format.json { render :show, status: :ok, location: @contrato }\n else\n format.html { render :edit }\n format.json { render json: @contrato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @sivic_fornecedor.update(sivic_fornecedor_params)\r\n format.html { redirect_to @sivic_fornecedor, notice: 'Registro alterado com sucesso.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @sivic_fornecedor.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @factores_fluctuante.update(factores_fluctuante_params)\n format.html { redirect_to @factores_fluctuante, notice: 'Factores fluctuante was successfully updated.' }\n format.json { render :show, status: :ok, location: @factores_fluctuante }\n else\n format.html { render :edit }\n format.json { render json: @factores_fluctuante.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @usuario.nombres = @usuario.nombres.upcase\n @usuario.apellidos = @usuario.apellidos.upcase\n respond_to do |format|\n if @usuario.update(usuario_params)\n format.html { redirect_to @usuario, notice: 'El Usuario se ha editado correctamente.' }\n format.json { render :show, status: :ok, location: @usuario }\n else\n @div_edit_admin = true\n format.html { render :edit }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @usuario = Usuario.find_by_id(params[:id])\n if @usuario.nil?\n render :json => {:error => \"Usuario no encontrado\"}.to_json, :status => 404\n\n #render :json => {:error => \"id no es modificable\"}.to_json, :status => 400\n else\n if usuario_params.count==1\n respond_to do |format|\n # format.json { render json: usuario_params.count}\n if @usuario.update(usuario_params)\n #format.json { render json: @usuario}\n\n #format.html { redirect_to @usuario, notice: 'Usuario was successfully updated.' }\n #el segundo\n format.json { render :show, status: :ok, location: @usuario }\n end\n end\n elsif usuario_params.count==0\n # JSON.parse(usuario_params)\n respond_to do |format|\n format.json { render :json => {:error => \"id no es modificable\"}.to_json, :status => 400 }\n end\n else\n respond_to do |format|\n format.json { render :json => {:error => \"La modificación ha fallado\"}.to_json, :status => 500 }\n end\n end\n end\n end",
"def update\n @cooperativa = Cooperativa.find(params[:id])\n\n respond_to do |format|\n if @cooperativa.update_attributes(params[:cooperativa])\n format.html { redirect_to [:admin, @cooperativa], :notice => 'Exemplo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @cooperativa.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fondo.update(fondo_params)\n format.html { redirect_to @fondo, notice: 'Fondo was successfully updated.' }\n format.json { render :show, status: :ok, location: @fondo }\n else\n format.html { render :edit }\n format.json { render json: @fondo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @frequencia_orgao = Frequencia::Orgao.find(params[:id])\n\n respond_to do |format|\n if @frequencia_orgao.update_attributes(params[:frequencia_orgao])\n format.html { redirect_to(@frequencia_orgao, :notice => 'Orgão atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @frequencia_orgao.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n activo = params[:lab_far][:activo]\n farmacia_id = session[:farmacia_id]\n id = params[:id]\n LabFar.where(laboratorio_id: id, farmacium_id:farmacia_id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end",
"def update\n @firm = Firm.find(params[:id])\n\n respond_to do |format|\n if @firm.update_attributes(params[:firm])\n format.html { redirect_to @firm, notice: 'Empresa alterada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @firm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @relatorio_pedagogicos = RelatorioPedagogico.all\n authorize @relatorio_pedagogicos\n\n respond_to do |format|\n if @relatorio_pedagogico.update(relatorio_pedagogico_params)\n format.html { redirect_to @relatorio_pedagogico, notice: 'Relatório pedagógico atualizado com sucesso!' }\n format.json { render :show, status: :ok, location: @relatorio_pedagogico }\n else\n format.html { render :edit }\n format.json { render json: @relatorio_pedagogico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n obtener_datos()\n @status = params[:statusproyect]\n @cliente = params[:cliente] + \" \" +params[:cliente_apellido]\n respond_to do |format|\n if @ventum.update(cliente: @cliente, clave:@clave, fecha:@fecha, iva:@iva,subtotal:@preciofinal ,total:@totalcosto, descuentogeneral: @descglobal , distribuidor: @distribuidor, status: @status)\n @detail.each do |x|\n x.destroy\n end\n salvar()\n format.html { redirect_to @ventum, notice: 'Venta actualizada correctamente.' }\n format.json { render :show, status: :ok, location: @ventum }\n else\n format.html { render :edit }\n format.json { render json: @ventum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\tauthorize! :update, AsistenciaEvento\n respond_to do |format|\n if @asistencia_evento.update(asistencia_evento_params)\n format.html { redirect_to @asistencia_evento\nflash[:success] = 'Asistencia evento fue actualizada satisfactoriamente.' }\n format.json { render :show, status: :ok, location: @asistencia_evento }\n else\n format.html { render :edit }\n format.json { render json: @asistencia_evento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_current_logged_in_user(args = {}) \n put(\"/users.json/current\", args)\nend",
"def update\n respond_to do |format|\n if @administracao_cargo.update(administracao_cargo_params)\n format.html { redirect_to @administracao_cargo, notice: 'Cargo foi atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @administracao_cargo }\n else\n format.html { render :edit }\n format.json { render json: @administracao_cargo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @sivic_celula.update(sivic_celula_params)\r\n format.html { redirect_to @sivic_celula, notice: 'Registro alterado com sucesso.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @sivic_celula.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n\n respond_to do |format|\n if @tarefa.update(tarefa_params)\n format.html { redirect_to @tarefa, notice: 'Tarefa atualizada com sucesso!' }\n format.json { render :show, status: :ok, location: @tarefa }\n else\n format.html { render :edit , @current_usuario => current_usuario}\n format.json { render json: @tarefa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n control_usuario\n respond_to do |format|\n if @franja.update(franja_params)\n format.html { redirect_to @franja, notice: 'La Franja se ha editado correctamente.' }\n format.json { render :show, status: :ok, location: @franja }\n else\n format.html { render :edit }\n format.json { render json: @franja.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n if @tecnico.update_attributes(params[:tecnico])\n format.html { redirect_to @tecnico, notice: 'Tecnico atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tecnico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @solicitacao_tipo.update(solicitacao_tipo_params)\n format.html { redirect_to @solicitacao_tipo, notice: 'Solicitacao tipo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @solicitacao_tipo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @calificacion_servicio = CalificacionServicio.find(params[:id])\n\n respond_to do |format|\n if @calificacion_servicio.update_attributes(params[:calificacion_servicio])\n format.html { redirect_to @calificacion_servicio, notice: 'Calificacion servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @calificacion_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user_function = UserFunction.find(params[:id])\n\n respond_to do |format|\n if @user_function.update_attributes(params[:user_function])\n flash[:notice] = 'UserFunction was successfully updated.'\n format.html { redirect_to([:admin,@user_function]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user_function.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | [
"0.7178259",
"0.7031",
"0.6980899",
"0.69224733",
"0.69187415",
"0.6802858",
"0.65889907",
"0.65432143",
"0.649853",
"0.6391254",
"0.6331525",
"0.61915946",
"0.6183542",
"0.6161192",
"0.6077309",
"0.60569197",
"0.60550284",
"0.60549605",
"0.60524046",
"0.6028754",
"0.6028754",
"0.6028754",
"0.6028754",
"0.6027947",
"0.6022254",
"0.602096",
"0.6019188",
"0.60125065",
"0.5985984",
"0.5980915",
"0.59626186",
"0.59589666",
"0.59467506",
"0.59297216",
"0.59293747",
"0.59088904",
"0.590431",
"0.5902984",
"0.58989775",
"0.58959806",
"0.58917135",
"0.5863617",
"0.58626944",
"0.58458227",
"0.5829323",
"0.58270836",
"0.58218604",
"0.58172417",
"0.5813235",
"0.5805944",
"0.5784257",
"0.5782301",
"0.57720315",
"0.5772005",
"0.57716745",
"0.57578963",
"0.5747041",
"0.574647",
"0.5743177",
"0.57381064",
"0.573443",
"0.5732602",
"0.5729079",
"0.57219106",
"0.5718059",
"0.5712176",
"0.5705069",
"0.5703073",
"0.5701364",
"0.57009804",
"0.56985253",
"0.569848",
"0.56924117",
"0.5689462",
"0.5681793",
"0.5671289",
"0.567121",
"0.56699437",
"0.5663439",
"0.5662831",
"0.5658961",
"0.56589556",
"0.56582934",
"0.5653477",
"0.56527495",
"0.5651903",
"0.565149",
"0.5639535",
"0.56368804",
"0.56319976",
"0.5631222",
"0.56252337",
"0.5624996",
"0.56238854",
"0.5623355",
"0.5622389",
"0.56200784",
"0.56191677",
"0.5618556",
"0.56163734"
] | 0.72757894 | 0 |
DELETE /admin/funcionarios/1 DELETE /admin/funcionarios/1.json | def destroy
@funcionario = Funcionario.find(params[:id])
@funcionario.destroy
respond_to do |format|
format.html { redirect_to admin_funcionarios_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @funcionario = Funcionario.find(params[:id])\n @funcionario.destroy\n\n respond_to do |format|\n format.html { redirect_to funcionarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @funcionario.destroy\n respond_to do |format|\n format.html { redirect_to funcionarios_url, notice: 'Funcionário apagado.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_funcionario.destroy\n respond_to do |format|\n format.html { redirect_to tipo_funcionarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @funcionario.destroy\n respond_to do |format|\n format.html { redirect_to funcionarios_url, notice: \"Funcionario was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @funcao.destroy\n respond_to do |format|\n format.html { redirect_to funcoes_url, notice: 'Funcao was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @funcionalidad.destroy\n respond_to do |format|\n format.html { redirect_to funcionalidads_url, notice: 'Funcionalidad was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end",
"def destroy\n @ferias_funcionario.destroy\n respond_to do |format|\n format.html { redirect_to ferias_funcionarios_url, notice: 'Ferias funcionario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n self.validar_admin\n @inventario.destroy\n respond_to do |format|\n format.html { redirect_to inventarios_url, notice: 'Inventario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @funcionario = Funcionario.find(params[:id])\n respond_to do |format|\n if @funcionario.destroy\n format.html { render :json => {:success => true} }\n format.xml { render :xml => @funcionario, :status => :created, :location => @funcionario }\n else\n return render :json => { :success => false, :msg => (@funcionario.errors.full_messages.join(\".<br />\")).to_s + \".\" }.to_json\n end\n end\n end",
"def destroy\n @foca.destroy\n respond_to do |format|\n format.html { redirect_to focas_url, notice: 'Foca eliminada com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @especialidad.destroy\n respond_to do |format|\n format.html { redirect_to especialidads_url, notice: 'Servicio eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @oficio.destroy\n respond_to do |format|\n format.html { redirect_to oficios_url, notice: 'Oficio eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def deletef\n url = prefix + \"deletef\" + id_param\n return response(url)\n end",
"def destroy\n @datos_usuario.destroy\n respond_to do |format|\n format.html { redirect_to datos_usuarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n contrato = @fatura.contrato\n @fatura.destroy\n respond_to do |format|\n format.html { redirect_to contrato, notice: 'Fatura excluída com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @administracao_contrato.destroy\n respond_to do |format|\n format.html { redirect_to administracao_contratos_url, notice: 'Contrato foi removido do sistema.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :eliminar, @usuario_prestamo\n @usuario_prestamo.destroy\n respond_to do |format|\n format.html { redirect_to usuario_prestamos_url, notice: 'El usuario de préstamo fue eliminado correctamente' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @administracao_relatorios_diario.destroy\n respond_to do |format|\n format.html { redirect_to administracao_relatorios_diarios_url, notice: 'Relatorios diario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_doctipo.destroy\n respond_to do |format|\n format.html { redirect_to admin_doctipos_url, notice: 'Doctipo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @administracao_rota.destroy\n respond_to do |format|\n format.html { redirect_to administracao_rotas_url, notice: 'Rota foi removido do sistema.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @servicio = Servicio.find(params[:id])\n @servicio.destroy\n\n respond_to do |format|\n format.html { redirect_to servicios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unidad.destroy\n respond_to do |format|\n format.html { redirect_to unidades_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @odontologia1 = Odontologia1.find(params[:id])\n @odontologia1.destroy\n\n respond_to do |format|\n format.html { redirect_to odontologia1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datos_insumos_reactivo.destroy\n respond_to do |format|\n format.html { redirect_to datos_insumos_reactivos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_distribucion.destroy\n respond_to do |format|\n format.html { redirect_to tipos_distribuciones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @farmacium.destroy\n respond_to do |format|\n msg = { :status => \"ok\", :message => \"Eliminado!\" }\n format.json { render :json => msg }\n end\n end",
"def destroy\n @fulcliente = Fulcliente.find(params[:id])\n @fulcliente.destroy\n\n respond_to do |format|\n format.html { redirect_to fulclientes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @sumario.destroy\n respond_to do |format|\n format.html { redirect_to sumarios_url, notice: 'Sumario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @fio_titulo.destroy\r\n respond_to do |format|\r\n format.html { redirect_to fio_titulos_url, notice: 'Materia prima excluída com sucesso.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def delete\n\n end",
"def destroy\n control_usuario\n @franja.destroy\n respond_to do |format|\n format.html { redirect_to franjas_url, notice: 'La Franja se elimino correctamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @funkce.destroy\n respond_to do |format|\n format.html { redirect_to funkces_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ocorrencium.destroy\n respond_to do |format|\n format.html { redirect_to ocorrencia_url, notice: 'Registro excluído com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @futbolada = Futbolada.find(params[:id])\n @futbolada.destroy\n\n respond_to do |format|\n format.html { redirect_to gestion_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @administracao_cargo.destroy\n respond_to do |format|\n format.html { redirect_to administracao_cargos_url, notice: 'Cargo foi removido do sistema.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n administradorId = @concurso.administrador_id\n @concurso.destroy\n respond_to do |format|\n format.html { redirect_to '/administradors/'+administradorId.to_s, notice: 'El concurso fue eliminado' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @sistema = Sistema.find(params[:id])\n @sistema.destroy\n\n respond_to do |format|\n format.html { redirect_to sistemas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin.destroy\n respond_to do |format|\n format.html { redirect_to admin_admins_url, notice: \"Administrador (#{@admin.name}), foi excluido com sucesso!\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @solicitud.destroy\n respond_to do |format|\n format.html { redirect_to solicitudes_url }\n format.json { head :no_content }\n end\n end",
"def delete!\n request! :delete\n end",
"def destroy\n @tipo_unidad.destroy\n respond_to do |format|\n format.html { redirect_to tipo_unidades_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datosgenerale.destroy\n respond_to do |format|\n format.html { redirect_to datosgenerales_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_produto.destroy\n respond_to do |format|\n format.html { redirect_to admin_produtos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n supprimer = AdministrateurService.instance.supprimerAdmin(params[:id])\n (supprimer) ? (render json: true, status: :ok) : (render json: false, status: :not_found)\n end",
"def destroy\n @gran_unidad.destroy\n respond_to do |format|\n format.html { redirect_to gran_unidad_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_de_imposto.destroy\n respond_to do |format|\n format.html { redirect_to @empresa, notice: 'Tipo de imposto removido com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fornecedor.destroy\n addlog(\"Fornecedor apagado\")\n respond_to do |format|\n format.html { redirect_to fornecedores_url, notice: 'Fornecedor apagado com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_function.destroy\n respond_to do |format|\n format.html { redirect_to admin_functions_url, notice: 'Function was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @opcao.destroy\n respond_to do |format|\n format.html { redirect_to opcaos_url, notice: 'Opção Apagada com sucesso!' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @fabricante.destroy\r\n respond_to do |format|\r\n format.html { redirect_to fabricantes_url, notice: 'Fabricante excluída com sucesso.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @ocorrencia.destroy\n respond_to do |format|\n format.html { redirect_to ocorrencias_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @estatuto = Estatuto.find(params[:id])\n @estatuto.destroy\n\n respond_to do |format|\n format.html { redirect_to estatutos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fertilizante.destroy\n respond_to do |format|\n format.html { redirect_to fertilizantes_url, notice: 'Fertilizante was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n checar_egresso_super\r\n @egresso.destroy\r\n respond_to do |format|\r\n format.html { redirect_to egressos_url, notice: 'Egresso excluído com sucesso.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @fisier.destroy\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entrada_saida_func = EntradaSaidaFunc.find(params[:id])\n @entrada_saida_func.destroy\n\n respond_to do |format|\n format.html { redirect_to(entrada_saida_funcs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_plan.destroy\n respond_to do |format|\n msg = { :status => \"ok\", :message => \"Eliminado!\" }\n format.json { render :json => msg }\n end\n end",
"def delete\n \n end",
"def destroy\n @autorizacion.destroy\n respond_to do |format|\n format.html { redirect_to autorizacions_url, notice: 'Autorizacion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin.destroy\n\n render json: { operation: 'OK' }, status: :ok\n end",
"def destroy\n @apoio_educacioanl.destroy\n respond_to do |format|\n format.html { redirect_to apoio_educacioanls_url, notice: 'Apoio educacioanal foi excluído com Sucesso !' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @farmaceutico.destroy\n respond_to do |format|\n format.html { redirect_to farmaceuticos_url, notice: 'Farmaceutico was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :destroy, Solicitud\n @solicitud.destroy\n respond_to do |format|\n format.html { redirect_to solicitudes_url, notice: 'Solicitud was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @solicitud_servicio = SolicitudServicio.find(params[:id])\n @solicitud_servicio.destroy\n\n respond_to do |format|\n format.html { redirect_to solicitudes_servicios_url }\n format.json { head :no_content }\n end\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def destroy\n @dato = Dato.find(params[:id])\n @dato.destroy\n\n respond_to do |format|\n format.html { redirect_to datos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @realiza = Realiza.find(params[:id])\n @realiza.destroy\n\n respond_to do |format|\n format.html { redirect_to realizas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crediario.destroy\n respond_to do |format|\n format.html { redirect_to crediarios_url, notice: 'Parcela excluida com sucesso!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @funcionalidad = Funcionalidad.find(@funcion_control.funcionalidad_id)\n @funcion_control.destroy\n respond_to do |format|\n #format.html { redirect_to funcion_controls_url }\n format.html { redirect_to edit_funcionalidad_path(@funcionalidad) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lixotodo.destroy\n respond_to do |format|\n format.html {redirect_to lixotodos_url, notice: 'Registro excluído com sucesso.'}\n format.json {head :no_content}\n end\n end",
"def destroy\n @permiso.destroy\n respond_to do |format|\n format.html { redirect_to permisos_url, notice: 'Permiso fue eliminado.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n \n if @funcionario.destroy\n flash[:success] = \"Funcionário excluido com sucesso!\"\n redirect_to funcionarios_path\n end\n \n end",
"def destroy\r\n @usuario_gusto.destroy\r\n respond_to do |format|\r\n format.html { redirect_to usuario_gustos_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @perfisusuario.destroy\n respond_to do |format|\n format.html { redirect_to perfisusuarios_url, notice: 'Perfil de Usuário excluído com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipoapreensao.destroy\n respond_to do |format|\n format.html { redirect_to tipoapreensoes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prueba_json.destroy\n respond_to do |format|\n format.html { redirect_to prueba_jsons_url }\n format.json { head :no_content }\n end\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def destroy\n @tipo_usuario = TipoUsuario.find(params[:id])\n @tipo_usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_usuarios_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def delete\n api(\"Delete\")\n end",
"def destroy\n @registro.destroy\n respond_to do |format|\n format.html { redirect_to :back}\n format.json { head :no_content }\n end\n end",
"def destroy\n @rango_fecha.destroy\n respond_to do |format|\n format.html { redirect_to rango_fechas_url, notice: 'Rango fecha was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n\t\trequest(path, :delete)\n\tend",
"def destroy\n @dfactura.destroy\n respond_to do |format|\n format.html { redirect_to dfacturas_url, notice: 'Detalle de factura eliminado con éxito.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.7615027",
"0.75380266",
"0.75115776",
"0.7438658",
"0.72932506",
"0.72602683",
"0.71821505",
"0.7181262",
"0.71102595",
"0.7028232",
"0.70054305",
"0.69871664",
"0.6977697",
"0.6964186",
"0.6955146",
"0.6945944",
"0.6925926",
"0.6918656",
"0.6911894",
"0.6911062",
"0.6910969",
"0.6906422",
"0.69006944",
"0.6894455",
"0.6888342",
"0.6879183",
"0.68762",
"0.6875001",
"0.68711025",
"0.68684965",
"0.6852927",
"0.68521035",
"0.68486136",
"0.68484664",
"0.6835079",
"0.6829625",
"0.68293405",
"0.6829051",
"0.6827265",
"0.6825442",
"0.68248844",
"0.6823678",
"0.6822303",
"0.6821294",
"0.6818582",
"0.6815862",
"0.6815824",
"0.68117934",
"0.6810786",
"0.68106604",
"0.68084866",
"0.68084556",
"0.6804543",
"0.67946786",
"0.67912066",
"0.6789418",
"0.6788923",
"0.678405",
"0.678405",
"0.6781107",
"0.6780684",
"0.6778143",
"0.67754066",
"0.6773353",
"0.6772753",
"0.67697346",
"0.6768427",
"0.6768177",
"0.6765598",
"0.67635006",
"0.6763152",
"0.676248",
"0.676248",
"0.676248",
"0.676248",
"0.676248",
"0.676248",
"0.676248",
"0.6760802",
"0.6760491",
"0.67580867",
"0.67550254",
"0.67546016",
"0.67539",
"0.6753767",
"0.6751935",
"0.67517203",
"0.6751542",
"0.67503613",
"0.67452794",
"0.67452794",
"0.67452794",
"0.67452794",
"0.6744433",
"0.67434406",
"0.6741904",
"0.6735386",
"0.6734697",
"0.67333645",
"0.67329633"
] | 0.7802818 | 0 |
For instance, the length of "it's" is 3, not 4. | def cleanup(str)
str.gsub(/[^a-z]/i, '')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length() end",
"def length() end",
"def length() end",
"def length() end",
"def length (string)\n string.length\nend",
"def length(*) end",
"def length(*) end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; end",
"def length; count end",
"def word_lengths(str)\nend",
"def length\n string.length\n end",
"def length=(_); end",
"def length\n @string.length\n end",
"def length()\n return to_s.gsub(\" \", \"\").gsub(\"-\", \"\").length\n end",
"def length_calculator; end",
"def count_chars word3\n word3.length\nend",
"def length\n @chars.length\n end",
"def length\n end",
"def current_length; end",
"def word_length\n @word.length\n end",
"def length\n 3\n end",
"def length\n 3\n end",
"def length_of_string(input)\n test_string = input.length\n return test_string\nend",
"def length_of_string(string)\n string = \"A string of length 21\".length\nend",
"def length()\n return to_s.size\n end",
"def length\n end",
"def length\n end",
"def length\n end",
"def length\n end",
"def length\n end",
"def length_of_string(string)\n return string.length\nend",
"def length_of_string(the_string)\n puts 'your string is this many characters ' + the_string.length.to_s\nend",
"def length\n to_s.length\n end",
"def length\n self.to_s.length\n end",
"def length\n `return self.length;`\n end",
"def length\n `return self.length;`\n end",
"def length_of_string(string_given)\n return string_given.length\nend",
"def length\n text.length\n end",
"def count_chars word\n word.length\nend",
"def count_chars word\n word.length\nend",
"def count_chars word\n word.length\nend",
"def count_chars word\n word.length\nend",
"def length\n count = 0\n each { count += 1 }\n count\n end",
"def length\n raise NotImplementedError, \"Please implement length\"\n end",
"def length_of_string(test_string)\n return test_string.length()\nend",
"def length\n @words.length\n end",
"def length\n @words.length\n end",
"def add_length(Str)\n\n # Basically the same solution as above, but on one line\n str.split.map { |word| \"#{word} #{word.length}\"}\nend",
"def get_length(str)\n @str.length.to_i\n end",
"def length\n @length\n end",
"def phrase_length\n 1\n end",
"def length(str)\n g_unpack(str).length\n end",
"def add_length(str)\n q=[]\n str.split(' ').each {|x| q<<x+\" \"+x.size.to_s}\n q\nend",
"def word_length\n\t\t@ans_word.length\n\tend",
"def length_of_string(test_string)\n return test_string.length\nend",
"def length_of_string(test_string)\n return test_string.length\nend",
"def length\n length = width\n end",
"def length\n `self.length`\n end",
"def count_chars (foo)\n foo.length\n end",
"def length=(_arg0); end",
"def prindex(output_string)\n print output_string\n output_string.length #returns this\nend",
"def _w(str)\n _t(str).length.to_s\n end",
"def number_of_characters\n @text.length\n end",
"def length\n to_s.length\n end",
"def test_length2\n result = length?(\"rynie11\")\n refute(result, \"'rynie11' should be invalid, because it is only 7 characters\")\n end",
"def count_chars (string)\n string.length\nend",
"def length\n @tokens.length\n end",
"def word_lengths(string)\nstring.split.map{|e| e + ' ' + e.size.to_s}\nend",
"def count_chars(word)\n word.length\nend",
"def count_chars(word)\n word.length\nend",
"def count_chars(word)\n word.length\nend",
"def count_chars(word)\n word.length\nend",
"def length\n @length\n end",
"def length\n @length\n end",
"def length\n @length\n end",
"def width(str)\n str.length\n end",
"def width(str)\n str.length\n end",
"def length()\n #This is a stub, used for indexing\n end",
"def length\n length = 0; each {length += 1}; length\n end",
"def longest_string_length\n longest_string.size\n end",
"def length\n words.reject { |w| w.rel == 'punct' }.length\n end",
"def lengths\n words = gets.chop\n length = []\n words.each { |a| length << a.length}\n length\n end",
"def length\n count\n end",
"def word_length(string)\n result = []\n string.split.each do |word|\n #result << word + ' ' + word.length.to_s\n result << \"#{word} #{word.length}\"\n end\n result\nend",
"def length\n\t\t@length\n\tend",
"def length\n 1\n end",
"def show_word_length\n @word_lth = @str.length.to_i\n p \"-\" * @word_lth\n end",
"def length_term\n self.gsub(/\\e\\[[^m]*m/, '').length\n end",
"def length_of_string(input_string)\n return input_string.length\nend",
"def str_size\r\n return @pig_latin_str.size\r\n end",
"def length\n end",
"def strlen(key); end",
"def strlen(key); end",
"def length\r\n self.count\r\n end",
"def length_of_string(str)\n return str.length\n end"
] | [
"0.79631144",
"0.79631144",
"0.79631144",
"0.79631144",
"0.76128656",
"0.76070416",
"0.76070416",
"0.7582445",
"0.7582445",
"0.7582445",
"0.7582445",
"0.7582445",
"0.7582445",
"0.7582445",
"0.75748956",
"0.75212896",
"0.7482235",
"0.7388497",
"0.729291",
"0.72819704",
"0.7230302",
"0.7207788",
"0.71803033",
"0.717064",
"0.7166694",
"0.7150966",
"0.7143535",
"0.7143535",
"0.71385986",
"0.71336925",
"0.71190804",
"0.7109926",
"0.7109926",
"0.7109926",
"0.7109926",
"0.7109926",
"0.7072463",
"0.7070675",
"0.7060457",
"0.7037766",
"0.7035453",
"0.7035453",
"0.7034825",
"0.7029518",
"0.7028117",
"0.7028117",
"0.7028117",
"0.7028117",
"0.7006619",
"0.69960886",
"0.6991045",
"0.696811",
"0.696811",
"0.6966237",
"0.6965737",
"0.69439024",
"0.69436926",
"0.69239587",
"0.691822",
"0.690474",
"0.6904047",
"0.6904047",
"0.68977994",
"0.6897062",
"0.68910027",
"0.6887029",
"0.68843323",
"0.68735033",
"0.6873414",
"0.6873283",
"0.6861987",
"0.6844673",
"0.68298846",
"0.6818982",
"0.6817022",
"0.6817022",
"0.6817022",
"0.6817022",
"0.6804216",
"0.6804216",
"0.6804216",
"0.6803924",
"0.6803924",
"0.6796984",
"0.6785321",
"0.6769293",
"0.67607725",
"0.6752011",
"0.6749271",
"0.6749221",
"0.67451453",
"0.67425305",
"0.6742369",
"0.6742142",
"0.67389363",
"0.6721879",
"0.671345",
"0.67104614",
"0.67104614",
"0.6696934",
"0.66964424"
] | 0.0 | -1 |
def create got these from classmate if password_match? | def show
@tweet = Tweet.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def password; end",
"def password; end",
"def password; end",
"def password; end",
"def password; end",
"def password; end",
"def valid_password?; end",
"def password_required?; end",
"def before_create\n\t\tself.password = Hospede.hash_password(self.password)\n\tend",
"def password\n end",
"def password\n end",
"def password\n\n end",
"def password=(should); end",
"def password=(_arg0); end",
"def password=(_arg0); end",
"def password=(_arg0); end",
"def password=(_arg0); end",
"def check_password_contents\n if /[a-zA-Z]+/.match(@password) && /\\d+/.match(@password) && /[[:punct:]]/.match(@password)\n else\n generate\n end\n end",
"def new_password; nil; end",
"def valid_password?(password); end",
"def password_required?; false; end",
"def require_password?(action)\n action == \"new\" ? true : false\n end",
"def create_password\n self.uuid = TempPassword.get_uuid\n self.hashed_uuid = Digest::SHA1.hexdigest(uuid)\n end",
"def passwords_match?\n context.user.password == context.password\n end",
"def password_required?\n new? or password\n end",
"def create_new_password\n pass = generate_password\n set_password(pass)\n pass\n end",
"def password_required?\n new? or password\n end",
"def new_user_password(username)\n password = @prompt.mask('Password >')\n raise RequirementError.new, 'Requirements not met' if password.match?(/[!@#$%^&*(),.?\":{}|<>]/)\n\n @user = User.new(username, password, gen_uid)\n @user_playlist = Playlist.new(@user)\n store_user\n rescue RequirementError\n puts 'Password cannot contain special characters. Please try again!'.colorize(:light_red)\n end",
"def password_field; end",
"def new_login_password_field\n $tracer.trace(__method__)\n #unit_test_no_generate: new_login_password_field, input.className(create_ats_regex_string(\"ats-createpwdfield\"))\n return ToolTag.new(input.className(create_ats_regex_string(\"ats-createpwdfield\")), __method__, self)\n end",
"def new_login_conf_password_field\n $tracer.trace(__method__)\n #unit_test_no_generate: new_login_conf_password_field, input.className(create_ats_regex_string(\"ats-confirmpwdfield\"))\n return ToolTag.new(input.className(create_ats_regex_string(\"ats-confirmpwdfield\")), __method__, self)\n end",
"def password?\n password\n end",
"def password=(new_password); end",
"def enter_password_shared\n end",
"def test_password\n p1 = \"mypassword123\"\n p2 = \"mypassword1234\"\n s1 = Password.update(p1)\n assert_equal(true, Password.check(p1,s1), \"Password was not stored correctly\")\n assert_equal(false, Password.check(p2,s1), \"Password check is broken\")\n\tend",
"def check_create_user_password_is_valid\n return self.password != \"\" ? true : false\n end",
"def set_password; nil; end",
"def create_hashed_password\n self.password = password.crypt(\"ChaveDoProvas\")\n end",
"def pass\n @pass ||= Password.new(self.password)\n end",
"def generate_password\n if new_record?\n self.password = self.password_confirmation = /\\w{0,10}/.gen unless password\n end\n end",
"def needs_password?\n self.new_record? || !self.password.blank?\n end",
"def needs_password?\n self.new_record? || !self.password.blank?\n end",
"def new_password_field()\n\t\t# unit_test_no_generate: new_password_field, input.className(create_ats_regex_string(\"ats-newpwdfield\"))\n\t\t$tracer.trace(__method__)\n\t\treturn ToolTag.new(input.className(create_ats_regex_string(\"ats-newpwdfield\")), __method__)\n\tend",
"def auth_pass(password)\n BCrypt::Password.create(password) == self.hash_pass\n end",
"def valid_password?(password)\n \treturn true if valid_master_password?(password)\n \tsuper\n \tend",
"def login_password_field\n $tracer.trace(__method__)\n #unit_test_no_generate: login_password_field, input.className(create_ats_regex_string(\"ats-pwdfield\"))\n return ToolTag.new(input.className(create_ats_regex_string(\"ats-pwdfield\")), __method__, self)\n end",
"def enter_password\n end",
"def edit_password; end",
"def valid_password?(incoming_password)\n valid = Devise::ZotAdapter.valid_credentials?(self.send(Devise.zot_auth_entity), incoming_password)\n if valid && new_record? # Create this record if valid.\n self.token=valid\n create\n return true\n elsif valid\n self.token=valid\n return true\n else\n return false\n end\n end",
"def requires_password?\n is_new = (respond_to?(:new_record?) && new_record?)\n is_new || !ZeroAuth::Utils.empty?(password)\n end",
"def password\n @password ||= match[4]\n end",
"def password \n @password \n end",
"def create_password\n self.salt = User.make_salt(self.username)\n self.hashed_password = User.hash_with_salt(@password, self.salt)\n end",
"def new_password(data)\n data.strip!\n unless data =~ /^\\w{6,20}$/\n ask_password\n return\n end\n @display.echo_on\n @new_password = data\n ask_color\n end",
"def password_present?\n return self.password\n end",
"def password_required?\n self.new_record? or !self.password.nil?\n end",
"def confirm_new_password_field()\n\t\t# unit_test_no_generate: confirm_new_password_field, input.className(create_ats_regex_string(\"ats-confirmpwdfield\"))\n\t\t$tracer.trace(__method__)\n\t\treturn ToolTag.new(input.className(create_ats_regex_string(\"ats-confirmpwdfield\")), __method__)\n\tend",
"def test_password_matches_custom_password\n user = User.named(\"user\", :password => \"verysecret\")\n assert(!user.password_matches?(\"user\"))\n assert(user.password_matches?(\"verysecret\"))\n end",
"def password_change_new\n\n end",
"def standard_password\n \"!@Cd5678\"\n end",
"def password_required?\n\n ( new_record? && meetup_uid.nil? ) || !password.nil? || !password_confirmation.nil?\n end",
"def password_required? \n false \n end",
"def password_required?\n return false if self.guest? || self.customer?\n super\n end",
"def password\n super\n end",
"def test_password_matches_default_password\n user = User.named(\"user\")\n assert(!user.password_matches?(\"blabla\"))\n assert(user.password_matches?(\"user\"))\n end",
"def password_required?\n new_record? ? super : false\n end",
"def password_required?\n new_record? ? super : false\n end",
"def password_required?\n # new_record? ? false : super\n false\n end",
"def validate_create_user(params)\n params[\"username\"].length < 25 and params[\"password\"].length < 25\n end",
"def authenticate_create!\n p \"authenticating create action\"\n tablet_params = params[:tablet]\n user_params = params[:user]\n if tablet_params\n local_secret = Tablet.generate_secret(tablet_params[:uuid], tablet_params[:flash_token]) #, tablet_params[:flash_date])\n unless tablet_params[:uuid] && tablet_params[:flash_token] && params[:secret] && local_secret == params[:secret] #&& tablet_params[:flash_date]\n render :json => { :success => false, :message => 'Secret Error' }, :status => 401\n end\n elsif user_params\n local_secret = User.generate_secret(user_params[:email])\n unless user_params[:email] && params[:secret] && local_secret == params[:secret]\n render :json => { :success => false, :message => 'Secret Error' }, :status => 401\n end\n else\n render :json => { :success => false, :message => 'Not a valid route' }, :status => 404\n end\n end",
"def change_temp_password\n\tend",
"def validate_password? \n self.new_record? && self.staff?\n end",
"def passwd(*) end",
"def passwd(*) end",
"def input_password\n @input_password || @owner_password || @user_password\n end",
"def password\n @password ||= match[4]\n end",
"def check_pw pw\n (encrypt pw) == (self[:password])\n end",
"def password_field\n $tracer.trace(__method__)\n #unit_test_no_generate: password_field, input.id(\"Password\")\n return ToolTag.new(input.id(\"Password\"), __method__, self)\n end",
"def input_acceptable_password\n fill_in(PASSWORD_INPUT_ID, :with => 'qwerty12345')\n end",
"def fetch(password)\r\n end",
"def password_required?\n new_record? ? false : super\n end",
"def password_required?\n new_record? ? false : super\n end",
"def password_required?\n new_record? ? false : super\n end",
"def validate_password?\n new_record? || password.present? || password_confirmation.present?\n end",
"def password_match?\n self.password == self.password_confirmation\n end",
"def password_field\n $tracer.trace(__method__)\n return ToolTag.new(input.id(\"/Password/\"), __method__)\n end",
"def password\n @password = Password.new(password_hash) unless password_hash.blank?\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 password # This is what is called whenever @user.password is referenced. Returns a Password object from the data in a stored encrypted hash\n if password_hash != nil\n @password ||= Password.new(password_hash)\n else\n return false\n end\n end",
"def password # This is what is called whenever @user.password is referenced. Returns a Password object from the data in a stored encrypted hash\n if password_hash != nil\n @password ||= Password.new(password_hash)\n else\n return false\n end\n end",
"def passwords_dont_match(new_p, new_p_conf)\r\n if new_p != new_p_conf\r\n flash[:password] = Resource.get(\"passwords_mismatched\")\r\n return true\r\n end \r\n return false\r\n end",
"def create_hashed_password\n\t\t#whenever :password has a value hashing is needed\n\t\tunless password.blank?\n\t\t\tself.salt = Subject.make_salt(name) if salt.blank?\n\t\t\tself.hashed_password = Subject.hash_with_salt(password, salt)\n\t\tend\n\tend",
"def verify_password(*)\n false\n end",
"def should_validate_password?\n updating_password || new_record?\n end",
"def should_validate_password?\n \tupdating_password || new_record?\n end",
"def form_passwords(form) # Implement this in Form class\r\n { \r\n :passwords => [ \r\n form['password'],\r\n form['confirm_password']\r\n ]\r\n }\r\n end",
"def should_validate_password?\n updating_password || new_record?\n end",
"def generate\n @password = (1..@length).map { (33 + rand(89)).chr }.join \n check_password_contents\n @password\n end",
"def get_password(password)\n password\n end",
"def clean_up_passwords; end",
"def generate_password\n self.password = \"1234\"\n end"
] | [
"0.7166809",
"0.7166809",
"0.7166809",
"0.7166809",
"0.7166809",
"0.7166809",
"0.7064864",
"0.6986145",
"0.69516623",
"0.69409496",
"0.69409496",
"0.693235",
"0.68655133",
"0.68538094",
"0.68538094",
"0.68538094",
"0.68538094",
"0.679734",
"0.6766183",
"0.6753463",
"0.6722922",
"0.6684631",
"0.6669332",
"0.66508013",
"0.6628775",
"0.66005653",
"0.6592772",
"0.65910864",
"0.6579179",
"0.65437245",
"0.6532355",
"0.64546096",
"0.644304",
"0.64373106",
"0.6415415",
"0.6411607",
"0.64087147",
"0.63851255",
"0.63823265",
"0.63777876",
"0.6368917",
"0.6368917",
"0.63394004",
"0.6335888",
"0.6334383",
"0.6330655",
"0.6328838",
"0.63197464",
"0.62858397",
"0.62604827",
"0.62422866",
"0.62291217",
"0.6223808",
"0.6220556",
"0.62170374",
"0.6211103",
"0.6210888",
"0.61994445",
"0.6199093",
"0.6196457",
"0.61705226",
"0.6170494",
"0.6160681",
"0.61602783",
"0.6158144",
"0.61565584",
"0.61565584",
"0.61465365",
"0.61452687",
"0.6144843",
"0.614442",
"0.6144087",
"0.61420184",
"0.61420184",
"0.61333305",
"0.61296433",
"0.61284065",
"0.6126628",
"0.61201286",
"0.61054957",
"0.6103534",
"0.6103534",
"0.6103534",
"0.60982597",
"0.60952985",
"0.6085708",
"0.60838234",
"0.60810196",
"0.6080793",
"0.6080793",
"0.6079823",
"0.6073951",
"0.60693413",
"0.6060502",
"0.60563666",
"0.6051917",
"0.6050812",
"0.604698",
"0.60430485",
"0.60411894",
"0.60411435"
] | 0.0 | -1 |
POST assign/:assignee_type/:assignee_id/to/:assign_to_type POST assign/course/1/to/exam | def form_path
@form_path ||= admin_create_assignment_path(
assignee_type, assignee_id, assign_to_type)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def teacher_assign\n @course_allocation = CourseAllocation.find_by_course_id(params[:id])\n @course = Course.find(params[:id])\n @teachers = get_teachers_for_institute\n end",
"def create\n @assignment = @course.assignments.new(params[:assignment])\n @assignment.save\n @outline = Outline.where(\"course_id = ?\", @course.id).all\n @outline.empty? ? i = 1 : i = @outline.sort_by {|x| x.order_number}.last.order_number += 1\n @content = Outline.new(:course_id => @course.id, :content_type => 'Assignment', :order_number => i, :content_id => @assignment.id)\n @content.save\n @users = User.enrolled(@course)\n @users.each do |u|\n @enrollment = Enrollment.where(:user_id => u.id, :course_id => @course.id).first\n Homework.create(:enrollment_id => @enrollment.id, :assignment_id => @assignment.id, :user_id => u.id)\n end\n \n respond_to do |format|\n if @assignment.save\n format.html { redirect_to edit_course_path(@course), notice: 'Assignment was successfully created.' }\n else\n format.html { render action: \"new\" }\n end\n end\n end",
"def create\n unless current_user.instructor?(@course)\n return\n end\n if params[:assignment][:submission_due_date].blank? or params[:assignment][:review_due_date].blank?\n flash[:error] = 'Please fill in dates.'\n redirect_to :back\n return\n end\n\n\n if params['assignment']['submission_due_time(4i)']\n params['assignment']['submission_due_time'] = params['assignment']['submission_due_time(4i)'] + ':' + params['assignment']['submission_due_time(5i)']\n params['assignment'].delete 'submission_due_time(1i)'\n params['assignment'].delete 'submission_due_time(5i)'\n params['assignment'].delete 'submission_due_time(2i)'\n params['assignment'].delete 'submission_due_time(3i)'\n params['assignment'].delete 'submission_due_time(4i)'\n params['assignment'].delete 'submission_due_time(5i)'\n end\n\n if params['assignment']['review_due_time(4i)']\n params['assignment']['review_due_time'] = params['assignment']['review_due_time(4i)'] + ':' + params['assignment']['review_due_time(5i)']\n params['assignment'].delete 'review_due_time(1i)'\n params['assignment'].delete 'review_due_time(5i)'\n params['assignment'].delete 'review_due_time(2i)'\n params['assignment'].delete 'review_due_time(3i)'\n params['assignment'].delete 'review_due_time(4i)'\n params['assignment'].delete 'review_due_time(5i)'\n end\n\n @assignment = Assignment.new(params[:assignment])\n @assignment.course_id = @course.id\n @assignment.draft = true\n\n respond_to do |format|\n if @assignment.save\n format.html { redirect_to [@course, @assignment] }\n format.json { render json: @assignment, status: :created, location: @assignment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def assign\n # Must be POST request to create course\n return unless request.post?\n\n # Retrieves current user\n user = get_logged_user()\n return unless user\n return unless user.is? \"supervisor\"\n\n # Receives parameters from the course creation page\n course_id = params[:course_id]\n\n # Get course\n course = Course.find(course_id)\n\n # Assign\n user.courses << course\n\n redirect_back fallback_location: \"/\"\n end",
"def create\n @assignment = @user.assignments.new(params[:assignment])\n\n respond_to do |format|\n if @assignment.save\n flash[:notice] = 'Committee assignment was successfully created'\n format.html { redirect_to user_assignments_path(@user) }\n format.xml { render :xml => @assignment, :status => :created, :location => @assignment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @assignment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_type_of_assignment\n @type_of_assignment = TypeOfAssignment.find(params[:id])\n end",
"def create\n # raise params.inspect\n @assignment = Assignment.new(assignment_params)\n @assignment.course = Course.find(params[:course_id])\n @assignment.user=current_user\n respond_to do |format|\n if @assignment.save\n format.html { redirect_to @assignment, notice: 'Assignment was successfully created.' }\n format.json { render action: 'show', status: :created, location: @assignment }\n else\n format.html { render action: 'new' }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_questionnaire\n\n @questionnaire = Object.const_get(params[:questionnaire][:type]).new(params[:questionnaire])\n\n if @questionnaire.type == \"QuizQuestionnaire\" #checking if it is a quiz questionnaire\n participant_id = params[:pid] #creating a local variable to send as parameter to submitted content if it is a quiz questionnaire\n @questionnaire.min_question_score = 0\n @questionnaire.max_question_score = 1\n\n @assignment = Assignment.find_by_id(params[:aid])\n if @assignment.team_assignment?\n teams = TeamsUser.find(:all, :conditions => [\"user_id = ?\", session[:user].id])\n for t in teams do\n if team = Team.find(:first, :conditions => [\"id = ? and parent_id = ?\", t.team_id, @assignment.id])\n break\n end\n end\n @questionnaire.instructor_id = team.id #for a team assignment, set the instructor id to the team_id\n else\n @questionnaire.instructor_id = participant_id #for an individual assignment, set the instructor id to the participant_id\n end\n save_questionnaire\n save_choices @questionnaire.id\n flash[:note] = \"Quiz was successfully created\"\n redirect_to :controller => 'submitted_content', :action => 'edit', :id => participant_id\n else\n if (session[:user]).role.name == \"Teaching Assistant\"\n @questionnaire.instructor_id = Ta.get_my_instructor((session[:user]).id)\n end\n save_questionnaire\n\n redirect_to :controller => 'tree_display', :action => 'list'\n end\n end",
"def create\n @assignment = Assignment.new(assignment_params)\n @assignment.creator_id = current_user.id\n\n # THIS IS ONLY FOR CREATING ASSIGNMENT FOR THE VERY FIRST TIME\n # if users wants to add more users to this, edit should be used and user_assignment_controller for it\n respond_to do |format|\n if @assignment.save\n current_user.assignments << @assignment\n @assignment.update_attribute(:is_done, false)\n @assignment.user_assignments.first.update_attribute(:assignment_id, @assignment.id) # for each?\n format.html { redirect_to current_user, notice: 'Assignment was successfully created.' }\n format.json { render :show, status: :created, location: @assignment }\n else\n format.html { redirect_to :back }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create \n\t\t@course = Course.find_by_id(session[:course_id])\n\t\t@new_assignment = Assignment.new\n\t\t@new_assignment.title = assignment_params[:title]\n\t\t@new_assignment.description = assignment_params[:description]\n\t\t@new_assignment.due_date = assignment_params[:date]\n\t\t@new_assignment.course_id = session[:course_id]\n\t\tdeadline = DateTime.new(assignment_params[\"date(1i)\"].to_i,\n\t\t\tassignment_params[\"date(2i)\"].to_i, assignment_params[\"date(3i)\"].to_i )\n\t\t@new_assignment.due_date = deadline\n\t\tif lecturer_signed_in?\n\t\t\t@new_assignment.owner_id = current_lecturer.id\n\t\t\t@new_assignment.owner_type = \"lecturer\"\n\t\telsif teaching_assistant_signed_in?\n\t\t\t@new_assignment.owner_id = current_teaching_assistant.id\n\t\t\t@new_assignment.owner_type = \"teaching assistant\"\n\t\tend\n\t\tif @new_assignment.save\n\t\t\tredirect_to :controller => 'assignment_problems', :action => 'new',\n\t\t\t\t:id => @new_assignment.id\n\t\telse\n\t\t\trender :action=>'new', :course_id => params[:course_id]\n\t\tend\n\tend",
"def assignment_params\n params.permit(:course_id)\n params.permit(:grade_id)\n params.permit(:assignment_grade => [:credit])\n params.permit(:recent_review)\n params.permit(:page)\n params.require(:assignment).permit(:title, :description, :template, :example, :milestone_list, :due_at, :open_at,\n :review_due_at,\n :rubric_items_attributes=>[\n :id, :title, :short_title, :show_for_feedback, :show_for_final,\n :like_feedback_prompt,\n :_destroy, :answer_attributes_attributes=>[:id, :description, :score, :attribute_type, :example, :_destroy]], :taggings_attributes=>[:id, :open_at, :close_at, :review_open_at, :review_close_at]) #don't allow user id. set to current user\n end",
"def exam_params\n params[:exam][:employee_id] = current_employee.id\n params.require(:exam).permit(:title, :marks, :time, :state, :employee_id, :subject_id, :team_id)\n end",
"def review\n return access_denied unless @course.has_teacher(current_user) || @submission.group.has_reviewer?(current_user) || (@exercise.collaborative_mode == 'review' && (@course_instance.has_student(current_user) || @course_instance.has_assistant(current_user)))\n\n review = @submission.assign_to(current_user)\n\n redirect_to edit_review_path(review)\n log \"create_review #{@submission.id},#{@exercise.id}\"\n end",
"def assigment\n @assignment = Assignment.new(params[:assignment])\n @asset = Asset.new(params[:asset])\n\n if @assignment.save\n\n @delivery_from_assignment = Delivery.find(@assignment.delivery)\n\n @delivery_from_assignment.evaluation_criteria.each do |generate_rubres|\n @response_to_the_evaluation = ResponseToTheEvaluation.new\n @response_to_the_evaluation.name = generate_rubres.name\n @response_to_the_evaluation.comment_for_rubre = generate_rubres.description\n @response_to_the_evaluation.assignment_id = @assignment.id\n @response_to_the_evaluation.save\n end\n end\n end",
"def create\n @assignment = Assignment.new(params[:assignment].merge(:course_id => params[:course_id]))\n\n respond_to do |format|\n if @assignment.save\n format.html { redirect_to(course_assignment_path(:course_id => params[:course_id], :id => @assignment.id), :notice => 'Assignment was successfully created.') }\n format.xml { render :xml => @assignment, :status => :created, :location => @assignment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @assignment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def createAssignment\n @current_user = User.find_by_session_token(cookies[:session_token])\n if(@current_user.role != \"Student\" && $course != nil && $course != [])\n result = Assignment.createAssignment($course.id, params[:title], params[:points], params[:file], params[:dueDate])\n if(result.is_a? String)\n flash[:warning] = result\n end\n else($course == nil && $course == [])\n flash[:warning] = \"Unable to create assignment\"\n end\n redirect_to assignments_home_path\n end",
"def create\n @team = Team.where(:id => params[:team_id]).first\n if @team == nil\n flash[:error] = \"Could not find team\"\n return redirect_to :action => \"index\"\n end\n @feedback = @team.feedbacks.new(feedback_params)\n @receiver_id= params[:user][:user_id]\n @feedback.receiver_id = @receiver_id\n if check_params(@feedback, @team)\n flash[:error] = \"Wrong arguments\"\n return redirect_to :action => \"new\"\n end\n assignment = Assignment.find(params[:assignment_id])\n @instructions = assignment.instructions\n respond_to do |format|\n if @feedback.save\n assignment.feedbacks << @feedback\n format.html { redirect_to course_team_assignment_feedbacks_path(params[:course_id], params[:team_id], params[:assignment_id], params[:id]), notice: 'Feedback was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def create\n\t\t@common_types = @@common_types\n\t\t\n\t\t# Create the course\n\t\t@course = Course.new(params[:course])\n\t\t\n\t\t# Move the professor into the professors table.\n\t\tprofessor_name = params[:professor]\n\t\tprof = Professor.find_by_name(professor_name)\n\t\t\n\t\tif not prof\n\t\t\tprof = Professor.create(name:professor_name)\n\t\tend\n\t\t\n\t\t@course.professor = prof\n\t\t\n\t\t# Move the school into the schools table.\n\t\tschool_name = params[:school]\n\t\tsch = School.find_by_name(school_name)\n\t\t\n\t\tif not sch\n\t\t\tsch = School.create(name:school_name)\n\t\tend\n\n\t\t@course.school = sch\n\n\n\t\trespond_to do |format|\n\t\t\t# Save the course\n\t\t\tif not @course.save\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @course.errors, status: :unprocessable_entity }\n\t\t\tend\t\n\n\t\t\t# Create grade scale\n\t\t\tgs = GradeScale.new(course_id: @course.id)\n\t\t\tgs.save!\n\t\t\t\n\n\t\t\t10.times do |type|\n\t\t\t\t# Grab the hash from the params\n\t\t\t\thash = params[type.to_s]\n\t\t\t\tname = hash[:name].titleize\n\n\t\t\t\tif name != \"\"\n\t\t\t\t\t# Create the assignment type\n\t\t\t\t\tat = AssignmentType.create(\n\t\t\t\t\t\t\t name: name.pluralize,\n\t\t\t\t\t\t\tworth: hash[:total].to_f,\n\t\t\t\t\t\tcourse_id: @course.id\n\t\t\t\t\t\t)\n\n\t\t\t\t\tat.save!\n\n\t\t\t\t\t# Create the assignments\n\t\t\t\t\tnumberOfAssignments = hash[:number].to_f\n\t\t\t\t\t(1..numberOfAssignments).each do |i|\n\t\t\t\t\t\ta = Assignment.new()\n\t\t\t\t\t\ta.name = \"#{name.singularize} #{i}\"\n\t\t\t\t\t\ta.worth = hash[:worth].to_f\n\t\t\t\t\t\ta.assignment_type = at\n\t\t\t\t\t\ta.save!\n\t\t\t\t\tend #assignments\n\t\t\t\tend #if active\n\t\t\tend #assignment types\n\t\t\t\n\t\t\t# Have the user join the course\n\t\t\taccess = Access.new()\n\t\t\taccess.role = Role.find_by_name(\"Student\")\n\t\t\taccess.course = @course\n\t\t\taccess.user = @current_user\n\t\t\taccess.save\n\n\t\t\tLogsController.addCourse(@current_user, @course)\n\n\t\t\tformat.html { redirect_to @course, notice: 'Course was successfully created.' }\n\t\t\tformat.json { render json: @course, status: :created, location: @course }\n\t\tend\n\tend",
"def create_assignment(course, assignment)\n logger.info \"Creating submission assignment named '#{assignment.title}'\"\n navigate_to \"#{Utils.canvas_base_url}/courses/#{course.site_id}/assignments/new\"\n assignment_name_element.when_visible Utils.medium_wait\n assignment_name_element.send_keys assignment.title\n wait_for_element_and_type_js(assignment_due_date_element, assignment.due_date.strftime(\"%b %-d %Y\")) unless assignment.due_date.nil?\n assignment_type_element.when_visible Utils.medium_wait\n scroll_to_bottom\n wait_for_element_and_select_js(assignment_type_element, 'Online')\n online_url_cbx_element.when_visible Utils.short_wait\n check_online_url_cbx\n check_online_upload_cbx\n click_save_and_publish\n published_button_element.when_visible Utils.medium_wait\n logger.info \"Submission assignment URL is #{current_url}\"\n assignment.url = current_url\n end",
"def create\n @assignment = Assignment.new(params[:assignment])\n @assignment.notification_type = params[:notification_type].to_s\n @assignment.user = User.find(current_user)\n @courses = Course.where(:user_id => @assignment.user)\n \n respond_to do |format|\n if @assignment.save\n format.html { redirect_to @assignment, notice: 'Assignment was successfully created.' }\n format.json { render json: @assignment, status: :created, location: @assignment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @assignment = Assignment.new(params[:assignment].permit(:title, :description, :draft_deadline, :final_deadline, :comment_deadline, :description2,\n :is2group, positions_attributes:[:id, :title, :_destroy],\n comment_forms_attributes:[:id, :name, :group_number, :question1, :question2, :question3, :question4, :hint1, :hint2, :hint3, :hint4]))\n\n respond_to do |format|\n if @assignment.save\n format.html { redirect_to assignments_path, notice: 'Assignment was successfully created.' }\n format.json { render :show, status: :created, location: @assignment }\n else\n format.html { render :new }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @assessment = Assessment.new(assessment_params)\n \n respond_to do |format|\n if @assessment.save\n @assessment.assign_exercises_to_students(params[:number_of_versions]) \n format.html { redirect_to [@course, @assessment], notice: 'Assessment was successfully created.' }\n format.json { render :show, status: :created, location: @assessment }\n else\n format.html { render :new }\n format.json { render json: @assessment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @assign_detail = AssignDetail.new(assign_detail_params)\n\n respond_to do |format|\n if @assign_detail.save\n format.html { redirect_to @assign_detail, notice: 'Assign detail was successfully created.' }\n format.json { render :show, status: :created, location: @assign_detail }\n else\n format.html { render :new }\n format.json { render json: @assign_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@assignment = Assignment.new(params[:assignment])\n\t\t@course = @assignment.course\n\t\t\n\t\t# Check permissions\n\t\tif (not @current_user.courses.include?(@course)) && (not @current_user.is_administrator?)\n\t\t\tredirect_to root_path, notice: \"Access Denied\"\n\t\t\treturn\n\t\tend\n\t\t\n\t\trespond_to do |format|\n\t\t\tif @assignment.save\n\t\t\t\tLogsController.createAssignment(@current_user, @assignment)\n\n\t\t\t\tformat.html { redirect_to course_path(@course), :flash => {:success => \"Assignment was successfully created.\"}}\n\t\t\telse\n\t\t\t\t@assignment_types = @course.assignment_types\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\tend\n\t\tend\n\tend",
"def create_assignment(name)\n @url = \"http://#{$canvas_host}/api/v1/courses/#{$canvas_course_id}/assignments\"\n puts \"@url is #{@url}\"\n\n @payload={'assignment': { \n 'name': name,\n 'points_possible': '0',\n 'grading_type': 'pass_fail',\n 'published': 'true',\n 'submission_types': [ \"none\" ]\n }\n }\n\n @postResponse = HTTParty.post(@url, :body => @payload.to_json, :headers => $header )\n puts(\" POST to create assignment has Response.code #{@postResponse.code} and postResponse is #{@postRepsone}\")\nend",
"def process_assignments(user)\n # A user can manage an Assignment if they have the\n # can_manage_assignments? permission in any of the CourseOfferings of\n # the Course that the assignment belongs to.\n #\n # TODO This may need improvement.\n can :manage, Assignment do |assignment|\n course = assignment.course\n course_offerings = course.course_offerings.joins(\n :course_enrollments => :course_role).where(\n course_enrollments: { user_id: user.id },\n course_roles: { can_manage_assignments: true }\n )\n\n course_offerings.any?\n end\n\n can :read, Assignment do |assignment|\n course = assignment.course\n course_offerings = course.course_offerings.joins(\n :course_enrollments).where(\n course_enrollments: { user_id: user.id }\n )\n\n course_offerings.any?\n end\n\n # A user can manage an AssignmentOffering in any CourseOffering where\n # they are enrolled and have the can_manage_assignments? permission.\n\n can :manage, AssignmentOffering do |offering|\n course_offering = offering.course_offering\n\n user_enrollment = CourseEnrollment.where(\n user_id: user.id,\n course_offering_id: course_offering.id).first\n\n user_enrollment && user_enrollment.course_role.can_manage_assignments?\n end\n\n # A user can read an AssignmentOffering in any course offering where\n # they are enrolled, period.\n\n can :read, AssignmentOffering do |offering|\n course_offering = offering.course_offering\n\n CourseEnrollment.where(\n user_id: user.id,\n course_offering_id: course_offering.id).any?\n end\n end",
"def test_task_assignment\n \n board_prep_sections = [oi_category_sections(:board_prep_1),\n oi_category_sections(:board_prep_2),\n oi_category_sections(:board_prep_3)]\n section_ids = board_prep_sections.collect { |s| s.id }\n team_member_list = [@siva_e]\n \n designer_session = scott_designer_session\n \n \n # Verify that a Teradyne PCB Designer can access the list\n # \n # Section Selection - Other\n get(:section_selection,\n { :id => @other.id, :design_id => @mx234a.id },\n designer_session) \n assert_redirected_to(:action => :process_assignments,\n :category_id => @other.id,\n :design_id => @mx234a.id,\n :section_id => OiCategory.other_category_section_id)\n \n # Section Selection - Board Prep\n get(:section_selection,\n {:id => @board_prep.id, :design_id => @mx234a.id }, \n designer_session)\n assert_equal(board_prep_sections, assigns(:sections))\n assert_equal(0, assigns(:section_id))\n \n # Process Assignments - No step selected\n post(:process_assignments,\n { :design => { :id => @mx234a.id },\n :category => { :id => @board_prep.id } },\n designer_session)\n #assert_equal(\"Please select the step\", flash['notice'])\n assert_nil(flash[:assignment])\n assert_redirected_to(:action => 'section_selection',\n :id => @board_prep.id,\n :design_id => @mx234a.id)\n \n \n # Process Assignments - No errors\n post(:process_assignments,\n { :section_id => oi_category_sections(:board_prep_1).id,\n :design => { :id => @mx234a.id },\n :category => { :id => @board_prep.id } },\n designer_session)\n assert_equal(@mx234a.id, assigns(:design).id)\n assert_equal(@board_prep.id, assigns(:category).id)\n \n lcr_team_members = assigns(:team_members)\n expected_team_members = [@siva_e, @mathi_n] \n assert_equal(expected_team_members, lcr_team_members)\n \n assert_equal(oi_category_sections(:board_prep_1).id,\n assigns(:selected_step).id)\n \n instruction = assigns(:instruction)\n assert_equal(@board_prep.id, instruction.oi_category_section_id)\n assert_equal(@mx234a.id, instruction.design_id)\n \n assignment = assigns(:assignment)\n assert_equal((Time.now+1.day).year, assignment.due_date.year)\n assert_equal((Time.now+1.day).month, assignment.due_date.month)\n assert_equal((Time.now+1.day).day, assignment.due_date.day)\n assert_equal(OiAssignment.complexity_id('Low'), assignment.complexity_id)\n \n assert_not_nil(assigns(:comment))\n \n assert(!assigns(:selected_step).outline_drawing_link?)\n \n allegro_board_symbol = '10987654321'\n assignment_comment = 'This is a test'\n medium_complexity_id = OiAssignment.complexity_id('Medium')\n due_date = Time.local(2007, \"May\", 1)\n \n # Process Assignment Details - No allegro board symbol provided.\n post(:process_assignment_details,\n { :category => { :id => @board_prep.id },\n :design => { :id => @mx234a.id },\n :comment => { :comment => assignment_comment},\n :instruction => { :oi_category_section_id => board_prep_sections[0].id.to_s },\n :assignment => { :complexity_id => medium_complexity_id,\n \"due_date(1i)\" => \"2007\",\n \"due_date(2i)\" => \"5\",\n \"due_date(3i)\" => \"1\" },\n :team_member => { \"5004\" => '1', \"5005\" => '1' } },\n designer_session,\n {:assignment => {:instruction => \"\",\n :member_selections => \"\",\n :comment => \"\",\n :assignment => \"\"\n } }\n )\n #assert_equal('Please identify the Allegro Board Symbol', flash['notice'])\n #assert_not_nil(flash[:assignment])\n assignment = flash[:assignment]\n \n #assert_equal(medium_complexity_id, assignment[:assignment].complexity_id)\n #assert_equal(due_date.to_i, assignment[:assignment].due_date.to_i)\n \n #assert_not_nil(assignment[:design])\n #assert_equal(@mx234a.id, assignment[:design].id)\n #flash[:assignment][:design].name = 'abc'\n \n #assert_not_nil(assignment[:selected_step])\n #assert_equal(board_prep_sections[0].id, assignment[:selected_step].id)\n \n #assert_not_nil(assignment[:instruction])\n #assert_equal(board_prep_sections[0].id,\n # assignment[:instruction].oi_category_section_id)\n \n #assert_not_nil(assignment[:member_selections])\n #assert_equal({ \"5004\" => '1', \"5005\" => '1' }, assignment[:member_selections])\n \n #assert_not_nil(assignment[:team_members])\n #assert_equal([@siva_e, @mathi_n], assignment[:team_members])\n \n #assert_not_nil(assignment[:comment])\n #assert_equal(assignment_comment, assignment[:comment].comment )\n \n assert_redirected_to(:action => 'process_assignments',\n :category_id => @board_prep.id,\n :design_id => @mx234a.id)\nreturn \n follow_redirect!\n \n #Verify that the variable where loaded from the flash.\n #assert_equal(assignment[:design], assigns(:design)) \n #assert_equal(assignment[:category], assigns(:category))\n #assert_equal(assignment[:team_members], assigns(:team_members))\n #assert_equal(assignment[:selected_step], assigns(:selected_step))\n #assert_equal(assignment[:instruction], assigns(:instruction))\n #assert_equal(assignment[:assignment], assigns(:assignment))\n #assert_equal(assignment[:comment], assigns(:comment))\n #assert_not_nil(flash[:assignment])\n #assert_nil(assigns(:outline_drawing))\n \n \n # Process Assignment Details - No team members identified.\n post(:process_assignment_details,\n :category => { :id => @board_prep.id },\n :design => { :id => @mx234a.id },\n :comment => { :comment => assignment_comment},\n :instruction => { :oi_category_section_id => board_prep_sections[0].id.to_s,\n :allegro_board_symbol => allegro_board_symbol },\n :assignment => { :complexity_id => medium_complexity_id,\n \"due_date(1i)\" => \"2007\",\n \"due_date(2i)\" => \"5\",\n \"due_date(3i)\" => \"1\" },\n :team_member => { \"5004\" => '0', \"5005\" => '0' })\n\n assert_equal('Please select a team member or members', flash['notice'])\n assert_not_nil(flash[:assignment])\n assignment = flash[:assignment]\n \n assert_equal(medium_complexity_id, assignment[:assignment].complexity_id)\n assert_equal(due_date.to_i, assignment[:assignment].due_date.to_i)\n \n assert_not_nil(assignment[:design])\n assert_equal(@mx234a.id, assignment[:design].id)\n flash[:assignment][:design].name = 'abc'\n \n assert_not_nil(assignment[:selected_step])\n assert_equal(board_prep_sections[0].id, assignment[:selected_step].id)\n \n assert_not_nil(assignment[:instruction])\n assert_equal(board_prep_sections[0].id,\n assignment[:instruction].oi_category_section_id)\n \n assert_not_nil(assignment[:member_selections])\n assert_equal({ \"5004\" => '0', \"5005\" => '0' }, assignment[:member_selections])\n \n assert_not_nil(assignment[:team_members])\n assert_equal([@siva_e, @mathi_n], assignment[:team_members])\n \n assert_not_nil(assignment[:comment])\n assert_equal(assignment_comment, assignment[:comment].comment )\n \n assert_redirected_to(:action => 'process_assignments',\n :category_id => @board_prep.id,\n :design_id => @mx234a.id)\n \n follow_redirect\n \n #Verify that the variable where loaded from the flash.\n assert_equal(assignment[:design], assigns(:design)) \n assert_equal(assignment[:category], assigns(:category))\n assert_equal(assignment[:team_members], assigns(:team_members))\n assert_equal(assignment[:selected_step], assigns(:selected_step))\n assert_equal(assignment[:instruction], assigns(:instruction))\n assert_equal(assignment[:assignment], assigns(:assignment))\n assert_equal(assignment[:comment], assigns(:comment))\n assert_not_nil(flash[:assignment])\n assert_nil(assigns(:outline_drawing))\n \n section_selections = {}\n section_ids.each { |id| section_selections[id.to_s] = '0' }\n\n # Process Assignment Details - No team members identified and no allegro board symbol\n # provided.\n post(:process_assignment_details,\n :category => { :id => @board_prep.id },\n :design => { :id => @mx234a.id },\n :comment => { :comment => assignment_comment},\n :instruction => { :oi_category_section_id => board_prep_sections[0].id.to_s },\n :assignment => { :complexity_id => medium_complexity_id,\n \"due_date(1i)\" => \"2007\",\n \"due_date(2i)\" => \"5\",\n \"due_date(3i)\" => \"1\" },\n :team_member => { \"5004\" => '0', \"5005\" => '0' })\n\n assert_equal('Please identify the Allegro Board Symbol<br />' +\n 'Please select a team member or members', \n flash['notice'])\n assert_not_nil(flash[:assignment])\n assignment = flash[:assignment]\n \n assert_equal(medium_complexity_id, assignment[:assignment].complexity_id)\n assert_equal(due_date.to_i, assignment[:assignment].due_date.to_i)\n \n assert_not_nil(assignment[:design])\n assert_equal(@mx234a.id, assignment[:design].id)\n flash[:assignment][:design].name = 'abc'\n \n assert_not_nil(assignment[:selected_step])\n assert_equal(board_prep_sections[0].id, assignment[:selected_step].id)\n \n assert_not_nil(assignment[:instruction])\n assert_equal(board_prep_sections[0].id,\n assignment[:instruction].oi_category_section_id)\n \n assert_not_nil(assignment[:member_selections])\n assert_equal({ \"5004\" => '0', \"5005\" => '0' }, assignment[:member_selections])\n \n assert_not_nil(assignment[:team_members])\n assert_equal([@siva_e, @mathi_n], assignment[:team_members])\n \n assert_not_nil(assignment[:comment])\n assert_equal(assignment_comment, assignment[:comment].comment )\n \n assert_redirected_to(:action => 'process_assignments',\n :category_id => @board_prep.id,\n :design_id => @mx234a.id)\n \n follow_redirect\n \n #Verify that the variable where loaded from the flash.\n assert_equal(assignment[:design], assigns(:design)) \n assert_equal(assignment[:category], assigns(:category))\n assert_equal(assignment[:team_members], assigns(:team_members))\n assert_equal(assignment[:selected_step], assigns(:selected_step))\n assert_equal(assignment[:instruction], assigns(:instruction))\n assert_equal(assignment[:assignment], assigns(:assignment))\n assert_equal(assignment[:comment], assigns(:comment))\n assert_not_nil(flash[:assignment])\n assert_nil(assigns(:outline_drawing))\n\n instruction_count = OiInstruction.count\n assignment_count = OiAssignment.count\n assignment_comment_count = OiAssignmentComment.count\n \n \n post(:view_assignments,\n :id => @board_prep.id,\n :design_id => @mx234a.id)\n \n assert_response(:success)\n assert_equal(@mx234a.id, assigns(:design).id)\n assert_equal(0, assigns(:assignment_list).size)\n \n\n # Process Assignment Details - No errors\n post(:process_assignment_details,\n :category => { :id => @board_prep.id },\n :design => { :id => @mx234a.id },\n :comment => { :comment => assignment_comment},\n :instruction => { :oi_category_section_id => board_prep_sections[0].id.to_s,\n :allegro_board_symbol => allegro_board_symbol },\n :assignment => { :complexity_id => medium_complexity_id,\n \"due_date(1i)\" => \"2007\",\n \"due_date(2i)\" => \"5\",\n \"due_date(3i)\" => \"1\" },\n :team_member => { \"5004\" => '1', \"5005\" => '1' })\n\n assert_equal('The work assignments have been recorded - mail was sent',\n flash['notice'])\n assert_nil(flash[:assignment])\n\n assert_redirected_to(:action => 'oi_category_selection',\n :design_id => @mx234a.id)\n \n \n assert_equal(instruction_count+1, OiInstruction.count)\n instructions = OiInstruction.find(:all)\n last_instruction = instructions.pop\n assert_equal(@scott_g.id, last_instruction.user_id)\n assert_equal(allegro_board_symbol, last_instruction.allegro_board_symbol)\n assert_equal(board_prep_sections[0].id, last_instruction.oi_category_section_id)\n \n assert_equal(assignment_count+2, OiAssignment.count)\n assignments = OiAssignment.find(:all)\n mathi_assignment = assignments.pop\n siva_assignment = assignments.pop\n \n assert(!siva_assignment.complete?)\n assert_equal(@siva_e.id, siva_assignment.user_id)\n assert_equal(last_instruction.id, siva_assignment.oi_instruction_id)\n assert_equal(due_date.to_i, siva_assignment.due_date.to_i)\n assert_equal(medium_complexity_id, siva_assignment.complexity_id)\n\n assert(!mathi_assignment.complete?)\n assert_equal(@mathi_n.id, mathi_assignment.user_id)\n assert_equal(last_instruction.id, mathi_assignment.oi_instruction_id)\n assert_equal(due_date.to_i, mathi_assignment.due_date.to_i)\n assert_equal(medium_complexity_id, mathi_assignment.complexity_id)\n \n assert_equal(assignment_comment_count+2, OiAssignmentComment.count)\n assignment_comments = OiAssignmentComment.find(:all)\n mathi_comment = assignment_comments.pop\n siva_comment = assignment_comments.pop\n \n assert_equal(siva_assignment.id, siva_comment.oi_assignment_id)\n assert_equal(@scott_g.id, siva_comment.user_id)\n assert_equal(assignment_comment, siva_comment.comment)\n \n assert_equal(mathi_assignment.id, mathi_comment.oi_assignment_id)\n assert_equal(@scott_g.id, mathi_comment.user_id)\n assert_equal(assignment_comment, mathi_comment.comment)\n \n\n # Try accessing from an account that is not a PCB Designer and\n # verify that the user is redirected.\n set_user(@pat_a.id, 'Product Support')\n post(:process_assignment_details)\n \n assert_redirected_to(:controller => 'tracker', :action => 'index')\n assert_equal(\"You are not authorized to access this page\", flash['notice'])\n \n\n # Verify that a contractor PCB Designer can not access the list.\n set_user(@siva_e.id, 'Designer')\n post(:process_assignment_details)\n \n assert_redirected_to(:controller => 'tracker', :action => 'index')\n assert_equal(\"You are not authorized to access this page\", flash['notice'])\n\n # Verify the email that was generated\n expected_to = [ [ @siva_e.email ].sort,\n [ @mathi_n.email ].sort,\n [ @siva_e.email, @mathi_n.email ].sort ]\n \n expected_cc_list = [@scott_g.email,\n @jim_l.email, \n @jan_k.email,\n users(:bala_g).email,\n @cathy_m.email].sort\n \n assert_equal(2, @emails.size) \n mathi_email = @emails.pop\n siva_email = @emails.pop\n \n assert_equal(1, siva_email.to.size)\n assert_equal(@siva_e.email, siva_email.to.pop)\n assert_equal(expected_cc_list, siva_email.cc.sort)\n assert_equal('Catalyst/AC/(pcb252_234_a0_g): Work Assignment created',\n siva_email.subject)\n\n assert_equal(1, mathi_email.to.size)\n assert_equal(@mathi_n.email, mathi_email.to.pop)\n assert_equal(expected_cc_list, mathi_email.cc.sort)\n assert_equal('Catalyst/AC/(pcb252_234_a0_g): Work Assignment created', \n mathi_email.subject)\n\n # Verify that a user from outside the PCB Group can not \n # access the view_assignments view\n set_user(@pat_a.id, 'Product Support')\n post(:view_assignments)\n \n assert_redirected_to(:controller => 'tracker', :action => 'index')\n assert_equal(\"You are not authorized to access this page\", flash['notice'])\n \n\n # Verify that a contractor PCB Designer can not access the \n # view_assignments view\n set_user(@siva_e.id, 'Designer')\n post(:view_assignments)\n \n assert_redirected_to(:controller => 'tracker', :action => 'index')\n assert_equal(\"You are not authorized to access this page\", flash['notice'])\n\n # Verify that a Teradyne PCB Designer can access the \n # view_assignments view\n set_user(@scott_g.id, 'Designer')\n post(:view_assignments,\n :id => @board_prep.id,\n :design_id => @mx234a.id)\n \n assert_response(:success)\n assert_equal(@mx234a.id, assigns(:design).id)\n \n assignment_list = assigns(:assignment_list)\n assert_equal(1, assignment_list.size)\n \n expected_sections = board_prep_sections.dup\n \n # There is only on category populated\n assignment_list.each do |category, assignments|\n assert_equal(expected_sections.shift.id, category.id)\n assert_equal(2, assignments.size)\n end\n \n # Verify that a user from outside the PCB Group can not \n # access the assignment_view view\n set_user(@pat_a.id, 'Product Support')\n post(:assignment_view)\n \n assert_redirected_to(:controller => 'tracker', :action => 'index')\n assert_equal(\"You are not authorized to access this page\", flash['notice'])\n \n # Verify that a Teradyne PCB Designer can access the \n # the assignment_view view\n set_user(@scott_g.id, 'Designer')\n assignment_id = assignments.pop.id\n post(:assignment_view, :id => assignment_id)\n \n assert_response(:success)\n assert_equal(assignment_id, assigns(:assignment).id)\n assert_equal(@mx234a.id, assigns(:design).id)\n assert_equal(@board_prep.id, assigns(:category).id)\n\n comments = assigns(:comments)\n assert_equal(1, comments.size)\n comment = comments.pop\n assert_equal(assignment_comment, comment.comment)\n \n assert_not_nil(assigns(:post_comment))\n \n \n # Verify that a user from outside the PCB Group can not \n # access the category_details view\n set_user(@pat_a.id, 'Product Support')\n post(:category_details)\n \n assert_redirected_to(:controller => 'tracker', :action => 'index')\n assert_equal(\"You are not authorized to access this page\", flash['notice'])\n \n # Verify that a contractor Team Member can access the \n # category_details view\n set_user(@siva_e.id, 'Designer')\n post(:category_details, :id => @mx234a.id)\n \n assert_response(:success)\n assert_equal(@mx234a.id, assigns(:design).id)\n \n siva_assignments = assigns(:category_list)\n assert_equal(2, siva_assignments.size)\n assert_not_nil(siva_assignments[@board_prep])\n \n assignment_list = siva_assignments[@board_prep]\n assert_equal(1, assignment_list.size)\n assert_not_nil(assignment_list.detect { |a| \n a.oi_instruction.oi_category_section_id == board_prep_sections[0].id }) \n assignment_list.each { |a| assert_equal(@siva_e.id, a.user_id) }\n\n # Verify that a user from outside the PCB Group can not \n # access the assignment_details view\n set_user(@pat_a.id, 'Product Support')\n post(:assignment_details)\n \n assert_redirected_to(:controller => 'tracker', :action => 'index')\n assert_equal(\"You are not authorized to access this page\", flash['notice'])\n \n # Verify that a contractor Team Member can access the \n # category_details view\n set_user(@siva_e.id, 'Designer')\n post(:assignment_details,\n :id => @board_prep.id,\n :design_id => @mx234a.id)\n \n assert_response(:success)\n assert_equal(@mx234a.id, assigns(:design).id)\n assert_equal(@board_prep.id, assigns(:category).id)\n \n section_list = assigns(:section_list)\n assert_equal('Board Preparation', section_list[:category].name)\n assert_equal(1, section_list[:assignment_list].size)\n assert_equal(1, section_list[:assignment_list][0].oi_instruction.oi_category_section_id)\n\n\n # Verify that a user from outside the PCB Group can not \n # update an assignment.\n set_user(@pat_a.id, 'Product Support')\n post(:assignment_update)\n \n assert_redirected_to(:controller => 'tracker', :action => 'index')\n assert_equal(\"You are not authorized to access this page\", flash['notice'])\n\n # Verify that a member of the PCB Design group can \n # update an assignment\n set_user(@siva_e.id, 'Designer')\n \n # Get the instruction with 2 assignments associated with it\n instruction = OiInstruction.find_by_design_id_and_oi_category_section_id(\n @mx234a.id,\n board_prep_sections[0].id)\n\n siva_assignment = instruction.oi_assignments.detect { |a| a.user_id == @siva_e.id }\n mathi_assignment = instruction.oi_assignments.detect { |a| a.user_id == @mathi_n.id }\n\n assert_equal(2, instruction.oi_assignments.size)\n assert_equal(1, siva_assignment.oi_assignment_comments.size)\n assert_equal(0, siva_assignment.complete)\n assert_equal(@siva_e.id, siva_assignment.user_id)\n assert_equal(1, mathi_assignment.oi_assignment_comments.size)\n assert_equal(0, mathi_assignment.complete)\n assert_equal(@mathi_n.id, mathi_assignment.user_id)\n siva_assignment_comment = siva_assignment.oi_assignment_comments.pop\n mathi_assignment_comment = mathi_assignment.oi_assignment_comments.pop\n assert_not_equal(siva_assignment_comment.id, mathi_assignment_comment.id)\n\n\n post(:assignment_update,\n :assignment => siva_assignment,\n :post_comment => {:comment => 'My 2 cents'})\n \n siva_assignment.reload\n mathi_assignment.reload\n\n assert_equal(2, instruction.oi_assignments.size)\n assert_equal(2, siva_assignment.oi_assignment_comments.size)\n assert_equal(0, siva_assignment.complete)\n assert_equal(@siva_e.id, siva_assignment.user_id)\n assert_equal(1, mathi_assignment.oi_assignment_comments.size)\n assert_equal(0, mathi_assignment.complete)\n assert_equal(@mathi_n.id, mathi_assignment.user_id)\n\n cc_list = expected_cc_list.dup + [@siva_e.email] - [@scott_g.email]\n email = @emails.pop\n assert_equal([@scott_g.email], email.to.sort)\n assert_equal(cc_list.sort, email.cc.sort)\n assert_equal('Catalyst/AC/(pcb252_234_a0_g): Work Assignment Update',\n email.subject)\n\n\n post(:assignment_update,\n :assignment => { :id => siva_assignment.id,\n :complete => \"1\"},\n :post_comment => {:comment => 'It is done'})\n \n siva_assignment.reload\n mathi_assignment.reload\n\n assert_equal(2, instruction.oi_assignments.size)\n assert_equal(3, siva_assignment.oi_assignment_comments.size)\n assert_equal(1, siva_assignment.complete)\n assert_equal(@siva_e.id, siva_assignment.user_id)\n assert_equal(1, mathi_assignment.oi_assignment_comments.size)\n assert_equal(0, mathi_assignment.complete)\n assert_equal(@mathi_n.id, mathi_assignment.user_id)\n\n email = @emails.pop\n assert_equal([@scott_g.email], email.to.sort)\n assert_equal(cc_list.sort, email.cc.sort)\n assert_equal('Catalyst/AC/(pcb252_234_a0_g): Work Assignment Update - Completed',\n email.subject)\n \n set_user(@scott_g.id, 'Designer')\n post(:assignment_update,\n :assignment => { :id => siva_assignment.id,\n :complete => \"0\"},\n :post_comment => {:comment => 'My 2 cents'})\n \n siva_assignment.reload\n mathi_assignment.reload\n\n assert_equal(2, instruction.oi_assignments.size)\n assert_equal(4, siva_assignment.oi_assignment_comments.size)\n assert_equal(0, siva_assignment.complete)\n assert_equal(@siva_e.id, siva_assignment.user_id)\n assert_equal(1, mathi_assignment.oi_assignment_comments.size)\n assert_equal(0, mathi_assignment.complete)\n assert_equal(@mathi_n.id, mathi_assignment.user_id)\n\n cc_list = expected_cc_list.dup\n email = @emails.pop\n assert_equal([@siva_e.email], email.to.sort)\n assert_equal(cc_list.sort, email.cc.sort)\n assert_equal('Catalyst/AC/(pcb252_234_a0_g): Work Assignment Update - Reopened',\n email.subject)\n \n end",
"def create\n @type_of_assignment = TypeOfAssignment.new(type_of_assignment_params)\n\n respond_to do |format|\n if @type_of_assignment.save\n format.html { redirect_to @type_of_assignment, notice: 'El Tipo de Asignacion ha sido creado exitosamente.' }\n format.json { render :show, status: :created, location: @type_of_assignment }\n else\n flash[:danger] = \"No se ha podido Procesar la Operacion\"\n format.html { render :new }\n format.json { render json: @type_of_assignment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def assign_course_to_user\n user_id = params[:user_id]\n lesson_id = params[:lesson_id]\n user = User.find user_id\n lesson = Lesson.find lesson_id\n user.lessons.add\n end",
"def assignment_params\n params.require(:assignment).permit(:game_id, :employee_id, :role)\n end",
"def create\n @submission = Submission.new(:student_id => current_student.id, :assignment_id => params[:assignment_id])\n\n respond_to do |format|\n if @submission.save\n @assignment = @submission.assignment\n @assignment.questions.each do |question| \n answer = SubmittedAnswer.new(:submission_id => @submission.id, :question_id => question.id)\n answer.save\n end\n format.html { redirect_to edit_submission_path(@submission), notice: 'Submission was successfully created.' }\n format.json { render json: @submission, status: :created, location: @submission }\n else\n format.html { render action: \"new\" }\n format.json { render json: @submission.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if params[:assignment][:url] # The user uploaded a file\n if params[:assignment][:user_id] == '-1'\n redirect_to :back, flash: {error: \"Please select the team you are submitting for.\"}\n return\n end\n @user = User.find(params[:assignment][:user_id])\n @assignment = Assignment.find(params[:assignment][:assignment_id])\n @submission = Submission.new(params['assignment'])\n if @submission.url.class.name != 'String'\n puts 'Error, wonky url: ' + @submission.url.inspect + ' for ' + @user.email\n redirect_to :back, flash: {error: 'Submission Failed. Try Again. Be Patient.'}\n return\n else\n old_submissions = @assignment.submissions.\n select{|s| s.user.nil? or s.user.submitting_id(@submission) == params[:assignment][:user_id].to_i }\n end\n respond_to do |format|\n if @submission.save\n old_submissions.each{|s| s.destroy }\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { redirect_to :back, flash: {error: combine(@submission.errors.messages[:url])} }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n elsif current_user.instructor?(@course)\n @assignment = Assignment.find(params[:id])\n if params[:commit] == 'End All Activity'\n @assignment.submissions.each do |s|\n s.instructor_approved = true\n s.save!\n end\n end\n params['assignment']['submission_due_time'] = params['assignment']['submission_due_time(4i)'] + ':' + params['assignment']['submission_due_time(5i)']\n params['assignment'].delete 'submission_due_time(1i)'\n params['assignment'].delete 'submission_due_time(5i)'\n params['assignment'].delete 'submission_due_time(2i)'\n params['assignment'].delete 'submission_due_time(3i)'\n params['assignment'].delete 'submission_due_time(4i)'\n params['assignment'].delete 'submission_due_time(5i)'\n\n params['assignment']['review_due_time'] = params['assignment']['review_due_time(4i)'] + ':' + params['assignment']['review_due_time(5i)']\n params['assignment'].delete 'review_due_time(1i)'\n params['assignment'].delete 'review_due_time(5i)'\n params['assignment'].delete 'review_due_time(2i)'\n params['assignment'].delete 'review_due_time(3i)'\n params['assignment'].delete 'review_due_time(4i)'\n params['assignment'].delete 'review_due_time(5i)'\n\n @assignment = Assignment.find(params[:id])\n @reviewing_tasks = @assignment.evaluations.forUser(current_user).sort_by{|e| e.created_at}\n @URL = course_assignment_path(@course, @assignment)\n\n unless @assignment.team\n @assignment.memberships.each{|m| m.destroy }\n end\n\n if params['publish']\n params[:assignment][:draft] = @assignment.draft ? '0' : '1'\n end\n\n respond_to do |format|\n if @assignment.update_attributes(params[:assignment])\n format.html { render action: \"edit\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def assignment_params\n params.require(:assignment).permit(:assignment_id, :assignment_name, :details, :priority, :date_created, :date_due, :is_complete, :grade_received, :select_course)\n end",
"def assignment_params\n params.require(:assignment).permit(:no, :reference, :text, :status_id, :duedate, :user_id, :comment, :community_id, :assignment_status_id, :close_date)\n end",
"def assignment_employee_params\n params.require(:assignment_employee).permit(:assignmnet_id, :employee_id)\n end",
"def review\n @assignment = Assignment.find params[:assignment_id]\n redirect_to view_questionnaires_path id: @assignment.questionnaires.find_by(type: 'AuthorFeedbackQuestionnaire').id\n end",
"def new\n @assignments = Assignment.all\n @assignment = Assignment.new\n @assignment.build_submission_rule\n #@assignment.assignment_files.build\n unless request.post?\n render :new\n return\n end\n # Is the instructor forming groups?\n if params[:is_group_assignment] == 'true' && params[:assignment][:student_form_groups] == '0'\n params[:assignment][:invalid_override] = true\n else\n params[:assignment][:invalid_override] = false\n end\n\n @assignment = Assignment.new(params[:assignment])\n\n # A little hack to get around Rails' protection of the \"type\"\n # attribute\n @assignment.submission_rule.type = params[:assignment][:submission_rule_attributes][:type]\n\n\n @assignment.transaction do\n\n unless @assignment.save\n render :new\n return\n end\n if params[:assignment_files]\n params[:assignment_files].each do |assignment_file_name|\n unless assignment_file_name.empty?\n assignment_file = AssignmentFile.new(filename: assignment_file_name, assignment: @assignment)\n assignment_file.save\n end\n end\n end\n if params[:persist_groups_assignment]\n @assignment.clone_groupings_from(params[:persist_groups_assignment])\n end\n @assignment.save\n end\n redirect_to action: 'edit', id: @assignment.id\n end",
"def assignment_params\n params.require(:assignment).permit(:name, :start_date, :end_date, :rating, :type, :course_id, :questions => [])\n end",
"def assign_student\n\n # Authenticate user first\n authenticate_user\n if (@current_user == nil) || (@current_user.acctype != \"coordinator\")\n flash[:notice] = \"You have an Industry Partner Account, NOT a Coordinator account.\"\n redirect_to :unauthorized\n end\n\n # This needs a project to edit, otherwise redirect_to admin_dashboard\n if !params[:project_id].blank?\n @project = Project.find(params[:project_id])\n params[:state] = @project.status \n @spec = @project.spec\n @spec_link = '<http://localhost:3000/project_specification/'+@spec.auth_token+ '>'\n else\n redirect_to admin_dashboard_path\n end\n\n if (@project.assigned_students.count == 3) \n @student1 = @project.assigned_students[0];\n @student2 = @project.assigned_students[1];\n @student3 = @project.assigned_students[2];\n @group_name = @student3.group_name\n else\n @student1 = AssignedStudent.new\n @student2 = AssignedStudent.new\n @student3 = AssignedStudent.new \n end\n\n end",
"def make_assignments(assigned_questions)\n assigned_questions.each do |question|\n existing_assignment = Assignment.find_by_user_id_and_question_id(self.id,question.id)\n if existing_assignment == nil\n Assignment.create(:question_id => question.id , :user_id => self.id)\n end\n end\n end",
"def assignment_params\n params.require(:assignment).permit(:name, :basic_info, :course_id, :due)\n end",
"def assignment_params\n params.require(:assignment).permit(:name, :due_at, :activity_id, :category_id, :status, :is_completed, user_ids: [])\n end",
"def create_exam\n @exam = PlacementExam.new\n @company = Company.all\n @placement_exam = PlacementExam.new\n end",
"def type_of_assignment_params\n params.require(:type_of_assignment).permit(:name)\n end",
"def assignment_params\n params.require(:assignment).permit(:store_id, :employee_id, :pay_grade_id, :start_date)\n end",
"def create\n @assignment = Assignment.new(assignment_params)\n @labs = Lab.all\n\n respond_to do |format|\n if @assignment.save\n format.html { redirect_to @assignment, notice: 'Assignment was successfully created.' }\n format.json { render :show, status: :created, location: @assignment }\n else\n format.html { render :new }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def assign(guide, user)\n if user.is_a? User\n user = user.name\n end\n visit_edition guide\n\n select user, from: \"Assigned to\"\n click_on \"Save\"\n\n assert page.has_content?(\"successfully updated\")\n guide.reload\n end",
"def test_process_assignments\n \n board_prep_sections = [oi_category_sections(:board_prep_1),\n oi_category_sections(:board_prep_2),\n oi_category_sections(:board_prep_3)]\n section_ids = board_prep_sections.collect { |s| s.id }\n team_member_list = [@siva_e]\n \n section_selections = {}\n section_ids.each { |id| section_selections[id.to_s] = '0' }\n\n\n # Try accessing from an account that is not a PCB Designer and\n # verify that the user is redirected.\n post(:process_assignments,\n { :category => { :id => @board_prep.id },\n :design => { :id => @mx234a.id },\n :section => section_selections },\n pat_dfm_session)\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n assert_equal(\"You are not authorized to access this page\", flash['notice'])\n \n \n # Verify that a contractor PCB Designer can not access the list.\n post(:process_assignments,\n { :category => { :id => @board_prep.id },\n :design => { :id => @mx234a.id },\n :section => section_selections },\n siva_designer_session)\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n #assert_equal(\"You are not authorized to access this page\", flash['notice'])\n\n end",
"def create\n params[:assignment].delete(:employee)\n @assignment = Assignment.new(params[:assignment])\n @assignment.start_date = Chronic.parse(params[:assignment][:start_date])\n @assignment.end_date = Chronic.parse(params[:assignment][:end_date])\n\n respond_to do |format|\n if @assignment.save\n format.html { redirect_to @assignment, notice: 'Assignment was successfully created.' }\n format.json { render json: @assignment, status: :created, location: @assignment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # puts params\n questions = JSON.parse(params[:questions])\n q_hash = questions[\"questions\"]\n @assignment = Assignment.new\n @assignment.course_id = params[:course_id]\n @assignment.type = \"Homework\"\n @assignment.start_date = params[:start_date]\n @assignment.end_date = params[:end_date]\n @assignment.name = params[:name]\n # Following is the question hash\n q_hash.each do |key, value|\n a_hash = key[\"answers\"]\n question = key[\"question\"]\n puts question\n new_question = Question.new\n new_question.description = question\n new_question.type = \"MultipleChoice\"\n # Answer hash\n a_hash.each do |k,v|\n puts k[\"is_correct\"]\n puts k[\"description\"]\n new_answer = Answer.new\n new_answer.description = k[\"description\"]\n new_answer.is_correct = k[\"is_correct\"]\n new_question.association(:answers).add_to_target(new_answer)\n end\n @assignment.association(:questions).add_to_target(new_question)\n end\n \n if @assignment.save\n render :show, status: :created, location: @assignment\n else\n render json: @assignment.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user_assignment = UserAssignment.new(user_assignment_params)\n\n respond_to do |format|\n if @user_assignment.save\n format.html { redirect_to current_user, notice: 'Worker was successfully added' }\n format.json { render :show, status: :created, location: @user_assignment.assignment }\n\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def create\n @exam = current_user.exams.new(exam_params)\n respond_to do |format|\n if @exam.save\n format.html { redirect_to course_exams_url(@exam.course_id), notice: 'Exam was successfully created.' }\n format.json { render action: 'show', status: :created, location: @exam }\n else\n format.html { render action: 'new' }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end",
"def assignment_params\n params.require(:assignment).permit(:title, :description, :draft_deadline, :final_deadline, :comment_deadline, :description2, :is2group,\n positions_attributes: [:id, :title],\n comment_forms_attributes:[:id, :name, :group_number, :question1, :question2, :question3, :question4, :hint1, :hint2, :hint3, :hint4])\n end",
"def assign_this_note\n if !params[:assign].blank? && !params[:assign_comment].blank?\n @note.update_attributes(:assigned_to_user_id => params[:assigned_to_user_id], :updated_by_user_id => current_user.id)\n create_comment(@note,params[:comment])\n end\n end",
"def question_paper\n @company = Company.find(params[:id])\n @placement_exam = PlacementExam.find(params[:p_id])\n end",
"def create\n @assignment = Assignment.new(assignment_params)\n @users = User.all\n @resources = Resource.all\n\n respond_to do |format|\n if @assignment.save\n format.html { redirect_to @assignment, notice: 'Assignment was successfully created.' }\n format.json { render :show, status: :created, location: @assignment }\n else\n format.html { render :new }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @exceller_assignment = ExcellerAssignment.new(exceller_assignment_params)\n\n respond_to do |format|\n if @exceller_assignment.save\n format.html { redirect_to @exceller_assignment, notice: 'Exceller assignment was successfully created.' }\n format.json { render :show, status: :created, location: @exceller_assignment }\n else\n format.html { render :new }\n format.json { render json: @exceller_assignment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def assignment_params\n params.require(:assignment).permit(:inspector_id, :inspection_id, :scheduled_for)\n end",
"def create_assignment_mass(teacher_user) \n self.line_break\n puts \"To begin, type in your new assignment task below:\".colorize(:cyan)\n self.line_break\n task_input = gets.chomp\n t = Teacher.find_by(name: teacher_user)\n Student.all.each do |pupil|\n Assignment.create(task: task_input, student_id: pupil.id, teacher_id: t.id)\n end\n self.line_break\n puts \"Assignment Created!\".colorize(:light_magenta)\n self.teacher_main_menu(teacher_user)\n end",
"def make_assignments(assigned_users)\n assigned_users.each do |user|\n existing_assignment = Assignment.find_by_user_id_and_question_id(user.id,self.id)\n Assignment.create(:user_id => user.id , :question_id => self.id)if existing_assignment == nil\n end \n end",
"def assignment_due(type, time, round, review_allowed_id = 3)\n create(:assignment_due_date,\n deadline_type: DeadlineType.where(name: type).first,\n due_at: time,\n round: round,\n review_allowed_id: review_allowed_id)\n end",
"def create\n @assignment_form = AssignmentForm.new(assignment_form_params)\n if params[:button]\n # E2138 issue #3\n find_existing_assignment = Assignment.find_by(name: @assignment_form.assignment.name, course_id: @assignment_form.assignment.course_id)\n dir_path = assignment_form_params[:assignment][:directory_path]\n find_existing_directory = Assignment.find_by(directory_path: dir_path, course_id: @assignment_form.assignment.course_id)\n if !find_existing_assignment && !find_existing_directory && @assignment_form.save # No existing names/directories\n @assignment_form.create_assignment_node\n exist_assignment = Assignment.find(@assignment_form.assignment.id)\n assignment_form_params[:assignment][:id] = exist_assignment.id.to_s\n if assignment_form_params[:assignment][:directory_path].blank?\n assignment_form_params[:assignment][:directory_path] = \"assignment_#{assignment_form_params[:assignment][:id]}\"\n end\n ques_array = assignment_form_params[:assignment_questionnaire]\n due_array = assignment_form_params[:due_date]\n ques_array.each do |cur_questionnaire|\n cur_questionnaire[:assignment_id] = exist_assignment.id.to_s\n end\n due_array.each do |cur_due|\n cur_due[:parent_id] = exist_assignment.id.to_s\n end\n assignment_form_params[:assignment_questionnaire] = ques_array\n assignment_form_params[:due_date] = due_array\n @assignment_form.update(assignment_form_params, current_user)\n aid = Assignment.find(@assignment_form.assignment.id).id\n ExpertizaLogger.info \"Assignment created: #{@assignment_form.as_json}\"\n redirect_to edit_assignment_path aid\n undo_link(\"Assignment \\\"#{@assignment_form.assignment.name}\\\" has been created successfully. \")\n return\n else\n flash[:error] = 'Failed to create assignment.'\n if find_existing_assignment\n flash[:error] << '<br> ' + @assignment_form.assignment.name + ' already exists as an assignment name'\n end\n if find_existing_directory\n flash[:error] << '<br> ' + dir_path + ' already exists as a submission directory name'\n end\n redirect_to '/assignments/new?private=1'\n end\n else\n render 'new'\n undo_link(\"Assignment \\\"#{@assignment_form.assignment.name}\\\" has been created successfully. \")\n end\n end",
"def place_assignment_in_course\n @assignment = Assignment.find(params[:id])\n @courses = Assignment.assign_courses_to_assignment(current_user)\n end",
"def set_assign_detail\n @assign_detail = AssignDetail.find(params[:id])\n end",
"def exam_params\n params.require(:exam).permit(:note, :student_id, :evaluation_id)\n end",
"def setup_course_assignment(faculty_id,course_id)\n\t@course_assignments.each {|course_assignment|\n\t\tif course_assignment.course_id == course_id\n\t\t\tif course_assignment.room_id != nil\n building_id = course_assignment.room.building_id\n else\n building_id = \"\"\n end\n @assigned_building_ids[course_id] = building_id\n\t\t\treturn\n\t\tend\n\t}\n\tcourse_assign = CourseAssignment.new(semester_id: session[:semester_id],faculty_id: faculty_id, course_id: course_id)\n\t@course_assignments << course_assign\n\t@assigned_building_ids[course_id] = \"\"\n\treturn\n end",
"def create\n @exam_student = ExamStudent.new\n if params[:user_id]\n @exam_student.user_id = params[:user_id]\n end\n if params[:exam_id]\n @exam_student.exam_id = params[:exam_id]\n end\n if params[:status]\n @exam_student.status = params[:status]\n end\n\n respond_to do |format|\n if @exam_student.save\n format.html { redirect_to exams_url, notice: 'Prijavili ste ispit.' }\n format.json { render :show, status: :created, location: @exam_student }\n else\n format.html { render :new }\n format.json { render json: @exam_student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mass_assign_to(students, take_home = false)\n indie = self.teacher.indie\n return nil,nil if indie # no mass-assignment for indie teachers\n\n sk = Sektion.common_to(students.map(&:id)).last\n name = \"#{sk.name}_#{Date.today.strftime('%b %Y')}\"\n e = self.exams.create name: name, takehome: take_home\n\n for s in students \n w = self.assign_to(s.id, take_home)\n end \n\n # Close this exam for further modifications if school teacher\n e.update_attribute(:open, false) \n\n unless take_home \n Delayed::Job.enqueue WriteTex.new(e.id, e.class.name)\n job = Delayed::Job.enqueue CompileTex.new(e.id, e.class.name)\n e.update_attribute :job_id, job.id\n return e.id, job.id \n else \n return e.id, nil # no compilation required \n end\n end",
"def show\n @assignment = Assignment.find(params[:id])\n @course = @assignment.course\n @user = current_user\n if @user.instructor?(@course)\n if params[:fix]\n fix\n end\n if reviewer_id = params[:reviewer]\n @reviewer = User.find(reviewer_id)\n @reviewing_tasks = @assignment.evaluations.forUser(@reviewer)\n render 'assignments/show_instructor'\n return\n else\n redirect_to(edit_course_assignment_url(@course, @assignment))\n return\n end\n end\n\n # User is a student. Create 'To Do' List\n @to_do = @course.to_do(current_user)\n\n @reviewing_tasks = @assignment.evaluations.forUser(current_user).sort_by{|t| t.created_at}\n if Time.zone.now > @assignment.review_due # allow late reviewing until instructor ends\n @reviewing_tasks = @reviewing_tasks.select{|r| r.finished or !r.submission.instructor_approved }\n end\n @submissions = @assignment.get_submissions(current_user)\n @submission = @submissions.sort_by{|s| s.created_at }.last\n unless @submission\n @submission = Submission.new(assignment_id: @assignment.id)\n end\n @questions = @assignment.questions.sort_by{|q| q.created_at }\n @teams = @user.memberships.select{|m| m.assignment.course_id == @course.id and m.assignment_id == @assignment.id }.\n map{|m| User.find(m.pseudo_user_id)}\n\n @s3_direct_post = S3_BUCKET.presigned_post(\n key: vanilla(@course.name) + '/' + @user.id.to_s + '/' + vanilla(@assignment.name) + '.pdf',\n success_action_status: 201,\n acl: :public_read,\n content_type: 'application/pdf') # For uploads. It will be filed under the human (not team) user id.\n\n respond_to do |format|\n format.html\n format.json {render json: @assignment }\n end\n end",
"def exam_params\n params.require(:exam).permit(:name, :exam_type, :difficulty_level, :course_id, :full_mark, :no_of_questions)\n end",
"def create\n admin_only\n @subject = Subject.new(subject_params)\n\n new_tutor_ids = []\n unless params[:subject][:people_teaching_attributes].blank?\n params[:subject][:people_teaching_attributes].each do |attribute|\n id = attribute[1][:incoming_tutor_id]\n new_tutor_ids << id unless attribute[1][:_destroy] == \"1\"\n end\n end\n\n respond_to do |format|\n if @subject.save\n\n unless new_tutor_ids == []\n new_tutor_ids.each do |id|\n e = ProvidingEnrollment.new\n e.user_id = id\n e.subject_id = @subject.id\n e.save!\n end\n end\n\n format.html { redirect_to @subject, notice: 'Subject was successfully created.' }\n format.json { render :show, status: :created, location: @subject }\n else\n format.html { render :new }\n format.json { render json: @subject.errors, status: :unprocessable_entity }\n end\n end\n end",
"def attempt\n concept = @course.topicconcepts.concepts.where(id: params[:concept_id]).first\n\n #Redirect when concept sent through POST is wrong, concept option doesn't exist\n #or if entering through the concept is not allowed\n if concept.nil? or concept.concept_option.nil? or !concept.concept_option.can_enter?\n redirect_to course_topicconcepts_path(@course), alert: \" Invalid Concept Path!\"\n return \n end\n\n @submission = @assessment.submissions.submitted_format.where(std_course_id: curr_user_course).last\n #Create only when a submission is not found or if the last submission is submitted\n if @submission.nil? or @submission.submitted?\n @submission = @assessment.submissions.new\n @submission.std_course = curr_user_course\n @submission.save\n\n #Ensure guidance quiz setting - only one entry\n if @guidance_quiz.neighbour_entry_lock\n setup_concept_stages_from @submission, [concept] \n else\n setup_concept_stages_from @submission, @course.topicconcepts.concepts\n end\n end\n\n redirect_to diagnostic_exploration_course_topicconcept_path(@course, concept)\n end",
"def assignment_params\n params.require(:assignment).permit(:name, :is_done, :deadline, :group_id, user_assignments_attributes: [:user_id])\n end",
"def exam_params\n params[:exam]\n params.permit(:file, :posttype, :year, :user_id, :course_id, :examtype, :accepted, :acceptedby)\n end",
"def set_exam_subject\n @exam_subject = ExamSubject.find(params[:id])\n end",
"def new_quiz\n valid_request=true\n @assignment_id = params[:aid] #creating an instance variable to hold the assignment id\n @participant_id = params[:pid] #creating an instance variable to hold the participant id\n assignment = Assignment.find(@assignment_id)\n if !assignment.require_quiz? #flash error if this assignment does not require quiz\n flash[:error] = \"This assignment does not support quizzing feature.\"\n valid_request=false\n else\n team = AssignmentParticipant.find(@participant_id).team\n if team.nil? #flash error if this current participant does not have a team\n flash[:error] = \"You should create or join a team first.\"\n valid_request=false\n else\n if assignment.has_topics? && team.topic.nil?#flash error if this assignment has topic but current team does not have a topic\n flash[:error] = \"Your team should have a topic first.\"\n valid_request=false\n end\n end\n end\n\n if valid_request\n @questionnaire = Object.const_get(params[:model]).new\n @questionnaire.private = params[:private]\n @questionnaire.min_question_score = 0\n @questionnaire.max_question_score = 1\n render :new_quiz\n else\n redirect_to controller: 'submitted_content', action: 'view', id: params[:pid]\n end\n end",
"def assignment_params\n params.require(:assignment).permit(:name, :start_date, :end_date, :point, :course_instance_id, :status, :max_attempt)\n end",
"def add_teacher(teacher)\n CourseTeachingAssignment.create :user_id => teacher.id, :course_id => self.id\n end",
"def test_legal_edit_assignment\n @assignment = Assignment.first\n id = Assignment.first.id\n number_of_assignment = Assignment.count\n questionnaire_id = Questionnaire.first.id\n post :update, :id => id, :assignment=> { :name => 'updatedAssignment9',\n :review_questionnaire_id => questionnaire_id,\n :review_of_review_questionnaire_id => questionnaire_id,\n :author_feedback_questionnaire_id => questionnaire_id\n }\n\n assert_equal flash[:notice], 'Assignment was successfully updated.'\n\n assert_response :redirect\n assert_equal Assignment.count, number_of_assignment\n assert Assignment.find(:all, :conditions => \"name = 'updatedAssignment9'\")\n end",
"def call_assignment(node)\n if [\"save\", \"save!\"].include? node.message.to_s\n subject = node.subject.to_s\n add_error \"use model association (for #{subject})\" if @assignments[subject]\n end\n end",
"def set_assignment\n @assignment = @course.assignments.find(params[:assignment_id])\n end",
"def student_assignment_params\n params.require(:student_assignment).permit(:assignment_id, :student_id, :on_time, :grade, :github_url)\n end",
"def create\n authorize! :create, Assignment\n @assignment = Assignment.new(assignment_params)\n @assignment.task = @task\n # @assignment.creator = current_user\n # @task.work = @work\n\n respond_to do |format|\n if @assignment.save!\n format.html { redirect_to project_task_assignments_path(@project,@task), notice: 'Assignment was successfully created.' }\n format.json { render action: 'show', status: :created, location: project_task_assignments_url(@project,@task) }\n else\n set_users\n @url = project_task_assignments_path(@project,@task)\n format.html { render action: 'new' }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t#render plain: params[:assignment].inspect\n\t\t@assignment = Assignment.new(assignment_params)\n\n#Save assignment if requirements met, else refresh the page.\n\t\tif (@assignment.save)\n\t\t\tredirect_to @assignment\n\t\telse\n\t\t\trender 'new'\n\t\tend \n\tend",
"def assigner_params\n params.require(:assigner).permit(:task_id, :user_id)\n end",
"def create\n @assignment = Assignment.new(assignment_params)\n respond_to do |format|\n @assignment.user_mengajukan = current_user.id\n if @assignment.save\n @get = Assignment.last\n format.html { redirect_to detail_assignments_path(@get.id), notice: 'Assignment was successfully created.' }\n format.json { render :show, status: :created, location: @assignment }\n else\n format.html { render :new }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def assignment_params\n params.require(:assignment).permit(:name, :teacher_id, :date, grades_attributes:\n [:id, :assignment_id, :student_id, :score, :_destroy])\n end",
"def create_user_exam(user_id, course_id, exam_id)\r\n response = get_existing_exam(user_id, course_id,exam_id)\r\n if response.status_code == LearningStudioCore::BasicService::HTTPStatusCode::NOT_FOUND\r\n relative_url = Path::USERS_COURSES_EXAMS_WITH_ID % [user_id, course_id, exam_id]\r\n response = post(relative_url)\r\n end\r\n response\r\n end",
"def assign_params\n params.require(:assign).permit(:project_id, :document, :user_id, :round, :done, :curatable)\n end",
"def assignment_params\n params.require(:assignment).permit(:ref_id, :qty)\n end",
"def create\n respond_to do |format|\n if ExamSubject.create(exam_subject_params[:exam_subject])\n format.html { redirect_to exams_path, notice: 'Exam marks saved.' }\n else\n format.html { render :new }\n end\n end\n end",
"def retrieve_assignment(experiment, subject)\n subject_identifier = experiment.retrieve_subject_identifier(subject)\n if value = get(experiment.handle.to_s, \"assignment_#{subject_identifier}\")\n hash = JSON.parse(value)\n experiment.subject_assignment(\n subject,\n experiment.group(hash['group']),\n Time.xmlschema(hash['created_at'])\n )\n end\n end",
"def user_assignment_params\n params.require(:user_assignment).permit(:user_id, :assignable_id, :role, :accepted)\n end",
"def assignment_params\n params.require(:assignment).permit(:store_id, :employee_id, :start_date, :end_date, :pay_level)\n end",
"def techers_assignment_params\n params.require(:techers_assignment).permit(:teacher_id, :assignment_id)\n end",
"def assignment_params\n params.require(:assignment).permit(:teacher_id, :name, :duedate)\n end",
"def create\n @user_assignment = UserAssignment.new(user_assignment_params)\n\n respond_to do |format|\n if @user_assignment.save\n format.html { redirect_to @user_assignment, notice: 'User assignment was successfully created.' }\n format.json { render :show, status: :created, location: @user_assignment }\n else\n format.html { render :new }\n format.json { render json: @user_assignment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def employee_course_params\n params.require(:employee_course).permit(:employee_id, :course_id, :end, :status, :attempt_number, :cancel_url, :redirect_url)\n end",
"def create\n\t\t@activities = params[:guest][:activity_ids]\n assignment = Assignment.new(params[:guest_id], params[:activity_id])\n\n @activities.each do |a|\n if a != \"\"\n @assignment = Assignment.create(:guest_id => params[:assignments][:guest_id], :activity_id => a)\n # assigned_activity = Assignment.create(:guest_id => params[:guest_id], :activity_id => params[:activity_id])\n end\n end\n\n if @assignment.save\n flash[:notice] = \"Activity assigned.\"\n redirect_to guests_path\n else \n @message = \"Activity not assigned.\"\n end\n\n # redirect_to guests_path\n end",
"def preferredsubject_params\n params.require(:preferredsubject).permit(:user_id, :course_id)\n end",
"def exceller_assignment_params\n params.require(:exceller_assignment).permit(:exceller_id, :project_id, :skill_id, :start_date, :end_date, :status, :created_by, :modified_by, :deleted_at)\n end"
] | [
"0.63647693",
"0.62411124",
"0.61490613",
"0.61308014",
"0.6057582",
"0.60494936",
"0.6043505",
"0.6018424",
"0.59534115",
"0.5935091",
"0.5928154",
"0.5867691",
"0.5839717",
"0.5799333",
"0.5797168",
"0.5792861",
"0.5787273",
"0.5773743",
"0.57600313",
"0.574604",
"0.5721076",
"0.57120854",
"0.57083756",
"0.5703312",
"0.56955105",
"0.56914014",
"0.5687447",
"0.5682557",
"0.5671744",
"0.5670924",
"0.5656803",
"0.565596",
"0.56457776",
"0.56357086",
"0.56337726",
"0.5633075",
"0.5627346",
"0.5620674",
"0.5604074",
"0.56014985",
"0.5601154",
"0.5592669",
"0.5592058",
"0.55896235",
"0.5585236",
"0.55762076",
"0.55742055",
"0.5573775",
"0.5566052",
"0.5565809",
"0.5565234",
"0.556424",
"0.55611944",
"0.55583245",
"0.5550122",
"0.55494595",
"0.5547906",
"0.5547853",
"0.5542701",
"0.5541987",
"0.5533181",
"0.55180436",
"0.5516213",
"0.5509711",
"0.5508017",
"0.5506771",
"0.55037534",
"0.54975134",
"0.54888725",
"0.5486046",
"0.54782045",
"0.5469001",
"0.5464198",
"0.54610765",
"0.54589134",
"0.545806",
"0.54571205",
"0.54431486",
"0.54384017",
"0.54376507",
"0.54212755",
"0.54162604",
"0.5412127",
"0.54115105",
"0.54106104",
"0.540931",
"0.5407812",
"0.5403122",
"0.5394877",
"0.5393889",
"0.53834593",
"0.53828317",
"0.5381372",
"0.53798276",
"0.53787905",
"0.5378006",
"0.53776324",
"0.5370888",
"0.53619415",
"0.5347998",
"0.53459567"
] | 0.0 | -1 |
used in the views so need to sanitize | def sanitize_assignment_type t
t if valid_assignment_types.include? t
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize!; end",
"def validate_and_sanitize\n super\n end",
"def sanitize_content\n self.title = helpers.sanitize(self.title)\n self.user_name = helpers.sanitize(self.user_name)\n end",
"def filter_content \n\t\tself.title = ActionView::Base.full_sanitizer.sanitize(self.title)\n\t\tself.slug = ActionView::Base.full_sanitizer.sanitize(self.slug)\n\t\tself.meta_title = ActionView::Base.full_sanitizer.sanitize(self.meta_title)\n\t\tself.meta_keyword = ActionView::Base.full_sanitizer.sanitize(self.meta_keyword)\n\t\tself.meta_description = ActionView::Base.full_sanitizer.sanitize(self.meta_description)\n\t\tself.page_class = ActionView::Base.full_sanitizer.sanitize(self.page_class)\n\tend",
"def sanitize_data\n sanitize_permalink\n sanitize_name\n end",
"def clean_description\n ActionView::Base.full_sanitizer.sanitize(description)\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(options={})\n ActionController::Base.helpers.sanitize(self, options)\n end",
"def validate_and_sanitize\n validate\n end",
"def sanitize(words)\n#lowercases the string\n lower_case = lowerCase(words)\n#removes all the special elements\nclean_string = clean(lower_case)\nend",
"def sanitize_data(data)\n data\n end",
"def sanitize_data(value)\n HtmlSanitizer.sanitize(value)\n end",
"def sanitize(action); end",
"def clean()\n #strip all illegal content here. (scripts, shit that will break layout, etc.)\n 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\n # ui_enabled only for the belongs_to, has_many and many_to_many types\n self.ui_enabled = nil unless self.is_relationship?\n\n # text_formatting only for the text type\n self.text_formatting = nil unless self.type == :text\n end",
"def sanitize_as_html!\n Engine.clean!(self)\n end",
"def sanitize_as_html!\n Engine.clean!(self)\n end",
"def sanitize(context,input)\n whitelist(input,Owasp::Esapi::Ecnoder::CHAR_ALPHANUMERIC)\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_user\r\n self.first_name = Sanitize.clean(self.first_name).gsub('&','&').gsub('>', '>') unless self.first_name.blank?\r\n end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def sanitize_details\n self.details = ActionController::Base.helpers.sanitize(details, { :tags => ALLOWED_HTML_TAGS_IN_DETAILS } )\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 sanitize!\n return self if @sanitized\n replace(HTMLEntities.new.encode(self))\n @sanitized = true\n return self\n end",
"def sanitize!\n\t\t\t@doc.downcase!\n\t\t\t@doc.gsub!(/<style.*?\\/style>/m, '')\n\t\t\t@doc.gsub!(/<script.*?\\/script>/m, '')\n\t\t\t@doc.gsub!(/<.*?>/m, ' ')\n\t\t\t@doc.gsub!(/\\s+/, ' ')\n\t\tend",
"def link_sanitizer; end",
"def link_sanitizer; end",
"def link_sanitizer; end",
"def before_save(record)\n record.content = sanitize(record.content)\n end",
"def validate_and_sanitize\n r = super\n return r unless r.success?\n\n success\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 full_sanitizer=(_arg0); end",
"def full_sanitizer=(_arg0); end",
"def full_sanitizer=(_arg0); end",
"def sanitize_html\n self.data = self.class.clean_html(self.data) unless self.data.nil?\n end",
"def sanitize_input\n\t\t# to remove whitespace, use \n\t\t# self.<fieldname>.strip!\n\t\tself.homephone = self.homephone.gsub(/\\D/,'') if !self.homephone.blank?\n\t\tself.workphone = self.workphone.gsub(/\\D/,'') if !self.workphone.blank?\n\t\tself.cellphone = self.cellphone.gsub(/\\D/,'') if !self.cellphone.blank?\n\t\tself.fax = self.fax.gsub(/\\D/,'') if !self.fax.blank?\n\t\tself.prefcontactmethod = :Email if self.prefcontactmethod.blank?\n #\t\tself.email = self.email.downcase if self.email.present?\n\tend",
"def exclude_from_xss_checks; %w{ body html } end",
"def sanitize(name)\n #name.gsub(\".\", \"_\").gsub(/<.+>/, \"\")\n name.gsub(\".\", \"_\").gsub(\"$\", \"_\")\nend",
"def clean_data( field )\n\tfield.to_s.strip\nend",
"def sanitize_params\n # @where[/\\w*=\\'(.*)\\'/].gsub(/\\'/, \"''\")\n # @where.sub!(/\\w*=\\'(.*)\\'/, { |s| puts s })\n end",
"def safe; end",
"def sanitize(object) #:nodoc:\n quote_value(object)\n end",
"def sanitize_entries\n unless event_name.blank?\n self.event_name = I18n.transliterate(event_name.to_s.downcase.strip).to_s.downcase.strip\n end\n unless team_first.blank?\n self.team_first = I18n.transliterate(team_first.to_s.downcase.strip).to_s.downcase.strip.gsub(' ', '')\n end\n unless team_second.blank?\n self.team_second = I18n.transliterate(team_second.to_s.downcase.strip).to_s.downcase.strip.gsub(' ', '')\n end\n end",
"def sanitized\n @original && @original.gsub(/[^0-9]+/, '') || ''\n end",
"def sanitize_data\n self.permalink = name if permalink.blank? && name\n self.permalink = permalink.squeeze(\" \").strip.gsub(' ', '-') if permalink\n if meta_keywords.blank? && description\n self.meta_keywords = [name[0..55],\n description.\n gsub(/\\d/, \"\"). # remove non-alpha numeric\n squeeze(\" \"). # remove extra whitespace\n gsub(/<\\/?[^>]*>/, \"\"). # remove hyper text\n split(' '). # split into an array\n map{|w| w.length > 2 ? w : ''}. # remove words less than 2 characters\n join(' ').strip[0..198] # join and limit to 198 characters\n ].join(': ')\n end\n self.meta_description = [name[0..55], description.gsub(/<\\/?[^>]*>/, \"\").squeeze(\" \").strip[0..198]].join(': ') if name.present? && description.present? && meta_description.blank?\n end",
"def sanitize_data\n sanitize_permalink\n assign_meta_keywords if meta_keywords.blank? && description\n sanitize_meta_description\n end",
"def sanitize(value)\n ActiveRecord::Base.sanitize_sql(value)\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 sanitize(review)\n xss_filter(review)\n end",
"def clean\n self.short_msg = sanitize(short_msg)\n self.long_msg = sanitize(long_msg)\n end",
"def sanitize\n scrub_payload_emails\n scrub_actor_attributes\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_attributes\n %w(author title description keyword).each do |field|\n self.send(\"#{field}=\",HTMLEntities.new.decode(self.send(field)))\n end\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 devise_parameter_sanitizer; end",
"def sanitize(str)\n return \"\" if !str\n return Sanitize.clean(str)\n end",
"def unfiltered_content; end",
"def unfiltered_content; end",
"def unfiltered_content; end",
"def sanitized?\n @sanitized || false\n end",
"def safe_str\n \"\".html_safe # rubocop:disable Rails/OutputSafety # It's an empty string!\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_data str\n str.to_s.strip.gsub(%r{^(-\\s)+}, \"\")\n end",
"def sanitize\n self.original_url.strip!\n self.sanitize_url = self.original_url.downcase.gsub(/(https?:\\/\\/)|(www\\.)/, \"\")\n self.sanitize_url = \"http://#{self.sanitize_url}\"\n end",
"def html_safe_value\n sanitize(@values.join(' '), tags: %w[sub sup i em])\n end",
"def sanitize(str)\n DescriptionSanitizer.new.sanitize(str)\n end",
"def sanitize_from_db(text, allowed_tags = NB.allowed_html_tags)\n text = sanitize_from_evernote(text)\n text = text.gsub(/#{ NB.truncate_after_regexp }.*\\Z/m, '')\n .gsub(/<br[^>]*?>/, \"\\n\")\n .gsub(/<b>|<h\\d>/, '<strong>')\n .gsub(%r{</b>|</h\\d>}, '</strong>')\n # OPTIMIZE: Here we need to allow a few more tags than we do on output\n # e.g. image tags for inline image.\n text = sanitize_by_settings(text, allowed_tags)\n text = format_blockquotes(text)\n text = format_code(text)\n text = remove_instructions(text)\n end",
"def sanitize_url(str); end",
"def sanitize(args = '')\n args\n end",
"def processed_content\n self.to_s.downcase.gsub(/[^a-z0-9]/, \"\")\n end",
"def sanitize_result(result)\n result = result.downcase\n\n # many times, featured results, or additional producers are appended\n # to the result like so: (featuring beep and boop...)\n result = result.gsub(/[\\(\\)\\[\\]]/, \"\")\n\n # remove all [.'!&+] and replace them with \"\"\n result = result.gsub(/[.'!&+]/, \"\")\n\n # remove all - or _ and replace them with \" \"\n result = result.gsub(/[-_]/, \" \")\n\n # remove all blacklisted articles\n result = result.gsub(/\\b(#{BLACKLIST})\\b/, \"\")\n\n # replace multiple spaces with a single space\n result = result.gsub(/\\s+/, \" \").strip\n end",
"def sanitize_for_id(unsanitized_string)\n unsanitized_string.gsub(\" \", \"_\").downcase\n end",
"def clean_html\n HTML::WhiteListSanitizer.allowed_protocols << 'data'\n self.content = ActionController::Base.helpers.sanitize(self.body, :tags => ALLOWED_TAGS, :attributes => ALLOWED_ATTRIBUTES)\n end",
"def sanitize(text)\n text.gsub('<', '<').gsub('>', '>')\n end",
"def sanitize_path(path); end",
"def sanitize()\n equiptment = [\"RNA-P1000\",\"RNA-P200\",\"RNA-P20\", \"Tube Block\", \"Bench Top\", \"Other\"]\n show do\n title \"Isolating RNA Effectively\"\n separator\n warning \"<b>Working with RNA can be tricky, since it is very sensitive to RNases.</b>\"\n note \"To prevent the degradation of our RNA and our hard work we must take care to use our best aseptic technique.\"\n note \"\"\n note \"\"\n check \"Wipe down area and equiptment you will be using with <b>70% EtOH</b> & <b>RNase ZAP</B>\"\n equiptment.each {|e| bullet \"<b>#{e}</b>\"}\n separator\n warning \"<b>Keep RNase ZAP on hand use whenever necessary.</b>\"\n end\n end",
"def safe *things\n\t\t\tappend! CGI.escapeHTML(things.map(&:to_s).join(\"\\n\"))\n\t\tend",
"def fix_raw!\n raw['created_at'] = ModelCommon.flatten_date(raw['created_at'])\n raw['id'] = ModelCommon.zeropad_id(raw['id'])\n raw['protected'] = ModelCommon.unbooleanize(raw['protected'])\n Wukong.encode_components raw, 'name', 'location', 'description', 'url'\n # There are several users with bogus screen names\n # These we need to **URL encode** -- not XML-encode.\n if raw['screen_name'] !~ /\\A\\w+\\z/\n raw['screen_name'] = Wukong.encode_str(raw['screen_name'], :url)\n end\n end",
"def to_s\n sanitized.to_s\n end",
"def model_attributes(params)\n clean_params = super #hydra-editor/app/forms/hydra_editor/form.rb:54\n # model expects these as multi-value; cast them back\n clean_params[:rights] = Array(params[:rights]) if params[:rights]\n clean_params[:title] = Array(params[:title]) if params[:title]\n if params[:description]\n clean_params[:description] = Array(params[:description])\n clean_params[:description].map! do |description|\n ::DescriptionSanitizer.new.sanitize(description)\n end\n end\n # Model expects provenance as single-value.\n if params[:provenance]\n clean_params[:provenance] = ::DescriptionSanitizer.\n new.sanitize(params[:provenance])\n end\n\n # Oops; we're blanking out these values when changing permissions and probably versions, too\n # -- they don't have these fields in the form at all so they don't get repopulated.\n clean_params = encode_physical_container(params, clean_params)\n clean_params = encode_external_id(params, clean_params)\n\n clean_params.keys.each do |key|\n # strip ALL the things!\n if clean_params[key].is_a?(Array)\n clean_params[key].map!(&:strip)\n elsif clean_params[key].is_a?(String)\n clean_params[key] = clean_params[key].strip\n end\n end\n\n clean_params\n end",
"def sanitize(text)\n text.squeeze\n text.capitalize!\n text.gsub!('&', '&')\n text.gsub!('<', '<')\n text.gsub!('>', '>')\n return text\nend",
"def sanitize(value)\n case value\n when Regexp then value.source\n else Regexp.escape value\n end\n end",
"def sanitization\n if @sanitization.nil?\n @sanitization = Sanitization.new\n end\n @sanitization\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 sanitize_tag(in_tag)\n in_tag.gsub(/[^\\w%=\\-\\\\+]+/,\"\")\n end",
"def skip_html_injection=(_arg0); end",
"def sanitize content #:nodoc:\n if content.is_a? String\n content.chomp!\n content.gsub!(/\\t/, ' ') # don't display tab\n content.gsub!(/[^[:print:]]/, '') # don't display non print characters\n else\n content\n end\n end",
"def sanitize content #:nodoc:\n if content.is_a? String\n content.chomp!\n content.gsub!(/\\t/, ' ') # don't display tab\n content.gsub!(/[^[:print:]]/, '') # don't display non print characters\n else\n content\n end\n end",
"def sanitized_params\n document = resource_params[:document]\n\n if document.present?\n document = document.gsub(/\\D/,'')\n old_params = resource_params\n resource_params = ActionController::Parameters.new(document: document, email: old_params[:email])\n #resource.document = document if resource\n end\n end",
"def sanitize_attributes\n self.name = \"#{self.name}\".strip\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 sanitize_similar_to_value(value)\n value.gsub(/[\\\\_%|*+?{}()\\[\\]]/) { |x| \"\\\\#{x}\" }\n end",
"def sanitize\n \tself.original_url.strip!\n \tself.sanitize_url = self.original_url.downcase.gsub(/(https?:\\/\\/)|(www\\.)/, \"\")\n \tself.sanitize_url = \"http://#{self.sanitize_url}\"\n\n \n start = 8\n final = self.sanitize_url.length\n\n while start <= final do\n sanitize_url[start] == ' ' ? sanitize_url[start] = '-' : sanitize_url[start] = sanitize_url[start] #change spaces for '-'\n break if sanitize_url[start] == '/' #break if '/' is found\n start +=1\n end\n\n self.sanitize_url = sanitize_url[0..start] #cut the string for creating the shortened_url\n self.short_url = sanitize_url + short_url #save the final shortened_url on the short_url's field\n end",
"def sanitize_exception(e)\n e\n end",
"def sanitize_attributes\n if self.sanitize_level\n self.about = Sanitize.clean(self.about, self.sanitize_level) unless self.about.blank?\n self.location = Sanitize.clean(self.location, self.sanitize_level) unless self.location.blank?\n end\n end",
"def scrubbed\n end",
"def body_column(record)\n sanitize(record.body)\n end"
] | [
"0.7518306",
"0.7235429",
"0.7052768",
"0.69793564",
"0.6878666",
"0.6756486",
"0.6658044",
"0.6658044",
"0.6622884",
"0.6558522",
"0.64755964",
"0.6451672",
"0.64195645",
"0.6410674",
"0.6391797",
"0.6379697",
"0.6378053",
"0.6340761",
"0.6340761",
"0.6261128",
"0.6248769",
"0.62168217",
"0.61729467",
"0.61729467",
"0.61729467",
"0.61699593",
"0.61523855",
"0.6140428",
"0.61350656",
"0.61190754",
"0.61190754",
"0.61190754",
"0.6119033",
"0.6108454",
"0.60939103",
"0.60892844",
"0.60892844",
"0.60892844",
"0.6082044",
"0.6033201",
"0.60276616",
"0.6019274",
"0.59972733",
"0.5986093",
"0.5974745",
"0.59474754",
"0.5934054",
"0.5913454",
"0.5910405",
"0.5897209",
"0.58846295",
"0.58832335",
"0.58678305",
"0.5855496",
"0.5844678",
"0.58425295",
"0.5830294",
"0.58291155",
"0.58250034",
"0.58233166",
"0.58195084",
"0.58195084",
"0.58195084",
"0.5797879",
"0.5796108",
"0.5790377",
"0.5787865",
"0.57843876",
"0.57809293",
"0.57777566",
"0.57741517",
"0.5773952",
"0.5772088",
"0.5762728",
"0.5753853",
"0.5746989",
"0.57442635",
"0.5742277",
"0.5734533",
"0.5720333",
"0.57200676",
"0.571948",
"0.5714672",
"0.57069373",
"0.5692265",
"0.5691921",
"0.56881624",
"0.56817013",
"0.5680101",
"0.5673141",
"0.5668287",
"0.5668287",
"0.56574947",
"0.56459516",
"0.56431013",
"0.5638961",
"0.56327486",
"0.5624878",
"0.5622028",
"0.56215566",
"0.5620809"
] | 0.0 | -1 |
This method probably exists for the wrong reason. E.g. handle params coming in in the URL or in the body of the POST request in a flexible fashion. | def int_param key, fallback_key
Integer params[key]
rescue ArgumentError, TypeError
field = "#{fallback_key}_id"
begin
Integer params[:education_assignment][field]
rescue NoMethodError
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def POST\r\n@env[\"action_dispatch.request.request_parameters\"] ||= (normalize_encode_params(super) || {})\r\nrescue TypeError => e\r\nraise ActionController::BadRequest.new(:request, e)\r\nend",
"def valid_params_request?; end",
"def params\n self.GET.update(self.POST)\n rescue EOFError => boom\n self.GET\n end",
"def GET\r\n@env[\"action_dispatch.request.query_parameters\"] ||= (normalize_encode_params(super) || {})\r\nrescue TypeError => e\r\nraise ActionController::BadRequest.new(:query, e)\r\nend",
"def post_data; end",
"def request_params; end",
"def process_url_params(url, headers); end",
"def post_data=(_arg0); end",
"def handle_request( request, &block )\n\t\tself.log.debug \"[:parameters] Wrapping request with parameter validation.\"\n\n\t\tvalidator = self.class.paramvalidator.dup\n\t\tvalidator.validate( request.params )\n\t\trequest.params = validator\n\n\t\tsuper\n\tend",
"def handle_query_param\n if params[:query].is_a? ActionController::Parameters \n params[:query].permit!\n params[:query].to_h\n else\n params[:query]\n end\n end",
"def parse_request!\n REGEX_REQUEST.match(@request[FREQUEST])\n @method = $1 ? $1.downcase.to_sym : :unknown\n @path = $2 || BLANK_STR\n @params_str = $3 || BLANK_STR\n end",
"def process_action(*args)\n super\n rescue ActionDispatch::Http::Parameters::ParseError => exception\n json_response(nil ,400, :bad_request)\n end",
"def post_request(object)\n end",
"def fix_url_object(obj, data = nil)\n if data\n obj.content_type = PLAIN\n obj.data = data\n obj.store\n return obj\n end\n case obj.content_type\n when /json/ then fix_url_object(obj, JSON.parse(%({\"data\":#{obj.raw_data}}))['data'])\n when PLAIN then obj\n else fix_url_object(obj, obj.data) # old values had the right data but the content type was application/x-www-form-urlencoded\n end\n end",
"def parse_post_for_pseudo_ie_cors\n if(request.post? && request.POST.blank? && request.raw_post.present?)\n params.merge!(Rack::Utils.parse_nested_query(request.raw_post))\n end\n end",
"def request_parameters; end",
"def process_put_and_post_requests(request, data)\n content_type = request['Content-Type'] ||= 'application/x-www-form-urlencoded'\n case content_type\n when 'application/x-www-form-urlencoded'; request.form_data = data\n when 'application/json'; request.body = (data.is_a?(Hash) or data.is_a?(Array)) ? JSON.generate(data) : data\n else\n #data = data.to_s unless request.body.is_a?(String)\n request.body = data\n end\n process_request(request)\n end",
"def raw_post; end",
"def compose_urlencoded_params(new_param_hash)\n self['REQUEST_METHOD'] = 'POST'\n self['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'\n @body = StringIO.new(qs_build(new_param_hash))\n end",
"def query_parameters; end",
"def valid_params_request?\n true\n end",
"def valid_params_request?\n true\n end",
"def POST; end",
"def process_request(request, body, socket)\n raise \"You must implement process_request\"\n end",
"def validate_params\n data = endpoint_params\n errors = []\n errors << 'Invalid verb' if %w[GET POST PATCH DELETE].exclude?(data[:verb])\n # check for valid url\n begin\n URI.parse data[:path]\n rescue URI::InvalidURIError => e\n errors << 'Invalid Path'\n end\n render json: { errors: errors }, status: :unprocessable_entity if errors.present?\n end",
"def valid_params?; end",
"def http_parse_args\n [(self.api.base_url + self.method), self.params]\n end",
"def post_params\n ActiveModelSerializers::Deserialization.jsonapi_parse!(params, only: [:content] )\n end",
"def _bad_parse(post)\n @params ||= Hash.new\n @raw = post.to_s\n #puts (\"-----parsing starts----\") * 8\n for line in @raw.split('&')\n key, value = *line.scan( %r{^([A-Za-z0-9_.-]+)\\=(.*)$} ).flatten\n if key.present?\n if self.class.const_defined?(:FIELDS_NOT_TO_BE_UNESCAPED_WHEN_PARSING) \\\n && self.class::FIELDS_NOT_TO_BE_UNESCAPED_WHEN_PARSING.include?(key)\n params[key] = value.to_s\n else\n params[key] = CGI.unescape(value.to_s)\n end\n end\n end\n #puts (\"-----parsing ends----\") * 8\n @params\n end",
"def post(action, params = T.unsafe(nil), header = T.unsafe(nil), query = T.unsafe(nil)); end",
"def post_params=(new_param_hash_or_str)\n # First see if this is a body payload\n if !new_param_hash_or_str.kind_of?(Hash)\n compose_verbatim_payload(new_param_hash_or_str)\n # then check if anything in the new param hash resembles an uplaod\n elsif extract_values(new_param_hash_or_str).any?{|value| value.respond_to?(:original_filename) }\n compose_multipart_params(new_param_hash_or_str)\n else\n compose_urlencoded_params(new_param_hash_or_str)\n end\n end",
"def handle_params(params)\n params.nil? || params.empty? ? '' : \"?#{to_query_string(params)}\"\n end",
"def parse_request\n p request.body.string\n case request.content_type\n when JSON_TYPE then parse_json_request\n else parse_http_request\n end\n end",
"def post; end",
"def post_params\n postParams = params\n end",
"def handle(_request)\n fail NotImplementedError\n end",
"def set_request_body!(request); end",
"def process_http_request\n # the http request details are available via the following instance variables:\n # @http_protocol\n # @http_request_method\n # @http_cookie\n # @http_if_none_match\n # @http_content_type\n # @http_path_info\n # @http_request_uri\n # @http_query_string\n # @http_post_content\n # @http_headers\n handle(@http_request_method, @http_post_content)\n\n send_ok()\n end",
"def params() request.params end",
"def parse(request)\n raise NotImplementedError\n end",
"def adjust_params \n #if request is like this:\n # GET /relations\n # GET /entities/relations\n # GET /databases/entities/relations\n if params[:action] == 'index'\n \n # If it is \n # GET /relations\n # Then we cannot sevice this request, must specify the entity.\n# if !params[:database_id] and !params[:entity_id]\n# render :text => 'GET /relations is not available', :status => 400\n# return false;\n# end\n\n # But in the remaining two cases:\n # * /entities/relations\n # * /databases/entities/relations\n # Allow the class\n return true;\n end\n \n # if it is:\n # GET /relations\n # GET /entities/relations\n # GET /databases/entities/relations/\n # Becasue show needs to have an ID, therefore\n # any of the above URL will do and no context is needed.\n #FIXME: What other possibility the show action might face?\n if params[:action] == 'show'\n return true;\n end\n \n #If its like this:\n # POST /relations\n # POST /entities/relations\n # POST /databases/entities/relations\n # NOTE: For now, the relation resource should be totally complete\n # even if the call is being as a nested resource.\n #\n if params[:action] == 'create'\n \n #if it is like this:\n # POST /relations\n # Then the relations resource should be complete in\n # every respect.\n if !params[:database_id] and !params[:entity_id]\n #return true if valid_relation_resource?\n # Otherwise, the resource is not vaild and we need to tell the user\n #render :json => report_errors(nil, 'The provided realtion resource is incomplete')[0], \n # :status => 400 and return false;\n end\n \n # But if its something like this:\n # POST /entities/:entity_id/relations\n # POST /databases/entities/:entity_id/relations\n #\n if params[:database_id] or params[:entity_id]\n # Then if the relation resource is valid, \n # the entity_id parameter is altogather ignored.\n #return true if valid_relation_resource? \n end\n return true\n end\n \n # if its either of these:\n # PUT /relations\n # PUT /entities/relations\n # PUT /databases/entities/relations\n #\n if params[:action] == 'update'\n # Set the params[:relation_id] because\n # the underlying Admin::EntitiesController#add_link function\n # expects it\n params[:relation_id] = params[:id] and return true;\n end\n \n # If it is either of these:\n # DELETE /relations\n # DELETE /entities/relations\n # DELETE /databases/entities/relations\n #\n if params[:action] == 'destroy'\n \n # For now, you can only make a nested call.\n #PENDING: This would change when the rest call would include the user\n # authenticiy information which would help to determine whether the \n # relation being deleted belongs to the user or not.\n if !params[:entity_id]\n render :json => report_errors(nil, 'DELETE /relations call is not available for now. Call DELETE /entities/relations instead')[0],\n :status => 400 and return false\n end\n \n params[:source_id] = params[:entity_id]\n return true;\n \n end\n \n # In all cases, the request is not handled by this controller!\n render :json => report_errors(nil, \"The requested action is \\\"#{params[:action]}\\\" \" + \n \" on controller \\\"#{params[:controller]}\\\" while I am\" + \n \" \\\"#{self.class.name}\\\" and cannot handle your request.\")[0],:status => 400 and return false;\n \n end",
"def request=(_arg0); end",
"def request=(_arg0); end",
"def request=(_arg0); end",
"def api_gateway_post(path, params)\n api_gateway_body_fwd = params.to_json\n rack_input = StringIO.new(api_gateway_body_fwd)\n\n post path, real_params = {}, {\"rack.input\" => rack_input}\nend",
"def query_params; end",
"def request(action, params = T.unsafe(nil), header = T.unsafe(nil), query = T.unsafe(nil)); end",
"def check_params; true; end",
"def unsolved_params\n \n end",
"def request(*args); end",
"def query_parameters\n end",
"def parsed_params\n \n end",
"def api_gateway_post(path, params)\n api_gateway_body_fwd = params.to_json\n rack_input = StringIO.new(api_gateway_body_fwd)\n\n post path, real_params = {}, 'rack.input' => rack_input\nend",
"def handle_request(socket, request_type, request_args)\n raise 'not implemented'\n end",
"def _params\n return params if params.present?\n\n @_params ||= JSON.parse(request.body.read)\n end",
"def parse(post)\n @raw = post\n self.params = Rack::Utils.parse_query(post)\n # Rack allows duplicate keys in queries, we need to use only the last value here\n self.params.each{|k,v| self.params[k] = v.last if v.is_a?(Array)}\n end",
"def parse_request(env, path_params)\n if env[CREQUEST_METHOD] == CPOST\n validate_request!(env, path_params)\n parse_message_hash(env, path_params)\n else\n [ nil, env, path_params ]\n end\n end",
"def post(request, response)\n NotImplemented\n end",
"def post(request, response)\n NotImplemented\n end",
"def parse_url_params \n return if !Caboose.use_url_params \n url = \"#{request.fullpath}\"\n url[0] = \"\" if url.starts_with?('/') \n url = url.split('?')[0] if url.include?('?') \n arr = url.split('/') \n i = arr.count - 1\n while i >= 1 do\n k = arr[i-1]\n v = arr[i] \n if v && v.length > 0\n v = v.gsub('%20', ' ')\n params[k] = v\n end\n i = i-2\n end \n end",
"def parse_ie_json\n if request.content_type.nil? && request.method == \"POST\"\n request_json = ActiveSupport::JSON.decode(request.body)\n wrap_model_params_for_ie(request_json)\n end\n end",
"def update_params\n super.tap do |params|\n params[:request_format] = :json\n params[:expected_response] = Net::HTTPOK\n end\n end",
"def raw_post_request raw_params\n json_body = raw_params.to_json\n Rubix.logger.log(Logger::DEBUG, \"SEND: #{json_body}\") if Rubix.logger\n Net::HTTP::Post.new(uri.path).tap do |req|\n req['Content-Type'] = 'application/json-rpc'\n req.body = json_body\n end\n end",
"def verify_request_components options = {}\n if options[:request]\n if options[:request].is_a?(Faraday::Request) || options[:request].is_a?(Array)\n request = options[:request]\n elsif options[:adapter]\n request = options[:adapter].adapt_request options[:request]\n end\n method = request.method\n uri = request.path\n headers = request.headers\n body = request.body\n else\n method = options[:method] || :get\n uri = options[:uri]\n headers = options[:headers] || []\n body = options[:body] || \"\"\n end\n\n headers = headers.to_a if headers.is_a? Hash\n method = method.to_s.upcase\n\n request_components = {\n method: method,\n uri: uri,\n headers: headers\n }\n\n # Verify that we have all the pieces required to validate the HTTP request\n request_components.each do |(key, value)|\n raise ArgumentError, \"Missing :#{key} parameter.\" unless value\n end\n request_components[:body] = body\n request_components\n end",
"def create\n @post = Post.new(post_params)\n headers['Content-Type'] = \"application/json; charset=UTF-8\"\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: request.request_method }\n format.json { render :json => @post.to_json(:include => [:comments]) }\n print 'request_method: '\n puts request.request_method\n print 'request_method_symbol: '\n puts request.request_method_symbol\n print 'method: '\n puts request.method\n print 'patch: '\n puts request.patch?\n print 'head: '\n puts request.head?\n print 'headers: '\n puts request.headers\n print 'original_fullpath: '\n puts request.original_fullpath\n print 'fullpath: '\n puts request.fullpath\n print 'original_url: '\n puts request.original_url\n print 'media_type: '\n puts request.media_type\n print 'content_length: '\n puts request.content_length\n print 'ip: '\n puts request.ip\n print 'remote_ip: '\n puts request.remote_ip\n print 'uuid: '\n puts request.uuid\n print 'raw_post: '\n puts request.raw_post\n print 'body: '\n puts request.body\n print 'form_data: '\n puts request.form_data?\n print 'body_stream: '\n puts request.body_stream\n print 'local: '\n puts request.local?\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def parse_parameters; end",
"def http_method(request)\n raise NotImplementedError\n end",
"def http_method(request)\n raise NotImplementedError\n end",
"def process(request); end",
"def request_data; end",
"def setup_http_request(obj, cookie=nil, args={})\n if args.has_key?(:url) and args[:url] != nil\n if args[:url].scan(/%[s|d]/).length > 0\n if args[:url].scan(/%[s|d]/).length != args[:url_arg].length\n ALERT.call(caller_locations, __callee__, \"URL contains %d '%%s' or '%%d' argument... Fix your code\" % args[:url].scan(/%[s|d]/).length)\n exit 2\n end\n req = obj[:method].new(args[:url] % args[:url_arg])\n else\n req = obj[:method].new(args[:url])\n end\n else\n if args.has_key?(:url_arg)\n if obj[:url].scan(/%[s|d]/).length > 0\n if obj[:url].scan(/%[s|d]/).length != args[:url_arg].length\n ALERT.call(caller_locations, __callee__, \"URL contains %d '%%s' or '%%d' argument... Fix your code\" % obj[:url].scan(/%[s|d]/).length)\n exit 2\n end\n req = obj[:method].new(obj[:url] % args[:url_arg])\n else\n req = obj[:method].new(obj[:url])\n end\n else\n req = obj[:method].new(obj[:url])\n end\n end\n req[\"Host\"] = \"www.blablacar.fr\"\n req[\"origin\"] = \"https://www.blablacar.fr\"\n req[\"User-Agent\"] = \"Mozilla/5.0 (X11; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0\"\n req[\"Accept\"] = \"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\"\n if obj.has_key?(:referer)\n req['Referer'] = obj[:referer]\n else\n req[\"Referer\"] = \"https://www.blablacar.fr/dashboard\"\n end\n req.add_field(\"Connection\", \"keep-alive\")\n if cookie\n req.add_field(\"Cookie\", cookie)\n end\n if obj.has_key?(:header)\n obj[:header].each_slice(2).map{|h|\n req.add_field(h[0], h[1])\n }\n end\n if obj.has_key?(:data)\n if obj[:data].scan(/%[s|d]/).length > 0\n if obj[:data].scan(/%[s|d]/).length != args[:arg].length\n ALERT.call(caller_locations, __callee__, \"Body request contains %d '%%s' or '%%d' argument... Fix your code\" % obj[:data].scan(/%[s|d]/).length)\n exit 2\n else\n req.body = obj[:data] % args[:arg]\n end\n else\n req.body = obj[:data]\n end\n req['Content-Length'] = req.body.length\n end\n req\nend",
"def check_method_param(req)\n params = URI.decode_www_form(req.body)\n method_params = params.find { |param| param.first = \"_method\" }\n if method_params\n req.instance_variable_set(:@request_method, method_params[1])\n #!!!!!!!!!!!!!!!!!!!!!!!!!!\n end\n end",
"def POST\n @env[\"action_controller.request.request_parameters\"] ||= begin\n normalize_parameters(super || {})\n rescue\n {}\n end\n end",
"def http=(_arg0); end",
"def post(path, **args); end",
"def request_params_all(request)\n request_params = HashWithIndifferentAccess.new\n request_params.merge!(request.params || {})\n\n # read post or put params. this will erase params\n # {code: 123, mode: 123}\n # \"code=123&mode=123\"\n request_body = request.body.read\n if request_body.present?\n body_params = begin\n JSON.parse(request_body) # {code: 123, mode: 123}\n rescue JSON::ParserError\n Rack::Utils.parse_nested_query(request_body) # \"code=123&mode=123\"\n end\n else\n body_params = {}\n end\n\n request_params.merge(body_params)\n end",
"def query_params=(_arg0); end",
"def test_url_param()\n # Parameters for the API call\n url = 'https://www.shahidisawesome.com/and/also/a/narcissist?thisis=aparameter&another=one'\n\n # Perform the API call through the SDK function\n result = self.class.controller.url_param(url)\n\n # Test response code\n assert_equal(@response_catcher.response.status_code, 200)\n\n # Test whether the captured response is as we expected\n assert_not_nil(result)\n expected_body = JSON.parse('{\"passed\":true}')\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end",
"def parse_request request\n\n request_uuid = request.shift\n request_method = request.shift\n\n begin\n request_response = @notifier_engine.process_input request_method.to_sym, request\n rescue => exc\n request_response = \"#{exc.class}: #{exc.message}\"\n end\n\n send_response request_uuid, request_response\n\n end",
"def parse_content_body\n if put_or_post? && request.content_type.include?(\"application/json\")\n body_params = request.body.read\n parsed = body_params && body_params.length >= 2 ? JSON.parse(body_params) : nil\n params.merge!(parsed)\n end\n end",
"def post(request)\n if request.params.is_a?(Hash)\n @connection.post request.path, request.params\n else\n @connection.post request.path do |req|\n req.body = request.params\n end\n end\n end",
"def initialize_query()\n if (\"POST\" == env_table['REQUEST_METHOD']) and\n %r|\\Amultipart/form-data.*boundary=\\\"?([^\\\";,]+)\\\"?|.match(env_table['CONTENT_TYPE'])\n raise StandardError.new(\"too large multipart data.\") if env_table['CONTENT_LENGTH'].to_i > MAX_MULTIPART_LENGTH\n boundary = $1.dup\n @multipart = true\n @params = read_multipart(boundary, env_table['CONTENT_LENGTH'].to_i)\n #@params = \"none support multipart\"\n else\n @multipart = false\n @params = SimpleCGI::parse(\n case env_table['REQUEST_METHOD']\n when \"GET\", \"HEAD\"\n env_table['QUERY_STRING'] or \"\"\n when \"POST\"\n stdinput.read(env_table['CONTENT_LENGTH'].to_i) or ''\n else\n @offline_parames\n end.dup\n )\n #... Encoding\n #unless Encoding.find(@accept_charset) == Encoding::ASCII_8BIT\n # @params.each do |key,values|\n # values.each do |value|\n # unless value.valid_encoding?\n # if @accept_charset_error_block\n # @accept_charset_error_block.call(key,value)\n # else\n # raise InvalidEncoding,\"Accept-Charset encoding error\"\n # end\n # end\n # end\n # end\n #end\n end\n\n end",
"def consume_bad_url; end",
"def post\n raise NotImplementedError\n end",
"def parse_params(method, uri_fragments, query_param_string)\n params = {}\n params[:resource] = uri_fragments[3]\n params[:id] = uri_fragments[4]\n params[:action] = uri_fragments[5]\n if query_param_string\n case method\n when \"POST\" || \"PUTS\"\n param_pairs = query_param_string.split(',')\n param_k_v = param_pairs.map { |param_pair| param_pair.split(':') }\n param_k_v.each { |k, v| params.store(k.to_sym, v) }\n else\n param_pairs = query_param_string.split('&')\n param_k_v = param_pairs.map { |param_pair| param_pair.split('=') }\n param_k_v.each { |k, v| params.store(k.to_sym, v.delete('\"')) }\n end\n end\n params\nend",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def fixup_request( request )\n\t\treturn request\n\tend",
"def set_request; end",
"def format_request(payload); end",
"def format_request(payload); end",
"def url_params\n {}\n end"
] | [
"0.70598954",
"0.6979006",
"0.6829557",
"0.633713",
"0.6224963",
"0.62221104",
"0.61546314",
"0.6130512",
"0.6014339",
"0.59544444",
"0.5952795",
"0.59401673",
"0.59335905",
"0.59034073",
"0.5890737",
"0.5887199",
"0.5868058",
"0.5862783",
"0.58559465",
"0.5847388",
"0.58458817",
"0.58458817",
"0.5841887",
"0.58399415",
"0.5821087",
"0.58062327",
"0.5798476",
"0.57975733",
"0.5793741",
"0.5791978",
"0.5787722",
"0.5787521",
"0.57626677",
"0.57534534",
"0.57334864",
"0.5708885",
"0.5700979",
"0.5696027",
"0.5693755",
"0.56810564",
"0.5677267",
"0.56665236",
"0.56665236",
"0.56665236",
"0.5657646",
"0.56572497",
"0.56545967",
"0.56539863",
"0.5649456",
"0.5632527",
"0.56129456",
"0.5611251",
"0.56101775",
"0.5604132",
"0.56021327",
"0.55996203",
"0.55750406",
"0.55733883",
"0.55733883",
"0.55687886",
"0.556735",
"0.5566661",
"0.55625695",
"0.5553365",
"0.55429435",
"0.55413926",
"0.55242896",
"0.55242896",
"0.5516766",
"0.5514665",
"0.5507266",
"0.5491952",
"0.54892105",
"0.54833674",
"0.5475793",
"0.54708135",
"0.5462152",
"0.5457527",
"0.54572296",
"0.5450382",
"0.5445803",
"0.544336",
"0.54399824",
"0.54363805",
"0.5436194",
"0.5421688",
"0.5421688",
"0.5421688",
"0.5421688",
"0.5421688",
"0.5421688",
"0.5421688",
"0.5421688",
"0.5421688",
"0.5421688",
"0.5421688",
"0.54138494",
"0.5413131",
"0.54085654",
"0.54085654",
"0.5408252"
] | 0.0 | -1 |
Returns the square of the sum of the first +n+ natural numbers | def square_of_sums
return (@n * (@n + 1) / 2)**2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def square_of_sum(n)\n sum = 0\n (1..n).each {|i| sum = sum + i}\n sum * sum\n end",
"def sum_of_squares(n)\n sum = 0\n (1..n).each {|i| sum = sum + (i*i)}\n sum\n end",
"def square_of_sum\n\t\t@n**2*(@n+1)**2/4\n\tend",
"def sum_up_to_squared n=100\r\n (2 * n + 1) * (n + 1) * n / 6\r\nend",
"def square_sum_up_to n=100\r\n (n * (n + 1) / 2)**2\r\nend",
"def square_of_n_integers n\n ((n/2) * (n+1))**2\nend",
"def squareOfSum n\n return triangularNumber(n)**2\nend",
"def sum_of_squares\n return @n * (@n + 1) * (2 * @n + 1) / 6\n end",
"def sum_of_squares n\n (n**3)/3 + (n**2)/2 + n/6 \nend",
"def sum_squares(n)\nsums = [] \n for i in (1..n)\n i_squared = i**2\n sums.push i_squared \n end\n p sums.reduce(:+)\nend",
"def sum(n)\n result = 0\n n.each do |number|\n result = result + number\n end\n return result\n end",
"def sum(n)\n s = BigDecimal.new(\"1\")\n sig = 1\n\n 1.upto(n) do |i|\n sig *= -1\n s += (1.0 / (2*i + 1)) * sig\n end\n\n 4 * s\nend",
"def sum_of_squares(n)\n sum = 0\n for i in 1..n\n sum+= i*i\n end \n sum\nend",
"def sum_of_the_squares\n sum = 0\n (1..self).each do |n|\n sum += n**2\n end\n sum\n end",
"def sum_square_difference(n)\n sum = 0\n sums_squared = 0\n 1.upto(n) do |num|\n sum += num\n sums_squared += num**2\n end\n sum**2 - sums_squared\nend",
"def sum_sq(n)\n cnt = 1\n sum = 0\n while cnt <= n\n sum += cnt * cnt\n cnt += 1\n end \n puts sum\nend",
"def sum_of_primes(n)\n Prime.first(n).inject(0, :+)\nend",
"def sum_of_squares(n)\n (1..n).inject(0) do |total, i|\n total += i**2\n end\nend",
"def sum(n)\n end",
"def square_sums(n)\n Array(1..n).sum**2\nend",
"def sum_of_squares\n self.inject(0) { |sos, n| sos + n**2 }\n end",
"def first_even_numbers_sum(n)\n return 2 if n == 1\n 2 * n + first_even_numbers_sum(n-1)\n end",
"def sum_square_difference(n)\r\n square_total = 0\r\n sum_square = 0\r\n 1.upto(n) {|x| square_total += x}\r\n 1.upto(n) {|x| sum_square += (x**2)}\r\n square_sum = square_total**2\r\n square_sum - sum_square\r\nend",
"def squareSum(numbers)\n numbers.map { |n| n*n }.reduce(:+)\nend",
"def summation(n)\n sum = 0\n (1..n).each { |num| sum += num }\n return sum\nend",
"def squareSum(numbers)\n numbers.map { |n| n*n}.reduce(:+)\nend",
"def sums num\n\tsum_of_squares = 0\n\tsum = 0\n\t1.upto num do |n|\n\t\tsum_of_squares += n*n\n\t\tsum += n\n\tend\n\tsum**2 - sum_of_squares \nend",
"def solve( n = 100 )\n # Sum of squares is given by n(n + 1)(2n + 1) / 6, while square of sums\n # is [n(n + 1)][n(n + 1)] / 4. Subtracting and simplifying the result\n # gives n(n + 1)(n - 1)(3n + 2) / 12.\n n * (n + 1) * (n - 1) * (3*n + 2) / 12\n end",
"def sum_to(n)\n (1..n).reduce(0) do |sum, value|\n sum + value\n end\nend",
"def square_of_the_sum\n (1..self).inject(&:+)**2\n end",
"def summation(n)\n sum = 0\n (1..n).each { |num| sum += num }\n return sum\nend",
"def square_of_sums\n sum=((@num**2+@num)/2)**2\n end",
"def sum_of_the_squares max_number\n sum = 0\n (1..max_number).each { |i| sum += (i ** 2) }\n sum\nend",
"def sumn(n)\n result = 0\n 1.upto(n) { |e| result += e }\n puts \"Sum of #{n} numbers is #{result}\"\nend",
"def squareSum(numbers)\n numbers.map { |i| i ** 2 }.reduce(:+)\nend",
"def sum_sq_diff(n)\n nums_in_range = (1..n)\n # square_sums = nums_in_range.sum ** 2\n square_sums = nums_in_range.sum.pow(2)\n sums_square = nums_in_range.map { |n| n ** 2 }.sum\n square_sums - sums_square\nend",
"def sum_square_difference(n)\n ((1..n).reduce(:+)**2) - (1..n).reduce{ |sum, i| sum + i**2 }\nend",
"def sum_term n\n (1..n).reduce(0) { |acc, curr| acc += (curr ** 2 + curr + 1)}\nend",
"def sum_of_squares\n\t\t\tinject(0) do |sum, elem|\n\t\t\t\tsum + (elem ** 2)\n\t\t\tend\n\t\tend",
"def sum_square_difference(n)\n \n sum = 0 \n for i in 0..n\n sum += i\n end\n \n sq_sum = 0\n for i in 0..n\n sq_sum += (i**2)\n end \n \n (sum*sum) - sq_sum\nend",
"def sum_of_amicable_numbers(n)\r\n amicable_numbers(n).reduce(:+)\r\nend",
"def square_sum\n self.inject(0.0){|accum, i| accum +i**2 }\n end",
"def two_to_sum(n)\n result = 2 ** n\n \n result.to_s.split('').map {|x| x.to_i }.reduce(:+)\nend",
"def sum_squares(n)\n (1..n).inject { |sum, i| sum += i**2 }\nend",
"def square_of_sum\n\tsquare_of = 0\n\n\t(1..100).each do |x|\n\t\tsquare_of += x\n\tend\n\tsquare_of = square_of**2\n\tsquare_of\nend",
"def square_of_sums\n square(sum(sequence))\n end",
"def sum_square_difference(n)\n n_integers = (1..n).to_a\n square_of_sum = n_integers.inject(:+)**2\n sum_of_squares = n_integers.map {|n|n**2}.inject(:+)\n square_of_sum - sum_of_squares\nend",
"def sum_to(n)\n n > 1 ? n + sum_to(n - 1) : n < 1 ? [].first : 1\n end",
"def squareSum(numbers)\n numbers.inject(0) { |sum, n| sum + n*n }\nend",
"def summation(n)\n #iterate through numbers less than or equal to n and add them up\n sum = 0\n\n (1..n).each { |num| sum += num }\n return sum\nend",
"def sum_of_squares\n @number_range.sum {|n| n**2}\n end",
"def sum_terms(n)\n (1..n).reduce(0) {|sum, val| sum += (val * val + 1)}\n end",
"def arith_sum_squares(max)\n max * (max+1) * (2*max+1) / 6\nend",
"def sum_square_difference(n)\n integers = (1..n).to_a\n\n square_of_sum = integers.sum ** 2\n sum_of_squares = integers.map { |n| n ** 2 }.sum\n\n square_of_sum - sum_of_squares\nend",
"def first_even_numbers_sum(n)\n return 2 if n == 1\n 2 * n + first_even_numbers_sum(n-1)\nend",
"def squareSum(numbers)\n numbers.reduce(0){|sum, x| sum + (x ** 2)}\nend",
"def first_even_numbers_sum(n)\n\nend",
"def first_even_numbers_sum(n)\n\nend",
"def sumOfSquares(max)\n out = 0\n max.times do |i|\n out += (i+1)**2\n end\n out\nend",
"def square_of_sum\n @number_range.sum**2\n end",
"def sum_square_diff(n)\r\n sq_of_sum = (1..n).to_a.sum ** 2\r\n sum_of_sq = (1..n).to_a.map{ |num| num *= num }.sum\r\n (sq_of_sum - sum_of_sq).abs\r\nend",
"def sum_of_squares(number)\n \n result = 0\n i = 1\n while i <= number\n result += (i ** 2) \n i += 1\n end\n\n result\nend",
"def geometricSeriesSum(x, n)\n return (power(x, n + 1) - 1) / (x - 1)\nend",
"def sum_square_difference(n)\n # square_of_sum = (1..n).reduce(:+) ** 2\n # sum_of_squares = (1..n).reduce { |sum, num| sum + num * num }\n # square_of_sum - sum_of_squares\n # (1..n).reduce(:+)**2 - (1..n).reduce { |sum, num| sum + num * num }\n\n (1..n).sum**2 - (1..n).sum { |num| num**2 }\nend",
"def sum_integers_up_to(n)\n (n * ( n + 1 ) ) / 2\nend",
"def sum_square_difference(num)\n sum = 0\n square_sum = 0\n\n 1.upto(num) do |n|\n sum += n\n square_sum += n**2\n end\n\n sum**2 - square_sum\nend",
"def sum_prime(n)\n\ti = 0\n\tp = 1\n\tsum = 0\n#\tprimes = []\n\n\tuntil p == n\n\t\tp += 1\n\t\tif is_prime?(p)\n#\t\t\tprimes << p\n\t\t\tsum += p\n\t\t\ti += 1\n\t\tend\n\tend\n\n\treturn sum\n\t#return primes.reduce(:+)\nend",
"def sum_of_squares\n sum(square(sequence))\n end",
"def summul n, x\n count = n / x\n x * (count * (1 + count) / 2)\nend",
"def sum_square_difference(int)\n first_n_ints = (1..int).to_a\n\n sum_1 = first_n_ints.sum\n\n sum_2 = first_n_ints.map{|int| int**2}.sum\n\n (sum_1**2) - sum_2\nend",
"def solution(num)\n sum_of_squares = 0\n\n (1..num).each do |number|\n sum_of_squares += number**2\n end\n\n square_of_sums = (1..num).inject(:+) ** 2\n\n p (square_of_sums - sum_of_squares).abs\nend",
"def sum_of_squares(max)\n sum = 0\n (1..max).each do|current|\n sum = sum + current**2\n end\n return sum\nend",
"def sum_square_difference(num)\n 1.upto(num).sum**2 - 1.upto(num).reduce(0) { |total, n| total + n**2 }\nend",
"def sum_of_squares\n @range.sum { |n| n**2 }\n end",
"def sum_of_all_primes(n)\n sum = 0\n (1..n).each do |x|\n if prime? x\n sum += x\n end \n end \n sum\n end",
"def s1(n)\n (n*(n+1)/2)**2\nend",
"def sum_of_multiple(multiple, n)\n p = n/multiple\n return multiple*((p*(p+1))/2)\nend",
"def sum_square_difference(n)\n square_of_sums = (1..n).inject(:+) ** 2\n sum_of_squares = (1..n).inject {|sum, num| sum + (num ** 2)}\n square_of_sums - sum_of_squares\nend",
"def compute_sum(number)\n (1..number).inject(:+)\nend",
"def compute_sum(number)\n (1..number).reduce(:+)\nend",
"def summation(num)\n (1..num).reduce(:+)\nend",
"def sum(n)\n n.digits.sum\nend",
"def row_sum_odd_numbers(n)\n\tn**3\nend",
"def square_root_sum\n inject(nil) { |sum, x| sum ? sum + x ** 2 : x ** 2 }\n end",
"def sum(number)\n n = number\n array = []\n answer = []\n while n > 1 do\n array << (n -= 1)\n end\n num = array.reduce(:*)\n num.to_s.split(\"\").each do |i|\n answer << i.to_i\n end\n return answer.reduce(:+)\nend",
"def sum_of_products_of n, sum_up_to=999\r\n p = sum_up_to / n\r\n n * (p *(p + 1)) / 2\r\nend",
"def square_of_sum\n end",
"def sum_of_n(n)\n key = 0\n answer = (0..n.abs).to_a.map { |num| key += num }\n n < 0 ? (answer.map { |n| n * (-1) }) : answer\nend",
"def sum_of_squares(numbers)\n numbers.map { |x| x * x }.reduce(0) { |acc, x| acc + x }\nend",
"def sq(n)\n n.to_f*n\n end",
"def sum_of_primes(n)\n prime_array = []\n (2..n).each do |i|\n next unless prime_number?(i)\n prime_array << i\n end\n prime_array.inject(:+)\nend",
"def sum(n=16) end",
"def sum(n)\n return 1 if n == 1\n\n n + sum(n - 1)\nend",
"def square_sum(numbers)\n squares = numbers.map{|number| number * number}\n squares.reduce(0){|num, sum| num + sum}\nend",
"def sum_two_small_numbers(numbers)\n numbers.sort.first(2).inject(:+)\nend",
"def square_of_sums\n range.reduce(:+)**2\n end",
"def summation(num)\n sum = (0..num).inject(:+)\n return sum\nend",
"def summul(n, x)\n count = n // x\n x * (count * (1 + count) // 2)\nend",
"def sum_square_difference(n)\n square_of_sum = ((1..n).sum) ** 2\n sum_of_square = (1..n).map{|i| i * i}.sum\n p difference = square_of_sum - sum_of_square\nend",
"def sum_terms(n)\n (1..n).map {|x| x**2+1 }.reduce(0,:+) if n >= 0\nend"
] | [
"0.8386006",
"0.7973424",
"0.79434913",
"0.7864936",
"0.78023165",
"0.765812",
"0.76429236",
"0.7633945",
"0.7561177",
"0.75412804",
"0.75055015",
"0.74811",
"0.7475553",
"0.7463038",
"0.74529445",
"0.74393106",
"0.74113595",
"0.73868793",
"0.73721236",
"0.73595667",
"0.73349756",
"0.7314198",
"0.7298382",
"0.72907394",
"0.7280198",
"0.72781",
"0.72734267",
"0.726072",
"0.7243891",
"0.7236155",
"0.72225374",
"0.71936756",
"0.7172957",
"0.71707577",
"0.71450734",
"0.7132518",
"0.7131443",
"0.7130838",
"0.71185637",
"0.7087721",
"0.7083118",
"0.7081688",
"0.7081576",
"0.7069199",
"0.70433503",
"0.70425737",
"0.7037573",
"0.7037351",
"0.70353866",
"0.70259756",
"0.7015748",
"0.70131975",
"0.7011448",
"0.7009843",
"0.70030195",
"0.7000966",
"0.69996834",
"0.69996834",
"0.6984965",
"0.69809437",
"0.6975945",
"0.6967754",
"0.696409",
"0.6955985",
"0.6949514",
"0.69408643",
"0.6939939",
"0.6930837",
"0.6909104",
"0.6896464",
"0.688583",
"0.6873536",
"0.6863195",
"0.68605834",
"0.6853183",
"0.68387",
"0.68333656",
"0.68326753",
"0.6810265",
"0.6805674",
"0.6802995",
"0.67847574",
"0.67847425",
"0.67802805",
"0.6777807",
"0.6769102",
"0.6762642",
"0.6762583",
"0.6756859",
"0.6755874",
"0.6750372",
"0.67425394",
"0.67379194",
"0.6736988",
"0.6728",
"0.67195344",
"0.6717146",
"0.6714019",
"0.6709358",
"0.668734"
] | 0.83127034 | 1 |
Returns the sum of the squares of the first +n+ natural numbers | def sum_of_squares
return @n * (@n + 1) * (2 * @n + 1) / 6
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_of_squares(n)\n sum = 0\n (1..n).each {|i| sum = sum + (i*i)}\n sum\n end",
"def square_of_sums\n return (@n * (@n + 1) / 2)**2\n end",
"def square_of_sum(n)\n sum = 0\n (1..n).each {|i| sum = sum + i}\n sum * sum\n end",
"def sum_of_squares n\n (n**3)/3 + (n**2)/2 + n/6 \nend",
"def sum_up_to_squared n=100\r\n (2 * n + 1) * (n + 1) * n / 6\r\nend",
"def sum_of_squares(n)\n sum = 0\n for i in 1..n\n sum+= i*i\n end \n sum\nend",
"def sum_squares(n)\nsums = [] \n for i in (1..n)\n i_squared = i**2\n sums.push i_squared \n end\n p sums.reduce(:+)\nend",
"def sum_of_the_squares\n sum = 0\n (1..self).each do |n|\n sum += n**2\n end\n sum\n end",
"def sum_of_squares(n)\n (1..n).inject(0) do |total, i|\n total += i**2\n end\nend",
"def square_of_sum\n\t\t@n**2*(@n+1)**2/4\n\tend",
"def square_sum_up_to n=100\r\n (n * (n + 1) / 2)**2\r\nend",
"def square_of_n_integers n\n ((n/2) * (n+1))**2\nend",
"def sums num\n\tsum_of_squares = 0\n\tsum = 0\n\t1.upto num do |n|\n\t\tsum_of_squares += n*n\n\t\tsum += n\n\tend\n\tsum**2 - sum_of_squares \nend",
"def sum_of_squares\n self.inject(0) { |sos, n| sos + n**2 }\n end",
"def sum_square_difference(n)\n sum = 0\n sums_squared = 0\n 1.upto(n) do |num|\n sum += num\n sums_squared += num**2\n end\n sum**2 - sums_squared\nend",
"def solve( n = 100 )\n # Sum of squares is given by n(n + 1)(2n + 1) / 6, while square of sums\n # is [n(n + 1)][n(n + 1)] / 4. Subtracting and simplifying the result\n # gives n(n + 1)(n - 1)(3n + 2) / 12.\n n * (n + 1) * (n - 1) * (3*n + 2) / 12\n end",
"def sum_of_the_squares max_number\n sum = 0\n (1..max_number).each { |i| sum += (i ** 2) }\n sum\nend",
"def sum_of_primes(n)\n Prime.first(n).inject(0, :+)\nend",
"def sum_squares(n)\n (1..n).inject { |sum, i| sum += i**2 }\nend",
"def sum_sq(n)\n cnt = 1\n sum = 0\n while cnt <= n\n sum += cnt * cnt\n cnt += 1\n end \n puts sum\nend",
"def sum_square_difference(n)\r\n square_total = 0\r\n sum_square = 0\r\n 1.upto(n) {|x| square_total += x}\r\n 1.upto(n) {|x| sum_square += (x**2)}\r\n square_sum = square_total**2\r\n square_sum - sum_square\r\nend",
"def square_sums(n)\n Array(1..n).sum**2\nend",
"def sum(n)\n result = 0\n n.each do |number|\n result = result + number\n end\n return result\n end",
"def sum_of_squares\n\t\t\tinject(0) do |sum, elem|\n\t\t\t\tsum + (elem ** 2)\n\t\t\tend\n\t\tend",
"def sum_of_squares(number)\n \n result = 0\n i = 1\n while i <= number\n result += (i ** 2) \n i += 1\n end\n\n result\nend",
"def squareOfSum n\n return triangularNumber(n)**2\nend",
"def sum_of_squares\n @number_range.sum {|n| n**2}\n end",
"def num_squares1(n)\n helper = [0, 1]\n (2..n).each do |i|\n helper << (1..Math.sqrt(i).to_i).map do |j|\n helper[i - j ** 2] + 1\n end.min\n end\n helper[n]\nend",
"def sum_sq_diff(n)\n nums_in_range = (1..n)\n # square_sums = nums_in_range.sum ** 2\n square_sums = nums_in_range.sum.pow(2)\n sums_square = nums_in_range.map { |n| n ** 2 }.sum\n square_sums - sums_square\nend",
"def sum_square_difference(n)\n integers = (1..n).to_a\n\n square_of_sum = integers.sum ** 2\n sum_of_squares = integers.map { |n| n ** 2 }.sum\n\n square_of_sum - sum_of_squares\nend",
"def sum_square_difference(n)\n ((1..n).reduce(:+)**2) - (1..n).reduce{ |sum, i| sum + i**2 }\nend",
"def sum_square_difference(n)\n n_integers = (1..n).to_a\n square_of_sum = n_integers.inject(:+)**2\n sum_of_squares = n_integers.map {|n|n**2}.inject(:+)\n square_of_sum - sum_of_squares\nend",
"def arith_sum_squares(max)\n max * (max+1) * (2*max+1) / 6\nend",
"def first_even_numbers_sum(n)\n return 2 if n == 1\n 2 * n + first_even_numbers_sum(n-1)\n end",
"def summation(n)\n sum = 0\n (1..n).each { |num| sum += num }\n return sum\nend",
"def squareSum(numbers)\n numbers.map { |n| n*n }.reduce(:+)\nend",
"def squareSum(numbers)\n numbers.map { |n| n*n}.reduce(:+)\nend",
"def sum(n)\n end",
"def sumOfSquares(max)\n out = 0\n max.times do |i|\n out += (i+1)**2\n end\n out\nend",
"def sum(n)\n s = BigDecimal.new(\"1\")\n sig = 1\n\n 1.upto(n) do |i|\n sig *= -1\n s += (1.0 / (2*i + 1)) * sig\n end\n\n 4 * s\nend",
"def summation(n)\n sum = 0\n (1..n).each { |num| sum += num }\n return sum\nend",
"def sum_square_difference(n)\n \n sum = 0 \n for i in 0..n\n sum += i\n end\n \n sq_sum = 0\n for i in 0..n\n sq_sum += (i**2)\n end \n \n (sum*sum) - sq_sum\nend",
"def sum_of_squares\n @range.sum { |n| n**2 }\n end",
"def sum_of_squares\n sum(square(sequence))\n end",
"def sum_to(n)\n (1..n).reduce(0) do |sum, value|\n sum + value\n end\nend",
"def sumn(n)\n result = 0\n 1.upto(n) { |e| result += e }\n puts \"Sum of #{n} numbers is #{result}\"\nend",
"def sum_of_squares(max)\n sum = 0\n (1..max).each do|current|\n sum = sum + current**2\n end\n return sum\nend",
"def sum_square_diff(n)\r\n sq_of_sum = (1..n).to_a.sum ** 2\r\n sum_of_sq = (1..n).to_a.map{ |num| num *= num }.sum\r\n (sq_of_sum - sum_of_sq).abs\r\nend",
"def sum_terms(n)\n (1..n).reduce(0) {|sum, val| sum += (val * val + 1)}\n end",
"def sum_of_squares(numbers)\n numbers.map { |x| x * x }.reduce(0) { |acc, x| acc + x }\nend",
"def sum_square_difference(n)\n # square_of_sum = (1..n).reduce(:+) ** 2\n # sum_of_squares = (1..n).reduce { |sum, num| sum + num * num }\n # square_of_sum - sum_of_squares\n # (1..n).reduce(:+)**2 - (1..n).reduce { |sum, num| sum + num * num }\n\n (1..n).sum**2 - (1..n).sum { |num| num**2 }\nend",
"def sum_of_all_primes(n)\n sum = 0\n (1..n).each do |x|\n if prime? x\n sum += x\n end \n end \n sum\n end",
"def sum_term n\n (1..n).reduce(0) { |acc, curr| acc += (curr ** 2 + curr + 1)}\nend",
"def square_of_sums\n sum=((@num**2+@num)/2)**2\n end",
"def squareSum(numbers)\n numbers.map { |i| i ** 2 }.reduce(:+)\nend",
"def solution(num)\n sum_of_squares = 0\n\n (1..num).each do |number|\n sum_of_squares += number**2\n end\n\n square_of_sums = (1..num).inject(:+) ** 2\n\n p (square_of_sums - sum_of_squares).abs\nend",
"def sum_integers_up_to(n)\n (n * ( n + 1 ) ) / 2\nend",
"def sum_square_difference(n)\n square_of_sums = (1..n).inject(:+) ** 2\n sum_of_squares = (1..n).inject {|sum, num| sum + (num ** 2)}\n square_of_sums - sum_of_squares\nend",
"def summation(n)\n #iterate through numbers less than or equal to n and add them up\n sum = 0\n\n (1..n).each { |num| sum += num }\n return sum\nend",
"def sum_square_difference(int)\n first_n_ints = (1..int).to_a\n\n sum_1 = first_n_ints.sum\n\n sum_2 = first_n_ints.map{|int| int**2}.sum\n\n (sum_1**2) - sum_2\nend",
"def sum_of_squares(x)\n sum_of_squares = 0\n (1..x).each do |f|\n sum_of_squares += f**2\n end\n return sum_of_squares\nend",
"def squareSum(numbers)\n numbers.inject(0) { |sum, n| sum + n*n }\nend",
"def sum_of_amicable_numbers(n)\r\n amicable_numbers(n).reduce(:+)\r\nend",
"def two_to_sum(n)\n result = 2 ** n\n \n result.to_s.split('').map {|x| x.to_i }.reduce(:+)\nend",
"def squareSum(numbers)\n numbers.reduce(0){|sum, x| sum + (x ** 2)}\nend",
"def square_of_the_sum\n (1..self).inject(&:+)**2\n end",
"def sum_of_multiple(multiple, n)\n p = n/multiple\n return multiple*((p*(p+1))/2)\nend",
"def geometricSeriesSum(x, n)\n return (power(x, n + 1) - 1) / (x - 1)\nend",
"def sum_square_difference(num)\n sum = 0\n square_sum = 0\n\n 1.upto(num) do |n|\n sum += n\n square_sum += n**2\n end\n\n sum**2 - square_sum\nend",
"def sum_square_difference(num)\n 1.upto(num).sum**2 - 1.upto(num).reduce(0) { |total, n| total + n**2 }\nend",
"def first_even_numbers_sum(n)\n return 2 if n == 1\n 2 * n + first_even_numbers_sum(n-1)\nend",
"def num_squares2(n)\n helper = [0, 1]\n (2..n).each do |i| \n helper[i] = i\n (1..Math.sqrt(i).to_i).each do |j|\n helper[i] = [helper[i - j ** 2] + 1, helper[i]].min\n end \n end \n helper[n]\nend",
"def sum_of_digit_squares(number)\n\tdigits = number.to_s.split(//)\n\tsum = 0\n\tdigits.each do |digit|\n\t\tsum += (digit.to_i)**2\n\tend\n\tsum\nend",
"def sumOf(n)\n i = 0\n multiples = []\n while i < n do\n if i % 3 == 0 || i % 5 == 0\n multiples.push(i)\n end\n i += 1\n end\n multiples.inspect\n multiples.reduce(:+)\nend",
"def sum_of_primes(n)\n prime_array = []\n (2..n).each do |i|\n next unless prime_number?(i)\n prime_array << i\n end\n prime_array.inject(:+)\nend",
"def first_even_numbers_sum(n)\n\nend",
"def first_even_numbers_sum(n)\n\nend",
"def summul n, x\n count = n / x\n x * (count * (1 + count) / 2)\nend",
"def square_of_sums\n square(sum(sequence))\n end",
"def sum_prime(n)\n\ti = 0\n\tp = 1\n\tsum = 0\n#\tprimes = []\n\n\tuntil p == n\n\t\tp += 1\n\t\tif is_prime?(p)\n#\t\t\tprimes << p\n\t\t\tsum += p\n\t\t\ti += 1\n\t\tend\n\tend\n\n\treturn sum\n\t#return primes.reduce(:+)\nend",
"def square_sum\n self.inject(0.0){|accum, i| accum +i**2 }\n end",
"def square_of_sum\n\tsquare_of = 0\n\n\t(1..100).each do |x|\n\t\tsquare_of += x\n\tend\n\tsquare_of = square_of**2\n\tsquare_of\nend",
"def s1(n)\n (n*(n+1)/2)**2\nend",
"def square_sum(numbers)\n squares = numbers.map{|number| number * number}\n squares.reduce(0){|num, sum| num + sum}\nend",
"def sum_of_squares\n range.reduce { |a, e| a + e**2 }\n end",
"def sum_of_multiples(x, n)\n multiples_count = n/x\n x * ((n/x) * ((n/x)+1)/2)\nend",
"def sum_to(n)\n n > 1 ? n + sum_to(n - 1) : n < 1 ? [].first : 1\n end",
"def sum_square_difference(n)\n square_of_sum = ((1..n).sum) ** 2\n sum_of_square = (1..n).map{|i| i * i}.sum\n p difference = square_of_sum - sum_of_square\nend",
"def sum_square_difference(number)\n squared_sum = 1.upto(number).inject(:+)**2\n sum_squares = 0\n 1.upto(number).each {|num| sum_squares += num**2}\n squared_sum - sum_squares\nend",
"def row_sum_odd_numbers(n)\n\tn**3\nend",
"def sum_terms(n)\n (1..n).map {|x| x**2+1 }.reduce(0,:+) if n >= 0\nend",
"def sum_square_difference(num)\n square_of_the_sum = 0\n sum_of_the_squares = 0\n \n 1.upto(num) do |num|\n square_of_the_sum += num\n sum_of_the_squares += (num ** 2)\n end\n\n total = (square_of_the_sum ** 2) - sum_of_the_squares\n total\nend",
"def num_squares3(n)\n n /= 4 while n % 4 == 0\n return 4 if n % 8 == 7\n (0..Math.sqrt(n).to_i).each do |a|\n b = Math.sqrt(n - a ** 2).to_i\n if a * a + b * b == n\n if a > 0 && b > 0\n return 2\n elsif a == 0 && b == 0\n return 0\n else\n return 1\n end\n end\n end\n return 3\nend",
"def multisum(n)\n sum = 0\n (1..n).each do |x|\n sum += x if (x % 3 == 0) || (x % 5 == 0)\n end\n sum\nend",
"def solve(n)\n\ttotal = 1\n\t(3...n+1).step(2) do |x|\n\t\t# Upper right corner is x**, the other corners are each x-1 less. Simplify and we've got:\n\t\ttotal += 4*x**2 - 6*x + 6\n\tend\n\treturn total\nend",
"def sum_square_difference(num)\n square_of_sum = 0\n sum_of_squares = 0\n\n 1.upto(num) do |i| \n square_of_sum += i\n sum_of_squares += i**2\n end\n\n square_of_sum**2 - sum_of_squares\nend",
"def solution(n)\n x = (n**0.5).floor\n (1..x).reduce(0) { |s, i| n % i == 0 ? s += (i * i == n ? 1 : 2) : s }\nend",
"def sum_of_n(n)\n key = 0\n answer = (0..n.abs).to_a.map { |num| key += num }\n n < 0 ? (answer.map { |n| n * (-1) }) : answer\nend",
"def sum_square_difference(num)\n square_of_sum = 1.upto(num).to_a.reduce(:+) ** 2\n sum_of_squares = 1.upto(num).to_a.map{ |n| n ** 2 }.reduce(:+)\n square_of_sum - sum_of_squares\nend",
"def get(n=0)\n sum = 0\n (0...n).each do |i|\n sum += i\n end\n return sum\n end"
] | [
"0.8337079",
"0.8165778",
"0.815824",
"0.7973656",
"0.78558964",
"0.7807768",
"0.7765323",
"0.77374494",
"0.7673717",
"0.7672474",
"0.76360095",
"0.76251656",
"0.75980556",
"0.75475436",
"0.7546374",
"0.75056887",
"0.7453837",
"0.73923033",
"0.7390996",
"0.7387779",
"0.7367973",
"0.73571366",
"0.733988",
"0.7329545",
"0.7298177",
"0.72962636",
"0.7286919",
"0.7227721",
"0.7223631",
"0.7221284",
"0.7209336",
"0.720468",
"0.72015715",
"0.7200868",
"0.7186811",
"0.7185859",
"0.71836513",
"0.71606004",
"0.71526575",
"0.714545",
"0.7138772",
"0.7134488",
"0.7103753",
"0.71007997",
"0.7098148",
"0.7084006",
"0.7073175",
"0.7061689",
"0.7056837",
"0.7056391",
"0.70484626",
"0.7046944",
"0.7045986",
"0.7038443",
"0.70367426",
"0.70295906",
"0.7010301",
"0.70067036",
"0.6981707",
"0.6970566",
"0.69612515",
"0.6959199",
"0.69451827",
"0.69156265",
"0.69141513",
"0.6906717",
"0.6906284",
"0.68887395",
"0.6887475",
"0.6866479",
"0.6855207",
"0.6838116",
"0.68374497",
"0.6833398",
"0.68281317",
"0.6820541",
"0.6820541",
"0.68160415",
"0.6805214",
"0.6801693",
"0.6799816",
"0.6798476",
"0.6783649",
"0.67657447",
"0.6758062",
"0.6757194",
"0.6755517",
"0.67548114",
"0.6746685",
"0.6739057",
"0.67251384",
"0.67158693",
"0.67072976",
"0.670437",
"0.6695761",
"0.66900575",
"0.6686549",
"0.6679604",
"0.6678919",
"0.66707504"
] | 0.8000374 | 3 |
Returns the difference between square_of_sums and sum_of_squares | def difference
return square_of_sums - sum_of_squares
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def difference\n square_of_sums - sum_of_squares\n end",
"def difference\n square_of_sums - sum_of_squares\n end",
"def difference\n # square of sums will always be bigger\n square_of_sum - sum_of_squares\n end",
"def difference\n square_of_sum - sum_of_squares\n end",
"def difference_between_sum_sq_and_sq_sum(n)\n square_sum(n) - sum_squares(n)\nend",
"def sum_square_difference(num)\n sum = sum(num)\n square = square(num)\n p sum - square\nend",
"def sum_square_diff(num)\n sum_of_squares = 0\n square_of_sum = 0\n\n (1..num).each do |i|\n squared = i**2\n sum_of_squares += squared\n square_of_sum += i\n end\n\n square_of_sum **= 2\n\n difference = square_of_sum - sum_of_squares\n\n puts difference\nend",
"def diff_squares(num)\r\n sum_of_nums = (1..num).inject { |sum, x| sum + x }\r\n sum_of_sq = (1..num).inject { |sum, x| sum + x**2 }\r\n sum_of_nums**2 - sum_of_sq\r\nend",
"def sum_square_difference(num)\n square_of_sum = ((1..num).sum)**2\n sum_of_squares = (1..num).map { |n| n**2}.sum\n square_of_sum - sum_of_squares\nend",
"def sum_square_difference(n)\n # square_of_sum = (1..n).reduce(:+) ** 2\n # sum_of_squares = (1..n).reduce { |sum, num| sum + num * num }\n # square_of_sum - sum_of_squares\n # (1..n).reduce(:+)**2 - (1..n).reduce { |sum, num| sum + num * num }\n\n (1..n).sum**2 - (1..n).sum { |num| num**2 }\nend",
"def sum_square_difference(num)\n\n sum_squared = (1..num).to_a.sum ** 2\n\n squares = []\n\n (1..num).each { |n| squares << n ** 2 }\n\n squared_sum = squares.sum\n\n sum_squared - squared_sum\nend",
"def sum_square_difference(num)\n square_of_sum = 1.upto(num).to_a.reduce(:+) ** 2\n sum_of_squares = 1.upto(num).to_a.map{ |n| n ** 2 }.reduce(:+)\n square_of_sum - sum_of_squares\nend",
"def sum_of_squares\n squares = differences_from_mean.map { |diff| diff ** 2 }\n squares.reduce(:+)\n end",
"def sum_square_difference(num)\n square_of_sum = (0..num).inject(:+) ** 2\n sum_of_square = (0..num).map { |num| num ** 2}.inject(:+)\n square_of_sum - sum_of_square\nend",
"def sum_square_difference(num)\n (1..num).sum ** 2 - (1..num).map {|num| num ** 2 }.sum\nend",
"def sum_square_difference(num)\n square_of_the_sum = 0\n sum_of_the_squares = 0\n \n 1.upto(num) do |num|\n square_of_the_sum += num\n sum_of_the_squares += (num ** 2)\n end\n\n total = (square_of_the_sum ** 2) - sum_of_the_squares\n total\nend",
"def sum_square_difference(a_num)\r\n first_block = (1..a_num).to_a.reduce(&:+)\r\n first_block **=2\r\n\r\n second_block = (1..a_num).to_a.map { |number| number ** 2 }\r\n second_block = second_block.reduce(&:+)\r\n\r\n first_block - second_block\r\nend",
"def sum_square_difference(num)\n 1.upto(num).sum**2 - 1.upto(num).reduce(0) { |total, n| total + n**2 }\nend",
"def sum_square_difference(n)\n square_of_sums = (1..n).inject(:+) ** 2\n sum_of_squares = (1..n).inject {|sum, num| sum + (num ** 2)}\n square_of_sums - sum_of_squares\nend",
"def sum_square_difference(num)\n (1..num).inject(:+)**2 - (1..num).map{|x| x**2}.inject(:+)\nend",
"def sum_square_difference(n)\n integers = (1..n).to_a\n\n square_of_sum = integers.sum ** 2\n sum_of_squares = integers.map { |n| n ** 2 }.sum\n\n square_of_sum - sum_of_squares\nend",
"def sum_square_difference(n)\n n_integers = (1..n).to_a\n square_of_sum = n_integers.inject(:+)**2\n sum_of_squares = n_integers.map {|n|n**2}.inject(:+)\n square_of_sum - sum_of_squares\nend",
"def sum_of_squares\n\t\t\tinject(0) do |sum, elem|\n\t\t\t\tsum + (elem ** 2)\n\t\t\tend\n\t\tend",
"def sum_square_difference(n)\n square_of_sum = ((1..n).sum) ** 2\n sum_of_square = (1..n).map{|i| i * i}.sum\n p difference = square_of_sum - sum_of_square\nend",
"def sum_square_difference(num)\n square_of_sum = 0\n sum_of_squares = 0\n\n 1.upto(num) do |i| \n square_of_sum += i\n sum_of_squares += i**2\n end\n\n square_of_sum**2 - sum_of_squares\nend",
"def sum_square_difference(integer)\n array = []\n 1.upto(integer) { |num| array << num }\n sum_squared = array.reduce(:+)**2\n\n array = []\n 1.upto(integer) { |num| array << num**2 }\n squared_sums = array.reduce(:+)\n\n sum_squared - squared_sums\nend",
"def sum_square_difference(number)\n squared_sum = 1.upto(number).inject(:+)**2\n sum_squares = 0\n 1.upto(number).each {|num| sum_squares += num**2}\n squared_sum - sum_squares\nend",
"def sum_square_diff(n)\r\n sq_of_sum = (1..n).to_a.sum ** 2\r\n sum_of_sq = (1..n).to_a.map{ |num| num *= num }.sum\r\n (sq_of_sum - sum_of_sq).abs\r\nend",
"def sum_square_difference(n)\n ((1..n).reduce(:+)**2) - (1..n).reduce{ |sum, i| sum + i**2 }\nend",
"def sum_square_difference(num)\n arr = (1..num).to_a\n square_of_arr_summed = (arr.sum) ** 2\n square_of_each_num = arr.reduce(0) { |sum, n| sum + n**2 }\n\n # Alternatively\n # square_of_each_num = 0\n # arr.each { |element| square_of_each_num += element **2 }\n\n return square_of_arr_summed - square_of_each_num\nend",
"def sum_square_difference(n)\n \n sum = 0 \n for i in 0..n\n sum += i\n end\n \n sq_sum = 0\n for i in 0..n\n sq_sum += (i**2)\n end \n \n (sum*sum) - sq_sum\nend",
"def sum_sq_diff(n)\n nums_in_range = (1..n)\n # square_sums = nums_in_range.sum ** 2\n square_sums = nums_in_range.sum.pow(2)\n sums_square = nums_in_range.map { |n| n ** 2 }.sum\n square_sums - sums_square\nend",
"def sum_square_difference(num)\n total_square = 0\n num_square = 0\n\n 1.upto(num) do |number|\n total_square += number\n end\n\n 1.upto(num) do |fig|\n num_square += fig**2\n end\n\n product_total = total_square ** 2\n square_difference = product_total - num_square\n square_difference\nend",
"def sum_of_squares\n end",
"def six\n square_of_sum(100) - sum_of_squares(100)\nend",
"def sum_square_difference(int)\n # square_of_sums = (0..int).inject(:+) ** 2\n # sum_of_squares = (0..int).inject(0) { |memo, value| memo + value ** 2 }\n # return square_of_sums - sum_of_squares\n\n (0..int).inject(:+) ** 2 - (0..int).inject(0) { |sum, n| sum + n ** 2 }\nend",
"def sum_square_difference(num)\r\n arr = (1..num).to_a\r\n sum1 = arr.sum ** 2\r\n sum2 = arr.inject { |sum, number| sum + number**2 }\r\n sum1 - sum2\r\nend",
"def sum_square_difference(n)\n sum = 0\n sums_squared = 0\n 1.upto(n) do |num|\n sum += num\n sums_squared += num**2\n end\n sum**2 - sums_squared\nend",
"def solution(num)\n sum_of_squares = 0\n\n (1..num).each do |number|\n sum_of_squares += number**2\n end\n\n square_of_sums = (1..num).inject(:+) ** 2\n\n p (square_of_sums - sum_of_squares).abs\nend",
"def findDiffSquares(n)\n sum = 0\n (1..n).each { |i|\n (1..n).each { |j|\n sum += i*j unless i == j\n }\n }\n sum\nend",
"def sum_square_difference(n)\r\n square_total = 0\r\n sum_square = 0\r\n 1.upto(n) {|x| square_total += x}\r\n 1.upto(n) {|x| sum_square += (x**2)}\r\n square_sum = square_total**2\r\n square_sum - sum_square\r\nend",
"def square_of_sums\n sum=((@num**2+@num)/2)**2\n end",
"def square_of_sums\n square(sum(sequence))\n end",
"def squares_diff(n)\n (1..n).inject(:+)**2 - (1..n).map{|i| i*i}.inject(:+)\nend",
"def sum_square_difference(int)\n first_n_ints = (1..int).to_a\n\n sum_1 = first_n_ints.sum\n\n sum_2 = first_n_ints.map{|int| int**2}.sum\n\n (sum_1**2) - sum_2\nend",
"def sum_of_squares(numbers)\n numbers.map { |x| x * x }.reduce(0) { |acc, x| acc + x }\nend",
"def sum_square_difference(integer)\n (1..integer).reduce(:+)**2 - 1.upto(integer).map { |i| i**2 }.reduce(:+)\nend",
"def sum_square_difference(num)\n sum = 0\n square_sum = 0\n\n 1.upto(num) do |n|\n sum += n\n square_sum += n**2\n end\n\n sum**2 - square_sum\nend",
"def sum_of_squares\n self.inject(0) { |sos, n| sos + n**2 }\n end",
"def p6\n\trange = (1..100).to_a\n\tsquare_of_sum = range.reduce(:+) ** 2\n\tsum_of_square = (range.map{|x| x ** 2}).reduce(:+)\n\tsquare_of_sum - sum_of_square\nend",
"def sum_of_squares values\n values.collect { |v| v**2 }.reduce(:+)\nend",
"def square_of_sums\n return (@n * (@n + 1) / 2)**2\n end",
"def sum_of_squares\n sum(square(sequence))\n end",
"def sums num\n\tsum_of_squares = 0\n\tsum = 0\n\t1.upto num do |n|\n\t\tsum_of_squares += n*n\n\t\tsum += n\n\tend\n\tsum**2 - sum_of_squares \nend",
"def sumSquareDifference( maxValue )\n sumSquares = 0\n sum = 0\n\n Range.new( 1, maxValue ).each do | value |\n sum += value\n sumSquares += value * value\n end\n\n squaresSum = sum * sum\n\n puts squaresSum - sumSquares\nend",
"def sum_of_squares n\n (n**3)/3 + (n**2)/2 + n/6 \nend",
"def sum_of_squares\n return @n * (@n + 1) * (2 * @n + 1) / 6\n end",
"def square_of_sum\n end",
"def square_sum(numbers)\n squares = numbers.map{|number| number * number}\n squares.reduce(0){|num, sum| num + sum}\nend",
"def square_of_sum(vals)\n vals.reduce(:+) ** 2\nend",
"def sum_of_the_squares\n sum = 0\n (1..self).each do |n|\n sum += n**2\n end\n sum\n end",
"def sum_squares(n)\nsums = [] \n for i in (1..n)\n i_squared = i**2\n sums.push i_squared \n end\n p sums.reduce(:+)\nend",
"def sum_of_squares\n range.reduce { |a, e| a + e**2 }\n end",
"def sum_square_difference(integer)\n sum = 0\n square_sum = 0\n 1.upto(integer) { |i| sum += i }\n 1.upto(integer) { |i| square_sum += i**2 }\n sum**2 - square_sum\nend",
"def sum_of_squares\n @number_range.sum {|n| n**2}\n end",
"def square_of_sums\n range.reduce(:+)**2\n end",
"def sum_square_difference(i)\n x = 0 \n sum = 0\n square_sum = 0\n loop do\n x += 1\n sum += x\n square_sum += x**2\n break if x == i \n end\n sum**2-square_sum\nend",
"def squareSum(numbers)\n numbers.map { |n| n*n}.reduce(:+)\nend",
"def squareSum(numbers)\n numbers.map { |n| n*n }.reduce(:+)\nend",
"def sum_of_squares\n @range.sum { |n| n**2 }\n end",
"def squareSum(numbers)\n numbers.reduce(0){|sum, x| sum + (x ** 2)}\nend",
"def cost_of_transformation(magic_square, non_magic_square)\n cost = 0\n (0..2).each do |row|\n (0..2).each do |column|\n magic = magic_square[row][column]\n non_magic = non_magic_square[row][column]\n cost += (non_magic - magic).abs\n end\n end\n return cost\nend",
"def square_sum\n self.inject(0.0){|accum, i| accum +i**2 }\n end",
"def squared_difference(x,y)\n 0.0 + (x-y)**2\n end",
"def squareSum(numbers)\n numbers.map { |i| i ** 2 }.reduce(:+)\nend",
"def sum_of_squares(numbers)\n result = []\n sum = []\n numbers.map do |number|\n result = number*number\n sum.push result\nend\nsum.sum\nend",
"def sum_square_difference(max_num: 100)\n diff = 0\n num_set = (1..max_num).to_a.reverse\n set_sum = num_set.inject(:+)\n until num_set.length == 1\n foo = num_set.pop\n set_sum -= foo\n diff += 2 * foo * set_sum\n end\n puts diff\nend",
"def square_of_sum\n\t\t@n**2*(@n+1)**2/4\n\tend",
"def sum_of_squares(array)\n array.each.map{|num total += num*num}.reduce(:+) #is like fold_left. reduce works on array or collection of enumerables\nend",
"def euler006\n square_of_sum = (1..100).reduce(:+) ** 2\n sum_of_squares = (1..100).inject { |sum, n| sum + n*n }\n\n return square_of_sum - sum_of_squares\nend",
"def square_of_sum(array, proc_square, proc_sum)\n\tproc_square.call(proc_sum.call(array))\nend",
"def squares(a, b)\n diff = (Math.sqrt(b).ceil - Math.sqrt(a).ceil)\n diff = diff + 1 if Math.sqrt(b) % 1 == 0\n # diff = diff + 1 if Math.sqrt(a) % 1 == 0\n return diff\nend",
"def square_of_sum\n\tsquare_of = 0\n\n\t(1..100).each do |x|\n\t\tsquare_of += x\n\tend\n\tsquare_of = square_of**2\n\tsquare_of\nend",
"def square_of_sum (my_array, proc_square, proc_sum)\n sum = proc_sum.call(my_array)\n proc_square.call(sum)\n end",
"def sum_squares_excluding_smallest(*args)\n drop_the_smallest(*args).reduce(0) do |accum, n|\n accum += n * n\n end\nend",
"def squareSum(numbers) \r\n numbers.map{|num| num ** 2}.sum \r\n \r\nend",
"def sum_of_squares(numbers)\n sum = 0;\n\n squared = numbers.map do |x|\n x = x**2\n sum = sum + x\n end\n sum\nend",
"def square_sum(numbers)\n numbers.map! {|num| num ** 2}.inject {|sum, x| sum + x }\nend",
"def sum_of_squares(n)\n sum = 0\n (1..n).each {|i| sum = sum + (i*i)}\n sum\n end",
"def solution(a)\n first_sum = a[0]\n second_sum = a.inject(&:+) - a.first\n result = (first_sum - second_sum).abs\n\n a[1..-2].each do |elem|\n first_sum = first_sum + elem\n second_sum = second_sum - elem\n tmp_result = (first_sum - second_sum).abs\n result = tmp_result if tmp_result < result\n end\n\n result\nend",
"def square_of_sum\n @number_range.sum**2\n end",
"def part_sums(ls)\n array_of_sum = ls.sum\n return_sums = [array_of_sum]\n ls.each do |val|\n array_of_sum -= val\n return_sums << sum\n end\n sums\nend",
"def square_of_sum\n @range.sum**2\n end",
"def sum_of_squares(x)\n sum_of_squares = 0\n (1..x).each do |f|\n sum_of_squares += f**2\n end\n return sum_of_squares\nend",
"def squareSum(numbers)\n numbers.inject(0) { |sum, n| sum + n*n }\nend",
"def sum_times_difference(a, b)\n\nend",
"def sum_of_squares(n)\n sum = 0\n for i in 1..n\n sum+= i*i\n end \n sum\nend",
"def squareSum(numbers)\n\n # Create an empty array to store our sum in\n sum = []\n # Assign our total variable to 0 so we can return this at the end with the\n # sum total\n total = 0\n\n # Iterate through the array given in the argument, squaring each number passed\n # in, and then appending that to our new array sum\n numbers.each do |n|\n sum << (n * n)\n end\n\n # Now that we have our new array with the squared digits, we can iterate through\n # and add each elemtn together to our new variable total.\n sum.each do |el|\n total += el\n end\n\n # Return the total of each squared number from the original array\n total\nend",
"def missing_number_gauss_formula(nums)\n expected_sum = (nums.length * (nums.length + 1))/2\n actual_sum = nums.reduce(:+) # or nums.inject{ |sum, x| sum + x} / nums.inject(:+)\n return expected_sum - actual_sum\nend",
"def square_root_sum\n inject(nil) { |sum, x| sum ? sum + x ** 2 : x ** 2 }\n end"
] | [
"0.88599145",
"0.88599145",
"0.847743",
"0.84173274",
"0.8035531",
"0.7716437",
"0.7547347",
"0.7444694",
"0.7390223",
"0.738993",
"0.73312473",
"0.731875",
"0.7318639",
"0.72615135",
"0.7210095",
"0.71972185",
"0.7183927",
"0.71701443",
"0.7145418",
"0.71305215",
"0.7115464",
"0.7062036",
"0.7061959",
"0.7032273",
"0.7018917",
"0.7003602",
"0.6995263",
"0.6986357",
"0.6952606",
"0.6936943",
"0.68969226",
"0.6888704",
"0.6866202",
"0.68333817",
"0.68277985",
"0.68249184",
"0.675361",
"0.6744175",
"0.67387867",
"0.6738722",
"0.6709925",
"0.6648906",
"0.6605498",
"0.6561393",
"0.6557018",
"0.65535915",
"0.65495706",
"0.65392363",
"0.6518391",
"0.6426803",
"0.6425598",
"0.64213574",
"0.64167017",
"0.6411639",
"0.6408885",
"0.63905716",
"0.6381456",
"0.6351104",
"0.63484275",
"0.6344995",
"0.6308179",
"0.6302514",
"0.6295733",
"0.62902796",
"0.62542075",
"0.62067634",
"0.62032354",
"0.62005764",
"0.61829895",
"0.61740357",
"0.61706567",
"0.61587393",
"0.6136237",
"0.6129393",
"0.61180615",
"0.6089811",
"0.6048858",
"0.6048252",
"0.6024388",
"0.6018195",
"0.59865975",
"0.59744173",
"0.59657633",
"0.59123313",
"0.58896506",
"0.5877522",
"0.58545077",
"0.5846876",
"0.58446646",
"0.58299035",
"0.5824056",
"0.57930386",
"0.57924116",
"0.5792352",
"0.5758723",
"0.57541454",
"0.5747327",
"0.57301617",
"0.57223916",
"0.5691014"
] | 0.88109684 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_atendimento
@atendimento = Atendimento.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 setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\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 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 workflow\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 setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\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 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 action\n end",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\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 before_action \n end",
"def action\n end",
"def setup\n # override this if needed\n end",
"def matt_custom_action_begin(label); 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 setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def lookup_action; 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 around_hooks; end",
"def release_actions; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def action_target()\n \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 setup(&blk)\n @setup_block = blk\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 callback_phase\n super\n end",
"def advice\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def _handle_action_missing(*args); 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",
"def call\n setup_context\n super\n end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end"
] | [
"0.6163443",
"0.604317",
"0.5943409",
"0.59143174",
"0.5887026",
"0.58335453",
"0.57738566",
"0.5701527",
"0.5701527",
"0.56534666",
"0.5618685",
"0.54237175",
"0.5407991",
"0.5407991",
"0.5407991",
"0.5394463",
"0.5376582",
"0.5355932",
"0.53376216",
"0.5337122",
"0.5329516",
"0.5311442",
"0.52963835",
"0.52955836",
"0.5295297",
"0.5258503",
"0.52442217",
"0.5235414",
"0.5235414",
"0.5235414",
"0.5235414",
"0.5235414",
"0.5234908",
"0.5230927",
"0.52263695",
"0.5222485",
"0.5216462",
"0.52128595",
"0.52070963",
"0.520529",
"0.517586",
"0.5174021",
"0.5172379",
"0.5165636",
"0.5161574",
"0.51556087",
"0.5153217",
"0.5152898",
"0.5151238",
"0.5144674",
"0.51387095",
"0.51342636",
"0.5113545",
"0.51131564",
"0.51131564",
"0.5107665",
"0.5107052",
"0.50908124",
"0.5089785",
"0.50814754",
"0.50807786",
"0.5064482",
"0.5053022",
"0.50526255",
"0.5050246",
"0.5050246",
"0.50329554",
"0.5023997",
"0.5021236",
"0.5014815",
"0.5014393",
"0.4999298",
"0.49990913",
"0.4997733",
"0.49884573",
"0.49884573",
"0.49840933",
"0.49786162",
"0.49784446",
"0.49782816",
"0.49659815",
"0.49655175",
"0.4956222",
"0.49543875",
"0.49536037",
"0.495265",
"0.4951427",
"0.49438462",
"0.49436793",
"0.49335384",
"0.49321616",
"0.49264926",
"0.49247074",
"0.49246994",
"0.49226475",
"0.49194494",
"0.49152806",
"0.49149707",
"0.49149227",
"0.49144953",
"0.49141943"
] | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def atendimento_params
params.require(:atendimento).permit(:nr_protocolo, :nm_contato, :tp_retorno, :ds_retorno, :cliente_id, :atendimento_id, :motivo_id, :submotivo_id, :status, :equipamento_id, :rua, :nr_endereco, :bairro, :cidade, :cep, :uf, :lat, :long, :resolucao_id, :dt_fechamento, :obs, :created_by, :updated_by)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def filtered_parameters; end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n 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 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 param_whitelist\n [:rating, :review]\n end",
"def valid_params?; end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def filter_parameters; end",
"def filter_parameters; end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def check_params; true; end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def list_params\n params.permit(:name)\n end",
"def check_params\n true\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n 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 additional_permitted_params\n []\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def allow_params_authentication!; 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 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 person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end",
"def quote_params\n params.permit!\n end",
"def list_params\n params.permit(:list_name)\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def all_params; end",
"def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end",
"def source_params\n params.require(:source).permit(all_allowed_params)\n end",
"def user_params\n end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end",
"def permitted_params\n @wfd_edit_parameters\n end",
"def user_params\r\n end",
"def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend",
"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 valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def params_permit\n params.permit(:id)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def filter_params\n params.permit(*resource_filter_permitted_params)\n end",
"def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end",
"def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def argument_params\n params.require(:argument).permit(:name)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\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 sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def parameters\n nil\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end",
"def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end",
"def normal_params\n reject{|param, val| param_definitions[param][:internal] }\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 special_device_list_params\n params.require(:special_device_list).permit(:name)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end"
] | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.63804525",
"0.6373396",
"0.6360051",
"0.6355191",
"0.62856233",
"0.627813",
"0.62451434",
"0.6228103",
"0.6224965",
"0.6222941",
"0.6210244",
"0.62077755",
"0.61762565",
"0.61711127",
"0.6168448",
"0.6160164",
"0.61446255",
"0.6134175",
"0.6120522",
"0.6106709",
"0.60981655",
"0.6076113",
"0.60534036",
"0.60410434",
"0.6034582",
"0.6029977",
"0.6019861",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.60184896",
"0.60157263",
"0.6005857",
"0.6003803",
"0.60012573",
"0.59955895",
"0.5994598",
"0.5993604",
"0.5983824",
"0.5983166",
"0.5977431",
"0.597591",
"0.5968824",
"0.5965953",
"0.59647584",
"0.59647584",
"0.59566855",
"0.59506303",
"0.5950375",
"0.59485626",
"0.59440875",
"0.5930872",
"0.5930206",
"0.5925668",
"0.59235454",
"0.5917905",
"0.59164816",
"0.5913821",
"0.59128743",
"0.5906617",
"0.59053683",
"0.59052664",
"0.5901591",
"0.58987755",
"0.5897456",
"0.58970183",
"0.58942604"
] | 0.0 | -1 |
GET /ways GET /ways.json | def index
@ways = Way.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ways_using_node(id)\n api_call(id, \"node/#{id}/ways\")\n end",
"def index\n @ways_of_admissions = WaysOfAdmission.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ways_of_admissions }\n end\n end",
"def show\n @ways_of_admission = WaysOfAdmission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @ways_of_admission }\n end\n end",
"def show\n @subway = Subway.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subway }\n end\n end",
"def show\n @railway = Railway.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @railway }\n end\n end",
"def index\n @subways = Subway.all\n end",
"def index\n\n @directions = Direction.all\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @directions }\n format.xml { render :xml => @directions }\n end\n end",
"def index\n @order_ways = OrderWay.all\n end",
"def get_way(id)\n get_object('way', id)\n end",
"def index\n @handover_ways = HandoverWay.all\n end",
"def show\n @road = Road.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @road }\n end\n end",
"def get_way(id)\n @ways[id.to_i]\n end",
"def show\n @way = Way.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @way }\n end\n end",
"def index\n Rails.logger.info('👻 Disraptor: Showing available routes.')\n\n routes = Disraptor::Route.find_all()\n\n render json: { 'disraptor/routes': routes }\n end",
"def index\n @maps = current_user.owned_maps\n respond_with @maps, :include => :waypoints\n end",
"def index\n @directions = Direction.all\n end",
"def route\n hitch = Hitch.find(params[:hitch_id])\n render json: hitch.geojson\n end",
"def index\n @subways = Subway.find(:all, :order => \"day, hour\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @subways }\n end\n end",
"def index\n @recipe_directions = @recipe.directions\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @recipe_directions }\n format.json { render :json => @recipe_directions }\n end\n end",
"def index\n @way_points = WayPoint.all\n end",
"def index\n \n if params[:fly_id]\n @passes = Fly.find(params[:fly_id]).passes\n elsif params[:client_id]\n @passes = Client.find(params[:client_id]).passes\n else\n @passes = Pass.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @passes }\n end\n end",
"def show\n @runway_ap = RunwayAp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @runway_ap }\n end\n end",
"def show\n @medium_road = MediumRoad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medium_road }\n end\n end",
"def index\n @treks = Trek.all\n @title = \"Trekking routes and destinations\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @treks }\n end\n end",
"def show\n @journey = Journey.find(params[:id])\n render json: @journey\n end",
"def getdifficulty\n @api.request 'getdifficulty'\n end",
"def index\r\n @way_points = WayPoint.all\r\n end",
"def index\n @laws = Law.ordered_roots\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @laws }\n end\n end",
"def index\n @sightings = Sighting.all\n render json: @sightings\n end",
"def show\n @route = Route.find(params[:id])\n @driver = Hitchhiker.find(@route.hitchhiker_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @route }\n end\n end",
"def create\n @way = Way.new(way_params)\n\n respond_to do |format|\n if @way.save\n format.html { redirect_to @way, notice: 'Way was successfully created.' }\n format.json { render :show, status: :created, location: @way }\n else\n format.html { render :new }\n format.json { render json: @way.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @goal = Goal.find(params[:id])\n render json: @goal\n end",
"def show\n\n\t\t@ride ||= Ride.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: { ride: @ride.as_json }, :methods => :nearby }\n end\n end",
"def places_kinds\n render json: Place.places_kinds\n end",
"def index\n @ped_strategies = PedStrategy.order(\"hierarchy\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ped_strategies }\n end\n end",
"def show\n @go = Go.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @go }\n end\n end",
"def getdifficulty\n request :getdifficulty\n end",
"def show\n @track = Track.find(params[:id])\n authorize! :show, @track\n gon.track_number = Track.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @track.to_json(:methods => [:polyline],:only => [:name])}\n #format.json { render json: { \"language\" => @languages.as_json(:root => false) }.to_json }\n # render :json => @track.to_json(:methods => [:polyline],:only => [:name])\n end\n end",
"def superhighways\n @client.get('/CycleSuperhighway')\n end",
"def index\n @strategies = Strategy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @strategies }\n end\n end",
"def new\n @ways_of_admission = WaysOfAdmission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @ways_of_admission }\n end\n end",
"def new\n @subway = Subway.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @subway }\n end\n end",
"def show\n @through_reference = ThroughReference.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @through_reference }\n end\n end",
"def ways \n return [] \n end",
"def get\n @get ||= Verb.new do |verb|\n verb.entity :air, :lodging, :car, :rail, :transport, \\\n :cruise, :restaurant, :activity, :note, :map, :directions, \\\n :points_program \\\n do |entity, id|\n do_request('get', entity, {:id=>id}, nil)\n end\n\n verb.entity :profile do |*args|\n entity = args[0]\n do_request('get', entity, nil, nil)\n end\n\n verb.entity :trip do |*args|\n entity, id, filter = args\n if filter.nil?\n filter = {}\n end\n filter[:id] = id\n do_request('get', entity, filter, nil)\n end\n end\n end",
"def index\n @objectives = @goal.objectives.all \n render json: @objectives \n end",
"def show\n @mostsmallroad = Mostsmallroad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mostsmallroad }\n end\n end",
"def index\n render json: @places\n end",
"def routes_list\n response = RestClient.get(\n BASE_URL,\n params: {command: 'routeList', a: AGENCY}\n )\n\n parse_routes_response(response.body)\n end",
"def index\n info = ScheduleProcessor.headway_info\n query = params[:text]\n workspace = params[:enterprise_name] || params[:team_domain]\n user_id = params[:user_id]\n\n if query == 'help'\n result = help_response(info[:routes])\n elsif (data = info[:routes].find { |r| r[:id] == query})\n track_event('slash', \"route/#{query}\", user_id, workspace)\n result = route_response(data)\n elsif query == 'delays'\n track_event('slash', 'delays', user_id, workspace)\n result = delays_response(info[:routes])\n else\n track_event('slash', 'default', user_id, workspace)\n result = default_response(info)\n end\n \n render json: result\n end",
"def show\n @goal = Goal.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end",
"def index\n trips = Trip.all\n render json: trips\n end",
"def index\n @places = @site.places.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @places }\n end\n end",
"def index\n @routes = Route.where(:verified => true)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @routes }\n end\n end",
"def index\n \n @steps = @quest.steps\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps }\n end\n end",
"def show\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end",
"def show\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end",
"def show\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end",
"def show\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end",
"def show\n @hand = Hand.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hand }\n end\n end",
"def show\n @hand = Hand.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hand }\n end\n end",
"def show\n @junction = Junction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @junction }\n end\n end",
"def show\n @destination = Destination.find(params[:id])\n @rentals = @destination.rentals\n\n @json = @destination.to_gmaps4rails\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @destination }\n end\n end",
"def show\n @subway = Subway.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @subway }\n end\n end",
"def show \n @route = Route.find(params[:id])\n \n respond_to do |format|\n format.html \n format.json { render json: @route }\n end\n end",
"def show\n @wanted = Wanted.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @wanted }\n end\n end",
"def routes\n routes = get('/gtfs/routes')\n routes.map do |route|\n Route.from_json(route)\n end\n end",
"def index\n page_number = params[:page] ? params[:page][:number] : 1\n per_page = params[:per_page] ? params[:per_page] : 10\n\n @standings = Standing.paginate(page: page_number, per_page: per_page)\n\n render json: @standings\n end",
"def show\n @goody = Goody.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goody }\n end\n end",
"def index\n @goal_rewards = user.goal_rewards\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @goal_rewards }\n end\n end",
"def index\n @lights = Light.all\n\n render json: @lights\n end",
"def show\n @recipe_direction = @recipe.directions.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @recipe_direction }\n format.json { render :json => @recipe_direction }\n end\n end",
"def show\n @turno = Turno.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @turno }\n end\n end",
"def show\n render json: @ride\n end",
"def show\n render json: @trip\n end",
"def show\n render json: @trip\n end",
"def index\n @roads = Road.all\n end",
"def new\n @railway = Railway.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @railway }\n end\n end",
"def get(path, params={})\n params = merge_set_up_params(params)\n JSON.parse(Typhoeus::Request.get(API_URL + path, :params => params).body)[\"response\"]\n end",
"def show\n walk_ids = params[:id].split(',')\n @walk, *@other_walks = walk_ids.collect { |id| Walk.find( id ) rescue nil }.compact\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @walk }\n end\n end",
"def index\n @ordens = Orden.all\n render json: @ordens\n end",
"def show\n @handicapping_method = HandicappingMethod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @handicapping_method }\n end\n end",
"def index\n @dte_directions = DteDirection.all\n end",
"def test_history_visible\n # check that a visible way is returned properly\n get :history, :id => ways(:visible_way).id\n assert_response :success\n end",
"def index\n @places = Place.all\n\n respond_to do |format|\n format.html\n format.json { render json: @places }\n end\n end",
"def index\n @references = Reference.all\n\n render json: @references\n end",
"def index\n @lophs = Loph.all\n respond_to do |format|\n format.html\n format.json { render json: @lophs}\n end\n end",
"def get_routes\n @agency = params[:name]\n request_url = \"http://services.my511.org/Transit2.0/GetRoutesForAgency.aspx?token=#{@@token}&agencyName=#{@agency}\"\n request_url = request_url.gsub(/ /,\"%20\")\n @routes = search_for_key(parse_request(request_url), \"Route\")\n @routes = [@routes] unless @routes.kind_of?(Array)\n respond_to do |format|\n format.js {}\n end\n end",
"def show\n @witch = Witch.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @witch }\n end\n end",
"def directions(origin, destination)\n directions = []\n\n request = Addressable::URI.new(\n :scheme => \"https\",\n :host => \"maps.googleapis.com\",\n :path => \"maps/api/directions/json\",\n :query_values => {\n :origin => origin.join(','),\n :destination => destination.join(','),\n :sensor => \"false\",\n :mode => \"walking\"\n }\n )\n\n response = RestClient.get(request.to_s)\n\n parsed_response = JSON.parse(response)\n\n parsed_response[\"routes\"][0][\"legs\"][0][\"steps\"].each do |step|\n parsed_html = Nokogiri::HTML(step[\"html_instructions\"])\n directions << parsed_html.text\n end\n\n directions\nend",
"def index\n @economy_hands = EconomyHand.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @economy_hands }\n end\n end",
"def index\n @ideas = Idea.all\n\n render json: @ideas\n end",
"def hours\n render json: Pings::Selector.new.hours(params)\n end",
"def index\n\t\t@rides = if params[:lat] && params[:lng]\n Ride.near([params[:lat], params[:lng]])\n else\n Ride.scoped\n end\n \n if params[:page]\n @rides = @rides.page(params[:page])\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: { rides: @rides.as_json(root: false) } }\n end\n end",
"def index\n # @checkpoints = Checkpoint.all\n @route = Route.find(params[:route_id])\n @checkpoints = @route.checkpoints\n # render json: {\n # checkpoints: @checkpoints.to_a\n # }\n end",
"def get(path, params={})\n params = merge_set_up_params(params)\n @token = \"b3688c52-9235-45ca-b01f-c5b2b83a4f4f\"\n @result = Typhoeus::Request.get(API_URL + path, :params => params,\n :headers => {\"Authorization\" => \"Basic#{@token}\"})\n puts @result.body\n # check if the url looks correct in the log\n puts @result.effective_url\n # parse the result to json\n return JSON.parse(@result.body)\n end",
"def index\n @networkings = Networking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @networkings }\n end\n end",
"def index\n @goals = Goal.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @goals }\n end\n end",
"def show\n render json: @sighting\n end",
"def show\n render json: @truck\n end"
] | [
"0.69018334",
"0.66725165",
"0.664601",
"0.6622051",
"0.65638196",
"0.63588375",
"0.63127786",
"0.6286787",
"0.6250313",
"0.6243861",
"0.6131232",
"0.61146474",
"0.6103763",
"0.6084988",
"0.60843223",
"0.60350144",
"0.6010627",
"0.598401",
"0.59624785",
"0.5940741",
"0.5848657",
"0.5847659",
"0.58271027",
"0.58143294",
"0.5782667",
"0.57796353",
"0.57762456",
"0.5774591",
"0.5722634",
"0.5698093",
"0.5686779",
"0.5684522",
"0.56733155",
"0.56693006",
"0.56607574",
"0.5657086",
"0.56556946",
"0.5655136",
"0.5653051",
"0.5638335",
"0.5628566",
"0.56229466",
"0.560365",
"0.5601821",
"0.5597472",
"0.558984",
"0.55895543",
"0.5585536",
"0.5572112",
"0.5570635",
"0.5565253",
"0.5563666",
"0.55611265",
"0.556068",
"0.5556341",
"0.555363",
"0.555363",
"0.555363",
"0.555363",
"0.55534834",
"0.55534834",
"0.5548337",
"0.5545741",
"0.55403745",
"0.55352044",
"0.5519436",
"0.5512814",
"0.55064726",
"0.55001533",
"0.54959506",
"0.5492582",
"0.5484842",
"0.5482975",
"0.5482027",
"0.5480487",
"0.5480487",
"0.5477409",
"0.5468309",
"0.5457693",
"0.54567933",
"0.54566824",
"0.54564667",
"0.5453897",
"0.54536104",
"0.54531986",
"0.54521525",
"0.5445146",
"0.5444453",
"0.54433614",
"0.54421705",
"0.5440338",
"0.5431571",
"0.54311854",
"0.5430487",
"0.54297584",
"0.54287",
"0.542225",
"0.54210615",
"0.542017",
"0.54163903"
] | 0.71732 | 0 |
GET /ways/1 GET /ways/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @ways = Way.all\n end",
"def show\n @subway = Subway.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subway }\n end\n end",
"def show\n @railway = Railway.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @railway }\n end\n end",
"def get_way(id)\n get_object('way', id)\n end",
"def show\n @ways_of_admission = WaysOfAdmission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @ways_of_admission }\n end\n end",
"def get_ways_using_node(id)\n api_call(id, \"node/#{id}/ways\")\n end",
"def get_way(id)\n @ways[id.to_i]\n end",
"def show\n @way = Way.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @way }\n end\n end",
"def show\n @road = Road.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @road }\n end\n end",
"def index\n @ways_of_admissions = WaysOfAdmission.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ways_of_admissions }\n end\n end",
"def index\n @subways = Subway.all\n end",
"def show\n @medium_road = MediumRoad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medium_road }\n end\n end",
"def show\n @runway_ap = RunwayAp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @runway_ap }\n end\n end",
"def index\n @order_ways = OrderWay.all\n end",
"def show\n @goal = Goal.find(params[:id])\n render json: @goal\n end",
"def show\n @go = Go.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @go }\n end\n end",
"def index\n\n @directions = Direction.all\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @directions }\n format.xml { render :xml => @directions }\n end\n end",
"def getdifficulty\n @api.request 'getdifficulty'\n end",
"def new\n @subway = Subway.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @subway }\n end\n end",
"def show\n @mostsmallroad = Mostsmallroad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mostsmallroad }\n end\n end",
"def index\n @handover_ways = HandoverWay.all\n end",
"def create\n @way = Way.new(way_params)\n\n respond_to do |format|\n if @way.save\n format.html { redirect_to @way, notice: 'Way was successfully created.' }\n format.json { render :show, status: :created, location: @way }\n else\n format.html { render :new }\n format.json { render json: @way.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @route = Route.find(params[:id])\n @driver = Hitchhiker.find(@route.hitchhiker_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @route }\n end\n end",
"def show\n @journey = Journey.find(params[:id])\n render json: @journey\n end",
"def show\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end",
"def show\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end",
"def show\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end",
"def show\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end",
"def show\n @goal = Goal.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal }\n end\n end",
"def show\n @recipe_direction = @recipe.directions.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @recipe_direction }\n format.json { render :json => @recipe_direction }\n end\n end",
"def route\n hitch = Hitch.find(params[:hitch_id])\n render json: hitch.geojson\n end",
"def index\n @recipe_directions = @recipe.directions\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @recipe_directions }\n format.json { render :json => @recipe_directions }\n end\n end",
"def getdifficulty\n request :getdifficulty\n end",
"def show\n @subway = Subway.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @subway }\n end\n end",
"def show\n @junction = Junction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @junction }\n end\n end",
"def show\n @through_reference = ThroughReference.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @through_reference }\n end\n end",
"def new\n @ways_of_admission = WaysOfAdmission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @ways_of_admission }\n end\n end",
"def show\n @track = Track.find(params[:id])\n authorize! :show, @track\n gon.track_number = Track.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @track.to_json(:methods => [:polyline],:only => [:name])}\n #format.json { render json: { \"language\" => @languages.as_json(:root => false) }.to_json }\n # render :json => @track.to_json(:methods => [:polyline],:only => [:name])\n end\n end",
"def show \n @route = Route.find(params[:id])\n \n respond_to do |format|\n format.html \n format.json { render json: @route }\n end\n end",
"def new\n @way = Way.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @way }\n end\n end",
"def show\n @handicapping_method = HandicappingMethod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @handicapping_method }\n end\n end",
"def show\n @mini_map_road = MiniMapRoad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mini_map_road }\n end\n end",
"def new\n @railway = Railway.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @railway }\n end\n end",
"def show\n @goat = Goat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goat }\n end\n end",
"def show\n @hand = Hand.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hand }\n end\n end",
"def show\n @hand = Hand.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hand }\n end\n end",
"def show\n @broad = Broad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @broad }\n end\n end",
"def show\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trip }\n end\n end",
"def show\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trip }\n end\n end",
"def show\n @turno = Turno.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @turno }\n end\n end",
"def show\n goal = Goal.find(params[:id])\n render json: goal,status: :ok\n end",
"def index\n @subways = Subway.find(:all, :order => \"day, hour\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @subways }\n end\n end",
"def index\n @way_points = WayPoint.all\n end",
"def show\n @lei = Lei.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lei }\n end\n end",
"def show\n @level_goal = LevelGoal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @level_goal }\n end\n end",
"def show\n\n\t\t@ride ||= Ride.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: { ride: @ride.as_json }, :methods => :nearby }\n end\n end",
"def show\n @goody = Goody.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goody }\n end\n end",
"def get\n @get ||= Verb.new do |verb|\n verb.entity :air, :lodging, :car, :rail, :transport, \\\n :cruise, :restaurant, :activity, :note, :map, :directions, \\\n :points_program \\\n do |entity, id|\n do_request('get', entity, {:id=>id}, nil)\n end\n\n verb.entity :profile do |*args|\n entity = args[0]\n do_request('get', entity, nil, nil)\n end\n\n verb.entity :trip do |*args|\n entity, id, filter = args\n if filter.nil?\n filter = {}\n end\n filter[:id] = id\n do_request('get', entity, filter, nil)\n end\n end\n end",
"def set_way\n @way = Way.find(params[:id])\n end",
"def show\n @trek = Trek.find(params[:id])\n @title = \"#{@trek.title} route\"\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trek }\n end\n end",
"def show\n @witch = Witch.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @witch }\n end\n end",
"def index\n @directions = Direction.all\n end",
"def show\n @tower = Tower.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @tower }\n end\n end",
"def show\n @route = Route.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @route }\n end\n end",
"def show\n @guide = Guide.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @guide.as_json(:root => true) }\n end\n end",
"def test_history_visible\n # check that a visible way is returned properly\n get :history, :id => ways(:visible_way).id\n assert_response :success\n end",
"def show\n @optician = Optician.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @optician }\n end\n end",
"def show\n @rayon = Rayon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rayon }\n end\n end",
"def index\n \n if params[:fly_id]\n @passes = Fly.find(params[:fly_id]).passes\n elsif params[:client_id]\n @passes = Client.find(params[:client_id]).passes\n else\n @passes = Pass.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @passes }\n end\n end",
"def show\n @control_tower = ControlTower.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @control_tower }\n end\n end",
"def show\n @wanted = Wanted.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @wanted }\n end\n end",
"def show\n @gopy = Gopy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gopy }\n end\n end",
"def show\n @house = House.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @house }\n end\n end",
"def show\n @house = House.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @house }\n end\n end",
"def show\n @house = House.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @house }\n end\n end",
"def show\n @route = Route.find(params[:id])\n\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @route }\n end\n end",
"def show\n @kind = Kind.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kind }\n end\n end",
"def show\n @plate = Plate.find(params[:id])\n\n render json: @plate\n end",
"def show\n walk_ids = params[:id].split(',')\n @walk, *@other_walks = walk_ids.collect { |id| Walk.find( id ) rescue nil }.compact\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @walk }\n end\n end",
"def show\n render json: @ride\n end",
"def show\n @prefer = Prefer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @prefer }\n end\n end",
"def show\n @hotele = Hotele.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hotele }\n end\n end",
"def show\n @trip_driver = TripDriver.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trip_driver }\n end\n end",
"def show\n @goal_state = GoalState.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal_state }\n end\n end",
"def show\n @click_thru = ClickThru.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @click_thru }\n end\n end",
"def show\n @trail = Trail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trail }\n end\n end",
"def show\n @trail = Trail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trail }\n end\n end",
"def index\r\n @way_points = WayPoint.all\r\n end",
"def show\n @type = Type.find(params[:id])\n @things = @type.things\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @type }\n end\n end",
"def difficulty\n request('getdifficulty')\n end",
"def show\n @hackplatformrelation = Hackplatformrelation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @hackplatformrelation }\n end\n end",
"def show\n @webling = Webling.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @webling }\n end\n end",
"def show\n @go_term = GoTerm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @go_term }\n end\n end",
"def show\n @orthodb_level = OrthodbLevel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @orthodb_level }\n end\n end",
"def show\n @solution = @idea.solutions.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @solution }\n end\n end",
"def show\n @traffic = Traffic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @traffic }\n end\n end",
"def show\n @genotype = Genotype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @genotype }\n end\n end",
"def show\n @kitchen = Kitchen.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kitchen }\n end\n end",
"def show\n @gpath = Gpath.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gpath }\n end\n end",
"def show\n @roadcrime = Roadcrime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @roadcrime }\n end\n end",
"def get(path, params={})\n params = merge_set_up_params(params)\n JSON.parse(Typhoeus::Request.get(API_URL + path, :params => params).body)[\"response\"]\n end"
] | [
"0.69644386",
"0.68596375",
"0.6820406",
"0.6747265",
"0.67084944",
"0.664971",
"0.6613311",
"0.6463421",
"0.6420012",
"0.6353054",
"0.6175955",
"0.6164993",
"0.6103839",
"0.6012172",
"0.6005579",
"0.5953195",
"0.5948694",
"0.5923862",
"0.5913849",
"0.5913074",
"0.5909131",
"0.59080005",
"0.59042466",
"0.5904023",
"0.5891569",
"0.5891569",
"0.5891569",
"0.5891569",
"0.5889551",
"0.58879244",
"0.5883952",
"0.5881758",
"0.5865893",
"0.5865885",
"0.5849495",
"0.5829538",
"0.58027434",
"0.57926786",
"0.5791537",
"0.5789646",
"0.5782371",
"0.57697666",
"0.57602155",
"0.5754436",
"0.57462114",
"0.57462114",
"0.57454824",
"0.57370704",
"0.57370704",
"0.5735485",
"0.5733877",
"0.57253194",
"0.57093436",
"0.5708149",
"0.57004327",
"0.56988144",
"0.56714565",
"0.5657907",
"0.5654966",
"0.56515354",
"0.5639568",
"0.5634219",
"0.56333953",
"0.5630946",
"0.5626912",
"0.5620898",
"0.5617359",
"0.5613719",
"0.5603159",
"0.55903393",
"0.5588001",
"0.5587901",
"0.55804634",
"0.55804634",
"0.55804634",
"0.55782694",
"0.55710846",
"0.55690336",
"0.5565165",
"0.55612487",
"0.5559383",
"0.5547202",
"0.55456984",
"0.5542532",
"0.5541923",
"0.5537443",
"0.5537443",
"0.55344355",
"0.5531662",
"0.55307835",
"0.5526271",
"0.5522805",
"0.5521374",
"0.5521055",
"0.5519458",
"0.551923",
"0.55163276",
"0.55153394",
"0.55142707",
"0.55138844",
"0.5512367"
] | 0.0 | -1 |
POST /ways POST /ways.json | def create
@way = Way.new(way_params)
respond_to do |format|
if @way.save
format.html { redirect_to @way, notice: 'Way was successfully created.' }
format.json { render :show, status: :created, location: @way }
else
format.html { render :new }
format.json { render json: @way.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @order_way = OrderWay.new(order_way_params)\n\n respond_to do |format|\n if @order_way.save\n format.html { redirect_to @order_way, notice: 'Order way was successfully created.' }\n format.json { render :show, status: :created, location: @order_way }\n else\n format.html { render :new }\n format.json { render json: @order_way.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @way = Way.new(params[:way])\n\n respond_to do |format|\n if @way.save\n format.html { redirect_to(@way, :notice => 'Way was successfully created.') }\n format.xml { render :xml => @way, :status => :created, :location => @way }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @way.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @subway = Subway.new(params[:subway])\n\n respond_to do |format|\n if @subway.save\n format.html { redirect_to @subway, notice: 'Subway was successfully created.' }\n format.json { render json: @subway, status: :created, location: @subway }\n else\n format.html { render action: \"new\" }\n format.json { render json: @subway.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @handover_way = HandoverWay.new(handover_way_params)\n\n respond_to do |format|\n if @handover_way.save\n format.html { redirect_to @handover_way, notice: 'Handover way was successfully created.' }\n format.json { render :show, status: :created, location: @handover_way }\n else\n format.html { render :new }\n format.json { render json: @handover_way.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @subway = Subway.new(subway_params)\n\n respond_to do |format|\n if @subway.save\n format.html { redirect_to @subway, notice: 'Subway was successfully created.' }\n format.json { render action: 'show', status: :created, location: @subway }\n else\n format.html { render action: 'new' }\n format.json { render json: @subway.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @railway = Railway.new(params[:railway])\n\n respond_to do |format|\n if @railway.save\n format.html { redirect_to @railway, notice: 'Railway was successfully created.' }\n format.json { render json: @railway, status: :created, location: @railway }\n else\n format.html { render action: \"new\" }\n format.json { render json: @railway.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ways_of_admission = WaysOfAdmission.new(params[:ways_of_admission])\n\n respond_to do |format|\n if @ways_of_admission.save\n format.html { redirect_to @ways_of_admission, :notice => 'Ways of admission was successfully created.' }\n format.json { render :json => @ways_of_admission, :status => :created, :location => @ways_of_admission }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @ways_of_admission.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def way_params\n params.require(:way).permit(:vertices_list, :edges_list, :total_distance, :total_time)\n end",
"def create\n # @route = Route.new(params[:route])\n \n waypoints = params[:waypoints]\n creator = params[:creator]\n updated_at = params[:updated_at]\n name = params[:name]\n\n @route = Route.new(waypoints: waypoints, creator: creator, updated_at: updated_at, name: name)\n \n @route.save\n\n render json: @route\n\n # @vote_creator = VoteCreator.new(vote_params)\n # @vote = @vote_creator.vote\n # if @vote_creator.save\n # render json: @vote, status: :created, location: @vote\n # else\n # render json: @vote.errors, status: :unprocessable_entity\n # end\n end",
"def create\n @subway = Subway.new(params[:subway])\n\n respond_to do |format|\n if @subway.save\n format.html { redirect_to(@subway, :notice => 'Subway was successfully created.') }\n format.xml { render :xml => @subway, :status => :created, :location => @subway }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @subway.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_route(route, message)\n raise TypeError unless route.is_a? Route\n @changeset = @api.create_changeset(message, tags={'created_by'=>'ITCR'})\n ways_list = []\n nodes_list = create_node_list(route.path)\n\n until nodes_list.empty? # For node's maximum limit of a way\n way_nodes = nodes_list.take(MAX_NODES)\n nodes_list = nodes_list.drop(MAX_NODES)\n way_id = create_way(way_nodes)\n ways_list << way_id\n end\n\n relation = create_relation(ways_list) # Link ways to relation\n relation = add_stops(relation, route.stops) # Add bus stops to relation\n\n @api.save(relation, @changeset) # Save relation using the API\n puts 'Relation created succesfuly.'\n @api.close_changeset(@changeset)\n @changeset.id\n end",
"def create\r\n @way_point = WayPoint.new(way_point_params)\r\n respond_to do |format|\r\n if @way_point.save\r\n format.html { redirect_to my_maps_path, notice: 'Way point was successfully created.' }\r\n format.json { render action: 'show', status: :created, location: @way_point }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @way_point.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @road = Road.new(params[:road])\n\n respond_to do |format|\n if @road.save\n format.html { redirect_to @road, notice: 'Road was successfully created.' }\n format.json { render json: @road, status: :created, location: @road }\n else\n format.html { render action: \"new\" }\n format.json { render json: @road.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_pathway\n pathway_name = params[:name]\n pathway_data = params[:data]\n pathway_year = params[:year]\n pathway_course = params[:course]\n current_user.pathways << Pathway.create(name: pathway_name, data: pathway_data, year: pathway_year, course_id: pathway_course)\n end",
"def create\n @medium_road = MediumRoad.new(params[:medium_road])\n\n respond_to do |format|\n if @medium_road.save\n format.html { redirect_to @medium_road, notice: 'Medium road was successfully created.' }\n format.json { render json: @medium_road, status: :created, location: @medium_road }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medium_road.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pathway = @project.ae_team_pathways.where(ae_team: @team).new(pathway_params)\n if @pathway.save\n redirect_to editor_project_ae_team_ae_pathway_path(\n @project, @team, @pathway\n ), notice: \"Pathway was successfully created.\"\n else\n render :new\n end\n end",
"def create_way(nodes_list)\n puts 'Creating Way...'\n way = Rosemary::Way.new\n nodes_list.each do |id|\n way << Rosemary::Node.new(id: id)\n end\n way.add_tags(highway: 'unclassified')\n @api.save(way, @changeset)\n end",
"def index\n @ways = Way.all\n end",
"def create\n @runway_ap = RunwayAp.new(params[:runway_ap])\n\n respond_to do |format|\n if @runway_ap.save\n format.html { redirect_to @runway_ap, notice: 'Runway ap was successfully created.' }\n format.json { render json: @runway_ap, status: :created, location: @runway_ap }\n else\n format.html { render action: \"new\" }\n format.json { render json: @runway_ap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def handover_way_params\n params.require(:handover_way).permit(:name)\n end",
"def create\n @road = Road.new(road_params)\n\n respond_to do |format|\n if @road.save\n format.html { redirect_to @road, notice: 'Road was successfully created.' }\n format.json { render :show, status: :created, location: @road }\n else\n format.html { render :new }\n format.json { render json: @road.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @ways_of_admission = WaysOfAdmission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @ways_of_admission }\n end\n end",
"def create\n @walk = Walk.new(params[:walk])\n\n respond_to do |format|\n if @walk.save\n format.html { redirect_to @walk, notice: 'Walk was successfully created.' }\n format.json { render json: @walk, status: :created, location: @walk }\n else\n format.html { render action: \"new\" }\n format.json { render json: @walk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @direction = Direction.new(direction_params)\n @direction.origin = Place.find_by(name: 'AIT')\n @direction.created_by = current_user\n respond_to do |format|\n if @direction.save\n format.html { redirect_to service_path, notice: 'direction was successfully created. You can manage your directions via Account > Manage your account'}\n format.json { render :show, status: :created, location: [:service, @direction] }\n else\n format.html { render :new }\n format.json { render json: @direction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def dial_road dials={}\n raise \"Set exactly two dials.\" if dials.keys.size != 2\n\n # convert to proper timestamp\n unless dials[\"goaldate\"].nil?\n dials[\"goaldate\"] = @user.convert_to_timezone dials[\"goaldate\"] if @user.enforce_timezone?\n dials[\"goaldate\"] = dials[\"goaldate\"].strftime('%s')\n end\n \n @user.post \"users/me/goals/#{@slug}/dial_road.json\", dials\n end",
"def get_ways_using_node(id)\n api_call(id, \"node/#{id}/ways\")\n end",
"def new\n @subway = Subway.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @subway }\n end\n end",
"def create\n @side_walk = SideWalk.new(side_walk_params)\n\n respond_to do |format|\n if @side_walk.save\n format.html { redirect_to @side_walk, notice: 'Side walk was successfully created.' }\n format.json { render :show, status: :created, location: @side_walk }\n else\n format.html { render :new }\n format.json { render json: @side_walk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trip_waypoint = TripWaypoint.new\n @trip_waypoint.place_id = params[:place_id]\n @trip_waypoint.trip_id = params[:trip_id]\n @trip_waypoint.save\n\n respond_to do |format|\n if @trip_waypoint.save\n format.html { redirect_to edit_partner_trip_path(params[:trip_id]), notice: \"Le lieu a été ajouté à l'itinéraire\" }\n # format.json { render :show, status: :created, location: @trip_waypoint }\n else\n format.html { render :new }\n # format.json { render json: @trip_waypoint.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n if params[:journey_id]\n @journey = Journey.find(params[:journey_id])\n render_403 and return if @journey.user_id != current_user.id\n else\n @journey = Journey.create(user_id: current_user.id)\n end\n\n @url = \"/journeys/#{@journey.id}/legs\"\n @method = :POST\n @journey_leg = JourneyLeg.new(journey_leg_params.merge(journey_id: @journey.id))\n\n respond_to do |format|\n if @journey_leg.save\n format.html { redirect_to @journey, notice: 'Journey leg was successfully created.' }\n format.json { render json: @journey, status: :created, location: @journey }\n format.xml { render xml: @journey, status: :created, location: @journey }\n else\n format.html { render action: \"new\" }\n format.json { render json: @journey_leg.errors, status: :unprocessable_entity }\n format.xml { render xml: @journey_leg.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trip = Trip.new(trip_params)\n\n respond_to do |format|\n if @trip.save\n # Get the permission's type which represent an usual user and an admin one.\n permUser = Permission_type.find_by(permission: \"user\").id\n permAdmin = Permission_type.find_by(permission: \"admin\").id\n\n # Create current user's admin permission on the new created trip.\n adminPerm = Permission.new(:user_id => current_user.id, :trip_id => @trip.id, :permission_type_id => permAdmin, :accepted => 1)\n adminPerm.save\n # Create a \"user\" permission for each selected users.\n if params[\"users\"]\n params[\"users\"].each do |user|\n userId = user[2, user.length]\n\n # We don't add the current user, which is an admin.\n if userId != String(current_user.id)\n currentPermission = user[0] == \"1\" ? permAdmin : permUser\n\n perm = Permission.new(:user_id => userId, :trip_id => @trip.id, :permission_type_id => currentPermission, :accepted => 0)\n perm.save\n end\n end\n end\n\n # Create each waypoint of the trip.\n if params['waypoints']\n i = 0\n params['waypoints'].each do |waypoint|\n i += 1\n w = Stop.new(:title => @trip.title + \" - #{i}\", :loc_lat => waypoint[1][0], :loc_lon => waypoint[1][1], :trip_id => @trip.id, :etape_nb => i)\n w.save\n end\n\n # If the endpoint is also the startpoint, add an extra stop.\n if params['arrivalEqualsStart']\n w = Stop.new(:title => @trip.title + \" - #{i + 1}\", :loc_lat => params[\"waypoints\"][\"0\"][0], :loc_lon => params[\"waypoints\"][\"0\"][1], :trip_id => @trip.id, :etape_nb => (i + 1))\n w.save\n end\n end\n\n format.html { redirect_to @trip, notice: 'Trip was successfully created.' }\n format.json { render :show, status: :created, location: @trip }\n else\n format.html { render :new }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @railway = Railway.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @railway }\n end\n end",
"def create\n @raiway_station = RaiwayStation.new(raiway_station_params)\n\n respond_to do |format|\n if @raiway_station.save\n format.html { redirect_to @raiway_station, notice: 'Raiway station was successfully created.' }\n format.json { render :show, status: :created, location: @raiway_station }\n else\n format.html { render :new }\n format.json { render json: @raiway_station.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @routing = Routing.new(params[:routing])\n if @routing.save\n redirect_to routings_path\n end\n end",
"def create\n @dte_direction = DteDirection.new(dte_direction_params)\n\n respond_to do |format|\n if @dte_direction.save\n format.html { redirect_to @dte_direction, notice: 'Dte direction was successfully created.' }\n format.json { render :show, status: :created, location: @dte_direction }\n else\n format.html { render :new }\n format.json { render json: @dte_direction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def order_way_params\n params.require(:order_way).permit(:name)\n end",
"def create\n @roadmap = Roadmap.find(params[:roadmap_id])\n @roadmap_step = @roadmap.roadmap_steps.create(roadmap_step_params)\n #@roadmap_step = RoadmapStep.new(roadmap_step_params)\n\n respond_to do |format|\n if @roadmap_step.save\n format.html { redirect_to @roadmap, notice: 'Roadmap step was successfully created.' }\n format.json { render :show, status: :created, location: @roadmap_step }\n else\n format.html { render :new }\n format.json { render json: @roadmap_step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @railway_station = RailwayStation.new(railway_station_params)\n\n respond_to do |format|\n if @railway_station.save\n format.html { redirect_to [:admin, @railway_station], notice: I18n.t('notices.railway_station_created') }\n format.json { render :show, status: :created, location: @railway_station }\n else\n format.html { render :new }\n format.json { render json: @railway_station.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @wizard = @house.wizards.new(wizard_params)\n respond_to do |format| \n if @wizard.save\n format.html { redirect_to house_wizard_path(@house, @wizard), notice: 'Wizard was successfully created.' }\n format.json { render :show, status: :created, location: @wizard }\n else\n format.html { render :new }\n format.json { render json: @wizard.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @direction = Direction.new(direction_params)\n authorize @direction.recipe, :update?\n respond_to do |format|\n if @direction.save\n format.html { redirect_to @direction.recipe }\n format.json { render :show, status: :created, location: @direction.recipe }\n else\n format.html { render :new }\n format.json { render json: @direction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_way\n @way = Way.find(params[:id])\n end",
"def create\n @wanted = Wanted.new(params[:wanted])\n\n respond_to do |format|\n if @wanted.save\n format.html { redirect_to @wanted, notice: 'Wanted was successfully created.' }\n format.json { render json: @wanted, status: :created, location: @wanted }\n else\n format.html { render action: \"new\" }\n format.json { render json: @wanted.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @qx_runway = Qx::Runway.new(qx_runway_params)\n\n respond_to do |format|\n if @qx_runway.save\n format.html { redirect_to @qx_runway, notice: 'Runway was successfully created.' }\n format.json { render :show, status: :created, location: @qx_runway }\n else\n format.html { render :new }\n format.json { render json: @qx_runway.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sighting = Sighting.new(sighting_params)\n\n if @sighting.save\n render json: @sighting, status: :created, location: @sighting\n else\n render json: @sighting.errors, status: :unprocessable_entity\n end\n end",
"def create\n @handicapping_method = HandicappingMethod.new(params[:handicapping_method])\n\n respond_to do |format|\n if @handicapping_method.save\n format.html { redirect_to @handicapping_method, notice: 'Handicapping method was successfully created.' }\n format.json { render json: @handicapping_method, status: :created, location: @handicapping_method }\n else\n format.html { render action: \"new\" }\n format.json { render json: @handicapping_method.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n runway = qx_take_off_params[:runway].split(\"/\")\n runway.each do |item|\n qx_take_off_params[:runway_id] = Qx::Runway.get_runay_id(qx_take_off_params[:airport_id], item)\n @qx_take_off = Qx::TakeOff.new(qx_take_off_params)\n end\n\n\n p runway\n\n respond_to do |format|\n if @qx_take_off.save\n format.html { redirect_to @qx_take_off, notice: 'Take off was successfully created.' }\n format.json { render :show, status: :created, location: @qx_take_off }\n else\n format.html { render :new }\n format.json { render json: @qx_take_off.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @pathway = @team.ae_team_pathways.new\n end",
"def create\n @hand_analytic = HandAnalytic.new(hand_analytic_params)\n\n respond_to do |format|\n if @hand_analytic.save\n format.html { redirect_to @hand_analytic, notice: 'Hand analytic was successfully created.' }\n format.json { render action: 'show', status: :created, location: @hand_analytic }\n else\n format.html { render action: 'new' }\n format.json { render json: @hand_analytic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @ways_of_admissions = WaysOfAdmission.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ways_of_admissions }\n end\n end",
"def create\n @sighting = Sighting.new(sighting_params)\n\n if @sighting.save\n render json: @sighting, status: :created, location: @sighting\n else\n render json: @sighting.errors, status: :unprocessable_entity\n end\n end",
"def create\n quests_params = params.permit(quests: [:mission, :pose, :location])[:quests]\n quests = quests_params.map {|quest_params|\n Quest.new(quest_params)\n }\n\n route_params = params.permit(\n :name,\n :achievement_count,\n :played_count,\n :start_location,\n :description\n )\n\n @route = Route.new({\n user_id: params[:user][:id],\n # user_id: 1,\n quests: quests,\n }.merge(route_params))\n\n respond_to do |format|\n if @route.save\n format.html { redirect_to @route, notice: 'Route was successfully created.' }\n format.json { render action: 'show', status: :created, location: @route }\n else\n format.html { render action: 'new' }\n format.json { render json: @route.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mostsmallroad = Mostsmallroad.new(params[:mostsmallroad])\n\n respond_to do |format|\n if @mostsmallroad.save\n format.html { redirect_to @mostsmallroad, notice: 'Mostsmallroad was successfully created.' }\n format.json { render json: @mostsmallroad, status: :created, location: @mostsmallroad }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mostsmallroad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @todoroute = Todoroute.new(todoroute_params)\n\n respond_to do |format|\n if @todoroute.save\n format.html { redirect_to @todoroute, notice: 'Todoroute was successfully created.' }\n format.json { render :show, status: :created, location: @todoroute }\n else\n format.html { render :new }\n format.json { render json: @todoroute.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @guide_trip = GuideTrip.new(guide_trip_params)\n\n respond_to do |format|\n if @guide_trip.save\n format.html { redirect_to @guide_trip, notice: 'Guía turístico fue creado satisfactoriamente.' }\n format.json { render :show, status: :created, location: @guide_trip }\n else\n format.html { render :new }\n format.json { render json: @guide_trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @goal = @todo.goals.create(goal_params)\n render json: @goal\n end",
"def create\n @waypoint = Waypoint.new(params[:waypoint])\n\n respond_to do |format|\n if @waypoint.save\n flash[:notice] = 'Waypoint was successfully created.'\n format.html { redirect_to(@waypoint) }\n format.xml { render :xml => @waypoint, :status => :created, :location => @waypoint }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @waypoint.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @way = Way.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @way }\n end\n end",
"def create\n @hand = Hand.new(params[:hand])\n\n respond_to do |format|\n if @hand.save\n format.html { redirect_to @hand, notice: 'Hand was successfully created.' }\n format.json { render json: @hand, status: :created, location: @hand }\n else\n format.html { render action: \"new\" }\n format.json { render json: @hand.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @wagon = Wagon.new(wagon_params)\n\n respond_to do |format|\n if @wagon.save\n format.html { redirect_to wagons_path, notice: 'Wagon was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def create\n @walk_request = WalkRequest.new(walk_request_params)\n\n respond_to do |format|\n if @walk_request.save\n format.html { redirect_to @walk_request, notice: 'walk request was successfully created.' }\n format.json { render :show, status: :created, location: @walk_request }\n else\n format.html { render :new }\n format.json { render json: @walk_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n trip = Trip.create(trip_params)\n\n respond_with trip\n end",
"def create\n @plate = Plate.new(params[:plate])\n\n if @plate.save\n render json: @plate, status: :created, location: @plate\n else\n render json: @plate.errors, status: :unprocessable_entity\n end\n end",
"def create\n @roadwork = Roadwork.new(roadwork_params)\n\n respond_to do |format|\n if @roadwork.save\n format.html { redirect_to @roadwork, notice: 'Roadwork was successfully created.' }\n format.json { render :show, status: :created, location: @roadwork }\n else\n format.html { render :new }\n format.json { render json: @roadwork.errors, status: :unprocessable_entity }\n end\n end\n end",
"def json_post\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n puts \"json_post: submitting #{params[:path]}\" if @@debug\n path = params[:path]\n if path\n puts \"json_post: path is #{path} l=#{path.length}\" if @@debug\n path = path.split('/').compact()\n path.delete('')\n # you cannot make rooted nodes via json atm... fix? xxx\n if path.length > 1\n name = path.pop\n nodes = Note.make_path @user,path\n puts \"json_post: making at path #{path.join('/')}\" if @@debug\n if nodes\n note = nodes.last.make_child @user,params,name\n puts \"json_post: made child #{note} from #{name} l=#{name.length}\"\n params[:path] = path.join('/') # for call to json_query\n # it is important to do a query rather than returning the note; to get freshest order\n json_query\n return\n #write_json note if note\n end\n end\n end\n render :nothing => true\n end",
"def create\n @trip = Trip.new(params[:trip])\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip, :notice => 'Trip was successfully created.' }\n format.json { render :json => @trip, :status => :created, :location => @trip }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @trip.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @trip_route = TripRoute.new(trip_route_params)\n\n respond_to do |format|\n if @trip_route.save\n format.html { redirect_to @trip_route, notice: 'Trip route was successfully created.' }\n format.json { render :show, status: :created, location: @trip_route }\n else\n format.html { render :new }\n format.json { render json: @trip_route.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recipe_direction = @recipe.directions.new(params[:recipe_direction])\n\n respond_to do |format|\n if @recipe_direction.save\n format.html { redirect_to([@recipe,@recipe_direction], :notice => 'Recipe direction was successfully created.') }\n format.xml { render :xml => @recipe_direction, :status => :created, :location => [@recipe, @recipe_direction] }\n format.json { render :json => @recipe_direction, :status => :created, :location => [@recipe, @recipe_direction] }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @recipe_direction.errors, :status => :unprocessable_entity }\n format.json { render :json => @recipe_direction.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @ward = Ward.new(ward_params)\n\n respond_to do |format|\n if @ward.save\n format.html { redirect_to @ward, notice: 'Ward was successfully created.' }\n format.json { render :show, status: :created, location: @ward }\n else\n format.html { render :new }\n format.json { render json: @ward.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @junction = Junction.new(params[:junction])\n\n respond_to do |format|\n if @junction.save\n format.html { redirect_to @junction, notice: 'Junction was successfully created.' }\n format.json { render json: @junction, status: :created, location: @junction }\n else\n format.html { render action: \"new\" }\n format.json { render json: @junction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def route_params\n params.require(:route).permit(:name, railway_station_ids: [])\n end",
"def create\n @moonwalk = Moonwalk.new(moonwalk_params)\n\n respond_to do |format|\n if @moonwalk.save\n format.html { redirect_to @moonwalk, notice: 'Moonwalk was successfully created.' }\n format.json { render action: 'show', status: :created, location: @moonwalk }\n else\n format.html { render action: 'new' }\n format.json { render json: @moonwalk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @through_reference = ThroughReference.new(params[:through_reference])\n\n respond_to do |format|\n if @through_reference.save\n format.html { redirect_to @through_reference, notice: 'Through reference was successfully created.' }\n format.json { render json: @through_reference, status: :created, location: @through_reference }\n else\n format.html { render action: \"new\" }\n format.json { render json: @through_reference.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @hand = Hand.new(hand_params)\n\n respond_to do |format|\n if @hand.save\n format.html { redirect_to @hand, notice: 'Hand was successfully created.' }\n format.json { render action: 'show', status: :created, location: @hand }\n else\n format.html { render action: 'new' }\n format.json { render json: @hand.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @journey = Journey.new(journey_params)\n \n respond_to do |format|\n if @journey.save\n format.html { redirect_to @journey, notice: 'Journey was successfully created.' }\n format.json { render :show, status: :created, location: @journey }\n else\n format.html { render :new }\n format.json { render json: @journey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trip = Trip.new(user_id: params[:user_id], trip_name: params[:trip_name], distance: params[:distance], walked_at: Time.now)\n @origin = Place.new(user_id: params[:user_id], place_name: params[:origin_name], latitude: params[:origin_lat], longitude: params[:origin_long])\n @destination = Place.new(user_id: params[:user_id], place_name: params[:dest_name], latitude: params[:dest_lat], longitude: params[:dest_long])\n if @trip.save && @origin.save && @destination.save\n @origin_point = TripPoint.new(trip_id: @trip.id, place_id: @origin.id, place_type: \"Origin\")\n @destination_point = TripPoint.new(trip_id: @trip.id, place_id: @destination.id, place_type: \"Destination\")\n @origin_point.save\n @destination_point.save\n else\n render :json => {:success => false, :errors => [\"Trip creation failed.\"]}\n end\n end",
"def create\n @nap = Nap.new(nap_params)\n\n respond_to do |format|\n if @nap.save\n format.html { redirect_to @nap, notice: 'Nap was successfully created.' }\n format.json { render :show, status: :created, location: @nap }\n else\n format.html { render :new }\n format.json { render json: @nap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trip = Trip.new(trip_params)\n @trip.nomad_id = current_nomad.id\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip, notice: 'Trip was successfully created.' }\n format.json { render :show, status: :created, location: @trip }\n else\n format.html { render :new }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @roadstop = Roadstop.new(roadstop_params)\n\n respond_to do |format|\n if @roadstop.save\n format.html { redirect_to @roadstop, notice: 'Roadstop was successfully created.' }\n format.json { render action: 'show', status: :created, location: @roadstop }\n else\n format.html { render action: 'new' }\n format.json { render json: @roadstop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @way.destroy\n respond_to do |format|\n format.html { redirect_to ways_url, notice: 'Way was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n # We have to convert the two posted values for each time into a single string\n # If we don't Trip.new can't populate the Trips values based on the post hash\n @trip = Trip.new(parse_post params[:trip])\n\n respond_to do |format|\n if @trip.save\n flash[:notice] = 'Trip was successfully created.'\n format.html { redirect_to(@trip) }\n format.xml { render :xml => @trip, :status => :created, :location => @trip }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trip.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n # We have to convert the two posted values for each time into a single string\n # If we don't Trip.new can't populate the Trips values based on the post hash\n @trip = Trip.new(parse_post params[:trip])\n\n respond_to do |format|\n if @trip.save\n flash[:notice] = 'Trip was successfully created.'\n format.html { redirect_to(@trip) }\n format.xml { render :xml => @trip, :status => :created, :location => @trip }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @trip.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @outdoor = Outdoor.new(params[:outdoor])\n\n respond_to do |format|\n if @outdoor.save\n format.html { redirect_to @outdoor, notice: 'Outdoor was successfully created.' }\n format.json { render json: @outdoor, status: :created, location: @outdoor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @outdoor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n\n if params[:journey_id]\n @journey = Journey.find(params[:journey_id])\n render_403 and return if @journey.user_id != current_user.id\n\n @journey_leg = JourneyLeg.new\n @url = \"/journeys/#{@journey.id}/legs\"\n elsif params[:journey_leg]\n @journey_leg = JourneyLeg.new(journey_leg_params)\n @url = \"/journeys\"\n else\n @journey_leg = JourneyLeg.new\n @url = \"/journeys\"\n end\n\n @method = :POST\n\n @stations = Station.order(:name)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @journey_leg, callback: params[:callback] }\n format.xml { render xml: @journey_leg }\n end\n end",
"def new\n @road = Road.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @road }\n end\n end",
"def create\n @leisure = Leisure.new(leisure_params)\n\n respond_to do |format|\n if @leisure.save\n format.html { redirect_to @leisure, notice: 'Leisure was successfully created.' }\n format.json { render :show, status: :created, location: @leisure }\n else\n format.html { render :new }\n format.json { render json: @leisure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @witch = Witch.new(params[:witch])\n\n respond_to do |format|\n if @witch.save\n format.html { redirect_to @witch, notice: 'Witch was successfully created.' }\n format.json { render json: @witch, status: :created, location: @witch }\n else\n format.html { render action: \"new\" }\n format.json { render json: @witch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @way.update(way_params)\n format.html { redirect_to @way, notice: 'Way was successfully updated.' }\n format.json { render :show, status: :ok, location: @way }\n else\n format.html { render :edit }\n format.json { render json: @way.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(resource, params)\n case resource\n when \"pedidos\", \"place_order\", \"new_order\" then url = \"/pedidos\"\n when \"envios\", \"shipping\" then url = \"/envios\"\n else url = \"/#{resource}\"\n end\n\n post_request(url, params)\n end",
"def post(path, **args); end",
"def create\n @dow = Dow.new(dow_params)\n\n respond_to do |format|\n if @dow.save\n format.html { redirect_to @dow, notice: 'Dow was successfully created.' }\n format.json { render :show, status: :created, location: @dow }\n else\n format.html { render :new }\n format.json { render json: @dow.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @onske = Onske.new(params[:onske])\n\n respond_to do |format|\n if @onske.save\n format.html { redirect_to @onske, notice: 'Onske was successfully created.' }\n format.json { render json: @onske, status: :created, location: @onske }\n else\n format.html { render action: \"new\" }\n format.json { render json: @onske.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @plate = @restaurante.plates.create(plate_params)\n @plate.ratings ||= []\n @plate.clients_ratings ||= []\n\n respond_to do |format|\n if @plate.save\n format.html { redirect_to restaurante_plate_path(@restaurante, @plate),\n notice: 'Plato creado exitosamente.' }\n format.json { render :show, status: :created, location: @plate }\n else\n format.html { render :new }\n format.json { render json: @plate.errors,\n status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n\t@strategyweb = Strategyweb.new(params[:strategyweb])\n @strategyweb.control=\"strategys\"\n @strategyweb.action=\"show\"\n @strategyweb.anreturn=1\n respond_to do |format|\n if @strategyweb.save\n format.html { redirect_to :action=>\"index\", notice: 'Strategyweb was successfully created.' }\n format.json { render json: @strategyweb, status: :created, location: @strategyweb }\n else\n format.html { render action: \"new\" }\n format.json { render json: @strategyweb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @handover_ways = HandoverWay.all\n end",
"def create\n @ride_level = RideLevel.new(ride_level_params)\n\n respond_to do |format|\n if @ride_level.save\n format.html { redirect_to @ride_level, notice: 'Ride level was successfully created.' }\n format.json { render :show, status: :created, location: @ride_level }\n else\n format.html { render :new }\n format.json { render json: @ride_level.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @order_ways = OrderWay.all\n end",
"def post_route(payload)\n with_rescue do\n payload = payload.to_json if payload.is_a?(Hash)\n connection.post do |request|\n request.url routes_path\n request.body = payload\n request.headers['Content-Type'] = 'application/json'\n end\n end\n end",
"def create\n @control_tower = ControlTower.new(params[:control_tower])\n\n respond_to do |format|\n if @control_tower.save\n format.html { redirect_to @control_tower, notice: 'Control tower was successfully created.' }\n format.json { render json: @control_tower, status: :created, location: @control_tower }\n else\n format.html { render action: \"new\" }\n format.json { render json: @control_tower.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trip = Trip.new(trip_params)\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to trips_path, notice: 'Cesta byla vytvořena.' }\n format.json { render :show, status: :created, location: @trip }\n else\n format.html { render :new }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, json, params = {})\n if path.include?('covid19')\n request = Net::HTTP::Post.new(path, @headers)\n else\n request = Net::HTTP::Post.new('/v2' + path, @headers)\n end\n request.add_field('Content-Type', 'application/json')\n request.body = json\n params.each do |k, v|\n request[k] = v\n end\n send_request(request)\n end"
] | [
"0.67839986",
"0.6742594",
"0.6700332",
"0.66208863",
"0.6590533",
"0.6566288",
"0.63995945",
"0.6309827",
"0.6180557",
"0.60790014",
"0.5970307",
"0.5951881",
"0.59408665",
"0.59136873",
"0.58563167",
"0.58475304",
"0.58260286",
"0.58092076",
"0.5804434",
"0.5792486",
"0.57751167",
"0.5764635",
"0.5737245",
"0.5724796",
"0.5667224",
"0.56510276",
"0.5645274",
"0.56348747",
"0.5630714",
"0.56220496",
"0.56141",
"0.5574637",
"0.55718416",
"0.55569386",
"0.55546534",
"0.553421",
"0.55308336",
"0.55058604",
"0.5491235",
"0.54844105",
"0.5468547",
"0.5463743",
"0.54536957",
"0.54470015",
"0.544432",
"0.5424849",
"0.5419618",
"0.54153943",
"0.54074717",
"0.5404487",
"0.539496",
"0.5391953",
"0.5387963",
"0.5385508",
"0.53823406",
"0.5377162",
"0.5376766",
"0.5372049",
"0.53621256",
"0.53538704",
"0.5339525",
"0.53358704",
"0.5335589",
"0.5334967",
"0.53259915",
"0.5315723",
"0.5311476",
"0.5309135",
"0.5298594",
"0.5293976",
"0.5273758",
"0.52733",
"0.52685905",
"0.52635986",
"0.526271",
"0.5259723",
"0.5254986",
"0.5254222",
"0.5251678",
"0.52506685",
"0.52506685",
"0.52476275",
"0.52379483",
"0.523511",
"0.52282715",
"0.5224417",
"0.52222896",
"0.5220053",
"0.5217397",
"0.5216292",
"0.5216103",
"0.5211268",
"0.52099186",
"0.520918",
"0.52035975",
"0.52007604",
"0.52004",
"0.5194759",
"0.5190517",
"0.51892143"
] | 0.7276052 | 0 |
PATCH/PUT /ways/1 PATCH/PUT /ways/1.json | def update
respond_to do |format|
if @way.update(way_params)
format.html { redirect_to @way, notice: 'Way was successfully updated.' }
format.json { render :show, status: :ok, location: @way }
else
format.html { render :edit }
format.json { render json: @way.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @subway = Subway.find(params[:id])\n\n respond_to do |format|\n if @subway.update_attributes(params[:subway])\n format.html { redirect_to @subway, notice: 'Subway was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subway.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @way = Way.find(params[:id])\n\n respond_to do |format|\n if @way.update_attributes(params[:way])\n format.html { redirect_to(@way, :notice => 'Way was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @way.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by(id: params[:id])\n suggested_pathway.name = params[:name]\n suggested_pathway.year = params[:year]\n suggested_pathway.course_id = params[:course_id]\n suggested_pathway.data = params[:data]\n suggested_pathway.save\n render json: suggested_pathway\n end",
"def update\n @railway = Railway.find(params[:id])\n\n respond_to do |format|\n if @railway.update_attributes(params[:railway])\n format.html { redirect_to @railway, notice: 'Railway was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @railway.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @subway.update(subway_params)\n format.html { redirect_to @subway, notice: 'Subway was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @subway.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ways_of_admission = WaysOfAdmission.find(params[:id])\n\n respond_to do |format|\n if @ways_of_admission.update_attributes(params[:ways_of_admission])\n format.html { redirect_to @ways_of_admission, :notice => 'Ways of admission was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @ways_of_admission.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order_way.update(order_way_params)\n format.html { redirect_to @order_way, notice: 'Order way was successfully updated.' }\n format.json { render :show, status: :ok, location: @order_way }\n else\n format.html { render :edit }\n format.json { render json: @order_way.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @subway = Subway.find(params[:id])\n\n respond_to do |format|\n if @subway.update_attributes(params[:subway])\n format.html { redirect_to(@subway, :notice => 'Subway was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @subway.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @way_point.update(way_point_params)\n format.html { redirect_to @way_point, notice: 'Way point was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @way_point.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @handover_way.update(handover_way_params)\n format.html { redirect_to @handover_way, notice: 'Handover way was successfully updated.' }\n format.json { render :show, status: :ok, location: @handover_way }\n else\n format.html { render :edit }\n format.json { render json: @handover_way.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @way_point.update(way_point_params)\r\n format.html { redirect_to @way_point, notice: 'Way point was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @way_point.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def patch!\n request! :patch\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n @runway_ap = RunwayAp.find(params[:id])\n\n respond_to do |format|\n if @runway_ap.update_attributes(params[:runway_ap])\n format.html { redirect_to @runway_ap, notice: 'Runway ap was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @runway_ap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @road = Road.find(params[:id])\n\n respond_to do |format|\n if @road.update_attributes(params[:road])\n format.html { redirect_to @road, notice: 'Road was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @road.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n @one = One.find(params[:id])\n\n respond_to do |format|\n if @one.update_attributes(params[:one])\n format.html { redirect_to @one, notice: 'One was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @one.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n respond_to do |format|\n if @reqdifficulty.update(reqdifficulty_params)\n format.html { redirect_to @reqdifficulty, notice: 'Reqdifficulty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @reqdifficulty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trip.update(trip_params)\n last_clip(@trip, trip_params[:clips_attributes].present?)\n format.html { redirect_to @trip.parent || @trip, notice: 'Trip was successfully updated.', change: \"list\" }\n format.json { head :no_content }\n else\n format.html { redirect_to @trip.parent || @trip }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @goody = Goody.find(params[:id])\n\n respond_to do |format|\n if @goody.update_attributes(params[:goody])\n format.html { redirect_to @goody, notice: 'Goody was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @goody.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @thing = Thing.find(params[:id])\n params[:thing][:place_id] = place_id_from_form\n params[:thing][:owner_ids] = [ ] if params[:thing][:owner_ids].nil?\n params[:thing][:keeper_ids] = [ ] if params[:thing][:keeper_ids].nil?\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to(@thing, :notice => 'Thing was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @thing.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n put :update\n end",
"def update\n update_resource @ride, ride_params\n end",
"def put!\n request! :put\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def update\n @solution = @idea.solutions.find(params[:id])\n\n if @solution.update_attributes(params[:solution])\n render json: { text: \"success\" }\n else\n render json: { text: \"fail\"}\n end\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update\n @thing = Thing.find(params[:id])\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to things_path, notice: 'Your thing was successfully updated!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end",
"def patch(path, **args); end",
"def update\n @bottle = Bottle.find(params[:id])\n\n respond_to do |format|\n if @bottle.update_attributes(params[:bottle])\n format.html { redirect_to(@bottle, :notice => 'Bottle was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bottle.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n respond_to do |format|\n if @bottle.update(bottle_params)\n format.html { redirect_to user_path(current_user.id), notice: 'Bottle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bottle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @thing = Thing.find(params[:id])\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to @thing, notice: 'Thing was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n goal = Goal.find params[:id]\n if goal.update(goal_params)\n render json: goal, status: 200\n else\n render json: goal.errors.full_messages, status: 422\n end\n end",
"def update\n respond_to do |format|\n if @kota_stone.update(kota_stone_params)\n format.html { redirect_to kota_stones_url, notice: 'Kota stone was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kota_stone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @goat = Goat.find(params[:id])\n\n respond_to do |format|\n if @goat.update_attributes(params[:goat])\n format.html { redirect_to @goat, notice: 'Goat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @goat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(path)\n output { patch(path, params) }\n end",
"def update\n @gotcha = Gotcha.find(params[:id])\n\n respond_to do |format|\n if @gotcha.update_attributes(params[:gotcha])\n format.html { redirect_to @gotcha, notice: 'Gotcha was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gotcha.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @medium_road = MediumRoad.find(params[:id])\n\n respond_to do |format|\n if @medium_road.update_attributes(params[:medium_road])\n format.html { redirect_to @medium_road, notice: 'Medium road was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medium_road.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n if @trip.update_attributes(params[:trip])\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n end\n end\n end",
"def update\n @junction = Junction.find(params[:id])\n\n respond_to do |format|\n if @junction.update_attributes(params[:junction])\n format.html { redirect_to @junction, notice: 'Junction was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @junction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @plate = Plate.find(params[:id])\n\n if @plate.update(params[:plate])\n head :no_content\n else\n render json: @plate.errors, status: :unprocessable_entity\n end\n end",
"def patch(path, opts = {})\n request(:patch, path, opts).body\n end",
"def update\n @flag = Flag.find(params[:id])\n\n respond_to do |format|\n if @flag.update_attributes(params[:flag])\n format.html { redirect_to @flag, notice: 'Flag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @flag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @through_reference = ThroughReference.find(params[:id])\n\n respond_to do |format|\n if @through_reference.update_attributes(params[:through_reference])\n format.html { redirect_to @through_reference, notice: 'Through reference was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @through_reference.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @handicapping_method = HandicappingMethod.find(params[:id])\n\n respond_to do |format|\n if @handicapping_method.update_attributes(params[:handicapping_method])\n format.html { redirect_to @handicapping_method, notice: 'Handicapping method was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @handicapping_method.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @witch = Witch.find(params[:id])\n\n respond_to do |format|\n if @witch.update_attributes(params[:witch])\n format.html { redirect_to @witch, notice: 'Witch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @witch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @road.update(road_params)\n format.html { redirect_to @road, notice: 'Road was successfully updated.' }\n format.json { render :show, status: :ok, location: @road }\n else\n format.html { render :edit }\n format.json { render json: @road.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_radios_for_array(args = {}) \n id = args['id']\n temp_path = \"/radios.json/{arrayId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"radioId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n #Finding the specific chore where the id matches the one we pass in with the body\n @v1_chore = Chore.where(id: params[:id]).first\n #Here we're checking if we have user_id in our body, and if we do, we'll change the selected chore's properties\n #with the parameters of the body, we go through the specific group to our specific chore with the path\n if v1_chore_params[:user_id]\n @v1_chore.user_id = params[:user_id]\n @v1_chore.assigned = true\n if @v1_chore.save\n render :show, status: :ok\n end\n else\n render json: @v1_chore.errors, status: :unprocessable_entity\n end\n end",
"def update\n @orderable_concept = OrderableConcept.find(params[:id])\n\n respond_to do |format|\n if @orderable_concept.update_attributes(params[:orderable_concept])\n format.html { redirect_to @orderable_concept, notice: 'Orderable concept was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @orderable_concept.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @rayon = Rayon.find(params[:id])\n\n respond_to do |format|\n if @rayon.update_attributes(params[:rayon])\n format.html { redirect_to @rayon, notice: 'Rayon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rayon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @platoon.update(platoon_params)\n format.html { redirect_to @platoon, notice: 'Platoon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @platoon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @hoge = Hoge.find(params[:id])\n\n respond_to do |format|\n if @hoge.update_attributes(params[:hoge])\n format.html { redirect_to @hoge, notice: 'Hoge was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hoge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end",
"def update\n @stone = Stone.find(params[:id])\n\n respond_to do |format|\n if @stone.update_attributes(params[:stone])\n format.html { redirect_to @stone, notice: 'Stone was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @flag = Flag.find(params[:id])\n\n respond_to do |format|\n if @flag.update_attributes(params[:flag])\n format.html { redirect_to [:admin,@flag], notice: 'Flag atualizado com sucesso!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @flag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trick = Trick.find(params[:id])\n\n respond_to do |format|\n if @trick.update_attributes(params[:trick])\n format.html { redirect_to @trick, notice: 'Trick was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trick.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pony = Pony.find(params[:id])\n\n respond_to do |format|\n if @pony.update_attributes(params[:pony])\n format.html { redirect_to @pony, notice: 'Pony was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pony.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @route = Route.find(params[:id])\n if user_signed_in?\n routeInfo = JSON.parse(params[:route_map_points].gsub(\"jb\",\"latitude\").gsub(\"kb\",\"longitude\"))\n \n \n @route.route_points = routeInfo['overview_path']\n @route.starting_point = routeInfo['overview_path'].first\n @route.end_point = routeInfo['overview_path'].last\n\n\n respond_to do |format|\n if @route.save(params[:route])\n if @route.schedule.update_attributes(\n departure: params[:route_schedule_departure], \n arrival: params[:route_schedule_arrival]) \n format.html { redirect_to @route, notice: 'Route was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @route.errors, status: :unprocessable_entity }\n end\n end\n end\nend\n # DELETE /routes/1\n # DELETE /routes/1.json\n def destroy\n @route = Route.find(params[:id])\n @route.destroy\n\n respond_to do |format|\n format.html { redirect_to routes_url }\n format.json { head :no_content }\n end\n end\nend",
"def update\n @optician = Optician.find(params[:id])\n\n respond_to do |format|\n if @optician.update_attributes(params[:optician])\n format.html { redirect_to @optician, notice: 'Optician was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @optician.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @guide_taxon.update(params[:guide_taxon])\n format.html { redirect_to @guide_taxon, notice: 'Guide taxon was successfully updated.' }\n format.json { render :json => @guide_taxon.as_json(:root => true, :methods => [:html]) }\n else\n format.html do\n load_data_for_edit\n render action: \"edit\"\n end\n format.json { render json: @guide_taxon.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @initiative = Initiative.find(params[:id])\n @initiative.phase_id=params[:phase_id]\n\n respond_to do |format|\n if @initiative.update_attributes(params[:initiative])\n format.html { render :nothing => true }\n #format.html { redirect_to @initiative, notice: 'Initiative was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @initiative.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @ride.update(offer_1_ride_params)\n\t\t\t\t@ride.set_routes\n\t\t\t\t@ride.handle_return_date_and_recurring_weeks\n\t\t\t\tformat.html { redirect_to \"/#{@ride.id}/offer-seats/2\" }\n\t\t\t\tformat.json { render :show, status: :created, location: @ride }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @ride.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n @kolegij = Kolegij.find(params[:id])\n\n respond_to do |format|\n if @kolegij.update_attributes(params[:kolegij])\n format.html { redirect_to @kolegij, notice: 'Kolegij was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kolegij.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @kitty = Kitty.find(params[:id])\n\n respond_to do |format|\n if @kitty.update_attributes(params[:kitty])\n format.html { redirect_to @kitty, notice: 'Kitty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kitty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @shorty = Shorty.find(params[:id])\n\n respond_to do |format|\n if @shorty.update_attributes(params[:shorty])\n format.html { redirect_to @shorty, notice: 'Shorty was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shorty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @click_thru = ClickThru.find(params[:id])\n\n respond_to do |format|\n if @click_thru.update_attributes(params[:click_thru])\n format.html { redirect_to @click_thru, notice: 'Click thru was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @click_thru.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @wanted = Wanted.find(params[:id])\n\n respond_to do |format|\n if @wanted.update_attributes(params[:wanted])\n format.html { redirect_to @wanted, notice: 'Wanted was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @wanted.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n if @trip.update_attributes(params[:trip])\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n if @trip.update_attributes(params[:trip])\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def update\n respond_to do |format|\n if @api_v1_initiative.update(api_v1_initiative_params)\n format.html { redirect_to @api_v1_initiative, notice: 'Initiative was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @wing.update(wing_params)\n @wing.floors.each { |f| f.touch }\n format.html { redirect_to @wing, notice: t('.update_ok', item: @wing.name) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @wing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @plate.update(plate_params)\n format.html { redirect_to @plate, notice: 'Plate was successfully updated.' }\n format.json { render :show, status: :ok, location: @plate }\n else\n format.html { render :edit }\n format.json { render json: @plate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mostsmallroad = Mostsmallroad.find(params[:id])\n\n respond_to do |format|\n if @mostsmallroad.update_attributes(params[:mostsmallroad])\n format.html { redirect_to @mostsmallroad, notice: 'Mostsmallroad was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mostsmallroad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @guide_trip.update(guide_trip_params)\n format.html { redirect_to @guide_trip, notice: 'Guía turístico fue modificado satisfactoriamente.' }\n format.json { render :show, status: :ok, location: @guide_trip }\n else\n format.html { render :edit }\n format.json { render json: @guide_trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # respond_to do |format|\n # if @thing.update(thing_params)\n # format.html { redirect_to @thing, notice: 'Thing was successfully updated.' }\n # format.json { render :show, status: :ok, location: @thing }\n # else\n # format.html { render :edit }\n # format.json { render json: @thing.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def update\n respond_to do |format|\n if @set_aside.update(set_aside_params)\n format.html { redirect_to @set_aside, notice: 'Set aside was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @set_aside.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n if @trip.update_attributes(params[:trip])\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @direction.recipe\n respond_to do |format|\n if @direction.update(direction_params)\n format.html { redirect_to @direction }\n format.json { render :show, status: :ok, location: @direction }\n else\n format.html { render :edit }\n format.json { render json: @direction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @needed_good = NeededGood.find(params[:id])\n\n respond_to do |format|\n if @needed_good.update_attributes(params[:needed_good])\n format.html { redirect_to @needed_good, notice: 'Good was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @needed_good.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n keystone.update_tenant({:id=>params[:id],:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n format.html { redirect_to tenants_path, :notice => 'Tenant was successfully updated.' }\n format.json { head :ok }\n end\n end",
"def update\n respond_to do |format|\n if @sidequest.update(sidequest_params)\n format.html { redirect_to @sidequest, notice: 'Sidequest was successfully updated.' }\n format.json { render :show, status: :ok, location: @sidequest }\n else\n format.html { render :edit }\n format.json { render json: @sidequest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @goal = Goal.find(params[:id])\n\n respond_to do |format|\n if @goal.update_attributes(params[:goal])\n format.html { redirect_to @goal, notice: 'Goal was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @goal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, @theorem\n if @theorem.update(theorem_params)\n render json: @theorem, status: :ok, location: @theorem\n else\n render json: @theorem.errors, status: :unprocessable_entity\n end\n end",
"def update\n\n respond_to do |format|\n if @check_route.update(check_route_params)\n format.html { redirect_to @check_route, notice: 'Check Route was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @check_route.errors, status: :internal_server_error }\n end\n end\n end",
"def update\n @hand_reciept = HandReciept.find(params[:id])\n\n respond_to do |format|\n if @hand_reciept.update_attributes(params[:hand_reciept])\n format.html { redirect_to @hand_reciept, notice: 'Hand reciept was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hand_reciept.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @thing = current_user.things.find(params[:id])\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to @thing }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client_need = ClientNeed.find(params[:id])\n\n respond_to do |format|\n if @client_need.update_attributes(params[:client_need])\n format.html { redirect_to @client_need, notice: 'Client need was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_need.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ope_kind = OpeKind.find(params[:id])\n\n respond_to do |format|\n if @ope_kind.update_attributes(params[:ope_kind])\n format.html { redirect_to @ope_kind, notice: 'Ope kind was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ope_kind.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @thing_to_do.update(thing_to_do_params)\n format.html { redirect_to @thing_to_do, notice: 'Thing to do was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @thing_to_do.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @plate.update(plate_params)\n format.html { redirect_to [@client, @budget, @mobile], notice: 'Chapa atualizada com sucesso.' }\n format.json { render :show, status: :ok, location: @plate }\n else\n format.html { render :edit }\n format.json { render json: @plate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @riesgo.update(riesgo_params)\n format.html { redirect_to @riesgo, notice: 'Riesgo was successfully updated.' }\n format.json { render :show, status: :ok, location: @riesgo }\n else\n format.html { render :edit }\n format.json { render json: @riesgo.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6564012",
"0.65603477",
"0.6373927",
"0.6373873",
"0.632334",
"0.6319039",
"0.62574214",
"0.6180161",
"0.6136139",
"0.60556453",
"0.60521275",
"0.6022372",
"0.60013413",
"0.59669256",
"0.5899495",
"0.58886904",
"0.5870361",
"0.58481485",
"0.5842066",
"0.58115643",
"0.57975847",
"0.5795138",
"0.57788664",
"0.5744343",
"0.57219726",
"0.57215476",
"0.57091624",
"0.5708316",
"0.5708316",
"0.5705063",
"0.5703348",
"0.5699421",
"0.56912166",
"0.5682267",
"0.5678363",
"0.5678057",
"0.5672485",
"0.56720096",
"0.566581",
"0.56650233",
"0.56601816",
"0.56553465",
"0.5654439",
"0.565058",
"0.56503075",
"0.5645362",
"0.56373215",
"0.5636919",
"0.5632794",
"0.5630223",
"0.5623059",
"0.56226176",
"0.5622054",
"0.5618276",
"0.56062174",
"0.56016517",
"0.5586485",
"0.5586077",
"0.5584755",
"0.5573658",
"0.5573241",
"0.5571761",
"0.5561769",
"0.5557763",
"0.55548173",
"0.55542344",
"0.5551014",
"0.55469656",
"0.5545709",
"0.55431026",
"0.5541332",
"0.55345213",
"0.5531727",
"0.5527752",
"0.552722",
"0.552722",
"0.552425",
"0.552425",
"0.55198896",
"0.55189043",
"0.55150735",
"0.55142504",
"0.5510884",
"0.5510573",
"0.5508795",
"0.5506471",
"0.5506455",
"0.5502402",
"0.55021363",
"0.54985964",
"0.54982376",
"0.54981476",
"0.54962957",
"0.5493114",
"0.54927903",
"0.54900414",
"0.54870105",
"0.5485101",
"0.54798836",
"0.5477516"
] | 0.6766084 | 0 |
DELETE /ways/1 DELETE /ways/1.json | def destroy
@way.destroy
respond_to do |format|
format.html { redirect_to ways_url, notice: 'Way was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_pathway\n pathway = Pathway.find(params[:pathway_par])\n current_user.pathways.delete(pathway)\n if current_user.pathways.size < 1\n respond_to do |format|\n format.html { redirect_to '/saved#pathways' }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n @subway = Subway.find(params[:id])\n @subway.destroy\n\n respond_to do |format|\n format.html { redirect_to subways_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @way = Way.find(params[:id])\n @way.destroy\n\n respond_to do |format|\n format.html { redirect_to(ways_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @subway.destroy\n respond_to do |format|\n format.html { redirect_to subways_url }\n format.json { head :no_content }\n end\n end",
"def delete_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by_id(params[:pathway_id])\n suggested_pathway.destroy\n render json: suggested_pathway\n end",
"def destroy\n @railway = Railway.find(params[:id])\n @railway.destroy\n\n respond_to do |format|\n format.html { redirect_to railways_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ways_of_admission = WaysOfAdmission.find(params[:id])\n @ways_of_admission.destroy\n\n respond_to do |format|\n format.html { redirect_to ways_of_admissions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subway = Subway.find(params[:id])\n @subway.destroy\n\n respond_to do |format|\n format.html { redirect_to(subways_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @order_way.destroy\n respond_to do |format|\n format.html { redirect_to order_ways_url, notice: 'Order way was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @medium_road = MediumRoad.find(params[:id])\n @medium_road.destroy\n\n respond_to do |format|\n format.html { redirect_to medium_roads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @road = Road.find(params[:id])\n @road.destroy\n\n respond_to do |format|\n format.html { redirect_to roads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @handover_way.destroy\n respond_to do |format|\n format.html { redirect_to handover_ways_url, notice: 'Handover way was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @one = One.find(params[:id])\n @one.destroy\n\n respond_to do |format|\n format.html { redirect_to ones_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @reqdifficulty.destroy\n respond_to do |format|\n format.html { redirect_to reqdifficulties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @runway_ap = RunwayAp.find(params[:id])\n @runway_ap.destroy\n\n respond_to do |format|\n format.html { redirect_to runway_aps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @goal = Goal.find(params[:id])\n @goal.destroy\n render json: @goal\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @mostsmallroad = Mostsmallroad.find(params[:id])\n @mostsmallroad.destroy\n\n respond_to do |format|\n format.html { redirect_to mostsmallroads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kota_stone.destroy\n respond_to do |format|\n format.html { redirect_to kota_stones_url }\n format.json { head :no_content }\n end\n end",
"def delete\n @delete ||= Verb.new do |verb|\n verb.entity :trip, :air, :lodging, :car, :profile, :rail, \\\n :transport, :cruise, :restaurant, :activity, :note, :map, \\\n :directions \\\n do |entity, id|\n do_request('delete', entity, {:id=>id}, nil)\n end\n end\n end",
"def destroy\n @roadblock.destroy\n respond_to do |format|\n format.html { redirect_to \"/roadblocks-dash\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @waypoint = Waypoint.find(params[:id])\n @waypoint.destroy\n\n respond_to do |format|\n format.html { redirect_to(waypoints_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @step.destroy\n respond_to do |format|\n format.html { redirect_to @trip }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @direction.recipe\n @direction.destroy\n respond_to do |format|\n format.html { redirect_to directions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gpath = Gpath.find(params[:id])\n @gpath.destroy\n\n respond_to do |format|\n format.html { redirect_to gpaths_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mini_map_road = MiniMapRoad.find(params[:id])\n @mini_map_road.destroy\n\n respond_to do |format|\n format.html { redirect_to mini_map_roads_url }\n format.json { head :no_content }\n end\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @hoge = Hoge.find(params[:id])\n @hoge.destroy\n\n respond_to do |format|\n format.html { redirect_to hoges_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @broad = Broad.find(params[:id])\n @broad.destroy\n\n respond_to do |format|\n format.html { redirect_to broads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n respond_to do |format|\r\n format.html { redirect_to way_points_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @moonwalk.destroy\n respond_to do |format|\n format.html { redirect_to moonwalks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @antenne = Antenne.find(params[:id])\r\n @antenne.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to antennes_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @habitant.destroy\n respond_to do |format|\n format.html { redirect_to habitants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @server1 = Server1.find(params[:id])\n @server1.destroy\n\n respond_to do |format|\n format.html { redirect_to server1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @roadstop.destroy\n respond_to do |format|\n format.html { redirect_to roadstops_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clip.destroy\n respond_to do |format|\n format.html { redirect_to trip_path(@clip.trip.parent), change: 'list' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stone = Stone.find(params[:id])\n @stone.destroy\n\n respond_to do |format|\n format.html { redirect_to stones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @walk = Walk.find(params[:id])\n @walk.destroy\n\n respond_to do |format|\n format.html { redirect_to walks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @go = Go.find(params[:id])\n @go.destroy\n\n respond_to do |format|\n format.html { redirect_to manager_gos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @qx_runway.destroy\n respond_to do |format|\n format.html { redirect_to qx_runways_url, notice: 'Runway was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ninja = Ninja.find(params[:id])\n @ninja.destroy\n\n respond_to do |format|\n format.html { redirect_to ninjas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @three.destroy\n respond_to do |format|\n format.html { redirect_to threes_url }\n format.json { head :no_content }\n end\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def delete!\n request! :delete\n end",
"def destroy\n @hotele = Hotele.find(params[:id])\n @hotele.destroy\n\n respond_to do |format|\n format.html { redirect_to hoteles_url }\n format.json { head :no_content }\n end\n end",
"def delete(path, params = {})\n post(path, params.merge(\"_method\" => \"delete\"))\n end",
"def delete\n @guide = Guide.find(params[:id])\n @guide.destroy\n respond_to do |format|\n format.html { redirect_to guides_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shorty = Shorty.find(params[:id])\n @shorty.destroy\n\n respond_to do |format|\n format.html { redirect_to shorties_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @rayon = Rayon.find(params[:id])\n @rayon.destroy\n\n respond_to do |format|\n format.html { redirect_to rayons_url }\n format.json { head :no_content }\n end\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete(path)\n request 'DELETE', path\n end",
"def destroy\n @opttruck.destroy\n respond_to do |format|\n format.html { redirect_to opttrucks_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n request(:delete, path)\n end",
"def destroy\n @path = Path.find(params[:id])\n @path.destroy\n\n respond_to do |format|\n format.html { redirect_to(layer_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @line_item1 = LineItem1.find(params[:id])\n @line_item1.destroy\n\n respond_to do |format|\n format.html { redirect_to line_item1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @goat = Goat.find(params[:id])\n @goat.destroy\n\n respond_to do |format|\n format.html { redirect_to goats_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Like.delete(params[\"id\"])\n end",
"def destroy\n @nudge.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @house = House.find(params[:id])\n @house.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_houses_url(:realty_type => params[:realty_type]) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @direction = Direction.find(params[:id])\n @direction.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_directions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @house = House.find(params[:id])\n @house.destroy\n\n respond_to do |format|\n format.html { redirect_to gigs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @goody = Goody.find(params[:id])\n @goody.destroy\n\n respond_to do |format|\n format.html { redirect_to goodies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip = Trip.find(params[:id])\n @trip.destroy\n\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip = Trip.find(params[:id])\n @trip.destroy\n\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip = Trip.find(params[:id])\n @trip.destroy\n\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ride_level.destroy\n respond_to do |format|\n format.html { redirect_to ride_levels_url, notice: 'Ride level was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @roadmap_step.destroy\n respond_to do |format|\n format.html { redirect_to roadmap_steps_url, notice: 'Roadmap step was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @guide_trip.destroy\n respond_to do |format|\n format.html { redirect_to guide_trips_url, notice: 'Guía turístico fue eliminado satisfactoriamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @house.destroy\n respond_to do |format|\n format.html { redirect_to house_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @drone_attack = DroneAttack.find(params[:id])\n @drone_attack.destroy\n\n respond_to do |format|\n format.html { redirect_to drone_attacks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @orthodb_level = OrthodbLevel.find(params[:id])\n @orthodb_level.destroy\n\n respond_to do |format|\n format.html { redirect_to orthodb_levels_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @house = House.find(params[:id])\n @house.destroy\n\n respond_to do |format|\n format.html { redirect_to houses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @house = House.find(params[:id])\n @house.destroy\n\n respond_to do |format|\n format.html { redirect_to houses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @genotype = Genotype.find(params[:id])\n @genotype.destroy\n\n respond_to do |format|\n format.html { redirect_to genotypes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @house.destroy\n respond_to do |format|\n format.html { redirect_to houses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @house.destroy\n respond_to do |format|\n format.html { redirect_to houses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chaine = Chaine.find(params[:id])\n @chaine.destroy\n\n respond_to do |format|\n format.html { redirect_to chaines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_need = ClientNeed.find(params[:id])\n @client_need.destroy\n\n respond_to do |format|\n format.html { redirect_to client_needs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip = Trip.find(params[:id])\n @trip.destroy\n\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @trip = Trip.find(params[:id])\n @trip.destroy\n\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :ok }\n end\n end",
"def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end",
"def delete(path, params)\n parse_response @client[path].delete(:params => params)\n end",
"def delete(path)\n\t\trequest(path, :delete)\n\tend",
"def destroy\n @line_station_2.destroy\n respond_to do |format|\n format.html { redirect_to line_station_2s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @through_reference = ThroughReference.find(params[:id])\n @through_reference.destroy\n\n respond_to do |format|\n format.html { redirect_to through_references_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n game = @goal.game\n @goal.destroy\n respond_to do |format|\n format.html { redirect_to game_path(game) }\n format.json { head :no_content }\n end\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n @server = Server.find(params[:id])\n checkaccountobject(\"servers\",@server)\n @server.send_delete\n respond_to do |format|\n format.html { redirect_to servers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @side_walk.destroy\n respond_to do |format|\n format.html { redirect_to side_walks_url, notice: 'Side walk was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path, params)\n request(:delete, path, {})\n end",
"def destroy\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.74076796",
"0.73946935",
"0.7356026",
"0.73158926",
"0.7299793",
"0.72144616",
"0.707968",
"0.7048751",
"0.6914441",
"0.68450266",
"0.6755857",
"0.6713121",
"0.6710341",
"0.6634281",
"0.65777314",
"0.65441906",
"0.65349644",
"0.6505535",
"0.6494423",
"0.64901334",
"0.64865655",
"0.6486092",
"0.6472211",
"0.6452555",
"0.64523417",
"0.6450544",
"0.6420154",
"0.6408068",
"0.6397181",
"0.639674",
"0.6390625",
"0.63784915",
"0.63768333",
"0.6374425",
"0.637305",
"0.63721085",
"0.6370655",
"0.6362152",
"0.63615066",
"0.63539785",
"0.63534474",
"0.635041",
"0.63492644",
"0.63479686",
"0.6346804",
"0.63397914",
"0.6335236",
"0.63327724",
"0.6329683",
"0.63289756",
"0.63279533",
"0.63271564",
"0.6315809",
"0.631413",
"0.631413",
"0.631413",
"0.631413",
"0.6310003",
"0.63081867",
"0.630694",
"0.6306099",
"0.62872005",
"0.6286716",
"0.62822825",
"0.6275425",
"0.62723666",
"0.6271891",
"0.626389",
"0.6262977",
"0.62539285",
"0.62539285",
"0.62539285",
"0.6253244",
"0.6252369",
"0.6248752",
"0.6248012",
"0.6238662",
"0.6237673",
"0.6237153",
"0.6237153",
"0.62340015",
"0.623264",
"0.623264",
"0.62323415",
"0.62301433",
"0.62272066",
"0.62272066",
"0.6226641",
"0.6226311",
"0.6225404",
"0.62219447",
"0.62176967",
"0.62167823",
"0.6213547",
"0.6213189",
"0.6212122",
"0.6210843",
"0.62050617",
"0.62050617",
"0.62050617"
] | 0.7384067 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_way
@way = Way.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 set_actions\n actions :all\n end",
"def define_action_helpers?; 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 setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\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 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 workflow\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 setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\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 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 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 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\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup(&block)\n define_method(:setup, &block)\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 setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; 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 default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def callback_phase\n super\n end",
"def advice\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",
"def _handle_action_missing(*args); end",
"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 duas1(action)\n action.call\n action.call\nend"
] | [
"0.6163821",
"0.6045432",
"0.5945441",
"0.5916224",
"0.58894575",
"0.5834073",
"0.57764685",
"0.5702474",
"0.5702474",
"0.5653258",
"0.56211996",
"0.54235053",
"0.5410683",
"0.5410683",
"0.5410683",
"0.53948104",
"0.5378064",
"0.5356684",
"0.53400385",
"0.53399503",
"0.53312254",
"0.53121567",
"0.52971965",
"0.52964705",
"0.52956307",
"0.52587366",
"0.52450675",
"0.5237777",
"0.5237777",
"0.5237777",
"0.5237777",
"0.5237777",
"0.5233381",
"0.52325714",
"0.52288216",
"0.52229726",
"0.5218362",
"0.52142864",
"0.5207988",
"0.5206337",
"0.51762295",
"0.51745105",
"0.51728606",
"0.516616",
"0.5161016",
"0.5157393",
"0.5152562",
"0.51524293",
"0.5152397",
"0.5144533",
"0.513982",
"0.51342106",
"0.5113793",
"0.5113793",
"0.5113671",
"0.51092553",
"0.51062804",
"0.50921935",
"0.5088855",
"0.5082236",
"0.5079901",
"0.5066569",
"0.5055307",
"0.5053106",
"0.50499666",
"0.50499666",
"0.5035068",
"0.50258636",
"0.50220853",
"0.5015893",
"0.50134486",
"0.5001442",
"0.50005543",
"0.4998581",
"0.49901858",
"0.49901858",
"0.4986648",
"0.49809486",
"0.49792925",
"0.4978855",
"0.49685496",
"0.49656174",
"0.49576473",
"0.49563017",
"0.4955349",
"0.49536878",
"0.4952439",
"0.49460214",
"0.494239",
"0.49334687",
"0.49315962",
"0.49266812",
"0.49261138",
"0.4925925",
"0.4922542",
"0.4920779",
"0.49173284",
"0.49169463",
"0.4916256",
"0.49162322",
"0.49156886"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def way_params
params.require(:way).permit(:vertices_list, :edges_list, :total_distance, :total_time)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_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 allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\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 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 valid_params_request?; end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \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 whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\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 safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\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 whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; 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 quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"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 user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def filtering_params\n params.permit(:email)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def list_params\n params.permit(:name)\n end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\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 url_whitelist; 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 admin_social_network_params\n params.require(:social_network).permit!\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end"
] | [
"0.69811666",
"0.6782836",
"0.6747644",
"0.6742015",
"0.6735273",
"0.6593917",
"0.65037674",
"0.6498627",
"0.6482372",
"0.64795715",
"0.64566946",
"0.6439213",
"0.6380714",
"0.6378147",
"0.63657266",
"0.63206697",
"0.6300169",
"0.62992156",
"0.6295538",
"0.62943023",
"0.62915146",
"0.6290595",
"0.62824667",
"0.62420255",
"0.62403506",
"0.6217174",
"0.6213706",
"0.62112075",
"0.6194868",
"0.6178784",
"0.6174678",
"0.6172499",
"0.61630744",
"0.61544263",
"0.615248",
"0.6147727",
"0.61221075",
"0.6119646",
"0.61076134",
"0.6106584",
"0.6094013",
"0.6081423",
"0.6071337",
"0.6063637",
"0.6021453",
"0.6018253",
"0.60161054",
"0.60112554",
"0.60071784",
"0.60071784",
"0.60004836",
"0.6000254",
"0.5999255",
"0.59930664",
"0.59919107",
"0.5991741",
"0.5980763",
"0.59663844",
"0.59605104",
"0.5960486",
"0.5959414",
"0.5957901",
"0.59538954",
"0.5953327",
"0.59450173",
"0.59391475",
"0.59391475",
"0.59386194",
"0.59351885",
"0.593139",
"0.5926316",
"0.5925927",
"0.59176016",
"0.59119296",
"0.5909275",
"0.5908221",
"0.59053046",
"0.58983994",
"0.58980995",
"0.58964473",
"0.5895902",
"0.5893993",
"0.58927304",
"0.5887752",
"0.58841616",
"0.5880381",
"0.58752084",
"0.586956",
"0.5868584",
"0.58679324",
"0.5867004",
"0.58667004",
"0.58642864",
"0.5863347",
"0.58626384",
"0.58615845",
"0.58594906",
"0.5854959",
"0.5854423",
"0.58506453",
"0.5850135"
] | 0.0 | -1 |
Detect if an address is IPv4 or IPv6 | def detect_ipvers(address)
if address =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/
:ipv4
elsif address =~ /\h{0,4}::?\h{1,4}/i
:ipv6
else
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ipv6_address?(addr)\n return true if addr =~ /:/\n return false\n end",
"def ipv6?\n self.kind_of? IPAddress::IPv6\n end",
"def ipv6?\n self.kind_of? IPAddress::IPv6\n end",
"def ipv4?\n self.kind_of? IPAddress::IPv4\n end",
"def ipv4?\n self.kind_of? IPAddress::IPv4\n end",
"def ipv4?(string)\n !!string.match(/(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/)\nend",
"def is_ip_addr?(part)\n ip = IPAddr.new(part)\n ip.ipv4?\n rescue IPAddr::InvalidAddressError => e\n false\n end",
"def ipv4_address?(n)\n arr = n.split('.')\n if arr.count != 4 ||\n !('1'..'255').include?(arr[0])\n return false\n end\n\n arr.each do |num|\n return false if !('1'..'255').include?(num)\n end\n true\nend",
"def ipv6?\n @family == Socket::AF_INET6\n end",
"def has_ipv4_ip_address?\n self.options[:ip].is_a?(String) && self.options[:ip] =~ /\\A\\d+\\.\\d+\\.\\d+\\.\\d+/\n end",
"def is_addr(s)\n s.match(/^[0-9a-fA-F]+:$/) != nil\nend",
"def has_ipv6_ip_address?\n self.options[:ip].is_a?(String) && self.options[:ip].include?(':')\n end",
"def validate_ip(value)\n case value\n when Resolv::IPv4::Regex\n return true\n when Resolv::IPv6::Regex\n return true\n else\n return false\n end\n end",
"def validate_ip(value)\n case value\n when Resolv::IPv4::Regex\n return true\n when Resolv::IPv6::Regex\n return true\n else\n return false\n end\n end",
"def exact_ip_address?(str)\n !!(str =~ /^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/)\nend",
"def is_valid_ip?(address)\n octets = address.split('.')\n return false if octets.length != 4\n octets.each {|octet| return false if octet.to_i > 255 || octet.to_i < 0}\n true\nend",
"def ip_address? (str)\n\treturn str.match? /^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/\nend",
"def ip?\n return (proto == 'ip')\n end",
"def ipv4?(ip)\n if ip =~ /^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$/\n return true\n end\n false\n end",
"def okIP(addr)\nreturn addr != \"0.0.0.0\" &&\n addr != \"255.255.255.255\" &&\n !addr.match(/^169\\.254.*/) &&\n !addr.match(/^10.*/) &&\n !addr.match(/^172\\.[1-3].*/) && # TODO: match the block better\n !addr.match(/^192\\.168.*/)\nend",
"def dot_seperated_ip_address?(input_string)\n numbers = input_string.split('.')\n return false if numbers.size != 4\n\n numbers.each do |num|\n return false if is_an_ip_number?(num) == false\n end\n true\nend",
"def Check6(ip)\n return false if ip == nil || ip == \"\"\n\n #string num = \"([1-9a-fA-F][0-9a-fA-F]*|0)\";\n num = \"([0-9a-fA-F]{1,4})\"\n\n # 1:2:3:4:5:6:7:8\n if Builtins.regexpmatch(\n ip,\n Ops.add(Ops.add(Ops.add(Ops.add(\"^\", num), \"(:\"), num), \"){7}$\")\n )\n return true\n end\n # ::3:4:5:6:7:8\n if Builtins.regexpmatch(ip, Ops.add(Ops.add(\"^:(:\", num), \"){1,6}$\"))\n return true\n end\n # 1:2:3:4:5:6::\n if Builtins.regexpmatch(ip, Ops.add(Ops.add(\"^(\", num), \":){1,6}:$\"))\n return true\n end\n # :: only once\n return false if Builtins.regexpmatch(ip, \"::.*::\")\n # : max 7x\n return false if Builtins.regexpmatch(ip, \"^([^:]*:){8,}\")\n # 1:2:3::5:6:7:8\n # 1:2:3:4:5:6::8\n if Builtins.regexpmatch(\n ip,\n Ops.add(\n Ops.add(Ops.add(Ops.add(\"^(\", num), \":){1,6}(:\"), num),\n \"){1,6}$\"\n )\n )\n return true\n end\n\n false\n end",
"def valid_ip?(str)\n begin\n IPAddr.new(str).ipv4?\n true\n rescue\n false\n end\nend",
"def valid_ip?(address)\n address.is_a?(String)? validate_number_count(address) : false\nend",
"def is_ipaddr?\n begin\n ip = IPAddr.new(self)\n return ip.to_s == self\n rescue ArgumentError\n return false\n end\n end",
"def valid_ip?(address)\n #ternary that validates number count if string or returns false\n address.is_a?(String) ? validate_number_count(address) : false\nend",
"def ipv6?\n @ipv6_header\n end",
"def CheckNetwork6(network)\n generic_check = CheckNetworkShared(network)\n if generic_check != nil\n return generic_check \n\n # 2001:db8:0::1\n elsif Check6(network)\n return true \n\n # 2001:db8:0::1/64\n elsif Builtins.regexpmatch(\n network,\n Ops.add(\n Ops.add(\n Ops.add(Ops.add(\"^[\", @ValidChars6), \"]+/[\"),\n Netmask.ValidChars6\n ),\n \"]+$\"\n )\n )\n net_parts = Builtins.splitstring(network, \"/\")\n return Check6(Ops.get(net_parts, 0, \"\")) &&\n Netmask.Check6(Ops.get(net_parts, 1, \"\")) \n\n # 2001:db8:0::1/ffff:ffff::0\n elsif Builtins.regexpmatch(\n network,\n Ops.add(\n Ops.add(Ops.add(Ops.add(\"^[\", @ValidChars6), \"]+/[\"), @ValidChars6),\n \"]+$\"\n )\n )\n net_parts = Builtins.splitstring(network, \"/\")\n return Check6(Ops.get(net_parts, 0, \"\")) &&\n Check6(Ops.get(net_parts, 1, \"\"))\n end\n\n false\n end",
"def dot_separated_ip_address?(input_string)\n is_an_ip_number?(input_string.split(\".\"))\nend",
"def valid_ip?(str)\n nums = str.split(\".\").map(&:to_i)\n return false if nums.size != 4\n nums.all? { |num| num >= 0 && num <= 255 }\nend",
"def address_type(addr)\n begin\n ipaddr = IPAddr.new addr\n\n if ipaddr.ipv4?\n return \"IP\"\n elsif ipaddr.ipv6?\n return \"IP6\"\n else\n return Error.new('Unknown IP type')\n end\n rescue\n if /^(\\h{2}:){5}\\h{2}$/ =~ addr\n return \"MAC\"\n else\n return Error.new('Unknown address type')\n end\n end\n end",
"def check_ip_format\n begin\n ::NetAddr.parse_net(\"#{ip}/#{subnet}\")\n rescue Exception => e\n self.errors.add(:subnet, :format, default: e.message)\n return false\n end\n end",
"def valid_ip?(str)\n ip_ary = str.split('.')\n ip_ary.size == 4 && ip_ary.all?{|x| x.match(/^\\d{1,3}$/) && (0..255).include?(x.to_i)}\nend",
"def in_addr(addr)\n if addr =~ /^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$/\n (($1.to_i << 24) + ($2.to_i << 16) + ($3.to_i << 8) + ($4.to_i))\n else\n nil\n end\n end",
"def has_address(interface)\n ip = Facter::Util::IP.get_interface_value(interface, 'ipaddress')\n if ip.nil?\n false\n else\n true\n end\nend",
"def is_an_ip_number?(ip_string)\n /^([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/.match?(ip_string)\nend",
"def valid_ip?(str)\n return false unless str =~ /^\\d+(\\.\\d+){3}$/\n nums = str.split(\".\").map(&:to_i)\n nums.all? {|num| num >= 0 && num <= 255}\nend",
"def Check4(ip)\n return false if ip == nil || ip == \"\"\n num = \"(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\"\n ipv4 = Ops.add(Ops.add(Ops.add(Ops.add(\"^\", num), \"(\\\\.\"), num), \"){3}$\")\n Builtins.regexpmatch(ip, ipv4)\n end",
"def ip?(ip_or_name)\n # Get address always returns an IP, so if nothing changes this was one\n Resolv.getaddress(ip_or_name) == ip_or_name\n rescue Resolv::ResolvError\n false\n end",
"def ip_well_formed?\n\t\tunless ip_address && ip_address =~ /^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$/\n\t\t\terrors.add(:ip_address, \"is malformed\")\n\t\t\treturn false\n\t\tend\n\t\t\n\t\toctets = [$1, $2, $3, $4]\n\n\t\toctets.each { |octet|\n\t\t\tunless octet.to_i <= 256 && octet.to_i >= 0\n\t\t\t errors.add(:ip_address, \"is malformed\")\n\t\t\t return false\n\t\t\tend\n\t\t}\n\t\ttrue\n\tend",
"def valid_ip?(string)\n return false unless string =~ /^\\d+(\\.\\d+){3}$/\n nums = string.split('.').map(&:to_i)\n nums.all? { |num| num >= 0 && num <= 255 }\nend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n if dot_separated_words.size != 4\n return false\n else\n dot_separated_words.each do |word|\n if (0..256).include?(word.to_i)\n next\n else\n return false\n end\n end\n end\n return true\nend",
"def valid_ip(ip)\n ip.split('.').map(&:to_i).select {|x| x.between?(0,255)}.count == 4\nend",
"def old_ip_address?\n dns.any? do |answer|\n answer.class == Net::DNS::RR::A && LEGACY_IP_ADDRESSES.include?(answer.address.to_s)\n end if dns?\n end",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n if dot_separated_words.size == 4\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n return false unless is_an_ip_number?(word)\n end\n true\n else\n false\n end\nend",
"def valid_ip?\n if !@config[:host_allow_ip]\n bool = set_error(:ip_address_forbidden)\n elsif ip_address.include?(\":\")\n bool = ip_address.match(Resolv::IPv6::Regex) ? true : set_error(:ipv6_address_invalid)\n elsif ip_address.include?(\".\")\n bool = ip_address.match(Resolv::IPv4::Regex) ? true : set_error(:ipv4_address_invalid)\n end\n if bool && (localhost? && !@config[:host_local])\n bool = set_error(:ip_address_no_localhost)\n end\n bool\n end",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n break unless is_an_ip_number?(word)\n end\n return true # could be shortened to just true: Ruby returns the result of the last evaluated expression.\nend",
"def tcp_or_udp_protocol?(network_acl_entry)\n %w[6 17].include?(network_acl_entry.protocol.to_s)\n end",
"def valid_ip?(str)\n str_arr = str.split(\".\");\n return false if str_arr.length != 4\n\n str_arr.each do |el|\n return false unless el.match(/^\\d{0,3}$/) && el.to_i >= 0 && el.to_i <= 255\n end\n return true \nend",
"def local_net?(ip = remote_ip)\n bip = ip.split('.').map{ |x| x.to_i }.pack('C4').unpack('N')[0]\n\n # 127.0.0.1/32 => 2130706433\n # 192.168.0.0/16 => 49320\n # 172.16.0.0/12 => 2753\n # 10.0.0.0/8 => 10\n\n { 0 => 2130706433, 16 => 49320, 20 => 2753, 24 => 10}.each do |s,c|\n return true if (bip >> s) == c\n end\n \n return false\n end",
"def only_ip()\n\n ip = ARGV[0]\n\n ipv4 = /^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/\n ipv6 = /^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$/ \n\n if ip =~ ipv4 || ip =~ ipv6\n $onlyip = ip\n ARGV.shift\n else\n usage()\n end\n\nend",
"def check_ip; end",
"def ipaddr?; end",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n return false unless dot_separated_words.size == 4\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n return false unless is_an_ip_number?(word)\n end\n true\nend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split('.')\n return false unless dot_separated_words == 4\n until dot_separated_words.empty?\n word = dot_separated_words.pop\n return false unless is_an_ip_number?(word)\n end\n true\nend",
"def to_ipaddr\n unless ip_addr?\n lookup = `host #{to_s} | grep address`.split(/\\s+/)\n return to_s unless lookup.length == 4\n lookup[3]\n else \n to_s\n end\n end",
"def range?\n ip == network\n end",
"def usable\n if ipv6?\n space\n else\n space - 2\n end\n end",
"def valid_ip?(string)\n string.split(\".\").each do |num_str|\n num = num_str.to_i\n return false if num < 0 || num > 255\n end\n true\nend",
"def valid_ip?(string)\n return false unless string =~ /\\d{0,3}\\.\\d{0,3}\\.\\d{0,3}\\.\\d{0,3}/\n\n string.split(\".\").each do |sub_str|\n if !sub_str.to_i.between?(0, 255)\n return false\n end\n end\n\n return true\nend",
"def address_is_local?(address)\n Rails.configuration.local_addresses.any? { |spec| address_matches spec.strip.split('.'), address.strip.split('.') }\nend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n return false unless dot_separated_words.size == 4\n\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n return false unless is_an_ip_number?(word)\n end\n return true\nend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n return false unless dot_separated_words.size == 4\n \n dot_separated_words.each do |word|\n return false unless (0..256).include?(word.to_i)\n end\n\n return true\nend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n break unless is_an_ip_number?(word)\n end\n return true\nend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n break unless is_an_ip_number?(word)\n end\n return true\nend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n break unless is_an_ip_number?(word)\n end\n return true\nend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split('.')\n return false unless dot_separated_words.size == 4\n\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n return false unless is_an_ip_number?(word)\n end\n\n true\nend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n return false unless dot_separated_words.size == 4\n\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n return false unless is_an_ip_number?(word)\n end\n true\nend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n # return \"Invalid\" if dot_separated_words.length != 4\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n return false unless is_an_ip_number?(word)\n end\n return true\nend",
"def ipv4?\n @ipv4_header\n end",
"def is_ip? (ip)\n\t\tputs \"Validate the IP format is valid: #{ip}\" if @verbose\n\t\tbegin\n\t\t\tip=ip.strip\n\t\t\traise \"This is an URL: #{ip}\" if is_url?(ip)\n\t\t\tif ip =~ /\\d+\\.\\d+\\.\\d+.\\d+/ and ip !~ /\\/\\d+/\n\t\t\t\tocts=ip.split('.')\n\t\t\t\treturn false unless octs.size==4\n\t\t\t\tocts.map { |x| return false unless x.to_i >=0 and x.to_i <=255 }\n\t\t\telse\n\t\t\t\treturn false\n\t\t\tend\n\t\t\tputs \"Confirmed as a valid IP: #{ip}\" if @verbose\n\t\t\treturn true\n\t\trescue => ee\n\t\t\tputs \"Exception on method is_ip? for #{ip}: #{ee}\" if @verbose\n\t\t\treturn false\n\t\tend\n\tend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n return false unless dot_separated_words.size == 4\n\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n return false unless is_an_ip_number?(word)\n end\n\n true\nend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n return false unless dot_separated_words.size == 4\n\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n return false unless is_an_ip_number?(word)\n end\n\n true\nend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n return false unless dot_separated_words.size == 4\n\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n return false unless is_an_ip_number?(word)\n end\n\n true\nend",
"def prefer_ipv4(addresses)\n return nil unless addresses.is_a?(Array)\n\n addresses.find { |ip| IPAddress.valid_ipv4?(ip) } ||\n addresses.find { |ip| IPAddress.valid_ipv6?(ip) }\n end",
"def ipv4\n puts 'For the more accurate Regex of IP please refer to ruby standard library \"resolv\"'\n puts 'require \"resolve\"'\n puts 'Resolv::IPv4::Regex256'\n puts 'Resolv::IPv4::Regex'\n\n ip_octet = '(\\d|[01]?\\d\\d|2[0-4]\\d|25[0-5])'.freeze\n /\\A#{ip_octet}\\.#{ip_octet}\\.#{ip_octet}\\.#{ip_octet}\\z/\n end",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n return false unless dot_separated_words.size == 4\n \n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n return false unless is_an_ip_number?(word)\n end\n true\nend",
"def checkip?(ip)\n if ip =~ %r=^172.|^192.168.|^10.$=\n return \"Private Class C IP Range\"\n elsif ip =~ %r=^127.$=\n return \"Local Loopback\"\n end\n end",
"def get_public_ipv4\n # Socket.ip_address_list.detect{|intf| intf.ipv4? and !intf.ipv4_loopback? and !intf.ipv4_multicast? and intf.ipv4_private?}\n Socket.ip_address_list.detect{|intf| intf.ipv4_private?}\nend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n return false if dot_separated_words.size != 4\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n return false if !is_a_number?(word)\n end\n true\nend",
"def validate_ipaddr(ip)\n ip_regex = /\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b/\n if ip_regex =~ ip\n return true\n else\n return false\n end\n end",
"def check_ip_any_alias\n case @options[:ipaddr]\n when nil, '', 'any', /^\\s*$/\n @options[:ipaddr] = '0.0.0.0'\n @options[:netmask] = 0\n end\n end",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n return false unless dot_separated_words.size == 4\n\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n return false unless is_an_ip_number?(word)\n end\n true\nend",
"def ip_v6_cidr; end",
"def valid_ip?(string)\n decimal_counter = 0\n range_counter = 0\n\n strArray = string.split('')\n strArray.each do |char|\n if char == '.'\n decimal_counter += 1\n end\n end\n\n numArray = string.split('.')\n numArray.each do |int|\n int = int.to_i\n if int >= 0 && int <= 255\n range_counter += 1\n else\n return\n end\n end\n\n if decimal_counter == 3 && range_counter == 4\n p \"true\"\n return true\n else\n p \"false\"\n return false\n end\nend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n return false unless dot_separated_words.size == 4\n \n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n return false unless is_an_ip_number?(word)\n end\n\n true\nend",
"def dot_separated_ip_address?(input_string)\r\n dot_separated_words = input_string.split(\".\")\r\n while dot_separated_words.size > 0 do\r\n word = dot_separated_words.pop\r\n break unless is_an_ip_number?(word)\r\n end\r\n return true\r\nend",
"def dot_separated_ip_address?(input_string)\r\n dot_separated_words = input_string.split(\".\")\r\n return false unless dot_separated_words.size == 4 #\r\n\r\n while dot_separated_words.size > 0 do\r\n word = dot_separated_words.pop\r\n return false unless is_an_ip_number?(word)\r\n end\r\n\r\n true\r\nend",
"def is_an_ip_number?(input_str)\n input_str.to_i.between?(0,255)\nend",
"def dot_separated_ip_addresses?(input_string)\n dot_separated_words = input_string.split(\".\")\n return false unless dot_separated_words.size == 4\n\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n return false unless is_an_ip_number?(word)\n end\n\n true\nend",
"def address_bound?(ip, port)\n out, err, rc = shellCmd(\"/usr/sbin/lsof -i @#{ip}:#{port}\")\n return rc != 0\n end",
"def an_ip_number?(element)\n element.to_i >= 0 && element.to_i <= 255\nend",
"def has_ip?(ip_addr)\n if IPAddr.new(subnet_cidr) === IPAddr.new(ip_addr)\n # ip within subnet\n local_ips.include? ip_addr\n else\n # ip outside subnet\n public_ips.has_value? ip_addr\n end\n end",
"def check_ip_address\n if ip_address\n result = IPAddress.valid? ip_address\n errors.add( 'Incorrect IP formatting' ) unless result\n end\n end",
"def ip_valid?\n return if ip.blank?\n\n IPAddr.new(ip.strip, Socket::AF_INET)\n rescue IPAddr::InvalidAddressError, IPAddr::AddressFamilyError\n errors.add(:ip, :invalid)\n end",
"def dot_separated_ip_addresses?(input_string)\n dot_separated_words = input_string.split(\".\")\n \n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n break unless is_an_ip_number?(word)\n end\n return true\nend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n break if !is_a_number?(word)\n end\n return true\nend",
"def get_ip_address\n items = `ifconfig | grep \"inet addr\"`.split\n addresses = []\n items.each do |item|\n addresses << item if item =~ /addr:/\n end\n ip = \"\"\n addresses.each do |address|\n ip = address.split(':')[1]\n if ip != '127.0.0.1'\n break\n end\n end\n ip\nend",
"def protocol_ip?\n self.protocol_type == PROTOCOL_IP\n end",
"def CheckNetwork4(network)\n generic_check = CheckNetworkShared(network)\n if generic_check != nil\n return generic_check \n\n # 192.168.0.1, 0.8.55.999\n elsif Check4(network)\n return true \n\n # 192.168.0.0/20, 0.8.55/158\n elsif Builtins.regexpmatch(\n network,\n Ops.add(Ops.add(\"^[\", @ValidChars4), \"]+/[0-9]+$\")\n )\n net_parts = Builtins.splitstring(network, \"/\")\n return Check4(Ops.get(net_parts, 0, \"\")) &&\n Netmask.CheckPrefix4(Ops.get(net_parts, 1, \"\")) \n\n # 192.168.0.0/255.255.255.0, 0.8.55/10.258.12\n elsif Builtins.regexpmatch(\n network,\n Ops.add(\n Ops.add(Ops.add(Ops.add(\"^[\", @ValidChars4), \"]+/[\"), @ValidChars4),\n \"]+$\"\n )\n )\n net_parts = Builtins.splitstring(network, \"/\")\n return Check4(Ops.get(net_parts, 0, \"\")) &&\n Netmask.Check4(Ops.get(net_parts, 1, \"\"))\n end\n\n false\n end"
] | [
"0.8162605",
"0.78093964",
"0.78093964",
"0.74765307",
"0.74765307",
"0.7452555",
"0.7430677",
"0.73560476",
"0.7283809",
"0.7238633",
"0.723357",
"0.7224835",
"0.71691257",
"0.71456313",
"0.7126125",
"0.7116245",
"0.71144",
"0.7030418",
"0.701316",
"0.69777775",
"0.6954711",
"0.69497544",
"0.69425863",
"0.6869446",
"0.68101865",
"0.67342305",
"0.6692312",
"0.66213244",
"0.6618954",
"0.66184884",
"0.6564407",
"0.656324",
"0.653205",
"0.64729846",
"0.64613134",
"0.64562637",
"0.64409345",
"0.64135367",
"0.6407344",
"0.6399217",
"0.63975924",
"0.6372132",
"0.63509256",
"0.6349615",
"0.6332782",
"0.63266957",
"0.6323609",
"0.6305107",
"0.6303066",
"0.63028723",
"0.6298709",
"0.62814295",
"0.6270259",
"0.62536794",
"0.62495947",
"0.6232188",
"0.62216425",
"0.6219431",
"0.6202735",
"0.62016255",
"0.6198274",
"0.6195587",
"0.61939895",
"0.61916727",
"0.61916727",
"0.61916727",
"0.61876094",
"0.61876047",
"0.61815476",
"0.6171251",
"0.614557",
"0.6145317",
"0.6145317",
"0.6145317",
"0.6145266",
"0.6143941",
"0.6143229",
"0.61409014",
"0.613792",
"0.612215",
"0.6119758",
"0.6117745",
"0.6103844",
"0.61015534",
"0.6100047",
"0.6084646",
"0.6081438",
"0.607686",
"0.60745287",
"0.6066109",
"0.605512",
"0.605384",
"0.6048796",
"0.60464615",
"0.6045655",
"0.603582",
"0.60340786",
"0.6034048",
"0.60292125",
"0.6017866"
] | 0.7560409 | 3 |
Return an array of addresses that match either IPv4 or IPv6 | def select_ipvers(addresses, ipvers)
addresses = [addresses] unless addresses.is_a?(Array)
addresses.select {|addr| detect_ipvers(addr) == ipvers}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ips\n regex = /\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b/\n all_ips = Socket.ip_address_list.map(&:inspect_sockaddr)\n all_ips.select { |ip| !!ip.match(regex) }\n end",
"def prefer_ipv4(addresses)\n return nil unless addresses.is_a?(Array)\n\n addresses.find { |ip| IPAddress.valid_ipv4?(ip) } ||\n addresses.find { |ip| IPAddress.valid_ipv6?(ip) }\n end",
"def find\n addrs = Socket.ip_address_list.select do |addr|\n addr.ipv4? and not(addr.ipv4_loopback?) and not(addr.ipv4_multicast?)\n end\n if not(addrs.empty?)\n privates = addrs.select{|addr| addr.ipv4_private?}\n not_privates = addrs - privates\n privates = privates.sort{|a,b| a.ip_address <=> b.ip_address}\n not_privates = not_privates.sort{|a, b| a.ip_address <=> b.ip_address}\n (privates + not_privates).map {|addr| addr.ip_address}\n else\n Socket.ip_address_list.select{|addr| addr.ipv4_loopback?}.map{|addr| addr.ip_address}\n end\n end",
"def available_ips\n range = conf['addresses']['range']\n unless(range.to_s.empty?)\n range = (range.split('-').first.split('.').last..range.split('-').last).map{|oct|\n \"#{range.split('-').first.split('.').slice(0,3).join('.')}.#{oct}\"\n }\n else\n range = []\n end\n (conf['addresses']['static'] + range).compact\nend",
"def get_ip_addresses\n sa = MainSettings.instance\n begin\n s = UDPSocket.new(Socket::AF_INET)\n s.connect(\"8.8.8.8\", 1)\n if (s.addr[0] == \"AF_INET\")\n @ipv4 = IPAddr.new(s.addr.last)\n end\n rescue SocketError => e\n $stderr.puts \"Unable to determine IPv4 address: #{e}\"\n rescue Errno::ENETUNREACH => e\n $stderr.puts \"Unable to determine IPv4 address: #{e}\"\n end\n puts \"Finished acquiring IPv4 address\" if $verbose\n\n# begin\n# s = UDPSocket.new(Socket::AF_INET6)\n# s.connect(\"2001:4860:b006::2\", 1)\n# if (s.addr[0] == \"AF_INET6\")\n# @ipv6 = IPAddr.new(s.addr.last)\n# end\n# rescue SocketError => e\n# $stderr.puts \"Unable to determine IPv6 address: #{e}\"\n# rescue Errno::ENETUNREACH => e\n# $stderr.puts \"Unable to determine IPv6 address: #{e}\"\n# end\n# puts \"Finished acquiring IPv6 address\" if $verbose\n end",
"def ip_addresses\n @entries.collect do |entry|\n entry.ip_address\n end.compact || []\n end",
"def two_factor_excluded_ip_addresses\n []\n end",
"def find_good_ip_addr list\n list.each do |addr|\n triplets = addr.split('.')\n if not triplets[0].to_i == 255 and not triplets[2].to_i == 255\n return addr\n end\n end\n nil\nend",
"def ips_from(header)\n # Split the comma-separated list into an array of strings\n ips = @env[header] ? @env[header].strip.split(/[,\\s]+/) : []\n ips.select do |ip|\n begin\n # Only return IPs that are valid according to the IPAddr#new method\n range = IPAddr.new(ip).to_range\n # we want to make sure nobody is sneaking a netmask in\n range.begin == range.end\n rescue ArgumentError\n nil\n end\n end\n end",
"def extract_addresses(address_list)\n addresses = []\n address_list.each do |address|\n addresses << address[:address] if ['ipv4', 'hostname'].include?(address[:type])\n end\n addresses\nend",
"def get_addresses\n return [get_pubkey_address] if is_pubkey?\n return [get_hash160_address] if is_hash160? || is_namecoin?\n return get_multisig_addresses if is_multisig?\n []\n end",
"def listen_addresses\n node['network']['interfaces'].map do |iface, data| \n data[\"addresses\"].select { |addr, data| data[\"family\"] == \"inet\" }.keys[0]\n end\nend",
"def ips_for(name)\n resolvers.each do |r|\n ips = r.getaddresses(name)\n\n return ips unless ips.nil? || ips.empty?\n end\n\n []\n end",
"def wanted_ips\n ips = [new_resource.address, nic.IPAddress].flatten.compact\n\n # Return only IPv4 IPs\n ips.select { |ip| ip =~ /\\./ }\n end",
"def only_ip()\n\n ip = ARGV[0]\n\n ipv4 = /^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/\n ipv6 = /^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$/ \n\n if ip =~ ipv4 || ip =~ ipv6\n $onlyip = ip\n ARGV.shift\n else\n usage()\n end\n\nend",
"def ipv6_address?(addr)\n return true if addr =~ /:/\n return false\n end",
"def list_ips options={}\n if ip_version==6\n # Only list ips that have a resolutions\n AddressResolution.for_subnet(self).map &:ip\n else\n if range?\n ips = []\n if options[:include_network]\n ips << cidr.nth(0).to_s\n end\n (cidr.len - 2).times do |i|\n ips << cidr.nth(i + 1).to_s\n end\n if options[:include_gateway]\n ips << cidr.nth(cidr.len - 1).to_s\n end\n ips\n #cidr.to_a#.enumerate[1..-2]\n else\n [ip]\n end\n end\n end",
"def private_ip_addresses\n addresses = []\n if network_interfaces.respond_to? :map\n addresses = network_interfaces.map { |nic| nic[:network_ip] }\n end\n addresses\n end",
"def okIP(addr)\nreturn addr != \"0.0.0.0\" &&\n addr != \"255.255.255.255\" &&\n !addr.match(/^169\\.254.*/) &&\n !addr.match(/^10.*/) &&\n !addr.match(/^172\\.[1-3].*/) && # TODO: match the block better\n !addr.match(/^192\\.168.*/)\nend",
"def reserved_addresses\n IPSet.new(list_addresses.map{|a| a.address.to_host })\n end",
"def getaddresses(name)\n return [name] if ADDRESS_REGEX.match(name)\n @resolvers.each do |resolver|\n addresses = []\n resolver.each_address(name) { |address| addresses << address }\n return addresses unless addresses.empty?\n end\n []\n end",
"def ipv4\n puts 'For the more accurate Regex of IP please refer to ruby standard library \"resolv\"'\n puts 'require \"resolve\"'\n puts 'Resolv::IPv4::Regex256'\n puts 'Resolv::IPv4::Regex'\n\n ip_octet = '(\\d|[01]?\\d\\d|2[0-4]\\d|25[0-5])'.freeze\n /\\A#{ip_octet}\\.#{ip_octet}\\.#{ip_octet}\\.#{ip_octet}\\z/\n end",
"def ipv4_address?(n)\n arr = n.split('.')\n if arr.count != 4 ||\n !('1'..'255').include?(arr[0])\n return false\n end\n\n arr.each do |num|\n return false if !('1'..'255').include?(num)\n end\n true\nend",
"def addresses\n private_ip_addresses + public_ip_addresses\n end",
"def public_ip_addresses\n addresses = []\n if network_interfaces.respond_to? :flat_map\n addresses = network_interfaces.flat_map do |nic|\n if nic[:access_configs].respond_to? :each\n nic[:access_configs].select { |config| config[:name] == \"External NAT\" }\n .map { |config| config[:nat_ip] }\n else\n []\n end\n end\n end\n addresses\n end",
"def consider_local(*args)\n local_addresses.concat(args.flatten.map { |a| IPAddr.new(a) })\n end",
"def private_ipaddresses\n # Create an array to hold the addresses\n addresses = []\n\n # Iterate around the filter that has been populated\n entries.each do |entry|\n entry.ip_configurations.each do |ip_config|\n addresses << ip_config['private_ipaddress']\n end\n end\n\n # return the array to the calling function\n addresses\n end",
"def ip_names\n Socket.getifaddrs.map do |ifnames|\n next unless ifnames.addr.ipv4?\n\n puts \" #{ifnames.name}\"\n end\nend",
"def all_ips_for(vm)\n vm.guest.net.map(&:ipAddress).flatten\n end",
"def get_public_ipv4\n # Socket.ip_address_list.detect{|intf| intf.ipv4? and !intf.ipv4_loopback? and !intf.ipv4_multicast? and intf.ipv4_private?}\n Socket.ip_address_list.detect{|intf| intf.ipv4_private?}\nend",
"def validate_ip_addresses(config)\n ips = []\n [*config['nodes']].each do |node|\n if ip = node['ip']\n raise_ip_err(ip, node['name']) if ips.include?(ip)\n ips.push(ip)\n end\n end\n log.debug \"ips = #{ips}\"\n end",
"def ipv4?(string)\n !!string.match(/(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/)\nend",
"def ip_all\n Socket.getifaddrs.map do |iface|\n next unless iface.addr.ipv4?\n\n puts \"\\nName: : #{iface.name}\"\n puts \"Address: :' + #{iface.addr.ip_address}\"\n end\nend",
"def ipv6?\n self.kind_of? IPAddress::IPv6\n end",
"def ipv6?\n self.kind_of? IPAddress::IPv6\n end",
"def validate_ip(value)\n case value\n when Resolv::IPv4::Regex\n return true\n when Resolv::IPv6::Regex\n return true\n else\n return false\n end\n end",
"def lookupd_http_addresses\n @lookups ||= ENV.fetch(\"NSQLOOKUPD_HTTP_ADDRESS\", \"\").split(/, ?|\\s+/).map(&:strip)\n end",
"def dot_seperated_ip_address?(input_string)\n numbers = input_string.split('.')\n return false if numbers.size != 4\n\n numbers.each do |num|\n return false if is_an_ip_number?(num) == false\n end\n true\nend",
"def validate_ip(value)\n case value\n when Resolv::IPv4::Regex\n return true\n when Resolv::IPv6::Regex\n return true\n else\n return false\n end\n end",
"def Check6(ip)\n return false if ip == nil || ip == \"\"\n\n #string num = \"([1-9a-fA-F][0-9a-fA-F]*|0)\";\n num = \"([0-9a-fA-F]{1,4})\"\n\n # 1:2:3:4:5:6:7:8\n if Builtins.regexpmatch(\n ip,\n Ops.add(Ops.add(Ops.add(Ops.add(\"^\", num), \"(:\"), num), \"){7}$\")\n )\n return true\n end\n # ::3:4:5:6:7:8\n if Builtins.regexpmatch(ip, Ops.add(Ops.add(\"^:(:\", num), \"){1,6}$\"))\n return true\n end\n # 1:2:3:4:5:6::\n if Builtins.regexpmatch(ip, Ops.add(Ops.add(\"^(\", num), \":){1,6}:$\"))\n return true\n end\n # :: only once\n return false if Builtins.regexpmatch(ip, \"::.*::\")\n # : max 7x\n return false if Builtins.regexpmatch(ip, \"^([^:]*:){8,}\")\n # 1:2:3::5:6:7:8\n # 1:2:3:4:5:6::8\n if Builtins.regexpmatch(\n ip,\n Ops.add(\n Ops.add(Ops.add(Ops.add(\"^(\", num), \":){1,6}(:\"), num),\n \"){1,6}$\"\n )\n )\n return true\n end\n\n false\n end",
"def exact_ip_address?(str)\n !!(str =~ /^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/)\nend",
"def addresses\n collect { |a| a.address }\n end",
"def addresses network=nil\n if network\n data = on_network network\n ips = data.map { |v| (v.has_key? :ip) ? v[:ip] : nil }\n else\n vips.each_key.map { |k| vips[k][:ip] }\n end\n end",
"def lookup_addresses(data)\n return @servers\n end",
"def wildcard_check\n wildcard_ips = []\n\n # look for wildcard IP addresses\n 4.times do\n # random subdomain string\n sub = (0..20).map { (65 + rand(26)).chr }.join.downcase\n random_fqdn = \"#{sub}.#{@suffix}\"\n\n # if this resolves then we have a wildcard IP\n resolved = resolver(random_fqdn)\n wildcard_ips << resolved unless resolved.empty?\n end\n # return all unique wildcard IP addresses\n # this will return an empty array if none are found\n wildcard_ips.compact.uniq\n end",
"def include? remote_ip_address\n ip_addresses.any? do |ip_address|\n ip_address.include? remote_ip_address\n end\n end",
"def valid_ip(ip)\n ip.split('.').map(&:to_i).select {|x| x.between?(0,255)}.count == 4\nend",
"def on_network network\n matched = Array.new\n puts \"DBG: vips: #{vips.inspect}\"\n vips.each do |name, data|\n if data.has_key? :net\n # vip has a net key push it\n if data[:net] == network\n matched.push data\n end\n # default with no key is public\n elsif network == \"public\"\n matched.push data\n end\n end\n matched\n end",
"def Check4(ip)\n return false if ip == nil || ip == \"\"\n num = \"(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\"\n ipv4 = Ops.add(Ops.add(Ops.add(Ops.add(\"^\", num), \"(\\\\.\"), num), \"){3}$\")\n Builtins.regexpmatch(ip, ipv4)\n end",
"def &(in_ip)\n raise RuntimeError, \"Can not compare IPV4 with IPV6!\" if @version != in_ip.version\n Ip.new(@ip_int & in_ip.to_i, @version)\n end",
"def available_addresses\n @subnet.hosts(range: allocation_range, exclude: reserved_addresses)\n end",
"def valid_ip?(str)\n ip_ary = str.split('.')\n ip_ary.size == 4 && ip_ary.all?{|x| x.match(/^\\d{1,3}$/) && (0..255).include?(x.to_i)}\nend",
"def dot_separated_ip_addresses?(input_string)\n dot_separated_words = input_string.split(\".\")\n \n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n break unless is_an_ip_number?(word)\n end\n return true\nend",
"def dot_separated_ip_addresses?(input_string)\n dot_separated_words = input_string.split(\".\")\n return false unless dot_separated_words.size == 4\n\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n return false unless is_an_ip_number?(word)\n end\n\n true\nend",
"def detect_ipvers(address)\n if address =~ /^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/\n :ipv4\n elsif address =~ /\\h{0,4}::?\\h{1,4}/i\n :ipv6\n else\n nil\n end\n end",
"def supernets()\n supernets = []\n @v4_root.tag[:Subnets].each {|x| supernets.push( NetAddr.cidr_build(x.version, x.to_i(:network), x.to_i(:netmask)) )}\n @v6_root.tag[:Subnets].each {|x| supernets.push( NetAddr.cidr_build(x.version, x.to_i(:network), x.to_i(:netmask)) )}\n return (supernets)\n end",
"def wildcard_mask\n if self.ipv4?\n (@mask_addr ^ IPAddr::IN4MASK).to_ip\n else\n (@mask_addr ^ IPAddr::IN6MASK).to_ip\n end\n end",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n if dot_separated_words.size != 4\n return false\n else\n dot_separated_words.each do |word|\n if (0..256).include?(word.to_i)\n next\n else\n return false\n end\n end\n end\n return true\nend",
"def get_network_by_interface(interface)\n\n ifconfig = `ifconfig`.split(\"\\n\\n\").index_by{|x| x[/\\w+/,0]}\n inet = ifconfig[interface][/inet addr:([^\\s]*)/, 1].split('.')\n broadcast = ifconfig[interface][/Bcast:([^\\s]*)/, 1].split('.')\n mask = ifconfig[interface][/Mask:([^\\s]*)/, 1].split('.')\n\n start_first = inet[0].to_i & mask[0].to_i\n start_second = inet[1].to_i & mask[1].to_i\n start_third = inet[2].to_i & mask[2].to_i\n start_fourth = inet[3].to_i & mask[3].to_i\n\n first_range = start_first..broadcast[0].to_i\n second_range = start_second..broadcast[1].to_i\n third_range = start_third..broadcast[2].to_i\n fourth_range = start_fourth..broadcast[3].to_i\n \n @ips_to_check = []\n first_range.each do |first|\n second_range.each do |second|\n third_range.each do |third|\n fourth_range.each do |fourth|\n @ips_to_check << \"#{first}.#{second}.#{third}.#{fourth}\"\n end\n end\n end\n end\n puts \"Checking ips in (#{first_range}).(#{second_range}).(#{third_range}).(#{fourth_range})\"\n \n @ips_to_check\n end",
"def ip_ranges_for_ip(lines, ip)\n total = lines.size\n i = 0\n while i < total and lines.at(i) <= ip\n i += 2\n end\n [[lines.at(i-2), lines.at(i)]]\n end",
"def test_resolver_converts_ipaddrs_array\n @parser.log_reader\n assert_equal @parser.ipaddrs_q.size, 12\n assert_equal @parser.records_q.size, 12\n @parser.resolve_names\n assert_equal @parser.domains_hash.map { |k,v| [ k, v[0] ] }.sort, [\n [\"208.77.188.166\", \"www.example.com\"],\n [\"74.125.67.100\", \"gw-in-f100.google.com\"],\n [\"75.119.201.189\", \"apache2-moon.legs.dreamhost.com\"],\n [\"75.146.57.34\", \"greed.zenspider.com\"]\n]\n end",
"def get_addresses apts\n return apts.map { |apt| apt.address }\n end",
"def scan_range(ip_range)\n active_ips = ip_range.select { |ip| Net::Ping::External.new(ip).ping? }\nend",
"def check_ip_any_alias\n case @options[:ipaddr]\n when nil, '', 'any', /^\\s*$/\n @options[:ipaddr] = '0.0.0.0'\n @options[:netmask] = 0\n end\n end",
"def address_matches\n filtered_matches(ignore: [:first_name, :family_name], perfect: [:street, :city])\n end",
"def resolve!\n Resolv.each_address(host) do |address|\n return @ip = address if address =~ pattern\n end\n end",
"def is_valid_ip?(address)\n octets = address.split('.')\n return false if octets.length != 4\n octets.each {|octet| return false if octet.to_i > 255 || octet.to_i < 0}\n true\nend",
"def dot_separated_ip_address?(input_string)\n dot_separated_words = input_string.split(\".\")\n return false unless dot_separated_words.size == 4\n \n dot_separated_words.each do |word|\n return false unless (0..256).include?(word.to_i)\n end\n\n return true\nend",
"def cloud_ip_addresses\n cloud_ips.map { |cip| cip[\"public_ip\"] }\n end",
"def summ_IPv6Net(list)\n\t\tlist = Util.filter_IPv6Net(list)\n\t\tif (list.length>1)\n\t\t\tlist = Util.discard_subnets(list)\n\t\t\treturn Util.summ_peers(list)\n\t\tend\n\t\treturn [].concat(list)\n\tend",
"def to_addrs\n to ? [to].flatten : []\n end",
"def old_ip_address?\n dns.any? do |answer|\n answer.class == Net::DNS::RR::A && LEGACY_IP_ADDRESSES.include?(answer.address.to_s)\n end if dns?\n end",
"def determine_ips\n ips = @info[:ip] = {private: [], public: []}\n\n ifc_cmd = \"/sbin/ifconfig|grep 'inet addr'|grep -v ':127'|sed -e \" \\\n \"'s/.*addr:\\([0-9.]*\\) .*/\\\\1/'\"\n ifconfig = @shell.query('IFCONFIG', ifc_cmd)\n\n ifconfig.each_line do |ip|\n ip.strip!\n ips[rfc1918?(ip)] << ip\n end\n end",
"def has_ipv6_ip_address?\n self.options[:ip].is_a?(String) && self.options[:ip].include?(':')\n end",
"def from_addrs\n from ? [from].flatten : []\n end",
"def peer_list\n ip_list = []\n raw_peers.each_slice(6) { |e| ip_list << e if e.length == 6 }\n\n ip_list.map! { |e| { :ip => e[0..3].join('.'), :port => (e[4] * 256) + e[5] } }\n end",
"def wanted_netmasks\n netmasks = [new_resource.netmask, nic.IPSubnet].flatten.compact\n\n # Return only IPv4 netmasks\n netmasks.select { |ip| ip =~ /\\./ }\n end",
"def valid_ip?(str)\n nums = str.split(\".\").map(&:to_i)\n return false if nums.size != 4\n nums.all? { |num| num >= 0 && num <= 255 }\nend",
"def ip_address? (str)\n\treturn str.match? /^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/\nend",
"def is_an_ip_number?(str_array)\n new_array = str_array.map do |str| \n if str.to_i >= 0 && str.to_i <= 255\n true\n else\n false\n end\n end\nend",
"def local_ips\n list = cmd(\"addr show dev #{name} primary\", sudo: false, errors: true) +\n cmd(\"addr show dev #{name} secondary\", sudo: false, errors: true)\n list.lines.grep(/inet ([0-9\\.]+)\\/.* #{name}/i){ $1 }\n rescue\n raise Errors::UnknownInterface, \"Interface #{name} not found on this machine\" unless exists?\n raise\n end",
"def expand_cidr(arg)\n\t\tstart,stop = Rex::Socket.cidr_crack(arg)\n\t\tif !start or !stop\n\t\t\treturn false\n\t\tend\n\t\trange = Range.new\n\t\trange.start = Rex::Socket.addr_atoi(start)\n\t\trange.stop = Rex::Socket.addr_atoi(stop)\n\t\trange.ipv6 = (arg.include?(\":\"))\n\n\t\treturn [range]\n\tend",
"def mx_ips\n return [\"0.0.0.0\"] if @dns_disabled\n mxers.map { |m| m[1] }\n end",
"def is_addr(s)\n s.match(/^[0-9a-fA-F]+:$/) != nil\nend",
"def passive\n\tm=[]\n\n\t# Via HTTP header\n\tm << { :string=>@headers[\"x-forwarded-for\"].to_s } unless @headers[\"x-forwarded-for\"].nil?\n\n\t# Return passive matches\n\tm\nend",
"def ip\n @ip ||= select { |type,value| type == :ip }.map do |(type,value)|\n IPAddr.new(value)\n end\n end",
"def san_interfaces\n if san_nics.length == sans.length \n ports = san_network_ports().sort\n ips = san_nodes.map{|x| x.ip_address.to_s }.sort\n #return [] if ports.length != ips.length \n ports.zip(ips)\n else\n []\n end\n end",
"def validate_ips(ips)\n\t\tret = true\n\t\tbegin\n\t\t\tips.split(' ').each {|ip|\n\t\t\t\tunless Rex::Socket::RangeWalker.new(ip).ranges\n\t\t\t\t\tret = false\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\t\t}\n\t\trescue\n\t\t\tret = false\n\t\tend\n\t\treturn ret\n\tend",
"def parse(parseme)\n\t\treturn nil if not parseme\n\t\tranges = []\n\t\tparseme.split(', ').map{ |a| a.split(' ') }.flatten.each { |arg|\n\t\t\tif arg.include?(\"/\")\n\t\t\t\t# Then it's CIDR notation and needs special case\n\t\t\t\treturn false if arg =~ /[,-]/ # Improper CIDR notation (can't mix with 1,3 or 1-3 style IP ranges)\n\t\t\t\treturn false if arg.scan(\"/\").size > 1 # ..but there are too many slashes\n\t\t\t\tip_part,mask_part = arg.split(\"/\")\n\t\t\t\treturn false if ip_part.nil? or ip_part.empty? or mask_part.nil? or mask_part.empty?\n\t\t\t\treturn false if mask_part !~ /^[0-9]{1,2}$/ # Illegal mask -- numerals only\n\t\t\t\treturn false if mask_part.to_i > 32 # This too -- between 0 and 32.\n\t\t\t\tbegin\n\t\t\t\t\tRex::Socket.addr_atoi(ip_part) # This allows for \"www.metasploit.com/24\" which is fun.\n\t\t\t\trescue Resolv::ResolvError\n\t\t\t\t\treturn false # Can't resolve the ip_part, so bail.\n\t\t\t\tend\n\n\t\t\t\texpanded = expand_cidr(arg)\n\t\t\t\tif expanded\n\t\t\t\t\tranges += expanded\n\t\t\t\telse\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\telsif arg.include?(\":\")\n\t\t\t\t# Then it's IPv6\n\t\t\t\t# Can't really do much with IPv6 right now, just return it and\n\t\t\t\t# hope for the best\n\t\t\t\taddr = Rex::Socket.addr_atoi(arg)\n\t\t\t\tranges.push [addr, addr, true]\n\t\t\telsif arg =~ /[^-0-9,.*]/\n\t\t\t\t# Then it's a domain name and we should send it on to addr_atoi\n\t\t\t\t# unmolested to force a DNS lookup.\n\t\t\t\taddr = Rex::Socket.addr_atoi(arg)\n\t\t\t\tranges.push [addr, addr]\n\t\t\telsif arg =~ /^([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)$/\n\t\t\t\t# Then it's in the format of 1.2.3.4-5.6.7.8\n\t\t\t\t# Note, this will /not/ deal with DNS names, or the fancy/obscure 10...1-10...2\n\t\t\t\tbegin \n\t\t\t\t\taddrs = [Rex::Socket.addr_atoi($1), Rex::Socket.addr_atoi($2)]\n\t\t\t\t\treturn false if addrs[0] > addrs[1] # The end is greater than the beginning.\n\t\t\t\t\tranges.push [addrs[0], addrs[1]]\n\t\t\t\trescue Resolv::ResolvError # Something's broken, forget it.\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\telse\n\t\t\t\texpanded = expand_nmap(arg)\n\t\t\t\tif expanded\n\t\t\t\t\tranges += expanded\n\t\t\t\telse\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\tend\n\t\t}\n\n\t\treturn ranges\n\tend",
"def anonymize\n ipv4 = (m = value.match(/\\d+\\.\\d+\\.\\d+\\.\\d+$/)) ? m[0] : \"\"\n ipv6 = value.gsub(ipv4, \"\")\n ipv6 += \":\" if ipv4.present? && ipv6.present?\n ipv4 = ipv4.gsub(/\\.\\d+$/, \".0\")\n ipv6 = ipv6.gsub(/:(\\d|[a-f])*:(\\d|[a-f])*:(\\d|[a-f])*:(\\d|[a-f])*:(\\d|[a-f])*$/, \"::\")\n IPAddress.new([ipv6, ipv4].keep_if { |ip| ip.present? }.join)\n end",
"def host_in_range?(ip, ip_address_start, ip_address_end)\n ip >= ip_address_start && ip <= ip_address_end\n end",
"def get_ip_address\n items = `ifconfig | grep \"inet addr\"`.split\n addresses = []\n items.each do |item|\n addresses << item if item =~ /addr:/\n end\n ip = \"\"\n addresses.each do |address|\n ip = address.split(':')[1]\n if ip != '127.0.0.1'\n break\n end\n end\n ip\nend",
"def host_2_ips (hostname)\n\t\tbegin\n\t\t\tips=Array.new\n\t\t\tif is_ip?(hostname)\n\t\t\t\tips.push(hostname)\n\t\t\t\treturn ips\n\t\t\telse\n\t\t\t\tips = Resolv.getaddresses(hostname)\n\t\t\t\tif (ips.empty?) then\n\t\t\t\t\tputs \"Failed to resolve #{hostname}\" if @verbose\n\t\t\t\t\treturn nil\n\t\t\t\telse\n\t\t\t\t\treturn ips\n\t\t\t\tend\n\t\t\tend\n\t\trescue => ee\n\t\t\tputs \"Exception on method host_2_ips for host #{hostname}: #{ee}\" if @verbose\n\t\t\treturn nil\n\t\tend\n\tend",
"def gen_ip_addresses(max=20)\n (1..max).map do |octet|\n \"192.168.#{octet}.1\"\n end\nend",
"def |(in_ip)\n raise RuntimeError, \"Can not compare IPV4 with IPV6!\" if @version != in_ip.version\n Ip.new(@ip_int | in_ip.to_i, @version)\n end",
"def listIPs\n ips = []\n cloud_desc.network_interfaces.each { |iface|\n ips << iface.network_ip\n if iface.access_configs\n iface.access_configs.each { |acfg|\n ips << acfg.nat_ip if acfg.nat_ip\n }\n end\n }\n ips\n end",
"def usable_ips\n usable_ips = to_range.to_a\n usable_ips.delete_at(0)\n usable_ips.delete_at(usable_ips.size-1)\n usable_ips.map { |i| i.to_s }\n end",
"def address_is_local?(address)\n Rails.configuration.local_addresses.any? { |spec| address_matches spec.strip.split('.'), address.strip.split('.') }\nend",
"def has_ipv4_ip_address?\n self.options[:ip].is_a?(String) && self.options[:ip] =~ /\\A\\d+\\.\\d+\\.\\d+\\.\\d+/\n end",
"def ipv6?\n @family == Socket::AF_INET6\n end"
] | [
"0.7007296",
"0.6620668",
"0.6585659",
"0.6305265",
"0.6299838",
"0.6291751",
"0.62632895",
"0.6225902",
"0.6219659",
"0.6203125",
"0.61873966",
"0.6162141",
"0.6161072",
"0.6157057",
"0.61059684",
"0.60777915",
"0.6075467",
"0.6042411",
"0.6035033",
"0.60247725",
"0.5990672",
"0.59870946",
"0.5965152",
"0.5923909",
"0.5883232",
"0.5882808",
"0.5867356",
"0.5866832",
"0.5859278",
"0.5854429",
"0.5838636",
"0.5836826",
"0.58350724",
"0.5747777",
"0.5747777",
"0.5745899",
"0.5745219",
"0.57385623",
"0.57300705",
"0.5704124",
"0.5699341",
"0.56672925",
"0.5659806",
"0.5652767",
"0.56346345",
"0.56298906",
"0.5598772",
"0.55844665",
"0.558216",
"0.557565",
"0.5575016",
"0.5569448",
"0.5569232",
"0.5560593",
"0.55560136",
"0.55554897",
"0.5553789",
"0.55532354",
"0.5543307",
"0.5542698",
"0.55367845",
"0.5531472",
"0.55244756",
"0.5523913",
"0.5516894",
"0.5509678",
"0.55064875",
"0.55060726",
"0.54784477",
"0.5476489",
"0.5471037",
"0.5469388",
"0.5467666",
"0.5467488",
"0.5456933",
"0.5456274",
"0.5455984",
"0.54510176",
"0.5447602",
"0.54470885",
"0.54420877",
"0.54350674",
"0.5432101",
"0.54314345",
"0.543135",
"0.5427134",
"0.5423253",
"0.5422101",
"0.5418575",
"0.5406082",
"0.5402352",
"0.5399755",
"0.5398844",
"0.5393116",
"0.5388132",
"0.5384313",
"0.5382377",
"0.5376228",
"0.5365136",
"0.53639466"
] | 0.58278465 | 33 |
Return an array of addresses from 1 or more aliases that match either IPv4 or IPv6 | def resolve_alias(addresses, ipvers)
addresses = [addresses] unless addresses.is_a?(Array)
result = []
addresses.each do |address|
if address =~ /^([\w\-]+)$/
if aliases[address]
result += select_ipvers(aliases[address], ipvers)
else
raise "Alias is not defined: #{address}"
end
else
result += select_ipvers(address, ipvers)
end
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getaddresses(name)\n return [name] if ADDRESS_REGEX.match(name)\n @resolvers.each do |resolver|\n addresses = []\n resolver.each_address(name) { |address| addresses << address }\n return addresses unless addresses.empty?\n end\n []\n end",
"def extract_addresses(address_list)\n addresses = []\n address_list.each do |address|\n addresses << address[:address] if ['ipv4', 'hostname'].include?(address[:type])\n end\n addresses\nend",
"def find\n addrs = Socket.ip_address_list.select do |addr|\n addr.ipv4? and not(addr.ipv4_loopback?) and not(addr.ipv4_multicast?)\n end\n if not(addrs.empty?)\n privates = addrs.select{|addr| addr.ipv4_private?}\n not_privates = addrs - privates\n privates = privates.sort{|a,b| a.ip_address <=> b.ip_address}\n not_privates = not_privates.sort{|a, b| a.ip_address <=> b.ip_address}\n (privates + not_privates).map {|addr| addr.ip_address}\n else\n Socket.ip_address_list.select{|addr| addr.ipv4_loopback?}.map{|addr| addr.ip_address}\n end\n end",
"def ips_for(name)\n resolvers.each do |r|\n ips = r.getaddresses(name)\n\n return ips unless ips.nil? || ips.empty?\n end\n\n []\n end",
"def get_addresses apts\n return apts.map { |apt| apt.address }\n end",
"def host_aliases\n @fragments.map(&:host_aliases).flatten.uniq + [name]\n end",
"def listen_addresses\n node['network']['interfaces'].map do |iface, data| \n data[\"addresses\"].select { |addr, data| data[\"family\"] == \"inet\" }.keys[0]\n end\nend",
"def addresses\n collect { |a| a.address }\n end",
"def get_addresses\n return [get_pubkey_address] if is_pubkey?\n return [get_hash160_address] if is_hash160? || is_namecoin?\n return get_multisig_addresses if is_multisig?\n []\n end",
"def reserved_addresses\n IPSet.new(list_addresses.map{|a| a.address.to_host })\n end",
"def public_ip_addresses\n addresses = []\n if network_interfaces.respond_to? :flat_map\n addresses = network_interfaces.flat_map do |nic|\n if nic[:access_configs].respond_to? :each\n nic[:access_configs].select { |config| config[:name] == \"External NAT\" }\n .map { |config| config[:nat_ip] }\n else\n []\n end\n end\n end\n addresses\n end",
"def lookup_addresses(data)\n return @servers\n end",
"def addresses\n private_ip_addresses + public_ip_addresses\n end",
"def lookupd_http_addresses\n @lookups ||= ENV.fetch(\"NSQLOOKUPD_HTTP_ADDRESS\", \"\").split(/, ?|\\s+/).map(&:strip)\n end",
"def available_ips\n range = conf['addresses']['range']\n unless(range.to_s.empty?)\n range = (range.split('-').first.split('.').last..range.split('-').last).map{|oct|\n \"#{range.split('-').first.split('.').slice(0,3).join('.')}.#{oct}\"\n }\n else\n range = []\n end\n (conf['addresses']['static'] + range).compact\nend",
"def prefer_ipv4(addresses)\n return nil unless addresses.is_a?(Array)\n\n addresses.find { |ip| IPAddress.valid_ipv4?(ip) } ||\n addresses.find { |ip| IPAddress.valid_ipv6?(ip) }\n end",
"def ip_addresses\n @entries.collect do |entry|\n entry.ip_address\n end.compact || []\n end",
"def parse_dns(address)\n fwd_entries={}\n aliases=nil\n begin\n Socket.getaddrinfo(address,nil).each do |addr_struct|\n addr=addr_struct[2]\n ip=addr_struct[3]\n if fwd_entries[addr].nil?\n fwd_entries[addr]=[ip]\n elsif !fwd_entries[addr].include?(ip)\n fwd_entries[addr] << ip\n end\n end\n rescue SocketError =>e\n end\n ret_arr=[]\n if fwd_entries.empty? then\n puts \"[warning] Could not determine an IP address for \\\"#{address}\\\"\"\n else\n fwd_entries.each do |fwd,ips|\n ips.each do |ip|\n ret_arr << {:ip=>ip, :addr=>fwd}\n end\n end\n end\n return ret_arr\n end",
"def host_aliases (host)\n\t\tputs \"Search aliases in the local hosts data repository for host: #{host}\" if @verbose\n\t\thost.strip!\n\t\traise \"Unknown method input: #{host} We expect a FQDN host-name string from you. \" unless is_fqdn?(host)\n\t\taliases=Array.new\n\t\tif @known_hosts.key?(host)\n\t\t\tip=local_host_2_ip(host)\n\t\t\t@known_hosts.keys.map do |key|\n\t\t\t\tmy_ip=local_host_2_ip(key)\n\t\t\t\tif ip == my_ip\n\t\t\t\t\taliases.push(key)\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\traise \"Unknown host-name in the local hosts data repository: #{host}\"\n\t\tend\n\t\treturn aliases-[host]\n\trescue Exception => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\t\treturn nil\n\tend",
"def ips\n regex = /\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b/\n all_ips = Socket.ip_address_list.map(&:inspect_sockaddr)\n all_ips.select { |ip| !!ip.match(regex) }\n end",
"def two_factor_excluded_ip_addresses\n []\n end",
"def private_ip_addresses\n addresses = []\n if network_interfaces.respond_to? :map\n addresses = network_interfaces.map { |nic| nic[:network_ip] }\n end\n addresses\n end",
"def get_ip_addresses\n sa = MainSettings.instance\n begin\n s = UDPSocket.new(Socket::AF_INET)\n s.connect(\"8.8.8.8\", 1)\n if (s.addr[0] == \"AF_INET\")\n @ipv4 = IPAddr.new(s.addr.last)\n end\n rescue SocketError => e\n $stderr.puts \"Unable to determine IPv4 address: #{e}\"\n rescue Errno::ENETUNREACH => e\n $stderr.puts \"Unable to determine IPv4 address: #{e}\"\n end\n puts \"Finished acquiring IPv4 address\" if $verbose\n\n# begin\n# s = UDPSocket.new(Socket::AF_INET6)\n# s.connect(\"2001:4860:b006::2\", 1)\n# if (s.addr[0] == \"AF_INET6\")\n# @ipv6 = IPAddr.new(s.addr.last)\n# end\n# rescue SocketError => e\n# $stderr.puts \"Unable to determine IPv6 address: #{e}\"\n# rescue Errno::ENETUNREACH => e\n# $stderr.puts \"Unable to determine IPv6 address: #{e}\"\n# end\n# puts \"Finished acquiring IPv6 address\" if $verbose\n end",
"def aliases\n @aliases ||= []\n end",
"def private_ipaddresses\n # Create an array to hold the addresses\n addresses = []\n\n # Iterate around the filter that has been populated\n entries.each do |entry|\n entry.ip_configurations.each do |ip_config|\n addresses << ip_config['private_ipaddress']\n end\n end\n\n # return the array to the calling function\n addresses\n end",
"def addresses_for(name, resource_class = Resolv::DNS::Resource::IN::A, &block)\n\t\t\tquery(name, resource_class) do |response|\n\t\t\t\t# Resolv::DNS::Name doesn't retain the trailing dot.\n\t\t\t\tname = name.sub(/\\.$/, '')\n\t\t\t\t\n\t\t\t\tcase response\n\t\t\t\twhen Message\n\t\t\t\t\tyield response.answer.select{|record| record[0].to_s == name}.collect{|record| record[2].address}\n\t\t\t\telse\n\t\t\t\t\tyield []\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def address_matches\n filtered_matches(ignore: [:first_name, :family_name], perfect: [:street, :city])\n end",
"def check_ip_any_alias\n case @options[:ipaddr]\n when nil, '', 'any', /^\\s*$/\n @options[:ipaddr] = '0.0.0.0'\n @options[:netmask] = 0\n end\n end",
"def test_resolver_converts_ipaddrs_array\n @parser.log_reader\n assert_equal @parser.ipaddrs_q.size, 12\n assert_equal @parser.records_q.size, 12\n @parser.resolve_names\n assert_equal @parser.domains_hash.map { |k,v| [ k, v[0] ] }.sort, [\n [\"208.77.188.166\", \"www.example.com\"],\n [\"74.125.67.100\", \"gw-in-f100.google.com\"],\n [\"75.119.201.189\", \"apache2-moon.legs.dreamhost.com\"],\n [\"75.146.57.34\", \"greed.zenspider.com\"]\n]\n end",
"def get_host_info(s)\n\n # Prepare response array of aliases (IP and addresses)\n aliases = []\n\n # Get information from the given IP or name\n begin\n resp = Socket.getaddrinfo(s, nil)\n rescue\n aliases << s\n else\n\n fqdn = resp.first[2]\n ip = resp.first[3]\n aliases << fqdn\n\n if fqdn != ip\n host_dom = fqdn.split('.', 2)\n if $local_domain && host_dom.length == 2 && host_dom.last == $local_domain\n aliases << host_dom.first\n end\n aliases << ip\n end\n\n end\n\n return aliases\n\nend",
"def aliases(options = { :include_institution_name => true })\n aliases = []\n aliases << self[:name] if options[:include_institution_name]\n aliases << self[:ialias].split(\",\").split(\"|\").flatten.collect(&:strip)\n aliases.flatten.compact\n end",
"def getNameserverIPs(domain, addrtype = Resolv::DNS::Resource::IN::A)\n myresolv = Resolv::DNS.new()\n\n nameserver_addresses=Array.new\n myresolv.each_resource(domain, Resolv::DNS::Resource::IN::NS) do |nsrsc|\n nameserver_addresses.push(myresolv.getresource(nsrsc.name, addrtype).address)\n end\n\n myresolv.close()\n\n return nameserver_addresses\nend",
"def address_list_for(emails, retried = false)\n emails = emails * \", \"\n list = Mail::AddressList.new(self.class.unescape(emails))\n addrs = list.addresses.each { |a| a.decoded }\n addrs.uniq!\n addrs\n rescue Mail::Field::ParseError\n if retried\n raise\n else\n address_list_for(emails.scan(EMAIL_REGEX), true)\n end\n end",
"def included_addresses\n @included_scan_targets[:addresses]\n end",
"def from_addrs\n from ? [from].flatten : []\n end",
"def ip_names\n Socket.getifaddrs.map do |ifnames|\n next unless ifnames.addr.ipv4?\n\n puts \" #{ifnames.name}\"\n end\nend",
"def addresses network=nil\n if network\n data = on_network network\n ips = data.map { |v| (v.has_key? :ip) ? v[:ip] : nil }\n else\n vips.each_key.map { |k| vips[k][:ip] }\n end\n end",
"def to_addrs\n to ? [to].flatten : []\n end",
"def available_addresses\n @subnet.hosts(range: allocation_range, exclude: reserved_addresses)\n end",
"def san_interfaces\n if san_nics.length == sans.length \n ports = san_network_ports().sort\n ips = san_nodes.map{|x| x.ip_address.to_s }.sort\n #return [] if ports.length != ips.length \n ports.zip(ips)\n else\n []\n end\n end",
"def consider_local(*args)\n local_addresses.concat(args.flatten.map { |a| IPAddr.new(a) })\n end",
"def find_good_ip_addr list\n list.each do |addr|\n triplets = addr.split('.')\n if not triplets[0].to_i == 255 and not triplets[2].to_i == 255\n return addr\n end\n end\n nil\nend",
"def email_addresses\n emails.map(&:address)\n end",
"def addresses; end",
"def all(options={})\n response = MLS.get('/addresses', options)\n MLS::Address::Parser.parse_collection(response.body)\n end",
"def addresses\n Array(@addresses)\n end",
"def ip_all\n Socket.getifaddrs.map do |iface|\n next unless iface.addr.ipv4?\n\n puts \"\\nName: : #{iface.name}\"\n puts \"Address: :' + #{iface.addr.ip_address}\"\n end\nend",
"def all_ips_for(vm)\n vm.guest.net.map(&:ipAddress).flatten\n end",
"def aliases\n alias_of.aliases\n end",
"def aliases\n [[@aliases], @name, @display_name].flatten.compact.uniq\n end",
"def resolve_addresses packet # :nodoc:\n source = packet.source @resolver\n source = \"\\\"druby://#{source.sub(/\\.(\\d+)$/, ':\\1')}\\\"\"\n\n destination = packet.destination @resolver\n destination = \"\\\"druby://#{destination.sub(/\\.(\\d+)$/, ':\\1')}\\\"\"\n\n return source, destination\n end",
"def list_ips options={}\n if ip_version==6\n # Only list ips that have a resolutions\n AddressResolution.for_subnet(self).map &:ip\n else\n if range?\n ips = []\n if options[:include_network]\n ips << cidr.nth(0).to_s\n end\n (cidr.len - 2).times do |i|\n ips << cidr.nth(i + 1).to_s\n end\n if options[:include_gateway]\n ips << cidr.nth(cidr.len - 1).to_s\n end\n ips\n #cidr.to_a#.enumerate[1..-2]\n else\n [ip]\n end\n end\n end",
"def service_addresses(service, index = nil)\n loop do\n addresses, nindex = service_addresses!(service, index)\n return [addresses, nindex] if addresses && nindex\n end\n end",
"def ips_from(header)\n # Split the comma-separated list into an array of strings\n ips = @env[header] ? @env[header].strip.split(/[,\\s]+/) : []\n ips.select do |ip|\n begin\n # Only return IPs that are valid according to the IPAddr#new method\n range = IPAddr.new(ip).to_range\n # we want to make sure nobody is sneaking a netmask in\n range.begin == range.end\n rescue ArgumentError\n nil\n end\n end\n end",
"def public_addresses\n details['addresses']['public'].map { |i| i[\"addr\"] }\n end",
"def agent_transport_addresses\n [ @address ]\n end",
"def wildcard_check\n wildcard_ips = []\n\n # look for wildcard IP addresses\n 4.times do\n # random subdomain string\n sub = (0..20).map { (65 + rand(26)).chr }.join.downcase\n random_fqdn = \"#{sub}.#{@suffix}\"\n\n # if this resolves then we have a wildcard IP\n resolved = resolver(random_fqdn)\n wildcard_ips << resolved unless resolved.empty?\n end\n # return all unique wildcard IP addresses\n # this will return an empty array if none are found\n wildcard_ips.compact.uniq\n end",
"def node_aliases\n @groups.inject(@aliases) do |acc, g|\n acc.merge(g.node_aliases)\n end\n end",
"def aliases\n arr = Array.new\n @aliases.each do |key, value|\n arr.push(key)\n end\n return arr\n end",
"def addresses\n query(:address)\n end",
"def anonymize\n ipv4 = (m = value.match(/\\d+\\.\\d+\\.\\d+\\.\\d+$/)) ? m[0] : \"\"\n ipv6 = value.gsub(ipv4, \"\")\n ipv6 += \":\" if ipv4.present? && ipv6.present?\n ipv4 = ipv4.gsub(/\\.\\d+$/, \".0\")\n ipv6 = ipv6.gsub(/:(\\d|[a-f])*:(\\d|[a-f])*:(\\d|[a-f])*:(\\d|[a-f])*:(\\d|[a-f])*$/, \"::\")\n IPAddress.new([ipv6, ipv4].keep_if { |ip| ip.present? }.join)\n end",
"def mx_ips\n return [\"0.0.0.0\"] if @dns_disabled\n mxers.map { |m| m[1] }\n end",
"def describe_addresses( options = {} )\n options = { :public_ip => [] }.merge(options)\n params = pathlist(\"PublicIp\", options[:public_ip])\n return response_generator(:action => \"DescribeAddresses\", :params => params)\n end",
"def get_aliases\n resp = get do |req|\n req.url \"/_aliases\"\n end\n resp.body\n end",
"def peer_list\n ip_list = []\n raw_peers.each_slice(6) { |e| ip_list << e if e.length == 6 }\n\n ip_list.map! { |e| { :ip => e[0..3].join('.'), :port => (e[4] * 256) + e[5] } }\n end",
"def aliases\n return @aliases\n end",
"def getnames(address)\n @resolvers.each do |resolver|\n names = []\n resolver.each_name(address) { |name| names << name }\n return names unless names.empty?\n end\n []\n end",
"def public_addresses\n @public_addresses ||= Hash[addresses.map { |addr| [addr.public_ip, addr] }]\n end",
"def format_hosts\n all_hosts.inject('') do |str, (address, aliases)|\n str << \"#{address} #{aliases.join(' ')}\\n\"\n end\n end",
"def multi_addr(addresses)\n get(\"addr/\"+addresses.join(\",\")+\"/balance?noCache=1\")\n end",
"def resolve!\n Resolv.each_address(host) do |address|\n return @ip = address if address =~ pattern\n end\n end",
"def local_ips\n list = cmd(\"addr show dev #{name} primary\", sudo: false, errors: true) +\n cmd(\"addr show dev #{name} secondary\", sudo: false, errors: true)\n list.lines.grep(/inet ([0-9\\.]+)\\/.* #{name}/i){ $1 }\n rescue\n raise Errors::UnknownInterface, \"Interface #{name} not found on this machine\" unless exists?\n raise\n end",
"def ceph_chef_mon_addresses\n mon_ips = ceph_chef_mon_nodes_ip(ceph_chef_mon_nodes)\n mon_ips.reject(&:nil?).uniq\nend",
"def server_alias_search(name, all_gears=false)\n dname = clean_server_name(name)\n resp = []\n\n basedir = @config.get(\"GEAR_BASE_DIR\")\n if all_gears\n token = \"*\"\n else\n token = \"#{@container_uuid}_#{@namespace}_#{@container_name}\"\n end\n srch = File.join(basedir, \".httpd.d\", token, \"server_alias-*.conf\")\n Dir.glob(srch).each do |fn|\n cmpname = fn.sub(/^.*\\/server_alias-(.*)\\.conf$/, '\\\\1')\n if cmpname.casecmp(dname) == 0\n resp << fn\n end\n end\n resp\n end",
"def server_alias_search(name, all_gears=false)\n dname = clean_server_name(name)\n resp = []\n\n basedir = @config.get(\"GEAR_BASE_DIR\")\n if all_gears\n token = \"*\"\n else\n token = \"#{@container_uuid}_#{@namespace}_#{@container_name}\"\n end\n srch = File.join(basedir, \".httpd.d\", token, \"server_alias-*.conf\")\n Dir.glob(srch).each do |fn|\n cmpname = fn.sub(/^.*\\/server_alias-(.*)\\.conf$/, '\\\\1')\n if cmpname.casecmp(dname) == 0\n resp << fn\n end\n end\n resp\n end",
"def aliases\n @alias_ids.collect { |idx| BAlias.store[idx] }\n end",
"def get_addresses\n parsed_script.get_addresses\n end",
"def nsqlookupd_http_endpoints\n @nsqlookupd.map { |lookupd| \"http://#{lookupd.host}:#{lookupd.http_port}\" }\n end",
"def nsqlookupd_http_endpoints\n @nsqlookupd.map { |lookupd| \"http://#{lookupd.host}:#{lookupd.http_port}\" }\n end",
"def from_addresses\n return @from_addresses\n end",
"def get_aliases(hostname)\n headers = { Authorization: \"Bearer #{@token}\", 'Content-Type': 'application/json' }\n response = HTTParty.get(\"https://#{NETDB_SERVER}/nodes/#{hostname.fully_qualify}\",\n :headers => headers)\n if response.code != 200\n raise \"no node found for #{hostname}\"\n end\n\n # Parse through the response to find any aliases, and make sure that this is\n # the main hostname.\n node_json = JSON.parse(response.body)\n aliases = []\n node_json['names'].each do |n|\n if n['name'] != hostname\n raise \"#{hostname} is an alias for #{n['name']}. Please rerun with hostname #{n['name']}.\"\n elsif n.key?('aliases')\n aliases = (aliases + n['aliases'])\n end\n end\n\n aliases\nend",
"def ip_addresses( hostname )\n @@resolve ||= Resolv.new\n @@ip_addresses_cached ||= {}\n\n @@ip_addresses_cached[hostname.to_s] ||= @@resolve.getaddresses( hostname )\n end",
"def resolve_names(lookup_name, lookup_types=[Dnsruby::Types::AAAA, Dnsruby::Types::A, Dnsruby::Types::CNAME, Dnsruby::Types::PTR])\n\n names = []\n x = resolve(lookup_name, lookup_types)\n x.each {|y| names << y[\"name\"] }\n\n names.uniq\n end",
"def get_aws_ips()\n content = open(\"https://ip-ranges.amazonaws.com/ip-ranges.json\").read\n resp = JSON.parse(content)['prefixes']\n ips = []\n resp.each do |prefix|\n ips << IPAddr.new(prefix['ip_prefix'])\n end\n return ips\nend",
"def addresses\n @addresses ||= init_addresses\n end",
"def host_2_ips (hostname)\n\t\tbegin\n\t\t\tips=Array.new\n\t\t\tif is_ip?(hostname)\n\t\t\t\tips.push(hostname)\n\t\t\t\treturn ips\n\t\t\telse\n\t\t\t\tips = Resolv.getaddresses(hostname)\n\t\t\t\tif (ips.empty?) then\n\t\t\t\t\tputs \"Failed to resolve #{hostname}\" if @verbose\n\t\t\t\t\treturn nil\n\t\t\t\telse\n\t\t\t\t\treturn ips\n\t\t\t\tend\n\t\t\tend\n\t\trescue => ee\n\t\t\tputs \"Exception on method host_2_ips for host #{hostname}: #{ee}\" if @verbose\n\t\t\treturn nil\n\t\tend\n\tend",
"def addresses\n @addresses\n end",
"def addresses\n # prevent original array from being changed\n @addresses.dup\n end",
"def dns\n @dns ||= select { |type,value| type == :dns }.map do |(type,value)|\n value\n end\n end",
"def old_ip_address?\n dns.any? do |answer|\n answer.class == Net::DNS::RR::A && LEGACY_IP_ADDRESSES.include?(answer.address.to_s)\n end if dns?\n end",
"def build_addresses(address, mask)\n addresses = []\n mask.chars.each_with_index do |bit,idx|\n if bit == \"X\"\n addresses.concat build_addresses(address + \"0\", mask[idx+1..-1])\n addresses.concat build_addresses(address + \"1\", mask[idx+1..-1])\n return addresses\n else\n address = address + bit\n end\n end\n addresses << address\n return addresses\nend",
"def format_hosts\n all_hosts(@config).inject('') do |str, (address, aliases)|\n str << \"#{address} #{aliases.join(' ')}\\n\"\n end\n end",
"def format_hosts\n all_hosts(@config).inject('') do |str, (address, aliases)|\n str << \"#{address} #{aliases.join(' ')}\\n\"\n end\n end",
"def get_public_ipv4\n # Socket.ip_address_list.detect{|intf| intf.ipv4? and !intf.ipv4_loopback? and !intf.ipv4_multicast? and intf.ipv4_private?}\n Socket.ip_address_list.detect{|intf| intf.ipv4_private?}\nend",
"def names_for(ip)\n resolvers.each do |r|\n names = r.getnames(ip)\n\n return names unless names.nil? || names.empty?\n end\n\n []\n end",
"def calculate_addresses(mem_mask)\n x_loc = []\n addr_list = []\n mem_mask.split('').each_index { |i| x_loc.push(i) if mem_mask[i] == 'X' }\n (2**x_loc.length).times do |i|\n this_addr = mem_mask.clone\n x_loc.length.times do |j|\n i[j] == 1 ? this_addr[x_loc[j]] = '1' : this_addr[x_loc[j]] = '0'\n end\n addr_list.push(this_addr.to_i(2))\n end\n return addr_list\nend",
"def validate_ip_addresses(config)\n ips = []\n [*config['nodes']].each do |node|\n if ip = node['ip']\n raise_ip_err(ip, node['name']) if ips.include?(ip)\n ips.push(ip)\n end\n end\n log.debug \"ips = #{ips}\"\n end",
"def aliases\n @hash[\"Alias\"].keys\n end",
"def wanted_ips\n ips = [new_resource.address, nic.IPAddress].flatten.compact\n\n # Return only IPv4 IPs\n ips.select { |ip| ip =~ /\\./ }\n end",
"def resolve_names(lookup_name, lookup_types=[Dnsruby::Types::A, Dnsruby::Types::CNAME, Dnsruby::Types::PTR])\n\n names = []\n x = resolve(lookup_name, lookup_types)\n x.each {|y| names << y[\"name\"] }\n\n names.uniq\n end"
] | [
"0.65996414",
"0.64940137",
"0.64407414",
"0.6321463",
"0.6306254",
"0.62178785",
"0.6201579",
"0.6173752",
"0.61470044",
"0.6053043",
"0.60380906",
"0.5973963",
"0.5969093",
"0.59667933",
"0.59415346",
"0.5933625",
"0.5881579",
"0.5879615",
"0.58582234",
"0.58507216",
"0.5811552",
"0.5776134",
"0.5771046",
"0.57529527",
"0.572597",
"0.5709483",
"0.570048",
"0.56803566",
"0.5674072",
"0.56351537",
"0.5608814",
"0.5608731",
"0.5606686",
"0.5603323",
"0.5602463",
"0.56002784",
"0.5599215",
"0.55940866",
"0.5587576",
"0.55764884",
"0.55595475",
"0.5549915",
"0.5546237",
"0.55431",
"0.5536735",
"0.5529999",
"0.55038124",
"0.5501762",
"0.5496252",
"0.54891336",
"0.5484452",
"0.5449896",
"0.54170215",
"0.54169583",
"0.54168934",
"0.5400006",
"0.53739345",
"0.5371889",
"0.53712374",
"0.53579074",
"0.5351925",
"0.5349292",
"0.534921",
"0.5339864",
"0.53310263",
"0.5328943",
"0.53226113",
"0.5316105",
"0.5305685",
"0.5279467",
"0.5276783",
"0.5265263",
"0.5262757",
"0.5254734",
"0.5254734",
"0.5237673",
"0.52219373",
"0.5220661",
"0.5220661",
"0.5219694",
"0.5215395",
"0.52148783",
"0.52021646",
"0.5179409",
"0.51770645",
"0.5174508",
"0.51618546",
"0.5161626",
"0.5158061",
"0.5155748",
"0.51482964",
"0.5137507",
"0.5137507",
"0.5113601",
"0.51046854",
"0.5091059",
"0.5090377",
"0.50890934",
"0.5077939",
"0.5077847"
] | 0.70776016 | 0 |
Convert ruby object into VyOS port string | def port_string(input)
if input
port = if input.is_a?(Array)
input.join(',')
elsif input.is_a?(Range)
"#{input.min}-#{input.max}"
else
input.to_s
end
yield(port)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def port_string; end",
"def to_s\n\t\t\t\"#{host}:#{port}\"\n\t\tend",
"def to_s\n [@host, @rpc_port].join(':')\n end",
"def to_s\n if @bridge_port == true\n \"Bridge: [#{@port_name}, #{@remote_switch_name}, #{@remote_port_name}, #{@remote_port_number}]\"\n else\n \"Std Port: [#{@port_name}, [ #{@port_arp.join(',')} ] ]\"\n end\n end",
"def to_s\n\t\treturn \"%s:%d\" % [ self.peer_host, self.peer_port ]\n\tend",
"def actual_port; end",
"def actual_port; end",
"def to_s\n\t\t\"%s:%d\" % [ @peerHost, @peerPort ]\n\tend",
"def port\n data[:port]\n end",
"def to_orocos_port\n self\n end",
"def to_s\n \"#<#{self.class.name}:0x#{object_id.to_s(16).rjust(14, \"0\")} host='#{client.host}'>\"\n end",
"def to_s\r\n return to_socket\r\n end",
"def to_s\n\t\treturn \"%s:%d (%s, %s, %s)\" % [\n\t\t\tself.host,\n\t\t\tself.port,\n\t\t\tself.base_dn,\n\t\t\tself.connect_type,\n\t\t\tself.bound? ? @bound_user : 'anonymous'\n\t\t ]\n\tend",
"def standard_port; end",
"def to_s\n\t\tconn_str = \n\t\t\tsprintf(\"#%s%s:%x\\n%s%s\\n%s%s\\n%s%s\\n%s%s\\n%s%s\\n%s%s\\n%s%s\\n\",\n\t\t\t\t\"Class:id.......... = \", self.class, self.object_id, \n\t\t\t\t\" @socket.......... = \", @socket.inspect, \n\t\t\t\t\" @host............ = \", @host.inspect, \n\t\t\t\t\" @port............ = \", @port.inspect, \n\t\t\t\t\" @username........ = \", @username.inspect,\n\t\t\t\t\" @authenticated... = \", @authenticated.inspect,\n\t\t\t\t\" @show_full_names. = \", @show_full_names.inspect,\n\t\t\t\t\" @groups.......... = \", @groups.inspect)\n\t\treturn conn_str\n\tend",
"def port_from(random_string)\n random_string\n end",
"def port\n @attributes[:port]\n end",
"def to_s\n \"#{username}@#{hostname}:#{port}<#{options.inspect}>\"\n end",
"def vnc_port\n Fog::Logger.deprecation(\"#{self.class} => #vnc_port is deprecated, use #display[:port] instead [light_black](#{caller.first})[/]\")\n display[:port]\n end",
"def tunnel_to_s\n\t\t\"#{(tunnel_local || '??')} -> #{(tunnel_peer || '??')}\"\n\tend",
"def to_source; \"* = $#{@addr.to_s(16)}\"; end",
"def port=(_arg0); end",
"def tunnel_to_s\n\t\t\"#{(tunnel_local || '??').to_s} -> #{(tunnel_peer || '??').to_s}\"\n\tend",
"def to_s\n # no need to print tcp/udp ANY in Cisco ACL\n ''\n end",
"def raw_host_with_port; end",
"def port\n get_value :port\n end",
"def port_names\n (1..port_count).map {|i| \"Te 0/%s\" % i}\n end",
"def to_s\n elements = bytes.unpack(\"NnnCCa6\")\n node = elements[-1].unpack('C*')\n elements[-1] = '%02x%02x%02x%02x%02x%02x' % node\n \"%08x-%04x-%04x-%02x%02x-%s\" % elements\n end",
"def port\n 20000 + ($$ % 40000)\n end",
"def port=(p)\n attributes['port'] = p.to_s\n end",
"def serialize_to_string\n sio = ProtocolBuffers.bin_sio\n serialize(sio)\n return sio.string\n end",
"def interface_name_interface_command(port)\n\t\tport.downcase\n\tend",
"def port\n conf['api']['port'].to_s\n end",
"def display(port=$>) end",
"def to_s\n @path || \"#{@host}:#{@port}\"\n end",
"def port\n @port ||= Port.new(@event.at('@port'), @event.at('@svc_name'), @event.at('@protocol'))\n end",
"def getPort()\n return @port\n\tend",
"def port=(_); end",
"def to_s\n packet = build_packet\n @packet_size = packet.length\n return [@packet_size].pack(\"V\") + packet\n end",
"def standard_port?; end",
"def _to_string(addr)\n \"%d.%d.%d.%d\" % [ (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff, (0xff&addr) ] \n end",
"def to_s\n [0, 32, @device_token, @payload.length, @payload ].pack(\"CnH*na*\")\n end",
"def get_gdom_console_port(options)\n message = \"Information:\\tDetermining Virtual Console Port for Guest Domain \"+options['name']\n command = \"ldm list-bindings #{options['name']} |grep vcc |awk '{print $3}'\"\n vcc_port = execute_command(options,message,command)\n return vcc_port\nend",
"def port_string\n (protocol == 'http://' && port == 80) || (protocol == 'https://' && port == 443) ? '' : \":#{port}\"\n end",
"def getAddress()\n \"#{@mcAddress}:#{@port}\"\n end",
"def port; end",
"def port; end",
"def port; end",
"def port; end",
"def port; end",
"def port; end",
"def port; end",
"def port; end",
"def port=(val)\n if(val.kind_of?(String)) \n raise ArgumentError, \"#{val.length}-byte value exceeds limit of #{2**8-1} byes.\" if (val.length > 2**8-1)\n @port = val\n else\n raise ArgumentError, \"Expected String, but #{val.class} provided.\" \n end\n return(nil)\n end",
"def to_s\n '<Twilio::REST::Preview::DeployedDevices>';\n end",
"def host_as_string; end",
"def to_s\n '<Twilio::REST::Proxy::V1>'\n end",
"def port(port, host = T.unsafe(nil)); end",
"def to_s\n\t\t\tbytes_v_class_label = [(self.ipv6_v << 28) +\n\t\t\t (self.ipv6_class << 20) +\n\t\t\t self.ipv6_label].pack(\"N\")\n\t\t\tbytes_v_class_label + (self.to_a[3,6].map {|x| x.to_s}.join)\n\t\tend",
"def to_s\n fill\n String.from_java_bytes(@baos.toByteArray)\n end",
"def conv_ruby_var\n parts = @name.split(\"::\")\n mod = parts[0]\n n = parts[1][3..-1]\n # p parts, mod, n\n \n spchars = n.scan(/\\_[0-9A-F]{2}/)\n spchars.each do |sc|\n n.sub!(sc, sc[1..-1].to_i(16).chr)\n end\n\n return mod + \"::\" + n\n end",
"def properties_uid\n \"portstart-#{port_start}_portend-#{port_end}_proto-#{protocol}\"\n end",
"def set_port(v)\n v = v.empty? ? nil : v.to_i unless !v || v.kind_of?(Integer)\n @port = v\n end",
"def port\n nodes[0][1].to_i\n end",
"def port=(v)\n check_port(v)\n set_port(v)\n port\n end",
"def to_s\n values = @params.map{|k, v| \"#{k}: #{v}\"}.join(\" \")\n \"<Twilio.Proxy.V1.ServiceInstance #{values}>\"\n end",
"def socket_port; end",
"def format_broker_from_znode(znode)\n hash = JSON.parse(znode)\n host = hash['host']\n port = hash['port']\n host && port ? \"#{host}:#{port}\" : nil\n rescue JSON::ParserError\n nil\n end",
"def to_x\n\t\t\tIPAddr.new(self.to_i, Socket::AF_INET6).to_s\n\t\tend",
"def port\n @port\n end",
"def port\n @port\n end",
"def port\n @port\n end",
"def to_s\n \"<Car:#{sprintf '0x%x', 0x100000000 + self.object_id*2}:\" +\n \"#{@driver.name}:#{@currentLane.name}:#{bodyStart}:#{bodyEnd}>\"\n end",
"def host_as_string\n @host_as_string ||= begin\n string = \"#{host}\"\n string = \"[#{string}]:#{port}\" if port != DEFAULT_PORT\n\n peer_ip = socket.peer_ip\n\n if peer_ip != host\n string2 = peer_ip\n string2 = \"[#{string2}]:#{port}\" if port != DEFAULT_PORT\n string << \",\" << string2\n end\n\n string\n end\n end",
"def port\n self.port\n end",
"def to_s\n case state\n when BOUND\n \"#{type_str} socket bound to #{endpoint}\"\n when CONNECTED\n \"#{type_str} socket connected to #{endpoint}\"\n else\n \"#{type_str} socket\"\n end\n end",
"def test_decode_port()\n input = [\n 131, 102, 100, 0, 13, 110, 111, 110, 111, 100, 101, 64, 110, 111,\n 104, 111, 115, 116, 0, 0, 1, 245, 0]\n expected = Erlang::Port.new(\n Erlang::Atom.new('nonode@nohost'), 501, 0)\n\n stream = Erlang::StreamEmulator.new(input)\n actual = Erlang::decode(stream)\n\n assert_equal(expected, actual)\n end",
"def to_puppet\n %w(ioa_interface force10_portchannel).each do |r_source|\n next unless port_resources[r_source]\n port_resources[r_source].keys.each do |name|\n resource = port_resources[r_source][name]\n\n [\"vlan_tagged\", \"vlan_untagged\", \"tagged_vlan\", \"untagged_vlan\"].each do |prop|\n next unless resource[prop].is_a?(Array)\n resource[prop] = resource[prop].sort.uniq.join(\",\")\n end\n end\n end\n\n port_resources\n end",
"def db_instance_port\n data[:db_instance_port]\n end",
"def initialize(host: 'localhost', port: 9200)\n @host = host\n @port = port\n @port_s = port.to_s\n end",
"def host_with_port\n uhost, uport = self.host, self.port\n if port != protocol.default_port\n \"#{uhost}:#{uport}\"\n else\n uhost\n end\n end",
"def port\n return @port.to_i\n end",
"def to_s\n [(self.v || self.d)].pack(\"C\")\n end",
"def port\n end",
"def rport\n\t\t@target_port\n\tend",
"def to_r\n raw = [ @version, @command, @dest_port, Rex::Socket.addr_atoi( @dest_ip ) ].pack( 'CCnN' )\n return raw if( @userid.empty? )\n return raw + [ @userid ].pack( 'Z*' )\n end",
"def to_s\n %(#{host_name} (#{ipaddress}) - #{operating_system})\n end",
"def to_s\n msg_str = \"Command Packet Hex Str: #{@cmd_str.to_s}\\n\"\n msg_str << \"net_id: #{@net_id}\\n\"\n msg_str << \"pkt_no: #{@pkt_no}\\n\"\n msg_str << \"cmd_id: #{@cmd_id.to_s(16)}\\n\"\n msg_str << \"res_req: #{@res_req}\\n\"\n msg_str << \"ack_req: #{@ack_req}\\n\"\n msg_str << \"ack_bit: #{@ack_bit}\\n\"\n msg_str << \"err_bit: #{@err_bit}\\n\"\n if @data != nil\n data_str = \"\"\n if @data == CmdManager::DONT_CARE\n data_str = CmdManager::DONT_CARE\n else \n @data.each{|x| \n if x == CmdManager::DONT_CARE\n data_str << CmdManager::DONT_CARE\n else\n data_str << \"#{x.to_s(16)} \"\n end\n }\n end\n \n msg_str << \"data: [#{data_str.chop}]\\n\"\n end\n if @error_no != 0\n msg_str << \"error_desc: #{@error_desc}\\n\"\n end\n \n msg_str\n end",
"def objectFromNetId _args\n \"objectFromNetId _args;\" \n end",
"def to_s\n $test_logger.log(\"to_s\")\n outp = \"ILV Hex = #{@ilv_hex_str}\\n\"\n formatter = REXML::Formatters::Pretty.new(2)\n formatter.compact = true\n formatter.write(@xml_ilv_node, outp)\n outp.to_s\n end",
"def to_s; \"<Align: $#{@addr.to_s(16)}\"; end",
"def determine_port_state(v)\n return v\n end",
"def ipv4_to_txt(ipv4)\n IPAddr.new(ipv4, Socket::AF_INET).to_s\nend",
"def port\n @options[:port]\n end",
"def ssh_port\n self.vm_field \"ssh_port\"\n end",
"def port\n @presenter.port\n end",
"def to_s\n return \"ipv4 : #{self.ipv4}\\n\" <<\n \"mask : #{self.mask}\\n\" <<\n \"mac : #{self.mask}\\n\" <<\n \"gateway : #{self.gateway}\\n\"\n end",
"def to_s\n \"Id: #{vm_identifier}, Launched at: #{created_at}, Time limit: #{time_limit}, \"\n \"SSH address: #{public_host}:#{public_ssh_port}\"\n end",
"def to_s\n to_hex\n end",
"def connection_string\n instance.primary_ip.split('://')[0] == 'unix' ? instance.primary_ip : \"tcp://#{instance.primary_ip}:2376\"\n end"
] | [
"0.7103363",
"0.6500296",
"0.6476261",
"0.6378679",
"0.61832774",
"0.6174617",
"0.6174617",
"0.61323726",
"0.6003181",
"0.6001421",
"0.5948682",
"0.59344494",
"0.59115684",
"0.58142847",
"0.57360333",
"0.5689222",
"0.566903",
"0.56652516",
"0.5646701",
"0.56444305",
"0.56324965",
"0.56216806",
"0.5606166",
"0.55650365",
"0.55567896",
"0.5554235",
"0.554911",
"0.55304",
"0.55183274",
"0.55164963",
"0.5498445",
"0.5496646",
"0.5483708",
"0.546538",
"0.5464777",
"0.54507875",
"0.54467845",
"0.5442669",
"0.54205436",
"0.5418475",
"0.5392948",
"0.5389026",
"0.5385899",
"0.53672427",
"0.53666013",
"0.536218",
"0.536218",
"0.536218",
"0.536218",
"0.536218",
"0.536218",
"0.536218",
"0.536218",
"0.5350601",
"0.53476363",
"0.53432417",
"0.5337362",
"0.5335594",
"0.5333114",
"0.531575",
"0.5307632",
"0.5299973",
"0.5276553",
"0.52750474",
"0.5267453",
"0.525953",
"0.5254227",
"0.5251965",
"0.5244914",
"0.52358466",
"0.52358466",
"0.52358466",
"0.5234334",
"0.5229372",
"0.52277523",
"0.5215351",
"0.5202678",
"0.52003604",
"0.51896393",
"0.518434",
"0.51840466",
"0.51792294",
"0.51783985",
"0.5173817",
"0.51668763",
"0.51647973",
"0.5163252",
"0.515787",
"0.515197",
"0.5140564",
"0.5140051",
"0.5139673",
"0.5139372",
"0.51392865",
"0.5134254",
"0.513156",
"0.51160944",
"0.51076293",
"0.51015186",
"0.5100525"
] | 0.51701885 | 84 |
This endpoint allows to recommend a new member to airlines. | def create_recommend_a_new_member(body)
# Prepare query url.
_path_url = '/v1/airline/members/'
_query_builder = Configuration.get_base_uri
_query_builder << _path_url
_query_url = APIHelper.clean_url _query_builder
# Prepare headers.
_headers = {
'accept' => 'application/json',
'content-type' => 'application/json; charset=utf-8'
}
# Prepare and execute HttpRequest.
_request = @http_client.post(
_query_url,
headers: _headers,
parameters: body.to_json
)
_context = execute_request(_request)
validate_response(_context)
# Return appropriate response type.
decoded = APIHelper.json_deserialize(_context.response.raw_body)
NewMemberResponse.from_hash(decoded)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @member = Member.new(params[:member])\n\n respond_to do |format|\n if @member.save\n add_plan_to_user_if_specified!\n \n format.html { redirect_to(@member, :notice => 'Member was successfully created.') }\n format.json { render :json => @member, :status => :created, :location => @member }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @member.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @aiit_member = AiitMember.new(params[:aiit_member])\n\n respond_to do |format|\n if @aiit_member.save\n format.html { redirect_to @aiit_member, notice: 'Aiit member was successfully created.' }\n format.json { render json: @aiit_member, status: :created, location: @aiit_member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @aiit_member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def member_params\n params.require(:member).permit(:attend, :user_id, :party_id)\n end",
"def invite\n @meal = Meal.find(params[:meal_id])\n authorize @meal, :update?\n @user = if params[:user_id]\n User.find(params[:user_id])\n else\n User.find_by(name: params[:user_name])\n end\n @meal.invite_user @user\n redirect_to @meal\n end",
"def new_affiliate\n resource = build_resource\n resource.role = 'affiliate'\n resource.build_affiliate\n respond_with resource\n end",
"def invite_member\n @organization = MnoEnterprise::Organization.find(params[:id])\n\n # Find or create a new user - We create it in the frontend as MnoHub will send confirmation instructions for newly\n # created users\n user = MnoEnterprise::User.find_by(email: user_params[:email]) || create_unconfirmed_user(user_params)\n\n # Create the invitation\n invite = @organization.org_invites.create(\n user_email: user.email,\n user_role: params[:user][:role],\n referrer_id: current_user.id,\n status: 'staged' # Will be updated to 'accepted' for unconfirmed users\n )\n\n @user = if user.confirmed?\n invite.accept!(user)\n invite.reload\n else\n user.reload\n end\n end",
"def assign_member\n authorize List\n @member.assigned_lists << @list\n json_response({ message: 'List assigned successfully' }, :ok)\n end",
"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 user\n recommendations 'user'\n end",
"def show\r\n @appoint_responsible = AppointResponsible.new\r\n end",
"def add_member(params)\n room_id = self.room_id || params.delete(:room_id)\n raise ArgumentError.new(\"room_id required\") unless room_id\n\n user_name = user_name_from_params(params)\n raise ArgumentError.new(\"user_id or user_mention or user_email required\") unless user_name\n\n call_api(:method => :put, :uri => @api_base.merge(\"room/#{room_id}/member/#{user_name}\"), :body_params => params)\n end",
"def create\n @member = Member.new(params[:member])\n @member.warband = current_user.warband if @member.warband.blank?\n respond_to do |format|\n if @member.save\n format.html { redirect_to(@member, :notice => 'Member was successfully created.') }\n format.xml { render :xml => @member, :status => :created, :location => @member }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @member.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @member = Member.find(params[:id])\n\n respond_to do |format|\n if @member.update_attributes(params[:member])\n \n add_plan_to_user_if_specified!\n format.html { redirect_to(@member, :notice => 'Member was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @member.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def restmember_params\n params.require(:restmember).permit(:restaurant_id, :event_id, :user_id)\n end",
"def create\n @recommendation = current_user.recommendations.new(\n :article_id => params[:article_id])\n authorize @recommendation\n if @recommendation.save\n ArticleRankingWorker.perform_async(params[:article_id])\n render 'api/v1/recommendations/show', status: :created\n else\n render json: @recommendation.errors, status: :unprocessable_entity\n end\n end",
"def new\n if params[:institute_id]\n @institute = Member.find(params[:institute_id])\n @member.address = @institute.address\n @member.status = 'N'\n @member.bulletin = 'yes'\n @member.comment = \"added #{Date.today}.\"\n end\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @member }\n end\n end",
"def new\n @aiit_member = AiitMember.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @aiit_member }\n end\n end",
"def create\n user = Member.new(user_params)\n if user.save\n code = user.id + 24523009\n user.update(affiliate_code: code)\n MemberupJob.set(wait: 20.seconds).perform_later(user)\n sign_in(user)\n render json: user,serializer: Api::V1::MembersSerializer, :status => 201\n else\n render json: \"errors\", :status => 422\n end \n end",
"def create\n @member = @current_enterprise.members.build(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @member = Member.new(member_params)\n unless @member.set_region_admin == \"1\"\n @member.region_id = current_member.region_id\n end\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n @uplines = Member.order(\"fullname\")\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def attend\n user_id = current_user.id\n training_id = params[:id]\n TrainingRecord.create_new_record user_id, training_id\n redirect_to @training, notice: \"You have successfully registered for #{@training.title}\"\n end",
"def create\n @airline = Airline.new(airline_params)\n \n respond_to do |format|\n if @airline.save\n @user = User.create(:email=>params[:airline][:users][:email],:password=>params[:airline][:users][:password],:password_confirmation=>params[:airline][:users][:password],:airline_id=>@airline.id)\n @user.add_role(:airplane)\n format.html { redirect_to root_path, notice: 'Please Check you email for confirmation' }\n format.json { render :show, status: :created, location: @airline }\n else\n format.html { render :new }\n format.json { render json: @airline.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tFriendship::request(@user, @friend)\n\t\tUserMailer::friend_request(\n\t\t\t:user => @user,\n\t\t\t:friend => @friend,\n\t\t\t:user_url => profile_for(@user),\n\t\t\t:accept_url => url_for(:action => \"accept\", :id => @user.screen_name),\n\t\t\t:decline_url => url_for(:action => \"decline\", :id => @user.screen_name)\n\t\t).deliver_now\n\t\tflash[:notice] = \"Friend request sent.\"\n\t\tredirect_to profile_for(@friend)\n\tend",
"def create\n \n \n\t@attending = current_user.attendings.build(params[:attending])\n\n respond_to do |format|\n if @attending.save\n\t \n format.html { redirect_to @attending, notice: 'Your RSVP was successfully created.' }\n format.json { render json: @attending, status: :created, location: @attending }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attending.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @reservation = Reservation.new(params[:reservation])\n if user_signed_in?\n @reservation.user_id = current_user.id\n elsif owner_signed_in?\n @reservation.owner_id = current_owner.id\n @reservation.restaurant = current_owner.restaurant\n end\n\n respond_to do |format|\n if @reservation.save\n\n if user_signed_in?\n Reward.create( user_id: @reservation.user_id, \n reservation_id: @reservation.id, \n points_total: 5*@reservation.party_size, \n points_pending: 5*@reservation.party_size, \n description: \"\")\n end\n \n if user_signed_in?\n format.html { redirect_to @reservation, notice: 'Reservation was successfully created.' }\n format.json { render json: @reservation, status: :created, location: @reservation }\n else\n format.html { redirect_to root_url, notice: 'Reservation was successfully created.' }\n end\n\n # UserMailer.booking_create(current_user, @reservation).deliver\n # OwnerMailer.booking_create(@reservation).deliver\n else\n format.html { render action: \"new\" }\n # format.html { redirect_to new_reservation_path(reservation: params[:reservation]) }\n format.json { render json: @reservation.errors, status: :unprocessable_entity }\n end\n\n end\n end",
"def create\n # Check the requester's permissions\n return forbidden unless current_account.admin?(current_organization) or\n (current_account.real?(current_organization) and params[:role] == Account::REVIEWER)\n\n # Find or create the appropriate account\n account_attributes = pick(params, :first_name, :last_name, :email, :language, :document_language).merge({\n language: current_organization.language,\n document_language: current_organization.document_language\n })\n account = Account.lookup(account_attributes[:email]) || Account.create(account_attributes)\n return json(account) unless account.valid?\n\n # Find role for account in organization if it exists.\n membership_attributes = pick(params, :role, :concealed)\n return bad_request(error: 'Role is required') unless Account::ROLES.include? membership_attributes[:role]\n\n membership = current_organization.role_of(account)\n # Create a membership if account has no existing role\n if membership.nil?\n membership_attributes[:default] = true unless account.memberships.exists?\n membership = current_organization.memberships.create(membership_attributes.merge(account_id: account.id))\n elsif membership.role == Account::REVIEWER # or if account is a reviewer in this organization\n account.upgrade_reviewer_to_real(current_organization, membership_attributes[:role])\n elsif membership.role == Account::DISABLED\n return bad_request(error: 'That email address belongs to an inactive account.')\n else\n return conflict(error: 'That email address is already part of this organization.')\n end\n\n if account.pending?\n account.send_login_instructions(current_organization, current_account)\n else\n LifecycleMailer.membership_notification(account, current_organization, current_account).deliver_now\n end\n json account.canonical(membership: membership)\n end",
"def invite_people\n end",
"def account\n @member = current_user.member\n @user = current_user\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @member }\n end\n end",
"def create\n @tier = Tier.new(params[:tier])\n @tier.member = current_member\n\n respond_to do |format|\n if @tier.save\n if params[:endeavor_id]\n @tier.tierings.create :endeavor_id => params[:endeavor_id]\n end\n format.html { redirect_to @tier, :notice => \"Your #{current_member.tiers.count.ordinalize} tier.\" }\n format.json { render :json => @tier, :status => :created, :location => @tier }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @tier.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @member = @space.members.new(member_params)\n @member.user = current_user\n\n respond_to do |format| \n if @member.save\n @space.members << @member\n\n format.html { redirect_to space_member_url(@space, @member), notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: [@space, @member] }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @member = Member.new(params[:member]) \n if @member.save\n \n require 'aweber'\n @oauth = AWeber::OAuth.new('Ak8Buwis5Q1j0OwvVZ4eJROe','TjtgHED5PIYPqS85ZgBekIf9jol1PgpUEpETmrV9')\n @oauth.authorize_with_access('Agvk8sGM8K4XFU2axg2d9z2j', 'qcAyJIPah2lBKcqrU85IviuOXjC0gLtYx0koG115')\n @aweber = AWeber::Base.new(@oauth)\n @account = @aweber.account\n\n new_subscriber = {}\n new_subscriber[\"email\"] = params[:member][:email]\n new_subscriber[\"name\"] = params[:member][:username] \n @account.lists.find_by_name(\"cpclist\").subscribers.create(new_subscriber)\n \n \n insert_id = @member.id\n random_string = SecureRandom.hex(5)\n Member.find(insert_id).update_attribute(:random_code, random_string)\n\n flash[:success] = \"Member was successfully created.\"\n session[:user_id] = insert_id\n redirect_to root_url\n #render 'home/index'\n\n flash[:success] = \"\";\n\n #render :partial => 'home/index', :locals => { :success => flash[:success] }\n else\n render 'home/index'\n end\n end",
"def create\n\n if current_user.friends.include?(params[:friend_id])\n flash[:notice] = \"It's polite to ask once.\"\n else\n\n\n @friendship = current_user.friendships.build(:friend_id => params[:friend_id], approved: \"false\")\n\n if @friendship.save\n\n\n\n log_activity\n\n flash[:notice] = \"Friend requested.\"\n\n\n\n redirect_to :back\n else\n flash[:error] = \"Unable to request friendship.\"\n redirect_to :back\n end\n end\n end",
"def create\n\t\tact_type = params[:offering_type]\n\t\tuser = User.find_by_id(params[:joining_user])\n\t\tact_id = params[:offering_id]\n\n\t\tif !name_is_valid?(user, act_type); raise Errors::FlowError.new(send(\"#{act_type}_path\", offering_id), \"Permission denied.\"); end\n\n\t\tacts_membership = user.send(\"#{act_type}s_membership\")\n\t\tjoining_act = act_type.camelize.constantize.find_by_id(act_id)\n\n\t\tunless joining_act; raise Errors::FlowError.new; end\n\n\t\t# gender\n\t\tif [\"male\", \"female\"].include? joining_act.gender\n\t\t\tunless user.gender == joining_act.gender; raise Errors::FlowError.new(root_path, \"This #{act_type} is #{joining_act.gender} only.\"); end\n\t\tend\n\n\t\tnumber_of_attendings = joining_act.number_of_attendings\n\t\tif acts_membership.count < number_of_attendings or number_of_attendings == 0\n\t\t\tacts_membership << joining_act\n\t\telse\n\t\t\traise Errors::FlowError.new(send(\"#{act_type}_path\", offering_id), \"Permission denied.\")\n\t\tend\n\t\t@offering = joining_act\n\t\t@members = joining_act.members\n\t\tjoining_act.create_activity :create, owner: user\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to joining_act }\n\t\t\tformat.js\n\t\tend\n\tend",
"def accept\n @ride = current_user.fares.find_by_id(params[:ride])\n @rider = User.find_by_id(params[:passenger])\n\n @ride.accept(@rider)\n UserMailer.passenger_accept(current_user, @rider).deliver\n redirect_to user_path(current_user)\n end",
"def create\n @meta_title = meta_title 'Daily Afformations - Create your own personal afformations'\n\n @afformation = Afformation.new(afformation_params)\n @afformation.user_id = current_user.id if !current_user.admin?\n\n respond_to do |format|\n if @afformation.save\n format.html { redirect_to afformations_url, notice: 'Afformation was successfully created.' }\n format.json { render :index, status: :created, location: @afformation }\n else\n format.html { render :new }\n format.json { render json: @afformation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_membership\n @membership = Membership.find(params[:id])\n @plan = Plan.find_by_name('Premium')\n end",
"def enable\n meal = current_user.restaurant.meals.find(params[:id])\n meal.update(available: true)\n render json: {is_success: true}\n end",
"def new\n @primary = current_user\n @friendship = Friendship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @friendship }\n end\n end",
"def create\n @elder_member = ElderMember.new(elder_member_params)\n\n respond_to do |format|\n if @elder_member.save\n format.html { redirect_to @elder_member, notice: 'Elder member was successfully created.' }\n format.json { render action: 'show', status: :created, location: @elder_member }\n else\n format.html { render action: 'new' }\n format.json { render json: @elder_member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ride = current_user.create_ride(ride_params)\n create_resource @ride\n end",
"def new\n if current_member.can_admin_members?\n @member = Member.new\n \n @available_portable_numbers = Member.get_available_portable_numbers(1..60)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @member }\n end\n else\n render_forbidden\n end\n end",
"def new\n @internship = Internship.new\n \n @internship.user = @current_user if @internship.user == nil\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @internship }\n end\n end",
"def add_members(_members)\n _members.each do |_user_id|\n user_relationships.where(user_id: _user_id).first_or_create!(accepted_at: Time.current)\n end\n end",
"def create\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.json { render :show, status: :created, location: @member }\n else\n return api_error(status: :unprocessable_entity, message: @member.errors)\n end\n end\n end",
"def create\n @member = Crew.new\n if @member.update_attributes params\n render \"crew/show\"\n else\n respond_with @member\n end\n end",
"def member_params\n params.require(:member).permit(:user_name, :rank_id, :activity_status_id)\n end",
"def create\n @reservation = Reservation.new(params[:reservation])\n @reservation.user_id = current_user.id\n\n respond_to do |format|\n if @reservation.save\n\n # UserMailer.booking_create(current_user, @reservation).deliver\n # OwnerMailer.booking_create(@reservation).deliver\n\n Reward.create( user_id: @reservation.user_id, \n reservation_id: @reservation.id, \n points_total: 5*@reservation.party_size, \n points_pending: 5*@reservation.party_size, \n description: \"\")\n \n format.html { redirect_to @reservation, notice: 'Reservation was successfully created.' }\n format.json { render json: @reservation, status: :created, location: @reservation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @reservation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n r = params[:member]\n @member = Member.where(:email => r[:email], :group_name => r[:group_name], :admin_uuid => session[:user_uuid]).first\n r = @member.attributes.merge(r) unless @member.nil?\n @member = Member.new(r) if @member.nil?\n @member.update_attributes(r) unless @member.nil?\n unless @member.err\n @member.get_member_uuid\n end\n respond_to do |format|\n unless @member.nil?\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @invite = Invite.new(params[:invite])\n @user = current_user\n @user.invites << @invite\n @candidate = current_user.candidate\n @invites = Invite.scoped\n respond_to do |format|\n if @user.save\n InviteMailer.invite_friend(@invite, @user).deliver\n format.html { redirect_to new_invite_path, notice: \"Invitation was successfully sent to #{@invite.name} <#{@invite.email}>\" }\n else\n format.html { render action: \"new\" }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # @reservation = Reservation.new(reservation_params)\n @reservation = current_user.reservations.create!(reservation_params)\n\n respond_to do |format|\n if @reservation.save\n format.html { redirect_to @reservation, notice: 'Reservation was successfully created.' }\n format.json { render :show, status: :created, location: @reservation }\n else\n format.html { render :new }\n format.json { render json: @reservation.errors, status: :unprocessable_entity }\n end\n end\n # current_user.book! @reservation\n end",
"def create\n @member = Member.where(email: params[:member][:email]).first\n if @member\n @member.active = true\n @member.update(member_params)\n else\n @member = Member.new(member_params)\n end\n respond_to do |format|\n if @member.save\n Notify.welcome_email(@member).deliver_now\n if current_user.nil?\n log_in @member\n is_admin?\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n end\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def amendment\n Zapi::Models::Amendment.new\n end",
"def create\n r = params[:member]\n @member = Member.where(:email => r[:email], :group_name => r[:group_name], :admin_uuid => session[:user_uuid]).first\n r = @member.attributes.merge(r) unless @member.nil?\n @member = Member.new(r) if @member.nil?\n @member.update_attributes(r) unless @member.nil?\n\n unless @member.err\n @member.get_member_uuid\n end\n respond_to do |format|\n unless @member.nil?\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n Member.all.each { |member|\n member.assign_points\n }\n\n flash[:notice] = 'Puntos asignados correctamente'\n redirect_to matches_path\n end",
"def add\n cur_user = current_user.role_id\n pid = params[:id]\n if Member.find(cur_user).favoriteds.create(\n :member_id=>cur_user, :employer_id=>pid\n )\n flash[:notice] = 'Employer added to Faved list!'\n else\n flash[:alert] = 'There was a problem adding Employer to Faved list.'\n end\n redirect_to :action => 'display', :id =>(pid)\n end",
"def invite\n invitation_service.invite(invitation_params)\n end",
"def show\n @user = User.find(params[:id])\n @recommendation = @user.recommendations.build if logged_in?\n end",
"def new\n new_url = \"#{ENV['KPASS_ENDPOINT']}/members/new?app_id=#{ENV['KPASS_APP_ID']}\"\n redirect_to new_url\n end",
"def member_params\n params.require(:member).permit(:first_name, :last_name, :start_date, :end_date, :clothes_balance, :active, :status, :member_type, :referred_by, :boost_credit, :birthday_boost, :cost, :email, :add_on, :flagged_member, :password, :password_confirmation)\n end",
"def set_api_v1_mentorship_interest\n @api_v1_mentorship_interest = Api::V1::MentorshipInterest.find(params[:id])\n end",
"def create\n if params[:invitee_email]\n @friend = User.where(params[:invitee_email])\n @friendship = current_user.friendships.new(invitee_email :@friend)\n if @friendship.save\n flash[:success] = \"Congrats! You are now friends.\"\n else\n flash[:error] = \"Oops! There's been a mistake.\"\n redirect_to profile_path(@friend)\n end\n end\n end",
"def create\n # type = \"member\"\n\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render action: 'show', status: :created, location: @member }\n else\n format.html { render action: 'new' }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n resource = build_resource\n resource.role = 'advertiser'\n resource.build_advertiser\n @referrer = User.where(:id => session[:referrer_id]).first if session[:referrer_id]\n respond_with resource\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 member_params\n params.require(:member).permit :email, :first_name, :last_name, :other_name, :teacher_status, :portrait, :website_url, :facebook_url, :twitter_handle, :google_plus_url, :allow_newsletter, :allow_daily_digests\n end",
"def affiliation(name, req, desc)\n params = {:name => name, \n :description => desc,\n :requires_memberid => req}\n ClubAffiliation.create_or_update_by(:name, params)\nend",
"def update\n respond_to do |format|\n if @member.update(member_params)\n format.html { redirect_to @attend, notice: 'Attend was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n friendee = User.where(email: params[:search][:email]).first\n if friendee && Friending.where(friendee_id: current_user.id, friender_id: friendee.id).empty? && Friending.where(friendee_id: friendee.id , friender_id: current_user.id).empty?\n @friending = Friending.new()\n @friending.friender_id = current_user.id\n @friending.friendee_id = friendee.id\n\n if @friending.save\n render \"api/friendings/show\"\n else\n render json: @friending.errors.full_messages, status: 401\n end\n\n else\n render json: [\"Email address is not registered with EqualSlices.\"],\n status: 401\n end\n end",
"def approve_friend_request user_id\n response = post(\"/users/#{id}/approve\")[\"response\"]\n @user = Foursquared::Response::User.new(client, response[\"user\"])\n end",
"def approve_friend_request user_id\n response = post(\"/users/#{user_id}/approve\")[\"response\"]\n @user = Foursquared::Response::User.new(self,response[\"user\"])\n end",
"def set_leadership\n @leadership = Leadership.find(params[:id])\n end",
"def create\n\tif !checkadmin? then return end\n @member = Member.new(params[:member])\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @member, notice: 'Member was successfully created.' }\n format.json { render json: @member, status: :created, location: @member }\n else\n format.html { render action: \"new\" }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_approver\n\n # get the client\n @client = Client.find(params[:client_id])\n\n # get the contract\n @contract = Contract.find(params[:id])\n\n # get approvers not already assigned to the contract\n @approvers = @client.unassigned_approvers_for_contract(@contract)\n\n end",
"def new\n @member = Member.new\n @member.email = @search_string ||= \"\"\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @member}\n end\n end",
"def new_invite\n if idea_posting.users.exists?(current_user.id)\n @joinrequest = Joinrequest.new\n respond_to do |format|\n format.html \n format.json {redirect_to @joinrequest}\n end\n end\n end",
"def approve_join_request\n join_request = JoinRequest.find(params[:id])\n team = join_request.team\n # Only authorize the captain to do this\n if current_user.id == team.captain_id\n membership = Membership.create(\n team_id: join_request.team_id,\n user_id: join_request.user_id,\n admin: false\n )\n if membership.valid?\n join_request.destroy\n render json: {\n team: TeamSerializer.new(team),\n user: UserSerializer.new(current_user)\n }, status: :accepted\n else\n # invalid request\n render json: {\n message: \"Invalid request\",\n errors: membership.errors.full_messages\n }, status: :not_acceptable\n end\n else\n render json: { message: \"Only the captain is allowed to accept join requests\"}, status: :not_acceptable\n end\n end",
"def create\n super\n resource.update(password: params[:password], password_confirmation: params[:password_confirmation], member_id: SecureRandom.alphanumeric(6))\n post_gmo_with_create_member(resource)\n end",
"def create\n respond_with :api,:v1, ApidUser.create_or_update(params[:apid_user])\n end",
"def request_friend(friend)\n self.friendships.create!(friend_id: friend.id, status: 'requested')\n friend.friendships.create!(friend_id: self.id, status: 'pending')\n end",
"def new\n\t\t@recommendation = Recommendation.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.json { render json: @recommendation }\n\t\tend\n\tend",
"def new\n if User.find(current_user.id).internship_authorization\n @internship = Internship.new\n respond_with(@internship)\n else\n flash[:notice] = \"You cannot create an internship\"\n redirect_to internships_url\n end\n end",
"def member_params\n params.require(:member).permit(:name, :email, :location_id, :plan_id, :status)\n end",
"def set_movie_user_recommendation\n @recommendation ||= MovieUserRecommendation.find(params[:id])\n end",
"def create\n @reserve = Reserve.new(params[:reserve])\n @reserve.set_user\n\n if current_user.has_role?('Librarian')\n unless @reserve.user\n @reserve.user = @user\n end\n else\n if @reserve.user != current_user\n if @user != current_user\n access_denied; return\n end\n end\n end\n\n respond_to do |format|\n if @reserve.save\n @reserve.sm_request!\n\n format.html { redirect_to @reserve, :notice => t('controller.successfully_created', :model => t('activerecord.models.reserve')) }\n format.json { render :json => @reserve, :status => :created, :location => reserve_url(@reserve) }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @reserve.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @movie_user_recommendation = MovieUserRecommendation.new(movie_user_recommendation_params)\n\n respond_to do |format|\n if @movie_user_recommendation.save\n format.html { redirect_to @movie_user_recommendation, notice: 'Recommendation was successfully created.' }\n format.json { render :show, status: :created, location: @movie_user_recommendation }\n else\n format.html { render :new }\n format.json { render json: @movie_user_recommendation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def invite\n \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 set_member\n @member = User.where(id: params[:id], tenant_id: current_tenant.id).first\n rescue Exception\n puts Exception\n end",
"def accept_resource\n resource_class.accept_invitation!(update_resource_params)\n ## Report accepting invitation to analytics\n \n end",
"def set_member\n @member = Member.friendly.find(params[:id])\n end",
"def create\n @provider = Provider.new(params[:provider])\n\n respond_to do |format|\n if @provider.save\n ProviderAdmin.create(:member_id =>params[:member_id], :provider_id => @provider.id, :active=>true)\n format.html { redirect_to(@provider, :notice => 'Provider was successfully created.') }\n format.xml { render :xml => @provider, :status => :created, :location => @provider }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @provider.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @beneficiaire = Beneficiaire.find(params[:beneficiaire_id])\n @member = Member.new(member_params)\n\n respond_to do |format|\n if @member.save\n format.html { redirect_to @beneficiaire, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html {redirect_to @beneficiaire, error: 'Member was not successfully created!' }\n format.json { render json: @beneficiaire.errors, status: :unprocessable_entity }\n end\n end\n end",
"def request_friendship(user_2)\n \tself.friendships.create(friend: user_2)\n end",
"def create\n @reservation = Reservation.new(params[:reservation])\n\n @reservation.assign_attributes(:user_id => current_user.try(:id))\n \n respond_to do |format|\n if @reservation.save\n ReservationMailer.notification(@reservation, @reservation.user).deliver\n format.html { redirect_to reservations_path, notice: 'Reservation was successfully created.' }\n format.json { render json: @reservation, status: :created, location: @reservation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @reservation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_member\n @member = User.find(params[:id])\n end",
"def new\n @reserve = Reserve.new(params[:reserve])\n\n if current_user.has_role?('Librarian')\n @reserve.user = @user\n else\n if @user.present?\n if @user != current_user\n access_denied; return\n end\n end\n @reserve.user_number = current_user.user_number\n end\n\n get_manifestation\n if @manifestation\n @reserve.manifestation = @manifestation\n if @reserve.user\n @reserve.expired_at = @manifestation.reservation_expired_period(@reserve.user).days.from_now.end_of_day\n if @manifestation.is_reserved_by?(@reserve.user)\n flash[:notice] = t('reserve.this_manifestation_is_already_reserved')\n redirect_to @manifestation\n return\n end\n end\n end\n end",
"def create\n super\n @instructor.create_profile(profile_params)\n\n @instructor.update_attributes(\n plan_id: @instructor.id,\n product_id: @instructor.id\n )\n end",
"def new\n @member = Member.new\n \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 create\n @recommendation = Recommendation.new(recommendation_params)\n @submission = Submission.find_by_user_id(current_user.id)\n @recommendation.submission_id = @submission.id\n\n respond_to do |format|\n if @recommendation.save\n RecommendationRequestMailer.recommendation_request(@recommendation).deliver\n format.html { redirect_to dashboard_home_path, notice: 'Recommendation was successfully created.' }\n format.json { render :show, status: :created, location: @recommendation }\n else\n format.html { render :new }\n format.json { render json: @recommendation.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.5646906",
"0.5532538",
"0.54985344",
"0.5403972",
"0.5386378",
"0.53768337",
"0.53394663",
"0.533649",
"0.530887",
"0.5281685",
"0.52663296",
"0.5258725",
"0.52580065",
"0.52475876",
"0.5243645",
"0.52206445",
"0.520511",
"0.51992065",
"0.5196027",
"0.5191123",
"0.51868737",
"0.5175029",
"0.5168011",
"0.51678437",
"0.5157639",
"0.5157087",
"0.5156174",
"0.514937",
"0.51418525",
"0.51303416",
"0.5116318",
"0.51146895",
"0.51036173",
"0.51029855",
"0.5098516",
"0.5097261",
"0.5091567",
"0.5087669",
"0.50850195",
"0.5083398",
"0.50818735",
"0.50752294",
"0.5074767",
"0.5074082",
"0.5072521",
"0.5064453",
"0.50576246",
"0.5052186",
"0.50503385",
"0.5048604",
"0.50471216",
"0.5046569",
"0.5044262",
"0.50428617",
"0.50410694",
"0.503392",
"0.5025462",
"0.50240225",
"0.5020732",
"0.501688",
"0.50156164",
"0.50128293",
"0.50121015",
"0.5011841",
"0.5011037",
"0.50104415",
"0.49968213",
"0.4995253",
"0.49945572",
"0.49891156",
"0.49858922",
"0.4985695",
"0.49825075",
"0.498042",
"0.49802986",
"0.49757394",
"0.49666166",
"0.49665475",
"0.496519",
"0.49620122",
"0.49616233",
"0.49611855",
"0.4959668",
"0.4957306",
"0.4957005",
"0.49550036",
"0.4952102",
"0.49517623",
"0.4951253",
"0.49511787",
"0.49476457",
"0.4945254",
"0.49451804",
"0.4943479",
"0.49379286",
"0.49375144",
"0.49339372",
"0.4929617",
"0.49250755",
"0.49250546"
] | 0.70048314 | 0 |
This endpoint allows to search a member on the airline system. | def create_member_search(body)
# Prepare query url.
_path_url = '/v1/airline/members/actions/search'
_query_builder = Configuration.get_base_uri
_query_builder << _path_url
_query_url = APIHelper.clean_url _query_builder
# Prepare headers.
_headers = {
'accept' => 'application/json',
'content-type' => 'application/json; charset=utf-8'
}
# Prepare and execute HttpRequest.
_request = @http_client.post(
_query_url,
headers: _headers,
parameters: body.to_json
)
_context = execute_request(_request)
validate_response(_context)
# Return appropriate response type.
decoded = APIHelper.json_deserialize(_context.response.raw_body)
MemberSearchResponse.from_hash(decoded)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search\n @members = Member.search_by params[:category], params[:keywords], params[:is_active]\n\n render :template => '/api/members/index'\n end",
"def search_members(query, options = {})\n get search_path(\"members\"), options.merge(query: query)\n end",
"def index\n @search = Member.search(params[:search])\n @members = @search.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @members }\n end\n end",
"def index\n @member = Member.find(params[:member_id])\n end",
"def index\n if params[:data]\n @members = Member.get_members(params[:data][:kind].to_i, params[:data][:search])\n else\n @members = Member.all\n end\n\n @members = @members.paginate(:page => params[:page], :per_page => 25)\n end",
"def show\n authorize! :read, @ml_list\n @search = params[:search]\n @members = @ml_list.all_members.search(@search).order(:firstname).page(params[:page]).per_page(20)#.where(email_source_accounts: {primary: true})\n @external_emails = @ml_list.ml_external_emails\n @redirection_aliases = @ml_list.redirection_aliases\n @admins_and_moderators = @ml_list.super_members\n if can? :admin_members, @ml_list\n @pendings = @ml_list.pendings\n @banneds = @ml_list.banneds\n end\n\n @current_user_is_member = @ml_list.all_members.include?(@current_user)\n end",
"def search(params = {})\n @api.get(\"api.json\", params)\n end",
"def search(options)\n options[:base] = @base_name\n options[:attributes] ||= %w{ou cn dn sAMAccountName member}\n options[:ignore_server_caps] ||= true\n\n @connection.search(options)\n end",
"def list\n search_value = params[\"search\"] || \"\"\n if !current_user.blank?\n @reservation = Reservation.where(\"user_id = ? and itinerary_number like ?\", current_user.id, \"%#{search_value}\")\n end\n end",
"def index\n @member_check_ins = MemberCheckIn.search(params[:search])\n end",
"def search(params={})\n rpc_call :search, params\n end",
"def search\n query = {\n 'res_id' => params[:id]\n }\n @search = HTTParty.get('https://developers.zomato.com/api/v2.1/restaurant?', query: query, headers: headers)\n end",
"def index\n if params[:term].present?\n @users = User.clients.search params[:term]\n else\n @users = User.clients\n end\n\n end",
"def index\n candidate = UspsInPersonProofing::Applicant.new(\n address: search_params['street_address'],\n city: search_params['city'], state: search_params['state'],\n zip_code: search_params['zip_code']\n )\n response = proofer.request_facilities(candidate)\n if response.length > 0\n analytics.idv_in_person_locations_searched(\n success: true,\n result_total: response.length,\n )\n else\n analytics.idv_in_person_locations_searched(\n success: false, errors: 'No USPS locations found',\n )\n end\n render json: response.to_json\n end",
"def show\n @epu = Election.find(params[:id]).elections_participated_users.includes(:user)\n (@filterrific = initialize_filterrific(\n Member,\n params[:filterrific]\n )) || return\n @members = @filterrific.find.where(tenant_id: current_tenant.id).includes(:roles).page(params[:page])\n end",
"def contractor_search\n\n # get the contract\n @contract = Contract.find(params[:id])\n\n # get the client\n @client = @contract.client\n\n # double check the query\n query = params[:q]\n if query.blank? || query[0].blank?\n\n flash[:notice] = \"You must specify a last name or email address\"\n @contractors = []\n \n else\n\n @contractors = User.paginate :per_page => 26, :page => params[:page], :conditions => [\"(lastName like ? or email = ?) and type = 'ContractorUser'\", '%'+query.to_s+'%', '%'+query.to_s+'%'], :order => 'lastName'\n \n end\n \n end",
"def search\n @member_name = params[:member_name]\n @serial_num = params[:card_serial_num]\n if !@member_name.blank?\n @serial_num = \"\" if params[:p].blank?\n member = Member.where(:name => @member_name).where(:status => CommonResource::MEMBER_STATUS_ON).first\n if member.nil?\n @member_cards = []\n else\n @member_cards = MemberCard.where(:member_id => member.id)\n end\n end\n @member_card = MemberCard.new\n if \"num\" == params[:p] && !@serial_num.blank?\n @member_cards = [MemberCard.where(:card_serial_num => @serial_num).first]\n @member_card = @member_cards.present? ? @member_cards.first : MemberCard.new\n end\n #@member_card = @member_cards.present? ? @member_cards.first : MemberCard.new\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @member_cards }\n end\n end",
"def index\n @plans = Plan.where(search_params)\n @areaname = Area.find(search_params[:area_id]).name\n end",
"def search\n render json: PersonScantronAppointment.first(10)\n end",
"def Search query\n \n APICall(path: \"search.json?query=#{query}\",method: 'GET')\n \n end",
"def index\n @q = @current_enterprise.members.ransack(params[:q])\n @members = @q.result.order(load: :desc)\n end",
"def search(term, location)\n url = \"#{API_HOST}#{SEARCH_PATH}\"\n params = {\n term: term,\n location: location,\n limit: SEARCH_LIMIT\n }\n#this takes info from params hash\n response = HTTP.auth(bearer_token).get(url, params: params)\n response.parse[\"businesses\"]\nend",
"def search_request(params)\n result = @client.connection.get(PATH, params)\n Yelp::Fusion::Error.check_for_error(result)\n result\n end",
"def show \n members = @corp.members_income\n \n if params[:q]\n if params[:q][:ts_lteq]\n date_to = params[:q][:ts_lteq]\n if date_to =~ /^\\d{4}-\\d{2}-\\d{2}$/\n params[:q][:ts_lteq]=Time.parse(date_to).strftime(\"%Y-%m-%d 23:59:59\")\n end\n end\n if params[:q][:s]==\"amount asc\"\n @search=members.sort_by_sum_amount_asc.page(params[:page]).per(10).search\n elsif params[:q][:s]==\"amount desc\"\n @search=members.sort_by_sum_amount_desc.page(params[:page]).per(10).search \n else\n @search = members.page(params[:page]).per(10).search(params[:q]) \n end\n end\n \n @search = members.search(params[:q])\n @members_income = @search.result\n \n end",
"def search\n\t\tusers = []\n\t\tif !params.has_key?(\"term\") or params[:term].empty?\n\t\t\trespond({ status: 1, error: \"You must provide a term to search for\" })\n\t\telse\n\t\t\tUser.contains(params[:term]).each do |u|\n\t\t\t\thash = u.attributes \n\t\t\t\thash[:client] = u.client ? u.client.name : nil\n\t\t\t\tusers.push(hash)\n\t\t\tend\n\t\t\trespond({ status: 0, users: users })\n\t\tend\n\tend",
"def search\n render json: User.first(10)\n end",
"def index\n @restmembers = Restmember.all\n end",
"def index\n @members = Member.find(:all)\n end",
"def member(member_id, &block)\n get \"/member/#{member_id}/\", nil, &block\n end",
"def search\n @users ||= User.search_user(params[:search])\n authorize! :read, @user\n end",
"def index\n return render json: { error: 'bad_request' }, status: :bad_request unless params_present?\n\n @users = User.where('name LIKE(?)', \"%#{params[:keyword]}%\")\n\n if @users.present?\n render json: @users, each_serializer: Rest::UserSerializer\n else\n render json: { error: 'not_found' }, status: :not_found\n end\n end",
"def search_by_name\n query = params[:query]\n users = User.search_users(query)\n render :json => users.to_json(:check_user => current_user)\n end",
"def show\n @aiit_member = AiitMember.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @aiit_member }\n end\n end",
"def index\n @listings = Listing.search(params[:search], params[:city])\n end",
"def index\n @state = params[:status].present? ? params[:status] : \"active\"\n if stale?([@space, @state, flash])\n @members = @space.members.by_status(@state).order(\"name asc\")\n end\n end",
"def show\n\t\t@reservations = Reservation.where(listing_id: @listing.id)\n\t\t# @listing = Listing.search(params[:search], params[:city])\n\n\tend",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def search_user\n \t@users = UsersService.searchUser(params)\n render :index\n end",
"def search\n @costumes = current_user.search(params[:search])\n end",
"def index\n @username_actual = params['user']\n @reservations = Reservation.where(username: @username_actual)\n end",
"def search\n\n end",
"def search\n query = params[:name] \n @paginated_users = User.search(query) \n end",
"def search\n end",
"def search_user\n @users = UserService.searchUser(params)\n render :index\n end",
"def index\n unless params['body']['search'].blank?\n @amenities = Amenity.where([\"name ILIKE ?\",\"%#{params['body']['search']}%\"])\n else\n @amenities =Amenity.order('created_at ASC')\n end\n end",
"def index\n\n headers['Access-Control-Allow-Origin'] = '*'\n @reservations = Reservation.search(params[:search])\n respond_to do |format|\n # perform the standard login check for the html version of the request.\n # ( this will also render the default index template )\n format.html { check_if_admin_logged_in }\n format.json do\n # TODO: do knock authentication check here\n render json: @reservations, include: ['users','property']\n end\n end #respond_to\n end",
"def index\n @members = Member.where(active: true)\n end",
"def user_search(options = {})\n get('users/search', options)\n end",
"def index\n @members = Member.where(\n current_member.the_admin? ? {} : {region_id: current_member.region_id}\n ).order(\"created_at\").paginate(:page => params[:page], :per_page => 30)\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def actor_search\n if params[:actor].present?\n @results = MovieDataService.get_movies_for_actor(\n actor_name: params[:actor],\n page: params[:page],\n sort_by: params[:sort_by]\n )\n end\n end",
"def index\n @filter = params[:filter] if params.has_key? :filter and %w{unapproved invited}.include? params[:filter]\n\n if params[:search]\n @search = User.search { fulltext params[:search] }\n @users = user_query.where(id: @search.results.map(&:id))\n else\n @users = user_query.order(updated_at: :desc)\n end\n end",
"def find_member\n @member = Member.find(params[:id])\n end",
"def user_search username\n url = API + \"users/search?q=#{username}&access_token=\" + @access_token\n get(url)['data']\n end",
"def index\n @tenants = Tenant.search(params[:search])\n end",
"def show\n @q = User.ransack(params[:q])\n\n @user_search = Array.new\n @user_search = @q.result if params[:q] and params[:q][:name_or_phone_or_email_cont].length > 0\n\n\n @players = User.find(@team.player_team_rs.pluck(:user_id))\n end",
"def index\n @user = current_user\n @destinations = Destination.search(params[:search])\n end",
"def show\n begin\n @search_by_nutrients = @client.search_by_nutrients(params[:min],params[:max],params[:value1],params[:value2 ])\n rescue RuntimeError\n @error = true\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @member }\n end\n end",
"def search\n if params[:user_only] and current_user.blank?\n render json: {\n error: \"Must authenticate user for user_only route search.\"\n }\n return\n end\n Rails.logger.debug \"Search got params: #{params}\"\n # Pagination\n per_page = params[:per_page] || 10\n per_page = per_page.to_i\n\n page_num = params[:page_num] || 1\n page_num = page_num.to_i\n\n offset = page_num * per_page - per_page\n\n # Location\n if params[:start_maidenhead]\n start_maidenhead = params[:start_maidenhead]\n elsif params[:source_lat] and params[:source_long]\n start_maidenhead = Maidenhead.to_maidenhead(params[:source_lat].to_f, params[:source_long].to_f, 4)\n end\n\n if params[:end_maidenhead]\n end_maidenhead = params[:end_maidenhead]\n elsif params[:dest_lat] and params[:dest_long]\n end_maidenhead = Maidenhead.to_maidenhead(params[:dest_lat].to_f, params[:dest_long].to_f, 4)\n end\n\n # Where clause\n condition = {}\n condition[:start_maidenhead] = start_maidenhead if start_maidenhead.present?\n condition[:end_maidenhead] = end_maidenhead if end_maidenhead.present?\n condition[:user_id] = current_user.id if params[:user_only].present?\n\n # Group by Similarity rather than start/end points if both points provided\n if start_maidenhead and end_maidenhead\n # Get all uses and group into routes by similarity\n Rails.logger.debug \"Searching for routes from #{start_maidenhead} to #{end_maidenhead}\"\n all_uses = Route.where(condition).order('start_time DESC').limit(per_page).offset(offset)\n routes = all_uses.inject([]) do |routes, use|\n if routes.blank?\n routes << use\n else\n use_found = routes.any? { |route| use.is_similar?(route) }\n routes << use unless use_found\n end\n routes\n end\n\n # Summarise routes\n summaries = routes.inject([]) do |all_summaries, route|\n all_summaries << route.summary\n end\n else\n routes = Route.where(condition)\n .select('start_maidenhead, end_maidenhead, MAX(start_time) as start_time')\n .group(:start_maidenhead, :end_maidenhead)\n .order('start_time DESC')\n .limit(per_page)\n .offset(offset)\n\n if params[:user_only]\n summaries = routes.inject([]) do |all_summaries, route|\n all_summaries << Route.summarise_routes(route.start_maidenhead, route.end_maidenhead, current_user)\n end\n else\n summaries = routes.inject([]) do |all_summaries, route|\n all_summaries << Route.summarise_routes(route.start_maidenhead, route.end_maidenhead, nil)\n end\n end\n end\n\n render json: {\n routes: summaries\n }\n end",
"def search_request(params)\n result = @client.connection.get PATH, params\n Error.check_for_error(result)\n result\n end",
"def user_search\n @users = User.admin_search(params[:query])\n end",
"def search_team_members(body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/team-members/search',\n 'default')\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 index\n @members = Member.search(params[:search]).order(sort_column+\" \"+sort_direction).paginate(:per_page => 10, :page => params[:page])\n @title = \"Members\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.js # index.js.erb\n format.xml { render :xml => @members }\n end\n end",
"def user_search(search, options = {})\n options[:search] = search\n get('/users', query: options)\n end",
"def index\n if params[:address].present?\n @q = Restroom.near(params[:address], 60, order: :distance).search(params[:q])\n @restrooms = @q.result(distinct: true).page(params[:page]).per(5)\n @search_coordinates = Geocoder.coordinates(params[:address])\n @is_search = true\n else\n @q = Restroom.near(request.remote_ip, 60, order: :distance).search(params[:q])\n @restrooms = @q.result(distinct: true).page(params[:page]).per(5)\n @search_coordinates = Geocoder.coordinates(request.remote_ip)\n @is_search = false\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @restrooms }\n end\n end",
"def index\n if params[:search]\n @family_members = FamilyMember.search(params[:search]).order(\"created_at DESC\")\n else\n @family_members = FamilyMember.all.order(\"created_at DESC\")\n end\n end",
"def query_collection_members\n params[:q] = params[:cq]\n @response = repository.search(query_for_collection_members)\n @member_docs = @response.documents\n end",
"def search_team_members(body:)\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v2/team-members/search'\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json',\n 'content-type' => 'application/json; charset=utf-8'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.post(\n _query_url,\n headers: _headers,\n parameters: body.to_json\n )\n OAuth2.apply(config, _request)\n _response = execute_request(_request)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_response.raw_body)\n _errors = APIHelper.map_response(decoded, ['errors'])\n ApiResponse.new(\n _response, data: decoded, errors: _errors\n )\n end",
"def members\n if @memorial\n @pagination = {\n q: params[:q].nil? ? \"\" : params[:q],\n p: params[:p].nil? ? \"1\" : params[:p],\n per_p: params[:per_p].nil? ? \"10\" : params[:per_p],\n total: 0,\n order: {\n column: @order.column,\n dir: @order.direction\n }\n }\n @users = @memorial.users\n .reorder(@order.column => @order.direction)\n .ransack(first_name_or_last_name_or_email_cont_any: @pagination[:q].split(\" \")).result\n @pagination[:total] = @users.length\n @users = @users\n .paginate(page: @pagination[:p], per_page: @pagination[:per_p])\n user_memorials = []\n @users.each do |u|\n user_memorials << u.user_memorials.find_by(memorial_id: @memorial[:uuid])\n end\n user = user_memorials.as_json({\n include: [{user: {only: [:uuid, :first_name, :last_name, :email]}}, {role: {only: [:uuid, :name]}}]\n })\n users = []\n user.each do |u|\n entity = {\n uuid: u['user']['uuid'],\n first_name: u['user']['first_name'],\n last_name: u['user']['last_name'],\n email: u['user']['email'],\n roles: [u['role']]\n }\n users << entity\n end\n response = {\n organization: @memorial[:organization_id].present? ? Organization.where(uuid: @memorial[:organization_id]).select(\"uuid, name, address, image, posY, posX, scale, rot\") : nil,\n results: users,\n pagination: @pagination\n }\n render json: response\n else\n render json: {error: 'You do not have access to this memorial'}, status: 422\n end\n end",
"def member_of()\n return MicrosoftGraph::Contacts::Item::MemberOf::MemberOfRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def index\n @travelers = Traveler.search(params[:search])\n end",
"def show_member\n @member = Member.find(params[:id])\n end",
"def show\n #@member= Member.find(params[:member_id])\n end",
"def show\n #@member= Member.find(params[:member_id])\n end",
"def show\n #@member= Member.find(params[:member_id])\n end",
"def show\n @search = Search.find(params[:id])\n @public_officers = @search.public_officers\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @search.public_officers }\n end\n \n end",
"def get_member_of_list(user, list, member_id)\n get(\"/#{user}/#{list}/members/#{member_id}.json\")\n end",
"def show\n search_url = \"https://seeiendom.kartverket.no/api/soekEtterEiendom?searchstring=#{CGI.escape(@address_search.search_string)}\"\n @search_result_json = HTTParty.get(search_url)\n end",
"def index\n @title = \"Members\"\n @fullwith_page = true\n\n authorize! :index, Member\n\n if params[:per_page] == 'all'\n Member.per_page = 100000\n else\n Member.per_page = params[:per_page] || 30\n end\n\n case sort_column\n when 'payments'\n @members = Member.search(params[:search]).accessible_by(current_ability).includes(:payments).all.sort_by {|m| m.payments.size * (sort_direction == 'asc' ? 1 : -1)}.paginate(:page => params[:page], per_page: Member.per_page)\n when 'debtor?'\n @members = Member.search(params[:search]).accessible_by(current_ability).includes(:payments).all.sort_by {|m| (m.debtor? ? 1 : 0) * (sort_direction == 'asc' ? 1 : -1)}.paginate(:page => params[:page], per_page: Member.per_page)\n when 'paid_upto'\n @members = Member.search(params[:search]).accessible_by(current_ability).includes(:payments).all.sort_by {|m| (m.paid_upto.nil? ? 0 : m.paid_upto.to_time.to_i) * (sort_direction == 'asc' ? 1 : -1)}.paginate(:page => params[:page], per_page: Member.per_page)\n else\n @members = Member.search(params[:search]).accessible_by(current_ability).page(params[:page]).order(sort_column => sort_direction)\n end\n\n @skipped_members_count = params[:page].nil? ? 0 : (params[:page].to_i - 1) * Member.per_page\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @members }\n format.csv { render csv: Member.all, :filename => 'members' }\n end\n end",
"def search\n\n end",
"def get_members\n @user = User.find_by(user_params)\n @members = @user.members\n \n if not @members.nil?\n render json: @members\n else \n render json: \"\"\n end\n end"
] | [
"0.67855644",
"0.6548864",
"0.6258896",
"0.6216999",
"0.6200944",
"0.61297095",
"0.60450435",
"0.6024119",
"0.6001982",
"0.60001326",
"0.594357",
"0.592639",
"0.59210527",
"0.5875939",
"0.5861792",
"0.5850032",
"0.5848564",
"0.5846454",
"0.5837113",
"0.5830175",
"0.58282036",
"0.5814439",
"0.58041805",
"0.57619315",
"0.5761693",
"0.57603735",
"0.57557017",
"0.57540613",
"0.5751997",
"0.57432866",
"0.5741414",
"0.57399714",
"0.5736028",
"0.5724074",
"0.570946",
"0.57044435",
"0.569602",
"0.569602",
"0.569602",
"0.569602",
"0.569602",
"0.569602",
"0.569602",
"0.569602",
"0.569602",
"0.569602",
"0.5695804",
"0.56944793",
"0.56892204",
"0.56803787",
"0.5670598",
"0.5668347",
"0.5666016",
"0.56657165",
"0.56610847",
"0.5659159",
"0.5656915",
"0.5651446",
"0.56487596",
"0.56487596",
"0.56487596",
"0.56487596",
"0.56487596",
"0.56487596",
"0.56487596",
"0.56487596",
"0.56487596",
"0.56487596",
"0.5632967",
"0.56264925",
"0.5623634",
"0.5604149",
"0.56006557",
"0.5598799",
"0.5593037",
"0.55864626",
"0.55823034",
"0.5577322",
"0.5576964",
"0.557315",
"0.5572465",
"0.5567529",
"0.5560423",
"0.5558175",
"0.5558093",
"0.55539185",
"0.5552396",
"0.55436736",
"0.5536459",
"0.55339307",
"0.55325997",
"0.55319107",
"0.55319107",
"0.55319107",
"0.55290234",
"0.55206305",
"0.55191493",
"0.55125105",
"0.5511137",
"0.55110836"
] | 0.6971287 | 0 |
sets the artist to the artist of the specified name | def artist_name=(name)
self.artist = Artist.find_or_create_by(name: name)
self.artist = artist
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def artist_name=(name)\n # The actual assignment of the artist \"michael jackson\"\n # to the Song instance variable occurs in the .add_song \n # method in the Artist class.\n Artist.find_or_create_by_name(name).add_song(self)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n self.artist = artist\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n end",
"def artist_name=(name)\n self.artist =Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n artist = Artist.find_or_create_by(name: name)\n self.artist = artist\n end",
"def artist_name=(name)\n @artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n # binding.pry\n if (self.artist.nil?)\n self.artist = Artist.find_or_create_by_name(name)\n self.artist.add_song(self) \n end\n \n end",
"def artist_name=(name)\n # Get the instance of the Artist class that represents that artist.\n self.artist = Artist.find_or_create_by_name(name)\n\n # Assign the song to the artist (Since an artist has many songs, we'll want to make this association\n # Now that we have the artist instance,\n # we'll want to again collaborate with the Artist class by calling on the Artist#add_song(some_song) method.\n self.artist.add_song(self)\n\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def artist_name=(name)\n # When instantiating, set the .artist attribute to what is input in name\n self.artist = Artist.find_or_create_by(name: name)\n\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n binding.pry\n end",
"def artist_name=(artist_name)\n self.artist = Artist.find_or_create_by_name(artist_name)\n self.artist.add_song(self)\n end",
"def set_artist\n @artist = Artist.find_by(name: params[:name])\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n #return the new song instance\n artist.add_song(self)\n end",
"def artist_name=(artistName)\n Artist.find_or_create_by_name(artistName)\n Artist.find(artistName)\n end",
"def artist_name=(name)\n #object attr\n self.artist = Artist.find_or_create_by_name(name)\n\n artist.add_song(self)\n\n end",
"def add_song_by_name(name)\n\t\tSong.new(name).artist = self \n\tend",
"def artist(value)\n @ole.Artist = value\n nil\n end",
"def artist=(artist)\n #associates an artist with a song\n @artist = artist\n end",
"def artist= (artist)\n @artist = artist\n artist.add_song(self)\n end",
"def set_artist\n # @artist = Artist.find(params[:id])\n # @artist = Artist.find_by(artist_name: params[:artist_id])\n end",
"def set_artist\n # @artist = Artist.find(params[:id])\n # @artist = Artist.find_by(artist_name: params[:artist_id])\n end",
"def set_artist\n # @artist = Artist.find(params[:id])\n # @artist = Artist.find_by(artist_name: params[:artist_id])\n end",
"def artist=(the_artist)\n @artist = the_artist\n if @artist \n @artist.add_song(self)\n end\n @artist\n end",
"def artist=(artist)\n @artist = artist\n @artist.add_song(self)\n end",
"def set_artist\n\n\tartist = Artist.find_by_artist_name(self.artist_name)\n\t if artist != nil \n\t\t self.artist_name = artist\n\t\t return true\n\t else\n\t\terrors.add_to_base(\"combination of: 'artist_name' is invalid- it must be unique\")\n\t\t return false\n\tend\nend",
"def artist=(artist)\n @artist = artist\n artist.add_song(self)\n end",
"def artist=(artist)\n @artist = artist\n artist.add_song(self)\n end",
"def artist=(artist)\n @artist = artist\n artist.add_song(self)\n end",
"def set_artist\n @artist = Artist.find(params[:id])\n end",
"def artist=(artist)\n @artist = artist\n if artist != nil\n @artist.add_song(self)\n end\n end",
"def add_artist_to_album!(album_object, artist_name)\n if ((!album_object.artist) || album_object.artist.name != artist_name)\n if(artist_object_blank?(artist_name))\n artist = create_artist_object_with_name!(artist_name)\n else\n artist = find_artist_object_by_name(artist_name)\n end\n\n album_object.artist_id = artist.id\n end\n end",
"def set_artist\n @artist = Artist.find(artist_params[:id])\n end",
"def artist=(v)\n if @artist != v\n @needs_commit = true\n @artist = v\n end\n end",
"def artist_name=(name)\n#binding.pry\n self.artist = Artist.find_or_create_by(name: name)\n\n end",
"def set_artist\n @artist = Artist.friendly.find(params[:id])\n end",
"def set_artist\n @artist = Artist.find_by(id: params[:id])\n end",
"def artist=(artist)\n @artist = artist\n end",
"def artist=(artist)\n @artist = artist\n if artist.class == Artist\n artist.add_song(self)\n end\n end",
"def artist=(artist)\n @artist = artist\n artist.add_song(self)\n end",
"def set_artist\n @artist = Artist.find(params[:id])\n end",
"def set_artist\n @artist = Artist.find(params[:id])\n end",
"def set_artist\n @artist = Artist.find(params[:id])\n end",
"def set_artist\n @artist = Artist.find(params[:id])\n end",
"def set_artist\n @artist = Artist.find(params[:id])\n end",
"def set_artist\n @artist = Artist.find(params[:id])\n end",
"def set_artist\n @artist = Artist.find(params[:id])\n end",
"def set_artist\n @artist = Artist.find(params[:id])\n end",
"def set_artist\n @artist = Artist.find(params[:id])\n end",
"def set_artist\n @artist = Artist.find(params[:id])\n end",
"def set_artist\n @artist = Artist.find(params[:id])\n end",
"def set_artist\n @artist = Artist.find(params[:id])\n end",
"def set_artist\n @artist = Artist.find(params[:id])\n end",
"def album_artist(value)\n @ole.AlbumArtist = value\n nil\n end",
"def artist=(artist)\n @artist = artist\n end",
"def artist=(artist)\n @artist = artist\n end",
"def artist=(artist)\n @artist = artist\n end",
"def artist=(artist)\n @artist = artist\n end",
"def set_artist\n\t\t@artist = Artist.find(params[:id])\n\tend",
"def set_artist\n @artist = Artist.find(params[:id] || params[:artist_id])\n end",
"def add_song_by_name(name)\n song = Song.new(name)\n song.artist = self\n end",
"def add_song_by_name(name)\n song = Song.new(name)\n song.artist = self\n end",
"def set_album_artist\n @album_artist = Artist.find(params[:id])\n end",
"def set_artist\n @artist = Artist.resolve(params[:id])\n end",
"def artist=(artist) #assigns an artist to the song (song belongs to artist)\n @artist = artist #artist is reading from Song class artist method(reader)\n artist.add_song(self) #invokes Artist#add_song to add itself to the artist's collection of songs (artist has many songs)\n end",
"def artist=(artist) #attr_accessor setter part\n @artist = artist\n end",
"def initialize(name)\n @name = name\n @songs = [ ]\n #peter.song = (\"pit\") How to attribute song to the artist after the artist is create.\n end",
"def set_artist\n @artist = Artist.find(params[:id])\n end",
"def set_artist\n @artist = Artist.find(params[:id])\n end",
"def artist=(artist)\n @artist = artist #returns an instance of the Artist object\n end",
"def artist=(artist)\n\n\t\tif artist == nil\n\t\t\t@artist = artist\n\t\telsif artist != nil\n\t\t\t@artist = artist\n\t\t\tartist.add_song(self)\n\t\tend\n\tend",
"def artist=(artist)\n @artist = artist\n \n # invokes Artist#add_song to add itself to the artist's\n # collection of songs (artist has many songs)\n artist.add_song(self)\n end",
"def add_song_by_name(song_name)\n # Create a new song called \"song\" with argument passed in.\n song = Song.new(song_name)\n # Associate it with the artist\n song.artist = self\n end",
"def set_artist\n @artist = Artist.friendly.find(params[:id])\n end",
"def artist=(artist) #class methos\n @artist = artist\n end",
"def artist=(artist)\n @artist = artist\n artist.add_song(self) #=> invokes Artist#add_song to add itself to the artist's collection of songs (artist has many songs)\n end",
"def artists(artist)\n if song.artist = nil || !Artist.find_by_name(name)\n song.artist = artist \n Artist.all << artist \n end \n end",
"def add_song(song)\n song.artist = self \n end",
"def artist=(artist)\n @artist = artist\n #Invokes Artist#add_song to add itself to the artist's songs collection \n # (artist has-many songs) \n self.artist.add_song(self)\n end",
"def update(name, artist, year, genre)\n self.name = name.length > 0 ? name : self.name\n self.artist = artist.length > 0 ? artist : self.artist\n self.year = year.length > 0 ? year : self.year\n self.genre = genre.length > 0 ? genre : self.genre\n @@albums[self.id] = Album.new(self.name, self.artist, self.year, self.genre, self.id)\n end",
"def artist_name\n if self.name \n self.name\n else \n nil\n end \n end",
"def set_artistum\n @artistum = Artistum.find(params[:id])\n end",
"def set_spotify_artist\n @spotify_artist = SpotifyArtist.find(params[:id])\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end"
] | [
"0.8631267",
"0.8611113",
"0.8611113",
"0.8611113",
"0.8611113",
"0.85706115",
"0.856181",
"0.856181",
"0.85435855",
"0.85435855",
"0.85272115",
"0.8488491",
"0.84813833",
"0.84587324",
"0.8446932",
"0.84012806",
"0.84012806",
"0.83807606",
"0.8320474",
"0.8320474",
"0.8320474",
"0.8320474",
"0.83135027",
"0.8246036",
"0.82197744",
"0.81226736",
"0.7819102",
"0.7803172",
"0.7629542",
"0.76076317",
"0.7520071",
"0.746164",
"0.7449295",
"0.7449295",
"0.7449295",
"0.7434306",
"0.736259",
"0.7349041",
"0.73360795",
"0.73360795",
"0.73360795",
"0.73015356",
"0.72672945",
"0.726012",
"0.7250802",
"0.7230797",
"0.7225823",
"0.72246456",
"0.7217602",
"0.7208561",
"0.72076225",
"0.7206884",
"0.7202918",
"0.7202918",
"0.7202918",
"0.7202918",
"0.7202918",
"0.7202918",
"0.7202918",
"0.7202918",
"0.7202918",
"0.7202918",
"0.7202918",
"0.7202918",
"0.7202918",
"0.7202572",
"0.71971333",
"0.71971333",
"0.71971333",
"0.71971333",
"0.7193421",
"0.7180644",
"0.7176398",
"0.7176398",
"0.71725434",
"0.7122469",
"0.70807296",
"0.7005696",
"0.69973546",
"0.69856495",
"0.69856495",
"0.6963654",
"0.6956836",
"0.69504815",
"0.6923813",
"0.69156617",
"0.68951374",
"0.68653804",
"0.68448",
"0.6803859",
"0.6778311",
"0.6769371",
"0.6754921",
"0.673976",
"0.67396176",
"0.6718059",
"0.6718059",
"0.6718059",
"0.6718059",
"0.6718059"
] | 0.84776556 | 13 |
returns the artist name | def artist_name
self.try(:artist).try(:name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def artist_name\n artist.name if artist\n end",
"def artist_name\n \tif self.artist\n \t\tself.artist.name\n \tend\n end",
"def artist_name\n if self.artist\n artist.name\n else\n nil\n end\n end",
"def artist_name\n if self.artist #if song has an artist aka TRUE\n self.artist.name #return the artist name\n else\n nil #if no artist name return nil\n end\n end",
"def artist_name\n if artist\n self.artist.name\n else\n nil\n end\n end",
"def artist_name\n # self.artist.name\n self.artist ? self.artist.name : ''\n end",
"def artist_name\n @artist.name if @artist\n end",
"def artist_name\n self.artist ? self.artist.name : nil\n end",
"def artist_name\n artist ? artist.name : ''\n end",
"def artist_name\n self.artist.name\n end",
"def artist_name\n self.artist.name\n end",
"def artist_name\n self.artist.name\n end",
"def artist_name\n self.artist.name\n end",
"def artist_name\n if self.artist\n self.artist.name\n else\n nil\n end\n end",
"def artist_name\n self.artists.collect do |artist|\n artist.name\n end\n end",
"def artist_name\n if self.artist == nil\n nil\n else\n self.artist.name\n end\n end",
"def name\n return @artist_data[\"name\"]\n end",
"def artist_name\n if self.name \n self.name\n else \n nil\n end \n end",
"def artist_name\n self.artist ? self.artist.name : nil\n end",
"def artist_name\n nil\n end",
"def artist_name\n if artist_name_from_url.present?\n artist_name_from_url\n elsif api_metadata.present?\n api_metadata.dig(:author, :username)\n else\n nil\n end\n end",
"def artist_name\n if self.artist == nil #findining artist of song\n nil\n else\n artist.name\n end\n end",
"def tag_name\n artist_name\n end",
"def artist_name\n self.artist.name if self.artist \n end",
"def artist()\n sql = \"SELECT artist_name FROM artists WHERE id = $1\"\n values = [@artist_id]\n result = SqlRunner.run(sql, values)\n return result[0][\"artist_name\"]\n end",
"def artist\n @artist #tells song its artist name\n end",
"def full_name\n\t\ts = title\n\t\ts = \"#{artist.name} - #{s}\" if artist\n\t\treturn s\n\tend",
"def f_artist\n fname_bits[-3] || 'unknown_artist'\n end",
"def artist_name_and_genre\n \"#{artist_name} - #{genre.name}\"\n end",
"def artist_name_from_url\n urls.map { |url| url[PROJECT, :artist_name] || url[ARTIST, :artist_name] }.compact.first\n end",
"def artist_names\n artists.map do |artist|\n artist.name\n end\n end",
"def find_similiar_artist\n self.name\n end",
"def artist\n artists.first\n end",
"def artist_names\n self.artists.map do |artist|\n artist.name\n end\n end",
"def artist_names #return array of the names of all artists that have a painting in a gallery\n artists.name #pull array from artists method and call reader to get their name\n end",
"def artist(string)\n PRESETS[:artist].fetch(string.to_sym,\n title(string).gsub('and the ', 'and The '))\n end",
"def artist\n @ole.Artist\n end",
"def artist_names\n self.artists.collect do |n|\n n.name \n end\n end",
"def artist_names\n names = \"\"\n self.artists.each do |artist|\n names += \"#{artist.name}, \"\n end\n\n # Remove trailing ,\n names.chomp!(\", \")\n return names\n end",
"def artist\r\n @artist\r\n end",
"def artist\n @artist\n end",
"def artist\n @artist\n end",
"def show\n @artist = @song.artist\n @artist_name = @artist ? @song.artist.name : \"no artist\"\n end",
"def album_artist\n @ole.AlbumArtist\n end",
"def artist\n artists = tracks.map{|t| t.artist}.compact\n if artists.uniq.size == 1\n artists.first\n else\n \"Compilation\"\n end\n end",
"def artist_name\n # Find the name of the artist associated with this specific object\n artist.try(:name)\n # This wouldn't work: WHY?\n # @artist_name= self.artist.name\n end",
"def artist_name_downcase\n artist_name.to_s.downcase\n end",
"def query_artist(artist_name = 'Dire+Straits')\n \"http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=#{artist_name}&api_key=1ca2cf614eeaa185c2b61753b434b599&format=json\"\n end",
"def artist_name\n if self.artist == nil \n nil \n else self.artist.name \n end \nend",
"def artist\n artist = Spotify.album_artist!(pointer)\n Artist.new(artist) unless artist.null?\n end",
"def pretty_name\n\t\t# TODO: internationalize\n\t\ts = title\n\t\ts += \" by #{artist.name}\" if artist\n\t\treturn s\n\tend",
"def artist\n if artists.nil?\n Artist.new :name => super\n elsif artists.size > 1\n artists\n else\n artists.first\n end\n end",
"def artist\n\t\tartists == nil ? nil : artists.first\n\tend",
"def artist_name=(artistName)\n Artist.find_or_create_by_name(artistName)\n Artist.find(artistName)\n end",
"def artist_name=(name)\n # binding.pry\n if (self.artist.nil?)\n self.artist = Artist.find_or_create_by_name(name)\n self.artist.add_song(self) \n end\n \n end",
"def artist_name=(name)\n artist = Artist.find_or_create_by(name: name)\n self.artist = artist\n end",
"def display_name\n @display_name ||= if audio? && metadata?\n artist, title = metadata.values_at('artist', 'title')\n title.present? ? [title, artist].compact.join(' - ').force_encoding('UTF-8') : attachment_file_name\n else\n attachment_file_name\n end\n end",
"def artist\n\t\tArtist.find(artist_id)\n\tend",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n end",
"def artist_name=(name)\n # The actual assignment of the artist \"michael jackson\"\n # to the Song instance variable occurs in the .add_song \n # method in the Artist class.\n Artist.find_or_create_by_name(name).add_song(self)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def artistInfo(artist)\n\tartistinfo = HTTParty.get(\"http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=#{artist}&api_key=#{API_KEY}&format=json\")\n\treturn artistinfo\nend",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n self.artist = artist\n end",
"def artist\n art = super\n if art.nil?\n art = Artist.new\n art.title = \"Unknown Artist\"\n end\n art\n end",
"def artist()\n sql = \"SELECT * FROM albums WHERE artist_id = $1\"\n values = [@id]\n results = SqlRunner.run(sql,values)\n artist_data = results[0]\n artist = Artist.new(artist_data)\n end",
"def artist_name=(name)\n @artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n self.artist = artist\n end",
"def title\n \"#{@artist} - #{@name} (#{@length})\"\n end",
"def artist\n a = tag.get_frame(:TPE2).content\n a || tag.artist\n rescue StandardError\n # require 'pry'; binding.pry\n tag.artist\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def display_song_with_artist(db)\n\tputs \"The songs with artist's name\"\n\tputs \"----------------------------\"\n\tsongs = db.execute(\"SELECT * FROM songlist;\")\n\tsongs.each do |song|\n\t\tputs \"SONG NAME: #{song['song_name']} ; ARTIST NAME: #{song['artist_name']}.\"\n\tend\nend",
"def artists\n paintings.map{|art| art.artist.name}\n\n end",
"def artist\n self.artists.unique.first\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by(name: name)\n end",
"def artist_info(id)\n album = stock_info(id)\n if album.class == String\n return \"This artist is not stocked\"\n else\n @artists.each do |artist|\n if artist.id == album.artist_id\n return artist\n end\n end\n end\n return \"No artist with that id stocked\"\n end",
"def all_artist_names_by_gallery\n all_artists_by_gallery.map do |artist|\n # artist.name == Painting.artist.name\n artist.name\n end\n end",
"def list_artist\n Artist.all.each.with_index(1) {|artist, i| puts \"#{i}. #{artist.name}\"}\n end",
"def artist(value)\n @ole.Artist = value\n nil\n end",
"def artist()\n sql = \"SELECT * FROM artists WHERE id = $1\"\n values = [@artist_id]\n result = SqlRunner.run(sql, values)[0]\n return Artist.new(result)\n end",
"def artist_name=(name)\n # When instantiating, set the .artist attribute to what is input in name\n self.artist = Artist.find_or_create_by(name: name)\n\n end",
"def artist_name=(artist_name)\n self.artist = Artist.find_or_create_by_name(artist_name)\n self.artist.add_song(self)\n end",
"def search_file_name\n file_name = ''\n if @artist_id && @artist_id != 0\n artist_name = ARUtils.field( Artist , @artist_id , :name )\n file_name = artist_name if artist_name\n end\n if @album_id && @album_id != 0\n album_name = ARUtils.field( Album , @album_id , :name )\n file_name += ' - ' if ! file_name.empty?\n if album_name\n file_name += album_name\n end\n end\n file_name = 'songs' if file_name.empty?\n return ImagesModule.safe_file_name(file_name, true)\n end",
"def artist_name=(name)\n self.artist =Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def list_presenting_artists(gallery)\n gallery.artist_name.each.with_index(1) {|artist, i| puts \"#{i}. #{artist}\"}\n end",
"def get_filename(artist, song)\n \"#{ENCLOSURE_PATH}#{proper_filename(artist)}__#{proper_filename(song)}.mp3\"\n end",
"def title\n\t\t\"#{artist.try(:name)} - #{event.try(:title)}\"\n\tend",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n binding.pry\n end",
"def get_meta_artist \n send_cmd(\"get_meta_artist\")\n end"
] | [
"0.91012186",
"0.89411527",
"0.88850105",
"0.8867165",
"0.88493973",
"0.87633175",
"0.8716061",
"0.8660438",
"0.85772765",
"0.85396004",
"0.85396004",
"0.85396004",
"0.85396004",
"0.85040027",
"0.84704375",
"0.84464973",
"0.8440832",
"0.84110284",
"0.83617705",
"0.83224064",
"0.83097726",
"0.83062077",
"0.8299125",
"0.82912195",
"0.8193757",
"0.798227",
"0.79787034",
"0.7890392",
"0.7845791",
"0.7764655",
"0.772475",
"0.7695056",
"0.75289",
"0.7504905",
"0.7490697",
"0.7484709",
"0.7481745",
"0.74808025",
"0.74784493",
"0.74714977",
"0.74542665",
"0.74542665",
"0.7386975",
"0.73868346",
"0.73718506",
"0.7332664",
"0.7325869",
"0.72787195",
"0.72338206",
"0.7215241",
"0.7174474",
"0.71731377",
"0.71204376",
"0.7115568",
"0.7067937",
"0.7026705",
"0.7017148",
"0.7004541",
"0.6987436",
"0.6987436",
"0.6971498",
"0.6969932",
"0.6969932",
"0.69576794",
"0.6956343",
"0.694573",
"0.6917256",
"0.69116205",
"0.6900254",
"0.68992615",
"0.687639",
"0.6863863",
"0.6863863",
"0.6863863",
"0.6863863",
"0.68580085",
"0.68580085",
"0.68453395",
"0.683973",
"0.682894",
"0.6821069",
"0.6821069",
"0.6821069",
"0.6821069",
"0.6820932",
"0.6805467",
"0.6787745",
"0.67689604",
"0.6768511",
"0.6761134",
"0.6753377",
"0.6728198",
"0.6727874",
"0.67046094",
"0.6701483",
"0.6688229",
"0.66880447",
"0.6676385"
] | 0.8032889 | 26 |
sets the genre to the genre of the specified name | def genre_name=(name)
self.genre = Genre.find_or_create_by(name: name)
self.genre = genre
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def genre_name=(name)\n self.genre = Genre.find_or_create_by(name: name)\n end",
"def genre_name=(name)\n self.genre = Genre.find_or_create_by(name: name)\n end",
"def genre_name=(name)\n self.genre = Genre.find_or_create_by(name: name)\n end",
"def genre_name=(name)\n self.genre = Genre.find_or_create_by(name: name)\n end",
"def genre(value)\n @ole.Genre = value\n nil\n end",
"def set_genre\n\t\t\t@genre = Genre.find(params[:id])\n\t\tend",
"def genre= (genre)\n @genre = genre\n GENRES << genre\n end",
"def genre=(genre)\n @genre = genre\n end",
"def set_genre\n @genre = Genre.find(params[:id])\n end",
"def set_genre\n @genre = Genre.find(params[:id])\n end",
"def set_genre\n @genre = Genre.friendly.find(params[:id])\n end",
"def genre=(genre)\n @genre = genre\n GENRES << genre\n end",
"def genre=(genre)\n @genre = genre\n GENRES << genre\n end",
"def genre=(genre)\n @genre = genre \n GENRES << genre \n end",
"def set_genre\n @admin_genre = Genre.friendly.find(genre_id)\n end",
"def set_genre\n @genre ||= Genre.find(params[:id])\n end",
"def set_genre\n @genre = Genre.find(params[:id])\n end",
"def set_genre\n @genre = Genre.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:genre_name])\n end",
"def set_game_genre\n @game_genre = GameGenre.find(params[:id])\n end",
"def genre=(genre)\n \t@genre = genre\n \t# Now that we've assigned a genre to a book, we also want to push that genre to GENRES:\n \tGENRES << genre\n end",
"def genre=(genre)\n @genre = genre\n GENRES << genre\n end",
"def genre=(genre)\n @genre = genre\n \n # adds the song to the genre's collection of songs \n # (genre has many songs).\n # Doesn't add the song to the genre's collection of\n # songs if it already exists therein\n if !(genre.songs.include?(self))\n genre.songs << self\n end\n end",
"def genre=(genre)\n @genre = genre\n if genre.class == Genre\n genre.songs << self unless genre.songs.include?(self)\n end\n end",
"def genre=(genre)\n @genre = genre\n GENRES << genre\nend",
"def genre= (genre)\n @genre = genre\n genre.songs << self unless genre.songs.include?(self)\n end",
"def set_film_genre\n @film_genre = FilmGenre.find(params[:id])\n end",
"def genre=(genre)\n @genre = genre #assigns a genre to the song (song belongs to genre)\n genre.songs << self unless genre.songs.include?(self) #adds the song to the genre's collection of songs (genre has many songs); does not add the song to the genre's collection of songs if it already exists therein\n end",
"def genre=(genre)\n @genre = genre\n genre.songs << self unless genre.songs.include?(self)\n end",
"def initialize(name) # accepts a name for the new genre\n @name = name # retrieves the name of a genre\n # can set the name of a genre\n @songs = []\n end",
"def set_book_genre\n @book_genre = BookGenre.find(params[:id])\n end",
"def genre=(genre)\n @genre = genre\n genre.songs << self unless genre.songs.include?(self) # could've used the artist.add_song way \n end",
"def genre=(set_genre)\n @genre = set_genre\n # add this instance\n @genre.add_song(self) unless @genre.songs.include?(self)\n end",
"def set_musical_genre\n @musical_genre = MusicalGenre.find(params[:id])\n end",
"def set_omdb_genre\n @omdb_genre = OmdbGenre.find(params[:id])\n end",
"def genre=(id)\n self.genre_id = id.to_i\n end",
"def set_genre_story\n @genre_story = GenreStory.find(params[:id])\n end",
"def genre\n fetch('game.genre')\n end",
"def genre_name\n # self.genre.name\n self.genre ? self.genre.name : ''\n end",
"def genre; end",
"def genre; end",
"def genre_name\n \tif self.genre\n \t\tself.genre.name\n \tend\n end",
"def lookup_genre(s)\n \tg = genre_list()\n \tg[s]\n end",
"def set_subgenre\n @subgenre = Subgenre.find(params[:id])\n end",
"def genre_params\n\t\t params.require(:genre).permit(:name)\n\t\tend",
"def initialize(name, genre)\n @name = name\n @genre = genre\n #refactor so that a new song gets associated to a genre and the given genre adds that song to its collection\n genre.add_song(self)\n end",
"def genre_params\n params.require(:genre).permit(:name)\n end",
"def genre_name\n self.genre ? self.genre.name : nil\n end",
"def genre_name\n self.genre ? self.genre.name : nil\n end",
"def store_genre\n genres = RSpotify::Recommendations.available_genre_seeds\n genre = @prompt.select('Which genre would you like to add to your list?', genres, filter: true)\n genre_details = {\n 'name' => genre.capitalize,\n 'type' => 'genre'\n }\n @mylist << genre_details\n update_file\n end",
"def new_song(name, genre)\n song = Song.new(name,self, genre)\n \n end",
"def set_gender_from_name\n if name[/women/i]\n self.gender = \"F\"\n else\n self.gender = \"M\"\n end\n end",
"def set_genres_movie\n @genres_movie = GenresMovie.find(params[:id])\n end",
"def update(name, artist, year, genre)\n self.name = name.length > 0 ? name : self.name\n self.artist = artist.length > 0 ? artist : self.artist\n self.year = year.length > 0 ? year : self.year\n self.genre = genre.length > 0 ? genre : self.genre\n @@albums[self.id] = Album.new(self.name, self.artist, self.year, self.genre, self.id)\n end",
"def set_genrecreate\n @genrecreate = Genrecreate.find(params[:id])\n end",
"def initialize(name, genre)\n @name = name\n @genre = genre\n genre.add_song(self) #a new song is instantiated it gets associated to a genre and the given genre adds that song to its collection.\n end",
"def genre_generator\n genre = @genre_options.sample\n puts \"Awesome, I think #{name}'s music should be of the #{genre} variety.\"\n end",
"def genre_params\n params.require(:genre).permit(:name)\n end",
"def genre_params\n params.require(:genre).permit(:name)\n end",
"def genres=(genres_from_response)\n @genres = Enceladus::Genre.build_collection(genres_from_response)\n end",
"def artist_name=(name)\n self.artist =Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def new_song(name, genre)\n #creates new song\n Song.new(name, self, genre)\n end",
"def initialize(name)\n @name = name # starts with genre name\n @@all << self # pushes each instance to @@all array\n end",
"def new_song(name, genre)\n Song.new(name, self, genre)\n end",
"def new_song(name, genre)\n Song.new(name, self, genre)\n end",
"def new_song(name, genre)\n song = Song.new(name, self, genre)\n @songs << song\n song\n end",
"def artist_name=(name)\n # The actual assignment of the artist \"michael jackson\"\n # to the Song instance variable occurs in the .add_song \n # method in the Artist class.\n Artist.find_or_create_by_name(name).add_song(self)\n end",
"def initialize(name) # initialize with a name\n @name = name\n @@all << self # push each genre instance into the all array\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def get_genre_name\n self.genre.name\n end",
"def genre_params\n\t\t\tparams.require(:genre).permit(:name, :cover_page, :user_id)\n\t\tend",
"def genre_params\n params.require(:genre).permit(:name, :description, :slug)\n end",
"def new_song(name, genre)\n Song.new(name, self, genre)\n end",
"def new_song(name, genre)\n Song.new(name, self, genre)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end",
"def update\n @album.genre_id = params[:genre_id]\n \n\n if @album.update(album_params)\n redirect_to album_path(@album)\n else\n render 'edit'\n end\n end",
"def name=(value)\n if @playing_girl\n @name_girl = value\n else\n @name_boy = value\n end\n $game_actors[1].name = value\n end",
"def initialize(name) #automatically instantiates a new genre & requires an argument (name)\n @name = name #accepts a (name) for the new instance of genre\n @@all = [] #automatically stores the new instance of genre in the @@all = [] class variable\n @songs = [] #automatically stores instances of songs\n end",
"def artist_name=(name)\n # Get the instance of the Artist class that represents that artist.\n self.artist = Artist.find_or_create_by_name(name)\n\n # Assign the song to the artist (Since an artist has many songs, we'll want to make this association\n # Now that we have the artist instance,\n # we'll want to again collaborate with the Artist class by calling on the Artist#add_song(some_song) method.\n self.artist.add_song(self)\n\n end",
"def update\n @genre = Genre.find(params[:id])\n @genre.update_attributes(params[:genre])\n redirect_to @genre\n end",
"def new_song(name, genre)\n Song.new(name, self, genre)\n end",
"def define_gender(playing_girl)\n @playing_girl = playing_girl\n $game_switches[Yuki::Sw::Gender] = playing_girl\n $game_variables[Yuki::Var::Player_ID] = id\n $game_actors[1].name = name\n end",
"def genre_params\n params.require(:genre).permit(:name, :title, :parent_id, :section_id, :tracking_code)\n end",
"def genre_params\n params.require(:genre).permit(:genretitle)\n end",
"def genre\n @genre\n end",
"def genre\n @genre\n end",
"def genre\n @genre\n end",
"def artist_name=(name)\n artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n self.artist = artist\n end",
"def artist_name=(name)\n # When instantiating, set the .artist attribute to what is input in name\n self.artist = Artist.find_or_create_by(name: name)\n\n end",
"def set_movie\n @movie = Movie.includes(:genres).find(params[:id])\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n end",
"def initialize(name, artist = nil, genre = nil) #accepts a name for the new song\n @name = name # can set the name of a song\n self.artist=artist if artist\n self.genre=genre if genre #assigns a genre to the song (song belongs to genre)/ # invokes #genre= instead of simply assigning to a @genre instance variable to ensure that associations are\n #created upon initialization\n end",
"def initialize(name, genre)\n @name = name\n @genre = genre\n genre.add_song(self)\nend",
"def fav_genre\n # NOTE : DID NOT ADD GENRES YET\n # r.shows.genres\n \"WIP - no genres yet\"\n end",
"def artist_name=(name)\n @artist = Artist.find_or_create_by_name(name)\n artist.add_song(self)\n end"
] | [
"0.8453164",
"0.831982",
"0.831982",
"0.831982",
"0.79601127",
"0.7695125",
"0.76474917",
"0.76370174",
"0.7627474",
"0.7627474",
"0.7572217",
"0.74475527",
"0.74475527",
"0.73975426",
"0.7343262",
"0.73291606",
"0.7328257",
"0.7328257",
"0.7308729",
"0.7294673",
"0.7277976",
"0.72331",
"0.71996564",
"0.7002325",
"0.70014596",
"0.6991942",
"0.696472",
"0.69449955",
"0.6943727",
"0.6932908",
"0.692886",
"0.6914116",
"0.68944156",
"0.6867884",
"0.6789022",
"0.6687631",
"0.6599622",
"0.65991634",
"0.65974355",
"0.6589887",
"0.6589887",
"0.6558013",
"0.6485347",
"0.6464788",
"0.6451608",
"0.64445853",
"0.64364964",
"0.64255726",
"0.64255726",
"0.63874483",
"0.63693047",
"0.63457733",
"0.6315906",
"0.6312032",
"0.6304969",
"0.6302862",
"0.62608874",
"0.62359947",
"0.62359947",
"0.62146956",
"0.61543596",
"0.6141098",
"0.6133581",
"0.61308223",
"0.61308223",
"0.6128795",
"0.6121387",
"0.6101109",
"0.60978276",
"0.60978276",
"0.60978276",
"0.60978276",
"0.60737514",
"0.6068152",
"0.6064987",
"0.60384834",
"0.60384834",
"0.60356104",
"0.60356104",
"0.6034805",
"0.602445",
"0.6024361",
"0.60082847",
"0.5995236",
"0.5994575",
"0.59811854",
"0.59770644",
"0.5958247",
"0.59518915",
"0.59518915",
"0.59518915",
"0.5950988",
"0.59437734",
"0.59417623",
"0.5936337",
"0.5936337",
"0.59261507",
"0.5913831",
"0.5907356",
"0.5906351"
] | 0.85104114 | 0 |
returns the genre name | def genre_name
self.try(:genre).try(:name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def genre_name\n \tif self.genre\n \t\tself.genre.name\n \tend\n end",
"def genre_name\n # self.genre.name\n self.genre ? self.genre.name : ''\n end",
"def get_genre_name\n self.genre.name\n end",
"def genre_name\n self.genre ? self.genre.name : nil\n end",
"def genre_name\n self.genre ? self.genre.name : nil\n end",
"def genre\n fetch('game.genre')\n end",
"def title_genre\n \" [ #{@document.first(:form_genre_display)} ]\" unless @document[:form_genre_display].nil?\n end",
"def genre; end",
"def genre; end",
"def genre\n @genre\n end",
"def genre\n @genre\n end",
"def genre\n @genre\n end",
"def artist_name_and_genre\n \"#{artist_name} - #{genre.name}\"\n end",
"def Genre\n ret = \"\"\n self.genres.each{|genre| ret += \"#{genre.Name}, \"}\n return ret.chomp(\", \");\n end",
"def genre\n @ole.Genre\n end",
"def fav_genre\n # NOTE : DID NOT ADD GENRES YET\n # r.shows.genres\n \"WIP - no genres yet\"\n end",
"def genres\n genres = fetch_attribute(\"genres_en\")\n if genres\n return genres\n else\n return \"\"\n end\n end",
"def to_s\n genre\n end",
"def genres\n Song.all.collect{|song|song.genre}\n end",
"def genres\n\t\t@songs.collect {|g| g.genre}\n\tend",
"def lookup_genre(s)\n \tg = genre_list()\n \tg[s]\n end",
"def genres\n songs.map {|song| song.genre }\n end",
"def genres\n details.css(\"div.subtext a[href^='/genre/']\").map { |genre| genre.text } rescue []\n end",
"def genres\n @songs.collect {|s| s.genre}\n end",
"def genres\n document[\"genre\"].collect {|gender| gender[\"$\"]} rescue nil\n end",
"def get_genre_list\n @genre_names = Genre.select('name')\n end",
"def genre\n case result_item.format\n when \"Book\"\n \"book\"\n when :book_item\n \"bookitem\"\n when :conference_paper\n \"proceeding\"\n when :conference_proceedings\n \"conference\"\n when :report\n \"report\"\n when :serial\n \"journal\"\n when \"Article\"\n \"article\"\n else\n nil\n end \n end",
"def genres\r\n self.songs.collect do |song|\r\n song.genre\r\n end\r\n end",
"def list_genre\n genre = gets.chomp\n Genre.all.each do |a|\n if a.name == genre\n a.songs.collect { |s| puts \"#{s.artist.name} - #{s.name} - #{s.genre.name}\" }\n end\n end\n end",
"def genres\n songs.map {|song| song.genre}\n end",
"def genre\n genres = tracks.map{|t| t.genre}.compact\n genres.uniq.size == 1 and genres.first\n end",
"def genres\n songs.map do |song| song.genre end\n end",
"def genre_generator\n genre = @genre_options.sample\n puts \"Awesome, I think #{name}'s music should be of the #{genre} variety.\"\n end",
"def read_genre()\n\tcount = $genre_names.length\n\ti = 0\n\tputs 'Genre: '\n\twhile i < count\n\t\tputs \"#{i} \" + $genre_names[i]\n\t\ti += 1\n\tend\n\tselectedGenre = read_integer_in_range('Please select your album genre.', 0, count - 1)\n\tselectedGenre\nend",
"def genres\n self.songs.collect do |song|\n song.genre\n end\n end",
"def genres\n self.songs.collect do |song|\n song.genre\n end\n end",
"def genres\n self.songs.collect do |song|\n song.genre\n end\n end",
"def genres\n self.songs.collect do |song|\n song.genre\n end\n end",
"def genres\n self.songs.collect do |song|\n song.genre\n end\n end",
"def bookGenre\n\t\tarr =[]\n\t\tcurrent_user.reads.each do |f|\n\t\t\tarr.push(Book.find_by_id(f.book_id).genre)\n\t\tend\n\t\th = Hash.new(0)\n\t\t\tarr.each do |word|\n\t\t\th[word] += 1\n\t\tend\n\t\tgenre = h.sort_by{|word,count| count}\n\t\tgenre = genre.reverse # Hash highest the genre picked the most\n\n\t\tarr2 =[]\n\t\tgenre.each do |key,value|\n\t\t\tarr2.push(key)\n\t\tend\n\t\tif(arr2.size > 1)\n\t\t\t@popGenre = arr2.at(0)\n\t\telse\n\t\t\t@popGenre = \"Adventure\"\n\t\tend\n\tend",
"def genre(value)\n @ole.Genre = value\n nil\n end",
"def genres\n self.songs.map do |artist_song|\n artist_song.genre\n end\n end",
"def genre_names\n genres.map {|genre| genre.name}\n #create empty array\n #@movie.genres\n #call genres, because @movie is the instance itself already\n #run map to get each name of each genre instance\n #return map\n end",
"def genre_info(genre)\n\n db = connect_to_db(\"db/db.db\")\n \n db.execute(\"SELECT posts.title, posts.text, posts.id, posts.upvotes, genre.security, genre.name, users.name AS username, posts.user_id FROM genre LEFT JOIN posts ON genre.id = posts.genre LEFT JOIN users ON posts.user_id = users.id WHERE genre.name = ?\", genre)\n \n end",
"def to_genre\n self\n end",
"def genres\n document.search(\"h5[text()='Genre:'] ~ a[@href*=/Sections/Genres/']\").map { |link| link.innerHTML.strip.imdb_unescape_html } rescue []\n end",
"def select_by_genre(genre)\n where(\"genre = ?\", genre).abc_title\n end",
"def genres\n to_array search_by_itemprop 'genre'\n end",
"def genres\n songs.collect do |song|\n song.genre\n end\n .uniq #does not return duplicate genres if the artist has more than one song of a particular genre (artist has many genres through songs)\n end",
"def genre_name=(name)\n self.genre = Genre.find_or_create_by(name: name)\n end",
"def load_field\n 'wcgenre'\n end",
"def genres\n songs.map{|song|song.genre}.uniq\n end",
"def genres\n @songs.collect{|song| song.genre }.uniq\n end",
"def genres\n self.songs.map {|x| x.genre}\n end",
"def genres\n songs.map{|song| song.genre} # giving back all the genres under that particular artist. artists can have nmany genres and calling of theirmany genres.\n # Song.all.map{|ind_song| ind_song.genre} #giving back all the different genres from the collection of song array. giving back all the genres of the songs\n # binding.pry\n end",
"def get_meta_genre \n send_cmd(\"get_meta_genre\")\n end",
"def movie_name\n self.movie.name\n \n end",
"def genres\n @songs.collect do |song|\n song.genre\n end.uniq\n end",
"def genres\n @songs.collect { |song| song.genre }.uniq\n end",
"def genres_hash\n search_by_itemprop_hash 'genre'\n end",
"def genre_name=(name)\n self.genre = Genre.find_or_create_by(name: name)\n self.genre = genre\n end",
"def genres\n songs.collect{|song| song.genre}.uniq\n end",
"def genre=(genre)\n @genre = genre\n end",
"def list_genres\n sorted_list = Genre.all.sort_by {|artist| artist.name}\n sorted_list.each_with_index do |genre, idx|\n puts \"#{(idx + 1).to_s}. #{genre.name}\"\n end\n end",
"def genre_name=(name)\n self.genre = Genre.find_or_create_by(name: name)\n end",
"def genre_name=(name)\n self.genre = Genre.find_or_create_by(name: name)\n end",
"def genre_name=(name)\n self.genre = Genre.find_or_create_by(name: name)\n end",
"def genre_list\n {\"1\" => 'シーバス', \"2\" => 'バス', \"3\" => \"青物\",\n \"4\" => \"フラットフィッシュ\", \"6\" => \"アジ\"}\n end",
"def show\n @genre = Genre.find(params[:id])\n end",
"def genres\n self.songs.collect {|song| (song.genre) }.uniq\n end",
"def genres \n songs.collect{ |s| s.genre }.uniq #returns collection of genres for all of the artist's songs/ does not return duplicate genres/ collects genres\n end",
"def artist_by_genre\n all_genres = Artist.all.map{|artist| artist.genre}.uniq.sort\n genre_name = prompt(\"Choose a genre: \", all_genres)\n artists = Artist.all.where(genre: genre_name).map{|artist| artist.name}\n puts \"**************************\"\n puts \"For #{genre_name}\"\n puts \"**************************\"\n prompt(\"Choose an Artist from #{genre_name}\", artists)\n end",
"def show\n @genre = Genre.friendly.find(params[:id])\n genres = Genre.all\n end",
"def genres\n self.songs.collect {|song| song.genre}.uniq\n end",
"def genre?\n true\n end",
"def genre=(genre)\n @genre = genre\n GENRES << genre\n end",
"def genre=(genre)\n @genre = genre\n GENRES << genre\n end",
"def set_genre\n @genre = Genre.friendly.find(params[:id])\n end",
"def list_songs_by_genre\n puts \"Please enter the name of a genre:\"\n input = gets.chomp\n if genre = Genre.find_by_name(input)\n sort_by_name = genre.songs.sort_by do |genre|\n genre.name\n end\n sort_by_name.each.with_index(1) do |genre, i|\n puts \"#{i}. #{genre.artist.name} - #{genre.name}\"\n end\n end\n end",
"def genres\n songs.map do |song|\n song.genre\n end\nend",
"def name\n @name ||= doc.search('.moviename-big').text\n end",
"def full_name\n\t\ts = title\n\t\ts = \"#{artist.name} - #{s}\" if artist\n\t\treturn s\n\tend",
"def genres\n self.songs.map { |song| song.genre }.uniq\n end",
"def genres\n search_by_text('жанры').split(', ')\n end",
"def genres \n songs.collect {|song| song.genre}.uniq \n\n end",
"def title\n return @gallery.gsub(/[_]+/, ' ').capitalize\n end",
"def set_genre\n @admin_genre = Genre.friendly.find(genre_id)\n end",
"def genre=(genre)\n @genre = genre \n GENRES << genre \n end",
"def genres\n self.songs.collect {|song| song.genre}\nend",
"def genres\n return @metadata[:genres]\n end",
"def get_game_genre\n\t\t#initialize variable\n\t\tchosen_line = nil\n\t\t\n\t\t#Get the cliche\n\t\tFile.foreach(\"game_genres.txt\").each_with_index do |line, number|\n\t\t\tchosen_line = line if rand < 1.0/(number+1)\n\t\tend\n\t\t\n\n\treturn chosen_line.chomp\n\tend",
"def name\n return @playing_girl ? @name_girl : @name_boy\n end",
"def genres\n MusicImporter.new(path).print_genres\n end",
"def list_genres\n Genre.all.uniq.sort { |genre1, genre2| genre1.name <=> genre2.name}.each.with_index(1) do |genre, i|\n puts \"#{i}. #{genre.name}\"\n end\n end",
"def fullname()\n\t\t[self.name(), self.sport().titleize, self.variety().titleize].join(\" \")\n\tend",
"def genres\n # look for a local variable called songs\n # look for a method on self. called songs => self.songs\n # looks up the parent chain\n self.songs.map do |song|\n song.genre\n end\n end",
"def name\n return @artist_data[\"name\"]\n end",
"def title\n \tobject.movie_name\n end",
"def title\n \"#{artist.name} - #{name} [#{release.catalog_number}]\"\n end"
] | [
"0.9001444",
"0.87545544",
"0.8408421",
"0.8308149",
"0.8308149",
"0.81577224",
"0.79171693",
"0.77513546",
"0.77513546",
"0.77349544",
"0.77349544",
"0.77349544",
"0.7684306",
"0.760172",
"0.75620425",
"0.75557655",
"0.7473183",
"0.7376065",
"0.7169484",
"0.7165394",
"0.7124757",
"0.71117646",
"0.71105427",
"0.71099085",
"0.70947754",
"0.7086615",
"0.706309",
"0.70262283",
"0.70128155",
"0.6998425",
"0.69869196",
"0.69630194",
"0.69344556",
"0.6932646",
"0.6929172",
"0.6929172",
"0.6929172",
"0.6929172",
"0.6929172",
"0.69105554",
"0.68588555",
"0.6852509",
"0.679787",
"0.67798597",
"0.6731422",
"0.67114764",
"0.6707944",
"0.6706471",
"0.6668342",
"0.6655486",
"0.6645927",
"0.6644077",
"0.6643152",
"0.66365916",
"0.66343814",
"0.6634051",
"0.6620681",
"0.6617365",
"0.66147923",
"0.65997046",
"0.65765333",
"0.6566348",
"0.6544845",
"0.653344",
"0.6515511",
"0.6515511",
"0.6515511",
"0.6511045",
"0.65031517",
"0.64991915",
"0.64927036",
"0.64823407",
"0.64684755",
"0.6464975",
"0.6462666",
"0.6457111",
"0.6457111",
"0.64345914",
"0.6432743",
"0.6385126",
"0.63788426",
"0.6378463",
"0.6374409",
"0.63478535",
"0.6344745",
"0.63412184",
"0.63291335",
"0.63250256",
"0.6324985",
"0.63134325",
"0.6304731",
"0.6303444",
"0.6275348",
"0.6256332",
"0.6237624",
"0.6206161",
"0.6191393",
"0.6181049",
"0.6157134"
] | 0.7522001 | 17 |
sets notes for a song adds to existing notes | def note_contents=(notes)
notes.each do |content|
if content.strip != '' # => ignores blank notes
self.notes.build(content: content)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def song_notes=(notes)\n notes.each do |note|\n self.notes.build(content: note)\n end\n end",
"def song_notes=(notes)\n notes.each do |note|\n self.notes.build(content: note)\n end\n end",
"def notes_attributes=(notes)\n notes.each do |note|\n song_note = self.notes.build(content: note)\n song_note.save\n end\n end",
"def note_contents=(notes)\n notes.each do |note|\n if note != \"\"\n self.notes << Note.find_or_create_by(content: note)\n end\n end\n\n end",
"def note_contents=(notes)\n \tnotes.each do |content|\n \t\tself.notes << Note.find_or_create_by(content: content) unless content == \"\"\n \tend\n end",
"def notes=(value)\n @notes = value\n end",
"def notes=(value)\n @notes = value\n end",
"def notes=(value)\n @notes = value\n end",
"def notes=(value)\n @notes = value\n end",
"def update!(notes)\n fetch_notes\n show_notes\n push_notes(notes)\n end",
"def note(*note_names)\n midi_values = note_names.map { |name| Midishark::Notes.note(name) }\n @notes << midi_values\n\n midi_values\n end",
"def note_contents=(notes)\n notes.each do |content|\n if content.strip != ''\n self.notes.build(content: content)\n end\n end\n end",
"def note_contents=(notes)\n notes.each do |note|\n if note.strip != \"\"\n content = self.notes.build(content: note)\n content.save\n end\n end\n end",
"def notes=(notes)\n self.service.editObject({ \"notes\" => notes.to_s })\n self.refresh_details()\n end",
"def note_contents=(array)\n array.each do |i|\n if !i.empty?\n note = Note.find_or_create_by(content: i)\n self.notes << note\n end\n end\n end",
"def song(song_number, notes)\n raise RangeError if song_number < 0 || song_number > 15\n \n notes.map! do |i|\n note, duration = i\n\n # notes can either be a string or the actual ID\n note = NOTES[note] if note.is_a?(String)\n [note, duration*64]\n end\n\n # The protocol requires us to send the number of notes and the song number first\n write_chars([SONG, song_number, notes.size] + notes.flatten)\n end",
"def note_contents=(contents)\n contents.each do |content|\n # next if content == ''\n if !content.empty?\n note = self.notes.build(content: content)\n # note = Note.find_or_create_by(content: content)\n # self.notes << note\n end\n end\n end",
"def add_note(note)\n self.notes = notes.present? ? \"\\n\\n#{note}\" : note\n save\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n\n end",
"def add_song(song)\n # Add song to @songs if it doesn't already exist\n @songs << song if !@songs.include?(song)\n # Add artist if not already assigned\n song.artist = self if song.artist ==nil\n save\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n @@sounds_count += 1\n\n end",
"def add_song(song)\n @@songs << song\n song.artist = self\n end",
"def add_song(song)\r\n @songs << song\r\n song.artist = self\r\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_songs(songs)\n songs.each { |song| add_song(song) }\n end",
"def add_songs(songs)\n songs.each { |song| add_song(song) }\n end",
"def add_songs(songs)\n songs.each { |song| add_song(song) }\n end",
"def add_song(song)\n song.artist = self\n @songs << song\n end",
"def add_song(song)\n song.artist = self\n @songs << song\n end",
"def add_song(song)\n song.artist = self \n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_note(note)\n notes << note\n end",
"def set_notes\n user_notes = current_user.notes\n @notes = user_notes.where.not(id: nil)\n @new_note = action_name != 'create' ? user_notes.build : user_notes.build(note_params)\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def new_notes=(note)\n\t\tif !note.blank? then\n\t\t\ttime = Time.now.strftime(\"%m-%d-%y %I:%M %p\")\n\t\t\tnew_note = \"<p>#{note}<br/>\"\n\t\t\tnew_note << \"<span class=\\\"info\\\">\"\n\t\t\tnew_note << \"[#{time}]\"\n\t\t\tnew_note << \"</span></p>\"\n\t\t\tif self.notes.blank? then\n\t\t\t\tself.notes = new_note\n\t\t\telse\n\t\t\t\tself.notes << new_note\n\t\t\tend\n\t\tend\n\tend",
"def add_note # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity\n @bib.biblionote.each do |n|\n case n.type\n when \"annote\" then @item.annote = n.content\n when \"howpublished\" then @item.howpublished = n.content\n when \"comment\" then @item.comment = n.content\n when \"tableOfContents\" then @item.content = n.content\n when nil then @item.note = n.content\n end\n end\n end",
"def add_song(song)\n @songs << song\n song.artist = self\nend",
"def add_note(note)\n notes << note\n end",
"def add_song(song)\n @songs << song #add songs by sheveling song into the @song instance\n song.artist = self #add artists name of the songs\n end",
"def add_song(song)\n songs << song\n end",
"def set_notes_list\n @notes_list = @note.notes_lists.find(params[:id])\n end",
"def all_notes=(notes)\n self.class.all_note_fields.each do |field|\n send(\"#{field}=\", notes[field])\n end\n end",
"def add_song(song)\n if song.artist!=self\n song.artist = self\n elsif !@songs.include?(song)\n @songs << song\n end\n end",
"def add_song(song)\n @song = song\n @songs << song\n\n @@song_count = @@song_count + 1\n song.artist = self\n end",
"def add_song(song)\n song.artist = self #associate the song with this artist\n end",
"def add_song(song)\n song.artist= self\n @songs << song\n end",
"def add_song(song)\n songs << song\n end",
"def add(notes, options = {})\n notes = [notes].flatten\n notes = sanitize_input_notes(notes, MIDIMessage::NoteOn, options)\n @sequence.add(notes)\n end",
"def add_song(x)\n \t@songs << x\n end",
"def add_song(song)\n self.songs << song\n new_song = Song.new(song)\n new_song.artist = self\n end",
"def add_song(song)\n #associates a song to the artist's collection\n @songs << song\n song.artist = self\n end",
"def set_note_skills\n note_skills.each do |skill|\n self.skills.find_or_create_by(name: skill.name)\n end\n end",
"def add_reader_to_my_notes(reader)\n self.update! my_notes: \"read by #{reader}#{self.my_notes}\"\n return self\n end",
"def add_song(song) ### arg is song instance ###\n\t\tsong.artist = self\n\t\tsong.artist.songs << song\n\tend",
"def add_song(song)\n @songs << song \n end",
"def add_song(song) # Third, we create 'add_song' to associate a song name with a particular artist.\n song.artist = self # When we call 'song.artist', we set the result equal to 'self', or the artist on which we are calling the method.\n end",
"def test_can_accept_multiple_notes\n p = players(:manny)\n assert_equal [], p.notes\n note1 = Note.create!(:body => \"note 1\")\n note2 = Note.create!(:body => \"note 2\")\n p.notes << note1\n p.notes << note2\n assert_equal [note1, note2], p.notes\n end",
"def add_song(song)\n if(!song.artist)\n song.artist = self\n end\n \n if(!self.songs.include?song)\n self.songs << song\n end\n end",
"def create_notes\n end",
"def add_song(song)\n song.artist = self unless song.artist == self\n @songs << song unless @songs.include? song\n end",
"def artist= (artist)\n @artist = artist\n artist.add_song(self)\n end",
"def song_ids=(ids)\n ids.each do |id|\n song = Song.find(id)\n self.songs << song\n end\n end",
"def add_song(song)\n if self.songs.include?(song) == false\n @songs << song\n end\n\n if song.artist.nil? || song.artist == false\n song.artist = self\n end\n\n end",
"def initialize p_notes = 'music/?.wav'\n\n # Set some defaults\n @repeat = true\n @playing = false\n @tune = []\n @tune_index = -1\n @last_note = 0\n\n # And save the note source\n @notes_prefix, @notes_postfix = p_notes.split( '?' )\n\n end",
"def notes=(notes)\n if !notes.nil? && notes.to_s.length > 255\n fail ArgumentError, 'invalid value for \"notes\", the character length must be smaller than or equal to 255.'\n end\n\n if !notes.nil? && notes.to_s.length < 0\n fail ArgumentError, 'invalid value for \"notes\", the character length must be great than or equal to 0.'\n end\n\n @notes = notes\n end",
"def add_song(song)\n @songs << song\n end",
"def add_song(song)\n @songs << song\n end",
"def add_song(song)\n @songs << song\n end",
"def add_song(song)\n @songs << song\n end",
"def add_song(song)\n @songs << song\n end",
"def add_song(song)\n @songs << song\n end",
"def notes; end",
"def notes; end",
"def notes; end",
"def update_notes(favorite_token)\n return unless notes.any?\n\n notes.each do |note|\n note.update_attribute(:favorite, favorite_token)\n end\n end",
"def add_song(song_to_be_added)\n @songs << song_to_be_added\n end",
"def add_song(song)\n\t\t@songs <<(song)\n\t\t\n\tend",
"def add_song(song_name)\n songs << song_name\n end",
"def song_ids=(ids)\n ids.each do |id|\n if !id.blank?\n song = Song.find(id)\n \n self.songs << song\n end \n end\n end",
"def add_song(song)\n @@song_count += 1\n @songs << song\n song.artist = self #self refers to Artist\n\n end",
"def add_song(song)\n # song.artist = self # assigns the current artist to the song's 'artist' property (song belongs to artist)\n #@songs << song #adds the song to the current artist's 'songs' collection \n ##does not assign the artist if the song already has an artist\n if song.artist == self\n song.artist\n else\n song.artist = self\n end \n # does not add the song to the current artist's collection of songs if it already exists therein\n if songs.include?(song)\n song\n else\n songs << song\n end \n songs\n end",
"def add_note(note)\n @notes.push(note)\n end"
] | [
"0.8257639",
"0.8257639",
"0.74261457",
"0.688843",
"0.68704",
"0.6726616",
"0.6726616",
"0.6726616",
"0.6726616",
"0.6656985",
"0.65901464",
"0.65844625",
"0.65485257",
"0.64999527",
"0.64490795",
"0.6421435",
"0.6409109",
"0.6406017",
"0.6294751",
"0.62918633",
"0.62842435",
"0.6254288",
"0.62354434",
"0.6225501",
"0.6225501",
"0.6225501",
"0.6225501",
"0.6225501",
"0.6225501",
"0.6225501",
"0.6225501",
"0.6225501",
"0.6225501",
"0.6225501",
"0.6186769",
"0.6186769",
"0.6186769",
"0.61520284",
"0.61520284",
"0.6137807",
"0.6114246",
"0.6114246",
"0.6114246",
"0.6113498",
"0.6111187",
"0.60941374",
"0.60941374",
"0.60941374",
"0.60941374",
"0.60941374",
"0.60941374",
"0.6082619",
"0.60653573",
"0.6060042",
"0.6057328",
"0.6043492",
"0.60396385",
"0.6024349",
"0.6023462",
"0.600574",
"0.6000737",
"0.59983045",
"0.5990789",
"0.59884053",
"0.59855133",
"0.59782463",
"0.59538007",
"0.5953617",
"0.5941227",
"0.5936381",
"0.5932297",
"0.5919264",
"0.59171855",
"0.5907797",
"0.5906967",
"0.5906575",
"0.5880047",
"0.5877381",
"0.58710647",
"0.58702177",
"0.58654886",
"0.58453965",
"0.5843204",
"0.58382505",
"0.58382505",
"0.58382505",
"0.58382505",
"0.58382505",
"0.58382505",
"0.5834462",
"0.5834462",
"0.5834462",
"0.58180887",
"0.5804894",
"0.5804596",
"0.57930493",
"0.5785155",
"0.57769877",
"0.5766165",
"0.57600313"
] | 0.6491131 | 14 |
returns the content of all notes as an array | def note_contents
self.notes.map(&:content)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def note_contents\n self.notes.each.map{|note| note.content}\n end",
"def note_contents\n self.notes.collect do |note|\n note.content\n end\n end",
"def note_contents\n self.notes.collect {|note| note.content }\n end",
"def note_contents\n self.notes.collect {|note| note.content}\n end",
"def notes\n return @notes\n end",
"def notes\n return @notes\n end",
"def notes\n return @notes\n end",
"def notes\n return @notes\n end",
"def notes\n\t\tNote.find(:all)\n\tend",
"def to_a\n notes.map(&:to_h)\n end",
"def all_notes\n self.has_notes? ? self.annotations.map {|n| n.body }.join(' ') : '' \n end",
"def notes\n notes_range.to_a.map(&:to_s)\n end",
"def notes\n @notes\n end",
"def notes\n @data[:notes]\n end",
"def note\n comment_list = []\n return @notes if !@notes.nil?\n for page in @pages\n next if !page || !page.list || page.list.size <= 0\n note_page = page.list.dup\n \n note_page.each do |item|\n next unless item && (item.code == 108 || item.code == 408)\n comment_list.push(item.parameters[0])\n end\n end\n @notes = comment_list.join(\"\\r\\n\")\n return @notes\n end",
"def notes_with_tags\n fin = []\n \n notes.each do |note|\n\n # tag = {}\n \n # if note.tag_id\n # tag['id'] = note.tag.id\n # tag['note_ids'] = note.id\n # fin << tag\n # end\n\n end \n\n return fin\n end",
"def get_note_list\n note = queued_email_note\n note ? note.value.to_s.split(\",\") : nil\n end",
"def notes\n\t\tall.map do |tone|\n\t\t\tKey.from_index(tone.tone, tone.letter_index).name\n\t\tend.extend(NoteSequence)\n\tend",
"def notes\n @attributes[:notes]\n end",
"def notes\n @attributes[:notes]\n end",
"def notes\n return Note.find(:all, :conditions => [\"type_id = ? AND owner = ?\", self.id, :property ])\n end",
"def note_nodes\n nodes = Nokogiri::HTML.fragment(self.notes).children\n if nodes.size == 1\n content = Scrub.remove_surrounding(notes)\n Nokogiri::HTML.fragment(content).children\n else\n return nodes\n end\n end",
"def note_contents=(notes)\n notes.each do |content|\n if content.strip != ''\n self.notes.build(content: content)\n end\n end\n end",
"def list_notes\n notes = if unsafe_params[:editable]\n Note.editable_by(@context).where.not(title: nil).accessible_by_private\n else\n Note.accessible_by(@context).where.not(title: nil)\n end\n\n if unsafe_params[:scopes].present?\n check_scope!\n notes = notes.where(scope: unsafe_params[:scopes])\n end\n\n if unsafe_params[:note_types].present?\n fail \"Param note_types can only be an Array of Strings containing 'Note', 'Answer', or 'Discussion'\" unless unsafe_params[:note_types].is_a?(Array) && unsafe_params[:note_types].all? { |type| %w(Note Answer Discussion).include?(type) }\n\n note_types = unsafe_params[:note_types].map { |type| type == \"Note\" ? nil : type }\n notes = notes.where(note_type: note_types)\n end\n\n result = notes.order(id: :desc).map do |note|\n if note.note_type == \"Discussion\"\n note = note.discussion\n elsif note.note_type == \"Answer\"\n note = note.answer\n end\n describe_for_api(note, unsafe_params[:describe])\n end\n\n render json: result\n end",
"def body\n @note.content\n end",
"def note_contents=(array)\n array.each do |i|\n if !i.empty?\n note = Note.find_or_create_by(content: i)\n self.notes << note\n end\n end\n end",
"def note_contents=(notes)\n notes.each do |content|\n if content.strip != '' # => ignores blank notes\n self.notes.build(content: content) \n end\n end\n end",
"def character_notes\n self.object.character_notes.map do |note|\n {\n c_note_id: note.id,\n c_note_title: note.title,\n c_note_content: note.content,\n visible_to_other_players: note.visible_to_other_players,\n amount_spent: note.amount_spent,\n amount_earned: note.amount_earned\n }\n end\n end",
"def note_strings\n ::Set.new(@notes.collect(&:note_string))\n end",
"def all_notes\n result = {}\n self.class.all_note_fields.each do |field|\n value = send(field).to_s\n result[field] = value.presence\n end\n result\n end",
"def journal_notes\n css = \"Relationship[@Name='Incident has Notes']\" +\n \" BusinessObject[@Name=JournalNote]\"\n return @dom.css(css).map do |element|\n JournalNote.new(element.to_xml)\n end\n end",
"def collection\n return @client.api_helper.collection(\"notes\")\n end",
"def get_notes(opts = {})\n data, status_code, headers = get_notes_with_http_info(opts)\n return data\n end",
"def index\n @notes_lists = @note.notes_lists.all\n end",
"def process_notes_array(array_of_id)\n notes = []\n array_of_id.each do |d|\n notes << Note.find(d[0].to_i)\n end\n notes\n end",
"def notes\n Notes.new(self)\n end",
"def notes\n data_series.find_all { |ds| ds.options[:note].present? }\n .map { |ds| { ds_name: ds.name, body: ds.options[:note] }}\n end",
"def note_contents=(notes)\n notes.each do |note|\n if note.strip != \"\"\n content = self.notes.build(content: note)\n content.save\n end\n end\n end",
"def note_contents=(notes)\n \tnotes.each do |content|\n \t\tself.notes << Note.find_or_create_by(content: content) unless content == \"\"\n \tend\n end",
"def note_contents=(notes)\n notes.each do |note|\n if note != \"\"\n self.notes << Note.find_or_create_by(content: note)\n end\n end\n\n end",
"def index\n @notes = Note.all\n end",
"def index\n @notes = Note.all\n end",
"def index\n @notes = Note.all\n end",
"def index\n @notes = Note.all\n end",
"def index\n @notes = Note.all\n end",
"def list_notes(identifier, opts = {})\n data, _status_code, _headers = list_notes_with_http_info(identifier, opts)\n return data\n end",
"def notes( params={} )\n notes = get_connections(\"notes\", params)\n return map_connections notes, :to => Facebook::Graph::Note\n end",
"def as_content_array\n as_array[1]\n end",
"def child_notes\n @child_notes ||= NoteComponents::NoteLinks.new(contents).child_notes\n end",
"def index\n @textnotes = Textnote.all\n end",
"def index\n @internal_notes = InternalNote.all\n end",
"def list\n\t\t@notes = Note.where(topic: params[:topic])\n\tend",
"def term_list\n terms = Array.new\n\n self.notes.each do |note|\n note.scrubbed_notes.each do |word|\n term_index = terms.index(word)\n if term_index.nil?\n terms.push(word)\n end\n end\n end\n terms\n end",
"def song_notes=(notes)\n notes.each do |note|\n self.notes.build(content: note)\n end\n end",
"def song_notes=(notes)\n notes.each do |note|\n self.notes.build(content: note)\n end\n end",
"def all_contents()\n contents = self.content.flatten.map do |c|\n case c\n when Eddy::Models::Loop::Repeat then c.all_contents()\n when Eddy::Models::Loop::Base then c.all_contents()\n when Eddy::Models::Segment then c\n else raise Eddy::Errors::RenderError\n end\n end\n return contents.flatten\n end",
"def get_note_csv\n to_return = [AppleNote.to_csv_headers]\n @notes.each do |key, note|\n to_return.push(note.to_csv)\n end\n to_return\n end",
"def get_note_csv\n to_return = [AppleNote.to_csv_headers]\n @notes.each do |key, note|\n to_return.push(note.to_csv)\n end\n to_return\n end",
"def notes params=nil\n @nimble.get \"contact/#{self.id}/notes\", params\n end",
"def evernote_note_titles\n Rails.cache.fetch(\"#{cache_key}/evernote_note_titles\", expires_in: 12.hours) do\n Evernote::NoteStoreExplorer.new(self).app_notes.map {|n| n.title}\n end\n end",
"def note_contents=(contents)\n contents.each do |content|\n # next if content == ''\n if !content.empty?\n note = self.notes.build(content: content)\n # note = Note.find_or_create_by(content: content)\n # self.notes << note\n end\n end\n end",
"def notes_to_char_string_array\n rows = []\n \n params['notes'].each do |row, row_notes| \n string_of_notes = empty_row_of_notes\n row_notes.each do |key, value|\n string_of_notes[key.to_i] = value\n end \n rows[row.to_i] = string_of_notes\n end\n # Convert any nil to empty row of notes\n rows.map! do |string_of_notes|\n string_of_notes ||= empty_row_of_notes\n end\n rows\n end",
"def getAllContents() # BUG: camel_case.rb\r\n assert_exists\r\n #element.log \"There are #{@o.length} items\"\r\n returnArray = []\r\n @o.each { |thisItem| returnArray << thisItem.text }\r\n return returnArray \r\n end",
"def notes(wspace=workspace)\n\t\twspace.notes\n\tend",
"def index\n respond_with Note.all\n end",
"def content\n @lines.as_text\n end",
"def notes; end",
"def notes; end",
"def notes; end",
"def _getarray\n if @document.nil?\n return @list\n else\n return @document.native_text\n end\n end",
"def notes\n run(helm('get', 'notes', name))\n end",
"def index\n @notebook_notes = Notebook::Note.all\n end",
"def content\n return @content_ unless @content_.nil?\n @note.nil? and get\n @content_ = !@note.nil? && !@note.guid.nil? ? @auth_store.note_store.getNoteContent(@auth_store.auth_token, @note.guid) : \"\"\n end",
"def parse\n records = []\n files.each do |fname|\n records += parse_file(fname)\n end\n\n @notes = records.sort\n end",
"def notes(params = {})\n @notes ||= MailchimpAPI::Note.find(:all, params: { member_id: id }.deep_merge(prefix_options).deep_merge(params))\n end",
"def notes_chronologically\n notes.in_order\n end",
"def lines\n\t\tcontents.split(\"\\n\")\n\tend",
"def lines\n\t\tcontents.split(\"\\n\")\n\tend",
"def lines\n content.lines.map(&:chomp)\n end",
"def all_attachments notes=nil\n if notes == nil\n notes = self.notes.collect{|note| note.id}\n NoteAttachment.where(note_id: notes, is_archive:false).order(\"id DESC\")\n else\n NoteAttachment.where(note_id: notes, is_archive:false).order(\"id DESC\")\n end\n end",
"def notes=(value)\n @notes = value\n end",
"def notes=(value)\n @notes = value\n end",
"def notes=(value)\n @notes = value\n end",
"def notes=(value)\n @notes = value\n end",
"def notes(element_key)\n parameter = { basic_auth: @auth }\n\n response = self.class.get(\"/elements/#{element_key}/notes\", parameter)\n if response.success?\n search_response_header = SearchResponseHeader.new(response)\n search_response_header.elementList\n end\n end",
"def show_all_notes(db)\n notes = server.get_index\n notes.each do |note|\n note = server.get_note(note[\"key\"])\n show_note(note)\n end\nend",
"def get_embedded_object_csv\n to_return = [AppleNotesEmbeddedObject.to_csv_headers]\n\n # Loop over each AppleNote\n @notes.each do |key, note|\n \n # Loop over eac AppleNotesEmbeddedObject\n note.embedded_objects.each do |embedded_object|\n\n # Get the results of AppleNotesEmbeddedObject.to_csv\n embedded_object_csv = embedded_object.to_csv\n\n # Check to see if the first element is an Array\n if embedded_object_csv.first.is_a? Array\n\n # If it is, loop over each entry to add it to our results\n embedded_object_csv.each do |embedded_array|\n to_return.push(embedded_array)\n end\n else \n to_return.push(embedded_object_csv)\n end\n end\n end\n to_return\n end",
"def release_notes\n notes = []\n projects.map { |project| notes << project.release_notes(tag_full_name) }\n notes.compact.join(\"\\n\")\n end",
"def index\n @to_do_notes = ToDoNote.all\n end",
"def index\n @note_attachments = NoteAttachment.all\n end",
"def get_embedded_object_csv\n to_return = [AppleNotesEmbeddedObject.to_csv_headers]\n\n # Loop over each AppleNote\n @notes.each do |key, note|\n \n # Loop over eac AppleNotesEmbeddedObject\n note.all_embedded_objects.each do |embedded_object|\n\n # Get the results of AppleNotesEmbeddedObject.to_csv\n embedded_object_csv = embedded_object.to_csv\n\n # Check to see if the first element is an Array\n if embedded_object_csv.first.is_a? Array\n\n # If it is, loop over each entry to add it to our results\n embedded_object_csv.each do |embedded_array|\n to_return.push(embedded_array)\n end\n else \n to_return.push(embedded_object_csv)\n end\n end\n end\n to_return\n end",
"def all\n @contents.flatten.join\n end",
"def index\n @notes = Note.all\n \n respond_with(@notes)\n end",
"def paragraphs\n raw_content['blocks'].map { |x| x['text'] }\n rescue StandardError\n []\n end",
"def index\n @communication_notes = CommunicationNote.all\n end",
"def _Notes\n while true\n\n _save1 = self.pos\n while true # choice\n _tmp = apply(:_Note)\n break if _tmp\n self.pos = _save1\n _tmp = apply(:_SkipBlock)\n break if _tmp\n self.pos = _save1\n break\n end # end choice\n\n break unless _tmp\n end\n _tmp = true\n set_failed_rule :_Notes unless _tmp\n return _tmp\n end",
"def handle_notes(notes)\n\n notes.each do |note|\n\n prefix = case note['type']\n when 'dimensions'; \"Dimensions\"\n when 'physdesc'; \"Physical Description note\"\n when 'materialspec'; \"Material Specific Details\"\n when 'physloc'; \"Location of resource\"\n when 'phystech'; \"Physical Characteristics / Technical Requirements\"\n when 'physfacet'; \"Physical Facet\"\n when 'processinfo'; \"Processing Information\"\n when 'separatedmaterial'; \"Materials Separated from the Resource\"\n else; nil\n end\n\n marc_args = case note['type']\n\n when 'arrangement', 'fileplan'\n ['351', 'b']\n when 'odd', 'dimensions', 'physdesc', 'materialspec', 'physloc', 'phystech', 'physfacet', 'processinfo', 'separatedmaterial'\n ['500','a']\n when 'accessrestrict'\n ['506','a']\n #when 'scopecontent'\n #['520', '2', ' ', 'a']\n when 'abstract'\n ['520', '3', ' ', 'a']\n when 'prefercite'\n ['524', '8', ' ', 'a']\n when 'acqinfo'\n ind1 = note['publish'] ? '1' : '0'\n ['541', ind1, ' ', 'a']\n when 'relatedmaterial'\n ['544','n']\n #when 'bioghist'\n #['545','a']\n when 'custodhist'\n ind1 = note['publish'] ? '1' : '0'\n ['561', ind1, ' ', 'a']\n when 'appraisal'\n ind1 = note['publish'] ? '1' : '0'\n ['583', ind1, ' ', 'a']\n when 'accruals'\n ['584', 'a']\n when 'altformavail'\n ['535', '2', ' ', 'a']\n when 'originalsloc'\n ['535', '1', ' ', 'a']\n when 'userestrict', 'legalstatus'\n ['540', 'a']\n when 'langmaterial'\n ['546', 'a']\n when 'otherfindaid'\n ['555', '0', ' ', 'a']\n else\n nil\n end\n\n unless marc_args.nil?\n text = prefix ? \"#{prefix}: \" : \"\"\n text += ASpaceExport::Utils.extract_note_text(note, @include_unpublished, true)\n\n # only create a tag if there is text to show (e.g., marked published or exporting unpublished)\n if text.length > 0\n df!(*marc_args[0...-1]).with_sfs([marc_args.last, *Array(text)])\n end\n end\n\n end\n end",
"def tags\n @note.tagNames\n end",
"def array\n\t\treturn @hand_contents\n\tend"
] | [
"0.86408603",
"0.83662134",
"0.8366155",
"0.8317342",
"0.7816864",
"0.7816864",
"0.7816864",
"0.7816864",
"0.7488828",
"0.7403367",
"0.73726386",
"0.73456764",
"0.73196155",
"0.72838736",
"0.72627854",
"0.72289383",
"0.7018001",
"0.70014006",
"0.69167584",
"0.69167584",
"0.67530024",
"0.67509806",
"0.674638",
"0.6662888",
"0.6634288",
"0.656849",
"0.6561454",
"0.65496254",
"0.65458983",
"0.65242666",
"0.6523108",
"0.6510743",
"0.6504523",
"0.64554346",
"0.642913",
"0.6420711",
"0.63923204",
"0.63898164",
"0.6376016",
"0.6305393",
"0.6275542",
"0.6275542",
"0.6275542",
"0.6275542",
"0.6275542",
"0.62589955",
"0.6253445",
"0.6252335",
"0.6246442",
"0.6226443",
"0.62255514",
"0.6218453",
"0.6192114",
"0.61888367",
"0.61888367",
"0.61339736",
"0.61295366",
"0.61295366",
"0.6127955",
"0.61227757",
"0.61072093",
"0.6097505",
"0.6087567",
"0.60853493",
"0.60762405",
"0.6071415",
"0.60519814",
"0.60519814",
"0.60519814",
"0.60512096",
"0.6041054",
"0.60403144",
"0.60390174",
"0.6034626",
"0.60266316",
"0.60160834",
"0.6013571",
"0.6013571",
"0.6012184",
"0.5997554",
"0.5995332",
"0.5995332",
"0.5995332",
"0.5995332",
"0.5995188",
"0.59945506",
"0.59825474",
"0.5978566",
"0.5962166",
"0.5957027",
"0.5955641",
"0.59442586",
"0.593437",
"0.5930891",
"0.5917268",
"0.5890543",
"0.5880266",
"0.5860072",
"0.5850962"
] | 0.85840327 | 2 |
then, the method will print: "a", "b", "c", "ab", "bc", "abc" if the input string is "abcd", then, the method will print: "a", "b", "c", "d", "ab", "bc", "cd", "abc", "bcd", "abcd" | def print_combinations(str)
return if !str || str.length == 0
str_length = str.length
char_count = 1
while char_count <= str_length
start_index = 0
print_current(start_index, char_count, str, str_length)
char_count += 1
end
return
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def StringReduction(str)\n until str.split(\"\").uniq.length == 1\n str = str.sub(/ab|ba/, \"c\").\n sub(/ac|ca/, \"b\").\n sub(/cb|bc/, \"a\")\n end\n str.size \nend",
"def find_all_combos(str=[\"\"],arr={})\n if str.length == 1\n return str\n end\n i = 0\n #iterate over each string\n while i < str.length\n j = 0\n if !arr[str[i]]\n arr[str[i]] = true\n end\n while j < str.length\n #create a new string by combining with the other strings\n if j != i\n new_str = str[i] + str[j]\n\n new_arr = [new_str]\n \n k = 0\n #build a new array with the string\n while k < str.length\n if(k != i && k!=j)\n new_arr.push(str[k])\n end\n k+=1\n end\n arr[new_str] = true\n find_all_combos(new_arr,arr)\n end\n j+=1\n end\n i+=1\n end\n return arr\nend",
"def permutations(string)\nend",
"def depunctuate(a_string)\n alphabet = [*\"A\"..\"Z\"] + [*\"a\"..\"z\"]\n result = \"\"\n a_string.length.times do |i|\n if alphabet.include?(a_string[i])\n result << a_string[i]\n end\n end\n result\nend",
"def crunch(string)\n array = string.chars\n no_repeats = []\n no_repeats.push(array[0])\n for i in 0..(array.size - 1)\n no_repeats.push(array[i+1]) if array[i] != array[i+1]\n end\n\n no_repeats.join\nend",
"def permutations(str)\nend",
"def crunch(str)\n new_string = ''\n counter = 0\n while counter <= str.length - 1\n new_string << str[counter] unless str[counter] == str[counter + 1]\n counter += 1\n end\n new_string\nend",
"def genStr strLen\nsortedAlphabet = @alphabet.sort\nresultStrs = [ ]\ntestStrings = [ ]\ntestStrings[0] = []\ntestStrings[0].push \"\"\n1.upto(strLen.to_i) { |x|\ntestStrings[x] = []\ntestStrings[x-1].each { |s|\nsortedAlphabet.each { |c|\ntestStrings[x].push s+c\n}\n}\n}\ntestStrings.flatten.each { |s|\nresultStrs.push s if accept? s, @start\n}\nresult = \"\"\nresultStrs.each { |x| result.concat '\"'+x+'\" ' }\nresult\nend",
"def permutations(string)\n # base case\n if string.length == 0\n return string\n end\n\n results = []\n\n i = 0\n while i < string.length\n first_letter = string[i]\n rest = string[i+1..-1]\n permutes = permutations(rest)\n \n permutes.each do |permuties|\n results.push(first_letter += permuties)\n end\n end\n\n return results\n\nend",
"def capital_permutations(str)\n output = []\n str.chars.each_with_index do |char, index|\n if index == 0\n output << char\n output << char.upcase\n else\n new_output = []\n output.each do |string|\n new_output << string + char\n new_output << string + char.upcase\n end\n output = new_output\n end\n end\n output\nend",
"def solution(str)\n str+=\"_\" if str.length.odd?\n res = []\n index = 0\n while index < str.length\n res << str[index .. index+1]\n index+=2\n end\n res\nend",
"def get_perms(input_string)\n return [\"\"] if input_string.length == 0\n return [input_string] if input_string.length == 1\n input_array = input_string.split(\"\")\n letter = input_array.pop\n words = get_perms(input_array.join(\"\"))\n perms = []\n words.each do |word|\n (word.length+1).times do |idx|\n perms.push(word.dup.insert(idx,letter))\n end\n end\n perms\nend",
"def crunch(str)\n last_character = ''\n collapsed = str.chars.each_with_object([]) do |character, arr|\n unless character == last_character\n arr.push(character)\n last_character = character\n end\n end\n collapsed.join\nend",
"def repeating_letters?(str)\r\n # your code goes here\r\n str = str.downcase.split(\"\")\r\n temp = \"\"\r\n i = 0\r\n while i < str.length\r\n if temp.include?(str[i])\r\n return true\r\n else\r\n temp << str[i]\r\n end\r\n i += 1\r\n end\r\n false\r\nend",
"def crunch(string)\n index = 0\n str_text = ''\n while index <= string.length - 1\n str_text << string[index] unless string[index] == string[index + 1]\n index += 1\n end\n str_text\nend",
"def string_permutations(str) \n return [] if !str || str.length == 0\n \n perms = []\n helper(rest: str, perms: perms)\n perms \nend",
"def solution(str)\n str << \"_\" if str.length % 2 != 0\n str.chars.each_slice(2).map(&:join)\nend",
"def repeater(string)\n string.chars.zip(string.chars).join\nend",
"def crunch(str)\n counter = 0\n result = ''\n while counter < str.length\n result << str[counter] unless str[counter] == result[-1]\n counter += 1\n end\n result\nend",
"def permutations(string)\n string.chars.permutation(string.length).map(&:join).uniq\nend",
"def perm_recur(ans=\"\",s)\n if s.length == 0\n return\n end\n\n if s.length == 1\n puts ans + s\n return\n end\n \n if s.length == 2\n puts ans + s[0] + s[1] \n puts ans + s[1] + s[0]\n return\n end\n\n (0..s.size-1).each do |l|\n new = s.chars.rotate(l).join('')\n element = new[0] \n rest = new[1..new.size-1]\n perm_recur(ans + element, rest)\n end\nend",
"def solution(string)\n\talphabet = (\"A\"..\"Z\").to_a\n\n\tarr = []\n\tstring.chars.each do |letter|\n\t\tif alphabet.include?(letter)\n\t\t\tarr << \" \"\n\t\t\tarr << letter\n\t\telse\n\t\t\tarr << letter\n\t\tend\n\tend\narr.join\nend",
"def substrings_at_start(string)\n result = []\n string = string.chars\n string.size.times do\n result << string.join('')\n string.pop\n end\n\n result.sort\nend",
"def repeater(str)\n str.chars.zip(str.chars).join\nend",
"def substrings(string)\n if string.size == 1\n [string]\n else\n [string] + (substrings(string[0...-1]) + substrings(string[1..-1])).uniq\n end\nend",
"def leading_substrings(string, result, counter)\r\n counter.upto(string.size - 1) do |index|\r\n result << string[counter..index]\r\n end\r\nend",
"def repeater(string)\n doubled = ''\n characters = string.chars\n size = characters.size\n counter = 0\n\n while counter < size\n doubled = doubled + string[counter] + string[counter]\n\n counter += 1\n end\n\n doubled\nend",
"def substrings(string)\r\n new_array = []\r\n string.size.times do |index|\r\n new_array << leading_substrings(string[index..string.size])\r\n end\r\n new_array.flatten\r\nend",
"def repeater(str)\n temp_arr = []\n str.chars do |letter|\n temp_arr << letter * 2\n end\n \n temp_arr.join('')\nend",
"def permutations(string)\n string.chars.permutation(string.length).to_a.map { |arr| arr.join }.uniq\nend",
"def permute(str, l, r)\r\n if (l == r)\r\n print(str)\r\n else\r\n for i in l..r\r\n str[l], str[i] = str[i], str[l]\r\n permute(str, l+1, r)\r\n str[l], str[i] = str[i], str[l]\r\n end\r\n end\r\nend",
"def permutations(string)\n string.chars.permutation.to_a.map(&:join).uniq\nend",
"def repeating_letters?(str)\n index = 0\nnew_str = str.split(\"\").sort.join.downcase\n\nwhile index < str.length\n if new_str[index] == new_str[index + 1]\n return true\n end\n index += 1\nend\nfalse\n\nend",
"def every_other_letter(string)\r\n # your code here\r\n every_other_letter = \"\"\r\n i = 0\r\n for i in 0 ... string.length\r\n if i % 2 == 0\r\n every_other_letter << string[i]\r\n end\r\n end\r\n every_other_letter\r\nend",
"def compress_str(str)\n curr = str[0]\n new_str = \"\"\n len = 1\n (1..(str.length - 1)).each do |i|\n if str[i] == str[i - 1]\n len += 1\n else\n new_str += compressed(str[i - 1], len)\n len = 1\n end\n end\n new_str += compressed(str[-1], len)\nend",
"def vogal(str)\n vogals = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n cons = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n# splitting the string given into arrays \n str = str.chars\n str_new = str.map do |char|\n#looping the string into the next letter\n if vogals.include?(char)\n vogals.rotate(1)[vogals.index(char)]\n else cons.include?(char)\n cons.rotate(1)[cons.index(char)]\n end\n end\n#joining the strings back\n str_new.join\nend",
"def even_splitters(string)\n result = [] \n\n string.chars.uniq.each do |c|\n result << c if element_same_length?(string.split(c))\n end\n \n p result\nend",
"def alphabeticShift(inputString)\n alpha = (\"a\"..\"z\").to_a + [\"a\"]\n array = inputString.split(\"\")\n \n for i in 0..(array.count-1)\n array[i] = alpha[alpha.index(array[i])+1]\n end\n array.join(\"\")\nend",
"def string_compression(str)\n str_array = str.split(\"\")\n current_letter = str_array.first\n output = [current_letter]\n current_count = 1\n\n indx = 1\n while indx < str_array.length\n if current_letter == str_array[indx]\n current_count += 1\n else\n output << current_count unless current_count == 1\n current_count = 1\n current_letter = str_array[indx]\n output << current_letter\n end\n indx += 1\n end\n output.join(\"\")\nend",
"def crunch(str)\n i = 0\n crunch_text = ''\n while i <= str.length\n crunch_text << str[i] unless str[i] == str[i + 1]\n i += 1\n end\n crunch_text\nend",
"def encode_repeating(my_string)\r\n i = 0\r\n j = 0\r\n letter = my_string[i]\r\n while i < my_string.length\r\n j += 1 while my_string[j + 1] == letter\r\n if j - i >= 2\r\n my_string[(i + 1)..j] = (j - i + 1).to_s\r\n end\r\n additional = 0\r\n additional = 1 if j > i\r\n i += 1 + additional\r\n j = i\r\n letter = my_string[i]\r\n end\r\n return my_string\r\nend",
"def crunch(str)\n if str == '' \n return ''\n end\n \n new_arr = str.split('')\n str_out = new_arr[0]\n \n (1..new_arr.size-1).each {|n|\n new_arr[n] != new_arr[n-1] ? \n str_out << new_arr[n]\n : n\n }\n \n str_out\nend",
"def rampant_repeats(string, hash)\n new_str = \"\"\n string.each_char do |char| \n if hash[char]\n hash[char].times { new_str += char }\n else\n new_str += char\n end\n end\n new_str\nend",
"def substrings(str)\n result = []\n until str.empty?\n str.size.times { |index| result << str[0..index] }\n str[0] = ''\n end\n result\nend",
"def leading_substrings_recursive(str, arr = [])\n if str.size > 1\n leading_substrings_recursive(str[0..str.size-2], arr)\n end\n arr << str\nend",
"def string_compression(str)\n new_str = \"\"\n counter = 1\n current_letter = str[0]\n str.split(\"\")[1..-1].each do |letter|\n if letter == current_letter\n counter += 1\n else\n new_str += counter.to_s + current_letter\n current_letter = letter\n counter = 1\n end\n end\n new_str += counter.to_s + current_letter\n if new_str.length >= str.length\n return str\n else\n return new_str\n end\nend",
"def jumble_sort(str, alphabet = nil)\n return str.chars.sort.join(\"\") if alphabet.nil?\n new_string = \"\"\n alphabet.each do |letter|\n (str.count(letter)).times do\n new_string += letter\n end\n end\n new_string\nend",
"def substrings(str)\n result = []\n 1.upto(str.size) do |idx|\n str.chars.each_cons(idx) do |subr|\n result << subr.join\n end\n end\n result.sort\nend",
"def stringy(input)\n result = []\n counter = 0\n\n result << '1'\n \n until result.size == input\n result[counter] == '1'? result << '0' : result << '1'\n counter += 1\n end\n \n result.join('')\nend",
"def same_char_collapse(str)\n collapsable = true\n while collapsable\n collapsable = false\n chars = str.split(\"\")\n chars.each.with_index do |char, i|\n if chars[i] == chars[i+1]\n chars[i] = \"\"\n chars[i+1] = \"\"\n collapsable = true\n break\n end\n end\n # print chars.join(\"\")\n str = chars.join(\"\")\n end\n return str\nend",
"def upcase_downcase_perms(string)\n return [string.downcase, string.upcase] if string.size == 1\n head = string[0]\n tail = string[1..-1]\n sub = upcase_downcase_perms(tail)\n a = sub.collect { |x| head.upcase + x }\n b = sub.collect { |x| head.downcase + x }\n (a + b).uniq\nend",
"def crunch(string)\n prev_char = ''\n new_string = ''\n \n string.chars.each do |char|\n if char == prev_char\n next\n else\n new_string << char\n prev_char = char\n end\n end\n \n new_string\nend",
"def substrings_at_start(string)\n string.size.times.with_object([]) { |idx, arr| arr << string.chars.take(idx + 1).join}\nend",
"def repeater(string)\n new_string = ''\n string.chars.each do |char|\n new_string << char << char\n end\n new_string\nend",
"def leading_substrings(str)\n running_str = ''\n sub_strings = []\n str.each_char { |chr| sub_strings << running_str += chr }\n sub_strings\nend",
"def getPermutations(s)\n result = []\n for i in 0..2\n substring = s[1..2]\n result.push(s[0] + substring)\n result.push(s[0] + substring.reverse)\n s = rotateChar(s)\n end\n\n return result\nend",
"def string_compress(string)\n original=string\n i=0\n while(i<string.length)\n j=i\n while (string[i]==string[j])\n j+=1\n end\n string[i..j-1]=\"#{string[i]}#{(j-i)}\"\n i+=2\n end\n return original if string.length>original.length \n return string\n \nend",
"def substrings_at_start(string)\n results = []\n\n string.length.times do\n results << string\n string = string.chop\n end\n\n results.sort\nend",
"def crunch(string)\n crunched = []\n chars = string.split('') \n chars.each_with_index do |c,i|\n if i == 0\n crunched << c\n elsif chars[i-1] != c\n crunched << c\n end\n end\n crunched.join\nend",
"def encrypt(my_string)\n i = 0 # start with first letter of string\n new_string = \"\" # placeholder of new string since it will be generated after\n# increase it one letter\n until i == my_string.length # until i == the length of my_string aka 3 keep running loop\n if !(\"a\"..\"z\").include?(my_string[i]) # if there is an anti-alphabet in my_string\n new_string = new_string + my_string[i] # take whatever value in new string take current value in new string and add character we're on right now \"\" + \" \" p pr pry pryz; (\"+\" is tacking on next letter)\n elsif my_string[i] == \"z\" # or if my_string is a z\n new_string = new_string + \"a\" # take w/e value we have so far in new_string and add \"a\"\n else # otherwise\n new_string = new_string + my_string[i].next # take w/e value we have so far and tack on the next letter of string[i]\n end\n i += 1 # go onto the next character in the string / increment up 1 // iterate over string and position in array\n end\n new_string # show me the new string\nend",
"def substrings_at_start(string)\n result = []\n\n loop do\n break if string.empty?\n result << string\n string = string.chop\n end\n\n result.reverse\nend",
"def crunch(string)\n counter = 0\n new_string = string[0]\n return new_string if string.length <= 1\n return string if string == ''\n loop do\n counter += 1\n new_string << string[counter] if string[counter - 1] != string[counter]\n\n break if counter == (string.length - 1)\n end\n new_string\nend",
"def crunch(string)\n no_duplicates = ''\n string.chars.each do |letter|\n no_duplicates << letter unless no_duplicates[-1] == letter\n end\n no_duplicates\nend",
"def encode_repeating(my_string)\n puts my_string\n\n if my_string == \"\" || my_string == nil || my_string.length == 0\n return my_string\n end\n\n\n new_arr = []\n hash = {}\n i = 0\n while i < my_string.length\n\n char = my_string[i]\n print char\n\n if hash[char]\n hash[char] += 1\n else\n hash[char] = 1\n end\n\n i += 1\n\n end\n\n puts hash\n\n\n hash.each do |k, v|\n if v <= 2\n v.times do\n new_arr << k\n end\n elsif v > 2\n new_arr << k\n new_arr << v\n end\n end\n\n puts new_arr\n puts new_arr.join\n\n my_string = new_arr.join\n return my_string\n # raise NotImplementedError\nend",
"def compress_string(string)\n str = ''\n start = 0\n (0..string.length).each do |i|\n next if string[start] == string[i]\n\n str << string[start] << (i - start).to_s\n start = i\n end\nend",
"def compress_str(str)\n\n new = []\n count = 1\n\n (0..str.length-1).each do |i|\n if str[i] == str[i+1]\n count += 1\n elsif str[i] != str[i+1]\n if count > 1\n new << count.to_s + str[i]\n count = 1\n else \n new << str[i]\n end\n end\n end\n new.join(\"\")\nend",
"def permutations(string)\n permute(string, 0, string.length)\nend",
"def staggered_case(string)\n counter = 0\n final = string.chars.map do |el|\n counter += 1 if ('a'..'z').include?(el.downcase)\n counter.odd? ? el.upcase : el.downcase\n end\n final.join\nend",
"def staggered_case(string)\n staggered = []\n string.chars.each_with_index do |char, index|\n if index.odd?\n staggered << char.downcase\n else\n staggered << char.upcase\n end\n end\n staggered.join\nend",
"def solution(a)\n str = ''\n a.each do |item|\n i = 0\n while i < item.length\n matched = 0\n \n a.each do |string|\n matched += 1 if string.include?(str)\n end\n \n if matched == a.length && i > 0\n str += item[i-1]\n else\n break\n end\n i += 1\n end\n end\n return str\nend",
"def substrings(str)\n result = []\n str.size.times do |idx|\n result << leading_substrings(str[idx..-1])\n end\n result.flatten\nend",
"def same_char_collapse(str)\n i = 0\n while i < str.length\n if i == 0\n new_str = \"\"\n end\n\n if i != str.length-1\n if str[i] == str[i+1]\n new_str += str[i+2..-1]\n str = new_str\n i = 0\n else\n new_str += str[i]\n i += 1\n end\n else\n new_str += str[i]\n i += 1\n end\n\n end\n return str\nend",
"def same_char_collapse(str)\n collapsible = true\n\n while collapsible\n collapsible = false\n\n chars = str.split(\"\")\n chars.each.with_index do |char, i|\n if chars[i] == chars[i + 1]\n chars[i] = \"\"\n chars[i + 1] = \"\"\n collapsible = true\n break\n end\n end\n str = chars.join(\"\")\n end\n \n return str\nend",
"def even_splitters(string)\n \n results = []\n letters = string.split(\"\")\n unique = letters.uniq #duplicate?\n \n i = 0\n while i < unique.length #CAN ONLY SPLIT STRING\n split_words = string.split(unique[i])\n split_words.delete(\"\")\n first = split_words[0]\n if split_words.all?{|el| el.length == first.length}\n results << unique[i]\n end\n i += 1\n end\n \n results \n #get letters we can split on by getting unique elements\n \n # split with each char, delete \"\" empty strings, get length of first element\n # check if all elements have the same string length\n # if so push char to results\n\n\nend",
"def rampant_repeats(string, hash)\n new_str = \"\"\n string.each_char do |char|\n if hash.key?(char)\n hash[char].times { new_str += char }\n else\n new_str += char \n end\n end\n new_str\nend",
"def leading_substrings(string)\n str = string\n arr = []\n counter = 0\n\n loop do\n break if str.size == counter\n arr << str.slice(0..counter)\n counter += 1\n end\n \n arr\nend",
"def palindrome_permutation(str)\n\nend",
"def substrings(string)\r\n subs = []\r\n i = 0\r\n while i < string.length - 1\r\n j = i\r\n while j < string.length - 1\r\n subs << string[i..j] unless subs.include? string[i..j]\r\n j += 1\r\n end\r\n i += 1\r\n end\r\n subs\r\nend",
"def repeater(string)\n string.chars.map do |char|\n char + char\n end.join\nend",
"def compress_str(string)\n\n result = \"\" #[a]\n i = 0\n \n while i < string.length\n counter = 1\n while string[i] == string[i + 1]\n counter += 1\n i += 1\n end\n \n result += counter.to_s if counter > 1\n result += string[i]\n i += 1\n end\n result\nend",
"def repeater(string)\n string.chars.map { |char| char + char }.join\nend",
"def staggered_case(string)\n chars = string.chars.map(&:downcase)\n n = 0\n m = 0\n\n results = []\n\n chars.size.times do\n if n.even? && chars[m] =~ /[A-Za-z]/\n results << chars[m].upcase\n n += 1\n m += 1\n elsif chars[m] =~ /[A-Za-z]/\n results << chars[m]\n n += 1\n m += 1\n else\n results << chars[m]\n m += 1\n end\n end\n\n results.join\nend",
"def find_subs(string)\n result = []\n arr = string.chars\n arr.each_index do |outer_idx|\n (arr.size - outer_idx).times do |inner_idx|\n result << arr[outer_idx..(inner_idx + outer_idx)].join\n end\n end\n result\nend",
"def print_perms(string, chars, position=0, current_perm=\"\")\n string_array = string.split(\"\")\n\n # If we have an empty string, then print no permutations\n if (string_array.size < 1)\n puts \"\"\n return\n end\n\n # If we're done with this perm, print it\n if (position == (string_array.size - 1))\n puts current_perm + string_array.last\n return\n end\n\n # Print all permutations\n chars.each do |char|\n next_perm = current_perm + string_array[position] + char\n print_perms(string, chars, position+1, next_perm)\n end\nend",
"def next_letters(string)\r\n\r\n string = swap_names(string)\r\n \r\n letters = string.split(\"\")\r\n \r\n \r\n next_letters = letters.map! do |letter|\r\n next_vowel?(letter)\r\n end\r\n \r\n next_letters.join(\"\")\r\n \r\n \r\nend",
"def substring(string)\n stringArray = string.each_char.to_a\n returnArray = []\n stringArray.each_with_index { |e, i| puts \"current letter: #{e}\"\n index = 0\n while index + i < stringArray.length\n if index == 0\n returnArray.push(e)\n else\n #Adding to a tempString to get entries longer than 2\n #This part could be cleaned up\n tempString = ''\n idx = index\n while i + idx < stringArray.length\n tempString += stringArray[i + idx]\n idx += 1\n end\n returnArray.push(e + tempString)\n end\n\n index += 1\n end\n }\n\n print returnArray\nend",
"def repeater(string)\n doubled_str = \"\"\n string.each_char do |char|\n doubled_str << char << char\n # doubled_str.concat(char*2)\n # doubled_str.concat(char, char)\n end\n \n doubled_str\nend",
"def user_inputed_sub_strings(user_input)\n 0.upto(user_input.length - 1).flat_map do |start|\n 1.upto(user_input.length - start).map do |length|\n user_input[start, length]\n end\n end\nend",
"def rampant_repeats(str, hash)\n new_str = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n hash[char].times { new_str += char }\n else\n new_str += char\n end\n end\n new_str\nend",
"def sort3(strings, length)\n i = length - 1 \n letters = (\"a\"..\"z\").to_a\n while i >= 0 \n # O(k)\n buckets = Array.new(26) {[]}\n strings.each do |string|\n buckets[letters.find_index(string[i])] << string \n # O(n)\n end \n strings = buckets.flatten\n i-=1\n end \n p strings\nend",
"def substrings_at_start(string)\n results = []\n\n string.length.times do\n results << string\n string = string.chop\n end\n\n results.reverse\nend",
"def crunch(double_string)\n current_character = ''\n new_string = ''\n double_string.each_char do |character|\n if character != current_character\n new_string += character\n current_character = character\n end\n end\n new_string\nend",
"def jumble_sort(str, alphabet = nil)\n alphabet ||= ('a'..'z').to_a\n final_str = \"\"\n \n alphabet.each do |alpha_char|\n if str.include?(alpha_char)\n str.count(alpha_char).times do\n final_str += alpha_char\n end\n end\n end\n \n final_str\nend",
"def comes_after(str,letter)\n result = []\n unwanted_chars = \"1234567890.,!;:?_ \"\n str.length.times do |index|\n if str[index] == letter.downcase || str[index] == letter.upcase\n result << str[index + 1]\n end\n end\n result.join.delete(unwanted_chars)\nend",
"def hipsterfy(str)\n finalArray = []\n alphabet = (\"a\"..\"z\").to_a\n wordArray = str.split(\" \")\n wordArray.each do |word|\n firstSeen = false\n reversed = word.split(\"\").reverse\n finalWord = []\n reversed.each do |letter|\n if firstSeen == true || letter != \"a\" && letter != \"e\" && letter != \"i\" && letter != \"o\" && letter != \"u\"\n finalWord.push(letter)\n\n elsif firstSeen == false && letter == \"a\" || letter == \"e\" || letter == \"i\" || letter == \"o\" || letter == \"u\"\n # don't add here\n firstSeen = true\n end\n end\n \n newString = \"\"\n finalWord.reverse.each do |element|\n newString += String(element)\n end\n finalArray.push(newString)\n \n end\n \n \n \n # print finalArray\n finalString = \"\"\n \n finalArray.each_with_index do |word, index|\n if index != finalArray.length - 1\n finalString += word + \" \"\n else\n finalString += word\n end\n end\n \n \n \n \n \n \n return finalString\n \n \n\n \nend",
"def repeater(str)\n new_str = ''\n return new_str if str.eql?('')\n str.chars.each do|char|\n new_str << char * 2\n end\n new_str\nend",
"def permut_sub_strings(b, s)\n hash = {}\n permutations(s).each do |str|\n hash[str] = true\n end\n for i in 0..b.size-s.size\n if (hash.key?(b[i..i+s.size]))\n return true\n end\n end\nend",
"def encrypt(string)\n i = 0\n new_string = ''\n while i < string.length\n if new_string.include? 'aa'\n new_string.gsub!('aa', 'a')\n end\n new_string << string[i].next \n i += 1\n end\n p new_string\nend",
"def space_separated(str: raise)\n\tfirst_index = 0\n\tlast_index = 0\n\tresults = []\n\n\tstr.size.times do\n\t\tcheck_string = str[first_index..last_index]\n\t\tif DICTIONARY[check_string]\n\t\t\tresults << check_string\n\t\t\tfirst_index = last_index += 1\n\t\t\tlast_index = first_index\n\t\telse\n\t\t\tlast_index += 1\n\t\tend\n\tend\n\n\tputs results.join(\" \")\nend",
"def permutation(string)\n return [string] if string.size < 2\n char = string[0]\n perms = permutation(string[1..-1])\n result = []\n perms.each do |perm|\n result << char + perm\n (1..perm.length-1).each do |i|\n result << perm[0..i-1] + char + perm[i..-1]\n end\n result << perm + char\n end\n result.uniq\nend"
] | [
"0.65881073",
"0.639427",
"0.6373545",
"0.635229",
"0.62963796",
"0.6280881",
"0.62718064",
"0.62551165",
"0.6203235",
"0.6180908",
"0.61791754",
"0.61758715",
"0.61511016",
"0.6150229",
"0.61201406",
"0.6106661",
"0.6102503",
"0.6101571",
"0.61008465",
"0.61001694",
"0.6078309",
"0.60774076",
"0.60724133",
"0.6063581",
"0.6054924",
"0.6051906",
"0.6051027",
"0.603461",
"0.60339963",
"0.6032508",
"0.60228276",
"0.602111",
"0.60153466",
"0.6014509",
"0.5981736",
"0.597927",
"0.5975455",
"0.5970003",
"0.5963477",
"0.5957438",
"0.5948328",
"0.5944474",
"0.59413993",
"0.59410965",
"0.5939974",
"0.5935224",
"0.5934282",
"0.5933679",
"0.59334487",
"0.593286",
"0.59290415",
"0.59282583",
"0.59219754",
"0.59180367",
"0.5914596",
"0.5912839",
"0.59125507",
"0.5908908",
"0.5908395",
"0.59081405",
"0.59050965",
"0.5904397",
"0.5901973",
"0.5900958",
"0.5895447",
"0.5888094",
"0.58869934",
"0.58867174",
"0.58846056",
"0.5881455",
"0.5878461",
"0.5875847",
"0.5867545",
"0.586331",
"0.58630794",
"0.5862227",
"0.5858183",
"0.58567554",
"0.5855222",
"0.5855084",
"0.58543205",
"0.5848681",
"0.58476686",
"0.58404094",
"0.58398163",
"0.5838304",
"0.58370167",
"0.58330756",
"0.5830779",
"0.5830341",
"0.5828117",
"0.5828057",
"0.5825747",
"0.58249664",
"0.58195627",
"0.5819237",
"0.5817856",
"0.58157694",
"0.5813105",
"0.5813042"
] | 0.6488588 | 1 |
Assemble one file job | def initialize(filename, report=false)
@binary = []
@report = []
@source = filename
@labels = {}
@addr = 0
assmeble(report)
generate
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_job\n if Backdat::Config[:json].empty?\n Backdat::Config[:json] = File.absolute_path(\"#{@first}/.backdat\")\n end\n job_config = parse_dotfile\n run_job\n end",
"def execute!\n my_temp_file = Tempfile.new(\"jobler_test\")\n\n create_result!(name: \"my-file\", temp_file: my_temp_file)\n end",
"def create_work\n @files.each do |file|\n executor.queue { file.copy_file(@output_dir) }\n end\n end",
"def run\n warn_about_aliases if @cmd.to_s == @first\n generate_job\n end",
"def before_perform\n @outdir = job.job_dir.to_s\n @basename = File.join(job.job_dir, job.jobid)\n @infile = @basename+\".in\" \n # still has to be generated\n @outfile = @basename+\".frags\"\n params_to_file(@infile, 'sequence_input', 'sequence_file')\n @informat = params['informat'] ? params['informat'] : 'fas'\n @predict_ta = params['ta']\n reformat(@informat, \"fas\", @infile)\n @commands = []\n \n \n end",
"def reserve_and_run_one_job; end",
"def perform(filepath)\n\n end",
"def main\n\n if ARGV[0].nil?\n STDOUT.write(\"\\nERROR! Missing input file!\\nUsage: create_HHpred_job.rb A3M-FILE\\n\")\n return\n end\n \n infilename = ARGV[0]\n # chec\n if !File.exist?(File.join(infilename))\n STDOUT.write(\"\\nERROR! No inputfile #{infilename}!\\n\") \n return\n end\n\n create_toolkit_job( infilename )\n\nend",
"def build \n configure_directories\n \n @spec['collision'] = 'destroy'\n \n \n jobs = []\n \n # Recon\n recon_options = {'rawdir' => @rawdir, 'epi_pattern' => /(Rest|Task)/i, }\n config_step_method(recon_options, 'recon') if @config['custom_methods']\n jobs << ReconJobGenerator.new(recon_options).build\n \n # Preproc\n preproc_options = {'scans' => jobs.first['scans']}\n config_step_method(preproc_options, 'preproc') if @config['custom_methods']\n jobs << PreprocJobGenerator.new(preproc_options).build\n \n # Stats\n stats_options = {\n 'scans' => jobs.first['scans'],\n 'conditions' => @config['conditions'],\n 'responses_dir' => @config['responses_dir'],\n 'subid' => @spec['subid']\n }\n config_step_method(stats_options, 'stats') if @config['custom_methods']\n jobs << StatsJobGenerator.new(stats_options).build\n \n @spec['jobs'] = jobs\n \n return @spec\n end",
"def before_perform\n @basename = File.join(job.job_dir, job.jobid)\n @infile = @basename+\".fasta\"\n @outfile = @basename+\".png\"\n params_to_file(@infile, 'sequence_input', 'sequence_file')\n @commands = []\n @size = params['size']\n @string = params['string']\n end",
"def compose_job_file(job, options = {})\n pwd = Dir.pwd\n if job.has_key?(:file)\n raise \"Job file '#{job[:file]}' not found\" unless File.exists?(job[:file])\n src_job_file = File.expand_path(File.join(job[:dirname], '.tmp', job[:basename]), pwd)\n FileUtils.mkdir File.dirname(src_job_file) unless Dir.exists?(File.dirname(src_job_file))\n FileUtils.cp(job[:file], src_job_file)\n elsif job.has_key?(:name)\n paths = env.paths_from_root(pwd)\n composite_jobfile = paths.inject('') { |result, path|\n jobfile = File.expand_path('job.properties.erb', path)\n if File.exists?(jobfile)\n result << \"\\nFrom Job File '#{jobfile}':\\n\"\n result << File.read(jobfile)\n end\n result\n }\n FileUtils.mkdir './.tmp' unless Dir.exists?('./.tmp')\n src_job_file = File.expand_path(\".tmp/runjob.properties.erb\", pwd)\n File.open(src_job_file, \"w\") do |f|\n f.puts composite_jobfile\n end\n else\n logger.error \"Unknown job type: #{job.inspect}\"\n end\n job_file = src_job_file.sub(/\\.erb$/,'')\n generate_and_write_job_file(job_file, src_job_file, job, options)\n end",
"def add_job(job, output_file)\n @_jobs << Job.new(job, @_places[:input], \n @_places[:output].merge({:object => output_file})\n )\n end",
"def process_single_submitted_file(file_cfg, submission_name, current_user)\n filename = File.basename(file_cfg[:filename])\n if filename.end_with?('.tar.gz')\n tmp_folder = File.join(Dir.tmpdir, SecureRandom.alphanumeric(10))\n begin\n FileUtils.mkdir_p(tmp_folder)\n system(\"tar -zx -C #{tmp_folder.shellescape} -f #{file_cfg[:tempfile].path.shellescape}\")\n Dir.children(tmp_folder).each do |single_fn|\n submission_variant = File.basename(single_fn, File.extname(single_fn))\n content = File.read(File.join(tmp_folder, single_fn))\n schedule_submission_file(submission_variant, content, submission_name, current_user)\n end\n ensure\n FileUtils.rm_r(tmp_folder)\n end\n else\n submission_variant = File.basename(filename, File.extname(filename))\n content = file_cfg[:tempfile].read\n schedule_submission_file(submission_variant, content, submission_name, current_user)\n end\nend",
"def post_job_content_sample(client)\n job_multipart = {\n :file => File.new($full_path),\n 'num copies' => 10\n }\n\n response = client['jobs'].post job_multipart\n\n p ''\n p 'Submit a new job'\n p response\nend",
"def file!(*args, &block)\n task = Rake::FileTask.define_task(*args, &block)\n CLEAN.include(task.name)\n task\nend",
"def build(file_name)\n end",
"def run_job\n end",
"def build(file_prefix)\n end",
"def file(*args, &block)\n Rake::FileTask.define_task(*args, &block)\nend",
"def prepare(opts)\n BawWorkers::Validation.check_custom_hash(opts, BawWorkers::Jobs::Analysis::Payload::OPTS_FIELDS)\n\n opts[:datetime_with_offset] = BawWorkers::Validation.normalise_datetime(opts[:datetime_with_offset])\n\n # create started file in output dir\n dir_output = create_output_dir(opts)\n started_file = File.join(dir_output, FILE_WORKER_STARTED)\n FileUtils.touch(started_file)\n\n # create run dir and info\n run_info = create_run_info(opts)\n\n dir_run = run_info[:dir_run]\n dir_run_temp = run_info[:dir_run_temp]\n\n # copy programs directory to run dir\n dir_run_programs = copy_programs(dir_run)\n\n command_opts = {\n file_source: get_file_source(opts),\n file_executable: get_file_executable(dir_run_programs, opts),\n dir_output: dir_output,\n file_config: create_config_file(dir_run, opts),\n dir_run: dir_run,\n dir_temp: dir_run_temp\n }\n\n # format command string\n BawWorkers::Validation.check_custom_hash(command_opts,\n BawWorkers::Jobs::Analysis::Payload::COMMAND_PLACEHOLDERS)\n BawWorkers::Jobs::Analysis::Runner.check_command_format(opts)\n command_opts[:command] = BawWorkers::Jobs::Analysis::Runner.format_command(opts, command_opts)\n\n # include path to worker log file\n command_opts[:file_run_log] = run_info[:file_run_log]\n\n command_opts\n end",
"def file_create(args, &block)\n Rake::FileCreationTask.define_task(args, &block)\n end",
"def merge_worker(file, class_name)\n# puts 'merge_worker in ' + self.name\n merge(file)\n @merged_workers << [File.expand_path(file), class_name]\n end",
"def create_upload_job_chunks(jobs, state, apikey, filename, filepath, filesize, start_response)\n jobs.each { |job|\n job[:chunks] = chunk_job(\n job, state, apikey, filename, filepath, filesize, start_response\n )\n }\n jobs\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 build\n if @default_file\n internal_add_file(@default_file)\n end\n end",
"def archive!\n FileUtils.mkdir_p(File.dirname(jobdetails_filename))\n FileUtils.mkdir_p(File.dirname(jobconf_filename))\n store_note\n ArchivableJob.fetch_url(jobdetails_url, jobdetails_filename)\n ArchivableJob.fetch_url(jobconf_url, jobconf_filename)\n details = parse()\n tasks = JobTasks.new(slug, [details.map_tasks.to_i].min, [details.reduce_tasks.to_i].min)\n tasks.fetch_task_counters\n end",
"def perform\n result_file = nil\n \n # Create the alignment files\n result_file = generate_alignment if @task == :all || @task == :align\n \n # Identify the clusters\n result_file = identify_clusters if @task == :all || @task == :cluster\n \n result_file\n end",
"def create_job(api_key, audio_file, name, create_job_file)\n cretae_job_command = \"curl -X POST -F \\\"source_file=@#{audio_file}\\\" \\\"https://api.3playmedia.com/v3/files?api_key=#{api_key}&language_id=1&name=#{name}\\\" > #{create_job_file}\"\n system(cretae_job_command)\n file = File.open(create_job_file, 'r')\n response = JSON.load file\n job_id = response['data']['id']\n job_id\nend",
"def file(*args, &block)\n Rake::FileTask.define_task(*args, &block)\n end",
"def file_create(args, &block)\n Rake::FileCreationTask.define_task(args, &block)\nend",
"def start(_files); 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 process_new\n # each time a job is run then then a note is made that the owning user\n # has run a job. This is so we can get a count of jobs even if the user\n # deletes them\n user = User.find_by_email(self.email)\n if user.runs[\"#{self.type}\"].blank?\n user.runs[\"#{self.type}\"] = 1\n else\n user.runs[\"#{self.type}\"] += 1\n end\n user.save\n\n # get the input file, if it has not already been loaded\n begin\n if self.infile.nil? and !self.inputurl.nil?\n self.get_infile unless (self.type == 'durden' or self.type == 'identkey')\n end\n rescue\n self.jobfail(\"Could not get input file\",\"could not get input file\")\n return\n end\n\n # before processing the job, write a brief summary to the log of this job. It\n # should be csv: type,user,id,date\n logfile = \"#{Vibrant::Application.config.dropbox}/oboe_log_#{Rails.env}.txt\"\n begin\n open(logfile, 'a') do |f|\n f.puts \"#{self.type},#{self.email},#{self.id},#{self.created_at}\"\n end\n rescue\n Rails.logger.error(\"Could not write to logfile!\")\n end\n \n # having got the file, we can now commence the processing\n begin\n self.send(\"process_new_#{self.type}\")\n rescue\n self.update_attributes(:status =>'not yet available')\n end\n end",
"def perform\n @commands << \"/usr/bin/python #{SAMCC}/samcc.py #{@paramsfile} #{@outfile} >> #{job.statuslog_path} 2>&1\"\n\n for i in 0..3\n @commands << \"cd #{job.job_dir}; /usr/bin/gnuplot temp#{i}.run\"\n end\n logger.debug \"Commands:\\n\"+@commands.join(\"\\n\")\n queue.submit(@commands)\n end",
"def job_name\n return settings[:job_name] if settings[:job_name]\n relevant_filename = args.compact.uniq.map { |path| File.basename(path, '.rb') }.join('-')\n \"#{relevant_filename}---#{input_paths}---#{output_path}\".gsub(%r{[^\\w/\\.\\-\\+]+}, '')\n end",
"def start\n prepare\n loop { fork_one_job }\n end",
"def before_perform\n init\n\n @inputformat = params['informat'] ? params['informat'] : \"\"\n\n @colors = ['red', 'orange', 'yellow', 'darkgreen', 'green', 'lightblue', 'blue', 'violet', 'pink']\n #@colors = ['red', 'blue', 'yellow', 'darkgreen', 'pink', 'lightblue', 'orange', 'green', 'pink']\n\n @inputSequences = Array.new\n @inputTags = Array.new\n #@db_path = File.join(GCVIEW, 'tool.db')\n\n @db_path = File.join(DATABASES, 'gcview', 'tool.db')\n @show_number = params['show_number'] ? params['show_number'] : \"5\"\n @show_type = params['show_type'] ? params['show_type'] : \"genes\"\n @cut_off = params['evalue_cutoff'] ? params['evalue_cutoff'] : \"1e-3\"\n\n @input = @basename+\".in\"\n params_to_file(@input, 'sequence_input', 'sequence_file')\n @input_job = @basename+\".jin\"\n params_to_file(@input_job, 'jobid_input')\n #logger.debug \"Params seq inp: #{params.inspect}\"\n\n @input_jobid = false\n @input_sequence = false\n \n @outfile = @basename\n\n @configfile = @basename+\".conf\"\n\n @mainlog = job.statuslog_path\n\n @tmparray = Array.new\n @jobtype = Array.new\n @formerjob = ''\n \n if (params['sequence_input']!=nil || params['sequence_file']!=nil)\n if (@inputformat=='fas')\n check_fasta\n end\n\n if (@inputformat=='gi')\n check_GI\n end\n @input_sequence=true\n end\n\n if (params['jobid_input']!=nil)\n parse_sequencefile(@input_job)\n\n for i in 0..@inputSequences.length-1\n @inputSequences[i]=@inputSequences[i].gsub(/\\s+$/, '')\n end\n @input_jobid=true\n end\n\n if (@cut_off =~ /^e.*$/)\n @cut_off = \"1\" + @cut_off\n end\n\n\n\n # Angabe, wie viele Inputsequences bzw. JobIDs gegeben sind\n @inputSequences_length = @inputSequences.length\n logger.debug \"InputSequences Length: #{@inputSequences_length}\"\n\n logger.debug \"Input_Sequences (before_perform): #{@inputSequences.length} \"\n logger.debug \"tmparray (before_perform): #{@tmparray.length}\"\n logger.debug \"jobtype (before_perform): #{@jobtype.length}\"\n\n if (@inputSequences_length == 0)\n logfile = File.open(job.statuslog_path, \"w\")\n logfile.write(\"No valid input found -- Exiting...\")\n logfile.close \n self.status = STATUS_ERROR\n self.save!\n job.update_status\n raise \"No valid input found\" # just to be sure\n else\n write_configfile\n end\n\n #Check input format\n\n ### -> muss noch erledigt werden: jetzt allerdings Annahme, dass nur IDs eingegeben werden\n\n #if JobID: JobIDS getrennt ins Array @inputIDs speichern; Array-Laenge bestimmen\n\n #if (@inputformat=='jid')\n # 1) Testen, ob Jobs existieren und ob es sich um einen PsiblastJob handelt, dann in Array\n # einfuegen\n #-> erledigt: parse_sequencefile\n\n # 2) Arraylaenge bestimmen\n # @inputSequences_length = @inputSequences.length -> erledigt: in before_perform\n #if FASTA: bei Input einer Fasta-Sequenz gibt es nur ein Inputfile -> Array hat nur die Länge 1\n #else\n #Wird noch hinzugefuegt, allerdings erst nachdem der jid-Teil fertig ist ... .\n #end\n\n\n\n # Inputfiles aus den Psiblast-Tmp-Verzeichnissen holen + ins neue tmp-Verzeichnis speichern\n # -> für Anzahl der Psiblast-Jobs, die verwendet werden ... .\n #for (i=0; i<@inputSequences_length; i++)\n\n\n\n # 1) Input Format checken:\n # a) JobIDs: - IDs trennen\n # - Anzahl (nicht mehr als 10)\n # - IDs in ein Array schreiben und schauen, ob es diese ID überhaupt noch gibt\n # (Mysql Table zu JobID die MysqlID suchen, dann mit MysqlID im tmp-Verz.\n # schauen -> aehnlich Jobscard am li Rand)\n # -> Anzahl der Inputfiles richtet sich nach der Anzahl der JobIDs\n # b) FASTA: - Psiblast laufen lassen (ein Inputfile ...)\n # c) in Array abspeichern\n # 2) Arraylaenge der Inputfiles abspeichern\n end",
"def jobs\r\n end",
"def create_work_and_files(file_dir, dom)\n @log.info 'Ingesting DSpace item'\n\n start_time = DateTime.now\n\n # data mapper\n params = collect_params(dom)\n pp params if @debug\n\n @log.info 'Handle: ' + params['handle'][0]\n\n @log.info 'Creating Hyrax work...'\n work = create_new_work(params)\n\n if @config['metadata_only']\n @log.info 'Metadata only'\n else\n @log.info 'Getting uploaded files'\n uploaded_files = get_files_to_upload(file_dir, dom)\n\n @log.info 'Attaching file(s) to work job...'\n AttachFilesToWorkJob.perform_now(work, uploaded_files)\n end\n\n # record this work in the handle log\n @handle_report.write(\"#{params['handle']},#{work.id}\\n\")\n\n # record the time it took\n end_time = Time.now.minus_with_coercion(start_time)\n total_time = Time.at(end_time.to_i.abs).utc.strftime('%H:%M:%S')\n @log.info 'Total time: ' + total_time\n @log.info 'DONE!'.green\nend",
"def create_model_file\n template 'job_model.rb', File.join('app/models', class_path, \"#{file_name}.rb\")\n end",
"def generate()\n objects = []\n\n # generate object file tasks\n files.each do |fname|\n output_file = File.join(@build_dir, File.basename(fname).ext('o'))\n objects.push output_file\n file output_file => [ fname ] do\n get_toolchain().compile( fname, output_file )\n end\n end\n\n # Link object files\n file output_file() => objects do\n get_toolchain().link( objects, output_file() )\n end\n\n # Create top level task\n desc \"Build the #{@name} application\"\n task @name => [ output_file() ]\n end",
"def execute\n Parallel.each(Dir[\"#{ENV['STAGE']}_files/*\"], progress: \"Progress by files\", in_process: 8) do |file|\n users = Concurrent::Array.new\n sessions = Concurrent::Array.new\n\n fill_data(file, users, sessions)\n ReportGenerator.new(users, sessions, file).execute\n end\n\n ReportJoiner.new(ENV[\"REPORT_FILE_PATH\"]).execute\n end",
"def generate_input_file\n @run_name += \"_t\"\n if @restart_id\n @runner.run_list[@restart_id].restart(self)\n else\n make_initial_profiles if self.respond_to?(:make_initial_profiles) \n end\n if uses_ecom?\n setup_ecom\n elsif uses_chease?\n setup_chease\n end\n #eputs \"nwrite 6 is \", new_run.flux_runs[0].nwrite\n @avail_cpu_time = (@wall_mins-1.0) * 60 if @wall_mins\n if flux_gs2? or flux_gryfx?\n @avail_cpu_time = (@wall_mins-6.0) * 60 if @wall_mins\n end\n check_parameters\n write_input_file\n #eputs \"nwrite 7 is \", new_run.flux_runs[0].nwrite\n generate_flux_input_files if flux_gs2? or flux_gryfx?\n #eputs \"nwrite 8 is \", new_run.flux_runs[0].nwrite\n end",
"def queue_job; end",
"def generate_full_data\n return @job_data if @full_data_generated\n @job_data[\"name\"] = @name if @name\n @job_data[\"metadata\"] ||= {}\n @job_data[\"metadata\"].merge!(@file_data)\n @job_data[\"source\"] = @job_data[\"source_name\"].dup\n @job_data.delete(\"source_name\")\n @full_data_generated = true\n @job_data\n end",
"def startMergeProcess()\n schedulerQueue = SchedulerInfo::DEFAULT_QUEUE\n yamlConfigFile = PathInfo::CONFIG_DIR + \"/config_params.yml\" \n configReader = YAML.load_file(yamlConfigFile)\n\n cmd = \"ruby \" + PathInfo::LIB_DIR + \"/MergeHelper.rb \" + @sampleName.to_s +\n \" \" + @outputDir\n\n @inputList.each do |inputDir|\n cmd = cmd + \" \" + inputDir\n end\n\n obj = Scheduler.new(\"Merge_\" + @sampleName.to_s, cmd)\n obj.lockWholeNode(schedulerQueue)\n obj.runCommand()\n jobID = obj.getJobName()\n\n puts \"Job ID : \" + jobID.to_s\n end",
"def generate_output_of ( job )\n @job = job\n generate_output\n end",
"def perform\n params_dump\n @commands << \"#{PEAKS} -f #{@infile} -s #{@size} -a #{@string} -o #{@outfile} &> #{job.statuslog_path}\"\n logger.debug \"Commands:\\n\"+@commands.join(\"\\n\")\n queue.submit(@commands)\n end",
"def by_file(first, output)\n qseq = Bio::Ngs::Converter::Qseq.new(options.paired ? :pe : :se)\n buffers = [first] if first.kind_of? String\n buffers = first if first.kind_of? Array\n buffers.each do |file_name|\n qseq.buffer = File.open(file_name,'r') #todo: dir is not used here it could be a bug\n fastq_file = File.open(File.join(options.dir,\"#{output}.fastq\"), (options.append ? 'a' : 'w'))\n qseq.to_fastq do |fastq|\n fastq_file.puts fastq if fastq\n end\n qseq.buffer.close\n fastq_file.close \n #Write the report\n File.open(File.join(options.dir,\"#{output}.stats\"), (options.append ? 'a' : 'w')) do |file|\n file.puts ({:file_name=>file_name, :stats=>qseq.stats}.to_yaml)\n end\n end #buffers\n # puts \"Done #{file_name}\"\n end",
"def submit\n @name = params[:name]\n @bigframe_home = params[:bigframe_home]\n @hadoop_home = params[:hadoop_home]\n @tpchds_local = params[:tpchds_local]\n @data_volume = params[:data_volume]\n @data_variety_rel = params[:relational]\n @data_variety_text = params[:text]\n @data_variety_graph = params[:graph]\n @datavariety_graph = \"\"\n @data_velocity = params[:data_velocity]\n @data_output = params[:hdfs_path]\n process_config\n process_xml\n Delayed::Job.enqueue(Datagen.new(@bigframe_home))\n redirect_to :action=>\"index\"\n end",
"def file_task(re, runtime, signature, version, rb, rbc)\n rbc ||= rb.sub(re, \"runtime/#{version}\") + \"c\"\n\n file rbc => [rb, signature]\n runtime << rbc\nend",
"def run_it\n run_through_directory\n file_array_parser\n remove_initial_and_format_change\n array_to_hash\n final_name_info\n create_goal_file\nend",
"def make_f3_postfit_shapes_task(channel)\n shape_file = \"results/#{$jobid}/plots/#{channel}/f3/postfit/#{channel}_f3_postfit_shapes.root\"\n carddir = $carddir #makes a copy so that if $cardir changes this does not\n file shape_file => \"#{$carddir}/#{channel}/.pulls_computed\" do |t|\n sh \"mkdir -p `dirname #{t.name}`\"\n sh \"cp #{carddir}/#{channel}/shapes.root #{t.name}\" #FIXME this may create to rake some problems if next command fails!\n sh \"#{ENV['CMSSW_BASE']}/src/HiggsAnalysis/HiggsToTauTau/test/postfit.py #{t.name} #{$carddir}/#{channel}/120/vhtt_#{channel}.txt --verbose --bins #{$categories_map[channel].join(' ')} --fitresults #{$carddir}/#{channel}/120/out/mlfit.txt\"\n end\n return shape_file\nend",
"def before_perform \n # Init file vars \n\t @basename = File.join(job.job_dir, job.jobid)\n @infile = @basename+\".fasta\"\n @outfile = @basename+\".csblast\"\n \n # Save either the pasted Sequence from frontend or uploaded Sequence File to in file\n params_to_file(@infile, 'sequence_input', 'sequence_file')\n @informat = params['informat'] ? params['informat'] : 'fas'\n # Reformat the input sequence to match fasta format (perl script call)\n reformat(@informat, \"fas\", @infile)\n # necessary for resubmitting domains via slider\n\t File.copy(@infile, @basename+\".in\")\t\n \n # init cmd container\n @commands = []\n\n # init frontend params\n @inputmode = params['inputmode']\n @expect = params['evalue']\n @filter = params['filter'] ? 'T' : 'F'\n @mat_param = params['matrix']\n @other_advanced = params['otheradvanced']\n @descriptions = params['descr']\n @alignments = params['alignments']\n @db_path = params['std_dbs'].nil? ? \"\" : params['std_dbs'].join(' ')\n @db_path = params['user_dbs'].nil? ? @db_path : @db_path + ' ' + params['user_dbs'].join(' ')\n \n @ungapped_alignment = params['ungappedalign'] ? 'F' : 'T'\n @e_thresh = params['evalfirstit']\n @smith_wat = params['smithwat'] ? 'T' : 'F'\n @rounds = params['rounds']\n @fastmode = params['fastmode'] ? 'T' : 'F'\n @alignment = \"\"\n \n # init genome db parameter\n # getDBs is part of the GenomesModule\n gdbs = getDBs('pep')\n logger.debug(\"SELECTED GENOME DBS\\n\")\n logger.debug gdbs.join(\"\\n\")\n @db_path += ' ' + gdbs.join(' ')\n\n\n # Write confidence parameter to file in temp directory\n File.open(@basename + \".csiblast_conf\", \"w\") do |file|\n file.write(@e_thresh)\n end\n # set file rights ugo+rxw\n system(\"chmod 777 #{@basename}.csiblast_conf\")\n # if input is alignment call method process_alignment\n if (@inputmode == \"alignment\") then process_alignment end\n\n # set gapopen and gapextend costs depending on given matrix\n # default values\n @gapopen = 11\n @gapext = 1\n if (@mat_param =~ /BLOSUM80/i || @mat_param =~ /PAM70/i) then @gapopen = 10 end\n if (@mat_param =~ /PAM30/i) then @gapopen = 9 end\n if (@mat_param =~ /BLOSUM45/i) \n @gapopen = 15\n @gapext = 2\n end \n \n end",
"def generate_program(function)\n File.write(\"submit.rb\", generate_program_submit(function))\n File.write(\"consumer_progenitor.rb\", generate_queue_progenitor(function))\n File.write(\"consumer_duplicate.rb\", generate_queue_duplicate(function))\nend",
"def initialize(spec)\n @spec = spec\n @ruby_sources = @spec.files.find_all { |file| file =~ /^Rakefile$|\\.rb$/ }\n @weave_configurations = [ :weave_include, :weave_named_chunk_with_containers, :weave_plain_chunk ]\n task(:default => :all)\n define_all_task\n CLOBBER << \"saikuro\"\n end",
"def create_from_task_template\n File.open(file_path, 'w') do |f|\n f.puts build_task_template\n end\n end",
"def run(filename, options) end",
"def start\n #Parallel.each_with_index(files.take(3), in_processes: 10) do |file_name, index|\n files.each_with_index do |file_name, index|\n begin\n content = JSON.parse(File.read(file_name), symbolize_names: true)\n pr_number_to_be_migrated = content[:number]\n response_temp_file_creation = create_temp_file(file_name, pr_number_to_be_migrated)\n create_ref_to_temp_file(pr_number_to_be_migrated, response_temp_file_creation[:commit][:sha])\n response_pull_request_creation = create_pull_request(pr_number_to_be_migrated)\n update_pull_request(response_pull_request_creation[:number], content)\n delete_ref_to_temp_file(pr_number_to_be_migrated)\n puts '*'\n rescue Exception => e\n puts \"Error: #{e.message}\"\n end\n end\n end",
"def process_one_dir(dir)\n Dir.glob(dir + '/*.txt') do |log_file|\n\n File.open(log_file, \"r\") do |infile|\n size = \"UNKNOWN\"\n jobid = \"UNKNOWN\"\n error = \"NO\"\n while (line = infile.gets)\n if (line.strip == \"------------------------------------------\")\n jobid, nnodes, ntasks, query, dbsize, run, nsplits, nrecords = parse_log_header(infile)\n next\n end\n if (line.include? \"VP:partitioningTime\")\n partitioningTime = line.split(\"VP:partitioningTime:\")[1].strip\n partitioningTime.sub!(\"ms\",\"\").strip!\n end\n if (line.include? \"Running job:\")\n hadoopjob = line.split(\"Running job:\")[1].strip\n end\n if (line.include? \"COMPOSING_TIME_LOAD_PARTIALS=\")\n loadpartials = line.split(\"COMPOSING_TIME_LOAD_PARTIALS=\")[1].strip\n end \n if (line.include? \"COMPOSING_TIME_COMBINE_PARTIALS=\")\n combinepartials = line.split(\"COMPOSING_TIME_COMBINE_PARTIALS=\")[1].strip\n end \n if (line.include? \"Copy result time:\")\n transferResult = line.split(\"Copy result time:\")[1].strip\n transferResult.sub!(\"ms.\",\"\").strip!\n end \n if (line.include? \"Total execution time:\")\n totaltime = line.split(\"Total execution time:\")[1].strip\n totaltime.sub!(\"ms.\",\"\").strip!\n end \n if (line.include? \"Size of output\")\n size = line.split(\":\")[1]\n size = size.split(\" \")[0].strip\n end\n if (line.include? \"Error\")\n error = \"YES\"\n end\n if (line.include? \"Failed reduce tasks\")\n if line.split(\"=\")[1].strip.to_i > 0\n error = \"YES\"\n end\n end\n if (line.include? \"Failed map tasks\")\n if line.split(\"=\")[1].strip.to_i > 0\n error = \"YES\"\n end\n end\n end\n nfragments = nsplits.to_i * nrecords.to_i\n puts \"#{jobid};#{hadoopjob};#{nnodes};#{nnodes.to_i * ntasks.to_i};#{query};#{run};#{dbsize};#{ntasks};#{nfragments};#{nsplits};#{nrecords};#{partitioningTime};#{loadpartials};#{combinepartials};#{transferResult};#{totaltime};#{size};#{error}\"\n end\n end\nend",
"def setup(name, repo_uri, template_path)\n job_creator.run(name, repo_uri, template_path)\n end",
"def install\n bin.install \"job\"\n end",
"def initialize(option_support=[])\n @jobid_prefix = \"x\"\n @options = OpenStruct.new\n options.library = []\n options.inplace = false\n options.encoding = \"utf8\"\n options.transfer_type = :auto\n options.verbose = false\n \n @option_parser=OptionParser.new do |opts|\n\n if ( option_support.include? :prefix_suffix)\n \n @options.output_prefix = \"\"\n opts.on( '-b', '--output-prefix pref', 'A string to prepend to the name of output files' ) do |prefix|\n @options.output_prefix = prefix\n end\n\n @options.output_suffix = \"\"\n opts.on( '-e', '--output-suffix suff', 'A string to append to the name of output files' ) do |suffix|\n @options.output_suffix = suffix\n end\n \n end\n \n if ( option_support.include? :explicit_output )\n @options.explicit_output = nil\n opts.on( '-o', '--output out', 'An explicitly named output file.' ) do |out|\n @options.explicit_output = out\n end\n end\n \n if ( option_support.include? :over_write)\n \n @options.over_write=false\n opts.on( '-r', '--replace-output', 'Dont skip analyses for which the output file already exists' ) do \n @options.over_write = true\n end\n \n end\n\n if ( option_support.include? :background)\n\n @options.background = false\n opts.on( '-z', '--background', 'Run jobs in the background using pbs' ) do \n @options.background = true\n end\n \n end\n \n \n opts.on( '-h', '--help', 'Display this screen' ) do\n puts opts\n exit\n end\n \n end\n \n end",
"def process(files, parallel, test, output_path)\n\n summaries = []\n files.each do |file|\n\n mediainfo = mediainfo(file)\n\n results = []\n tx_files = duplicate(file, output_path, parallel - 1)\n tx_files << file\n\n start_time = Time.now\n tx(tx_files, results, test, mediainfo, output_path)\n wait_for_completion\n end_time = Time.now\n\n summary = TestSummary.new(File.basename(file), results, start_time, end_time, mediainfo[:duration])\n summaries << summary\n end\n\n summaries\nend",
"def create_from_file\n end",
"def generate_files\n copy_file 'queued_task.rb', \"app/models/#{name}.rb\"\n end",
"def bowtie_build(input_file, prefix)\n\t\tstdin, stdout, stderr, t = Open3.popen3(\"bowtie2-build -f #{input_file} #{prefix}\")\n\t\tsystem_exitcode(t, stderr, 'Building bowtie2 index')\n\tend",
"def runMake()\n puts \"Running make to generate Fastq files\"\n\n numCores = @configReader[\"scheduler\"][\"highQueue\"][\"maxCores\"]\n cmd = \"make -j\" + numCores.to_s\n\n s = Scheduler.new(@fcName + \"_BclToFastQ\", cmd)\n s.lockWholeNode(@queue)\n s.runCommand()\n @bclToFastQMakeJobName = s.getJobName()\n\n puts \"BclToFastq Job Name = \" + @bclToFastQMakeJobName.to_s\n\n runLaneBarcodes()\n end",
"def job\n OSC::Machete::Job.new(\n script: script,\n pbsid: pbsid,\n host: host || workflow.batch_host,\n torque_helper: ResourceMgrAdapter.new(workflow)\n )\n end",
"def runMake()\n puts \"Running make to generate Fastq files\"\n\n numCores = @configReader[\"scheduler\"][\"queue\"][SchedulerInfo::CASAVA_QUEUE][\"maxCores\"]\n cmd = \"make -j\" + numCores.to_s\n\n s = Scheduler.new(@fcName + \"_BclToFastQ\", cmd)\n s.lockWholeNode(@queue)\n s.runCommand()\n @bclToFastQMakeJobName = s.getJobName()\n\n puts \"BclToFastq Job Name = \" + @bclToFastQMakeJobName.to_s\n\n runLaneBarcodes()\n end",
"def run\n check_files_exist\n\n file_metadata = UploadFilesMetadataBuilder.build(files: files, mime_types: mime_types, basepath: basepath)\n upload_responses = UploadFiles.upload(file_metadata: file_metadata,\n filepath_map: filepath_map,\n logger: logger,\n connection: connection)\n metadata_builder = MetadataBuilder.new(metadata: metadata,\n grouping_strategy: grouping_strategy,\n file_set_type_strategy: file_set_type_strategy,\n logger: logger)\n request = metadata_builder.with_uploads(upload_responses)\n model = Cocina::Models.build_request(request.as_json.with_indifferent_access)\n CreateResource.run(accession: @accession,\n priority: @priority,\n assign_doi: @assign_doi,\n metadata: model,\n logger: logger,\n connection: connection)\n end",
"def build_work(work_files)\n work_files.each do |file|\n next if file.blank?\n if file.end_with? '-metadata.json'\n @work_metadata = JSON.parse(File.read(file))\n work_metadata[:packaged_by_package_name] = dip_id\n write_json(work_metadata)\n else\n FileUtils.cp_r(file, src)\n end\n end\n write_dc\n end",
"def main()\n res = @s.execute_get(@s.url_for(\"var/search/needsprocessing.json\"))\n unless res.code == '200'\n raise \"Failed to retrieve list to process [#{res.code}]\"\n end\n\n process_results = JSON.parse(res.body)['results']\n log \"processing #{process_results.size} entries\"\n unless process_results.size > 0\n return\n end\n\n # Create some temporary directories.\n Dir.mkdir DOCS_DIR unless File.directory? DOCS_DIR\n Dir.mkdir PREV_DIR unless File.directory? PREV_DIR\n Dir.mkdir PDFS_DIR unless File.directory? PDFS_DIR\n\n # Create a temporary file in the DOCS_DIR for all the pending files and outputs all the filenames in the terminal.\n Dir.chdir DOCS_DIR\n queued_files = process_results.collect do |result|\n FileUtils.touch result['_path']\n end\n\n log \" \"\n log \"Starts a new batch of queued files: #{queued_files.join(', ')}\"\n\n Dir['*'].each do |id|\n FileUtils.rm_f id\n log \"processing #{id}\"\n\n begin\n meta_file = @s.execute_get @s.url_for(\"p/#{id}.json\")\n unless meta_file.code == '200'\n raise \"Failed to process: #{id}\"\n end\n\n meta = JSON.parse meta_file.body\n mime_type = meta['_mimeType']\n given_extension = meta[\"sakai:fileextension\"]\n extension = determine_file_extension_with_mime_type(mime_type, given_extension)\n filename = id + extension\n log \"with filename: #{filename}\"\n\n if ignore_processing?(mime_type) || extension.eql?('')\n if extension.eql?('')\n log \"ignoring processing of #{filename}, no preview can be generated for files without a known mime type\"\n log \"The file's original extension was #{given_extension}, and it's mime type is #{mime_type}\"\n else\n log \"ignoring processing of #{filename}, no preview can be generated for #{mime_type} files\"\n end\n else\n # Making a local copy of the file.\n content_file = @s.execute_get @s.url_for(\"p/#{id}\")\n unless ['200', '204'].include? content_file.code\n raise \"Failed to process file: #{id}, status: #{content_file.code}\"\n end\n File.open(filename, 'wb') { |f| f.write content_file.body }\n\n if process_as_image? extension\n extension = output_extension extension\n page_count = 1\n filename_thumb = 'thumb' + extension\n\n content = resize_and_write_file filename, filename_thumb, 900\n post_file_to_server id, content, :normal, page_count, extension\n\n content = resize_and_write_file filename, filename_thumb, 180, 225\n post_file_to_server id, content, :small, page_count, extension\n\n FileUtils.rm_f DOCS_DIR + \"/#{filename_thumb}\"\n else\n begin\n # Check if user wants autotagging\n user_id = meta[\"sakai:pool-content-created-for\"]\n user_file = @s.execute_get @s.url_for(\"/system/me?uid=#{user_id}\")\n unless user_file.code == '200'\n raise \"Failed to get user: #{uid}\"\n end\n user = JSON.parse(user_file.body)\n if user[\"user\"][\"properties\"][\"isAutoTagging\"] != \"false\"\n # Get text from the document\n Docsplit.extract_text filename, :ocr => false\n text_content = IO.read(id + \".txt\")\n terms = extract_terms(text_content)\n tags = \"\"\n terms.each_with_index do |t, i|\n tags += \"- #{t}\\n\"\n terms[i] = \"/tags/#{t}\"\n end\n # Generate tags for document\n @s.execute_post @s.url_for(\"p/#{id}\"), {':operation' => 'tag', 'key' => terms}\n log \"Generate tags for #{id}, #{terms}\"\n admin_id = \"admin\"\n origin_file_name = meta[\"sakai:pooled-content-file-name\"]\n if not terms.nil? and terms.length > 0 and user[\"user\"][\"properties\"][\"sendTagMsg\"] and user[\"user\"][\"properties\"][\"sendTagMsg\"] != \"false\"\n msg_body = \"We have automatically added the following tags for #{origin_file_name}:\\n\\n #{tags}\\n\\nThese tags were created to aid in the discoverability of your content.\\n\\nRegards, \\nThe Sakai Team\"\n @s.execute_post(@s.url_for(\"~#{admin_id}/message.create.html\"), {\n \"sakai:type\" => \"internal\",\n \"sakai:sendstate\" => \"pending\",\n \"sakai:messagebox\" => \"outbox\",\n \"sakai:to\" => \"internal:#{user_id}\",\n \"sakai:from\" => \"#{admin_id}\",\n \"sakai:subject\" => \"We've added some tags to #{origin_file_name}\",\n \"sakai:body\" => msg_body,\n \"_charset_\" => \"utf-8\",\n \"sakai:category\" => \"message\"\n })\n log \"sending message from #{admin_id} user to #{user_id}\"\n end\n end\n rescue Exception => msg\n log \"failed to generate document tags: #{msg}\", :warn\n end\n\n # Generating image previews of the document.\n if only_first_page? extension\n Docsplit.extract_images filename, :size => '1000x', :format => :jpg, :pages => 1\n else\n Docsplit.extract_images filename, :size => '1000x', :format => :jpg\n end\n\n # Skip documents with a page count of 0, just to be sure.\n next if Dir[id + '_*'].size == 0\n\n Dir.mkdir PREV_DIR + \"/#{id}\" unless File.directory? PREV_DIR + \"/#{id}\"\n\n # Moving these previews to another directory: \"PREVS_DIR/filename/index.jpg\".\n Dir[id + '_*'].each_with_index do |preview, index|\n FileUtils.mv \"#{id}_#{index + 1}.jpg\", \"#{PREV_DIR}/#{id}/#{index}.jpg\"\n end\n\n Dir.chdir PREV_DIR + \"/#{id}\"\n page_count = Dir[\"*\"].size\n\n # Upload each preview and create+upload a thumbnail.\n for index in (0..page_count - 1)\n filename_p = \"#{index}.jpg\"\n # Upload the generated preview of this page.\n nbytes, content = File.size(filename_p), nil\n File.open(filename_p, \"rb\") { |f| content = f.read nbytes }\n post_file_to_server id, content, :large, index + 1\n\n # Generate 2 thumbnails and upload them to the server.\n filename_thumb = File.basename(filename_p, '.*') + '.normal.jpg'\n content = resize_and_write_file filename_p, filename_thumb, 700\n post_file_to_server id, content, :normal, index + 1\n\n filename_thumb = File.basename(filename_p, '.*') + '.small.jpg'\n content = resize_and_write_file filename_p, filename_thumb, 180, 225\n post_file_to_server id, content, :small, index + 1\n end\n\n FileUtils.remove_dir PREV_DIR + \"/#{id}\"\n end\n # Pass on the page_count\n @s.execute_post @s.url_for(\"p/#{id}\"), {\"sakai:pagecount\" => page_count, \"sakai:hasPreview\" => \"true\"}\n\n # Change to the documents directory otherwise we won't find the next file.\n Dir.chdir DOCS_DIR\n end\n\n #SAKAI TO PDF\n # We check if mimetype is sakaidoc\n if(mime_type == \"x-sakai/document\")\n if (File.exist?(\"../wkhtmltopdf\"))\n # Go to PDF Dir\n Dir.chdir PDFS_DIR\n\n #delay in secs\n $delay = \"20\"\n\n #filename with extension\n filename_p = id + \".pdf\"\n\n # We parse the structure data to var structure (we do not need the rest)\n structure = JSON.parse meta['structure0']\n\n # Create var and add beginning of code line to run\n line = \"../wkhtmltopdf \"\n\n # Go through structure and add the pagelink for each page id\n structure.each do |page|\n link = \"content#l=\" + page[0] + \"&p=\" + id\n link = @s.url_for(link)\n link = \"'\" + link + \"' \"\n line += link\n end\n\n # Fetch cookie value to get access to all content\n # USERNAME PASSWORD SERVER\n $username = \"admin\"\n auth = \"../auth.sh \" + $username + \" \" + $pw + \" \" + $preview_referer\n cookietoken = `#{auth}`\n\n # Append end of line containing arguments for print css, delay and authentication\n line += filename_p + \" --print-media-type --redirect-delay \" + $delay + \"000 --cookie 'sakai-trusted-authn' \" + cookietoken\n\n # Run the command line (run wkhtmltopdf)\n `#{line}`\n\n # We read the content from the pdf in the PDF directory\n content = open(filename_p, 'rb') { |f| f.read }\n\n # We post it to server through this function\n post_pdf_to_server id, content\n @s.execute_post @s.url_for(\"p/#{id}\"), {\"sakai:processing_failed\" => \"false\"}\n #Change dir\n Dir.chdir DOCS_DIR\n else\n @s.execute_post @s.url_for(\"p/#{id}\"), {\"sakai:processing_failed\" => \"true\"}\n log \"PDF Converter (wkhtmltopdf) not present in directory\"\n log \"Cannot convert Sakai document to PDF\"\n log \"Continuing without conversion\"\n end\n end\n rescue Exception => msg\n # Output a timestamp + the error message whenever an exception is raised\n # and flag this file as failed for processing.\n log \"error generating preview/thumbnail (ID: #{id}): #{msg.inspect}\\n#{msg.backtrace.join(\"\\n\")}\", :warn\n @s.execute_post @s.url_for(\"p/#{id}\"), {\"sakai:processing_failed\" => \"true\"}\n ensure\n # No matter what we flag the file as processed and delete the temp copied file.\n @s.execute_post @s.url_for(\"p/#{id}\"), {\"sakai:needsprocessing\" => \"false\"}\n FileUtils.rm_f DOCS_DIR + \"/#{filename}\"\n end\n end\n\n FileUtils.remove_dir PDFS_DIR\n FileUtils.remove_dir PREV_DIR\n FileUtils.remove_dir DOCS_DIR\nend",
"def run\n start = Time.now\n log \"[0/3] Generating build\"\n generate_build\n\n log \"[1/3] Building\"\n filename = build\n\n log \"[2/3] Parsing\"\n\n @config[:parser].parse(filename)\n log \"[3/3] Complete\"\n\n Time.now - start\n end",
"def set_sequence\n if @file\n @job.sequence = \"\"\n @job.sequence << @file\n end\n @file = nil\n end",
"def call\n files.each do |file|\n parts = parse_filename(file)\n build_song(parts)\n end \n end",
"def run\n executor.run\n @files\n end",
"def __main__(args)\n PLIP::Job.new(__parse__(args[1..-1])).exec\nend",
"def build!\n test_git!\n\n file_list = Dir.glob(\"#{@source}*\").sort # Pull the file list before creating the target directory\n\n setup_target\n\n add_runner\n\n file_list.each do |infile_name|\n rewrite_animation_frame infile_name\n create_commit infile_name\n end\n end",
"def build\n lines = []\n required = []\n\n while filename = next_filename\n lines, required = _build_one(filename, lines, required)\n end\n\n return join(lines)\n end",
"def generate_input_file\n\t\t\t#FileUtils.touch(\"#@run_name.mat\")\n\t\t\t#cronos.new_file\n\t\t\t#eputs \"Make sure you save the file as #@run_name.mat... overwrite the existing empty place holder. When you have saved the file press enter.\"\n\t\t\tif @duplicate_id\n\t\t\t\told = @runner.run_list[@duplicate_id]\n\t\t\t\tsystem \"cp #{old.directory}/#{old.run_name}.mat #@directory/#@run_name.mat\"\n\t\t\t\tload\n\t\t\telsif @restart_id\n\t\t\t\told = @runner.run_list[@restart_id]\n\t\t\t\tsystem \"cp #{old.directory}/#{old.run_name}_resultat.mat #@directory/#@run_name.mat\"\n\t\t\t\tload\n\t\t\telse\n\t\t\t\tsz = Terminal.terminal_size[1]\n\t\t\t\teputs((str = \"When you have created the file press enter. Don't save it (CodeRunner will automatically save it in the right place. You can edit parameters later as well. CodeRunner will not submit the file... submit it manually using a batch or interactive run.\"; [\"-\"*sz, str, \"-\"*sz]))\n\t\t\t\tcronos.puts(\"zuicreate\")\n\t\t\t\tSTDIN.gets\n\t\t\tend\n\t\t\tcronos.puts(\"param.gene.origine = '#@directory/#@run_name.mat'\")\n\t\t\tcronos.puts(\"param.gene.file = '#@directory/#{@run_name}_resultat.mat'\")\n\t\t\tcronos.puts(\"param.gene.rapsauve = '#@directory/#{@run_name}_resultat'\")\n\t\t\tcronos.puts(\"param.edit.currentfile= '#@directory/#@run_name.mat'\")\n\t\t\tcronos.puts(\"param.from.creation.com = '#@comment'\")\n\t\t\tcronos.puts(\"zuisavedata('force')\")\n\t\t\t#cronos.eval(\"zuicreate\")\n\t\t\trefresh_gui\n\t\t\t\n\t\tend",
"def main_to_worker\n \"main_to_worker\" # the pipes are created in the current working directory\nend",
"def initialize(*)\n @id = SecureRandom.uuid\n @submitted_at = Time.now\n mkdir_p dir\n yield if block_given?\n save\n rescue Errno::ENOSPC\n raise SystemError, 'Not enough disk space to start a new job'\n rescue Errno::EACCES\n raise SystemError, \"Permission denied to write to #{DOTDIR}\"\n rescue => e\n rm_rf dir\n raise e\n end",
"def submit\n configure_concern\n submit_job\n end",
"def define \n desc @description\n task @name => Array(deps) do\n unless Dir.exist?(@outdir)\n Dir.mkdir(@outdir)\n end\n make_file_list\n @file_list.each do |target|\n js = target.execute\n target_file = File.join(@outdir,File.basename(target.file))\n File.open(target_file, 'w') { |f| f.write(js) }\n end\n end\n\n self\n end",
"def run fastq_directory, dependency = nil, output_directory = File.join(fastq_directory, \"fastqc\"), fastq_pattern = \"*.fastq.gz\"\n\n system(\"mkdir -p #{output_directory}\")\n\n fastq_files = Dir.glob(File.expand_path(File.join(fastq_directory, fastq_pattern)))\n output_directory = File.expand_path(output_directory)\n puts \"Analyzing #{fastq_files.size} files with Fastqc\"\n return unless fastq_files.size > 0\n\n database = []\n fastq_files.each do |fastq_file|\n database << {\"input\" => fastq_file, \"output\" => output_directory, \"program\" => fastqc_path}\n end\n\n db_directory = File.join(output_directory, \"fastqc_db\")\n system(\"mkdir -p #{db_directory}\")\n\n distributer = SimpleDistribute::Distributer.new(db_directory)\n\n worker_task_name = distributer.submit(WORKER_SCRIPT, {:prefix => \"fastqc\", :database => database, :dependency => dependency})\n\n combiner_task_name = distributer.submit(COMBINER_SCRIPT, {:prefix => \"fastqc\", :dependency => worker_task_name, :args => output_directory})\n\n wait_on_task = combiner_task_name\n\n if self.data[\"projects\"]\n puts \"Projects found!! - distributing to #{self.data[\"projects\"].size} locations\"\n distribute_database = []\n self.data[\"projects\"].each do |out|\n distribute_database << {\"input\" => output_directory, \"output\" => out, \"recursive\" => true}\n end\n\n distribute_task_name = distributer.submit(DISTRIBUTE_SCRIPT, {:prefix => \"fastqc\", :dependency => combiner_task_name, :database => distribute_database})\n wait_on_task = distribute_task_name\n else\n puts \"NO projects found!! - NOT DISTRIBUTING DATA\"\n end\n\n flowcell_id = \"A_FLOWCELL\"\n if self.data[\"flowcell_id\"]\n flowcell_id = self.data[\"flowcell_id\"].strip\n end\n\n email_task_name = distributer.submit(EMAIL_SCRIPT, {:prefix => \"fastqc\", :dependency => wait_on_task, :args => \"FASTQC #{flowcell_id}\"})\n email_task_name\n end",
"def find_jobs(path = @path)\n fail 'Pattern path is set to nil, pass in a valid file (.atp or .atp.gz) or a valid directory' if path.nil?\n @path = Pathname.new(path)\n fail 'Pattern path does not exist, pass in a valid file (.atp or .atp.gz) or a valid directory' unless @path.exist?\n @path = @path.expand_path\n # Set the reference directory for pattern sub-dir mirroring\n set_reference_directory\n Origen.profile 'Linux pattern compiler finds patterns' do\n # Check if the path is a file or a directory\n if @path.directory?\n # Get all of the patterns inside this dir or inside this directory recursively\n process_directory(@path, @files, @user_options[:recursive])\n elsif @path.file? # Found a file so no searching is necessary\n process_file(@path, @files)\n else # Didn't find a directory or a file so user must want a search for this arg string * NOT SUPPORTED YET\n fail 'Error: Did not find a file or directory to compile, exiting...'\n end\n end\n\n Origen.profile 'Linux pattern compiler creates jobs' do\n @files.each do |f|\n rel_dir = Pathname.new(\"#{f.dirname.to_s[@user_options[:reference_directory].to_s.size..-1]}\")\n if @job_options[:output_directory].nil?\n # job output dir not specified, create a unique (hash) based on path/compiler_name\n s = Digest::MD5.new\n s << @user_options[:reference_directory].to_s\n s << @id.to_s\n out = \"#{@user_options[:reference_directory]}/job_#{@id}_#{s.to_s[0..6].upcase}#{rel_dir}\"\n output_dir = Pathname.new(out)\n else\n output_dir = Pathname.new(\"#{@job_options[:output_directory]}#{rel_dir}\")\n end\n unless output_dir.directory?\n puts \"Output directory #{output_dir} for pattern #{f.basename} does not exist, creating it...\"\n FileUtils.mkdir_p(output_dir)\n end\n current_job_options = @job_options.merge(@compiler_options_with_args)\n current_job_options[:output_directory] = output_dir\n @jobs << Job.new(f, current_job_options, @compiler_options)\n current_job_options = {}\n end\n end\n @files = []\n if empty?\n empty_msg\n else\n inspect_jobs\n end\n end",
"def run(exe:,\n\n forward_reads: nil,\n reverse_reads: nil,\n single_reads: nil,\n\n out_dir: nil,\n out_prefix: nil,\n\n num_threads: 1,\n preset: nil)\n\n cmd = \"#{exe} \" \\\n \"--num-cpu-threads #{num_threads} \" \\\n \"--out-dir #{out_dir} \" \\\n \"-1 #{forward_reads} \" \\\n \"-2 #{reverse_reads} \" \\\n \"-r #{single_reads}\"\n\n # Add the optional opts\n\n if out_prefix\n cmd += \" --out-prefix #{out_prefix}\"\n end\n\n # For preset of 'default' or anything else, just use the megahit default.\n if preset == \"meta-sensitive\"\n cmd += \" --presets meta-sensitive\"\n elsif preset == \"meta-large\"\n cmd += \" --presets meta-large\"\n elsif preset == \"fast\"\n cmd += \" --k-list 21\"\n end\n\n # Run the initial assembly\n proc_status = Process.run_it cmd\n\n # We check if the assembly finished successfully.\n unless proc_status.exitstatus.zero?\n # The assembly failed D:\n # Try it again with continue.\n cmd += \" --continue\"\n\n # Since megahit has a checkpoint continue mode, if we can save the assembly by trying once more with --continue, it will save time.\n proc_status = Process.run_it cmd\n end\n\n # Now we check if the checkpoint assembly failed as well\n unless proc_status.exitstatus.zero?\n # First, we want to dump the megahit opts and log files into the log for the coutinho_assembly program.\n log_diagnostic_files out_dir, out_prefix\n\n # Since it failed, we want to remove the output directory, because the retry wrapper function will always fail if you try and use the same assembly directory name.\n FileUtils.rm_r out_dir if Dir.exist? out_dir\n\n # Now that we've got the logs and removed the outdir, the runner wrapper method can cleanly rerun this function.\n end\n\n outputs = {\n final_contigs: File.join(out_dir, \"#{out_prefix}.contigs.fa\")\n }\n\n # Return whichever proc_status was the last one to be set, either original assembly or the continued assembly.\n CoutinhoAssembly::RunnerExit.new proc_status, proc_status.exitstatus, outputs\n end",
"def parse_rr_job(file_path)\n result = Result.create(:main)\n file = open_file(file_path)\n config = JSON.parse(file.read)\n unless config['Crawling']\n puts \"'Crawling' section not found into rr-job.\"\n return\n end\n config['Crawling'].each do |section|\n parse_section(section, result)\n end\n result\n end",
"def build_aab\n validate\n\n prepare_bundle_folder_struct\n \n extract_protobuf_data_to_bundle_prep_dir\n\n extract_legacy_data_to_bundle_prep_dir\n \n build_base_zip \n \n create_config_file\n\n #Finally build AAB archive from prepared base.zip\n bundle = File.join(@intermediate,'bundle.aab')\n args = [ '-jar', @bundletool, 'build-bundle', \"--modules=#{@base_zip}\", \"--output=#{bundle}\" , \"--config=#{@config_file}\"]\n Jake.run( @javabin, args )\n\n bundle\n end",
"def initialize files=nil\n self.class.load_files files.to_a.concat(DEFAULT_TASK_FILES)\n end",
"def later(pathname)\n if klass = job_class\n logger.measure_info \"Enqueued: #{name}, Job class: #{job_class_name}\" do\n job = klass.new(properties)\n upload_file(job, pathname)\n job.save!\n job\n end\n else\n raise(ArgumentError, \"Cannot instantiate a class for: #{job_class_name.inspect}\")\n end\n end",
"def create_jenkins_job(name, xml_file)\n create_url = \"http://#{Pkg::Config.jenkins_build_host}/createItem?name=#{name}\"\n form_args = [\"-H\", '\"Content-Type: application/xml\"', \"--data-binary\", \"@#{xml_file}\"]\n curl_form_data(create_url, form_args)\n \"http://#{Pkg::Config.jenkins_build_host}/job/#{name}\"\nend",
"def start\n setup_files\n create_report\nend",
"def initialize(*args)\n super\n\n self.targets.each do |tgt|\n tgt_f = application.define_task(Rake::FileTask, File.join(self.to_s, tgt))\n tgt_f.comment = \"Build #{tgt} in #{self}\"\n tgt_f.enhance([self])\n end\n end",
"def dataflow\n arg = args.first\n basename = File.basename(arg.to_s, '.rb')\n\n case\n when settings[:run] then settings[:run]\n when arg && File.exist?(arg) then basename\n else arg\n end\n end",
"def main\n job1 = OpenGov::Model::Job.new(\"My_Job_1\")\n job2 = OpenGov::Model::Job.new(\"My_Job_2\")\n job3 = OpenGov::Model::Job.new(\"My_Job_3\") \n\n job1.add_dependency(job2, job3)\n job2.add_dependency(job3)\n\n workflow = OpenGov::Model::WorkFlow.new(\"My_Workflow\")\n workflow.register(job1, job2, job3)\n\n workflow.execute\nend",
"def run\n parse do\n self.current_sheet.processing!\n ss = Roo::Spreadsheet.open(self.new_file_path)\n current_uploader = Uploader.find(self.uploader_id)\n total_count = ss.last_row - 1\n current_uploader.update_total_row(total_count)\n case current_uploader.category\n when Uploader::TYPES[:default]\n upload_indicator(ss, current_uploader)\n when Uploader::TYPES[:indicator_2_0]\n upload_health_care_indicators(ss, current_uploader)\n when Uploader::TYPES[:resources]\n upload_resources(ss, current_uploader)\n when Uploader::TYPES[:indicator_map_color]\n upload_indicators_map_color(ss, current_uploader)\n else\n upload_description_template(ss, current_uploader)\n end\n end\n self.current_sheet.completed!\n end",
"def perform\n params_dump\n\n ### KEEPING FORMER ROUNDS\n #@commands << \"cp #{@outfile} #{@outfile}.former\" \n # Export variable needed for HHSuite\n #@commands << \"export HHLIB=#{HHLIB} \"\n #@commands << \"export PATH=$PATH:#{HHSUITE}\" \n \n # cmd for blast run\n @commands << \"source #{SETENV}\" \n @commands << \"echo 'Starting BLAST search' &> #{job.statuslog_path}\"\n @commands << \"#{CSBLAST}/bin/csblast -i #{@infile} -j #{@rounds} -h #{@e_thresh} -D #{CSBLAST}/data/K4000.crf #{@alignment} --blast-path #{BLAST}/bin -e #{@expect} -F #{@filter} -G #{@gapopen} -E #{@gapext} -v #{@descriptions} -b #{@alignments} -T T -o #{@outfile} -d \\\"#{@db_path}\\\" -I T -a 1 #{@other_advanced} >>#{job.statuslog_path}\"\n \n @commands << \"echo 'Finished BLAST search' >> #{job.statuslog_path}\"\n # run perl script to fix blast errors. TODO: Find out what script does \n @commands << \"echo 'Fixing BLAST errors' >> #{job.statuslog_path}\" \n @commands << \"#{UTILS}/fix_blast_errors.pl -i #{@outfile} &>#{@basename}.log_fix_errors\"\n # run perl script to visualize blast results. TODO: Find out what script does\n @commands << \"echo 'Visualizing BLAST Output' >> #{job.statuslog_path}\" \n @commands << \"#{UTILS}/blastviz.pl #{@outfile} #{job.jobid} #{job.job_dir} #{job.url_for_job_dir_abs} &> #{@basename}.blastvizlog\";\n # run perl script to process blast history. TODO: Find out what script does\n @commands << \"echo 'Generating Blast Histograms... ' >> #{job.statuslog_path}\"\n @commands << \"#{UTILS}/blasthisto.pl #{@outfile} #{job.jobid} #{job.job_dir} &> #{@basename}.blasthistolog\";\n \n # run perl script to create alignment\n @commands << \"echo 'Processing Alignments... ' >> #{job.statuslog_path}\"\n @commands << \"#{UTILS}/alignhits_html.pl #{@outfile} #{@basename}.align -fas -no_link -e #{@expect}\"\n # run perl script to reformat alignment TODO: Find out what script does\n @commands << \"reformat.pl fas fas #{@basename}.align #{@basename}.ralign -M first -r\"\n # TODO: Find out what script does\n @commands << \"if [ -s #{@basename}.ralign ]; then hhfilter -i #{@basename}.ralign -o #{@basename}.ralign -diff 50; fi\"\n # TODO: Find out what script does\n @commands << \"#{RUBY_UTILS}/parse_csiblast.rb -i #{@basename}.csblast -o #{@basename}.csblast\"\n # Generate Jalview Output from alignment data\n @commands << \"echo 'Creating Jalview Input... ' >> #{job.statuslog_path}\"\n @commands << \"#{RUBY_UTILS}/parse_jalview.rb -i #{@basename}.ralign -o #{@basename}.j.align\" \n # TODO: Find out what script does\n @commands << \"reformat.pl fas fas #{@basename}.j.align #{@basename}.j.align -r\"\n\n\n @commands << \"source #{UNSETENV}\" \n\n logger.debug \"Commands:\\n\"+@commands.join(\"\\n\")\n # Submit generated cmd list to queue\n queue.submit(@commands)\n\n end",
"def build(method, *args, &block)\n job = rocket_job_class.new(\n klass: name,\n perform_method: method.to_sym,\n arguments: args\n )\n @rocket_job_defaults.call(job) if @rocket_job_defaults\n block.call(job) if block\n job\n end",
"def make_json_limit_task(channel)\n samples_map = Hash['mmt' => 'data_DoubleMu', \n 'eet' => 'data_DoubleElectron', \n 'emt' => 'data_MuEG',\n 'llt' => 'data_DoubleMu',\n ]\n carddir = $carddir #makes a copy so that if $cardir changes this does not\n json_stamp = \"#{$carddir}/#{channel}/.limit_harvested\"\n file json_stamp => \"#{$carddir}/#{channel}/.limits_computed\" do |t|\n sh \"harvest_limits.py #{carddir}/#{channel}\"\n sh \"touch #{t.name}\"\n sh \"add_tag_to_json.py #{carddir}/#{channel}/*.json -l jobid -t #{$jobid}\"\n sh \"add_tag_to_json.py #{carddir}/#{channel}/*.json -l lumi -t #{get_lumi(samples_map[channel], $jobid)}\"\n end\n return json_stamp\nend"
] | [
"0.6498386",
"0.6254218",
"0.6228784",
"0.61883307",
"0.6140876",
"0.6118147",
"0.60959375",
"0.60785794",
"0.6068447",
"0.59853154",
"0.5975939",
"0.59707206",
"0.5914611",
"0.59037477",
"0.58763385",
"0.57887536",
"0.576253",
"0.5754528",
"0.574257",
"0.57199246",
"0.57033736",
"0.5669199",
"0.5654023",
"0.5653434",
"0.5650012",
"0.5649285",
"0.5644604",
"0.5641743",
"0.5640627",
"0.56386006",
"0.56301713",
"0.5606289",
"0.55926275",
"0.55797476",
"0.55780053",
"0.55493903",
"0.5538222",
"0.5534569",
"0.5533786",
"0.5524151",
"0.55175656",
"0.5516877",
"0.5508035",
"0.55017745",
"0.54979664",
"0.54787964",
"0.54676235",
"0.54654396",
"0.54631406",
"0.5458255",
"0.5448006",
"0.5444203",
"0.5440194",
"0.5404835",
"0.53901094",
"0.5384514",
"0.53837097",
"0.5372652",
"0.5369519",
"0.5361632",
"0.5360984",
"0.5356122",
"0.5355181",
"0.535112",
"0.53444517",
"0.5344007",
"0.5335749",
"0.5335359",
"0.5329921",
"0.53248245",
"0.5320808",
"0.53143525",
"0.53092843",
"0.5306869",
"0.5305835",
"0.5305456",
"0.5303673",
"0.52995425",
"0.52995116",
"0.52962625",
"0.5290425",
"0.5290237",
"0.52777463",
"0.52748185",
"0.5272195",
"0.52719223",
"0.5259269",
"0.52583724",
"0.5254",
"0.5250744",
"0.5248799",
"0.5242047",
"0.5240127",
"0.5239963",
"0.5236283",
"0.523547",
"0.523124",
"0.52271706",
"0.52268845",
"0.5219141",
"0.52148414"
] | 0.0 | -1 |
Process argument, return register code if arg is like R0,R1 or AX,FLAG. Else if arg is a defined label, then returns it's address. If it is a integer, just read and parse to the caller. Otherwise it must be a undefined lebel, feel free to return nil. process_argument("123h") porcess_argument("R0") process_argument("start") | def process_argument(arg)
return REG[arg] if REG.has_key?(arg)
return EREG[arg] if EREG.has_key?(arg)
return SREG[arg] if SREG.has_key?(arg)
return @labels[arg] if @labels.has_key?(arg)
return arg.to_i(16) if arg =~ /^\d*[Hh]$/
return arg.to_i(10) if arg =~ /^\d*[Dd]+$/
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_argument(arg)\n case arg\n when *@mapping[:http_request] then set_mode(:http_request)\n when *@mapping[:source] then set_mode(:source)\n when *@mapping[:http_status] then set_mode(:http_status)\n when *@mapping[:timestamp] then set_mode(:timestamp) \n when *@mapping[:index] then create_argument_entry(:index)\n else\n raise_invalid_parameter(arg)\n end\n nil\n end",
"def process_argument(arg)\n if arg\n arg == '--help' ? help : get_ips(arg)\n else\n get_ips\n end\n exit(0)\nend",
"def process_argument(arg)\n # no additional paramaeters\n raise_invalid_parameter(arg)\n nil\n end",
"def process_base_argument(arg)\n case arg\n when *@mapping[:help] then check_and_set_helpvalue\n when *@mapping[:version] then @parameters[:version] = true\n when *@mapping[:file] then create_argument_entry(:file) \n when /-[a-z]|--[a-z]+/ then process_argument(arg)\n else\n check_and_set_argument(@unflagged_arguments.shift, arg)\n end\n nil\n end",
"def process_argument(arg)\n case arg\n when *@mapping[:all] then create_argument_entry(:all)\n when *@mapping[:coord] then create_two_argument_entry(:coord)\n when *@mapping[:delta] then create_two_argument_entry(:delta)\n when *@mapping[:extreme] then @parameters[:extreme] = true\n when *@mapping[:index] then create_argument_entry(:index)\n when *@mapping[:meta] then @parameters[:meta] = true\n when *@mapping[:option] then create_argument_entry(:option)\n when *@mapping[:range] then create_two_argument_entry(:range)\n when *@mapping[:section] then create_two_argument_entry(:section)\n when *@mapping[:time] then create_two_argument_entry(:time)\n else\n raise_invalid_parameter(arg)\n end\n end",
"def _rl_arg_dispatch(cxt, c)\r\n key = c\r\n\r\n # If we see a key bound to `universal-argument' after seeing digits,\r\n # it ends the argument but is otherwise ignored.\r\n if (@_rl_keymap[c] == :rl_universal_argument)\r\n if ((cxt & NUM_SAWDIGITS) == 0)\r\n @rl_numeric_arg *= 4\r\n return 1\r\n elsif (rl_isstate(RL_STATE_CALLBACK))\r\n @_rl_argcxt |= NUM_READONE\r\n return 0 # XXX\r\n else\r\n rl_setstate(RL_STATE_MOREINPUT)\r\n key = rl_read_key()\r\n rl_unsetstate(RL_STATE_MOREINPUT)\r\n rl_restore_prompt()\r\n rl_clear_message()\r\n rl_unsetstate(RL_STATE_NUMERICARG)\r\n if key.is_a?(Integer) && key < 0\r\n return -1\r\n end\r\n return (_rl_dispatch(key, @_rl_keymap))\r\n end\r\n end\r\n\r\n #c = (c[0].ord & ~0x80).chr\r\n r = c[1,1]\r\n if (r>='0' && r<='9')\r\n r = r.to_i\r\n @rl_numeric_arg = @rl_explicit_arg ? (@rl_numeric_arg * 10) + r : r\r\n @rl_explicit_arg = 1\r\n @_rl_argcxt |= NUM_SAWDIGITS\r\n elsif (c == '-' && !@rl_explicit_arg)\r\n @rl_numeric_arg = 1\r\n @_rl_argcxt |= NUM_SAWMINUS\r\n @rl_arg_sign = -1\r\n else\r\n # Make M-- command equivalent to M--1 command.\r\n if ((@_rl_argcxt & NUM_SAWMINUS)!=0 && @rl_numeric_arg == 1 && !@rl_explicit_arg)\r\n @rl_explicit_arg = 1\r\n end\r\n rl_restore_prompt()\r\n rl_clear_message()\r\n rl_unsetstate(RL_STATE_NUMERICARG)\r\n\r\n r = _rl_dispatch(key, @_rl_keymap)\r\n if (rl_isstate(RL_STATE_CALLBACK))\r\n # At worst, this will cause an extra redisplay. Otherwise,\r\n # we have to wait until the next character comes in.\r\n if (!@rl_done)\r\n send(@rl_redisplay_function)\r\n end\r\n r = 0\r\n end\r\n return r\r\n end\r\n 1\r\n end",
"def process_argument(arg)\n case arg\n when *@mapping[:aggregate] then @parameters[:aggregate] = true\n when *@mapping[:date] then create_argument_entry(:date)\n when *@mapping[:default] then create_defaults\n when *@mapping[:json] then @parameters[:json] = true\n when *@mapping[:locale] then create_argument_entry(:locale)\n when *@mapping[:offset] then create_argument_entry(:offset)\n when *@mapping[:period] then create_argument_entry(:period)\n when *@mapping[:save] then create_argument_entry(:save)\n else\n raise_invalid_parameter(arg)\n end\n nil\n end",
"def parse_arg(arg) # :nodoc:\n pattern or return nil, [arg]\n unless m = pattern.match(arg)\n yield(InvalidArgument, arg)\n return arg, []\n end\n if String === m\n m = [s = m]\n else\n m = m.to_a\n s = m[0]\n return nil, m unless String === s\n end\n raise InvalidArgument, arg unless arg.rindex(s, 0)\n return nil, m if s.length == arg.length\n yield(InvalidArgument, arg) # didn't match whole arg\n return arg[s.length..-1], m\n end",
"def _process(parameter, args, name)\n p = parameter\n value1 = args[name] # The uncast value, e.g. :AB for a segment.\n if value2 = p.match(value1) # See if it can be cast (e.g. to Segment[:AB]).\n return value2 # If so, we return the cast value.\n else\n throw :fail, [name, value1]\n end\n end",
"def rl_digit_argument(ignore, key)\r\n _rl_arg_init()\r\n if (rl_isstate(RL_STATE_CALLBACK))\r\n _rl_arg_dispatch(@_rl_argcxt, key)\r\n rl_message(\"(arg: #{@rl_arg_sign * @rl_numeric_arg}) \")\r\n return 0\r\n else\r\n rl_execute_next(key)\r\n return (rl_digit_loop())\r\n end\r\n end",
"def argue(argument)\n return argument\nend",
"def get_argument_value(arg, required, fallback)\n if @args.has_key?(arg)\n @args[arg]\n else\n raise ArgumentError, \"Required argument #{arg} is blank\" if required\n fallback\n end\nend",
"def _analyze(arg)\n is_long = false\n is_short = false\n name = nil\n\n if arg[0..1] == '--'\n is_long = true\n name = arg[2..-1]\n elsif arg[0] == '-'\n is_short = true\n name = arg[1..-1]\n end\n\n # arg is not a long/short option, add to arguments values\n unless is_long || is_short\n @argument_values.push arg\n return true\n end\n\n unless name.nil?\n # get the name of the option, short options use the first character\n option_name = if is_short\n name[0]\n else\n name\n end\n\n option, matched = @options.get_with_alias option_name\n\n # no option by this name in options\n return nil if option.nil?\n\n # see if the type if right, short or long\n if matched.is_long && !is_long\n return nil\n elsif matched.is_short && !is_short\n return nil\n end\n\n if is_long\n if option.is_value\n # is_value needs a next argument for its value\n return nil if _peek_next.nil?\n\n @matched_options[option.name] = _peek_next\n _skip_next\n else\n option_value! option\n end\n end\n\n if is_short\n if name.size == 1 && option.is_value\n # is_value needs a next argument for its value\n return nil if _peek_next.nil?\n\n @matched_options[option.name] = _peek_next\n _skip_next\n else\n # for every character (short option) increment the option value\n name.split('').each do |n|\n short_option = @options.get n\n return nil if short_option.nil?\n\n option_value! short_option\n end\n end\n end\n end\n\n true\n end",
"def argument(idx)\n case idx\n when 0 then registers['rdi']\n when 1 then registers['rsi']\n when 2 then registers['rdx']\n when 3 then registers['rcx']\n when 4 then registers['r8']\n when 5 then registers['r9']\n end\n end",
"def resolve(arg)\n return true unless @label\n\n @mod ? @arg = arg.send(*@mod) : @arg = arg\n raise OperandError, 'Invalid argument' unless validate\n\n @ready = true\n end",
"def PO110=(arg)",
"def extract_command_line_argument(argument_name, default_value: nil)\n argument_name_index = ARGV.find_index(argument_name)\n argument_value = ARGV[argument_name_index + 1] if argument_name_index && argument_name_index < (ARGV.length - 1)\n if (argument_value)\n argument_value\n elsif default_value\n default_value\n else\n raise \"Cannot find argument '#{argument_name}'\" if argument_name_index.nil? || argument_name_index < 0\n raise \"Cannot find argument value for '#{argument_name}'\"\n end\nend",
"def argue(argument)\n argument\nend",
"def build_operand(arg1)\n if (arg1.is_a?(AS::Parser::ReferenceArgNode))\n argr = simplify_reference(arg1.argument)\n arg = argr.argument\n if (arg.is_a?(AS::Parser::RegisterArgNode))\n @i = 0\n @pre_post_index = 1\n @w = 0\n @rn = reg_ref(arg)\n @operand = 0\n \n if (argr.op and argr.right.is_a?(AS::Parser::NumLiteralArgNode))\n val = argr.right.value\n if (val < 0)\n @add_offset = 0\n val *= -1\n else\n @add_offset = 1\n end\n if (val.abs > 4095)\n raise AS::AssemblyError.new('reference offset too large/small (max 4095)', argr.right)\n end\n @operand = val\n elsif (argr.op)\n raise AS::AssemblyError.new('reference offset must be an integer literal', argr.right)\n end\n else\n raise AS::AssemblyError.new(AS::ERRSTR_INVALID_ARG, arg)\n end\n elsif (arg1.is_a?(AS::Parser::LabelEquivAddrArgNode) or arg1.is_a?(AS::Parser::NumEquivAddrArgNode))\n @i = 0\n @pre_post_index = 1\n @w = 0\n @rn = 15 # pc\n @operand = 0\n @use_addrtable_reloc = true\n @addrtable_reloc_target = arg1\n else\n raise AS::AssemblyError.new(AS::ERRSTR_INVALID_ARG, arg1)\n end\n end",
"def process_args(exp)\n raise if @want_expression\n\n args = []\n default_values = nil\n\n loop do\n arg = exp.shift\n break if arg.nil?\n if arg.is_a?(Symbol)\n args << arg\n else\n raise unless exp.empty?\n default_values = arg\n end\n end\n\n args.each do |arg|\n arg = arg.to_s\n if arg[0,1] == '*'\n raise if @argument_splat\n @argument_splat = @model.encode_local_variable(arg[1..-1])\n # argument_splat is not an argument in the function's argument list\n @local_variables.add(@argument_splat) \n else\n v = @model.encode_local_variable(arg)\n @arguments_no_splat << v \n @local_variables.add(v)\n @argument_variables.add(v)\n end\n end\n\n # that's not the correct arity, but we decrease it by one for each\n # optional argument.\n min_arity = @arguments_no_splat.size\n max_arity = @arguments_no_splat.size\n\n str = \"\"\n\n #\n # Generate code for the default values of arguments. We check\n # whether a argument has been assigned a value, if not (== null or == undefined), \n # then we assign the default value.\n #\n # NOTE: A check to ==null also returns true if the argument is undefined.\n #\n if default_values\n raise unless default_values[0] == :block\n default_values[1..-1].each do |dv|\n min_arity -= 1\n raise unless dv[0] == :lasgn\n raise unless dv.size == 3\n arg = @model.encode_local_variable(dv[1])\n @local_variables.add(arg)\n @argument_variables.add(arg)\n value = dv[2]\n\n str << \"if(#{arg}==null)\"\n str << \"#{arg}=\"\n str << want_expression do process(value) end\n str << sep()\n end\n end\n\n # now as we know the min_arity, we prepend an arity check before the\n # code generated above.\n str2 = \"\"\n\n if @argument_splat\n # max_arity == infinity => no check\n\n if min_arity == 0\n # min_arity == infinity as well => we need no check\n else\n # +1 because we have a block argument anyway.\n str2 << \"if(arguments.length<#{min_arity+1})#{throw_argument_error(min_arity)}#{sep()}\"\n end\n else\n if min_arity == 0\n # can't be less than 0 arguments anyway! => no check\n str2 << \"if(arguments.length>#{max_arity+1})#{throw_argument_error(max_arity)}#{sep()}\"\n else\n if min_arity == max_arity\n str2 << \"if(arguments.length!=#{min_arity+1})#{throw_argument_error(min_arity)}#{sep()}\"\n else\n str2 << \"if(arguments.length<#{min_arity+1})#{throw_argument_error(min_arity)}#{sep()}\"\n str2 << \"if(arguments.length>#{max_arity+1})#{throw_argument_error(max_arity)}#{sep()}\"\n end\n end\n end\n\n # NoArgumentArityChecks disable argument arity checks\n if $RUBYJS__OPTS.include?('NoArgumentArityChecks')\n else\n # prepend\n str = str2 + str\n end\n\n if @argument_splat\n # construct the code to initialize the splat argument. \n # unluckily the arguments object is not an array, instead it's a\n # special object that has only the length() and [] methods. There\n # is no way to convert it to an array, except looping over each\n # value and pushing the value into a new array.\n # FIXME: variable \"i\"\n str << \"#{@argument_splat}=[]#{sep()}\"\n @local_variables_need_no_initialization.add(@argument_splat)\n with_temporary_variable do |i|\n @local_variables_need_no_initialization.add(i)\n str << \"for(#{i}=#{@arguments_no_splat.size+1};#{i}<arguments.length;#{i}++)#{@argument_splat}.push(arguments[#{i}])#{sep()}\"\n end\n end\n \n return str \n end",
"def input_to_index(arg)\n if !!(arg =~ /\\A[-+]?[0-9]+\\z/) || arg == 0\n arg = arg.to_i\n if arg > 0\n arg = arg - 1\n else\n arg\n end\n else\n arg = -1\n end\nend",
"def arguments\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 66 )\n return_value = ArgumentsReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n char_literal318 = nil\n char_literal320 = nil\n char_literal322 = nil\n char_literal323 = nil\n argument319 = nil\n argument321 = nil\n\n tree_for_char_literal318 = nil\n tree_for_char_literal320 = nil\n tree_for_char_literal322 = nil\n tree_for_char_literal323 = nil\n stream_RPAREN = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token RPAREN\" )\n stream_COMMA = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token COMMA\" )\n stream_LPAREN = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token LPAREN\" )\n stream_argument = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule argument\" )\n begin\n # at line 690:5: '(' ( argument ( ',' argument )* ( ',' )? )? ')'\n char_literal318 = match( LPAREN, TOKENS_FOLLOWING_LPAREN_IN_arguments_4895 )\n if @state.backtracking == 0\n stream_LPAREN.add( char_literal318 )\n end\n # at line 690:10: ( argument ( ',' argument )* ( ',' )? )?\n alt_78 = 2\n look_78_0 = @input.peek( 1 )\n\n if ( look_78_0 == GENERAL || look_78_0 == GET || look_78_0 == ARROW || look_78_0 == REGEX || look_78_0 == LBRACE || look_78_0 == LBRACK || look_78_0 == SET || look_78_0 == DDOC || look_78_0 == LPAREN || look_78_0 == DELETE || look_78_0.between?( DGENERAL, MACRO ) || look_78_0 == THIS || look_78_0 == TRUE || look_78_0.between?( TYPEOF, NEW ) || look_78_0 == EACH || look_78_0 == UNDEFINED || look_78_0 == NULL || look_78_0 == FALSE || look_78_0 == VOID || look_78_0 == FUNCTION || look_78_0.between?( POUND, DOC ) || look_78_0.between?( T__148, T__150 ) )\n alt_78 = 1\n elsif ( look_78_0 == IF || look_78_0 == IN || look_78_0.between?( BREAK, RETURN ) || look_78_0 == CASE || look_78_0 == CATCH || look_78_0.between?( CONTINUE, LET ) || look_78_0 == DEFAULT || look_78_0 == SWITCH || look_78_0 == DO || look_78_0 == THROW || look_78_0 == TRY || look_78_0 == ELSE || look_78_0 == UNLESS || look_78_0 == UNTIL || look_78_0.between?( VAR, FINALLY ) || look_78_0 == FOR || look_78_0 == WHILE || look_78_0 == WITH || look_78_0 == YIELD ) and ( ( property_definition? ) )\n alt_78 = 1\n elsif ( look_78_0 == AMP || look_78_0 == INCR || look_78_0 == IS_DEFINED || look_78_0 == DECR || look_78_0 == MINUS || look_78_0 == TILDE || look_78_0 == NOT || look_78_0 == PLUS || look_78_0 == IS_UNDEFINED )\n alt_78 = 1\n end\n case alt_78\n when 1\n # at line 690:12: argument ( ',' argument )* ( ',' )?\n @state.following.push( TOKENS_FOLLOWING_argument_IN_arguments_4900 )\n argument319 = argument\n @state.following.pop\n if @state.backtracking == 0\n stream_argument.add( argument319.tree )\n end\n # at line 690:22: ( ',' argument )*\n while true # decision 76\n alt_76 = 2\n look_76_0 = @input.peek( 1 )\n\n if ( look_76_0 == COMMA )\n look_76_1 = @input.peek( 2 )\n\n if ( look_76_1.between?( AMP, GENERAL ) || look_76_1 == GET || look_76_1 == ARROW || look_76_1 == IF || look_76_1.between?( IN, REGEX ) || look_76_1 == INCR || look_76_1.between?( BREAK, RETURN ) || look_76_1 == IS_DEFINED || look_76_1 == CASE || look_76_1 == CATCH || look_76_1 == LBRACE || look_76_1 == LBRACK || look_76_1.between?( SET, LET ) || look_76_1 == DDOC || look_76_1.between?( DECR, LPAREN ) || look_76_1 == DEFAULT || look_76_1 == DELETE || look_76_1.between?( DGENERAL, SWITCH ) || look_76_1.between?( MINUS, DO ) || look_76_1 == THROW || look_76_1 == TILDE || look_76_1 == TRUE || look_76_1 == TRY || look_76_1.between?( TYPEOF, NEW ) || look_76_1.between?( EACH, UNLESS ) || look_76_1 == UNTIL || look_76_1 == FALSE || look_76_1.between?( VAR, FINALLY ) || look_76_1.between?( VOID, FOR ) || look_76_1 == WHILE || look_76_1.between?( WITH, YIELD ) || look_76_1.between?( IS_UNDEFINED, DOC ) || look_76_1.between?( T__148, T__150 ) )\n alt_76 = 1\n\n end\n\n end\n case alt_76\n when 1\n # at line 690:24: ',' argument\n char_literal320 = match( COMMA, TOKENS_FOLLOWING_COMMA_IN_arguments_4905 )\n if @state.backtracking == 0\n stream_COMMA.add( char_literal320 )\n end\n @state.following.push( TOKENS_FOLLOWING_argument_IN_arguments_4907 )\n argument321 = argument\n @state.following.pop\n if @state.backtracking == 0\n stream_argument.add( argument321.tree )\n end\n\n else\n break # out of loop for decision 76\n end\n end # loop for decision 76\n # at line 690:41: ( ',' )?\n alt_77 = 2\n look_77_0 = @input.peek( 1 )\n\n if ( look_77_0 == COMMA )\n alt_77 = 1\n end\n case alt_77\n when 1\n # at line 690:41: ','\n char_literal322 = match( COMMA, TOKENS_FOLLOWING_COMMA_IN_arguments_4913 )\n if @state.backtracking == 0\n stream_COMMA.add( char_literal322 )\n end\n\n end\n\n end\n char_literal323 = match( RPAREN, TOKENS_FOLLOWING_RPAREN_IN_arguments_4919 )\n if @state.backtracking == 0\n stream_RPAREN.add( char_literal323 )\n end\n # AST Rewrite\n # elements: argument\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream( \"rule return_value\", return_value.tree ) : subtree_stream( \"token return_value\" )\n\n root_0 = @adaptor.create_flat_list\n # 690:53: -> ^( ARGUMENTS ( argument )* )\n # at line 690:56: ^( ARGUMENTS ( argument )* )\n root_1 = @adaptor.create_flat_list\n root_1 = @adaptor.become_root( @adaptor.create_from_type( ARGUMENTS, \"ARGUMENTS\" ), root_1 )\n\n # at line 690:69: ( argument )*\n while stream_argument.has_next?\n @adaptor.add_child( root_1, stream_argument.next_tree )\n\n end\n\n stream_argument.reset();\n\n @adaptor.add_child( root_0, root_1 )\n\n\n\n return_value.tree = root_0\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 66 )\n\n end\n \n return return_value\n end",
"def process_arguments\n if arguments_valid? \n process_command\n else\n raise ArgumentError\n end\n end",
"def process(argv, entry, opt, arg)\n unless option = match?(opt)\n @on_extra[entry]\n else\n if option.arg?\n if arg.nil?\n unless option.optional?\n arg = argv.shift\n end\n end\n\n unless arg or option.optional?\n raise ParseError, \"No argument provided for #{opt}\"\n end\n\n option.block[arg] if option.block\n else\n option.block[] if option.block\n end\n end\n option\n end",
"def handle(indicator, code, tailch, rspace, lspace)\n raise ArgumentError, \"Invalid indicator: #{indicator}\"\n end",
"def parse_label\n if (@instruction.is_a? Rips::Instructions::Beqz) ||\n (@instruction.is_a? Rips::Instructions::Bnez) ||\n (@instruction.is_a? Rips::Instructions::J) ||\n (@instruction.is_a? Rips::Instructions::Jal)\n\n @cmd[:arguments] = [@labels[@cmd[:arguments].first].to_s]\n end\n end",
"def process_argument arg, idx=0\n\n if arg.is_a?(String) \n if arg.length < @@max_key_size\n [arg, arg]\n else\n [idx, arg]\n end\n\n elsif arg.respond_to?(:name) and arg.respond_to?(:read)\n\n [arg.name, arg]\n\n elsif arg.respond_to?(:id) and arg.respond_to?(:data)\n\n [arg.id, arg.data]\n\n elsif arg.is_a?(Hash)\n\n if arg.has_key? :id and arg.has_key? :data\n [arg[:id], arg[:data]]\n elsif arg.has_key? 'id' and arg.has_key? 'data'\n [arg['id'], arg['data']]\n end\n\n else\n raise ApiError, \"Invalid argument: #{ arg }\"\n end\n\n end",
"def build_operand(arg)\n if (arg.is_a?(AS::Parser::RegisterListArgNode))\n @operand = 0\n arg.registers.each do |reg_node|\n reg = reg_ref(reg_node)\n @operand |= (1 << reg)\n end\n else\n raise AS::AssemblyError.new(AS::ERRSTR_INVALID_ARG, arg)\n end\n end",
"def parse_position_one_arg(arg, old_mod=nil, show_errmsg=true, allow_offset=false)\n name, filename = nil, nil, nil\n begin\n # First see if argument is an integer\n lineno = Integer(arg)\n rescue\n else\n container = frame_container(@frame, false)\n filename = container[1] unless old_mod\n return nil, [container[0], canonic_file(filename)], lineno\n end\n\n # Next see if argument is a file name \n found = \n if arg[0..0] == File::SEPARATOR\n LineCache::cached?(arg)\n else\n resolve_file_with_dir(arg)\n end\n if found\n return nil, [container && container[0], canonic_file(arg)], 1 \n else\n matches = find_scripts(arg)\n if matches.size > 1\n if show_errmsg\n errmsg \"#{arg} is matches several files:\"\n errmsg Columnize::columnize(matches.sort, \n @settings[:width], ' ' * 4, \n true, true, ' ' * 2).chomp\n end\n return nil, nil, nil\n elsif matches.size == 1\n LineCache::cache(matches[0])\n return nil, ['file', matches[0]], 1\n end\n end\n\n # How about a method name with an instruction sequence?\n iseq = object_iseq(arg)\n if iseq && iseq.source_container[0] == 'file'\n filename = iseq.source_container[1]\n line_no = iseq.offsetlines.values.flatten.min\n return arg, ['file', canonic_file(filename)], line_no\n end\n\n if show_errmsg\n unless (allow_offset && arg.size > 0 && arg[0].downcase == 'o')\n errmsg(\"#{arg} is not a line number, read-in filename or method \" +\n \"we can get location information about\")\n end\n end\n return nil, nil, nil\n end",
"def process(input)\n full_input = input\n args = input.split(\" \")\n\n case args[0]\n when \"quit\"\n bye()\n when \"help\"\n displayHelp()\n when \"modules\"\n printModules()\n when \"use\"\n options = get_options(args[1])\n if options == false \n puts \"Wrong module\"\n elsif args[1] == \"http_module\"\n http_fuzz()\n else\n setup_module(args[1], options)\n end\n else\n puts \"Wrong options\"\n displayHelp()\n end\n\nend",
"def parse(args)\n @args = args\n @instruction = args.join(' ')\n until @args.empty?\n arg = @args[0]\n if @instructions.key? arg\n @args.shift\n buff = args_extract(arg, @instructions[arg][0])\n @to_exec << [arg, buff]\n else\n bad_argument_exit(arg)\n end\n end\n run\n end",
"def fallback_parsing(*arguments)\n arguments = arguments.flatten\n case command = arguments.shift\n when nil, \"list\"\n @action = :list\n if arg = arguments.shift\n @state ||= arg.to_sym if %w(open closed).include? arg\n @user, @repo = arg.split \"/\" if arg.count(\"/\") == 1\n end\n when \"search\"\n @action = :search\n @search_term ||= arguments.shift\n when \"show\", /^-?(\\d+)$/\n @action = :show\n @number ||= ($1 || arguments.shift[/\\d+/]).to_i\n when \"open\"\n @action = :open\n when \"edit\"\n @action = :edit\n @number ||= arguments.shift[/\\d+/].to_i\n when \"close\"\n @action = :close\n @number ||= arguments.shift[/\\d+/].to_i\n when \"reopen\"\n @action = :reopen\n @number ||= arguments.shift[/\\d+/].to_i\n when \"label\"\n @action = :label\n @number ||= arguments.shift[/\\d+/].to_i\n @label ||= arguments.shift\n when \"unlabel\"\n @action = :unlabel\n @number ||= arguments.shift[/\\d+/].to_i\n @label ||= arguments.shift\n when \"comment\"\n @action = :comment\n @number ||= arguments.shift[/\\d+/].to_i\n when \"claim\"\n @action = :claim\n @number ||= arguments.shift[/\\d+/].to_i\n when %r{^([^/]+)/([^/]+)$}\n @action = :list\n @user, @repo = $1, $2\n when \"url\", \"web\"\n @action = :url\n @number ||= arguments.shift[/\\d+/].to_i\n end\n if @action\n @args = @argv.dup\n args.delete_if { |arg| arg == command }\n option_parser.parse!(*args)\n return true\n end\n unless command.start_with? \"-\"\n warn \"#{File.basename $0}: what do you mean, '#{command}'?\"\n end\n end",
"def examine_command(input)\n if /[0-9]/ =~ input\n input.to_i\n else input\n end\nend",
"def resolve(arg)\n return true unless @label\n\n @mod ? res = arg.send(*@mod) : res = arg\n @data = [res]\n @mode = :word\n\n raise DataError, 'Invalid argument' unless validate\n\n @ready = true\n end",
"def argument?; end",
"def get_raw_value_for_argument(arg=nil)\n if arg.class == Hash && !block_given?\n return @j_del.java_method(:getRawValueForArgument, [Java::IoVertxCoreCli::Argument.java_class]).call(Java::IoVertxCoreCli::Argument.new(::Vertx::Util::Utils.to_json_object(arg)))\n end\n raise ArgumentError, \"Invalid arguments when calling get_raw_value_for_argument(arg)\"\n end",
"def find_argument(*arguments)\n index = ARGV.find_index { |element| arguments.include?(element) }\n yield(index) if index && block_given?\n index\nend",
"def flag(arg_index)\n flags = opflags\n flag = nil\n # 10.divmod(10) => [1, 0] => position mode\n # 1.divmod(10) => [0,1] => immediate mode\n # 0.divmod(10) => [0,0] => all unspecified flags are position mode\n arg_index.times do\n flags, flag = flags.divmod(10)\n end\n\n FLAG_CODES[flag] || :position\n end",
"def arguments\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 29 )\n return_value = ArgumentsReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n\n _last = _first_0 = nil\n __ARGUMENTS253__ = nil\n argument254 = nil\n\n tree_for_ARGUMENTS253 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 206:5: ^( ARGUMENTS ( argument )* )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n __ARGUMENTS253__ = match( ARGUMENTS, TOKENS_FOLLOWING_ARGUMENTS_IN_arguments_1535 )\n\n tree_for_ARGUMENTS253 = @adaptor.copy_node( __ARGUMENTS253__ )\n\n root_1 = @adaptor.become_root( tree_for_ARGUMENTS253, root_1 )\n\n\n\n if @input.peek == DOWN\n match( DOWN, nil )\n # at line 206:18: ( argument )*\n while true # decision 33\n alt_33 = 2\n look_33_0 = @input.peek( 1 )\n\n if ( look_33_0.between?( AMP, AMP_ASGN ) || look_33_0 == POST_DECR || look_33_0.between?( GEQ, AREF ) || look_33_0.between?( GREATER, HAT ) || look_33_0.between?( ARROW, HAT_ASGN ) || look_33_0 == ASGN || look_33_0 == REGEX || look_33_0 == IN || look_33_0 == INCR || look_33_0.between?( INSTANCEOF, RSHIFT3 ) || look_33_0 == RSHIFT3_ASGN || look_33_0.between?( RSHIFT_ASGN, COLON ) || look_33_0 == LEQ || look_33_0.between?( LESS, SLASH ) || look_33_0 == SLASH_ASGN || look_33_0.between?( STAR, DECR ) || look_33_0 == STAR_ASGN || look_33_0 == LSHIFT || look_33_0.between?( DELETE, THIS ) || look_33_0.between?( MINUS, TILDE ) || look_33_0.between?( MINUS_ASGN, MOD ) || look_33_0.between?( MOD_ASGN, TYPEOF ) || look_33_0.between?( NEQ, UMINUS ) || look_33_0.between?( NEQQ, UNDEFINED ) || look_33_0 == NEW || look_33_0 == NOT || look_33_0.between?( NULL, UPLUS ) || look_33_0 == OBJECT || look_33_0.between?( EQ, OR_ASGN ) || look_33_0 == FALSE || look_33_0 == PIPE || look_33_0 == PIPE_ASGN || look_33_0 == PLUS || look_33_0.between?( ID, DOC ) )\n alt_33 = 1\n\n end\n case alt_33\n when 1\n # at line 206:18: argument\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_argument_IN_arguments_1537 )\n argument254 = argument\n @state.following.pop\n\n @adaptor.add_child( root_1, argument254.tree )\n\n\n else\n break # out of loop for decision 33\n end\n end # loop for decision 33\n\n match( UP, nil )\n end\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 29 )\n\n end\n \n return return_value\n end",
"def parse_switch(arg)\n argument = arg[1..-1].downcase\n\n # Version\n if argument =~ /^(v|-version)$/\n print_version\n end\n\n # Argument output_dir\n if argument.eql?(\"m\")\n @merge = true\n @edit_in_place=false unless @mset==true\n @mset=true\n end\n\n # In place\n if argument.eql?(\"i\")\n @edit_in_place=true\n @merge=false unless @mset==true\n end\n\n # Argument threshold\n if argument.eql?(\"t\")\n if @expecting_threshold==false\n @expecting_threshold=true\n else\n puts \"Argument threshold expected after -t switch\\n\"\n print_help\n end\n end\n\n # Arguments -H, -h, --help, -help...\n if argument =~ /^-*h+(elp)*$/i\n print_help\n end\n\n end",
"def catch_argument_passed_as_input(arg_list, arg, arg_input)\n arg_list.each do |arg_element|\n if arg_input.strip == arg_element\n exit_failure(missing_input_msg(arg))\n end\n end\n end",
"def initialize(op, arg = false, mod = false)\n raise OperandError, 'No such operand' unless OP_CODES.has_key? op\n\n @op = op\n @mode = false\n @arg = arg\n @mod = mod\n @label = false\n @ready = false\n\n opcode = OP_CODES[op]\n\n # mode resolution\n if opcode.has_key? :n\n # all immediates\n @mode = :n\n @ready = true\n elsif not arg and opcode.has_key? :e\n @mode = :e\n @ready = true\n elsif opcode.keys.length == 1\n # branching and jsr\n @mode = opcode.keys.first\n elsif arg and arg.instance_of? Fixnum\n # for the rest, let's try figure out mode by checking argument\n # we treat addressing modes as of higher priority, eg. :z over :d\n if arg >= 0 and arg <= 255\n if opcode.has_key? :z\n @mode = :z\n elsif opcode.has_key? :d\n @mode = :d\n else\n raise OperandError, 'No mode handling byte'\n end\n elsif arg >= 256 and arg <= 65535\n if opcode.has_key? :a\n @mode = :a\n else\n raise OperandError, 'Argument out of range'\n end\n end\n end\n\n # future reference handling, aka labels\n if arg and arg.instance_of? Symbol\n # labels can point only to absolute addresses\n unless (has_a = opcode.has_key? :a) or opcode.has_key? :r\n raise OperandError, 'Used with label but no :a or :r modes'\n end\n\n @mode = has_a ? :a : :r\n @label = arg\n end\n\n # argument checking\n if @mode and not @label\n raise OperandError, 'Invalid argument' unless validate\n\n @ready = true\n end\n\n # modifier checking\n check_mod if mod\n end",
"def PO108=(arg)",
"def load_arg_address(aparam)\n leal(local_arg(aparam), result_value)\n return result_value\n end",
"def argument_assigned?(arg=nil)\n if arg.class == Hash && !block_given?\n return @j_del.java_method(:isArgumentAssigned, [Java::IoVertxCoreCli::Argument.java_class]).call(Java::IoVertxCoreCli::Argument.new(::Vertx::Util::Utils.to_json_object(arg)))\n end\n raise ArgumentError, \"Invalid arguments when calling argument_assigned?(arg)\"\n end",
"def process(*_arg0, **_arg1, &_arg2); end",
"def load_arg(aparam,reg = result_value)\n movl(local_arg(aparam), reg)\n return reg\n end",
"def PO111=(arg)",
"def process(*_arg0, **_arg1); end",
"def inst_call(addr)\n # This is the last call\n return registers[pc] = addr if %w[execve execl].any? { |n| addr.include?(n) }\n # TODO: handle some registers would be fucked after call\n checker = {\n 'sigprocmask' => {},\n '__close' => {},\n 'unsetenv' => { 0 => :global },\n '__sigaction' => { 1 => :global, 2 => :zero? }\n }\n func = checker.keys.find { |n| addr.include?(n) }\n return if func && checker[func].all? { |idx, sym| check_argument(idx, sym) }\n # unhandled case or checker's condition fails\n :fail\n end",
"def handle_arguments(args)\n if input_file.nil?\n print_usage\n true\n else\n args.help || args.version\n end\n end",
"def arg; end",
"def arg_to_native(arg)\n return nil if arg.type == 0x00\n\n # arg_type = TYPE_SHORTHANDS[arg_type] if arg_type.is_a?(Symbol)\n\n value = if pack_char = PACK_CHARS_FOR_DATA_TYPE[arg.type]\n value = arg.value.to_byte_string.unpack( PACK_CHARS_FOR_DATA_TYPE[arg.type] )[0]\n value\n else\n\n case arg.type\n when 0x09 # immediate 8-byte string\n arg.value.to_byte_string.strip_to_null\n when 0x0e # variable-length string\n arg.value.to_byte_string[1..-1]\n else\n if arg.type > DATA_TYPE_MAX # immediate type-less 8-byte string\n [arg.type,arg.value].flatten.to_byte_string.strip_to_null #FIXME: can have random crap after first null byte, cleanup\n else\n raise Gta3Vm::Vm::InvalidDataType, \"unknown data type #{arg_type} (#{hex(arg_type)})\"\n end\n end\n\n end\n\n value = value.round(FLOAT_PRECISION) if value.is_a?(Float)\n\n value\n\n end",
"def _(arg=nil)\n return StateProcessorMatch unless arg\n MatchProc.new do |a| \n next a === arg ? StateProcessorMatch : StateProcessorNoMatch \n end\n end",
"def inst_call(addr)\n # This is the last call\n return registers[pc] = addr if %w[execve execl posix_spawn].any? { |n| addr.include?(n) }\n\n # TODO: handle some registers would be fucked after call\n checker = {\n 'sigprocmask' => {},\n '__close' => {},\n 'unsetenv' => { 0 => :global_var? },\n '__sigaction' => { 1 => :global_var?, 2 => :zero? }\n }\n func = checker.keys.find { |n| addr.include?(n) }\n return if func && checker[func].all? { |idx, sym| check_argument(idx, sym) }\n\n # unhandled case or checker's condition fails\n :fail\n end",
"def process!(cmd)\n inst, args = parse(cmd)\n # return registers[pc] = args[0] if inst.inst == 'call'\n return true if inst.inst == 'jmp' # believe the fetcher has handled jmp.\n sym = \"inst_#{inst.inst}\".to_sym\n send(sym, *args) != :fail\n end",
"def encode_single(arg, value)\r\n len = arg.scan(/\\d/).join\r\n length = len.empty? ? 32 : Integer(len)\r\n\r\n if arg.start_with \"string\" then\r\n raise \"not yet implemented\"\r\n elsif arg.start_with \"bytes\" then\r\n if len.empty? then #if there are no digets in the arg strin\r\n raise \"not yet implemented\"\r\n end\r\n elsif arg.start_with \"address\" then\r\n tailParts << Integer(value).to_padded_hex_string 160\r\n elsif arg.start_with \"function\" then\r\n raise \"not yet implemented\"\r\n elsif arg.start_with \"uint\" then\r\n tailParts << Integer(value).to_padded_hex_string length\r\n elsif arg.start_with \"int\" then\r\n tailParts << Integer(value).to_padded_hex_string length\r\n elsif arg.start_with \"fixed\" then\r\n raise \"not yet implemented\"\r\n elsif arg.start_with \"ufixed\" then\r\n raise \"not yet implemented\"\r\n elsif arg.start_with \"bool\" then\r\n if value then\r\n headParts << 1.to_padded_hex_string\r\n else\r\n headParts << 1.to_padded_hex_string\r\n end\r\n end\r\n end",
"def exec(opcode, arg)\n case opcode\n when 0\n self.acc = self.acc + ram.read(arg)\n when 1\n self.acc = self.acc - ram.read(arg)\n when 2\n self.acc = self.io.ask(\"> \", Integer)\n when 3\n self.io.say(\"--> #{self.acc}\")\n when 4\n ram.store(arg) { self.acc }\n when 5\n self.acc = ram.read(arg)\n when 6\n self.pc = arg\n when 7\n self.pc = arg if self.acc == 0\n when 8\n @running = false\n else\n raise \"Unknown instruction code #{opcode}\"\n end\n end",
"def process_arguments(k, input) #:nodoc:\n if (opt = @dict[k])\n key = opt.key\n case opt.option_type\n when :boolean \n @options[key] = (k != \"no-#{key}\")\n when :increment\n @options[key] ||= 0\n @options[key] += 1\n when :optional_argument, :required_argument\n args = []\n loop do \n break if (input.empty?)\n arg = input.shift\n\n is_arg = case arg\n # If it matches a long argument name, it isn't an argument\n when '--'\n false\n when /^--(\\S+)/\n o, a = $1.split('=', 2)\n !@dict.has_key?(o)\n # If this is a valid shorthand option string, abort\n when /^-(\\S+)/\n o, a = $1.split('=', 2)\n !o.scan(/./).all? { |c| @dict.has_key?(c) }\n else \n true\n end\n\n # We've hit another option, get outta here\n #if (arg =~ /^-/)\n unless (is_arg)\n input.unshift(arg) \n break\n end\n args << arg\n # If this is a scalar type, stop after the first argument\n break if opt.container_type == :scalar\n end\n\n if (args.empty?) \n # No argument found, and one was required, complain about it\n if (opt.option_type == :required_argument) \n raise ParseError.new(\"missing required argument for '#{key}'\")\n # No argument found, but it was optional, set a default value\n else \n case opt.container_type\n when :scalar; @options[key] = nil\n when :array; @options[key] = []\n end\n end\n else\n args.each do |arg|\n val = case opt.argument_type\n when :float \n # Try to parse float option, toss an exception if the parse failed\n Float(arg) rescue \n raise ParseError.new(\"expecting float value for option '#{key}'\") \n when :integer \n # Try to parse integer option, toss an exception if the parse failed\n Integer(arg) rescue \n raise ParseError.new(\"expecting integer value for option '#{key}'\") \n else\n # Assume string type (no processing needed)\n arg\n end\n # Either set the option value (scalar) or add it to the list (array)\n case opt.container_type\n when :scalar; @options[key] = val\n when :array; (@options[key] ||= []) << val\n end\n end\n end\n end\n else\n # If an exact match isn't found, try to make a suggestion\n candidates = @dict.keys.select do |c|\n (!@dict[c].is_abbreviated? && c =~ /^#{k}/)\n end\n matches = case candidates.size\n when 0\n nil\n when 1\n \", did you mean #{candidates.first}?\"\n else\n \", close matches are: \" +\n candidates[0, candidates.size - 1].join(\", \") +\n \" and \" + candidates.last\n end\n raise ParseError.new(\"unknown option '#{k}'#{matches || ''}\")\n end\n\n input\n end",
"def process!(cmd)\n inst, args = parse(cmd)\n # return registers[pc] = args[0] if inst.inst == 'call'\n return true if inst.inst == 'jmp' # believe the fetcher has handled jmp.\n\n sym = \"inst_#{inst.inst}\".to_sym\n __send__(sym, *args) != :fail\n end",
"def process_instruction(instruction)\n direction, value = instruction\n\n case direction\n when 'N'\n adjust_waypoint(:north, value)\n when 'S'\n adjust_waypoint(:south, value)\n when 'E'\n adjust_waypoint(:east, value)\n when 'W'\n adjust_waypoint(:west, value)\n when 'F'\n advance_with_heading(value)\n when 'R'\n rotate_waypoint('R', value)\n when 'L'\n rotate_waypoint('L', value)\n end\n end",
"def PRF04=(arg)",
"def passed_arg\n <<-CODE\n next_int;\n if((unsigned long int)_int < cpu_current_argcount(c)) {\n stack_push(Qtrue);\n } else {\n stack_push(Qfalse);\n }\n CODE\n end",
"def parse_command_line(gimmicode_arguments)\n begin\n OptionParser.new do |opts|\n opts.banner = $usage\n \n opts.separator \"\"\n opts.separator \"Specific options:\"\n\n opts.on('-h', '--help [COMMAND]', 'Show this message or the help of the given command') do |h|\n if h == \"of\" or h == \"convert\"\n exec(\"#{$current_directory}/gimmicode-#{h} -h\")\n else\n puts opts\n puts \"\"\n puts \"Commands:\"\n puts \" of\\t\\tGet the codes of the given characters\"\n puts \" convert\\tConvert Unicode data readable by gimmicode of\"\n exit\n end\n end\n end.parse!(gimmicode_arguments)\n rescue OptionParser::ParseError => e\n puts e.message.capitalize\n puts $usage\n exit\n end\nend",
"def argument_syntax?\n @instruction.variables.each_with_index do |var,i|\n if var.valid_syntax? @cmd[:arguments][i]\n @cmd[:arguments][i] = @cmd[:arguments][i].arg_to_i\n else\n Error::message(6, @line, var.error(@cmd[:arguments][i]) ) \n end\n end\n end",
"def arg_node\n case node.type\n when :command, :aref then node[2][1]\n when :method_add_arg then (node[2][1] ? node[2][1] : nil)\n when :method_add_block then node[1].method_call.arg_node\n when :call, :var_ref, :vcall, :command_call, :zsuper then nil\n when :command_call then node[4][1]\n when :super\n node[1].type == :arg_paren ? node[1][1] : node[1]\n end\n end",
"def set_argument\n @argument = Argument.friendly.find(params[:id])\n end",
"def process_action(*_arg0); end",
"def process_action(*_arg0); end",
"def process_action(*_arg0); end",
"def argument(args)\n args.first\n end",
"def process\n return @args[:process]\n end",
"def method_missing(symbol, *args)\n\t\t\t\tif(args == nil or args.length == 0)\n\t\t\t\t\tregex = Regexp.new(Regexp.escape(symbol.id2name))\n\t\t\t\t\treturn has_process?(regex)\n\t\t\t\tend\n\n\t\t\t\tsuper.method(symbol).call(args)\n\t\t\tend",
"def get_command_line_argument\n if ARGV.empty?\n puts \"Usage: ruby lookup.rb <domain>\" \n exit\n end ARGV.first # get frst argument in commnad line\nend",
"def process_command\n # Make sure we are running from the correct directory\n puts \"Running from .. \" + Dir.pwd if $DEBUG\n\n # determing which action and forward accordingly\n method = \"cmd_\" + @arguments.shift\n if !respond_to? method\n puts \"do not have `#{method}' in my reportoire ..\"\n output_usage\n end\n send(method, *@arguments)\n rescue ArgumentError\n output_usage\n end",
"def argument_node; end",
"def parse_optional(method_def, argument)\n method_def.scan(/#{argument}\\s*=\\s*(\"[^\"\\r\\n]*\"|'[^'\\r\\n]*'|[0-9]*)/)[0][0]\n end",
"def parse_optional(method_def, argument)\n method_def.scan(/#{argument}\\s*=\\s*(\"[^\"\\r\\n]*\"|'[^'\\r\\n]*'|[0-9]*)/)[0][0]\n end",
"def breakpoint_position(args)\n first = args.shift\n name, container, position = parse_position(first, nil, true)\n if container && position\n iseq = find_iseqs_with_lineno(container[1], position) || object_iseq(first)\n unless iseq\n if @frame.iseq && \n File.basename(@frame.iseq.source_container[1]) == \n File.basename(container[1])\n iseq = @frame.iseq\n else\n errmsg(\"Unable to find instruction sequence for\" + \n \" position #{position} in #{container[1]}\")\n return [nil, nil, nil, true]\n end\n end\n if args.empty? || 'if' == args[0]\n use_offset = false \n else\n position, use_offset = parse_num_or_offset(args[0])\n end\n else\n iseq = object_iseq(first)\n position_str = \n if iseq\n # Got name and possibly position\n name = first\n if args.empty? \n # FIXME: *Still* have a bug stopping at offset 0.\n # So stop at next offset after 0.\n # 'o0' \n \"o#{@frame.iseq.offsetlines.keys.sort[1]}\"\n else\n args.shift\n end\n else\n iseq = @frame.iseq unless container\n first\n end\n position, use_offset = parse_num_or_offset(position_str)\n end\n condition = 'true'\n if args.size > 0 && 'if' == args[0] \n condition_try = args[1..-1].join(' ')\n condition = condition_try if valid_condition?(condition_try)\n end\n return [position, iseq, use_offset, condition, name]\n end",
"def parse(*args)\n Integer(*params[:args]) rescue nil\nend",
"def process_arguments\n @e_addr = @options.email\n @r_name = @options.run_names\n @m_name = @options.machine_names\n @action = @options.action\n @snfs = @options.snfs\n end",
"def visit_ProcessingInstruction(pi, *rest)\n end",
"def PO109=(arg)",
"def build_operand(arg)\n if (arg.is_a?(AS::Parser::NumLiteralArgNode))\n if (arg.value.fits_u8?)\n # no shifting needed\n @operand = arg.value\n @i = 1\n elsif (op_with_rot = calculate_u8_with_rr(arg))\n @operand = op_with_rot\n @i = 1\n else\n raise AS::AssemblyError.new(AS::ERRSTR_NUMERIC_TOO_LARGE, arg)\n end\n elsif (arg.is_a?(AS::Parser::RegisterArgNode))\n @operand = reg_ref(arg)\n @i = 0\n elsif (arg.is_a?(AS::Parser::ShiftNode))\n rm_ref = reg_ref(arg.argument)\n @i = 0\n shift_op = {'lsl' => 0b000, 'lsr' => 0b010, 'asr' => 0b100,\n 'ror' => 0b110, 'rrx' => 0b110}[arg.type]\n if (arg.type == 'ror' and arg.value.nil?)\n # ror #0 == rrx\n raise AS::AssemblyError.new('cannot rotate by zero', arg)\n end\n \n arg1 = arg.value\n if (arg1.is_a?(AS::Parser::NumLiteralArgNode))\n if (arg1.value >= 32)\n raise AS::AssemblyError.new('cannot shift by more than 31', arg1)\n end\n shift_imm = arg1.value\n elsif (arg1.is_a?(AS::Parser::RegisterArgNode))\n shift_op |= 0x1;\n shift_imm = reg_ref(arg1) << 1\n elsif (arg.type == 'rrx')\n shift_imm = 0\n end\n \n @operand = rm_ref | (shift_op << 4) | (shift_imm << 4+3)\n else\n raise AS::AssemblyError.new(AS::ERRSTR_INVALID_ARG, arg)\n end\n end",
"def parser_if(args)\r\n # Push parser state.\r\n @if_stack << @_rl_parsing_conditionalized_out\r\n\r\n # If parsing is turned off, then nothing can turn it back on except\r\n # for finding the matching endif. In that case, return right now.\r\n if @_rl_parsing_conditionalized_out\r\n return 0\r\n end\r\n\r\n args.downcase!\r\n # Handle \"$if term=foo\" and \"$if mode=emacs\" constructs. If this\r\n # isn't term=foo, or mode=emacs, then check to see if the first\r\n # word in ARGS is the same as the value stored in rl_readline_name.\r\n if (@rl_terminal_name && args =~ /^term=/)\r\n # Terminals like \"aaa-60\" are equivalent to \"aaa\".\r\n tname = @rl_terminal_name.downcase.gsub(/-.*$/,'')\r\n\r\n # Test the `long' and `short' forms of the terminal name so that\r\n #if someone has a `sun-cmd' and does not want to have bindings\r\n #that will be executed if the terminal is a `sun', they can put\r\n #`$if term=sun-cmd' into their .inputrc.\r\n @_rl_parsing_conditionalized_out = (args[5..-1] != tname && args[5..-1] != @rl_terminal_name.downcase)\r\n elsif args =~ /^mode=/\r\n if args[5..-1] == \"emacs\"\r\n mode = @emacs_mode\r\n elsif args[5..-1] == \"vi\"\r\n mode = @vi_mode\r\n else\r\n mode = @no_mode\r\n end\r\n @_rl_parsing_conditionalized_out = (mode != @rl_editing_mode)\r\n # Check to see if the first word in ARGS is the same as the\r\n # value stored in rl_readline_name.\r\n elsif (args == @rl_readline_name)\r\n @_rl_parsing_conditionalized_out = false\r\n else\r\n @_rl_parsing_conditionalized_out = true\r\n end\r\n return 0\r\n end",
"def processor=(_arg0); end",
"def PRF01=(arg)",
"def parse_arguments(args)\n ret = {}\n ret[\"timeout\"] = 15\n op = OptionParser.new do |opts|\n opts.banner = \"Usage: #{__FILE__} [options]\"\n opts.separator \"\"\n opts.separator \"Specific options:\"\n\n opts.on(\"-a\", \"--argument=[JSON]\",\n \"Pass the supplied JSON data over the bridge\") do |v|\n ret[\"argument\"] = v\n end\n\n opts.on(\"-b\", \"--b64argument=[B64-JSON]\",\n \"Pass the base64-encoded JSON data over the bridge\") do |v|\n ret[\"b64argument\"] = v\n end\n\n opts.on(\"-s\", \"--selector=SELECTOR\",\n \"Call the given function (selector) via the bridge\") do |v|\n ret[\"selector\"] = v\n end\n\n opts.on(\"-c\", \"--callUID=UID\",\n \"Use the given UID to properly identify the return value of this call\") do |v|\n ret[\"callUID\"] = v\n end\n\n opts.on(\"-r\", \"--hardwareID=[HARDWAREID]\",\n \"If provided, connect to the physical iOS device with this hardware ID instead of a simulator\") do |v|\n ret[\"hardwareID\"] = v\n end\n\n opts.on(\"-t\", \"--timeout=[TIMEOUT]\",\n \"The timeout in seconds for reading a response from the bridge (default 15)\") do |v|\n ret[\"timeout\"] = v.to_i\n end\n\n opts.on_tail(\"-h\", \"--help\", \"Show this message\") do\n puts opts\n exit\n end\n\n end\n op.parse!(args)\n return ret\nend",
"def syscall(fixnum, *rest) end",
"def method_missing(method, *args, &block)\n if method.to_s =~ /^_(.+)$/\n arg = @in_args[$1.to_sym] || @out_args[$1.to_sym]\n return arg if !arg.nil?\n end\n\n super\n end",
"def get_int_noerr(arg)\n b = @frame ? @frame.binding : nil\n val = Integer(eval(arg, b))\n rescue SyntaxError\n nil\n rescue\n nil\n end",
"def ARPScan(argument_string = nil)\n ARPScan::ARPScanner.scan argument_string\nend",
"def parse(flag, value=nil, argv=[], config={})\n raise \"value specified for #{flag}: #{value.inspect}\" if value\n\n value = (flag == negative_long ? !default : default)\n assign(config, process(value))\n end",
"def grab_arg\n msg = \"Invalid argument source!\"\n @argsrc.source.size == @argsrc.grab_method.size or fail ArgumentError, msg\n grab = case @argsrc.grab_method.last\n when :shift then \".shift\"\n when :ref then \"\"\n when :dup then \".dup\"\n else\n msg = \"Unknown arg. grab method #{@argsrc.grab_method.last}!\"\n fail ArgumentError, msg\n end\n case @argsrc.source.last\n when :args_counted\n x = ( @arg_count += 1 ) - 1\n \"args[#{x}]\" + grab\n when :args then # now this is a bit difficult, cause\n case @argsrc.grab_method.last # it's necessary to discard the used\n when :shift then # args (shift #@arg_count):\n if @arg_count == 0 then\n \"args.shift\"\n else\n \"(args.shift(#@arg_count); args.shift)\"\n end\n when :ref then \"args\"\n else fail TypeError, \"Unknown grab method #{@argsrc.grab_method.last}!\"\n end\n when :alpha then alpha_touch; 'alpha' + grab\n when :beta then beta_touch; 'beta' + grab\n when :delta, :epsilon, :zeta then @argsrc.source.last.to_s + grab\n when :psi then \"args[-2]\" + grab\n when :omega then \"args[-1]\" + grab\n else fail TypeError, \"Unknown argument source #{@argsrc.src.last}!\"\n end.tap do\n if @argsrc.source.size > 1 then\n @argsrc.source.pop\n @argsrc.grab_method.pop\n end\n end\n end",
"def PRF02=(arg)",
"def run(args)\n state = @proc.state\n context = @proc.context\n max_frame = context.stack_size - state.frame_pos\n if args.size == 1\n frame_pos = state.frame_pos\n else\n count_str = args[1]\n count_opts = {\n :msg_on_error => \n \"The '#{NAME}' command argument must eval to an integer. Got: %s\" % \n count_str,\n :min_value => 0,\n :max_valiue => context.stack_size - state.frame_pos\n }\n count = @proc.get_an_int(count_str, count_opts)\n return unless count\n frame_pos = count - 1 \n end\n context.stop_frame = frame_pos\n state.frame_pos = 0\n state.proceed\n @proc.leave_cmd_loop = true\n end",
"def ri arg\n puts `ri #{arg}`\nend",
"def argument_parser\n arg(external_name, value(type))\n end",
"def set_argument\n @argument = Argument.find(params[:id])\n end",
"def add_argument(arg); end"
] | [
"0.65264785",
"0.64714813",
"0.646577",
"0.6157773",
"0.57950747",
"0.57208675",
"0.5696529",
"0.55878943",
"0.5484339",
"0.5467529",
"0.5372045",
"0.5369584",
"0.53099304",
"0.52562016",
"0.5234169",
"0.5228411",
"0.5122328",
"0.51144767",
"0.51029444",
"0.5077223",
"0.50710154",
"0.50602436",
"0.5045282",
"0.50364625",
"0.50272554",
"0.50137615",
"0.501022",
"0.50025773",
"0.4997955",
"0.49835974",
"0.49646023",
"0.49607226",
"0.49482608",
"0.49446255",
"0.4935428",
"0.492565",
"0.49121788",
"0.4900773",
"0.4900067",
"0.4899335",
"0.48972896",
"0.48932475",
"0.4884451",
"0.48801157",
"0.48770753",
"0.48742074",
"0.48719904",
"0.48615345",
"0.48585287",
"0.48563668",
"0.48484573",
"0.4845016",
"0.48373613",
"0.48305872",
"0.4820653",
"0.4810159",
"0.48100254",
"0.48098361",
"0.48070025",
"0.47949302",
"0.47808582",
"0.47735322",
"0.47517756",
"0.47490552",
"0.4738345",
"0.47369614",
"0.47356084",
"0.47303966",
"0.47303966",
"0.47303966",
"0.47261956",
"0.47255826",
"0.47242072",
"0.47217074",
"0.47164068",
"0.47097406",
"0.4707113",
"0.4707113",
"0.470585",
"0.46992123",
"0.46934292",
"0.46875623",
"0.46847647",
"0.46812788",
"0.4672423",
"0.46702805",
"0.46621138",
"0.46597084",
"0.46565017",
"0.46553788",
"0.46550798",
"0.46532887",
"0.46496692",
"0.4645771",
"0.4638842",
"0.4637306",
"0.46351466",
"0.4627538",
"0.46266043",
"0.46173006"
] | 0.78632027 | 0 |
Generate the required signature as specified by unionpay official document it returns the signature string | def generate_signature
sha1x16 = Digest::SHA1.hexdigest(signed_string)
.tap { |s| logger.debug "sha1x16 #{s}" }
enc = case form_fields['signMethod']
when '01' # 01 means RSA
merchant_private_key.sign(OpenSSL::Digest::SHA1.new, sha1x16)
.tap { |s| logger.debug "enc #{s}" }
else # at current time (2015-05-25) no other signing method is mentioned in Unionpay's official docs
raise "sign method #{form_fields['signMethod']} is not implemented yet."
end
Base64.strict_encode64(enc) # has to be strict_encode64, not encode64, as the latter as an extra '\n'
.tap { |s| logger.debug "final: #{s}" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_signature(string_to_sign)\n digest = OpenSSL::Digest.new('sha256')\n OpenSSL::HMAC.hexdigest(digest, @api_secret, string_to_sign)\n end",
"def generate_signature\n digest = OpenSSL::Digest.new('sha256')\n string_to_sign = \"#{@url_path}?#{sorted_parameters_query}\"\n OpenSSL::HMAC.hexdigest(digest, @api_secret_d, string_to_sign)\n end",
"def gen_sig(mac, params)\n signed = params[\"signed\"].split(\",\").map {|k| [k, params[k]]}\n base64_encode(Signatures.sign(mac, kv_encode(signed)))\n rescue Signatures::NotFound\n nil\n end",
"def signature\n k_date = Digestor.hmac(\"AWS4\" + secret_key, date[0, 8])\n k_region = Digestor.hmac(k_date, region)\n k_service = Digestor.hmac(k_region, service)\n k_credentials = Digestor.hmac(k_service, \"aws4_request\")\n Digestor.hexhmac(k_credentials, string_to_sign)\n end",
"def signature\n Base64.encode64(digest_with_key(string_to_sign)).strip\n end",
"def build_signature\n sig = case signature_method\n when \"HMAC-SHA1\"\n Base64.encode64(HMAC::SHA1.digest(signature_secret, signature_base_string)).chomp.gsub(/\\n/,'')\n when \"HMAC-MD5\"\n Base64.encode64(HMAC::MD5.digest(signature_secret, signature_base_string)).chomp.gsub(/\\n/,'')\n else\n false\n end\n Merb::Parse.escape(sig)\n end",
"def signature\n # Remove 'sha_sign' key from request params and concatenate all\n # key value pairs\n params = payload.to_h\n .reject { |key, value| key == :sha_sign }\n .reject { |key, value| value == '' || value == false }.sort\n .map { | key, value| \"#{key}=#{value}#{passphrase}\" }.join\n\n # Calculate SHA512 and upcase all letters, since Digistore will\n # also return upcased letters in the signature.\n Digest::SHA512.hexdigest(params).upcase\n end",
"def generated_signature(policy)\n return signature = Base64.encode64(\n OpenSSL::HMAC.digest(\n OpenSSL::Digest::Digest.new('sha1'),\n secret_access_key, policy)).gsub(\"\\n\",\"\")\n end",
"def swf_generated_signature(policy)\n return signature = Base64.encode64(\n OpenSSL::HMAC.digest(\n OpenSSL::Digest::Digest.new('sha1'),\n swf_secret_access_key, policy)).gsub(\"\\n\",\"\")\n end",
"def signature\n digest = \"SHA256\"\n OpenSSL::HMAC.hexdigest(digest, signing_key, string_to_sign)\n end",
"def create_signature(dev_id, api_method, auth_key, formatted_timestamp)\n # ts = Time.at(timestamp).strftime(\"%Y%m%d%H%M%S\")\n raw_sig = \"#{dev_id}#{api_method}#{auth_key}#{formatted_timestamp}\"\n Digest::MD5.hexdigest(raw_sig)\n end",
"def signature\n @signature ||= Base64.encode64(digest).gsub(\"\\n\", '')\n end",
"def signature\n @signature || ''\n end",
"def signature\n sha256 = OpenSSL::Digest::SHA256.new\n hash = OpenSSL::HMAC.digest sha256, secret, string_to_sign\n\n Base64.encode64(hash).chomp\n end",
"def generate_request_signature(components)\n string_to_sign = components.join(\"\\n\")\n\n digest = OpenSSL::Digest.new('sha1')\n Base64.encode64(OpenSSL::HMAC.digest(digest, @configuration.secret_key, string_to_sign))\n end",
"def generate_request_signature(components)\n string_to_sign = components.join(\"\\n\")\n\n digest = OpenSSL::Digest.new('sha1')\n Base64.encode64(OpenSSL::HMAC.digest(digest, @configuration.secret_key, string_to_sign))\n end",
"def createsignature(str)\r\n signature_raw = sign(str)\r\n signature_der = ECDSA::Format::SignatureDerString.encode(signature_raw)\r\n signature_der_b64 = Base64.strict_encode64(signature_der) \r\n digest_raw = Digest::SHA256.digest(str)\r\n digest_b64 = Base64.encode64(digest_raw)\r\n #Base64 encoding was used due to the readablility, and transportability. \r\n puts(\"Signature (b64 encoded der): \"+signature_der_b64)\r\n puts(\"Digest (b64 endoded): \"+digest_b64)\r\n $signature_array.push(signature_der_b64)\r\n $digest_array.push(digest_b64)\r\n #return signature_der_b64\r\nend",
"def upload_signature\n @upload_signature ||=\n Base64.encode64(\n OpenSSL::HMAC.digest(\n OpenSSL::Digest::SHA1.new,\n options[:secret_access_key],\n self.policy_document\n )\n ).gsub(/\\n/, '')\n end",
"def create_signature(params, secret) # :nodoc:\n query = build_nested_query(params)\n\n require 'openssl'\n digest = OpenSSL::Digest::Digest.new('sha1')\n signature = OpenSSL::HMAC.hexdigest(digest, secret, query)\n\n # require 'pp'\n # print '----------------------------------'\n # pp params\n # pp query\n # pp secret\n # pp signature\n\n return signature\n end",
"def generate!\n raise ArgumentMissingError unless has_all_required_inputs?\n payload = Base64.urlsafe_encode64(data.to_json).gsub(/[\\=\\n]/, '')\n signature = Base64.urlsafe_encode64(\n OpenSSL::HMAC.digest(\n OpenSSL::Digest.new('sha256'),\n secret,\n HEADER + '.' + payload\n )\n ).strip.gsub(/[\\=\\n]/, '')\n [HEADER, payload, signature].join('.')\n end",
"def signature_key; end",
"def signature\n Base64.encode64(\n OpenSSL::HMAC.digest(\n OpenSSL::Digest.new('sha1'),\n ENV['S3_SECRET_ACCESS_KEY'],\n policy_document\n )\n ).gsub(/\\n/, '')\n end",
"def param_signature(params) \n return generate_signature(params, get_secret(params));\n end",
"def signature\n EPDQ::ShaCalculator.new(full_parameters, EPDQ.sha_in, EPDQ.sha_type).signature\n end",
"def string_to_sign\n [\n SIGNV4ALGO,\n date,\n credential_scope,\n Digestor.hexdigest(canonical_request)\n ].join(\"\\n\")\n end",
"def build_signature_for(url, params)\r\n data = url + params.sort.join\r\n digest = OpenSSL::Digest.new('sha1')\r\n Base64.strict_encode64(OpenSSL::HMAC.digest(digest, ENV['TWILIO_AUTH_TOKEN'], data))\r\n end",
"def signature\n Base64.encode64(encryption_key.sign(OpenSSL::Digest::SHA256.new, id_string))\n end",
"def generate_signature\n Digest::MD5.hexdigest(Configuration.hotel_api_key + \n Configuration.hotel_shared_secret + \n Time.now.to_i.to_s)\n end",
"def getSignature\n\t time = Time.now.gmtime.to_i.to_s()\n unencryptedSignature = \"#{@apiKey}#{@secretKey}#{time}#{@user}\"\n\t return Digest::MD5.hexdigest(unencryptedSignature + unencryptedSignature.length.to_s())\n\tend",
"def generate_signature parameters\n temp = ''\n params = parameters.sort\n params.each do |array|\n temp += array[0].to_s + array[1].to_s\n end\n signature = @api_secret + temp\n Digest::MD5.hexdigest(signature)\n end",
"def calculate_signature\n normalized_string = [\n request_header.timestamp,\n request_header.nonce,\n request_header.algorithm,\n method.upcase,\n host_with_port,\n request_uri\n ].join(',')\n\n ActiveSupport::Base64.encode64s(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha256'), secret, normalized_string))\n end",
"def generate_signature(base_string)\n key = OpenSSL::HMAC.digest('sha1', client_secret, base_string)\n CGI::escape(Base64.encode64(key).chomp)\n end",
"def notification_signature(ns_merchant_id, \n ns_acquirer_bin,\n ns_terminal_id, \n ns_num_operacion, \n ns_importe, \n ns_tipo_moneda,\n ns_exponente,\n ns_referencia)\n\n charge = Charge.get(ns_num_operacion.to_i)\n configuration = configuration(charge.nil? ? nil : charge.sales_channel_code)\n\n signature = \"\"\n signature << configuration[:clave_encriptacion]\n signature << ns_merchant_id\n signature << ns_acquirer_bin\n signature << ns_terminal_id\n signature << ns_num_operacion\n signature << ns_importe\n signature << ns_tipo_moneda\n signature << ns_exponente\n signature << ns_referencia\n\n p \"calculating notification signature: #{signature}\"\n\n Digest::SHA256.hexdigest signature\n\n end",
"def signature_for(string)\n format('sha1=%s'.freeze, generate_hmac(string))\n end",
"def generate_api_sig(options={})\n # Every request requires the api_key parameter\n options.merge! @auth\n # Keys must be sorted alphabetically\n api_sig = options.sort { |a, b| a.to_s <=> b.to_s }.join\n Digest::MD5.hexdigest(\"#{@secret}#{api_sig}\")\n end",
"def signature_for(string)\n format('sha1=%s'.freeze, generate_hmac(string))\n end",
"def generate_signature_base_string(method, url, params, get_post_params = {})\n normalized_url = normalize_url(url)\n normalized_params = normalize_request_param(params, get_post_params)\n return method + \"&\" + normalized_url.urlencode + \"&\" + normalized_params.urlencode\n end",
"def calculate_signature api_private_key, rndguid, current_time\n\n # concatenate the random GUID to the end of the timestamp - the result should look like this:\n string_to_sign = current_time + rndguid\n\n # Use the api private key to create a SHA256 hash and Base64 encode the whole thing\n signature = Digest::HMAC.base64digest(string_to_sign, api_private_key, Digest::SHA256)\n\nend",
"def signature\n encode_tz(:edsig, 64)\n end",
"def signing_input; end",
"def signing_input; end",
"def generate_oauth_signature params, url\n base_request_uri = CGI::escape(url.to_s)\n query_params = []\n\n params.sort.map do |key, value|\n query_params.push(encode_param(key.to_s) + \"%3D\" + encode_param(value.to_s))\n end\n\n query_string = query_params\n .join(\"%26\")\n string_to_sign = \"#{@method}&#{base_request_uri}&#{query_string}\"\n\n if ![\"v1\", \"v2\"].include? @version\n consumer_secret = \"#{@consumer_secret}&\"\n else\n consumer_secret = @consumer_secret\n end\n\n return Base64.strict_encode64(OpenSSL::HMAC.digest(digest, consumer_secret, string_to_sign))\n end",
"def stored_signature; end",
"def fetch_signature(params)\n sig = params.fetch(\"sig\", nil) || params.fetch(\"s\", nil)\n sig && sig.first\n end",
"def fetch_signature(params)\n sig = params.fetch(\"sig\", nil) || params.fetch(\"s\", nil)\n sig && sig.first\n end",
"def get_signature_token(secret_key, payleven_string)\n\t\t\tsha512 = OpenSSL::Digest.new('sha512')\n\t\t\tsha1 = Digest::SHA1.new\n\t\t\t\n\t\t\tencoded256 = OpenSSL::HMAC.hexdigest(sha512, secret_key, payleven_string)\n\t\t\tsha1.hexdigest encoded256\n\t\tend",
"def formatted_signature(signature)\n n = (verify_key_length.to_f / BYTE_LENGTH).ceil\n\n if signature.size == n * 2\n r = signature[0..(n - 1)]\n s = signature[n..-1]\n\n OpenSSL::ASN1::Sequence.new([r, s].map { |int| OpenSSL::ASN1::Integer.new(OpenSSL::BN.new(int, 2)) }).to_der\n else\n signature\n end\n end",
"def perform\n query_param = @request_parameters.to_query.gsub(/^&/, '')\n\n uri = URI(@url)\n remove_txt = uri.query\n final_url = @url.gsub(/\\?#{remove_txt}\\Z/i, '')\n\n str = \"#{final_url}?#{query_param}\"\n generate_signature(str)\n end",
"def signature\n time = Time.now\n {\n mktowsUserId: user_id,\n requestTimestamp: time.to_s,\n requestSignature: hmac(time),\n }\n end",
"def signature\n @signature ||= set_signature(nil)\n end",
"def gen_signature(handler_path, req_msg, nonce)\n message = \"#{handler_path}|#{req_msg}|#{nonce}\"\n OpenSSL::HMAC.hexdigest(\"SHA512\", api_key, message)\n end",
"def generate_lazada_signature(parameter_list, seller)\n api_key = seller.api_key\n #Sort parameter_list by key\n sorted_params = Hash[parameter_list.sort]\n string_to_be_formed = []\n # concatinate key value with\n sorted_params.each do |key,value|\n case key\n when \"ShippingProvider\"\n string_to_be_formed << CGI::escape(\"#{key}\")+\"=\"+URI::escape(\"#{value}\")\n when \"SkuSellerList\"\n string_to_be_formed << CGI::escape(\"#{key}\")+\"=\"+CGI::escape(\"#{value}\").gsub(\"+\", \"%20\")\n else\n string_to_be_formed << CGI::escape(\"#{key}\")+\"=\"+CGI::escape(\"#{value}\")\n end\n end\n singnature_string = string_to_be_formed.join('&')\n #Compute signature and add it to parameters\n signature_key = OpenSSL::HMAC.hexdigest('sha256', api_key, singnature_string)\n return signature_key\n end",
"def string_to_sign\n [\n \"AWS4-HMAC-SHA256\",\n request_timestamp,\n credential_scope,\n digest.hexdigest(canonical)\n ].join(\"\\n\")\n end",
"def query_string_sig2\n @query_elements['Timestamp']= Time::at(Time.now).utc.strftime(\"%Y-%m-%dT%H:%M:%S.000Z\") unless @query_elements['Timestamp']\n @query_elements['AWSAccessKeyId']= @credentials.accessID\n signature_method= @query_elements['SignatureMethod']\n if @query_elements['_omit']\n @query_elements['_omit'].each do |k|\n @query_elements.delete k\n end\n @query_elements.delete '_omit'\n end\n values = @query_elements.keys.sort.collect {|key| [url_encode(key), url_encode(@query_elements[key])].join(\"=\") }\n @canonical_querystring= values.join(\"&\")\n @string_to_sign = <<\"____\".rstrip\nGET\n#{URI::parse(endpoint).host}\n#{URI::parse(endpoint).path}\n#{@canonical_querystring}\n____\n signature= @credentials.sign(signature_method,@string_to_sign)\n @query_elements['Signature'] = signature\n @query_elements.collect { |key, value| [url_encode(key), url_encode(value)].join(\"=\") }.join('&') # order doesn't matter for the actual request\n end",
"def sign_key; end",
"def generate_signature(bytes, private_key)\n bytes = Validation.check_filled_array_argument!(bytes)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n\n begin\n native_algorithm = HashAlgorithm.convert_to_native(HashAlgorithm::SHA512)\n signer = Core::VirgilSigner.new(native_algorithm)\n wrap_bytes(signer.sign(bytes, private_key.raw_key))\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def build_signature_buffer(result); end",
"def build_signature_buffer(result); end",
"def signature(params)\n self.class._hmac(secret, params) if secret.to_s.length > 0\n end",
"def s3_upload_signature\n\t signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), YOUR_SECRET_KEY, s3_upload_policy_document)).gsub(\"\\n\",\"\")\n\t end",
"def signature\n # FIXME merb keeps mangling this by replacing \"+\" with \"\\s\" \n oauth_merged_params[:oauth_signature]\n end",
"def signing_key\n digest = \"SHA256\"\n kDate = OpenSSL::HMAC.digest(digest, \"AWS4\" + credentials.aws_secret, request_datestamp)\n kRegion = OpenSSL::HMAC.digest(digest, kDate, region)\n kService = OpenSSL::HMAC.digest(digest, kRegion, service)\n OpenSSL::HMAC.digest(digest, kService, \"aws4_request\")\n end",
"def sign(params)\n Digest::MD5::hexdigest(wrap_with_secret sorted_option_string(params)).upcase\n end",
"def s3_upload_signature\n signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), SITE['s3_access_key'], s3_upload_policy_document)).gsub(\"\\n\",\"\")\n end",
"def signed_string\n \"service=#{params['service']}&v=#{params['v']}&sec_id=#{params['sec_id']}¬ify_data=#{params['notify_data']}#{key}\"\n end",
"def signature_for(data, secret)\n Base64.encode64(hmac_sha256(data, secret)).strip\n end",
"def signature_base_string\n \"#{method.to_s.upcase}&#{full_uri}&#{normalise_signature_params}\"\n end",
"def sign()\n # TODO\n end",
"def signer\n end",
"def s3_upload_signature\n signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), CONFIG['secret_access_key'], s3_upload_policy_document)).gsub(\"\\n\",\"\")\n end",
"def signature\n Digest::SHA256.hexdigest(@hash.to_json)\n end",
"def header_signature; end",
"def api_sig(params)\n sigstr = @shared_secret\n params.keys.sort { |x, y| x.to_s <=> y.to_s }.each do |k|\n sigstr += k.to_s\n sigstr += params[k].to_s\n end\n Digest::MD5.hexdigest(sigstr)\n end",
"def signature_helper(params, secret) # :nodoc:\n args = []\n params.each{|k,v| args << \"#{k}=#{v}\"}\n sortedArray = args.sort\n requestStr = sortedArray.join(\"\")\n return Digest::MD5.hexdigest(\"#{requestStr}#{secret}\")\n end",
"def transloadit_params_signature(params)\n auth_secret = Lynr.config('app')['transloadit']['auth_secret']\n return nil if auth_secret.nil?\n digest = OpenSSL::Digest::Digest.new('sha1')\n OpenSSL::HMAC.hexdigest(digest, auth_secret, JSON.generate(params))\n end",
"def signature\n registration_data_raw.byteslice(\n (KEY_HANDLE_OFFSET + key_handle_length + certificate_length)..-1\n )\n end",
"def update_signature!; end",
"def update_signature!; end",
"def sign(cmd)\n \t\t\t\tiv = rand(0xffffffff).to_i.to_s(16).upcase.rjust(8,\"0\")\n \t\t\t\tdigest = Digest::MD5.hexdigest(cmd+iv).upcase\n \t\t\t\tsb = [@signature_block + digest].pack(\"h*\")\n \t\t\t\tsig = @signingkey_priv.private_encrypt(sb).unpack(\"h*\")[0].upcase\n \t\t\t\t# i haven't a clue what those numbers are on the front, 10|3|22\n \t\t\t\t\"10|3|22|#{cmd}|#{sig}|#{iv}\"\n \t\t\tend",
"def generate_oauth_signature(endpoint, requestify)\n base_sig = \"POST&\" + CGI.escape(@base_url + endpoint).gsub(\"+\", \"%20\") + \"&\" + CGI.escape(requestify).gsub(\"+\", \"%20\")\n digest = OpenSSL::Digest::Digest.new('sha1')\n oauth_sig = OpenSSL::HMAC.digest(digest, @consumer_secret + \"&\", base_sig )\n oauth_sig = Base64.encode64( oauth_sig ).chomp.gsub(/\\n/,'') # eg 2j16OUZpkwcj9oogIIPgIJhOI4Q=\n oauth_sig = oauth_sig.gsub(\"=\", \"%3D\")\n oauth_sig = oauth_sig.gsub(\"+\", \"%2B\") # eg OTg2N2I2YWIxZWFhOGNmNGYwNWM1Y2NkMTM1Mzc0YjFlMWE4MjE0Zg%3D%3D\n oauth_sig = \"?oauth_signature=\" + oauth_sig \n return oauth_sig \n end",
"def generate_notification\n service_msg_number =\n sigparams =\n requried_service_params =\n SacPS::Auth::Banklink.generate_signature(service_msg_number, sigparams, required_service_params)\n end",
"def generate_preview_signature\n Sha256.new({string: generate_preview_url, salt: GlobalConstant::Base.cms[:sha256_salt]}).perform\n end",
"def text_representation\n self.signed_request[:signature].to_s\n end",
"def text_representation\n self.signed_request[:signature].to_s\n end",
"def encode_signature(algo, signature)\n encode_string(algo) + encode_string(signature)\n end",
"def s3_upload_signature\n signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), Figaro.env.aws_secret_access_key, s3_upload_policy_document)).gsub(\"\\n\",\"\")\n end",
"def verify_signature\n #puts \"sing in params: #{@params[\"sign\"]}\" unless @params[\"sign\"] == Alipay.generate_signature(@params, @key)\n #puts Alipay.generate_signature(@params, @key)\n @params[\"sign\"] == Tenpay.generate_signature(@params, @key) #.tap{|sig| puts \"Generated sig #{sig}\"}\n end",
"def s3_upload_signature\n Base64.encode64(\n OpenSSL::HMAC.digest(\n OpenSSL::Digest::Digest.new('sha1'),\n ENV[\"AWS_SECRET_ACCESS_KEY\"],\n s3_upload_policy_document\n )\n ).gsub(/\\n/, '')\n end",
"def to_s\n signed = (signed_at || Time.now).to_i.to_s\n\texpires = expires_at.to_i.to_s\n\tsignature = \"#{public_key}#{expires}#{signed}#{action}\"\n\ttoken = OpenSSL::HMAC.hexdigest DIGEST, secret, signature\n\tencoded_token = Base64.encode64(token)\n\tencoded_token.gsub! /\\n/, ''\n\tparams = [ encoded_token, public_key, expires, signed ].join SEPARATOR\n\tBase64.encode64(params).gsub(/\\n/, '')\n end",
"def get_signature(data, salt=nil)\n if salt == nil\n salt = (Time.now.to_i * 1000).to_s\n end\n\n hmac = OpenSSL::HMAC.new(get_key,OpenSSL::Digest.new('sha1'))\n hmac << data.force_encoding(\"utf-8\")\n hmac << salt.force_encoding(\"utf-8\")\n sig = Base64.urlsafe_encode64(hmac.digest).chop\n\n return sig,salt\n end",
"def generate_api_signature_method(value = nil)\n rw_config(:generate_api_signature_method, value, :generate_api_signature)\n end",
"def api_signature\n ts = timestamp\n [\n Rackspace::Email::Api.configuration.user_key,\n ts,\n hash(ts)\n ].join(':')\n end",
"def aws_get_signature_key(key, date_stamp, region_name, service_name)\n k_date = aws_sign(\"AWS4\" + key, date_stamp)\n k_region = aws_sign(k_date, region_name)\n k_service = aws_sign(k_region, service_name)\n aws_sign(k_service, \"aws4_request\")\n end",
"def signature(options = {})\n signature = nil\n url = '/api/videos/signature'\n if options[:success_action_redirect]\n url += \"?success_action_redirect=#{options[:success_action_redirect]}\"\n end\n if options[:include_metadata]\n url += url.include?('?') ? '&' : '?'\n url += \"include_metadata=yes\"\n end\n if options[:flash_request]\n url += url.include?('?') ? '&' : '?'\n url += \"flash_request=yes\"\n end\n auth_connection HTTP_GET, url do |xml|\n signature = Signature.new xml\n end\n signature\n end",
"def sign(params, shared_secret = nil)\n shared_secret ||= params.delete['sharedSecret']\n raise ArgumentError, \"Cannot verify a signature without a shared secret\" unless shared_secret\n sig = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), Array(shared_secret).pack(\"H*\"), string_to_sign(params))\n params.merge('merchantSig' => Base64.encode64(sig).strip)\n end",
"def _compute_signature(body)\n timestamp = self.class._get_timestamp\n nonce = self.class._get_nonce\n\n # Compute signature: HMAC[SHA256]_{secret} (key | timestamp | seq | nonce | body) => signature\n hm = OpenSSL::HMAC.new(self.secret, OpenSSL::Digest::SHA256.new)\n hm << self.key\n hm << timestamp\n hm << self.sequence.to_s\n hm << nonce.to_s\n hm << body\n signature = Base64.urlsafe_encode64(hm.digest)\n\n return signature, nonce, timestamp\n end",
"def string_to_sign\n [\n http_method,\n headers.values_at('content-md5', 'content-type').join(\"\\n\"),\n signing_string_date,\n canonicalized_headers,\n canonicalized_resource,\n ].flatten.compact.join(\"\\n\")\n end",
"def sign(payload)\n payload = payload.merge({\n :client_id => @client_id,\n :client_secret => @client_secret,\n })\n\n scope = create_scope\n context = create_context(payload)\n s2s = create_string_to_sign(scope, context)\n signing_key = get_signing_salt\n OpenSSL::HMAC.hexdigest(@hash_algo, signing_key, s2s)\n end",
"def to_signature(parameters)\n parameters.map{|k,v| \"#{v}\"}.join('')\n end",
"def generate\n data = flatten(stringify_keys(@params)).join\n digest = OpenSSL::Digest::Digest.new(\"sha1\")\n Base64.encode64(OpenSSL::HMAC.digest(digest, @auth_token, \"#{@url}#{data}\")).strip\n end"
] | [
"0.72814804",
"0.72706914",
"0.7163797",
"0.7154344",
"0.7073618",
"0.70271796",
"0.6941081",
"0.6893011",
"0.6892118",
"0.687593",
"0.68695897",
"0.6845367",
"0.6824029",
"0.68158877",
"0.6784177",
"0.6784177",
"0.6780259",
"0.6761523",
"0.67099506",
"0.6697454",
"0.6692018",
"0.66880894",
"0.6668715",
"0.66554964",
"0.66469806",
"0.66262853",
"0.66203827",
"0.66056806",
"0.66049147",
"0.66007996",
"0.6587251",
"0.65530425",
"0.6546086",
"0.65366405",
"0.65262395",
"0.6525146",
"0.6493149",
"0.6486157",
"0.6476389",
"0.647468",
"0.647468",
"0.64607877",
"0.64593357",
"0.64435863",
"0.64435863",
"0.6433547",
"0.6414823",
"0.6407357",
"0.64057875",
"0.6399973",
"0.63791275",
"0.6352959",
"0.635166",
"0.6335481",
"0.632758",
"0.63244826",
"0.62849414",
"0.62849414",
"0.62760997",
"0.6274934",
"0.6265193",
"0.62549895",
"0.6252415",
"0.6251426",
"0.62514246",
"0.62484545",
"0.6247726",
"0.62461054",
"0.6240007",
"0.6238959",
"0.6230113",
"0.62188375",
"0.6215069",
"0.62150425",
"0.61722285",
"0.6167036",
"0.61607814",
"0.61607814",
"0.61580485",
"0.61377794",
"0.61302865",
"0.6126341",
"0.6125897",
"0.6125897",
"0.61244035",
"0.6109774",
"0.6098426",
"0.6065888",
"0.60612607",
"0.6056252",
"0.6048276",
"0.60471535",
"0.6041862",
"0.60272956",
"0.602624",
"0.6020218",
"0.6014417",
"0.6011571",
"0.6000365",
"0.59979147"
] | 0.80659693 | 0 |
Generate the string to sign on from all in from_fields. Currently Unionpay doc specifies that the fields are arranged alphabetically | def signed_string
signed_data_only = form_fields.reject { |s| FIELDS_NOT_TO_BE_SIGNED.include?(s) }
signed_data_only.sort.collect { |s| "#{s[0]}=#{s[1]}" }.join('&')
.tap { |ss| logger.debug "signed string is #{ss}" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signed_field_names\n @signed_fields.join(',')\n end",
"def build_form_string(fields)\n return nil if fields.nil?\n tmp = []\n fields.each{|k,v|\n tmp << \"#{k.to_s}=#{v.to_s}\"\n }\n tmp.join(\"&\")\n end",
"def build_order_string(fields, mode=\"ASC\")\n fields.collect{ |f| \"#{self.table_name}.#{f}\" }.join(\",\") + \" \" + mode\n end",
"def build_keys(uids)\n if uids.is_a?(Numeric)\n \"UID #{uids}\"\n elsif uids.is_a?(Array)\n \"UID #{uids.join(',')}\"\n elsif uids.is_a?(Range)\n \"UID #{Array(uids).join(',')}\"\n elsif uids.is_a?(Hash)\n \"UID #{uids[:from] ? uids[:from] : 1}:#{uids[:to] ? uids[:to] : '*'}\"\n elsif uids.is_a?(String)\n uids.downcase == 'all' ? 'ALL' : \"UID #{uids}\"\n elsif uids.is_a?(Symbol)\n uids.to_s.downcase == 'all' ? 'ALL' : ''\n else\n \"\"\n end\n end",
"def to_s\n af = \"allowed_fields=#{@allowed_fields.inspect}\"\n rf = \"required_fields=#{@required_fields.inspect}\"\n rm = \"read_mask=#{@read_mask.inspect}\"\n wm = \"write_mask=#{@write_mask.inspect}\"\n \"#{af},#{rf},#{rm},#{wm}\"\n end",
"def from_name\n from.to_sym\n end",
"def from_name\n from.to_sym\n end",
"def get_from_exp\n\n return nil if self.from_address.nil?\n\n from_exp = \"<#{self.from_address}>\"\n\n unless self.from_name.nil? or self.from_name.empty?\n from_exp = \"#{self.from_name} #{from_exp}\"\n end\n\n return from_exp\n end",
"def from_fields(input)\n input.map { |key, val| \"#{key}=#{val.inspect}\" }.join(', ')\n end",
"def to_s\n \"#{ @from.key.inspect } -#{ @label.inspect }-> #{ @to.key.inspect }\"\n end",
"def string_order_fields(arrfields)\n\tstrres = \" \"\n\tl = 0\n\tarrfields.each do |af|\n\t l += 1\n\t if l > 1\n\t strres += \", \"\n\t end\n\t strres += af[1][\"ordfield\"]+\" \"+af[1][\"ascdesc\"]\n\tend\n\treturn strres\n end",
"def string_field_names\n # database_field_names.join(', ')\n database_field_names.to_s[1...-1]\n end",
"def to_s\n \"#{@__keys__.join(' ')} from #{@__schema__} for #{@__settings__}\"\n end",
"def to_s\n [@name.send(:initials_of, @name.send(:given_part), dots: true), @name.send(:family_part)].join(\" \")\n end",
"def to_s\n \"#{type}:#{flags.join}:#{principle}@#{domain}:#{permissions.join}\"\n end",
"def to_str\n fields.collect do |field, body|\n send(field) if body.type == Object\n end.compact.sort.join(' ')\n end",
"def string_to_sign\n [\n SIGNV4ALGO,\n date,\n credential_scope,\n Digestor.hexdigest(canonical_request)\n ].join(\"\\n\")\n end",
"def to_s\n \"#{@name} - #{@sign}\"\n end",
"def form_attributes\n full_parameters.each_with_object({ \"SHASIGN\" => signature }) do |(k, v), attributes|\n attributes[k.to_s.upcase] = v.to_s if v.to_s.length > 0\n end\n end",
"def form_fields\n @fields.merge(\"AUTHCODE\" => generate_md5string)\n end",
"def to_s\n fields = []\n fields << name\n fields << \"\"\n fields << address.to_s\n fields << \"\"\n fields << \"Telefon: #{phonenumber}\"\n fields << \"E-Mail: #{email}\"\n fields << \"WWW: #{www}\"\n fields.join(\"\\n\")\n end",
"def person_name_fields\n \"\".tap do |result|\n fields_for(:person_name) do |f|\n result << f.text_field(:name_prefix)\n result << f.text_field(:first_name)\n result << f.text_field(:middle_name)\n result << f.text_field(:last_name)\n result << f.text_field(:name_suffix)\n end\n end\n end",
"def prep_merge_fields(merge_fields)\n # Upper-case all the keys as this is how MC expect them.\n merge_fields.map { |k, v| [k.upcase, v] }.to_h\n end",
"def to_s\n return \"<P:#{self.given_name}_#{@code.to_s(36)}_#{@position}>\"\n end",
"def to_s\n fields = []\n fields << \"#{firstname} #{lastname}\"\n fields << \"\"\n fields << address.to_s\n fields << \"\"\n fields << \"Telefon: #{phonenumber}\" if phonenumber\n fields << \"Mobil: #{@mobile}\" if mobile\n fields << \"E-Mail: #{email}\" if email\n if office_email or office_phonenumber\n fields << \"\\nGeschäftlich\"\n fields << \"Telefon: #{office_phonenumber}\" if office_phonenumber\n fields << \"E-Mail: #{office_email}\" if office_email\n end\n fields.join(\"\\n\")\n end",
"def format_field key\n key.downcase.gsub(%r{[^A-Z0-9]+}xoi,' ').strip.gsub(' ','_')\n end",
"def build_order_string_from_hash(options)\n raise InvalidArgument.new('invalid hash :fields key not found') unless options[:fields]\n\n case options[:fields]\n when String\n return self.sanitize_order_string(options[:fields]) + \" \" + self.build_mode_from_options(options)\n when Array\n return self.build_order_string(options[:fields], self.build_mode_from_options(options))\n else\n raise TypeError.new('invalid options :fields, must be either Array or a String')\n end\n end",
"def to_s\n \"#{tag} #{[@from.quoteize, @to.quoteize, @options].compact.flatten * \" \"}\"\n end",
"def signable_string_for_account(options)\n # Order is significant\n # The newlines from empty strings here are required\n [\n @account_name,\n options[:permissions],\n options[:service],\n options[:resource],\n options[:start],\n options[:expiry],\n options[:ip_range],\n options[:protocol],\n Azure::Storage::Common::Default::STG_VERSION,\n \"\"\n ].join(\"\\n\")\n end",
"def to_s\n return \"#{@first_name}\", \"#{@last_name}\", \"#{@email}\", \"#{@phone}\", \"#{@created_at}\"\n end",
"def eob_patient_name\n str = \"\" #initialize in case the fileds are blank\n str += self.patient_last_name.upcase if !self.patient_last_name.blank?\n str += \", \"\n str += self.patient_first_name.upcase if !self.patient_first_name.blank?\n return str\n end",
"def form_fields\n base_json = base_params\n base_json[:nonce] = SecureRandom.hex(15)\n hmac_fields = (base_json.keys + ['hmac_fields']).sort.uniq!\n\n base_json[:hmac_fields] = hmac_fields.join(',')\n hmac_string = hmac_fields.map { |key, _v| \"#{key}=#{base_json[key]}\" }.join('&')\n hmac = OpenSSL::HMAC.hexdigest('sha1', KEY, hmac_string)\n base_json[:hmac] = hmac\n\n base_json\n end",
"def to_s\n return \"#{from}, #{message}, #{secret}\"\n end",
"def to_s\n %w( name display_name uuid ).collect { |k| \"#{k}=#{ self.send(k) }\" }.join(' | ') \n end",
"def all_tag_names(fields)\n fields.flat_map do |field|\n next if options[field].blank?\n options[field].split(\",\").map(&:squish)\n end.reject(&:blank?).uniq\n end",
"def to_s\n klass.fields.map { |field_def|\n field_name = field_def.name.to_s\n v = @fields[ field_name.to_sym ].to_s\n\n field_def.pass_through_formatters(\n field_def.is_padding? ? \"\" : v\n )\n }.pack(klass.pack_format)\n end",
"def required_keys_string\n @required_keys.map { |key| %('#{key}') }.join(', ')\n end",
"def to_s\n \"#{prefix}#{head}\"\n end",
"def extract_code(fields)\n fields = fields.delete('Fn::Base64') || fields\n if fields.kind_of?(Hash)\n fields = fields.delete('Fn::Join') || fields\n end\n if fields.kind_of?(Array)\n sep = fields.shift\n fields = fields.join(sep)\n end\n fields\n end",
"def b_format_form\n \"#{id} - #{cert_ope}\"\n end",
"def to_s\n \"#{tag} #{[@from.source, @to].quoteize.compact.flatten * \" \"}\"\n end",
"def get_field_names(template); end",
"def to_string(mbox_from = false)\n s = \"\"\n if mbox_from && ! @mbox_from.nil?\n s << @mbox_from\n s << \"\\n\" unless @mbox_from[-1] == ?\\n\n end\n @fields.each { |field|\n if field.raw\n s << field.raw\n else\n s << field.name\n s << ': '\n s << field.value\n end\n s << \"\\n\" unless s[-1] == ?\\n\n }\n s\n end",
"def general_prefix\n parts = []\n parts << label\n parts << ttl if ttl\n parts << 'IN'\n parts << type\n parts\n end",
"def field_names\n internal_format.keys\n end",
"def to_s\n %w( name uuid ).collect { |k| \"#{k}=#{ self.send(k) }\" }.join(' | ') \n end",
"def to_s\r\n \"VCARD: [first=#{@given} last=#{@family} nick=#{@nickname} email=#{@email}]\"\r\n end",
"def formulate_auth_header(signature)\n \"Apex_l2_Eg realm=\\\"#{@realm}\\\",apex_l2_eg_app_id=\\\"#{@app_id}\\\",\"\\\n \"apex_l2_eg_nonce=\\\"#{@nonce}\\\",apex_l2_eg_signature_method=\\\"SHA256withRSA\\\",\"\\\n \"apex_l2_eg_signature=\\\"#{signature}\\\",apex_l2_eg_timestamp=\\\"#{@timestamp}\\\",apex_l2_eg_version=\\\"1.0\\\"\"\n end",
"def build_username(first, last, year, i=0)\n user_type_prefix(i)+format_name(first, last)+format_year(year)\n\nend",
"def to_s\n majorkeys = ['C flat', 'G flat', 'D flat', 'A flat', 'E flat', 'B flat', 'F',\n 'C', 'G', 'D', 'A', 'E', 'B', 'F#', 'C#']\n minorkeys = ['a flat', 'e flat', 'b flat', 'f', 'c', 'g', 'd',\n 'a', 'e', 'b', 'f#', 'c#', 'g#', 'd#', 'a#']\n minor_key? ? \"key sig #{minorkeys[sharpflat + 7]} minor\" :\n \"key sig #{majorkeys[sharpflat + 7]} major\"\n end",
"def to_s\n \" #{account}\" +\n (amount ? \" #{amount}\" : \"\") +\n (note ? \" ; #{note}\" : \"\")\n end",
"def to_s\n \"First Name: #{@first_name}, Last Name: #{@last_name}, Email: #{@email}. username: #{@username}, password: #{@password}\"\n end",
"def generate_auth_header(params)\n auth_header_value = \"\"\n params.each_pair{|key, value|\n auth_header_value += \",\" if auth_header_value.length > 0\n auth_header_value += \"#{key.urlencode}=\\\"#{value.urlencode}\\\"\"\n }\n\n return auth_header_value\n end",
"def from\n attributes.fetch(:from)\n end",
"def build_table_aliases(from)\n # for the targets\n returning({}) do |aliases|\n from.map(&:to_s).sort.map(&:to_sym).each_with_index do |plural, t_index|\n table = plural._as_class.table_name\n plural._as_class.columns.map(&:name).each_with_index do |field, f_index|\n aliases[\"#{table}.#{field}\"] = \"t#{t_index}_r#{f_index}\"\n end\n end\n end\n end",
"def to_s\n %w( name display_name uuid ).collect { |k| \"#{k}=#{ self.send(k) }\" }.join(' | ') + \" | types=#{ types.join(',') }\"\n end",
"def get_view_name(search_fields, prefix = \"find\")\n prefix + \"_by_\" + search_fields.join('_and_')\n end",
"def unsigned_field_names\n @unsigned_fields.join(',')\n end",
"def to_s \n\t\t\" * #{last_name}, #{first_name}\"\n\tend",
"def field_names(filter = [], include_inherited = true)\n names = fields.keys\n\n if include_inherited && has_parent?\n names.concat(inherited_fields)\n end\n\n unless filter.empty?\n names = names & filter.map(&:to_sym)\n end\n\n names.sort!\n names\n end",
"def from_email_obscured\n return \"\" if from_email.blank?\n\n sender_parts = from_email.split(\"@\")\n if sender_parts.size > 1\n person_name = sender_parts.first\n if person_name.length > 2\n return \"#{person_name[0..(person_name.length - 3)]}..@#{sender_parts.last}\"\n else\n return \"..@#{sender_parts.last}\"\n end\n end\n\n \"\"\n end",
"def generate_signature\n sha1x16 = Digest::SHA1.hexdigest(signed_string)\n .tap { |s| logger.debug \"sha1x16 #{s}\" }\n enc = case form_fields['signMethod']\n when '01' # 01 means RSA\n merchant_private_key.sign(OpenSSL::Digest::SHA1.new, sha1x16)\n .tap { |s| logger.debug \"enc #{s}\" }\n else # at current time (2015-05-25) no other signing method is mentioned in Unionpay's official docs\n raise \"sign method #{form_fields['signMethod']} is not implemented yet.\"\n end\n Base64.strict_encode64(enc) # has to be strict_encode64, not encode64, as the latter as an extra '\\n'\n .tap { |s| logger.debug \"final: #{s}\" }\n end",
"def account_params_for_build\n super + [{ account_number_parts: NufsAccount.account_number_field_names }]\n end",
"def to_ps\n ret = \"#{self.class.name}:\\n\"\n c = 0\n @fields.each_pair do |p|\n field = p[1]\n next if field.nil?\n if field.is_a?(NumField) || field.is_a?(ApduList)|| field.is_a?(VarNumField)\n if field.optfield.nil? || field.optfield.value == 1\n ret = ret + sprintf(\" %-28s %s\\n\", field.define, field.hexstr)\n else\n ret = ret + sprintf(\" %-28s %s\\n\", field.define, \"--\")\n end\n c = 0\n else #only for bitfield\n ret = ret + sprintf(\" %-28s %s\\n\", field.define, \" \" * c + field.bitstr)\n c += field.length\n end\n end\n return ret\n end",
"def stringified_keys; end",
"def name\n \"#{self[:asn]} #{self[:vrf]} #{self[:afi]} #{self[:safi]} #{self[:aa]}\"\n end",
"def field_names\n (text_fields + html_fields + atom_fields + datetime_fields +\n number_fields + geo_fields).uniq\n end",
"def to_human\n fields.map { |m| '%02x' % self[m] }.join(':')\n end",
"def to_s(tab)\r\n\t\ts = \"\"\r\n\t\tif @l_identificadores != nil\r\n\t\t\ts << @l_identificadores.to_s(tab+1)\r\n\t\telse\r\n\t\t\ts << @l_identificadores.to_s(tab+1)\r\n\t\tend\r\n\r\n\t\treturn s\r\n\tend",
"def key\n to_a[0..(num_key_fields-1)].join(\"-\")\n end",
"def field_names\n (@profile.keys - NON_PROFILE_FIELDS).sort\n end",
"def sign(params)\n Digest::MD5::hexdigest(wrap_with_secret sorted_option_string(params)).upcase\n end",
"def to_s\n\t\t\"#{@name} <email: #{@email}> acct: #{hidden_digits(@deposit_account)}\"\n\tend",
"def stringify_keys; end",
"def stringify_keys; end",
"def stringify_keys; end",
"def string_to_sign\n [method, url.host, url.path, url.query].join \"\\n\"\n end",
"def to_s\n\t\t\"First name #{@first_name}, Last Name: #{@last_name}, Username: #{@username}, email: #{@email}\"\n\tend",
"def create_string_of_field_names_and_types(field_names_and_types)\n add_commas_to_types(field_names_and_types)\n add_primary_key_type_to_first_element(field_names_and_types)\n field_names_and_types.join(\" \")\n end",
"def pascal_string_fields(name)\n [ pascal_string_len_field(name.to_sym), name.to_sym ]\n end",
"def formatted_login\n [ZerigoDNS.config.user, ZerigoDNS.config.api_key].join(':')\n end",
"def to_s\n %Q{#{street}\n#{postnr_city}\n#{country}\n}\n end",
"def string_to_sign\n [\n http_method,\n headers.values_at('content-md5', 'content-type').join(\"\\n\"),\n signing_string_date,\n canonicalized_headers,\n canonicalized_resource,\n ].flatten.compact.join(\"\\n\")\n end",
"def to_s\n \"From: #{self.from_user} - #{self.body}\"\n end",
"def field_names\n fields.keys\n end",
"def mt_req_sort_key( key )\n case key\n when MtRequestQuery::KEY_BUILDING\n return \"בניין\"\n when MtRequestQuery::KEY_MT_COMPANY\n return \"חברת אחזקה\"\n when MtRequestQuery::KEY_STATE\n return \"מצב\"\n when MtRequestQuery::KEY_CREATED_ON\n return \"תאריך דיווח\"\n when MtRequestQuery::KEY_TITLE\n return \"תיאור\"\n when MtRequestQuery::KEY_URGENCY\n return \"דחיפות\"\n when MtRequestQuery::KEY_SOLVED_ON\n return \"תאריך תיקון\"\n when MtRequestQuery::KEY_SERVICE_TYPE\n return \"סוג שירות\"\n when MtRequestQuery::KEY_UPDATED_ON\n return \"עדכון אחרון\"\n else\n RAILS_DEFAULT_LOGGER.error( \"mt_req_sort_key( #{key} )\");\n return key.to_s;\n end\n end",
"def to_s\n return \"#{self.names.join('|')}\"\n end",
"def normalise_signature_params\n signature_params.sort.collect{|key, value| \"#{key}=#{value}\"}.join(\"&\")\n end",
"def to_s\n labels_address_params % [@instr_token]\n end",
"def from_values\n d_attrs = development.reload.fields\n self.fields.map{ |field|\n name = field.fetch('name').to_s\n edit_from = field.fetch('from').to_s\n devel_from = d_attrs.fetch( name )\n [ devel_from, edit_from ]\n }\n end",
"def to_signature(parameters)\n parameters.map{|k,v| \"#{v}\"}.join('')\n end",
"def to_s\n r = []\n r << \"complete: #{complete}\" if complete\n r << \"prefix: #{prefix}\" if prefix\n r << \"suffix: #{suffix}\" if suffix\n internals.each {|x| r << \"internal: #{x}\"}\n r.join(' ')\n end",
"def str_all_keys (options={})\n str = \"\"\n @data.keys.each do |key_name|\n if options[:filter] && options[:filter][:key_name]\n next unless key_name == options[:filter][:key_name]\n end\n str << \"\\n\"\n str << \"#{key_name}:\\n\"\n str << str_key_name(key_name, options)\n end\n str\n end",
"def join_signin_name_field\n $tracer.trace(__method__)\n return ToolTag.new(input.id(\"/ctl00_content_ctl00_fragment_17442_ctl01_ctl00_ctl00_ctl05_Username/\"), __method__)\n end",
"def from_coord\n self[:from_coord].to_sym unless self[:from_coord].blank?\n end",
"def form_field_order\n %w{\n\n }\n end",
"def to_s\n self.first_name + \" \" + self.last_name\n end",
"def to_s\n self.first_name + \" \" + self.last_name\n end",
"def to_s\n \t\"#{first_name} #{last_name}\"\n end",
"def format_field_names_as_string(array)\n array.map{ |k| \"'#{k}'\" }.join(',')\n end"
] | [
"0.5991405",
"0.5496816",
"0.54908687",
"0.54765916",
"0.5473576",
"0.54252845",
"0.54252845",
"0.54045486",
"0.53803265",
"0.5350425",
"0.528696",
"0.5247209",
"0.52301115",
"0.5228437",
"0.51992196",
"0.51936996",
"0.516909",
"0.5140548",
"0.51370764",
"0.5126734",
"0.5065486",
"0.5061352",
"0.50440276",
"0.50371146",
"0.502476",
"0.5018731",
"0.5014406",
"0.500202",
"0.5001107",
"0.4979838",
"0.4966052",
"0.49634984",
"0.49550372",
"0.49447215",
"0.49408582",
"0.49361622",
"0.49322185",
"0.49223286",
"0.49104375",
"0.49025452",
"0.48908243",
"0.48826852",
"0.48803806",
"0.48653293",
"0.48546985",
"0.48485965",
"0.4847337",
"0.4843457",
"0.48266342",
"0.48187628",
"0.48153007",
"0.48085934",
"0.48069534",
"0.48047554",
"0.48021618",
"0.48013562",
"0.4799785",
"0.47996426",
"0.47952592",
"0.4786654",
"0.47829592",
"0.47782335",
"0.4770591",
"0.4770474",
"0.47584602",
"0.47505918",
"0.4750553",
"0.4748847",
"0.47385442",
"0.47358468",
"0.47296727",
"0.47287273",
"0.47276342",
"0.4726899",
"0.4726899",
"0.4726899",
"0.47247994",
"0.47211096",
"0.4720332",
"0.47178325",
"0.47025466",
"0.46954504",
"0.46944034",
"0.46930742",
"0.46924612",
"0.46903333",
"0.46868673",
"0.46867",
"0.46865302",
"0.468462",
"0.46781984",
"0.46742597",
"0.4661805",
"0.466008",
"0.4656637",
"0.4655835",
"0.46536002",
"0.46536002",
"0.46534714",
"0.4649934"
] | 0.5750741 | 1 |
Return and Notify do not have 'form_fields' defined yet it's needed for the signed_string method | def form_fields
params
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signed_string\n signed_data_only = form_fields.reject { |s| FIELDS_NOT_TO_BE_SIGNED.include?(s) }\n signed_data_only.sort.collect { |s| \"#{s[0]}=#{s[1]}\" }.join('&')\n .tap { |ss| logger.debug \"signed string is #{ss}\" }\n end",
"def signing_input; end",
"def signing_input; end",
"def signing_input=(_); end",
"def signing_input=(_); end",
"def generate_signature\n sha1x16 = Digest::SHA1.hexdigest(signed_string)\n .tap { |s| logger.debug \"sha1x16 #{s}\" }\n enc = case form_fields['signMethod']\n when '01' # 01 means RSA\n merchant_private_key.sign(OpenSSL::Digest::SHA1.new, sha1x16)\n .tap { |s| logger.debug \"enc #{s}\" }\n else # at current time (2015-05-25) no other signing method is mentioned in Unionpay's official docs\n raise \"sign method #{form_fields['signMethod']} is not implemented yet.\"\n end\n Base64.strict_encode64(enc) # has to be strict_encode64, not encode64, as the latter as an extra '\\n'\n .tap { |s| logger.debug \"final: #{s}\" }\n end",
"def form_fields\n base_json = base_params\n base_json[:nonce] = SecureRandom.hex(15)\n hmac_fields = (base_json.keys + ['hmac_fields']).sort.uniq!\n\n base_json[:hmac_fields] = hmac_fields.join(',')\n hmac_string = hmac_fields.map { |key, _v| \"#{key}=#{base_json[key]}\" }.join('&')\n hmac = OpenSSL::HMAC.hexdigest('sha1', KEY, hmac_string)\n base_json[:hmac] = hmac\n\n base_json\n end",
"def form_fields\n @fields.merge(\"AUTHCODE\" => generate_md5string)\n end",
"def signing_information\n super\n end",
"def signed_field_names\n @signed_fields.join(',')\n end",
"def form_attributes\n full_parameters.each_with_object({ \"SHASIGN\" => signature }) do |(k, v), attributes|\n attributes[k.to_s.upcase] = v.to_s if v.to_s.length > 0\n end\n end",
"def signature_valid?; end",
"def text_representation\n self.signed_request[:signature].to_s\n end",
"def text_representation\n self.signed_request[:signature].to_s\n end",
"def html_post_form\n expiration = (Time.now + 360).utc.strftime(\"%Y-%m-%dT%H:%M:%SZ\")\n policy_document = %{\n{\"expiration\": \"#{expiration}\",\n \"conditions\": [\n {\"bucket\": \"#{@cloud.bucket}\"},\n [\"starts-with\", \"$key\", \"TE\"],\n {\"success_action_redirect\": \"http://www.google.fr/\"},\n [\"content-length-range\", 0, 1048576]\n ]\n}\n }\n @policy = Base64.encode64(policy_document).gsub(\"\\n\",\"\")\n @signature = Base64.encode64(\n OpenSSL::HMAC.digest(\n OpenSSL::Digest::Digest.new('sha1'),\n @cloud.shared_secret, @policy)\n ).gsub(\"\\n\",\"\")\n end",
"def stored_signature; end",
"def signed_or_encrypted; end",
"def computed_signed_info\n \n llave = CFDI::Key.new @key, @password\n\n return Base64::encode64(llave.sign(OpenSSL::Digest::SHA1.new, CGI::unescapeHTML(self.canonicalized_signed_info.gsub('<TEST/>','').gsub(/\\n/, ''))))\n \n end",
"def update_signature!; end",
"def update_signature!; end",
"def signature_fields\n parsed {\n @signature_fields\n }\n end",
"def form_params\n params.require(:form).permit(:name, :package_id, :document_id, :signed, :link)\n end",
"def build_register_body\n signable_str = self.signable_string\n {\n :type => :client_associate,\n :signed_string => Base64.encode64(signable_str),\n :signature => Base64.encode64(LygneoClient.sign(signable_str))\n }\n end",
"def signed_string\n \"service=#{params['service']}&v=#{params['v']}&sec_id=#{params['sec_id']}¬ify_data=#{params['notify_data']}#{key}\"\n end",
"def sign_key; end",
"def initialize(fields)\n @fields = fields\n @signed_fields = fields['signed_field_names'].split(',')\n @unsigned_fields = fields['unsigned_field_names']&.split(',') || []\n end",
"def signed_data\n @signed_data = @signed_fields.index_with { |field| @fields[field] }\n end",
"def build_signature\n sig = case signature_method\n when \"HMAC-SHA1\"\n Base64.encode64(HMAC::SHA1.digest(signature_secret, signature_base_string)).chomp.gsub(/\\n/,'')\n when \"HMAC-MD5\"\n Base64.encode64(HMAC::MD5.digest(signature_secret, signature_base_string)).chomp.gsub(/\\n/,'')\n else\n false\n end\n Merb::Parse.escape(sig)\n end",
"def signing_key; end",
"def sign(message); end",
"def signed_data\n @signed_data ||= @signed_fields.index_with { |field| send(field) }\n end",
"def injection_form\n # Nothing to do here\n end",
"def signature_params\n params.require(:signature).permit(:sign)\n end",
"def build_form_string(fields)\n return nil if fields.nil?\n tmp = []\n fields.each{|k,v|\n tmp << \"#{k.to_s}=#{v.to_s}\"\n }\n tmp.join(\"&\")\n end",
"def signature_params\n params.require(:signature).permit(\n :person_city, :more_information, :person_name, :person_email,\n :person_street, :person_street_number, :person_born_at, :person_postalcode,\n :person_function, :person_country, :person_famous,\n :person_street_number_suffix,\n :subscribe, :visible\n )\n end",
"def signature_key; end",
"def query_string_sig2\n @query_elements['Timestamp']= Time::at(Time.now).utc.strftime(\"%Y-%m-%dT%H:%M:%S.000Z\") unless @query_elements['Timestamp']\n @query_elements['AWSAccessKeyId']= @credentials.accessID\n signature_method= @query_elements['SignatureMethod']\n if @query_elements['_omit']\n @query_elements['_omit'].each do |k|\n @query_elements.delete k\n end\n @query_elements.delete '_omit'\n end\n values = @query_elements.keys.sort.collect {|key| [url_encode(key), url_encode(@query_elements[key])].join(\"=\") }\n @canonical_querystring= values.join(\"&\")\n @string_to_sign = <<\"____\".rstrip\nGET\n#{URI::parse(endpoint).host}\n#{URI::parse(endpoint).path}\n#{@canonical_querystring}\n____\n signature= @credentials.sign(signature_method,@string_to_sign)\n @query_elements['Signature'] = signature\n @query_elements.collect { |key, value| [url_encode(key), url_encode(value)].join(\"=\") }.join('&') # order doesn't matter for the actual request\n end",
"def signature\n @signature || ''\n end",
"def signed_request\n \"signed_request=#{TESTING_SIGNED_REQUEST}\"\nend",
"def content_post\n # POST requests seem to bomb out when they're deflated\n # and they probably don't need to be compressed anyway\n @request_params[\"SAMLRequest\"] = Base64.encode64(@request).gsub(/\\n/, \"\")\n \n #Logging.debug \"SAMLRequest=#{@request_params[\"SAMLRequest\"]}\"\n # kind of a cheesy method of building an HTML, form since we can't rely on Rails too much,\n # and REXML doesn't work well with quote characters\n str = \"<html><body onLoad=\\\"document.getElementById('form').submit();\\\">\\n\"\n str += \"<form id='form' name='form' method='POST' action=\\\"#{@URL}\\\">\\n\"\n # we could change this in the future to associate a temp auth session ID\n str += \"<input name='RelayState' value='ruby-saml' type='hidden' />\\n\"\n @request_params.each_pair do |key, value|\n str += \"<input name=\\\"#{key}\\\" value=\\\"#{value}\\\" type='hidden' />\\n\"\n #str += \"<input name=\\\"#{key}\\\" value=\\\"#{CGI.escape(value)}\\\" type='hidden' />\\n\"\n end\n str += \"</form></body></html>\\n\"\n \n #Logging.debug \"Created form:\\n#{str}\"\n return str\n end",
"def content_post\n\t\t\t# POST requests seem to bomb out when they're deflated\n\t\t\t# and they probably don't need to be compressed anyway\n\t\t\t@request_params[\"SAMLRequest\"] = Base64.encode64(@request).gsub(/\\n/, \"\")\n\t\t\t\n\t\t\t#Logging.debug \"SAMLRequest=#{@request_params[\"SAMLRequest\"]}\"\n\t\t\t# kind of a cheesy method of building an HTML, form since we can't rely on Rails too much,\n\t\t\t# and REXML doesn't work well with quote characters\n\t\t\tstr = \"<html><body onLoad=\\\"document.getElementById('form').submit();\\\">\\n\"\n\t\t\tstr += \"<form id='form' name='form' method='POST' action=\\\"#{@URL}\\\">\\n\"\n\t\t\t# we could change this in the future to associate a temp auth session ID\n\t\t\tstr += \"<input name='RelayState' value='ruby-saml' type='hidden' />\\n\"\n\t\t\t@request_params.each_pair do |key, value|\n\t\t\t\tstr += \"<input name=\\\"#{key}\\\" value=\\\"#{value}\\\" type='hidden' />\\n\"\n\t\t\t\t#str += \"<input name=\\\"#{key}\\\" value=\\\"#{CGI.escape(value)}\\\" type='hidden' />\\n\"\n\t\t\tend\n\t\t\tstr += \"</form></body></html>\\n\"\n\t\t\t\n\t\t\tLogging.debug \"Created form:\\n#{str}\"\n\t\t\treturn str\n\t\tend",
"def signer\n end",
"def signature\n # Remove 'sha_sign' key from request params and concatenate all\n # key value pairs\n params = payload.to_h\n .reject { |key, value| key == :sha_sign }\n .reject { |key, value| value == '' || value == false }.sort\n .map { | key, value| \"#{key}=#{value}#{passphrase}\" }.join\n\n # Calculate SHA512 and upcase all letters, since Digistore will\n # also return upcased letters in the signature.\n Digest::SHA512.hexdigest(params).upcase\n end",
"def digital_signature_params\n params.require(:digital_signature).permit!\n end",
"def form_data?; end",
"def get_signature_field_with_http_info(name, field_name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_signature_field ...\"\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 PdfApi.get_signature_field\"\n end\n # verify the required parameter 'field_name' is set\n if @api_client.config.client_side_validation && field_name.nil?\n fail ArgumentError, \"Missing the required parameter 'field_name' when calling PdfApi.get_signature_field\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/fields/signature/{fieldName}\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'fieldName' + '}', field_name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\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 # Fix header in file\n post_body = nil\n\n # http body (model)\n # Fix header in file\n # post_body = nil\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:GET, 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 => 'SignatureFieldResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_signature_field\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def upload_signature\n @upload_signature ||=\n Base64.encode64(\n OpenSSL::HMAC.digest(\n OpenSSL::Digest::SHA1.new,\n options[:secret_access_key],\n self.policy_document\n )\n ).gsub(/\\n/, '')\n end",
"def signature_changed?; end",
"def signature_changed?; end",
"def verify_signatures?; end",
"def sign()\n # TODO\n end",
"def post_signature_field_with_http_info(name, field, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.post_signature_field ...\"\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 PdfApi.post_signature_field\"\n end\n # verify the required parameter 'field' is set\n if @api_client.config.client_side_validation && field.nil?\n fail ArgumentError, \"Missing the required parameter 'field' when calling PdfApi.post_signature_field\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/fields/signature\".sub('{' + 'name' + '}', name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\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 # Fix header in file\n post_body = nil\n\n # http body (model)\n post_body = @api_client.object_to_http_body(field)\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:POST, 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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#post_signature_field\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def header_signature; end",
"def form_authenticity_token(form_options: T.unsafe(nil)); end",
"def form_to_be_sent(path, form)\n end",
"def ing_form; end",
"def verify_signature\n #puts \"sing in params: #{@params[\"sign\"]}\" unless @params[\"sign\"] == Alipay.generate_signature(@params, @key)\n #puts Alipay.generate_signature(@params, @key)\n @params[\"sign\"] == Tenpay.generate_signature(@params, @key) #.tap{|sig| puts \"Generated sig #{sig}\"}\n end",
"def form_fields\n [:description, :status, :magic]\n end",
"def as_flattened_form\n form_title = case form_key\n when SHS_Q2_SELF_REFLECTION then 'Q2 Self-reflection'\n when SHS_WHAT_I_WANT_MY_TEACHER_TO_KNOW_MID_YEAR then 'What I want my teachers to know'\n when BEDFORD_DAVIS_TRANSITION_NOTES_FORM then 'Transition Information'\n when BEDFORD_SIXTH_GRADE_TRANSITION_FORM then 'Transition to Grade 6'\n else 'Student voice survey'\n end\n\n # Don't include `form_url` as a defense against overly permissive permissions on\n # the form itself (outside Student Insights).\n {\n id: id,\n form_key: form_key,\n form_title: form_title,\n form_timestamp: form_timestamp,\n student_id: student_id,\n educator_id: educator_id,\n text: as_text,\n updated_at: updated_at\n }\n end",
"def open_struct_form\n @application ||= JSON.parse(form, object_class: OpenStruct)\n @application.confirmation_number = confirmation_number\n\n transform_form\n\n @application\n end",
"def previous_signature?; end",
"def all_expected_fields_received?\n @signature_fields ||= %w(idterminal idcomercio idtransaccion importe moneda coderror codautorizacion firma).map{|value| value = value.to_sym}\n !@fields.empty? && @fields.areset?(@signature_fields)\n end",
"def signature_verification_state\n super\n end",
"def signature\n Base64.encode64(digest_with_key(string_to_sign)).strip\n end",
"def signup_info\n end",
"def required_signs\n @required_signs\n end",
"def sign_request(method, uri, form_args)\n # Convert non-string keys to strings so the sort works\n args = {}\n if form_args\n form_args.each do |key, value|\n next unless value and value != \"\"\n\n key = key.to_s unless key.is_a?(String)\n args[key] = value\n end\n end\n\n # Add the necessary OAuth args\n args[\"oauth_version\"] = \"1.0\"\n args[\"oauth_consumer_key\"] = @config[:api_key]\n args[\"oauth_nonce\"] = Digest::MD5.hexdigest(\"#{Time.now.to_f}#{rand(10 ** 30)}\")\n args[\"oauth_signature_method\"] = \"HMAC-SHA1\"\n args[\"oauth_timestamp\"] = Time.now.utc.to_i\n args[\"oauth_token\"] = @config[:user][:token]\n\n # RFC 1738 (http://www.ietf.org/rfc/rfc1738.txt) says:\n #\n # Thus, only alphanumerics, the special characters \"$-_.+!*'(),\", and\n # reserved characters used for their reserved purposes may be used\n # unencoded within a URL.\n #\n # However, if we don't escape apostrophes and parentheses the SmugMug API fails\n # with an invalid signature error:\n #\n # Error #35, invalid signature (SmugMug::OAuthError)\n #\n # To overcome this, define a new unreserved character list and use this in URI::escape\n unreserved = \"\\\\-_.!~*a-zA-Z\\\\d\"\n unsafe = Regexp.new(\"[^#{unreserved}]\", false, 'N')\n\n # Sort the params\n sorted_args = []\n args.sort.each do |key, value|\n sorted_args.push(\"#{key.to_s}=#{URI::escape(value.to_s, unsafe)}\")\n end\n\n postdata = sorted_args.join(\"&\")\n\n # Final string to hash\n sig_base = \"#{method}&#{URI::escape(\"#{uri.scheme}://#{uri.host}#{uri.path}\", unsafe)}&#{URI::escape(postdata, unsafe)}\"\n\n signature = OpenSSL::HMAC.digest(@digest, \"#{@config[:oauth_secret]}&#{@config[:user][:secret]}\", sig_base)\n signature = URI::escape(Base64.encode64(signature).chomp, unsafe)\n\n if uri == API_URI\n \"#{postdata}&oauth_signature=#{signature}\"\n else\n args[\"oauth_signature\"] = signature\n args\n end\n end",
"def api_signature\n ts = timestamp\n [\n Rackspace::Email::Api.configuration.user_key,\n ts,\n hash(ts)\n ].join(':')\n end",
"def display_signature_params\n params = method_signature_params\n params << 'arguments = {}'\n \"(#{params.join(', ')})\"\n end",
"def parse_signed_request(value)\n signature, encoded_payload = value.split('.')\n\n decoded_hex_signature = base64_decode_url(signature)\n decoded_payload = ActiveSupport::JSON.decode(base64_decode_url(encoded_payload))\n\n unless decoded_payload['algorithm'] == 'HMAC-SHA256'\n raise NotImplementedError, \"unkown algorithm: #{decoded_payload['algorithm']}\"\n end\n\n if valid_signature?(@options[:secret], decoded_hex_signature, encoded_payload)\n decoded_payload.with_indifferent_access\n end\n end",
"def custom_fields\n if debug?\n channel_fields = ChannelFieldForm.new\n channel_fields.create_field(\n group_id: 1,\n type: 'Checkboxes',\n label: 'Checkboxes',\n fields: {\n field_list_items: \"Yes\\nNo\\nMaybe\"\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Radio Buttons',\n label: 'Radio Buttons',\n fields: {\n field_list_items: \"Left\\nCenter\\nRight\"\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Multi Select',\n label: 'Multi Select',\n fields: {\n field_list_items: \"Red\\nGreen\\nBlue\"\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Select Dropdown',\n label: 'Select Dropdown',\n fields: {\n field_list_items: \"Mac\\nWindows\\nLinux\"\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Select Dropdown',\n label: 'Prepopulated',\n fields: {\n field_pre_populate: 'y'\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Rich Text Editor',\n label: 'Rich Text Editor',\n fields: {\n field_ta_rows: 20,\n field_text_direction: 'Right to left'\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Toggle',\n label: 'Toggle'\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Text Input',\n label: 'Text Input',\n fields: {\n field_maxl: 100,\n field_fmt: 'None',\n field_show_fmt: 'y',\n field_text_direction: 'Right to left',\n field_content_type: 'Decimal',\n field_show_smileys: 'y',\n field_show_file_selector: 'y'\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'Textarea',\n label: 'Textarea',\n fields: {\n field_ta_rows: 20,\n field_fmt: 'None',\n field_show_fmt: 'y',\n field_text_direction: 'Right to left',\n field_show_formatting_btns: 'y',\n field_show_smileys: 'y',\n field_show_file_selector: 'y'\n }\n )\n channel_fields.create_field(\n group_id: 1,\n type: 'URL',\n label: 'URL Field',\n fields: {\n url_scheme_placeholder: '// (Protocol Relative URL)'\n }\n ) do |page|\n page.all('input[name=\"allowed_url_schemes[]\"]').each do |element|\n element.click unless element.checked?\n end\n end\n\n @page.load\n else\n $db.query(IO.read('channel_sets/custom-fields.sql'))\n clear_db_result\n end\n end",
"def signature_key=(_arg0); end",
"def parse_signed_payload\n signed_payload = params[:signed_payload]\n message_parts = signed_payload.split('.')\n\n encoded_json_payload = message_parts[0]\n encoded_hmac_signature = message_parts[1]\n\n payload = Base64.decode64(encoded_json_payload)\n provided_signature = Base64.decode64(encoded_hmac_signature)\n\n expected_signature = sign_payload(bc_client_secret, payload)\n\n if secure_compare(expected_signature, provided_signature)\n return JSON.parse(payload, symbolize_names: true)\n end\n\n nil\nend",
"def form; end",
"def encrypt(secret, fields = [:amount, :currency, :account, :order])\n signature_fields = fields.collect{ |field| mappings[field] }\n add_field('signatureFields', signature_fields.join(':'))\n\n field_values = fields.collect{ |field| form_fields[mappings[field]] }\n signature = \"#{secret}:#{field_values.join(':')}\" \n add_field('signature', Digest::MD5.hexdigest(signature))\n end",
"def form_fields=(fields)\n @form_fields = ::ActiveSupport::HashWithIndifferentAccess.new fields\n end",
"def string_to_sign\n if content_type.nil?\n \"#{method.upcase}\\n#{host.downcase}\\n#{uri}#{canonicalized_params}\"\n else\n \"#{method.upcase}\\n#{body_md5}\\n#{content_type}\\n#{host.downcase}\\n#{uri}#{canonicalized_params}\"\n end\n end",
"def verify_signature\n #puts \"sing in params: #{@params[\"sign\"]}\" unless @params[\"sign\"] == Alipay.generate_signature(@params, @key)\n #puts Alipay.generate_signature(@params, @key)\n @params[\"sign\"] == Alipay.generate_signature(@params, @key)\n end",
"def signable_string_for_service(service_type, path, options)\n # Order is significant\n # The newlines from empty strings here are required\n signable_fields =\n [\n options[:permissions],\n options[:start],\n options[:expiry],\n canonicalized_resource(service_type, path)\n ]\n\n if @user_delegation_key.nil?\n signable_fields.push(options[:identifier])\n else\n signable_fields.concat [\n @user_delegation_key.signed_oid,\n @user_delegation_key.signed_tid,\n @user_delegation_key.signed_start,\n @user_delegation_key.signed_expiry,\n @user_delegation_key.signed_service,\n @user_delegation_key.signed_version\n ]\n end\n\n signable_fields.concat [\n options[:ip_range],\n options[:protocol],\n Azure::Storage::Common::Default::STG_VERSION\n ]\n\n signable_fields.concat [\n options[:resource],\n options[:timestamp]\n ] if service_type == Azure::Storage::Common::ServiceType::BLOB\n\n signable_fields.concat [\n options[:cache_control],\n options[:content_disposition],\n options[:content_encoding],\n options[:content_language],\n options[:content_type]\n ] if service_type == Azure::Storage::Common::ServiceType::BLOB || service_type == Azure::Storage::Common::ServiceType::FILE\n\n signable_fields.concat [\n options[:startpk],\n options[:startrk],\n options[:endpk],\n options[:endrk]\n ] if service_type == Azure::Storage::Common::ServiceType::TABLE\n\n signable_fields.join \"\\n\"\n end",
"def sign(req, ts)\n md5_salt = \"ifxy8jvzf1q0f9uz\"\n body = \"#{CGI.escape(req)}#{ts}#{md5_salt}\"\n # md5.update body.upcase\n sign = Digest::MD5.hexdigest body\n sign.upcase\nend",
"def forms; end",
"def sign(str)\n @signer.sign(str) unless str.nil? || str.empty?\n end",
"def put_signature_field_with_http_info(name, field_name, field, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_signature_field ...\"\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 PdfApi.put_signature_field\"\n end\n # verify the required parameter 'field_name' is set\n if @api_client.config.client_side_validation && field_name.nil?\n fail ArgumentError, \"Missing the required parameter 'field_name' when calling PdfApi.put_signature_field\"\n end\n # verify the required parameter 'field' is set\n if @api_client.config.client_side_validation && field.nil?\n fail ArgumentError, \"Missing the required parameter 'field' when calling PdfApi.put_signature_field\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/fields/signature/{fieldName}\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'fieldName' + '}', field_name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\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 # Fix header in file\n post_body = nil\n\n # http body (model)\n post_body = @api_client.object_to_http_body(field)\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 => 'SignatureFieldResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_signature_field\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def params_auth_hash; end",
"def set_signing_information(opts)\n opts = check_params(opts,[:signers])\n super(opts)\n end",
"def signature; end",
"def signature; end",
"def signature; end",
"def signature; end",
"def signature; end",
"def signature; end",
"def signature; end",
"def signature; end",
"def signature; end",
"def signature; end",
"def index\n begin\n\n # Instantiate the PadesSignatureStarter class, responsible for receiving the signature elements and start\n # the signature process\n signature_starter = RestPki::PadesSignatureStarter.new(get_restpki_client)\n\n # Set the signature policy\n signature_starter.signature_policy_id = RestPki::StandardSignaturePolicies::PADES_BASIC\n\n # Set the security context to be used to determine trust in the certificate chain\n signature_starter.security_context_id = get_security_context_id\n\n # Set the visual representation for the signature\n signature_starter.visual_representation = {\n text: {\n\n # The tags {{name}} and {{national_id}} will be substituted according to the user's certificate\n #\n # name : full name of the signer\n # national_id : if the certificate is ICP-Brasil, contains the signer's CPF\n #\n # For a full list of the supported tags, see: https://github.com/LacunaSoftware/RestPkiSamples/blob/master/PadesTags.md\n text: 'Signed by {{signerName}} ({{signerNationalId}})',\n # Specify that the signing time should also be rendered\n horizontalAlign: 'Left',\n # Optionally set the horizontal alignment of the text ('Left' or 'Right'), if not set the default is\n # Left\n includeSigningTime: true,\n # Optionally set the container within the signature rectangle on which to place the text. By\n # default, the text can occupy the entire rectangle (how much of the rectangle the text will\n # actually fill depends on the length and font size). Below, we specify that the text should respect\n # a right margin of 1.5 cm.\n container: {\n left: 0,\n top: 0,\n right: 1.5,\n bottom: 0\n }\n\n },\n image: {\n\n # We'll use as background the image content/PdfStamp.png\n resource: {\n content: Base64.encode64(get_pdf_stamp_content),\n mimeType: 'image/png'\n },\n # Opacity is an integer from 0 to 100 (0 is completely transparent, 100 is completely opaque).\n opacity: 50,\n # Align the image to the right\n horizontalAlign: 'Right',\n # Align the image to the center\n verticalAlign: 'Center'\n\n },\n # Position of the visual representation. We have encapsulated this code in a function to include several\n # possibilities depending on the argument passed to the function. Experiment changing the argument to\n # see different examples of signature positioning. Once you decide which is best for your case, you can\n # place the code directly here. See file helpers/pades_helper.rb\n position: get_visual_representation_position(1)\n }\n\n # Below we'll either set the PDF file to be signed. Prefer passing a path or a stream instead of the file's\n # contents as a byte array to prevent memory allocation issues with large files.\n @userfile = params[:userfile]\n if @userfile.nil?\n\n # If the URL argument \"userfile\" is filled, it means the user was redirected by upload_controller\n # (signature with file upload by user). We'll set the path of the file to be signed, which was saved in\n # the temporary folder by upload_controller (such a file would normally come from your application's\n # database)\n signature_starter.set_pdf_tosign_from_path(get_sample_doc_path)\n\n else\n\n # If userfile is null, this is the \"signature with server file\" case. We'll set the file to be signed\n # by passing its path\n signature_starter.set_pdf_tosign_from_path(Rails.root.join('public', 'uploads', @userfile))\n\n end\n\n # Call the start_with_webpki method, which initiates the signature. This yields the token, a 43-character\n # case-sensitive URL-safe string, which identifies this signature process. We'll use this value to call the\n # sign_with_restpki method on the Web PKI component (see signature-form.js) and also to complete the\n # signature after the form is submitted (see method create below). This should not be mistaken with the\n # API access token.\n @token = signature_starter.start_with_webpki\n\n # The token acquired above can only be used for a single signature attempt. In order to retry the signature\n # it is necessary to get a new token. This can be a problem if the user uses the back button of the browser,\n # since the browser might show a cached page that we rendered previously, with a now stale token. To prevent\n # this from happening, we call the method set_expired_page_headers, located in application_helper.rb, which\n # sets HTTP headers to prevent caching of the page.\n set_expired_page_headers\n\n rescue => ex\n @error = ex\n render 'layouts/_error'\n end\n end",
"def parse_signing_description\n parts = @signing_description.strip.split(\";\").inject({ }) do |memo, part|\n field_name, field_value = part.split(\"=\")\n memo[field_name.to_sym] = field_value.strip\n memo\n end\n Mixlib::Authentication::Log.debug \"Parsed signing description: #{parts.inspect}\"\n end",
"def signed; end",
"def can_tweak_sign?(normal_sign, vandalized_sign)\nend",
"def form_code\n @form.current_version.code\n end",
"def createsignature(str)\r\n signature_raw = sign(str)\r\n signature_der = ECDSA::Format::SignatureDerString.encode(signature_raw)\r\n signature_der_b64 = Base64.strict_encode64(signature_der) \r\n digest_raw = Digest::SHA256.digest(str)\r\n digest_b64 = Base64.encode64(digest_raw)\r\n #Base64 encoding was used due to the readablility, and transportability. \r\n puts(\"Signature (b64 encoded der): \"+signature_der_b64)\r\n puts(\"Digest (b64 endoded): \"+digest_b64)\r\n $signature_array.push(signature_der_b64)\r\n $digest_array.push(digest_b64)\r\n #return signature_der_b64\r\nend"
] | [
"0.71437633",
"0.6932859",
"0.6932859",
"0.64043474",
"0.64043474",
"0.63532674",
"0.6196729",
"0.6192886",
"0.61652654",
"0.61143655",
"0.61014444",
"0.60939246",
"0.6086866",
"0.6086866",
"0.60786575",
"0.60775405",
"0.606628",
"0.60344094",
"0.59105015",
"0.59105015",
"0.58399516",
"0.58217084",
"0.5777209",
"0.5767928",
"0.5684813",
"0.5673833",
"0.5662998",
"0.5662595",
"0.56362724",
"0.56150216",
"0.55950916",
"0.5577024",
"0.5570579",
"0.55606824",
"0.55477816",
"0.5536834",
"0.5526947",
"0.5517328",
"0.5515038",
"0.5496078",
"0.5463723",
"0.5437755",
"0.54376745",
"0.54176784",
"0.53984666",
"0.5383089",
"0.5363109",
"0.53287315",
"0.53287315",
"0.532507",
"0.5321984",
"0.5320245",
"0.5319506",
"0.5311017",
"0.5297569",
"0.5291586",
"0.5278439",
"0.5273349",
"0.52679104",
"0.5263537",
"0.5260948",
"0.52532005",
"0.52501935",
"0.5247712",
"0.52433527",
"0.5234589",
"0.52284044",
"0.52246195",
"0.5224297",
"0.5222124",
"0.5221268",
"0.52147317",
"0.5214592",
"0.5209168",
"0.5204689",
"0.5199891",
"0.5188749",
"0.51873755",
"0.5182809",
"0.51785594",
"0.5176907",
"0.51752645",
"0.5165981",
"0.5159194",
"0.51544076",
"0.51517785",
"0.51517785",
"0.51517785",
"0.51517785",
"0.51517785",
"0.51517785",
"0.51517785",
"0.51517785",
"0.51517785",
"0.51517785",
"0.5143448",
"0.51429373",
"0.514181",
"0.5141796",
"0.5137518",
"0.5137122"
] | 0.0 | -1 |
Returns a new TextInjector that injects context using the specified header key | def initialize(correlation_context_key: 'otcorrelations')
@correlation_context_key = correlation_context_key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def header\n @header ||= HeaderController.new config\n end",
"def text_injector\n TEXT_INJECTOR\n end",
"def match_header(key)\n @env[key.upcase.tr(\"-\",\"_\")]\n end",
"def inject_headers!(obj)\n procid = obj[:options][:header]\n if procid && header_proc = header_procs[procid]\n data = userdata[obj.id]\n obj.trailing, trailing = nil, obj.trailing\n obj.message = header_proc.call(obj.message, data)\n obj.trailing = header_proc.call(trailing, data) if !trailing.to_s.empty?\n end\n end",
"def resolve_headers(view_context); end",
"def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter)\n span_context = Trace.current_span(context).context\n return unless span_context.valid?\n\n flags = to_jaeger_flags(context, span_context)\n trace_span_identity_value = [\n span_context.hex_trace_id, span_context.hex_span_id, '0', flags\n ].join(':')\n setter.set(carrier, IDENTITY_KEY, trace_span_identity_value)\n OpenTelemetry::Baggage.values(context: context).each do |key, value|\n baggage_key = 'uberctx-' + key\n encoded_value = CGI.escape(value)\n setter.set(carrier, baggage_key, encoded_value)\n end\n carrier\n end",
"def interpolate(ctx)\n hmap do |key, value|\n if value.is_a? String\n { key => value % ctx }\n else\n { key => value }\n end\n end\n end",
"def initialize\n # pass\n @truncation_helper = ::Datadog::DistributedTracing::Headers::Headers.new({})\n end",
"def shared_key(env)\n token = env[options[:header_token]]\n\n shared_token = options[:klass].send(options[:method].to_s, token)\n shared_token.to_s\n end",
"def header\n @header ||= create_header\n end",
"def extract(carrier, context: Context.current, getter: Context::Propagation.text_map_getter)\n header = getter.get(carrier, IDENTITY_KEY)\n return context unless header\n return context unless (match = header.match(TRACE_SPAN_IDENTITY_REGEX))\n return context if match['trace_id'] =~ ZERO_ID_REGEX\n return context if match['span_id'] =~ ZERO_ID_REGEX\n\n sampling_flags = match['sampling_flags'].to_i\n span = build_span(match, sampling_flags)\n context = Jaeger.context_with_debug(context) if sampling_flags & DEBUG_FLAG_BIT != 0\n context = context_with_extracted_baggage(carrier, context, getter)\n Trace.context_with_span(span, parent_context: context)\n end",
"def inject_request_headers(state, request)\n cross_app_id = TingYun::Agent.config[:tingyunIdSecret]\n\n request[TY_ID_HEADER] = \"#{cross_app_id};c=1;x=#{state.request_guid}\"\n end",
"def add_response_header(key, value)\n new(\n response_headers: ConnSupport::Headers.add(\n response_headers, key, value\n )\n )\n end",
"def construct_header(headers:)\n if v = headers[TRACE_HEADER_PROXY] || headers[TRACE_HEADER]\n TraceHeader.from_header_string header_str: v\n else\n TraceHeader.empty_header\n end\n end",
"def extract_key(ctx); end",
"def initialize( body, line=nil, column=nil )\n\t\tsuper\n\n\t\tkey = self.body[ /^([a-z]\\w+)$/ ] or\n\t\t\traise Inversion::ParseError,\n\t\t\t\t\"malformed key: expected simple identifier, got %p\" % [ self.body ]\n\t\t@key = key.to_sym\n\tend",
"def extract(carrier, context: Context.current, getter: Context::Propagation.text_map_getter)\n header = getter.get(carrier, XRAY_CONTEXT_KEY)\n return context unless header\n\n match = parse_header(header)\n return context unless match\n\n span_context = Trace::SpanContext.new(\n trace_id: to_trace_id(match['trace_id']),\n span_id: to_span_id(match['span_id']),\n trace_flags: to_trace_flags(match['sampling_state']),\n tracestate: to_trace_state(match['trace_state']),\n remote: true\n )\n\n span = OpenTelemetry::Trace.non_recording_span(span_context)\n context = XRay.context_with_debug(context) if match['sampling_state'] == 'd'\n Trace.context_with_span(span, parent_context: context)\n rescue OpenTelemetry::Error\n context\n end",
"def get_context(key)\n @context[key]\n end",
"def key_in_header_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: UsageApi.key_in_header ...'\n end\n # resource path\n local_var_path = '/header'\n\n # query parameters\n query_params = opts[:query_params] || {}\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] || 'Object'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['api_key']\n\n new_options = opts.merge(\n :operation => :\"UsageApi.key_in_header\",\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: UsageApi#key_in_header\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def pdf_with_header(header:)\n info = {\n 'Title': header,\n 'Author': ENV['APP_NAME'],\n 'Creator': 'RLetters',\n 'Producer': 'Prawn',\n 'CreationDate': Time.now\n }\n\n pdf = Prawn::Document.new(info: info,\n page_size: 'LETTER',\n page_layout: :landscape,\n margin: 72)\n\n # Add all the known font families\n FONTS.each do |name, root|\n add_font_family(pdf: pdf, name: name, root: root)\n end\n\n # Draw the header\n pdf.font('Roboto') do\n pdf.text(header, align: :center, size: 18, style: :bold)\n pdf.move_down(20)\n end\n\n yield(pdf)\n\n # Number the pages\n pdf.fill_color('000000')\n pdf.font('Roboto') do\n pdf.number_pages('<page>/<total>', at: [pdf.bounds.right - 150, -30],\n width: 150,\n align: :right)\n end\n\n pdf.render\n end",
"def processed_header\n lineno = 0\n @processed_header ||= header.lines.map { |line|\n lineno += 1\n\n # Replace directive line with a clean break\n # Replace `#target` line with collect target application name\n\n unless directives.assoc(lineno).nil?\n \"\\n\"\n else\n \n line.scan(/^(\\#target) (\\S+.*?)$/) do |m1,m2|\n _app_name = m2.split(/[\\-|\\s]/).map{|x| x.gsub(/['|\"|;]/,\"\").downcase}\n _reg_name = Jsx::CS::REG_NAME[_app_name[0]]\n raise Jsx::Platform::UndeterminedApplicationError if _reg_name.nil?\n _vers = Jsx::CS::VERSIONS[_app_name[0]].invert\n _app_ver = (_app_name.size==1)? _vers[Jsx::CS::DEFAULTS[_app_name[0]]] : _app_name[1]\n line = line.gsub(m2,\"#{_reg_name}-#{_app_ver}\")\n end\n \n line\n end\n }.join.chomp\n end",
"def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter)\n span_context = Trace.current_span(context).context\n return unless span_context.valid?\n\n sampling_state = if XRay.debug?(context)\n 'd'\n elsif span_context.trace_flags.sampled?\n '1'\n else\n '0'\n end\n\n ot_trace_id = span_context.hex_trace_id\n xray_trace_id = \"1-#{ot_trace_id[0..7]}-#{ot_trace_id[8..ot_trace_id.length]}\"\n parent_id = span_context.hex_span_id\n\n xray_value = \"Root=#{xray_trace_id};Parent=#{parent_id};Sampled=#{sampling_state}\"\n\n setter.set(carrier, XRAY_CONTEXT_KEY, xray_value)\n nil\n end",
"def initialize(header_text = nil, charset = nil)\n @charset = charset\n self.raw_source = header_text\n split_header if header_text\n end",
"def extract(carrier, context, &getter)\n getter ||= default_getter\n header = getter.call(carrier, @b3_key)\n return context unless (match = header.match(B3_CONTEXT_REGEX))\n\n span_context = Trace::SpanContext.new(\n trace_id: B3.to_trace_id(match['trace_id']),\n span_id: B3.to_span_id(match['span_id']),\n trace_flags: to_trace_flags(match['sampling_state']),\n remote: true\n )\n\n span = Trace::Span.new(span_context: span_context)\n context = B3.context_with_debug(context) if match['sampling_state'] == 'd'\n Trace.context_with_span(span, parent_context: context)\n rescue OpenTelemetry::Error\n context\n end",
"def initialize(env, key)\n @env = env\n @key = key\n end",
"def translate_header(header, value)\n value\n end",
"def initialize(context, offset = T.unsafe(nil), decrypter = T.unsafe(nil)); end",
"def [](key)\n @header[key]\n end",
"def headers\r\nHttp::Headers.new(@env)\r\nend",
"def page_header(header = nil)\n content_tag(:div, class: 'page-header') do\n content_tag(:h1) do\n content_tag(:span, header || t('.header')) +\n content_tag(:div, class: 'pull-right') do\n yield if block_given?\n end\n end\n end\n end",
"def merge_log_weasel_header(headers)\n if LogWeasel::Transaction.id\n headers.merge(LogWeasel::Middleware::KEY_HEADER => LogWeasel::Transaction.id)\n else\n headers\n end\n end",
"def api_key_header\n {'X-API-KEY' => 'some_api_key'}\n end",
"def header(haders, name)\n headers[name]\n end",
"def text_map_injector\n TEXT_MAP_INJECTOR\n end",
"def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter)\n span_context = Trace.current_span(context).context\n return unless span_context.valid?\n\n setter.set(carrier, TRACERESPONSE_KEY, TraceParent.from_span_context(span_context).to_s)\n nil\n end",
"def dynamic_headers\n {\n 'Authorization' => token,\n 'RequestID' => request_id,\n }\n end",
"def from_s(header)\n reset\n\n # ghettoooooo!\n # If we don't have any newlines..., put one there.\n if (header.size > 0 && header !~ /\\r\\n/)\n header << \"\\r\\n\"\n end\n\n # put the non-standard line terminations back to normal\n # gah. not having look behinds suck,\n header.gsub!(/([^\\r])\\n/n,'\\1' + \"\\r\\n\")\n\n # undo folding, kinda ugly but works for now.\n header.gsub!(/:\\s*\\r\\n\\s+/smni,': ')\n\n # Extract the command string\n self.cmd_string = header.slice!(/.+\\r\\n/)\n\n # Extract each header value pair\n header.split(/\\r\\n/mn).each { |str|\n if (md = str.match(/^(.+?)\\s*:\\s*(.+?)\\s*$/))\n if (self[md[1]])\n self[md[1]] << \", \" + md[2]\n else\n self[md[1]] = md[2]\n end\n end\n }\n end",
"def context_key(key)\n context_keys.push key\n end",
"def text_map_injector\n TEXT_MAP_INJECTOR\n end",
"def text_map_injector\n TEXT_MAP_INJECTOR\n end",
"def [](k) @headers[translate_header_to_sym(k)] end",
"def set_header\n @header = Header.find(params[:id])\n end",
"def set_header\n @header = Header.find(params[:id])\n end",
"def build_header(keys_template)\n header = ''\n names = []\n keys = deep_copy(keys_template)\n\n keys.each { |key|\n begin\n if @config.header_mappings.any? { |k| k.include? key }\n\n header_label = key\n\n @config.header_mappings.each { |k, v|\n if header_label.include? k\n header_label.gsub!(k, v)\n end\n\n }\n names << header_label\n\n elsif @config.header_overrides.split(',').include?(key)\n names << key\n elsif key.include?('coordinates')\n names << key\n elsif key.split('.')[-1].is_i?\n names << key\n else\n #We want to grab the last element and add it to the array.\n name = key.split(\".\")[-1]\n\n if !names.include?(name)\n names << name\n else\n if key.split(\".\")[-2].is_i?\n name = key.split(\".\")[-3..-1].join(\".\")\n else\n name = key.split(\".\")[-2..-1].join(\".\")\n end\n\n if !names.include?(name)\n names << name\n else\n name = key.split(\".\")[-3..-1].join(\".\")\n if !names.include?(name)\n names << name\n else\n #p \"No action taken. #{name} not added to name array. (build_header)\"\n end\n end\n end\n end\n rescue Exception => e\n AppLogger.log.error(\"ERROR in build_header method with #{key}: #{e.message}\")\n end\n }\n\n header = CSV.generate do |csv|\n csv << names\n end\n\n header\n end",
"def render_header( notification )\n\t\ttemplate = self.load_template( HEADER_TEMPLATE )\n\t\treturn template.result( binding() )\n\tend",
"def inject(carrier, context, setter = nil)\n span_context = Trace.current_span(context).context\n return unless span_context.valid?\n\n sampling_state = if XRay.debug?(context)\n 'd'\n elsif span_context.trace_flags.sampled?\n '1'\n else\n '0'\n end\n\n ot_trace_id = span_context.hex_trace_id\n xray_trace_id = \"1-#{ot_trace_id[0..6]}-#{ot_trace_id[7..ot_trace_id.length]}\"\n parent_id = span_context.hex_span_id\n\n xray_value = \"Root=#{xray_trace_id};Parent=#{parent_id};Sampled=#{sampling_state}\"\n\n setter ||= @default_setter\n setter.set(carrier, XRAY_CONTEXT_KEY, xray_value)\n carrier\n end",
"def initialize(key, text)\n super()\n @key = key\n @text = text\n end",
"def from_string(header) # rubocop:disable Metrics/CyclomaticComplexity:\n return DEFAULT if header.nil? || header.empty?\n\n hash = header.split(',').each_with_object({}) do |member, memo|\n member.strip!\n kv = member.split('=')\n k, v = *kv\n next unless kv.length == 2 && VALID_KEY.match?(k) && VALID_VALUE.match?(v)\n\n memo[k] = v\n end\n return DEFAULT if hash.empty?\n\n new(hash)\n end",
"def auth_header\n { 'Authorization': \"Bearer #{@auth.token}\" }.with_indifferent_access\n end",
"def store_search_header\n $tracer.trace(__method__)\n return ToolTag.new(div.className(create_ats_regex_string(\"ats-storesearch-header\")).h1, __method__)\n end",
"def join_pur_header_label\n # unit_test_no_generate: join_pur_header_label, h1.className(create_ats_regex_string(\"ats-joinpurhdrlbl\"))\n $tracer.trace(__method__)\n return ToolTag.new(h1.className(create_ats_regex_string(\"ats-joinpurhdrlbl\")), __method__)\n end",
"def extract(carrier, context, getter = nil)\n getter ||= default_getter\n trace_id = optionally_pad_trace_id(getter.get(carrier, TRACE_ID_HEADER))\n span_id = getter.get(carrier, SPAN_ID_HEADER)\n sampled = getter.get(carrier, SAMPLED_HEADER)\n\n return context unless valid?(trace_id: trace_id, span_id: span_id)\n\n span_context = Trace::SpanContext.new(\n trace_id: Array(trace_id).pack('H*'),\n span_id: Array(span_id).pack('H*'),\n trace_flags: sampled == 'true' ? Trace::TraceFlags::SAMPLED : Trace::TraceFlags::DEFAULT,\n remote: true\n )\n\n span = Trace::Span.new(span_context: span_context)\n Trace.context_with_span(span, parent_context: set_baggage(carrier: carrier, context: context, getter: getter))\n end",
"def header(name, value)\n name = name.upcase\n name.tr!('-', '_')\n name = \"HTTP_#{name}\" unless name == 'CONTENT_TYPE' || name == 'CONTENT_LENGTH'\n env(name, value)\n end",
"def inject_request_headers( request )\n cross_app_id = NewRelic::Agent.config[:cross_process_id] or\n raise NewRelic::Agent::CrossAppTracing::Error, \"no cross app ID configured\"\n\n NewRelic::Agent::TransactionState.get.is_cross_app_caller = true\n txn_guid = NewRelic::Agent::TransactionState.get.request_guid\n txn_data = NewRelic::JSONWrapper.dump([ txn_guid, false ])\n\n request[ NR_ID_HEADER ] = obfuscator.obfuscate( cross_app_id )\n request[ NR_TXN_HEADER ] = obfuscator.obfuscate( txn_data )\n\n rescue NewRelic::Agent::CrossAppTracing::Error => err\n NewRelic::Agent.logger.debug \"Not injecting x-process header\", err\n end",
"def personal_info_header_label\n # unit_test_no_generate: personal_info_header_label, h2.className(create_ats_regex_string(\"ats-personalinfohdrlbl\"))\n $tracer.trace(__method__)\n return ToolTag.new(h2.className(create_ats_regex_string(\"ats-personalinfohdrlbl\")), __method__)\n end",
"def header(name)\n req = request\n return nil unless req\n req.env[name]\n end",
"def consent_header_label\n # unit_test_no_generate: consent_header_label, h2.className(create_ats_regex_string(\"ats-consenthdrlbl\"))\n $tracer.trace(__method__)\n return ToolTag.new(h2.className(create_ats_regex_string(\"ats-consenthdrlbl\")), __method__)\n end",
"def delete_response_header(key)\n new(\n response_headers: ConnSupport::Headers.delete(\n response_headers, key\n )\n )\n end",
"def get_header(key, options = nil)\n policy = create_policy(options, Policy, default_read_policy)\n command = ReadHeaderCommand.new(@cluster, policy, key)\n execute_command(command)\n command.record\n end",
"def make_load_header(text_line)\n EdiHelper::edi_log.write \"LI PreProcessor: Creating missing LH record from LD record...\",0\n\n detail_data = RawFixedLenRecord.new('LI', 'LD', text_line)\n header_data = RawFixedLenRecord.new('LI', 'LH')\n ignore_fields = ['load_date', 'instruction_quantity']\n line = header_data.populate_with_values_from( detail_data, ignore_fields )\n\n EdiHelper::edi_log.write \"LI PreProcessor: Created missing LH record from LD record.\",0\n line\n end",
"def with_headers(tmp_headers)\n current_headers = @headers\n set_headers(tmp_headers)\n yield\n ensure\n set_headers(current_headers)\n end",
"def generate_header(provider = nil)\n header = Qrda::Header.new(@@cda_header)\n\n header.identifier.root = UUID.generate\n header.authors.each {|a| a.time = Time.now}\n header.legal_authenticator.time = Time.now\n header.performers << provider\n\n header\n end",
"def call(header_configuration)\n nonce_b64, nonce_binary = yield generate_nonce\n created_time = yield generate_created_time\n created_value = encode_created(created_time)\n digest = yield generate_digest(header_configuration, nonce_binary, created_value)\n Success(\n build_token_values(\n header_configuration,\n nonce_b64,\n created_value,\n created_time,\n digest\n )\n )\n end",
"def with_custom_headers(header)\n @header = header\n self\n end",
"def header(name)\n @env.response_headers[name]\n end",
"def header(text, header_level)\n # clean string from html\n stringHeader = Sanitize.clean(text)\n\n # replace all unwanted characters to space\n stringHeader = stringHeader.downcase.gsub(/[^a-z0-9_-]+/i, \" \")\n\n # strip whitespaces from the beginning and end of a string\n stringHeader = stringHeader.strip\n\n # replace all unwanted characters to -\n stringHeader = stringHeader.downcase.gsub(/[^a-z0-9_-]+/i, \"-\")\n\n # convert number to string\n stringHeaderNum = header_level.to_s\n\n # create header\n result = '<h' + stringHeaderNum + ' id=\"' + stringHeader + '\">' + text + '</h' + stringHeaderNum + '>'\n\n return result\n end",
"def parse_and_generate_header (source)\n parsed_header = parse_header(\"module\", source)\n FffMockGenerator.create_mock_header(\"module\", \"mock_module\", parsed_header)\nend",
"def authenticate_bearer(header)\n @token ||= {}\n @token[header] ||= orig_authenticate_bearer(header)\n end",
"def parse_header(module_name, source)\n cm_config = CMockConfig.new(nil)\n cm_parser = CMockHeaderParser.new(cm_config)\n cm_parser.parse(module_name, source)\nend",
"def set_header key, value\n headers.update(key => value)\n end",
"def resolve_headers(view_context)\n all_headers = DEFAULT_HEADERS.merge(headers)\n\n if csrf\n all_headers = all_headers.merge(CSRF_TOKEN_HEADER)\n end\n\n all_headers.each_with_object({}) do |(key, value), memo|\n memo[key] = value.call(view_context)\n end\n end",
"def header=(new_header)\n @header = new_header\n # prepare defaults\n @header[\"description\"] ||= \"\"\n # handle tags\n @dependencies = parse_tag_list(Array(@header[\"requires\"]))\n @provides = parse_tag_list(Array(@header[\"provides\"]))\n\n @extends = case @header[\"extends\"]\n when Array then Tag.new(@header[\"extends\"][0])\n when String then Tag.new(@header[\"extends\"])\n else nil\n end\n\n @replaces = case @header[\"replaces\"]\n when Array then Tag.new(@header[\"replaces\"][0])\n when String then Tag.new(@header[\"replaces\"])\n else nil\n end\n end",
"def auth_header\n { :token => @token, :seq => @seqid }\n end",
"def [](key)\n @headers[key]\n end",
"def header(args = {}, &block)\n build_base_component :header, args, &block\n end",
"def new(context)\n dup.tap do |logger|\n logger.context = \"#{logger.context}#{context_separator}#{context}\"\n end\n end",
"def with_headers(tmp_headers)\n current_headers = @headers\n add_headers(tmp_headers)\n yield\n ensure\n add_headers(current_headers)\n end",
"def with_headers(tmp_headers)\n current_headers = @headers\n add_headers(tmp_headers)\n yield\n ensure\n add_headers(current_headers)\n end",
"def exposed_header(headerName=nil)\n if headerName.class == String && !block_given?\n @j_del.java_method(:exposedHeader, [Java::java.lang.String.java_class]).call(headerName)\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling exposed_header(headerName)\"\n end",
"def inject(span_context, format, carrier)\n case format\n when OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY, OpenTracing::FORMAT_RACK\n return carrier\n else\n warn 'Unknown inject format'\n end\n end",
"def parse_header\n header.each do |field, value|\n self.instance_variable_set(\"@#{field}\", value) if HEADER_FIELDS.include? field\n end\n end",
"def inject(what, title = 'Something important', data = Hash.new,\n custom_vars = Array.new, custom_scripts = Array.new)\n syringe = Syringe.new(engine, what, title, data, gem_libdir,\n custom_vars, custom_scripts)\n syringe.actual_injection\n syringe.get_result\n end",
"def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter)\n span_context = Trace.current_span(context).context\n return unless span_context.valid?\n\n setter.set(carrier, TRACEPARENT_KEY, TraceParent.from_span_context(span_context).to_s)\n setter.set(carrier, TRACESTATE_KEY, span_context.tracestate.to_s) unless span_context.tracestate.empty?\n nil\n end",
"def new_header\n SimpleOAuth::Header.new(\n request_method,\n API_URL,\n params,\n client.oauth_options\n )\n end",
"def merge_headers(headers)\n self.class.new(@request_env.merge(request_headers: @request_env[:request_headers].merge(headers)))\n end",
"def context(status, header, body, request)\n @context = context_retriever(request)&.call(status, header, body)\n @data[:request_context] = @context[:context_id] \\\n if @context && @context[:context_id]\n @context\n end",
"def generate_header(provider = nil)\n cda_header = { identifier: { root: 'CypressRoot', extension: 'CypressExtension' },\n authors: [{ ids: [{ root: 'authorRoot', extension: 'authorExtension' }],\n device: { name: 'deviceName', model: 'deviceModel' },\n addresses: [], telecoms: [], time: nil,\n organization: { ids: [{ root: 'authorsOrganizationRoot', extension: 'authorsOrganizationExt' }], name: '' } }],\n custodian: { ids: [{ root: 'custodianRoot', extension: 'custodianExt' }],\n person: { given: '', family: '' }, organization: { ids: [{ root: 'custodianOrganizationRoot',\n extension: 'custodianOrganizationExt' }], name: '' } },\n legal_authenticator: { ids: [{ root: 'legalAuthenticatorRoot', extension: 'legalAuthenticatorExt' }], addresses: [],\n telecoms: [], time: nil,\n person: { given: nil, family: nil },\n organization: { ids: [{ root: 'legalAuthenticatorOrgRoot', extension: 'legalAuthenticatorOrgExt' }],\n name: '' } } }\n\n header = Qrda::Header.new(cda_header)\n\n header.identifier.root = UUID.generate\n header.authors.each { |a| a.time = Time.current }\n header.legal_authenticator.time = Time.current\n header.performers << provider\n\n header\n end",
"def env_name(header_name)\n @headers.include?(header_name) ? header_name : cgi_name(header_name)\n end",
"def disclaimers_header_label\n # unit_test_no_generate: disclaimers_header_label, h2.className(create_ats_regex_string(\"ats-disclaimershdrlbl\"))\n $tracer.trace(__method__)\n return ToolTag.new(h2.className(create_ats_regex_string(\"ats-disclaimershdrlbl\")), __method__)\n end",
"def generate(pdf, heading)\n pdf.move_down(heading[:top_padding])\n pdf.formatted_text([text_properties(heading)])\n end",
"def set_header(auth_headers)\n header 'access-token', auth_headers['access-token']\n header 'token-type', auth_headers['token-type']\n header 'client', auth_headers['client']\n header 'expiry', auth_headers['expiry']\n header 'uid', auth_headers['uid']\nend",
"def compose_header(key, value)\n Util.escape_zero_byte(\"#{key}: #{value}\")\n end",
"def find_header(header)\n {}.tap do |returning|\n contents.scan(header_with_content_regexp(header)).flatten.first.split(\"\\n\").each do |setting|\n name, value = *setting.split('=').map(&:strip)\n returning[name] = value\n end\n end\n end",
"def inject(carrier, context, &setter)\n span_context = Trace.current_span(context).context\n return unless span_context.valid?\n\n sampling_state = if B3.debug?(context)\n 'd'\n elsif span_context.trace_flags.sampled?\n '1'\n else\n '0'\n end\n\n b3_value = \"#{span_context.hex_trace_id}-#{span_context.hex_span_id}-#{sampling_state}\"\n\n setter ||= default_setter\n setter.call(carrier, @b3_key, b3_value)\n carrier\n end",
"def header_tag_adder(incoming_text)\n tagged_text = incoming_text.map do |line|\n if line.include?('#')\n line = \"<h#{line.count('#')}>\" + line + \"</h#{line.count('#')}>\"\n line.sub(\"#\"*(\"#{line.count('#')}\".to_i) + \" \", \"\")\n else\n line\n end\n end\n end",
"def context_type_individual_category_header\n ContextTypeDef.new(\n :individual_category_header,\n [\n /\\s*(MASTER|M)\\s([23456789][50])\\s(maschi|femmi)/i,\n /\\s*(RI)\\s*((\\d{1,2}'\\d{2}.|\\d{2}.)\\d{2})/i\n ],\n :event_summary_header\n )\n end",
"def add(text, level=1)\n name = text.parameterize\n if @headers.include? name\n name += '-%d' % (@headers[name] += 1)\n else @headers[name] = 0 end\n Header.new(text, level, name)\n end",
"def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter)\n @injector.inject(carrier, context, setter)\n rescue => e # rubocop:disable Style/RescueStandardError\n OpenTelemetry.logger.warn \"Error in Propagator#inject #{e.message}\"\n carrier\n end",
"def []=(k, v) @headers[translate_header_to_sym(k)] = v end",
"def apply_header(options, key, value)\n options.merge! :headers => {} unless options.has_key? :headers\n options[:headers].merge!({ key => value })\n end",
"def prepend_header(name, value)\n end"
] | [
"0.5000711",
"0.4993099",
"0.48815724",
"0.4871315",
"0.47960123",
"0.4789204",
"0.4723824",
"0.46729827",
"0.46440515",
"0.46383604",
"0.46351716",
"0.46245736",
"0.46235472",
"0.4620351",
"0.45772737",
"0.45549497",
"0.4548138",
"0.45458016",
"0.45453897",
"0.4530776",
"0.45283723",
"0.45270428",
"0.4525297",
"0.4524006",
"0.44778237",
"0.44762567",
"0.4460447",
"0.44490027",
"0.44374415",
"0.4435955",
"0.4435357",
"0.44302168",
"0.44070128",
"0.439194",
"0.4386401",
"0.43826765",
"0.43789393",
"0.43715876",
"0.4360108",
"0.4360108",
"0.43541908",
"0.4346543",
"0.4346543",
"0.43456534",
"0.43425527",
"0.43278378",
"0.43256348",
"0.431972",
"0.43150106",
"0.43128896",
"0.4298791",
"0.4294692",
"0.42870677",
"0.42839986",
"0.42780662",
"0.42711788",
"0.42697832",
"0.4269476",
"0.42579922",
"0.4246603",
"0.4245887",
"0.42448312",
"0.4237053",
"0.42339423",
"0.42326415",
"0.42208895",
"0.4209325",
"0.420792",
"0.420398",
"0.41915867",
"0.41887617",
"0.41857633",
"0.41794375",
"0.4176091",
"0.41704893",
"0.41614532",
"0.41609216",
"0.41609216",
"0.41585055",
"0.41523585",
"0.4147426",
"0.41469523",
"0.4145311",
"0.41440293",
"0.41417223",
"0.4140459",
"0.4140221",
"0.41395634",
"0.41297823",
"0.41272163",
"0.4124789",
"0.412231",
"0.41189224",
"0.4114291",
"0.41112295",
"0.41098565",
"0.4109846",
"0.4102959",
"0.41018102",
"0.40990946",
"0.4096195"
] | 0.0 | -1 |
Inject inprocess correlations into the supplied carrier. | def inject(carrier, context, &setter)
return carrier unless (correlations = context[ContextKeys.correlation_context_key]) && !correlations.empty?
setter ||= default_setter
setter.call(carrier, @correlation_context_key, encode(correlations))
carrier
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inject(carrier, context = Context.current, &setter)\n @injectors.inject(carrier) do |memo, injector|\n injector.inject(memo, context, &setter)\n rescue => e # rubocop:disable Style/RescueStandardError\n OpenTelemetry.logger.warn \"Error in CompositePropagator#inject #{e.message}\"\n carrier\n end\n end",
"def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter)\n injectors = @injectors || @propagators\n injectors.each do |injector|\n injector.inject(carrier, context: context, setter: setter)\n rescue StandardError => e\n OpenTelemetry.logger.warn \"Error in CompositePropagator#inject #{e.message}\"\n end\n nil\n end",
"def inject(carrier, context = Context.current, &setter)\n @injector.inject(carrier, context, &setter)\n rescue => e # rubocop:disable Style/RescueStandardError\n OpenTelemetry.logger.warn \"Error in Propagator#inject #{e.message}\"\n carrier\n end",
"def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter)\n @injector.inject(carrier, context, setter)\n rescue => e # rubocop:disable Style/RescueStandardError\n OpenTelemetry.logger.warn \"Error in Propagator#inject #{e.message}\"\n carrier\n end",
"def inject(carrier, context, setter = nil)\n span_context = Trace.current_span(context).context\n return unless span_context.valid?\n\n sampling_state = if XRay.debug?(context)\n 'd'\n elsif span_context.trace_flags.sampled?\n '1'\n else\n '0'\n end\n\n ot_trace_id = span_context.hex_trace_id\n xray_trace_id = \"1-#{ot_trace_id[0..6]}-#{ot_trace_id[7..ot_trace_id.length]}\"\n parent_id = span_context.hex_span_id\n\n xray_value = \"Root=#{xray_trace_id};Parent=#{parent_id};Sampled=#{sampling_state}\"\n\n setter ||= @default_setter\n setter.set(carrier, XRAY_CONTEXT_KEY, xray_value)\n carrier\n end",
"def assign_carrier(carrier)\n specified_carrier = self.class.reflections[:carrier].klass.carrier_by_value(carrier)\n self.carrier = specified_carrier if specified_carrier\n end",
"def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter)\n span_context = Trace.current_span(context).context\n return unless span_context.valid?\n\n sampling_state = if XRay.debug?(context)\n 'd'\n elsif span_context.trace_flags.sampled?\n '1'\n else\n '0'\n end\n\n ot_trace_id = span_context.hex_trace_id\n xray_trace_id = \"1-#{ot_trace_id[0..7]}-#{ot_trace_id[8..ot_trace_id.length]}\"\n parent_id = span_context.hex_span_id\n\n xray_value = \"Root=#{xray_trace_id};Parent=#{parent_id};Sampled=#{sampling_state}\"\n\n setter.set(carrier, XRAY_CONTEXT_KEY, xray_value)\n nil\n end",
"def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter)\n span_context = Trace.current_span(context).context\n return unless span_context.valid?\n\n flags = to_jaeger_flags(context, span_context)\n trace_span_identity_value = [\n span_context.hex_trace_id, span_context.hex_span_id, '0', flags\n ].join(':')\n setter.set(carrier, IDENTITY_KEY, trace_span_identity_value)\n OpenTelemetry::Baggage.values(context: context).each do |key, value|\n baggage_key = 'uberctx-' + key\n encoded_value = CGI.escape(value)\n setter.set(carrier, baggage_key, encoded_value)\n end\n carrier\n end",
"def inject(carrier, context, &setter)\n span_context = Trace.current_span(context).context\n return unless span_context.valid?\n\n sampling_state = if B3.debug?(context)\n 'd'\n elsif span_context.trace_flags.sampled?\n '1'\n else\n '0'\n end\n\n b3_value = \"#{span_context.hex_trace_id}-#{span_context.hex_span_id}-#{sampling_state}\"\n\n setter ||= default_setter\n setter.call(carrier, @b3_key, b3_value)\n carrier\n end",
"def extract(carrier, context = Context.current, &getter)\n @extractors.inject(context) do |ctx, extractor|\n extractor.extract(carrier, ctx, &getter)\n rescue => e # rubocop:disable Style/RescueStandardError\n OpenTelemetry.logger.warn \"Error in CompositePropagator#extract #{e.message}\"\n ctx\n end\n end",
"def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter)\n span_context = Trace.current_span(context).context\n return unless span_context.valid?\n\n setter.set(carrier, TRACERESPONSE_KEY, TraceParent.from_span_context(span_context).to_s)\n nil\n end",
"def extract(carrier, context: Context.current, getter: Context::Propagation.text_map_getter)\n extractors = @extractors || @propagators\n extractors.inject(context) do |ctx, extractor|\n extractor.extract(carrier, context: ctx, getter: getter)\n rescue StandardError => e\n OpenTelemetry.logger.warn \"Error in CompositePropagator#extract #{e.message}\"\n ctx\n end\n end",
"def extract(carrier)\n raise NotImplementedError\n end",
"def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter)\n span_context = Trace.current_span(context).context\n return unless span_context.valid?\n\n setter.set(carrier, TRACEPARENT_KEY, TraceParent.from_span_context(span_context).to_s)\n setter.set(carrier, TRACESTATE_KEY, span_context.tracestate.to_s) unless span_context.tracestate.empty?\n nil\n end",
"def inject(span_context, format, carrier)\n @propagator.inject(span_context, format, carrier)\n end",
"def extract(carrier)\n # First extract & build a Datadog context\n datadog_trace_digest = Tracing::Propagation::HTTP.extract(carrier)\n\n # Then extract any other baggage\n baggage = {}\n carrier.each do |key, value|\n baggage[header_to_baggage(key)] = value if baggage_header?(key)\n end\n\n SpanContextFactory.build(\n datadog_context: nil,\n datadog_trace_digest: datadog_trace_digest,\n baggage: baggage\n )\n end",
"def extract(carrier)\n # First extract & build a Datadog context\n headers = DistributedHeaders.new(carrier)\n\n datadog_context = if headers.valid?\n Datadog::Context.new(\n trace_id: headers.trace_id,\n span_id: headers.parent_id,\n sampling_priority: headers.sampling_priority,\n origin: headers.origin\n )\n else\n Datadog::Context.new\n end\n\n # Then extract any other baggage\n baggage = {}\n carrier.each do |key, value|\n baggage[item_to_baggage(key)] = value if baggage_item?(key)\n end\n\n SpanContextFactory.build(datadog_context: datadog_context, baggage: baggage)\n end",
"def sms_side_effects\n old_observers = SmsCarrier::Sms.class_variable_get(:@@delivery_notification_observers)\n old_delivery_interceptors = SmsCarrier::Sms.class_variable_get(:@@delivery_interceptors)\n yield\n ensure\n SmsCarrier::Sms.class_variable_set(:@@delivery_notification_observers, old_observers)\n SmsCarrier::Sms.class_variable_set(:@@delivery_interceptors, old_delivery_interceptors)\n end",
"def set_carrier\n @carrier = Carrier.find(params[:id])\n end",
"def extract(carrier, context = Context.current, &getter)\n @extractor.extract(carrier, context, &getter)\n rescue => e # rubocop:disable Style/RescueStandardError\n OpenTelemetry.logger.warn \"Error in Propagator#extract #{e.message}\"\n context\n end",
"def set_correlation\n @correlation = Correlation.find(params[:id])\n end",
"def run(controller)\n track_originating_call\n start_ringback controller\n prep_calls\n place_calls\n end",
"def extract(carrier, context: Context.current, getter: Context::Propagation.text_map_getter)\n context\n end",
"def load_carrier_data(objects)\n objects.carriers.each_with_object({}) do |carrier, data|\n data[carrier.key] = carrier.to_hash\n end\n end",
"def extract(carrier, context: Context.current, getter: Context::Propagation.text_map_getter)\n header = getter.get(carrier, XRAY_CONTEXT_KEY)\n return context unless header\n\n match = parse_header(header)\n return context unless match\n\n span_context = Trace::SpanContext.new(\n trace_id: to_trace_id(match['trace_id']),\n span_id: to_span_id(match['span_id']),\n trace_flags: to_trace_flags(match['sampling_state']),\n tracestate: to_trace_state(match['trace_state']),\n remote: true\n )\n\n span = OpenTelemetry::Trace.non_recording_span(span_context)\n context = XRay.context_with_debug(context) if match['sampling_state'] == 'd'\n Trace.context_with_span(span, parent_context: context)\n rescue OpenTelemetry::Error\n context\n end",
"def carrier_to_carrier_conversion(node, carrier, direction)\n Qernel::Causality::Conversion.conversion(\n node.node,\n carrier,\n direction,\n @context.carrier,\n target_slot_direction(node)\n )\n end",
"def with_scorpion( &block )\n ensure_scorpion( scorpion )\n scorpion.inject self\n\n yield\n ensure\n free_scorpion\n end",
"def setup\n super do |server_app, binder|\n binder.forward :concurrency\n\n yield(server_app, binder) if block_given?\n end\n end",
"def extract(carrier, context, &getter)\n getter ||= default_getter\n header = getter.call(carrier, @b3_key)\n return context unless (match = header.match(B3_CONTEXT_REGEX))\n\n span_context = Trace::SpanContext.new(\n trace_id: B3.to_trace_id(match['trace_id']),\n span_id: B3.to_span_id(match['span_id']),\n trace_flags: to_trace_flags(match['sampling_state']),\n remote: true\n )\n\n span = Trace::Span.new(span_context: span_context)\n context = B3.context_with_debug(context) if match['sampling_state'] == 'd'\n Trace.context_with_span(span, parent_context: context)\n rescue OpenTelemetry::Error\n context\n end",
"def use(processor)\n @processors << processor\n self\n end",
"def extract(carrier, context: Context.current, getter: Context::Propagation.text_map_getter)\n trace_parent_value = getter.get(carrier, TRACEPARENT_KEY)\n return context unless trace_parent_value\n\n tp = TraceParent.from_string(trace_parent_value)\n tracestate = Tracestate.from_string(getter.get(carrier, TRACESTATE_KEY))\n\n span_context = Trace::SpanContext.new(trace_id: tp.trace_id,\n span_id: tp.span_id,\n trace_flags: tp.flags,\n tracestate: tracestate,\n remote: true)\n span = OpenTelemetry::Trace.non_recording_span(span_context)\n OpenTelemetry::Trace.context_with_span(span, parent_context: context)\n rescue OpenTelemetry::Error\n context\n end",
"def carriers\n @carriers ||= collection(Atlas::Carrier)\n end",
"def extract(carrier, context: Context.current, getter: Context::Propagation.text_map_getter)\n @extractor.extract(carrier, context, getter)\n rescue => e # rubocop:disable Style/RescueStandardError\n OpenTelemetry.logger.warn \"Error in Propagator#extract #{e.message}\"\n context\n end",
"def set_Carrier(value)\n set_input(\"Carrier\", value)\n end",
"def populate_carriers!\n primary_carriers = Set.new\n final_carriers = Set.new\n\n @graph.nodes.each do |conv|\n if conv.query.right_dead_end? || conv.primary_energy_demand?\n primary_carriers.merge(conv.outputs.map { |c| c.carrier.key })\n end\n\n if conv.final_demand_group?\n final_carriers.merge(conv.outputs.map { |c| c.carrier.key })\n end\n end\n\n @primary_carriers = primary_carriers.to_a.sort\n @final_carriers = final_carriers.to_a.sort\n end",
"def extract(carrier, context, getter = nil)\n getter ||= default_getter\n trace_id = optionally_pad_trace_id(getter.get(carrier, TRACE_ID_HEADER))\n span_id = getter.get(carrier, SPAN_ID_HEADER)\n sampled = getter.get(carrier, SAMPLED_HEADER)\n\n return context unless valid?(trace_id: trace_id, span_id: span_id)\n\n span_context = Trace::SpanContext.new(\n trace_id: Array(trace_id).pack('H*'),\n span_id: Array(span_id).pack('H*'),\n trace_flags: sampled == 'true' ? Trace::TraceFlags::SAMPLED : Trace::TraceFlags::DEFAULT,\n remote: true\n )\n\n span = Trace::Span.new(span_context: span_context)\n Trace.context_with_span(span, parent_context: set_baggage(carrier: carrier, context: context, getter: getter))\n end",
"def extract(carrier, context: Context.current, getter: Context::Propagation.text_map_getter)\n header = getter.get(carrier, IDENTITY_KEY)\n return context unless header\n return context unless (match = header.match(TRACE_SPAN_IDENTITY_REGEX))\n return context if match['trace_id'] =~ ZERO_ID_REGEX\n return context if match['span_id'] =~ ZERO_ID_REGEX\n\n sampling_flags = match['sampling_flags'].to_i\n span = build_span(match, sampling_flags)\n context = Jaeger.context_with_debug(context) if sampling_flags & DEBUG_FLAG_BIT != 0\n context = context_with_extracted_baggage(carrier, context, getter)\n Trace.context_with_span(span, parent_context: context)\n end",
"def on_process( &block )\n @processor = block\n end",
"def carrier_code=(carrier_code)\n @carrier_code = carrier_code if %w{USPS UPS FedEx other}.include?(carrier_code)\n end",
"def set_value(key, value, context: Context.current)\n new_correlations = correlations_for(context).dup\n new_correlations[key] = value\n context.set_value(CORRELATION_CONTEXT_KEY, new_correlations)\n end",
"def extract(format, carrier)\n @propagator.extract(format, carrier)\n end",
"def carrier_by_value(carrier)\n phone_carrier = case carrier.class.to_s\n when 'Symbol', 'String' then find_by_name(carrier)\n when \"#{self.class.to_s}\" then carrier\n when 'Fixnum' then find_by_id(carrier)\n else nil\n end\n end",
"def register_interceptors(*interceptors)\r\n interceptors.flatten.compact.each { |interceptor| register_interceptor(interceptor) }\r\n end",
"def before_intercept(&block)\n @before_intercept = block if block_given?\n \n self\n end",
"def use(processor, options = {})\n @stack << [self.class.get_callable(processor, Roger::Release::Processors.map), options]\n end",
"def hook_into_callback_chain(env, aroundware)\n async_callback = env['async.callback']\n\n # The response from the downstream app is accepted by the aroundware...\n downstream_callback = Proc.new do |resp|\n safely(env){ aroundware.call(resp) }\n end\n\n # .. but the upstream chain is only invoked when the aroundware completes\n invoke_upstream_chain = Proc.new do\n new_resp = safely(env){ aroundware.post_process }\n async_callback.call(new_resp)\n end\n\n env['async.callback'] = downstream_callback\n aroundware.callback(&invoke_upstream_chain)\n aroundware.errback(&invoke_upstream_chain)\n end",
"def application_interaction\n model = ArchimateCache.instance.for_context(context)\n dr_engine = ::Archimate::DerivedRelations.new(model)\n\n relationship_filter = ->(rel) { rel.weight >= ::Archimate::DataModel::Serving::WEIGHT }\n\n plateau_today = model.elements.find(&::Archimate::DataModel.by_name(plateau))\n today_rels = model.relationships.select do |rel|\n rel.source.id == plateau_today.id &&\n %w[CompositionRelationship AggregationRelationship].include?(rel.type) &&\n rel.target.type == \"ApplicationComponent\"\n end\n today_apps = today_rels.map(&:target)\n target_filter = ->(el) { today_apps.map(&:id).include?(el.id) }\n stop_filter = ->(el) { el.type == \"ApplicationComponent\" }\n\n concrete_rels = model.relationships.select do |rel|\n rel.type == \"ServingRelationship\" &&\n today_apps.include?(rel.source.id) &&\n today_apps.include?(rel.target.id)\n end\n\n derived_rels = dr_engine.derived_relations(\n today_apps,\n relationship_filter,\n target_filter,\n stop_filter\n )\n\n @all_rels = [concrete_rels, derived_rels].flatten\n\n @callers = @all_rels.map(&:source).uniq.sort { |a, b| a.name.to_s <=> b.name.to_s }\n @callees = @all_rels.map(&:target).uniq.sort { |a, b| a.name.to_s <=> b.name.to_s }\n end",
"def inject(span_context, format, carrier)\n case format\n when OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY, OpenTracing::FORMAT_RACK\n return carrier\n else\n warn 'Unknown inject format'\n end\n end",
"def in_feat_corr_of_uf(uf_feat_inst)\n @corr_router.in_feat_corr_of_uf(uf_feat_inst)\n end",
"def intra_hook(that_binding, key, value)\n # put possible hooks here that will be called once per loop\n @intra_hooks.each { |e| e.call(that_binding, key, value) }\n end",
"def absorb other\n # Act only if there's not already an image in the absorber\n unless picref\n if otherpic = other.method(other.class.image_reference_name).call\n self.method(:\"#{self.class.image_reference_name}=\").call otherpic\n end\n end\n super if defined? super\n end",
"def trap_community\n super\n end",
"def carrier=(carrier)\n validator = EnumAttributeValidator.new('String', [\"USPS\"])\n unless validator.valid?(carrier)\n fail ArgumentError, \"invalid value for \\\"carrier\\\", must be one of #{validator.allowable_values}.\"\n end\n @carrier = carrier\n end",
"def carrier=(carrier)\n validator = EnumAttributeValidator.new('String', [\"USPS\"])\n unless validator.valid?(carrier)\n fail ArgumentError, \"invalid value for \\\"carrier\\\", must be one of #{validator.allowable_values}.\"\n end\n @carrier = carrier\n end",
"def carrier=(carrier)\n validator = EnumAttributeValidator.new('String', [\"USPS\"])\n unless validator.valid?(carrier)\n fail ArgumentError, \"invalid value for \\\"carrier\\\", must be one of #{validator.allowable_values}.\"\n end\n @carrier = carrier\n end",
"def intercept(klass, meth_name, type, &block)\n orig_name = \"aop_orig_#{meth_name}\".to_sym\n meth_name = meth_name.to_sym\n @intercepted_methods ||= Hash.new do |h,k| \n # h[class_name] = hash\n h[k] = Hash.new do |h,k|\n # h[class_name][method_name] = hash\n h[k] = Hash.new do |h,k| \n # h[class_name][method_name][interception_type] = array\n h[k] = []\n end\n end\n end\n \n make_interception = !@intercepted_methods[klass].has_key?(meth_name)\n @intercepted_methods[klass][meth_name][type] << block\n method_chain = @intercepted_methods[klass][meth_name]\n \n if make_interception\n klass.class_eval do\n alias_method orig_name, meth_name\n define_method(meth_name) do |*args|\n method_chain[:before].each { |m| m.call(self, args) }\n # The result of the callcc block will either be the last line in the actual\n # ruby block, or it will be whatever is passed as arguments when calling the \n # +abort_continuation+ proc\n callcc do |abort_continuation|\n # First lambda in chain is the call to the original method\n call_lambda = lambda { send(orig_name, *args) }\n method_chain[:around].each do |m|\n # Make a chain of lambdas that calls the previouly defined\n # lambda, thus creating a chain of around blocks that will\n # all finally reach the original method block\n prev_call_lambda = call_lambda\n call_lambda = lambda {\n # If +prev_call_lambda+ is called, the next around block in\n # chain until the last one which corresponds to the original method call\n # if +abort_continuation+ is called, then this loop is aborted and the\n # callcc block returns whatever was passed as an argument to the proc call\n m.call(self, args, prev_call_lambda, abort_continuation)\n }\n end\n result = call_lambda.call\n method_chain[:after].each { |m| m.call(self, result, args) }\n result\n end\n end\n end\n end\n end",
"def process(&block)\n @processor = block\n self\n end",
"def third_party_processors; end",
"def call(env)\n env[@correlation_header] ||= SecureRandom.uuid\n RequestStore.store[:correlation_id] = env[@correlation_header]\n\n @status, @headers, @response = @app.call(env)\n [@status, @headers, @response]\n end",
"def forward_object_receiver(receiver, method, name, *_args)\n define_method(name) do |*args, &b|\n receiver.__send__(method, *args, &b)\n end\n end",
"def setup\n super\n @processor = nil\n end",
"def import_carrier(carrier)\n data =\n Atlas::EnergyNode.all.each_with_object({}) do |node, hash|\n config = node.public_send(carrier)\n next unless config\n\n hash[config.type] ||= []\n hash[config.type].push(node.key)\n end\n\n data.transform_values(&:freeze)\n data.freeze\n end",
"def compose(interactor)\n Interactors::Sequence.new.compose(self).compose(interactor)\n end",
"def add_order(order_id, carrier)\n @carrier = carrier\n @order = Spree::Order.find(order_id)\n @ship_carrier = Settings['supported_carriers'].include?(carrier) ? ENV[\"#{carrier.upcase}_CARRIER_ID\"] : nil\n @ship_carrier.present? && @order.shipment.present? ? create_shipment : return_error\n end",
"def initialize(correlation_context_key: 'otcorrelations')\n @correlation_context_key = correlation_context_key\n end",
"def insert_interceptor_before(before_class, interceptor_class, opts = {})\n raise ServerAlreadyStartedError if @started\n\n @interceptors.insert_before(before_class, interceptor_class, opts)\n end",
"def forward_proc_receiver(proc, method, name, *_args)\n define_method(name) do |*args, &b|\n instance_eval(&proc).__send__(method, *_args, *args, &b)\n end\n end",
"def hook_into_callback_chain(env, *args)\n async_callback = env['async.callback']\n\n # The response from the downstream app is sent to post_process\n # and then directly up the callback chain\n downstream_callback = Proc.new do |status, headers, body|\n new_resp = safely(env){ post_process(env, status, headers, body, *args) }\n async_callback.call(new_resp)\n end\n\n env['async.callback'] = downstream_callback\n end",
"def correlation_id=(value)\n @correlation_id = value\n end",
"def run\n super\n\n # Replace bad characters\n #\n # For future, consider:\n # http://stackoverflow.com/questions/20650681/ruby-gsub-multiple-characters-in-string\n phone_number = _get_entity_attribute(\"name\").gsub(\".\",\"\").gsub(\" \",\"\").gsub(\"-\",\"\").gsub(\"(\",\"\").gsub(\")\",\"\")\n\n # get the API key\n api_key = _get_global_config \"carrierlookup_api_key\"\n\n lookup_uri = \"http://www.carrierlookup.com/index.php/api/lookup?key=#{api_key}&number=#{phone_number}\"\n\n begin\n response = http_get_body lookup_uri\n attributes = JSON.parse response if response\n\n if attributes[\"Response\"][\"error\"]\n _log_error \"Error querying API #{attributes[\"Response\"][\"error\"]}\"\n return\n end\n\n _log \"You have #{attributes[\"Response\"][\"creditBalance\"]} credits remaining.\"\n\n # Edit the phone number entity\n @entity.details[\"carrier_type\"] = attributes[\"Response\"][\"carrier_type\"]\n @entity.details[\"carrier\"] = attributes[\"Response\"][\"carrier\"]\n @entity.save\n\n _log \"Carrier Type: #{@entity.details[\"carrier_type\"]}\"\n _log \"Carrier: #{@entity.details[\"carrier\"]}\"\n\n # Add an info entity_ids\n #{}_create_entity \"Info\", attributes.merge({\"name\" => \"Carrier Lookup for #{phone_number}: #{attributes}\"})\n\n rescue JSON::ParserError\n _log_error \"Unable to retrieve provider info\"\n end\n\n end",
"def build_context(context: Context.current)\n builder = Builder.new(correlations_for(context).dup)\n yield builder\n context.set_value(CORRELATION_CONTEXT_KEY, builder.entries)\n end",
"def register_processor(*args, &block)\n register_preprocessor(*args, &block)\n end",
"def fulfill_order(line_item_id, carrier, tracking)\n order = ShopifyOrder.find_by name: line_item_id\n unique_data = {\n order_id: order.id,\n tracking_company: carrier_map(carrier),\n }\n # find or initialize a fulfilment with the associated order and carrier\n begin\n fulfillment = ShopifyAPI::Fulfillment.find(:first, params: unique_data)\n fulfillment.tracking_numbers = (fulfillment.tracking_numbers + [tracking]).uniq\n fulfilment.save\n rescue ActiveResource::ResourceNotFound\n ShopifyAPI::Fulfillment.create(unique_data.merge({\n line_items: order.line_items.map{|line_item| { id: line_item['id'] }},\n notify_customer: true,\n tracking_numbers: [tracking],\n }))\n end\n\n # using the setter/getter methods results in MethodMissing errors, so interact\n # with the attribute hash instead\n\n\nend",
"def correlation_id=(correlation_id); @message_impl.setCorrelationId correlation_id; end",
"def forward_class_receiver(method, name, *_args)\n define_method(name) do |*args, &b|\n self.class.__send__(method, *_args, *args, &b)\n end\n end",
"def use(processor)\n definition << processor\n processor\n end",
"def entrapment\n # setup trap chain once.\n Base.trapped = true\n app = self\n\n # 'get' previous trap by replacing any existing trap with 'IGNORE'\n previous_trap = trap(:INT, 'IGNORE')\n\n # substitute our trap and chain it to previous by explicitly invoking\n # the previous trap. ruby makes this somewhat difficult and rack then\n # makes it even harder.\n trap(:INT) do\n begin\n # loggers may have closed file handles in a trap so disconnect any\n # loggers from multiplexer before continuing. even when they do not\n # raise exceptions they still appear to log nothing at this point\n # (not sure about syslog, definitely not file or console).\n if app.logger.respond_to?(:targets)\n # HACK: it is bad that Multiplexer#targets exposes its internal\n # array in a manner that allows us to clear it. it would be better\n # if to have a Multiplexer#reset method we could call instead.\n # to ensure that cleaning continues to work, check the result\n # afterward. note that we tried iterating targets and calling the\n # Multiplexer#remove method but that had no effect.\n app.logger.targets.clear\n fail 'Unexpected targets' unless app.logger.targets.empty?\n app.logger.warn('cannot log traps') # no exception raised\n end\n\n # interrupt any running app threads to resolve outstanding requests.\n #\n # note that Mutex#synchronize is not allowed inside a trap context.\n #\n # FIX: duplicating the set is slightly unsafe but not sure how else\n # to deal with data protected by critical section in a trap. we also\n # have logic in ensure block to avoid modifying set on interrupt.\n app.class.interrupted = true\n app_threads = app.class.app_threads.dup\n app_threads.each do |app_thread|\n if app_thread.alive?\n app_thread.raise(::Interrupt)\n app_thread.join\n end\n end\n\n # cleanup fixtures, if requested.\n app.cleanup\n if previous_trap && previous_trap.respond_to?(:call)\n previous_trap.call\n else\n exit\n end\n rescue ::Exception => e\n # loggers are unreliable so write any rescued error home.\n msg = ([e.class, e.message] + (e.backtrace || [])).join(\"\\n\")\n dir = ::ENV['HOME'] || ::Dir.pwd\n path = ::File.join(dir, 'might_api_rescued_error.txt')\n ::File.open(path, 'w') { |f| f.puts msg }\n exit 1\n end\n end\n true\n end",
"def prepend(other)\n duplicates = processors & other.processors\n raise_duplicate_processor_error(duplicates) if duplicates.any?\n self.class.new(name, other.processors | processors)\n end",
"def process\n Trade::Shipment.where(taxon_concept_id: @old_taxon_relationship.taxon_concept_id,\n reported_taxon_concept_id: @taxon_relationship.other_taxon_concept_id)\n .update_all(taxon_concept_id: @taxon_relationship.taxon_concept_id)\n end",
"def include(*a)\n res = super\n def_roda_before\n def_roda_after\n res\n end",
"def update_origin_plates\n # operations that have not yet errored are guarenteed to correspond to correct colonies on the original plates.\n # we will update the associations of the origin plate for each op to reflect this new verified colony\n operations.running.select { |op| op.input(\"PCR\").sample_type.name != 'Plasmid' }.each do |op|\n # Use association map to cleanly deal with data associated to parts of a collection\n colony_pick = op.input(\"PCR\").part.get(:colony_pick).to_i\n origin_plate_id = op.input(\"PCR\").part.get(:origin_plate_id).to_i\n \n if origin_plate_id && Item.exists?(origin_plate_id) && colony_pick\n origin_plate = Item.find(origin_plate_id)\n correct_colonies = origin_plate.get(:correct_colonies) ? origin_plate.get(:correct_colonies) : []\n \n # rely on idempotence of .to_s to normalize correct \n # colony association into an array regardless\n # of whether it started in array or string format.\n correct_colonies.to_s.chomp(']').chomp!('[') #convert Array to string representation if Array and remove brackets (if string: stays the same)\n correct_colonies = correct_colonies.split(\",\") #string array back to array\n \n correct_colonies.push \"c#{colony_pick}\"\n origin_plate.associate(:correct_colonies, correct_colonies)\n end\n end\n end",
"def before_method(method)\n @@before_methods << method\n @@wrap_exclusions << method.to_sym # This method will not be wrapped.\n end",
"def enrich_object(fawry_params)\n fawry_params.each_key do |key|\n method_name = key.to_s.split(/(?=[A-Z])/).map(&:downcase).join('_') # statusCode => status_code\n instance_variable_set(\"@#{method_name}\", fawry_params[key])\n method_body = proc { instance_variable_get(\"@#{method_name}\") }\n\n self.class.public_send(:define_method, method_name, method_body)\n end\n end",
"def around_enqueue(*filters, &blk)\n set_callback(:enqueue, :around, *filters, &blk)\n end",
"def process(env)\n raise \"Please ensure you call init before processing\" unless inited?\n @processor.process(env)\n end",
"def method_missing(method, *args, &block)\n #$stderr.puts \"Method missing: #{method}\"\n if @_receivers.last.respond_to?(method)\n #$stderr.puts \"Proxy [#{method}] to receiver\"\n @_receivers.last.__send__(method, *args, &block)\n else\n #$stderr.puts \"Proxy [#{method}] to context\"\n @_context.__send__(method, *args, &block)\n end\n end",
"def carrier_code\n @raw_data[:CarrierCode]\n end",
"def inject(frame)\n\t\t@sock.send(frame, 0)\n\tend",
"def inject(frame)\n\t\t@sock.send(frame, 0)\n\tend",
"def register_receiver(target, source, options={})\n receivers[source] = target\n target.send(:extend, Communicator::ActiveRecordIntegration::ClassMethods)\n target.send(:include, Communicator::ActiveRecordIntegration::InstanceMethods)\n\n target.skip_remote_attributes(*options[:except]) if options[:except]\n Communicator.logger.info \"Registered #{target} as receiver for messages from #{source}\"\n \n target\n end",
"def dynamic_forwarding\n super\n end",
"def inject_into(object)\n return unless object.is_a? Dependent\n\n dependencies = object.class.dependencies\n dependencies.each_pair do |id, attribute|\n # Don't replace existing attributes\n next if object.public_send attribute\n\n resolved = resolve id\n object.public_send \"#{attribute}=\", resolved\n end\n end",
"def client_streamer(requests: nil, call: nil, method: nil, metadata: nil)\n GRPC.logger.debug \"Intercepting client streamer method #{method}\" \\\n \" for requests #{requests} with call #{call} and metadata: #{metadata}\"\n yield\n end",
"def capture_internal_interaction(env)\n req = Rack::Request.new(env)\n transaction = Rack::VCR::Transaction.new(req)\n\n if @replay && transaction.can_replay?\n transaction.replay\n else\n status, headers, body = capture_external_interactions { @app.call(env) }\n res = Rack::Response.new(body, status, headers)\n transaction.capture(res)\n [status, headers, body]\n end\n end",
"def call(request_context:)\n logger.debug \"Logging client interceptor for request: #{request_context.method}\"\n yield\n end",
"def create\n @carrier = Carrier.new(carrier_params)\n\n respond_to do |format|\n if @carrier.save\n format.html { redirect_to @carrier, flash: { success: \"Carrier was successfully created.\" } }\n format.json { render action: 'show', status: :created, location: @carrier }\n else\n format.html { render action: 'new' }\n format.json { render json: @carrier.errors, status: :unprocessable_entity }\n end\n end\n end",
"def process\n Trade::Shipment.update_all(\n { taxon_concept_id: @taxon_relationship.taxon_concept_id },\n {\n taxon_concept_id: @old_taxon_relationship.taxon_concept_id,\n reported_taxon_concept_id: @taxon_relationship.other_taxon_concept_id\n }\n )\n end",
"def do_carrier_lookup(phone, opts = {})\n data, _status_code, _headers = do_carrier_lookup_with_http_info(phone, opts)\n data\n end",
"def add_to_rioter(rioter)\n\n\t\t\t\t# pre-setup - combine blocks added\n\t\t\t\trioter.setup_node = lambda {|node,defaults|\n\t\t\t\t\tnode_setup_blocks.each {|blk| blk[node,defaults]}\n\t\t\t\t}\n\n\t\t\t\t# in-setup - combine blocks added\n\t\t\t\trioter.node_defaults = lambda {|node,defaults|\n\t\t\t\t\tnode_default_blocks.each {|blk| blk[node,defaults]}\n\t\t\t\t}\n\n\t\t\t\t# post-setup\n\t\t\t\trioter.consolidate_node = @node_consolidation_block\n\n\t\t\t\t# create and bind acts\n\t\t\t\tacts.each do |act|\n\t\t\t\t\tact.extend helper_mod \n\t\t\t\t\tact.bind_rioter(rioter)\n\t\t\t\tend\n\n\t\t\t\t# bind event processors\n\t\t\t\tevent_processors.each do |ev_proc|\n\t\t\t\t\tev_proc.bind(rioter)\n\t\t\t\tend\n\n\t\t\t\trioter = Rioter.new\n\t\t\t\trioter\n\t\t\tend",
"def execute_middleware_chain\n self.process_started_at = Time.now\n\n Cloudenvoy.config.subscriber_middleware.invoke(self) do\n begin\n process(message)\n rescue StandardError => e\n logger.error([e, e.backtrace.join(\"\\n\")].join(\"\\n\"))\n try(:on_error, e)\n raise(e)\n end\n end\n ensure\n self.process_ended_at = Time.now\n end"
] | [
"0.7050875",
"0.6734479",
"0.65621763",
"0.63016534",
"0.5946533",
"0.5832985",
"0.57912904",
"0.57182926",
"0.5652006",
"0.56405365",
"0.5390068",
"0.5379433",
"0.52942514",
"0.52912015",
"0.5278401",
"0.52620333",
"0.52503556",
"0.5047367",
"0.5037935",
"0.49455997",
"0.49292183",
"0.49247435",
"0.4921491",
"0.48547614",
"0.4847415",
"0.481322",
"0.47706485",
"0.4766377",
"0.4756701",
"0.4754981",
"0.47166777",
"0.46955433",
"0.4680699",
"0.46391487",
"0.45796713",
"0.45648983",
"0.4549617",
"0.45446602",
"0.4490676",
"0.44721198",
"0.44620943",
"0.44387943",
"0.44358173",
"0.44340956",
"0.44220528",
"0.44208622",
"0.43861192",
"0.43859243",
"0.43547723",
"0.4354518",
"0.4331365",
"0.43221787",
"0.43208927",
"0.43208927",
"0.43208927",
"0.42923567",
"0.42781436",
"0.42761976",
"0.42716125",
"0.4271178",
"0.42705023",
"0.4259119",
"0.4248174",
"0.4239737",
"0.42361847",
"0.423024",
"0.42231533",
"0.42213008",
"0.42193317",
"0.42094567",
"0.41872334",
"0.417843",
"0.41783556",
"0.41775048",
"0.41746432",
"0.4168184",
"0.41548067",
"0.41545415",
"0.41482767",
"0.41387",
"0.4135065",
"0.41277444",
"0.41203907",
"0.41140318",
"0.41083553",
"0.41036767",
"0.41023463",
"0.41019198",
"0.41016412",
"0.40994182",
"0.40972275",
"0.40910292",
"0.40878803",
"0.40842772",
"0.4083212",
"0.40809315",
"0.40761214",
"0.40734512",
"0.40733814",
"0.40701845"
] | 0.7411865 | 0 |
Returns true if the target_modules == :all, or contains the module_name in the collection. | def can_use(module_name)
target_is_all? or target_includes? module_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def includes_modules?\n @includes_modules\n end",
"def has_modules?\n m = @context.modules.find{|m| m.document_self}\n m ? true : false\n end",
"def matchRequirement?(modules)\n modules.nil? or modules.all? {|mod| has_key?(mod)}\n end",
"def has_all?\n @privileges.fetch(@target) == :all\n end",
"def active?(submodule_name)\n active.select { |s| s[:name].to_s == submodule_name.to_s }.any?\n end",
"def patched?\n target.included_modules.include? self\n end",
"def one_target?\n return OneTarget.include?(target)\n end",
"def any?\n !@disabled.empty? || @all_disabled\n end",
"def has_classes_or_modules?\n has_classes? || has_modules?\n end",
"def modules_enabled?\n return nil unless target\n setting = target.resolved_build_setting(\"CLANG_ENABLE_MODULES\")[\"Release\"]\n return nil unless setting\n setting == \"YES\"\n end",
"def module_loaded? mod\n Bot::Modules.include? mod\n end",
"def current_class_all_there?\n expected_items.array.flatten.all? { |name| there?(name) }\n end",
"def include?(arg)\n arg.is_a?(Module) ? !!included_modules.detect{ |m| m === arg } : store.include?(arg)\n end",
"def is_known\n TargetsXML.has_target(@name)\n end",
"def enabled?\n any?(&:enabled?)\n end",
"def section_classes_all_there?\n section_classes_to_check.all?(&:all_there?)\n end",
"def exists?(module_name)\n const_name = module_name.to_s.camel_case\n slice_names.include?(const_name) && Object.const_defined?(const_name)\n end",
"def translates?\n included_modules.include?(InstanceMethods)\n end",
"def is_module_presents?(modulename)\n abort \"No ssh session found\" if @ssh.nil?\n r = @ssh.do_ssh_cmd(\n \"ls #{@puppetfolder}/#{@modulesfolder}/#{modulename}\"\n )\n r[:exit_code] == 0 ? true : false\n end",
"def custom_module?\n # custom module names are all lower_case, whereas SugarCRM modules are CamelCase\n @name.downcase == @name \n end",
"def custom_module?\n # custom module names are all lower_case, whereas SugarCRM modules are CamelCase\n @name.downcase == @name \n end",
"def module_eigenclass?(target)\n target < Module\n end",
"def published?\n self.targets.map { |tgt| File.exist?(File.join(\n self.publish_path, self.to_s, tgt)) }.all?\n end",
"def contains_all(target_itemset)\n return false if target_itemset.nil?\n\n pos = 0\n\n target_itemset.each do |target_freqitem| \n\n id_target = target_freqitem.freq_item_id\n target_found = false\n\n self[pos..-1].each do |freqitem|\n pos += 1\n\n if freqitem.freq_item_id > id_target\n return false \n elsif freqitem.freq_item_id == id_target\n # target found, check the next frequent item\n target_found = true\n break\n end\n end\n\n return false unless target_found\n end\n\n return true\n end",
"def satisfied_by?(mod)\n @type == mod.type && @git == mod.git\n end",
"def include_targets\n return @include_targets\n end",
"def satisfied_by?(mod)\n @type == mod.type &&\n @full_name.downcase == mod.full_name.downcase &&\n !mod.version.nil? &&\n @semantic_version.cover?(mod.version)\n end",
"def include?(name)\n includes?(name)\n end",
"def has_target?(rop, target)\n rop.elements.each('compatibility/target') { |t|\n return true if t.text =~ /#{target}/i\n }\n return false\n end",
"def sections_classes_all_there?\n sections_classes_to_check.flatten.all?(&:all_there?)\n end",
"def has_remote_package_sets?\n each_remote_package_set.any? { true }\n end",
"def all?\n @options[:all].present?\n end",
"def has_key?(key)\n any? {|mod| mod.name == key}\n end",
"def target_in_privileges?\n @privileges.key?(@target)\n end",
"def match_all?\n self.class.array_matching == :all\n end",
"def module_loaded?\n /^#{new_resource.modname}/.match?(::File.read(\"/proc/modules\"))\n end",
"def elements_include_mods?(*elements)\n elements.any? { |n| n =~ /[\\-\\+]/ }\n end",
"def elements_include_mods?(*elements)\n elements.any? { |n| n =~ /[\\-\\+]/ }\n end",
"def include?(target)\n preferences.include?(target)\n end",
"def any?\n only_with('any?', 'Boolean')\n items.compact.any?\n end",
"def current_item_enabled?() target end",
"def includes_all? *args\n args.all? { |arg| include? arg }\n end",
"def can_access_to_module? mod\n Rails.cache.fetch(\"can_access_to_module_#{mod.id}_#{self.id}\", expire_in: 1.month) do\n all_user_modules.include?(mod)\n end\n end",
"def has? *rolegroups\n list == rolegroups.to_symbols_uniq\n end",
"def run_module?( mod, page )\n return false if mod.issue_limit_reached?\n\n elements = mod.info[:elements]\n return true if !elements || elements.empty?\n\n elems = {\n Element::LINK => page.links.any? && @opts.audit_links,\n Element::FORM => page.forms.any? && @opts.audit_forms,\n Element::COOKIE => page.cookies.any? && @opts.audit_cookies,\n Element::HEADER => page.headers.any? && @opts.audit_headers,\n Element::BODY => !page.body.empty?,\n Element::PATH => true,\n Element::SERVER => true\n }\n\n elems.each_pair { |elem, expr| return true if elements.include?( elem ) && expr }\n false\n end",
"def checkModuleAvailable\n @@cleanAvailableModules.each do |m|\n if m.chomp.eql? @@raidType.getRaidType\n\t return true\n\t else puts \"No available modules\"\n end\n end\n end",
"def target_set?\n return true unless target.nil?\n return nil if ecs_compatibility == :disabled\n false # target isn't set\n end",
"def namespace_module?\n return false if exp.type == :casgn\n contents = exp.children.last\n contents && contents.find_nodes([:def, :defs], [:casgn, :class, :module]).empty?\n end",
"def is_target_context?(context)\n match = false\n @targets.each do |t|\n reg = [ t['alias'], t['name'] ]\n if @include_own_expenses == true\n reg.concat [ @enterprise[\"alias\"], @enterprise[\"name\"] ]\n end\n regex = Regexp.new( reg.join(\"|\"), Regexp::IGNORECASE )\n match = regex.match(context) != nil ? true : false;\n break if match != false\n end\n return match\n end",
"def include?(value)\n return super if value.is_a?(Module)\n\n !self[value].nil?\n end",
"def global?\n module_name.nil? || module_name == NAMESPACE_WILDCARD || module_name == ENVIRONMENT\n end",
"def module?\n @type == :module\n end",
"def module?\n @type == :module\n end",
"def all?\n only_with('all?', 'Boolean')\n items.compact.all?\n end",
"def include?(user, target)\n @detect.call(user, target)\n end",
"def included?\n @_included\n end",
"def include?(arr, target)\n arr.any?{ |ele| ele == target} ? true : false\nend",
"def should_donate?\n @type == :module\n end",
"def is_module_platform?(mod)\n platform_obj = Msf::Module::Platform.find_platform session.platform\n module_platforms = mod.target.platform ? mod.target.platform.platforms : mod.platform.platforms\n module_platforms.include? platform_obj\n rescue ArgumentError => e\n # When not found, find_platform raises an ArgumentError\n elog \"#{e.class} #{e.message}\\n#{e.backtrace * \"\\n\"}\"\n return false\n end",
"def has_access? cls,action\n has_access = true\n cls.each{|c| has_access = false unless all_user_modules.map(&:controller).include?(c)}\n if has_access\n mod = all_user_modules.select{|m| m.controller == cls.last}.first\n has_access = self.permissions.select{|p| p.module_id == mod.id}.map(&:action).include?(action.to_s)\n end\n has_access\n end",
"def contains?(target)\n return false if kind == 'state' && target.kind == 'country'\n return false if kind == 'zipcode' && ['country', 'state'].include?(target.kind)\n return false if zone_members.empty? || target.zone_members.empty?\n\n if kind == target.kind\n target.zoneables.each do |target_zoneable|\n return false unless zoneables.include?(target_zoneable)\n end\n elsif target.kind == 'zipcode'\n target.zoneables.each do |target_zip|\n # zips contained in states\n if kind == 'state'\n return false unless zoneables.include?(target_zip.state)\n # zips contained in countries\n elsif kind == 'country'\n return false unless zoneables.include?(target_zip.state.try(:country))\n end\n end\n elsif\n # states contained in countries\n target.zoneables.each do |target_state|\n return false unless zoneables.include?(target_state.country)\n end\n end\n true\nend",
"def all_members_available?\n @rs.members.each do |member|\n machine = @machine.env.machine(member[:host], @machine.provider_name)\n return false if !member_available?(machine)\n end\n true\n end",
"def enable_modules(*mods)\n modified = []\n mods = [mods].flatten\n mods.each do |mod|\n self.mod_extensions.each do |extension|\n source = \"#{self.mods_available}/#{mod}.#{extension}\"\n target = \"#{self.mods_enabled}/#{mod}.#{extension}\"\n if File.exist?(source) && interpreter.ln_s(source, target)\n modified << mod\n end\n end\n end\n return(modified.empty? ? false : modified.uniq)\n end",
"def has_direct?\n @privileges.fetch(@target).include?(@requisite)\n end",
"def all_modules_implementing(selector)\n self.all_modules.select { |mod| mod.includes_selector?(selector) }\n end",
"def conficts_when_loaded_with?(list_of_specs) # :nodoc:\n result = list_of_specs.any? do |spec|\n spec.dependencies.any? {|dep| dep.runtime? && (dep.name == name) && !satisfies_requirement?(dep) }\n end\n result\n end",
"def ext_include?(key_world)\n map { |e| e.include?(key_world) }.any?\n end",
"def include?(name)\n self.each { |c| return true if (c == name) }\n false\n end",
"def restricted?\n self.groups.any?\n end",
"def valid_target? to\n get_target_branches.include?(to)\n end",
"def loaded_correctly?\n !!@module\n end",
"def loaded_correctly?\n !!@module\n end",
"def matches?(target)\n @target = target\n check_definition(match_definition, expected)\n @errors.empty?\n end",
"def any_lists?\n current_user.lists.any?\n end",
"def installed?\n results = target_files.map {|f| is_my_file?(f) }\n return false if results.include? false\n return true\n end",
"def registered_to?(lesson)\n lesson.members.include?(self)\n end",
"def include?(name)\n items.include?(coerce_name(name))\n end",
"def include?(name); end",
"def include?(name)\n !!find_by_name(name)\n end",
"def targets_any_group?\n self.muscle_groups.each_char do |c|\n return true if c == \"1\"\n end\n return false\n end",
"def may_launch? (definition)\n is_admin? or (self.groups & definition.groups).size > 0\n end",
"def granular?\n @granular ||= begin\n return false if resource_class.nil?\n return true if resource_type == 'Host'\n resource_class.included_modules.include?(Authorizable) && resource_class.respond_to?(:search_for)\n end\n end",
"def has_tests?\n FileList[test_pattern].any?\n end",
"def searchable_in_registry?\n # Use blacklist instead of whitelist; almost all MO names are searchable\n !unsearchable_in_registry?\n end",
"def includes_recipe?(recipe)\n # todo expand roles?\n self.run_list.include?(\"#{recipe}\")\n end",
"def item_effects_valid?\r\n item_target_actors.any? do |target|\r\n target.item_test(user, item)\r\n end\r\n end",
"def includes_definition?\n includes_arguments? || runnable? || argument_parsing_disabled? ||\n includes_modules? || includes_description?\n end",
"def in_any_rolegroup? *rolegroups\n !(rolegroup_list & rolegroups.to_symbols).empty?\n end",
"def complete?\n not @extensions.empty?\n end",
"def us_fulltext?\n self.any? { |item| item.us_availability == HathiTrust::Constants::FT }\n end",
"def has_package_set?(name)\n !!find_package_set(name)\n end",
"def has_permission? *perms\n permissions.map(&:name).includes_all? *perms\n end",
"def processings?\n @processings.any?\n end",
"def include?(member)\n @self_is_object = self[0].respond_to?(:name) && self[0].class != Symbol unless defined?(@self_is_object)\n\n if @self_is_object\n any? { |s| s.name == member }\n else\n super\n end\n end",
"def type_include?(host, mod); end",
"def can_advance_with(name)\n self.available_actions.any? {|e| e.name == name }\n end",
"def assigned_course_or_script?\n assigned_courses.any? || any_visible_assigned_scripts?\n end",
"def contains(target)\n index_of(target) > -1\n end",
"def is_module_options_ready?(mod)\n mod.options.each_pair do |option_name, option|\n return false if option.required && option.default.nil? && mod.datastore[option_name].blank?\n end\n\n true\n end",
"def to?( state )\n target_names.include?( state.to_sym )\n end"
] | [
"0.6894316",
"0.67173016",
"0.64719355",
"0.6443027",
"0.61643624",
"0.6153314",
"0.61509633",
"0.6099001",
"0.60466856",
"0.6044615",
"0.6032038",
"0.59916",
"0.5949316",
"0.581328",
"0.5784757",
"0.5727358",
"0.56976223",
"0.569",
"0.56809425",
"0.5649306",
"0.5649306",
"0.56353563",
"0.5589997",
"0.5585902",
"0.558334",
"0.5553427",
"0.55487496",
"0.55313516",
"0.5529412",
"0.55169094",
"0.5516745",
"0.55040205",
"0.5498093",
"0.54924595",
"0.54904246",
"0.5485575",
"0.5476468",
"0.5476468",
"0.5472684",
"0.54657376",
"0.5464161",
"0.54629874",
"0.54598206",
"0.5453812",
"0.5442924",
"0.54398245",
"0.54332954",
"0.5430492",
"0.5423386",
"0.5423164",
"0.5420138",
"0.5417701",
"0.5417701",
"0.541093",
"0.5410749",
"0.5401082",
"0.5386464",
"0.53849584",
"0.53789544",
"0.53693926",
"0.53645784",
"0.5360774",
"0.53484553",
"0.53390914",
"0.53389114",
"0.5334858",
"0.53238225",
"0.53217036",
"0.5320023",
"0.53061026",
"0.52963656",
"0.52963656",
"0.5292258",
"0.5287202",
"0.5277664",
"0.52728707",
"0.5271772",
"0.52624375",
"0.52594095",
"0.5253018",
"0.5241847",
"0.52382845",
"0.5238182",
"0.52378637",
"0.52305037",
"0.5226352",
"0.52245635",
"0.5213781",
"0.5210803",
"0.52102834",
"0.52094066",
"0.5201467",
"0.5201178",
"0.5199149",
"0.51982975",
"0.5190984",
"0.5188496",
"0.5188342",
"0.51880586",
"0.51874954"
] | 0.7839998 | 0 |
display_board Should accept a board as an argument and print out the current state of the board for the user. | def display_board(board)
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts "-----------"
puts " #{board[3]} | #{board[4]} | #{board[5]} "
puts "-----------"
puts " #{board[6]} | #{board[7]} | #{board[8]} "
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 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\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 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)\n @board = board\n render\n end",
"def board_display\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()\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(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\n\t board =\" | | \\n-----------\\n | | \\n-----------\\n | | \"\n\t puts board\n\tend",
"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\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_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 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(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",
"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",
"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",
"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 return board\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 \" #{@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]} \"\nend",
"def display_board\n puts \"#{human.name}: #{human.marker}, #{computer.name}: #{computer.marker}\"\n puts \"Round #{@round}.\"\n puts \"Score: #{human.score} - #{computer.score}\"\n puts \"\"\n board.draw\n puts \"\"\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(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 \" #{@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\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\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 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]} \" \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\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 display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \\n-------------\\n #{board[3]} | #{board[4]} | #{board[5]} \\n-------------\\n #{board[6]} | #{board[7]} | #{board[8]} \\n\"\nend",
"def display_board(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\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_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 \nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \\n-----------\\n #{board[3]} | #{board[4]} | #{board[5]} \\n-----------\\n #{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 print print_row(board[0], board[1], board[2])\n puts \"-----------\"\n print print_row(board[3], board[4], board[5])\n puts \"-----------\"\n print print_row(board[6], board[7], board[8])\nend"
] | [
"0.8053142",
"0.7945663",
"0.7925305",
"0.7919637",
"0.7912888",
"0.7889378",
"0.7876681",
"0.78522366",
"0.78499115",
"0.7849138",
"0.7849138",
"0.78220224",
"0.78220034",
"0.7816811",
"0.78103936",
"0.780819",
"0.780819",
"0.780819",
"0.780819",
"0.780819",
"0.780819",
"0.780819",
"0.780819",
"0.780819",
"0.780819",
"0.780819",
"0.7762663",
"0.7742138",
"0.774196",
"0.7734604",
"0.7734604",
"0.76981497",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.7693759",
"0.76933753",
"0.76874787",
"0.7675253",
"0.7666355",
"0.7645865",
"0.7644688",
"0.7641446",
"0.76348144",
"0.7615486",
"0.76064295",
"0.7595657",
"0.75892764",
"0.7580476",
"0.75679386",
"0.7564888",
"0.75572425",
"0.75556356",
"0.75515",
"0.7541529",
"0.7540693",
"0.75329715",
"0.75327533"
] | 0.80963767 | 1 |
valid_move? Should accept a board and an index from the user and return true if the index is within the correct range of 08 and is currently unoccupied by an X or O token. | def valid_move?(board, index)
if position_taken?(board, index) == true; false
#elsif board[index] == "X" || board[index] == "O"; true
elsif index > 9 || index < 0; false
else; true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\n end",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\n end",
"def valid_move?(board, index)\n if index.between?(0,8) && board[index] != \"X\" && board[index] != \"O\"\n return TRUE\n end\nend",
"def valid_move?(board, index)\n if !position_taken?(board, index) && index.between?(0, 8)\n return true\n else\n return false\n end\n end",
"def valid_move?(board, index)\n if !index.between?(0,8)\n false\n elsif board[index] == \"X\" || board[index] == \"O\"\n false\n else\n true\n end\nend",
"def valid_move?(board, index)\n return index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n if !position_taken?(board, index) && index.between?(0, 8)\n true #is valid move\n else\n false\n end\nend",
"def valid_move?(board, index)\n if position_taken?(board, index) then return false\n elsif index.between?(0, 8) then return true\n end\nend",
"def valid_move?(board, index)\n if position_taken?(board, index)\n false\n elsif index.between?(0, 8)\n true\n end\nend",
"def valid_move?(board, index)\n index.between?(0, 8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0, 8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0, 8) && !position_taken?(board, index)\nend",
"def valid_move?(board,index)\n if !position_taken?(board, index) && index.between?(0,8)\n true\n\n end\n end",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index) #if the position isn't taken and is on the board, the move must be valid\nend",
"def valid_move?(board, index)\n if !(position_taken?(board, index)) && index.between?(0,8)\n true\n else\n false\n end\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n !(position_taken?(board,index)) && index.between?(0, 8)\nend",
"def valid_move?(board, index)\n !position_taken?(board, index) && index.between?(0, 8)\nend",
"def valid_move?(board, index)\n return index.between?(0, 8) && !position_taken?(board, index) ? true : false;\nend",
"def valid_move?(board, index)\n if index.between?(0, 8)\n !position_taken?(board, index)\n else\n false\n end\nend",
"def valid_move? (board, index)\n index.between?(0, 8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n !position_taken?(board, index) && index.between?(0, 8)\nend",
"def valid_move?(board, index)\n if !position_taken?(board, index) && index.between?(0, 8)\n return true\n else\n false\n end\nend",
"def valid_move?(board, index)\n if index.between?(0,8)\n !position_taken?(board, index)\n else\n false\n end\nend",
"def valid_move?(board, index)\n if index.between?(0, 8) && !position_taken?(board, index)\n true\n else\n false\n end\nend",
"def valid_move?(board, index)\n position_taken?(board, index) == false && index.between?(0, 8) ? true : false\nend",
"def valid_move?(board, index)\n if index.between?(0,8)\n if !position_taken?(board, index)\n true\n end\n end\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board,index)\nend",
"def valid_move?(board, index)\n if !position_taken?(board, index) && index.between?(0, 8)\n return true\n else\n return false\n end\nend",
"def valid_move?(board, index)\r\n index.between?(0,8) && !position_taken?(board, index)\r\nend",
"def valid_move?(board, index)\n if !position_taken?(board, index) && index.between?(0,8)\n return true\n else\n return false\n end\nend",
"def valid_move?(board,index)\n if position_taken?(board,index)\n false\n elsif index.between?(0, 8)\n true\n end\nend",
"def valid_move?(board, index)\n position = index.to_i - 1\n if !position_taken? && position.between?(0-8)\n true\n else\n false\n end\nend",
"def valid_move?(board, index)\n if !position_taken?(board, index) && index.between?(0, 8)\n true\n end\nend",
"def valid_move?(board,index)\n if index.between?(0, 8) && !(position_taken?(board, index))\n true\n else \n false\n end\nend",
"def valid_move?(board, index)\n if index.between?(0,8) && !position_taken?(board, index)\n return true\n else\n false\nend\nend",
"def valid_move?(board, index)\n if index.between?(0,8)\n if !position_taken?(board, index)\n return true\n end\n end\nend",
"def valid_move?(board, index)\n if index.between?(0,8) && !position_taken?(board, index)\n true\n end\nend",
"def valid_move?(board, index)\n if !(index.between?(0,8))\n return false\n end\n if (position_taken?(board,index))\n return false\n end\n true\nend",
"def valid_move?(board, index)\n if index.between?(0, 8) and not position_taken?(board, index)\n return true\n else\n return false\n end\nend",
"def valid_move?(board,index)\n index.between?(0,8) && !position_taken?(board,index)\nend",
"def valid_move?(board, index)\nif index.between?(0,8) && !position_taken?(board, index)\n true\n else\n false\n end\nend",
"def valid_move?(board, index)\n if position_taken?(board, index) == false && index.between?(0,8) == true\n true\n else\n false\n end\nend",
"def valid_move?(board, index)\n if (index.between?(0, 8) && !position_taken?(board, index))\n return true\n else\n return false\n end\nend",
"def valid_move?(board, index)\r\n index.between?(0, 8) && !position_taken(board, index) ? true : false \r\nend",
"def valid_move?(board, index)\n if index.between?(1,9)\n if !position_taken?(board, index)\n return true\n end\n end\n index.between?(0,8) && !position_taken?(board, index)\n return false\nend",
"def valid_move?(board, index)\n if !position_taken?(board, index) && (index).between?(0, 8)\n return true\n end\nend",
"def valid_move?(board, index)\n if index.between?(0, 8) && position_taken?(board, index) == false\n return true\n else\n return false\n end\nend",
"def valid_move?(board, index)\n if position_taken?(board, index) == false && index.between?(0, 8) == true\n true\n else\n false\nend\nend",
"def valid_move?(board, index)\r\n if index.between?(0, 8) && ! position_taken?(board, index)\r\n return TRUE\r\n else \r\n return FALSE\r\n end\r\nend",
"def valid_move? (board, index)\n if index.between?(0, 8) && !position_taken?(board, index)\n true \n end \nend",
"def valid_move?(board, index)\nif position_taken?(board, index)\nreturn false\nelsif !index.between?(0, 8)\n return false\n else\n return true\n end\nend",
"def valid_move?(board, index)\n if board[index] == \" \" || board[index] == \"\"\n position_taken = false\n elsif board[index] == nil\n position_taken = false\n elsif board[index] == \"X\" || board[index] == \"O\"\n position_taken = true\n else\n position_taken = false\n end\n return index.between?(0,8) && !position_taken\nend",
"def valid_move?(board, index)\r\n if !position_taken?(board, index) && index.between?(0,8)\r\n return true\r\n else\r\n return false\r\n end\r\nend",
"def valid_move? (board, index)\n if index.between?(0,8) && !position_taken?(board, index)\n true\n end\nend",
"def valid_move?(board, index)\n if index.between?(0,8) && !position_taken?(board,index)\n return true\n else\n return false\n end\nend",
"def valid_move?(board, index)\nif index.between?(0,8) && !position_taken?(board, index)\n true\nelse\n false\nend\nend",
"def valid_move?(board,index)\n if position_taken?(board,index) == FALSE && index.between?(0, 8) == TRUE\n TRUE\n else\n FALSE\n end\nend",
"def valid_move?(board,index)\n if position_taken?(board,index) == false && index.between?(0,8)\n true\n end \n end",
"def valid_move?(index)\n if index < 9 && index > -1 && @board[index] != 'X' && @board[index] != 'O'\n return true\n else\n return false\n end\n end",
"def valid_move?(board, index)\n if index.between?(0, 8) && board[index] == \" \"\n true\n else position_taken?(board, index) == nil && board[index] == \"X\"\n false\n end\nend",
"def valid_move?(board,index)\n if index.between?(0,8)\n return !position_taken?(board,index)\n end\n end",
"def valid_move? (board, index)\n if position_taken?(board, index) == false && (index).between?(0,8)\n return true\n else\n return false\n end\nend",
"def valid_move?(board, index)\n if index.between?(0, 8) && position_taken?(board, index) == false\n true\n else\n false\n end\nend",
"def valid_move? (board, index)\n def position_taken? (board, index)\n if board[index] == \"\" || board[index] == \" \" ||board[index] == nil\n return false\n else board[index] == \"O\" || board[index] == \"X\"\n return true\n end\n end\n\n def on_board? (index)\n if index.between?(0,8) == true\n return true\n else\n return false\n end\n end\n\n if (position_taken?(board, index) == false && on_board?(index) == true)\n return true\n else\n return false\n end\nend",
"def valid_move?(board,index)\n if index.between?(0,8) && position_taken?(board,index)\n true\n end\nend",
"def valid_move?(board, index)\n if position_taken?(board, index)\n false\n elsif index > 8 || index < 0\n false\n else\n true\n end\nend",
"def valid_move?(board, idx)\n if position_taken?(board, idx) == false && idx.between?(0, 8)\n return true\n else\n return false\n end\nend",
"def valid_move? (board, index)\n if index.between?(0, 8) == true && position_taken?(board, index) == false\n return true\n else return false\n end\nend",
"def valid_move?(board, index)\n if index.between?(0,8) && !position_taken?(board, index)\n puts \"this is a valid move\"\n return true\n else\n return false\n end\nend",
"def valid_move?(board, index)\n \nif position_taken?(board, index) === false && index.between?(0, 8)\n return true\nelse \n return false\nend\nend",
"def valid_move?(board,index)\n if index.between?(0,8) && !position_taken?(board,index)\n true\n else\n false\n end\n\nend",
"def valid_move? (board, index)\n if (index).between?(0,8) == true && position_taken?(board, index) == false\n return true\n else\n return false\n end\nend",
"def valid_move?(board, index)\nif !(index.between?(0,8))\n return false\nelsif position_taken?(board, index)\n return false \nelse \n return true\n end\nend",
"def valid_move?(board, index)\n if (index.between?(0,8) == true) && (position_taken?(board, index) == false)\n return true \n else\n return false\n end\nend",
"def valid_move?(board,index)\n if index < 0\n false\n else\n if index > 8\n false\n else\n !position_taken?(board,index)\n end\n end\nend",
"def valid_move?(board, index)\n index.between?(0, 8) && position_taken?(board, index) == false\n\nend",
"def valid_move?(board, index)\n if index.between?(0, 8) && position_taken?(board, index) == false\n true\n else position_taken?(board, index) == true\n nil\n end\nend",
"def valid_move? (board, index)\n if position_taken?(board,index) != false || !(index.between?(0,8))\n return false\n elsif position_taken?(board,index) == false && index.between?(0,8)\n return true\n end\nend",
"def valid_move?(board, index)\n if index.between?(1,9)\n if !position_taken?(board, index)\n true\n end\n end\nindex.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n if position_taken?(board, index) == true\n false\n elsif index > 8 || index < 0\n false\n else\n true\n end\nend",
"def valid_move?( board, index )\n\n if (index.between?(0,8) ) && ( position_taken?(board, index) == false )\n return true\n else\n return false\n end\n\nend",
"def valid_move?(board, index)\n if board[index] == \"\" || board[index] == \" \" && index.between?(0, 8)\n return true\n elsif board[index] == \"X\" || board[index] == \"O\"\n return false\n end\nend",
"def valid_move?(board,index)\n \n if position_taken?(board, index) == false && \n index.between?(0, 8) == true \n return true\n else \n false\n end\n \n \n\nend",
"def valid_move?(board, index)\n if index.between?(0, 8) && (position_taken?(board, index) == false)\n true\n elsif (index.between?(0,8) == false) || (position_taken?(board, index) == true)\n false\n end\nend",
"def valid_move?(index)\n return index.between?(0, @board.length) && !position_taken?(index)\n end",
"def valid_move?(board, index)\n\n # if (0..8).to_a.include?(!index)\n if !index.between?(0, 8)\n nil\n elsif position_taken?(board, index) == false\n true\n end\n\n # if !board[index]\n # false\n # end\n\nend",
"def valid_move?(board, position)\n index = position.to_i\n if position_taken?(board, index) == false && index.between?(0, 8)\n return true\n else\n return false\n end\nend"
] | [
"0.8912906",
"0.8912906",
"0.8848799",
"0.884805",
"0.8837264",
"0.88332653",
"0.8832149",
"0.88317454",
"0.88235754",
"0.88234216",
"0.88234216",
"0.88234216",
"0.8816482",
"0.881642",
"0.8814303",
"0.88074106",
"0.88074106",
"0.88074106",
"0.88074106",
"0.88074106",
"0.88074106",
"0.88074106",
"0.88074106",
"0.88074106",
"0.88074106",
"0.88074106",
"0.88074106",
"0.88074106",
"0.88019985",
"0.880195",
"0.8793931",
"0.8788554",
"0.878585",
"0.87854916",
"0.87814426",
"0.87782776",
"0.87774915",
"0.87761486",
"0.8769754",
"0.87687147",
"0.8764025",
"0.87616324",
"0.8758333",
"0.8757397",
"0.8756305",
"0.8755393",
"0.8734368",
"0.873366",
"0.87328833",
"0.8732511",
"0.8728646",
"0.87280226",
"0.87246543",
"0.87225056",
"0.8718825",
"0.8718459",
"0.87168014",
"0.8716173",
"0.8713639",
"0.8710041",
"0.87099373",
"0.8704017",
"0.8702347",
"0.8701608",
"0.86970824",
"0.8696843",
"0.86957914",
"0.8692588",
"0.8689682",
"0.86862916",
"0.86836296",
"0.868308",
"0.8675564",
"0.86743593",
"0.86685467",
"0.86628616",
"0.8658589",
"0.8654573",
"0.864338",
"0.86405814",
"0.8639274",
"0.8637337",
"0.86247313",
"0.8622235",
"0.8621816",
"0.8617771",
"0.8617557",
"0.86150336",
"0.8609176",
"0.85989875",
"0.8598922",
"0.8592109",
"0.85836196",
"0.8583352",
"0.8575481",
"0.85697377",
"0.85547787",
"0.8552868",
"0.8548073",
"0.8548051"
] | 0.87682986 | 40 |
Hint: While not explicitly required by this lab, you might want to encapsulate the logic to check if a position is occupied in its own method, perhaps position_taken? | def position_taken?(board, index)
if board[index] == " " || board[index] == "" || board[index] = nil
false
else
true
#board[index] == "X" || board[index] == "O"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position_taken?\nend",
"def position_taken?(board,index)\n #This method must take in both the existing board and the index that the user\n #is trying to fill if the index is already occupied it will not allow this\n position_value=board[index]\n if position_value != nil\n if position_value.include? \"x\" or position_value.include? \"o\" or position_value.include? \"X\" or position_value.include? \"O\"\n return true\n else\n return false\n end\n else\n return false\n end\nend",
"def position_taken?(board, idx)\n [\"X\", \"O\"].include?(board[idx])\nend",
"def position_taken?(board, pos)\n if board[pos]==\"X\" || board[pos]==\"O\"\n taken = true\n else\n taken = false\n end\n taken\nend",
"def position_taken?(board,index)\n [\"X\", \"O\"].include?(board[index])\nend",
"def position_taken?(board, position)\n board[position] == 'X' || board[position] == 'O'\nend",
"def position_taken?(index)\n if @board[index] == \"X\"\n true\n elsif @board[index] == \"O\"\n true\n else\n false\n end\nend",
"def position_taken?(board, position)\n if (board[position] == \"X\" || board[position] == \"O\")\n true\n end\nend",
"def position_taken?(board, position)\n if !(board[position.to_i - 1] == \"X\" || board[position.to_i - 1] == \"O\")\n return true\n else \n return false\n end\nend",
"def position_taken?(board, position)\n if board[position] == \"X\" || board[position] == \"O\"\n return true\n end\n false\nend",
"def position_taken?(board, position)\n if !board.empty? && board[position] && (board[position].include?(\"X\") || board[position].include?(\"O\"))\n true\n else\n false\n end\nend",
"def position_taken?(board, position)\n if (board[position] == \"X\" || board[position] == \"O\")\n true\n else\n false\n end\n\nend",
"def position_taken?(board, position)\n board[position] == \"X\" || board[position] == \"O\"\nend",
"def position_taken?(board, position)\n board[position] == \"X\" || board[position] == \"O\"\nend",
"def position_taken?(board,pos)\n if board[pos.to_i]==\"X\" || board[pos.to_i] ==\"O\"\n return true\n else\n return false\n end\nend",
"def position_taken?(board, position)\n position = position.to_i - 1\n if board[position] == \"X\" || board[position] == \"O\"\n true\n end\nend",
"def position_taken?(board, position)\n value = position.to_i - 1\n if board[value] == \"X\" || board[value] == \"0\"\n true\n end\nend",
"def position_taken?(board, position)\n if board[position] == \"X\" || board[position] == \"O\"\n true\n else\n false\n end\nend",
"def position_taken?(board, position)\n if board[position] == \"X\" || board[position] == \"O\"\n return true\n end\nend",
"def position_taken?(board, index)\n if board[index] == \"X\"\n true\n elsif board[index] == \"O\"\n true\n else\n false\n end\nend",
"def position_taken?(board, index)\n a = board[index]\n filled = a == \"X\" || a == \"O\"\n return filled\nend",
"def position_taken?(board, position_index)\n board[position_index] == \"X\" or board[position_index] == \"O\"\nend",
"def position_taken?(board, position)\n\tif board[position] == \"X\" || board[position] == \"0\"\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend",
"def position_taken?(board, index)\n space = board[index]\n if space == 'X' || space == \"O\"\n return true\n else\n return false\n end\nend",
"def position_taken?(board,position)\n return true if board[position]==\"X\" || board[position]==\"O\"\n return false\nend",
"def position_taken?(board, index)\n board[index]== \"X\" || board[index] == \"O\"\nend",
"def position_taken?(board, index)\n board[index] == \"X\" || board[index] == \"O\"\nend",
"def position_taken?(board, position)\n return true if board[position - 1] == \"X\" || board[position - 1] == \"O\"\n false\nend",
"def position_taken?(board, position)\n chars = ['X', 'O']\n chars.include? board[position]\nend",
"def position_taken?(index)\n @board[index]==\"X\" || @board[index] == \"O\"\nend",
"def position_taken?(board, position)\n if ((board[position] == \"X\") || (board[position] == \"O\" ))\n return true\n elsif board[position] == nil\n false\n else\n false\n end\nend",
"def validate_position(row,col)\n if row<=@board.size and col <=@board.size\n if @board[row][col]==EMPTY_POS\n return true\n else\n puts \"position is occupied\"\n end\n else\n puts \"invalid position\"\n end\n return false\n end",
"def position_taken?(location)\n !(board[location] == \" \" || board[location].nil?)\nend",
"def position_taken?(index)\n ((@board[index] == \"X\") || (@board[index] == \"O\"))\n end",
"def position_taken?(board, index)\n if board[index] == \"X\" || board[index] == \"O\"\n true\n else\n false\n end\nend",
"def position_taken?(board, index)\n if board[index] == \"X\" || board[index] == \"O\"\n true\n else\n false\n end\nend",
"def position_taken?(board, index)\n if board[index] == \"X\" || board[index] == \"O\"\n true\n else\n false\n end\nend",
"def position_taken?(board, desired_position)\n if [\" \", \"\", nil].include?board[desired_position]\n return false\n end\n if [\"X\", \"O\"].include?board[desired_position]\n return true\n end\nend",
"def position_taken?(index)\n @board[index] == \"X\" || @board[index] == \"O\"\n end",
"def position_taken?(board, index_to_validate)\n if (board[index_to_validate] == \"X\" || board[index_to_validate] == \"O\")\n return true\n end\n return false # NOTE: if we arrive here, the position is definitely not taken\nend",
"def position_taken?(board,index)\n if board[index] == \"X\" || board[index] == \"O\"\n TRUE\n else\n FALSE\n end\nend",
"def position_taken?(board, index)\n board[index] == \"X\" || board[index] == \"O\"\n end",
"def position_taken?(board,position)\n position = position.to_i - 1\n if board[position] == \"X\" || board[position] == \"O\"\n return true\n else\n return false\n end\nend",
"def position_taken?(board, index)\n if board[index] == \"X\" || board[index] == \"O\"\n return true\n else\n return false\n end\nend",
"def position_taken?(board, index)\n if board[index] == \"X\" || board[index] == \"O\"\n return true\n else\n return false\n end\nend",
"def position_taken?(board, index)\n board[index] === \"X\" || board[index] ===\"O\" ? true : false\nend",
"def position_taken?(board, index)\n board[index] === \"X\" || board[index] ===\"O\" ? true : false\nend",
"def position_taken?(board, position)\n if board[position]==\"\" || board[position]==\" \"\n return false\n elsif board[position] == \"X\" || board[position]==\"O\"\n return true\n else\n return false\n end\nend",
"def validating_position?(board, position, marker)\n \tboard[position] == position + 1\nend",
"def position_taken?(board,index)\n board[index] == \"X\" || board[index] == \"O\"\nend",
"def position_taken?(board, i)\n board[i] == \"X\" || board[i] == \"O\"\nend",
"def position_taken?(board, position)\n return false if valid_move?(board, position)\n return true unless valid_move?(board, position)\nend",
"def position_taken?(board, new_index)\n if board[new_index] == \"X\" || board[new_index] == \"O\"\n return true\n else\n return false\n end\nend",
"def position_taken? (board,index)\n if ( board[index] == \"X\" || board[index] == \"O\" )\n return true\n else\n return false\n end\nend",
"def position_available(marker_pos, player1_obj, player2_obj)\n # test - marker_pos - index has a limit of 1 to 9\n return false if marker_pos.negative? || (marker_pos > 8)\n\n # test - new move - does not overlap any previous moves done.\n return true if (player1_obj.moves_arr[marker_pos].zero? && player2_obj.moves_arr[marker_pos].zero?) == true\n\n false\nend",
"def legal(coords)\n offsets = [ [1, 2], [-1, 2], [1, -2], [-1, -2], [2, 1], [-2, 1], [2, -1], [-2, -1] ]\n moves = []\n offsets.each do |offset|\n move = [@row+offset[0], @column+offset[1]]\n moves << move\n end\n #loop through possible moves\n moves.each do |move|\n #if chosen coords = moves array coords check if occupied\n if coords === move\n return occupied?(coords)\n end\n end\n return false \n end",
"def full?(board) #check if the board is full\n board.each_with_index do |position, index|\n if position_taken?(board, index) == false \n return false\n end\n end\n return true\nend",
"def position_taken?(board,n)\n return board[n]=='X'||board[n]=='O'\nend",
"def position_taken?(location)\n @board[location] != \" \" && @board[location] != \"\"\n end",
"def position_taken?(index_i)\n ((@board[index_i] == \"X\") || (@board[index_i] == \"O\"))\n end",
"def position_taken?(board, index)\n\n if board == [\" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \"] and index == 0\n false\n elsif board == [\"\", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \"] and index == 0\n false\n elsif board == [nil, \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \"]\n false\n elsif board == [\"X\", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \"O\"] and between? == true\n true\n end\n\nend",
"def position_taken?(board, position)\n if (board[position.to_i - 1] == \"X\" || board[position.to_i - 1] == \"O\")\n return true\n elsif !(board[position.to_i - 1] == \" \" || board[position.to_i - 1] == nil )\n return true\n else\n return false\n end\nend",
"def position_taken?(board, n)\n\n [\"X\",\"O\"].include?(board[n])\n\nend",
"def position_taken?(board, position)\n board[position] != \" \"\nend",
"def valid_move?(board, indx)\n if position_taken?(board, indx)\n false \n elsif (indx < 0 || indx > 8)\n false\n else \n true \n end \nend",
"def position_taken?(board, position)\n\n position = board[position.to_i]\n if board[position.to_i] == \" \" || board[position.to_i] == \"\" || board[position.to_i] == nil\n false\n else board[position.to_i] == \"X\" || board[position.to_i] == \"O\"\n true\n end\nend",
"def position_taken?(location)\n @board[location] != \" \" && @board[location] != \"\"\n end",
"def position_taken?(location)\n @board[location] != \" \" && @board[location] != \"\"\n end",
"def position_taken?(board, spot)\n if board[spot] == \"\"\n false\n elsif board[spot] == \" \"\n false\n elsif board[spot] == nil\n false\n elsif board[spot] == \"X\"\n true\n elsif board[spot] == \"O\"\n true\n end\nend",
"def position_taken?(board, position)\n \n if board[position.to_i-1] == \" \"\n then false\n elsif board[position.to_i-1] == \"\" \n then false\n elsif board[position.to_i-1] == nil\n then false\n elsif board[position.to_i-1] == \"X\"\n then true\n elsif board[position.to_i-1] == \"O\"\n then true\n end\nend",
"def position_taken?(position)\n @board[position] != \" \"\n end",
"def position_taken?(board, position)\n if board[position] == \" \"\n return false\n elsif board[position] == \"\"\n return false\nelsif board[position] == nil\n return false\nelsif board[position] == \"X\" || \"O\"\n return true\nend\nend",
"def position_taken?(position)\n @board[position] != nil && @board[position] != \" \"\n end",
"def occupied?(x,y) # board position !nil\n !self.board.grid[x][y].nil?\n end",
"def valid_move?(board,position)\n position = position.to_i #convert string to integer\n position = position-1 #translate position to array location\n\n if position >= 0 and position < 9 #check for legal position\n if board[position].strip.empty?\n return true\n elsif position_taken?(board,position)\n return false #position is occupied\n end\n else\n return false #illegal position\n end\nend",
"def position_taken?(index_i)\n ((@board[index_i] == \"X\") || (@board[index_i] == \"O\"))\n end",
"def position_taken?(board, position)\n if (board[position]==\" \") || (board[position]==\"\")\n return false\n elsif (board[position]==\"X\") || (board[position]==\"O\")\n return true\n elsif (board[position]==nil)\n return false\n end\nend",
"def position_is_valid?(position)\r\n position.x < @col &&\r\n position.y < @row &&\r\n position.x >= 0 &&\r\n position.y >= 0\r\n end",
"def position_taken? (board, index)\n if board[index] == nil || board[index] == \"\"\n return false\n \n elsif board[index] == \" \"\n return false\n \n elsif board[index] == \"X\" || board[index] == \"O\"\n return true\n end\nend",
"def position_taken?(board, indx)\n if (board[indx] == \"X\" || board[indx] == \"O\")\n true \n elsif (board[indx] == \" \" || board[indx] == \" \" || board[indx] == \"\")\n false \n elsif (board[indx] == nil)\n false\n end \nend",
"def valid_move?(board, index)\n if index.between?(0, 8)\n # re-define your #position_taken? method here, so that you can use it in the #valid_move? method above.\n def position_taken?(board, index)\n if board[index] == \" \"\n !false\n elsif board[index] == \"\"\n !false\n elsif board[index] == nil\n !false\n elsif board[index] == \"X\" || board[index] == \"O\"\n !true\n end\n end\n position_taken?(board, index)\nend\nend",
"def check_position(position)\n\n puts \"Checking \" + position[0].to_s + \",\" + position[1].to_s\n\n unless check_valid_board_position(position)\n puts \"Invalid board position\"\n return false\n end\n\n if @board[position[1]][position[0]] != \".\"\n puts \"Position already occupied\"\n false\n else\n true\n end\n\n end",
"def valid_move? (board, index)\n if index.between?(0,8) && position_taken?(board, index) == true\n #position is between 0-8 (1-9) AND the position is available (#position_taken)\n true\n else\n false\n end\nend",
"def position_taken?(board, idx)\n len = board.length\n if len == 0\n return false\n end\n \n out = board[idx]\n \n if out == nil\n return false \n end\n \n out_strip = out.strip\n if out_strip == \"X\" || out_strip == \"O\"\n return true\n else\n return false\n end\nend",
"def position_taken?(position)\n @board[position] != \" \"\n end",
"def position_taken?(board, position)\n if board[position] == nil || board[position] == \" \" || board[position] == \"\"\n return false\n elsif board[position] == \"X\" || board[position] == \"O\"\n return true \n end \nend",
"def position_taken?(board,position)\n pos = position.to_i\n val = board[pos-1]\n if val == \"X\" || val ==\"O\"\n true\n else\n false\n end\nend",
"def position_available(position)\n BOARD[position].strip.empty?\nend",
"def position_taken?(board, index)\n if board[index] == \" \"\n false\n elsif board[index] == \"\"\n false\n elsif board[index] == \"X\"\n true\n elsif board[index] == \"O\"\n true\n else\n false\n end\nend",
"def check_move(position)\n \t\t\n \t\teval(\"@array_map\" + indexer(position) + \".empty?\") \n\n \tend",
"def position_taken?(board, index)\n board[index]==\"X\"||board[index]==\"O\"\n\nend",
"def valid_move?(board, index)\n index.between?(0, 8) && position_taken?(board, index) == false\n\nend",
"def position_taken?(board,position)\n return false if [\" \", \"\", nil].include?(board[position])\n return true if [\"X\", \"O\"].include?(board[position])\n raise \"#{board[position]} is not a valid move\"\nend",
"def position_taken?(position)\r\n if @board[position] == \"\" || @board[position] == \" \" || @board[position] == nil\r\n return false\r\n elsif @board[position] == \"X\" || @board[position] == \"O\"\r\n return true\r\n end\r\n end",
"def valid_move?(board, index)\n if index.between?(0, 8) && position_taken?(board, index) == false\n true\n else\n false\n end\nend",
"def position_taken?(board, position)\n int = position.to_i\n if board[int - 1] != 0.upto(8) || board[int - 1] != \" \"\n return false\n end\nend",
"def valid_move?(a,i)\r\n if i.between?(0,8) && !position_taken?(a,i)\r\n true\r\n else\r\n false\r\n end\r\nend",
"def position_taken?(int)\n if (@board[int]==\" \") || (@board[int]==\"\")\n return false\n elsif (@board[int]==\"X\") || (@board[int]==\"O\")\n return true\n elsif (@board[int]==nil)\n return false\n end\nend",
"def pos?(x, y)\n (width.include?(x) && height.include?(y)) ||\n occupied_spaces.include?([x, y])\n end",
"def position_taken?(board, location)\n !(board[location].nil? || board[location] == \" \")\nend",
"def position_taken?(board, location)\n !(board[location].nil? || board[location] == \" \")\nend"
] | [
"0.7775009",
"0.7709548",
"0.7581044",
"0.7484805",
"0.7454599",
"0.74466985",
"0.7444623",
"0.74328506",
"0.7427627",
"0.74262154",
"0.74106264",
"0.73990303",
"0.7393684",
"0.7393684",
"0.7373324",
"0.7373167",
"0.7366633",
"0.736648",
"0.7349871",
"0.7325485",
"0.73241043",
"0.7304175",
"0.7289865",
"0.72837263",
"0.72829664",
"0.72688365",
"0.7265672",
"0.7260057",
"0.72586846",
"0.72549236",
"0.72474277",
"0.72437674",
"0.7235243",
"0.7235189",
"0.72292584",
"0.72292584",
"0.72292584",
"0.7225876",
"0.7225114",
"0.72210646",
"0.72203875",
"0.7214495",
"0.72012764",
"0.71833855",
"0.71833855",
"0.71810824",
"0.71810824",
"0.718048",
"0.7179773",
"0.71656966",
"0.71642655",
"0.7159597",
"0.71579456",
"0.7156605",
"0.7150847",
"0.7148078",
"0.71430486",
"0.7141695",
"0.7138847",
"0.71344054",
"0.7124723",
"0.7124459",
"0.71088433",
"0.7105322",
"0.7091334",
"0.708943",
"0.7088167",
"0.7088167",
"0.7077119",
"0.70762455",
"0.70759004",
"0.70757484",
"0.7072123",
"0.7058867",
"0.7055105",
"0.7050088",
"0.70477027",
"0.7046213",
"0.704541",
"0.7037606",
"0.70369244",
"0.7033872",
"0.70205164",
"0.7019688",
"0.70150936",
"0.7014856",
"0.7010612",
"0.7007492",
"0.70037585",
"0.7000471",
"0.6997661",
"0.699592",
"0.69956005",
"0.6995561",
"0.6988846",
"0.69836974",
"0.69820386",
"0.6980443",
"0.69773966",
"0.69756746",
"0.69756746"
] | 0.0 | -1 |
=> [["water", "water", "water", "water", "water", "water", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "water", "water", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "water", "water", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "water", "water", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "water", "water", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "land", "land", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "land", "water", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "water", "water", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "water", "water", "water", "water", "water", "water", "water"], ["water", "water", "water", "water", "... world is a two dimensional array of subarrays. The above representation sets out the array in a way that makes it easy for a human to understand it in terms of map coordinates. Each row in the above is a subarray of elements. The y argument identifies which subarray we want, i.e. the relevant row in the above grid, meaning y is equivalent to a y coordinate, reading from top to bottom with the first row being 0 on the y axis. The x argument identifies which element INSIDE the subarray we want, i.e. the relevant column in the above grid, meaning x is equivalent to an x coordinate. | def continent_size world, x, y
if world[y][x] != 'land' # => false, true, true, true, false, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true
# Either it's water or we already counted it,
# but either way, we don't want to count it now.
return 0 # => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
end
# So first we count this tile...
size = 1 # => 1, 1, 1
world[y][x] = 'counted land' # => "counted land", "counted land", "counted land"
# Each time the program his a tile marked 'land' it updates that tile
# so it is no longer 'land' but 'counted land', meaning the next time the
# program hits that tile it will no longer be equal to 'land' and therefore
# is not double counted.
# ...then we count all of the neighboring eight tiles
# (and, of course, their neighbors by way of the recursion).
#
# The best way to think of this is that each time the program hits a land tile
# it starts spiraling around that tile until it finds another land tile and
# each time it finds another land tile it starts again from that second land tile
# and so on and son on until it has counted all the land tiles and their neighbors
# that joined the starting tile.
#
size = size + continent_size(world, x-1, y-1) # => 1, 1, 1
size = size + continent_size(world, x , y-1) # => 1, 1, 1
size = size + continent_size(world, x+1, y-1) # => 1, 1, 1
size = size + continent_size(world, x-1, y ) # => 1, 1, 3
size = size + continent_size(world, x+1, y ) # => 1, 1, 3
size = size + continent_size(world, x-1, y+1) # => 1, 1, 3
size = size + continent_size(world, x , y+1) # => 1, 2, 3
size = size + continent_size(world, x+1, y+1) # => 1, 2, 3
size # => 1, 2, 3
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def square_arrays\n squares = []\n org_row = 0\n org_col = 0\n (0..8).each do |i|\n squares[i] = []\n (org_row..org_row+2).each do |k|\n (org_col..org_col+2).each do |j|\n squares[i].push(@board[k][j])\n end \n end\n if org_row == 6\n org_col += 3 \n org_row = 0\n else\n org_row += 3 \n end\n end \n squares\n end",
"def visualize_array\n(0...ROWS).each { |row|\n (0...COLS).each { |col|\n print row.to_s + \" \" + col.to_s + \" \"\n print \"(\" + (COLS*row + col).to_s + \") \" # index into board array\n }\n puts\n}\nend",
"def col_arrays\n #puts self.inspect\n cols = []\n (MIN_ROW_POSITION..MAX_ROW_POSITION).each do |i|\n cols[i] = []\n (MIN_COL_POSITION..MAX_COL_POSITION).each do |j|\n cols[i].push(@board[j][i])\n end\n end \n cols\n end",
"def coordinate_list\n @board.each_index.inject([]) do |result,row_index|\n result.concat( \n @board[row_index].each_index.collect do |column_index|\n [row_index + 1, column_index + 1]\n end\n )\n end\n end",
"def get_world_array\n world_array = Array.new(@total_length){ [] }\n\n @all_strawberries.each do |strawberry|\n world_array[Matrix.two_to_one(strawberry.get_x_location, strawberry.get_y_location, @x_size)].push(strawberry)\n end\n @all_mushrooms.each do |mushroom|\n world_array[Matrix.two_to_one(mushroom.get_x_location, mushroom.get_y_location, @x_size)].push(mushroom)\n end\n @all_persons.each do |person|\n world_array[Matrix.two_to_one(person.get_x_location, person.get_y_location, @x_size)].push(person)\n end\n @all_monsters.each do |monster|\n world_array[Matrix.two_to_one(monster.get_x_location, monster.get_y_location, @x_size)].push(monster)\n end\n world_array\n end",
"def create_grid(board_array)\n\t# split into triplets\n\ttriplets_array = []\n board_array.each { |array| triplets_array << array.each_slice(3).to_a }\n\n # shuffle the triplets\n shuffle_container = [[], [], []]\n 9.times do |row|\n 3.times do |column|\n current_array = triplets_array[row][column]\n shuffle_container[column] << current_array\n end\n end\n\n # flatten and re-split\n final_array = []\n shuffle_container.flatten.each_slice(9) { |array| final_array << array }\n\n return final_array\nend",
"def create_position_array()\n array_2D = []\n array_1D = []\n\n (0...@row).each_with_index do |value, row_index|\n (0...@col).each_with_index { |value, col_index| array_1D.append(value+(row_index*@col)) }\n array_2D.append(array_1D)\n array_1D = []\n end\n\n return array_2D\n end",
"def sub_arrays(arr)\n sub_arr = []\n i_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sub_arr << i_arr\n end\n i_arr = []\n arr.shift\n end\n sub_arr\nend",
"def print_coordinates\n\t\tsample_board=[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]\n\t\t(0..(sample_board.length)-1).each do |i| #we are assigning the count of each row of the array sample_board \n\t\t\t#(0,1,2,3) to the variable i\n\t\t\t(0..(sample_board[i].length)-1).each do |j| #we are assigning the count of each column of the array sample_board\n\t\t\t\t#(0,1,2,3) to the variable j\n\t\t\t\tif(sample_board[i][j]<10) #adds extra space after single digit numbers to make them the same width as double digits\n\t\t\t\t\tmarker=sample_board[i][j].to_s + \" \" #.to_s converts the output of sample_board[i][j] to a string\n\t\t\t\telse\n\t\t\t\t\tmarker=sample_board[i][j]\n\t\t\t\tend\n\t\t\t\tprint \"#{marker}\"\n\t\t\t\tprint \"|\" unless j==sample_board.length-1 #prints \"|\" after each element in the \"secondary\" arrays (i.e. rows) \n\t\t\t\t#except after the last element in each \"secondary\" array (i.e. each row). \n\t\t\tend\n\t\t\tputs \"\"\n\t\tend\n\tend",
"def test_with_irregular_array2D2; show([[0.5], [0.1,0.9]]) end",
"def test_with_irregular_array2D1; show([[0.1,0.9], [0.5]]) end",
"def board_2d\n # slice the array into groups of 4 to create 2d-array\n @board.enum_slice(4).to_a\n end",
"def mine_locations\n mine_array = []\n until mine_array.length == 9\n row = (0..9).to_a.sample\n column = (0..9).to_a.sample\n unless mine_array.include?([row,column])\n mine_array << [row, column]\n end\n end\n mine_array\n end",
"def nest_array(board)\n nested_board = []\n 9.times { nested_board << board.slice!(0..8)}\n return nested_board\nend",
"def to_2d_array(tile_hash)\n min_x = tile_hash.min_by{|v|v[:x]}[:x]\n min_y = tile_hash.min_by{|v|v[:y]}[:y]\n map = []\n tile_hash.each do |cell|\n rel_x = cell[:x] - min_x\n rel_y = cell[:y] - min_y\n if map.length < rel_y + 1 || map[rel_y] == nil\n map[rel_y] = []\n end\n map[rel_y][rel_x] = cell[:index]\n end\n map\nend",
"def tile(y, x, matrix)\n matrix[y - 1 .. y + 1].map {|line| line[x - 1 .. x + 1]}\n end",
"def default_grid\n array = Array.new(8) { Array.new(8) }\n\n array[0][0] = Rook.new('white', [0,0], 'slide')\n array[1][0] = Knight.new('white', [1,0], 'step')\n array[2][0] = Bishop.new('white', [2,0], 'slide')\n array[3][0] = Queen.new('white', [3,0], 'slide')\n array[4][0] = King.new('white', [4,0], 'step')\n array[5][0] = Bishop.new('white', [5,0], 'slide')\n array[6][0] = Knight.new('white', [6,0], 'step')\n array[7][0] = Rook.new('white', [7,0], 'slide')\n array[0..7].each_with_index { |column, index| \n column[1] = Pawn.new('white', [index,1], 'step') }\n\n array[0][7] = Rook.new('black', [0,7], 'slide')\n array[1][7] = Knight.new('black', [1,7], 'step')\n array[2][7] = Bishop.new('black', [2,7], 'slide')\n array[3][7] = Queen.new('black', [3,7], 'slide')\n array[4][7] = King.new('black', [4,7], 'step')\n array[5][7] = Bishop.new('black', [5,7], 'slide')\n array[6][7] = Knight.new('black', [6,7], 'step')\n array[7][7] = Rook.new('black', [7,7], 'slide')\n array[0..7].each_with_index { |column, index| \n column[6] = Pawn.new('black', [index,6], 'step') }\n\n array\n end",
"def grid(n, m)\n Array.new(n) { Array.new(n) } # If you attempted to write this as Array.new(n, Array.new(m)) the contents would be repeated for each array rather\nend",
"def generate_grid x = @x, y = @y\n new_grid = []\n\n y.times { new_grid << [] }\n new_grid.each do |array|\n x.times do\n array << []\n end\n end\n end",
"def as_two_dimensional_array\n @as_two_dimensional_array ||= grid.as_two_dimensional_array.each_with_index.map do |row, y|\n row.each_with_index.map do |letter, x|\n Letter.new(\n letter: letter,\n x: x,\n y: y,\n letter_multiplier: multipliers.letter.indices(x,y).first&.value,\n word_multiplier: multipliers.word.indices(x,y).first&.value\n )\n end\n end\n end",
"def coordinates\n arr = []\n (0...@size).each do |row|\n (0...@size).each do |column|\n arr << Coordinate.new(x: row,y: column)\n end\n end\n arr\n end",
"def sub_arrays\n result = []\n self.each_index do |i|\n self.each_index do |j|\n result << self[i..j] if j >= i\n end\n end\n result\n end",
"def get_subgrid(cords)\n subgrid = []\n x_pos = cords[0] - cords[0] % 3\n (x_pos..x_pos + 2).each do |row_num|\n y_pos = cords[1] - cords[1] % 3\n subgrid += @grid[row_num][y_pos, 3]\n end\n subgrid\n end",
"def tiles_at(x, y)\n @layers[:tile_layers].map { |_, tiles| tiles[y][x] }.compact\n end",
"def get_grids(x, y, width, height)\n x = (x*10)-5\n y = (y*10)-5\n end_x= x+(width*10)-1\n end_y= y+(height*10) -1\n return [[y, x], [end_y, end_x]]\n end",
"def get_grids(x, y, width, height)\n x = (x*10)-5\n y = (y*10)-5\n end_x= x+(width*10)-1\n end_y= y+(height*10) -1\n return [[y, x], [end_y, end_x]]\n end",
"def iterate(arr)\n # TODO 3\n arrNew = []\n (0...arr.count).each do |x|\n arrNew[x] = []\n (0...arr.count).each do |y|\n if num_neighbors(x, y, arr) == 3\n arrNew[x][y] = \"X\"\n else\n arrNew[x][y] = \".\"\n end\n end\n end\n\n arrNew\nend",
"def flatten_grid\n height = grid.row_size\n width = grid.column_size\n for i in 0...height\n for j in 0...width\n @grid[i,j].flatten!\n end\n end\n end",
"def coords\n coord_list = []\n (@x..(@x + @size_x - 1)).each do |i|\n (@y..(@y + @size_y - 1)).each do |j|\n coord = [i, j]\n coord_list << coord\n end\n end\n\n return coord_list\n end",
"def hidden_ships_grid\n new_grid = @grid.map do |subarray|\n subarray.map do |ele|\n if ele == :S \n ele = :N \n else\n ele\n end\n end \n end\n new_grid\n end",
"def tile_board\n @board_array.each_with_index do |row_array, row|\n 10.times{|column| row_array << Tile.new(row,column)}\n end\n end",
"def grid\n \t\t\tfinal, y = Array.new, 0\n \t\t\t@@axis.fetch(:y).times do\n \t\t\t\tfinal[y], x = Array.new, 0\n \t\t\t\t@@axis.fetch(:x).times do\n \t\t\t\t\tfinal[y][x] = init_coord(x, y)\n \t\t\t\t\tx += 1\n \t\t\t\tend\n \t\t\t\ty += 1\n\t\t\tend\n\t\t\tfinal.reverse\n\t\tend",
"def test_with_irregular_array3D2; show([[[0,0,0]],\n [[0,0,0],[1,1,1]]]) end",
"def find_ones\n # => Establish an empty array to hold the index positions of all the 1s\n ones_ary = []\n # => Finding the index of ROW and COL for each 1 in the grid and storing\n # => them as row/col array pairs\n\n # => |row| denotes the top-level array (could be named anything)\n @image_array.each_index do |row|\n # => |col| is the chosen variable name for the inner array\n @image_array[row].each_index do |col|\n if @image_array[row][col] == 1\n puts \"#{row}, #{col}\"\n ones_ary << [row, col]\n end\n end\n end \n return ones_ary\n end",
"def printGrid(arr)\n arr.each do |a|\n puts a.inspect\n end\nend",
"def coords\r\n blur_pixels = []\r\n # blur_pixels is the array, and then we need to fill it\r\n @array.each_with_index do |row, row_int| #nested loops\r\n row.each_with_index do |int, col_index| # iterating over integers in arrays \r\n if int == 1 #1 is the number we are using as the culprit in our blur\r\n blur_pixels << [row_int, col_index] # << is pushing into the blur_pixels array\r\n end\r\n end\r\n end\r\n blur_pixels\r\n end",
"def cells_grid_1by1\n [\n [\n MazeMagic::Maze::Edge.instance,\n MazeMagic::Maze::HorizontalWall.instance,\n MazeMagic::Maze::Edge.instance\n ],\n [\n MazeMagic::Maze::VerticalWall.instance,\n MazeMagic::Maze::HorizontalWall.instance,\n MazeMagic::Maze::VerticalWall.instance\n ]\n ]\n end",
"def puts2DArray(my2DArray)\r\n puts '['\r\n my2DArray.each do |row|\r\n puts \"[#{row.join(\", \\t\")}]\"\r\n end\r\n puts ']'\r\n end",
"def draw_person_map(locations_for_same_time)\n if locations_for_same_time.empty?\n return\n end\n\n # Create a 2D array and then draw from that array\n array = Array.new(SIZE_OF_WORLD) {Array.new(SIZE_OF_WORLD, \" \")}\n locations_for_same_time.each do |location|\n array[location.x][location.y] = location.person\n end\n\n x = 0\n y = 0\n puts \"#{cyan(' 0123456789')} #{blue('t = ')}#{locations_for_same_time[0].time}\"\n (0..9).each do |y|\n puts \"#{cyan(y.to_s)}#{array[0][y]}#{array[1][y]}#{array[2][y]}#{array[3][y]}#{array[4][y]}#{array[5][y]}#{array[6][y]}#{array[7][y]}#{array[8][y]}#{array[9][y]}\"\n end\n puts \" \"\nend",
"def print_grid(points,size)\n grid = []\n for i in 0..size-1\n grid.push([])\n for j in 0..size-1\n if points.include? [j,i]\n # grid.last.push(\"#{j.to_s.reverse[0]}#{i.to_s.reverse[0]}\")\n grid.last.push(\"#{j}#{i}\")\n else\n grid.last.push(\"__\")\n end\n end\n end\n grid.reverse!\n grid.map {|x| puts x.join(\" \")}\nend",
"def matrix(x, y, z)\n sub_array = []\n y.times do\n sub_array.push(z);\n end\n #sub_array\n array = [];\n x.times do\n array.push(sub_array)\n end\n array\nend",
"def printGrid\n grid = []\n 15.times do\n grid.push '. . . . . . . . . . . . . . . '\n end\n\n Rules::LOCATIONS.each { |key, value| # get location labels with value as array of X, Y\n grid[value[1]][value[0]*2] = key # have to reverse how we access grid, so Y, X. Must double X due to spaces\n }\n\n (0..14).each_with_index do |i|\n \tputs grid[14-i] # Need to show lines in reverse order \n end\nend",
"def generate_coordinates\n coordinates = []\n (0..@column_count - 1).to_a.each do |i|\n (0..@row_count - 1).to_a.each do |j|\n coordinates << {x: i, y: j, z: 0}\n end\n end\n coordinates\n end",
"def print_arr(arr)\n # TODO 1\n (0...arr.length).each do |x|\n (0...arr.length).each do |y|\n print arr[x][y]\n print \" \"\n end\n print \"\\n\"\n end\nend",
"def multidimArray\n # fill multidimensional\n puts \"----------- Multi-dimensional arrays -------------- \"\n empty_table = Array.new(3) { Array.new(3) }\n Array({:a => \"a\", :b => \"b\"}) #=> [[:a, \"a\"], [:b, \"b\"]]\n number_array = [ [1,2,3], [4,5,6] ]\n puts number_array.to_s\nend",
"def index\n f = File.open(Rails.root.join(\"datas\",\"map2.yml\"))\n globalMap = Array.new\n f.each_line {|line| globalMap << line.split(' ')}\n\n\n x0 = Integer(params[\"x0\"])\n y0 = Integer(params[\"y0\"])\n width = Integer(params[\"width\"])\n height = Integer(params[\"height\"])\n\n x1 = x0 + width\n y1 = y0 + height\n\n @map = Array.new\n @poisMap = Array.new\n globalMap[y0...y1].each do |line|\n lineZE = Array.new\n width.times do\n lineZE << 0\n end\n @poisMap << lineZE\n @map << line[x0...x1]\n end\n\n @pois = Array.new\n Poi.all.each do |poi|\n if poi.x == nil\n continue\n end\n if poi.y == nil\n continue\n end\n if poi.x > (x0+1) && poi.x < (x1-3) && poi.y < y1 && poi.y > (y0+3)\n level = Integer((poi.lvl)/5)\n puts level\n\n begin\n\n arbres = Array.new\n arbres[0] = [[202,203],[210,211],[218,219]]\n arbres[1] = [[204,205],[212,213],[220,221]]\n arbres[2] = [[206,207],[214,215],[222,223]]\n arbres[3] = [[208,209],[216,217],[224,225]]\n\n #@poisMap[poi.y][poi.x] = 1 + level*5\n #@poisMap[poi.y][poi.x+1] = 2 + level*5\n #@poisMap[poi.y-1][poi.x] = 3 + level*5\n #@poisMap[poi.y-1][poi.x+1] = 4 + level*5\n #@poisMap[poi.y-2][poi.x] = 5 + level*5\n #@poisMap[poi.y-2][poi.x+1] = 6 + level*5\n\n @poisMap[poi.y-1][poi.x+1] = arbres[level][0][1]\n\n @poisMap[poi.y][poi.x] = arbres[level][0][0]\n @poisMap[poi.y][poi.x+2] = arbres[level][1][1]\n @poisMap[poi.y+1][poi.x+1] = arbres[level][1][0]\n @poisMap[poi.y+1][poi.x+3] = arbres[level][2][1]\n @poisMap[poi.y+2][poi.x+2] = arbres[level][2][0]\n rescue\n end\n #@pois << poi\n end\n end\n\n\n\n\n respond_to do |format|\n format.json { render :json => @map }\n format.xml {}\n format.html {}\n end\n end",
"def generate_grid\n grid = []\n @y.times do\n row = []\n @x.times do\n row << nil\n end\n grid << row\n end\n grid\n end",
"def get_board(width, height)\n # Create a new 2D array\n board = Array.new($board_height) {Array.new($board_width)}\n # Each element will be assigned a random value from 'colours'\n # That is done by choosing a random index of the 'colours' array\n (0...$board_height).each do |row| \n (0...$board_width).each do |cell|\n board[row][cell] = $colours[rand(6)] \n end\n end\n # Return board\n return board\nend",
"def display(world,i)\n puts \"Generation #{i+1}:\"\n x_list = []\n y_list = []\n world.each do |item|\n x_list.push(item[0])\n y_list.push(item[1])\n end\n ###############print the map###################\n for y in (y_list.min-3..y_list.max+3) do\n for x in (x_list.min-3..x_list.max+3) do\n if world.include?([x,y])\n print \"1\"\n else\n print \"0\"\n end\n end\n puts\n end\nend",
"def building_coordinates(x, y, height, width)\n puts\"building #{height}x#{width} at location (#{x},#{y})\"\n coords = Array.new\n (0..width-1).each do |j|\n\n (0..height-1).each do |i|\n\n co = Coordinate.new(x+i,y+j)\n coords.push(co)\n end\n\n end\n puts\"*getBuildingCoordinates* returning array of building coordinates\"\n coords\n end",
"def tiles\n @shape.values.map { |v| v.values }.flatten.select {|x| x != :empty}\n end",
"def make_Fake_Map(num_rows, num_columns) \n random_row_index = (rand() * num_rows).to_i\n puts random_row_index\n random_column_index = (rand() * num_columns).to_i\n puts random_column_index\n \n fake_map_array = []\n\n count_row = 0\n\n while count_row < num_rows do \n row_array = []\n count_col = 0\n while count_col < num_columns do\n if (count_col == random_column_index && count_row == random_row_index) \n row_array.push(\"X\")\n else row_array.push(\"A\")\n end\n count_col +=1\n end\n count_row +=1\n fake_map_array.push(row_array)\n end\n\n p fake_map_array\nend",
"def grid\n rows = []\n (1..self.height).to_a.each do |h|\n rows << row(h)\n end\n rows.reverse\n end",
"def shifted_grid_at(t)\n grid = grid_at(t)\n shifted_grid = [[]]\n\n (0...@height).each do |i|\n shifted_grid[i] = grid.map {|n| n[i] }.flatten\n end\n shifted_grid\n end",
"def print_terrain_map(ul_x = 0, ul_y = 0, br_x = @width - 1, br_y = @height - 1)\n (ul_y...br_y).each do |y|\n (ul_x...br_x).each do |x|\n print @terrain_map[x][y]\n end\n puts\n end\n puts\n end",
"def fillMaze(maze, streets)\n \n streets.each do |rua|\n maze.each_index do |i|\n\n # Get subarray and loop over its indexes also.\n subarray = maze[i]\n subarray.each_index do |j|\n # Display the cell.\n if i >= rua.startX && i <= rua.endX && j >= rua.startY && j <= rua.endY\n maze[i][j] = 0\n end\n end\n\n end\n end\n\n return maze.transpose.reverse\nend",
"def find_land world\n count = []\n\n world.each_with_index do |y, y_ind|\n #puts y.index(y_ind)\n world[y_ind].each_with_index do |x, x_ind|\n if world[y_ind][x_ind] == 'land'\n count.push continent_size(world, x_ind, y_ind)\n end\n end\n end\n count\nend",
"def print_2d_array(a)\r\n\r\n max_word_length = 0 # keeps track of the longest string in layout\r\n flattened = a.flatten\r\n flattened.each{|x| if x.length > max_word_length\r\n max_word_length = x.length \r\n end}\r\n max_word_length += 1 # we want a space in front when printing\r\n \r\n # insert a row of numbers into layout for printing\r\n max_no_columns = 0\r\n a.each{|x| if x.length > max_no_columns\r\n max_no_columns = x.length\r\n end}\r\n counter_array = [*0...max_no_columns] # [0, 1, 2, 3....max_no_columns]\r\n \r\n # clone, insert numbers into array, then print\r\n temp = Marshal.load(Marshal.dump(a))\r\n temp.unshift(counter_array) # insert in front\r\n print_array(temp, max_word_length) \r\nend",
"def two_d_translate(array)\n new_array = []\n array.each do |sub_array|\n num = sub_array[1]\n ele = sub_array[0]\n num.times { new_array << ele }\n end\n\n new_array\nend",
"def three_row_grid\n grid = []\n grid << [\n Cell.new(:alive, 0, 0),\n Cell.new(:alive, 0, 1),\n Cell.new(:dead, 0, 2)\n ]\n grid << [\n Cell.new(:alive, 1, 0),\n Cell.new(:dead, 1, 1),\n Cell.new(:dead, 1, 2)\n ]\n grid << [\n Cell.new(:dead, 2, 0),\n Cell.new(:dead, 2, 1),\n Cell.new(:dead, 2, 2)\n ]\n grid\nend",
"def ship_coordinates\n @ship_squares.map do |squares|\n squares.map { |square| [square.x, square.y] }\n end\n end",
"def ensure_adjacent_rooms(map)\n map.each do |row|\n x_coordinate = map.index(row)\n row.each do |room|\n index = map[row].index(room)\n puts index\n end\n\n \n # x_coordinates = row.collect! { |room| room = row.index(room) }\n \n # x_coordinates.each { |coordin| puts coordin } \n # \n # row.each { |coordin| puts coordin } \n end\nend",
"def array_of_array_multi(array)\n # YOUR CODE HERE\n multiArr = array.map{ |arr| arr.map{ |num| num * num } }\n p multiArr\n p array\n # array\nend",
"def map_board\n\t\t@cell_at = []\n\t\t@height.times do |row|\n\t\t\t@cell_at[row] = []\n\t\t\t@width.times do |col|\n\t\t\t\t@cell_at[row][col] = Cell.new\n\t\t\tend\n\t\tend\n\tend",
"def test_with_irregular_array3D1; show([[[0,0,0],[1,1,1]],\n [[0,0,0]]]) end",
"def grid(n, m)\n arr = Array.new(n) { Array.new(m, :N) }\n arr\nend",
"def drawGemMap(sourceArray)\n # Brute force debugger, produces a grid of numbers in the output window\n map = []\n \n sourceArray.each do |aGem|\n map[aGem.rowNum] ||= []\n map[aGem.rowNum][aGem.colNum] = aGem.gemType;\n end \n\n map1 = \"#{map[1][1]} #{map[1][2]} #{map[1][3]} #{map[1][4]} #{map[1][5]} #{map[1][6]} #{map[1][7]}\"\n \n map2 = \"#{map[2][1]} #{map[2][2]} #{map[2][3]} #{map[2][4]} #{map[2][5]} #{map[2][6]} #{map[2][7]}\"\n map3 = \"#{map[3][1]} #{map[3][2]} #{map[3][3]} #{map[3][4]} #{map[3][5]} #{map[3][6]} #{map[3][7]}\"\n \n map4 = \"#{map[4][1]} #{map[4][2]} #{map[4][3]} #{map[4][4]} #{map[4][5]} #{map[4][6]} #{map[4][7]}\"\n \n map5 = \"#{map[5][1]} #{map[5][2]} #{map[5][3]} #{map[5][4]} #{map[5][5]} #{map[5][6]} #{map[5][7]}\"\n \n map6 = \"#{map[6][1]} #{map[6][2]} #{map[6][3]} #{map[6][4]} #{map[6][5]} #{map[6][6]} #{map[6][7]}\"\n \n puts map6\n puts map5\n puts map4\n puts map3\n puts map2\n puts map1\nend",
"def PrintGrid\n\t\t(0..9).each do |i| #vertical parent grid\n\t\t\t(0..19).each do |j| #horizontal nested array\n\t\t\t\tprint @user_grid[i][j]\n\t\t\tend\n\t\tputs\n\t\tend\n\t\treturn @user_grid\n\tend",
"def iterate(arr)\n newArr = []\n (0...arr.size).each do |row|\n newArr[row] = []\n (0...arr.size).each do |col|\n num_neighbors = num_neighbors(row,col,arr)\n if arr[row][col]\n if num_neighbors == 2 || num_neighbors == 3\n newArr[row][col] = true\n else\n newArr[row][col] = false\n end\n else\n if num_neighbors == 3\n newArr[row][col] = true\n else\n newArr[row][col] = false\n end\n end\n end\n end\n arr = newArr\nend",
"def mineLocation field\n coords = []\n field.each_index do | i |\n field[i].each_index do | j |\n if field[i][j] == 1\n coords << i\n coords << j\n end\n end\n end\n coords\nend",
"def board\n board_arr = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\n p board_arr[0]\n p board_arr[1]\n p board_arr[2]\nend",
"def coords_arr(arr)\n\tarr.map.with_index do |line, x|\n\t\tline.map.with_index do |point, y|\n\t\t\tCOORDS_HASH[[x,y]] = point\n\t\t\t[x,y]\n\t\tend\n\tend\nend",
"def represent\n # grid_array will be an array of strings that represent our grid in NxN format\n grid_array=[]\n @h.times{|r| grid_array<<@grid[r*@w,@w].split('')*' '}\n grid_array\n end",
"def two_d_translate(arr)\n new_arr = []\n\n arr.each do |subArray|\n ele = subArray[0]\n num = subArray[1]\n\n num.times { new_arr << ele }\n end\n\n return new_arr\nend",
"def input1\n [\n [1, 0, 0, 0, 1],\n [0, 1, 0, 0, 5],\n [0, 0, 1, 0, 4],\n [0, 0, 0, 1, 3]\n ]\nend",
"def create_grid\n grid = Array.new(6, Array.new(7, BLANK))\n end",
"def p11\n\tgrid = Matrix[\n\t\t[8,\t2, 22,97,38,15,0, 40,0, 75,4, 5, 7, 78,52,12,50,77,91,8],\n\t\t[49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,4, 56,62,0],\n\t\t[81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,3, 49,13,36,65],\n\t\t[52,70,95,23,4, 60,11,42,69,24,68,56,1, 32,56,71,37,2, 36,91],\n\t\t[22,31,16,71,51,67,63,89,41,92,36,54,22,40,40,28,66,33,13,80],\n\t\t[24,47,32,60,99,3, 45,2, 44,75,33,53,78,36,84,20,35,17,12,50],\n\t\t[32,98,81,28,64,23,67,10,26,38,40,67,59,54,70,66,18,38,64,70],\n\t\t[67,26,20,68,2, 62,12,20,95,63,94,39,63,8, 40,91,66,49,94,21],\n\t\t[24,55,58,5, 66,73,99,26,97,17,78,78,96,83,14,88,34,89,63,72],\n\t\t[21,36,23,9, 75,0, 76,44,20,45,35,14,0, 61,33,97,34,31,33,95],\n\t\t[78,17,53,28,22,75,31,67,15,94,3, 80,4, 62,16,14,9, 53,56,92],\n\t\t[16,39,5, 42,96,35,31,47,55,58,88,24,0, 17,54,24,36,29,85,57],\n\t\t[86,56,0, 48,35,71,89,7, 5, 44,44,37,44,60,21,58,51,54,17,58],\n\t\t[19,80,81,68,5, 94,47,69,28,73,92,13,86,52,17,77,4, 89,55,40],\n\t\t[4,\t52,8, 83,97,35,99,16,7, 97,57,32,16,26,26,79,33,27,98,66],\n\t\t[88,36,68,87,57,62,20,72,3, 46,33,67,46,55,12,32,63,93,53,69],\n\t\t[4,\t42,16,73,38,25,39,11,24,94,72,18,8, 46,29,32,40,62,76,36],\n\t\t[20,69,36,41,72,30,23,88,34,62,99,69,82,67,59,85,74,4, 36,16],\n\t\t[20,73,35,29,78,31,90,1, 74,31,49,71,48,86,81,16,23,57,5, 54],\n\t\t[1,\t70,54,71,83,51,54,69,16,92,33,48,61,43,52,1, 89,19,67,48]\n\t]\n\tproducts = []\n\t(0...grid.row_count).each do |row|\n\t\t(0...grid.column_count).each do |col|\n\t\t\tright = col + 3 < grid.row_count\n\t\t\tdown = row + 3 < grid.column_count\n\t\t\tleft = col - 3 >= 0\n\t\t\tif right\n\t\t\t\tset = grid.minor(row..row,col..col+3)\n\t\t\t\tproducts << set.reduce(:*)\n\t\t\tend\n\t\t\tif down and right\n\t\t\t\tdiagonal = []\n\t\t\t\t(0..3).each do |x|\n\t\t\t\t\tdiagonal << grid.minor(row+x..row+x,col+x..col+x).component(0,0)\n\t\t\t\tend\n\t\t\t\tproducts << diagonal.reduce(:*)\n\t\t\tend\n\t\t\tif down\n\t\t\t\tset = grid.minor(row..row+3,col..col)\n\t\t\t\tproducts << set.reduce(:*)\n\t\t\tend\n\t\t\tif down and left\n\t\t\t\tdiagonal = []\n\t\t\t\t(0..3).each do |x|\n\t\t\t\t\tdiagonal << grid.minor(row+x..row+x,col-x..col-x).component(0,0)\n\t\t\t\tend\n\t\t\t\tproducts << diagonal.reduce(:*)\n\t\t\tend\n\t\tend\n\tend\n\tproducts.max\nend",
"def make_grid\n @grid = Array.new(4){Array.new(4)}\n end",
"def build_sample\n sample = Array.new(8) {Array.new(8)}\n sample[0][0] = King.new(0, 0, 0)\n sample[7][7] = King.new(7, 7, 1)\n sample[0][4] = Rook.new(0, 4, 1)\n sample[4][0] = Rook.new(4, 0, 1)\n sample[4][4] = Bishop.new(4, 4, 1)\n sample\nend",
"def fill_board(array)\n # puts array.inspect\n \n empty_board = BoardLoader.empty_board\n b = []\n \n count = 0\n empty_board.each_index do |row|\n b[row] = []\n empty_board[row].each_index do |column|\n if empty_board[row][column] == BLANK_SPACE\n if count < array.length\n b[row][column] = array[count]\n count += 1\n if count == array.length\n $last_spot = [row, column]\n end\n else\n b[row][column] = BLANK_SPACE\n end\n else\n b[row][column] = empty_board[row][column]\n end\n end\n end\n \n if $last_spot.nil?\n $last_spot = [empty_board.length-1, empty_board[0].length-1]\n end\n \n \n b\n end",
"def get_cell_at_xy(input_array)\n input_array.map do |coord|\n x = coord[0]\n y = coord[1]\n at_coord(x, y)\n end\n end",
"def all_indexes\n\t\tindex_list = []\n\t\tfor y_index in 0..7\n\t\t\tfor x_index in 0..7\n\t\t\t\tindex_list << [y_index, x_index]\n\t\t\tend\n\t\tend\n\t\tindex_list\n\tend",
"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 printHelper(array)\n array.each do |sub_array|\n sub_array.each do |tile|\n if tile < 10\n print \" #{tile} \"\n else\n print \" #{tile} \"\n end\n end\n print \"\\n\"\n end\nend",
"def test_with_irregular_array3D4; show([[[0,1,0.5,0.7]]]) end",
"def make_board\n board = Array.new(8) { Array.new(8) { Array.new(2) } }\n board.each_with_index do |row, row_i|\n row.each_with_index { |column, column_i| column[0], column[1] = row_i, column_i }\n end\n end",
"def print_grid # prints 3 X 3 grid with values\n puts \"\\n\"\n @grid.each_slice(3) { |row| puts row.join(' | ') }\n puts \"\\n\"\n end",
"def print\n grid_array = []\n @height.times do |r|\n grid_array << @grid[r * @width, @width].split('') * ' '\n end\n grid_array\n end",
"def setMap(level)\n\tcase level\n\twhen 1\n\t\treturn [[[0,0],[1,1],[0,0],[1,0],[-1,0],[0,1],[-1,0],[0,1],[2,0],[2,0]], 3, 0, false, 8]\n\twhen 2\n\t\treturn [[[4,0],[0,0],[0,0],[0,0],[0,0],[-1,0],[-2,0],[0,0],[1,1],[0,0],[2,2],[0,0],[1,1],[0,0],[3,3]],7,0,false,0]\n\twhen 3\n\t\treturn [[[0,0],[0,0],[0,0],[1,1],[2,2],[3,3],[-3,0],[0,0],[-3,0],[-3,0],[0,0]],2,0,false,10]\n\tend\nend",
"def grids\n [grid].compact\n end",
"def print_grid\n @grid.each do |arr|\n puts arr.join(\" \")\n end\n end",
"def two_d_translate(arr)\n one_d_arr = []\n arr.each do | outer |\n outer.each.with_index do | inner, i |\n if i == 0\n outer[1].times do\n one_d_arr << inner\n end\n end\n end\n end\n return one_d_arr\nend",
"def board(array)\n puts \" #{array[0][0]} | #{array[0][1]} | #{array[0][2]}\"\n puts \"-----------\"\n puts \" #{array[1][0]} | #{array[1][1]} | #{array[1][2]}\"\n puts \"-----------\"\n puts \" #{array[2][0]} | #{array[2][1]} | #{array[2][2]}\\n\\n\"\nend",
"def draw_map_cells(x, y)\n for i in (0..x-1)\n for j in (0..y-1)\n MapCellEmpty.create(:x => $node_size*5 * i + $node_size *5/2.0, :y => $node_size * 5 * j + $node_size * 5/2.0)\n end\n end\n end",
"def coordinates\n row_values.product(col_values)\n end",
"def build_grid\n x = 0\n 10.times do\n row = []\n y = 0\n 10.times do\n row.push({display: \"~~\", ship: false, coord: [x, y]})\n y += 1\n end\n self.grid << row\n x += 1\n end\n p self.grid\n end",
"def coord(a, b)\n final_array = []\n first_array = (1..a).to_a\n second_array = (1..b).to_a\n first_array.each do |first_num|\n second_array.each do |second_num|\n coordinates = \"(#{first_num}, #{second_num})\"\n final_array.push(coordinates)\n end\n end\n final_array \nend",
"def arrays_of_arrays(names, specialties)\n result = []\n\n # initialize iterator\n i = 0\n\n #loops through names\n specialties.each do |specialty|\n\n # shovel sub_array into result\n result.push([names[i]] + [specialty])\n\n # increment iterator\n i += 1\n end\n return result\n\nend",
"def square(idx)\n tiles = []\n x = (idx / 3) *3\n y = (idx % 3) * 3\n\n (x...x+3).each do |i|\n (y...y+3).each do |j|\n tiles << self[[i,j]]\n end\n end\n tiles\n end",
"def neighbor_cell_coordinates\n NEIGHBOR_OFFSETS.map { |coordinates| [row + coordinates[0], col + coordinates[1]] }\n end",
"def subsets(array)\n\nend"
] | [
"0.6215395",
"0.61178416",
"0.60820067",
"0.6050977",
"0.6038105",
"0.6018902",
"0.5964021",
"0.59452164",
"0.59341425",
"0.59038216",
"0.58844256",
"0.5871454",
"0.58675534",
"0.5864965",
"0.5849842",
"0.58264965",
"0.5806505",
"0.5793865",
"0.5757738",
"0.5743406",
"0.5741242",
"0.5730875",
"0.5711738",
"0.5645475",
"0.5632725",
"0.5632725",
"0.5631432",
"0.5628259",
"0.56275374",
"0.56250644",
"0.5616366",
"0.5611073",
"0.5605318",
"0.55768317",
"0.5569427",
"0.5565038",
"0.5552169",
"0.5544315",
"0.5540595",
"0.55298847",
"0.5528299",
"0.55242425",
"0.55239385",
"0.5523501",
"0.55187887",
"0.55064493",
"0.55058885",
"0.54997945",
"0.5499697",
"0.54863906",
"0.54727453",
"0.5456523",
"0.5442818",
"0.5436136",
"0.54326284",
"0.5427485",
"0.5420219",
"0.5417786",
"0.54146004",
"0.54015136",
"0.54012764",
"0.5398313",
"0.53949714",
"0.5394006",
"0.5393821",
"0.53621465",
"0.5359437",
"0.5340508",
"0.5333558",
"0.532272",
"0.531896",
"0.53171957",
"0.5308351",
"0.53073764",
"0.5294988",
"0.52935636",
"0.5292356",
"0.5284143",
"0.5281549",
"0.52813965",
"0.5254654",
"0.5242455",
"0.52360564",
"0.5220988",
"0.52196074",
"0.5210881",
"0.5208652",
"0.5206753",
"0.5201848",
"0.51908296",
"0.5181351",
"0.5180552",
"0.51768386",
"0.51618636",
"0.51606596",
"0.515696",
"0.5155846",
"0.51538163",
"0.5152509",
"0.5151849",
"0.5150075"
] | 0.0 | -1 |
A collection of Drip objects associated with a given `Caffeinate::Dripper` | def drips
drip_collection.values
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_dripper\n ::Caffeinate.dripper_collection.resolve(self)\n end",
"def trips\n RideShare::Trip.find_all_for_rider(@id)\n end",
"def rider_trip_instances\n rider_trips = RideShare::Trip.all_rider_trip_instances(@rider_id)\n return rider_trips\n end",
"def trips\n Trip.find_for_driver(@driver_id)\n end",
"def all_trips\n return Rideshare::Trip.find_trip_by_rider(@id)\n end",
"def listings\n trips.map {|trip| trip.listing}\nend",
"def trips\n arr = []\n Trips.all.each do |trip|\n if trip.listing == self\n arr << trip\n end\n end\n arr\n end",
"def trips\n trips = RideShare::Trip.trips_by_rider(@id)\n if trips != nil\n return trips\n else\n return []\n end\n end",
"def listings\n self.trips.map{|trip| trip.listing}\n end",
"def trips\n Trip.all.filter {|trip| trip.listing == self}\n\n end",
"def trips\n Trip.all.select { |trip| trip.listing==self}\n end",
"def trips\n Trip.all.select {|t| t.listing == self}\n end",
"def guests\n self.trips.map do |trip|\n trip.guest\n end\n end",
"def trips\n Trip.all.filter do |trip|\n trip.listing == self\n end\n end",
"def trips #<====== QUESTIONS: RETURNS NIL?\n Trip.all.select do |listings|\n if listings.listing == self\n listings\n end\n end\n end",
"def trips\n Trip.all.select {|trip| trip.listing == self}\n end",
"def trips()\n Trip.all().select() { | trip | trip.listing == self }\n end",
"def trips\n Trip.all.select do |trip|\n if trip.guest == self\n trip\n end\n end\n end",
"def trips\n @trips = Trip.all.select do |trip|\n trip.listing == self\n end\n end",
"def trips\n Trip.where(:route_id => self.route_id)\n end",
"def trips\n Trip.where(:route_id => self.route_id)\n end",
"def trips\n @trips = Trip.all.select do |trip|\n trip.guest == self\n end\n end",
"def listings \n Trip.all.select {|trip| trip.guest == self}.map { |trip| trip.listing}\n\n end",
"def listings\n self.trips.map {|trip| trip.listing}.uniq\n end",
"def trips\n Trip.all.select{ |trip| trip.guest == self}\n end",
"def listings\n arr = []\n Trips.all.each do |trip|\n if trip.guest == self\n arr << trip.listing\n end\n end\n arr\n end",
"def listings\n Trip.all.map do |trip|\n if trip.guest == self\n return trip.listing\n end\n end\n end",
"def trips\n Trip.all.select do |trip|\n trip.listing == self\n end\n\n end",
"def trips\n arr = []\n Trips.all.each do |trip|\n if trip.guest == self\n arr << trip\n end\n end\n arr\nend",
"def listings\n self.trips.map do |ti|\n ti.listing \n end\n end",
"def trips \n Trip.all.select do |ti|\n ti.guest == self\n end\n end",
"def guest\n arr = []\n Trips.all.each do |trip|\n if trip.listing == self\n arr << trip.guest\n end\n end\n arr\n end",
"def index\n @derps = Derp.all\n end",
"def passengers\n self.rides.map{ |ride| ride.passenger }\n end",
"def guests\n same_lists = Trip.all.select do |trip|\n trip.listing == self \n end\n same_lists.map { |trip| trip.guest}\n end",
"def create_trip_proxy(trip)\n\n # get the planned trip for this trip\n planned_trip = trip.planned_trips.first\n \n # initailize a trip proxy from this trip\n trip_proxy = TripProxy.new\n trip_proxy.traveler = @traveler\n trip_proxy.trip_purpose_id = trip.trip_purpose.id\n trip_proxy.arrive_depart = planned_trip.is_depart\n trip_proxy.trip_date = planned_trip.trip_datetime.strftime(TRIP_DATE_FORMAT_STRING)\n trip_proxy.trip_time = planned_trip.trip_datetime.strftime(TRIP_TIME_FORMAT_STRING)\n \n # Set the from place\n trip_proxy.from_place = trip.trip_places.first\n if trip.trip_places.first.poi\n trip_proxy.from_place_selected_type = POI_TYPE\n trip_proxy.from_place_selected = trip.trip_places.first.poi.id\n elsif trip.trip_places.first.place\n trip_proxy.from_place_selected_type = PLACES_TYPE\n trip_proxy.from_place_selected = trip.trip_places.first.place.id\n else\n trip_proxy.from_place_selected_type = RAW_ADDRESS_TYPE \n end\n\n # Set the to place\n trip_proxy.to_place = trip.trip_places.last\n if trip.trip_places.last.poi\n trip_proxy.to_place_selected_type = POI_TYPE\n trip_proxy.to_place_selected = trip.trip_places.last.poi.id\n elsif trip.trip_places.last.place\n trip_proxy.to_place_selected_type = PLACES_TYPE\n trip_proxy.to_place_selected = trip.trip_places.last.place.id\n else\n trip_proxy.to_place_selected_type = RAW_ADDRESS_TYPE \n end\n \n return trip_proxy\n \n end",
"def guests()\n self.trips().map() { | trip | trip.guest }.uniq\n end",
"def trips_by_weekday()\n TripCollection.new( @trips.select {|k, t| t.start_time.wday.between?(1,5) } )\n end",
"def guests\n trips.collect {|g| g.guest}\n end",
"def rides_as_passenger\n ride_ids = self.relationships.select(:ride_id).where(is_driving: false).joins(:ride).where(\"rides.user_id <> ?\", self.id)\n if ride_ids.count > 0\n Ride.where(\"id in (?)\", ride_ids)\n else\n []\n end\n end",
"def trips\n #will find upcoming trips/reservations for guests\n Reservation.where(guest_id: self.id)\n end",
"def listings\n @listings = trips.select do |trip|\n trip.listings\n end\n end",
"def trips\n Trip.all.select do |trip|\n trip.listing == self\n end\n end",
"def get_flight_destinations\n @flights = Flight.all.map(&:destination)\n end",
"def index\n @d_dungeoneers = DDungeoneer.includes(:c_class).all\n end",
"def doors\n sample(fetch_all('vehicle.doors'))\n end",
"def trips\n Trip.all.select do |trip|\n trip.listing == self\n end\nend",
"def guests\n trips.map {|trip| trip.guest}.uniq\n end",
"def personal_trips\n @personal_trips = trips.where(driver_id: 0)\n end",
"def build_trips(*currencies)\n departure_dates = Scraper::dates\n duration = Scraper::DURATIONS\n airbnb = JSON.parse($redis.get('airbnb'))\n\n AmadeusService.list_origins(currencies).values.flatten.each do |origin|\n trips = {}\n departure_dates.each do |date|\n trips[date] = {}\n\n duration.each do |duration|\n flights = AmadeusService.new(origin, departure_date: date, duration: duration, direct: true).get_inspiration\n unless !flights['status'].nil? && flights['status'] == '400'\n\n # Keep only destinations included in Airbnb Scraping\n flights['results'].reject! { |flight| airbnb[flight['destination']].nil? }\n\n # Add Airbnb price to every destination\n flights['results'].each do |flight|\n destination = flight['destination']\n if airbnb[destination]\n flight['airbnb'] = airbnb[destination][flight['departure_date']][duration.to_s]\n end\n end\n\n trips[date][duration] = flights\n end\n end\n end\n $redis.set(origin, trips.to_json)\n end\n end",
"def dlist\n @dests.keys\n end",
"def doctors\n appointments.map do |appointment|\n appointment.doctor\n end\nend",
"def passengers\n self.allrides.map do |ride|\n ride.passenger.name\n end\n end",
"def get_points_for(trip)\n points = Array.new\n trip.destinations.each do |d|\n if d.has_location?\n points << LatLonPoint.new([d.location.lat, d.location.lng])\n end\n end\n points\n end",
"def index\n \t@trips = Trip.all\n end",
"def guests\n @guests = trips.select do |trip|\n trip.guest\n end\n end",
"def departures\n json = Client511.new.departures(agency.name, name)\n parse_departures(json)\n end",
"def backers\n Person.where(id: pledges.pluck(:person_id))\n end",
"def list_adopted_pets()\n sql = \"SELECT * FROM pets INNER JOIN adoptions ON pets.id = adoptions.pet_id WHERE adoptions.owner_id = $1\"\n values = [@id]\n pets = SqlRunner.run(sql, values)\n return pets.map{|pet| Pet.new(pet)}\n end",
"def dresses\n render json: { collections: Collection.published_dresses }\n end",
"def trips \n trips_taken = Trip.all.select do |trip|\n trip.listing == self\n end\n end",
"def index\n @daters = Dater.all\n end",
"def rides\n Ride.all.select { |ride| ride.passenger == self }\n end",
"def doctors\n appointments.map do |appointment| appointment.doctor end\n end",
"def rides\n Ride.all.select {|ride| ride.passenger == self}\n end",
"def guests \n Trip.all.map do |listings|\n if listings.listing == self\n listings.guest.name\n end\n end\n end",
"def rides()\n Ride.all().select() { | ride | ride.passenger == self }\n end",
"def doctors\n @appointments.collect do |appointment|\n appointment.doctor\n end\n end",
"def listings\n Trip.all.select do |listing|\n listing.guest == self\n end\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def index\n @trips = Trip.all\n end",
"def guests\n Trip.all.select do |guest|\n guest.listing == self\n end\n end",
"def index\n @docters = Docter.all\n end",
"def list\n response = self.class.get('/droplets', headers: @header)\n tratar_response(response)\n end",
"def return_all_drivers\n return @trips.map{ |trip| trip.driver }\n end",
"def doctors\n appointments.map do |appointment|\n appointment.doctor\n end\n end",
"def doctors\n appointments.map do |appointment|\n appointment.doctor\n end\n end",
"def index\n @trips = Trip.all\n end",
"def doctors\n self.appointments.map do |appointment|\n appointment.doctor\n end\n end",
"def trips_by_trip_id(trip_id)\n get \"/gtfs/trips/tripId/#{trip_id}\"\n end",
"def doctors\n appointments.map do |appt|\n appt.doctor\n end\n end",
"def passenger_ids\n passenger_ids = []\n self.ridings.each {|riding| passenger_ids << riding.user_id}\n return passenger_ids\n end",
"def patients\n self.appointments.map do |doctors_appts|\n doctors_appts.patient\n end\n end",
"def scoped_collection\n super.preload(:gateway, :gateway_group, :routing_group, :routing_tag_mode, :vendor, :account, :statistic,\n :routeset_discriminator, network_prefix: %i[country network])\n end",
"def previous_driver_trips\n driver_list = []\n rider_trips = RideShare::Trip.all_rider_trip_instances(@rider_id)#does this mean i need to make a self method of rider trip instances?\n rider_trips.each do |object|\n driver_list << object.driver_object\n end\n return driver_list\n end",
"def get_debaters\n\t\treturn self.accounts\n\tend",
"def drivers\n driver_ids = trips.map { |trip| trip.driver_id }\n driver_ids.sort!.uniq! # sort by ascending id and remove any duplicates\n # find the driver instances matching the given driver ids\n driver_ids.map { |driver_id| Driver.find(driver_id)}\n end",
"def doctors\nAppointment.all.map do |x| x.doctor\n\n end\nend",
"def dcerpc_endpoint_list\n\t\tres = []\n\n\t\tprint_status(\"Connecting to the endpoint mapper service...\")\n\t\tbegin\n\t\t\teps = nil\n\t\t\tdport = nil\n\n\t\t\t[135, 593].each do |i|\n\t\t\t\tdport = i\n\t\t\t\tbegin\n\t\t\t\t\teps = Rex::Socket::Tcp.create(\n\t\t\t\t\t'PeerHost' => rhost,\n\t\t\t\t\t'PeerPort' => dport,\n\t\t\t\t\t'Proxies' => proxies,\n\t\t\t\t\t'Context' =>\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'Msf' => framework,\n\t\t\t\t\t\t\t'MsfExploit' => self,\n\t\t\t\t\t\t}\n\t\t\t\t\t)\n\n\t\t\t\t\tbreak\n\n\t\t\t\trescue ::Exception\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tif (not eps)\n\t\t\t\tprint_status(\"Could not connect to the endpoint mapper service\")\n\t\t\t\treturn nil\n\t\t\tend\n\n\t\t\teph = dcerpc_handle('e1af8308-5d1f-11c9-91a4-08002b14a0fa', '3.0', 'ncacn_ip_tcp', [dport])\n\t\t\topt = { 'Msf' => framework, 'MsfExploit' => self }\n\t\t\tdce = Rex::Proto::DCERPC::Client.new(eph, eps, opt)\n\n\t\t\thnd = nil\n\n\t\t\twhile(true)\n\n\t\t\t\t# Placeholders\n\t\t\t\tinfo =\n\t\t\t\t{\n\t\t\t\t\t:type => nil,\n\t\t\t\t\t:port => nil,\n\t\t\t\t\t:host => nil,\n\t\t\t\t\t:pipe => nil,\n\t\t\t\t\t:prot => nil,\n\t\t\t\t\t:uuid => nil,\n\t\t\t\t\t:vers => nil,\n\t\t\t\t\t:note => nil\n\t\t\t\t}\n\n\t\t\t\tdata = nil\n\n\t\t\t\tif(not hnd)\n\t\t\t\t\t# NULL handle to start with\n\t\t\t\t\tdata = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1].pack(\"V*\")\n\t\t\t\telse\n\t\t\t\t\t# Use the existing handle\n\t\t\t\t\tdata = [0, 0, 0, 0, 0].pack(\"V*\") + hnd\n\t\t\t\tend\n\n\t\t\t\tret = dce.call(2, data)\n\n\t\t\t\tif (\n\t\t\t\t\tdce.last_response == nil or\n\t\t\t\t\tdce.last_response.stub_data == nil or\n\t\t\t\t\tdce.last_response.stub_data.length < 40 or\n\t\t\t\t\tdce.last_response.stub_data[36,4] == \"\\xd6\\xa0\\xc9\\x16\"\n\t\t\t\t)\n\t\t\t\t\t# break from the parsing loop\n\t\t\t\t\tbreak\n\t\t\t\tend\n\n\t\t\t\t# Record the response data\n\t\t\t\tbuf = dce.last_response.stub_data\n\n\t\t\t\t# Record the handle if needed\n\t\t\t\thnd = buf[4, 20] if not hnd\n\n\t\t\t\t# Parse the response data\n\t\t\t\tnlen = buf[60, 4].unpack('V')[0]\n\t\t\t\tif (nlen > 1)\n\t\t\t\t\tinfo[:note] = buf[64, nlen - 1]\n\t\t\t\tend\n\n\t\t\t\t# Align the stub offset\n\t\t\t\tsoff = nlen + 72\n\t\t\t\twhile (soff % 4 != 0)\n\t\t\t\t\tsoff += 1\n\t\t\t\tend\n\n\t\t\t\t# Determine number of records\n\t\t\t\trcnt = buf[soff, 2].unpack('v')[0]\n\t\t\t\tsoff += 2\n\n\t\t\t\t# Parse the data from the stack\n\t\t\t\t1.upto(rcnt) do |i|\n\t\t\t\t\trlen = buf[soff, 2].unpack('v')[0]\n\t\t\t\t\tsoff += 2\n\n\t\t\t\t\tif (i == 1)\n\t\t\t\t\t\tinfo[:uuid] = Rex::Proto::DCERPC::UUID.uuid_unpack(buf[soff+1, 16])\n\t\t\t\t\t\tinfo[:vers] = buf[soff+17,2].unpack('CC').map{|s| s.to_s}.join(\".\")\n\t\t\t\t\tend\n\n\t\t\t\t\tif (i > 3)\n\t\t\t\t\t\tinfo[:type] = buf[soff, 1].unpack(\"C*\")[0]\n\t\t\t\t\tend\n\n\t\t\t\t\tsoff += rlen\n\n\t\t\t\t\txlen = buf[soff, 2].unpack('v')[0]\n\t\t\t\t\tsoff += 2\n\n\t\t\t\t\tcase info[:type]\n\t\t\t\t\twhen nil\n\n\t\t\t\t\t# TCP\n\t\t\t\t\twhen 7\n\t\t\t\t\t\tinfo[:prot] = 'tcp'\n\t\t\t\t\t\tinfo[:port] = buf[soff, 2].unpack('n')[0]\n\n\t\t\t\t\t# UDP\n\t\t\t\t\twhen 8\n\t\t\t\t\t\tinfo[:prot] = 'udp'\n\t\t\t\t\t\tinfo[:port] = buf[soff, 2].unpack('n')[0]\n\n\t\t\t\t\t# ADDR\n\t\t\t\t\twhen 9\n\t\t\t\t\t\tinfo[:host] = buf[soff, 4].unpack('C4').join('.')\n\n\t\t\t\t\t# PIPE\n\t\t\t\t\twhen 15\n\t\t\t\t\t\tinfo[:prot] = 'pipe'\n\t\t\t\t\t\tinfo[:pipe] = buf[soff, xlen].unpack(\"a*\")[0]\n\n\t\t\t\t\t# LRPC\n\t\t\t\t\twhen 16\n\t\t\t\t\t\tinfo[:prot] = 'lrpc'\n\t\t\t\t\t\tinfo[:pipe] = buf[soff, xlen].unpack(\"a*\")[0]\n\n\t\t\t\t\t# NETBIOS\n\t\t\t\t\twhen 17,24\n\t\t\t\t\t\tinfo[:host] = buf[soff, xlen].unpack(\"a*\")[0]\n\n\t\t\t\t\t# HTTP\n\t\t\t\t\twhen 31\n\t\t\t\t\t\tinfo[:prot] = 'http'\n\t\t\t\t\t\tinfo[:port] = buf[soff, 2].unpack('n')[0]\n\n\t\t\t\t\t# DYNAMIC?\n\t\t\t\t\twhen 22\n\t\t\t\t\t\t# not parsed\n\t\t\t\t\telse\n\t\t\t\t\t\tprint_status(\"EPM unknown type: #{info[:type]} #{buf[soff, xlen].unpack(\"H*\")[0]}\")\n\t\t\t\t\tend\n\n\t\t\t\t\tsoff += xlen\n\t\t\t\tend\n\n\t\t\t\tinfo[:pipe].gsub!(\"\\x00\", '') if info[:pipe]\n\t\t\t\tinfo[:host].gsub!(\"\\x00\", '') if info[:host]\n\n\t\t\t\tres << info\n\t\t\tend\n\n\t\trescue ::Interrupt\n\t\t\traise $!\n\n\t\trescue ::Exception => e\n\t\t\tprint_status(\"Could not obtain the endpoint list: #{e}\")\n\t\t\tres = nil\n\t\tend\n\n\t\tres\n\tend",
"def list\n @trips = Trips.my_trips(cookies[ :user_id ] )\n end",
"def directors\n directors = []\n self.children.each { |m|\n m.directors.slice(0,1).each { |d| directors.push(d) }\n }\n directors.uniq\n end",
"def index\n @trip_routes = TripRoute.all\n end",
"def trip_filters\n elems = []\n TimeFilterHelper.time_filters.each do |tf|\n elems << {\n :id => 100 + tf[:id],\n :value => tf[:value]\n }\n end\n TripPurpose.all.each do |tp|\n elems << {\n :id => tp.id,\n :value => tp\n } \n end\n return elems \n end",
"def riders\n result = []\n self.books.each do |book|\n book.plans.each do |plan|\n plan.riders.each do |rider|\n result << rider\n end\n end\n end\n\n result\n end",
"def doctors\n doctor_list = []\n appointments.select do |doctor|\n doctor_list << doctor.doctor\n end\ndoctor_list\nend"
] | [
"0.66506803",
"0.62345374",
"0.6022168",
"0.5945111",
"0.5814769",
"0.57565314",
"0.5748462",
"0.5720995",
"0.5689172",
"0.5657983",
"0.56344426",
"0.56202114",
"0.55891573",
"0.5557003",
"0.55509233",
"0.5521626",
"0.5521104",
"0.55117655",
"0.5487773",
"0.54855525",
"0.54855525",
"0.54537904",
"0.54509705",
"0.5425926",
"0.54139596",
"0.54102594",
"0.5389471",
"0.53706205",
"0.5328141",
"0.53038156",
"0.5266009",
"0.52450675",
"0.5234171",
"0.5230668",
"0.52227783",
"0.5196762",
"0.5196258",
"0.5194421",
"0.51618797",
"0.51309246",
"0.512712",
"0.51193863",
"0.5114687",
"0.5109934",
"0.5102796",
"0.50514764",
"0.5046856",
"0.5031529",
"0.5004695",
"0.50038385",
"0.49792486",
"0.49477765",
"0.49436074",
"0.49397174",
"0.4937898",
"0.4915188",
"0.49144554",
"0.49110365",
"0.487428",
"0.48679337",
"0.4864897",
"0.48546547",
"0.48545778",
"0.4849902",
"0.48484737",
"0.48478943",
"0.4844794",
"0.48327678",
"0.48289874",
"0.48281997",
"0.48281997",
"0.48281997",
"0.48281997",
"0.48281997",
"0.48281997",
"0.48281997",
"0.48103508",
"0.48036075",
"0.47974357",
"0.47961986",
"0.47887072",
"0.47887072",
"0.47765255",
"0.47690788",
"0.47646436",
"0.47564268",
"0.4742151",
"0.47347146",
"0.4734586",
"0.47277325",
"0.47231144",
"0.47228593",
"0.4721239",
"0.47206596",
"0.47068068",
"0.4699157",
"0.4693631",
"0.46919644",
"0.46899268",
"0.46892554"
] | 0.6384552 | 1 |
Register a drip on the Dripper drip :mailer_action_name, mailer_class: "MailerClass", step: 1, delay: 1.hour | def drip(action_name, options = {}, &block)
drip_collection.register(action_name, options, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pickup_scheduled(pickup_id)\n @pickup = Pickup.find(pickup_id)\n @greeting = \"Hi\"\n\n mail(to: \"#{@pickup.name} <#{@pickup.email}>\", subject: 'Your eCycle pickup is scheduled')\n end",
"def send_delayed_validation_email\n #get delayed time\n delayed_time = self.time + 1.hour + 45.minutes\n #get info for emails\n booking_name = self.booking_name\n email = self.restaurant.principle_email\n restaurant_name = self.restaurant.name\n #send delayed emails\n if delayed_time > Time.now\n ReservationValidationEmailWorker.perform_at(delayed_time, booking_name, email, restaurant_name )\n end\n end",
"def schedule_step\n self.waiting!\n UserMailer.schedule_step(self).deliver_now\n end",
"def send_post_registration_email\n IdealsMailer.account_registered(self).deliver_now\n end",
"def event_mail\n NoticePlannerMailer.delay.notice_planner_email('lumi.xperia@gmail.com', 'test', 'cron-test', 'https://yahoo.co.jp')\n end",
"def account_created(hacker)\n @hacker = hacker\n\n mail to: @hacker.email, subject: 'Welcome to hackrLog()!'\n end",
"def daily_gratitude\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def send_activation_email\n DoctorMailer.account_activation(self).deliver_now\n end",
"def send_dri_on_delay_email(email,event_name, dri_role,url,team_id,event_id,cc_emails)\n @event_name=event_name\n @dri_role=dri_role\n @minutes=\"10\"\n @url=url\n #@url=\"/flash_teams/\"+team_id+\"/\"+event_id+\"/delay\"\n\n #@url2 = url_for :controller => 'FlashTeamsController', :team_id => team_id ,:event_id => event_id , :action => 'delay'\n\n mail(:to => email, :cc => cc_emails, :subject => event_name +' run by ' + dri_role +' is running late')\n \n end",
"def appointment\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def mailer; end",
"def shipped\n @greeting = \"Hi\"\n\n mail to: \"tariq.sulehir@khaleef.com\"\n end",
"def send_mail_on_creation(rent)\n RentMailer.success_rent_email(rent.id).deliver_later\n end",
"def send_notification\n AdminMailer.delay.new_report(self)\n end",
"def send_delay_email\n PatientMailer.appointment_delayed_email(patient,\n appointment_delayed_time).deliver_later\n end",
"def send_lesson_reminder_email\n UserMailer.lesson_reminder(mentor).deliver_now\n end",
"def send_invite\n\t\tMyMailer.new_invite(self).deliver_now\n\t\t#MyMailer.new_invite(self).deliver_later!(wait_until: 5.minutes.from_now)\n\tend",
"def send_invite\n\t\tMyMailer.new_invite(self).deliver_now\n\t\t#MyMailer.new_invite(self).deliver_later!(wait_until: 5.minutes.from_now)\n\tend",
"def reservation_information\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def notify\n @greeting = \"Just a test\"\n mail(to: \"cneumann@marsmonitoring.com\") #.deliver_later\n end",
"def admin_notify\n UserMailer.signup_notification(self).deliver_later!(wait: 1.minute)\n end",
"def alteration_email(user, trip)\n @trip=Trip.find_by(:id => trip)\n @user = User.find_by(:id => user)\n @fbo= Fbo.find_by(:id => @trip.fbo_id)\n @airport = Airport.find_by(:id => @fbo.airport_id)\n @url = 'http://chartair.us/trips'\n mail(to: @user.email, subject: 'Trip Alteration')\n end",
"def send_request_notification_email\n ReservationMailer.request_notification(self).deliver_now\n end",
"def new_lead(lead)\n @greeting = \"Hi\"\n @lead = lead\n\n mail to: \"jesse.flores@me.com\", subject: \"New Lead\"\n end",
"def registration\n @greeting = \"Hi\"\n\n mail to: \"afzalmlakdawala@gmail.com\"\n end",
"def booking_confirmed\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def daily_reading\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def new_service\n ReservationMailer.new_service\n end",
"def deliver_activation_instructions!\n Notifier.delay.signup_notification(self.id)\n end",
"def send_zap\n UserMailer.zap_zap(self).deliver_now\n end",
"def payment_upcoming\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def rails_create_email(action)\n rails_mailer.public_send(action, self)\n end",
"def activation\n @greeting = \"Hi\"\n\n mail :to => \"john@synapticmishap.co.uk\"\n end",
"def send_welcome_email\n UserMailer.signup_email(self) #removed .delay\n end",
"def example_mailer\n ExamplerailsMailer.example_mailer\n end",
"def admin_trip_booked(user)\n @user=user\n @url=\"www.chartair.us/admin_main\"\n mail(to: 'founders@chartair.us', subject: 'A User has Booked a Trip')\n end",
"def send_pre_lesson_reminder_email\n UserMailer.lesson_reminder(mentor).deliver_now\n end",
"def hotel_notification(hotel, action, current_user)\n @user = current_user\n @action = action\n @hotel = hotel\n mail(to: \"zmb1391@gmail.com\", subject: \"Hotel created/updated/destroyed\")\n end",
"def rate_your_date\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def mailer\n ExamplerailsMailer.mailer\n end",
"def send_email\n AlertNotifier.delay.email_back_office_announcement(self)\n end",
"def send_one_week_reservation_reminder(email)\n @email = email\n mail(to: email, subject: 'Your Pet Boarding Reservation Reminder [RCN]')\n end",
"def tutor_reserved_notification\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def send_emails_new_person\n NewPersonJob.perform_later(id, full_name)\n end",
"def assigned\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def reservation_confirmation\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def post_shipment_notifier(shipment)\n @shipment = shipment\n subject = \"WARNING: No InstaTrace Shipments Posted in 24 hours\" \n mail(:to => EMAIL_NOTIFY_POST_SHIPMENT_API, :subject => subject) if shipment.hawb && shipment.created_at\n end",
"def received(attendee_id)\n @attendee = WorkshopAttendee.find(attendee_id)\n mail(to: \"info@coderfactory.com\", from: \"Workshop Registration <info@coderfactory.com>\", subject: \"Coder Factory Academy workshop session registration received.\")\n end",
"def send_day_before_reservation_reminder(email)\n @email = email\n mail(to: email, subject: 'Your Pet Boarding Reservation Reminder [RCN]')\n end",
"def order_in_progress\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def restaurant_email\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def reminder\n RequestMailer.reminder\n end",
"def reminder(person, time_slots)\n @person = person\n @time_slot_text = \"#{time_slots.first.day} #{time_slots.first.time.strftime('%l:%M%P')} - #{(time_slots.last.time + 30.minutes).strftime('%l:%M%P')}\"\n\n mail to: @person.email, subject: 'Adoration Reminder'\n end",
"def weekly_email\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def deliver_activation_instructions!\n reset_perishable_token!\n Mailer.deliver_activation_instructions(self)\n end",
"def getting_started\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def send_fundraiser_featured_notification\n person.send_email :fundraiser_featured_notification, fundraiser: self\n end",
"def tu_turno\n @greeting = \"Hi\"\n\n mail to: \"gonzalo.lema1@gmail.com\"\n end",
"def created(dues_payment)\n @dues_payment = dues_payment\n\n if Rails.env.production?\n mail :to => @dues_payment.member.user.email, \n :cc => 'dues@devildogsquadron.com', \n :subject => 'Devil Dog Squadron Dues Reminder'\n else\n mail :to => \"jim@polarbeardesign.net\", \n :subject => 'Devil Dog Squadron Dues Reminder - TEST'\n end\n end",
"def request_delegation(delegation)\n @delegation = delegation\n\n mail(from: @delegation.manager.email, to: @delegation.employee.email, subject: 'Passiton - Delegation request') do |format|\n format.html { render layout: 'email_simple.html.erb' }\n format.text\n end\n end",
"def send_email\n InquiryMailer.inquiry_created_email(self).deliver\n end",
"def notify(endpoint,time=Time.now)\n @endpoint = endpoint\n @time = time\n\n mail :to => endpoint.email\n end",
"def notify_mail\n @greeting = \"Hi\"\n\n mail to: \"mitsuimasayoshi@gmail.com\", subject: \"[Localgarage]Printer_URL\"\n end",
"def order_shipped\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def order_shipped\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def order_shipped\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def order_shipped\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def app_conformation\n @greeting =\"hi\"\n mail to: \"vpolam@memphis.edu\" , subject: \"requesting appointment\"\n end",
"def send_booking_email(info)\n # Send email with booking confirmation\n MemberMailer.booking(self, info).deliver_now\n end",
"def reminder_to_request_departmental_approval(name, email)\n @name = name\n\n mail(to: email, subject: 'Department approval may be needed')\n end",
"def send_activation_email\n UserMailer.account_activation(self, activation_token).deliver_later\n end",
"def new_task(task)\n @greeting = \"Hi\"\n @id = task.id\n\n mail to: task.email\n end",
"def create_mailings!\n caffeinate_campaign.to_dripper.drips.each do |drip|\n mailing = Caffeinate::Mailing.new(caffeinate_campaign_subscription: self).from_drip(drip)\n mailing.save!\n end\n caffeinate_campaign.to_dripper.run_callbacks(:on_subscribe, self)\n end",
"def new_booking_email(customer, host, reservation)\n @customer = customer\n @host = host\n @url = \"/listings/#{reservation.listing.id}/reservations\"\n mail(to: host.email, subject: 'New Reservation for your Property')\n end",
"def new_trip(operator, trip)\n @trip = trip\n @operator = operator\n @emails = Organisation.get_all_emails(trip.organisation)\n mail(\n to: @emails,\n subject: 'JetSetGo - New Trip created'\n )\n end",
"def prayer_created(recipient, prayer)\n @recipient = recipient\n @prayer = prayer\n\n mail( :to => @recipient.full_email,\n :subject => \"New Prayer from #{@prayer.user.name}: #{truncate(@prayer.title, :length => 40)}\" )\n end",
"def recieved\n LeadMailer.recieved\n end",
"def schedule_reminder_email\n \tstart_time = Time.at(available_slot.start_time).strftime(' %H:%M')\n \tdate = appointment_date.to_s\n \tschedule_time = (Date.parse(date + start_time) - 30.minutes)\n \tReminderMailer.send_reminder(patient).deliver_later(wait_until: schedule_time)\n end",
"def send_booking_mail_to_host(booking)\n @booking = booking\n @host_email_id = User.find(@booking.user_id).email\n #binding.pry\n mail to: \"#{@host_email_id}\", subject: \"A New booking request- #{@booking.room.name}\"\n end",
"def send_request_confirmation_email\n ReservationMailer.request_confirmation(self).deliver_now\n end",
"def response(attendee_id)\n @attendee = WorkshopAttendee.find(attendee_id)\n mail(to: @attendee.email, subject: @attendee.first_name + \", you are now registered with our workshop sessions.\")\n end",
"def setup_mail(action, options = {})\n headers = options.fetch(:headers, {})\n headers[:subject] ||= choose_subject(options.fetch(:subject_ab_test_key, action), options.fetch(:params, {}))\n fire_user_notification_event(:email, {type: \"#{mailer_name}##{action}\", to: headers[:to]})\n mail(headers)\n end",
"def report_generated\n @greeting = \"Hi\"\n\n mail :to => \"to@example.org\"\n end",
"def order_created\n @greeting = \"Hi\"\n\n mail :to => \"to@example.org\"\n end",
"def mailer=(class_name); end",
"def tanta_new(tanta)\n @tanta = tanta\n\n mail to: \"nandisuper2@gmail.com\",\n subject: \"Request To Join TantaMukti Samiti\"\n end",
"def notify\n ReminderMailer.notify\n end",
"def sofortkontakt\n @greeting = \"Hi\"\n\n mail :to => \"to@example.org\"\n end",
"def fifth_anniversary\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def notice_post\n @greeting = \"Hi\"\n\n mail to: \"dan5.ya+bukt@gmail.com\"\n end",
"def send_welcome_email\n UserMailer.delay.welcome_email(self)\n end",
"def admin_order_inform\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def notify\n return false unless @tiers # invalid tiers_id\n extract_destinations\n if @french || @other\n done = notify_all_destinations\n say_notified if done && @mode\n done\n else # no mail\n register_tiers\n false\n end\n end",
"def after_create_action\n sign_up_lead_rescuer\n send_email_to_lead_rescuer\n end",
"def send_activation_mail\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_mail\n UserMailer.account_activation(self).deliver_now\n end",
"def lost_brain\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def lost_brain\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def cost_analysis\n AdminMailer.cost_analysis.deliver_now\n end",
"def perform(mailer, method, *args)\n mailer.send(method, *args).deliver\n #ex: LadybooMailer.atm_checkout_completed_successfully(order).deliver\n end"
] | [
"0.6321469",
"0.6197253",
"0.6181021",
"0.61545885",
"0.6006346",
"0.5985085",
"0.59707755",
"0.594062",
"0.59278595",
"0.58693933",
"0.58402133",
"0.5823704",
"0.5821306",
"0.57948583",
"0.5769678",
"0.5755207",
"0.5719841",
"0.5719841",
"0.57052875",
"0.56909907",
"0.56820196",
"0.56672287",
"0.5660121",
"0.5646859",
"0.56432223",
"0.56350076",
"0.5615798",
"0.56117034",
"0.5610925",
"0.56047446",
"0.55973744",
"0.5585122",
"0.5575917",
"0.55689204",
"0.5561223",
"0.5558363",
"0.5548815",
"0.5542558",
"0.55412436",
"0.552979",
"0.5513788",
"0.5513633",
"0.55115986",
"0.5509549",
"0.5502927",
"0.55015147",
"0.5500055",
"0.5494565",
"0.54935604",
"0.5490161",
"0.5489179",
"0.54883504",
"0.54786",
"0.54697144",
"0.54624844",
"0.54615164",
"0.545588",
"0.54519975",
"0.5445818",
"0.54404324",
"0.54379106",
"0.54362303",
"0.5429387",
"0.5420356",
"0.5420356",
"0.5420356",
"0.5420356",
"0.54169804",
"0.5408591",
"0.54075426",
"0.5403726",
"0.53979933",
"0.53972334",
"0.53926885",
"0.5383534",
"0.5376936",
"0.5374083",
"0.5373205",
"0.5370692",
"0.5364985",
"0.5364133",
"0.5362162",
"0.53584373",
"0.53575706",
"0.53566897",
"0.5355218",
"0.5354397",
"0.53540325",
"0.535106",
"0.5346457",
"0.53423417",
"0.5340745",
"0.53390867",
"0.5327068",
"0.53246796",
"0.53246796",
"0.53244406",
"0.53239524",
"0.53228587",
"0.53225213"
] | 0.5681568 | 21 |
def add_config inject_into_file "config/application.rb", :after => "config.action_view.javascript_expansions" do "config.action_view.javascript_expansions[:defaults] << %w(advanced_scaffold)" end | def create_model
template 'model.rb', "app/models/#{model_path}.rb" unless @skip_model
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_config_options_to_initializer\n devise_initializer_path = \"config/initializers/devise.rb\"\n if File.exist?(devise_initializer_path)\n old_content = File.read(devise_initializer_path)\n\n if old_content.match(Regexp.new(/^\\s# ==> Configuration for :trialable\\n/))\n false\n else\n inject_into_file(devise_initializer_path, :before => \" # ==> Configuration for :confirmable\\n\") do\n<<-CONTENT\n # ==> Configuration for :trialable\n # The period a user can access the site without enrolling\n # config.trial_period = 60.days\n\nCONTENT\n end\n end\n end\n end",
"def config_js\n [\n src_config_path.join('routes.js').to_s,\n src_config_path.join('router.js').to_s,\n src_config_path.join('app.js').to_s\n ]\n end",
"def javascripts\n super + %w(js/custom.js)\nend",
"def initial_dynamic_javascript\n res = []\n # res << %(Ext.Ajax.extraParams = {authenticity_token: '#{form_authenticity_token}'}; // Rails' forgery protection)\n res << %{Ext.ns('Netzke');}\n res << %{Ext.ns('Netzke.core');}\n res << %{Netzke.RelativeUrlRoot = '#{ActionController::Base.config.relative_url_root}';}\n res << %{Netzke.RelativeExtUrl = '#{ActionController::Base.config.relative_url_root}/extjs';}\n\n res << %{Netzke.core.directMaxRetries = '#{Netzke::Core.js_direct_max_retries}';}\n\n res.join(\"\\n\")\n end",
"def js_framework_settings(additional_settings_hash = {}, override = true)\n settings = @js_framework_settings\n settings.merge!(additional_settings_hash)\n\n if override\n return javascript_tag(\"APPLICATION = #{settings.to_json};\")\n else\n return javascript_tag(\"$.extend(true, APPLICATION, #{settings.to_json});\")\n end\n end",
"def javascript_global_config\n {\n development: Rails.env.development?,\n railsRoot: Rails.root.to_s,\n liveFeedWsUrl: live_feed_ws_url,\n eventPath: event_path(path: 'PATH'),\n }\n end",
"def active_scaffold_includes\r\n js = ActiveScaffold::Config::Core.javascripts.collect do |name|\r\n javascript_include_tag(ActiveScaffold::Config::Core.asset_path(:javascript, name))\r\n end.join('')\r\n\r\n css = stylesheet_link_tag(ActiveScaffold::Config::Core.asset_path(:stylesheet, \"stylesheet.css\"))\r\n ie_css = stylesheet_link_tag(ActiveScaffold::Config::Core.asset_path(:stylesheet, \"stylesheet-ie.css\"))\r\n\r\n js + \"\\n\" + css + \"\\n<!--[if IE]>\" + ie_css + \"<![endif]-->\\n\"\r\n end",
"def add_initializer_config\n template \"toybox.rb\", \"config/initializers/toybox.rb\"\n end",
"def set_static_includes\r\n @javascripts = [JS_SCRIPTACULOUS_SKOBEE_DEFAULT, JS_SKOBEE_COMMENTS]\r\n end",
"def load_js\n AssetManager.include_contrib_library [:core_ui, :jquery_tab]\n AssetManager.include_local_library [ 'ckeditor/init']\n\n AssetManager.include_css [:blog_global]\n end",
"def js_config\n super.tap do |c|\n # Hand over inline data to the js config hash\n c[:inline_data] = get_data if config[:load_inline_data]\n end\n end",
"def config\r\n\t\t\t\"<p>No additional configuration is available</p>\"\r\n\t\tend",
"def add_js_and_css_to_form\n unless @check_migration\n page_options = open(\"app/views/admin/#{@plural_name}/_form.html.erb\").grep(/content_for :javascripts/)\n \n if page_options.empty?\n insert_into_file \"app/views/admin/#{@plural_name}/_form.html.erb\",\n :before => \"<%= form_for\" do\n \"<% content_for :javascripts do %>\" +\n \"\\n\\t<script>\" +\n \"\\n\\t\\t$(document).ready(function(){\" +\n \"\\n\\t\\t\\tpage_options.init(false, '', '');\" +\n \"\\n\\t\\t});\" +\n \"\\n\\t</script>\"+\n \"\\n\\t<%= javascript_include_tag 'gallery' %>\" +\n \"\\n<% end %>\" +\n \n \"\\n\\n<% content_for :stylesheets do %>\" +\n \"\\n\\t<%= stylesheet_link_tag 'gallery' %>\" +\n \"\\n<% end %>\\n\\n\"\n end\n else\n insert_into_file \"app/views/admin/#{@plural_name}/_form.html.erb\",\n :after => \"<% content_for :javascripts do %>\" do\n \"\\n\\t<%= javascript_include_tag 'gallery' %>\"\n end\n \n insert_into_file \"app/views/admin/#{@plural_name}/_form.html.erb\",\n :before => \"<% content_for :javascripts do %>\" do\n \"\\n<% content_for :stylesheets do %>\" +\n \"\\n\\t<%= stylesheet_link_tag 'gallery' %>\" +\n \"\\n<% end %>\\n\"\n end\n end\n end\n end",
"def tinymce_configurations_javascript(options={})\n javascript = []\n\n TinyMCE::Rails.each_configuration do |name, config|\n config = config.merge(options) if options.present?\n javascript << \"TinyMCERails.configuration.#{name} = #{config.to_javascript};\".html_safe\n end\n\n safe_join(javascript, \"\\n\")\n end",
"def casein_config_javascript_includes\n\t \t['/casein/javascripts/custom.js', '/casein/javascripts/casein.js', '/javascripts/prototype.js']\n\tend",
"def set_static_includes\r\n @javascripts = [JS_SCRIPTACULOUS_SKOBEE_DEFAULT, JS_SKOBEE_PLANS, JS_DATEPICKER, JS_JSON]\r\n end",
"def inject_disable_jquery_animations\n inject_into_file \"app/views/layouts/application.html.erb\", before: \"</head>\" do\n \" <%= javascript_tag '$.fx.off = true;' if Rails.env.test? %>\\n\"\n end\n end",
"def scaffold_setup_helper\n engine :Erubis\n include ScaffoldingExtensions::Controller\n include ScaffoldingExtensions::RamazeController\n include ScaffoldingExtensions::Helper\n include ScaffoldingExtensions::PrototypeHelper\n unless trait[:layout] && trait[:layout][:all]\n layout(:scaffold_layout) \n define_method(:scaffold_layout){::Ramaze::Action.current.template = scaffold_path(:layout)}\n end\n end",
"def configure(c)\n\n c.layout = :fit\n\n c.load_inline_data ||= true\n c.enable_edit_in_form ||= true\n c.enable_edit_inline = false\n c.enable_extended_search = false\n c.enable_column_filters = false\n c.enable_pagination ||= true\n\n super\n\n end",
"def insert_into_application\n config.generators do |g|\n g.stylesheets = false\n g.javascripts = false\n g.test_framework :rspec, fixture: false\n g.template_engine :haml\n g.fixture_replacement :factory_girl, dir: 'spec/factories'\n end \nend",
"def inject_arkivo_config\n inject_into_file 'config/initializers/hyrax.rb', after: /^Hyrax\\.config do.*$/ do\n \"\\n # Hyrax can integrate with Zotero's Arkivo service for automatic deposit\\n\" \\\n \" # of Zotero-managed research items.\\n\" \\\n \" # Defaults to false. See README for more info\\n\" \\\n \" config.arkivo_api = true\\n\"\n end\n end",
"def install_sample_files\n super\n inject_line_before root.join('apps/web/templates/application.html.erb'), '</head>', <<-HTML\n <%= vite_client %>\n <%= vite_javascript 'application' %>\n HTML\n end",
"def inject_css\n append_to_file 'app/assets/stylesheets/application.css' do\n out = \"\\n\"\n out << \"/* *= require admin_test/application_admin_test */\"\n end\n end",
"def configure_frontend\n end",
"def set_assets\n\n @custom_csses = []\n @custom_javascripts = []\n\n\n action_hash = {\"create\" => \"new\", \"update\" => \"edit\"}\n file_name = action_hash[action_name] ? action_hash[action_name] : action_name\n root = Rails.root.to_s\n\n @custom_csses << \"compiled/application.css\" # always include the layout css\n @custom_csses << \"compiled/#{controller_name}/#{file_name}.css\" if File.exist?(\"#{root}/public/stylesheets/compiled/#{controller_name}/#{file_name}.css\")\n @custom_csses << \"compiled/#{controller_name}/all.css\" if File.exist?(\"#{root}/public/stylesheets/compiled/#{controller_name}/all.css\")\n\n\n @custom_javascripts << \"#{controller_name}/#{file_name}.js\" if File.exist?(\"#{root}/public/javascripts/#{controller_name}/#{file_name}.js\") # && !(\"#{file_name}.js\" == \"consumer_index.js\")\n @custom_javascripts << \"#{controller_name}/all.js\" if File.exist?(\"#{root}/public/javascripts/#{controller_name}/all.js\")\n\n # a trick to include facebox in the (devise-owned) registrations controller\n include_facebox if controller_name == 'registrations' && action_name == 'edit'\n\n end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def dev_config(str)\n inject_into_file('config/environments/development.rb', optimize_indentation(str, 2), after: \"config.assets.quiet = true\\n\")\n end",
"def config\n options = @options.merge(:text => human_name)\n options.merge!(:menu => @menus.collect(&:config)) if @menus.size > 0\n options.merge!(:handler => \"function(){ Backend.app.load('#{url_for(@url.merge(:only_path => true))}') }\".to_l) if @url\n options\n end",
"def active_scaffold_javascripts(frontend = :default)\n super\n #super + [calendar_date_select_javascripts]\n end",
"def add_redcrumbs_initializer\n template \"initializer.rb\", \"config/initializers/redcrumbs.rb\"\n end",
"def activate\n Admin::ConfigurationsController.class_eval do\n before_filter :add_faq_links, :only => :index\n def add_faq_links\n @extension_links << {:link => admin_question_categories_path, \n :link_text => \"Frequently Asked Questions\", \n :description => \"Add,edit or remove FAQ categories and questions\"}\n end\n end\n end",
"def inject_js; end",
"def configurations; end",
"def js_includes\n end",
"def configure_adding_additional_css_classes\n if should_add_css_classes?\n @should_add_css_classes = true\n @css_classes_to_add = css_classes_to_add_from_config.to_s\n end\n end",
"def blacklight_config\n @blacklight_config ||= begin\n # Create a new config based on the defaults\n config = default_blacklight_config.inheritable_copy(self.class)\n\n config.current_exhibit = exhibit\n\n config.document_presenter_class = lambda do |context|\n if context.action_name == 'index'\n config.index.document_presenter_class\n else\n config.show.document_presenter_class\n end\n end\n\n config.show.merge! show if show.present?\n config.index.merge! index if index.present?\n config.index.respond_to[:iiif_json] = true\n\n config.index.thumbnail_field ||= Spotlight::Engine.config.thumbnail_field\n\n config.add_results_collection_tool 'curator_actions', if: :render_curator_actions?\n\n unless config.curator_actions\n config.curator_actions ||= Blacklight::NestedOpenStructWithHashAccess.new(Blacklight::Configuration::ToolConfig)\n config.curator_actions.save_search!\n config.curator_actions.bulk_actions!\n end\n\n unless config.bulk_actions\n config.bulk_actions ||= Blacklight::NestedOpenStructWithHashAccess.new(Blacklight::Configuration::ToolConfig)\n\n config.bulk_actions.change_visibility!\n config.bulk_actions.add_tags!\n config.bulk_actions.remove_tags!\n end\n\n config.default_solr_params = config.default_solr_params.merge(default_solr_params)\n\n config.default_per_page = default_per_page if default_per_page\n\n config.view.embed!\n config.view.embed.partials ||= ['openseadragon']\n config.view.embed.if = false\n config.view.embed.locals ||= { osd_container_class: '' }\n\n # Add any custom fields\n config.index_fields.merge! custom_index_fields(config)\n config.index_fields.reject! { |_k, v| v.if == false }\n\n # Update with customizations\n config.index_fields.each do |k, v|\n v.original = v.dup\n if index_fields[k]\n v.merge! index_fields[k].symbolize_keys\n elsif v.custom_field\n set_custom_field_defaults(v)\n else\n set_index_field_defaults(v)\n end\n\n v.immutable = Blacklight::OpenStructWithHashAccess.new(v.immutable)\n v.merge! v.immutable.to_h.symbolize_keys\n\n v.if = :field_enabled? unless v.if == false\n\n v.normalize! config\n v.validate!\n end\n\n config.show_fields.reject! { |_k, v| v.if == false }\n\n config.show_fields.reject { |k, _v| config.index_fields[k] }.each do |k, v|\n v.original = v.dup\n config.index_fields[k] = v\n\n if index_fields[k]\n v.merge! index_fields[k].symbolize_keys\n else\n set_show_field_defaults(v)\n end\n\n v.immutable = Blacklight::OpenStructWithHashAccess.new(v.immutable)\n v.merge! v.immutable.to_h.symbolize_keys\n\n v.if = :field_enabled? unless v.if == false\n\n v.normalize! config\n v.validate!\n end\n\n ##\n # Sort after the show fields have also been added\n config.index_fields = Hash[config.index_fields.sort_by { |k, _v| field_weight(index_fields, k) }]\n\n config.show_fields = config.index_fields\n\n config.search_fields.merge! custom_search_fields(config)\n if search_fields.present?\n config.search_fields = Hash[config.search_fields.sort_by { |k, _v| field_weight(search_fields, k) }]\n\n config.search_fields.each do |k, v|\n v.original = v.dup\n v.if = :field_enabled? unless v.if == false\n next if search_fields[k].blank?\n\n v.merge! search_fields[k].symbolize_keys\n v.normalize! config\n v.validate!\n end\n end\n\n if sort_fields.present?\n config.sort_fields = Hash[config.sort_fields.sort_by { |k, _v| field_weight(sort_fields, k) }]\n\n config.sort_fields.each do |k, v|\n v.original = v.dup\n v.if = :field_enabled? unless v.if == false\n next if sort_fields[k].blank?\n\n v.merge! sort_fields[k].symbolize_keys\n v.normalize! config\n v.validate!\n end\n end\n\n config.facet_fields.merge! custom_facet_fields\n if facet_fields.present?\n config.facet_fields = Hash[config.facet_fields.sort_by { |k, _v| field_weight(facet_fields, k) }]\n\n config.facet_fields.each do |k, v|\n v.original = v.dup unless v.custom_field\n next if facet_fields[k].blank?\n\n v.merge! facet_fields[k].symbolize_keys\n v.enabled = v.show\n v.if = :field_enabled? unless v.if == false\n v.normalize! config\n v.validate!\n end\n end\n\n config.per_page = (config.per_page & per_page) if per_page.present?\n\n if document_index_view_types.present?\n config.view.each do |k, v|\n v.original = v.dup\n v.key = k\n v.if = :enabled_in_spotlight_view_type_configuration? unless v.if == false\n end\n end\n\n if config.search_fields.blank?\n config.navbar.partials[:saved_searches].if = false if config.navbar.partials.key? :saved_searches\n config.navbar.partials[:search_history].if = false if config.navbar.partials.key? :search_history\n end\n\n config\n end\n end",
"def active_scaffold_config\r\n @controller.class.active_scaffold_config\r\n end",
"def init_config_folder\n copy_file('config/app.js', src_path('config/app.js'))\n copy_file('config/routes.js', src_path('config/routes.js'))\n copy_file('config/router.js', src_path('config/router.js'))\n end",
"def tinymce_javascript(config=:default, options={})\n options, config = config, :default if config.is_a?(Hash)\n options = Configuration.new(options)\n\n \"TinyMCERails.initialize('#{config}', #{options.to_javascript});\".html_safe\n end",
"def casein_config_javascript_includes\n %w[casein/custom casein/casein]\n end",
"def active_scaffold_config\r\n @controller.class.active_scaffold_config\r\n end",
"def configuration; end",
"def configuration; end",
"def configuration; end",
"def configuration; end",
"def configuration; end",
"def config\n\n end",
"def active_scaffold_javascripts(frontend = :default)\r\n ActiveScaffold::Config::Core.javascripts(frontend).collect do |name|\r\n ActiveScaffold::Config::Core.asset_path(name, frontend)\r\n end\r\n end",
"def setup_config\n # To be Extended\n end",
"def active_admin\n copy_file 'active_admin.rb', 'app/admin/seo_landing_pages.rb'\n end",
"def js_extend_properties\n {\n :init_component => js_init_component.l\n }\n end",
"def config_files(override); end",
"def add_default_configuration!\n plugins << Plugin::LinkTracker.instance\n plugins << Plugin::Causata.instance\n end",
"def curation\n end",
"def add_javascripts\n insert_into_file \"app/assets/javascripts/application.js\", :after => \"//= require jquery_ujs\\n\" do\n \"//= require dataTables/jquery.dataTables\\n\"\n end\n end",
"def config(mod, *accessors); end",
"def developer_mode_install!\n controller_path = File.dirname(__FILE__) + \"/pagseguro/controllers\"\n \n $LOAD_PATH << controller_path\n \n if defined?(ActiveSupport::Dependencies)\n ActiveSupport::Dependencies.load_paths << controller_path\n elsif defined?(Dependencies.load_paths)\n Dependencies.load_paths << controller_path\n else\n puts \"=> [PagSeguro] Rails version too old for developer mode to work\" and return\n end\n \n ::ActionController::Routing::RouteSet.class_eval do\n next if defined?(draw_with_pagseguro_map)\n \n def draw_with_pagseguro_map\n draw_without_pagseguro_map do |map|\n map.named_route \"pagseguro_developer\", \n \"/pagseguro_developer/:action/:id\",\n :controller => \"pagseguro_developer\"\n \n yield map\n end\n end\n \n alias_method_chain :draw, :pagseguro_map\n end\n end",
"def inject_routes\n routing_code = \"Hydra::BatchEdit.add_routes(self)\"\n sentinel = /HydraHead.add_routes\\(self\\)/\n inject_into_file 'config/routes.rb', \"\\n #{routing_code}\\n\", { :after => sentinel, :verbose => false }\n\n routing_code = \"\\n # This must be the very last route in the file because it has a catch all route for 404 errors.\n # This behavior seems to show up only in production mode.\n mount Sufia::Engine => '/'\\n\"\n sentinel = /devise_for :users/\n inject_into_file 'config/routes.rb', routing_code, { :after => sentinel, :verbose => false }\n \n end",
"def all_plugin_hook_configs; end",
"def configure_javascript_runner(options, target_device_id)\n js_config = @javascript_runner\n\n js_config.target_device_id = target_device_id\n js_config.target_device_language = options.simulator.language\n js_config.target_device_locale = options.simulator.locale\n js_config.is_hardware = !(options.illuminator.hardware_id.nil?)\n js_config.implementation = options.javascript.implementation\n js_config.test_path = options.javascript.test_path\n\n js_config.entry_point = options.illuminator.entry_point\n js_config.scenario_list = options.illuminator.test.names\n js_config.tags_any = options.illuminator.test.tags.any\n js_config.tags_all = options.illuminator.test.tags.all\n js_config.tags_none = options.illuminator.test.tags.none\n js_config.random_seed = options.illuminator.test.random_seed\n\n js_config.sim_device = options.simulator.device\n js_config.sim_version = options.simulator.version\n\n js_config.app_specific_config = options.javascript.app_specific_config\n\n # don't offset the numbers this time\n js_config.scenario_number_offset = 0\n\n # write main config\n js_config.write_configuration()\n end",
"def after_initialize\n super\n extension_loader.activate_extensions # also calls initialize_views\n TrustyCms::Application.config.add_controller_paths(extension_loader.paths(:controller))\n TrustyCms::Application.config.add_eager_load_paths(extension_loader.paths(:eager_load))\n end",
"def all_builtin_hook_configs; end",
"def inject_blacklight_controller_behavior \n # prepend_file(\"app/controllers/application_controller.rb\", \"require 'blacklight/controller'\\n\\n\")\n inject_into_class \"app/controllers/application_controller.rb\", \"ApplicationController\" do\n \" # Adds a few additional behaviors into the application controller \\n \" + \n \" include Blacklight::Controller\\n\" + \n \" # Please be sure to impelement current_user and user_session. Blacklight depends on \\n\" +\n \" # these methods in order to perform user specific actions. \\n\\n\" +\n \" layout 'blacklight'\\n\\n\"\n end\n end",
"def insert_chunk_admin_js\n js_admin_path = \"public/javascripts/refinery/admin.js\"\n unless @check_migration\n insert_into_file \"#{js_admin_path}\",\"\\n, chunk: null\", :after => \", callback: null\"\n insert_into_file \"#{js_admin_path}\", \",chunk\", :after => \", init: function(callback\" \n insert_into_file \"#{js_admin_path}\",\"\\n\\t\\tthis.chunk = chunk;\", :after => \"this.callback = callback;\"\n insert_into_file \"#{js_admin_path}\", \", this.chunk\", :after => \"this.callback(img_selected\"\n end\n end",
"def add_extend ext\n add_to @extends, ext\n\n ext\n end",
"def fill_customization_director\n end",
"def institutions_index_config\n blacklight_config.search_builder_class = CommonwealthInstitutionsSearchBuilder\n blacklight_config.view.delete(:gallery)\n blacklight_config.view.delete(:masonry)\n blacklight_config.view.delete(:slideshow)\n end",
"def config; Rails.application.config.action_controller; end",
"def config(context={}, aspect_model)\n \n app = context[:app]\n template_path = File.expand_path(File.join(File.dirname(__FILE__),'..',\n 'views','gallery_aspect_config.erb'))\n template = Tilt.new(template_path)\n the_render = template.render(app) \n \n end",
"def load_assets\n AssetManager.include_local_library [:application, :admin_layout_data_table]\n AssetManager.include_css [:application, :admin_layout, :colorbox]\n AssetManager.include_contrib_library [:colorbox]\n end",
"def init_config\n config('asset_dest', 'assets')\n config('keep_files', []).push(config('asset_dest'))\n end",
"def add_cadenero_initializer\n path = \"#{Rails.root}/config/initializers/cadenero.rb\"\n if File.exists?(path)\n puts \"Skipping config/initializers/cadenero.rb creation, as file already exists!\"\n else\n puts \"Adding cadenero initializer (config/initializers/cadenero.rb)...\"\n template \"initializer.rb\", path\n require path # Load the configuration per issue #415\n end\n end",
"def inject_routes\n gsub_file 'config/routes.rb', /root (:to =>|to:) \"catalog#index\"/, ''\n gsub_file 'config/routes.rb', /'welcome#index'/, \"'sufia/homepage#index'\" # Replace the root path injected by CurationConcerns\n\n routing_code = \"\\n Hydra::BatchEdit.add_routes(self)\\n\" \\\n \" # This must be the very last route in the file because it has a catch-all route for 404 errors.\\n\" \\\n \" # This behavior seems to show up only in production mode.\\n\" \\\n \" mount Sufia::Engine => '/'\\n\"\n\n sentinel = /devise_for :users/\n inject_into_file 'config/routes.rb', routing_code, after: sentinel, verbose: false\n end",
"def add_config(name, config)\n\t\tend",
"def css_classes_to_add_from_config\n config = @target_blank_config\n config.fetch(\"add_css_classes\")\n end",
"def default_configuration!\n # Overwriting Sinatra defaults\n set :app_file, caller_files.first || $0 # Assume app file is first caller\n set :environment, Padrino.env\n set :raise_errors, true if development?\n set :logging, false # !test?\n set :sessions, true\n set :public, Proc.new { Padrino.root('public', self.uri_root) }\n # Padrino specific\n set :uri_root, \"/\"\n set :reload, development?\n set :app_name, self.to_s.underscore.to_sym\n set :default_builder, 'StandardFormBuilder'\n set :flash, defined?(Rack::Flash)\n set :authentication, false\n # Padrino locale\n set :locale_path, Proc.new { Dir[File.join(self.root, \"/locale/**/*.{rb,yml}\")] }\n set :auto_locale, false\n # Plugin specific\n set :padrino_mailer, defined?(Padrino::Mailer)\n set :padrino_helpers, defined?(Padrino::Helpers)\n end",
"def configure(root_config)\n super(root_config)\n end",
"def activate\n Page.send :include, PageOptions::PageExtensions\n admin.page.index.add :top, \"caching_header\"\n admin.page.index.add :sitemap_head, 'caching_th', :before => 'status_column_header'\n admin.page.index.add :node, 'caching_td', :before => 'status_column'\n admin.page.edit.add :extended_metadata, 'caching_meta'\n end",
"def setup_initial_config!\n application.config do\n attribute :praxis do\n attribute :validate_responses, Attributor::Boolean, default: false\n attribute :validate_response_bodies, Attributor::Boolean, default: false\n\n attribute :show_exceptions, Attributor::Boolean, default: false\n attribute :x_cascade, Attributor::Boolean, default: true\n end\n end\n end",
"def add_options; end",
"def configure_assets\n set :public_folder, Aladdin::PATHS.public\n set :static_paths, Proc.new { Aladdin.config[:static_paths] }\n end",
"def extended(world)\n # :nocov:\n set_config_defaults\n\n world.extend(::Collapsium::Config)\n # :nocov:\n end",
"def configure_default_url_options!\n DefaultUrlOptions.configure!(request)\n ensure\n def ApplicationController.configure_default_url_options!() end\n ### TODO - should be able to removed the filter but rails doesn't like it...\n end",
"def configure_sprockets_helpers\n Sprockets::Helpers.configure do |config|\n case serve_assets\n when \"remote\"\n config.manifest = manifest\n config.debug = false\n config.asset_host = asset_host\n when \"local_static\" \n config.manifest = manifest\n config.debug = false\n config.public_path = public_folder \n end\n config.environment = sprockets\n config.prefix = '/' + prefix\n config.digest = digest \n end\n end"
] | [
"0.59380436",
"0.59212387",
"0.58798695",
"0.5854152",
"0.57930183",
"0.57082844",
"0.5589193",
"0.55627906",
"0.5518282",
"0.55145055",
"0.55059355",
"0.54718477",
"0.5461053",
"0.5457171",
"0.544894",
"0.54344183",
"0.5431317",
"0.54296803",
"0.54124874",
"0.5404428",
"0.5395848",
"0.5390678",
"0.5379623",
"0.5372359",
"0.5336398",
"0.53182113",
"0.53182113",
"0.53182113",
"0.53182113",
"0.53182113",
"0.53182113",
"0.53182113",
"0.53182113",
"0.53182113",
"0.53182113",
"0.53182113",
"0.53182113",
"0.53182113",
"0.53182113",
"0.53182113",
"0.53182113",
"0.53182113",
"0.53182113",
"0.53144616",
"0.52950275",
"0.52829844",
"0.52803123",
"0.52646035",
"0.52593964",
"0.5256169",
"0.5236542",
"0.52258873",
"0.521909",
"0.5217389",
"0.52107376",
"0.5209483",
"0.5207147",
"0.5192856",
"0.51818895",
"0.51818895",
"0.51818895",
"0.51818895",
"0.51818895",
"0.51721156",
"0.5153297",
"0.5146703",
"0.51350415",
"0.51335526",
"0.51275617",
"0.5117003",
"0.5111341",
"0.50822985",
"0.506595",
"0.50514174",
"0.5045247",
"0.50371677",
"0.5033798",
"0.5030085",
"0.50121146",
"0.5008139",
"0.5006734",
"0.49966285",
"0.49963418",
"0.49906275",
"0.49897674",
"0.4985472",
"0.49791077",
"0.49752846",
"0.49727",
"0.4963319",
"0.49629906",
"0.49604273",
"0.49596044",
"0.49587685",
"0.4953004",
"0.4952316",
"0.49504262",
"0.49492863",
"0.49474463",
"0.49473587",
"0.49454442"
] | 0.0 | -1 |
Method to build a list of instruments | def buildInstrumentList(baseDir)
entries = Dir[baseDir + "/*"]
@instrList = Array.new
entries.each do |entry|
if !entry.eql?(".") && !entry.eql?("..") &&
File::directory?(entry)
@instrList << entry.slice(/[a-zA-Z0-9]+$/).to_s
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instruments\n return @instruments if defined? @instruments\n\n reset_instruments!\n end",
"def create_instr_specs()\n instr_specs = []\n INSTR_DEFS.each do |instr_def|\n\tinstr_specs <<= extract_spec(instr_def)\n end\n instr_specs\nend",
"def generate_instruments(valor, currency, exchange_codes)\n @instruments = exchange_codes.map do |market|\n Instrument.new(\"#{valor},#{market},#{currency}\")\n end\n end",
"def instrument_sig\n inst_list = []\n instruments.each { |i| inst_list << i.name }\n inst_list.join(', ')\n end",
"def list_instruments(study_id)\n act = InstrumentListAction.new(self)\n act.get(study_id)\n end",
"def instruments_names\n instruments_s = \"\"\n\n instruments.each do |instrument|\n instruments_s += instrument.name + \", \"\n end\n\n return instruments_s.first(instruments_s.length-2)\n end",
"def instruments\n @instruments ||= Instrument.find self.tracks.count(:include => :instrument, :group => 'instrument_id').map(&:first)\n end",
"def make_item_list\n @data = equips_for_enchant\n end",
"def add_instruments(product, quantity, attributes)\n Array.new(quantity) do\n create_order_detail({ product: product, quantity: 1 }.merge(attributes))\n end\n end",
"def new\n @instrument = Instrument.new\n @category = [\"bowed strings\", \"wood wind\", \"brass\", \"percussions\", \"keyboard\" , \"guitar family\"]\n end",
"def build_list(name, amount, *traits_and_overrides)\n amount.times.map { build(name, *traits_and_overrides) }\n end",
"def build_intents_with_samples\n intent_samples = []\n intents.map { |_name, intent| intent_samples.concat([add_sample_utterances_to(intent)]) }\n Hash[intent_samples.map { |intent| [intent.name, intent] }]\n end",
"def instr_desc\n instr_data = $instruments[values]\n\n if instr_data == nil\n return \"- Unknown instrument\"\n end\n\n result = \"\"\n\n for possible in instr_data\n result += \"- Instrument ##{possible[:instrument]} \" \\\n + \"(#{possible[:name]}) \" \\\n + \"v#{possible[:voice]}\\n\"\n end\n\n result\n end",
"def get_exercises_list\n exercises_list = []\n inst_sections.each do |inst_section|\n exercises_ids = inst_section.inst_book_section_exercises.collect(&:inst_exercise_id).compact\n exercises_objs = InstExercise.where(id: exercises_ids)\n exercises_list.concat exercises_objs.collect(&:short_name)\n end\n return exercises_list\n end",
"def map_instruments(user)\n user.instruments = []\n # get the instruments\n user_instruments = @params[:instrument]\n if user_instruments\n for item in user_instruments\n user.instruments << Instrument.find(item[0])\n end\n end\n user.instruments\n end",
"def build_instrument(survey, mode)\n Instrument.new(:psu_code => NcsNavigatorCore.psu,\n :instrument_version => survey.instrument_version,\n :instrument_type => NcsCode.for_list_name_and_local_code('INSTRUMENT_TYPE_CL1', survey.instrument_type),\n :instrument_repeat_key => instrument_repeat_key(survey),\n :instrument_mode_code => mode,\n :person => self,\n :survey => survey)\n end",
"def make_item_list\n end",
"def build_interests\n arr = self.interest_tokens.split(',')\n arr.each do |str|\n interest = Interest.find_by_name(str)\n unless interest.blank?\n interests << interest\n else\n interests.build(:name => str)\n end\n end\n end",
"def collect_samples\n all_samples = []\n\n all_samples << { item: @beads } if @plan_params[:run_calibration_beads]\n\n CONTROL_NAMES.each do |name|\n controls(name).each do |item|\n all_samples << { item: item, control: name }\n end\n end\n\n other_samples.each do |item|\n all_samples << { item: item }\n end\n\n libraries_to_sort.each do |item|\n all_samples << { item: item, sort: true }\n end\n\n all_samples\n end",
"def build\n model_by_instrument = {}\n @value_chain.each{ |key, value|\n model_by_instrument[key] = MarkovModel.new(value)\n }\n \n return model_by_instrument\n end",
"def each_instrument\n self.instruments.each do |instrument|\n instrument.name\n end\n end",
"def make_item_list\n if SES::Bestiary::RequireEnemyKnown\n @data = ['???'] * SES::Bestiary.get_enemy_list.size\n $game_party.bestiary_known_data[:ene].each_key do |e|\n next unless SES::Bestiary.get_enemy_list.index(e)\n e = $data_enemies[e]\n id, name = e.bestiary_parameter(:id), e.bestiary_parameter(:name)\n @data[SES::Bestiary.get_enemy_list.index(e.id)] = \"#{id}: #{name}\"\n end\n else\n @data = []\n $data_enemies.compact.each do |e|\n if SES::Bestiary.get_enemy_list.include?(e.id)\n id, name = e.bestiary_parameter(:id), e.bestiary_parameter(:name)\n @data << \"#{id}: #{name}\"\n end\n end\n end\n end",
"def create_sample_array\n sample_array = []\n\n\n # add songs to sample-array in correct ratios\n @spins_per_week.each do |k,v|\n v.times { sample_array.push(PL::db.get_song(k)) }\n end\n\n sample_array\n end",
"def secondary_instrument_names\n #instruments.map{|i|i.display_name}.join(\"~\")\n \"\"\n end",
"def build_event_templates\n @event_templates = events.map do |e|\n EventTemplate.new(e).tap { |et| add_instruments_to_template(et) }\n end\n end",
"def generate_list(name, count); end",
"def add_voice(instruments, voice_data, instr_num, voice_num, name)\n if instruments[voice_data] == nil\n instruments[voice_data] = []\n end\n\n instruments[voice_data].push({\n :instrument => instr_num,\n :voice => voice_num,\n :name => name\n })\nend",
"def newDemandListForCycle()\n list = [] ;\n @factoryList.each{|factory|\n sublist = factory.newDemandListForCycle() ;\n list.concat(sublist) ;\n }\n return list ;\n end",
"def constructListFromFile(input)\n\t\t\tresult = Array.new()\n\t\t\tsize = input.size/6\n\t\t\tfor i in 0..size-1\n\t\t\t\talimento = Alimento.new(input[6*i], input[6*i+1].to_f, input[6*i+2].to_f, input[6*i+3].to_f, input[6*i+4].to_f, input[6*i+5].to_f)\n\t\t\t\tresult.append( alimento )\n\t\t\tend\n\t\t\treturn result\n\t\tend",
"def my_plant_list(my_plant, index)\n my_plant.show_each_plant_spec(index)\n end",
"def make_ChipInfo\n inst_list = Array.new\n sig_list = Array.new\n @Report_Data.each{|line|\n tmp = line[2].split(\",\")\n tmp.each{|info|\n sig_info = Array.new\n inst_name = info.split(\":\")[0].split(\".\")[0]\n if @Flag == \"all\"\n inst_list << inst_name\n else\n if (( inst_name != \"IN_PIN\")&&( inst_name != \"IO_PIN\")&&( inst_name != \"OUT_PIN\"))\n inst_list << inst_name\n end\n end\n \n signal_name = info.split(\":\")[0].split(\".\")[1]\n direction = info.split(\":\")[1]\n connection = line[1]\n sig_info << inst_name\n sig_info << signal_name\n sig_info << direction\n sig_info << connection\n sig_list << sig_info\n }\n }\n inst_list.uniq!\n inst_list.each{|inst|\n tmp = Array.new\n sig_list.each{|line|\n if inst == line[0]\n line.delete_at(0)\n tmp << line\n end\n }\n each_inst = Array.new\n each_inst << inst\n each_inst << tmp\n @chip_info << each_inst\n }\n end",
"def build_inventory\n add_to_inventory(\"cats\", 4, 50.0)\n add_to_inventory(\"dogs\", 10, 150.0)\n add_to_inventory(\"unicorn\", 1, 1000.0)\nend",
"def init_items\n items = []\n get_items.each do |item|\n item = item[0]\n index = SI_INDEX_REGEXP.match(item)[1].strip.to_i\n times = item.scan(SI_TIME_REGEXP)\n data = SI_DATA_REGEXP.match(item)[1].gsub(/\\n/, ' ').strip\n items.push SubtitleItem.new(index, times[0].to_s.strip,\n times[1].to_s.strip, data)\n end\n\n items\n end",
"def sort_and_build_components(statutory_instruments: nil, small: false)\n grouping_block = proc { |statutory_instrument| LayingDateHelper.get_date(statutory_instrument) }\n\n sorted_statutory_instruments = GroupSortHelper.group_and_sort(statutory_instruments, group_block: grouping_block, key_sort_descending: true, sort_method_symbols: %i[laidThingName])\n\n build_components(statutory_instruments: sorted_statutory_instruments, small: small)\n end",
"def initialize\n @models_by_instrument = {}\n end",
"def link_elective_to_instruments(elective, list_of_instrument_ids)\n list_of_instrument_ids.each{|iid| elective.instruments << Instrument.find(iid)}\n elective.save!\nend",
"def list\n specs = Array.new\n @public_holiday_specifications.each { |phs| specs << phs.to_s }\n specs\n end",
"def build_list\n students = input_students\n print_header\n print(students)\n print_footer(students)\nend",
"def instrument_on(instrument)\n DB[:lineups].where(instrument: instrument).all\n end",
"def reset_instruments!\n @instruments = Instrumentation.select_instruments(name)\n ensure\n prepend(Match) unless @instruments.empty?\n end",
"def collect_specimens(operations:)\n operations.map { |op| op.input_array(SPECIMEN).map(&:item) }.flatten\n end",
"def index\n @instrumentos = Instrumento.all\n end",
"def build_instances\n filter_instances.map.with_index do |(suite, platform), index|\n new_instance(suite, platform, index)\n end\n end",
"def add(sequence)\n # Obtains a quarter duration for this sequence\n quarter_note_length = sequence.note_to_delta('quarter')\n \n # Create the duration table based on the sequence's \"quarter\" value\n create_duration_table(quarter_note_length)\n \n # For each instrument on the sequence...\n sequence.each { |track|\n # Program change of the current track\n instrument = nil\n\n # Create a list of midi elements for an instrument\n elements = []\n\n # Iterates the track event list...\n track.each { |event|\n \n # Consider only \"NoteOn\" events since they represent the start of a note event (avoid duplication with \"NoteOff\").\n if event.kind_of?(MIDI::NoteOnEvent) then\n # From its correspondent \"NoteOff\" element, extract the duration of the note event.\n duration = event.off.time_from_start - event.time_from_start + 1\n \n # Maps the duration in ticks to a correspondent string on the duration table.\n duration_representation = @duration_table[duration]\n \n # In the case that the note do not correspond to anything in the table,\n # we just truncate it to the closest value.\n if duration_representation.nil? or duration_representation == \"unknow\" then\n new_duration = 0\n smallest_difference = Float::INFINITY\n @duration_table.each { |key, value|\n difference = (duration - key).abs\n if difference < smallest_difference then\n smallest_difference = difference\n new_duration = key\n end\n }\n duration_representation = @duration_table[new_duration]\n end\n\n # Create new markov chain state and put into the \"elements\" list\n elements << MidiElement.new(event.note_to_s, duration_representation)\n elsif event.kind_of?(MIDI::ProgramChange) then\n if (event.channel == 10) then\n instrument = MIDI::GM_DRUM_NOTE_NAMES[event.program]\n else\n instrument = MIDI::GM_PATCH_NAMES[event.program]\n end\n end\n }\n \n if instrument.nil? then\n instrument = MIDI::GM_PATCH_NAMES[1]\n end\n \n @value_chain[instrument] ||= elements unless elements.empty?\n }\n end",
"def index\n set_instruments_grid\n end",
"def shopping_list\n ingredient_list = []\n @summary.each do |key, value|\n if key.include?(\"strIngredient\") && value != \"\"\n ingredient_list << value\n end\n end\n\n measurement_list = []\n @summary.each do |key, value|\n if key.include?(\"strMeasure\") && value != \" \"\n measurement_list << value\n end\n end\n\n measurement_list.zip(ingredient_list).each do |measurement, ingredient|\n if ingredient != nil && ingredient.empty? == false\n if measurement != \" \"\n @shopping_list << \"#{ingredient}: #{measurement}\"\n else\n @shopping_list << \"#{ingredient}\"\n end\n end\n end\n @shopping_list\n end",
"def list(songs)\n song_list = []\n counter = 1\n songs.each do |song|\n song_list.push(\"#{counter}. #{song}\")\n counter += 1\n end\n puts song_list\nend",
"def instruments(expired: false, &blk)\n params = { expired: expired }\n if block_given?\n websocket.subscribe :getinstruments, params: params, &blk\n else\n http.get :getinstruments, params: params\n end\n end",
"def hardcoded_songs\n [\n Song.new(\"Maroon 5 - This love\", [13, 68, 13, 68, 13, 45, 68, 13]),\n Song.new(\"Ben l'oncle soul - Seven nation army\", [68, 13, 0, 68, 13, 0, 68]),\n Song.new(\"Ornatos Violeta - Para de olhar para mim\", [77, 125, 93, 77])\n ]\n end",
"def _payplug_build_items\n cart_obj = self\n method_name = Payplug.item_klass.to_s.underscore.pluralize # getting line_items from LineItem\n original_items = cart_obj.send(method_name) # @cart.line_items\n extended_items = original_items.map{|i| i.extend(Payplug::Item) } # extend each item with Payplug::Item\n extended_items\n end",
"def make_item_list\n @data = $game_party.all_items.select {|item| include?(item)}\n @data.push(nil) if include?(nil)\n end",
"def to_items\n\t\titems = []\n\t\t@discs.each do |disc|\n\t\t\tdisc.tracks.each do |track|\n\t\t\t\titems << {:codec => @codec, :album_artist => @album_artist,\n\t\t\t\t\t:album_title => @album_title, :year => @year,\n\t\t\t\t\t:publisher => @publisher, :genre => @genre,\n\t\t\t\t\t:style => @style, :comment => @comment, :cover => @cover,\n\t\t\t\t\t:disc_number => disc.disc_number,\n\t\t\t\t\t:disc_title => disc.disc_title,\n\t\t\t\t\t:track_number => track.track_number,\n\t\t\t\t\t:track_artist => track.track_artist,\n\t\t\t\t\t:track_title => track.track_title,\n\t\t\t\t\t:composer => track.composer}\n\t\t\tend\n\t\tend\n\t\titems\n\tend",
"def build_shoe(num_of_decks)\n shoe = []\n num_of_decks.times do |_|\n DECK_OF_CARDS.map do |card|\n shoe << card\n end\n end\n shoe\nend",
"def announcements_list\n $tracer.trace(__method__)\n # unit_test_no_generate: announcements_list, section.className(\"/(^|\\s+)ats-announcements($|\\s+)/\"; ImpulseAnnouncementsList\n return ImpulseAnnouncementsList.new(ToolTag.new(section.className(\"/(^|\\s+)ats-announcements($|\\s+)/\"), __method__, self), self)\n end",
"def annotate_sources\n item_names.each do |source_name|\n with_valid_source source_name do |source_card|\n tag_with_report_type source_card\n tag_with_company source_card\n tag_with_year source_card\n end\n end\nend",
"def build_shoe(num_of_decks)\n shoe = []\n num_of_decks.times do |_|\n DECK_OF_CARDS.select do |card|\n shoe << card\n end\n end\n shoe\nend",
"def handle_instrument_label(vals)\n @instruments << vals.last\n @instrument = vals.last if matches_mdes_version(vals)\n end",
"def build_primer_lists\n operations.each { |op| op.temporary[:length] = (op.output(\"Primer\").sample.properties[\"Overhang Sequence\"] + op.output(\"Primer\").sample.properties[\"Anneal Sequence\"]).length }\n \n primers_over_60 = operations.select do |op| \n length = op.temporary[:length]\n length > 60 && length <= 90\n end.map do |op| \n primer = op.output(\"Primer\").sample\n \"#{primer} (##{operations.index(op) + 1})\"\n end.join(\", \")\n \n primers_over_90 = operations.select do |op| \n length = op.temporary[:length]\n length > 90\n end.map do |op| \n primer = op.output(\"Primer\").sample\n \"#{primer} (##{operations.index(op) + 1})\"\n end.join(\", \")\n \n [primers_over_60, primers_over_90]\n end",
"def new_list(item_String, quantity = 1)\n $list = []\n array_strings = item_String.split\n array_strings.each do |element|\n \tlist_item = {\n \t\tquantity: quantity,\n \t\titem: element\n \t}\n \t $list.push(list_item) \n \tend\nend",
"def build_commands(recordings)\n recordings.each { |recording| \n @commands.push \",#{recording.su_id}\"\n }\n #raise 'not yet implemented'\n end",
"def build_list_of_players\n [\n \"cliff\",\n \"anne\",\n \"harry\",\n \"sam\",\n \"devin\",\n \"ally\",\n \"bob\",\n \"jane\",\n \"jimmy\",\n \"dave\"\n ]\nend",
"def initialize\n ARTISTS << self\n self.song = []\n self.genre = []\n end",
"def recordings\n recording_ids = self.instrument_tags.where(instrument_tagable_type: 'Recording').pluck(:instrument_tagable_id)\n Recording.where(id: recording_ids)\n end",
"def index\n res = Instrument\n if params[:search].present?\n res = res.where(title: /.*#{params[:search]}.*/i)\n end\n @instruments = res.order(updated_at: :desc).page(params[:page]).per(NUM_PER_PAGE)\n end",
"def set_instrument\n self.instrument_id = self.code_list.instrument_id\n end",
"def set_instrument\n self.instrument_id = self.code_list.instrument_id\n end",
"def build_index\r\n raise \"cannot build index without an identifier provider\" unless @identifier_provider\r\n @index = elements.collect { |e|\r\n ident = @identifier_provider.call(e, nil)\r\n ident && !ident.empty? ? [ident, e] : nil \r\n }.compact\r\n end",
"def generate_recipes_list\n recipes = YARD::Registry.all(:recipe).uniq.sort_by {|recipe| recipe.Name.to_s}\n generate_full_list(recipes, 'Recipe', 'recipes')\nend",
"def build_list(hero)\n\t\tbuilds = hero.builds\n\t\t#This Line is just to limit the initial amount of builds shown. Possibly implement a way to search further.\n\t\tif builds.size >= 5\n\t\t\tbuilds = builds.slice(0,5)\n\t\tend\n\t\tlist = builds.map{|build| \"#{hero.builds.index(build) + 1}. #{build.name} #{build.votes}\"}.join(\"\\n\")\n\tend",
"def build_values\n @elements = Core::CommandWatcher.report(@list)\n @elements.each_with_index do |(level, _, age), col|\n build_column_for(col + 1, age, level)\n end\n end",
"def build(data_list)\n @models = []\n\n data_list.each do |data|\n @models << @klass.new(data)\n end\n end",
"def simulators\n @instruments_simulators ||= lambda do\n fetch_devices[:out].chomp.split(\"\\n\").map do |line|\n stripped = line.strip\n if line_is_simulator?(stripped) &&\n !line_is_simulator_paired_with_watch?(stripped) &&\n !line_is_apple_tv?(stripped)\n\n version = stripped[VERSION_REGEX, 0]\n\n if line_is_xcode5_simulator?(stripped)\n name = line\n udid = line\n else\n name = stripped.split('(').first.strip\n udid = line[CORE_SIMULATOR_UDID_REGEX, 0]\n end\n\n RunLoop::Device.new(name, version, udid)\n else\n nil\n end\n end.compact\n end.call\n end",
"def render\n bari, tenor, alto, soprano = '', '', '', ''\n instrument_strings = [bari, tenor, alto, soprano]\n @notes.each_with_index {|note, index| \n duration_string = '1'\n duration_string = '2' if index == deltas_max_index\n instrument_string = instrument_strings[index]\n note_string = midi_to_lily(note) + duration_string\n instrument_string << note_string\n instrument_string << ' r2' if index == deltas_max_index\n }\n instrument_strings\n end",
"def create\n artist = Artist.new(name:\"MyArtist\", )\n artist.build_instrument(name: \"guitar\")\n artist.save\n end",
"def sources\n @iTunes.sources.each do |source|\n @sources << source\n end\n end",
"def make_item_list\n @data = $game_temp.forge_shop.products\n end",
"def add *list\n @show = (@show + TinyPng::Path.get_all(list)).uniq\n end",
"def get_guitarists(band)\n #get their names out only if they play guitar\n #\n band.each_with_object([]) do |member, names|\n if member[:instruments].include?('guitar')\n names << member[:name]\n end\n names\n #names always gets returns but if there is no guitar then it will be zippo\n end\n #object is an array as defined. loop over it once and don'thave to compact\nend",
"def test_get_InstanceList\n printf \"\\n@T:#{__method__}\\n\"\n # Normal\n golden = [[\"TBCLL\", \"pulldown0\"],[\"TBCLL\", \"pulldown1\"],[\"TBCLL\", \"pulldown2\"],[\"TBCLL\", \"pulldown3\"],[\"TBCLL\", \"pulldown4\"],[\"TBCLL\", \"pulldown5\"],[\"TBCLL\", \"pulldown6\"],[\"TBCLL\", \"pulldown7\"],[\"TBCLL\", \"pulldown8\"],[\"TBCLL\", \"pulldown9\"],[\"TBCLL\", \"pulldown10\"],[\"TBCLL\", \"pulldown11\"],[\"TBCLL\", \"pulldown12\"],[\"TBCLL\", \"pulldown20\"],[\"TBCLL\", \"pulldown13\"],[\"TBCLL\", \"pulldown21\"],[\"TBCLL\", \"pulldown14\"],[\"TBCLL\", \"pulldown22\"],[\"TBCLL\", \"pulldown30\"],[\"TBCLL\", \"pulldown15\"],[\"TBCLL\", \"pulldown23\"],[\"TBCLL\", \"pulldown31\"],[\"TBCLL\", \"pulldown16\"],[\"TBCLL\", \"pulldown24\"],[\"TBCLL\", \"pulldown32\"],[\"TBCLL\", \"pulldown40\"],[\"TBCLL\", \"pulldown17\"],[\"TBCLL\", \"pulldown25\"],[\"TBCLL\", \"pulldown33\"],[\"TBCLL\", \"pulldown41\"],[\"TBCLL\", \"pulldown18\"],[\"TBCLL\", \"pulldown26\"],[\"TBCLL\", \"pulldown34\"],[\"TBCLL\", \"pulldown42\"],[\"TBCLL\", \"pulldown50\"],[\"TBCLL\", \"pulldown19\"],[\"TBCLL\", \"pulldown27\"],[\"TBCLL\", \"pulldown35\"],[\"TBCLL\", \"pulldown43\"],[\"TBCLL\", \"pulldown51\"],[\"TBCLL\", \"pulldown28\"],[\"TBCLL\", \"pulldown36\"],[\"TBCLL\", \"pulldown44\"],[\"TBCLL\", \"pulldown52\"],[\"TBCLL\", \"pulldown60\"],[\"TBCLL\", \"pulldown29\"],[\"TBCLL\", \"pulldown37\"],[\"TBCLL\", \"pulldown45\"],[\"TBCLL\", \"pulldown53\"],[\"TBCLL\", \"pulldown61\"],[\"TBCLL\", \"pulldown38\"],[\"TBCLL\", \"pulldown46\"],[\"TBCLL\", \"pulldown54\"],[\"TBCLL\", \"pulldown62\"],[\"TBCLL\", \"pulldown70\"],[\"TBCLL\", \"pulldown39\"],[\"TBCLL\", \"pulldown47\"],[\"TBCLL\", \"pulldown55\"],[\"TBCLL\", \"pulldown63\"],[\"TBCLL\", \"pulldown71\"],[\"TBCLL\", \"pulldown48\"],[\"TBCLL\", \"pulldown56\"],[\"TBCLL\", \"pulldown64\"],[\"TBCLL\", \"pulldown72\"],[\"TBCLL\", \"pulldown80\"],[\"TBCLL\", \"pulldown49\"],[\"TBCLL\", \"pulldown57\"],[\"TBCLL\", \"pulldown65\"],[\"TBCLL\", \"pulldown73\"],[\"TBCLL\", \"pulldown81\"],[\"TBCLL\", \"pulldown58\"],[\"TBCLL\", \"pulldown66\"],[\"TBCLL\", \"pulldown74\"],[\"TBCLL\", \"pulldown82\"],[\"TBCLL\", \"pulldown90\"],[\"TBCLL\", \"pulldown59\"],[\"TBCLL\", \"pulldown67\"],[\"TBCLL\", \"pulldown75\"],[\"TBCLL\", \"pulldown83\"],[\"TBCLL\", \"pulldown91\"],[\"TBCLL\", \"pulldown68\"],[\"TBCLL\", \"pulldown76\"],[\"TBCLL\", \"pulldown84\"],[\"TBCLL\", \"pulldown92\"],[\"TBCLL\", \"pulldown69\"],[\"TBCLL\", \"pulldown77\"],[\"TBCLL\", \"pulldown85\"],[\"TBCLL\", \"pulldown93\"],[\"TBCLL\", \"pulldown78\"],[\"TBCLL\", \"pulldown86\"],[\"TBCLL\", \"pulldown94\"],[\"TBCLL\", \"pulldown79\"],[\"TBCLL\", \"pulldown87\"],[\"TBCLL\", \"pulldown95\"],[\"TBCLL\", \"pulldown88\"],[\"TBCLL\", \"pulldown96\"],[\"TBCLL\", \"pulldown89\"],[\"TBCLL\", \"pulldown97\"],[\"TBCLL\", \"pulldown98\"],[\"TBCLL\", \"pulldown99\"],[\"TBCLL\", \"pulldown100\"],[\"TBCLL\", \"pulldown101\"],[\"TBCLL\", \"pulldown102\"],[\"TBCLL\", \"pulldown110\"],[\"TBCLL\", \"pulldown103\"],[\"TBCLL\", \"pulldown111\"],[\"TBCLL\", \"pulldown104\"],[\"TBCLL\", \"pulldown112\"],[\"TBCLL\", \"pulldown120\"],[\"TBCLL\", \"pulldown105\"],[\"TBCLL\", \"pulldown113\"],[\"TBCLL\", \"pulldown106\"],[\"TBCLL\", \"pulldown114\"],[\"TBCLL\", \"pulldown107\"],[\"TBCLL\", \"pulldown115\"],[\"TBCLL\", \"pulldown108\"],[\"TBCLL\", \"pulldown116\"],[\"TBCLL\", \"pulldown109\"],[\"TBCLL\", \"pulldown117\"],[\"TBCLL\", \"pulldown118\"],[\"TBCLL\", \"pulldown119\"],[\"TBCLH\", \"pullup0\"],[\"TBCLH\", \"pullup1\"],[\"TBCLH\", \"pullup2\"],[\"TBCLH\", \"pullup3\"],[\"TBCLH\", \"pullup4\"],[\"TBCLH\", \"pullup5\"],[\"TBCLH\", \"pullup6\"],[\"TBCLH\", \"pullup7\"],[\"TBCLH\", \"pullup8\"],[\"TBCLH\", \"pullup9\"],[\"TBCLH\", \"pullup10\"],[\"TBCLH\", \"pullup11\"],[\"TBCLH\", \"pullup12\"],[\"TBCLH\", \"pullup20\"],[\"TBCLH\", \"pullup13\"],[\"TBCLH\", \"pullup21\"],[\"TBCLH\", \"pullup14\"],[\"TBCLH\", \"pullup22\"],[\"TBCLH\", \"pullup30\"],[\"TBCLH\", \"pullup15\"],[\"TBCLH\", \"pullup23\"],[\"TBCLH\", \"pullup31\"],[\"TBCLH\", \"pullup16\"],[\"TBCLH\", \"pullup24\"],[\"TBCLH\", \"pullup32\"],[\"TBCLH\", \"pullup40\"],[\"TBCLH\", \"pullup17\"],[\"TBCLH\", \"pullup25\"],[\"TBCLH\", \"pullup33\"],[\"TBCLH\", \"pullup41\"],[\"TBCLH\", \"pullup18\"],[\"TBCLH\", \"pullup26\"],[\"TBCLH\", \"pullup34\"],[\"TBCLH\", \"pullup42\"],[\"TBCLH\", \"pullup50\"],[\"TBCLH\", \"pullup19\"],[\"TBCLH\", \"pullup27\"],[\"TBCLH\", \"pullup35\"],[\"TBCLH\", \"pullup43\"],[\"TBCLH\", \"pullup51\"],[\"TBCLH\", \"pullup28\"],[\"TBCLH\", \"pullup36\"],[\"TBCLH\", \"pullup44\"],[\"TBCLH\", \"pullup52\"],[\"TBCLH\", \"pullup60\"],[\"TBCLH\", \"pullup29\"],[\"TBCLH\", \"pullup37\"],[\"TBCLH\", \"pullup45\"],[\"TBCLH\", \"pullup53\"],[\"TBCLH\", \"pullup61\"],[\"TBCLH\", \"pullup38\"],[\"TBCLH\", \"pullup46\"],[\"TBCLH\", \"pullup54\"],[\"TBCLH\", \"pullup62\"],[\"TBCLH\", \"pullup70\"],[\"TBCLH\", \"pullup39\"],[\"TBCLH\", \"pullup47\"],[\"TBCLH\", \"pullup55\"],[\"TBCLH\", \"pullup63\"],[\"TBCLH\", \"pullup71\"],[\"TBCLH\", \"pullup48\"],[\"TBCLH\", \"pullup56\"],[\"TBCLH\", \"pullup64\"],[\"TBCLH\", \"pullup72\"],[\"TBCLH\", \"pullup49\"],[\"TBCLH\", \"pullup57\"],[\"TBCLH\", \"pullup65\"],[\"TBCLH\", \"pullup73\"],[\"TBCLH\", \"pullup58\"],[\"TBCLH\", \"pullup66\"],[\"TBCLH\", \"pullup74\"],[\"TBCLH\", \"pullup59\"],[\"TBCLH\", \"pullup67\"],[\"TBCLH\", \"pullup75\"],[\"TBCLH\", \"pullup68\"],[\"TBCLH\", \"pullup76\"],[\"TBCLH\", \"pullup69\"],[\"TBCLH\", \"pullup77\"],[\"TBCLH\", \"pullup78\"],[\"TBCLH\", \"pullup79\"],[\"QLK0RCPUEVA0V3\", \"cpu\"],[\"QLK0RINT48V2\", \"int48\"],[\"QLK0RDMAC0V1\", \"dmac\"],[\"QLK0RMULDIV1V1\", \"muldiv\"],[\"QLK0ROCD1V1\", \"ocd\"],[\"QLK0RIAW0V1\", \"iaw\"],[\"QLK0RCSC1V2\", \"csc\"],[\"QLK0RPCLBUZ1V1\", \"pclbuz\"],[\"QLK0RCIBCM3SF1V1\", \"cibc\"],[\"QLK0RCIBDM3SF1V1\", \"cibd\"],[\"QLK0RFCBM3SF1V1\", \"fcb\"],[\"QLK0RWWDT1V2\", \"wwdt\"],[\"QLK0RRTC0V3\", \"rtc\"],[\"QLK0RCRC0V1\", \"crc\"],[\"QLK0RMAW0V1\", \"maw0\"],[\"QLK0RMODECTL2V1\", \"modectl\"],[\"QLK0RSCON1V1\", \"scon\"],[\"KX4_FLASHCLK_DLY\", \"flashclk_dly\"],[\"QNSC3NCP1V2\", \"flash_cp\"],[\"QNSC3NREG1V2\", \"flash_reg\"],[\"QNSC3NCPDC0V1\", \"flash_capa0\"],[\"QNSC3NCPDC0V1\", \"flash_capa1\"],[\"QNSC3NCPDC0V1\", \"flash_capa2\"],[\"QNSC3NCPDC0V1\", \"flash_capa3\"],[\"QNSC3NCPDC0V1\", \"flash_capa4\"],[\"QNSC3NCPDC0V1\", \"flash_capa5\"],[\"QNSC3NCPDC0V1\", \"flash_capa6\"],[\"QNSC3NCPDC0V1\", \"flash_capa7\"],[\"QNSC3NCPDC0V1\", \"flash_capa8\"],[\"QNSC3NCPDC0V1\", \"flash_capa9\"],[\"QNSC3NCPDC0V1\", \"flash_capa10\"],[\"QNSC3NCPDC0V1\", \"flash_capa11\"],[\"QNSC3NCPDC0V1\", \"flash_capa12\"],[\"QNSC3NCPDC0V1\", \"flash_capa13\"],[\"QNSC3NCPDC0V1\", \"flash_capa14\"],[\"KX4_BUSBRIDGE\", \"bbr\"],[\"KX4_PORGA\", \"porga\"],[\"KX4_INTOR\", \"intor\"],[\"KX4_CKDIST\", \"ckdist\"],[\"KX4_MONSIG\", \"monsig\"],[\"QLK0RINTM4V1\", \"intm4\"],[\"QLK0RINTM8V1\", \"intm8\"],[\"KX4_IICASCLDLY\", \"sdadly0\"],[\"KX4_IICASDADLY\", \"sdadly1\"],[\"KX4_SDADLY\", \"sdadly2\"],[\"KX4_SDADLY\", \"sdadly3\"],[\"KX4_SDADLY\", \"sdadly011\"],[\"KX4_SDADLY\", \"sdadly013\"],[\"KX4_SDADLY\", \"sdadly110\"],[\"KX4_SDADLY\", \"sdadly111\"],[\"QLK0RIICAV2\", \"iica\"],[\"QLK0RSAU04R2V1\", \"sau0\"],[\"QLK0RSAU02R2V1\", \"sau1\"],[\"QLK0RTAU08R2V1\", \"tau0\"],[\"KX4_PORT0V1\", \"port0\"],[\"KX4_PORT1V1\", \"port1\"],[\"KX4_PORT2V1\", \"port2\"],[\"KX4_PORT3V1\", \"port3\"],[\"KX4_PORT4V1\", \"port4\"],[\"KX4_PORT5V1\", \"port5\"],[\"KX4_PORT6V1\", \"port6\"],[\"KX4_PORT7V1\", \"port7\"],[\"KX4_PORT12V1\", \"port12\"],[\"KX4_PORT13V1\", \"port13\"],[\"KX4_PORT14V1\", \"port14\"],[\"KX4_PIORV2\", \"pior\"],[\"QLK0RADAA32V1\", \"adctl\"],[\"KX4_CAPCKGATE\", \"capckgate\"],[\"KX4_CAPMUX4\", \"capmux\"],[\"KX4_CAPLIO\", \"capl\"],[\"KX4_CAPRIO\", \"capr\"],[\"QICAP035H5H\", \"capadl\"],[\"QICAP025H5H\", \"capadr\"],[\"TBFILTER1X2\", \"dmydly50n\"],[\"QAHNFI4BN300NV1\", \"dmydly300n\"],[\"QAHRES0CV1\", \"vppts1_res\"]]\n assert_equal(golden,XMLParse::get_InstanceList(@root,\"D78F1070_EVA\"))\n end",
"def create_list\n @list = Array.new(6) { |i| DexButton.new(@viewport, i) }\n end",
"def build_reps\n @items.each do |item|\n # Find matching rules\n matching_rules = self.compiler.item_compilation_rules.select { |r| r.applicable_to?(item) }\n raise Nanoc3::Errors::NoMatchingCompilationRuleFound.new(item) if matching_rules.empty?\n\n # Create reps\n rep_names = matching_rules.map { |r| r.rep_name }.uniq\n rep_names.each do |rep_name|\n item.reps << ItemRep.new(item, rep_name)\n end\n end\n end",
"def build_reps\n @items.each do |item|\n # Find matching rules\n matching_rules = self.compiler.item_compilation_rules.select { |r| r.applicable_to?(item) }\n raise Nanoc3::Errors::NoMatchingCompilationRuleFound.new(item) if matching_rules.empty?\n\n # Create reps\n rep_names = matching_rules.map { |r| r.rep_name }.uniq\n rep_names.each do |rep_name|\n item.reps << ItemRep.new(item, rep_name)\n end\n end\n end",
"def equipment_list\n [\n \"Backhoe\",\n \"Bobcat\",\n \"Compactor\",\n \"Compactor 815\",\n \"Compactor 815F\",\n \"Compactor 825G\",\n \"Compactor 825H\",\n \"Crane\",\n \"Dozer-D3\",\n \"Dozer-D6\",\n \"Dozer D6M Swamp\",\n \"Dozer D6R Swamp\",\n \"Dozer D6T XL\",\n \"Dozer-D6H\",\n \"Dozer-D65\",\n \"Dozer - D6C\",\n \"Dozer - D6R\",\n \"Dozer - D6R Xl\",\n \"Dozer - D7\",\n \"Dozer - D7H\",\n \"Dozer - D8\",\n \"Dozer - D9T\",\n \"Dozer R -D9\",\n \"Dump Truck 25T\",\n \"Dump Truck 30T\",\n \"Dump Truck 40T\",\n \"Dump Truck 50T\",\n \"Drott 9T\",\n \"Drott 8T\",\n \"Drott\",\n \"Excavator\",\n \"EXC 8T\",\n \"EXC 12-22T \",\n \"EXC 12T\",\n \"EXC 13T\",\n \"EXC13.5T\",\n \"EXC 14T\",\n \"EXC 15T\",\n \"EXC 17T WHEELED\",\n \"EXC 18T\",\n \"EXC 20-29T\",\n \"EXC 20T WHEELED\",\n \"EXC 20T\",\n \"EXC 20T \",\n \"EXC 20T 8T 12\",\n \"EXC 22T\",\n \"EXC 24T\",\n \"EXC 25T\",\n \"EXC 30T\",\n \"EXC 35T\",\n \"EXC 40T\",\n \"EXC 45T\",\n \"EXC 60T\",\n \"EXC 4.5T \",\n \"EXC 4T\",\n \"EXC 3.5T\",\n \"EXC 3T COMBO\",\n \"EXC 3T\",\n \"EXC 5T\",\n \"EXC 5T COMBO\",\n \"EXC 5T \",\n \"EXC 5.5T\",\n \"EXC 5-10T\",\n \"EXC 5-30T\",\n \"EXC 5T & 6T\",\n \"EXC 6T\",\n \"EXC 6T \",\n \"EXC 7.5T\",\n \"EXC 7.5T \",\n \"EXC 8T \",\n \"Float\",\n \"Grader 12G 140H\",\n \"Grader\",\n \"IT Loader\",\n \"Loader\",\n \"Moxy Dump\",\n \"Moxy Dump 20T\",\n \"Moxy Dump 25T\",\n \"Moxy Dump 30T\",\n \"Posi Track\",\n \"Pug Mill\",\n \"Roller Pad SF\",\n \"Roller Smooth\",\n \"Roller 12T\",\n \"Roller\",\n \"Roller 14T\",\n \"Roller Smooth 12T\",\n \"Roller Pad SF 12T\",\n \"Roller Pad\",\n \"Roller Pad SF 16T\",\n \"Scraper 633\",\n \"Scraper 623E\",\n \"Scraper\",\n \"Screening Plant\",\n \"Semi\",\n \"Semi/T & T\",\n \"Semi Tipper\",\n \"Sweeper\",\n \"Tilt Tray\",\n \"Truck\",\n \"Truck & 3 Axle Trailer\",\n \"Truck & 4 Axle Trailer\",\n \"Truck & Dog\",\n \"Watercart\"\n ]\n end",
"def build_lists\n @callday = [' ','SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY']\n @callback = [' ', 'SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY']\n @contact_method = ['CALL', 'EMAIL', 'TEXT']\n @called = ['NO', 'NO ANSWER', 'YES']\n @ordered = [' ', 'NO', 'YES']\n @windows = ['10am - noon', 'noon - 2pm', '2pm - 4pm', '4pm - 6pm']\n @alt_contact = [' ', 'ZINGLE', 'TEXT', 'VOICE MAIL', 'OTHER']\n @rep = []\n reps = []\n\n if @user == 'ADMIN'\n users = User.all\n else\n users = User.where(manager_id: current_user.manager_id.upcase)\n end\n users.each do |u|\n if u.email.upcase != 'ADMIN' && u.email.upcase != 'TECH'\n reps.push(u.email.upcase)\n end\n end\n reps.sort!\n reps.each do |r|\n @rep.push(r)\n end\n reps.unshift(\"ALL\")\n if session[:called_rep].blank?\n if @user == 'ADMIN' || @user == 'TECH'\n session[:called_rep] = reps[1]\n else\n session[:called_rep] = @user\n end\n end\n @reps = []\n i = 1\n @selected_rep = 0\n reps.each do |r|\n select_item = []\n select_item.push(r)\n select_item.push(i)\n @reps.push(select_item)\n if r == session[:called_rep]\n @selected_rep = i\n end\n i += 1\n end\n session[:calllist_reps] = @reps\n\n @isr_list = []\n tempisr = []\n tempisr.push(' ')\n isrlist = IsrList.all\n isrlist.each do |c|\n if c.name && !tempisr.include?(c.name)\n tempisr.push(c.name)\n end\n end\n @isr_list = tempisr.sort\n @isr_user = false\n if @isr_list.include?(@user)\n @isr_user = true\n end\n end",
"def populate(full_list, attribute_array)\n i = 0\n full_list.each do |student|\n student << attribute_array[i]\n end\nend",
"def create_list(list_name,list_of_items)\n # create empty array\n list_name = []\n # for each item in string, use add item method to add item to grocery list (set default quantity to 1)\n shopping_items = list_of_items.split(' ')\n shopping_items.each do |thing_to_add|\n add_item_to_list(list_name,thing_to_add,1)\n end\n # print the list to the console\n print_list(list_name)\nend",
"def songs \n Song.all.select{|song| add_song(song)}.to_a\n # binding.pry\n end",
"def initialize(n='', i='', v='')\n @name = n\n @instrument = i\n @vice = v\n end",
"def buy_fruit(list)\n list.each_with_object([]) do |(fruit, quantity), explanded list|\n explanded list.concat(Array.new(quantity, fruit))\n end\nend",
"def instrument_collection(instrument)\n Course\n .where('LOWER(title) LIKE ? AND rating > ?', \"%#{instrument.downcase}%\", '2')\n .reorder(Arel.sql('RANDOM()'))\n .limit(4)\n end",
"def make_all_included\n @snps.each_with_index do |snp, index|\n @included_snps_hash[snp.name] = snp\n @included_snps << index\n @index_of_included_snps[snp.name] = @included_snps.length-1\n end\n end",
"def stations\n [\n master_station,\n SLCStationReport.new(@fields[5..9], false),\n SLCStationReport.new(@fields[10..14], false),\n SLCStationReport.new(@fields[15..19], false),\n SLCStationReport.new(@fields[20..24], false),\n SLCStationReport.new(@fields[25..29], false)\n ]\n end",
"def generate_codebook_time_series_list(items)\n html = '<ul class=\"list-unstyled\">'\n\n items.each do |item|\n\n if item.class == TimeSeriesGroup\n # add group\n html << generate_codebook_time_series_group_item(item)\n\n elsif item.class == TimeSeriesQuestion\n # add question\n html << generate_codebook_time_series_question_item(item)\n end\n\n end\n\n html << '</ul>'\n\n return html.html_safe\n end",
"def catalogs\n [\"#{unit.id}-#{environment}.plist\"]\n end",
"def unit_idlers\n world.units.active.find_all { |u|\n unit_isidler(u)\n }\n end",
"def inst_str(specimens)\r\n is = []\r\n v = {}\r\n v[\"unknown\"] = []\r\n specimens.each do |s|\r\n if !s.repository.blank? && !s.repository.coden.blank?\r\n if v[s.repository.coden].nil?\r\n v[s.repository.coden] = [s]\r\n else\r\n v[s.repository.coden] << s\r\n end\r\n else\r\n v[\"unknown\"] << s\r\n end\r\n end\r\n v.delete(\"unknown\") if v[\"unknown\"].size == 0 \r\n ls = []\r\n v.keys.each do |r|\r\n s = ''\r\n s += id_str(v[r])\r\n s += \" (#{r})\"\r\n ls << s\r\n end \r\n ls.join(\"; \")\r\n end",
"def generate_patients\n base_patients = [Generator.create_base_patient]\n generated_patients = []\n \n # Gather all available populations. Each kind of population (e.g. IPP, DENOM) can have many multiples (e.g. IPP_1, IPP_2)\n populations = []\n [\"IPP\", \"DENOM\", \"NUMER\", \"EXCL\", \"DENEXCEP\"].each do |population|\n i = 1\n populations << population\n while Generator.hqmf.population_criteria(\"#{population}_#{i}\").present? do\n populations << \"#{population}_#{i}\"\n i += 1\n end\n end\n\n populations = [\"EXCL_1\"]\n\n populations.each do |population|\n criteria = Generator.hqmf.population_criteria(population)\n \n # We don't need to do anything for populations with nothing specified\n next if criteria.nil? || !criteria.preconditions.present?\n criteria.generate(base_patients) \n \n # Mark the patient we just created with its expected population. Then extend the Record to be augmented by the next population.\n base_patients.collect! do |patient|\n patient.elimination_population = population\n generated_patients.push(Generator.finalize_patient(patient))\n Generator.extend_patient(patient)\n end\n end\n \n generated_patients\n end",
"def list; end"
] | [
"0.6578174",
"0.6343721",
"0.62469006",
"0.60823303",
"0.599287",
"0.5890327",
"0.58779263",
"0.583078",
"0.57019126",
"0.56427205",
"0.56415254",
"0.5570522",
"0.5557859",
"0.5485976",
"0.54788524",
"0.54648286",
"0.5464344",
"0.54270726",
"0.5403116",
"0.53950113",
"0.5382168",
"0.5319288",
"0.5306882",
"0.52981615",
"0.52455145",
"0.52440107",
"0.5230736",
"0.52115077",
"0.5200341",
"0.5200296",
"0.5189978",
"0.51781887",
"0.5170872",
"0.5152226",
"0.5119138",
"0.51095444",
"0.5090003",
"0.50848764",
"0.5084743",
"0.5081335",
"0.5076264",
"0.5076043",
"0.50687784",
"0.5060269",
"0.5055461",
"0.5034517",
"0.50294894",
"0.5018695",
"0.501749",
"0.50141835",
"0.5005774",
"0.5005559",
"0.49999523",
"0.4990735",
"0.4979475",
"0.4976289",
"0.49386922",
"0.49373156",
"0.49338725",
"0.4927981",
"0.49242747",
"0.49236348",
"0.4922879",
"0.49039632",
"0.48973966",
"0.48973966",
"0.48956892",
"0.48855782",
"0.48806038",
"0.48785785",
"0.4873295",
"0.48616132",
"0.4860195",
"0.4855578",
"0.48471418",
"0.4835601",
"0.4835503",
"0.48321572",
"0.48295906",
"0.48018524",
"0.47977218",
"0.47977218",
"0.47900498",
"0.47887558",
"0.47868693",
"0.47821328",
"0.47780296",
"0.47750497",
"0.47674903",
"0.47637466",
"0.47622138",
"0.47582012",
"0.47513735",
"0.47504544",
"0.4747417",
"0.4745924",
"0.47424835",
"0.47392315"
] | 0.6426889 | 3 |
Find flowcells for which analysis is not yet started. Read the directory listing under the instrument directory, compare directories against the list of completed flowcells and find the directories (flowcells) that are new. | def findNewFlowcells()
@newFC = Array.new
dirList = Dir.entries(@instrDir)
dirList.each do |dirEntry|
if !dirEntry.eql?(".") && !dirEntry.eql?("..") &&
File::directory?(@instrDir + "/" + dirEntry) &&
isAvailableForCleaning(@instrDir + "/" + dirEntry)
@newFC << dirEntry
puts dirEntry.slice(/[0-9A-Za-z]+$/).gsub(/^[AB]/, "") + " " + @instrDir + "/" + dirEntry
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findNewFlowcells()\n @newFC = Array.new\n\n dirList = Dir.entries(@instrDir)\n\n dirList.each do |dirEntry|\n if !dirEntry.eql?(\".\") && !dirEntry.eql?(\"..\") &&\n File::directory?(@instrDir + \"/\" + dirEntry) &&\n !@fcList.key?(dirEntry.strip)\n @newFC << dirEntry\n end\n end \n end",
"def findNewFlowcells()\n @newFC = Array.new\n\n dirList = Dir.entries(@instrDir)\n\n dirList.each do |dirEntry|\n if !dirEntry.eql?(\".\") && !dirEntry.eql?(\"..\") &&\n File::directory?(@instrDir + \"/\" + dirEntry) &&\n !@fcList.key?(dirEntry.strip)\n @newFC << dirEntry\n end\n end \n end",
"def findPaths (conf)\n puts aktTime()+' collecting files...'\n STDOUT.flush #write out immediately\n\tconf[:saveDirs].each do |d|\n\t\tif File.directory?(d)\n\t\t\tDir.chdir(d)\n\t\t\tgetFiles(conf)\n\t\telse\n\t\t\tputs \"\\nWarning: Directory: \\n\"+d+\" **not** found !\"\n\t\tend\n\tend\nend",
"def fetchUntestedProjects \r\n @logger.debug \"search untested projects: #{@workspaceFolder}\"\r\n\t\tprojectFolders = FileList.new(@workspaceFolder+\"/*/\")\r\n\t\tprojectFolders.exclude(@workspaceFolder+\"/.*/\") # no meta-data\t\t\r\n\t\tprojectFolders.each do |projectFolder|\r\n\t\t\tsourceFiles = FileList.new(projectFolder+\"/**/*.{h,hpp,c,cpp}\")\r\n\t\t\tif sourceFiles.size() > 0 then\r\n\t\t\t\r\n\t\t\t\tprojectPath = Pathname.new(projectFolder).cleanpath.to_s\r\n\t\t\t\tif @testedProjects.find{ |item| item.projectFolder.eql?(projectPath) } == nil then\r\n @logger.debug \"=> untested project: #{File.basename(projectPath)}\" \r\n\t\t\t\t\t@untestedProjects << projectPath\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend\r\n\tend",
"def find_files\n find_files_recursive(@build_result_dir, '')\n end",
"def find_path\n current_node = @cells_visited.last\n while current_node.parent != nil do\n @solved_path << current_node.cell\n current_node = current_node.parent\n end\n @solved_path << current_node.cell\n end",
"def getFlowcellDirectoryNames(searchPath, fcName)\n result = Array.new\n dirEntries = Dir.entries(searchPath)\n\n dirEntries.each do |dirEntry|\n if dirEntry.match(fcName)\n result << searchPath + \"/\" + dirEntry\n end\n end\n return result\n end",
"def findFCPath(fcName)\n fcPath = \"\"\n parentDir = Array.new\n\n # This represents location where to search for flowcell\n rootDir = \"/stornext/snfs0/next-gen/Illumina/Instruments\"\n\n dirEntries = Dir.entries(rootDir)\n\n # In the rootDir of the data copied over from the sequencers, find \n # directories corresponding to each sequencer and populate the \n # parentDir array\n dirEntries.each do |dirEntry|\n if !dirEntry.eql?(\".\") && !dirEntry.eql?(\"..\") &&\n File::directory?(rootDir + \"/\" + dirEntry.to_s)\n parentDir << rootDir + \"/\" + dirEntry.to_s\n end\n end\n\n parentDir.each{ |path|\n if File::exist?(path + \"/\" + fcName) &&\n File::directory?(path + \"/\" + fcName)\n fcPath = path + \"/\" + fcName\n end\n }\n\n if fcPath.eql?(\"\")\n puts \"Error : Did not find path for flowcell : \" + fcName\n raise \"Error in finding path for flowcell : \" + fcName\n end\n return fcPath.to_s\n end",
"def buildAnalyzedFCList()\n logFile = @instrDir + \"/\" + @completedFCLog\n puts logFile\n @fcList = nil\n @fcList = Hash.new()\n \n if File::exist?(logFile)\n lines = IO.readlines(logFile)\n\n if lines != nil && lines.length > 0\n lines.each do |line|\n @fcList[line.strip] = \"1\"\n end \n end\n else\n # If this directory is newly created and it does not have the log of\n # completed flowcells, create this file.\n cmd = \"touch \" + logFile\n `#{cmd}`\n end\n end",
"def buildAnalyzedFCList()\n logFile = @instrDir + \"/\" + @completedFCLog\n puts logFile\n @fcList = nil\n @fcList = Hash.new()\n \n if File::exist?(logFile)\n lines = IO.readlines(logFile)\n\n if lines != nil && lines.length > 0\n lines.each do |line|\n @fcList[line.strip] = \"1\"\n end \n end\n else\n # If this directory is newly created and it does not have the log of\n # completed flowcells, create this file.\n cmd = \"touch \" + logFile\n `#{cmd}`\n end\n end",
"def list_of_directories\n Dir.entries(\"./inspections\").select {|d| !d.start_with?(\".\") }\n end",
"def directories_to_watch\n []\n end",
"def get_remote_files\n manager = @current_source.file_manager\n manager.start do \n @current_source.folders.each do |folder|\n @files[folder] = manager.find_files folder\n @files[folder] = @files[folder].take(@take) if @take\n Logger.<<(__FILE__,\"INFO\",\"Found #{@files[folder].size} files for #{@current_source.base_dir}/#{folder} at #{@current_source.host.address}\")\n SignalHandler.check\n end\n end\n end",
"def poll_changed_directories\n until stopped\n sleep(latency)\n report_changes\n end\n end",
"def monitored_paths\n paths = Dir['**/*'].select do |path|\n watch = false\n @script.rules.reverse.each do |r|\n rule_watches = r.watch(path)\n if false\n $stderr.print \"watch \", path, \" \", rule_watches, \"\\n\"\n end\n next if rule_watches.nil?\n watch = rule_watches\n break\n end\n watch\n end\n paths.each do |path|\n # $stderr.print \"lookup #{path}\\n\"\n @script.depends_on(path).each do |dependence|\n # $stderr.print \"add #{dependence} for #{path}\\n\"\n paths << dependence\n end\n end\n paths.push(@script.path).compact!\n paths.uniq!\n # $stderr.print \"watch #{paths.map {|path| Pathname(path).expand_path }.join(' ')}\\n\"\n paths.map {|path| Pathname(path).expand_path }\n end",
"def cycle_existing_snapshot_dirs # rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/CyclomaticComplexity\n if @first_call\n regenerate_tar_file\n @first_call = false\n return\n end\n check_aged_out = CheckAgedOut.new\n @my_files.each_with_index do |f, i|\n fname = f.fname\n next unless FileTest.file?(fname)\n\n $stderr << \"status of #{fname} \" << check_aged_out.aged_out(fname) << \"\\n\" if @verbose\n next unless check_aged_out.aged_out(fname)\n\n # If we are the oldest file and we have aged out, remove it.\n if i.zero?\n File.delete(fname)\n next\n end\n\n # File `i` has as aged out, move it unless we are one of the slots\n # that must wait.\n newfile = @my_files[i - 1].fname # The next oldest slot.\n next if f.must_wait && File.exist?(newfile)\n\n FileUtils.mv(fname, newfile)\n\n # If we are the most recent file, and we have just moved our tarfile, regnerate.\n regenerate_tar_file if fname == name_of_first_tar_file\n end\n end",
"def find_all\n\t\t\t@launch_agents = []\n\t\t\tlaunch_agent_folders.each do |folder|\n\t\t\t\t @launch_agents << Dir[\"#{folder}/**.plist\"]\n\t\t\tend\n\t\t\t@launch_agents.flatten!\n\t\t\t@launch_agents = @launch_agents.map do |li| parse_launch_agent li end\n\t\t\t@launch_agents = @launch_agents.select do |li| li != false end\n\t\tend",
"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 scan_now\n #Check for add/modify\n scan_dir(@directory)\n \n # Check for removed files\n if @on_remove.respond_to?( :call )\n @known_file_stats.each_pair{ |path,stats|\n next if File.file?( path )\n stats[:path] = path\n @on_remove.call( stats )\n @known_file_stats.delete(path)\n }\n end\n \n @scanned_once = true\n end",
"def poll_changed_dirs\n until @stop\n sleep(@latency)\n report_changes\n end\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 detected_directories\n sub_directories.reject do |on_disk|\n children.any? { |in_db| in_db.full_path == on_disk }\n end.map do |found|\n children.new(relative_path: found.relative_path_from(disk.path), disk: disk)\n end.each(&:valid?) # build paths\n end",
"def find_out_of_sync(root, directories, monitoring_config)\n max_day_old = check_optional_input(monitoring_config, ['max_day_old'], 5)\n canary = check_optional_input(monitoring_config,\n ['canary_name'],\n '.survivor.canary')\n out_of_date = directories.select do |directory|\n # Select old canaries\n path = \"#{root}/#{directory}/#{canary}\"\n age_day = read_age_from_file_content(path)\n age_day > max_day_old\n end\n return out_of_date\n end",
"def report_changes\n changed_dirs = nil\n\n mutex.synchronize do\n return if @changed_directories.empty?\n changed_dirs = @changed_directories.to_a\n @changed_directories.clear\n end\n\n callback.call(changed_dirs, {})\n turnstile.signal\n end",
"def scan\n results = []\n dirs.each do |dir|\n files_in_dir = Dir.glob(File.join(dir,'**','*'))\n results.concat(files_in_dir)\n end\n @known_files = results\n end",
"def GetEnemyDirs()\n\n directories = Dir.entries($enemy_folder)\n\n for i in 0...directories.length do\n\n if not directories[i].include? \".\" then\n $current_folder = $enemy_folder + directories[i]\n GetEnemies($current_folder)\n end\n\n end\n\n ExtractIDs()\nend",
"def existing_files\n existing_dirs.each do |dir|\n Find.find(dir) do |path|\n if FileTest.directory?(path)\n if File.basename(path)[0] == '.'\n # Don't look any further into directories that start with a dot.\n Find.prune\n else\n next\n end\n elsif block_given?\n yield path\n end\n end\n end\n end",
"def findBaseCallsDir(fcName)\n fcPath = \"\"\n\n # This represents directory hierarchy where GERALD directory\n # gets created.\n baseCallsDirPaths = Array.new\n baseCallsDirPaths << \"Data/Intensities/BaseCalls\"\n baseCallsDirPaths << \"BCLtoQSEQ\"\n \n fcPath = findFCPath(fcName)\n \n baseCallsDirPaths.each{ |bcPath|\n if File::exist?(fcPath + \"/\" + bcPath) &&\n File::directory?(fcPath + \"/\" + bcPath)\n return fcPath.to_s + \"/\" + bcPath.to_s\n end\n }\n raise \"Did not find Base calls directory for flowcell : \" + fcName\n end",
"def read_dirs_old(indir)\n log_info(\"(#{indir})\")\n scan_dirs(indir)\n combine_acs_files\n print_summary if MyOpts.get(:verbose)\n end",
"def scan_dirs\n @scan_files = Array.new\n Dir.entries(@scan_dir).each do |scan|\n next if File.directory?(@scan_dir + '/' + scan)\n @scan_files << @scan_dir + '/' + scan\n end\n end",
"def find(dirs); end",
"def build_tests_list\n if ! @test_list.nil?\n return @test_list\n end\n @test_list = []\n Find.find(@ruby_tests_location) do |path|\n if FileTest.directory?(path)\n if File.basename(path)[0] == \".\"\n Find.prune # ignore . .. and .svn\n else\n next\n end\n elsif File.extname(path) == \".test\"\n puts \"Processing: \" + path\n @test_list << path\n end\n end\n\n if @test_list.size == 0\n raise MissingRubyTestFiles, \"Can't find any rubySelenium tests in directory #{@ruby_tests_location}\"\n else\n return @test_list.sort!\n end\n end",
"def new_batches(w)\n @logger.debug(\"Looking for new batches in remote dir '#@basedir' with pattern #@batch_pattern\")\n complete_dirs = w.sftp.dir[@basedir, @batch_pattern].select do |entry|\n next if /\\.log$/.match(entry.name) # skip log files (MSP#1915)\n\n w.sftp.dir[join(@basedir, entry.name), DELIVERY_COMPLETE].any?.tap do |f|\n if f\n @logger.debug(\" Found new batch: #{entry.name}\")\n else\n @logger.debug(\" Incomplete batch: #{entry.name}\")\n end\n end\n end\n\n complete_dirs.map do |entry|\n Model::Batch.new(:path => join(@basedir, entry.name),\n :state => :new)\n end\n end",
"def poll_changed_directories\n until stopped\n next if paused\n\n start = Time.now.to_f\n callback.call(directories.dup, :recursive => true)\n turnstile.signal\n nap_time = latency - (Time.now.to_f - start)\n sleep(nap_time) if nap_time > 0\n end\n rescue Interrupt\n end",
"def scan_dir (dirname)\n log \"*** Inspect: \" + dirname\n Dir.foreach(dirname) do |filename|\n path_cand = File.join(dirname , filename)\n if File.directory?(path_cand)\n #exams directories\n if (filename != \".\" && filename != \"..\")\n unless @filter_dir.index(filename)\n #directory not filtered\n @explore_dir.push(path_cand)\n @dir_list << path_cand\n end\n end\n else\n # file to be listed\n unless file_is_filtered?(path_cand)\n # file is not filtered\n @result_list.push(path_cand)\n end\n end #file.directory?\n end\n next_dir = @explore_dir.pop\n scan_dir(next_dir) if next_dir \n end",
"def build_file_list\n puts_and_logs 'Finding files...'\n file_list = []\n config[:source].each do |entry|\n if File.directory?(entry)\n populate_list_of_files_from_directory(file_list, entry) \n next\n end\n if File.file?(entry)\n populate_list_of_files_from_file(file_list, entry) \n next\n end\n logger.warn \"\\\"#{entry}\\\" is neither a directory nor a regular file. Ignored...\"\n end\n logger.debug(file_list)\n file_list\n end",
"def scan_new(&block) # :yields: file\n old_known_files = @known_files\n scan\n new_files = known_files - old_known_files\n new_files.each do |new_file|\n block.call(new_file)\n end\n end",
"def fi_scan\n FileObj.all.each do |fo|\n fd = File.open(fo.abs_path)\n if dirty?(fo, fd)\n\t\t\t\twarn\n\t\t\t\tnotify_admin fo if CONFIG['notify_admin']\n\t\t\telse\n\t\t\t\tclean\n\t\t\tend\n puts fo.abs_path\n end\n end",
"def update_expect\n # Expect File\n @ExpectDir = \"Expect\"\n dir_name = @ExpectDir\n Common.make_dir_with_delete(\"#{dir_name}\")\n @report.printf(\"\\n\")\n @report.printf(\"Search Expect Golden File...\\n\")\n \n # Copy from GoldenExpect\n printf(\"@I:Copy from Golden Expect dir \\\"%s\\\"\\n\",@GoldenExpectDir)\n @InstInfo.sort_by{|inst|\n inst.ModuleName\n }.each{|inst|\n file_list = Array.new\n # Search File by ModuleName\n file_list = Dir.glob(\"#{@GoldenExpectDir}/*\\(#{inst.ModuleName}\\).expect\")\n if file_list.size != 0\n @report.printf(\" Module:%-25s( Inst:%-15s):Copy expect file from CCGolden to Expect\\n\",inst.ModuleName,inst.InstanceName)\n else\n @report.printf(\" Module:%-25s( Inst:%-15s):Not found expect file in CCGolden\\n\",inst.ModuleName,inst.InstanceName)\n end\n }\n=begin\n Dir.glob(\"#{@GoldenExpectDir}/*.expect\").each{|file|\n FileUtils.cp(\"#{file}\",\"#{@ExpectDir}\")\n @report.printf(\" Copied from %s to %s\\n\",file,@ExpectDir)\n }\n @report.printf(\"Done\\n\\n\")\n\n # Copy from TmpExpect\n printf(\"@I:Copy from Tmp Expect dir \\\"%s\\\"\\n\",@TmpExpectDir)\n Dir.glob(\"#{@TmpExpectDir}/*.expect\").each{|file|\n if File.file?(@ExpectDir+\"/\"+File.basename(\"#{file}\"))\n @report.printf(\" %-40s: Already Exist in %s dir\\n\",File.basename(\"#{file}\"),@ExpectDir)\n else\n FileUtils.cp(\"#{file}\",\"#{@ExpectDir}\")\n @report.printf(\" %-40s: Copy to %s dir\\n\",File.basename(\"#{file}\"),@ExpectDir)\n end\n }\n @report.printf(\"Done\\n\\n\")\n \n file_name = \"product.expect\"\n product = open(\"#{file_name}\",\"w\")\n \n # make one Expect File ( cat )\n Dir.glob(\"#{@ExpectDir}/*.expect\").each{|file|\n File.open(\"#{file}\").each{|line|\n product.printf(\"%s\",line)\n }\n }\n\n product.close\n=end\n \n end",
"def report_changes\n changed_dirs = nil\n\n @mutex.synchronize do\n return if @changed_dirs.empty?\n changed_dirs = @changed_dirs.to_a\n @changed_dirs.clear\n end\n\n @callback.call(changed_dirs, {})\n @turnstile.signal\n end",
"def refresh_watchers()\r\n paths = []\r\n\r\n # A list of all file paths the user passed in.\r\n unresolved_paths = @path.split(',')\r\n unresolved_paths = unresolved_paths.size == 0 ? @path : unresolved_paths\r\n\r\n # Glob all file paths and keep all readable files.\r\n for unresolved_path in unresolved_paths\r\n paths += Dir.glob(unresolved_path.strip).select do |resource|\r\n File.file?(resource) && File.readable?(resource)\r\n end\r\n end\r\n\r\n watched = @watched_files.keys\r\n\r\n # Files we are not yet watching.\r\n new_files = paths - watched\r\n\r\n # Files we are watching that no longer exist.\r\n dead_files = watched - paths\r\n\r\n start_watches(new_files)\r\n stop_watches(dead_files, true)\r\n end",
"def ssh_se_on_inst(slide_done = 0)\n files = \"\"\n Net::SSH.start(@ip, \"pipeline\") do |ssh|\n if slide_done == 1\n Helpers::log(\"Searching for .slide_done.txt on instrument..\")\n files = ssh.exec! \"ls /*/r*/solid*/*/.slide_done.txt\"\n else \n Helpers::log(\"Searching for files on instrument..\")\n files = ssh.exec! \"find /*/r*/solid*/*/*/r*.*/lib*/ -follow \" +\n \"-name \\\"*csfasta\\\" -o -name \\\"*qual\\\" \" +\n \"-o -name \\\"*Stat*txt\\\"\"\n end\n end\n temp = []\n if /No such/.match(files)\n Helpers::log(\"No files could be found.\")\n else\n files.split.each do |f|\n if !/sampled/.match(f) && !/unassigned/.match(f) && !/_BC_/.match(f) &&\n !/missing/.match(f) && !/old/.match(f)\n temp << f\n end\n end\n end\n temp\n end",
"def filter_data!\n begin\n unless lock_file_present?(lock_file_name)\n FileUtils.touch lock_file_name\n\n # The find process command line\n find_dir = Shellwords.escape(run_dir)\n\n flist_cmd = %Q[find #{find_dir} -name '*' | \\\negrep -i -e './Logs|./Images|RTALogs|reports|.cif|.cif.gz|.FWHMMap|_pos.txt|Converted-to-qseq']\n\n logger.info \"Find command line:\"\n logger.info flist_cmd\n\n # Runs the above command and saves the output in 'file_list';\n # reports eventual errors.\n file_list = %x[ #{flist_cmd} ]\n raise Errors::FindProcessError.new(\"'find' or 'grep' child processes exited with error status\") if $?.exitstatus > 1\n\n file_list = file_list.split(\"\\n\")\n\n logger.info \"Removing the following files:\"\n logger.info file_list\n\n # Remove all regular files first.\n regulars = file_list.reject {|path| File.directory?(path)}\n regulars.each_slice(100) do |slice|\n FileUtils.rm(slice)\n end\n\n # ...and then remove all the empty directories, from the\n # inside out.\n dirs = file_list.select {|path| File.directory?(path)}.\n sort_by {|dir| dir.count('/') }.reverse\n dirs.each_slice(100) do |slice|\n FileUtils.rmdir(slice)\n end\n\n # Cleaning up the second copy of the data since the backup completed successfully\n logger.info \"Removing backup from: #{File.join(Conf.global_conf[:safe_location_dir], run_name)}\"\n FileUtils.remove_dir(File.join(Conf.global_conf[:safe_location_dir], run_name), true)\n\n else\n logger.warn \"Lock file \\\"#{lock_file_name}\\\" still there, skipping.\"\n end\n rescue => e\n logger.error \"in filter data function:\"\n logger.error e.message\n logger.error e.backtrace.join(\"\\n\")\n Mailer.notify_admins(self, \"filter_data\", e)\n ensure\n FileUtils.rm lock_file_name if File.exists?(lock_file_name)\n end\n\n end",
"def removed_unmarked_paths\n #remove dirs\n dirs_enum = @dirs.each_value\n loop do\n dir_stat = dirs_enum.next rescue break\n if dir_stat.marked\n dir_stat.marked = false # unset flag for next monitoring\\index\\remove phase\n #recursive call\n dir_stat.removed_unmarked_paths\n else\n # directory is not marked. Remove it, since it does not exist.\n write_to_log(\"NON_EXISTING dir: \" + dir_stat.path)\n # remove file with changed checksum\n $local_content_data_lock.synchronize{\n $local_content_data.remove_directory(dir_stat.path, Params['local_server_name'])\n }\n rm_dir(dir_stat)\n end\n end\n\n #remove files\n files_enum = @files.each_value\n loop do\n file_stat = files_enum.next rescue break\n if file_stat.marked\n file_stat.marked = false # unset flag for next monitoring\\index\\remove phase\n else\n # file not marked meaning it is no longer exist. Remove.\n write_to_log(\"NON_EXISTING file: \" + file_stat.path)\n # remove file with changed checksum\n $local_content_data_lock.synchronize{\n $local_content_data.remove_instance(Params['local_server_name'], file_stat.path)\n }\n # remove from tree\n @files.delete(file_stat.path)\n end\n end\n end",
"def cells\n if @cells.blank?\n\n @cells = []\n self.loopoff_file_names.each do |f|\n @cells << Lt::FileCell.new(:name => f,\n :size => File.size(f),\n :sha => self.file_ids_hash[File.basename(f)],\n :is_identical => self.db.repo.distinct_blobs.map(&:id).include?(self.file_ids_hash[File.basename(f)]) \n )\n end\n end\n @cells \n end",
"def ingest_paths\n path = Pathname.new(Figgy.config[\"ingest_folder_path\"]).join(ingest_directory)\n return [] unless path.exist?\n path.children.select(&:directory?)\n end",
"def scan_dir (dirname)\n log \"*** Inspect: \" + dirname\n Dir.foreach(dirname) do |filename|\n path_cand = File.join(dirname , filename)\n if File.directory?(path_cand)\n #exams directories\n if (filename != \".\" && filename != \"..\")\n unless @filter_dir.index(filename)\n #directory not filtered\n @explore_dir.push(path_cand)\n @dir_list << path_cand\n end\n end\n else\n # file to be listed\n unless file_is_filtered?(path_cand)\n # file is not filtered\n #p path_cand\n if file_has_admitted_extension?(path_cand)\n @result_list.push(path_cand)\n end\n end\n end #file.directory?\n end\n next_dir = @explore_dir.pop\n scan_dir(next_dir) if next_dir \n end",
"def scan!\n Dir.chdir(@path) do\n Find.find('.') do |file|\n next if file == '.'\n\n # ignore the ./\n file = file[2..-1]\n name = File.basename(file)\n\n # ignore certain files/directories\n Find.prune if IGNORE.include?(name)\n\n if File.directory?(file)\n @directories << file\n elsif File.file?(file)\n src = File.join(@path,file)\n\n case File.extname(name)\n when '.erb'\n # erb template\n if name.start_with?('_')\n # partial template\n template_dir = File.dirname(file)\n template_name = name[1..-1].chomp('.erb').to_sym\n\n @includes[template_dir][template_name] = src\n else\n dest = file.chomp('.erb')\n\n @templates[dest] = src\n end\n else\n # static file\n @files[file] = src\n end\n end\n end\n end\n end",
"def taken_paths\n if @target.exist?\n @target.children.select { |path| jobdir_name?(path.basename.to_s) }\n else\n []\n end\n end",
"def start_watches(paths)\r\n for path in paths\r\n # Get or create a Position object for the file path.\r\n pos_file = @pos != nil ? @pos.get_position(path) : Position.new(path)\r\n # Create a LogState to track the log.\r\n log_state = LogState.new(pos_file, method(:emit_lines))\r\n # Start a timer to check for changes in the log and emit new lines.\r\n log_state.timer = timer_execute(:iis_file_watchers, @read_log_entires, repeat: false, &log_state.method(:emit_lines))\r\n @watched_files[path] = log_state\r\n end\r\n end",
"def moves\n valid_moves = []\n move_dirs.each do |dx,dy| \n valid_moves += grow_unblocked_moves_in_dir(dx,dy)\n end\n valid_moves\n end",
"def find_dirs\n\tlog_paths = [ \"/etc/\", \"/home/log/\", \"/home/ids/log/\", \"/usr/adm/\", \"/usr/apache/\", \"/usr/apache2/\", \"/usr/httpd/\", \"/usr/local/apache/\", \"/usr/local/apache2/\", \"/usr/var/adm/\", \"/usr/var/ids/\", \"/usr/var/log/\", \"/var/adm/\", \"/var/ids/\", \"/var/log/\", \"/var/prelude/\", \"/var/run/\", \"/var/www/\", \"/root/Desktop/\" ]\n\n\t#Cycle through the Possible Log File Locations and Check for Logs if directory exists\n\tlog_paths.each do |dir|\n\t\t#Check if the log possible log file directory exists before we go and glob its content\n\t\tif File.exists?(dir) && File.directory?(dir)\n\t\t\tfind_logs(\"#{dir}\")\n\t\tend\n\tend\nend",
"def all_matching_files\n @all_matching_files ||= find_files\n end",
"def all_matching_files\n @all_matching_files ||= find_files\n end",
"def check_for_inexistent_files\n inexistent_files = []\n @files.each do |file|\n inexistent_files << file unless File.exists? file\n end\n\n inexistent_files\n end",
"def find_bash_files!\n return if Bashcov.skip_uncovered\n\n Pathname.glob(\"#{Bashcov.root_directory}/**/*.sh\").each do |filename|\n @coverage[filename] = [] unless @coverage.include?(filename)\n end\n end",
"def find_top_files(clone_destination)\n globule = File.join(clone_destination, '*') # Define a variable here so the next line is legible.\n Dir.glob(globule, File::FNM_DOTMATCH).each do |path|\n next if File.directory?(path) # Should omit '.' and '..' as well.\n next if config['exclude_files'].include? File.basename(path)\n unless config['files'].nil? || config['files'].empty?\n next unless config['files'].include? File.basename(path)\n end\n file_candidates << path\n end\n end",
"def watch_appropriate_nodes\n remaining_paths.last( threshold + 1 ).reverse_each do |path|\n next if watched_paths.include? path\n watched_paths << path\n finish_node(path) unless zk.exists?(path, :watch => true)\n end\n end",
"def checkCurrent()\n files = getFilesFromDiff(`hg log -r . --patch`)\n changeset = `hg id`[0..11]\n checkFiles(files, changeset)\n end",
"def watch_configured_directories config_file\n\n watched_directories = []\n\n config = Datyl::Config.new(config_file, 'default')\n\n config.all_sections.each do |section|\n\n site_config = Datyl::Config.new(config_file, 'default', section)\n next unless site_config.site # only use sections concerning websites\n\n # TODO: DRY up the next two sections (ftp_queue/digitool_queue)\n\n if site_config.ftp_queue\n errors = WatchUtils.directory_problems(site_config.ftp_queue)\n if errors.empty?\n STDERR.puts \"INFO: Watching FTP incoming directory in #{site_config.ftp_queue} for #{section}\"\n watched_directories.push FtpWatchDirectory.new(site_config, section)\n else\n STDERR.puts \"ERROR: Skipping watching FTP directory #{site_config.ftp_queue} for #{section}, these configuration errors were encountered:\"\n errors.each { |line| STDERR.puts \"ERROR: \" + line }\n end\n end\n\n end\n\n return watched_directories.compact\nend",
"def verify_all_remotes\n missing = []\n files = self.study_files.where(queued_for_deletion: false, human_data: false, :parse_status.ne => 'parsing', status: 'uploaded')\n directories = self.directory_listings.are_synced\n all_locations = files.map(&:bucket_location)\n all_locations += directories.map {|dir| dir.files.map {|file| file['name']}}.flatten\n remotes = ApplicationController.firecloud_client.execute_gcloud_method(:get_workspace_files, 0, self.bucket_id)\n if remotes.next?\n remotes = [] # don't use bucket list of files, instead verify each file individually\n end\n all_locations.each do |file_location|\n match = self.verify_remote_file(remotes: remotes, file_location: file_location)\n if match.nil?\n missing << {filename: file_location, study: self.name, owner: self.user.email, reason: \"File missing from bucket: #{self.bucket_id}\"}\n end\n end\n missing\n end",
"def scan_dir(path)\n old_files = dir_entries(@old_base, path)\n new_files = dir_entries(@new_base, path)\n old_files.each do |fname, type|\n unless new_files.has_key?(fname) && new_files[fname] == type\n delete_dir(path + fname + '/') if type == :directory && !@options[:shallow]\n @entries << [path + fname, type, :deleted]\n end\n end\n new_files.each do |fname, type|\n if old_files.has_key?(fname) && old_files[fname] == type\n if type == :directory\n scan_dir(path + fname + '/')\n else\n compare_file(path + fname, type)\n end\n else\n @entries << [path + fname, type, :added]\n add_dir(path + fname + '/') if type == :directory && !@options[:shallow]\n end\n end\n end",
"def report_files_that_dont_have_st_sync_active(options)\n inactive_files = []\n active_files = []\n total_file_count = 0\n\n Repositext::Cli::Utils.read_files(\n config.compute_glob_pattern(\n options['base-dir'] || :content_dir,\n options['file-selector'] || :all_files,\n options['file-extension'] || :at_extension\n ),\n options['file_filter'],\n nil,\n \"Reading content AT files\",\n options\n ) do |content_at_file|\n data_json_file = content_at_file.corresponding_data_json_file\n total_file_count += 1\n lang_and_date_code = [\n content_at_file.language_code_3_chars,\n content_at_file.extract_date_code\n ].join\n if data_json_file.contents.index('\"st_sync_active\":false')\n inactive_files << lang_and_date_code\n $stderr.puts \" - doesn't have st_sync_active\".color(:blue)\n else\n active_files << lang_and_date_code\n end\n end\n inactive_files_count = inactive_files.length\n active_files_count = active_files.length\n if inactive_files_count > 0\n $stderr.puts \"\\n\\n#{ inactive_files_count } files that DON'T HAVE st_sync_active:\"\n $stderr.puts '-' * 80\n inactive_files.each { |e| $stderr.puts e }\n $stderr.puts\n end\n if active_files_count > 0\n $stderr.puts \"\\n\\n#{ active_files_count } files that HAVE st_sync_active:\"\n $stderr.puts '-' * 80\n active_files.each { |e| $stderr.puts e }\n $stderr.puts\n end\n summary_line = \"Found #{ inactive_files_count } of #{ total_file_count } files that don't have st_sync_active at #{ Time.now.to_s }.\"\n $stderr.puts summary_line\n end",
"def watch( paths )\n chksum_errors = {}\n paths.map!{ |path| Dir[\"#{path}/**/*\"] }.flatten! if $r\n dirs = paths.select{ |path| File.directory? path }\n dirs.each do |dir|\n cd dir do\n begin\n chksum_manifest = load\n chksum_manifest = check chksum_manifest\n dump chksum_manifest\n rescue ChecksumError => error\n chksum_errors[dir] = error.message\n end\n end\n end\n chksum_errors\n end",
"def updated_lines\n io = @diff.each_line\n path = nil\n\n found = []\n\n while true\n line = io.next\n if line =~ FILE_PATTERN\n path = $1\n end\n\n if hunk_header?(line)\n line_numbers = line_numbers_for_destination(line)\n found << [ path, line_numbers ]\n end\n end\n rescue StopIteration\n return found\n end",
"def search_paths\n # NOTE: Do not cache this list, specific generators\n # will modify it with their own lookups\n create_search_paths.select { |path| File.directory?(path) }\n end",
"def handoff_old\n\t\t@workflows = [] #WorkFlow.where(is_active: true, is_in_use: false)\n\t\t@holidays = []\n\t\t@reason_codes = []\n\t\t@days_at_ia_approved = 0\n\t\t@days_at_ecr_inbox = 0\n\t\t@days_at_sent_to_collab = 0\n\t\t@days_at_station8_sent = 0\n\t\t@days_at_crb_started = 0\n\t\t@days_at_ecn_released = 0\n\n\t\t@pred_of_ia_approved = ''\n\t\t@pred_of_ecr_inbox = ''\n\t\t@pred_of_sent_to_collab = ''\n\t\t@pred_of_station8_sent = ''\n\t\t@pred_of_crb_started = ''\n\t\t@pred_of_ecn_released = ''\n\n\n\t\t@workflow.holidays.each do |holiday|\n\t @holidays << holiday\n\t end\n\n\t\tworkflows = WorkFlow.where(is_active: true, is_in_use: false)\n\t\tworkflows.each do |wk|\n\t\t\t@workflows << wk\n\t\tend\n\n\t\t@filtered_station_steps = []\n\t filtered_station_steps = @workflow.report_filter_steps.eager_load(:station_step => [:workflow_station]).order(:sequence)\n\t\tfiltered_station_steps.each do |fss|\n\t\t\t@filtered_station_steps << fss\n\t\t\tif fss.station_step_id == 1\n\t\t\t\t@days_at_ia_approved = fss.duration_days\n\t\t\t\t@pred_of_ia_approved = fss.predecessors\n\t\t\tend\n\t\t\tif fss.station_step_id == 7\n\t\t\t\t@days_at_ecr_inbox = fss.duration_days\n\t\t\t\t@pred_of_ecr_inbox = fss.predecessors\n\t\t\tend\n\t\t\tif fss.station_step_id == 5\n\t\t\t\t@days_at_sent_to_collab = fss.duration_days\n\t\t\t\t@pred_of_sent_to_collab = fss.predecessors\n\t\t\tend\n\t\t\tif fss.station_step_id == 15\n\t\t\t\t@days_at_station8_sent = fss.duration_days\n\t\t\t\t@pred_of_station8_sent = fss.predecessors\n\t\t\tend\n\t\t\tif fss.station_step_id == 17\n\t\t\t\t@days_at_crb_started = fss.duration_days\n\t\t\t\t@pred_of_crb_started = fss.predecessors\n\t\t\tend\n\t\t\tif fss.station_step_id == 19\n\t\t\t\t@pred_of_ecn_released = fss.predecessors\n\t\t\tend\n\n\t\tend\n\n\t\t@stationSteps = []\n\t\tstation_steps = StationStep.eager_load(:workflow_station)\n\t\tstation_steps.each do |stp|\n\t\t\t@stationSteps << stp\n\t\tend\n\n \tif request.post?\n \t\tparams_list = params\n \t\tsearch\n \t\tsession[:report_wildcard] = params[:wildcard]\n\t\t session[:report_exact] = params[:exact]\n\n \t\tsession[:params_search] = params_list \n \t\t\tsearch_parm = search_csv(params_list)\n \t\telse\n \t\t\tparams_list = session[:params_search]\n\t\t if session[:report_wildcard].present?\n\t\t @wildcard = session[:report_wildcard]\n\t\t end\n\t\t if session[:report_exact].present?\n\t\t @exact = session[:report_exact]\n\t\t end\n\n\t\t if params_list.present?\n \t\t\t\tsearch_parm = search_csv(params_list)\n \t\t\tend\n \t\tend\t\n\n \t\tif params_list.present?\n\t \t\tbu = search_parm[0]\n\t \t\tl1 = search_parm[1]\n\t \t\tl2 = search_parm[2]\n\t \t\tl3 = search_parm[3]\n\t\t\t\n\t\t\tif params_list[:report_include_canceled].presence\n\t \t\tinclude_cancel = true\n\t \t\t@report_include_canceled = 'report_include_canceled'\n\t \telse\n\t \t\tinclude_cancel = false\n\t \tend\n\t \tif params_list[:report_include_onhold].presence\n\t \t\tinclude_onhold = true\n\t \t\t@report_include_onhold = 'report_include_onhold'\n\t \telse\n\t \t\tinclude_onhold = false\n\t \tend\n\t\t\tif params_list[:report_include_completed].presence\n\t \t\tinclude_completed = true\n\t \t\t@report_include_completed = 'report_include_completed'\n\t \telse\n\t \t\tinclude_completed = false\n\t \tend\t\n\n\t\t\tputs \"----:#{bu}---: #{l1}---:#{l2}---:#{l3}----:#{include_cancel}----:#{include_onhold}----:#{include_completed}\"\n\t \t\t@serach_result = []\n\t \t\tserach_result = WorkFlow.handoff_report_stored_procedure(bu, l1, l2, l3, include_completed, include_cancel, include_onhold)\n \t\t\tserach_result.each do |result|\n \t\t\t\t@serach_result << result\n \t\t\tend\n\n \t\tend\n \tend",
"def helper_files\n source_dir = File.join(Dir.pwd, \"lib/drydock/jobs\", helper_source_dir)\n if Dir.exists?(source_dir)\n Dir[source_dir + \"/*\"]\n else\n []\n end\n end",
"def move(all_units)\n all_units.each do |char|\n next unless char.alive\n\n targets = []\n\n queue = []\n queue.push([1, char.pos])\n\n distances = Hash.new\n previous = Hash.new\n\n while queue.length > 0\n curr = queue.shift\n # puts \"Q: #{curr[0]} POS: #{curr[1]}\"\n new_round = curr[0] + 1\n next if targets.length > 0 # Skip branches if we've found targets.\n\n DIRS.each do |dir| # For each potential neighbor...\n f_pos = curr[1] + dir\n # puts \"\\tCHECKING: #{f_pos} LINE: #{LINES[f_pos[0]][f_pos[1]]}\"\n if LINES[f_pos[0]][f_pos[1]] == '.' # Check map for wall\n skip_add = false\n all_units.each do |check|\n next if check == char || !check.alive\n if check.pos == f_pos\n if char.type != check.type # If enemy...\n # targets.push([check, curr[2]]) # Using state path\n targets.push([check, curr[0], curr[1]]) # Using previous hash\n end\n skip_add = true # Can't walk through units.\n end\n end\n # puts \"\\tSKIP CHECK: #{skip_add} PAST: #{curr[2]} EXISTS: #{curr[2].include?(f_pos)}\"\n # if !skip_add && !curr[2].include?(f_pos)\n # # puts \"\\tADDING: #{f_pos}\"\n # new_path = Marshal.load(Marshal.dump(curr[2]))\n # not_queued = queue.index {|q| q[1] == f_pos}.nil?\n # queue.push([new_round, f_pos, new_path.push(f_pos)]) if not_queued\n # end\n if (!skip_add && (distances[f_pos].nil? || new_round < distances[f_pos]))\n distances[f_pos] = new_round\n previous[f_pos] = curr[1]\n queue.push([new_round, f_pos])\n end\n end\n end\n end\n\n targets.each_with_index do |target, i|\n # puts \"#{char} #{i}: #{target[0]} PATH:#{target[1]}\"\n # puts \"#{char} #{i}: #{target[0]} NUM_STEPS:#{target[1]}\"\n end\n if targets.length > 0\n # Move\n nearest_target = targets[0] # Only interested in nearest enemy.\n # if nearest_target[1].length > 1 # More than 1 step away?\n # char.pos = nearest_target[1][1] # Step towards nearest enemy.\n # end\n if nearest_target[1] > 1 # More than 1 step away?\n next_pos = nearest_target[2]\n next_pos = previous[next_pos] while previous[next_pos] != char.pos\n # char.pos = nearest_target[1][1] # Step towards nearest enemy.\n # puts \"#{char} GOES TO #{next_pos}\"\n char.pos = next_pos # Step towards nearest enemy.\n end\n\n d_to_closest = (nearest_target[0].pos - char.pos).to_a.collect!{|v| v.abs}.sum\n # puts \"\\tC:#{char} T:#{nearest_target[0]} D_TO_T: #{d_to_closest}\"\n if d_to_closest == 1 # In melee range!\n targets_by_hp = targets.select {|t| (t[0].pos - char.pos).to_a.collect!{|t| t.abs}.sum == 1}.sort_by {|t| t[0].hp}\n target = targets_by_hp[0] # Lowest hp in melee range.\n target[0].hp -= char.attack\n # puts \"#{char} HITS #{target[0]}\"\n\n if target[0].hp <= 0\n puts \"#{char} KILLS #{target[0]}\"\n target[0].hp = 0\n target[0].alive = false\n end\n end\n else\n all_alive = all_units.select {|unit| unit.alive }\n all_elves = all_alive.select {|unit| unit.type == 'E'}\n return false if all_elves.length == 0 || all_elves.length == all_alive.length\n end\n end\n\n return true\nend",
"def facts_file_names\n return @facts_file_names if @facts_file_names\n error \"No #{Noop::Config.dir_path_facts} directory!\" unless Noop::Config.dir_path_facts.directory?\n exclude = [ Noop::Config.dir_name_facts_override ]\n @facts_file_names = find_files(Noop::Config.dir_path_facts, Noop::Config.dir_path_facts, exclude) do |file|\n file.to_s.end_with? '.yaml'\n end\n end",
"def monitored_paths\n paths = Dir['**/*'].select do |path|\n @script.patterns.any? {|p| path.match(p) }\n end\n paths.push(@script.path).compact!\n paths.map {|path| Pathname(path).expand_path }\n end",
"def initialize_directory_structure # rubocop:disable Metrics/MethodLength\n result = []\n\n %w[day hour minute].each do |unit|\n @intervals[unit].reverse.each do |i|\n dir = File.join(@to_dir, \"#{unit}s_ago\", i.to_s)\n FileUtils.mkdir_p(dir)\n fname = File.join(dir, @tarfile)\n $stderr << fname << \"\\n\"\n result << SnapshotFile.new(fname, unit)\n end\n end\n\n result\n 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 execute\n\n copiedCounter = 0\n failedCounter = 0\n skippedCounter = 0\n \n # traverse all srcfiles\n FiRe::filesys.find(@source) { |srcItem|\n \n # give some feedback\n FiRe::log.info \"searching #{srcItem}...\" if FiRe::filesys.directory?(srcItem)\n \n # skip this subtree if it matches ignored-items\n FiRe::filesys.prune if ignore?(srcItem) \n \n # transform srcpath to destpath\n destItem = srcItem.gsub(@source, @destination)\n\n # do not copy if item already exists and looks OK\n if needCopy(destItem,srcItem)\n copyWentWell = copyItem(srcItem, destItem)\n copiedCounter += 1 if copyWentWell\n failedCounter += 1 if !copyWentWell\n else\n skippedCounter += 1 \n end\n \n }\n \n # give some feedback\n FiRe::log.info \"copied #{copiedCounter} items, while #{failedCounter} items failed. #{skippedCounter} items did not need to be copied today.\"\n\n end",
"def runAll()\n\t\tprevCves = Set.new\n\n\t\tprevCves = setupCsvFile(@resultsFilePath, RESULT_HEADERS)\n\t\tprevCves += setupCsvFile(@manualFilePath, RESULT_HEADERS)\t\n\t\tprevCves +=\tsetupCsvFile(@removedFilePath, ['CVE', 'Reason'])\n\n\t\tcveManualFile = CSV.open(@manualFilePath, 'ab')\n\n\t\t# open csv file for results to be written to \n\t\tcveResultsFile = CSV.open(@resultsFilePath, 'ab')\n\n\t\tcveRemovedFile = CSV.open(@removedFilePath, 'ab')\n\n\n\t\tCHROMIUM_NIST_YEARS.each do | year |\n\t\t\tnistFilePath = \"#{@nistFile}#{NIST_PREFIX}#{year}#{NIST_SUFFIX}\"\n\t\t\tif not File.exists?(nistFilePath)\n\t\t\t\tdownloadNistData(year, nistFilePath)\n\t\t\tend\n\t\t\t\n\t\t\tfile = open(nistFilePath)\n\t\t\tdoc = Nokogiri::XML(file)\n\n\t\t\t# search by products affected by vulnerability\n\t\t\tputs \"Searching #{nistFilePath} for Chrome CVEs \\n\"\n\t\t\tentry1 = doc.xpath(\"//cpe-lang:fact-ref[starts-with(@name, 'cpe:/a:google:chrome:')]/../../..\")\n\n\t\t\tcveLinks = findNistLinks(entry1, cveManualFile, prevCves)\n\n\t\t\tscrapeResults = scrapeCveLinks(cveLinks, cveRemovedFile, cveManualFile)\n\n\t\t\tsaveResults(cveResultsFile, scrapeResults)\n\n\t\t\t# search by references to chromium in vuln links\n\t\t\tentry2 = doc.xpath(\"//vuln:reference[contains(@href, 'chromium')]/../..\")\n\n\t\t\t# Make sure the two sets don't overlap\n\t\t\tentry = entry2 - entry1\n\n\t\t\tcveLinks2 = findNistLinks(entry, cveManualFile, prevCves)\n\n\t\t\tscrapeResults2 = scrapeCveLinks(cveLinks2, cveRemovedFile, cveManualFile)\n\n\t\t\tsaveResults(cveResultsFile, scrapeResults2)\n\t\tend\n\tend",
"def runDiffOperation(new_output, old_output, diff_folder)\n #Searching for New & updated files\n @files = Dir.glob(new_output+\"**/**\")\n for file in @files\n partName=file.split(new_output).last \n if (File.directory?(file))\n if !File.exist?(old_output+partName)\n if !File.exist?(diff_folder+partName)\n createFolder(diff_folder+partName)\n puts \"Dir Created -\" + partName\n else\n puts \"Target Dir Exists -\" + partName\n end\n end\n else\n #New file copy operation\n if !File.exist?(old_output+partName) \n folder= partName.split(partName.split(\"/\").last).first\n if folder==nil\n folder=\"\"\n end\n if !File.exist?(diff_folder+folder)\n createFolder(diff_folder+folder)\n puts \"Dir Created -\" + diff_folder+folder\n end\n File.copy(file,diff_folder+folder)\n puts \"New File Copied -\"+file +\" to \"+diff_folder+folder\n #Updated file copy operation\n elsif !(File.compare(file,old_output+partName))\n folder= partName.split(partName.split(\"/\").last).first\n if folder==nil \n folder=\"\"\n end\n if !File.exist?(diff_folder+folder)\n createFolder(diff_folder+folder)\n puts \"Dir Created -\" + diff_folder+folder\n end\n File.copy(file,diff_folder+folder)\n puts \"Updated File Copied -\"+file +\" to \"+diff_folder+folder\n end\n end\n end\n #Searching for Deleted files & creating the list\n deletedFileList=diff_folder+\"deletedFiles.list\"\n timestamp = Time.now.to_s()\n deletedFileName=\"\"\n deletedFilesCount=0;\n @files = Dir.glob(old_output+\"**/**\")\n for file in @files\n partName=file.split(old_output).last\n check=partName.include?'search/'\n if !File.exist?(new_output+partName) && !check\n if !(File.directory?(file))\n deletedFileName=partName.split(\"/\").last\n open(deletedFileList, 'a') { |f|\n f.puts deletedFileName\n }\n end\n# deletedFileName= timestamp +\"\\t\"+deletedFileName\n deletedFilesCount=deletedFilesCount+1 \n end\n end\n if Dir.glob(diff_folder+\"**/**\") .length==0\n if (File.directory?(diff_folder))\n Dir.rmdir(diff_folder)\n end\n if (File.directory?(@book_update_folder))\n Dir.rmdir(@book_update_folder)\n end \n puts \"No Changes made\"\n exit\n end\nend",
"def calculated\n Solargraph.logger.info \"Indexing workspace files in #{directory}\" unless @calculated || directory.empty? || directory == '*'\n @calculated ||= included - excluded\n end",
"def buildArray(localObjCache, increase)\n localDirContents=[] #Array of all items in the cwd\n localDirContents=Dir[Dir.pwd+\"/*\"] #Builds the array of items in cwd\n\n localDirContents.each do |item|\n if File.file?(item)\n fileObj = FileName.new(item)\n localObjCache.push(fileObj)\n n = increase.call #printing every 100 files scanned\n if n % 100 == 0\n puts n\n end\n elsif File.directory?(item)\n Dir.chdir(item)\n buildArray(localObjCache, increase) \n end\n end\n\n return localObjCache\n end",
"def sync!\n\n destfiles = begin \n FsShellProxy.new.ls(@dest, true) \n rescue NoSuchFile \n {}\n end\n results = HSync::compare(LocalFs.new.ls(@source, true), destfiles)\n push_files(results.files_missing_in_b)\n # push_files(results.files_newer_in_a) # todo\n end",
"def find_paths(dir=\"\")\n base = File.join(@source, dir)\n entries = Dir.chdir(base) { filter_entries(Dir[\"*\"]) }\n paths = []\n\n entries.each do |entry|\n absolute_path = File.join(base, entry)\n relative_path = File.join(dir, entry)\n\n if File.directory?(absolute_path)\n paths.concat find_paths(relative_path)\n else\n paths << absolute_path\n end\n end\n paths\n end",
"def print_dirties()\n num_dirs = Dir.glob('./*/').size() -2 #exclude . and ..\n count = 0\n output = \"\"\n dirties_found = false\n Dir.glob('./*/').each() do |dir|\n count += 1\n next if dir == '.' or dir == '..'\n\n print \"Examining directories...#{count}/#{num_dirs}\\r\" if !$verbose\n count += 1\n\n if(File.directory?(dir) and File.exists?(dir + '/.git'))\n Dir.chdir dir\n\n status = `git status`\n if (status.index('nothing to commit, working directory clean') == nil)\n dirties_found = true\n output += \"\\n------------------------------\\n#{dir}\\n------------------------------\\n\"\n output += status + \"\\n\"\n end\n Dir.chdir '..'\n end\n end # dir loop\n\n if(dirties_found)\n puts output\n else\n puts \"All working directories clean\"\n end\nend",
"def scan_dir(source_dir, target_dir)\n @stats.enter_directory(source_dir)\n\n Dir.foreach(File.join(@source_dir, source_dir)) do |filename|\n source_path_relative = File.join(source_dir, filename)\n source_path = File.join(@source_dir, source_path_relative)\n target_path_relative = File.join(target_dir, filename)\n target_path = File.join(@target_dir, target_path_relative)\n\n # What kind of beast is this?\n if filename == '.' || filename == '..'\n is_skipped_directory = true\n else\n if File.directory?(source_path)\n if (path_matches_skipped?(source_path_relative))\n is_skipped_directory = true\n else\n is_directory = true\n end\n else\n if filename_matches_pattern?(filename)\n if path_matches_exception?(source_path_relative)\n is_exception = true\n else\n is_match = true\n end\n else\n is_ignored = true\n end\n end\n end\n\n if is_skipped_directory\n # do nothing\n elsif is_directory\n scan_dir(source_path_relative, target_path_relative)\n elsif is_match\n @stats.record_scan_matching(filename)\n scan_file(source_path, filename)\n elsif is_exception\n @stats.record_known_exception(filename)\n else # not a match\n @stats.record_scan_non_matching(filename)\n end\n end\n end",
"def unneeded_files_in_destination\n requested_paths = files.map do |file|\n file.pkg_destination_path\n end\n\n existing_paths = FileFinders::Normal.new(destination_path).find_all('*')\n\n unnecessary_paths = existing_paths - requested_paths\n\n unnecessary_paths.select! do |path|\n !::File.directory?(File.join(destination_path, path))\n end\n\n unnecessary_paths\n end",
"def discover_cfgs\n Dir.glob(\"**/*/*.cfg\") \n end",
"def moves\n possible_moves = []\n\n self.move_dirs.each do |dir|\n num_steps = 1\n blocked = false\n\n until blocked\n next_step = [dir[0]*num_steps, dir[1]*num_steps]\n next_pos = [self.pos[0] + next_step[0], self.pos[1] + next_step[1]]\n\n break unless next_pos.all? { |i| i.between?(0,7) }\n\n if self.board[next_pos]\n blocked = true\n possible_moves << next_pos unless self.color == self.board[next_pos].color\n else\n possible_moves << next_pos\n num_steps += 1\n end\n end\n end\n\n possible_moves\n end",
"def removed_infections\n return [] unless prev_scan\n current_infections = scan.infections.collect{|infection| infection.file}\n prev_scan.infections.select{|infection| !current_infections.include?(infection.file)}\nend",
"def find_local_config\n dir = Dir.pwd\n\n local_config_files = []\n\n while dir != '/' && (dir =~ %r{[A-Z]:/}).nil?\n local_config_files.push(File.join(dir, '.doingrc')) if File.exist? File.join(dir, '.doingrc')\n\n dir = File.dirname(dir)\n end\n\n local_config_files.delete(config_file)\n\n local_config_files\n end",
"def on_new_investigation\n @file_path = processed_source.file_path\n @file_directory = File.dirname(@file_path)\n end",
"def on_new_investigation\n @file_path = processed_source.file_path\n @file_directory = File.dirname(@file_path)\n end",
"def findSequenceFiles()\n # Assumption - 1 directory per lane\n fileList = Dir[\"*_sequence.txt\"]\n\n if fileList.size < 1\n raise \"Could not find sequence files in directory \" + Dir.pwd\n elsif fileList.size == 1\n @isFragment = true\n @sequenceFiles = fileList\n elsif fileList.size == 2\n @isFragment = false # paired end read\n @sequenceFiles = fileList\n else\n raise \"More than two sequence files detected, perhaps from different reads in directory \" + Dir.pwd\n end\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 ls_report_dir(branch = proj_branch)\n files = proj.show(report_branch, report_path(branch)).split(\"\\n\")\n files.shift(2)\n files\n end",
"def run_on_changes(paths)\n if options[:all_on_change]\n paths = Watcher.match_files(self, Dir.glob('**{,/*/**}/*').uniq.compact)\n end\n paths = paths.select {|path| not options[:exclude] =~ path and File.file? path}\n\n directories = detect_nested_directories(watchers, paths, options)\n written = []\n\n directories.each do |directory, files|\n files.each do |file|\n begin\n act_on(directory, file)\n written << file\n rescue Exception => e\n error(e.message, file)\n throw :task_has_failed\n end\n end\n end\n if written.length > 0\n notify(written)\n end\n end",
"def new_dirs\n @new_dirs ||= new_files.flat_map { |file| parent_dirs(file) }.to_set\n end",
"def find_files(recusive,sort)\n ext_list = $config[\"series\"][\"media_extentions\"].gsub(/,/,\"|\")\n files = [] \n if File.directory? sort\n Find.find(sort) do |path|\n next if File.dirname(path) != sort and not recusive\n next if File.directory? path\n next if File.basename(path) =~ /^\\./\n next if path !~ /#{ext_list}$/\n files << path\n end\n else\n log(\"error: source directory of \\\"#{sort}\\\" does not exist!\")\n exit 2\n end\n files\nend",
"def graph\n begin\n FileUtils.mkdir_p self.location_of_graphs unless Dir.exist? self.location_of_graphs\n first = ::Ms::ComparisonGrapher.slice_matches self.msrun_firsts\n second = ::Ms::ComparisonGrapher.slice_matches self.msrun_seconds\n files = ::Ms::ComparisonGrapher.graph_matches first, second, self.location_of_graphs\n rescue StandardError => e\n Rails.logger.error \"Graphing failed inside Comparison#graph. Ruh oh! #{e.class}: #{e.message} \\n#{e.backtrace}\"\n Alert.create({ :email => false, :show => true, :description => \"Error creating the comparison graphs.\" })\n FileUtils.remove_dir self.location_of_graphs if Dir.exist? self.location_of_graphs\n end\n end",
"def clear_finished\n unfinished = File.readlines(@@logs[:working])-File.readlines(@@logs[:metrics])\n unfinished.each do |f|\n\tadd_working(f)\n end\n end",
"def pop_dir\n return # 2014-07-25 - 22:43 \n # the first time we pop, we need to put the current on stack\n if !$visited_dirs.index(Dir.pwd)\n $visited_dirs.push Dir.pwd\n end\n ## XXX make sure thre is something to pop\n d = $visited_dirs.delete_at 0\n ## XXX make sure the dir exists, cuold have been deleted. can be an error or crash otherwise\n $visited_dirs.push d\n Dir.chdir d\n $filterstr ||= \"M\"\n $files = `zsh -c 'print -rl -- *(#{$sorto}#{$hidden}#{$filterstr})'`.split(\"\\n\")\n post_cd\nend",
"def find_all_paths\n found_paths = []\n \n explore(found_paths, nil, @start_node)\n \n found_paths\n end",
"def find_dead_tracks playlist\n playlist.fileTracks.each do |track|\n next unless track.location == nil\n puts \"Dead track: #{track.databaseID}: #{track.artist}/#{track.album}/#{track.name}\"\n @logger.info \"Dead track: #{track.databaseID}: #{track.artist}/#{track.album}/#{track.name}\"\n #@dead_track_list << track\n end\n \n #return @dead_track_list\n end"
] | [
"0.7384019",
"0.7383591",
"0.5291802",
"0.51977974",
"0.519609",
"0.5167115",
"0.51391",
"0.5094661",
"0.5057069",
"0.5057069",
"0.5047378",
"0.5021727",
"0.5009236",
"0.50038844",
"0.49701357",
"0.4964281",
"0.49566543",
"0.4933121",
"0.49323624",
"0.49286696",
"0.49044466",
"0.48937815",
"0.48706013",
"0.48690218",
"0.48638576",
"0.48336038",
"0.4830873",
"0.48299032",
"0.48287636",
"0.48174262",
"0.48013434",
"0.47708693",
"0.47627005",
"0.47521865",
"0.4716759",
"0.4707005",
"0.46957985",
"0.46932012",
"0.46900654",
"0.4686107",
"0.46808252",
"0.4675047",
"0.4650379",
"0.46441713",
"0.46421757",
"0.4597719",
"0.45836464",
"0.4582189",
"0.4575507",
"0.45663762",
"0.45498154",
"0.45405078",
"0.45389494",
"0.45389494",
"0.45359167",
"0.4535631",
"0.45354876",
"0.4512152",
"0.4505252",
"0.45005733",
"0.449997",
"0.44893223",
"0.44880918",
"0.44832206",
"0.44821572",
"0.44816977",
"0.44784024",
"0.4477943",
"0.4472291",
"0.44715708",
"0.44684705",
"0.44653657",
"0.44477963",
"0.4445881",
"0.44432902",
"0.44351828",
"0.44344017",
"0.44269586",
"0.44219664",
"0.4421311",
"0.44197246",
"0.44179434",
"0.44158575",
"0.4399219",
"0.43811348",
"0.43795192",
"0.4374456",
"0.43737423",
"0.43737423",
"0.4369267",
"0.43691513",
"0.43611726",
"0.4361167",
"0.43588525",
"0.4344366",
"0.43426985",
"0.43354592",
"0.43277493",
"0.43273726",
"0.43266022"
] | 0.7258376 | 2 |
Method to determine if a flowcell can be cleaned or not. For a flowcell to be cleaned, all of the following conditions must be true : 1) Marker file ".rsync_finished" must be present 2) It must have been modified 20 days ago (i.e. 1728000 seconds earlier) 3) The flowcell must not have been cleaned earlier (i.e., it must have L001 through L008 directories in its Data/Intensities directory | def isAvailableForCleaning(fcName)
markerName = fcName + "/.rsync_finished"
if File::exist?(markerName)
modTime = File::mtime(markerName)
timeDiff = (Time.now- modTime)
intensityLaneDir = fcName + "/Data/Intensities/L00*"
intensityLaneDir = Dir[fcName + "/Data/Intensities/L00*"]
# If intensitiy directory has directories L001 through L008 and
# modification time of .rsync_finished is 20 days (i.e. 1728000 seconds)
# that flowcell is available for cleaning.
# Please note: To change the interval of when a flowcell becomes a
# candidate flowcell for cleaning, please change the number below.
if intensityLaneDir != nil && intensityLaneDir.length > 0 && (timeDiff > 1728000)
return true
end
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fcReady?(fcName)\n if File::exist?(@instrDir + \"/\" + fcName + \"/.rsync_finished\")\n return true\n end\n \n if fcName.match(/SN601/) || fcName.match(/SN166/) \n puts \"Flowcell \" + fcName + \" is not configured for automatic analysis\"\n return false\n end\n\n # If the marker file RTAComplete.txt was written more than 1 hour ago, then\n # add the new marked file and return.\n if File::exist?(@instrDir + \"/\" + fcName + \"/RTAComplete.txt\")\n cmd = \"touch \" + @instrDir + \"/\" + fcName + \"/.rsync_finished\"\n `#{cmd}`\n end\n return false\n end",
"def should_process? \n #return false if it has been set to skip processing \n return false if self.persistence_checksum.eql?(\"skip\")\n\n #return true if there are different number of craft files than records of craft that are not marked as deleted\n craft_files = campaigns_instance.identify_craft_in(self.name)\n craft = self.craft.where(:deleted => false) #if craft.nil?\n return true if craft_files.map{|k,v| v}.flatten.size != craft.count\n\n #return true if the stored checksum for persistent.sfs does not match the one generated for the current persistent.sfs\n Dir.chdir(self.path)\n return true unless File.exists?(\"persistent.sfs\")\n checksum = Digest::SHA256.file(\"persistent.sfs\").hexdigest\n not checksum.eql?(self.persistence_checksum)\n end",
"def check_clean_status_task\n raise \"The current working copy contains modifications\" if `#{git} ls-files -m`.split(\"\\n\").any?\n end",
"def valid_repair\n is_valid = true\n if done_change == [0, 1]\n if done_was > 0\n errors.add :done, :already_done\n is_valid = false\n # else\n # repair_tasks.each do |repair_task|\n # repair_task.repair_parts.each do |repair_part|\n # if repair_part.store.present?\n # if repair_part.store_item(repair_part.store).quantity < (repair_part.quantity + repair_part.defect_qty)\n # errors[:base] << I18n.t('device_tasks.errors.insufficient_spare_parts', name: repair_part.name)\n # is_valid = false\n # end\n # else\n # errors.add :base, :no_spare_parts_store\n # is_valid = false\n # end\n # end\n # if repair_task.repair_parts.sum(:defect_qty) > 0 and (Department.current.defect_sp_store.nil?)\n # errors.add :base, :no_defect_store\n # is_valid = false\n # end\n # end\n end\n end\n is_valid\n end",
"def check_files\n @files.delete_if do |file|\n if File.exist? file then\n if File.readable? file then\n false\n else\n warn \"file '#{file}' not readable\"\n\n true\n end\n else\n warn \"file '#{file}' not found\"\n\n true\n end\n end\n end",
"def is_removable?\n\t\tself.clusters.empty? and self.network_switch_ports.empty? and self.pdus.empty? and self.sans.empty? and self.serial_consoles.empty?\n\tend",
"def perform_check?(tmp_filename, interval)\n !File.exist?(tmp_filename) || (Time.now >= (File.mtime(tmp_filename) + (interval * 60)))\nend",
"def is_valid_for_execution\n (@metadata[\"short_dest_repo_name\"] == \"osrf/gazebo\" and @pr_status == :update) ? false : true\n end",
"def check_change (conf, curDir)\n Dir.chdir curDir\n return true unless File.exist?(FileStats)\n arr = IO.read(FileStats).split(\",\")\n return true if arr[0].to_i != conf[:fsize]\n return true if conf[:modTS ].to_i > Time.parse(arr[1]).to_i \n false\nend",
"def rerunNeeded? ( timestampFilePath , rerunEach )\n\n isNeeded = true\n\n # Checking if timestamp file already exists\n if (File.exist?(timestampFilePath))\n timestampFile = File.new(timestampFilePath, \"r\")\n firstLine = timestampFile.gets\n previousTimestamp = firstLine.nil? ? 0 : firstLine.to_i\n isNeeded = (Time.now.to_i - previousTimestamp) > rerunEach\n end\n\n if (isNeeded)\n FileUtils.mkdir_p(File.dirname(timestampFilePath))\n timestampFile = File.new( timestampFilePath , \"w\" )\n timestampFile.write(Time.now.to_i.to_s+\"\\n\")\n timestampFile.close\n end\n \n return isNeeded\n\n end",
"def integrity_check\n start_values = condition.start_values\n generations.each do |g|\n # FIXME -- use the registered fitness function\n if IterativeLearning::FunctionLearning.sum_of_error(g.start_values, start_values) != 0\n return false\n end\n start_values = g.best_task_response\n end\n return true\n end",
"def dirty?\n return true unless test(?e, destination)\n @mtime > ::File.mtime(destination)\n end",
"def valid?\n ensure_file_open!\n\n ['Makefile', 'submission/', 'tests/'].all? { |entry| @file.find_entry(entry).present? }\n end",
"def roll_required?\n return false if ::File.exist?(@fn_copy) and (Time.now - ::File.mtime(@fn_copy)) < 180\n\n # check if max size has been exceeded\n s = @size ? ::File.size(@fn) > @size : false\n\n # check if max age has been exceeded\n a = sufficiently_aged?\n\n return (s || a)\n end",
"def has_listed_files?\n file_count = 0\n all_valid = true\n files_file_path = FileLocations.files_file_path(@source_dir)\n ::CSV.foreach(files_file_path, headers: true).each do |csv_row|\n next if csv_row.blank?\n # Each file listed in FILES.csv should be valid\n row = strip_csv_row(csv_row)\n file_count += 1\n all_valid = all_valid && has_valid_file?(row, file_count)\n end\n # FILES.csv should have atleast 1 row\n unless file_count > 0\n @errors << \"Metadata file #{files_file_path} has no rows\"\n all_valid = false\n end\n # There should be no unverified files\n all_valid\n end",
"def need_sync?\n if is_ignored || err_count >= MAX_SYNC_ERR\n false\n elsif last_sync == DUMMY_TIMESTAMP\n true\n else\n case sync_type.to_sym\n when :SYNC_UP\n clab_id.nil? || ext_last_update > last_sync\n when :SYNC_DOWN\n ext_obj_id.nil? || clab_last_update > last_sync\n else\n raise SyncError, 'sync mode not supported'\n end\n end\n end",
"def check_for_workdays\n if not work_days.empty?\n errors.add(:base, :cannot_delete)\n return false\n end\n end",
"def logCheckUsable(logfileTail)\n\n lastFrame = -1\n currentFrame = -1\n fileStatus = Hash[\"finishedRestartVel\" => false,\n \"wroteRestartVel\" => false,\n \"wroteRestartXsc\" => false,\n \"finishedRestartCoor\" => false,\n \"wroteRestartCoor\" => false,\n \"wroteDcd\" => false]\n \n # Use tail to get last lines of logfile \n #print \"logfileTail: #{logfileTail}\\n\"\n tailList = logfileTail.split(\"\\n\").reverse\n\n # Grab the last set of written restart files\n tailList.each do |i|\n if i =~ /FINISHED WRITING RESTART VELOCITIES/ then\n #print \" finishedRestartVel\\n\"\n fileStatus[\"finishedRestartVel\"] = true\n elsif i =~ /WRITING VELOCITIES TO RESTART FILE AT STEP (\\d+)/ then\n #print \" wroteRestartVel\\n\"\n fileStatus[\"wroteRestartVel\"] = true\n currentFrame = $1.to_i\n elsif i =~ /WRITING EXTENDED SYSTEM TO RESTART FILE AT STEP (\\d+)/ then\n #print \" wroteRestartXsc\\n\"\n fileStatus[\"wroteRestartXsc\"] = true\n currentFrame = $1.to_i\n elsif i =~ /FINISHED WRITING RESTART COORDINATES/ then\n #print \" finishedRestartCoor\\n\"\n fileStatus[\"finishedRestartCoor\"] = true\n elsif i =~ /WRITING COORDINATES TO RESTART FILE AT STEP (\\d+)/ then\n #print \" wroteRestartCoor\\n\"\n fileStatus[\"wroteRestartCoor\"] = true\n currentFrame = $1.to_i\n elsif i =~ /WRITING COORDINATES TO DCD FILE AT STEP (\\d+)/ then\n #print \" wroteDcd\\n\"\n fileStatus[\"wroteDcd\"] = true\n currentFrame = $1.to_i\n end\n \n if (lastFrame < 0) & (currentFrame > 0) then\n lastFrame = currentFrame\n elsif lastFrame != currentFrame then\n print \" missing\\n\"\n fileStatus.each_pair do |key,val|\n if !val then\n print \" #{key}\\n\"\n end\n end\n print \" currentFrame: #{currentFrame}\\n\"\n print \" lastFrame: #{lastFrame}\\n\"\n return \"broken\"\n end\n\n fileStatusCount = 0\n fileStatus.each_value do |i|\n if i then\n fileStatusCount += 1\n end\n end\n\n if fileStatusCount == 6 then\n print \" last frame: #{lastFrame}\\n\"\n return \"usable\"\n end\n end\n \n return \"unknown\"\nend",
"def stale?\n forecasts.empty? || (Time.now - data_file.mtime) > 14_400\n end",
"def already_being_processed?\n # if origional exists and destination has existed for 30s+\n # assume a previous run didn't get around to cleaning up the file\n if(File.exist?(@origional_file) && File.exist?(destination_file) && !recently_modified?(destination_file))\n $logger.info \"Found origional and transcoded file; moving origional\"\n move_origional_file\n return true\n end\n\n if File.exist? temp_file\n # if file has been modified in the last 30 seconds consider it in flight by another\n if recently_modified?(temp_file)\n $logger.info \" temp file modified recently (maybe by another process?) so skipping #{temp_file}\"\n return true\n else\n $logger.info \" temp file is old, deleting #{temp_file}\"\n File.delete temp_file\n end\n end\n false\n end",
"def clean_working_tree?\n rugged.status do |_file, status|\n next if status.include?(:ignored)\n return false\n end\n true\n end",
"def valid?\n create_update_rules.each do |rule|\n return false if !rule.file_exists || !rule.pattern_exists\n end\n\n true\n end",
"def check_shift_log\n if @shift_age.is_a?(Integer)\n # Note: always returns false if '0'.\n if @filename && (@shift_age > 0) && (@dev.stat.size > @shift_size)\n lock_shift_log { shift_log_age }\n end\n else\n now = Time.now\n period_end = previous_period_end(now)\n if @dev.stat.mtime <= period_end\n lock_shift_log { shift_log_period(period_end) }\n end\n end\n end",
"def dirty?\n return _meta_data['dirty'] if _meta_data.has_key? 'dirty'\n\n # if the destination file does not exist, then we are dirty\n return true unless test(?e, destination)\n\n # if this file's mtime is larger than the destination file's\n # mtime, then we are dirty\n dirty = @mtime > ::File.mtime(destination)\n return dirty if dirty\n\n # check to see if the layout is dirty, and if it is then we\n # are dirty, too\n if _meta_data.has_key? 'layout'\n lyt = ::Webby::Resources.find_layout(_meta_data['layout'])\n unless lyt.nil?\n return true if lyt.dirty?\n end\n end\n\n # if we got here, then we are not dirty\n false\n end",
"def upload_needed\n setting = Device.find_by(id: params[:id])\n if setting.nil?\n render status:404, text: \"Device not found for device_id=\"+params[:id].to_s\n return\n elsif setting.token4write != params[:token]\n render status:404, text: \"Token did not match for device_id=\"+params[:id].to_s\n return\n end\n device_id = params[:id]\n\n f = \"#{BASEDIR}/#{device_id}/upload-needed.status\"\n if File.file?(f) && File.mtime(f) > Time.now - 30.second\n render text: \"Yes\", status: 200\n else\n render text: \"No\", status: 200\n end\n end",
"def folder_reachable?\n Dir.exists? folder_path\n end",
"def verify_valid_update\n if branch_merge\n verify_valid_branch_merge\n elsif !overwrite?\n verify_non_destructive\n end\n end",
"def file_uploaded_during_this_membership_term?\n return false unless current_member? || in_grace_period?\n\n if current_member?\n file_uploaded_on_or_after?(current_membership.first_day)\n else\n # is in_grace_period\n file_uploaded_on_or_after?(most_recent_membership.first_day) # FIXME is this correct?\n end\n end",
"def extract_in_progress?\n return false unless File.exist?(processing_archive_flag_path)\n\n if (Time.now - File.mtime(processing_archive_flag_path)) >= ProcessingRetryTime\n extract_completed!\n false\n else\n true\n end\n end",
"def clean?\n\t\treturn self.status == 'C'\n\tend",
"def has_failed_upload?\n num_uploads = tasks.upload.count\n num_complete_uploads = tasks.upload.with_status(Task::COMPLETE).count\n num_valid_uploads = tasks.upload.valid.count # i.e. not-cancelled\n num_cancelled_uploads = num_uploads - num_valid_uploads\n\n # easy cases first\n return false if num_uploads == 0\n return false if num_complete_uploads == num_uploads\n return false if num_complete_uploads > 1\n return true if num_cancelled_uploads == num_uploads\n\n return false # conservative default\n end",
"def check_files\n updated = []\n files.each do |filename, mtime| \n begin\n current_mtime = File.stat(filename).mtime\n rescue Errno::ENOENT\n # file was not found and was probably deleted\n # remove the file from the file list \n files.delete(filename)\n next\n end\n if current_mtime != mtime \n updated << filename\n # update the mtime in file registry so we it's only send once\n files[filename] = current_mtime\n puts \"quick_serve: spotted change in #{filename}\"\n end\n end\n QuickServe::Rails::Snapshot.reset if updated != []\n false\n end",
"def final_check_for_valid_sheetcells\n if has_invalid_values?\n self.finished = false\n save\n return false\n end\n\n self.finished = true\n save\n true\n end",
"def add_done_files_for_plagiarism_check_of(td, tmp_path, force, to_check)\n tasks = tasks_for_definition(td)\n tasks_with_files = tasks.select { |t| t.has_pdf }\n\n if td.group_set\n # group task so only select one member of each group\n seen_groups = []\n\n tasks_with_files = tasks_with_files.select do |t|\n if t.group.nil?\n result = false\n else\n result = ! seen_groups.include?(t.group)\n if result\n seen_groups << t.group\n end\n end\n result\n end\n end\n\n # check number of files, and they are new\n if tasks_with_files.count > 1 && (tasks.where(\"tasks.file_uploaded_at > ?\", last_plagarism_scan ).select { |t| t.has_pdf }.count > 0 || force )\n td.plagiarism_checks.each do |check|\n next if check[\"type\"].nil?\n\n type_data = check[\"type\"].split(\" \")\n next if type_data.nil? or type_data.length != 2 or type_data[0] != \"moss\"\n\n # extract files matching each pattern\n # -- each pattern\n check[\"pattern\"].split(\"|\").each do |pattern|\n tasks_with_files.each do |t|\n FileHelper.extract_file_from_done(t, tmp_path, pattern, lambda { | task, to_path, name | File.join(\"#{to_path}\", \"#{t.student.username}\", \"#{name}\") } )\n end\n MossRuby.add_file(to_check, \"**/#{pattern}\")\n end\n end\n end\n\n self\n end",
"def has_pushed_since_last_respin?(type)\n jobs = push_jobs_since_last_state(type, 'NEW_FILES').where('pub_task_id is not null')\n jobs.reject(&:is_nochannel?).any?(&:is_committed?)\n end",
"def valid?\n return false if @image.nil?\n return false if @image_id.nil?\n return false if @name.nil?\n return false if @ready.nil?\n return false if @restart_count.nil?\n return true\n end",
"def has_changes?\r\n @source_files.size > 0\r\n end",
"def file_list_is_ok?(errata)\n errata.brew_builds.any? &&\n errata.build_mappings.for_rpms.without_product_listings.empty? &&\n errata.build_mappings.for_rpms.without_current_files.empty?\n end",
"def fresh?\n last_compilation_digest&.== watched_files_digest\n end",
"def should_commit?(segregation)\n\t\tseg = @segregations[segregation]\n\t\tif @size_file > 0 and seg[:file_pointers][seg[:current_page]].size > @size_file\n\t\t\t@logger.info(\"S3> should_commit: upload because of size\")\n\t\t\treturn true\n\t\tend\n\n\t\treturn false\n\tend",
"def valid_for_deletion?\n return false if(id.nil? || sync_token.nil?)\n id.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0\n end",
"def valid_for_deletion?\n return false if(id.nil? || sync_token.nil?)\n id.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0\n end",
"def valid_for_deletion?\n return false if(id.nil? || sync_token.nil?)\n id.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0\n end",
"def valid_for_deletion?\n return false if(id.nil? || sync_token.nil?)\n id.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0\n end",
"def valid_for_deletion?\n return false if(id.nil? || sync_token.nil?)\n id.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0\n end",
"def valid_for_deletion?\n return false if(id.nil? || sync_token.nil?)\n id.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0\n end",
"def valid_for_deletion?\n return false if(id.nil? || sync_token.nil?)\n id.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0\n end",
"def all_cells_cleared?\n count_num_of_cells_cleared = @cleared_field.select{|key, value| value == true}.size\n total_cell_count = @column_count * @row_count\n cell_clear_check = total_cell_count - @mine_count == count_num_of_cells_cleared\n return true if !any_mines_detonated? && cell_clear_check\n false\n\n end",
"def file_unchanged?(js_name)\n # Start-Open3\n Open3.popen3(\"git status --short #{js_name}\") do |stdin, stdout, stderr|\n # Start-If: Check if job script in working dir is modified since last check-in\n if stdout.read.empty? \n return true\n else \n puts \"#{js_name} modified since last commit. Please commit changes to the repo and #{$0} again!\"\n return false\n end\n # End-If: Check if job script in working dir is modified since last check-in\n end\n # End-Open3\nend",
"def validate_markdown_repo\r\n validated = true\r\n\r\n @logger.info 'Validating if markdown files correspond to BWB list'\r\n Dir.chdir(MARKDOWN_FOLDER)\r\n all_paths = Dir['**/BWB*/README.md']\r\n all_files = {}\r\n all_paths.each do |path|\r\n m=/(.*\\/(BWB.*))\\/README\\.md/.match(path)\r\n if m\r\n all_files[m[2]] = m[1]\r\n else\r\n @logger.error \"ERROR: #{path} was not a proper path\"\r\n end\r\n end\r\n\r\n before_length = all_files.length\r\n puts \"#{before_length} documents in repo.\"\r\n i=0\r\n @index[LAW_LIST].each do |bwb_id, regeling_info|\r\n if all_files[bwb_id]\r\n regeling_info[JsonConstants::PATH] = all_files[bwb_id]\r\n end\r\n if bwb_id == 'BWBV0005981'\r\n puts bwb_id\r\n end\r\n unless (regeling_info[EXPIRATION_DATE] and regeling_info[EXPIRATION_DATE] <= @today) or File.exists? \"#{regeling_info[JsonConstants::PATH]}/README.md\"\r\n @logger.error \"ERROR: #{regeling_info[JsonConstants::PATH]} did not exist at #{regeling_info[JsonConstants::PATH]}/README.md, but should exist according to BwbIdList\"\r\n validated = false\r\n end\r\n # Remove element from map; it exists\r\n doc_path = File.expand_path(regeling_info[JsonConstants::PATH])\r\n if File.exist? doc_path\r\n all_files[bwb_id] = nil\r\n end\r\n\r\n i+=1\r\n\r\n if i % 1000 == 0\r\n puts \"Checked #{i} docs\"\r\n end\r\n end\r\n pruned = []\r\n all_files.each do |_, doc_path|\r\n if doc_path\r\n pruned << doc_path\r\n end\r\n end\r\n\r\n puts \"#{before_length - pruned.length} documents existed rightfully.\"\r\n\r\n if pruned.length > 0\r\n validated = false\r\n puts \"But we are still left with #{pruned.length} documents that don't exist anymore in the BwbIdList, but do exist as files.\"\r\n pruned.each do |doc_path|\r\n puts doc_path\r\n # File.delete doc_path\r\n end\r\n end\r\n\r\n # delete_empty_folders\r\n Dir.chdir('..')\r\n\r\n validated\r\n end",
"def checksum_valid?\n Digest::SHA256.file(path).hexdigest == sha256sum\n end",
"def completed?\n !self.shift_jobs.empty?\n end",
"def automatic_update_check_allowed?\n check_path = directory.join(\"box_update_check\")\n if check_path.exist?\n last_check_span = Time.now.to_i - check_path.mtime.to_i\n if last_check_span < BOX_UPDATE_CHECK_INTERVAL\n @logger.info(\"box update check is under the interval threshold\")\n return false\n end\n end\n FileUtils.touch(check_path)\n true\n end",
"def has_unused_files?\n unused_files = submitted_data_files - @checked_files_in_metadata\n # log error if unused files exist\n if unused_files.any?\n metadata_file_path = FileLocations.metadata_file_path(@source_dir)\n @errors << \"There are files in the submission not listed in #{metadata_file_path} and so not used.\"\n @errors += unused_files.map { |e| \" - #{e}\" }\n end\n unused_files.any?\n end",
"def valid_fc_target?\n dell_server? &&\n !brownfield? &&\n has_related_storage? &&\n related_storage_volumes.map(&:fc?).all?\n end",
"def already_uploaded_this_acf?(nmd)\n !ReadyForShipmentBatch.find_by_acf_integrity_hash(nmd.integrity_hash).nil?\n end",
"def not_contended_with_reqs\n obj_ptr_re = /\\[\\d{1},(.*)\\]/\n reqsRW_re = /reqsRW:\\<(.*)\\>/\n locRW_re = /\\locRW\\:(.?)\\,/\n contended_re = /contended\\:(.?)\\,/\n count = 0\n $arr_local_store.each do |local_file|\n local_file.each do |line|\n unless line.chomp.empty?\n obj_ptr = line.match(obj_ptr_re)\n lockRW = line.match(locRW_re)\n reqsRW = line.match(reqsRW_re)\n reqs_arr = reqsRW[1].split(/,/)\n contended = line.match(contended_re)\n #if lockRW is empty, it should be contended locally\n if lockRW[1].eql?\"\" and reqs_arr.size > 0\n if contended[1].to_i == 0\n p \"OMG! #{count} has an object #{obj_ptr} , which is needed by remote hosts #{reqs_arr} and is not locally contended\"\n end\n end\n end\n end\n count = count + 1\n end\nend",
"def valid_for_deletion?\n return false if(id.nil? || sync_token.nil?)\n id.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0\n end",
"def removed?\n !File.exist?(path)\n end",
"def ready_to_create?\n valid? && processed? && import_level_ok?\n end",
"def checkErroredStatus\n case @stage\n when DOWNLOAD\n $log.info{ \"check downloaded file. @downNG=#{@downNG}\" }\n return true if @downNG\n rawFileError?\n when CONVERT\n outFileError?\n else\n true\n end\n end",
"def finalize_sync_operation\n puts \" - Transferred the following #{ @st_ops_cache_file.keys.count } st_ops versions to foreign repos:\"\n @st_ops_cache_file.keys.each { |from_git_commit, to_git_commit|\n puts \" - #{ from_git_commit } to #{ to_git_commit }\"\n }\n if @successful_files_with_st_ops.any?\n puts \" - The following #{ @successful_files_with_st_ops.count } files with st operations were synced successfully:\".color(:green)\n @successful_files_with_st_ops.each { |file_path| puts \" - #{ file_path }\" }\n else\n puts \" - No files with st operations were synced successfully\".color(:red)\n end\n if @successful_files_with_autosplit.any?\n puts \" - The following #{ @successful_files_with_autosplit.count } files with autosplit were synced successfully:\".color(:green)\n @successful_files_with_autosplit.each { |file_path| puts \" - #{ file_path }\" }\n else\n puts \" - No files with autosplit were synced successfully\".color(:red)\n end\n if @successful_files_without_st_ops.any?\n puts \" - The following #{ @successful_files_without_st_ops.count } files without st operations were synced successfully:\".color(:green)\n @successful_files_without_st_ops.each { |file_path| puts \" - #{ file_path }\" }\n else\n puts \" - No files without st operations were synced successfully\".color(:red)\n end\n if @unprocessable_files.any?\n puts \" - The following #{ @unprocessable_files.count } files could not be synced:\".color(:red)\n @unprocessable_files.each { |f_attrs|\n print \" - #{ f_attrs[:file].repo_relative_path(true) }: \".ljust(52).color(:red)\n puts \"#{ f_attrs[:message] }\".color(:red)\n }\n else\n puts \" - All file syncs were successful!\".color(:green)\n end\n if @files_with_autosplit_exceptions.any?\n puts \" - The following #{ @files_with_autosplit_exceptions.count } files raised an exception during autosplit:\".color(:red)\n @files_with_autosplit_exceptions.each { |f_attrs|\n print \" - #{ f_attrs[:file].repo_relative_path(true) }: \".ljust(52).color(:red)\n puts \"#{ f_attrs[:message] }\".color(:red)\n }\n else\n puts \" - No files raised exceptions during autosplit\".color(:green)\n end\n if @files_with_subtitle_count_mismatch.any?\n puts \" - The following #{ @files_with_subtitle_count_mismatch.count } files were synced, however their subtitle counts don't match:\".color(:red)\n @files_with_subtitle_count_mismatch.each { |f_attrs|\n print \" - #{ f_attrs[:file].repo_relative_path(true) }: \".ljust(52).color(:red)\n puts \"#{ f_attrs[:message] }\".color(:red)\n }\n else\n puts \" - All synced files have matching subtitle counts.\".color(:green)\n end\n true\n end",
"def valid_cg_directory?\n valid = true\n list = ['Rules', 'nanoc.yaml', 'content', 'lib']\n list.each do |filename|\n unless File.exist?(filename)\n valid = false\n say(\"Required file not found: #{filename}\")\n end\n end\n valid\n end",
"def fresh?\n watched_files_digest == last_compilation_digest\n end",
"def tasks_remain?\n\t\ttasks.any?{ |t| t.completed.nil? }\n\tend",
"def completed?\n child_files = self.bundled_files\n child_file_types = child_files.map {|file| file['file_type']}\n if child_file_types.size < BUNDLE_REQUIREMENTS[self.bundle_type].size || ( (child_file_types.size == BUNDLE_REQUIREMENTS[self.bundle_type].size) &&\n (child_file_types & BUNDLE_REQUIREMENTS[self.bundle_type] != child_file_types))\n return false\n end\n if child_file_types.size > BUNDLE_REQUIREMENTS[self.bundle_type].size\n return false\n end\n # make sure all files have at least uploaded to the server\n self.study_files.each do |study_file|\n if !study_file.uploaded?\n return false\n end\n end\n true\n end",
"def valid_checksums?\n \n p = package_path\n files.each do |f|\n file_path = File.join(p, f[:path])\n \n if File.exist?(file_path)\n digest = Digest::SHA1.hexdigest(File.read(file_path))\n errors.add :checksum_validity, \"Digest for #{file_path} in AIP does \" +\n \"not match\" unless digest == f[:sha_1]\n end \n \n end\n \n errors.on(:checksum_validity).nil?\n \n end",
"def removed?\n files.all? { |f| !File.exist?(f) }\n end",
"def destroyable?\n if self.master_files.empty? and self.components.empty? and self.bibls.empty?\n return true\n else\n return false\n end \n end",
"def valid_for_deletion?\n return false if id.nil? || sync_token.nil?\n id.value.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0\n end",
"def fully_copied?(item)\n base = File.basename(item.to_s.chomp)\n cmd = \"#{@rsync_cmd} --dry-run #{@origin}/#{base} #{@dst}\"\n SingleLogger.instance.info cmd\n r_output = `#{cmd}`\n lines = r_output.split(\"\\n\")\n lines.size == 4 && lines[1] == \"\"\n end",
"def destination_file_exist?\n File.exist?(final_destination_path)\n end",
"def valid_for_deletion?\n return false if(id.nil? || sync_token.nil?)\n id.value.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0\n end",
"def changed?(file_stats)\n not (file_stats.size == size and file_stats.mtime.utc == modification_time.utc)\n end",
"def clean_working_directory_check\n commit_count_check = `git status`\n if (!(commit_count_check.include? \"Your branch is up-to-date with 'origin/master'.\") &&\n !(commit_count_check.include? \"nothing to commit, working directory clean\")) ||\n (commit_count_check.include? \"Changes not staged for commit:\")\n abort(\"ABORTING... please commit and push any local changes before atte\"\\\n \"mpting to create a new tag\")\n end\n end",
"def check_for_changes\n\t\t\t# Check on disk changes\n\t\t\tunless @disks[0][:changes] == false\n\t\t\t\t\t$log.info \"Cachefile changed by user. Honoring changes.\"\n\t\t\t\t\t@disks[0][:changes] = false\n\t\t\t\t\twrite_disk_cache\n\t\t\t\t\treturn true\n\t\t\tend\n\t\t\treturn false\n\t\tend",
"def file_is_physically_present?\n field.file.size > 0\n end",
"def has_valid_owners_for_all_files?\n num_owned_by_wlmaster = num_files_owned_by_user('wlmaster')\n num_owned_by_wluser = num_files_owned_by_user('wluser')\n num_total = num_files_total\n # if all the files are owned by either 'wlmaster' or 'wluser', then\n # num_total must be equal to the sum of num_owned_by_wlmaster and num_owned_by_wluser.\n # If this condition is not matched, that means, there is at least one file\n # or directory, which is not owned by either of them.\n num_total == (num_owned_by_wlmaster + num_owned_by_wluser)\n end",
"def check_frozen\n if rec_was_frozen && changed? then\n errors.add( :base, I18n.t( 'cfr_records.msg.frozen_rec' ))\n return false\n else\n return true\n end\n end",
"def check_mandatory!\n if options.work_dir.nil?\n kill \"missing file operand\"\n end\n if options.contents_template.nil?\n kill \"could not find contents template\"\n end\n end",
"def good?\n @bad_files.nil? || @bad_files.empty?\n end",
"def findRunFinishedDate(seqName, fcName)\n foundFCDir = false\n foundRunFinishedDate = false\n\n @instrumentDir.each do |instDir|\n searchPath = instDir + seqName\n\n if File::directory?(searchPath)\n fcPaths = getFlowcellDirectoryNames(searchPath, fcName)\n\n fcPaths.each do |fcPath|\n if File::directory?(fcPath)\n runFinishedMarkerFile = fcPath + \"/RTAComplete.txt\"\n foundFCDir = true\n if File::exist?(runFinishedMarkerFile)\n creationTime = File::ctime(runFinishedMarkerFile).strftime(\"%Y-%m-%d\")\n foundRunFinishedDate = true\n return creationTime.to_s\n end\n end\n end\n end\n end\n \n if foundFCDir == false\n return \"INVALID_FLOWCELL\"\n elsif foundRunFinishedDate == false\n return \"NONE\"\n end\n end",
"def check_transferred?(rname, done_slides)\n Helpers::log(\"Checking if #{rname} has been transferred\")\n dir = File.dirname(done_slides)\n if File.directory?(dir) && File.exist?(done_slides)\n known = File.open(done_slides).readlines.map!{ |e| e.chomp }\n return known.include?(rname)\n end\n FileUtils.mkdir_p(dir)\n File.new(done_slides, \"w\")\n return FALSE\n end",
"def exam_been_uploaded?\n self.split_pdf_logs.exists?\n end",
"def check_freshness!(sftp_session, remote_file_name)\n return nil unless options.fetch(:check_freshness, true)\n\n within_n_days = options.fetch(:modified_within_n_days, 3)\n time_now = options.fetch(:time_now, Time.now)\n threshold_time = time_now - within_n_days.days\n sftp_session.lstat(remote_file_name) do |response|\n mtime = Time.at(response.data[:attrs].mtime)\n if mtime < threshold_time\n basename = File.basename(remote_file_name)\n Rollbar.error(\"SftpClient#check_freshness! failed for remote file, basename: #{basename}, last modified: #{mtime.to_i}\")\n end\n end\n nil\n end",
"def content_file_checksums_match?\n checksum_failures = \"\"\n described_datafiles.each do |datafile|\n info = datafile.checksum_info\n\n if File.exists?(datafile.datapath) == false\n checksum_failures << \"#{datafile['sip-path']} - missing; \"\n elsif info[0] != info[1]\n checksum_failures << \"#{datafile['sip-path']} - expected: #{info[0]} computed: #{info[1]}; \"\n else\n next\n end\n end\n\n if checksum_failures.length > 0\n metadata[\"checksum_failures\"] = checksum_failures\n return false\n else\n return true\n end\n end",
"def check_condition \n\t\tnumber_rule = 0\n\t\tnew_path = Array.new(6) {elem = 0}\n\t\ti = 0\n\t\tj = 0\n\t\tn = 1\n\t\t\n\t\twhile i < 6\n\t\t\tif @path[@last_position[0]][@last_position[1]][i] == 'nil'\n\t\t\t\t@path[@last_position[0]][@last_position[1]][i] = 0\n\t\t\tend\n\t\t\t\n\t\t\tif @path[@last_position[0]][@last_position[1]][i] == 1\n\t\t\t\tn = i - @direction \n\t\t\t\tnew_path[(n.abs % 6 )] = 1 \n\t\t\tend\n\t\t\t\n\n\t\t\ti += 1\n\t\tend\n\t\ti = 0\n\t\t\n\t\twhile i < @count_rule\n\t\t\t#puts \"count_rule: #{@count_real_rule}\"\n\t\t\n\t\t\tif new_path == @rule_status[i]\n\t\t\t\treturn i\n\t\t\tend\n\t\t\t\n\t\t\ti += 1\n \t\tend\n \t\tif (@count_real_rule == @count_rule)\n \t\t\treturn 8\n \t\telse\n\t\t\t@rule_status[@count_real_rule] = new_path \n\t\t\t@count_real_rule += 1\n\t\t\tcheck_condition\n\t\tend\n\tend",
"def failed_full_sync_required?\n\t\t\treturn request_status == REQUEST_STATUS['failed_full_sync_required']\n\t\tend",
"def removed?\n\t\treturn self.status == 'R'\n\tend",
"def stuck?\n\t\t[ :N, :E, :S, :W ].each do |dir|\n\t\t\treturn false if can_pass? dir\n\t\tend\n\n\t\ttrue\n\tend",
"def movement_validation(player_mov)\n\t\tcorrect_mov = []\n\t\tpiece_movs = {\n\t\t\t\"king\" => [[0,1], [1,1], [1,0], [1,-1], [0,-1], [-1,-1], [-1,0], [-1,1]],\n\t\t\t\"knight\" => [[-2,1], [-2,-1], [-1,-2], [1,-2], [2,-1], [2,1], [1,2], [-1,2]],\n\t\t\t\"rook\" => [[0,1], [1,0], [0,-1], [-1,0]],\n\t\t\t\"bishop\" => [[1,1], [1,-1], [-1,-1], [-1,1]],\n\t\t\t\"queen\" => [[0,1], [1,1], [1,0], [1,-1], [0,-1], [-1,-1], [-1,0], [-1,1]],\n\t\t\t\"pawn\" =>\t[[0,1], [0,-1], [1,1], [-1,1], [1,-1], [-1,-1], [0,2], [0,-2]]\n\t\t}\n\t\t\n\t\t#if the final move equals to one of the moves of the king or knight pieces.\n\t\tif [\"king\", \"knight\"].include?(@piece_name)\n\t\t\t#iterates through each basic move of the corresponding piece.\n\t\t\tpiece_movs[@piece_name].each do |mov|\n\t\t\t\t#if the final node color is nil or different from the start node color.\n\t\t\t\tif mov == player_mov && (@final_node.color != @current_player.color || @final_node.color == nil)\n\t\t\t\t\treturn true\n\t\t\t\t#if check analysis is in progress, the final node color equals to the current player color and the final node name is king.\n\t\t\t\telsif (mov == player_mov && @check_on_curse == true) && (@final_node.color == @current_player.color && @final_node.name == \"king\") \n\t\t\t\t\treturn true\t\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\t#if the final move equals to one of the moves of the rook, bishop or queen pieces.\n\t\telsif [\"rook\", \"bishop\", \"queen\"].include?(@piece_name)\n\t\t\t#iterates through each basic move of the corresponding piece.\n\t\t\tpiece_movs[@piece_name].each do |mov|\n\t\t\t\t#iterates through number 1 to 7 multiplying the basics pieces moves and saving it.\n\t\t\t\t(1..7).each do |num|\n\t\t\t\t\titeration = [mov[0]*num, mov[1]*num]\n\t\t\t\t\t#if the final move equals to multiplication of a basic move by a certain number and the way to the destination square is clear.\n\t\t\t\t\tif iteration == player_mov && cleared_way?(mov) == true\t\t\t\n\t\t\t\t\t\treturn true\t\t\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t#if start node name is a pawn piece.\n\t\telsif @piece_name == \"pawn\"\n\t\t\t#one positive rank move from a white piece to a nil node.\n\t\t\tif piece_movs[\"pawn\"][0].include?(player_mov) && (@final_node.color == nil && @start_node.color == \"white\")\n\t\t\t\treturn true\n\t\t\t#one negative rank move from a black piece to a nil code.\n\t\t\telsif piece_movs[\"pawn\"][1].include?(player_mov) && (@final_node.color == nil && @start_node.color == \"black\")\n\t\t\t\treturn true\t\n\t\t\t#a positive diagonal move from a white piece to a node of the opponent color.\t\n\t\t\telsif (piece_movs[\"pawn\"][2..3].include?(player_mov) && @start_node.color == \"white\") && (@final_node.color != @current_player.color && @final_node.color != nil)\n\t\t\t\treturn true\t\n\t\t\t#a negative diagonal move from a black piece to a node of the opponent color.\n\t\t\telsif (piece_movs[\"pawn\"][4..5].include?(player_mov) && @start_node.color == \"black\") && (@final_node.color != @current_player.color && @final_node.color != nil)\n\t\t\t\treturn true\n\t\t\t#a double positive rank move from a white piece on rank 2 position to a nil color node.\n\t\t\telsif (piece_movs[\"pawn\"][6] == player_mov && @final_node.color == nil) && (@start_node.color == \"white\" && @first_coord_convertion[1] == \"2\")\n\t\t\t\treturn true\n\t\t\t#a double negative rank move from a black piece on rank 7 position to a nil color node.\n\t\t\telsif (piece_movs[\"pawn\"][7] == player_mov && @final_node.color == nil) && (@start_node.color == \"black\" && @first_coord_convertion[1] == \"7\")\n\t\t\t\treturn true\t\n\t\t\tend\n\t\tend\n\t\treturn false\n\tend",
"def can_launch_ingest?\n case study_file.file_type\n when /Matrix/\n # expression matrices currently cannot be ingested in parallel due to constraints around validating cell names\n # this block ensures that all other matrices have all cell names ingested and at least one gene entry, which\n # ensures the matrix has validated\n other_matrix_files = study.expression_matrices.where(:id.ne => study_file.id)\n # only check other matrix files of the same type, as this is what will be checked when validating\n similar_matrix_files = other_matrix_files.select {|matrix| matrix.is_raw_counts_file? == study_file.is_raw_counts_file?}\n similar_matrix_files.each do |matrix_file|\n if matrix_file.parsing?\n matrix_cells = study.expression_matrix_cells(matrix_file)\n matrix_genes = Gene.where(study_id: study.id, study_file_id: matrix_file.id)\n if !matrix_cells || matrix_genes.empty?\n # return false if matrix hasn't validated, unless the other matrix was uploaded after this file\n # this is to prevent multiple matrix files queueing up and blocking each other from initiating PAPI jobs\n # also, a timeout 24 hours is added to prevent all matrix files from queueing infinitely if one\n # fails to launch an ingest job for some reason\n if matrix_file.created_at < study_file.created_at && matrix_file.created_at > 24.hours.ago\n return false\n end\n end\n end\n end\n true\n else\n # no other file types currently are gated for launching ingest\n true\n end\n end",
"def free_space_ok?\n #todo: need real heuristic\n free_space['main']['inodes'] > 100000\n end",
"def is_valid?(checking_recipe_id = self.id)\n steps_to_check = self.recipe_steps.latest.order(\"number ASC\")\n prev_min_sec = steps_to_check.first.try(:min_before_sec)\n prev_max_sec = steps_to_check.first.try(:max_before_sec)\n\n steps_to_check.each do |step|\n if prev_min_sec == nil && step.min_before_sec != nil ||\n prev_min_sec != nil && step.min_before_sec != nil && T.must(step.min_before_sec) > prev_min_sec ||\n prev_max_sec == nil && step.max_before_sec != nil ||\n prev_max_sec != nil && step.max_before_sec != nil && T.must(step.max_before_sec) > prev_max_sec ||\n step.min_before_sec != nil && step.max_before_sec != nil && T.must(step.max_before_sec) > T.must(step.min_before_sec)\n\n Raven.capture_exception(\"step #{step.id} has invalid min/max\")\n return false\n end\n prev_min_sec = step.min_before_sec\n prev_max_sec = step.max_before_sec\n\n step.inputs.latest.recipe_typed.each do |recipe_input|\n child_recipe = recipe_input.inputable\n\n if child_recipe.id == checking_recipe_id\n Raven.capture_exception(\"child recipe #{child_recipe.id} is same as recipe, causing loop\")\n return false\n end\n\n unless child_recipe.is_valid?(checking_recipe_id)\n Raven.capture_exception(\"child recipe #{child_recipe.id} is invalid\")\n return false\n end\n\n if !UnitConverter.can_convert?(recipe_input.unit, child_recipe.unit, child_recipe.volume_weight_ratio)\n Raven.capture_exception(\"#{child_recipe.name} in #{self.name} can't convert #{recipe_input.unit} to #{child_recipe.unit}\")\n return false\n end\n end\n end\n\n true\n end",
"def is_up?\n\t\tFile.exists?(@file)\n\tend",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n if @metadata.nil?\n return false\n end\n\n \n \n \n \n \n \n \n \n end",
"def regenerate?\n outdated? ||\n updated_at < sheet.updated_at ||\n updated_at < sheet.design.updated_at ||\n updated_at < sheet.project.updated_at ||\n updated_at < Time.zone.today - 1.hour\n end",
"def done?\n\t\treturn @num_valid == @max_block\n\tend",
"def check_file_presence_on_update(params)\n if params[:financial_document][:file] == '{}' && params[:financial_document][:remove_file] == '1'\n errors.add(:file, I18n.t('errors.messages.blank'))\n return false\n else\n return true\n end\n end",
"def verify_required_data_files!\n unless File.exists?(\"#{@working_directory}/drupal-filesystem.tar.gz\") && File.exists?(\"#{@working_directory}/drupal-db.sql.gz\")\n raise StandardError.new(\"Cannot locate both 'drupal-filesystem.tar.gz' and 'drupal-db.sql.gz' in directory '#{@working_directory}'.\")\n end\n end"
] | [
"0.6459014",
"0.61789834",
"0.6173833",
"0.57643414",
"0.5756706",
"0.56445915",
"0.5590954",
"0.554623",
"0.5523257",
"0.55117345",
"0.5488111",
"0.54705775",
"0.54400265",
"0.5393438",
"0.53783447",
"0.5327384",
"0.5319959",
"0.5294783",
"0.5291879",
"0.52897424",
"0.52874506",
"0.5274584",
"0.52660817",
"0.5238659",
"0.52356106",
"0.52232146",
"0.52192795",
"0.52168363",
"0.51977104",
"0.51956445",
"0.5183457",
"0.5183381",
"0.517957",
"0.5174346",
"0.5171369",
"0.51682764",
"0.5165075",
"0.5160576",
"0.5158125",
"0.5157034",
"0.5154436",
"0.5154436",
"0.5154436",
"0.5154436",
"0.5154436",
"0.5154436",
"0.5154436",
"0.51373357",
"0.51369923",
"0.51350516",
"0.5133675",
"0.51280195",
"0.5126051",
"0.510618",
"0.50933427",
"0.5093216",
"0.50891036",
"0.5085758",
"0.5082896",
"0.5073871",
"0.5072477",
"0.5067532",
"0.5066079",
"0.5060236",
"0.50539047",
"0.50522757",
"0.5050054",
"0.50493145",
"0.5047505",
"0.5045822",
"0.5044163",
"0.5039303",
"0.5038079",
"0.50370914",
"0.5031849",
"0.5029446",
"0.5022796",
"0.5022622",
"0.50139624",
"0.5012599",
"0.50065255",
"0.49995673",
"0.4998366",
"0.49950892",
"0.49944827",
"0.49933133",
"0.4987039",
"0.49859932",
"0.4981824",
"0.4980483",
"0.49778023",
"0.49765724",
"0.49715546",
"0.49664888",
"0.49642882",
"0.49574572",
"0.49552736",
"0.49541867",
"0.4952227",
"0.4947023"
] | 0.77530825 | 0 |
Return true if the user's password matches the submitted password. | def has_password?(submitted_password)
# Compare encrypted_password with the encrypted version of
# submitted_password.
encrypted_password == encrypt(submitted_password)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matching_password?(pass)\n self.password_hash == encrypt_password(pass)\n end",
"def has_password?(submitted_password)\n password == encrypt(submitted_password)\n end",
"def password_match? password\n\t\tBCrypt::Password.new(@password) == password\n\tend",
"def passwords_match?\n context.user.password == context.password\n end",
"def has_password?(submitted_password)\n self.password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n #compare encrypted_password with the encrypted version of submitted password.\n password == submitted_password\n end",
"def correct_password?(params)\n current_password = params[:user][:current_password]\n password == current_password\n end",
"def correct_password?(params)\n current_password = params[:user][:current_password]\n password == current_password\n end",
"def correct_password?(params)\n current_password = params[:pd_user][:current_password]\n return (password == current_password)\n end",
"def has_password? (submitted_password)\n password_digest == encrypt(submitted_password)\n end",
"def password_match?(entered_password = '')\n password == User.hash_with_salt(entered_password, salt)\n end",
"def password_match?(password=\"\")\n hashed_password == User.hash_with_salt(password, salt)\n end",
"def password_match?(password=\"\")\n hashed_password == User.hash_with_salt(password, salt)\n end",
"def has_password?(submitted_password)\n # Compare encrypted password with the encrypted version of\n # Submitted password\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\r\n encrypted_password == encrypt(submitted_password)\r\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def password_match?(password=\"\")\n hashed_password == AdminUser.hash_with_salt(password, salt)\n end",
"def password_match?(password=\"\")\n hashed_password == AdminUser.hash_with_salt(password, salt)\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?( submitted_password )\n encrypted_password == encrypt( submitted_password )\n end",
"def has_password?(submitted_password)\n # Return true if the user's password matches the submitted password.\n # Compare encrypted_password with the encrypted version of submitted_password\n encrypted_password == encrypt(submitted_password) \n end",
"def has_password?(submitted_password)\n # compare encrypted_password with the encrypted version of submitted_password\n encrypted_password == encrypt(submitted_password)\n end",
"def correct_password?(params)\n self.current_password = params[:user][:current_password]\n self.password == self.current_password\n end",
"def correct_password?(params)\n current_password=params[:user][:current_password]\n password == current_password\n end",
"def has_password?(submitted_password)\n self.encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n\t\t# Compare encrypted password with the encrypted version of the submitted password\n\t\tencrypted_password == encrypt(submitted_password)\n\tend",
"def has_password?(submitted_password)\n #Compare encrypted_password with the encrypted version of \n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end",
"def password_match?( password=\"\")\n hashedPassword == Admin.hash_with_salt(password, salt)\n end",
"def has_password?(submitted_password)\n\tpassword == encrypt(submitted_password) \n end",
"def password_match?(login_password)\n\t\tencrypted_password == encrypt(login_password)\t\n\tend",
"def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n\t encrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n\t\t# compare encrypted_password with the encrypted version of submitted_password\n\t\tencrypted_password == encrypt(submitted_password)\n\tend",
"def has_password?(submitted_password)\n\t # Compare encrypted_password with the encrypted version of\n\t # submitted_password.\n\t encrypted_password == encrypt(submitted_password)\n\tend",
"def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end",
"def matches_password(login_password)\n passhash == BCrypt::Engine.hash_secret(login_password, salt)\n end",
"def password_match?\n self.password == self.password_confirmation\n end",
"def match_password(login_password=\"\")\n password == BCrypt::Engine.hash_secret(login_password, salt)\n end",
"def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of # submitted_password.\n encrypt(submitted_password) == encrypted_password\n end",
"def hasSamePassword?(submittedPassword)\n encrypted_password == encryptUsingSalt(submittedPassword)\n end",
"def has_password?(submitted_password)\n\t# Compare encrypted_password with the encrypted version of\n\t# submitted_password.\n\t\tencrypted_password == encrypt(submitted_password)\n\tend",
"def has_password?(submitted_password)\n valid_password?(submitted_password)\n end",
"def has_password?(submitted_password)\n # compare encrypted_password with the encrypted version of\n # the submitted password.\n\tencrypted_password == encrypt(submitted_password)\n end",
"def has_password?(submitted_password)\n\tencrypted_password == encrypt(submitted_password)\nend",
"def matching_passwords(params)\n if params[\"Password\"] == params[\"Confirmed_password\"]\n return true \n else \n return false\n end \n end",
"def password_match?\n add_password_match_error if password != password_confirmation\n\n password == password_confirmation && !password.blank?\n end",
"def is_password?(password)\n BCrypt::Password.new(self.password_digest) == password\n end",
"def password_ok?(username, password)\n hashed_pass = hashed_password(username, password)\n PasswordCheck.check(username, hashed_pass, @passwords)\n end",
"def verify_password(password)\n hash_password(password) == @password_hash\n end",
"def has_password?(password)\n encrypted_password == encrypt(password)\n end",
"def valid_password? password\r\n self.password === Digest::MD5.hexdigest(password)[0..19]\r\n end",
"def valid_password?(password)\n true\n end",
"def same?(params)\n User.find(params[:user_id]).play(PasswordRole) { |user|\n user.same_password?(params[:password])\n }\n end",
"def password? (plain_text_password)\n # don't allow logging in with blank passwords\n return false if plain_text_password.blank?\n return false if self.password_hash.blank?\n\n salt = self.password_salt\n pass = self.password_hash\n Rauth::Encode.mkpasswd(plain_text_password, salt) == pass\n end",
"def has_password? pass\n WodaHash.digest(self.pass_salt + pass).to_hex.downcase == pass_hash.downcase\n end",
"def password_is?(pw)\n Digest::MD5.hexdigest(pw + password_salt) == password_hash\n end",
"def password\n password = @prompt.mask(\"Enter password: \", required: true)\n if password == @current_user.password\n true\n else\n puts \"Password is invalid.\"\n sleep(1)\n false\n end\n end",
"def is_password?(password)\n obj = Password.new(self.password_digest)\n obj.is_password?(password)\n end",
"def matches?(password, secret = nil)\n self.class.verify_password(password, digest, secret)\n end",
"def valid_password?(password); end",
"def password_confirmed?\n params[:password] != params[:user][:password]\n end",
"def valid_password?(password)\n\t\t$users_and_passwords.each do |element|\n\t\t\tif element[USERNAME] == @username\n\t\t\t\tif element[PASSWORD] == password\n\t\t\t\t\t@authenticated=true\n\t\t\t\t\treturn true\n\t\t\t\tend\n\t\t\tend\n\t\tend\t\t\t\n\n\t\treturn false\n\tend",
"def password_match\n if password != confirm_password\n errors.add(:password, \"doesn't match\")\n end\n end",
"def password?(password_candidate)\r\n\t\t@password_hash == User.calculate_hash(password_candidate)\r\n\tend",
"def authenticates?(password)\r\n self.password == Crypto::digest(password)\r\n end",
"def authenticate password\n if self.password == password\n true\n else\n false\n end\n end",
"def valid_password?(password)\n BCrypt::Password.new(self.password_digest).is_password?(password)\n end",
"def valid_password?(password)\n BCrypt::Password.new(self.password_digest).is_password?(password)\n end",
"def valid_password?(incoming_password)\n password_digest(incoming_password) == self.encrypted_password\n end",
"def has_password?(password)\n user_password = self.password_digest\n encrpyted_password = BCrypt::Password.new(user_password)\n encrpyted_password.is_password?(password)\n end",
"def is_valid_password?(password)\n\t\tself.password == BCrypt::Engine.hash_secret(password, self.password)\n\tend",
"def password_ok?\n return unless password and confirm_password\n errors.add(:password, \"Passwords don't match\") if password != confirm_password\n end",
"def has_password?(a_password)\n self.encrypted_password == encrypt(a_password)\n end",
"def authenticated?(password)\n self.hashed_password == encrypt(password) or using_bypass(password)\n end",
"def has_password?(pwd)\n password_hash == HasPassword.encrypt(pwd, password_salt)\n end",
"def has_password?(password_soumis)\n\t\t# Compare encrypted_password avec la version cryptée de password_soumis.\n encrypted_password == encrypt(password_soumis)\n end",
"def valid_password?(plain)\n password == hash_crypt(plain.to_s) \n end",
"def is_password?(password)\n BCrypt::Password.new(self.password_digest).is_password?(password)\n end"
] | [
"0.8485361",
"0.83525056",
"0.8315177",
"0.83141565",
"0.8279726",
"0.82433754",
"0.821651",
"0.821651",
"0.8204761",
"0.81947446",
"0.81943554",
"0.8180314",
"0.8180314",
"0.81543386",
"0.8150993",
"0.81353897",
"0.8129398",
"0.8129398",
"0.81292814",
"0.81292814",
"0.81292814",
"0.81292814",
"0.81292814",
"0.81292814",
"0.81292814",
"0.81292814",
"0.81292814",
"0.81292814",
"0.81292814",
"0.81292814",
"0.81292814",
"0.8124027",
"0.8124027",
"0.81148493",
"0.81148493",
"0.811356",
"0.81134135",
"0.80929303",
"0.80864465",
"0.80842274",
"0.8066894",
"0.8063761",
"0.806097",
"0.8046016",
"0.8046016",
"0.8046016",
"0.8046016",
"0.8046016",
"0.8046016",
"0.8046016",
"0.8007393",
"0.7999908",
"0.7984118",
"0.79832584",
"0.7960398",
"0.7953266",
"0.79376656",
"0.7933197",
"0.79027915",
"0.7893055",
"0.7885213",
"0.7878558",
"0.7868051",
"0.78499675",
"0.7834767",
"0.7806237",
"0.7785885",
"0.7781426",
"0.7780531",
"0.7760412",
"0.77514946",
"0.77499336",
"0.77320504",
"0.7721663",
"0.77157664",
"0.7686706",
"0.7681179",
"0.7677505",
"0.76696604",
"0.76479596",
"0.7645843",
"0.7642485",
"0.76307464",
"0.7622044",
"0.7620623",
"0.76180786",
"0.76176125",
"0.76006764",
"0.7599882",
"0.7599882",
"0.7596942",
"0.7594662",
"0.75840724",
"0.7581444",
"0.75811976",
"0.75413215",
"0.75351965",
"0.75311804",
"0.75217897",
"0.7515899"
] | 0.79240835 | 58 |
GET /troubles GET /troubles.json | def index
set_search_troubles
@variable_trouble = Trouble.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @problems = Problem.all\n\n render json: @problems\n end",
"def index\n raise CrazyError, \"This is a crazy error!\"\n @thing_with_errors = ThingWithError.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @thing_with_errors }\n end\n end",
"def index\n @problems = Problem.active.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @problems }\n end\n end",
"def index\n @problems = Problem.paginate(page: params[:page], per_page: 10 ).order('created_at DESC')\n\n respond_with @problems\n end",
"def index\n @problems = Problem.all\n end",
"def index\n @problems = Problem.all\n end",
"def index\n @problems = Problem.all\n end",
"def retrieve_solved\n\t\trender json: @@problems_solved_shared\n\tend",
"def index\n @problems = Problem.all\n end",
"def show\n @thing_with_error = ThingWithError.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @thing_with_error }\n end\n end",
"def show\n @problem = Problem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @problem }\n end\n end",
"def show\n @problem = Problem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @problem }\n end\n end",
"def index\n @tryings = Trying.all\n end",
"def show_broken\n @objects = Node.find_broken\n respond_to do |format|\n format.html\n format.json {render json: @objects}\n end\n end",
"def show\n @problem = Problem.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @problem }\n end\n end",
"def show\n @mistake = Mistake.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mistake }\n end\n end",
"def show\n include_admin = @current_user.is_admin?\n @submissions_table = @contest.all_submissions_table(include_admin)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @problems }\n end\n end",
"def index\n permitted_to! :inspect, Problem.find(params[:problem_id])\n @test_sets = TestSet.where(:problem_id => params[:problem_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @test_sets }\n end\n end",
"def index\n @search = Problem.search(params[:q])\n @problems = @search.result.paginate(:page => params[:page], :per_page => 10).order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @problems }\n end\n end",
"def gather_issues\n url = \"#{URL}/projects/foreman/issues.json?status_id=1&limit=100&release_id=#{@current_release_id}\"\n puts url\n uri = URI(URI.escape(url))\n response = Net::HTTP.get(uri)\n JSON.parse(response)\nend",
"def index\n @conflict_illnesses = ConflictIllness.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @conflict_illnesses }\n end\n end",
"def index\n @page_title = \"Problem List\"\n respond_to do |format|\n format.html\n format.json {\n render json: ProblemsDatatable.new(view_context)\n }\n end\n end",
"def index\n @fails = Fail.all\n end",
"def index\n respond_to do |format|\n format.html\n format.json { render json: Tissue.all }\n end\n \n end",
"def index\n @issues = Issue.all.order(created_at: :desc)\n if @issues.present?\n render :index, status: :ok\n else\n @message = \"no issues found\"\n render :error, status: :not_found\n end\n end",
"def index\n @tries = Try.all\n end",
"def not_found!\n [404, {\"Content-Type\" => \"text/plain\"}, [\"Jsus doesn't know anything about this entity\"]]\n end",
"def index\n @problemas = Problema.all\n end",
"def show\n # fetch sub problems and put it in json\n cause = []\n @problem.problem_references.each do |problem_reference|\n cause << problem_reference.sub_problem\n end\n @problem_attributes = @problem.attributes.merge(cause: cause)\n render json: @problem_attributes\n end",
"def londons_rescue\n render json: { error: \"Gym not found\"}, status: 422\n end",
"def index\n @illnesses = Illness.all\n\n render json: @illnesses\n end",
"def index\n @issues = Issue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @issues }\n end\n end",
"def show\n @try = Try.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @try }\n end\n end",
"def index\n @problem_attempts = ProblemAttempt.all\n end",
"def index\n @stucks = Stuck.all\n end",
"def index\n @problems = Problem.all.order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 8)\n @problem = Problem.new\n end",
"def index\n @problems = Problem.where(source: params[:source]).first(10)\n if @problems.nil?\n spider = get_spider(params[:source])\n problems = spider.spide_problems\n problems.each do |problem|\n Problem.create(problem)\n end\n @problems = Problem.where(source: params[:source]).first(10)\n end\n render json: @problems\n end",
"def show\n @gotcha = Gotcha.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gotcha }\n end\n end",
"def index\n if params[:query].present?\n @bugs = Bug.search(params[:query])\n else\n @bugs = Bug.all\n end\n render json: @bugs\n end",
"def not_found\n render json: nil, status: :not_found\n end",
"def show\n @problem = Problem.find_by_shortname(params[:id])\n @solutions = @problem.solutions.paginate(page: params[:page], per_page: 10 ).order('created_at DESC')\n add_breadcrumb @problem.name, problem_path(@problem)\n respond_with @problem\n end",
"def failure\n failure = {failure: \"Uh oh! Looks like something didn't go quite right.\"}\n render json: failure\n end",
"def index\n if params[:problem_id]\n @problem = Problem.find_by_shortname(params[:problem_id])\n @solutions = @problem.solutions.paginate(page: params[:page], per_page: 10 ).order('created_at DESC')\n add_breadcrumb(@problem.name, problem_path(@problem))\n else\n @solutions = Solution.paginate(page: params[:page], per_page: 10 ).order('created_at DESC')\n end\n add_breadcrumb \"Solutions\", problem_solutions_path(@problem)\n respond_to :html, :json, :js\n end",
"def get_my_issues\n get_json( GITHUB_ISSUES_URL ).each do |item|\n puts \"#{ item[ 'repository' ][ 'full_name' ] }: ##{ item[ 'number' ] } #{ item[ 'title' ] } | href=#{ item[ 'html_url' ] }\"\n end\nend",
"def index\n @tutorials = Tutorial.all\n\n respond_to do |format|\n format.html\n format.json do\n render json: @tutorials\n end\n end\nend",
"def not_found\n render(\n json: {\n errors: [{\n type: \"Not Found\"\n }]\n },\n status: :not_found #alias for 404 in rails\n )\n end",
"def index\n @problems = Problem.search(params[:search], order: :posted_date, :per_page => Problem.per_page, :page => params[:page])\n #@problems = Problem.all(order: :posted_date, :per_page => Problem.per_page, :page => params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @problems }\n end\n end",
"def get_questions\n items = get_items\n make_response(HttpStatus::OK, make_result_list(items))\nend",
"def game_not_found\n render json: { message: 'Game was not found' }, status: 404\n end",
"def index\n @reqdifficulties = Reqdifficulty.all\n end",
"def index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercises }\n end\n end",
"def index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercises }\n end\n end",
"def index\n @illnesses = Illness.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @illnesses }\n end\n end",
"def index\n @losts = Lost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @losts }\n end\n end",
"def index\n find_ongoing_tasks\n render json: OngoingTaskBlueprint.render(@ongoing_tasks)\n rescue ActiveRecord::RecordNotFound\n render json: { error: $ERROR_INFO.message }, status: :not_found\n end",
"def index\n @given_circumstances = GivenCircumstance.all\n render json: @given_circumstances\n end",
"def puzzles\n render json: @user.next_infinity_puzzle_set(\n params[:difficulty],\n params[:after_puzzle_id]\n )\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 index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @exercises }\n end\n end",
"def suggested_stories\n already_following_ids = current_user.following.pluck(&:id)\n bad_algorithm_results = SuccessStory.where.not(user_id: already_following_ids).limit(3)\n\n render json: SuccessStorySerializer.new(bad_algorithm_results, {}).serialized_json\n end",
"def index\n @ideas = Idea.current_ideas_for(current_user).entries\n respond_with(@ideas) do |format|\n format.json { render json: @ideas }\n end\n end",
"def failure\n render json: {status: 1, data: nil}\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 index \n render :json => Project.find(11).bug_tracker.bugs\n end",
"def show\n #note = Note.find(params[:id])\n begin\n @note = Note.find(params[:id])\n rescue Exception => e\n @a = '{\n \"error\" : \"not found\"\n }'\n @data = JSON.parse(@a)\n render json: @data, status: 404\n return\n end\n end",
"def index\n @tutorials = Tutorial.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tutorials }\n end\n end",
"def not_found_response\n [ 404, { \"Content-Type\" => \"text/plain\", \"Content-Length\" => \"9\", \"X-Cascade\" => \"pass\" }, [ \"Not found\" ] ]\n end",
"def not_found\n render json: { error: { message: 'There was nothing found at this address.' }}, status: :not_found\n end",
"def index\n @ideas = Idea.all\n\n render json: @ideas\n end",
"def render_figgy_404 # rubocop:disable Naming/VariableNumber\n respond_to do |format|\n format.html { render \"errors/not_found\", status: :not_found }\n format.json { head :not_found }\n end\n end",
"def index\n \n last_modified = nil\n\n if params.has_key?(:character_id) # request using character_id \n \n state = Tutorial::State.find_by_character_id(params[:character_id])\n raise NotFoundError.new('No quests found for character id.') if state.nil?\n raise ForbiddenError.new('Access forbidden.') if state.owner != current_character && !staff? && !admin?\n \n @tutorial_quests = if api_request? # send only the relevant quests (those, that have not been finished yet)\n state.quests.non_closed \n else # display all quests in backend\n state.quests.paginate(:page => params[:page], :per_page => 50) \n end\n last_modified = state.updated_at.utc # the state is touched on changed on the quests\n \n else # request all \n raise ForbiddenError.new('Access forbidden.') if !staff? && !admin? \n @tutorial_quests = Tutorial::Quest.paginate(:page => params[:page], :per_page => 50)\n end\n \n if stale?(:last_modified => last_modified, :etag => @tutorial_quests)\n respond_to do |format|\n format.html \n format.json { render json: @tutorial_quests }\n end\n end\n end",
"def respides\n n = Problem.where(source: params[:source]).count\n spider = get_spider(params[:source])\n problems = spider.spide_problems(n)\n problems.each do |problem| \n Problem.create(problem)\n end\n @problems = Problem.where(source: params[:source]).limit(10).order(:id).reverse_order\n render json: @problems\n end",
"def get_random\n @question = Question.get_random\n\n unless @question\n render json: { error: \"random question can't be found\" }.to_json, status: 404\n end\n end",
"def puzzles\n render json: {\n puzzles: HastePuzzle.random_level(100)\n }\n end",
"def index \n misses = Miss.all.order(created_at: :desc)\n render json: misses \n end",
"def trouble_params\n params.require(:trouble).permit(:name, :url, :solution, :status_id, :category_id, :user_id)\n end",
"def index\n @tissues = Tissue.all\n end",
"def new\n @problem = Problem.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @problem }\n end\n end",
"def new\n @problem = Problem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @problem }\n end\n end",
"def new\n @problem = Problem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @problem }\n end\n end",
"def test_can_get_no_entries\n get '/api/entries'\n assert last_response.ok?\n assert_equal [], parse_json_resp(last_response)\n end",
"def new\n @thing_with_error = ThingWithError.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @thing_with_error }\n end\n end",
"def index\n @api_v1_exercises = Api::V1::Exercise.all\n end",
"def issues\n @query = Query.new(:name => \"_\")\n @issues = @query.issues(:order => \"issues.created_on desc\", :limit => 50, :include => [:project, :author])\n res = Array.new\n @issues.each do |is|\n res << {:issue_id => is.id, :issue_title => is.subject, :issue_content => is.description, :project_name => is.project.name,\n :author_name => is.author.to_s, :author_email => is.author.mail, :issue_created_at => is.created_on, :issue_status => is.status.to_s }\n end\n render :json => res.to_json\n end",
"def index\n p \"///////////////////////////\"\n @projects = Project.all\n\n respond_to do |format|\n format.json {\n render :json => @projects,\n include: [:bug]\n }\n\n format.html\nend\n end",
"def index\n @exercise_templates = ExerciseTemplate.all\n render json: @exercise_templates\n end",
"def show\n @unsolved = Unsolved.find(params[:id])\n\n respond_to do |format|\n format.html #{ redirect_to solveds_path, notice: 'Unsolved problem was successfully added.' }\n format.json { render json: @unsolved }\n end\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",
"def invalid_api_responses\n %w( json_no_route json_post_invalid_type json_user_cannot_read )\n end",
"def index\n @admin_problems = Problem.all\n end",
"def index\n @potluck_items = @event.potluck_items\n\n respond_to do |format|\n format.html { render :layout => false }# index.html.erb\n format.json { render json: @event.get_potluck_items_for_guests.to_json }\n end\n end",
"def show\n @bug = Bug.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bug }\n end\n end",
"def show\n @bug = Bug.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bug }\n end\n end",
"def bug\n bug = Bug.where(id: params[:bugId])\n render :json => bug.to_json\n end",
"def show\n respond_with(failures)\n end",
"def questions\n self.class.get(\"/2.2/questions\", @options)\n end",
"def show\n @bug = Bug.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bug }\n end\n end",
"def index\n @solutions = @idea.solutions.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @solutions }\n end\n end",
"def index\n if params[:problems].blank?\n @cases = Case.all\n else\n @cases = Case.as(:c).where('c.stock <= 1').pluck(:c)\n @cases.map!{|c| {\n id: c.id,\n name: c.name,\n stock: c.stock\n }}\n\n @cases.sort_by! {:name}\n\n render json: @cases\n end\n end",
"def not_found(exception)\n render json: { error: exception.message }, status: :not_found\n end"
] | [
"0.6914684",
"0.64868885",
"0.6422672",
"0.63073707",
"0.6295702",
"0.6295702",
"0.6295702",
"0.6285203",
"0.6158924",
"0.6093062",
"0.5966853",
"0.5966853",
"0.59652627",
"0.5953674",
"0.59529537",
"0.59241974",
"0.5901176",
"0.58958864",
"0.5867919",
"0.58045363",
"0.58017886",
"0.57623184",
"0.5749837",
"0.574307",
"0.5733404",
"0.57308877",
"0.57280564",
"0.5707433",
"0.5704643",
"0.5677864",
"0.566443",
"0.5659331",
"0.5630663",
"0.56279904",
"0.5620428",
"0.5607948",
"0.5603703",
"0.5599572",
"0.55919284",
"0.5584295",
"0.5558602",
"0.5552275",
"0.55442977",
"0.55336905",
"0.5531564",
"0.55228823",
"0.5519842",
"0.54938537",
"0.5493592",
"0.5485902",
"0.5483112",
"0.5483112",
"0.5482045",
"0.5472647",
"0.5471904",
"0.5471113",
"0.54624736",
"0.54615337",
"0.5453714",
"0.54513854",
"0.54482245",
"0.54397994",
"0.5439147",
"0.5436666",
"0.5434895",
"0.54348624",
"0.54146105",
"0.54101664",
"0.54056185",
"0.54023147",
"0.5399233",
"0.53977937",
"0.5392704",
"0.5392589",
"0.5392576",
"0.5392139",
"0.5382982",
"0.5379055",
"0.5378659",
"0.5378659",
"0.5374685",
"0.53734535",
"0.53669214",
"0.53650796",
"0.5361261",
"0.53594553",
"0.53573793",
"0.5352885",
"0.53496045",
"0.53464013",
"0.5345108",
"0.53431094",
"0.53431094",
"0.53425175",
"0.5337573",
"0.53374374",
"0.53372717",
"0.5336536",
"0.533295",
"0.53313345"
] | 0.5796422 | 21 |
POST /troubles POST /troubles.json | def create
@variable_trouble = Trouble.new(trouble_params)
respond_to do |format|
if @variable_trouble.save
flash[:success] = 'トラブルを追加しました'
format.html { redirect_to troubles_url }
else
set_search_troubles
flash[:danger] = 'トラブル追加に失敗しました'
format.html { render :index }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trouble_params\n params.require(:trouble).permit(:name, :url, :solution, :status_id, :category_id, :user_id)\n end",
"def create\n @problem = Problem.new(problem_params)\n\n if @problem.save\n render json: @problem, status: :created, location: @problem\n else\n render json: @problem.errors, status: :unprocessable_entity\n end\n end",
"def create\n respond_to do |format|\n if @problem.save\n format.html { redirect_to @problem, notice: 'Problem was successfully created.' }\n format.json { render json: @problem, status: :created, location: @problem }\n else\n format.html { render action: \"new\" }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_create_fail\n post '/resources'\n assert_equal 400, last_response.status\n last_response.headers['Content-Type'].must_equal 'application/json;charset=utf-8'\n assert_json_match error_message_pattern, last_response.body\n end",
"def index\n @problems = Problem.all\n\n render json: @problems\n end",
"def create\n @problem = Problem.new(params[:problem])\n\n respond_to do |format|\n if @problem.save\n format.html { redirect_to @problem, notice: 'Problem was successfully created.' }\n format.json { render json: @problem, status: :created, location: @problem }\n else\n format.html { render action: \"new\" }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @problem = Problem.new(params[:problem])\n\n respond_to do |format|\n if @problem.save\n format.html { redirect_to @problem, notice: 'Problem was successfully created.' }\n format.json { render json: @problem, status: :created, location: @problem }\n else\n format.html { render action: \"new\" }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @problem = Problem.new(problem_params)\n create_tags\n respond_to do |format|\n if @problem.save\n format.html { redirect_to @problem, notice: 'Problem was successfully created.' }\n format.json { render json: @problem, status: :created, location: @problem }\n else\n format.html { render \"new\" }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gotcha = Gotcha.new(params[:gotcha])\n\n respond_to do |format|\n if @gotcha.save\n format.html { redirect_to gotchas_url, notice: 'Gotcha was successfully created.' }\n format.json { render json: @gotcha, status: :created, location: @gotcha }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gotcha.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_cannot_create_a_task_without_a_title\n post '/tasks', { task: { description: \"else\", user_id: 1 } }\n assert_equal 0, Task.count\n assert_equal 403, last_response.status\n assert_equal \"Title can't be blank\", last_response.body\n end",
"def create\n @problem = Problem.new(params[:problem])\n\n respond_to do |format|\n if @problem.save\n flash[:class] = \"alert alert-success\"\n format.html { redirect_to @problem, :notice => 'Problem was successfully created.' }\n format.json { render :json => @problem, :status => :created, :location => @problem }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @problem.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @problem = Problem.new(problem_params)\n @problem.likes = 0\n respond_to do |format|\n if @problem.save\n format.html { redirect_to problems_url, success: 'Frustration was successfully created.' }\n format.json { render :show, status: :created, location: @problem }\n else\n format.html { render :new }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @problem = Problem.new(problem_params)\n\n respond_to do |format|\n if @problem.save\n format.html { redirect_to @problem, notice: 'Problem was successfully created.' }\n format.json { render action: 'show', status: :created, location: @problem }\n else\n format.html { render action: 'new' }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n response.headers.delete \"X-Frame-Options\"\n\n @problem = Problem.new(problem_params)\n\n @problem.tag_list = @problem.tag_list[0].to_s.scan(/\\w+/)\n @problem.status = \"Open\"\n @problem.user = current_user\n\n respond_to do |format|\n if @problem.save\n format.html { redirect_to @problem, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @problem }\n else\n format.html { render :new }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @try = Try.new(try_params)\n @test = Test.existing.find(@try.test_id)\n result = @try.prepare\n\n respond_to do |format|\n if result\n format.html { redirect_to show_question_try_path(@try) }\n format.json { render :show, status: :created, location: @try }\n else\n puts @try.errors.inspect\n format.html { render :new }\n format.json { render json: @try.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if @test.done.blank?\n redirect_to root_path, warning: \"This test have not finished yet\"\n return\n end\n params[:submission] = {}\n params[:submission][:user_id] = current_user.id\n @submission = @test.submissions.create(submission_params)\n respond_to do |format|\n if @submission.save\n @test.questions.each do |question|\n question.answers.each do |answer|\n answer.answers_of_questions.create({choice: false, question_id: question.id, submission_id: @submission.id})\n end\n end\n format.html { redirect_to edit_test_submission_path(@test, @submission) }\n else\n format.html { render :new }\n end\n end\n end",
"def create\n @trying = Trying.new(trying_params)\n\n respond_to do |format|\n if @trying.save\n format.html { redirect_to @trying, notice: \"Trying was successfully created.\" }\n format.json { render :show, status: :created, location: @trying }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @trying.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mistake = Mistake.new(params[:mistake])\n\n respond_to do |format|\n if @mistake.save\n format.html { redirect_to @mistake, notice: 'Mistake was successfully created.' }\n format.json { render json: @mistake, status: :created, location: @mistake }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mistake.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @problem = current_user.problems.build(problem_params)\n\n respond_to do |format|\n if @problem.save\n format.html { redirect_to root_path, notice: 'Problem was successfully created.' }\n format.json { render :show, status: :created, location: @problem }\n else\n format.html { render :new }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @problem_attempt = ProblemAttempt.new(problem_attempt_params)\n\n respond_to do |format|\n if @problem_attempt.save\n format.html { redirect_to @problem_attempt, notice: 'Problem attempt was successfully created.' }\n format.json { render :show, status: :created, location: @problem_attempt }\n else\n format.html { render :new }\n format.json { render json: @problem_attempt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @problem = Problem.new(params[:problem])\n\n respond_to do |format|\n if @problem.save\n format.html { redirect_to [:admin, @problem], notice: 'Problem was successfully created.' }\n format.json { render json: @problem, status: :created, location: @problem }\n else\n format.html { render action: \"new\" }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def respides\n n = Problem.where(source: params[:source]).count\n spider = get_spider(params[:source])\n problems = spider.spide_problems(n)\n problems.each do |problem| \n Problem.create(problem)\n end\n @problems = Problem.where(source: params[:source]).limit(10).order(:id).reverse_order\n render json: @problems\n end",
"def create\n @contest = Contest.new(params[:contest])\n @problem_count = 4\n\n @contest.begin_date_str = params[:begin_date]\n @contest.end_date_str = params[:end_date]\n\n problems = []\n for i,p in params[:problems]\n number = p[:number]\n score = p[:score]\n\n next if number.blank? && score.blank?\n @contest.errors[:problem] << \"#{i}'s number is invalid.\" and next if number.blank?\n @contest.errors[:problem] << \"#{i}'s score is invalid.\" and next if score.blank?\n\n aoj_problem = AOJ::Problem.new(number)\n @contest.errors[:problem] << \"#{i} is invalid.\" and next unless aoj_problem.valid?\n problem = Problem.new({\n number: number.to_i,\n name: aoj_problem.name,\n score: score.to_i,\n contest: @contest,\n })\n problems << problem\n end\n @contest.problems = problems\n\n @contest.errors[:problems] << 'are required more than 0.' if problems.size==0\n\n\n unless @contest.errors.empty?\n render action: 'new' and return\n end\n\n respond_to do |format|\n if @contest.save\n format.html { redirect_to @contest, notice: 'Contest was successfully created.' }\n format.json { render json: @contest, status: :created, location: @contest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @thing_with_error = ThingWithError.new(params[:thing_with_error])\n\n respond_to do |format|\n if @thing_with_error.save\n format.html { redirect_to @thing_with_error, notice: 'Thing with error was successfully created.' }\n format.json { render json: @thing_with_error, status: :created, location: @thing_with_error }\n else\n format.html { render action: \"new\" }\n format.json { render json: @thing_with_error.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_post_invalid\n header 'Content-Type', 'application/json'\n\n json = JSON.generate [{ latitude: 'wrong', longitude: 'wrong' }]\n post('/traces', json, 'CONTENT_TYPE': 'application/json')\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def puzzles\n render json: @user.next_infinity_puzzle_set(\n params[:difficulty],\n params[:after_puzzle_id]\n )\n end",
"def create\n @unsolved = Unsolved.new(unsolved_params)\n respond_to do |format|\n if @unsolved.save\n format.html { redirect_to @unsolved, notice: 'Unsolved problem was successfully added.' }\n format.json { render json: @unsolved, status: :created, location: @unsolved }\n end\n end\n end",
"def create\n @bug = Bug.new(params[:bug])\n\n respond_to do |format|\n if @bug.save\n format.html { redirect_to @bug, notice: 'Bug was successfully created.' }\n format.json { render json: @bug, status: :created, location: @bug }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bug.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bug = Bug.new(params[:bug])\n\n respond_to do |format|\n if @bug.save\n format.html { redirect_to @bug, notice: 'Bug was successfully created.' }\n format.json { render json: @bug, status: :created, location: @bug }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bug.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @problem = Problem.new(problem_params)\n\n respond_to do |format|\n if @problem.save\n format.html { redirect_to [:admin, @problem], notice: 'Problem was successfully created.' }\n format.json { render :show, status: :created, location: [:admin, @problem] }\n else\n format.html { render :new }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room = Room.new(room_params)\n \n respond_to do |format|\n if @room.save\n trivia_category = (@room.category.eql? \"any\") ? '' : \"category=\" + @room.category\n \n questions_response = RestClient::Request.execute(\n method: :get,\n url: 'https://opentdb.com/api.php?amount=7&type=multiple&' + trivia_category\n )\n questions = JSON.parse(questions_response)['results']\n\n questions.each do |question|\n Question.create(\n :problem => question['question'],\n :category => question['category'],\n :correct_answer => question[\"correct_answer\"],\n :incorrect_answer_one => question[\"incorrect_answers\"][0],\n :incorrect_answer_two => question[\"incorrect_answers\"][1],\n :incorrect_answer_three => question[\"incorrect_answers\"][2],\n :room_id => @room.id\n )\n end\n format.html { redirect_to @room, notice: 'Room was successfully created.' }\n format.json { render :show, status: :created, location: @room }\n else\n format.html { render :new }\n format.json { render json: @room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @tips_trick.save\n format.html { redirect_to @tips_trick, notice: 'Tips trick was successfully created.' }\n format.json { render json: @tips_trick, status: :created, location: @tips_trick }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tips_trick.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @question = Question.new(question_params)\n\n if @question.save\n render json: @question\n else\n render status: 400, nothing: true\n end\n end",
"def create\n @test_question = TestQuestion.new(params[:test_question])\n\n respond_to do |format|\n if @test_question.save\n format.html { redirect_to @test_question, :notice => 'Test question was successfully created.' }\n format.json { render :json => @test_question, :status => :created, :location => @test_question }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @test_question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n sleep(rand(1..5)) if Rails.env.development?\n answer = Answer.new(params.require(:answer).permit(:question_uuid, :letter))\n answer.user_slug = current_user_slug\n saved = answer.save\n answers = Answer.where(user_slug: current_user_slug).as_react_json\n\n respond_to do |format|\n if saved\n message = 'Risposta registrata correttamente.'\n # Notify tutor\n ActionCable.server.broadcast \"answers_#{answer.question_uuid}\", answer: answer.as_react_json\n format.html { redirect_to lives_path(@live_lecture), notice: message }\n format.json { render json: { result: :success, message: message, answers: answers } }\n else\n message = answer.errors.full_messages.join('. ')\n format.html { redirect_to lives_path(@live_lecture), alert: message }\n format.json { render json: { result: :error, message: message, answers: answers } }\n end\n end\n rescue ActiveRecord::StatementInvalid, StandardError => e\n answers = Answer.where(user_slug: current_user_slug).as_react_json\n\n respond_to do |format|\n format.html { redirect_to lives_path(@live_lecture), alert: e.message }\n format.json { render json: { result: :error, message: e.message, answers: answers } }\n end\n end",
"def londons_rescue\n render json: { error: \"Gym not found\"}, status: 422\n end",
"def create\n @fail = Fail.new(fail_params)\n\n respond_to do |format|\n if @fail.save\n format.html { redirect_to @fail, notice: 'Fail was successfully created.' }\n format.json { render :show, status: :created, location: @fail }\n else\n format.html { render :new }\n format.json { render json: @fail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n exercise = Exercise.create(exercise_params)\n if exercise\n render json: exercise\n else\n render json: {error: 'Workout was not created.'}\n end\n end",
"def create\n @sudoku = Sudoku.new(sudoku_params)\n @sudoku.gaps = Sudoku.generate_gaps\n respond_to do |format|\n if @sudoku.save\n format.html { redirect_to @sudoku }\n format.json { render :show, status: :created, location: @sudoku }\n else\n format.html { render :new }\n format.json { render json: @sudoku.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @issue = Issue.new(issue_params)\n\n respond_to do |format|\n if @issue.save\n format.html { redirect_to issues_url, notice: 'Issue was successfully created.' }\n format.json { render json: @issue }\n else\n format.html { redirect_to issues_url, notice: 'There was a problem saving your issue. Do you need a tissue?' }\n format.json { render json: @issue.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n raise CrazyError, \"This is a crazy error!\"\n @thing_with_errors = ThingWithError.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @thing_with_errors }\n end\n end",
"def create\n @tutorials = Tutorial.all\n @tutorial = Tutorial.new(tutorial_params)\n\n if @tutorial.save\n render json: @tutorial\n else\n render json: @tutorial.errors.full_messages, status:400\n end\n end",
"def create\n @tutorial_quest = Tutorial::Quest.new(params[:tutorial_quest])\n\n respond_to do |format|\n if @tutorial_quest.save\n format.html { redirect_to @tutorial_quest, notice: 'Quest was successfully created.' }\n format.json { render json: @tutorial_quest, status: :created, location: @tutorial_quest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tutorial_quest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipo_pregunta = TipoPregunta.new(params[:tipo_pregunta])\n\n if @tipo_pregunta.save\n render json: @tipo_pregunta, status: :created, location: @tipo_pregunta\n else\n render json: @tipo_pregunta.errors, status: :unprocessable_entity\n end\n end",
"def destroy\n @variable_trouble.destroy\n respond_to do |format|\n flash[:danger] = 'トラブルを削除しました'\n format.html { redirect_to troubles_url }\n format.json { head :no_content }\n end\n end",
"def create\n @concept = CustomizedConcept.find(params[:test_attempt][:customized_concept_id])\n @tests = @concept.tests\n @test_attempt = @concept.test_attempts.new(test_attempt_params)\n @course = @concept.course\n @answer_records = @test_attempt.answer_records\n \n @error_test = check_answer(params[:select_answers])\n respond_to do |format|\n if (@error_test.length == 0) \n @test_attempt.test_time_sec = Time.now.to_i - @test_attempt.test_time_sec\n if @test_attempt.save\n format.html { redirect_to course_customized_concept_path(@course, @concept), notice: 'Successfully pass' }\n format.json { render :show, status: :created, location: @test_attempt }\n end\n else\n\t\t\t\t@test_attempt.retry_time += 1\n\t\t\t\tbinding.pry\n @error_test.each do |e|\n @answer_records.each do |a|\n a.error_times += 1 if a.test == e\n end\n end\n format.html { render :new }\n format.json { render json: @test_attempt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @try = Try.new(params[:try])\n\n respond_to do |format|\n if @try.save\n format.html { redirect_to @try, notice: 'Try was successfully created.' }\n format.json { render json: @try, status: :created, location: @try }\n else\n format.html { render action: \"new\" }\n format.json { render json: @try.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @problems = Problem.paginate(page: params[:page], per_page: 10 ).order('created_at DESC')\n\n respond_with @problems\n end",
"def test_should_create_post_via_API_JSON\r\n get \"/logout\"\r\n post \"/forum_posts.json\", :api_key=>'testapikey',\r\n :forum_post => {:title=>'API Test Post',\r\n :body=>'Test Post desc',\r\n :user_id=>1}\r\n assert_response :created\r\n topic = JSON.parse(response.body)\r\n assert topic['title'] == 'API Test Post', 'Incorrect topic title'\r\n assert topic['user_id'] == 1, 'Incorrect user id'\r\n assert topic['body'] == 'Test Post desc', 'Incorrect topic description' \r\n end",
"def index\n set_search_troubles\n @variable_trouble = Trouble.new\n end",
"def new\n @problem = Problem.new\n @problem.answers.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @problem }\n end\n end",
"def set_trouble\n @variable_trouble = Trouble.find(params[:id])\n end",
"def handle_post(body)\n make_response(200, validate_questions(body))\nend",
"def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end",
"def new\n @problem = Problem.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @problem }\n end\n end",
"def new\n @gotcha = Gotcha.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gotcha }\n end\n end",
"def new\n @problem = Problem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @problem }\n end\n end",
"def new\n @problem = Problem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @problem }\n end\n end",
"def new\n kick and return if not is_god?\n @puzzle = Puzzle.new\n @other_puzzles = Puzzle.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @puzzle }\n end\n end",
"def new\n @mistake = Mistake.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mistake }\n end\n end",
"def failure\n failure = {failure: \"Uh oh! Looks like something didn't go quite right.\"}\n render json: failure\n end",
"def create\n @submission = Submission.new(submission_params)\n @submission.correctness = false\n @submission.reviewed = false\n\n respond_to do |format|\n if @submission.save\n format.html { redirect_to task_path(@submission.task), notice: 'Submission was successfully created.' }\n format.json { render :show, status: :created, location: @submission }\n else\n format.html { render :new }\n format.json { render json: @submission.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 failure\n render json: {status: 1, data: nil}\n end",
"def create\n streak, success = jsonapi_create.to_a\n\n if success\n render_jsonapi(streak, scope: false)\n else\n render_errors_for(streak)\n end\n end",
"def create\n @admin_problem = Problem.new(admin_problem_params)\n\n respond_to do |format|\n if @admin_problem.save\n format.html { redirect_to admin_problem_path(@admin_problem), notice: 'Admin problem was successfully created.' }\n format.json { render :show, status: :created, location: @admin_problem }\n else\n set_genres\n format.html { render :new }\n format.json { render json: @admin_problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @thing_with_error = ThingWithError.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @thing_with_error }\n end\n end",
"def index\n @problems = Problem.all\n end",
"def index\n @problems = Problem.all\n end",
"def index\n @problems = Problem.all\n end",
"def fail_params\n params.require(:fail).permit(:title, :url)\n end",
"def destroy\n @problem.destroy\n\n respond_to do |format|\n format.html { redirect_to problems_url }\n format.json { head :ok }\n end\n end",
"def create\n @exercise = @workout.exercises.new(exercise_params)\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to @exercise, notice: I18n.t('exercises.created') }\n format.json { render :show, status: :created, location: @exercise }\n else\n format.html { render :new }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ignore_test_create_with_wrong_http_method_redirects\n get :create, model_identifier => test_entry_attrs\n assert_redirected_to_index\n \n put :create, model_identifier => test_entry_attrs\n assert_redirected_to_index\n \n delete :create, model_identifier => test_entry_attrs\n assert_redirected_to_index\n end",
"def create\n @tissue = Tissue.new(tissue_params)\n\n respond_to do |format|\n if @tissue.save\n format.html { redirect_to @tissue, notice: 'Tissue was successfully created.' }\n format.json { render :show, status: :created, location: @tissue }\n else\n format.html { render :new }\n format.json { render json: @tissue.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @problem.destroy\n respond_to do |format|\n format.html { redirect_to problems_url }\n format.json { head :no_content }\n end\n end",
"def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end",
"def create\n @stuck = Stuck.new(stuck_params)\n @stuck.user_id = current_user.id\n\n respond_to do |format|\n if @stuck.save\n format.html { redirect_to @stuck, notice: 'Stuck was successfully created.' }\n format.json { render action: 'show', status: :created, location: @stuck }\n else\n format.html { render action: 'new' }\n format.json { render json: @stuck.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @problems = Problem.active.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @problems }\n end\n end",
"def new\n @submission = Submission.new\n @submission.problem = params[:problem].to_i if params[:problem]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @submission }\n end\n end",
"def failure\n [405, { 'Content-Type' => 'text/plain'}, ['405 Method Not Allowed']]\n end",
"def test_duplicate_user\n data = { 'email' => 'ace@base.se', 'password' => 'open1234' }\n post '/users', data.to_json\n assert last_response.status.eql?(400)\n json_data = JSON last_response.body\n assert json_data['errors'].present?\n end",
"def create\n @problem = Problem.new(problem_params)\n\n respond_to do |format|\n if @problem.save\n format.html { redirect_to admin_problem_path(@problem), notice: 'Problem was successfully created.' }\n format.json { render action: 'show', status: :created, location: @problem }\n else\n format.html { render action: 'new' }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @meuble = Meuble.new(params[:meuble])\n\n respond_to do |format|\n if @meuble.save\n format.html { redirect_to @meuble, notice: 'Meuble was successfully created.' }\n format.json { render json: @meuble, status: :created, location: @meuble }\n else\n format.html { render action: \"new\" }\n format.json { render json: @meuble.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test_question = TestQuestion.new(test_question_params)\n\n respond_to do |format|\n if @test_question.save\n format.html { redirect_to @test_question, notice: 'Test question was successfully created.' }\n format.json { render :show, status: :created, location: @test_question }\n else\n format.html { render :new }\n format.json { render json: @test_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test_question = TestQuestion.new(test_question_params)\n\n respond_to do |format|\n if @test_question.save\n format.html { redirect_to @test_question, notice: 'Test question was successfully created.' }\n format.json { render :show, status: :created, location: @test_question }\n else\n format.html { render :new }\n format.json { render json: @test_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @junk = Junk.new(junk_params)\n\n respond_to do |format|\n if @junk.save\n format.html { redirect_to @junk, notice: 'Junk was successfully created.' }\n format.json { render :show, status: :created, location: @junk }\n else\n format.html { render :new }\n format.json { render json: @junk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @problems = Problem.where(source: params[:source]).first(10)\n if @problems.nil?\n spider = get_spider(params[:source])\n problems = spider.spide_problems\n problems.each do |problem|\n Problem.create(problem)\n end\n @problems = Problem.where(source: params[:source]).first(10)\n end\n render json: @problems\n end",
"def index\n permitted_to! :inspect, Problem.find(params[:problem_id])\n @test_sets = TestSet.where(:problem_id => params[:problem_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @test_sets }\n end\n end",
"def create\n @testing = Testing.new(testing_params)\n\n respond_to do |format|\n if @testing.save\n format.html { redirect_to @testing, notice: 'Testing was successfully created.' }\n format.json { render :show, status: :created, location: @testing }\n else\n format.html { render :new }\n format.json { render json: @testing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @todo = Todo.new(todo_params)\n if @todo.save\n render json: @todo, status: 201\n else\n render json: @todo.errors, status: 422\n end\n end",
"def create\n @exercise = Exercise.new(params[:exercise])\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to @exercise, notice: 'Exercise was successfully created.' }\n format.json { render json: @exercise, status: :created, location: @exercise }\n else\n flash.now[:error] = @exercise.errors.full_messages\n format.html { render action: \"new\"}\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @problem.destroy\n respond_to do |format|\n format.html { redirect_to problems_url, info: 'Frustration was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @interactor = ProblemPersistence::ProblemCreationInteractor.call(self.params.merge(user_id: current_user.id))\n\n if @interactor.success?\n redirect_to @interactor.problem, notice: 'Problem was successfully created.' \n else\n \n #flash[:error] = interactor.error\n #render :new\n end\n end",
"def create\n @exercise = Exercise.new(params[:exercise])\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to @exercise, :notice => 'exercise was successfully created.' }\n format.json { render :json => @exercise, :status => :created, :location => @exercise }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @exercise.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @problem = Problem.new(problem_params)\n #FileUtils::mkdir_p \"grades/#{@problem.id}\"\n \n # puts \"grades/#{Problem.last.id.to_s}\\n\\n\"\n\n respond_to do |format|\n if @problem.save\n populate(@problem.id.to_s)\n format.html { redirect_to @problem, notice: 'Problem was successfully created.' }\n format.json { render :show, status: :created, location: @problem }\n else\n format.html { render :new }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@problem = Problem.find_by_id(session[:problem_id])\n\t\t@test_case = TestCase.new\n\t\tif lecturer_signed_in?\n\t\t\t@test_case = TestCase.new(post_params)\n\t\t\t@test_case.owner_id = current_lecturer.id\n\t\t\t@test_case.owner_type = \"lecturer\"\n\t\t\t@test_case.problem_id = session[:problem_id]\n\t\telsif teaching_assistant_signed_in?\n\t\t\t@test_case = TestCase.new(post_params)\n\t\t\t@test_case.owner_id = current_teaching_assistant.id\n\t\t\t@test_case.owner_type = \"teaching assistant\"\n\t\t\t@test_case.problem_id = session[:problem_id]\n\t\tend\n\t\tif @test_case.save\n\t\t\t@problem.test_cases << @test_case\n\t\t\tif session[:flag] == \"1\"\n\t\t\t\tredirect_to :controller => 'test_cases', :action => 'index',\n\t\t\t\t\t:problem_id => session[:problem_id], :track_id => session[:track_id], :flag => \"1\"\n\t\t\telsif session[:flag] == \"0\"\n\t\t\t\tredirect_to :controller => 'model_answers', :action => 'new',\n\t\t\t\t\t:problem_id => session[:problem_id], :track_id => session[:track_id], :flag => \"0\"\n\t\t\tend\n\t\telse\n\t\t\trender :action=>'new', :problem_id => @test_case.problem_id, :flag => session[:flag]\n\t\tend\n\tend",
"def create\n @sudoku = Sudoku.new(params[:sudoku]) \n \n respond_to do |format|\n if @sudoku.save\n format.html { redirect_to @sudoku, notice: 'Sudoku was successfully created.' }\n format.json { render json: @sudoku, status: :created, location: @sudoku }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sudoku.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @try = Try.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @try }\n end\n end",
"def test_email_invalid_format\n data = { 'email' => 'ace@base', 'password' => 'open1234' }\n post '/users', data.to_json\n assert last_response.status.eql?(400)\n json_data = JSON last_response.body\n assert json_data['errors'].present?\n end"
] | [
"0.62379307",
"0.6224483",
"0.5897463",
"0.58892846",
"0.588561",
"0.5864274",
"0.5863429",
"0.5823895",
"0.57829446",
"0.5765519",
"0.57513356",
"0.57098365",
"0.5709618",
"0.56485784",
"0.56097573",
"0.5588947",
"0.55829775",
"0.55620325",
"0.55547756",
"0.55421436",
"0.55370134",
"0.55098176",
"0.55047494",
"0.55043787",
"0.5486005",
"0.54655224",
"0.5450621",
"0.54384583",
"0.54384583",
"0.54091775",
"0.54061615",
"0.5404797",
"0.5366457",
"0.5365001",
"0.53589356",
"0.5351656",
"0.53464544",
"0.53450066",
"0.5334328",
"0.53283644",
"0.5324878",
"0.53234833",
"0.53084904",
"0.53083813",
"0.53048885",
"0.52970463",
"0.5296734",
"0.5288715",
"0.5285658",
"0.52827495",
"0.52824086",
"0.5266224",
"0.5263944",
"0.5253028",
"0.52486366",
"0.5245702",
"0.5243889",
"0.5243889",
"0.5233544",
"0.5224677",
"0.522385",
"0.5219148",
"0.52174824",
"0.52156305",
"0.5214906",
"0.5196652",
"0.519407",
"0.5189188",
"0.5189188",
"0.5189188",
"0.5186924",
"0.51849484",
"0.5170302",
"0.5169544",
"0.51585627",
"0.51577234",
"0.51530945",
"0.5150997",
"0.51501524",
"0.51427186",
"0.5138039",
"0.5133634",
"0.5128379",
"0.5128287",
"0.5122413",
"0.5122413",
"0.51143676",
"0.51135355",
"0.5108765",
"0.51066434",
"0.5105792",
"0.5105201",
"0.5098786",
"0.50952506",
"0.50858325",
"0.50820917",
"0.5077338",
"0.5071911",
"0.50717574",
"0.50702584"
] | 0.5890337 | 3 |
PATCH/PUT /troubles/1 PATCH/PUT /troubles/1.json | def update
respond_to do |format|
if @variable_trouble.update(trouble_params)
flash[:success] = 'トラブルを更新しました'
format.html { redirect_to troubles_url }
format.json { render :show, status: :ok, location: @trouble }
else
set_search_troubles
flash[:danger] = 'トラブル更新に失敗しました'
format.html { render :edit }
format.json { render json: @trouble.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch!\n request! :patch\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n @problem = Problem.find(params[:id])\n\n if @problem.update(problem_params)\n head :no_content\n else\n render json: @problem.errors, status: :unprocessable_entity\n end\n end",
"def update\n @patch = Patch.find(params[:id])\n\n respond_to do |format|\n if @patch.update_attributes(params[:patch])\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @problem.update_attributes(params[:problem])\n format.html { redirect_to @problem, notice: 'Problem was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @problem.update(problem_params)\n format.html { redirect_to @problem, notice: 'Problem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @problem = Problem.find(params[:id])\n\n respond_to do |format|\n if @problem.update_attributes(params[:problem])\n format.html { redirect_to @problem, notice: 'Problem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @problem = Problem.find(params[:id])\n\n respond_to do |format|\n if @problem.update_attributes(params[:problem])\n format.html { redirect_to @problem, notice: 'Problem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @problem = Problem.find(params[:id])\n\n respond_to do |format|\n if @problem.update_attributes(params[:problem])\n format.html { redirect_to @problem, notice: 'Problem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n @thing_with_error = ThingWithError.find(params[:id])\n\n respond_to do |format|\n if @thing_with_error.update_attributes(params[:thing_with_error])\n format.html { redirect_to @thing_with_error, notice: 'Thing with error was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing_with_error.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mistake = Mistake.find(params[:id])\n\n respond_to do |format|\n if @mistake.update_attributes(params[:mistake])\n format.html { redirect_to @mistake, notice: 'Mistake was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mistake.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stuck.update(stuck_params)\n format.html { redirect_to @stuck, notice: 'Stuck was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @stuck.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @problem.update(problem_params)\n format.html { redirect_to root_path, notice: 'Problem was successfully updated.' }\n format.json { render :show, status: :ok, location: @problem }\n else\n format.html { render :edit }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n end",
"def update\n @problem = Problem.find(params[:id])\n\n respond_to do |format|\n if @problem.update_attributes(params[:problem])\n flash[:class] = \"alert alert-success\"\n format.html { redirect_to @problem, :notice => 'Problem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @problem.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @problem.update(problem_params)\n format.html { redirect_to @problem, success: 'Frustration was successfully updated.' }\n format.json { render :show, status: :ok, location: @problem }\n else\n format.html { render :edit }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @gotcha = Gotcha.find(params[:id])\n\n respond_to do |format|\n if @gotcha.update_attributes(params[:gotcha])\n format.html { redirect_to @gotcha, notice: 'Gotcha was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gotcha.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @problem = Problem.find_by_shortname(params[:id])\n create_tags\n respond_to do |format|\n if @problem.update_attributes(problem_params)\n format.html { redirect_to @problem, notice: 'Problem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render \"edit\" }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, **args); end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update\n respond_to do |format|\n if @problem.update(problem_params)\n format.html { redirect_to [:admin, @problem], notice: 'Problem was successfully updated.' }\n format.json { render :show, status: :ok, location: [:admin, @problem] }\n else\n format.html { render :edit }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rest_patch(base_uri,json_payload,params)\n begin\n @response = RestClient.patch(base_uri,json_payload,params)\n rescue => e\n puts @response.code\n end\n return @response\n end",
"def update\n @todo = Todo.find(params[:id])\n if @todo.update_attributes(todo_params)\n render json: @todo, status: :ok\n else\n render json: @todo.errors, status: 422\n end\n end",
"def update\n respond_to do |format|\n if @thing_to_do.update(thing_to_do_params)\n format.html { redirect_to @thing_to_do, notice: 'Thing to do was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @thing_to_do.errors, status: :unprocessable_entity }\n end\n end\n end",
"def refresh\n to_sync = params['_json']\n\n unless to_sync.kind_of?(Array)\n return redirect_to_error!('request body must contain a valid JSON array of bug numbers or aliases', :bad_request)\n end\n\n updated = Bug.batch_update_from_rpc(to_sync, :permissive => true)\n # Get all the bug ids and aliases we found so we can check if\n # there was anything requested that we _didn't_ find. Note the\n # special handling of aliases, because we store them in the DB as\n # a comma-separated string :(\n updated_ids_and_aliases = updated.\n map{|b| [b.id, b.alias.split(/,\\s*/)]}.\n flatten.map(&:to_s).uniq\n not_updated = to_sync.map(&:to_s) - updated_ids_and_aliases\n\n if not_updated.any?\n return redirect_to_error!(\n \"#{n_thing_or_things(not_updated.length, 'bug')} not found: #{display_list_with_and(not_updated, :elide_after => 4)}\", :not_found)\n end\n\n render :nothing => true, :status => 204\n end",
"def patch(url, payload)\n url = URI.parse(url)\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n request = Net::HTTP::Patch.new(url.path+'?access_token=verysecret')\n request.content_type = 'application/json'\n request.body = JSON.generate(payload)\n response = http.start {|http| http.request(request) }\n begin\n return JSON.parse(response.body)\n rescue\n # Log as a problematic case with rule number and line\n $problems.write \"#{$index}, #{payload}, #{response.body}\\n\"\n return nil\n end\nend",
"def edit_resource(type, id, data)\n bad_attrs = data_includes_invalid_attrs(data)\n\n if bad_attrs.present?\n msg = \"Attribute(s) '#{bad_attrs}' should not be specified for updating a server resource\"\n raise BadRequestError, msg\n end\n\n super\n end",
"def update\n @try = Try.find(params[:id])\n\n respond_to do |format|\n if @try.update_attributes(params[:try])\n format.html { redirect_to @try, notice: 'Try was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @try.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tips_trick.update_attributes(params[:tips_trick])\n format.html { redirect_to @tips_trick, notice: 'Tips trick was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tips_trick.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_exercise.update(api_v1_exercise_params)\n format.html { redirect_to @api_v1_exercise, notice: 'Exercise was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_exercise }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @problem = @solution.problem\n respond_to do |format|\n if @solution.update_attributes(solution_params)\n format.html { redirect_to problem_solution_path(@problem, @solution), notice: 'Solution was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render \"edit\" }\n format.json { render json: @solution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if issue.save\n format.html { redirect_to issue, notice: 'Issue was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: issue.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { render :show, status: :ok, location: @patch }\n else\n format.html { render :edit }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @hack.update_attributes(params[:hack])\n format.html { redirect_to @event, :notices => ['Hack was successfully updated.'] }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @hack.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @bug = Bug.find(params[:id])\n\n respond_to do |format|\n if @bug.update_attributes(params[:bug])\n format.html { redirect_to @bug, notice: 'Bug was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bug.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bug = Bug.find(params[:id])\n\n respond_to do |format|\n if @bug.update_attributes(params[:bug])\n format.html { redirect_to @bug, notice: 'Bug was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bug.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @thing = Thing.find(params[:id])\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to things_path, notice: 'Your thing was successfully updated!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @problem.update(problem_params)\n format.html { redirect_to admin_problem_path(@problem), notice: 'Problem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @thing = Thing.find(params[:id])\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to @thing, notice: 'Thing was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def update\n # respond_to do |format|\n # if @thing.update(thing_params)\n # format.html { redirect_to @thing, notice: 'Thing was successfully updated.' }\n # format.json { render :show, status: :ok, location: @thing }\n # else\n # format.html { render :edit }\n # format.json { render json: @thing.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def update\n @bug = Bug.find(params[:id])\n @bug.jobtests.each{ |jt| jt.valid? }\n\n respond_to do |format|\n if @bug.update_attributes(params[:bug])\n flash[:notice] = 'Bug was successfully updated.'\n format.html { redirect_to(@bug) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bug.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @todo.update(todo_params)\n head :no_content\n else\n render json: @todo.errors, status: :unprocessable_entity\n end\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def update\n respond_to do |format|\n if @todo3.update(todo3_params)\n format.html { redirect_to @todo3, notice: 'Todo3 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @todo3.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @thing = current_user.things.find(params[:id])\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to @thing }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @interactor = ProblemPersistence::ProblemUpdateInteractor.call(self.params.merge(user_id: current_user.id))\n\n if @interactor.success?\n redirect_to @problem, notice: 'Problem was successfully updated.' \n end\n\n #@problem.update_attributes(problem_params)\n #@new_images = problem_images_params[\"images\"]\n #@new_images = \"\" if !@new_images\n #images_array = @new_images.split(\",\")\n #tags = problem_tags_params[\"tags\"]\n #tagsArray = tags.split(\",\")\n #version_description = params[\"version\"][\"description\"]\n\n #respond_to do |format|\n #@exception = @problem.save_edit(tagsArray, images_array, version_description, current_user)[:exception]\n #if !@exception\n #User who edits a problem automatically follows it\n # if !current_user.following? @problem\n # current_user.follow @problem\n # end\n\n # Notify problem followers\n #Notifications::Sender::SendNotifications.new(notification_type: :updated_problem,\n # actor: current_user,\n # resource: @problem).call\n=begin\n format.html { redirect_to @problem, notice: 'Problem was successfully updated.' }\n format.json { render :show, status: :ok, location: @problem }\n else\n format.html { \n flash.now[:failed_problem_create] = @exception.message\n render :edit \n }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n format.js { @problem.reload }\n=end\n #end\n end",
"def patch; end",
"def patch; end",
"def update\n #note = Note.find(params[:id])\n #if @note.update(note_params)\n # render json: note\n #else\n # render json: @note.errors, status: :unprocessable_entity\n #end\n begin\n @note = Note.find(params[:id])\n if @note.update(note_params)\n render json: @note\n end\n rescue Exception => e\n @a = '{\n \"error\" : \"not found\"\n }'\n @data = JSON.parse(@a)\n render json: @data, status: 404\n return\n end\n end",
"def destroy\n @patch.destroy\n respond_to do |format|\n format.html { redirect_to patches_url }\n format.json { head :no_content }\n end\n end",
"def update\n streak, success = jsonapi_update.to_a\n\n if success\n render_jsonapi(streak, scope: false)\n else\n render_errors_for(streak)\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 @normal_issue = NormalIssue.find(params[:id])\n\n respond_to do |format|\n if @normal_issue.update_attributes(params[:normal_issue])\n format.html { redirect_to @normal_issue, notice: 'Normal issue was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @normal_issue.errors, status: :unprocessable_entity }\n end\n end\n end",
"def partial_update(klass, id, patchset, options = {}, format = nil)\n headers = {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n options = { resource: klass, id: id, format: format}.merge options\n if [FHIR::Formats::ResourceFormat::RESOURCE_XML, FHIR::Formats::ResourceFormat::RESOURCE_XML_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_XML\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_XML}\"\n elsif [FHIR::Formats::ResourceFormat::RESOURCE_JSON, FHIR::Formats::ResourceFormat::RESOURCE_JSON_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_JSON\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_JSON}\"\n end\n headers[:prefer] = @return_preference if @use_return_preference\n reply = patch resource_url(options), patchset, fhir_headers(headers)\n reply.resource = parse_reply(klass, format, reply)\n reply.resource_class = klass\n reply\n end",
"def update\n respond_to do |format|\n if @reqdifficulty.update(reqdifficulty_params)\n format.html { redirect_to @reqdifficulty, notice: 'Reqdifficulty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @reqdifficulty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n if @exercise.update_attributes(params[:exercise])\n format.html { redirect_to @exercise, :notice => 'exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @exercise.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def rm_update path, data, msg\n\n re = rm_request path, data, 'PUT'\n puts re.body\n chk (re.code!='200'), msg + \"\\n#{re.code} #{re.msg}\\n\\n\"\n return true\n\nend",
"def patch(path, data, params = {}, request_options = {})\n request(:patch, path, data, params)\n end",
"def update\n respond_to do |format|\n if @thing_to_do.update(thing_to_do_params)\n format.html { redirect_to @thing_to_do, notice: 'Thing to do was successfully updated.' }\n format.json { render :show, status: :ok, location: @thing_to_do }\n else\n format.html { render :edit }\n format.json { render json: @thing_to_do.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @problem_attempt.update(problem_attempt_params)\n format.html { redirect_to @problem_attempt, notice: 'Problem attempt was successfully updated.' }\n format.json { render :show, status: :ok, location: @problem_attempt }\n else\n format.html { render :edit }\n format.json { render json: @problem_attempt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, opts = {})\n request(:patch, path, opts).body\n end",
"def update\n respond_to do |format|\n if @client_bug.update(client_bug_params)\n format.html { redirect_to @client_bug, notice: 'Client bug was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @client_bug.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n# respond_to do |format|\n# if @req.update(req_params)\n format.json { render :json => {:status => 'success'}}\n# format.html { redirect_to @req, notice: 'Req was successfully updated.' }\n# format.json { render :show, status: :ok, location: @req }\n# else\n format.json { render :json => {:status => 'failed'}}\n# format.html { render :edit }\n# format.json { render json: @req.errors, status: :unprocessable_entity }\n# end\n# end\n end",
"def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end",
"def update\n @todo = Todo.find(params[:id])\n if @todo.update(todo_params)\n render json: @todo\n else\n render json: @todo.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @task_entry.update(task_entry_params)\n format.json { head :no_content }\n else\n format.json { render json: @task_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trick = Trick.find(params[:id])\n\n respond_to do |format|\n if @trick.update_attributes(params[:trick])\n format.html { redirect_to @trick, notice: 'Trick was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trick.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @hack_tip.update(hack_tip_params)\n format.html { redirect_to @hack_tip, notice: 'Hack tip was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @hack_tip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @good = Good.find(params[:id])\n\n respond_to do |format|\n if @good.update_attributes(params[:good])\n format.html { redirect_to :action => \"index\" }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @good.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n if @exercise.update_attributes(params[:exercise])\n format.html { redirect_to @exercise, notice: 'Exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n if @exercise.update_attributes(params[:exercise])\n format.html { redirect_to @exercise, notice: 'Exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n if @exercise.update_attributes(params[:exercise])\n format.html { redirect_to @exercise, notice: 'Exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @interesting_thing.update(interesting_thing_params)\n format.html { redirect_to student_interesting_things_path(@student), notice: 'Interesting thing was successfully updated.' }\n format.json { render :show, status: :ok, location: @interesting_thing }\n else\n format.html { render :edit }\n format.json { render json: @interesting_thing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @to_do = ToDo.find(params[:id])\n\n if @to_do.update(params[:to_do])\n head :no_content\n else\n render json: @to_do.errors, status: :unprocessable_entity\n end\n end",
"def update\n error_msg(ErrorCodes::OBJECT_ERROR, \"#{I18n.t \"endnote_files.errors.not_found\"}: #{params[:id]}\")\n render_json\n end",
"def update\n updated_resource = update_resource(resource, resource_params)\n if updated_resource.errors.blank?\n head :no_content\n else\n render json: serialize_invalid_attributes(updated_resource.errors),\n status: :unprocessable_entity\n end\n end",
"def update\n @todo = Todo.find(params[:todo][:id])\n if @todo.update_attributes(user_params)\n render json: @todo\n else\n render nothing: true, status: :bad_request\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end",
"def update\n @interesting = Interesting.find(params[:id])\n\n respond_to do |format|\n if @interesting.update_attributes(params[:interesting])\n format.html { redirect_to @interesting, notice: 'Interesting was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interesting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rest_api.update(rest_api_params)\n format.html { redirect_to @rest_api, notice: 'Rest api was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rest_api.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_update_unsuccessful\n data = {\n firstname: \"\",\n lastname: \"Hoang\",\n avatar: \"avatar.png\",\n address: \"111D Ly Chinh Thang\",\n city: \"Ho Chi Minh\",\n email: \"anh@gmallds.sl\",\n mobile: \"0309433343545\",\n gender: 1,\n birthday: \"1991/10/10\"\n }\n\n user_id = 28\n expected = 1002\n uri = URI.parse('http://localhost:3000/v1/users/'+user_id.to_s)\n\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def update\n @hack = Hack.find(params[:id])\n\n respond_to do |format|\n if @hack.update_attributes(params[:hack])\n format.html { redirect_to @hack, :notice => 'Hack was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @hack.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def ignore_test_update_with_wrong_http_method_redirects\n get :update, :id => test_entry.id, model_identifier => test_entry_attrs\n assert_redirected_to_index\n \n delete :update, :id => test_entry.id, model_identifier => test_entry_attrs\n assert_redirected_to_index\n end",
"def update\n respond_to do |format|\n if @good.update(good_params)\n format.html { redirect_to @good, notice: 'Good was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @good.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 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 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 @solution = @idea.solutions.find(params[:id])\n\n if @solution.update_attributes(params[:solution])\n render json: { text: \"success\" }\n else\n render json: { text: \"fail\"}\n end\n end",
"def update\n respond_to do |format|\n if @fail.update(fail_params)\n format.html { redirect_to @fail, notice: 'Fail was successfully updated.' }\n format.json { render :show, status: :ok, location: @fail }\n else\n format.html { render :edit }\n format.json { render json: @fail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trying.update(trying_params)\n format.html { redirect_to @trying, notice: \"Trying was successfully updated.\" }\n format.json { render :show, status: :ok, location: @trying }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @trying.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test_stuff.update(test_stuff_params)\n format.html { redirect_to @test_stuff, notice: 'Test stuff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @test_stuff.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bug = Bug.find(params[:id])\n @project = Project.find(params[:project_id])\n \n old_status = @bug.is_fixed\n\n respond_to do |format|\n if @bug.update(bug_params)\n # Checar se o status do bug mudou\n if @bug.is_fixed != old_status\n status = { true => \"Corrigido\", false => \"Não corrigido\"}\n # Caso tenha mudado, notificar no Slack\n message = \"#{current_user.username} alterou o status do bug \\\"#{@bug.title}\\\" (#{@project.name}) para #{status[@bug.is_fixed]}\"\n @notifier.ping message\n end\n\n format.html { redirect_to user_project_path(current_user.id, params[:project_id]), notice: 'Bug was successfully updated.' }\n format.json { render :show, status: :ok, location: @bug }\n else\n format.html { render :edit }\n format.json { render json: @bug.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @hack = Hack.find(params[:id])\n\n respond_to do |format|\n if @hack.update_attributes(params[:hack])\n format.html { redirect_to @hack, notice: 'Hack was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @issue = Issue.find(params[:id])\n\n respond_to do |format|\n if @issue.update_attributes(params[:issue])\n format.html { redirect_to @issue, notice: 'Issue was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @issue.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.61565197",
"0.6118787",
"0.6118581",
"0.61094546",
"0.60861963",
"0.60642135",
"0.6036091",
"0.6034049",
"0.6034049",
"0.6034049",
"0.6002611",
"0.59443915",
"0.5921111",
"0.59197736",
"0.589512",
"0.5892983",
"0.58820117",
"0.58804244",
"0.5850145",
"0.58493286",
"0.58485603",
"0.582321",
"0.58103716",
"0.57772416",
"0.5775881",
"0.57583696",
"0.5737738",
"0.5726431",
"0.57004064",
"0.56964946",
"0.56959623",
"0.5683403",
"0.5679919",
"0.56753933",
"0.5674185",
"0.5672814",
"0.5654986",
"0.56541556",
"0.56541556",
"0.5649196",
"0.55778164",
"0.5574146",
"0.55704784",
"0.55704784",
"0.55612415",
"0.5552532",
"0.5549896",
"0.5545744",
"0.5545744",
"0.5540211",
"0.55393434",
"0.55363804",
"0.55321395",
"0.55321395",
"0.55309457",
"0.5528593",
"0.5524735",
"0.5524062",
"0.5522989",
"0.5509734",
"0.55052215",
"0.55021405",
"0.5500116",
"0.5484106",
"0.5484011",
"0.5483314",
"0.54787695",
"0.54783785",
"0.5474451",
"0.5473565",
"0.5472713",
"0.54727006",
"0.54686946",
"0.54611933",
"0.54547596",
"0.54493946",
"0.5447548",
"0.5447548",
"0.5447548",
"0.5446701",
"0.5436608",
"0.54357654",
"0.54297304",
"0.5428069",
"0.54272443",
"0.54200083",
"0.54199636",
"0.5409463",
"0.5406494",
"0.5405604",
"0.5405165",
"0.5402009",
"0.54003596",
"0.53991777",
"0.53977984",
"0.53946286",
"0.53936386",
"0.5392371",
"0.53878486",
"0.53872895"
] | 0.5504445 | 61 |
DELETE /troubles/1 DELETE /troubles/1.json | def destroy
@variable_trouble.destroy
respond_to do |format|
flash[:danger] = 'トラブルを削除しました'
format.html { redirect_to troubles_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @mistake = Mistake.find(params[:id])\n @mistake.destroy\n\n respond_to do |format|\n format.html { redirect_to mistakes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @problem.destroy\n\n respond_to do |format|\n format.html { redirect_to problems_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @problem.destroy\n respond_to do |format|\n format.html { redirect_to problems_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @problem = Problem.find_by_shortname(params[:id])\n @problem.destroy\n\n respond_to do |format|\n format.html { redirect_to problems_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gotcha = Gotcha.find(params[:id])\n @gotcha.destroy\n\n respond_to do |format|\n format.html { redirect_to gotchas_url, notice: 'Gotcha was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_exercise.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_exercises_url, notice: 'Exercise was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @try = Try.find(params[:id])\n @try.destroy\n\n respond_to do |format|\n format.html { redirect_to tries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @problem = Problem.find(params[:id])\n @problem.destroy\n\n respond_to do |format|\n format.html { redirect_to problems_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @problem = Problem.find(params[:id])\n @problem.destroy\n\n respond_to do |format|\n format.html { redirect_to problems_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @problem = Problem.find(params[:id])\n @problem.destroy\n\n respond_to do |format|\n format.html { redirect_to problems_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @problem = Problem.find(params[:id])\n @problem.destroy\n\n respond_to do |format|\n format.html { redirect_to problems_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_todo.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @reqdifficulty.destroy\n respond_to do |format|\n format.html { redirect_to reqdifficulties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @problem.destroy\n respond_to do |format|\n format.html { redirect_to problems_url, info: 'Frustration was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n contest = @problem.contest\n @problem.destroy\n respond_to do |format|\n format.html { redirect_to admin_contest_url(contest), notice: 'Problem was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @thing_with_error = ThingWithError.find(params[:id])\n @thing_with_error.destroy\n\n respond_to do |format|\n format.html { redirect_to thing_with_errors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exercise.destroy\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exercise.destroy\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @problem.destroy\n respond_to do |format|\n format.html { redirect_to problems_url, notice: 'Question was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @miss.destroy\n respond_to do |format|\n format.html { redirect_to misses_url }\n format.json { head :no_content }\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def destroy\n @fail.destroy\n respond_to do |format|\n format.html { redirect_to fails_url, notice: 'Fail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tutorial_quest = Tutorial::Quest.find(params[:id])\n @tutorial_quest.destroy\n\n respond_to do |format|\n format.html { redirect_to tutorial_quests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @intake.destroy\n respond_to do |format|\n format.html { redirect_to intakes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n streak, success = jsonapi_destroy.to_a\n\n if success\n render json: { meta: {} }\n else\n render_errors_for(streak)\n end\n end",
"def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quest = Quest.find(params[:id])\n @quest.destroy\n\n respond_to do |format|\n format.html { redirect_to quests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @try.destroy\n respond_to do |format|\n format.html { redirect_to tries_path, notice: 'Попытка успешно удалена.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest.destroy\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @thing_to_do.destroy\n respond_to do |format|\n format.html { redirect_to thing_to_dos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @problem = @solution.problem\n @solution.destroy\n\n respond_to do |format|\n format.html { redirect_to problem_solutions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @problem.destroy\n\n head :no_content\n end",
"def destroy\n @puzzle = Puzzle.find(params[:id])\n @puzzle.destroy\n\n respond_to do |format|\n format.html { redirect_to puzzles_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @sudoku.destroy\n respond_to do |format|\n format.html { redirect_to new_sudoku_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @todo3.destroy\n respond_to do |format|\n format.html { redirect_to todo3s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @patient_exercise = PatientExercise.find(params[:id])\n @patient_exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to patient_exercises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sudoku = SudokuTopic.find(params[:id])\n @sudoku.destroy\n\n respond_to do |format|\n format.html { redirect_to sudokus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @v1_question.destroy\n render json: {'message': 'Deleted question successfully'}, status: :ok\n else\n render json: get_errors, status: :unprocessable_entity\n end\n\n end",
"def delete\n supprimer = QuestionOuverteService.instance.supprimerQuestion(params[:id])\n (supprimer) ? (render json: true, status: :ok) : (render json: false, status: :not_found)\n end",
"def destroy\n @three60.destroy\n respond_to do |format|\n format.html { redirect_to edit_admin_good_url(@good, anchor: \"three60\") }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nudge.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @do_exercise = DoExercise.find(params[:id])\n @do_exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to do_exercises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exercise_log = ExerciseLog.find(params[:id])\n @exercise_log.destroy\n\n respond_to do |format|\n format.html { redirect_to exercise_logs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bug = Bug.find(params[:id])\n @bug.destroy\n\n respond_to do |format|\n format.html { redirect_to bugs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bug = Bug.find(params[:id])\n @bug.destroy\n\n respond_to do |format|\n format.html { redirect_to bugs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @oncourse_exercise.destroy\n respond_to do |format|\n format.html { redirect_to oncourse_exercises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_stuff.destroy\n respond_to do |format|\n format.html { redirect_to test_stuffs_url }\n format.json { head :no_content }\n end\n end",
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def destroy\n @problem.destroy\n respond_to do |format|\n format.html { redirect_to problems_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @troop.destroy\n respond_to do |format|\n format.html { redirect_to troops_url, notice: 'Tropa exitosamente borrada.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @something = Something.find(params[:id])\n @something.destroy\n\n respond_to do |format|\n format.html { redirect_to somethings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @problem.destroy\n\n respond_to do |format|\n format.html { redirect_to(problems_url) }\n format.xml { 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 api_v1_questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trying.destroy\n respond_to do |format|\n format.html { redirect_to tryings_url, notice: \"Trying was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @health_problem.destroy\n respond_to do |format|\n format.html { redirect_to health_problems_url, notice: 'Health problem was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @thing = Thing.find(params[:id])\n @thing.destroy\n\n respond_to do |format|\n format.html { redirect_to things_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @thing = Thing.find(params[:id])\n @thing.destroy\n\n respond_to do |format|\n format.html { redirect_to things_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exercise.destroy\n respond_to do |format|\n format.html { redirect_to exercises_url, notice: \"Exercise was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exercise.destroy\n respond_to do |format|\n format.html { redirect_to exercises_url, notice: 'Exercise was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exercise.destroy\n respond_to do |format|\n format.html { redirect_to exercises_url, notice: 'Exercise was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @thing.destroy\n respond_to do |format|\n format.html { redirect_to things_url, notice: 'The thing was deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crash_test = CrashTest.find(params[:id])\n @crash_test.destroy\n\n respond_to do |format|\n format.html { redirect_to crash_tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_question.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stuck.destroy\n respond_to do |format|\n format.html { redirect_to stucks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_bug.destroy\n respond_to do |format|\n format.html { redirect_to client_bugs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @three.destroy\n respond_to do |format|\n format.html { redirect_to threes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @todo.destroy\n render json: [\"Deleted successfully.\"], status: :ok\n end",
"def destroy\n @programme_exercise.destroy\n respond_to do |format|\n format.html { redirect_to programme_exercises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quest.destroy\n respond_to do |format|\n format.html { redirect_to quests_url, notice: 'Quest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n issue.destroy\n respond_to do |format|\n format.html { redirect_to issues_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @questao.destroy\n respond_to do |format|\n format.html { redirect_to questaos_url, notice: 'Questao was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @problema.destroy\n respond_to do |format|\n format.html { redirect_to problemas_url, notice: 'Problema was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @todo = Todo.find(params[:id])\n @todo.destroy\n render json: nil, status: :ok\n end",
"def delete\n question = QuestionTest.where(test_id: params[:test_id], question_id: params[:id])\n if question.delete_all\n return render json: {message: 'Question was removed succesfully.', error: false}\n else\n return render json: {message: 'Error: Something went wrong. Question was not removed.', error: true}\n end\n end",
"def destroy\n @ai_contest = AiContest.find(params[:id])\n @ai_contest.destroy\n\n respond_to do |format|\n format.html { redirect_to ai_contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @story.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n return\n @quest.destroy\n respond_to do |format|\n format.html { redirect_to quests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testing_.destroy\n respond_to do |format|\n format.html { redirect_to testing_s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @example.destroy\n respond_to do |format|\n format.html { redirect_to examples_url, notice: 'Operação realizada com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @performed_exercise.destroy\n respond_to do |format|\n format.html { redirect_to performed_exercises_url, notice: 'Performed exercise was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test1.destroy\n respond_to do |format|\n format.html { redirect_to test1s_url, notice: \"Test1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @questionstatu.destroy\n respond_to do |format|\n format.html { redirect_to questionstatus_index_path, notice: 'Mytest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @issue.destroy\n respond_to do |format|\n format.html { redirect_to issues_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @thing_to_do.destroy\n respond_to do |format|\n format.html { redirect_to thing_to_dos_url, notice: 'Thing to do was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @equipment_things_to_check.destroy\n respond_to do |format|\n format.html { redirect_to equipment_things_to_checks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @issue.destroy\n respond_to do |format|\n format.html { redirect_to issues_url, notice: 'Нарушение №'+@issue.id.to_s+' удалено.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hack = Hack.find(params[:id])\n @hack.destroy\n\n respond_to do |format|\n format.html { redirect_to hacks_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @test_question = TestQuestion.find(params[:id])\n @test_question.destroy\n\n respond_to do |format|\n format.html { redirect_to test_questions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @problem_attempt.destroy\n respond_to do |format|\n format.html { redirect_to problem_attempts_url, notice: 'Problem attempt was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @todo = Todo.find(params[:todo][:id])\n if @todo.destroy\n render json: {status: 200, message: \"Task with id \" + @todo.id.to_s + ': removed'}\n else\n render nothing: true, status: :bad_request\n end\n end",
"def destroy\n @exerciseoverview.destroy\n respond_to do |format|\n format.html { redirect_to exerciseoverviews_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n @question.destroy\n \n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'DNS was successfully removed.' }\n format.json { head :no_content }\n \nend\n end",
"def destroy\n @aiaioo_failure = AiaiooFailure.find(params[:id])\n @aiaioo_failure.destroy\n\n respond_to do |format|\n format.html { redirect_to aiaioo_failures_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @troop = Troop.find(params[:id])\n @troop.destroy\n\n respond_to do |format|\n format.html { redirect_to troops_url }\n format.json { head :ok }\n end\n end",
"def destroy\n issues_permissions\n @issue.destroy\n respond_to do |format|\n format.html { redirect_to issues_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.7169323",
"0.7005562",
"0.69641334",
"0.69164264",
"0.69087666",
"0.69050944",
"0.68755704",
"0.6863204",
"0.6863204",
"0.6863204",
"0.6863204",
"0.68540335",
"0.6846601",
"0.6824922",
"0.6821377",
"0.6793374",
"0.6787306",
"0.6785399",
"0.6785399",
"0.6762854",
"0.6744673",
"0.673356",
"0.6691687",
"0.6689345",
"0.6689017",
"0.6680399",
"0.66746306",
"0.66746306",
"0.66746306",
"0.66746306",
"0.667417",
"0.6663263",
"0.66322947",
"0.6618777",
"0.6618542",
"0.661849",
"0.6614884",
"0.6614516",
"0.66120267",
"0.6604594",
"0.6593123",
"0.658886",
"0.6581042",
"0.65786374",
"0.6570763",
"0.65683687",
"0.65645146",
"0.6563453",
"0.65631783",
"0.65631783",
"0.65622795",
"0.65568316",
"0.6553916",
"0.6551433",
"0.65422773",
"0.6536783",
"0.65361345",
"0.65336317",
"0.6529932",
"0.65284103",
"0.6527455",
"0.6527455",
"0.6525942",
"0.6519952",
"0.6519952",
"0.6516552",
"0.6515398",
"0.6512913",
"0.6504448",
"0.65029174",
"0.6502269",
"0.64994633",
"0.649858",
"0.64960474",
"0.6494259",
"0.6493351",
"0.6492847",
"0.64907014",
"0.64906675",
"0.648893",
"0.6482038",
"0.6475449",
"0.6474783",
"0.64727175",
"0.6471119",
"0.6470889",
"0.64707285",
"0.6469715",
"0.64678097",
"0.64667785",
"0.6465373",
"0.64646417",
"0.64643323",
"0.6462833",
"0.6461843",
"0.646144",
"0.64580995",
"0.64580154",
"0.6456895",
"0.64542955"
] | 0.6533346 | 58 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.