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
GET /item_alerts/1 GET /item_alerts/1.json
def show # authorize! :read, @item_alert # @item_alert = ItemAlert.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @item_alert } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n authorize! :read, ItemAlert\n @item_alerts = ItemAlert.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @item_alerts }\n end\n end", "def index\n @alerts = Alert.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @alerts }\n end\n end", "def index\n @alerts = Alert.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @alerts }\n end\n end", "def index\n @alerts = Alert.all\n end", "def index\n @alerts = Alert.all\n end", "def index\n @alerts = Alert.all\n end", "def index\n org = Organization.find(current_employee.organization_id)\n @alerts = org.alerts\n render \"index.json.jbuilder\", status: :ok\n end", "def alerts(query)\n get_json(\"#{api_url}/alerts/#{url_settings}/q/#{parse_query(query)}.#{@options[:format]}\")\n end", "def new\n @item_alert = ItemAlert.new(author: current_user)\n authorize! :create, @item_alert\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item_alert }\n end\n end", "def show\n @alert = Alert.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @alert }\n end\n end", "def show\n @alert = Alert.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @alert }\n end\n end", "def show\n @alert = Alert.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @alert }\n end\n end", "def index\n \t#render json: Api::Alert.all, status: :ok\n \tend", "def index\n @items = Item.order('created_at DESC').where(activated: true)\n respond_to do |format|\n format.html\n format.json {render html: '<strong>404 Not Found</strong>'.html_safe}\n end\n end", "def index\n current_user.havemessage = 0\n current_user.save\n @alerts = current_user.alerts.order(\"created_at DESC\").page(params[:page]).per(15)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @alerts }\n end\n end", "def index\n @api_v1_items = Item.all\n render json: @api_v1_items\n end", "def create\n @item_alert = ItemAlert.new(item_alert_params)\n authorize! :create, ItemAlert\n\n respond_to do |format|\n if @item_alert.save\n format.html do\n redirect_to @item_alert, notice: 'Item alert was successfully created.'\n end\n format.json do\n render json: @item_alert, status: :created, location: @item_alert\n end\n else\n format.html { render 'new' }\n format.json do\n render json: @item_alert.errors, status: :unprocessable_entity\n end\n end\n end\n end", "def get_item\n @item = Item.find_by_id(params[:id])\n if @item\n return @item\n else \n render json: {\"message\": {\"type\": \"error\", \"content\": \"The item could not be found!\"}}\n end\n end", "def show\n @itemstatus = Itemstatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @itemstatus }\n end\n end", "def index\n # @alerts = Alert.all\n @user = User.find(session[:id])\n @alerts = @user.alerts\n end", "def index\n @alerts = Alert.all\n\n # If an activation status is passed, get the specified alerts\n check_active_param\n @alerts = @alerts.where(:active => @active) if (@active != nil)\n\n # If a search query is received, filter the results\n if (!params[:q].blank?)\n # Do the search\n @query = params[:q]\n @alerts = @alerts.where(\"$or\" => [{:name => /#{@query}/i}, {:description => /#{@query}/i}])\n end\n\n # If a page number is received, save it (if not, the page is the first)\n if (!params[:page].blank?)\n page = params[:page].to_i\n page = 1 if (page < 1)\n else\n page = 1\n end\n \n # Paginate!\n @alerts = @alerts.page(page)\n\n respond_to do |format|\n format.html\n end\n end", "def get_single_alert(alert_id)\n ret = http_get('/alert/' + alert_id)\n val = Alert.new(ret)\n val\n end", "def show\n @potluck_item = PotluckItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @potluck_item }\n end\n end", "def show\n @items = Item.find(params[:id])\n render json: @items\n end", "def show\n render json: B1Admin::Logs::ItemSerializer.new(@item).serializable_hash\n end", "def index\n #@alarms = Alarm.all\n @alarms = Alarm.where(machine_id:Tenant.find(current_tenant.id).machines.ids).distinct(:alarm_message).order(\"updated_at DESC\").where('updated_at > ?', 3.days.ago)\n render json: @alarms\n end", "def show\n submenu_item 'applications-index'\n @app = App.find(params[:id], query)\n @alerts = Alert.all({\n :conditions => [\"source_type = 2 and source_id = ? and severity <> 0\", @app.id]\n })\n @services = @app.services\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @app }\n end\n end", "def index\n @sleep_alerts = SleepAlert.all\n end", "def index\n @items = Item.found\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end", "def show\n item = Item.find(params[:id])\n render json: item\n end", "def alerts_v2\n return @alerts_v2\n end", "def alerts(type = 'price')\n authenticated_post(\"auth/r/alerts\", params: {type: type}).body\n end", "def show\n render json: @item, status: :ok\n end", "def index\n @price_alerts = PriceAlert.all\n end", "def show\n @alert = Alert.find(params[:id])\n end", "def alerts\n response = self.class.get(\"/#{self.class.account}/activities.xml\")\n response['alerts'].map { |alert| ScoutScout::Alert.new(alert) }\n end", "def show\n @inventoryitem = Inventoryitem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inventoryitem }\n end\n end", "def show\n @item = Item.all.where(collection_id: params[:id])\n render :json => @item\n end", "def index\n add_breadcrumb \"Index\"\n\n @alerts = AlarmNotification.not_archieved.order(\"created_at DESC\").page(params[:page])\n\n respond_with(@alerts)\n end", "def index\n @items = Admin::Item.by_agency(@current_agency.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_items }\n end\n end", "def list_alert(project_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:pattern] = '/projects/[ProjectName]/alerts'\n\t\targs[:query]['Action'] = 'ListAlert'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :alert_name\n\t\t\targs[:query]['AlertName'] = optional[:alert_name]\n\t\tend\n\t\tif optional.key? :page\n\t\t\targs[:query]['Page'] = optional[:page]\n\t\tend\n\t\tif optional.key? :page_size\n\t\t\targs[:query]['PageSize'] = optional[:page_size]\n\t\tend\n\t\tself.run(args)\n\tend", "def findItem\n item = Item.find(params[:id])\n if item\n return item\n else\n return render json: {data: \"Failure, could not find this item.\"}, status: :not_found\n end\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 get_alerts\r\n\t\turl = URI.parse(\"http://api.wunderground.com/api/#{@token}/alerts/q/#{@state_code}/#{@city}.json\")\r\n\t\thttp_response = HTTParty.get(url).parsed_response\r\n\t\tputs JSON.pretty_generate(http_response)\r\n\tend", "def new\n @alert = Alert.new\n @selected = params[:alert_ids]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @alert }\n end\n end", "def index\n render json:user.last_n_items(20), status: :ok\n rescue StandardError => e\n render json:e.modal_response, status: :bad_request\n end", "def show\n render json: Item.find(params[\"id\"])\n end", "def index\n render json: RequestItem.all\n end", "def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end", "def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end", "def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end", "def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end", "def show\n @feed_item = Item.find(params[:id])\n\n render json: @feed_item\n end", "def show\n render json: Item.find(params[:id])\n end", "def show\n \n render status: 200, :json => @item\n\n end", "def new\n @alert = Alert.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @alert }\n end\n end", "def new\n @alert = Alert.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @alert }\n end\n end", "def index\n #@items = Item.find_by_user_id(Session[user_id])\n @items = Item.all\n render json: @items\n end", "def show\n @item = TodoItem.find(params[:id])\n \n respond_to do |format|\n format.html\n format.json {render json: {\n success:true, \n data: [@item],\n message: \"TodoItem found.\"\n }}\n end\n end", "def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @items }\n end\n end", "def item\n # Url generated from Js script function => getitem() of _form.html.erb file under Views of different controllers\n @item = Report.where(\"user_id = ?\" , current_user.id).pluck(:item_name )\n # send item_names' in form of json\n render json: @item\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item.to_json() }\n end\n end", "def index\n @items = Item.all\n @items_response = Hash.new \n @items_response[:items] = Array.new \n @items.each do |item|\n temp_item = Hash.new\n temp_item[:title] = item.title\n temp_item[:description] = item.description\n temp_item[:price] = item.price\n temp_item[:status] = item.status\n unless item.status.eql?('banned')\n temp_item[:published_date] = item.published_date\n temp_item[:Seller_Name] = Seller.find(item.seller_id).name\n temp_item[:Seller_Latitude] = Seller.find(item.seller_id).latitude\n temp_item[:Seller_Longitude] = Seller.find(item.seller_id).longitude\n end\n temp_item[:Category] = Category.find(item.category_id).name\n @items_response[:items] << temp_item\n end\n render json: {response: @items_response, count: @items_response[:items].count }, status: :ok\n end", "def read_all\n @alerts = @current_event.alerts\n authorize(@alerts)\n @alerts.update_all(resolved: params[:resolved])\n\n respond_to do |format|\n format.html { redirect_to admins_event_alerts_path(@current_event, resolved: params[:resolved].!), notice: t(\"alerts.updated\") }\n format.json { head :ok }\n end\n end", "def show\n @activity_item = ActivityItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @activity_item }\n end\n end", "def show\n @item_response = Hash.new \n @item_response[:item] = Array.new \n\n temp_item = Hash.new\n temp_item[:title] = @item.title\n temp_item[:description] = @item.description\n temp_item[:price] = @item.price\n temp_item[:status] = @item.status\n unless @item.status.eql?('banned')\n temp_item[:published_date] = @item.published_date\n temp_item[:Seller_Name] = Seller.find(@item.seller_id).name\n end\n @item_response[:item] << temp_item\n \n render json: {response: @item_response, count: @item_response[:item].count }, status: :ok\n end", "def index\n @items = Item.all\n @budget = Budget.find params[:budget_id]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\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 @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end", "def get_all_report\n limit = 15\n begin\n if params.has_key? :last_iso_timestamp\n from_time = DateTime.iso8601 params[:last_iso_timestamp]\n\n items = Item.active_items.order('updated_at DESC').where(\"updated_at < ?\",from_time).limit(limit)\n else \n items = Item.active_items.order('updated_at DESC').limit(limit)\n end\n #return\n render json:{success:true, lost_and_found: items.take(limit)} \n rescue Exception => e\n render json:{success:false, message: e.to_s}\n end\n end", "def show\n @tipo_alerta = TipoAlerta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_alerta }\n end\n end", "def show\n self.identify_user\n @item = Item.find(params[:id])\n @itemjson = convert_to_json(@item)\n puts @itemjson\n respond_to do |format|\n format.json { render :json => @itemjson}\n format.xml { render :xml => @item }\n format.html\n end\n end", "def alert(x, status:200, type:\"request\", title:\"Alert\", message:\"\", args: [])\n x.res.status = status\n App[:app_error][type.to_sym][:get][x, title, message, *args]\n end", "def destroy\n @item_alert = ItemAlert.find(params[:id])\n @item_alert.destroy\n authorize! :delete, @item_alert\n\n respond_to do |format|\n format.html { redirect_to item_alerts_url }\n format.json { head :no_content }\n end\n end", "def index\n @received_item_and_qties = ReceivedItemAndQty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @received_item_and_qties }\n end\n end", "def index\n @feedback_items = FeedbackItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @feedback_items }\n end\n end", "def get_site_alerts_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SiteApi.get_site_alerts ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling SiteApi.get_site_alerts\"\n end\n # resource path\n local_var_path = \"/api/3/sites/{id}/alerts\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json;charset=UTF-8'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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 => 'ResourcesAlert')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SiteApi#get_site_alerts\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def alerts\n return @alerts\n end", "def get_item( item )\n @session.base_url = \"http://cl.ly\"\n resp = @session.get( \"/\" + item )\n \n raise ItemNotFound if resp.status == 404\n Crack::JSON.parse(resp.body)\n end", "def get_site_alerts_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SiteApi.get_site_alerts ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling SiteApi.get_site_alerts\"\n end\n # resource path\n local_var_path = '/api/3/sites/{id}/alerts'.sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json;charset=UTF-8'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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 => 'ResourcesAlert')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SiteApi#get_site_alerts\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @item = Item.find(params[:id])\n params[:status] = params[:status] || 'active'\n @status = params[:status]\n @items_activity = Reporting::ItemActivity.get_recent_activity(get_company_id,current_user, params.deep_dup)\n authorize @item\n\n respond_to do |format|\n format.html # show.html.erb\n format.js\n format.json { render :json => @item }\n end\n end", "def index\n @items = Item.find(:all, :order => 'id ASC')\n # @items = Item.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end" ]
[ "0.75725156", "0.6692824", "0.6692824", "0.63853455", "0.63853455", "0.63853455", "0.63407147", "0.6333764", "0.6324947", "0.62646353", "0.6264148", "0.6264148", "0.61909854", "0.61897486", "0.6131482", "0.6069874", "0.60690945", "0.6061999", "0.6029045", "0.60230285", "0.59916055", "0.59586483", "0.5945197", "0.59429365", "0.5942652", "0.59327656", "0.5925776", "0.59029335", "0.58826846", "0.5882606", "0.58799547", "0.586547", "0.58614343", "0.5853638", "0.5853138", "0.58374465", "0.58347625", "0.58328384", "0.5831259", "0.5818334", "0.5813609", "0.58124435", "0.5801751", "0.58007497", "0.5787453", "0.5781178", "0.5774478", "0.5767908", "0.57666546", "0.57666546", "0.57666546", "0.57666546", "0.57590777", "0.575669", "0.57426506", "0.574258", "0.5737913", "0.5735739", "0.5719348", "0.5712539", "0.57004786", "0.56969655", "0.5689271", "0.5687172", "0.5670086", "0.5648848", "0.564559", "0.5623263", "0.5621523", "0.5621523", "0.5621523", "0.5621523", "0.5621523", "0.5621523", "0.5621523", "0.5621523", "0.5621523", "0.5621523", "0.5621523", "0.5621523", "0.5621523", "0.5621523", "0.5621523", "0.5621523", "0.5621523", "0.5621523", "0.5621523", "0.5614476", "0.56053895", "0.5604662", "0.56012684", "0.5600026", "0.5596209", "0.5595638", "0.5595541", "0.55926234", "0.5585794", "0.55845654", "0.55841416", "0.55787" ]
0.6896498
1
GET /item_alerts/new GET /item_alerts/new.json
def new @item_alert = ItemAlert.new(author: current_user) authorize! :create, @item_alert respond_to do |format| format.html # new.html.erb format.json { render json: @item_alert } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @alert = Alert.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @alert }\n end\n end", "def new\n @alert = Alert.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @alert }\n end\n end", "def new\n @itemstatus = Itemstatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @itemstatus }\n end\n end", "def new\n @item = Item.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n \n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @item }\n end\n end", "def new\n @alert = Alert.new\n @selected = params[:alert_ids]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @alert }\n end\n end", "def new\n @inventoryitem = Inventoryitem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inventoryitem }\n end\n end", "def new\n @item = Item.new(:list_id => params[:list_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @item }\n end\n end", "def create\n @item_alert = ItemAlert.new(item_alert_params)\n authorize! :create, ItemAlert\n\n respond_to do |format|\n if @item_alert.save\n format.html do\n redirect_to @item_alert, notice: 'Item alert was successfully created.'\n end\n format.json do\n render json: @item_alert, status: :created, location: @item_alert\n end\n else\n format.html { render 'new' }\n format.json do\n render json: @item_alert.errors, status: :unprocessable_entity\n end\n end\n end\n end", "def new\n @potluck_item = PotluckItem.new\n\n respond_to do |format|\n format.html { render :layout => false }# new.html.erb\n format.json { render json: @potluck_item }\n end\n end", "def new\n @activity_item = ActivityItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @activity_item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n format.xml { render xml: @item }\n end\n end", "def new\n @item = current_user.items.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item_info = ItemInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item_info }\n end\n end", "def new\n @item = Item.new\n @items = Item.all\n @tags = Tag.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @launch_item = LaunchItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @launch_item }\n end\n end", "def new\n @itemstable = Itemstable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @itemstable }\n end\n end", "def new_alert\n@alert = Alert.new(params[:id])\nend", "def new\n @item_datum = ItemData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item_datum }\n end\n end", "def new\n @item = Item.new\n respond_to do |format|\n format.html # new.html.erb\n format.js # new.js.rjs\n format.xml { render :xml => @item }\n end\n end", "def new\n @mail_item = MailItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mail_item }\n end\n end", "def new\n @admin_item = Admin::Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @admin_item }\n end\n end", "def new\n @tipo_alerta = TipoAlerta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_alerta }\n end\n end", "def new\n @alert = Alert.new\n\n respond_to do |format|\n format.html\n end\n end", "def new\n @item_class = ItemClass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item_class }\n end\n end", "def new\n @feed_item = FeedItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feed_item }\n end\n end", "def new\n @showitem = Showitem.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @showitem }\n end\n end", "def new\n @menuitem = Menuitem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @menuitem }\n end\n end", "def new\n @basket_item = BasketItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @basket_item }\n end\n end", "def new\n @feedback_item = FeedbackItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feedback_item }\n end\n end", "def new\n @result_item = ResultItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @result_item }\n end\n end", "def new\n @rackitem = Rackitem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rackitem }\n end\n end", "def new\n @list = List.find(params[:list_id])\n @item = @list.items.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @item_line = ItemLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item_line }\n end\n end", "def new\n @inventory_check_result = InventoryCheckResult.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inventory_check_result }\n end\n end", "def new\n @inventory_item_type = InventoryItemType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inventory_item_type }\n end\n end", "def new\n @closing_item = ClosingItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @closing_item }\n end\n end", "def new\n @locations = Location.all\n @itemname = Itemname.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @itemname }\n end\n end", "def item\n @new = New.find(params[:id])\n end", "def new\n @item_transaction = ItemTransaction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item_transaction }\n end\n end", "def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end", "def new\n @weather_item = WeatherItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @weather_item }\n end\n end", "def new\n @item_print = ItemPrint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item_print }\n end\n end", "def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to lists_path, :notice => 'Item was successfully created.' }\n format.json { render :json => lists_path, :status => :created, :location => lists_path }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @inventory_entry = InventoryEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inventory_entry }\n end\n end", "def new_rest\n @entry_item = EntryItem.new\n\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @entry_item }\n end\n end", "def new\n @lineitem = Lineitem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lineitem }\n end\n end", "def new\n @found_item = current_user.found_items.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @found_item }\n end\n end", "def new\n @item = Item.factory('local')\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end", "def new\n @to_do_item = ToDoItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @to_do_item }\n end\n end", "def new\n @menu_title = 'Post Item' if @category\n @item = Item.new(category_id: @category.try(:id) )\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end", "def new\n @tipo_item = TipoItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_item }\n end\n end", "def new\n @inventory_status = InventoryStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inventory_status }\n end\n end", "def new\r\n @item = Item.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @item }\r\n end\r\n end", "def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to root_url, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, item: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @eve_notification = EveNotification.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @eve_notification }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.haml\n format.json { render :json => @news_item }\n end\n end", "def new\n @fooditem = Fooditem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @fooditem }\n end\n end", "def new\n @item_catalog = ItemCatalog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item_catalog }\n end\n end", "def new\n @item = params[:id] ? Item.find_by_id(params[:id]).dup : Item.new\n authorize @item\n respond_to do |format|\n format.html # new.html.erb\n format.js\n format.json { render :json => @item }\n end\n\n end", "def new\n @trade_item = TradeItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trade_item }\n end\n end", "def new\n @issue = Issue.new\n\n @new = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @issue }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end", "def new\n @item = Item.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end", "def new\n @new_status = NewStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_status }\n end\n end", "def new\n @manifest_item = ManifestItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @manifest_item }\n end\n end", "def new\n @daily_inventory = DailyInventory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @daily_inventory }\n end\n end", "def new\n @liked_item = LikedItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @liked_item }\n end\n end", "def create\n @potluck_item = PotluckItem.new(params[:potluck_item])\n\n respond_to do |format|\n if @potluck_item.save\n format.html { redirect_to [@event, @potluck_item], notice: 'Potluck item was successfully created.' }\n format.json { render json: @potluck_item, status: :created, location: @potluck_item }\n else\n format.html { render action: \"new\", status: :unprocessable_entity }\n format.json { render json: @potluck_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @purchase_item_status = PurchaseItemStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchase_item_status }\n end\n end", "def new\n authorize! :create, @binder\n \n @inventory_item = InventoryItem.new(binder_id: working_binder.id, created_by: current_user.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inventory_item }\n format.js\n end\n end", "def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7386758", "0.7386439", "0.7263244", "0.7217224", "0.7204508", "0.7204508", "0.7204508", "0.7204508", "0.7204508", "0.7204508", "0.7204508", "0.7204508", "0.7204508", "0.7204508", "0.7204508", "0.7204508", "0.7204508", "0.7204508", "0.7204508", "0.7204508", "0.7204508", "0.7204508", "0.7204508", "0.7204508", "0.7111479", "0.7111479", "0.7074457", "0.6971706", "0.6961012", "0.6936747", "0.6895718", "0.6881126", "0.68747836", "0.6867482", "0.68594515", "0.68580544", "0.68448114", "0.683553", "0.6827539", "0.6822163", "0.6744706", "0.6733424", "0.67098266", "0.67031044", "0.6692444", "0.66823775", "0.6647529", "0.6646119", "0.6637751", "0.66269004", "0.6620335", "0.66185343", "0.66169786", "0.66062343", "0.65888953", "0.6585557", "0.6582132", "0.6577007", "0.6574672", "0.6571923", "0.6560218", "0.6550334", "0.65388656", "0.6532205", "0.65271056", "0.65184474", "0.6514631", "0.6512282", "0.6510757", "0.64972854", "0.64960515", "0.6495554", "0.6495175", "0.64939696", "0.6491061", "0.64900994", "0.6471025", "0.64695984", "0.64686745", "0.6466467", "0.64647895", "0.6459352", "0.6458528", "0.6456234", "0.6456234", "0.6456234", "0.6456234", "0.6456234", "0.6456234", "0.6456234", "0.6456234", "0.6451648", "0.6448341", "0.64481974", "0.6441632", "0.6441084", "0.64341974", "0.64256525", "0.6424498", "0.6424498" ]
0.7478622
0
POST /item_alerts POST /item_alerts.json
def create @item_alert = ItemAlert.new(item_alert_params) authorize! :create, ItemAlert respond_to do |format| if @item_alert.save format.html do redirect_to @item_alert, notice: 'Item alert was successfully created.' end format.json do render json: @item_alert, status: :created, location: @item_alert end else format.html { render 'new' } format.json do render json: @item_alert.errors, status: :unprocessable_entity end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n authorize! :read, ItemAlert\n @item_alerts = ItemAlert.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @item_alerts }\n end\n end", "def create\n @alert = Alert.new(params[:alert])\n notifiers = Hash.new\n User.find(params[:notifiers]).each{|user| notifiers[user.id] = 0}\n @alert.notifiers = notifiers\n @alert.host = params[:host]\n @alert.trigger = params[:trigger]\n respond_to do |format|\n if @alert.save\n format.html { redirect_to @alert, notice: 'Alert was successfully created.' }\n format.json { render json: @alert, status: :created, location: @alert }\n\t AlertMailer.new_alert(@alert.id).deliver\n else\n format.html { render action: \"new\" }\n format.json { render json: @alert.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @item_alert = ItemAlert.new(author: current_user)\n authorize! :create, @item_alert\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item_alert }\n end\n end", "def create\n @potluck_item = PotluckItem.new(params[:potluck_item])\n\n respond_to do |format|\n if @potluck_item.save\n format.html { redirect_to [@event, @potluck_item], notice: 'Potluck item was successfully created.' }\n format.json { render json: @potluck_item, status: :created, location: @potluck_item }\n else\n format.html { render action: \"new\", status: :unprocessable_entity }\n format.json { render json: @potluck_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n if @item.save\n @items = Item.all\n render status: 201, :json => @item\n \n else\n render status: 404, json: { message: @item.errors}.to_json\n end\n \n \n end", "def alerts(type = 'price')\n authenticated_post(\"auth/r/alerts\", params: {type: type}).body\n end", "def create\n @alert = Alert.new(alert_params)\n\n respond_to do |format|\n if @alert.save\n format.html { redirect_to alerts_path, notice: 'Alert was successfully created.' }\n #format.json { render action: 'show', status: :created, location: @alert }\n else\n format.html { render action: 'new' }\n format.json { render json: @alert.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n alerts = JSON.parse(params[:alert] || params[:deployment]) \n user_application = UserApplication.find_by_name(alerts[\"application_name\"])\n @alert = build_application_alert(user_application,alerts) if params.has_key?(\"alert\")\n # @deploy_alert = build_deployment_alert(params[:deployment]) if params.has_key?(\"deployment\")\n # @alert = ApplicationAlert.new(params[:application_alert])\n @error = {:error => 'Error while creating record'}\n \n if [email protected]? && @alert.save\n respond_to do |format|\n format.json { render :nothing => true, :status => :ok}\n format.xml { render :nothing => true, :status => :ok }\n end\n # elsif @deploy_alert.save\n # respond_to do |format|\n # format.json { render :nothing => true, :status => :ok}\n # format.xml { render :nothing => true, :status => :ok }\n # end\n else\n respond_to do |format|\n format.json { render :json => @error}\n format.xml { render :xml => @error}\n end\n end\n end", "def create\n @alert = Alert.new(alert_params)\n\n respond_to do |format|\n if @alert.save\n format.html { redirect_to root_path, notice: \"Has creado una nueva alerta. Pronto te avisaremos cuando encontremos lo que buscas\" }\n format.json { render :show, status: :created, location: @alert }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @alert.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n @item.stock_id = params[:stock_id]\n @stock_audit = StockAudit.new\n @stock_audit.item = @item\n @stock_audit.user = current_user\n @stock_audit.audit_params = \"#{item_params}\"\n @stock_audit.comment = \"created a new item\"\n respond_to do |format|\n if @item.save\n @stock_audit.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def addBeaconItem\n if params[:type].present? && params[:beacon_id].present? && params[:item_name].present? && params[:item_image].present? && params[:item_description].present? && params[:item_template].present? && params[:item_category].present?\n if params[:type]==\"addBeaconItem\"\n @beacon = Beacon.find(params[:beacon_id])\n @item = Item.new\n @item.name = params[:item_name]\n @item.image = params[:item_image]\n @item.description = params[:item_description]\n @item.template = params[:item_template]\n @item.category = params[:item_category]\n @item.beacon = @beacon\n if @item.save\n # Success Message\n print \"Sucess!\"\n render :json => { :status => :ok, :message => \"Success!\", :description => \"Saved\", :withItemID => @item.id}\n else\n # Fail-Save Error\n print \"Fail!\"\n render :json => { :status => :ok, :message => \"Fail!\", :description => \"Unable to save\"}\n end\n else\n # Wrong Type Error\n render :json => { :status => :ok, :message => \"Fail!\", :description => \"Wrong Type\"}\n print \"Wrong Type!\"\n end\n else\n # Missing Attribute Error\n render :json => { :status => :ok, :message => \"Fail!\", :description => \"Missing Attribute\"}\n print \"Missing Attribute!\"\n end\n end", "def create_alert_with_http_info(body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: AlertApi.create_alert ...\"\n end\n # verify the required parameter 'body' is set\n if @api_client.config.client_side_validation && body.nil?\n fail ArgumentError, \"Missing the required parameter 'body' when calling AlertApi.create_alert\"\n end\n # resource path\n local_var_path = \"/v2/alerts\"\n\n # query parameters\n query_params = {}\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\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(body)\n auth_names = ['GenieKey']\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 => 'SuccessResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AlertApi#create_alert\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end", "def create\n user = User.find(session[:id])\n \n alert = {:title => alert_params[:title], :city_name => alert_params[:city_name], :alert_time => alert_params[:alert_time], :user => user }\n puts 'ALERT TIME!!!!!!!!!!!!!!!!!!!!!!!!'\n puts alert_params[:alert_time][0]\n @alert = Alert.new(alert)\n respond_to do |format|\n if @alert.save\n # format.html { redirect_to @user, notice: 'Alert was successfully created.' }\n format.html { redirect_to('/alerts', notice: 'Alert was successfully created.') }\n format.json { render :show, status: :created, location: @alert }\n else\n format.html { render :new }\n format.json { render json: @alert.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n current_user.havemessage = 0\n current_user.save\n @alerts = current_user.alerts.order(\"created_at DESC\").page(params[:page]).per(15)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @alerts }\n end\n end", "def create\n @inventory_item = InventoryItem.new(inventory_item_params)\n\n respond_to do |format|\n if @inventory_item.save\n flash[:success] = \"Inventory item was successfully created.\"\n format.html { redirect_to @inventory_item }\n format.json { render :show, status: :created, location: @inventory_item }\n else\n format.html { render :new }\n format.json { render json: @inventory_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item_alert = ItemAlert.find(params[:id])\n authorize! :create, @item_alert\n\n respond_to do |format|\n # if @item_alert.update_attributes(params[:item_alert])\n if @item_alert.update_attributes(item_alert_params)\n format.html do\n redirect_to @item_alert, notice: 'Item alert was successfully updated.'\n end\n format.json { head :no_content }\n else\n format.html { render 'edit' }\n format.json do\n render json: @item_alert.errors, status: :unprocessable_entity\n end\n end\n end\n end", "def create\n item = Item.new(item_params)\n item.done = \"0\"\n item.trash = \"0\"\n\n if item.save\n render json: {data:item}, status: :created\n else\n render json: {data:item}, status: :unprocessable_entity\n end\n end", "def create_alert(data=nil)\n if (!data.blank? && data.is_a?(Hash))\n @alert = Alert.create(data)\n else\n create_service\n create_host\n\n @service.hosts << @host\n @service.save\n \n @alert = Alert.create(:name => \"Test Alert #{rand(1..1000)}\", :description => \"Test alert description.\", :active => true, :limit => 600, :condition => :greater_than, :condition_target => Alert::CONDITION_TARGET_ALL, :error_control => true, :service_id => @service.id, :hosts => [@host])\n end\n end", "def create\n @inventoryitem = Inventoryitem.new(params[:inventoryitem])\n\n respond_to do |format|\n if @inventoryitem.save\n format.html { redirect_to @inventoryitem, notice: 'Item was successfully created.' }\n format.json { render json: @inventoryitem, status: :created, location: @inventoryitem }\n else\n format.html { render action: \"new\" }\n format.json { render json: @inventoryitem.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @email_alert = EmailAlert.new(email_alert_params)\n\n respond_to do |format|\n if @email_alert.save\n format.html { redirect_to @email_alert, notice: 'Email alert was successfully created.' }\n format.json { render :show, status: :created, location: @email_alert }\n else\n format.html { render :new }\n format.json { render json: @email_alert.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n parameters = alert_params\n parameters[:service] = Service.where(:_id => parameters[:service_id]).first\n parameters[:hosts] = Host.where(:_id.in => parameters[:host_ids]).to_a if (!parameters[:host_ids].blank?)\n\n # Delete string'd id's\n parameters.delete(:service_id)\n parameters.delete(:host_ids)\n\n # Apply the params received\n @alert = Alert.new(parameters)\n\n respond_to do|format|\n format.html{\n # Can be saved?\n if (@alert.save)\n flash[:notice] = t(\"alerts.notice.created\", :name => @alert.name)\n redirect_to alert_path(@alert)\n else\n # If an error raises, show the form again.\n render :action => :new\n end\n return\n }\n end\n end", "def create\n @item_inventory = ItemInventory.new(item_inventory_params)\n\n respond_to do |format|\n if @item_inventory.save\n format.html { redirect_to @item_inventory, notice: 'Item inventory was successfully created.' }\n format.json { render :show, status: :created, location: @item_inventory }\n else\n format.html { render :new }\n format.json { render json: @item_inventory.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to :items, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @slot }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @status_item = StatusItem.new(status_item_params)\n\n respond_to do |format|\n if @status_item.save\n format.html { redirect_to status_items_path, notice: 'El estatus del artículo fue creado correctamente.' }\n format.json { render :show, status: :created, location: @status_item }\n else\n format.html { render :new }\n format.json { render json: @status_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @price_alert = PriceAlert.new(price_alert_params)\n\n respond_to do |format|\n if @price_alert.save\n format.html { redirect_to @price_alert, notice: 'Price alert was successfully created.' }\n format.json { render :show, status: :created, location: @price_alert }\n else\n format.html { render :new }\n format.json { render json: @price_alert.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to root_url, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, item: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n item = Item.new(item_params)\n item.user = current_user\n if item.save\n render json: item\n else\n render json: {errors: item.errors}, status: :unprocessable_entity\n end\n end", "def create\n # from mac - state, duration, uuid, major, minor\n # we have - current_employee.id , @beacon.id\n @alert = Alert.new(beacon_id: @beacon.id,\n duration: params[:duration],\n state: params[:state],\n employee_id: current_employee.id)\n if @alert.save\n render json: { success: \"PREY ACQUIRED! TRACKING MODE ACTIVATED! SCREEEEEEEEE!\" }, status: :ok\n else\n render json: { errors: @alert.errors.full_messages }, status: :unprocessable_entity\n end\n end", "def index\n @alerts = Alert.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @alerts }\n end\n end", "def index\n @alerts = Alert.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @alerts }\n end\n end", "def new\n @alert = Alert.new\n @selected = params[:alert_ids]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @alert }\n end\n end", "def create\n @item = @client.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully added.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admin_digitization_queue_item = Admin::DigitizationQueueItem.new(admin_digitization_queue_item_params)\n\n respond_to do |format|\n if @admin_digitization_queue_item.save\n # send an alert if email address is set\n if ScihistDigicoll::Env.lookup(:digitization_queue_alerts_email_address)\n DigitizationQueueMailer.with(digitization_queue_item: @admin_digitization_queue_item).new_item_email.deliver_later\n end\n\n format.html { redirect_to admin_digitization_queue_items_url(@admin_digitization_queue_item.collecting_area), notice: 'Digitization queue item was successfully created.' }\n format.json { render :show, status: :created, location: admin_digitization_queue_items_url(@admin_digitization_queue_item.collecting_area) }\n else\n format.html { render :new }\n format.json { render json: @admin_digitization_queue_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to '/items', notice: 'Item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n if @item.save\n render json: @item\n else\n render json: { error: t('story_create_error') }, status: :unprocessable_entity\n end\n end", "def create\n @item = Item.new(item_params)\n if @item.save\n render json: ItemSerializer.new(@item)\n else\n render json: @section.errors, status: :unprocessable_entity\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: \"Item was successfully created.\" }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @api_v1_item = Item.new(api_v1_item_params)\n\n if @api_v1_item.save\n render json: @api_v1_item\n else\n render json: @api_v1_item.errors\n end\n end", "def create\n # defined object to receive strict item_params including :description, :price, :stockQty ; else return 400\n @item = Item.new(item_params)\n \n if @item.save\n render json: @item.to_json, status: 201\n else\n head 400\n end\n end", "def create\n @request_item = RequestItem.new(request_item_params)\n @request_item.item = Item.new(name: params[:request_item][:item][:name])\n\n if @request_item.save\n render json: @request_item \n else\n render json: @request_item.errors, status: :bad_request\n end\n end", "def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to lists_path, :notice => 'Item was successfully created.' }\n format.json { render :json => lists_path, :status => :created, :location => lists_path }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n @item.views_count = 0\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n action = params[:oper]\n if action == \"add\"\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n StoreActivity.leave(:item => @item,\n :action => :create,\n :user => current_user\n )\n format.html { render :nothing => true, :status => 200 }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render :nothing => true, :status => 500 }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n elsif action == \"edit\"\n @item = Item.find(params[:id])\n first_count = @item.count\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n\n StoreActivity.leave(:item => @item,\n :action => :edit,\n :user => current_user,\n :count => @item.count,\n :first_count => first_count\n )\n format.html { render :nothing => true, :status => 200 }\n format.json { head :no_content }\n else\n format.html { render :nothing => true, :status => 500 }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n @itemstatus = Itemstatus.new(params[:itemstatus])\n\n respond_to do |format|\n if @itemstatus.save\n format.html { redirect_to @itemstatus, notice: 'Itemstatus was successfully created.' }\n format.json { render json: @itemstatus, status: :created, location: @itemstatus }\n else\n format.html { render action: \"new\" }\n format.json { render json: @itemstatus.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @survey_answer_item = SurveyAnswerItem.new(params[:survey_answer_item])\n\n respond_to do |format|\n if @survey_answer_item.save\n format.html { redirect_to @survey_answer_item, notice: 'Survey answer item was successfully created.' }\n format.json { render json: @survey_answer_item, status: :created, location: @survey_answer_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @survey_answer_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @hamper_item = HamperItem.new(hamper_item_params)\n\n respond_to do |format|\n if @hamper_item.save\n format.html { redirect_to @hamper_item, notice: 'Hamper item was successfully created.' }\n format.json { render :show, status: :created, location: @hamper_item }\n else\n format.html { render :new }\n format.json { render json: @hamper_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def alerts=(value)\n @alerts = value\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #api_key = \"cb8d3966-e1c6-4429-a8cf-b615523481c4\"\n\n @item = Item.new(item_params)\n\n @swift_api_key = SwiftApiKey.first\n\n api_key = @swift_api_key.key\n\n HTTParty.post(\"https://app.getswift.co/api/v2/deliveries\",\n {\n :body => {\n \"apiKey\": api_key,\n \"booking\":{\n \"items\": [{\n \"quantity\": @item.quantity,\n \"sku\": @item.sku,\n \"description\": @item.description,\n \"price\": @item.price\n }],\n \"pickupDetail\": {\n \"name\": \"Marko\",\n \"phone\": \"604 356 8259\",\n \"address\": \"301 Maude Road, Port Moody, V3H5B1\"\n },\n \"dropoffDetail\": {\n \"name\": @item.name,\n \"phone\": @item.phone,\n \"address\": @item.address\n }\n }\n }.to_json,\n :headers => { 'Content-Type' => 'application/json' }\n }\n )\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n \n respond_to do |format|\n if @item.save \n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_alert(obj, alert_type)\n alert = self.alerts.new\n alert.thing = obj\n alert.reason_type = alert_type\n alert.save\n end", "def create\n @inventory_item = InventoryItem.new(inventory_item_params)\n puts(params)\n\n respond_to do |format|\n if @inventory_item.save\n format.html { redirect_to backoffice_inventory_list_path, notice: 'Bem de patrimônio criado com sucesso.' }\n format.json { render :show, status: :created, location: @inventory_item }\n else\n format.html { render :new, notice: 'Algo de errado aconteceu.' }\n format.json { render json: @inventory_item.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 @item_alias = ItemAliase.new(item_alias_params)\n\n if @item_alias.save\n render :show, status: :created, location: @item_alias\n else\n render json: @item_alias.errors, status: :unprocessable_entity\n end\n end", "def create\n @survey_item = SurveyItem.new(survey_item_params)\n\n respond_to do |format|\n if @survey_item.save\n format.html { redirect_to @survey_item, notice: 'Survey item was successfully created.' }\n format.json { render :show, status: :created, location: @survey_item }\n else\n format.html { render :new }\n format.json { render json: @survey_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @food_item_add_on = FoodItemAddOn.new(food_item_add_on_params)\n\n\n\n#Todo: can select multiple items for a sinfle addons\n respond_to do |format|\n if @food_item_add_on.save\n format.html { redirect_to :controller => 'home', :action => 'dashboard' }\n format.json { render :show, status: :created, location: @food_item_add_on }\n else\n format.html { render :new }\n format.json { render json: @food_item_add_on.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\titem = Item.create(item_params)\n\t\trender json: item\n\tend", "def create\n @apiv1_item = Item.new(apiv1_item_params)\n\n respond_to do |format|\n if @apiv1_item.save\n format.html { redirect_to @apiv1_item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @apiv1_item }\n else\n format.html { render :new }\n format.json { render json: @apiv1_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def alert_params\n params.require(:alert).permit(:title, :message, :begins, :ends)\n end", "def create\n @item = Item.new(item_save_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @test_item = TestItem.new(test_item_params)\n\n respond_to do |format|\n if @test_item.save\n format.html { redirect_to @test_item, notice: 'Test item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @test_item }\n else\n format.html { render action: 'new' }\n format.json { render json: @test_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @intitem = Intitem.new(intitem_params)\n\n respond_to do |format|\n if @intitem.save\n format.html { redirect_to @intitem, notice: 'Intitem was successfully created.' }\n format.json { render :show, status: :created, location: @intitem }\n else\n format.html { render :new }\n format.json { render json: @intitem.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @alerts = Alert.all\n end", "def index\n @alerts = Alert.all\n end", "def index\n @alerts = Alert.all\n end", "def new\n @alert = Alert.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @alert }\n end\n end", "def create\n @set_item = SetItem.new(set_item_params)\n\n @set_item.vote_count = 0\n @set_item.play_count = 0\n respond_to do |format|\n if @set_item.save\n format.html { redirect_to event_url(params[:event_id]) }\n format.json { render action: 'show', status: :created, location: @set_item }\n else\n format.html { render action: 'new' }\n format.json { render json: @set_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @alert = Alert.new(params[:alert])\n respond_to do |format|\n if @alert.save\n format.html { redirect_to(alerts_path, :notice => 'Alert was successfully created.') }\n format.xml { render :xml => @alert, :status => :created, :location => @alert }\n else\n NO_OF_IMAGES.times {@alert.alert_uploads.build}\n format.html { render :action => \"new\" }\n format.xml { render :xml => @alert.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @alert = Alert.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @alert }\n end\n end", "def create\n \n #debug\n write_log(\n Const::SL::LOG_PATH_SL,\n \"items_controller#create(params[:item] => #{params[:item]})\",\n # __FILE__,\n __FILE__.split(\"/\")[-1],\n __LINE__.to_s)\n\n \n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6206999", "0.6036369", "0.6022345", "0.5936935", "0.5878697", "0.5853556", "0.58084035", "0.5782575", "0.57697564", "0.57670176", "0.5693192", "0.5668247", "0.56330496", "0.5615316", "0.56021184", "0.559469", "0.55924493", "0.55824566", "0.55732167", "0.55604225", "0.55577564", "0.55555296", "0.5531507", "0.5522656", "0.55117196", "0.5492629", "0.54911524", "0.5482543", "0.5476983", "0.54766226", "0.54766226", "0.5469667", "0.5465977", "0.5458036", "0.5444313", "0.5436248", "0.5436214", "0.5426309", "0.54177856", "0.54177856", "0.54177856", "0.54177856", "0.54177856", "0.54177856", "0.54177856", "0.54174453", "0.5412352", "0.54122394", "0.5410615", "0.5402847", "0.5399575", "0.53980255", "0.5392135", "0.53913087", "0.5380536", "0.5377075", "0.5377075", "0.5377075", "0.5377075", "0.5377075", "0.5377075", "0.5377075", "0.5377075", "0.5377075", "0.5377075", "0.5377075", "0.5377075", "0.5377075", "0.5377075", "0.5377075", "0.5377075", "0.53745884", "0.5371719", "0.5364767", "0.5364767", "0.5364767", "0.5364767", "0.5364767", "0.53626484", "0.5362264", "0.5348828", "0.5348756", "0.53458554", "0.5343138", "0.53394526", "0.5338064", "0.53306836", "0.5323318", "0.53223795", "0.531423", "0.53055584", "0.5301895", "0.52958375", "0.52958375", "0.52958375", "0.52953404", "0.52832675", "0.5281852", "0.5281758", "0.5280949" ]
0.69677263
0
PUT /item_alerts/1 PUT /item_alerts/1.json
def update @item_alert = ItemAlert.find(params[:id]) authorize! :create, @item_alert respond_to do |format| # if @item_alert.update_attributes(params[:item_alert]) if @item_alert.update_attributes(item_alert_params) format.html do redirect_to @item_alert, notice: 'Item alert was successfully updated.' end format.json { head :no_content } else format.html { render 'edit' } format.json do render json: @item_alert.errors, status: :unprocessable_entity end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @item.update(item_params)\n render json: @item, status: :ok\n else\n render json: @item.errors, status: :unprocessable_entity\n end\n end", "def update\n render json: Item.update(params[\"id\"], params[\"item\"])\n end", "def update\n\n if @api_v1_item.update(api_v1_item_params)\n render json: @api_v1_item\n else\n render json: @api_v1_item.errors\n end\n end", "def update\n @alert = Alert.find(params[:id])\n notifiers = Hash.new\n User.find(params[:notifiers]).each{|user| notifiers[user.id] = 0}\n @alert.notifiers = notifiers\n @alert.host = params[:host]\n @alert.trigger = params[:trigger]\n respond_to do |format|\n if @alert.update_attributes(params[:alert])\n format.html { redirect_to @alert, notice: 'Alert was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @alert.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = \"Vger::Resources::#{params[:item][:item_type]}\".constantize.find(params[:id])\n respond_to do |format|\n if @item.class.save_existing(params[:id], params[:item])\n format.html { redirect_to suitability_item_path(params[:id]), notice: 'Suitability Item was successfully updated.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @set_item.vote_count += 1\n @set_item.save\n redirect_to live_event_path(@set_item.event.code)\n # respond_to do |format|\n # if @set_item.update(set_item_params)\n # format.html { redirect_to @set_item, notice: 'Set item was successfully updated.' }\n # format.json { head :no_content }\n # else\n # format.html { render action: 'edit' }\n # format.json { render json: @set_item.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def update\n if @item.update_attributes(item_params)\n render json: @item, status: :ok\n else\n render_error(@item, :unprocessable_entity)\n end\n end", "def update_item(item_id)\n request_body = {\n 'name' => 'Malted Milkshake'\n }\n\n response = Unirest.put CONNECT_HOST + '/v1/' + LOCATION_ID + '/items/' + item_id,\n headers: REQUEST_HEADERS,\n parameters: request_body.to_json\n\n if response.code == 200\n puts 'Successfully updated item:'\n puts JSON.pretty_generate(response.body)\n return response.body\n else\n puts 'Item update failed'\n puts response.body\n return nil\n end\nend", "def update\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = \"Item has been updated\"\n format.json { render :json => @item.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { render :action => :edit }\n else\n format.json { render :text => \"Could not update item\", :status => :unprocessable_entity } #placeholder\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n format.html { render :action => :edit, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @alert = Alert.find(params[:id])\n\n respond_to do |format|\n if @alert.update_attributes(params[:alert])\n format.html { redirect_to(alerts_path, :notice => 'Alert was successfully updated.') }\n format.xml { head :ok }\n else\n if @alert.alert_uploads.count != NO_OF_IMAGES\n @alert.alert_uploads.count + ( NO_OF_IMAGES - @alert.alert_uploads.count).times{@alert.alert_uploads.build}\n end\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @alert.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @alert = Alert.find(params[:id])\n\n respond_to do |format|\n if @alert.update_attributes(params[:alert])\n format.html { redirect_to @alert, notice: 'Alert was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @alert.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_rest\n @item_usage = ItemUsage.find(params[:id])\n\n respond_to do |format|\n if @item_usage.update_attributes(params[:item_usage])\n flash[:notice] = 'ItemUsage was successfully updated.'\n format.html { redirect_to(@item_usage) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item_usage.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @apiv1_item.update(apiv1_item_params)\n format.html { redirect_to @apiv1_item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @apiv1_item }\n else\n format.html { render :edit }\n format.json { render json: @apiv1_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = @client.items.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @alert = Alert.find(params[:id])\n\n respond_to do |format|\n if @alert.update_attributes(params[:alert])\n format.html { redirect_to user_path(current_user), notice: 'Alert was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @alert.errors, status: :unprocessable_entity }\n end\n end\n end", "def item_update\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to item_show_path(@item), notice: 'O item foi atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n Rails.logger.debug params.inspect\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update_attributes(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n respond_with(@items)\n end\n end\n end", "def update\n\n #update the item of request_item\n if (params[:request_item].present?)\n @request_item.item = params[:request_item][:item].present? ? Item.new(name: params[:request_item][:item][:name]) : @request_item.item\n end\n #update all other parameters\n if @request_item.update(request_item_params)\n render json: @request_item\n else\n render json: @request_item.errors, status: :bad_request\n end\n\n end", "def update\n respond_to do |format|\n if @lint_item.update(lint_item_params)\n format.html { redirect_to @lint_item, notice: 'Lint item was successfully updated.' }\n format.json { render :show, status: :ok, location: @lint_item }\n else\n format.html { render :edit }\n format.json { render json: @lint_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @alerts = args[:alerts] if args.key?(:alerts)\n end", "def update\n respond_to do |format|\n if @alert.update(alert_params)\n format.html { redirect_to @alert, notice: \"Alert was successfully updated.\" }\n format.json { render :show, status: :ok, location: @alert }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @alert.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @alert.update(alert_params)\n format.html { redirect_to [:admins, @current_event, @alert], notice: t(\"alerts.updated\") }\n format.json { render json: @alert, status: :ok, location: [:admins, @current_event, @alert] }\n else\n format.html { render :edit }\n format.json { render json: @alert.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @alert.update(alert_params)\n format.html { redirect_to @alert, notice: 'Alert was successfully updated.' }\n format.json { render :show, status: :ok, location: @alert }\n else\n format.html { render :edit }\n format.json { render json: @alert.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @alert.update(alert_params)\n format.html { redirect_to @alert, notice: 'Alert was successfully updated.' }\n format.json { render action: 'show', status: :ok, location: @alert }\n else\n format.html { render action: 'edit' }\n format.json { render json: @alert.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item_alert = ItemAlert.new(item_alert_params)\n authorize! :create, ItemAlert\n\n respond_to do |format|\n if @item_alert.save\n format.html do\n redirect_to @item_alert, notice: 'Item alert was successfully created.'\n end\n format.json do\n render json: @item_alert, status: :created, location: @item_alert\n end\n else\n format.html { render 'new' }\n format.json do\n render json: @item_alert.errors, status: :unprocessable_entity\n end\n end\n end\n end", "def update\r\n @item = Item.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @item.update_attributes(params[:item])\r\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\r\n format.json { head :ok }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @item.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to items_path, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n# @item = Item.get(params[:id])\n\n respond_to do |format|\n if @item.update(params[:item])\n format.html { redirect_to({action: :show, id: @item}, notice: 'Item was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n user = User.find(session[:id])\n alert = {:title => alert_params[:title], :city_name => alert_params[:city_name], :alert_time => alert_params[:alert_time], :user => user }\n respond_to do |format|\n if @alert.update(alert)\n format.html { redirect_to('/alerts', notice: 'Alert was successfully updated.')}\n format.json { render :show, status: :ok, location: @alert }\n else\n format.html { render :edit }\n format.json { render json: @alert.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(item_params)\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.name, status: :unprocessable_entity }\n # format.html { render json: @item, notice: 'Item was not successfully updated.' }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_rest\n @entry_item = EntryItem.find(params[:id])\n\n respond_to do |format|\n if @entry_item.update_attributes(params[:entry_item])\n flash[:notice] = 'EntryItem was successfully updated.'\n #format.html { redirect_to(@entry_item) }\n format.xml { head :ok }\n else\n #format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to '/items', notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n @item.update_attributes(params[:item])\n respond_with @item\n end", "def update_alert(alert_name, project_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'PUT'\n\t\targs[:path]['AlertName'] = alert_name\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:pattern] = '/projects/[ProjectName]/alerts/[AlertName]'\n\t\targs[:query]['Action'] = 'UpdateAlert'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :alert\n\t\t\targs[:body]['Alert'] = optional[:alert]\n\t\tend\n\t\tself.run(args)\n\tend", "def item_inventory_update\n \n item = Item.find(params[:item_id])\n order= Order.find(params[:id])\n item_order = ItemOrder.where(item_id: item.id, order_id: order.id).first\n new_inventory = item.inventory - item_order.quantity\n item_order.update(status: \"fulfilled\")\n item.update(inventory: new_inventory)\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to items_path, notice: 'Item ' + @item.name + ' was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: \"Item was successfully updated.\" }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: \"Item was successfully updated.\" }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: \"Item was successfully updated.\" }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: \"Item was successfully updated.\" }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @itemstatus = Itemstatus.find(params[:id])\n\n respond_to do |format|\n if @itemstatus.update_attributes(params[:itemstatus])\n format.html { redirect_to @itemstatus, notice: 'Itemstatus was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @itemstatus.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n\n\n end", "def update\n @item = Item.find(params[:id])\n @statuses = ItemStatus.all\n @tags= Item.all_tags\n \n delete_images \n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n if current_user and current_user.role_id == 1\n Notifier.item_updated(@item).deliver\n format.html { redirect_to(manage_items_url, :notice => 'Item was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { redirect_to(@item, :notice => 'Item was successfully updated.') }\n format.xml { head :ok }\n end\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to root_path, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @inventoryitem = Inventoryitem.find(params[:id])\n\n respond_to do |format|\n if @inventoryitem.update_attributes(params[:inventoryitem])\n format.html { redirect_to @inventoryitem, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inventoryitem.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @toodoo_item.update(toodoo_item_params)\n format.html { redirect_to @toodoo_item, notice: 'Toodoo item was successfully updated.' }\n format.json { render :show, status: :ok, location: @toodoo_item }\n else\n format.html { render :edit }\n format.json { render json: @toodoo_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @considered_item.update(considered_item_params)\n format.html { redirect_to @considered_item, notice: 'Considered item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @considered_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to [@item.user, @item], notice: t('.notice') }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to lists_path, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6448728", "0.6427076", "0.6404043", "0.6318351", "0.6289061", "0.62789416", "0.6225659", "0.62192327", "0.61859727", "0.61685854", "0.6133771", "0.6128254", "0.6102616", "0.6091629", "0.6080883", "0.60655695", "0.6048288", "0.6044828", "0.6044785", "0.60419357", "0.603559", "0.60338986", "0.6027182", "0.6016623", "0.6011002", "0.6009958", "0.6006995", "0.6005442", "0.6003301", "0.6002305", "0.6002305", "0.60019773", "0.59991956", "0.59926885", "0.599102", "0.5979092", "0.5979092", "0.5979092", "0.5979092", "0.5979092", "0.5979092", "0.5979092", "0.5979092", "0.5979092", "0.5979092", "0.5979092", "0.59780294", "0.59620804", "0.5952373", "0.59512794", "0.5937999", "0.5937823", "0.59362966", "0.59334743", "0.59334743", "0.59334743", "0.59334743", "0.59332734", "0.59332734", "0.59332734", "0.59332734", "0.59332734", "0.59332734", "0.59332734", "0.59332734", "0.59332734", "0.5912773", "0.59075934", "0.590531", "0.59042394", "0.5901654", "0.5896747", "0.58942026", "0.5893441", "0.5886824", "0.58846474", "0.58825517", "0.5881151", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385", "0.58807385" ]
0.7063758
0
DELETE /item_alerts/1 DELETE /item_alerts/1.json
def destroy @item_alert = ItemAlert.find(params[:id]) @item_alert.destroy authorize! :delete, @item_alert respond_to do |format| format.html { redirect_to item_alerts_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_item(item_id)\n response = Unirest.delete CONNECT_HOST + '/v1/' + LOCATION_ID + '/items/' + item_id,\n headers: REQUEST_HEADERS\n\n if response.code == 200\n puts 'Successfully deleted item'\n return response.body\n else\n puts 'Item deletion failed'\n puts response.body\n return nil\n end\nend", "def delete\n render json: Item.delete(params[\"id\"])\n end", "def destroy\n @api_v1_item.destroy\n render json: {message: 'deletado com sucesso'}\n end", "def destroy\n @alert = Alert.find(params[:id])\n @alert.destroy\n\n respond_to do |format|\n format.html { redirect_to alerts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @alert = Alert.find(params[:id])\n @alert.destroy\n\n respond_to do |format|\n format.html { redirect_to alerts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @alert.destroy\n respond_to do |format|\n format.html { redirect_to alerts_path }\n format.json { head :no_content }\n end\n end", "def delete_item(id)\n record \"/todos/delete_item/#{id}\"\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 @apiv1_item.destroy\n respond_to do |format|\n format.html { redirect_to apiv1_items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = @client.items.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully removed from Inventory.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n# @item = Item.get(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to({action: :index}, notice: 'Item was successfully deleted.') }\n format.json { head :ok }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n render status: 200, json: @request_item.destroy\n end", "def destroy\n @itemstatus = Itemstatus.find(params[:id])\n @itemstatus.destroy\n\n respond_to do |format|\n format.html { redirect_to itemstatuses_url }\n format.json { head :ok }\n end\n end", "def destroy_rest\n @item_usage = ItemUsage.find(params[:id])\n @item_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to(item_usages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @alert = Alert.find(params[:id])\n @alert.destroy\n\n respond_to do |format|\n format.html { redirect_to(alerts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to '/items', notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :ok }\n end\n end", "def destroy\n item = @item.name\n @item.deleted = true\n @item.deleted_at = Time.now\n @item.save\n\n respond_to do |format|\n format.html { redirect_to items_url, notice: \"#{item} was successfully deleted.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @alert = Alert.find(params[:id])\n @alert.destroy\n\n respond_to do |format|\n format.html { redirect_to user_path(current_user) }\n format.json { head :no_content }\n end\n end", "def item_destroy\n @item = Item.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.html { redirect_to item_index_path, notice: 'O item foi removido com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @rackitem = Rackitem.find(params[:id])\n @rackitem.destroy\n\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Rackitem removed' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_item = Admin::Item.find(params[:id])\n @admin_item.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_item = Admin::Item.find(params[:id])\n @admin_item.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :ok }\n format.xml { head :ok }\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 @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def destroy#\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @log_item.destroy\n\n respond_to do |format|\n format.html { redirect_to goal_log_items_url }\n format.json { head :ok }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url}\n format.json { head :no_content }\n end\n end", "def destroy\n # @item.destroy\n # respond_to do |format|\n # format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n # format.json { head :no_content }\n # end\n end", "def destroy_rest\n @entry_item = EntryItem.find(params[:id])\n @entry_item.destroy\n\n respond_to do |format|\n #format.html { redirect_to(entry_items_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @inventoryitem = Inventoryitem.find(params[:id])\n @inventoryitem.destroy\n\n respond_to do |format|\n format.html { redirect_to inventoryitems_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to tasks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sub1_line_item.destroy\n respond_to do |format|\n format.html { redirect_to sub1_line_items_url, notice: 'Sub1 line item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to itemstores_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.70364356", "0.6982611", "0.69521034", "0.691859", "0.6917775", "0.68811953", "0.68722075", "0.6864879", "0.6854338", "0.68435425", "0.6801066", "0.6799383", "0.6771074", "0.6751779", "0.6750032", "0.67378694", "0.6725671", "0.66899264", "0.6674385", "0.6665564", "0.6645596", "0.66279227", "0.6622489", "0.66165614", "0.6616497", "0.6616497", "0.6616497", "0.6616497", "0.6616497", "0.6616497", "0.6616497", "0.6616497", "0.6616497", "0.6616497", "0.6616497", "0.6616497", "0.6616497", "0.6616497", "0.6616497", "0.6614461", "0.6614461", "0.6613135", "0.66123986", "0.660573", "0.6603148", "0.6603148", "0.6603148", "0.6603148", "0.6603148", "0.6603148", "0.6603148", "0.6603148", "0.6603148", "0.6603148", "0.6598903", "0.65968484", "0.6587275", "0.6577859", "0.65759456", "0.65725595", "0.65557706", "0.65510803", "0.65452045", "0.6537968", "0.6535952", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576", "0.6532576" ]
0.7485512
0
Get bookmarks without setting a user in data store
def test_get_bookmarks_nouser ds = BookmarkStore.new($conn_str) assert_raises(RuntimeError) { ds.get_bookmarks } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bookmarks(user)\n user = Access::Validate.user(user, false)\n Bookmark\n .where('(bookmarks.creator_id = ? OR bookmarks.updater_id = ?)', user.id, user.id)\n .order('bookmarks.updated_at DESC')\n end", "def index\n @bookmarks = Bookmark.user_bookmarks(current_user)\n end", "def index\n @bookmarks = Bookmark.where(owner: current_user)\n end", "def list_bookmarks(user_id)\n url = \"#{@@request_url}/User.listBookmarks?appid=#{@@appid}&ID=#{user_id}\"\n end", "def index\n\t\trespond_with current_user.bookmarks\n\tend", "def bookmarks\n @user = User.find(params[:id])\n\n render :status => 404 and return if @user.nil?\n\n # Grab Bookmarks and Render Them Out\n @bookmarks = @user.current_bookmarks\n render_collection_json Serialize::BookmarksSerializer.as_json_with_current_entries(@bookmarks, @user)\n end", "def get_bookmarks\n @logger.debug \"Fetching bookmarks from Delicious\"\n bookmarks = []\n doc = REXML::Document.new(open(\"http://feeds.delicious.com/v2/rss/#{@username}?count=5\"))\n doc.each_element('//channel/item') do |item|\n bookmarks << {\n :title => item.get_text('title'),\n :url => item.get_text('link'),\n :date => Date.parse(item.get_text('pubDate').to_s)\n }\n end\n return bookmarks\n end", "def index\n# Bookmark.destroy_all\n# @bookmarks = Bookmark.all\n\n# Get all bookmarks related to user where the primary key of User record is in session[:user_id]\n @bookmarks =User.find(session[:user_id]).bookmarks.scoped\n @[email protected](:name)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookmarks }\n end\n end", "def get_bookmarks(name, bookmark_path, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_bookmarks_with_http_info(name, bookmark_path, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_bookmarks_with_http_info(name, bookmark_path, opts)\n else\n raise\n end\n return data\n end", "def bookmark_object(the_user)\n the_user.bookmarked_posts.find_by_post_id(id)\n end", "def search\n @user = User.find(params[:user_id])\n @tags = show_user_tags @user\n result_search = search_bookmarks_by params[:tag_name], @user\n\n if current_user? @user\n @bookmarks = result_search.paginate(page: params[:page], per_page: 10) \n else\n temp = []\n result_search.each do |bookmark|\n unless bookmark.privacy? then\n temp.push(bookmark)\n end\n end\n @bookmarks = temp.paginate(page: params[:page], per_page: 10)\n end\n end", "def get_bookmarks_for_user(user_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url\n FROM bookmarks b, web_pages w\n WHERE b.web_page_id = w.id\n AND user_id = $1\n EOS\n bms = @conn.exec(query, [user_id])\n Bookmark.build(bms)\n end", "def bookmarks\n full = options[:full]\n docs = options[:doc] && documents.map { |doc| [doc.id, doc] }.to_h\n item_list.map { |item|\n next unless item.is_a?(Bookmark)\n entry = {\n document_id: item.document_id,\n document_type: item.document_type.to_s,\n lens: item.lens,\n updated_at: item.updated_at,\n created_at: item.created_at,\n }\n full && entry.merge!(\n title: item.user_type, # TODO: not persisted; should it be?\n id: item.id,\n user_id: item.user_id,\n user_type: item.user_type,\n )\n docs && entry.merge!(doc: docs[item.document_id])\n entry\n }.compact.as_json\n end", "def bookmarks\n\t\toptions = { list: true }\n\t\tresponse = self.server.run_with_json_template( :bookmarks, **options )\n\t\treturn response.map {|bk| Hglib::Repo::Bookmark.new(self, **bk) }\n\tend", "def bookmarks\n xpath './bookmark'\n end", "def bookmark_by(u)\r\n Bookmark.bookmark_by(u, self)\r\n end", "def index\n @bookmarks = BookmarkLister.new(@tag || current_user)\n .(query: params[:q], by: params[:by])\n .to_a\n end", "def user_index\n @user = params[:user]\n @results = []\n \n u = User.where(name: params[:user]).first\n \n if u == nil\n redirect_to :root\n else \n u.bookmarks.each do |b|\n user_url = \"/\" + u.name\n entry = {id: b.id, url: b.url, title: b.title, user: b.user, name: u.name, user_url: user_url}\n @results.push(entry)\n end\n end\n end", "def get_document_bookmarks(name, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_bookmarks_with_http_info(name, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_bookmarks_with_http_info(name, opts)\n else\n raise\n end\n return data\n end", "def is_bookmarked user\n Bookmark.find_by(user_id: user_id, post_id: id)\n end", "def index\n @public_bookmarks = PublicBookmark.all\n end", "def get_bookmark_for_user(user_id, bookmark_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url \n FROM bookmarks b, users u, web_pages w\n WHERE b.user_id = u.id\n AND b.web_page_id = w.id\n AND b.user_id = $1\n AND b.id = $2\n EOS\n bm = @conn.exec(query, [user_id, bookmark_id]).first\n unless bm == nil\n bm = Bookmark.new(bm)\n end\n bm \n end", "def get_pinned_bookmarks_for_user(user_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url\n FROM bookmarks b, web_pages w\n WHERE b.web_page_id = w.id\n AND user_id = $1\n AND is_pinned = TRUE\n EOS\n pbms = @conn.exec(query, [user_id])\n Bookmark.build(pbms)\n end", "def bookmark_query(q,&blk)\n response = query(q)\n bookmark = response[\"bookmark\"]\n docs = response[\"docs\"]\n\n until !docs || docs.empty?\n yield docs\n q[\"bookmark\"] = bookmark\n response = query(q)\n bookmark = response[\"bookmark\"]\n docs = response[\"docs\"]\n end\n\n docs\n end", "def existing_bookmark_for(document_id)\n # to_a, we don't want to go to the database, we want to use cached\n # copy. \n self.bookmarks.to_a.find {|b| b.document_id == document_id}\n end", "def index\n if logged_in?\n @bookmarks = @current_user.bookmarks.pluck(:story_id)\n respond_to do |format|\n format.json { render json: {ids: @bookmarks} }\n format.html { redirect_to bookmarks_url }\n end\n else\n redirect_to bookmarks_url\n end\n end", "def index\n @bookmarklets = Bookmarklet.find(:all)\n if logged_in?\n @user_bookmarkltes = current_user.bookmarklets\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookmarklets }\n end\n end", "def general_bookmarks\n @general_bookmarks ||=\n Bookmark.with_missing_bookmarkable.or(\n Bookmark.with_bookmarkable_visible_to_registered_user\n ).is_public\n end", "def show\n @end_user = EndUser.find(params[:id])\n @post = @end_user.posts.all\n @bkm = @end_user.bookmarks.all\n end", "def remember_bookmark\n @ole.RememberBookmark\n end", "def bookmarked_by_user?(user)\n bookmark_object(user).present?\n end", "def index\n @bookmarks = Bookmark.all\n end", "def index\n @bookmarks = Bookmark.all\n end", "def index\n @results = []\n \n Bookmark.all.each do |b|\n user_url = \"/\" + b.user.name\n entry = {id: b.id, url: b.url, title: b.title, user: b.user, name: b.user.name, user_url: user_url }\n @results.push(entry)\n end\n end", "def index\n bookmarks_loader(Time.now, current_user.id) \n bookmark = @bookmarks.first\n if bookmark\n session[:first_link_time] = bookmark.updated_at \n end \n bookmark = @bookmarks.last\n if bookmark\n session[:last_link_time] = bookmark.updated_at\n end \n end", "def index\n search = Bookmark.search(:include => [:manifestation])\n query = params[:query].to_s.strip\n unless query.blank?\n @query = query.dup\n end\n user = @user\n unless current_user.has_role?('Librarian')\n if user and user != current_user and !user.try(:share_bookmarks)\n access_denied; return\n end\n if current_user == @user\n redirect_to bookmarks_url\n return\n end\n end\n\n search.build do\n fulltext query\n order_by(:created_at, :desc)\n if user\n with(:user_id).equal_to user.id\n else\n with(:user_id).equal_to current_user.id\n end\n end\n page = params[:page] || \"1\"\n flash[:page] = page if page.to_i >= 1\n search.query.paginate(page.to_i, Bookmark.default_per_page)\n @bookmarks = search.execute!.results\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bookmarks }\n end\n end", "def index\n\t\t@bookmarks = Bookmark.all\n\tend", "def bookmarks(bookmarks)\n bookmarks.each_with_object({}) do |b, bs|\n first_image = b.entry.entry_images.min_by(&:pocket_image_id)\n bs[b.id] = {\n id: b.id.to_s,\n title: b.entry.resolved_title,\n url: b.entry.url,\n status: b.status,\n addedAt: b.added_to_pocket_at.to_i,\n archivedAt: b.archived_at&.to_i,\n favorite: b.favorite,\n thumbnailUrl: determine_image_url(first_image),\n }\n end\n end", "def set_bookmark\n @bookmark = current_user.bookmarks.find(params[:id])\n end", "def test_get_by_bookmark_id\n\n comments = Comment.getByBookmarkId(1)\n \n comment = comments[0]\n\n assert_equal 1, comment.commentId\n assert_equal \"This is a comment\", comment.content\n assert_equal 1, comment.bookmarkId\n assert_equal 1, comment.userId\n\n end", "def index\n if session[:user_id]\n @bookmarks = Bookmark.all(:conditions => \"user_id = \"+session[:user_id].to_s)\n user = User.find(session[:user_id])\n \n @background = Rails.root + '/data/' + user.background\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookmarks }\n end\n else\n redirect_to \"/login\"\n end\n end", "def atom_feed_for(bookmarks, title, feed_uri, user=nil)\n feed = Atom::Feed.new\n feed.title = title\n most_recent_bookmark = bookmarks.max do |b1,b2|\n b1.timestamp <=> b2.timestamp\n end\n feed.updated = most_recent_bookmark.timestamp\n\n # Link this feed to itself\n self_link = feed.links.new\n self_link['rel'] = 'self'\n self_link['href'] = feed_uri + \".atom\"\n\n # If this list is a list of bookmarks from a single user, that user is\n # the author of the feed.\n if user\n user_to_atom_author(user, feed)\n end\n\n # Turn each bookmark in the list into an entry in the feed.\n bookmarks.each do |bookmark|\n entry = feed.entries.new\n entry.title = bookmark.short_description\n entry.content = bookmark.long_description\n\n # In a real application, a bookmark would have a separate\n # \"modification date\" field which was not under the control of\n # the user. This would also make the Last-Modified calculations\n # more accurate.\n entry.updated = bookmark.timestamp \n\n # First, link this Atom entry to the external URI that the\n # bookmark tracks.\n external_uri = entry.links.new\n external_uri['href'] = bookmark.uri\n\n # Now we give some connectedness to this service. Link this Atom\n # entry to this service's resource for this bookmark.\n bookmark_resource = entry.links.new\n bookmark_resource['rel'] = \"self\"\n bookmark_resource['href'] = bookmark_url(bookmark.user.name, \n bookmark.uri_hash) + \".atom\"\n bookmark_resource['type'] = \"application/xml+atom\"\n\n # Then link this entry to the list of users who've bookmarked\n # this URI.\n other_users = entry.links.new\n other_users['rel'] = \"related\"\n other_users['href'] = uri_url(bookmark.uri_hash) + \".atom\"\n other_users['type'] = \"application/xml+atom\"\n\n # Turn this entry's user into the \"author\" of this entry, unless\n # we already specified a user as the \"author\" of the entire\n # feed.\n unless user\n user_to_atom_author(bookmark.user, entry) \n end\n\n # For each of this bookmark's tags...\n bookmark.tags.each do |tag|\n # ...represent the tag as an Atom category.\n category = entry.categories.new\n category['term'] = tag\n category['scheme'] = user_url(bookmark.user.name) + \"/tags\"\n\n # Link to this user's other bookmarks tagged using this tag.\n tag_uri = entry.links.new\n tag_uri['href'] = tag_url(bookmark.user.name, tag.name) + \".atom\"\n tag_uri['rel'] = 'related'\n tag_uri['type'] = \"application/xml+atom\"\n\n # Also link to all bookmarks tagged with this tag.\n recent_tag_uri = entry.links.new\n recent_tag_uri['href'] = recent_url(tag.name) + \".atom\"\n recent_tag_uri['rel'] = 'related'\n recent_tag_uri['type'] = \"application/xml+atom\"\n end\n end \n return feed.to_xml\n end", "def test_get_bookmark\n exp_bm = get_bookmark(@bs.user_id, 'http://www.ml-class.com/')\n act_bm = @bs.get_bookmark(4)\n assert(exp_bm === act_bm)\n end", "def render_bookmarks(bookmarks, title, feed_uri, user, except=[])\n # Figure out a current value for the Last-Modified header.\n if bookmarks.empty?\n last_modified = nil\n else\n # Last-Modified is the most recent timestamp in the bookmark list.\n most_recent_bookmark = bookmarks.max do |b1,b2|\n b1.timestamp <=> b2.timestamp\n end\n last_modified = most_recent_bookmark.timestamp\n end\n \n # If the bookmark list has been modified since it was last requested...\n render_not_modified_or(last_modified) do\n respond_to do |format|\n # If the client requested XML, serialize the ActiveRecord\n # objects to XML. Include references to the tags in the\n # serialization.\n format.xml { render :xml => \n bookmarks.to_xml(:except => except + [:id, :user_id],\n :include => [:tags]) }\n # If the client requested Atom, turn the ActiveRecord objects\n # into an Atom feed.\n format.atom { render :xml => atom_feed_for(bookmarks, title, \n feed_uri, user) }\n end\n end\n end", "def bookmark_or_not(document)\n unless document.blank?\n if params[:controller] == 'bookmarks'\n context = {\n :url => bookmark_path(document)\n }\n else\n context = {\n :url => facet_catalog_path(document),\n :data_counter => session[:search][:counter].to_i\n }\n end\n end\n end", "def index\n @topic = Topic.find(params[:topic_id])\n @bookmarks = current_user.topics.find(params[:topic_id]).bookmarks.all\n @bookmark = current_user.topics.find(params[:topic_id]).bookmarks.new\n end", "def bookmarked?(user_id)\n !Bookmark.where(story_id: self.id, user_id: user_id).empty?\n end", "def get_document_bookmarks(request)\n data, _status_code, _headers = get_document_bookmarks_with_http_info(request)\n request_token if _status_code == 401\n data\n end", "def bookmarked_songs\n doc = request(@user, \"favorites\")\n songs = []\n doc.xpath('//rss/channel/item').each do |node|\n songs << { :title => node.xpath('title').text.strip,\n :link => node.xpath('link').text.strip,\n :description => node.xpath('description').text.strip,\n :date => node.xpath('pubDate').text.strip,\n :track => node.xpath('mm:Track/dc:title').text.strip,\n :artist => node.xpath('mm:Artist/dc:title').text.strip,\n :album => node.xpath('mm:Album/dc:title').text.strip,\n :artwork => node.xpath('pandora:albumArtUrl').text.strip,\n :station => node.xpath('pandora:stationLink').text.strip }\n end\n songs\n end", "def show_bookmarks(conditions, title, feed_uri, user=nil, tag=nil)\n errors = []\n\n # Make sure the specified limit is valid. If no limit is specified,\n # use the default.\n if params[:limit] && params[:limit].to_i < 0\n errors << \"limit must be >=0\"\n end\n params[:limit] ||= @@default_limit\n params.delete(:limit) if params[:limit] == 0 # 0 means \"no limit\"\n\n # If a date filter was specified, make sure it's a valid date.\n if params[:date]\n begin \n params[:date] = Date.parse(params[:date])\n rescue ArgumentError\n errors << \"incorrect date format\"\n end\n end\n\n if errors.empty?\n conditions ||= [\"\"]\n \n # Add a restriction by date if neccessary.\n if params[:date]\n conditions[0] << \" AND \" unless conditions[0].empty?\n conditions[0] << \"timestamp >= ? AND timestamp < ?\"\n conditions << params[:date]\n conditions << params[:date] + 1\n end\n\n # Restrict the list to bookmarks visible to the authenticated user.\n Bookmark.only_visible_to!(conditions, @authenticated_user)\n\n # Find a set of bookmarks that matches the given conditions.\n bookmarks = Bookmark.custom_find(conditions, tag, params[:limit])\n \n # Render the bookmarks however the client requested.\n render_bookmarks(bookmarks, title, feed_uri, user)\n else\n render :text => errors.join(\"\\n\"), :status => \"400 Bad Request\"\n end\n end", "def index\n @bookmarks = @user.bookmarks\n # render json: @bookmarks\n #(.order by distance)\n end", "def bookmarklet\n unless session[:user_id] \n flash[:info] = \"Please Sign In.\"\n session[:return_to] = request.fullpath\n redirect_to login_url\n end\n @bookmark = Bookmark.find_or_create_by(:url => params[:address], :user_id => session[:user_id])\n end", "def index\n @solicitation_bookmarks = SolicitationBookmark.all\n end", "def create\n @bookmarks = if params[:bookmarks]\n permit_bookmarks[:bookmarks]\n else\n [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]\n end\n\n current_or_guest_user.save! unless current_or_guest_user.persisted?\n\n bookmarks_to_add = @bookmarks.reject { |bookmark| current_or_guest_user.bookmarks.where(bookmark).exists? }\n success = ActiveRecord::Base.transaction do\n current_or_guest_user.bookmarks.create!(bookmarks_to_add)\n rescue ActiveRecord::RecordInvalid\n false\n end\n\n if request.xhr?\n success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) : render(json: current_or_guest_user.errors.full_messages, status: \"500\")\n else\n if @bookmarks.any? && success\n flash[:notice] = I18n.t('blacklight.bookmarks.add.success', count: @bookmarks.length)\n elsif @bookmarks.any?\n flash[:error] = I18n.t('blacklight.bookmarks.add.failure', count: @bookmarks.length)\n end\n\n redirect_back fallback_location: bookmarks_path\n end\n end", "def show\n set_group\n\n # For groups timeline\n @bookmark_plugins = PLUGIN_CONFIG['bookmark'] \n @bookmarks = Bookmark.eager_load(:tags, :user, :url)\n .eager_load(group: :memberships)\n .where(\"bookmarks.group_id IS NOT NULL\")\n .where(\"bookmarks.group_id = ?\", params[:id])\n .order('bookmarks.updated_at DESC')\n end", "def show\n if session[:user_id]\n @bookmark = Bookmark.first(:conditions => \"id = \" + params[:id].to_s + \" AND user_id = \" + session[:user_id].to_s)\n if @bookmark\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bookmark }\n end\n else\n redirect_to \"/bookmarks/\"\n end\n else\n redirect_to \"/login\"\n end\n end", "def action_documents\n @bookmarks = token_or_current_or_guest_user.bookmarks\n bookmark_ids = @bookmarks.collect { |b| b.document_id.to_s }\n query_params = {\n q: bookmarks_query(bookmark_ids),\n defType: 'lucene',\n rows: bookmark_ids.count\n }\n solr_response = search_service.repository.search(query_params)\n [solr_response, solr_response.documents]\n end", "def get_bookmark bookmark_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if bookmark_index == ''\n raise 'bookmark index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + bookmark_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmark']\n \n \n rescue Exception=>e\n print e\n end\n end", "def load_bookmarks\n $bookmarks = {}\n $bookcodes = []\n\n # check if bookmark file exists\n if FileTest.file?( $SETTINGS[:BOOKMARKS_FILE] )\n fp = File.new( $SETTINGS[:BOOKMARKS_FILE], 'rb' )\n str = fp.read(2**26)\n fp.close\n $bookmarks = JSON.parse( str )\n end\n\n for bcbz, dat in $bookmarks\n $bookcodes << dat[2]\n end\nend", "def show\n render json: { bookmark: @bookmark }, status: :ok\n end", "def bookmark_params\n\t\tparams[:bookmarks]\n\tend", "def get_all_bookmarks\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n \n total_bookmarks = self.get_bookmarks_count\n \n all_bookmarks = Array.new\n \n index = 1\n while index <= total_bookmarks\n \n all_annotations.push(self.get_bookmark(index))\n \n index+=1\n end\n \n return all_bookmarks\n \n \n rescue Exception=>e\n print e\n end\n end", "def show\n @bookmark = Bookmark.find(params[:id])\n end", "def show\n @bookmark = Bookmark.find(params[:id])\n end", "def index\n if params[:dress_id]\n @bookmarks = @bookmarks.where(\"bookmarkable_id = ?\", params[:dress_id])\n elsif params[:vendor_id]\n @bookmarks = @bookmarks.where(\"bookmarkable_id = ?\", params[:vendor_id])\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookmarks }\n end\n end", "def test_get_existing_bookmark\n test_url = 'http://www.ml-class.com/'\n num0 = count_bookmarks(@bs.user_id)\n tot0 = count_bookmarks\n assert(get_bookmark(@bs.user_id, test_url) === @bs.add_or_get_bookmark(test_url))\n assert_equal(num0, count_bookmarks(@bs.user_id))\n assert_equal(tot0, count_bookmarks)\n end", "def index\n @bookmarks = Bookmark.all\n \n @test = Bookmark.where(\"url = ?\", :url =>\"http://google.com\")\n \n @duplicates = Bookmark.find(:all,\n :select => \"url, COUNT(url) AS duplicate_count\",\n :conditions => \"url IS NOT NULL AND url != ''\",\n :group => \"url HAVING duplicate_count > 1\")\n \n @urlcount = Bookmark.count(:group => :url,\n :conditions => \"url IS NOT NULL AND url != ''\")\n \n @getuid = Bookmark.find(:all,\n :select => \"user_id, name\",\n :conditions => \"user_id =='4'\")\n \n @getallpeople = Bookmark.find(:all,\n :select => \"url, user_id\",\n :conditions => \"url = 'http://google.com'\")\n \n @getname = User.find(:all,\n :select => \"username\", :conditions => \"id = '4'\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookmarks }\n end\n end", "def test_bookmarks\n [{ url: 'https://www.google.com', title: 'Google' },\n { url: 'https://github.com/', title: 'Github' },\n { url: 'https://www.garybusey.com/', title: 'Gary Busey' }]\nend", "def public_bookmarks\n @public_bookmarks ||=\n Bookmark.with_missing_bookmarkable.or(\n Bookmark.with_bookmarkable_visible_to_all\n ).is_public\n end", "def display_social_bookmarks?; true end", "def show\n @notes = @bookmark.notes\n end", "def bookmarked_by_ids\n Recommendable.redis.smembers(Recommendable::Helpers::RedisKeyMapper.bookmarked_by_set_for(self.class, id))\n end", "def show\n @title = @note.title\n @[email protected]\n @[email protected]\n @tags = @note.tag\n @pages = Page.joins(:notes).where(\"notes.id = #{params[:id]}\").paginate(:page => params[:page], per_page: APP_CONFIG[\"pagenate_count\"][\"notes\"]).order(\"pages.id\").all\n\n if current_user\n @bookmarked = Bookmark.where(:user_id => current_user.id)\n @bookmark = Bookmark.new\n @bookmark.note_id = @note.id\n @bookmark.user_id = current_user.id\n end\n end", "def index\n @bookmarks = token_or_current_or_guest_user.bookmarks\n bookmark_ids = @bookmarks.collect { |b| b.document_id.to_s }\n\n if bookmark_ids.empty?\n @response = Blacklight::Solr::Response.new({}, {})\n @document_list = []\n else\n query_params = {\n q: bookmarks_query(bookmark_ids),\n defType: 'lucene',\n rows: bookmark_ids.count\n }\n # search_service.fetch does this internally (7.25)\n @response = search_service.repository.search(query_params)\n @document_list = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(@response.documents, 'The @document_list instance variable is now deprecated and will be removed in Blacklight 8.0')\n end\n\n respond_to do |format|\n format.html {}\n format.rss { render layout: false }\n format.atom { render layout: false }\n\n additional_response_formats(format)\n document_export_formats(format)\n end\n end", "def set_bookmark\n @user = User.find(session[:usr])\n @receipe = Receipe.find(params[:receipe_id])\n\n end", "def get_bookmarked_topics(org_unit_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/bookmarks\"\n _get(query_string)\n # Returns: a JSON array of Topic ToC entries.\nend", "def bookmark?(key)\n\t\t\t@bookmarks[key.to_sym]\n\t\tend", "def index\n @bookmarks = Bookmark.all\n @bookmark = Bookmark.new\n end", "def index\n @bookmarks = Bookmark.all\n @bookmark = Bookmark.new\n end", "def bookmarklet\n set_bookmarklet_vars(current_user)\n if @account_option.bookmarklet? && @key\n render :bookmarklet\n else\n render :no_access\n end\n end", "def test_get_unauth_bookmark\n bm = @bs.get_bookmark(15)\n assert(bm.errors.count > 0)\n end", "def test_get_by_bookmark_id\n\n resultCreated = Tag.newTag(\"Payroll\", 1);\n\n assert_equal true, resultCreated\n\n results = Tag.getByBookmarkId(1);\n\n result = results[0]\n\n assert_equal \"Payroll\", result.tag\n\n assert_equal 1, results.length\n\n end", "def json_index_user_bookmarks_by_user_id\n\n respond_to do |format|\n\n if UsersBookmark.exists?(user_id: params[:user_id])\n\n @user_bookmarks = Bookmark.\n select('bookmarks.id, bookmark_url, bookmarks_category_id, description, i_frame, image_name, image_name_desc, bookmarks_categories.item_id, title,position,\"like\"').\n joins(:users_bookmarks).\n joins(:bookmarks_category).\n where('user_id = ? ',params[:user_id])\n\n format.json { render json: @user_bookmarks }\n\n else\n format.json { render json: 'not found user_id ' , status: :not_found }\n end\n end\n\n end", "def strip_bookmark_to_json(bookmark)\n\t\t\t\tformatted_tags = []\n\t\t\t\tbookmark.tags.each do |tag|\n\t\t\t\t formatted_tags << tag.tagname\n\t\t\t\tend\t\t\t \t\t\t\t\n\t\t\t\tbookmark_json = {:id => bookmark.id, :url => bookmark.url.url, :title => bookmark.title, :description => bookmark.description, :updated_at => bookmark.updated_at.to_i, :tags => formatted_tags}\n\n\t\t\t\tif bookmark.group_id\n\t\t\t\t\tbookmark_json[:username] = bookmark.user.name\n\t\t\t\t\tbookmark_json[:groupname] = bookmark.group.name\t\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tif bookmark.user_id == doorkeeper_token.resource_owner_id\n\t\t\t\t\tbookmark_json[:my_bookmark] = true\n\t\t\t\telse\n\t\t\t\t\tbookmark_json[:my_bookmark] = false\n\t\t\t\tend\t\t\t\n\t\t\t\tbookmark_json\n\t\t\tend", "def bookmarklet\n # @bookmark = Bookmark.new(:tags => [Tag.new])\n @bookmark = Bookmark.where(:url => params[:address], :user_id => session[:user_id]).first_or_initialize(:tags => [Tag.new])\n respond_to do |format|\n format.html # bookmarklet.html.erb\n format.xml { render :xml => @bookmark }\n end\n end", "def index\n\t\t\t\tbookmarks = Bookmark.where(\"user_id == ?\", doorkeeper_token.resource_owner_id)\n\t\t\t\tformatted_bookmarks = []\n\t\t\t\tbookmarks.each do |bookmark|\n\t\t\t\t formatted_tags = []\n\t\t\t\t bookmark.tags.each do |tag|\n\t\t\t\t formatted_tags << tag.tagname\n\t\t\t\t end\t\t\t \n\t\t\t\t formatted_bookmarks << {:id => bookmark.id, :url => bookmark.url.url, :title => bookmark.title, :description => bookmark.description, :tags => formatted_tags}\n\t\t\t\tend\n\t\t\t\trespond_with formatted_bookmarks\n\t\t\tend", "def bookmarks_export_url(format, params = {})\n bookmarks_url(params.merge(format: format, encrypted_user_id: encrypt_user_id(current_or_guest_user.id) ))\n end", "def bookmark_params\n params.permit(:user_id, :raffle_id)\n end", "def index\n @categorybookmarks = CategoryBookmark.all\n end", "def index\n @bookmarks = Bookmark.all\n render json: { bookmarks: @bookmarks }, status: :ok\n end", "def bookmark!(article)\n user_articles.create!( :article_id => article.id )\n end", "def bookmark\n\t\tanswer = $screen.ask(\"bookmark:\",@bookmarks_hist)\n\t\tif answer == nil\n\t\t\t$screen.write_message(\"Cancelled\");\n\t\telse\n\t\t\t$screen.write_message(\"Bookmarked\");\n\t\t\t@bookmarks[answer] = [@row,@col]\n\t\tend\n\tend", "def index\n # testing some params\n user = nil\n if params[:username]\n user = User.find_by_name(params[:username])\n if user == nil\n redirect_to :controller => :application, :action => :index, :notice => \"User not found\"\n return\n end\n end\n # building conditions\n conditions = Array.new\n conditions[0] = \"\"\n if params[:fromdt]\n conditions[0] = \"bookmarked_at >= ?\"\n conditions << DateTime.parse(params[:fromdt])\n end\n if params[:todt]\n conditions[0] += \" AND \" if params[:fromdt]\n conditions[0] += \"bookmarked_at <= ?\"\n conditions << DateTime.parse(params[:todt])\n end\n if params[:username]\n # filter private ones\n conditions[0] += \" AND \" if (params[:fromdt] || params[:todt])\n conditions[0] += \"private = ?\"\n conditions << 0\n elsif params[:all_users]\n user = nil\n elsif current_user\n user = current_user\n elsif (!current_user && !params[:username] && !params[:all_users])\n redirect_to :controller => :application, :action => :index\n end\n if params[:tag]\n limit = \"ALL\"\n if ActiveRecord::Base.connection.class.to_s.split('::')[-1].gsub(\"Adapter\",'') == \"SQLite3\"\n limit = -1\n end\n tags = params[:tag].split(/[ +]/)\n if user\n posts = user.bookmarks.tagged_with(params[:tag], :match_all => true).find(:all, :offset => (params[:start] || 0), :limit => (params[:results] || limit), :conditions => conditions, :order => \"bookmarked_at DESC\")\n else\n posts = Bookmark.tagged_with(params[:tag], :match_all => true).find(:all, :offset => (params[:start] || 0), :limit => (params[:results] || limit), :conditions => conditions, :order => \"bookmarked_at DESC\")\n end\n else\n if user\n posts = user.bookmarks.find(:all, :offset => (params[:start] || 0), :limit => (params[:results] || limit), :conditions => conditions, :order => \"bookmarked_at DESC\")\n else\n posts = Bookmark.find(:all, :offset => (params[:start] || 0), :limit => (params[:results] || limit), :conditions => conditions, :order => \"bookmarked_at DESC\")\n end\n end\n # filter private ones\n the_posts = Array.new\n posts.each do |post|\n if post.private?\n if current_user\n the_posts << post if (post.user == current_user)\n end\n else\n the_posts << post\n end\n end\n respond_to do |format|\n format.xml do\n if current_user\n xml_posts = Array.new\n the_posts.each do |post|\n tags = Array.new\n post.tags.each { |t| tags << t.name } if post.tags.count > 0\n xml_posts << {\"href\" => post.link.url, \"description\" => post.title, \"tag\" => tags.join(' ')}\n end\n meta = Digest::MD5.hexdigest(current_user.name + current_user.updated_at.utc.strftime(\"%Y-%m-%dT%H:%M:%SZ\"))\n posts = {:user => current_user.name, :update => current_user.updated_at.utc.strftime(\"%Y-%m-%dT%H:%M:%SZ\"), :hash => meta, :tag => \"\", :total => current_user.bookmarks.size, :post => xml_posts}\n xml_output = \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\" + XmlSimple.xml_out(posts).gsub(\"opt\",\"posts\")\n render :xml => xml_output\n else\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"something went wrong\\\" />\"\n end\n end\n end\n end", "def set_my_bookmark\n @my_bookmark = MyBookmark.find(params[:id])\n end", "def bookmark_param\n params.require(:bookmark).permit(:user_id, :review_id)\n end", "def bookmark_params\n params.require(:bookmark).permit(:user_id, :receipe_id)\n end", "def has_bookmarked?(type, id)\n id.in? self.bookmarks.where({ :bookmarkable_type => type }).pluck(:bookmarkable_id)\n end", "def list_favourites(user_id)\n @favourites_store.where(user_id)\n end", "def json_show_user_bookmark_by_user_id_and_bookmark_id\n\n respond_to do |format|\n\n if Bookmark.\n joins(:users_bookmarks).\n joins(:bookmarks_category).\n where('user_id = ? and bookmarks.id = ?',params[:user_id],params[:bookmark_id]).exists?\n\n @user_bookmark = Bookmark.\n select('bookmarks.id, bookmark_url, bookmarks_category_id, description, i_frame, image_name, image_name_desc, bookmarks_categories.item_id, title,position,\"like\"').\n joins(:users_bookmarks).\n joins(:bookmarks_category).\n where('user_id = ? and bookmarks.id = ?',params[:user_id],params[:bookmark_id]).first\n\n format.json { render json: @user_bookmark }\n else\n format.json { render json: 'not found user_id and bookmark id' , status: :not_found }\n end\n end\n\n end", "def index\n @token = form_authenticity_token\n @posts = Post.where(category: 1).reverse\n \n # @latest_post = []\n \n # (0..4).each do |i|\n # @latest_post[i] = @posts[i]\n # end\n \n @rs = Post.all\n @bm = Bookmark.where(user_id: current_user.id)\n @bookmarks = []\n @rs.each do |r|\n @bm.each do |b|\n if r.id == b.post_id\n @bookmarks.push(r)\n end\n end\n end\n end" ]
[ "0.72326785", "0.72011226", "0.70743287", "0.7037133", "0.6967528", "0.6930669", "0.6834692", "0.66484296", "0.6638327", "0.65910035", "0.65484047", "0.65316385", "0.65127164", "0.6463278", "0.64406705", "0.6440491", "0.6414593", "0.64123327", "0.64052445", "0.63684773", "0.62781125", "0.6258687", "0.6220985", "0.62022555", "0.6175159", "0.6174057", "0.61731553", "0.6156439", "0.613777", "0.61269814", "0.610743", "0.6077474", "0.6070682", "0.6066205", "0.60535115", "0.6046563", "0.6029011", "0.59982556", "0.5979654", "0.59487134", "0.5939176", "0.5929553", "0.59103477", "0.58968985", "0.58923095", "0.58879316", "0.5865575", "0.586489", "0.5844734", "0.58424795", "0.58373404", "0.5813538", "0.5799425", "0.5797357", "0.57926023", "0.57753265", "0.5760943", "0.57494986", "0.5740467", "0.57233906", "0.5696097", "0.5688214", "0.5676639", "0.5676639", "0.5669383", "0.5651672", "0.56485623", "0.5643206", "0.5629669", "0.5628214", "0.56229323", "0.5622573", "0.5620289", "0.5617743", "0.5613748", "0.5582658", "0.5579797", "0.5570021", "0.5570021", "0.5558169", "0.5548693", "0.55413383", "0.5534827", "0.5503124", "0.5497276", "0.54681176", "0.5464327", "0.54621714", "0.54601127", "0.54507834", "0.5442586", "0.5437696", "0.5436611", "0.5432274", "0.5427586", "0.54148877", "0.54021764", "0.5395871", "0.5386541", "0.5385007" ]
0.6338514
20
Get bookmarks for a valid user
def test_get_bookmarks exp_num_bms = count_bookmarks(1) act_num_bms = @bs.get_bookmarks.count assert_equal(exp_num_bms, act_num_bms) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_bookmarks(user_id)\n url = \"#{@@request_url}/User.listBookmarks?appid=#{@@appid}&ID=#{user_id}\"\n end", "def bookmarks(user)\n user = Access::Validate.user(user, false)\n Bookmark\n .where('(bookmarks.creator_id = ? OR bookmarks.updater_id = ?)', user.id, user.id)\n .order('bookmarks.updated_at DESC')\n end", "def get_bookmarks_for_user(user_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url\n FROM bookmarks b, web_pages w\n WHERE b.web_page_id = w.id\n AND user_id = $1\n EOS\n bms = @conn.exec(query, [user_id])\n Bookmark.build(bms)\n end", "def bookmarks\n @user = User.find(params[:id])\n\n render :status => 404 and return if @user.nil?\n\n # Grab Bookmarks and Render Them Out\n @bookmarks = @user.current_bookmarks\n render_collection_json Serialize::BookmarksSerializer.as_json_with_current_entries(@bookmarks, @user)\n end", "def index\n @bookmarks = Bookmark.user_bookmarks(current_user)\n end", "def get_bookmark_for_user(user_id, bookmark_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url \n FROM bookmarks b, users u, web_pages w\n WHERE b.user_id = u.id\n AND b.web_page_id = w.id\n AND b.user_id = $1\n AND b.id = $2\n EOS\n bm = @conn.exec(query, [user_id, bookmark_id]).first\n unless bm == nil\n bm = Bookmark.new(bm)\n end\n bm \n end", "def get_pinned_bookmarks_for_user(user_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url\n FROM bookmarks b, web_pages w\n WHERE b.web_page_id = w.id\n AND user_id = $1\n AND is_pinned = TRUE\n EOS\n pbms = @conn.exec(query, [user_id])\n Bookmark.build(pbms)\n end", "def user_index\n @user = params[:user]\n @results = []\n \n u = User.where(name: params[:user]).first\n \n if u == nil\n redirect_to :root\n else \n u.bookmarks.each do |b|\n user_url = \"/\" + u.name\n entry = {id: b.id, url: b.url, title: b.title, user: b.user, name: u.name, user_url: user_url}\n @results.push(entry)\n end\n end\n end", "def index\n\t\trespond_with current_user.bookmarks\n\tend", "def get_bookmarks(name, bookmark_path, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_bookmarks_with_http_info(name, bookmark_path, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_bookmarks_with_http_info(name, bookmark_path, opts)\n else\n raise\n end\n return data\n end", "def is_bookmarked user\n Bookmark.find_by(user_id: user_id, post_id: id)\n end", "def index\n @bookmarks = Bookmark.where(owner: current_user)\n end", "def search\n @user = User.find(params[:user_id])\n @tags = show_user_tags @user\n result_search = search_bookmarks_by params[:tag_name], @user\n\n if current_user? @user\n @bookmarks = result_search.paginate(page: params[:page], per_page: 10) \n else\n temp = []\n result_search.each do |bookmark|\n unless bookmark.privacy? then\n temp.push(bookmark)\n end\n end\n @bookmarks = temp.paginate(page: params[:page], per_page: 10)\n end\n end", "def get_bookmarks\n @logger.debug \"Fetching bookmarks from Delicious\"\n bookmarks = []\n doc = REXML::Document.new(open(\"http://feeds.delicious.com/v2/rss/#{@username}?count=5\"))\n doc.each_element('//channel/item') do |item|\n bookmarks << {\n :title => item.get_text('title'),\n :url => item.get_text('link'),\n :date => Date.parse(item.get_text('pubDate').to_s)\n }\n end\n return bookmarks\n end", "def bookmarked_by_user?(user)\n bookmark_object(user).present?\n end", "def bookmark_object(the_user)\n the_user.bookmarked_posts.find_by_post_id(id)\n end", "def show_bookmarks(conditions, title, feed_uri, user=nil, tag=nil)\n errors = []\n\n # Make sure the specified limit is valid. If no limit is specified,\n # use the default.\n if params[:limit] && params[:limit].to_i < 0\n errors << \"limit must be >=0\"\n end\n params[:limit] ||= @@default_limit\n params.delete(:limit) if params[:limit] == 0 # 0 means \"no limit\"\n\n # If a date filter was specified, make sure it's a valid date.\n if params[:date]\n begin \n params[:date] = Date.parse(params[:date])\n rescue ArgumentError\n errors << \"incorrect date format\"\n end\n end\n\n if errors.empty?\n conditions ||= [\"\"]\n \n # Add a restriction by date if neccessary.\n if params[:date]\n conditions[0] << \" AND \" unless conditions[0].empty?\n conditions[0] << \"timestamp >= ? AND timestamp < ?\"\n conditions << params[:date]\n conditions << params[:date] + 1\n end\n\n # Restrict the list to bookmarks visible to the authenticated user.\n Bookmark.only_visible_to!(conditions, @authenticated_user)\n\n # Find a set of bookmarks that matches the given conditions.\n bookmarks = Bookmark.custom_find(conditions, tag, params[:limit])\n \n # Render the bookmarks however the client requested.\n render_bookmarks(bookmarks, title, feed_uri, user)\n else\n render :text => errors.join(\"\\n\"), :status => \"400 Bad Request\"\n end\n end", "def show\n @end_user = EndUser.find(params[:id])\n @post = @end_user.posts.all\n @bkm = @end_user.bookmarks.all\n end", "def index\n# Bookmark.destroy_all\n# @bookmarks = Bookmark.all\n\n# Get all bookmarks related to user where the primary key of User record is in session[:user_id]\n @bookmarks =User.find(session[:user_id]).bookmarks.scoped\n @[email protected](:name)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookmarks }\n end\n end", "def get_document_bookmarks(name, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_bookmarks_with_http_info(name, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_bookmarks_with_http_info(name, opts)\n else\n raise\n end\n return data\n end", "def index\n @bookmarks = BookmarkLister.new(@tag || current_user)\n .(query: params[:q], by: params[:by])\n .to_a\n end", "def bookmarks\n full = options[:full]\n docs = options[:doc] && documents.map { |doc| [doc.id, doc] }.to_h\n item_list.map { |item|\n next unless item.is_a?(Bookmark)\n entry = {\n document_id: item.document_id,\n document_type: item.document_type.to_s,\n lens: item.lens,\n updated_at: item.updated_at,\n created_at: item.created_at,\n }\n full && entry.merge!(\n title: item.user_type, # TODO: not persisted; should it be?\n id: item.id,\n user_id: item.user_id,\n user_type: item.user_type,\n )\n docs && entry.merge!(doc: docs[item.document_id])\n entry\n }.compact.as_json\n end", "def bookmark_by(u)\r\n Bookmark.bookmark_by(u, self)\r\n end", "def bookmarks\n\t\toptions = { list: true }\n\t\tresponse = self.server.run_with_json_template( :bookmarks, **options )\n\t\treturn response.map {|bk| Hglib::Repo::Bookmark.new(self, **bk) }\n\tend", "def bookmarked?(user_id)\n !Bookmark.where(story_id: self.id, user_id: user_id).empty?\n end", "def test_get_bookmarks_nouser\n ds = BookmarkStore.new($conn_str)\n assert_raises(RuntimeError) { ds.get_bookmarks }\n end", "def index\n search = Bookmark.search(:include => [:manifestation])\n query = params[:query].to_s.strip\n unless query.blank?\n @query = query.dup\n end\n user = @user\n unless current_user.has_role?('Librarian')\n if user and user != current_user and !user.try(:share_bookmarks)\n access_denied; return\n end\n if current_user == @user\n redirect_to bookmarks_url\n return\n end\n end\n\n search.build do\n fulltext query\n order_by(:created_at, :desc)\n if user\n with(:user_id).equal_to user.id\n else\n with(:user_id).equal_to current_user.id\n end\n end\n page = params[:page] || \"1\"\n flash[:page] = page if page.to_i >= 1\n search.query.paginate(page.to_i, Bookmark.default_per_page)\n @bookmarks = search.execute!.results\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bookmarks }\n end\n end", "def bookmark_query(q,&blk)\n response = query(q)\n bookmark = response[\"bookmark\"]\n docs = response[\"docs\"]\n\n until !docs || docs.empty?\n yield docs\n q[\"bookmark\"] = bookmark\n response = query(q)\n bookmark = response[\"bookmark\"]\n docs = response[\"docs\"]\n end\n\n docs\n end", "def show\n if session[:user_id]\n @bookmark = Bookmark.first(:conditions => \"id = \" + params[:id].to_s + \" AND user_id = \" + session[:user_id].to_s)\n if @bookmark\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bookmark }\n end\n else\n redirect_to \"/bookmarks/\"\n end\n else\n redirect_to \"/login\"\n end\n end", "def atom_feed_for(bookmarks, title, feed_uri, user=nil)\n feed = Atom::Feed.new\n feed.title = title\n most_recent_bookmark = bookmarks.max do |b1,b2|\n b1.timestamp <=> b2.timestamp\n end\n feed.updated = most_recent_bookmark.timestamp\n\n # Link this feed to itself\n self_link = feed.links.new\n self_link['rel'] = 'self'\n self_link['href'] = feed_uri + \".atom\"\n\n # If this list is a list of bookmarks from a single user, that user is\n # the author of the feed.\n if user\n user_to_atom_author(user, feed)\n end\n\n # Turn each bookmark in the list into an entry in the feed.\n bookmarks.each do |bookmark|\n entry = feed.entries.new\n entry.title = bookmark.short_description\n entry.content = bookmark.long_description\n\n # In a real application, a bookmark would have a separate\n # \"modification date\" field which was not under the control of\n # the user. This would also make the Last-Modified calculations\n # more accurate.\n entry.updated = bookmark.timestamp \n\n # First, link this Atom entry to the external URI that the\n # bookmark tracks.\n external_uri = entry.links.new\n external_uri['href'] = bookmark.uri\n\n # Now we give some connectedness to this service. Link this Atom\n # entry to this service's resource for this bookmark.\n bookmark_resource = entry.links.new\n bookmark_resource['rel'] = \"self\"\n bookmark_resource['href'] = bookmark_url(bookmark.user.name, \n bookmark.uri_hash) + \".atom\"\n bookmark_resource['type'] = \"application/xml+atom\"\n\n # Then link this entry to the list of users who've bookmarked\n # this URI.\n other_users = entry.links.new\n other_users['rel'] = \"related\"\n other_users['href'] = uri_url(bookmark.uri_hash) + \".atom\"\n other_users['type'] = \"application/xml+atom\"\n\n # Turn this entry's user into the \"author\" of this entry, unless\n # we already specified a user as the \"author\" of the entire\n # feed.\n unless user\n user_to_atom_author(bookmark.user, entry) \n end\n\n # For each of this bookmark's tags...\n bookmark.tags.each do |tag|\n # ...represent the tag as an Atom category.\n category = entry.categories.new\n category['term'] = tag\n category['scheme'] = user_url(bookmark.user.name) + \"/tags\"\n\n # Link to this user's other bookmarks tagged using this tag.\n tag_uri = entry.links.new\n tag_uri['href'] = tag_url(bookmark.user.name, tag.name) + \".atom\"\n tag_uri['rel'] = 'related'\n tag_uri['type'] = \"application/xml+atom\"\n\n # Also link to all bookmarks tagged with this tag.\n recent_tag_uri = entry.links.new\n recent_tag_uri['href'] = recent_url(tag.name) + \".atom\"\n recent_tag_uri['rel'] = 'related'\n recent_tag_uri['type'] = \"application/xml+atom\"\n end\n end \n return feed.to_xml\n end", "def index\n if session[:user_id]\n @bookmarks = Bookmark.all(:conditions => \"user_id = \"+session[:user_id].to_s)\n user = User.find(session[:user_id])\n \n @background = Rails.root + '/data/' + user.background\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookmarks }\n end\n else\n redirect_to \"/login\"\n end\n end", "def test_get_by_bookmark_id\n\n comments = Comment.getByBookmarkId(1)\n \n comment = comments[0]\n\n assert_equal 1, comment.commentId\n assert_equal \"This is a comment\", comment.content\n assert_equal 1, comment.bookmarkId\n assert_equal 1, comment.userId\n\n end", "def index\n @bookmarklets = Bookmarklet.find(:all)\n if logged_in?\n @user_bookmarkltes = current_user.bookmarklets\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookmarklets }\n end\n end", "def index\n if logged_in?\n @bookmarks = @current_user.bookmarks.pluck(:story_id)\n respond_to do |format|\n format.json { render json: {ids: @bookmarks} }\n format.html { redirect_to bookmarks_url }\n end\n else\n redirect_to bookmarks_url\n end\n end", "def get_document_bookmarks(request)\n data, _status_code, _headers = get_document_bookmarks_with_http_info(request)\n request_token if _status_code == 401\n data\n end", "def index\n # testing some params\n user = nil\n if params[:username]\n user = User.find_by_name(params[:username])\n if user == nil\n redirect_to :controller => :application, :action => :index, :notice => \"User not found\"\n return\n end\n end\n # building conditions\n conditions = Array.new\n conditions[0] = \"\"\n if params[:fromdt]\n conditions[0] = \"bookmarked_at >= ?\"\n conditions << DateTime.parse(params[:fromdt])\n end\n if params[:todt]\n conditions[0] += \" AND \" if params[:fromdt]\n conditions[0] += \"bookmarked_at <= ?\"\n conditions << DateTime.parse(params[:todt])\n end\n if params[:username]\n # filter private ones\n conditions[0] += \" AND \" if (params[:fromdt] || params[:todt])\n conditions[0] += \"private = ?\"\n conditions << 0\n elsif params[:all_users]\n user = nil\n elsif current_user\n user = current_user\n elsif (!current_user && !params[:username] && !params[:all_users])\n redirect_to :controller => :application, :action => :index\n end\n if params[:tag]\n limit = \"ALL\"\n if ActiveRecord::Base.connection.class.to_s.split('::')[-1].gsub(\"Adapter\",'') == \"SQLite3\"\n limit = -1\n end\n tags = params[:tag].split(/[ +]/)\n if user\n posts = user.bookmarks.tagged_with(params[:tag], :match_all => true).find(:all, :offset => (params[:start] || 0), :limit => (params[:results] || limit), :conditions => conditions, :order => \"bookmarked_at DESC\")\n else\n posts = Bookmark.tagged_with(params[:tag], :match_all => true).find(:all, :offset => (params[:start] || 0), :limit => (params[:results] || limit), :conditions => conditions, :order => \"bookmarked_at DESC\")\n end\n else\n if user\n posts = user.bookmarks.find(:all, :offset => (params[:start] || 0), :limit => (params[:results] || limit), :conditions => conditions, :order => \"bookmarked_at DESC\")\n else\n posts = Bookmark.find(:all, :offset => (params[:start] || 0), :limit => (params[:results] || limit), :conditions => conditions, :order => \"bookmarked_at DESC\")\n end\n end\n # filter private ones\n the_posts = Array.new\n posts.each do |post|\n if post.private?\n if current_user\n the_posts << post if (post.user == current_user)\n end\n else\n the_posts << post\n end\n end\n respond_to do |format|\n format.xml do\n if current_user\n xml_posts = Array.new\n the_posts.each do |post|\n tags = Array.new\n post.tags.each { |t| tags << t.name } if post.tags.count > 0\n xml_posts << {\"href\" => post.link.url, \"description\" => post.title, \"tag\" => tags.join(' ')}\n end\n meta = Digest::MD5.hexdigest(current_user.name + current_user.updated_at.utc.strftime(\"%Y-%m-%dT%H:%M:%SZ\"))\n posts = {:user => current_user.name, :update => current_user.updated_at.utc.strftime(\"%Y-%m-%dT%H:%M:%SZ\"), :hash => meta, :tag => \"\", :total => current_user.bookmarks.size, :post => xml_posts}\n xml_output = \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\" + XmlSimple.xml_out(posts).gsub(\"opt\",\"posts\")\n render :xml => xml_output\n else\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"something went wrong\\\" />\"\n end\n end\n end\n end", "def test_get_bookmark\n exp_bm = get_bookmark(@bs.user_id, 'http://www.ml-class.com/')\n act_bm = @bs.get_bookmark(4)\n assert(exp_bm === act_bm)\n end", "def index\n @results = []\n \n Bookmark.all.each do |b|\n user_url = \"/\" + b.user.name\n entry = {id: b.id, url: b.url, title: b.title, user: b.user, name: b.user.name, user_url: user_url }\n @results.push(entry)\n end\n end", "def json_index_user_bookmarks_by_user_id\n\n respond_to do |format|\n\n if UsersBookmark.exists?(user_id: params[:user_id])\n\n @user_bookmarks = Bookmark.\n select('bookmarks.id, bookmark_url, bookmarks_category_id, description, i_frame, image_name, image_name_desc, bookmarks_categories.item_id, title,position,\"like\"').\n joins(:users_bookmarks).\n joins(:bookmarks_category).\n where('user_id = ? ',params[:user_id])\n\n format.json { render json: @user_bookmarks }\n\n else\n format.json { render json: 'not found user_id ' , status: :not_found }\n end\n end\n\n end", "def bookmarklet\n unless session[:user_id] \n flash[:info] = \"Please Sign In.\"\n session[:return_to] = request.fullpath\n redirect_to login_url\n end\n @bookmark = Bookmark.find_or_create_by(:url => params[:address], :user_id => session[:user_id])\n end", "def json_show_user_bookmark_by_user_id_and_bookmark_id\n\n respond_to do |format|\n\n if Bookmark.\n joins(:users_bookmarks).\n joins(:bookmarks_category).\n where('user_id = ? and bookmarks.id = ?',params[:user_id],params[:bookmark_id]).exists?\n\n @user_bookmark = Bookmark.\n select('bookmarks.id, bookmark_url, bookmarks_category_id, description, i_frame, image_name, image_name_desc, bookmarks_categories.item_id, title,position,\"like\"').\n joins(:users_bookmarks).\n joins(:bookmarks_category).\n where('user_id = ? and bookmarks.id = ?',params[:user_id],params[:bookmark_id]).first\n\n format.json { render json: @user_bookmark }\n else\n format.json { render json: 'not found user_id and bookmark id' , status: :not_found }\n end\n end\n\n end", "def create\n @bookmarks = if params[:bookmarks]\n permit_bookmarks[:bookmarks]\n else\n [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]\n end\n\n current_or_guest_user.save! unless current_or_guest_user.persisted?\n\n bookmarks_to_add = @bookmarks.reject { |bookmark| current_or_guest_user.bookmarks.where(bookmark).exists? }\n success = ActiveRecord::Base.transaction do\n current_or_guest_user.bookmarks.create!(bookmarks_to_add)\n rescue ActiveRecord::RecordInvalid\n false\n end\n\n if request.xhr?\n success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) : render(json: current_or_guest_user.errors.full_messages, status: \"500\")\n else\n if @bookmarks.any? && success\n flash[:notice] = I18n.t('blacklight.bookmarks.add.success', count: @bookmarks.length)\n elsif @bookmarks.any?\n flash[:error] = I18n.t('blacklight.bookmarks.add.failure', count: @bookmarks.length)\n end\n\n redirect_back fallback_location: bookmarks_path\n end\n end", "def set_bookmark\n @bookmark = current_user.bookmarks.find(params[:id])\n end", "def bookmarks\n xpath './bookmark'\n end", "def index\n @public_bookmarks = PublicBookmark.all\n end", "def get_address_book(user_id)\n self.class.get(\"https://api.yesgraph.com/v0/address-book/#{user_id}\",\n {\n :headers => @options\n }\n )\n end", "def render_bookmarks(bookmarks, title, feed_uri, user, except=[])\n # Figure out a current value for the Last-Modified header.\n if bookmarks.empty?\n last_modified = nil\n else\n # Last-Modified is the most recent timestamp in the bookmark list.\n most_recent_bookmark = bookmarks.max do |b1,b2|\n b1.timestamp <=> b2.timestamp\n end\n last_modified = most_recent_bookmark.timestamp\n end\n \n # If the bookmark list has been modified since it was last requested...\n render_not_modified_or(last_modified) do\n respond_to do |format|\n # If the client requested XML, serialize the ActiveRecord\n # objects to XML. Include references to the tags in the\n # serialization.\n format.xml { render :xml => \n bookmarks.to_xml(:except => except + [:id, :user_id],\n :include => [:tags]) }\n # If the client requested Atom, turn the ActiveRecord objects\n # into an Atom feed.\n format.atom { render :xml => atom_feed_for(bookmarks, title, \n feed_uri, user) }\n end\n end\n end", "def general_bookmarks\n @general_bookmarks ||=\n Bookmark.with_missing_bookmarkable.or(\n Bookmark.with_bookmarkable_visible_to_registered_user\n ).is_public\n end", "def test_get_unauth_bookmark\n bm = @bs.get_bookmark(15)\n assert(bm.errors.count > 0)\n end", "def index\n @bookmarks = @user.bookmarks\n # render json: @bookmarks\n #(.order by distance)\n end", "def index\n @topic = Topic.find(params[:topic_id])\n @bookmarks = current_user.topics.find(params[:topic_id]).bookmarks.all\n @bookmark = current_user.topics.find(params[:topic_id]).bookmarks.new\n end", "def index\n bookmarks_loader(Time.now, current_user.id) \n bookmark = @bookmarks.first\n if bookmark\n session[:first_link_time] = bookmark.updated_at \n end \n bookmark = @bookmarks.last\n if bookmark\n session[:last_link_time] = bookmark.updated_at\n end \n end", "def test_get_existing_bookmark\n test_url = 'http://www.ml-class.com/'\n num0 = count_bookmarks(@bs.user_id)\n tot0 = count_bookmarks\n assert(get_bookmark(@bs.user_id, test_url) === @bs.add_or_get_bookmark(test_url))\n assert_equal(num0, count_bookmarks(@bs.user_id))\n assert_equal(tot0, count_bookmarks)\n end", "def bookmarks_export_url(format, params = {})\n bookmarks_url(params.merge(format: format, encrypted_user_id: encrypt_user_id(current_or_guest_user.id) ))\n end", "def load_bookmarks\n $bookmarks = {}\n $bookcodes = []\n\n # check if bookmark file exists\n if FileTest.file?( $SETTINGS[:BOOKMARKS_FILE] )\n fp = File.new( $SETTINGS[:BOOKMARKS_FILE], 'rb' )\n str = fp.read(2**26)\n fp.close\n $bookmarks = JSON.parse( str )\n end\n\n for bcbz, dat in $bookmarks\n $bookcodes << dat[2]\n end\nend", "def favorites(user = nil, params = {})\n args = [user, params]\n get path_from_args('favorites', args), params_from_args(args)\n end", "def existing_bookmark_for(document_id)\n # to_a, we don't want to go to the database, we want to use cached\n # copy. \n self.bookmarks.to_a.find {|b| b.document_id == document_id}\n end", "def index\n @bookmarks = Bookmark.all\n \n @test = Bookmark.where(\"url = ?\", :url =>\"http://google.com\")\n \n @duplicates = Bookmark.find(:all,\n :select => \"url, COUNT(url) AS duplicate_count\",\n :conditions => \"url IS NOT NULL AND url != ''\",\n :group => \"url HAVING duplicate_count > 1\")\n \n @urlcount = Bookmark.count(:group => :url,\n :conditions => \"url IS NOT NULL AND url != ''\")\n \n @getuid = Bookmark.find(:all,\n :select => \"user_id, name\",\n :conditions => \"user_id =='4'\")\n \n @getallpeople = Bookmark.find(:all,\n :select => \"url, user_id\",\n :conditions => \"url = 'http://google.com'\")\n \n @getname = User.find(:all,\n :select => \"username\", :conditions => \"id = '4'\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookmarks }\n end\n end", "def public_bookmarks\n @public_bookmarks ||=\n Bookmark.with_missing_bookmarkable.or(\n Bookmark.with_bookmarkable_visible_to_all\n ).is_public\n end", "def bookmark_params\n params.permit(:user_id, :raffle_id)\n end", "def favourite_places_for_user(user_id)\n where(:user_id => user_id).map(&:place_id)\n end", "def create\n if session[:user_id]\n user = User.find(session[:user_id])\n params[:bookmark][:user] = user\n @bookmark = Bookmark.new(params[:bookmark])\n if params[:tag]\n @tags = params[:tag]\n @tags.each do |tag|\n objTag = Tag.find(tag)\n @bookmark.tags << objTag\n end\n end\n if @bookmark.url.include?(\"http://\")\n else\n @bookmark.url = \"http://\" + @bookmark.url\n end\n \n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to \"/login\"\n end\n end", "def set_bookmark\n @user = User.find(session[:usr])\n @receipe = Receipe.find(params[:receipe_id])\n\n end", "def get_bookmarked_topics(org_unit_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/bookmarks\"\n _get(query_string)\n # Returns: a JSON array of Topic ToC entries.\nend", "def get_bookmark bookmark_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if bookmark_index == ''\n raise 'bookmark index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + bookmark_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmark']\n \n \n rescue Exception=>e\n print e\n end\n end", "def show\n render json: { bookmark: @bookmark }, status: :ok\n end", "def index\n @bookmarks = Bookmark.all\n end", "def show\n set_group\n\n # For groups timeline\n @bookmark_plugins = PLUGIN_CONFIG['bookmark'] \n @bookmarks = Bookmark.eager_load(:tags, :user, :url)\n .eager_load(group: :memberships)\n .where(\"bookmarks.group_id IS NOT NULL\")\n .where(\"bookmarks.group_id = ?\", params[:id])\n .order('bookmarks.updated_at DESC')\n end", "def bookmarked?(an_user_id, select=nil)\n return false if self.new_record?\n return (self.send(select).to_i != 0) if !select.nil?\n Bookmark.where(:user_id => an_user_id, :bookmarkable_type => 'MediaElement', :bookmarkable_id => self.id).any?\n end", "def test_get_by_bookmark_id\n\n resultCreated = Tag.newTag(\"Payroll\", 1);\n\n assert_equal true, resultCreated\n\n results = Tag.getByBookmarkId(1);\n\n result = results[0]\n\n assert_equal \"Payroll\", result.tag\n\n assert_equal 1, results.length\n\n end", "def index\n @bookmarks = Bookmark.all\n end", "def bookmark_params\n params.require(:bookmark).permit(:user_id, :receipe_id)\n end", "def get_bookmarks_with_http_info(name, bookmark_path, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_bookmarks ...\"\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_bookmarks\"\n end\n # verify the required parameter 'bookmark_path' is set\n if @api_client.config.client_side_validation && bookmark_path.nil?\n fail ArgumentError, \"Missing the required parameter 'bookmark_path' when calling PdfApi.get_bookmarks\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/bookmarks/list/{bookmarkPath}\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'bookmarkPath' + '}', bookmark_path.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].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 => 'BookmarksResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_bookmarks\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def action_documents\n @bookmarks = token_or_current_or_guest_user.bookmarks\n bookmark_ids = @bookmarks.collect { |b| b.document_id.to_s }\n query_params = {\n q: bookmarks_query(bookmark_ids),\n defType: 'lucene',\n rows: bookmark_ids.count\n }\n solr_response = search_service.repository.search(query_params)\n [solr_response, solr_response.documents]\n end", "def create\n #@bookmark = Bookmark.new(params[:bookmark])\n #\n #respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n # format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n # else\n # format.html { render :action => \"new\" }\n # format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n # end\n #end\n\n #@bookmark = current_user.bookmarks.build(params[:bookmark])\n \n @user = @current_user\n @bookmark = @current_user.bookmarks.build(params[:bookmark])\n @user.bookmarks << @bookmark\n \n #@bookmarkuser = @current_user.bookmarkusers.build(params[:bookmark])\n #\n \n \n \n #@bookmarkuser.save\n \n if @bookmark.save\n flash[:success] = \"Bookmark created!\"\n redirect_to root_path, :flash => { :success => \"Bookmark created!\" }\n else\n render 'pages/home'\n end\n\n end", "def index\n if params[:dress_id]\n @bookmarks = @bookmarks.where(\"bookmarkable_id = ?\", params[:dress_id])\n elsif params[:vendor_id]\n @bookmarks = @bookmarks.where(\"bookmarkable_id = ?\", params[:vendor_id])\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookmarks }\n end\n end", "def pin_bookmark_for_user(user_id, bookmark_id)\n bm = get_bookmark_for_user(user_id, bookmark_id)\n unless bm == nil\n bm.is_pinned = true\n bm = update_bookmark_for_user(user_id, bm)\n end\n bm\n end", "def show\n @bookmark = Bookmark.find(params[:id])\n end", "def show\n @bookmark = Bookmark.find(params[:id])\n end", "def get_document_bookmark_by_name(request)\n data, _status_code, _headers = get_document_bookmark_by_name_with_http_info(request)\n request_token if _status_code == 401\n data\n end", "def test_bookmarks\n [{ url: 'https://www.google.com', title: 'Google' },\n { url: 'https://github.com/', title: 'Github' },\n { url: 'https://www.garybusey.com/', title: 'Gary Busey' }]\nend", "def get_user_books\n user = User.find_by_id(params[:user_id])\n shelves = user.bookshelves\n \n @books = Array.new\n \n shelves.each do |s|\n s.books.each do |book|\n @books << book\n end\n end\n \n #books = Book.where(user_id: params[:user_id])\n \n render json: @books\n end", "def new\n @bookmark = Bookmark.new\n @users = User.find(:all)\n \n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bookmark }\n end\n end", "def index\n\t\t\t\tbookmarks = Bookmark.where(\"user_id == ?\", doorkeeper_token.resource_owner_id)\n\t\t\t\tformatted_bookmarks = []\n\t\t\t\tbookmarks.each do |bookmark|\n\t\t\t\t formatted_tags = []\n\t\t\t\t bookmark.tags.each do |tag|\n\t\t\t\t formatted_tags << tag.tagname\n\t\t\t\t end\t\t\t \n\t\t\t\t formatted_bookmarks << {:id => bookmark.id, :url => bookmark.url.url, :title => bookmark.title, :description => bookmark.description, :tags => formatted_tags}\n\t\t\t\tend\n\t\t\t\trespond_with formatted_bookmarks\n\t\t\tend", "def index\n\t\t@bookmarks = Bookmark.all\n\tend", "def set_bookmark_check_owner\n @bookmark = Bookmark.find(params[:id])\n\n if @bookmark.user != current_user\n respond_to do |format|\n\n format.html { redirect_to root_url, alert: \"You dont have permissions for this action\"}\n\n end\n end\n end", "def bookmarks(bookmarks)\n bookmarks.each_with_object({}) do |b, bs|\n first_image = b.entry.entry_images.min_by(&:pocket_image_id)\n bs[b.id] = {\n id: b.id.to_s,\n title: b.entry.resolved_title,\n url: b.entry.url,\n status: b.status,\n addedAt: b.added_to_pocket_at.to_i,\n archivedAt: b.archived_at&.to_i,\n favorite: b.favorite,\n thumbnailUrl: determine_image_url(first_image),\n }\n end\n end", "def bookmark_params\n\t\tparams[:bookmarks]\n\tend", "def get_all_bookmarks\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n \n total_bookmarks = self.get_bookmarks_count\n \n all_bookmarks = Array.new\n \n index = 1\n while index <= total_bookmarks\n \n all_annotations.push(self.get_bookmark(index))\n \n index+=1\n end\n \n return all_bookmarks\n \n \n rescue Exception=>e\n print e\n end\n end", "def test_get_by_bookmark_id\n\n validId = BookmarkReport.getById(1)\n\n assert_equal 1, validId.userId\n assert_equal 'something', validId.issue\n assert_equal 'report', validId.description\n\n invalidId = BookmarkReport.getById(0)\n\n assert_nil invalidId\n\n end", "def json_index_user_bookmarks_by_user_id_and_item_id\n\n respond_to do |format|\n\n if Bookmark.\n joins(:users_bookmarks).\n joins(:bookmarks_category).\n where('user_id = ? and bookmarks_categories.item_id = ?',params[:user_id],params[:item_id]).exists?\n\n @user_bookmarks = Bookmark.\n select('bookmarks.id, bookmark_url, bookmarks_category_id, description, i_frame, image_name, image_name_desc, bookmarks_categories.item_id, title,position,\"like\"').\n joins(:users_bookmarks).\n joins(:bookmarks_category).\n where('user_id = ? and bookmarks_categories.item_id = ?',params[:user_id],params[:item_id] )\n\n format.json { render json: @user_bookmarks }\n else\n format.json { render json: 'not found user_id and item id' , status: :not_found }\n end\n end\n\n end", "def bookmark_param\n params.require(:bookmark).permit(:user_id, :review_id)\n end", "def index\n @bookmarks = token_or_current_or_guest_user.bookmarks\n bookmark_ids = @bookmarks.collect { |b| b.document_id.to_s }\n\n if bookmark_ids.empty?\n @response = Blacklight::Solr::Response.new({}, {})\n @document_list = []\n else\n query_params = {\n q: bookmarks_query(bookmark_ids),\n defType: 'lucene',\n rows: bookmark_ids.count\n }\n # search_service.fetch does this internally (7.25)\n @response = search_service.repository.search(query_params)\n @document_list = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(@response.documents, 'The @document_list instance variable is now deprecated and will be removed in Blacklight 8.0')\n end\n\n respond_to do |format|\n format.html {}\n format.rss { render layout: false }\n format.atom { render layout: false }\n\n additional_response_formats(format)\n document_export_formats(format)\n end\n end", "def bookmarked_songs\n doc = request(@user, \"favorites\")\n songs = []\n doc.xpath('//rss/channel/item').each do |node|\n songs << { :title => node.xpath('title').text.strip,\n :link => node.xpath('link').text.strip,\n :description => node.xpath('description').text.strip,\n :date => node.xpath('pubDate').text.strip,\n :track => node.xpath('mm:Track/dc:title').text.strip,\n :artist => node.xpath('mm:Artist/dc:title').text.strip,\n :album => node.xpath('mm:Album/dc:title').text.strip,\n :artwork => node.xpath('pandora:albumArtUrl').text.strip,\n :station => node.xpath('pandora:stationLink').text.strip }\n end\n songs\n end", "def friends(user=nil)\n\t\tcursor = -1\n\t\tpage = 0\n\t\tfriends = []\n\t\tbegin\n\t\t\tfriendspage = friends_by_cursor( user, cursor )\n\t\t\tpage += 1\n\t\t\tputs \"page #{page}/cursor #{cursor} - found #{friendspage[\"users\"].size} friends. Next cursor: #{friendspage[\"next_cursor\"]}\"\n\t\t\tfriends += friendspage[\"users\"] if friendspage\n\t\t\tcursor = friendspage[\"next_cursor\"]\n\t\tend until cursor == 0\n\t\tfriends\n\trescue => err\n\t\tputs \"Exception in friends: #{err}\"\n\t\traise err\n\tend", "def index\n @solicitation_bookmarks = SolicitationBookmark.all\n end", "def remember_bookmark\n @ole.RememberBookmark\n end", "def show\n @title = @note.title\n @[email protected]\n @[email protected]\n @tags = @note.tag\n @pages = Page.joins(:notes).where(\"notes.id = #{params[:id]}\").paginate(:page => params[:page], per_page: APP_CONFIG[\"pagenate_count\"][\"notes\"]).order(\"pages.id\").all\n\n if current_user\n @bookmarked = Bookmark.where(:user_id => current_user.id)\n @bookmark = Bookmark.new\n @bookmark.note_id = @note.id\n @bookmark.user_id = current_user.id\n end\n end", "def bookmarklet\n set_bookmarklet_vars(current_user)\n if @account_option.bookmarklet? && @key\n render :bookmarklet\n else\n render :no_access\n end\n end", "def favorite_for(user)\n favs.find_by(user_id: user)\n end", "def get_lists(user)\n get(\"/#{user}/lists.json\")\n end" ]
[ "0.7724672", "0.7675483", "0.75782675", "0.71765727", "0.7074246", "0.7014627", "0.6934293", "0.6886563", "0.6840565", "0.680035", "0.67672414", "0.67662024", "0.6689592", "0.6545206", "0.6523133", "0.6447586", "0.6404685", "0.63477755", "0.6292949", "0.62805396", "0.62382364", "0.61963165", "0.612148", "0.610668", "0.60598546", "0.6024529", "0.60132885", "0.6006832", "0.59901625", "0.59441555", "0.5929885", "0.5914172", "0.58977765", "0.58973736", "0.589681", "0.5862875", "0.58470494", "0.5828099", "0.5817247", "0.58142567", "0.5769576", "0.5753324", "0.5709717", "0.56635815", "0.5638401", "0.56360674", "0.55482405", "0.55365086", "0.55034655", "0.54984474", "0.5495624", "0.54713553", "0.5465866", "0.5465658", "0.5450023", "0.54258233", "0.5411658", "0.53974867", "0.5390495", "0.53624576", "0.53406006", "0.5336613", "0.53215146", "0.53092456", "0.53075665", "0.52876747", "0.5283999", "0.5274042", "0.5269863", "0.5268349", "0.5263141", "0.5261331", "0.5255683", "0.52532136", "0.5246574", "0.5241911", "0.5239231", "0.52388287", "0.52388287", "0.5235245", "0.5230119", "0.52249855", "0.52216226", "0.521067", "0.52070564", "0.51887214", "0.51846445", "0.518381", "0.5181316", "0.517655", "0.5159754", "0.51596326", "0.51546186", "0.5148185", "0.51332587", "0.512578", "0.512082", "0.5107518", "0.50935125", "0.5077652", "0.5071709" ]
0.0
-1
Add a bookmark that the user already has No new bookmarks should be created
def test_get_existing_bookmark test_url = 'http://www.ml-class.com/' num0 = count_bookmarks(@bs.user_id) tot0 = count_bookmarks assert(get_bookmark(@bs.user_id, test_url) === @bs.add_or_get_bookmark(test_url)) assert_equal(num0, count_bookmarks(@bs.user_id)) assert_equal(tot0, count_bookmarks) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n if session[:user_id]\n user = User.find(session[:user_id])\n params[:bookmark][:user] = user\n @bookmark = Bookmark.new(params[:bookmark])\n if params[:tag]\n @tags = params[:tag]\n @tags.each do |tag|\n objTag = Tag.find(tag)\n @bookmark.tags << objTag\n end\n end\n if @bookmark.url.include?(\"http://\")\n else\n @bookmark.url = \"http://\" + @bookmark.url\n end\n \n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to \"/login\"\n end\n end", "def bookmarklet\n unless session[:user_id] \n flash[:info] = \"Please Sign In.\"\n session[:return_to] = request.fullpath\n redirect_to login_url\n end\n @bookmark = Bookmark.find_or_create_by(:url => params[:address], :user_id => session[:user_id])\n end", "def create\n #@bookmark = Bookmark.new(params[:bookmark])\n #\n #respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n # format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n # else\n # format.html { render :action => \"new\" }\n # format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n # end\n #end\n\n #@bookmark = current_user.bookmarks.build(params[:bookmark])\n \n @user = @current_user\n @bookmark = @current_user.bookmarks.build(params[:bookmark])\n @user.bookmarks << @bookmark\n \n #@bookmarkuser = @current_user.bookmarkusers.build(params[:bookmark])\n #\n \n \n \n #@bookmarkuser.save\n \n if @bookmark.save\n flash[:success] = \"Bookmark created!\"\n redirect_to root_path, :flash => { :success => \"Bookmark created!\" }\n else\n render 'pages/home'\n end\n\n end", "def add(bookmark)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'bookmark', bookmark)\n\t\t\tclient.queue_service_action_call('bookmark', 'add', 'bool', kparams)\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn client.do_queue()\n\t\tend", "def bookmark(url, name = \"\")\n Item.create(:bookmark, {:name => name, :redirect_url => url})\n end", "def create\n @bookmarks = if params[:bookmarks]\n permit_bookmarks[:bookmarks]\n else\n [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]\n end\n\n current_or_guest_user.save! unless current_or_guest_user.persisted?\n\n bookmarks_to_add = @bookmarks.reject { |bookmark| current_or_guest_user.bookmarks.where(bookmark).exists? }\n success = ActiveRecord::Base.transaction do\n current_or_guest_user.bookmarks.create!(bookmarks_to_add)\n rescue ActiveRecord::RecordInvalid\n false\n end\n\n if request.xhr?\n success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) : render(json: current_or_guest_user.errors.full_messages, status: \"500\")\n else\n if @bookmarks.any? && success\n flash[:notice] = I18n.t('blacklight.bookmarks.add.success', count: @bookmarks.length)\n elsif @bookmarks.any?\n flash[:error] = I18n.t('blacklight.bookmarks.add.failure', count: @bookmarks.length)\n end\n\n redirect_back fallback_location: bookmarks_path\n end\n end", "def bookmark!(article)\n user_articles.create!( :article_id => article.id )\n end", "def create\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if Bookmark.create(user_id: session_user, receipe_id: receipe.id)\n redirect_to receipe\n else\n \n end\n\n end", "def create\n bookmark = Bookmark.find_or_create_by_URL(params[:bookmark][:URL])\n\n @user_bookmark = UserBookmark.new(:bookmark_id => bookmark.id, :user_id => current_user.id)\n\n respond_to do |format|\n if @user_bookmark.save\n format.html { redirect_to(bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @user_bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add_bookmark(url, options = {})\n perform_post_with_object('/api/1.1/bookmarks/add', options.merge(url: url), Instapaper::Bookmark)\n end", "def _add\n # Load a new bookmark object\n bookmark = Taupe::Model::Bookmark.load\n\n # Modify properties\n bookmark.url = @options[:url]\n bookmark.name = @options[:name]\n\n # Save in database and cache\n bookmark.save\n\n # Tags?\n unless @options[:tags].empty?\n @options[:tags].each do |tag_name|\n tag = Taupe::Model::Tag.fetch \"SELECT * FROM tag WHERE name = '#{tag_name}'\", true\n if tag.nil? || tag.empty?\n tag = Taupe::Model::Tag.load\n tag.name = tag_name\n tag.save\n end\n\n query = \"INSERT INTO bookmark_tag (bookmark_id, tag_id) VALUES (#{bookmark.bookmark_id}, #{tag.tag_id})\"\n Taupe::Model::Tag.exec query\n end\n end\n\n puts 'Bookmark added successfully'\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.user_id = current_user.id\n\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @redirect, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: bookmarks_path }\n else\n format.html { redirect_to @redirect, alert: \"Bookmark could not be saved\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_bookmark\n @bookmark = current_user.bookmarks.find(params[:id])\n end", "def create\n incomplete = true\n error = false\n if ((params[:url] != nil) &&( (params[:description] != nil ) || (params[:bookmark][\"title\"] != nil )))\n incomplete = false\n url = nil\n if params[:url][:url]\n url = params[:url][:url]\n else\n url = params[:url]\n end\n if not ((url =~ /^http:\\/\\//) || (url =~ /^https:\\/\\//))\n url = \"http://\" + url\n end\n link = Link.find_by_url(url) || Link.new(:url => url)\n link.save\n if link.users.include?(current_user)\n flash[:message] = \"Already in\"\n else\n datetime = nil\n datetime = params[:dt] if params[:dt]\n description = params['description'] || params[:bookmark]['title']\n\n new_bookmark = Bookmark.new(:title => description, :link_id => link.id, :user_id => current_user.id, :bookmarked_at => (datetime || Time.now))\n new_bookmark.private = 1 if ((params[:shared] && (params[:shared] == \"no\")))\n new_bookmark.private = params[:bookmark][\"private\"] if params[:bookmark][\"private\"]\n new_bookmark.tag_list = params['tags'] || params[:bookmark]['tags']\n current_user.bookmarks_update_at = Time.now\n if new_bookmark.save\n current_user.save\n logger.info(\"bookmark for #{url} added\")\n else\n error = true\n logger.warn(\"Error : could not save the new bookmark\")\n end\n end\n end\n respond_to do |format|\n format.xml do\n if incomplete || error\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"something went wrong\\\" />\"\n else\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"done\\\" />\"\n end\n end\n end\n end", "def create\n @bookmark = Bookmark.create(bookmark_params)\n end", "def bookmark_params\n params.require(:bookmark).permit(:user_id, :receipe_id)\n end", "def bookmark\n\t\tanswer = $screen.ask(\"bookmark:\",@bookmarks_hist)\n\t\tif answer == nil\n\t\t\t$screen.write_message(\"Cancelled\");\n\t\telse\n\t\t\t$screen.write_message(\"Bookmarked\");\n\t\t\t@bookmarks[answer] = [@row,@col]\n\t\tend\n\tend", "def bookmark_params\n params.permit(:user_id, :raffle_id)\n end", "def add(opts={})\r\n Rakuten::Request.get(\"https://app.rakuten.co.jp/services/api/FavoriteBookmark/Add/20120627\", Rakuten::Api.merge(opts))\r\n end", "def create\n @bookmark = current_user.becomes(LearnUser).bookmarks.new(params[:bookmark])\n\n respond_to do |format|\n if @bookmark.save\n flash[:notice] = 'Bookmark was successfully created.'\n format.html { redirect_to(@bookmark) }\n format.js {redirect_from_facebox(session[:return_to]) }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else \n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity } \n format.js { }\n end\n end\n end", "def set_bookmark\n @user = User.find(session[:usr])\n @receipe = Receipe.find(params[:receipe_id])\n\n end", "def bookmark_param\n params.require(:bookmark).permit(:user_id, :review_id)\n end", "def set_bookmark(bm_name, value)\n raise_if_no_document\n bm_range = set_at_bookmark(bm_name, value)\n @doc.Bookmarks.Add bm_name, bm_range\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :description, :user, :url, :tags, :favourite)\n end", "def set_my_bookmark\n @my_bookmark = MyBookmark.find(params[:id])\n end", "def add_bookmark_to_shoes_topic\n add_topic\n click_link 'Shoes'\n click_link 'New bookmark'\n within 'form' do\n fill_in( 'Url', with: 'http://eu.christianlouboutin.com/uk_en/shop/women/so-kate-patent.html' )\n fill_in('Title', with: 'Christian Louboutins')\n click_button 'Create Bookmark' \n end\n end", "def bookmarklet\n url_str = params[:url]\n url_str.insert(0, 'http://') if url_str.match('^http').nil?\n \n url = Url.find_by_url(url_str)\n if url.nil?\n url = Url.new({:url => params[:url], :icon => nil})\n if !url.save\n render :status => 404\n end\n end\n\n @bookmark = Bookmark.new({:url => url, :title => params[:title], :description => params[:description], :user => current_user})\n \n params[:tags].split(',').each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end \n \n end", "def create\n \n #cross-site scripting fix\n headers['Access-Control-Allow-Origin'] = '*'\n headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-Prototype-Version'\n \n u = User.find(params[:id])\n b = Bookmark.where(url: params[:url], user_id: u).first\n c = Category.find(params[:category])\n \n #ensure user does not submit a link more than once\n if b == nil\n Bookmark.create(url: params[:url], title: params[:title], user: u, category: c); \n end\n\n render :nothing => true\n end", "def test_add_new_bookmark\n test_url = 'http://gigaom.com'\n title = 'GigaOM'\n num_lns0 = count_links\n tot_bms0 = count_bookmarks\n num_bms0 = count_bookmarks(@bs.user_id)\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_lns0 + 1, count_links)\n assert_equal(tot_bms0 + 1, count_bookmarks)\n assert_equal(num_bms0 + 1, count_bookmarks(@bs.user_id))\n assert_equal(get_link_title(test_url), exp_bm.name)\n delete_link(test_url)\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n \n respond_to do |format|\n if @bookmark.save\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @bookmark }\n else\n # format.html { render :new }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bookmarklet = Bookmarklet.new(params[:bookmarklet])\n @bookmarklet.author = current_user\n\n respond_to do |format|\n if @bookmarklet.save\n flash[:notice] = 'Bookmarklet was successfully created.'\n format.html { redirect_to(@bookmarklet) }\n format.xml { render :xml => @bookmarklet, :status => :created, :location => @bookmarklet }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmarklet.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def bookmark_params\n params.require(:bookmark).permit(:user_id, :record_id)\n end", "def create\n @bookmark = current_user.bookmarks.new(params[:bookmark])\n\n respond_to do |format|\n if @bookmark.save\n flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.bookmark'))\n @bookmark.create_tag_index\n @bookmark.manifestation.index!\n if params[:mode] == 'tag_edit'\n format.html { redirect_to(@bookmark.manifestation) }\n format.json { render :json => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { redirect_to(@bookmark) }\n format.json { render :json => @bookmark, :status => :created, :location => @bookmark }\n end\n else\n @user = current_user\n format.html { render :action => \"new\" }\n format.json { render :json => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n\n session[:params][:bookmark] = nil if session[:params]\n end", "def bookmark_params\n params.permit(:bookmark, :post_id)\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n\t\t@bookmark = Bookmark.find(params[:id])\n\tend", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.owner = current_user\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark.poi }\n format.json { render :show, status: :created, location: @bookmark }\n else\n format.html { redirect_to root_path, alert: t('error', scope: @t_scope) }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit([:title, :url, :category, :comment, :is_favorite])\n end", "def create\n @bookmark = @tag.bookmarks.new(bookmark_params)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to path_for_redirect, notice: \"Bookmark, #@bookmark created.\" }\n\n format.json { render json: @bookmark, status: :created }\n else\n format.html { render :new }\n\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit([:title, :url, :category, :is_favorite, :comment])\n end", "def create\n @bookmark = Bookmark.new(params[:bookmark])\n @bookmark.publisher = current_account\n @bookmark.should_tweet = params[:twitter]\n \n respond_to do |format|\n if @bookmark.save\n flash[:notice] = 'Bookmark was successfully created.'\n format.html { redirect_to(@bookmark) }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_authorized_bookmark\n @bookmark = Bookmark.find(params[:id])\n redirect_to bookmarks_path, notice: \"Not authorized to operate on this bookmark\" unless current_user == @bookmark.user\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @title = PageTitleGetter.new(params[:bookmark][:url]).title\n @bookmark.name = @title\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to topic_bookmarks_path, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @bookmark }\n else\n format.html { render :new }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_add_bookmark\n test_url = 'http://www.gridgain.com/'\n num_lns0 = count_links\n num_bms0 = count_bookmarks\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_bms0 + 1, count_bookmarks)\n assert_equal(num_lns0, count_links)\n assert(get_link_title(test_url), exp_bm.name)\n delete_bookmark(@bs.user_id, test_url)\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n\n if @bookmark.save\n render json: { bookmark: @bookmark }, status: :created\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end", "def create\n\t\tbookmark_params = {\n\t\t\t:owner => Prover.find(params[:owner]),\n\t\t\t:post => Post.find(params[:post])\n\t\t}\n\n\t\t@bookmark = Bookmark.new(bookmark_params)\n\n\t\trespond_to do |format|\n\t\t\tif @bookmark.save\n\t\t\t\tformat.html { render :json => @bookmark }\n\t\t\t\tformat.json { render :show, status: :created, location: @bookmark }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.save\n @bookmarks = Bookmark.all\n\n # respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n # format.json { render :show, status: :created, location: @bookmark }\n # else\n # format.html { render :new }\n # format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n tags = params[:bookmark][:tags].split(',').map do |tag|\n Tag.new(:name => tag.strip)\n end\n # use find_or_create\n @bookmark = Bookmark.find_or_create_by_user_id_and_url(:url => params[:bookmark][:url], :title => params[:bookmark][:title], :desc => params[:bookmark][:desc], :private => params[:bookmark][:private], :user_id => params[:bookmark][:user_id], :hashed_url => Digest::MD5.hexdigest(params[:bookmark][:url]) )\n \n respond_to do |format|\n if @bookmark.save\n # add bookmark id to each tag we created\n tags.each { |t| t.bookmark_id = @bookmark.id; t.save}\n if params[:bookmark][:is_popup]\n format.html { redirect_to(@bookmark, :notice => 'Close the Window!', :locals => {:close_window => 1}) }\n else \n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n end\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def savebookmark\n\t\t\t\turl_str = save_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => save_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t render :status => 404\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\t \n\t\t\t @bookmark = Bookmark.new({:title => save_bookmark_params[:title], :description => save_bookmark_params[:description], :url => url, :user_id => doorkeeper_token.resource_owner_id})\t\t\t \n\n\t\t\t tags = save_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\t\t\t \n\t\t\t \n\t\t\t if @bookmark.save\n\t\t\t \trespond_to do |format|\n \t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t\t \n\t\t\t else\n\t\t\t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\t end\t\t\t \n\t\t\tend", "def bookmark_params\n params.require(:bookmark).permit(:title, :url)\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url)\n end", "def bookmark_object(the_user)\n the_user.bookmarked_posts.find_by_post_id(id)\n end", "def pin_bookmark_for_user(user_id, bookmark_id)\n bm = get_bookmark_for_user(user_id, bookmark_id)\n unless bm == nil\n bm.is_pinned = true\n bm = update_bookmark_for_user(user_id, bm)\n end\n bm\n end", "def bookmark_params\n params.require(:bookmark).permit(:name, :url, :tag_id, :category_id)\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url, :desc, :group_id)\n end", "def bookmark_params\n params.require(:bookmark).permit(:name, :url, :topic_id)\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render :index, status: :created, location: @bookmark }\n else\n format.html { render :index }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:url, :title, :notes, :tag_list)\n end", "def set_bookmark\n @bookmark = current_user.topics.find(params[:topic_id]).bookmarks.find(params[:id])\n end", "def bookmark_by(u)\r\n Bookmark.bookmark_by(u, self)\r\n end", "def remember_bookmark(value)\n @ole.RememberBookmark = value\n nil\n end", "def remember_bookmark\n @ole.RememberBookmark\n end", "def bookmark( *names, **options )\n\t\traise \"expected at least one bookmark name\" if names.empty?\n\n\t\tself.server.run( :bookmark, *names, **options )\n\t\treturn true\n\tend", "def bookmark_params\n params.require(:bookmark).permit(:bookmark_type, :user_id, :value, :cover)\n end", "def savebookmark\n @bookmark_plugins = PLUGIN_CONFIG['bookmark']\n url = Url.find_by_url(timeline_bookmark_params[:url])\n if url.nil?\n url = Url.new({:url => timeline_bookmark_params[:url]})\n if !url.save\n format.html { redirect_to 'new', notice: 'Trouble saving the url.' }\n end\n end\n if params[:id].nil?\n @bookmark = Bookmark.new({:title => timeline_bookmark_params[:title], :description => timeline_bookmark_params[:description], :url => url, :user => current_user})\n else\n @bookmark = Bookmark.new({:title => timeline_bookmark_params[:title], :description => timeline_bookmark_params[:description], :url => url, :user => current_user, :group => Group.find(params[:id])})\n end\n\n tags = timeline_bookmark_params[:tags]\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end unless tags.nil?\n #@bookmark = Bookmark.new(bookmark_params) #TODO: Explore this.. Above is Ugly\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to timeline_path, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url, :tag_list)\n end", "def create\n @bookmark = Bookmark.new(bookmark_param)\n review = Review.find_by(id: params[:bookmark][:review_id])\n if @bookmark.save\n redirect_to :back\n else\n render 'new'\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:url, :title, :tag_list)\n end", "def create\n @bookmark.bookmarkable = @vendor || @dress\n @bookmark.user = current_user\n bookmarkable = @bookmark.bookmarkable\n url = (bookmarkable.class.to_s == \"Dress\" ? bookmarkable : vendor_seo_path(bookmarkable))\n\n # Comentado por Gabriel / Andre revisar\n # if current_user.bookmarked?(bookmarkable)\n # return redirect_to(bookmarkable, notice: 'Você já favoritou este item')\n # end\n \n respond_to do |format|\n if @bookmark.save!\n format.js\n format.html { redirect_to url, notice: 'Item adicionado com sucesso aos favoritos.' }\n format.json { render json: @bookmark, status: :created, location: @bookmark }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def updatebookmark\n @bookmark_plugins = PLUGIN_CONFIG['bookmark']\n url = Url.find_by_url(timeline_bookmark_params[:url])\n if url.nil?\n url = Url.new({:url => timeline_bookmark_params[:url]})\n if !url.save\n render :status => 404\n end\n end\n @bookmark = Bookmark.find_by_id(timeline_bookmark_params[:bookmark_id])\n if @bookmark.nil?\n render :status => 404\n end\n @bookmark.title = timeline_bookmark_params[:title]\n @bookmark.description = timeline_bookmark_params[:description]\n @bookmark.url = url\n @bookmark.user = current_user\n\n @bookmark.tags.clear\n\n tags = timeline_bookmark_params[:tags]\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end unless tags.nil?\n #@bookmark = Bookmark.new(bookmark_params) #TODO: Explore this.. Above is Ugly\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url, category_id: [], kind_id: [])\n end", "def bookmarked_by_user?(user)\n bookmark_object(user).present?\n end", "def existing_bookmark_for(document_id)\n # to_a, we don't want to go to the database, we want to use cached\n # copy. \n self.bookmarks.to_a.find {|b| b.document_id == document_id}\n end", "def bookmark_exists?(bm_name)\n raise_if_no_document\n @doc.Bookmarks.Exists(bm_name)\n end", "def bookmark_params\n params.require(:bookmarking).permit(:post_id)\n end", "def bookmark_params\n params.require(:bookmark).permit(:url, :title, :private, :desc, :is_archived, :tag_list)\n end", "def is_bookmarked user\n Bookmark.find_by(user_id: user_id, post_id: id)\n end", "def bookmark_params\n params.require(:bookmark).permit(:message_id)\n end", "def test_add_pvt_bookmark\n test_url = 'http://www.avilayparekh.com/'\n num_lns0 = count_links\n num_bms0 = count_bookmarks\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_lns0 + 1, count_links)\n assert_equal(num_bms0 + 1, count_bookmarks)\n assert_empty(get_link_title(test_url))\n assert_empty(exp_bm.name)\n delete_link(test_url)\n end", "def bookmarklet\n # @bookmark = Bookmark.new(:tags => [Tag.new])\n @bookmark = Bookmark.where(:url => params[:address], :user_id => session[:user_id]).first_or_initialize(:tags => [Tag.new])\n respond_to do |format|\n format.html # bookmarklet.html.erb\n format.xml { render :xml => @bookmark }\n end\n end", "def create\n @solicitation_bookmark = SolicitationBookmark.new(solicitation_bookmark_params)\n\n respond_to do |format|\n if @solicitation_bookmark.save\n format.html { redirect_to @solicitation_bookmark, notice: 'Solicitation bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @solicitation_bookmark }\n else\n format.html { render :new }\n format.json { render json: @solicitation_bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit([:url, :title, :comment, :category, :checkbox])\nend", "def new_bookmark(username, password, uri, short_description)\n representation = form_encoded({ \"bookmark[uri]\" => uri,\n \"bookmark[short_description]\" => \n short_description })\n begin\n dest = \"#{@service_root}/users/#{URI.encode(username)}/bookmarks\"\n response = open(dest, :method => :post, :body => representation,\n :http_basic_authentication => [username, password])\n puts \"Bookmark posted to #{response.meta['location']}\"\n rescue OpenURI::HTTPError => e\n response_code = e.io.status[0].to_i\n if response_code == 401 # Unauthorized\n puts \"It looks like you gave me a bad password.\"\n elsif response_code == 409 # Conflict\n puts \"It looks like you already posted that bookmark.\"\n else\n raise e\n end\n end \n end", "def bookmark(title = \"My Default Sitewide Bookmark Title\", url=\"#{request.request_uri}\")\n url = 'http://' + request.host_with_port + url\n\n \"javascript:bookmarksite('#{title}=>#{request.request_uri}', '#{url}');\"\n end", "def bookmarks(user)\n user = Access::Validate.user(user, false)\n Bookmark\n .where('(bookmarks.creator_id = ? OR bookmarks.updater_id = ?)', user.id, user.id)\n .order('bookmarks.updated_at DESC')\n end", "def create\n @bookmark = Bookmark.new(params[:bookmark])\n @bookmarkable = @bookmark.bookmarkable \n if @bookmarkable.new_record? && @bookmarkable.fandoms.blank?\n @bookmark.errors.add(:base, \"Fandom tag is required\")\n render :new and return\n end\n if @bookmark.errors.empty?\n if @bookmarkable.save && @bookmark.save\n flash[:notice] = ts('Bookmark was successfully created.')\n redirect_to(@bookmark) and return\n end\n end\n @bookmarkable.errors.full_messages.each { |msg| @bookmark.errors.add(:base, msg) }\n render :action => \"new\" and return\n end", "def updatebookmark\n\t\t\t\turl_str = update_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\t\t\n\n\t\t\t url = Url.find_by_url(update_bookmark_params[:url])\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => update_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\n\n\t\t\t @bookmark = Bookmark.find_by_id(update_bookmark_params[:bookmark_id])\n\t\t\t if @bookmark.nil?\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t @bookmark.title = update_bookmark_params[:title]\n\t\t\t @bookmark.description = update_bookmark_params[:description]\n\t\t\t @bookmark.url = url\n\t\t\t @bookmark.user_id = doorkeeper_token.resource_owner_id\n\n\t\t\t @bookmark.tags.clear\n\n\t\t\t tags = update_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\n\n\t\t\t \n\t\t \tif @bookmark.save\n\t\t \trespond_to do |format|\n\t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t \n\t\t \telse\t\t\t \n\t\t \t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t \tend\n\t\t\tend", "def bookmark_params\n params.require(:bookmark).permit(:poi_id)\n end" ]
[ "0.7668615", "0.756963", "0.75449663", "0.7304702", "0.72948056", "0.727888", "0.7272424", "0.72638637", "0.7204328", "0.71956146", "0.7166677", "0.7122617", "0.71022606", "0.69950825", "0.6966107", "0.69440436", "0.69351745", "0.69175786", "0.6868568", "0.6866908", "0.6843982", "0.6803328", "0.6770335", "0.67505467", "0.6744538", "0.6725698", "0.669216", "0.66652215", "0.665808", "0.66314167", "0.66220284", "0.6614851", "0.6614851", "0.6614851", "0.6614851", "0.6614851", "0.6614851", "0.6614851", "0.66094035", "0.66032535", "0.6577831", "0.6577633", "0.6577633", "0.6577633", "0.6577633", "0.6577633", "0.6577633", "0.6574651", "0.6564411", "0.65563995", "0.6548518", "0.6541807", "0.6534754", "0.6523495", "0.6510207", "0.6507834", "0.6505637", "0.64972997", "0.6495353", "0.64791554", "0.6470893", "0.64706063", "0.64706063", "0.64605105", "0.6439832", "0.6437962", "0.6430952", "0.6429462", "0.6418852", "0.64187413", "0.6406983", "0.6396697", "0.63832444", "0.635617", "0.6355277", "0.6351497", "0.63496184", "0.6331907", "0.6331643", "0.6328319", "0.6313543", "0.63113075", "0.6304301", "0.63037705", "0.6288287", "0.6285792", "0.62792945", "0.62791365", "0.6277461", "0.62690693", "0.62653595", "0.6255557", "0.6249122", "0.624821", "0.6222618", "0.6218224", "0.61989063", "0.61629057", "0.6148368", "0.613908" ]
0.61983454
97
Add a new bookmark that is in the system but not for this user A new bookmark should be created, but no new links The new bookmark will have the same name as the title of the link
def test_add_bookmark test_url = 'http://www.gridgain.com/' num_lns0 = count_links num_bms0 = count_bookmarks act_bm = @bs.add_or_get_bookmark(test_url) exp_bm = get_bookmark(@bs.user_id, test_url) assert(exp_bm === act_bm) assert_equal(num_bms0 + 1, count_bookmarks) assert_equal(num_lns0, count_links) assert(get_link_title(test_url), exp_bm.name) delete_bookmark(@bs.user_id, test_url) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n if session[:user_id]\n user = User.find(session[:user_id])\n params[:bookmark][:user] = user\n @bookmark = Bookmark.new(params[:bookmark])\n if params[:tag]\n @tags = params[:tag]\n @tags.each do |tag|\n objTag = Tag.find(tag)\n @bookmark.tags << objTag\n end\n end\n if @bookmark.url.include?(\"http://\")\n else\n @bookmark.url = \"http://\" + @bookmark.url\n end\n \n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to \"/login\"\n end\n end", "def bookmark(url, name = \"\")\n Item.create(:bookmark, {:name => name, :redirect_url => url})\n end", "def bookmarklet\n unless session[:user_id] \n flash[:info] = \"Please Sign In.\"\n session[:return_to] = request.fullpath\n redirect_to login_url\n end\n @bookmark = Bookmark.find_or_create_by(:url => params[:address], :user_id => session[:user_id])\n end", "def create\n #@bookmark = Bookmark.new(params[:bookmark])\n #\n #respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n # format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n # else\n # format.html { render :action => \"new\" }\n # format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n # end\n #end\n\n #@bookmark = current_user.bookmarks.build(params[:bookmark])\n \n @user = @current_user\n @bookmark = @current_user.bookmarks.build(params[:bookmark])\n @user.bookmarks << @bookmark\n \n #@bookmarkuser = @current_user.bookmarkusers.build(params[:bookmark])\n #\n \n \n \n #@bookmarkuser.save\n \n if @bookmark.save\n flash[:success] = \"Bookmark created!\"\n redirect_to root_path, :flash => { :success => \"Bookmark created!\" }\n else\n render 'pages/home'\n end\n\n end", "def bookmark!(article)\n user_articles.create!( :article_id => article.id )\n end", "def create\n bookmark = Bookmark.find_or_create_by_URL(params[:bookmark][:URL])\n\n @user_bookmark = UserBookmark.new(:bookmark_id => bookmark.id, :user_id => current_user.id)\n\n respond_to do |format|\n if @user_bookmark.save\n format.html { redirect_to(bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @user_bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if Bookmark.create(user_id: session_user, receipe_id: receipe.id)\n redirect_to receipe\n else\n \n end\n\n end", "def create\n incomplete = true\n error = false\n if ((params[:url] != nil) &&( (params[:description] != nil ) || (params[:bookmark][\"title\"] != nil )))\n incomplete = false\n url = nil\n if params[:url][:url]\n url = params[:url][:url]\n else\n url = params[:url]\n end\n if not ((url =~ /^http:\\/\\//) || (url =~ /^https:\\/\\//))\n url = \"http://\" + url\n end\n link = Link.find_by_url(url) || Link.new(:url => url)\n link.save\n if link.users.include?(current_user)\n flash[:message] = \"Already in\"\n else\n datetime = nil\n datetime = params[:dt] if params[:dt]\n description = params['description'] || params[:bookmark]['title']\n\n new_bookmark = Bookmark.new(:title => description, :link_id => link.id, :user_id => current_user.id, :bookmarked_at => (datetime || Time.now))\n new_bookmark.private = 1 if ((params[:shared] && (params[:shared] == \"no\")))\n new_bookmark.private = params[:bookmark][\"private\"] if params[:bookmark][\"private\"]\n new_bookmark.tag_list = params['tags'] || params[:bookmark]['tags']\n current_user.bookmarks_update_at = Time.now\n if new_bookmark.save\n current_user.save\n logger.info(\"bookmark for #{url} added\")\n else\n error = true\n logger.warn(\"Error : could not save the new bookmark\")\n end\n end\n end\n respond_to do |format|\n format.xml do\n if incomplete || error\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"something went wrong\\\" />\"\n else\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"done\\\" />\"\n end\n end\n end\n end", "def add_bookmark_to_shoes_topic\n add_topic\n click_link 'Shoes'\n click_link 'New bookmark'\n within 'form' do\n fill_in( 'Url', with: 'http://eu.christianlouboutin.com/uk_en/shop/women/so-kate-patent.html' )\n fill_in('Title', with: 'Christian Louboutins')\n click_button 'Create Bookmark' \n end\n end", "def create\n @bookmarks = if params[:bookmarks]\n permit_bookmarks[:bookmarks]\n else\n [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]\n end\n\n current_or_guest_user.save! unless current_or_guest_user.persisted?\n\n bookmarks_to_add = @bookmarks.reject { |bookmark| current_or_guest_user.bookmarks.where(bookmark).exists? }\n success = ActiveRecord::Base.transaction do\n current_or_guest_user.bookmarks.create!(bookmarks_to_add)\n rescue ActiveRecord::RecordInvalid\n false\n end\n\n if request.xhr?\n success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) : render(json: current_or_guest_user.errors.full_messages, status: \"500\")\n else\n if @bookmarks.any? && success\n flash[:notice] = I18n.t('blacklight.bookmarks.add.success', count: @bookmarks.length)\n elsif @bookmarks.any?\n flash[:error] = I18n.t('blacklight.bookmarks.add.failure', count: @bookmarks.length)\n end\n\n redirect_back fallback_location: bookmarks_path\n end\n end", "def add_bookmark(url, options = {})\n perform_post_with_object('/api/1.1/bookmarks/add', options.merge(url: url), Instapaper::Bookmark)\n end", "def create\n \n #cross-site scripting fix\n headers['Access-Control-Allow-Origin'] = '*'\n headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-Prototype-Version'\n \n u = User.find(params[:id])\n b = Bookmark.where(url: params[:url], user_id: u).first\n c = Category.find(params[:category])\n \n #ensure user does not submit a link more than once\n if b == nil\n Bookmark.create(url: params[:url], title: params[:title], user: u, category: c); \n end\n\n render :nothing => true\n end", "def bookmarklet\n url_str = params[:url]\n url_str.insert(0, 'http://') if url_str.match('^http').nil?\n \n url = Url.find_by_url(url_str)\n if url.nil?\n url = Url.new({:url => params[:url], :icon => nil})\n if !url.save\n render :status => 404\n end\n end\n\n @bookmark = Bookmark.new({:url => url, :title => params[:title], :description => params[:description], :user => current_user})\n \n params[:tags].split(',').each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end \n \n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.user_id = current_user.id\n\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @redirect, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: bookmarks_path }\n else\n format.html { redirect_to @redirect, alert: \"Bookmark could not be saved\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def _add\n # Load a new bookmark object\n bookmark = Taupe::Model::Bookmark.load\n\n # Modify properties\n bookmark.url = @options[:url]\n bookmark.name = @options[:name]\n\n # Save in database and cache\n bookmark.save\n\n # Tags?\n unless @options[:tags].empty?\n @options[:tags].each do |tag_name|\n tag = Taupe::Model::Tag.fetch \"SELECT * FROM tag WHERE name = '#{tag_name}'\", true\n if tag.nil? || tag.empty?\n tag = Taupe::Model::Tag.load\n tag.name = tag_name\n tag.save\n end\n\n query = \"INSERT INTO bookmark_tag (bookmark_id, tag_id) VALUES (#{bookmark.bookmark_id}, #{tag.tag_id})\"\n Taupe::Model::Tag.exec query\n end\n end\n\n puts 'Bookmark added successfully'\n end", "def create\n @bookmark = current_user.becomes(LearnUser).bookmarks.new(params[:bookmark])\n\n respond_to do |format|\n if @bookmark.save\n flash[:notice] = 'Bookmark was successfully created.'\n format.html { redirect_to(@bookmark) }\n format.js {redirect_from_facebox(session[:return_to]) }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else \n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity } \n format.js { }\n end\n end\n end", "def test_add_new_bookmark\n test_url = 'http://gigaom.com'\n title = 'GigaOM'\n num_lns0 = count_links\n tot_bms0 = count_bookmarks\n num_bms0 = count_bookmarks(@bs.user_id)\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_lns0 + 1, count_links)\n assert_equal(tot_bms0 + 1, count_bookmarks)\n assert_equal(num_bms0 + 1, count_bookmarks(@bs.user_id))\n assert_equal(get_link_title(test_url), exp_bm.name)\n delete_link(test_url)\n end", "def bookmark_params\n params.permit(:user_id, :raffle_id)\n end", "def new_bookmark(username, password, uri, short_description)\n representation = form_encoded({ \"bookmark[uri]\" => uri,\n \"bookmark[short_description]\" => \n short_description })\n begin\n dest = \"#{@service_root}/users/#{URI.encode(username)}/bookmarks\"\n response = open(dest, :method => :post, :body => representation,\n :http_basic_authentication => [username, password])\n puts \"Bookmark posted to #{response.meta['location']}\"\n rescue OpenURI::HTTPError => e\n response_code = e.io.status[0].to_i\n if response_code == 401 # Unauthorized\n puts \"It looks like you gave me a bad password.\"\n elsif response_code == 409 # Conflict\n puts \"It looks like you already posted that bookmark.\"\n else\n raise e\n end\n end \n end", "def set_bookmark\n @user = User.find(session[:usr])\n @receipe = Receipe.find(params[:receipe_id])\n\n end", "def bookmark_params\n params.require(:bookmark).permit(:user_id, :receipe_id)\n end", "def add(opts={})\r\n Rakuten::Request.get(\"https://app.rakuten.co.jp/services/api/FavoriteBookmark/Add/20120627\", Rakuten::Api.merge(opts))\r\n end", "def bookmark(title = \"My Default Sitewide Bookmark Title\", url=\"#{request.request_uri}\")\n url = 'http://' + request.host_with_port + url\n\n \"javascript:bookmarksite('#{title}=>#{request.request_uri}', '#{url}');\"\n end", "def set_bookmark\n @bookmark = current_user.bookmarks.find(params[:id])\n end", "def create\n @bookmarklet = Bookmarklet.new(params[:bookmarklet])\n @bookmarklet.author = current_user\n\n respond_to do |format|\n if @bookmarklet.save\n flash[:notice] = 'Bookmarklet was successfully created.'\n format.html { redirect_to(@bookmarklet) }\n format.xml { render :xml => @bookmarklet, :status => :created, :location => @bookmarklet }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmarklet.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @title = PageTitleGetter.new(params[:bookmark][:url]).title\n @bookmark.name = @title\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to topic_bookmarks_path, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @bookmark }\n else\n format.html { render :new }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bookmark = Bookmark.create(bookmark_params)\n end", "def bookmark\n\t\tanswer = $screen.ask(\"bookmark:\",@bookmarks_hist)\n\t\tif answer == nil\n\t\t\t$screen.write_message(\"Cancelled\");\n\t\telse\n\t\t\t$screen.write_message(\"Bookmarked\");\n\t\t\t@bookmarks[answer] = [@row,@col]\n\t\tend\n\tend", "def set_bookmark(bm_name, value)\n raise_if_no_document\n bm_range = set_at_bookmark(bm_name, value)\n @doc.Bookmarks.Add bm_name, bm_range\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :description, :user, :url, :tags, :favourite)\n end", "def create\n @bookmark = current_user.bookmarks.new(params[:bookmark])\n\n respond_to do |format|\n if @bookmark.save\n flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.bookmark'))\n @bookmark.create_tag_index\n @bookmark.manifestation.index!\n if params[:mode] == 'tag_edit'\n format.html { redirect_to(@bookmark.manifestation) }\n format.json { render :json => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { redirect_to(@bookmark) }\n format.json { render :json => @bookmark, :status => :created, :location => @bookmark }\n end\n else\n @user = current_user\n format.html { render :action => \"new\" }\n format.json { render :json => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n\n session[:params][:bookmark] = nil if session[:params]\n end", "def savebookmark\n\t\t\t\turl_str = save_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => save_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t render :status => 404\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\t \n\t\t\t @bookmark = Bookmark.new({:title => save_bookmark_params[:title], :description => save_bookmark_params[:description], :url => url, :user_id => doorkeeper_token.resource_owner_id})\t\t\t \n\n\t\t\t tags = save_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\t\t\t \n\t\t\t \n\t\t\t if @bookmark.save\n\t\t\t \trespond_to do |format|\n \t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t\t \n\t\t\t else\n\t\t\t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\t end\t\t\t \n\t\t\tend", "def create\n tags = params[:bookmark][:tags].split(',').map do |tag|\n Tag.new(:name => tag.strip)\n end\n # use find_or_create\n @bookmark = Bookmark.find_or_create_by_user_id_and_url(:url => params[:bookmark][:url], :title => params[:bookmark][:title], :desc => params[:bookmark][:desc], :private => params[:bookmark][:private], :user_id => params[:bookmark][:user_id], :hashed_url => Digest::MD5.hexdigest(params[:bookmark][:url]) )\n \n respond_to do |format|\n if @bookmark.save\n # add bookmark id to each tag we created\n tags.each { |t| t.bookmark_id = @bookmark.id; t.save}\n if params[:bookmark][:is_popup]\n format.html { redirect_to(@bookmark, :notice => 'Close the Window!', :locals => {:close_window => 1}) }\n else \n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n end\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_add_pvt_bookmark\n test_url = 'http://www.avilayparekh.com/'\n num_lns0 = count_links\n num_bms0 = count_bookmarks\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_lns0 + 1, count_links)\n assert_equal(num_bms0 + 1, count_bookmarks)\n assert_empty(get_link_title(test_url))\n assert_empty(exp_bm.name)\n delete_link(test_url)\n end", "def bookmark_by(u)\r\n Bookmark.bookmark_by(u, self)\r\n end", "def create_bookmark\n clear_last_line\n print 'Enter A-Z, a-z or 0-9 to create a bookmark: '\n # print \"\\e[?25h\" # unhide cursor\n key = get_char\n # print \"\\e[?25l\" # hide cursor\n if /^[0-9A-Za-z]$/.match?(key)\n set_bookmark key\n @modified = true\n message \"Created bookmark #{key} for #{File.basename(Dir.pwd)}.\"\n else\n perror 'Bookmark must be alpha character or number.'\n end\nend", "def savebookmark\n @bookmark_plugins = PLUGIN_CONFIG['bookmark']\n url = Url.find_by_url(timeline_bookmark_params[:url])\n if url.nil?\n url = Url.new({:url => timeline_bookmark_params[:url]})\n if !url.save\n format.html { redirect_to 'new', notice: 'Trouble saving the url.' }\n end\n end\n if params[:id].nil?\n @bookmark = Bookmark.new({:title => timeline_bookmark_params[:title], :description => timeline_bookmark_params[:description], :url => url, :user => current_user})\n else\n @bookmark = Bookmark.new({:title => timeline_bookmark_params[:title], :description => timeline_bookmark_params[:description], :url => url, :user => current_user, :group => Group.find(params[:id])})\n end\n\n tags = timeline_bookmark_params[:tags]\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end unless tags.nil?\n #@bookmark = Bookmark.new(bookmark_params) #TODO: Explore this.. Above is Ugly\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to timeline_path, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.owner = current_user\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark.poi }\n format.json { render :show, status: :created, location: @bookmark }\n else\n format.html { redirect_to root_path, alert: t('error', scope: @t_scope) }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def remember_bookmark(value)\n @ole.RememberBookmark = value\n nil\n end", "def remember_bookmark\n @ole.RememberBookmark\n end", "def bookmark_param\n params.require(:bookmark).permit(:user_id, :review_id)\n end", "def add(bookmark)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'bookmark', bookmark)\n\t\t\tclient.queue_service_action_call('bookmark', 'add', 'bool', kparams)\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn client.do_queue()\n\t\tend", "def set_my_bookmark\n @my_bookmark = MyBookmark.find(params[:id])\n end", "def create\n\t\tbookmark_params = {\n\t\t\t:owner => Prover.find(params[:owner]),\n\t\t\t:post => Post.find(params[:post])\n\t\t}\n\n\t\t@bookmark = Bookmark.new(bookmark_params)\n\n\t\trespond_to do |format|\n\t\t\tif @bookmark.save\n\t\t\t\tformat.html { render :json => @bookmark }\n\t\t\t\tformat.json { render :show, status: :created, location: @bookmark }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def bookmark_params\n params.require(:bookmark).permit(:title, :url, :desc, :group_id)\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n \n respond_to do |format|\n if @bookmark.save\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @bookmark }\n else\n # format.html { render :new }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_authorized_bookmark\n @bookmark = Bookmark.find(params[:id])\n redirect_to bookmarks_path, notice: \"Not authorized to operate on this bookmark\" unless current_user == @bookmark.user\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url)\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url)\n end", "def updatebookmark\n @bookmark_plugins = PLUGIN_CONFIG['bookmark']\n url = Url.find_by_url(timeline_bookmark_params[:url])\n if url.nil?\n url = Url.new({:url => timeline_bookmark_params[:url]})\n if !url.save\n render :status => 404\n end\n end\n @bookmark = Bookmark.find_by_id(timeline_bookmark_params[:bookmark_id])\n if @bookmark.nil?\n render :status => 404\n end\n @bookmark.title = timeline_bookmark_params[:title]\n @bookmark.description = timeline_bookmark_params[:description]\n @bookmark.url = url\n @bookmark.user = current_user\n\n @bookmark.tags.clear\n\n tags = timeline_bookmark_params[:tags]\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end unless tags.nil?\n #@bookmark = Bookmark.new(bookmark_params) #TODO: Explore this.. Above is Ugly\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark( *names, **options )\n\t\traise \"expected at least one bookmark name\" if names.empty?\n\n\t\tself.server.run( :bookmark, *names, **options )\n\t\treturn true\n\tend", "def open_bookmark(name, bookmark, &block)\n create_tab(name, bookmark, &block)\n end", "def bookmark_params\n params.require(:bookmark).permit([:title, :url, :category, :comment, :is_favorite])\n end", "def bookmark_params\n params.require(:bookmark).permit([:title, :url, :category, :is_favorite, :comment])\n end", "def bookmark_params\n params.permit(:bookmark, :post_id)\n end", "def create\n @bookmark = @tag.bookmarks.new(bookmark_params)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to path_for_redirect, notice: \"Bookmark, #@bookmark created.\" }\n\n format.json { render json: @bookmark, status: :created }\n else\n format.html { render :new }\n\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bookmark = Bookmark.new(params[:bookmark])\n @bookmark.publisher = current_account\n @bookmark.should_tweet = params[:twitter]\n \n respond_to do |format|\n if @bookmark.save\n flash[:notice] = 'Bookmark was successfully created.'\n format.html { redirect_to(@bookmark) }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def bookmarklet\n # @bookmark = Bookmark.new(:tags => [Tag.new])\n @bookmark = Bookmark.where(:url => params[:address], :user_id => session[:user_id]).first_or_initialize(:tags => [Tag.new])\n respond_to do |format|\n format.html # bookmarklet.html.erb\n format.xml { render :xml => @bookmark }\n end\n end", "def export_link(builder, link)\n folders = []\n folders << link.folder.name if link.folder\n folders = folders + link.keywords if link.keywords.present?\n builder.bookmarks << Markio::Bookmark.create({\n title: link.name,\n href: link.url,\n folders: folders.present? ? folders : nil,\n add_date: link.saved_at\n })\n end", "def bookmark_object(the_user)\n the_user.bookmarked_posts.find_by_post_id(id)\n end", "def bookmarklet\n text 'Drag the following link to your toolbar to submit with a single click: '\n a 'bookmark-it!', :href =>\"javascript:location.href='http:#{URL(New)}?page_link='+encodeURIComponent(location.href)+'&description='+encodeURIComponent(document.title)+'&body='+encodeURIComponent(window.getSelection())\"\n end", "def create\n @bookmark.bookmarkable = @vendor || @dress\n @bookmark.user = current_user\n bookmarkable = @bookmark.bookmarkable\n url = (bookmarkable.class.to_s == \"Dress\" ? bookmarkable : vendor_seo_path(bookmarkable))\n\n # Comentado por Gabriel / Andre revisar\n # if current_user.bookmarked?(bookmarkable)\n # return redirect_to(bookmarkable, notice: 'Você já favoritou este item')\n # end\n \n respond_to do |format|\n if @bookmark.save!\n format.js\n format.html { redirect_to url, notice: 'Item adicionado com sucesso aos favoritos.' }\n format.json { render json: @bookmark, status: :created, location: @bookmark }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:user_id, :record_id)\n end", "def bookmark_params\n params.require(:bookmark).permit(:name, :url, :tag_id, :category_id)\n end", "def bookmark_params\n params.require(:bookmark).permit(:name, :url, :topic_id)\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def save_bookmark(data)\n t = open(File.expand_path(\"~/Dropbox/test.txt\"), \"a\")\n t.write(data)\n puts \"saved\"\n t.close\nend", "def pin_bookmark_for_user(user_id, bookmark_id)\n bm = get_bookmark_for_user(user_id, bookmark_id)\n unless bm == nil\n bm.is_pinned = true\n bm = update_bookmark_for_user(user_id, bm)\n end\n bm\n end", "def updatebookmark\n\t\t\t\turl_str = update_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\t\t\n\n\t\t\t url = Url.find_by_url(update_bookmark_params[:url])\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => update_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\n\n\t\t\t @bookmark = Bookmark.find_by_id(update_bookmark_params[:bookmark_id])\n\t\t\t if @bookmark.nil?\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t @bookmark.title = update_bookmark_params[:title]\n\t\t\t @bookmark.description = update_bookmark_params[:description]\n\t\t\t @bookmark.url = url\n\t\t\t @bookmark.user_id = doorkeeper_token.resource_owner_id\n\n\t\t\t @bookmark.tags.clear\n\n\t\t\t tags = update_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\n\n\t\t\t \n\t\t \tif @bookmark.save\n\t\t \trespond_to do |format|\n\t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t \n\t\t \telse\t\t\t \n\t\t \t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t \tend\n\t\t\tend", "def create\n @bookmark = Bookmark.new(bookmark_params)\n\n if @bookmark.save\n render json: { bookmark: @bookmark }, status: :created\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.save\n @bookmarks = Bookmark.all\n\n # respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n # format.json { render :show, status: :created, location: @bookmark }\n # else\n # format.html { render :new }\n # format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def saveurl\n url_str = link_params[:url]\n url_str.insert(0, 'http://') if url_str.match('^http').nil?\n \n annotations = get_annotations(url_str)\n \n url = Url.find_by_url(url_str)\n if url.nil?\n url = Url.new({:url => link_params[:url], :icon => annotations[:icon]})\n if !url.save\n render :status => 404\n end\n else\n Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n end\n\n @bookmark = Bookmark.new({:url => url, :title => annotations[:title], :description => annotations[:desc], :user => current_user})\n\n @share_with_group = Group.find(params[:id]) if params[:id]\n\n annotations[:keywords].each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end\n\n respond_to do |format|\n format.html { render action: 'bookmark_form' }\n format.js\n end\n end", "def set_bookmark\n\t\t@bookmark = Bookmark.find(params[:id])\n\tend", "def bookmark_params\n params.require(:bookmark).permit(:url, :title, :notes, :tag_list)\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def test_add_invalid_bookmark\n num_lns0 = count_links\n act_bm = @bs.add_or_get_bookmark('ha ha ha')\n assert(act_bm.errors.count > 0)\n assert_equal(num_lns0, count_links)\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render :index, status: :created, location: @bookmark }\n else\n format.html { render :index }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:url, :title, :private, :desc, :is_archived, :tag_list)\n end", "def bookmarks(user)\n user = Access::Validate.user(user, false)\n Bookmark\n .where('(bookmarks.creator_id = ? OR bookmarks.updater_id = ?)', user.id, user.id)\n .order('bookmarks.updated_at DESC')\n end", "def new\n @bookmark = Bookmark.new\n @bookmark.user_id= session[:user_id]\n @bookmark.origin='database-created'\n @bookmark.url='http://'\n @bookmark.folder=[\" \"]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bookmark }\n end\n end", "def list_bookmarks(user_id)\n url = \"#{@@request_url}/User.listBookmarks?appid=#{@@appid}&ID=#{user_id}\"\n end", "def create\n @solicitation_bookmark = SolicitationBookmark.new(solicitation_bookmark_params)\n\n respond_to do |format|\n if @solicitation_bookmark.save\n format.html { redirect_to @solicitation_bookmark, notice: 'Solicitation bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @solicitation_bookmark }\n else\n format.html { render :new }\n format.json { render json: @solicitation_bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url, category_id: [], kind_id: [])\n end", "def create\n @bookmark = Bookmark.new(params[:bookmark])\n @bookmarkable = @bookmark.bookmarkable \n if @bookmarkable.new_record? && @bookmarkable.fandoms.blank?\n @bookmark.errors.add(:base, \"Fandom tag is required\")\n render :new and return\n end\n if @bookmark.errors.empty?\n if @bookmarkable.save && @bookmark.save\n flash[:notice] = ts('Bookmark was successfully created.')\n redirect_to(@bookmark) and return\n end\n end\n @bookmarkable.errors.full_messages.each { |msg| @bookmark.errors.add(:base, msg) }\n render :action => \"new\" and return\n end", "def test_get_existing_bookmark\n test_url = 'http://www.ml-class.com/'\n num0 = count_bookmarks(@bs.user_id)\n tot0 = count_bookmarks\n assert(get_bookmark(@bs.user_id, test_url) === @bs.add_or_get_bookmark(test_url))\n assert_equal(num0, count_bookmarks(@bs.user_id))\n assert_equal(tot0, count_bookmarks)\n end", "def newbookmark\n @bookmarklet = bookmarklet_params(params)\n @event = @calendar.events.build\n \n respond_to do |format|\n format.html # newbookmark.html.erb\n format.xml { render :xml => @event }\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:url, :title, :tag_list)\n end", "def create_bookmark\n ch = get_single \"Enter A to Z or 0-9 for bookmark: \"\n #ch = get_char\n if ch =~ /^[0-9A-Z]$/\n #$bookmarks[ch] = \"#{Dir.pwd}:#{$cursor}\"\n # \n # The significance of putting a : and not a / is that with a \n # : the dir will be opened with cursor on same object it was on, and not\n # go into the dir. e.g, If bookmark is created with cursor on a dir, we don't want\n # it to go into the dir.\n $bookmarks[ch] = \"#{Dir.pwd}:#{$view[$cursor]}\"\n $modified = true\n else\n perror \"Bookmark must be upper-case character or number.\"\n end\nend", "def bookmark_params\n params.require(:bookmark).permit(:title, :url, :tag_list)\n end" ]
[ "0.7378412", "0.73379254", "0.7270012", "0.7123105", "0.70684594", "0.7002804", "0.69816124", "0.6975062", "0.6803726", "0.6779687", "0.6770813", "0.67296064", "0.6688902", "0.66777533", "0.66677034", "0.66621345", "0.66582173", "0.660443", "0.6565674", "0.6533371", "0.65295464", "0.6501501", "0.6484649", "0.6469283", "0.64656276", "0.6440242", "0.6419153", "0.63954353", "0.6364809", "0.6327648", "0.6324699", "0.6320824", "0.6314574", "0.6299381", "0.6291635", "0.62712324", "0.6233815", "0.6231534", "0.62299466", "0.6228736", "0.6221442", "0.62126726", "0.6201321", "0.6192687", "0.6184123", "0.61735183", "0.61659855", "0.61614406", "0.61614406", "0.6147878", "0.6147742", "0.61405843", "0.6132795", "0.6130564", "0.61280245", "0.6118249", "0.6095519", "0.6092629", "0.6089438", "0.6088159", "0.6077495", "0.60758215", "0.6062433", "0.6053502", "0.6027633", "0.602554", "0.602554", "0.602554", "0.602554", "0.602554", "0.602554", "0.602554", "0.6025153", "0.601294", "0.60128546", "0.60086876", "0.60049516", "0.6004469", "0.60024184", "0.5987233", "0.5969144", "0.5969144", "0.5969144", "0.5969144", "0.5969144", "0.5969144", "0.596906", "0.5968784", "0.5949542", "0.5949121", "0.5944942", "0.5934925", "0.5930624", "0.5923845", "0.5914113", "0.5904343", "0.58933306", "0.5882642", "0.5880914", "0.5873428" ]
0.6351619
29
Add a new bookmark that is not in the system A new link should be created along with a new bookmark The bookmark name and link title should be the page title
def test_add_new_bookmark test_url = 'http://gigaom.com' title = 'GigaOM' num_lns0 = count_links tot_bms0 = count_bookmarks num_bms0 = count_bookmarks(@bs.user_id) act_bm = @bs.add_or_get_bookmark(test_url) exp_bm = get_bookmark(@bs.user_id, test_url) assert(exp_bm === act_bm) assert_equal(num_lns0 + 1, count_links) assert_equal(tot_bms0 + 1, count_bookmarks) assert_equal(num_bms0 + 1, count_bookmarks(@bs.user_id)) assert_equal(get_link_title(test_url), exp_bm.name) delete_link(test_url) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bookmark(url, name = \"\")\n Item.create(:bookmark, {:name => name, :redirect_url => url})\n end", "def bookmark(title = \"My Default Sitewide Bookmark Title\", url=\"#{request.request_uri}\")\n url = 'http://' + request.host_with_port + url\n\n \"javascript:bookmarksite('#{title}=>#{request.request_uri}', '#{url}');\"\n end", "def add_bookmark(url, options = {})\n perform_post_with_object('/api/1.1/bookmarks/add', options.merge(url: url), Instapaper::Bookmark)\n end", "def add_bookmark_to_shoes_topic\n add_topic\n click_link 'Shoes'\n click_link 'New bookmark'\n within 'form' do\n fill_in( 'Url', with: 'http://eu.christianlouboutin.com/uk_en/shop/women/so-kate-patent.html' )\n fill_in('Title', with: 'Christian Louboutins')\n click_button 'Create Bookmark' \n end\n end", "def bookmarklet\n url_str = params[:url]\n url_str.insert(0, 'http://') if url_str.match('^http').nil?\n \n url = Url.find_by_url(url_str)\n if url.nil?\n url = Url.new({:url => params[:url], :icon => nil})\n if !url.save\n render :status => 404\n end\n end\n\n @bookmark = Bookmark.new({:url => url, :title => params[:title], :description => params[:description], :user => current_user})\n \n params[:tags].split(',').each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end \n \n end", "def bookmarklet\n text 'Drag the following link to your toolbar to submit with a single click: '\n a 'bookmark-it!', :href =>\"javascript:location.href='http:#{URL(New)}?page_link='+encodeURIComponent(location.href)+'&description='+encodeURIComponent(document.title)+'&body='+encodeURIComponent(window.getSelection())\"\n end", "def bookmarklet\n unless session[:user_id] \n flash[:info] = \"Please Sign In.\"\n session[:return_to] = request.fullpath\n redirect_to login_url\n end\n @bookmark = Bookmark.find_or_create_by(:url => params[:address], :user_id => session[:user_id])\n end", "def create\n if session[:user_id]\n user = User.find(session[:user_id])\n params[:bookmark][:user] = user\n @bookmark = Bookmark.new(params[:bookmark])\n if params[:tag]\n @tags = params[:tag]\n @tags.each do |tag|\n objTag = Tag.find(tag)\n @bookmark.tags << objTag\n end\n end\n if @bookmark.url.include?(\"http://\")\n else\n @bookmark.url = \"http://\" + @bookmark.url\n end\n \n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to \"/login\"\n end\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @title = PageTitleGetter.new(params[:bookmark][:url]).title\n @bookmark.name = @title\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to topic_bookmarks_path, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @bookmark }\n else\n format.html { render :new }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def _add\n # Load a new bookmark object\n bookmark = Taupe::Model::Bookmark.load\n\n # Modify properties\n bookmark.url = @options[:url]\n bookmark.name = @options[:name]\n\n # Save in database and cache\n bookmark.save\n\n # Tags?\n unless @options[:tags].empty?\n @options[:tags].each do |tag_name|\n tag = Taupe::Model::Tag.fetch \"SELECT * FROM tag WHERE name = '#{tag_name}'\", true\n if tag.nil? || tag.empty?\n tag = Taupe::Model::Tag.load\n tag.name = tag_name\n tag.save\n end\n\n query = \"INSERT INTO bookmark_tag (bookmark_id, tag_id) VALUES (#{bookmark.bookmark_id}, #{tag.tag_id})\"\n Taupe::Model::Tag.exec query\n end\n end\n\n puts 'Bookmark added successfully'\n end", "def create\n incomplete = true\n error = false\n if ((params[:url] != nil) &&( (params[:description] != nil ) || (params[:bookmark][\"title\"] != nil )))\n incomplete = false\n url = nil\n if params[:url][:url]\n url = params[:url][:url]\n else\n url = params[:url]\n end\n if not ((url =~ /^http:\\/\\//) || (url =~ /^https:\\/\\//))\n url = \"http://\" + url\n end\n link = Link.find_by_url(url) || Link.new(:url => url)\n link.save\n if link.users.include?(current_user)\n flash[:message] = \"Already in\"\n else\n datetime = nil\n datetime = params[:dt] if params[:dt]\n description = params['description'] || params[:bookmark]['title']\n\n new_bookmark = Bookmark.new(:title => description, :link_id => link.id, :user_id => current_user.id, :bookmarked_at => (datetime || Time.now))\n new_bookmark.private = 1 if ((params[:shared] && (params[:shared] == \"no\")))\n new_bookmark.private = params[:bookmark][\"private\"] if params[:bookmark][\"private\"]\n new_bookmark.tag_list = params['tags'] || params[:bookmark]['tags']\n current_user.bookmarks_update_at = Time.now\n if new_bookmark.save\n current_user.save\n logger.info(\"bookmark for #{url} added\")\n else\n error = true\n logger.warn(\"Error : could not save the new bookmark\")\n end\n end\n end\n respond_to do |format|\n format.xml do\n if incomplete || error\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"something went wrong\\\" />\"\n else\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"done\\\" />\"\n end\n end\n end\n end", "def bookmark_link(options,no_text=false)\n case options[:site]\n when :delicious\n href = \"http://del.icio.us/post?url=#{options[:page_url]}&title=#{URI.encode(options[:page_title])}\"\n when :google\n href = \"http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=#{options[:page_url]}&title=#{URI.encode(options[:page_title])}\"\n when :reddit\n href = \"http://reddit.com/submit?url=#{options[:page_url]}&title=#{URI.encode(options[:page_title])}\"\n when :digg\n href = \"http://digg.com/submit?phase=2&url=#{options[:page_url]}&title=#{URI.encode(options[:page_title])}\"\n when :yahoo\n href = \"http://myweb2.search.yahoo.com/myresults/bookmarklet?u=#{options[:page_url]}&t=#{URI.encode(options[:page_title])}\"\n when :stumbleupon\n href= \"http://www.stumbleupon.com/refer.php?url=#{options[:page_url]}&title=#{URI.encode(options[:page_title])}\"\n end\n script = \"window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;\"\n # script = \"link_open_window(this.href)\"\n link_text = \"<span class='bookmark_link_text'>#{image_tag((options[:site].to_s + \".png\"), :alt => options[:link_title])}&nbsp;#{options[:site].to_s.capitalize unless no_text}</span>\"\n link_to(link_text, href, {:onclick => script, :title => options[:link_title], :class => \"site_bookmark_link\"})\n end", "def bookmark!(article)\n user_articles.create!( :article_id => article.id )\n end", "def export_link(builder, link)\n folders = []\n folders << link.folder.name if link.folder\n folders = folders + link.keywords if link.keywords.present?\n builder.bookmarks << Markio::Bookmark.create({\n title: link.name,\n href: link.url,\n folders: folders.present? ? folders : nil,\n add_date: link.saved_at\n })\n end", "def set_bookmark(bm_name, value)\n raise_if_no_document\n bm_range = set_at_bookmark(bm_name, value)\n @doc.Bookmarks.Add bm_name, bm_range\n end", "def open_bookmark(name, bookmark, &block)\n create_tab(name, bookmark, &block)\n end", "def test_add_bookmark\n test_url = 'http://www.gridgain.com/'\n num_lns0 = count_links\n num_bms0 = count_bookmarks\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_bms0 + 1, count_bookmarks)\n assert_equal(num_lns0, count_links)\n assert(get_link_title(test_url), exp_bm.name)\n delete_bookmark(@bs.user_id, test_url)\n end", "def add(opts={})\r\n Rakuten::Request.get(\"https://app.rakuten.co.jp/services/api/FavoriteBookmark/Add/20120627\", Rakuten::Api.merge(opts))\r\n end", "def create\n bookmark = Bookmark.find_or_create_by_URL(params[:bookmark][:URL])\n\n @user_bookmark = UserBookmark.new(:bookmark_id => bookmark.id, :user_id => current_user.id)\n\n respond_to do |format|\n if @user_bookmark.save\n format.html { redirect_to(bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @user_bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if Bookmark.create(user_id: session_user, receipe_id: receipe.id)\n redirect_to receipe\n else\n \n end\n\n end", "def create\n @bookmark = Bookmark.create(bookmark_params)\n end", "def create_bookmark\n clear_last_line\n print 'Enter A-Z, a-z or 0-9 to create a bookmark: '\n # print \"\\e[?25h\" # unhide cursor\n key = get_char\n # print \"\\e[?25l\" # hide cursor\n if /^[0-9A-Za-z]$/.match?(key)\n set_bookmark key\n @modified = true\n message \"Created bookmark #{key} for #{File.basename(Dir.pwd)}.\"\n else\n perror 'Bookmark must be alpha character or number.'\n end\nend", "def bookmark\n\t\tanswer = $screen.ask(\"bookmark:\",@bookmarks_hist)\n\t\tif answer == nil\n\t\t\t$screen.write_message(\"Cancelled\");\n\t\telse\n\t\t\t$screen.write_message(\"Bookmarked\");\n\t\t\t@bookmarks[answer] = [@row,@col]\n\t\tend\n\tend", "def savebookmark\n\t\t\t\turl_str = save_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => save_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t render :status => 404\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\t \n\t\t\t @bookmark = Bookmark.new({:title => save_bookmark_params[:title], :description => save_bookmark_params[:description], :url => url, :user_id => doorkeeper_token.resource_owner_id})\t\t\t \n\n\t\t\t tags = save_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\t\t\t \n\t\t\t \n\t\t\t if @bookmark.save\n\t\t\t \trespond_to do |format|\n \t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t\t \n\t\t\t else\n\t\t\t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\t end\t\t\t \n\t\t\tend", "def create\n #@bookmark = Bookmark.new(params[:bookmark])\n #\n #respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n # format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n # else\n # format.html { render :action => \"new\" }\n # format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n # end\n #end\n\n #@bookmark = current_user.bookmarks.build(params[:bookmark])\n \n @user = @current_user\n @bookmark = @current_user.bookmarks.build(params[:bookmark])\n @user.bookmarks << @bookmark\n \n #@bookmarkuser = @current_user.bookmarkusers.build(params[:bookmark])\n #\n \n \n \n #@bookmarkuser.save\n \n if @bookmark.save\n flash[:success] = \"Bookmark created!\"\n redirect_to root_path, :flash => { :success => \"Bookmark created!\" }\n else\n render 'pages/home'\n end\n\n end", "def test_add_pvt_bookmark\n test_url = 'http://www.avilayparekh.com/'\n num_lns0 = count_links\n num_bms0 = count_bookmarks\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_lns0 + 1, count_links)\n assert_equal(num_bms0 + 1, count_bookmarks)\n assert_empty(get_link_title(test_url))\n assert_empty(exp_bm.name)\n delete_link(test_url)\n end", "def open_bookmark(bm)\n id = bm.shift\n url = Bookmarks.new.bookmark_url(id)\n pexit \"Failure:\".red + \" bookmark #{id} not found\", 1 if url.nil?\n puts 'opening bookmark ' + url + '...'\n openweb(wrap(url))\n open_bookmark bm unless bm.empty?\n end", "def saveurl\n url_str = link_params[:url]\n url_str.insert(0, 'http://') if url_str.match('^http').nil?\n \n annotations = get_annotations(url_str)\n \n url = Url.find_by_url(url_str)\n if url.nil?\n url = Url.new({:url => link_params[:url], :icon => annotations[:icon]})\n if !url.save\n render :status => 404\n end\n else\n Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n end\n\n @bookmark = Bookmark.new({:url => url, :title => annotations[:title], :description => annotations[:desc], :user => current_user})\n\n @share_with_group = Group.find(params[:id]) if params[:id]\n\n annotations[:keywords].each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end\n\n respond_to do |format|\n format.html { render action: 'bookmark_form' }\n format.js\n end\n end", "def savebookmark\n @bookmark_plugins = PLUGIN_CONFIG['bookmark']\n url = Url.find_by_url(timeline_bookmark_params[:url])\n if url.nil?\n url = Url.new({:url => timeline_bookmark_params[:url]})\n if !url.save\n format.html { redirect_to 'new', notice: 'Trouble saving the url.' }\n end\n end\n if params[:id].nil?\n @bookmark = Bookmark.new({:title => timeline_bookmark_params[:title], :description => timeline_bookmark_params[:description], :url => url, :user => current_user})\n else\n @bookmark = Bookmark.new({:title => timeline_bookmark_params[:title], :description => timeline_bookmark_params[:description], :url => url, :user => current_user, :group => Group.find(params[:id])})\n end\n\n tags = timeline_bookmark_params[:tags]\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end unless tags.nil?\n #@bookmark = Bookmark.new(bookmark_params) #TODO: Explore this.. Above is Ugly\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to timeline_path, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n #cross-site scripting fix\n headers['Access-Control-Allow-Origin'] = '*'\n headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-Prototype-Version'\n \n u = User.find(params[:id])\n b = Bookmark.where(url: params[:url], user_id: u).first\n c = Category.find(params[:category])\n \n #ensure user does not submit a link more than once\n if b == nil\n Bookmark.create(url: params[:url], title: params[:title], user: u, category: c); \n end\n\n render :nothing => true\n end", "def bookmark( *names, **options )\n\t\traise \"expected at least one bookmark name\" if names.empty?\n\n\t\tself.server.run( :bookmark, *names, **options )\n\t\treturn true\n\tend", "def newbookmark\n @bookmarklet = bookmarklet_params(params)\n @event = @calendar.events.build\n \n respond_to do |format|\n format.html # newbookmark.html.erb\n format.xml { render :xml => @event }\n end\n end", "def create\n @bookmark = @tag.bookmarks.new(bookmark_params)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to path_for_redirect, notice: \"Bookmark, #@bookmark created.\" }\n\n format.json { render json: @bookmark, status: :created }\n else\n format.html { render :new }\n\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_bookmark(username, password, uri, short_description)\n representation = form_encoded({ \"bookmark[uri]\" => uri,\n \"bookmark[short_description]\" => \n short_description })\n begin\n dest = \"#{@service_root}/users/#{URI.encode(username)}/bookmarks\"\n response = open(dest, :method => :post, :body => representation,\n :http_basic_authentication => [username, password])\n puts \"Bookmark posted to #{response.meta['location']}\"\n rescue OpenURI::HTTPError => e\n response_code = e.io.status[0].to_i\n if response_code == 401 # Unauthorized\n puts \"It looks like you gave me a bad password.\"\n elsif response_code == 409 # Conflict\n puts \"It looks like you already posted that bookmark.\"\n else\n raise e\n end\n end \n end", "def create\n @bookmarks = if params[:bookmarks]\n permit_bookmarks[:bookmarks]\n else\n [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]\n end\n\n current_or_guest_user.save! unless current_or_guest_user.persisted?\n\n bookmarks_to_add = @bookmarks.reject { |bookmark| current_or_guest_user.bookmarks.where(bookmark).exists? }\n success = ActiveRecord::Base.transaction do\n current_or_guest_user.bookmarks.create!(bookmarks_to_add)\n rescue ActiveRecord::RecordInvalid\n false\n end\n\n if request.xhr?\n success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) : render(json: current_or_guest_user.errors.full_messages, status: \"500\")\n else\n if @bookmarks.any? && success\n flash[:notice] = I18n.t('blacklight.bookmarks.add.success', count: @bookmarks.length)\n elsif @bookmarks.any?\n flash[:error] = I18n.t('blacklight.bookmarks.add.failure', count: @bookmarks.length)\n end\n\n redirect_back fallback_location: bookmarks_path\n end\n end", "def save_bookmark(data)\n t = open(File.expand_path(\"~/Dropbox/test.txt\"), \"a\")\n t.write(data)\n puts \"saved\"\n t.close\nend", "def create\n @bookmark = Bookmark.new(bookmark_params)\n \n respond_to do |format|\n if @bookmark.save\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @bookmark }\n else\n # format.html { render :new }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n tags = params[:bookmark][:tags].split(',').map do |tag|\n Tag.new(:name => tag.strip)\n end\n # use find_or_create\n @bookmark = Bookmark.find_or_create_by_user_id_and_url(:url => params[:bookmark][:url], :title => params[:bookmark][:title], :desc => params[:bookmark][:desc], :private => params[:bookmark][:private], :user_id => params[:bookmark][:user_id], :hashed_url => Digest::MD5.hexdigest(params[:bookmark][:url]) )\n \n respond_to do |format|\n if @bookmark.save\n # add bookmark id to each tag we created\n tags.each { |t| t.bookmark_id = @bookmark.id; t.save}\n if params[:bookmark][:is_popup]\n format.html { redirect_to(@bookmark, :notice => 'Close the Window!', :locals => {:close_window => 1}) }\n else \n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n end\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def updatebookmark\n @bookmark_plugins = PLUGIN_CONFIG['bookmark']\n url = Url.find_by_url(timeline_bookmark_params[:url])\n if url.nil?\n url = Url.new({:url => timeline_bookmark_params[:url]})\n if !url.save\n render :status => 404\n end\n end\n @bookmark = Bookmark.find_by_id(timeline_bookmark_params[:bookmark_id])\n if @bookmark.nil?\n render :status => 404\n end\n @bookmark.title = timeline_bookmark_params[:title]\n @bookmark.description = timeline_bookmark_params[:description]\n @bookmark.url = url\n @bookmark.user = current_user\n\n @bookmark.tags.clear\n\n tags = timeline_bookmark_params[:tags]\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end unless tags.nil?\n #@bookmark = Bookmark.new(bookmark_params) #TODO: Explore this.. Above is Ugly\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bookmarklet = Bookmarklet.new(params[:bookmarklet])\n @bookmarklet.author = current_user\n\n respond_to do |format|\n if @bookmarklet.save\n flash[:notice] = 'Bookmarklet was successfully created.'\n format.html { redirect_to(@bookmarklet) }\n format.xml { render :xml => @bookmarklet, :status => :created, :location => @bookmarklet }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmarklet.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_my_bookmark\n @my_bookmark = MyBookmark.find(params[:id])\n end", "def add(bookmark)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'bookmark', bookmark)\n\t\t\tclient.queue_service_action_call('bookmark', 'add', 'bool', kparams)\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn client.do_queue()\n\t\tend", "def bookmark_params\n params.require(:bookmark).permit(:title, :url, :desc, :group_id)\n end", "def create_bookmark\n ch = get_single \"Enter A to Z or 0-9 for bookmark: \"\n #ch = get_char\n if ch =~ /^[0-9A-Z]$/\n #$bookmarks[ch] = \"#{Dir.pwd}:#{$cursor}\"\n # \n # The significance of putting a : and not a / is that with a \n # : the dir will be opened with cursor on same object it was on, and not\n # go into the dir. e.g, If bookmark is created with cursor on a dir, we don't want\n # it to go into the dir.\n $bookmarks[ch] = \"#{Dir.pwd}:#{$view[$cursor]}\"\n $modified = true\n else\n perror \"Bookmark must be upper-case character or number.\"\n end\nend", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark_meta_data\n begin\n page = Pismo::Document.new(self.full_url)\n self.name = page.html_title\n self.favicon_url = page.favicon\n self.description = page.description\n rescue => e\n self.description = \"Error => #{e}\"\n ensure\n self.save\n end\n end", "def remember_bookmark(value)\n @ole.RememberBookmark = value\n nil\n end", "def create\n @bookmark = current_user.becomes(LearnUser).bookmarks.new(params[:bookmark])\n\n respond_to do |format|\n if @bookmark.save\n flash[:notice] = 'Bookmark was successfully created.'\n format.html { redirect_to(@bookmark) }\n format.js {redirect_from_facebox(session[:return_to]) }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else \n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity } \n format.js { }\n end\n end\n end", "def set_bookmark\n\t\t@bookmark = Bookmark.find(params[:id])\n\tend", "def bookmarklet\n # @bookmark = Bookmark.new(:tags => [Tag.new])\n @bookmark = Bookmark.where(:url => params[:address], :user_id => session[:user_id]).first_or_initialize(:tags => [Tag.new])\n respond_to do |format|\n format.html # bookmarklet.html.erb\n format.xml { render :xml => @bookmark }\n end\n end", "def updatebookmark\n\t\t\t\turl_str = update_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\t\t\n\n\t\t\t url = Url.find_by_url(update_bookmark_params[:url])\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => update_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\n\n\t\t\t @bookmark = Bookmark.find_by_id(update_bookmark_params[:bookmark_id])\n\t\t\t if @bookmark.nil?\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t @bookmark.title = update_bookmark_params[:title]\n\t\t\t @bookmark.description = update_bookmark_params[:description]\n\t\t\t @bookmark.url = url\n\t\t\t @bookmark.user_id = doorkeeper_token.resource_owner_id\n\n\t\t\t @bookmark.tags.clear\n\n\t\t\t tags = update_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\n\n\t\t\t \n\t\t \tif @bookmark.save\n\t\t \trespond_to do |format|\n\t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t \n\t\t \telse\t\t\t \n\t\t \t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t \tend\n\t\t\tend", "def bookmark_params\n params.require(:bookmark).permit(:title, :url)\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url)\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :description, :user, :url, :tags, :favourite)\n end", "def bookmark ( name, options = {}, html_options = {} )\n service = SERVICES[name]\n return unless service # igore if not in list\n \n image = @image_prefix.to_s + \"#{options.delete(:image) || \"#{name}.gif\"}\"\n @bookmarks << @template.link_to( @template.image_tag(image, :alt => service.first), parse_url(service.last), html_options)\n end", "def create\n\t\tbookmark_params = {\n\t\t\t:owner => Prover.find(params[:owner]),\n\t\t\t:post => Post.find(params[:post])\n\t\t}\n\n\t\t@bookmark = Bookmark.new(bookmark_params)\n\n\t\trespond_to do |format|\n\t\t\tif @bookmark.save\n\t\t\t\tformat.html { render :json => @bookmark }\n\t\t\t\tformat.json { render :show, status: :created, location: @bookmark }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def bookmark_params\n params.require(:bookmark).permit(:name, :url, :tag_id, :category_id)\n end", "def create\n @bookmark = current_user.bookmarks.new(params[:bookmark])\n\n respond_to do |format|\n if @bookmark.save\n flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.bookmark'))\n @bookmark.create_tag_index\n @bookmark.manifestation.index!\n if params[:mode] == 'tag_edit'\n format.html { redirect_to(@bookmark.manifestation) }\n format.json { render :json => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { redirect_to(@bookmark) }\n format.json { render :json => @bookmark, :status => :created, :location => @bookmark }\n end\n else\n @user = current_user\n format.html { render :action => \"new\" }\n format.json { render :json => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n\n session[:params][:bookmark] = nil if session[:params]\n end", "def build_bookmark(attributes = {}, &block)\n node = Nokogiri::XML::Node.new('bookmark', document)\n assign_to node, attributes\n\n add_child node\n end", "def new\n @bookmark = Bookmark.new\n end", "def new\n @bookmark = Bookmark.new\n end", "def new\n @bookmark = Bookmark.new\n end", "def new\n @bookmark = Bookmark.new\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render :index, status: :created, location: @bookmark }\n else\n format.html { render :index }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def archive_bookmark(bookmark_id)\n perform_post_with_object('/api/1.1/bookmarks/archive', {bookmark_id: bookmark_id}, Instapaper::Bookmark)\n end", "def bookmark_params\n params.require(:bookmark).permit(:url, :title, :notes, :tag_list)\n end", "def create\n @bookmark = Bookmark.new(params[:bookmark])\n @bookmark.publisher = current_account\n @bookmark.should_tweet = params[:twitter]\n \n respond_to do |format|\n if @bookmark.save\n flash[:notice] = 'Bookmark was successfully created.'\n format.html { redirect_to(@bookmark) }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.permit(:bookmark, :post_id)\n end", "def bookmark_params\n params.require(:bookmark).permit([:title, :url, :category, :is_favorite, :comment])\n end", "def bookmark_params\n params.require(:bookmark).permit(:name, :url, :topic_id)\n end", "def bookmark_params\n params.require(:bookmark).permit([:title, :url, :category, :comment, :is_favorite])\n end", "def remember_bookmark\n @ole.RememberBookmark\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.save\n @bookmarks = Bookmark.all\n\n # respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n # format.json { render :show, status: :created, location: @bookmark }\n # else\n # format.html { render :new }\n # format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.user_id = current_user.id\n\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @redirect, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: bookmarks_path }\n else\n format.html { redirect_to @redirect, alert: \"Bookmark could not be saved\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_bookmark\n @user = User.find(session[:usr])\n @receipe = Receipe.find(params[:receipe_id])\n\n end", "def bookmark_params\n params.require(:bookmark).permit(:user_id, :receipe_id)\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url, category_id: [], kind_id: [])\n end", "def create\n @bookmark = Bookmark.new(bookmark_param)\n review = Review.find_by(id: params[:bookmark][:review_id])\n if @bookmark.save\n redirect_to :back\n else\n render 'new'\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:url, :title, :tag_list)\n end", "def submit(title: '', url: '', shortening: '')\n fill_in 'bookmark_title', with: title\n fill_in 'bookmark_url', with: url\n fill_in 'bookmark_shortening', with: shortening\n\n click_button 'Update Bookmark'\n end", "def set_bookmark\n @bookmark = current_user.bookmarks.find(params[:id])\n end", "def bookmark_params\n params.permit(:user_id, :raffle_id)\n end", "def test_add_invalid_bookmark\n num_lns0 = count_links\n act_bm = @bs.add_or_get_bookmark('ha ha ha')\n assert(act_bm.errors.count > 0)\n assert_equal(num_lns0, count_links)\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url, :tag_list)\n end", "def initialize(bookmark)\n self.url = bookmark.url\n self.title = bookmark.title\n self.description = bookmark.preview_text\n self.date_added = bookmark.date_added\n self.tags = []\n self\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n\n if @bookmark.save\n render json: { bookmark: @bookmark }, status: :created\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:url, :title, :private, :desc, :is_archived, :tag_list)\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :description, :url_attributes => :url)\n end" ]
[ "0.78617215", "0.73552716", "0.71774745", "0.71621644", "0.7050708", "0.69208086", "0.69071114", "0.69058055", "0.6878341", "0.6870793", "0.67546004", "0.6648521", "0.6635095", "0.66106963", "0.6594734", "0.659241", "0.65716654", "0.65650654", "0.6560024", "0.6520975", "0.647768", "0.6473758", "0.64609784", "0.6456041", "0.6453594", "0.6444505", "0.6326679", "0.63120013", "0.62609065", "0.6250419", "0.6249752", "0.6241554", "0.6234617", "0.6228471", "0.6216664", "0.62136805", "0.6208456", "0.6202906", "0.6202399", "0.61954355", "0.6183553", "0.6182918", "0.61525327", "0.6137202", "0.61363965", "0.61363965", "0.61363965", "0.61363965", "0.61363965", "0.61363965", "0.61363965", "0.6135785", "0.6129316", "0.6126667", "0.6124167", "0.61157393", "0.6113415", "0.6098545", "0.6098545", "0.60802066", "0.60749376", "0.6060606", "0.60587615", "0.60477114", "0.6042371", "0.6030672", "0.6030672", "0.6030672", "0.6030672", "0.6026266", "0.6026266", "0.6026266", "0.6026266", "0.6026266", "0.6026266", "0.60188997", "0.6012775", "0.6009588", "0.59866154", "0.59852755", "0.59799397", "0.59727347", "0.59626293", "0.5951913", "0.59403867", "0.5933351", "0.5932545", "0.5931419", "0.5928791", "0.5913779", "0.59086055", "0.5908561", "0.59006214", "0.58978504", "0.58900154", "0.58896655", "0.5886754", "0.588569", "0.5859343", "0.585036" ]
0.68595207
10
Add a new bookmark that is not a valid URI No new bookmarks or links should be created
def test_add_invalid_bookmark num_lns0 = count_links act_bm = @bs.add_or_get_bookmark('ha ha ha') assert(act_bm.errors.count > 0) assert_equal(num_lns0, count_links) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bookmark(url, name = \"\")\n Item.create(:bookmark, {:name => name, :redirect_url => url})\n end", "def add_bookmark(url, options = {})\n perform_post_with_object('/api/1.1/bookmarks/add', options.merge(url: url), Instapaper::Bookmark)\n end", "def bookmarklet\n url_str = params[:url]\n url_str.insert(0, 'http://') if url_str.match('^http').nil?\n \n url = Url.find_by_url(url_str)\n if url.nil?\n url = Url.new({:url => params[:url], :icon => nil})\n if !url.save\n render :status => 404\n end\n end\n\n @bookmark = Bookmark.new({:url => url, :title => params[:title], :description => params[:description], :user => current_user})\n \n params[:tags].split(',').each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end \n \n end", "def _add\n # Load a new bookmark object\n bookmark = Taupe::Model::Bookmark.load\n\n # Modify properties\n bookmark.url = @options[:url]\n bookmark.name = @options[:name]\n\n # Save in database and cache\n bookmark.save\n\n # Tags?\n unless @options[:tags].empty?\n @options[:tags].each do |tag_name|\n tag = Taupe::Model::Tag.fetch \"SELECT * FROM tag WHERE name = '#{tag_name}'\", true\n if tag.nil? || tag.empty?\n tag = Taupe::Model::Tag.load\n tag.name = tag_name\n tag.save\n end\n\n query = \"INSERT INTO bookmark_tag (bookmark_id, tag_id) VALUES (#{bookmark.bookmark_id}, #{tag.tag_id})\"\n Taupe::Model::Tag.exec query\n end\n end\n\n puts 'Bookmark added successfully'\n end", "def new_bookmark(username, password, uri, short_description)\n representation = form_encoded({ \"bookmark[uri]\" => uri,\n \"bookmark[short_description]\" => \n short_description })\n begin\n dest = \"#{@service_root}/users/#{URI.encode(username)}/bookmarks\"\n response = open(dest, :method => :post, :body => representation,\n :http_basic_authentication => [username, password])\n puts \"Bookmark posted to #{response.meta['location']}\"\n rescue OpenURI::HTTPError => e\n response_code = e.io.status[0].to_i\n if response_code == 401 # Unauthorized\n puts \"It looks like you gave me a bad password.\"\n elsif response_code == 409 # Conflict\n puts \"It looks like you already posted that bookmark.\"\n else\n raise e\n end\n end \n end", "def create\n incomplete = true\n error = false\n if ((params[:url] != nil) &&( (params[:description] != nil ) || (params[:bookmark][\"title\"] != nil )))\n incomplete = false\n url = nil\n if params[:url][:url]\n url = params[:url][:url]\n else\n url = params[:url]\n end\n if not ((url =~ /^http:\\/\\//) || (url =~ /^https:\\/\\//))\n url = \"http://\" + url\n end\n link = Link.find_by_url(url) || Link.new(:url => url)\n link.save\n if link.users.include?(current_user)\n flash[:message] = \"Already in\"\n else\n datetime = nil\n datetime = params[:dt] if params[:dt]\n description = params['description'] || params[:bookmark]['title']\n\n new_bookmark = Bookmark.new(:title => description, :link_id => link.id, :user_id => current_user.id, :bookmarked_at => (datetime || Time.now))\n new_bookmark.private = 1 if ((params[:shared] && (params[:shared] == \"no\")))\n new_bookmark.private = params[:bookmark][\"private\"] if params[:bookmark][\"private\"]\n new_bookmark.tag_list = params['tags'] || params[:bookmark]['tags']\n current_user.bookmarks_update_at = Time.now\n if new_bookmark.save\n current_user.save\n logger.info(\"bookmark for #{url} added\")\n else\n error = true\n logger.warn(\"Error : could not save the new bookmark\")\n end\n end\n end\n respond_to do |format|\n format.xml do\n if incomplete || error\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"something went wrong\\\" />\"\n else\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"done\\\" />\"\n end\n end\n end\n end", "def savebookmark\n\t\t\t\turl_str = save_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => save_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t render :status => 404\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\t \n\t\t\t @bookmark = Bookmark.new({:title => save_bookmark_params[:title], :description => save_bookmark_params[:description], :url => url, :user_id => doorkeeper_token.resource_owner_id})\t\t\t \n\n\t\t\t tags = save_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\t\t\t \n\t\t\t \n\t\t\t if @bookmark.save\n\t\t\t \trespond_to do |format|\n \t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t\t \n\t\t\t else\n\t\t\t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\t end\t\t\t \n\t\t\tend", "def saveurl\n url_str = link_params[:url]\n url_str.insert(0, 'http://') if url_str.match('^http').nil?\n \n annotations = get_annotations(url_str)\n \n url = Url.find_by_url(url_str)\n if url.nil?\n url = Url.new({:url => link_params[:url], :icon => annotations[:icon]})\n if !url.save\n render :status => 404\n end\n else\n Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n end\n\n @bookmark = Bookmark.new({:url => url, :title => annotations[:title], :description => annotations[:desc], :user => current_user})\n\n @share_with_group = Group.find(params[:id]) if params[:id]\n\n annotations[:keywords].each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end\n\n respond_to do |format|\n format.html { render action: 'bookmark_form' }\n format.js\n end\n end", "def add(opts={})\r\n Rakuten::Request.get(\"https://app.rakuten.co.jp/services/api/FavoriteBookmark/Add/20120627\", Rakuten::Api.merge(opts))\r\n end", "def create\n bookmark = Bookmark.find_or_create_by_URL(params[:bookmark][:URL])\n\n @user_bookmark = UserBookmark.new(:bookmark_id => bookmark.id, :user_id => current_user.id)\n\n respond_to do |format|\n if @user_bookmark.save\n format.html { redirect_to(bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @user_bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def bookmarklet\n unless session[:user_id] \n flash[:info] = \"Please Sign In.\"\n session[:return_to] = request.fullpath\n redirect_to login_url\n end\n @bookmark = Bookmark.find_or_create_by(:url => params[:address], :user_id => session[:user_id])\n end", "def bookmark!(article)\n user_articles.create!( :article_id => article.id )\n end", "def create\n if session[:user_id]\n user = User.find(session[:user_id])\n params[:bookmark][:user] = user\n @bookmark = Bookmark.new(params[:bookmark])\n if params[:tag]\n @tags = params[:tag]\n @tags.each do |tag|\n objTag = Tag.find(tag)\n @bookmark.tags << objTag\n end\n end\n if @bookmark.url.include?(\"http://\")\n else\n @bookmark.url = \"http://\" + @bookmark.url\n end\n \n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to \"/login\"\n end\n end", "def updatebookmark\n\t\t\t\turl_str = update_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\t\t\n\n\t\t\t url = Url.find_by_url(update_bookmark_params[:url])\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => update_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\n\n\t\t\t @bookmark = Bookmark.find_by_id(update_bookmark_params[:bookmark_id])\n\t\t\t if @bookmark.nil?\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t @bookmark.title = update_bookmark_params[:title]\n\t\t\t @bookmark.description = update_bookmark_params[:description]\n\t\t\t @bookmark.url = url\n\t\t\t @bookmark.user_id = doorkeeper_token.resource_owner_id\n\n\t\t\t @bookmark.tags.clear\n\n\t\t\t tags = update_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\n\n\t\t\t \n\t\t \tif @bookmark.save\n\t\t \trespond_to do |format|\n\t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t \n\t\t \telse\t\t\t \n\t\t \t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t \tend\n\t\t\tend", "def test_add_new_bookmark\n test_url = 'http://gigaom.com'\n title = 'GigaOM'\n num_lns0 = count_links\n tot_bms0 = count_bookmarks\n num_bms0 = count_bookmarks(@bs.user_id)\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_lns0 + 1, count_links)\n assert_equal(tot_bms0 + 1, count_bookmarks)\n assert_equal(num_bms0 + 1, count_bookmarks(@bs.user_id))\n assert_equal(get_link_title(test_url), exp_bm.name)\n delete_link(test_url)\n end", "def set_bookmark(bm_name, value)\n raise_if_no_document\n bm_range = set_at_bookmark(bm_name, value)\n @doc.Bookmarks.Add bm_name, bm_range\n end", "def savebookmark\n @bookmark_plugins = PLUGIN_CONFIG['bookmark']\n url = Url.find_by_url(timeline_bookmark_params[:url])\n if url.nil?\n url = Url.new({:url => timeline_bookmark_params[:url]})\n if !url.save\n format.html { redirect_to 'new', notice: 'Trouble saving the url.' }\n end\n end\n if params[:id].nil?\n @bookmark = Bookmark.new({:title => timeline_bookmark_params[:title], :description => timeline_bookmark_params[:description], :url => url, :user => current_user})\n else\n @bookmark = Bookmark.new({:title => timeline_bookmark_params[:title], :description => timeline_bookmark_params[:description], :url => url, :user => current_user, :group => Group.find(params[:id])})\n end\n\n tags = timeline_bookmark_params[:tags]\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end unless tags.nil?\n #@bookmark = Bookmark.new(bookmark_params) #TODO: Explore this.. Above is Ugly\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to timeline_path, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def updatebookmark\n @bookmark_plugins = PLUGIN_CONFIG['bookmark']\n url = Url.find_by_url(timeline_bookmark_params[:url])\n if url.nil?\n url = Url.new({:url => timeline_bookmark_params[:url]})\n if !url.save\n render :status => 404\n end\n end\n @bookmark = Bookmark.find_by_id(timeline_bookmark_params[:bookmark_id])\n if @bookmark.nil?\n render :status => 404\n end\n @bookmark.title = timeline_bookmark_params[:title]\n @bookmark.description = timeline_bookmark_params[:description]\n @bookmark.url = url\n @bookmark.user = current_user\n\n @bookmark.tags.clear\n\n tags = timeline_bookmark_params[:tags]\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end unless tags.nil?\n #@bookmark = Bookmark.new(bookmark_params) #TODO: Explore this.. Above is Ugly\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_add_bookmark\n test_url = 'http://www.gridgain.com/'\n num_lns0 = count_links\n num_bms0 = count_bookmarks\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_bms0 + 1, count_bookmarks)\n assert_equal(num_lns0, count_links)\n assert(get_link_title(test_url), exp_bm.name)\n delete_bookmark(@bs.user_id, test_url)\n end", "def bookmark(title = \"My Default Sitewide Bookmark Title\", url=\"#{request.request_uri}\")\n url = 'http://' + request.host_with_port + url\n\n \"javascript:bookmarksite('#{title}=>#{request.request_uri}', '#{url}');\"\n end", "def add(bookmark)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'bookmark', bookmark)\n\t\t\tclient.queue_service_action_call('bookmark', 'add', 'bool', kparams)\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn client.do_queue()\n\t\tend", "def add_bookmark_to_shoes_topic\n add_topic\n click_link 'Shoes'\n click_link 'New bookmark'\n within 'form' do\n fill_in( 'Url', with: 'http://eu.christianlouboutin.com/uk_en/shop/women/so-kate-patent.html' )\n fill_in('Title', with: 'Christian Louboutins')\n click_button 'Create Bookmark' \n end\n end", "def create\n \n #cross-site scripting fix\n headers['Access-Control-Allow-Origin'] = '*'\n headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-Prototype-Version'\n \n u = User.find(params[:id])\n b = Bookmark.where(url: params[:url], user_id: u).first\n c = Category.find(params[:category])\n \n #ensure user does not submit a link more than once\n if b == nil\n Bookmark.create(url: params[:url], title: params[:title], user: u, category: c); \n end\n\n render :nothing => true\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url)\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url)\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @title = PageTitleGetter.new(params[:bookmark][:url]).title\n @bookmark.name = @title\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to topic_bookmarks_path, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @bookmark }\n else\n format.html { render :new }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url, category_id: [], kind_id: [])\n end", "def parse_bookmark_from(b_node)\n Elements::Bookmark.new(b_node)\n end", "def parse_bookmark_from(b_node)\n Elements::Bookmark.new(b_node)\n end", "def newbookmark\n @bookmarklet = bookmarklet_params(params)\n @event = @calendar.events.build\n \n respond_to do |format|\n format.html # newbookmark.html.erb\n format.xml { render :xml => @event }\n end\n end", "def create\n @bookmark = Bookmark.create(bookmark_params)\n end", "def create\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if Bookmark.create(user_id: session_user, receipe_id: receipe.id)\n redirect_to receipe\n else\n \n end\n\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n \n respond_to do |format|\n if @bookmark.save\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @bookmark }\n else\n # format.html { render :new }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :description, :url_attributes => :url)\n end", "def open_bookmark(bm)\n id = bm.shift\n url = Bookmarks.new.bookmark_url(id)\n pexit \"Failure:\".red + \" bookmark #{id} not found\", 1 if url.nil?\n puts 'opening bookmark ' + url + '...'\n openweb(wrap(url))\n open_bookmark bm unless bm.empty?\n end", "def test_add_pvt_bookmark\n test_url = 'http://www.avilayparekh.com/'\n num_lns0 = count_links\n num_bms0 = count_bookmarks\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_lns0 + 1, count_links)\n assert_equal(num_bms0 + 1, count_bookmarks)\n assert_empty(get_link_title(test_url))\n assert_empty(exp_bm.name)\n delete_link(test_url)\n end", "def bookmark_params\n params.require(:bookmark).permit([:title, :url, :category, :is_favorite, :comment])\n end", "def create\n @bookmark = Bookmark.new(params[:bookmark])\n @bookmark.publisher = current_account\n @bookmark.should_tweet = params[:twitter]\n \n respond_to do |format|\n if @bookmark.save\n flash[:notice] = 'Bookmark was successfully created.'\n format.html { redirect_to(@bookmark) }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:name, :url, :topic_id)\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url, :desc, :group_id)\n end", "def create\n @bookmarklet = Bookmarklet.new(params[:bookmarklet])\n @bookmarklet.author = current_user\n\n respond_to do |format|\n if @bookmarklet.save\n flash[:notice] = 'Bookmarklet was successfully created.'\n format.html { redirect_to(@bookmarklet) }\n format.xml { render :xml => @bookmarklet, :status => :created, :location => @bookmarklet }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmarklet.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n tags = params[:bookmark][:tags].split(',').map do |tag|\n Tag.new(:name => tag.strip)\n end\n # use find_or_create\n @bookmark = Bookmark.find_or_create_by_user_id_and_url(:url => params[:bookmark][:url], :title => params[:bookmark][:title], :desc => params[:bookmark][:desc], :private => params[:bookmark][:private], :user_id => params[:bookmark][:user_id], :hashed_url => Digest::MD5.hexdigest(params[:bookmark][:url]) )\n \n respond_to do |format|\n if @bookmark.save\n # add bookmark id to each tag we created\n tags.each { |t| t.bookmark_id = @bookmark.id; t.save}\n if params[:bookmark][:is_popup]\n format.html { redirect_to(@bookmark, :notice => 'Close the Window!', :locals => {:close_window => 1}) }\n else \n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n end\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit([:title, :url, :category, :comment, :is_favorite])\n end", "def bookmark_params\n params.require(:bookmark).permit(:name, :url, :tag_id, :category_id)\n end", "def create\n @bookmark = @tag.bookmarks.new(bookmark_params)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to path_for_redirect, notice: \"Bookmark, #@bookmark created.\" }\n\n format.json { render json: @bookmark, status: :created }\n else\n format.html { render :new }\n\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:url, :title, :notes, :tag_list)\n end", "def bookmark_params\n params.require(:bookmark).permit(:user_id, :receipe_id)\n end", "def create\n @bookmarks = if params[:bookmarks]\n permit_bookmarks[:bookmarks]\n else\n [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]\n end\n\n current_or_guest_user.save! unless current_or_guest_user.persisted?\n\n bookmarks_to_add = @bookmarks.reject { |bookmark| current_or_guest_user.bookmarks.where(bookmark).exists? }\n success = ActiveRecord::Base.transaction do\n current_or_guest_user.bookmarks.create!(bookmarks_to_add)\n rescue ActiveRecord::RecordInvalid\n false\n end\n\n if request.xhr?\n success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) : render(json: current_or_guest_user.errors.full_messages, status: \"500\")\n else\n if @bookmarks.any? && success\n flash[:notice] = I18n.t('blacklight.bookmarks.add.success', count: @bookmarks.length)\n elsif @bookmarks.any?\n flash[:error] = I18n.t('blacklight.bookmarks.add.failure', count: @bookmarks.length)\n end\n\n redirect_back fallback_location: bookmarks_path\n end\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n\n tags = bookmark_params[:tags].split(\",\")\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.permit(:bookmark, :post_id)\n end", "def create\n #@bookmark = Bookmark.new(params[:bookmark])\n #\n #respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n # format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n # else\n # format.html { render :action => \"new\" }\n # format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n # end\n #end\n\n #@bookmark = current_user.bookmarks.build(params[:bookmark])\n \n @user = @current_user\n @bookmark = @current_user.bookmarks.build(params[:bookmark])\n @user.bookmarks << @bookmark\n \n #@bookmarkuser = @current_user.bookmarkusers.build(params[:bookmark])\n #\n \n \n \n #@bookmarkuser.save\n \n if @bookmark.save\n flash[:success] = \"Bookmark created!\"\n redirect_to root_path, :flash => { :success => \"Bookmark created!\" }\n else\n render 'pages/home'\n end\n\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :description, :user, :url, :tags, :favourite)\n end", "def bookmarklet\n text 'Drag the following link to your toolbar to submit with a single click: '\n a 'bookmark-it!', :href =>\"javascript:location.href='http:#{URL(New)}?page_link='+encodeURIComponent(location.href)+'&description='+encodeURIComponent(document.title)+'&body='+encodeURIComponent(window.getSelection())\"\n end", "def initialize(bookmark)\n self.url = bookmark.url\n self.title = bookmark.title\n self.description = bookmark.preview_text\n self.date_added = bookmark.date_added\n self.tags = []\n self\n end", "def create_bookmark\n clear_last_line\n print 'Enter A-Z, a-z or 0-9 to create a bookmark: '\n # print \"\\e[?25h\" # unhide cursor\n key = get_char\n # print \"\\e[?25l\" # hide cursor\n if /^[0-9A-Za-z]$/.match?(key)\n set_bookmark key\n @modified = true\n message \"Created bookmark #{key} for #{File.basename(Dir.pwd)}.\"\n else\n perror 'Bookmark must be alpha character or number.'\n end\nend", "def bookmark_params\n params.permit(:user_id, :raffle_id)\n end", "def create\n @solicitation_bookmark = SolicitationBookmark.new(solicitation_bookmark_params)\n\n respond_to do |format|\n if @solicitation_bookmark.save\n format.html { redirect_to @solicitation_bookmark, notice: 'Solicitation bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @solicitation_bookmark }\n else\n format.html { render :new }\n format.json { render json: @solicitation_bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:url, :title, :tag_list)\n end", "def bookmarklet\n # @bookmark = Bookmark.new(:tags => [Tag.new])\n @bookmark = Bookmark.where(:url => params[:address], :user_id => session[:user_id]).first_or_initialize(:tags => [Tag.new])\n respond_to do |format|\n format.html # bookmarklet.html.erb\n format.xml { render :xml => @bookmark }\n end\n end", "def new\n @bookmark = Bookmark.new\n end", "def new\n @bookmark = Bookmark.new\n end", "def new\n @bookmark = Bookmark.new\n end", "def new\n @bookmark = Bookmark.new\n end", "def bookmark_params\n params.require(:bookmark).permit(:url, :title, :private, :desc, :is_archived, :tag_list)\n end", "def create\n @bookmark = current_user.becomes(LearnUser).bookmarks.new(params[:bookmark])\n\n respond_to do |format|\n if @bookmark.save\n flash[:notice] = 'Bookmark was successfully created.'\n format.html { redirect_to(@bookmark) }\n format.js {redirect_from_facebox(session[:return_to]) }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else \n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity } \n format.js { }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url, :tag_list)\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.user_id = current_user.id\n\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @redirect, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: bookmarks_path }\n else\n format.html { redirect_to @redirect, alert: \"Bookmark could not be saved\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_url(url, shortcode)\n @db.execute \"INSERT INTO pairings VALUES('#{url}', '#{shortcode}')\"\n return true\n rescue SQLite3::Exception => e\n puts 'Unable to add url:'\n puts e\n return false\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n\n if @bookmark.save\n render json: { bookmark: @bookmark }, status: :created\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.owner = current_user\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark.poi }\n format.json { render :show, status: :created, location: @bookmark }\n else\n format.html { redirect_to root_path, alert: t('error', scope: @t_scope) }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark( *names, **options )\n\t\traise \"expected at least one bookmark name\" if names.empty?\n\n\t\tself.server.run( :bookmark, *names, **options )\n\t\treturn true\n\tend", "def bookmark\n\t\tanswer = $screen.ask(\"bookmark:\",@bookmarks_hist)\n\t\tif answer == nil\n\t\t\t$screen.write_message(\"Cancelled\");\n\t\telse\n\t\t\t$screen.write_message(\"Bookmarked\");\n\t\t\t@bookmarks[answer] = [@row,@col]\n\t\tend\n\tend", "def test_update_nonexisting_bookmark\n bm0 = Bookmark.new('id' => 1000, \n 'url' => '/some/url', \n 'title' => 'some title')\n new_bm = @bs.update_bookmark(bm0)\n assert(new_bm.errors.count > 0)\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render :index, status: :created, location: @bookmark }\n else\n format.html { render :index }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def save_bookmark(data)\n t = open(File.expand_path(\"~/Dropbox/test.txt\"), \"a\")\n t.write(data)\n puts \"saved\"\n t.close\nend", "def validate_anchor( uri, doc )\n return false if uri.fragment.nil?\n\n anchor = '#' + uri.fragment\n if doc.at(anchor).nil?\n @log.error \"invalid URI '#{uri.to_s}'\"\n false\n else true end\n end", "def export_link(builder, link)\n folders = []\n folders << link.folder.name if link.folder\n folders = folders + link.keywords if link.keywords.present?\n builder.bookmarks << Markio::Bookmark.create({\n title: link.name,\n href: link.url,\n folders: folders.present? ? folders : nil,\n add_date: link.saved_at\n })\n end", "def create\n @bookmark = Bookmark.new(params[:bookmark])\n @bookmarkable = @bookmark.bookmarkable \n if @bookmarkable.new_record? && @bookmarkable.fandoms.blank?\n @bookmark.errors.add(:base, \"Fandom tag is required\")\n render :new and return\n end\n if @bookmark.errors.empty?\n if @bookmarkable.save && @bookmark.save\n flash[:notice] = ts('Bookmark was successfully created.')\n redirect_to(@bookmark) and return\n end\n end\n @bookmarkable.errors.full_messages.each { |msg| @bookmark.errors.add(:base, msg) }\n render :action => \"new\" and return\n end", "def test_get_existing_bookmark\n test_url = 'http://www.ml-class.com/'\n num0 = count_bookmarks(@bs.user_id)\n tot0 = count_bookmarks\n assert(get_bookmark(@bs.user_id, test_url) === @bs.add_or_get_bookmark(test_url))\n assert_equal(num0, count_bookmarks(@bs.user_id))\n assert_equal(tot0, count_bookmarks)\n end", "def add(uri, text)\n # if redirect, add to index and keep going\n entry = @@entry.new(uri, @cur_block, @buflocation, text.size)\n\n # calculate the sha1 code, use the first four characters as the index\n entry.sha1, firstfour = sha1_w_sub(entry.uri, @idx_size)\n\n # add this entry to the index in the right place\n @index[firstfour] ||= []\n @index[firstfour] << entry\n\n # add to the buffer, and update the counter\n @buffer << text\n @buflocation += text.size\n\n flush_block if @buffer.size > @blocksize\n end", "def create\n @bookmark = Bookmark.new(bookmark_param)\n review = Review.find_by(id: params[:bookmark][:review_id])\n if @bookmark.save\n redirect_to :back\n else\n render 'new'\n end\n end", "def remember_bookmark(value)\n @ole.RememberBookmark = value\n nil\n end", "def save_bookmark_params\n\t\t\t params.permit(:url, :title, :description, :tags)\n\t\t\tend", "def bookmark_params\n params.require(:bookmark).permit([:url, :title, :comment, :category, :checkbox])\nend", "def build_bookmark(attributes = {}, &block)\n node = Nokogiri::XML::Node.new('bookmark', document)\n assign_to node, attributes\n\n add_child node\n end", "def bookmark_params\n params.require(:bookmarking).permit(:post_id)\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.save\n @bookmarks = Bookmark.all\n\n # respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n # format.json { render :show, status: :created, location: @bookmark }\n # else\n # format.html { render :new }\n # format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n @public_bookmark = PublicBookmark.new(public_bookmark_params)\n\n respond_to do |format|\n if @public_bookmark.save\n format.html { redirect_to @public_bookmark, notice: 'Public bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @public_bookmark }\n else\n format.html { render :new }\n format.json { render json: @public_bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_bookmark\n ch = get_single \"Enter A to Z or 0-9 for bookmark: \"\n #ch = get_char\n if ch =~ /^[0-9A-Z]$/\n #$bookmarks[ch] = \"#{Dir.pwd}:#{$cursor}\"\n # \n # The significance of putting a : and not a / is that with a \n # : the dir will be opened with cursor on same object it was on, and not\n # go into the dir. e.g, If bookmark is created with cursor on a dir, we don't want\n # it to go into the dir.\n $bookmarks[ch] = \"#{Dir.pwd}:#{$view[$cursor]}\"\n $modified = true\n else\n perror \"Bookmark must be upper-case character or number.\"\n end\nend", "def set_my_bookmark\n @my_bookmark = MyBookmark.find(params[:id])\n end", "def bookmark_param\n params.require(:bookmark).permit(:user_id, :review_id)\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n\t\t@bookmark = Bookmark.find(params[:id])\n\tend", "def create\n @bookmark = current_user.bookmarks.new(params[:bookmark])\n\n respond_to do |format|\n if @bookmark.save\n flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.bookmark'))\n @bookmark.create_tag_index\n @bookmark.manifestation.index!\n if params[:mode] == 'tag_edit'\n format.html { redirect_to(@bookmark.manifestation) }\n format.json { render :json => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { redirect_to(@bookmark) }\n format.json { render :json => @bookmark, :status => :created, :location => @bookmark }\n end\n else\n @user = current_user\n format.html { render :action => \"new\" }\n format.json { render :json => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n\n session[:params][:bookmark] = nil if session[:params]\n end" ]
[ "0.7100404", "0.68750364", "0.68282086", "0.65775937", "0.65098935", "0.6509209", "0.64910096", "0.6419508", "0.6368577", "0.6304404", "0.62898225", "0.6288837", "0.6288614", "0.6219053", "0.62123704", "0.61552143", "0.6128389", "0.60410184", "0.601832", "0.60015666", "0.59964985", "0.5957323", "0.5956453", "0.5935604", "0.5935604", "0.59260297", "0.59053636", "0.5871888", "0.5871888", "0.5846844", "0.58295965", "0.58220136", "0.57777125", "0.5770192", "0.5768706", "0.5753662", "0.57482666", "0.5745961", "0.5733422", "0.5727165", "0.5722906", "0.570969", "0.57069737", "0.5693826", "0.56926477", "0.56705004", "0.56689185", "0.5663929", "0.5656686", "0.5652435", "0.5650388", "0.5647471", "0.56432503", "0.5623821", "0.56081945", "0.5601439", "0.5594645", "0.5582964", "0.5569502", "0.55609304", "0.55609304", "0.55609304", "0.55609304", "0.5555461", "0.55404615", "0.5536023", "0.55335313", "0.55334467", "0.55334216", "0.552029", "0.5516885", "0.55167997", "0.55128235", "0.54942954", "0.54775083", "0.5476133", "0.5454676", "0.54444087", "0.54422826", "0.5432231", "0.5431304", "0.5423997", "0.54215664", "0.5415379", "0.54143476", "0.53993446", "0.53821456", "0.53787065", "0.5375746", "0.53746957", "0.53729373", "0.53686917", "0.53686917", "0.53686917", "0.53686917", "0.53686917", "0.53686917", "0.53686917", "0.53657216", "0.53541404" ]
0.65869874
3
Add a new bookmark that is a valid URI but is not reachable over the Internet A new link should be created along with a new bookmark Both the link title and the bookmark name should be an empty string
def test_add_pvt_bookmark test_url = 'http://www.avilayparekh.com/' num_lns0 = count_links num_bms0 = count_bookmarks act_bm = @bs.add_or_get_bookmark(test_url) exp_bm = get_bookmark(@bs.user_id, test_url) assert(exp_bm === act_bm) assert_equal(num_lns0 + 1, count_links) assert_equal(num_bms0 + 1, count_bookmarks) assert_empty(get_link_title(test_url)) assert_empty(exp_bm.name) delete_link(test_url) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bookmark(url, name = \"\")\n Item.create(:bookmark, {:name => name, :redirect_url => url})\n end", "def bookmarklet\n url_str = params[:url]\n url_str.insert(0, 'http://') if url_str.match('^http').nil?\n \n url = Url.find_by_url(url_str)\n if url.nil?\n url = Url.new({:url => params[:url], :icon => nil})\n if !url.save\n render :status => 404\n end\n end\n\n @bookmark = Bookmark.new({:url => url, :title => params[:title], :description => params[:description], :user => current_user})\n \n params[:tags].split(',').each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end \n \n end", "def add_bookmark(url, options = {})\n perform_post_with_object('/api/1.1/bookmarks/add', options.merge(url: url), Instapaper::Bookmark)\n end", "def bookmark(title = \"My Default Sitewide Bookmark Title\", url=\"#{request.request_uri}\")\n url = 'http://' + request.host_with_port + url\n\n \"javascript:bookmarksite('#{title}=>#{request.request_uri}', '#{url}');\"\n end", "def saveurl\n url_str = link_params[:url]\n url_str.insert(0, 'http://') if url_str.match('^http').nil?\n \n annotations = get_annotations(url_str)\n \n url = Url.find_by_url(url_str)\n if url.nil?\n url = Url.new({:url => link_params[:url], :icon => annotations[:icon]})\n if !url.save\n render :status => 404\n end\n else\n Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n end\n\n @bookmark = Bookmark.new({:url => url, :title => annotations[:title], :description => annotations[:desc], :user => current_user})\n\n @share_with_group = Group.find(params[:id]) if params[:id]\n\n annotations[:keywords].each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end\n\n respond_to do |format|\n format.html { render action: 'bookmark_form' }\n format.js\n end\n end", "def create\n incomplete = true\n error = false\n if ((params[:url] != nil) &&( (params[:description] != nil ) || (params[:bookmark][\"title\"] != nil )))\n incomplete = false\n url = nil\n if params[:url][:url]\n url = params[:url][:url]\n else\n url = params[:url]\n end\n if not ((url =~ /^http:\\/\\//) || (url =~ /^https:\\/\\//))\n url = \"http://\" + url\n end\n link = Link.find_by_url(url) || Link.new(:url => url)\n link.save\n if link.users.include?(current_user)\n flash[:message] = \"Already in\"\n else\n datetime = nil\n datetime = params[:dt] if params[:dt]\n description = params['description'] || params[:bookmark]['title']\n\n new_bookmark = Bookmark.new(:title => description, :link_id => link.id, :user_id => current_user.id, :bookmarked_at => (datetime || Time.now))\n new_bookmark.private = 1 if ((params[:shared] && (params[:shared] == \"no\")))\n new_bookmark.private = params[:bookmark][\"private\"] if params[:bookmark][\"private\"]\n new_bookmark.tag_list = params['tags'] || params[:bookmark]['tags']\n current_user.bookmarks_update_at = Time.now\n if new_bookmark.save\n current_user.save\n logger.info(\"bookmark for #{url} added\")\n else\n error = true\n logger.warn(\"Error : could not save the new bookmark\")\n end\n end\n end\n respond_to do |format|\n format.xml do\n if incomplete || error\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"something went wrong\\\" />\"\n else\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"done\\\" />\"\n end\n end\n end\n end", "def bookmarklet\n unless session[:user_id] \n flash[:info] = \"Please Sign In.\"\n session[:return_to] = request.fullpath\n redirect_to login_url\n end\n @bookmark = Bookmark.find_or_create_by(:url => params[:address], :user_id => session[:user_id])\n end", "def new_bookmark(username, password, uri, short_description)\n representation = form_encoded({ \"bookmark[uri]\" => uri,\n \"bookmark[short_description]\" => \n short_description })\n begin\n dest = \"#{@service_root}/users/#{URI.encode(username)}/bookmarks\"\n response = open(dest, :method => :post, :body => representation,\n :http_basic_authentication => [username, password])\n puts \"Bookmark posted to #{response.meta['location']}\"\n rescue OpenURI::HTTPError => e\n response_code = e.io.status[0].to_i\n if response_code == 401 # Unauthorized\n puts \"It looks like you gave me a bad password.\"\n elsif response_code == 409 # Conflict\n puts \"It looks like you already posted that bookmark.\"\n else\n raise e\n end\n end \n end", "def _add\n # Load a new bookmark object\n bookmark = Taupe::Model::Bookmark.load\n\n # Modify properties\n bookmark.url = @options[:url]\n bookmark.name = @options[:name]\n\n # Save in database and cache\n bookmark.save\n\n # Tags?\n unless @options[:tags].empty?\n @options[:tags].each do |tag_name|\n tag = Taupe::Model::Tag.fetch \"SELECT * FROM tag WHERE name = '#{tag_name}'\", true\n if tag.nil? || tag.empty?\n tag = Taupe::Model::Tag.load\n tag.name = tag_name\n tag.save\n end\n\n query = \"INSERT INTO bookmark_tag (bookmark_id, tag_id) VALUES (#{bookmark.bookmark_id}, #{tag.tag_id})\"\n Taupe::Model::Tag.exec query\n end\n end\n\n puts 'Bookmark added successfully'\n end", "def savebookmark\n\t\t\t\turl_str = save_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => save_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t render :status => 404\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\t \n\t\t\t @bookmark = Bookmark.new({:title => save_bookmark_params[:title], :description => save_bookmark_params[:description], :url => url, :user_id => doorkeeper_token.resource_owner_id})\t\t\t \n\n\t\t\t tags = save_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\t\t\t \n\t\t\t \n\t\t\t if @bookmark.save\n\t\t\t \trespond_to do |format|\n \t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t\t \n\t\t\t else\n\t\t\t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\t end\t\t\t \n\t\t\tend", "def create\n bookmark = Bookmark.find_or_create_by_URL(params[:bookmark][:URL])\n\n @user_bookmark = UserBookmark.new(:bookmark_id => bookmark.id, :user_id => current_user.id)\n\n respond_to do |format|\n if @user_bookmark.save\n format.html { redirect_to(bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @user_bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def bookmark_link(options,no_text=false)\n case options[:site]\n when :delicious\n href = \"http://del.icio.us/post?url=#{options[:page_url]}&title=#{URI.encode(options[:page_title])}\"\n when :google\n href = \"http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=#{options[:page_url]}&title=#{URI.encode(options[:page_title])}\"\n when :reddit\n href = \"http://reddit.com/submit?url=#{options[:page_url]}&title=#{URI.encode(options[:page_title])}\"\n when :digg\n href = \"http://digg.com/submit?phase=2&url=#{options[:page_url]}&title=#{URI.encode(options[:page_title])}\"\n when :yahoo\n href = \"http://myweb2.search.yahoo.com/myresults/bookmarklet?u=#{options[:page_url]}&t=#{URI.encode(options[:page_title])}\"\n when :stumbleupon\n href= \"http://www.stumbleupon.com/refer.php?url=#{options[:page_url]}&title=#{URI.encode(options[:page_title])}\"\n end\n script = \"window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;\"\n # script = \"link_open_window(this.href)\"\n link_text = \"<span class='bookmark_link_text'>#{image_tag((options[:site].to_s + \".png\"), :alt => options[:link_title])}&nbsp;#{options[:site].to_s.capitalize unless no_text}</span>\"\n link_to(link_text, href, {:onclick => script, :title => options[:link_title], :class => \"site_bookmark_link\"})\n end", "def add_bookmark_to_shoes_topic\n add_topic\n click_link 'Shoes'\n click_link 'New bookmark'\n within 'form' do\n fill_in( 'Url', with: 'http://eu.christianlouboutin.com/uk_en/shop/women/so-kate-patent.html' )\n fill_in('Title', with: 'Christian Louboutins')\n click_button 'Create Bookmark' \n end\n end", "def add(opts={})\r\n Rakuten::Request.get(\"https://app.rakuten.co.jp/services/api/FavoriteBookmark/Add/20120627\", Rakuten::Api.merge(opts))\r\n end", "def test_add_new_bookmark\n test_url = 'http://gigaom.com'\n title = 'GigaOM'\n num_lns0 = count_links\n tot_bms0 = count_bookmarks\n num_bms0 = count_bookmarks(@bs.user_id)\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_lns0 + 1, count_links)\n assert_equal(tot_bms0 + 1, count_bookmarks)\n assert_equal(num_bms0 + 1, count_bookmarks(@bs.user_id))\n assert_equal(get_link_title(test_url), exp_bm.name)\n delete_link(test_url)\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @title = PageTitleGetter.new(params[:bookmark][:url]).title\n @bookmark.name = @title\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to topic_bookmarks_path, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @bookmark }\n else\n format.html { render :new }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if session[:user_id]\n user = User.find(session[:user_id])\n params[:bookmark][:user] = user\n @bookmark = Bookmark.new(params[:bookmark])\n if params[:tag]\n @tags = params[:tag]\n @tags.each do |tag|\n objTag = Tag.find(tag)\n @bookmark.tags << objTag\n end\n end\n if @bookmark.url.include?(\"http://\")\n else\n @bookmark.url = \"http://\" + @bookmark.url\n end\n \n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to \"/login\"\n end\n end", "def test_add_invalid_bookmark\n num_lns0 = count_links\n act_bm = @bs.add_or_get_bookmark('ha ha ha')\n assert(act_bm.errors.count > 0)\n assert_equal(num_lns0, count_links)\n end", "def create\n \n #cross-site scripting fix\n headers['Access-Control-Allow-Origin'] = '*'\n headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-Prototype-Version'\n \n u = User.find(params[:id])\n b = Bookmark.where(url: params[:url], user_id: u).first\n c = Category.find(params[:category])\n \n #ensure user does not submit a link more than once\n if b == nil\n Bookmark.create(url: params[:url], title: params[:title], user: u, category: c); \n end\n\n render :nothing => true\n end", "def bookmarklet\n text 'Drag the following link to your toolbar to submit with a single click: '\n a 'bookmark-it!', :href =>\"javascript:location.href='http:#{URL(New)}?page_link='+encodeURIComponent(location.href)+'&description='+encodeURIComponent(document.title)+'&body='+encodeURIComponent(window.getSelection())\"\n end", "def test_add_bookmark\n test_url = 'http://www.gridgain.com/'\n num_lns0 = count_links\n num_bms0 = count_bookmarks\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_bms0 + 1, count_bookmarks)\n assert_equal(num_lns0, count_links)\n assert(get_link_title(test_url), exp_bm.name)\n delete_bookmark(@bs.user_id, test_url)\n end", "def bookmark!(article)\n user_articles.create!( :article_id => article.id )\n end", "def open_bookmark(bm)\n id = bm.shift\n url = Bookmarks.new.bookmark_url(id)\n pexit \"Failure:\".red + \" bookmark #{id} not found\", 1 if url.nil?\n puts 'opening bookmark ' + url + '...'\n openweb(wrap(url))\n open_bookmark bm unless bm.empty?\n end", "def updatebookmark\n\t\t\t\turl_str = update_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\t\t\n\n\t\t\t url = Url.find_by_url(update_bookmark_params[:url])\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => update_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\n\n\t\t\t @bookmark = Bookmark.find_by_id(update_bookmark_params[:bookmark_id])\n\t\t\t if @bookmark.nil?\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t @bookmark.title = update_bookmark_params[:title]\n\t\t\t @bookmark.description = update_bookmark_params[:description]\n\t\t\t @bookmark.url = url\n\t\t\t @bookmark.user_id = doorkeeper_token.resource_owner_id\n\n\t\t\t @bookmark.tags.clear\n\n\t\t\t tags = update_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\n\n\t\t\t \n\t\t \tif @bookmark.save\n\t\t \trespond_to do |format|\n\t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t \n\t\t \telse\t\t\t \n\t\t \t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t \tend\n\t\t\tend", "def savebookmark\n @bookmark_plugins = PLUGIN_CONFIG['bookmark']\n url = Url.find_by_url(timeline_bookmark_params[:url])\n if url.nil?\n url = Url.new({:url => timeline_bookmark_params[:url]})\n if !url.save\n format.html { redirect_to 'new', notice: 'Trouble saving the url.' }\n end\n end\n if params[:id].nil?\n @bookmark = Bookmark.new({:title => timeline_bookmark_params[:title], :description => timeline_bookmark_params[:description], :url => url, :user => current_user})\n else\n @bookmark = Bookmark.new({:title => timeline_bookmark_params[:title], :description => timeline_bookmark_params[:description], :url => url, :user => current_user, :group => Group.find(params[:id])})\n end\n\n tags = timeline_bookmark_params[:tags]\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end unless tags.nil?\n #@bookmark = Bookmark.new(bookmark_params) #TODO: Explore this.. Above is Ugly\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to timeline_path, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark( *names, **options )\n\t\traise \"expected at least one bookmark name\" if names.empty?\n\n\t\tself.server.run( :bookmark, *names, **options )\n\t\treturn true\n\tend", "def create_bookmark\n clear_last_line\n print 'Enter A-Z, a-z or 0-9 to create a bookmark: '\n # print \"\\e[?25h\" # unhide cursor\n key = get_char\n # print \"\\e[?25l\" # hide cursor\n if /^[0-9A-Za-z]$/.match?(key)\n set_bookmark key\n @modified = true\n message \"Created bookmark #{key} for #{File.basename(Dir.pwd)}.\"\n else\n perror 'Bookmark must be alpha character or number.'\n end\nend", "def set_bookmark(bm_name, value)\n raise_if_no_document\n bm_range = set_at_bookmark(bm_name, value)\n @doc.Bookmarks.Add bm_name, bm_range\n end", "def create\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if Bookmark.create(user_id: session_user, receipe_id: receipe.id)\n redirect_to receipe\n else\n \n end\n\n end", "def open_bookmark(name, bookmark, &block)\n create_tab(name, bookmark, &block)\n end", "def updatebookmark\n @bookmark_plugins = PLUGIN_CONFIG['bookmark']\n url = Url.find_by_url(timeline_bookmark_params[:url])\n if url.nil?\n url = Url.new({:url => timeline_bookmark_params[:url]})\n if !url.save\n render :status => 404\n end\n end\n @bookmark = Bookmark.find_by_id(timeline_bookmark_params[:bookmark_id])\n if @bookmark.nil?\n render :status => 404\n end\n @bookmark.title = timeline_bookmark_params[:title]\n @bookmark.description = timeline_bookmark_params[:description]\n @bookmark.url = url\n @bookmark.user = current_user\n\n @bookmark.tags.clear\n\n tags = timeline_bookmark_params[:tags]\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end unless tags.nil?\n #@bookmark = Bookmark.new(bookmark_params) #TODO: Explore this.. Above is Ugly\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n tags = params[:bookmark][:tags].split(',').map do |tag|\n Tag.new(:name => tag.strip)\n end\n # use find_or_create\n @bookmark = Bookmark.find_or_create_by_user_id_and_url(:url => params[:bookmark][:url], :title => params[:bookmark][:title], :desc => params[:bookmark][:desc], :private => params[:bookmark][:private], :user_id => params[:bookmark][:user_id], :hashed_url => Digest::MD5.hexdigest(params[:bookmark][:url]) )\n \n respond_to do |format|\n if @bookmark.save\n # add bookmark id to each tag we created\n tags.each { |t| t.bookmark_id = @bookmark.id; t.save}\n if params[:bookmark][:is_popup]\n format.html { redirect_to(@bookmark, :notice => 'Close the Window!', :locals => {:close_window => 1}) }\n else \n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n end\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def initialize(bookmark)\n self.url = bookmark.url\n self.title = bookmark.title\n self.description = bookmark.preview_text\n self.date_added = bookmark.date_added\n self.tags = []\n self\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n \n respond_to do |format|\n if @bookmark.save\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @bookmark }\n else\n # format.html { render :new }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def newbookmark\n @bookmarklet = bookmarklet_params(params)\n @event = @calendar.events.build\n \n respond_to do |format|\n format.html # newbookmark.html.erb\n format.xml { render :xml => @event }\n end\n end", "def create\n @bookmark = Bookmark.create(bookmark_params)\n end", "def export_link(builder, link)\n folders = []\n folders << link.folder.name if link.folder\n folders = folders + link.keywords if link.keywords.present?\n builder.bookmarks << Markio::Bookmark.create({\n title: link.name,\n href: link.url,\n folders: folders.present? ? folders : nil,\n add_date: link.saved_at\n })\n end", "def bookmarklet\n # @bookmark = Bookmark.new(:tags => [Tag.new])\n @bookmark = Bookmark.where(:url => params[:address], :user_id => session[:user_id]).first_or_initialize(:tags => [Tag.new])\n respond_to do |format|\n format.html # bookmarklet.html.erb\n format.xml { render :xml => @bookmark }\n end\n end", "def create\n @bookmarklet = Bookmarklet.new(params[:bookmarklet])\n @bookmarklet.author = current_user\n\n respond_to do |format|\n if @bookmarklet.save\n flash[:notice] = 'Bookmarklet was successfully created.'\n format.html { redirect_to(@bookmarklet) }\n format.xml { render :xml => @bookmarklet, :status => :created, :location => @bookmarklet }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmarklet.errors, :status => :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url)\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url)\n end", "def add(bookmark)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'bookmark', bookmark)\n\t\t\tclient.queue_service_action_call('bookmark', 'add', 'bool', kparams)\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn client.do_queue()\n\t\tend", "def bookmarklet(text)\n # We need to POST the current URL to / from javascript. The only way\n # that I know to do this is to use javascript to create a form on the\n # current page, and then submit that form to /.\n js_code = <<EOF\n var%20f = document.createElement('form');\n f.style.display = 'none';\n document.body.appendChild(f);\n f.method = 'POST';\n f.action = '#{root_url}/';\n var%20m = document.createElement('input');\n m.setAttribute('type', 'hidden');\n m.setAttribute('name', 'long_url');\n m.setAttribute('value', location.href);\n f.appendChild(m);\n f.submit();\nEOF\n\n # Remove all the whitespace from the javascript, so that it's a\n # bookmarkable URL.\n js_code.gsub!(/\\s+/, '')\n\n # Return the link.\n %(<a href=\"javascript:#{js_code}\">#{text}</a>)\n end", "def create\n @bookmark = Bookmark.new(params[:bookmark])\n @bookmark.publisher = current_account\n @bookmark.should_tweet = params[:twitter]\n \n respond_to do |format|\n if @bookmark.save\n flash[:notice] = 'Bookmark was successfully created.'\n format.html { redirect_to(@bookmark) }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @link = Link.new(params[:link])\n doc = Pismo::Document.new(@link.url) \n #grab metadata from doc\n if doc.title.nil?\n @link.name = doc.description\n else\n @link.name = doc.title\n end\n @link.favicon = doc.favicon\n\n #FOR OFFLINE USE\n #@link.name = \"Offline Description\"\n\n\n\n\n paginate_all_links\n respond_to do |format|\n if @link.save\n #if using bookmarklet foward back to link you came from\n if request.referer =~ /autosave/\n format.html { redirect_to @link.url }\n else\n #if using frontpage redirect to show all links \n format.html { redirect_to root_url+\"#show-links\", notice: 'Link was successfully created.' }\n end\n format.html { redirect_to @link.url, notice: 'Link was successfully created.' }\n format.json { render json: @link, status: :created, location: @link }\n else\n format.html { render action: \"new\" }\n format.json { render json: @link.errors, status: :unprocessable_entity }\n end\n end\n end", "def parse_bookmark_from(b_node)\n Elements::Bookmark.new(b_node)\n end", "def parse_bookmark_from(b_node)\n Elements::Bookmark.new(b_node)\n end", "def bookmark ( name, options = {}, html_options = {} )\n service = SERVICES[name]\n return unless service # igore if not in list\n \n image = @image_prefix.to_s + \"#{options.delete(:image) || \"#{name}.gif\"}\"\n @bookmarks << @template.link_to( @template.image_tag(image, :alt => service.first), parse_url(service.last), html_options)\n end", "def create\n @link = Link.new(params[:link])\n logger.debug \"url: \" << @link.url\n if not Link.url(@link.url).nil?\n logger.debug 'URL: ' << @link.url << ' already exists'\n @link = Link.url(@link.url)\n respond_to do |format|\n flash[:notice] = 'Your URL is a lot cooler now!'\n format.html { redirect_to :action => \"link\", :id => Base32::Crockford.encode(@link.id).downcase }\n end \n else\n respond_to do |format|\n if @link.save\n flash[:notice] = 'Your URL is a lot cooler now!'\n format.html { redirect_to :action => \"link\", :id => Base32::Crockford.encode(@link.id).downcase }\n \n else\n format.html { render :action => \"new\" }\n end\n end\n end\n end", "def set_bookmark_meta_data\n begin\n page = Pismo::Document.new(self.full_url)\n self.name = page.html_title\n self.favicon_url = page.favicon\n self.description = page.description\n rescue => e\n self.description = \"Error => #{e}\"\n ensure\n self.save\n end\n end", "def save_bookmark(data)\n t = open(File.expand_path(\"~/Dropbox/test.txt\"), \"a\")\n t.write(data)\n puts \"saved\"\n t.close\nend", "def bookmark_params\n params.require(:bookmark).permit(:title, :description, :url_attributes => :url)\n end", "def bookmark\n\t\tanswer = $screen.ask(\"bookmark:\",@bookmarks_hist)\n\t\tif answer == nil\n\t\t\t$screen.write_message(\"Cancelled\");\n\t\telse\n\t\t\t$screen.write_message(\"Bookmarked\");\n\t\t\t@bookmarks[answer] = [@row,@col]\n\t\tend\n\tend", "def add_hardlink(uri, targeturi)\n @hardlinks[uri] = targeturi\n end", "def add(url)\n @links << url\n end", "def create\n @solicitation_bookmark = SolicitationBookmark.new(solicitation_bookmark_params)\n\n respond_to do |format|\n if @solicitation_bookmark.save\n format.html { redirect_to @solicitation_bookmark, notice: 'Solicitation bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @solicitation_bookmark }\n else\n format.html { render :new }\n format.json { render json: @solicitation_bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bookmark = @tag.bookmarks.new(bookmark_params)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to path_for_redirect, notice: \"Bookmark, #@bookmark created.\" }\n\n format.json { render json: @bookmark, status: :created }\n else\n format.html { render :new }\n\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @bookmark = Bookmark.new\n end", "def new\n @bookmark = Bookmark.new\n end", "def new\n @bookmark = Bookmark.new\n end", "def new\n @bookmark = Bookmark.new\n end", "def bookmark_params\n params.require(:bookmark).permit(:name, :url, :topic_id)\n end", "def create_link_for(u)\r\n l = links.build(:url => u)\r\n if l.save\r\n @link_url = nil\r\n return true\r\n end\r\n \r\n errors.add(:link_url, \"#{u} is not a valid URL, or is not responding\") and return false\r\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url, :desc, :group_id)\n end", "def test_get_existing_bookmark\n test_url = 'http://www.ml-class.com/'\n num0 = count_bookmarks(@bs.user_id)\n tot0 = count_bookmarks\n assert(get_bookmark(@bs.user_id, test_url) === @bs.add_or_get_bookmark(test_url))\n assert_equal(num0, count_bookmarks(@bs.user_id))\n assert_equal(tot0, count_bookmarks)\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render :index, status: :created, location: @bookmark }\n else\n format.html { render :index }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def build_bookmark(attributes = {}, &block)\n node = Nokogiri::XML::Node.new('bookmark', document)\n assign_to node, attributes\n\n add_child node\n end", "def create\n\t\tbookmark_params = {\n\t\t\t:owner => Prover.find(params[:owner]),\n\t\t\t:post => Post.find(params[:post])\n\t\t}\n\n\t\t@bookmark = Bookmark.new(bookmark_params)\n\n\t\trespond_to do |format|\n\t\t\tif @bookmark.save\n\t\t\t\tformat.html { render :json => @bookmark }\n\t\t\t\tformat.json { render :show, status: :created, location: @bookmark }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def submit(title: '', url: '', shortening: '')\n fill_in 'bookmark_title', with: title\n fill_in 'bookmark_url', with: url\n fill_in 'bookmark_shortening', with: shortening\n\n click_button 'Update Bookmark'\n end", "def bookmark_params\n params.require(:bookmark).permit([:title, :url, :category, :is_favorite, :comment])\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n\n if @bookmark.save\n render json: { bookmark: @bookmark }, status: :created\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end", "def add_new_urls(urls)\n return if urls.length == 0\n @db[LINKS_COLLECTION_NAME].insert(urls.map {|u| {'_id' => hash_url(u)}})\n end", "def bookmark_params\n params.require(:bookmark).permit(:name, :url, :tag_id, :category_id)\n end", "def bookmark_params\n params.require(:bookmark).permit([:title, :url, :category, :comment, :is_favorite])\n end", "def create(clean_url)\n key = generate_unique_key\n @@urls[key] = clean_url\n key\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :description, :user, :url, :tags, :favourite)\n end", "def add_url(url, filterchain, referring_document = nil)\n return if url.nil? || url.empty?\n\n @logger.debug \"add_url #{url}\"\n doc = if referring_document\n referring_document.create_child(url)\n else\n Document.create(url)\n end\n\n if doc = filterchain.apply(doc)\n @documents << doc\n @logger.debug \"url #{url} survived filterchain\"\n end\n rescue\n nil\n end", "def create\n @public_bookmark = PublicBookmark.new(public_bookmark_params)\n\n respond_to do |format|\n if @public_bookmark.save\n format.html { redirect_to @public_bookmark, notice: 'Public bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @public_bookmark }\n else\n format.html { render :new }\n format.json { render json: @public_bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bookmark = Bookmark.new(bookmark_param)\n review = Review.find_by(id: params[:bookmark][:review_id])\n if @bookmark.save\n redirect_to :back\n else\n render 'new'\n end\n end", "def create\n @bookmark = current_user.becomes(LearnUser).bookmarks.new(params[:bookmark])\n\n respond_to do |format|\n if @bookmark.save\n flash[:notice] = 'Bookmark was successfully created.'\n format.html { redirect_to(@bookmark) }\n format.js {redirect_from_facebox(session[:return_to]) }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else \n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity } \n format.js { }\n end\n end\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.owner = current_user\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark.poi }\n format.json { render :show, status: :created, location: @bookmark }\n else\n format.html { redirect_to root_path, alert: t('error', scope: @t_scope) }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url, category_id: [], kind_id: [])\n end", "def create\n @bookmark = Bookmark.new(params[:bookmark])\n @bookmarkable = @bookmark.bookmarkable \n if @bookmarkable.new_record? && @bookmarkable.fandoms.blank?\n @bookmark.errors.add(:base, \"Fandom tag is required\")\n render :new and return\n end\n if @bookmark.errors.empty?\n if @bookmarkable.save && @bookmark.save\n flash[:notice] = ts('Bookmark was successfully created.')\n redirect_to(@bookmark) and return\n end\n end\n @bookmarkable.errors.full_messages.each { |msg| @bookmark.errors.add(:base, msg) }\n render :action => \"new\" and return\n end", "def bookmark_params\n params.require(:bookmark).permit(:url, :title, :notes, :tag_list)\n end", "def remember_bookmark(value)\n @ole.RememberBookmark = value\n nil\n end", "def create\n #@bookmark = Bookmark.new(params[:bookmark])\n #\n #respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n # format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n # else\n # format.html { render :action => \"new\" }\n # format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n # end\n #end\n\n #@bookmark = current_user.bookmarks.build(params[:bookmark])\n \n @user = @current_user\n @bookmark = @current_user.bookmarks.build(params[:bookmark])\n @user.bookmarks << @bookmark\n \n #@bookmarkuser = @current_user.bookmarkusers.build(params[:bookmark])\n #\n \n \n \n #@bookmarkuser.save\n \n if @bookmark.save\n flash[:success] = \"Bookmark created!\"\n redirect_to root_path, :flash => { :success => \"Bookmark created!\" }\n else\n render 'pages/home'\n end\n\n end", "def create_bookmark\n ch = get_single \"Enter A to Z or 0-9 for bookmark: \"\n #ch = get_char\n if ch =~ /^[0-9A-Z]$/\n #$bookmarks[ch] = \"#{Dir.pwd}:#{$cursor}\"\n # \n # The significance of putting a : and not a / is that with a \n # : the dir will be opened with cursor on same object it was on, and not\n # go into the dir. e.g, If bookmark is created with cursor on a dir, we don't want\n # it to go into the dir.\n $bookmarks[ch] = \"#{Dir.pwd}:#{$view[$cursor]}\"\n $modified = true\n else\n perror \"Bookmark must be upper-case character or number.\"\n end\nend", "def add_valid_url(url, refs)\n @results[url] = 1\n end", "def add_valid_url(url, refs)\n @results[url] = 1\n end", "def create\n @bookmark.bookmarkable = @vendor || @dress\n @bookmark.user = current_user\n bookmarkable = @bookmark.bookmarkable\n url = (bookmarkable.class.to_s == \"Dress\" ? bookmarkable : vendor_seo_path(bookmarkable))\n\n # Comentado por Gabriel / Andre revisar\n # if current_user.bookmarked?(bookmarkable)\n # return redirect_to(bookmarkable, notice: 'Você já favoritou este item')\n # end\n \n respond_to do |format|\n if @bookmark.save!\n format.js\n format.html { redirect_to url, notice: 'Item adicionado com sucesso aos favoritos.' }\n format.json { render json: @bookmark, status: :created, location: @bookmark }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_add_link\n num_links0 = count_links\n test_link = 'http://news.ycombinator.com/'\n @ds.add_or_get_link(test_link)\n assert_equal(num_links0 + 1, count_links)\n assert_equal(1, count_links(test_link))\n assert_equal('Hacker News', get_link_title(test_link))\n delete_link(test_link)\n end", "def add_url(url)\n @ole.AddURL(url)\n end", "def add_url(url)\n @ole.AddURL(url)\n end", "def test_existing_with_slug_different_uri\n link = Snip::Link.create :slug => 'existing1', :original => 'http://existing.com/1'\n\n assert_raise RuntimeError do\n post '/', 'original' => 'http://existing.com/2', 'slug' => link.slug\n assert last_response.body.include? 'A different URL already exists'\n end\n end", "def put_url url, url_name = url\n item = [\n [Pasteboard::Type::URL, url],\n [Pasteboard::Type::URL_NAME, url_name],\n [Pasteboard::Type::UTF_8, url],\n ]\n\n put item\n end", "def fix_url(feed_url, link_url)\n\n\t\t\t#wspecial handling for links that start with ../ or ./\n\t\t\t#if sth\n\t\t\t#end\n\n\t\t\t#testiraj jabuk forum..tam so ful problemi.. \n\t\t\t\n\t\t\turi = Addressable::URI.parse(feed_url)\n\t\t\tif !link_url.include? \"http\"\n\t\t\t\tlink_url = uri.scheme + \"://\" + uri.host + link_url\n\t\t\tend\n\t\t\tlink_url\n\t\tend", "def add_url(url, shortcode)\n @db.execute \"INSERT INTO pairings VALUES('#{url}', '#{shortcode}')\"\n return true\n rescue SQLite3::Exception => e\n puts 'Unable to add url:'\n puts e\n return false\n end", "def create\n @bookmarks = if params[:bookmarks]\n permit_bookmarks[:bookmarks]\n else\n [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]\n end\n\n current_or_guest_user.save! unless current_or_guest_user.persisted?\n\n bookmarks_to_add = @bookmarks.reject { |bookmark| current_or_guest_user.bookmarks.where(bookmark).exists? }\n success = ActiveRecord::Base.transaction do\n current_or_guest_user.bookmarks.create!(bookmarks_to_add)\n rescue ActiveRecord::RecordInvalid\n false\n end\n\n if request.xhr?\n success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) : render(json: current_or_guest_user.errors.full_messages, status: \"500\")\n else\n if @bookmarks.any? && success\n flash[:notice] = I18n.t('blacklight.bookmarks.add.success', count: @bookmarks.length)\n elsif @bookmarks.any?\n flash[:error] = I18n.t('blacklight.bookmarks.add.failure', count: @bookmarks.length)\n end\n\n redirect_back fallback_location: bookmarks_path\n end\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.save\n @bookmarks = Bookmark.all\n\n # respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n # format.json { render :show, status: :created, location: @bookmark }\n # else\n # format.html { render :new }\n # format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def bookmark_params\n params.require(:bookmark).permit(:url, :title, :private, :desc, :is_archived, :tag_list)\n end" ]
[ "0.74731624", "0.7078461", "0.6896734", "0.6865405", "0.6600093", "0.6555521", "0.64713037", "0.6403258", "0.6363484", "0.6330094", "0.6321621", "0.6316843", "0.6294058", "0.62899977", "0.6284061", "0.62758213", "0.6262909", "0.6253047", "0.6228213", "0.6190284", "0.6133268", "0.60790575", "0.606201", "0.5998037", "0.5959283", "0.5892105", "0.58665985", "0.585302", "0.5845259", "0.58229506", "0.5812019", "0.577124", "0.57701457", "0.57582986", "0.5757992", "0.575448", "0.57288885", "0.57068413", "0.57019603", "0.5689219", "0.5689219", "0.5664281", "0.5663798", "0.56503403", "0.56447786", "0.5636806", "0.5636806", "0.55992496", "0.5595258", "0.55827886", "0.5574201", "0.55525315", "0.555226", "0.55460566", "0.5538448", "0.5530815", "0.5528055", "0.55158466", "0.55158466", "0.55158466", "0.55158466", "0.5513827", "0.5512334", "0.5508106", "0.5499813", "0.5478508", "0.5475877", "0.5472649", "0.54715693", "0.54639995", "0.54516166", "0.54446393", "0.54392684", "0.54323846", "0.5424111", "0.54235274", "0.5417788", "0.54070395", "0.5405732", "0.54035586", "0.5401156", "0.5401124", "0.53922105", "0.5389346", "0.5388464", "0.53858805", "0.53855765", "0.536676", "0.536676", "0.53509665", "0.5347663", "0.53384995", "0.53384995", "0.5335139", "0.53300387", "0.5326482", "0.5318326", "0.5312484", "0.5305298", "0.5303309" ]
0.59816444
24
Update a valid bookmark name, notes, is_pinned
def test_update_bookmark bm0 = get_bookmark(@bs.user_id, 'http://www.ml-class.com/') new_name = SecureRandom.uuid.to_s bm0.name = new_name bm0.is_pinned = true new_notes = SecureRandom.uuid.to_s bm0.notes = new_notes new_bm = @bs.update_bookmark(bm0) assert(bm0 === new_bm, 'Updated bookmark does not match prototype') bm1 = get_bookmark(@bs.user_id, 'http://www.ml-class.com/') assert(bm1 === bm0, 'Before and after db dookmarks do not match') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n bookmark = Bookmark.find_by(id: params[:id])\n bookmark.update(\n name: bookmark.name,\n path: bookmark.path,\n note_id: params[:note_id],\n user_id: current_user.id,\n screenshot_data: bookmark.screenshot_data\n )\n if bookmark.save\n render json: { message: \"success\"}\n else\n render json: { errors: bookmark.full_messages }, status: 422\n end\n end", "def updatebookmark\n\t\t\t\turl_str = update_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\t\t\n\n\t\t\t url = Url.find_by_url(update_bookmark_params[:url])\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => update_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\n\n\t\t\t @bookmark = Bookmark.find_by_id(update_bookmark_params[:bookmark_id])\n\t\t\t if @bookmark.nil?\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t @bookmark.title = update_bookmark_params[:title]\n\t\t\t @bookmark.description = update_bookmark_params[:description]\n\t\t\t @bookmark.url = url\n\t\t\t @bookmark.user_id = doorkeeper_token.resource_owner_id\n\n\t\t\t @bookmark.tags.clear\n\n\t\t\t tags = update_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\n\n\t\t\t \n\t\t \tif @bookmark.save\n\t\t \trespond_to do |format|\n\t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t \n\t\t \telse\t\t\t \n\t\t \t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t \tend\n\t\t\tend", "def update\n if @bookmark.update(bookmark_params)\n render json: { bookmark: @bookmark }, status: :ok\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end", "def pin_bookmark_for_user(user_id, bookmark_id)\n bm = get_bookmark_for_user(user_id, bookmark_id)\n unless bm == nil\n bm.is_pinned = true\n bm = update_bookmark_for_user(user_id, bm)\n end\n bm\n end", "def update\n\t\trespond_to do |format|\n\t\t\tif @bookmark.update(bookmark_params)\n\t\t\t\tformat.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @bookmark }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update_bookmark_params\n\t\t\t params.permit(:bookmark_id, :url, :title, :description, :tags)\n\t\t\tend", "def update\n \n @bookmark = Bookmark.find(params[:id])\n \n respond_to do |format|\n if @bookmark.UserMade == current_user.username && @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n flash[:notice] = 'Bookmark was successfully updated.'\n format.html { redirect_to(@bookmark) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n flash[:notice] = 'Bookmark was successfully updated.'\n format.html { redirect_to(@bookmark) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_bookmark(bm_name, value)\n raise_if_no_document\n bm_range = set_at_bookmark(bm_name, value)\n @doc.Bookmarks.Add bm_name, bm_range\n end", "def update\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bookmark.update(bookmark_params)\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @bookmark }\n else\n format.html { render :edit }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bookmark.update(bookmark_params)\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @bookmark }\n else\n format.html { render :edit }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bookmark.update(bookmark_params)\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @bookmark }\n else\n # format.html { render :edit }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #get the bookmark to update\n @bookmark = Bookmark.find(params[:id])\n\n #Using strong params\n #update this bookmark\n\n # bookmark#update\n #this is where we actually update the model\n if @bookmark.update(bookmark_params)\n redirect_to @bookmark, notice: \"You have updated the #{@bookmark.title}\"\n else\n # No worky, try again, show me the form you.\n render :edit\n end\n end", "def update\n respond_to do |format|\n if @solicitation_bookmark.update(solicitation_bookmark_params)\n format.html { redirect_to @solicitation_bookmark, notice: 'Solicitation bookmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @solicitation_bookmark }\n else\n format.html { render :edit }\n format.json { render json: @solicitation_bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n unless @bookmark.url.try(:bookmarkable?)\n access_denied; return\n end\n @bookmark.title = @bookmark.manifestation.try(:original_title)\n @bookmark.taggings.where(:tagger_id => @bookmark.user.id).map{|t| t.destroy}\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.bookmark'))\n @bookmark.manifestation.index!\n @bookmark.create_tag_index\n case params[:mode]\n when 'tag_edit'\n format.html { redirect_to @bookmark.manifestation }\n format.json { head :no_content }\n else\n format.html { redirect_to @bookmark }\n format.json { head :no_content }\n end\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to @bookmark, notice: 'Item atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def updatebookmark\n @bookmark_plugins = PLUGIN_CONFIG['bookmark']\n url = Url.find_by_url(timeline_bookmark_params[:url])\n if url.nil?\n url = Url.new({:url => timeline_bookmark_params[:url]})\n if !url.save\n render :status => 404\n end\n end\n @bookmark = Bookmark.find_by_id(timeline_bookmark_params[:bookmark_id])\n if @bookmark.nil?\n render :status => 404\n end\n @bookmark.title = timeline_bookmark_params[:title]\n @bookmark.description = timeline_bookmark_params[:description]\n @bookmark.url = url\n @bookmark.user = current_user\n\n @bookmark.tags.clear\n\n tags = timeline_bookmark_params[:tags]\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end unless tags.nil?\n #@bookmark = Bookmark.new(bookmark_params) #TODO: Explore this.. Above is Ugly\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @anchor = args[:anchor] if args.key?(:anchor)\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def update!(**args)\n @anchor = args[:anchor] if args.key?(:anchor)\n @anchor_scope = args[:anchor_scope] if args.key?(:anchor_scope)\n end", "def update\n @bookmark = Bookmark.find(params[:id])\n\n # #Using strong params update this product Product#update- mode\n if @bookmark.update(bookmark_params)\n redirect_to @bookmark, notice: \"You have updated the #{@bookmark.title}\"\n else\n # No worky, try again, show me the form you.\n render :edit\n end\n end", "def update\n respond_to do |format|\n new_url = Url.find_by_url(bookmark_params[:url_attributes][:url])\n if new_url == nil\n update_bookmark_params = bookmark_params\n else\n update_bookmark_params = bookmark_params.except :url_attributes\n update_bookmark_params.merge! :url_attributes => {:id => new_url.id, :url => new_url.url}\n end\n\n if @bookmark.update update_bookmark_params\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_bookmark\n\t\t@bookmark = Bookmark.find(params[:id])\n\tend", "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 update\n if session[:user_id]\n @bookmark = Bookmark.first(:conditions => {:id => params[:id], :user_id => session[:user_id]})\n if @bookmark \n @tags = params[:tag]\n \n @bookmark.tags.delete_all\n if params[:tag]\n @tags.each do |tag|\n objTag = Tag.find(tag)\n @bookmark.tags << objTag\n end\n end\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to \"/bookmarks/\"\n end\n else\n redirect_to \"/login\"\n end\n end", "def remember_bookmark(value)\n @ole.RememberBookmark = value\n nil\n end", "def bookmark\n\t\tanswer = $screen.ask(\"bookmark:\",@bookmarks_hist)\n\t\tif answer == nil\n\t\t\t$screen.write_message(\"Cancelled\");\n\t\telse\n\t\t\t$screen.write_message(\"Bookmarked\");\n\t\t\t@bookmarks[answer] = [@row,@col]\n\t\tend\n\tend", "def bookmark_params\n params.require(:bookmark).permit(:url, :title, :notes, :tag_list)\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def bookmark_params\n params.permit(:bookmark, :post_id)\n end", "def update\n # Get the Bookmark to update\n @bookmark = Bookmark.find(params[:id])\n\n # Using strong params, update this bookmark\n if @bookmark.update(bookmark_params)\n redirect_to @bookmark, notice: \"You have updated the #{@bookmark.title}.\"\n else\n # Doesn't work, shows the form\n render :edit\n end\n end", "def update\n req = ActiveSupport::JSON.decode(request.body)\n @bookmark = Bookmark.find(req)\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:id])\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render json: @bookmark, status: :created, location: @bookmarks }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @notes = args[:notes] if args.key?(:notes)\n end", "def update\n @bookmarklet = Bookmarklet.find(params[:id])\n\n respond_to do |format|\n if @bookmarklet.update_attributes(params[:bookmarklet])\n flash[:notice] = 'Bookmarklet was successfully updated.'\n format.html { redirect_to(@bookmarklet) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmarklet.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_bookmark\n @bookmark = current_user.bookmarks.find(params[:id])\n end", "def bookmark_params\n params.require(:bookmark).permit(:user_id, :receipe_id)\n end", "def update!(notes)\n fetch_notes\n show_notes\n push_notes(notes)\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :description, :user, :url, :tags, :favourite)\n end", "def update!(**args)\n @alternate_link = args[:alternate_link] if args.key?(:alternate_link)\n @id = args[:id] if args.key?(:id)\n @title = args[:title] if args.key?(:title)\n end", "def update!(**args)\n @pin = args[:pin] if args.key?(:pin)\n end", "def update!(**args)\n @anchor = args[:anchor] if args.key?(:anchor)\n @block_id = args[:block_id] if args.key?(:block_id)\n @doc_id = args[:doc_id] if args.key?(:doc_id)\n @page_id = args[:page_id] if args.key?(:page_id)\n @paragraph_id = args[:paragraph_id] if args.key?(:paragraph_id)\n @route_id = args[:route_id] if args.key?(:route_id)\n @symbol_id = args[:symbol_id] if args.key?(:symbol_id)\n @url = args[:url] if args.key?(:url)\n @word_id = args[:word_id] if args.key?(:word_id)\n end", "def bookmark_params\n params.require(:bookmark).permit(:name, :url, :topic_id)\n end", "def bookmark_params\n params.permit(:user_id, :raffle_id)\n end", "def update!(**args)\n @pin = args[:pin] if args.key?(:pin)\n @pstn_info_url = args[:pstn_info_url] if args.key?(:pstn_info_url)\n end", "def bookmark_params\n params.require(:bookmark).permit(:url, :title, :private, :desc, :is_archived, :tag_list)\n end", "def update!(**args)\n @average_bookmark_usefulness = args[:average_bookmark_usefulness] if args.key?(:average_bookmark_usefulness)\n @average_description_quality = args[:average_description_quality] if args.key?(:average_description_quality)\n @furball_url = args[:furball_url] if args.key?(:furball_url)\n end", "def update!(**args)\n @anchor_text = args[:anchor_text] if args.key?(:anchor_text)\n @url = args[:url] if args.key?(:url)\n end", "def update_address_book(address_book_id, prop_patch)\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url, :desc, :group_id)\n end", "def submit(title: '', url: '', shortening: '')\n fill_in 'bookmark_title', with: title\n fill_in 'bookmark_url', with: url\n fill_in 'bookmark_shortening', with: shortening\n\n click_button 'Update Bookmark'\n end", "def update!(**args)\n @add_app = args[:add_app] if args.key?(:add_app)\n @add_pinned_item = args[:add_pinned_item] if args.key?(:add_pinned_item)\n @remove_app = args[:remove_app] if args.key?(:remove_app)\n @remove_pinned_item = args[:remove_pinned_item] if args.key?(:remove_pinned_item)\n end", "def bookmark_params\n params.require(:bookmark).permit(:poi_id)\n end", "def set_at_bookmark(bm_name, value)\n raise_if_no_document\n # the easy version :\n bm_range = @doc.Bookmarks(bm_name).Range\n bm_range.Text = value\n return bm_range\n end", "def bookmark_params\n params.require(:bookmark).permit(:bookmark_type, :user_id, :value, :cover)\n end", "def edit\n @bookmark = Bookmark.find(params[:id])\n end", "def set_my_bookmark\n @my_bookmark = MyBookmark.find(params[:id])\n end", "def bookmark( *names, **options )\n\t\traise \"expected at least one bookmark name\" if names.empty?\n\n\t\tself.server.run( :bookmark, *names, **options )\n\t\treturn true\n\tend", "def update!(**args)\n @address = args[:address] if args.key?(:address)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @notes = args[:notes] if args.key?(:notes)\n @quick_preview = args[:quick_preview] if args.key?(:quick_preview)\n end", "def test_update_unauth_bookmark\n bm0 = get_bookmark(2, 'http://www.gridgain.com/')\n bm0.name = 'hahaha'\n new_bm = @bs.update_bookmark(bm0)\n assert(new_bm.errors.count > 0) \n end", "def update!(**args)\n @anchor_text = args[:anchor_text] if args.key?(:anchor_text)\n @end = args[:end] if args.key?(:end)\n @start = args[:start] if args.key?(:start)\n @uri = args[:uri] if args.key?(:uri)\n end", "def bookmark_params\n params.require(:bookmark).permit([:title, :url, :category, :comment, :is_favorite])\n end", "def pin!\n update_attribute(:pinned, true)\n end", "def update\n respond_to do |format|\n if @nagayoshi_bookmark_log.update(nagayoshi_bookmark_log_params)\n format.html { redirect_to @nagayoshi_bookmark_log, notice: 'Nagayoshi bookmark log was successfully updated.' }\n format.json { render :show, status: :ok, location: @nagayoshi_bookmark_log }\n else\n format.html { render :edit }\n format.json { render json: @nagayoshi_bookmark_log.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit([:title, :url, :category, :is_favorite, :comment])\n end", "def update!(**args)\n @address = args[:address] if args.key?(:address)\n @business_name = args[:business_name] if args.key?(:business_name)\n end", "def set_bookmark\n @user = User.find(session[:usr])\n @receipe = Receipe.find(params[:receipe_id])\n\n end", "def remember_bookmark\n @ole.RememberBookmark\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url, :tag_list)\n end", "def update!(**args)\n @document_link = args[:document_link] if args.key?(:document_link)\n @request_metadata = args[:request_metadata] if args.key?(:request_metadata)\n end", "def bookmark_params\n params.require(:bookmarking).permit(:post_id)\n end", "def pin!\n update_attribute(:pinned, true)\n end", "def bookmark_params\n params.require(:bookmark).permit(:name, :url, :tag_id, :category_id)\n end", "def bookmark_params\n params.require(:bookmark).permit(:url, :title, :tag_list)\n end", "def update!(**args)\n @link = args[:link] if args.key?(:link)\n end", "def update!(**args)\n @anchor_text = args[:anchor_text] if args.key?(:anchor_text)\n @byte_end = args[:byte_end] if args.key?(:byte_end)\n @byte_start = args[:byte_start] if args.key?(:byte_start)\n @phrase = args[:phrase] if args.key?(:phrase)\n @url = args[:url] if args.key?(:url)\n end", "def update!(**args)\n @metadata = args[:metadata] if args.key?(:metadata)\n @link = args[:link] if args.key?(:link)\n end", "def update!(**args)\n @flags = args[:flags] if args.key?(:flags)\n @kc_link_name = args[:kc_link_name] if args.key?(:kc_link_name)\n @topic_property_name = args[:topic_property_name] if args.key?(:topic_property_name)\n end", "def update!(**args)\n @flags = args[:flags] if args.key?(:flags)\n @kc_link_name = args[:kc_link_name] if args.key?(:kc_link_name)\n @topic_property_name = args[:topic_property_name] if args.key?(:topic_property_name)\n end", "def set_public_bookmark\n @public_bookmark = PublicBookmark.find(params[:id])\n end", "def update!(**args)\n @anchorinfo = args[:anchorinfo] if args.key?(:anchorinfo)\n @begin = args[:begin] if args.key?(:begin)\n @end = args[:end] if args.key?(:end)\n @items = args[:items] if args.key?(:items)\n @score = args[:score] if args.key?(:score)\n @text = args[:text] if args.key?(:text)\n @type = args[:type] if args.key?(:type)\n end", "def bookmark_param\n params.require(:bookmark).permit(:user_id, :review_id)\n end", "def set_bookmark\n @bookmark = current_user.topics.find(params[:topic_id]).bookmarks.find(params[:id])\n end", "def update!(**args)\n @alias = args[:alias] if args.key?(:alias)\n end", "def update!(**args)\n @anchor_text = args[:anchor_text] if args.key?(:anchor_text)\n @annotation_source = args[:annotation_source] if args.key?(:annotation_source)\n @language_code = args[:language_code] if args.key?(:language_code)\n @source_feed_url = args[:source_feed_url] if args.key?(:source_feed_url)\n end", "def update!(**args)\n @address = args[:address] if args.key?(:address)\n @partition = args[:partition] if args.key?(:partition)\n @snat_pool = args[:snat_pool] if args.key?(:snat_pool)\n end" ]
[ "0.7195438", "0.6478249", "0.63931626", "0.6347408", "0.6278724", "0.6229141", "0.61931026", "0.6155853", "0.6155853", "0.6148525", "0.6129744", "0.6129744", "0.6122792", "0.6122792", "0.61062384", "0.60448325", "0.5964274", "0.58810306", "0.5838535", "0.5834831", "0.5829671", "0.5829094", "0.5829094", "0.5829094", "0.5829094", "0.5829094", "0.5829094", "0.5829094", "0.5825391", "0.58174825", "0.5791524", "0.5788467", "0.5785833", "0.57746714", "0.5765695", "0.5760078", "0.57581973", "0.57501787", "0.57501787", "0.57501787", "0.57501787", "0.57501787", "0.57501787", "0.5733697", "0.5727227", "0.57200235", "0.57172275", "0.5715597", "0.571281", "0.56964695", "0.5696241", "0.56933355", "0.56890255", "0.56851524", "0.5670023", "0.5666472", "0.56629235", "0.5662377", "0.561963", "0.56059086", "0.557899", "0.5563279", "0.55606925", "0.55570656", "0.5556808", "0.55555487", "0.55541396", "0.5538865", "0.55301", "0.55198", "0.5517574", "0.5511758", "0.54854494", "0.54716766", "0.54690534", "0.54659593", "0.5465628", "0.5462973", "0.54586715", "0.54548186", "0.5448772", "0.54094845", "0.54017687", "0.539461", "0.5394054", "0.5391995", "0.5391897", "0.5379805", "0.5377411", "0.5361303", "0.5348631", "0.53471786", "0.53471786", "0.5344237", "0.5341774", "0.53389436", "0.53302693", "0.533005", "0.5328619", "0.5302207" ]
0.69014424
1
Try to update a bookmark that does not exist
def test_update_nonexisting_bookmark bm0 = Bookmark.new('id' => 1000, 'url' => '/some/url', 'title' => 'some title') new_bm = @bs.update_bookmark(bm0) assert(new_bm.errors.count > 0) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def updatebookmark\n\t\t\t\turl_str = update_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\t\t\n\n\t\t\t url = Url.find_by_url(update_bookmark_params[:url])\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => update_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\n\n\t\t\t @bookmark = Bookmark.find_by_id(update_bookmark_params[:bookmark_id])\n\t\t\t if @bookmark.nil?\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t @bookmark.title = update_bookmark_params[:title]\n\t\t\t @bookmark.description = update_bookmark_params[:description]\n\t\t\t @bookmark.url = url\n\t\t\t @bookmark.user_id = doorkeeper_token.resource_owner_id\n\n\t\t\t @bookmark.tags.clear\n\n\t\t\t tags = update_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\n\n\t\t\t \n\t\t \tif @bookmark.save\n\t\t \trespond_to do |format|\n\t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t \n\t\t \telse\t\t\t \n\t\t \t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t \tend\n\t\t\tend", "def update\n bookmark = Bookmark.find_by(id: params[:id])\n bookmark.update(\n name: bookmark.name,\n path: bookmark.path,\n note_id: params[:note_id],\n user_id: current_user.id,\n screenshot_data: bookmark.screenshot_data\n )\n if bookmark.save\n render json: { message: \"success\"}\n else\n render json: { errors: bookmark.full_messages }, status: 422\n end\n end", "def update\n if @bookmark.update(bookmark_params)\n render json: { bookmark: @bookmark }, status: :ok\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n new_url = Url.find_by_url(bookmark_params[:url_attributes][:url])\n if new_url == nil\n update_bookmark_params = bookmark_params\n else\n update_bookmark_params = bookmark_params.except :url_attributes\n update_bookmark_params.merge! :url_attributes => {:id => new_url.id, :url => new_url.url}\n end\n\n if @bookmark.update update_bookmark_params\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_update_bookmark \n bm0 = get_bookmark(@bs.user_id, 'http://www.ml-class.com/')\n new_name = SecureRandom.uuid.to_s\n bm0.name = new_name\n bm0.is_pinned = true\n new_notes = SecureRandom.uuid.to_s\n bm0.notes = new_notes\n new_bm = @bs.update_bookmark(bm0)\n assert(bm0 === new_bm, 'Updated bookmark does not match prototype')\n bm1 = get_bookmark(@bs.user_id, 'http://www.ml-class.com/')\n assert(bm1 === bm0, 'Before and after db dookmarks do not match')\n end", "def test_update_unauth_bookmark\n bm0 = get_bookmark(2, 'http://www.gridgain.com/')\n bm0.name = 'hahaha'\n new_bm = @bs.update_bookmark(bm0)\n assert(new_bm.errors.count > 0) \n end", "def updatebookmark\n @bookmark_plugins = PLUGIN_CONFIG['bookmark']\n url = Url.find_by_url(timeline_bookmark_params[:url])\n if url.nil?\n url = Url.new({:url => timeline_bookmark_params[:url]})\n if !url.save\n render :status => 404\n end\n end\n @bookmark = Bookmark.find_by_id(timeline_bookmark_params[:bookmark_id])\n if @bookmark.nil?\n render :status => 404\n end\n @bookmark.title = timeline_bookmark_params[:title]\n @bookmark.description = timeline_bookmark_params[:description]\n @bookmark.url = url\n @bookmark.user = current_user\n\n @bookmark.tags.clear\n\n tags = timeline_bookmark_params[:tags]\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end unless tags.nil?\n #@bookmark = Bookmark.new(bookmark_params) #TODO: Explore this.. Above is Ugly\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_get_existing_bookmark\n test_url = 'http://www.ml-class.com/'\n num0 = count_bookmarks(@bs.user_id)\n tot0 = count_bookmarks\n assert(get_bookmark(@bs.user_id, test_url) === @bs.add_or_get_bookmark(test_url))\n assert_equal(num0, count_bookmarks(@bs.user_id))\n assert_equal(tot0, count_bookmarks)\n end", "def update\n unless @bookmark.url.try(:bookmarkable?)\n access_denied; return\n end\n @bookmark.title = @bookmark.manifestation.try(:original_title)\n @bookmark.taggings.where(:tagger_id => @bookmark.user.id).map{|t| t.destroy}\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.bookmark'))\n @bookmark.manifestation.index!\n @bookmark.create_tag_index\n case params[:mode]\n when 'tag_edit'\n format.html { redirect_to @bookmark.manifestation }\n format.json { head :no_content }\n else\n format.html { redirect_to @bookmark }\n format.json { head :no_content }\n end\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_add_invalid_bookmark\n num_lns0 = count_links\n act_bm = @bs.add_or_get_bookmark('ha ha ha')\n assert(act_bm.errors.count > 0)\n assert_equal(num_lns0, count_links)\n end", "def update\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n flash[:notice] = 'Bookmark was successfully updated.'\n format.html { redirect_to(@bookmark) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n flash[:notice] = 'Bookmark was successfully updated.'\n format.html { redirect_to(@bookmark) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def bookmark_exists?(bm_name)\n raise_if_no_document\n @doc.Bookmarks.Exists(bm_name)\n end", "def update\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bookmark.update(bookmark_params)\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @bookmark }\n else\n format.html { render :edit }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bookmark.update(bookmark_params)\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @bookmark }\n else\n format.html { render :edit }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #get the bookmark to update\n @bookmark = Bookmark.find(params[:id])\n\n #Using strong params\n #update this bookmark\n\n # bookmark#update\n #this is where we actually update the model\n if @bookmark.update(bookmark_params)\n redirect_to @bookmark, notice: \"You have updated the #{@bookmark.title}\"\n else\n # No worky, try again, show me the form you.\n render :edit\n end\n end", "def update\n @bookmarklet = Bookmarklet.find(params[:id])\n\n respond_to do |format|\n if @bookmarklet.update_attributes(params[:bookmarklet])\n flash[:notice] = 'Bookmarklet was successfully updated.'\n format.html { redirect_to(@bookmarklet) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmarklet.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to @bookmark, notice: 'Item atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bookmark.update(bookmark_params)\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @bookmark }\n else\n # format.html { render :edit }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\trespond_to do |format|\n\t\t\tif @bookmark.update(bookmark_params)\n\t\t\t\tformat.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @bookmark }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n \n @bookmark = Bookmark.find(params[:id])\n \n respond_to do |format|\n if @bookmark.UserMade == current_user.username && @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_get_nonexisting_bookmark\n bm = @bs.get_bookmark(15000)\n assert(bm.errors.count > 0)\n end", "def update\n session[:folder_document_ids] = session[:folder_document_ids] || []\n session[:folder_document_ids] << params[:id]\n \n unless request.xhr?\n respond_to do |format|\n format.html do\n flash[:notice] = \"#{(params[:bookmark] && params[:bookmark][:title]) ? params[:bookmark][:title] : \"Item\"} successfully selected\"\n redirect_to :back\n end\n end\n else\n render :text => \"OK\"\n end \n end", "def existing_bookmark_for(document_id)\n # to_a, we don't want to go to the database, we want to use cached\n # copy. \n self.bookmarks.to_a.find {|b| b.document_id == document_id}\n end", "def update\n # Get the Bookmark to update\n @bookmark = Bookmark.find(params[:id])\n\n # Using strong params, update this bookmark\n if @bookmark.update(bookmark_params)\n redirect_to @bookmark, notice: \"You have updated the #{@bookmark.title}.\"\n else\n # Doesn't work, shows the form\n render :edit\n end\n end", "def update\n if session[:user_id]\n @bookmark = Bookmark.first(:conditions => {:id => params[:id], :user_id => session[:user_id]})\n if @bookmark \n @tags = params[:tag]\n \n @bookmark.tags.delete_all\n if params[:tag]\n @tags.each do |tag|\n objTag = Tag.find(tag)\n @bookmark.tags << objTag\n end\n end\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to \"/bookmarks/\"\n end\n else\n redirect_to \"/login\"\n end\n end", "def bookmarklet\n unless session[:user_id] \n flash[:info] = \"Please Sign In.\"\n session[:return_to] = request.fullpath\n redirect_to login_url\n end\n @bookmark = Bookmark.find_or_create_by(:url => params[:address], :user_id => session[:user_id])\n end", "def update\n req = ActiveSupport::JSON.decode(request.body)\n @bookmark = Bookmark.find(req)\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:id])\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render json: @bookmark, status: :created, location: @bookmarks }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bookmark = Bookmark.find(params[:id])\n\n # #Using strong params update this product Product#update- mode\n if @bookmark.update(bookmark_params)\n redirect_to @bookmark, notice: \"You have updated the #{@bookmark.title}\"\n else\n # No worky, try again, show me the form you.\n render :edit\n end\n end", "def set_bookmark(bm_name, value)\n raise_if_no_document\n bm_range = set_at_bookmark(bm_name, value)\n @doc.Bookmarks.Add bm_name, bm_range\n end", "def update\n respond_to do |format|\n if @solicitation_bookmark.update(solicitation_bookmark_params)\n format.html { redirect_to @solicitation_bookmark, notice: 'Solicitation bookmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @solicitation_bookmark }\n else\n format.html { render :edit }\n format.json { render json: @solicitation_bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def remember_bookmark(value)\n @ole.RememberBookmark = value\n nil\n end", "def set_bookmark\n\t\t@bookmark = Bookmark.find(params[:id])\n\tend", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def open_bookmark(bm)\n id = bm.shift\n url = Bookmarks.new.bookmark_url(id)\n pexit \"Failure:\".red + \" bookmark #{id} not found\", 1 if url.nil?\n puts 'opening bookmark ' + url + '...'\n openweb(wrap(url))\n open_bookmark bm unless bm.empty?\n end", "def update\n @bookmark_tag = BookmarkTag.find(params[:id])\n\n respond_to do |format|\n if @bookmark_tag.update_attributes(params[:bookmark_tag])\n format.html { redirect_to @bookmark_tag, notice: 'Bookmark tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bookmark_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_add_pvt_bookmark\n test_url = 'http://www.avilayparekh.com/'\n num_lns0 = count_links\n num_bms0 = count_bookmarks\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_lns0 + 1, count_links)\n assert_equal(num_bms0 + 1, count_bookmarks)\n assert_empty(get_link_title(test_url))\n assert_empty(exp_bm.name)\n delete_link(test_url)\n end", "def resolve_numeric_key key\n d = @bookmarks[key]\n if d\n change_dir d\n return\n end\n\n set_bookmark key\n message \"Created bookmark #{key}.\"\nend", "def set_my_bookmark\n @my_bookmark = MyBookmark.find(params[:id])\n end", "def test_add_new_bookmark\n test_url = 'http://gigaom.com'\n title = 'GigaOM'\n num_lns0 = count_links\n tot_bms0 = count_bookmarks\n num_bms0 = count_bookmarks(@bs.user_id)\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_lns0 + 1, count_links)\n assert_equal(tot_bms0 + 1, count_bookmarks)\n assert_equal(num_bms0 + 1, count_bookmarks(@bs.user_id))\n assert_equal(get_link_title(test_url), exp_bm.name)\n delete_link(test_url)\n end", "def savebookmark\n\t\t\t\turl_str = save_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => save_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t render :status => 404\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\t \n\t\t\t @bookmark = Bookmark.new({:title => save_bookmark_params[:title], :description => save_bookmark_params[:description], :url => url, :user_id => doorkeeper_token.resource_owner_id})\t\t\t \n\n\t\t\t tags = save_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\t\t\t \n\t\t\t \n\t\t\t if @bookmark.save\n\t\t\t \trespond_to do |format|\n \t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t\t \n\t\t\t else\n\t\t\t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\t end\t\t\t \n\t\t\tend", "def bookmarklet\n url_str = params[:url]\n url_str.insert(0, 'http://') if url_str.match('^http').nil?\n \n url = Url.find_by_url(url_str)\n if url.nil?\n url = Url.new({:url => params[:url], :icon => nil})\n if !url.save\n render :status => 404\n end\n end\n\n @bookmark = Bookmark.new({:url => url, :title => params[:title], :description => params[:description], :user => current_user})\n \n params[:tags].split(',').each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end \n \n end", "def bookmark_or_not(document)\n unless document.blank?\n if params[:controller] == 'bookmarks'\n context = {\n :url => bookmark_path(document)\n }\n else\n context = {\n :url => facet_catalog_path(document),\n :data_counter => session[:search][:counter].to_i\n }\n end\n end\n end", "def bookmark\n\t\tanswer = $screen.ask(\"bookmark:\",@bookmarks_hist)\n\t\tif answer == nil\n\t\t\t$screen.write_message(\"Cancelled\");\n\t\telse\n\t\t\t$screen.write_message(\"Bookmarked\");\n\t\t\t@bookmarks[answer] = [@row,@col]\n\t\tend\n\tend", "def unstar_bookmark(bookmark_id)\n perform_post_with_object('/api/1.1/bookmarks/unstar', {bookmark_id: bookmark_id}, Instapaper::Bookmark)\n end", "def process_node_bookmark(xn)\n pull_node(xn)\n flag_match_found\n end", "def update\n respond_to do |format|\n if @bookmark.update(bookmark_params)\n format.html { redirect_to path_for_redirect, notice: \"Bookmark, #@bookmark updated.\" }\n\n format.js { @bookmarks = BookmarkLister.new(@bookmark.reload.tag).() ; render :index }\n\n format.json { render json: @bookmark, status: :ok }\n else\n format.html { render :edit }\n\n format.js { render :edit }\n\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_add_bookmark\n test_url = 'http://www.gridgain.com/'\n num_lns0 = count_links\n num_bms0 = count_bookmarks\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_bms0 + 1, count_bookmarks)\n assert_equal(num_lns0, count_links)\n assert(get_link_title(test_url), exp_bm.name)\n delete_bookmark(@bs.user_id, test_url)\n end", "def bookmark?(key)\n\t\t\t@bookmarks[key.to_sym]\n\t\tend", "def set_at_bookmark(bm_name, value)\n raise_if_no_document\n # the easy version :\n bm_range = @doc.Bookmarks(bm_name).Range\n bm_range.Text = value\n return bm_range\n end", "def set_authorized_bookmark\n @bookmark = Bookmark.find(params[:id])\n redirect_to bookmarks_path, notice: \"Not authorized to operate on this bookmark\" unless current_user == @bookmark.user\n end", "def bookmark(url, name = \"\")\n Item.create(:bookmark, {:name => name, :redirect_url => url})\n end", "def submit(title: '', url: '', shortening: '')\n fill_in 'bookmark_title', with: title\n fill_in 'bookmark_url', with: url\n fill_in 'bookmark_shortening', with: shortening\n\n click_button 'Update Bookmark'\n end", "def edit\n @bookmark = Bookmark.find(params[:id])\n end", "def update\n respond_to do |format|\n if @nagayoshi_bookmark_log.update(nagayoshi_bookmark_log_params)\n format.html { redirect_to @nagayoshi_bookmark_log, notice: 'Nagayoshi bookmark log was successfully updated.' }\n format.json { render :show, status: :ok, location: @nagayoshi_bookmark_log }\n else\n format.html { render :edit }\n format.json { render json: @nagayoshi_bookmark_log.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_bookmark_params\n\t\t\t params.permit(:bookmark_id, :url, :title, :description, :tags)\n\t\t\tend", "def set_bookmark\n @bookmark = current_user.bookmarks.find(params[:id])\n end", "def create\n incomplete = true\n error = false\n if ((params[:url] != nil) &&( (params[:description] != nil ) || (params[:bookmark][\"title\"] != nil )))\n incomplete = false\n url = nil\n if params[:url][:url]\n url = params[:url][:url]\n else\n url = params[:url]\n end\n if not ((url =~ /^http:\\/\\//) || (url =~ /^https:\\/\\//))\n url = \"http://\" + url\n end\n link = Link.find_by_url(url) || Link.new(:url => url)\n link.save\n if link.users.include?(current_user)\n flash[:message] = \"Already in\"\n else\n datetime = nil\n datetime = params[:dt] if params[:dt]\n description = params['description'] || params[:bookmark]['title']\n\n new_bookmark = Bookmark.new(:title => description, :link_id => link.id, :user_id => current_user.id, :bookmarked_at => (datetime || Time.now))\n new_bookmark.private = 1 if ((params[:shared] && (params[:shared] == \"no\")))\n new_bookmark.private = params[:bookmark][\"private\"] if params[:bookmark][\"private\"]\n new_bookmark.tag_list = params['tags'] || params[:bookmark]['tags']\n current_user.bookmarks_update_at = Time.now\n if new_bookmark.save\n current_user.save\n logger.info(\"bookmark for #{url} added\")\n else\n error = true\n logger.warn(\"Error : could not save the new bookmark\")\n end\n end\n end\n respond_to do |format|\n format.xml do\n if incomplete || error\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"something went wrong\\\" />\"\n else\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"done\\\" />\"\n end\n end\n end\n end", "def bookmarklet\n # @bookmark = Bookmark.new(:tags => [Tag.new])\n @bookmark = Bookmark.where(:url => params[:address], :user_id => session[:user_id]).first_or_initialize(:tags => [Tag.new])\n respond_to do |format|\n format.html # bookmarklet.html.erb\n format.xml { render :xml => @bookmark }\n end\n end", "def remember_bookmark\n @ole.RememberBookmark\n end", "def update!(**args)\n @url_found_on_page = args[:url_found_on_page] if args.key?(:url_found_on_page)\n end", "def bookmark!(article)\n user_articles.create!( :article_id => article.id )\n end", "def savebookmark\n @bookmark_plugins = PLUGIN_CONFIG['bookmark']\n url = Url.find_by_url(timeline_bookmark_params[:url])\n if url.nil?\n url = Url.new({:url => timeline_bookmark_params[:url]})\n if !url.save\n format.html { redirect_to 'new', notice: 'Trouble saving the url.' }\n end\n end\n if params[:id].nil?\n @bookmark = Bookmark.new({:title => timeline_bookmark_params[:title], :description => timeline_bookmark_params[:description], :url => url, :user => current_user})\n else\n @bookmark = Bookmark.new({:title => timeline_bookmark_params[:title], :description => timeline_bookmark_params[:description], :url => url, :user => current_user, :group => Group.find(params[:id])})\n end\n\n tags = timeline_bookmark_params[:tags]\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end unless tags.nil?\n #@bookmark = Bookmark.new(bookmark_params) #TODO: Explore this.. Above is Ugly\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to timeline_path, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def _delete\n # Set id and cache key\n id = @options[:id]\n cache_key = nil #\"bookmark_#{id}\"\n\n # Retrieve bookmark object\n bookmark = Taupe::Model::Bookmark.load id, cache_key\n fail \"Unknown bookmark ##{id}\" if bookmark.empty?\n\n # Delete it\n Taupe::Model::Tag.exec \"DELETE FROM bookmark_tag WHERE bookmark_id = #{bookmark.bookmark_id}\"\n bookmark.delete\n\n puts 'Bookmark deleted successfully'\n end", "def _add\n # Load a new bookmark object\n bookmark = Taupe::Model::Bookmark.load\n\n # Modify properties\n bookmark.url = @options[:url]\n bookmark.name = @options[:name]\n\n # Save in database and cache\n bookmark.save\n\n # Tags?\n unless @options[:tags].empty?\n @options[:tags].each do |tag_name|\n tag = Taupe::Model::Tag.fetch \"SELECT * FROM tag WHERE name = '#{tag_name}'\", true\n if tag.nil? || tag.empty?\n tag = Taupe::Model::Tag.load\n tag.name = tag_name\n tag.save\n end\n\n query = \"INSERT INTO bookmark_tag (bookmark_id, tag_id) VALUES (#{bookmark.bookmark_id}, #{tag.tag_id})\"\n Taupe::Model::Tag.exec query\n end\n end\n\n puts 'Bookmark added successfully'\n end", "def bookmark_params\n params.permit(:bookmark, :post_id)\n end", "def bookmark(title = \"My Default Sitewide Bookmark Title\", url=\"#{request.request_uri}\")\n url = 'http://' + request.host_with_port + url\n\n \"javascript:bookmarksite('#{title}=>#{request.request_uri}', '#{url}');\"\n end", "def update_pages_entry(db, read, id)\n\tdb.execute(\"UPDATE books SET read=? WHERE id=?\", [read, id])\nend", "def update; @doc = get(link('self')); nil; end", "def update; @doc = get(link('self')); nil; end", "def set_bookmark_check_owner\n @bookmark = Bookmark.find(params[:id])\n\n if @bookmark.user != current_user\n respond_to do |format|\n\n format.html { redirect_to root_url, alert: \"You dont have permissions for this action\"}\n\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url)\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :url)\n end", "def create_bookmark\n clear_last_line\n print 'Enter A-Z, a-z or 0-9 to create a bookmark: '\n # print \"\\e[?25h\" # unhide cursor\n key = get_char\n # print \"\\e[?25l\" # hide cursor\n if /^[0-9A-Za-z]$/.match?(key)\n set_bookmark key\n @modified = true\n message \"Created bookmark #{key} for #{File.basename(Dir.pwd)}.\"\n else\n perror 'Bookmark must be alpha character or number.'\n end\nend", "def add_to_index?(url)\n print &quot;\\n- indexing #{url}&quot;\n t0 = Time.now\n page = Page.find(scrub(url))\n \n # if the page is not in the index, then index it\n if page.new_record? then\n index(url) { |doc_words, title|\n dsize = doc_words.size.to_f\n puts &quot; [new] - (#{dsize.to_i} words)&quot;\n doc_words.each_with_index { |w, l|\n printf(&quot;\\r\\e - %6.2f%&quot;,(l*100/dsize))\n loc = Location.new(:position =&gt; l)\n loc.word, loc.page, page.title = Word.find(w), page, title\n loc.save\n }\n }\n \n # if it is but it is not fresh, then update it\n elsif not page.fresh? then\n index(url) { |doc_words, title|\n dsize = doc_words.size.to_f\n puts &quot; [refreshed] - (#{dsize.to_i} words)&quot;\n page.locations.destroy!\n doc_words.each_with_index { |w, l|\n printf(&quot;\\r\\e - %6.2f%&quot;,(l*100/dsize))\n loc = Location.new(:position =&gt; l)\n loc.word, loc.page, page.title = Word.find(w), page, title\n loc.save\n }\n }\n page.refresh\n \n #otherwise just ignore it\n else\n puts &quot; - (x) already indexed&quot;\n return false\n end\n t1 = Time.now\n puts &quot; [%6.2f sec]&quot; % (t1 - t0)\n return true\n end\n \n # scrub the given link\n def scrub(link, host=nil)\n unless link.nil? then\n return nil if DO_NOT_CRAWL_TYPES.include? link[(link.size-4)..link.size] or link.include? '?' or link.include? '/cgi-bin/' or link.include? '&amp;' or link[0..8] == 'javascript' or link[0..5] == 'mailto'\n link = link.index('#') == 0 ? '' : link[0..link.index('#')-1] if link.include? '#'\n if link[0..3] == 'http'\n url = URI.join(URI.escape(link))\n else\n url = URI.join(host, URI.escape(link))\n end\n return url.normalize.to_s\n end\n end\n \n # do the common indexing work\n def index(url)\n open(url, &quot;User-Agent&quot; =&gt; USER_AGENT){ |doc|\n h = Hpricot(doc)\n title, body = h.search('title').text.strip, h.search('body')\n %w(style noscript script form img).each { |tag| body.search(tag).remove}\n array = []\n body.first.traverse_element {|element| array &lt;&lt; element.to_s.strip.gsub(/[^a-zA-Z ]/, '') if element.text? }\n array.delete(&quot;&quot;)\n yield(array.join(&quot; &quot;).words, title)\n }\n end\nend\n \n$stdout.sync = true\nspider = Spider.new\nspider.start\n", "def goto_bookmark key=nil\n unless key\n clear_last_line\n print 'Enter bookmark char (? to view): '\n key = get_char\n end\n if key == '?'\n view_bookmarks\n return\n end\n\n d = @bookmarks[key]\n if d\n change_dir d\n else\n perror \"#{key} not a bookmark. \"\n end\nend", "def update\n\n @bookmark = Bookmark.find(params[:id])\n# convert folder array to pure strings ie remove back-slash characters\n\n# @bookmark.folder.each {|f| f=eval(f)}\n\n @bookmark.modified_date=Time.now\n# remove backslashes to reconstruct array\n# @bookmark.folder = eval(@bookmark.folder)\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def unbookmark(article)\n bookmarked_articles.destroy(article)\n end", "def destroy\n if @bookmark.destroy\n head :no_content\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end", "def destroy\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if bookmark = Bookmark.find_by(user_id: session_user, receipe_id: receipe.id)\n bookmark.delete\n redirect_to receipe\n else\n \n end\n \n end", "def parse_bookmark_from(b_node)\n Elements::Bookmark.new(b_node)\n end", "def parse_bookmark_from(b_node)\n Elements::Bookmark.new(b_node)\n end", "def pin_bookmark_for_user(user_id, bookmark_id)\n bm = get_bookmark_for_user(user_id, bookmark_id)\n unless bm == nil\n bm.is_pinned = true\n bm = update_bookmark_for_user(user_id, bm)\n end\n bm\n end", "def test_get_bookmark\n exp_bm = get_bookmark(@bs.user_id, 'http://www.ml-class.com/')\n act_bm = @bs.get_bookmark(4)\n assert(exp_bm === act_bm)\n end", "def update!(**args)\n @anchor = args[:anchor] if args.key?(:anchor)\n end", "def set_public_bookmark\n @public_bookmark = PublicBookmark.find(params[:id])\n end" ]
[ "0.66662264", "0.6618943", "0.65052134", "0.6453506", "0.64423984", "0.6309225", "0.6295251", "0.62498504", "0.6236375", "0.6178784", "0.617064", "0.617064", "0.61605555", "0.61459845", "0.61459845", "0.609051", "0.609051", "0.6084615", "0.6082597", "0.60710514", "0.60611504", "0.60298616", "0.6017963", "0.6014574", "0.60143834", "0.58657753", "0.5838042", "0.5836154", "0.5834232", "0.58306783", "0.5828362", "0.5805284", "0.57689786", "0.5760925", "0.5760925", "0.5760925", "0.5760925", "0.5760925", "0.5760925", "0.5741634", "0.5732668", "0.5729682", "0.5729682", "0.5729682", "0.5729682", "0.5729682", "0.5729682", "0.5729682", "0.5675784", "0.5668902", "0.5633236", "0.5616264", "0.56066483", "0.5580047", "0.5552825", "0.55440384", "0.5535852", "0.5503027", "0.54680115", "0.5465049", "0.5462205", "0.54575247", "0.545544", "0.5439192", "0.54332966", "0.54236835", "0.5394806", "0.53801334", "0.53594375", "0.5343382", "0.5308099", "0.5297457", "0.5291812", "0.52863204", "0.52310663", "0.5230353", "0.52207446", "0.5216278", "0.5202856", "0.5199501", "0.51793325", "0.5157989", "0.5152369", "0.5152369", "0.5152021", "0.51462215", "0.51462215", "0.51391155", "0.513087", "0.5122901", "0.5117309", "0.5108217", "0.5105987", "0.510168", "0.50914073", "0.50914073", "0.5085763", "0.5081549", "0.50747573", "0.5074447" ]
0.7117027
0
Try to update a bookmark that exists but the user does not own
def test_update_unauth_bookmark bm0 = get_bookmark(2, 'http://www.gridgain.com/') bm0.name = 'hahaha' new_bm = @bs.update_bookmark(bm0) assert(new_bm.errors.count > 0) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n \n @bookmark = Bookmark.find(params[:id])\n \n respond_to do |format|\n if @bookmark.UserMade == current_user.username && @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_bookmark_check_owner\n @bookmark = Bookmark.find(params[:id])\n\n if @bookmark.user != current_user\n respond_to do |format|\n\n format.html { redirect_to root_url, alert: \"You dont have permissions for this action\"}\n\n end\n end\n end", "def update\n bookmark = Bookmark.find_by(id: params[:id])\n bookmark.update(\n name: bookmark.name,\n path: bookmark.path,\n note_id: params[:note_id],\n user_id: current_user.id,\n screenshot_data: bookmark.screenshot_data\n )\n if bookmark.save\n render json: { message: \"success\"}\n else\n render json: { errors: bookmark.full_messages }, status: 422\n end\n end", "def set_authorized_bookmark\n @bookmark = Bookmark.find(params[:id])\n redirect_to bookmarks_path, notice: \"Not authorized to operate on this bookmark\" unless current_user == @bookmark.user\n end", "def test_update_bookmark \n bm0 = get_bookmark(@bs.user_id, 'http://www.ml-class.com/')\n new_name = SecureRandom.uuid.to_s\n bm0.name = new_name\n bm0.is_pinned = true\n new_notes = SecureRandom.uuid.to_s\n bm0.notes = new_notes\n new_bm = @bs.update_bookmark(bm0)\n assert(bm0 === new_bm, 'Updated bookmark does not match prototype')\n bm1 = get_bookmark(@bs.user_id, 'http://www.ml-class.com/')\n assert(bm1 === bm0, 'Before and after db dookmarks do not match')\n end", "def bookmarklet\n unless session[:user_id] \n flash[:info] = \"Please Sign In.\"\n session[:return_to] = request.fullpath\n redirect_to login_url\n end\n @bookmark = Bookmark.find_or_create_by(:url => params[:address], :user_id => session[:user_id])\n end", "def update\n if @bookmark.update(bookmark_params)\n render json: { bookmark: @bookmark }, status: :ok\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end", "def set_bookmark\n @bookmark = current_user.bookmarks.find(params[:id])\n end", "def pin_bookmark_for_user(user_id, bookmark_id)\n bm = get_bookmark_for_user(user_id, bookmark_id)\n unless bm == nil\n bm.is_pinned = true\n bm = update_bookmark_for_user(user_id, bm)\n end\n bm\n end", "def updatebookmark\n\t\t\t\turl_str = update_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\t\t\n\n\t\t\t url = Url.find_by_url(update_bookmark_params[:url])\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => update_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\n\n\t\t\t @bookmark = Bookmark.find_by_id(update_bookmark_params[:bookmark_id])\n\t\t\t if @bookmark.nil?\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t @bookmark.title = update_bookmark_params[:title]\n\t\t\t @bookmark.description = update_bookmark_params[:description]\n\t\t\t @bookmark.url = url\n\t\t\t @bookmark.user_id = doorkeeper_token.resource_owner_id\n\n\t\t\t @bookmark.tags.clear\n\n\t\t\t tags = update_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\n\n\t\t\t \n\t\t \tif @bookmark.save\n\t\t \trespond_to do |format|\n\t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t \n\t\t \telse\t\t\t \n\t\t \t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t \tend\n\t\t\tend", "def update\n if session[:user_id]\n @bookmark = Bookmark.first(:conditions => {:id => params[:id], :user_id => session[:user_id]})\n if @bookmark \n @tags = params[:tag]\n \n @bookmark.tags.delete_all\n if params[:tag]\n @tags.each do |tag|\n objTag = Tag.find(tag)\n @bookmark.tags << objTag\n end\n end\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to \"/bookmarks/\"\n end\n else\n redirect_to \"/login\"\n end\n end", "def bookmarked_by_user?(user)\n bookmark_object(user).present?\n end", "def set_bookmark\n @user = User.find(session[:usr])\n @receipe = Receipe.find(params[:receipe_id])\n\n end", "def remember_bookmark(value)\n @ole.RememberBookmark = value\n nil\n end", "def test_update_nonexisting_bookmark\n bm0 = Bookmark.new('id' => 1000, \n 'url' => '/some/url', \n 'title' => 'some title')\n new_bm = @bs.update_bookmark(bm0)\n assert(new_bm.errors.count > 0)\n end", "def bookmark_by(u)\r\n Bookmark.bookmark_by(u, self)\r\n end", "def update\n #get the bookmark to update\n @bookmark = Bookmark.find(params[:id])\n\n #Using strong params\n #update this bookmark\n\n # bookmark#update\n #this is where we actually update the model\n if @bookmark.update(bookmark_params)\n redirect_to @bookmark, notice: \"You have updated the #{@bookmark.title}\"\n else\n # No worky, try again, show me the form you.\n render :edit\n end\n end", "def remember_bookmark\n @ole.RememberBookmark\n end", "def test_get_existing_bookmark\n test_url = 'http://www.ml-class.com/'\n num0 = count_bookmarks(@bs.user_id)\n tot0 = count_bookmarks\n assert(get_bookmark(@bs.user_id, test_url) === @bs.add_or_get_bookmark(test_url))\n assert_equal(num0, count_bookmarks(@bs.user_id))\n assert_equal(tot0, count_bookmarks)\n end", "def bookmark_object(the_user)\n the_user.bookmarked_posts.find_by_post_id(id)\n end", "def is_bookmarked user\n Bookmark.find_by(user_id: user_id, post_id: id)\n end", "def update\n session[:folder_document_ids] = session[:folder_document_ids] || []\n session[:folder_document_ids] << params[:id]\n \n unless request.xhr?\n respond_to do |format|\n format.html do\n flash[:notice] = \"#{(params[:bookmark] && params[:bookmark][:title]) ? params[:bookmark][:title] : \"Item\"} successfully selected\"\n redirect_to :back\n end\n end\n else\n render :text => \"OK\"\n end \n end", "def update\n respond_to do |format|\n new_url = Url.find_by_url(bookmark_params[:url_attributes][:url])\n if new_url == nil\n update_bookmark_params = bookmark_params\n else\n update_bookmark_params = bookmark_params.except :url_attributes\n update_bookmark_params.merge! :url_attributes => {:id => new_url.id, :url => new_url.url}\n end\n\n if @bookmark.update update_bookmark_params\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmarked?(user_id)\n !Bookmark.where(story_id: self.id, user_id: user_id).empty?\n end", "def update\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n flash[:notice] = 'Bookmark was successfully updated.'\n format.html { redirect_to(@bookmark) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n flash[:notice] = 'Bookmark was successfully updated.'\n format.html { redirect_to(@bookmark) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_my_bookmark\n @my_bookmark = MyBookmark.find(params[:id])\n end", "def update\n unless @bookmark.url.try(:bookmarkable?)\n access_denied; return\n end\n @bookmark.title = @bookmark.manifestation.try(:original_title)\n @bookmark.taggings.where(:tagger_id => @bookmark.user.id).map{|t| t.destroy}\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.bookmark'))\n @bookmark.manifestation.index!\n @bookmark.create_tag_index\n case params[:mode]\n when 'tag_edit'\n format.html { redirect_to @bookmark.manifestation }\n format.json { head :no_content }\n else\n format.html { redirect_to @bookmark }\n format.json { head :no_content }\n end\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def updatebookmark\n @bookmark_plugins = PLUGIN_CONFIG['bookmark']\n url = Url.find_by_url(timeline_bookmark_params[:url])\n if url.nil?\n url = Url.new({:url => timeline_bookmark_params[:url]})\n if !url.save\n render :status => 404\n end\n end\n @bookmark = Bookmark.find_by_id(timeline_bookmark_params[:bookmark_id])\n if @bookmark.nil?\n render :status => 404\n end\n @bookmark.title = timeline_bookmark_params[:title]\n @bookmark.description = timeline_bookmark_params[:description]\n @bookmark.url = url\n @bookmark.user = current_user\n\n @bookmark.tags.clear\n\n tags = timeline_bookmark_params[:tags]\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end unless tags.nil?\n #@bookmark = Bookmark.new(bookmark_params) #TODO: Explore this.. Above is Ugly\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bookmark.update(bookmark_params)\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @bookmark }\n else\n format.html { render :edit }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bookmark.update(bookmark_params)\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @bookmark }\n else\n format.html { render :edit }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to @bookmark, notice: 'Item atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\trespond_to do |format|\n\t\t\tif @bookmark.update(bookmark_params)\n\t\t\t\tformat.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @bookmark }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @bookmark.update(bookmark_params)\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @bookmark }\n else\n # format.html { render :edit }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark!(article)\n user_articles.create!( :article_id => article.id )\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def bookmark_params\n params.permit(:user_id, :raffle_id)\n end", "def bookmark_param\n params.require(:bookmark).permit(:user_id, :review_id)\n end", "def bookmark_params\n params.require(:bookmark).permit(:user_id, :receipe_id)\n end", "def update\n @bookmarklet = Bookmarklet.find(params[:id])\n\n respond_to do |format|\n if @bookmarklet.update_attributes(params[:bookmarklet])\n flash[:notice] = 'Bookmarklet was successfully updated.'\n format.html { redirect_to(@bookmarklet) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmarklet.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def update\n respond_to do |format|\n if @solicitation_bookmark.update(solicitation_bookmark_params)\n format.html { redirect_to @solicitation_bookmark, notice: 'Solicitation bookmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @solicitation_bookmark }\n else\n format.html { render :edit }\n format.json { render json: @solicitation_bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_bookmark\n\t\t@bookmark = Bookmark.find(params[:id])\n\tend", "def update\n # Get the Bookmark to update\n @bookmark = Bookmark.find(params[:id])\n\n # Using strong params, update this bookmark\n if @bookmark.update(bookmark_params)\n redirect_to @bookmark, notice: \"You have updated the #{@bookmark.title}.\"\n else\n # Doesn't work, shows the form\n render :edit\n end\n end", "def existing_bookmark_for(document_id)\n # to_a, we don't want to go to the database, we want to use cached\n # copy. \n self.bookmarks.to_a.find {|b| b.document_id == document_id}\n end", "def bookmark\n\t\tanswer = $screen.ask(\"bookmark:\",@bookmarks_hist)\n\t\tif answer == nil\n\t\t\t$screen.write_message(\"Cancelled\");\n\t\telse\n\t\t\t$screen.write_message(\"Bookmarked\");\n\t\t\t@bookmarks[answer] = [@row,@col]\n\t\tend\n\tend", "def update\n req = ActiveSupport::JSON.decode(request.body)\n @bookmark = Bookmark.find(req)\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:id])\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render json: @bookmark, status: :created, location: @bookmarks }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark_exists?(bm_name)\n raise_if_no_document\n @doc.Bookmarks.Exists(bm_name)\n end", "def update\n @bookmark = Bookmark.find(params[:id])\n\n # #Using strong params update this product Product#update- mode\n if @bookmark.update(bookmark_params)\n redirect_to @bookmark, notice: \"You have updated the #{@bookmark.title}\"\n else\n # No worky, try again, show me the form you.\n render :edit\n end\n end", "def destroy\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if bookmark = Bookmark.find_by(user_id: session_user, receipe_id: receipe.id)\n bookmark.delete\n redirect_to receipe\n else\n \n end\n \n end", "def bookmarklet\n set_bookmarklet_vars(current_user)\n if @account_option.bookmarklet? && @key\n render :bookmarklet\n else\n render :no_access\n end\n end", "def set_bookmark(bm_name, value)\n raise_if_no_document\n bm_range = set_at_bookmark(bm_name, value)\n @doc.Bookmarks.Add bm_name, bm_range\n end", "def set_public_bookmark\n @public_bookmark = PublicBookmark.find(params[:id])\n end", "def unstar_bookmark(bookmark_id)\n perform_post_with_object('/api/1.1/bookmarks/unstar', {bookmark_id: bookmark_id}, Instapaper::Bookmark)\n end", "def set_bookmark\n @bookmark = current_user.topics.find(params[:topic_id]).bookmarks.find(params[:id])\n end", "def edit\n @bookmark = Bookmark.find(params[:id])\n end", "def create\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if Bookmark.create(user_id: session_user, receipe_id: receipe.id)\n redirect_to receipe\n else\n \n end\n\n end", "def test_add_pvt_bookmark\n test_url = 'http://www.avilayparekh.com/'\n num_lns0 = count_links\n num_bms0 = count_bookmarks\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_lns0 + 1, count_links)\n assert_equal(num_bms0 + 1, count_bookmarks)\n assert_empty(get_link_title(test_url))\n assert_empty(exp_bm.name)\n delete_link(test_url)\n end", "def bookmark_params\n params.require(:bookmark).permit(:user_id, :record_id)\n end", "def bookmark_params\n params.permit(:bookmark, :post_id)\n end", "def get_bookmark_for_user(user_id, bookmark_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url \n FROM bookmarks b, users u, web_pages w\n WHERE b.user_id = u.id\n AND b.web_page_id = w.id\n AND b.user_id = $1\n AND b.id = $2\n EOS\n bm = @conn.exec(query, [user_id, bookmark_id]).first\n unless bm == nil\n bm = Bookmark.new(bm)\n end\n bm \n end", "def document_is_bookmarked?(document_id)\n bookmarked_document_ids.include? document_id\n end", "def set_solicitation_bookmark\n @solicitation_bookmark = SolicitationBookmark.find(params[:id])\n end", "def destroy\n if session[:user_id] != @bookmark.user_id\n flash[:error] = \"Sorry, you do not have permission to delete this bookmark.\"\n redirect_to root_url\n else \n @bookmark.archive.destroy if @bookmark.archive\n # @bookmark.archive.try(:destroy)\n @bookmark.destroy\n redirect_to root_url, :notice => \"#{@bookmark.title} was deleted!\"\n end\n end", "def update!(**args)\n @private_do_not_access_or_else_safe_url_wrapped_value = args[:private_do_not_access_or_else_safe_url_wrapped_value] if args.key?(:private_do_not_access_or_else_safe_url_wrapped_value)\n end", "def bookmark_or_not(document)\n unless document.blank?\n if params[:controller] == 'bookmarks'\n context = {\n :url => bookmark_path(document)\n }\n else\n context = {\n :url => facet_catalog_path(document),\n :data_counter => session[:search][:counter].to_i\n }\n end\n end\n end", "def update\n if params.has_key? :like\n @client.put(\"/me/favorites/#{params[:id]}\")\n head :ok and return\n end\n\n if params.has_key? :unlike\n @client.delete(\"/me/favorites/#{params[:id]}\")\n head :ok and return\n end\n\n if params.has_key? :repost\n @client.put(\"/me/track_reposts/#{params[:id]}\")\n head :ok and return\n end\n\n if params.has_key? :unpost\n @client.delete(\"/me/track_reposts/#{params[:id]}\")\n head :ok and return\n end\n\n head :bad_request\n end", "def test_get_bookmark\n exp_bm = get_bookmark(@bs.user_id, 'http://www.ml-class.com/')\n act_bm = @bs.get_bookmark(4)\n assert(exp_bm === act_bm)\n end", "def open_bookmark(bm)\n id = bm.shift\n url = Bookmarks.new.bookmark_url(id)\n pexit \"Failure:\".red + \" bookmark #{id} not found\", 1 if url.nil?\n puts 'opening bookmark ' + url + '...'\n openweb(wrap(url))\n open_bookmark bm unless bm.empty?\n end", "def deletebookmark\n\t\t\t\tbookmark = Bookmark.find_by_id(params[:id])\n\t\t\t\tif bookmark.user_id == doorkeeper_token.resource_owner_id\n\t\t\t\t\tbookmark.destroy\n\t\t\t\t\thead :ok\n\t\t\t\telse\n\t\t\t\t\trender :status => 504\n\t\t\t\tend\n\t\t\tend", "def update!(**args)\n @private_do_not_access_or_else_trusted_resource_url_wrapped_value = args[:private_do_not_access_or_else_trusted_resource_url_wrapped_value] if args.key?(:private_do_not_access_or_else_trusted_resource_url_wrapped_value)\n end", "def create\n if session[:user_id]\n user = User.find(session[:user_id])\n params[:bookmark][:user] = user\n @bookmark = Bookmark.new(params[:bookmark])\n if params[:tag]\n @tags = params[:tag]\n @tags.each do |tag|\n objTag = Tag.find(tag)\n @bookmark.tags << objTag\n end\n end\n if @bookmark.url.include?(\"http://\")\n else\n @bookmark.url = \"http://\" + @bookmark.url\n end\n \n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to \"/login\"\n end\n end", "def bookmark?(key)\n\t\t\t@bookmarks[key.to_sym]\n\t\tend", "def test_add_new_bookmark\n test_url = 'http://gigaom.com'\n title = 'GigaOM'\n num_lns0 = count_links\n tot_bms0 = count_bookmarks\n num_bms0 = count_bookmarks(@bs.user_id)\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_lns0 + 1, count_links)\n assert_equal(tot_bms0 + 1, count_bookmarks)\n assert_equal(num_bms0 + 1, count_bookmarks(@bs.user_id))\n assert_equal(get_link_title(test_url), exp_bm.name)\n delete_link(test_url)\n end", "def create\n bookmark = Bookmark.find_or_create_by_URL(params[:bookmark][:URL])\n\n @user_bookmark = UserBookmark.new(:bookmark_id => bookmark.id, :user_id => current_user.id)\n\n respond_to do |format|\n if @user_bookmark.save\n format.html { redirect_to(bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @user_bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def show\n @bookmark = Bookmark.find(params[:id])\n# Update visited date\n @bookmark.visited_date=Time.now\n @bookmark.update_attributes(params[:bookmark])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bookmark }\n end\n end", "def update_bookmark_params\n\t\t\t params.permit(:bookmark_id, :url, :title, :description, :tags)\n\t\t\tend", "def secure_update(attrs, account)\n if !account.allowed_to_edit?(self)\n self.errors.add(:base, \"You don't have permission to update the document.\" )\n return false\n end\n access = attrs.delete :access\n access &&= access.to_i\n published_url = attrs.delete :published_url\n attrs[:remote_url] ||= published_url\n data = attrs.delete :data\n update_attributes attrs\n self.data = data if data\n set_access(access) if access && self.access != access\n true\n end", "def destroy\n @bookmark = Bookmark.where(\"user_id = ? AND raffle_id = ?\", params[:user_id], params[:raffle_id]).first\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to bookmarked_user_path(params[:user_id]), notice: 'Rifa removida de guardadas' }\n format.json { head :no_content }\n end\n end", "def create\n incomplete = true\n error = false\n if ((params[:url] != nil) &&( (params[:description] != nil ) || (params[:bookmark][\"title\"] != nil )))\n incomplete = false\n url = nil\n if params[:url][:url]\n url = params[:url][:url]\n else\n url = params[:url]\n end\n if not ((url =~ /^http:\\/\\//) || (url =~ /^https:\\/\\//))\n url = \"http://\" + url\n end\n link = Link.find_by_url(url) || Link.new(:url => url)\n link.save\n if link.users.include?(current_user)\n flash[:message] = \"Already in\"\n else\n datetime = nil\n datetime = params[:dt] if params[:dt]\n description = params['description'] || params[:bookmark]['title']\n\n new_bookmark = Bookmark.new(:title => description, :link_id => link.id, :user_id => current_user.id, :bookmarked_at => (datetime || Time.now))\n new_bookmark.private = 1 if ((params[:shared] && (params[:shared] == \"no\")))\n new_bookmark.private = params[:bookmark][\"private\"] if params[:bookmark][\"private\"]\n new_bookmark.tag_list = params['tags'] || params[:bookmark]['tags']\n current_user.bookmarks_update_at = Time.now\n if new_bookmark.save\n current_user.save\n logger.info(\"bookmark for #{url} added\")\n else\n error = true\n logger.warn(\"Error : could not save the new bookmark\")\n end\n end\n end\n respond_to do |format|\n format.xml do\n if incomplete || error\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"something went wrong\\\" />\"\n else\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"done\\\" />\"\n end\n end\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:bookmark_type, :user_id, :value, :cover)\n end", "def test_add_invalid_bookmark\n num_lns0 = count_links\n act_bm = @bs.add_or_get_bookmark('ha ha ha')\n assert(act_bm.errors.count > 0)\n assert_equal(num_lns0, count_links)\n end", "def bookmark_params\n params.require(:bookmark).permit(:title, :description, :user, :url, :tags, :favourite)\n end", "def bookmarks(user)\n user = Access::Validate.user(user, false)\n Bookmark\n .where('(bookmarks.creator_id = ? OR bookmarks.updater_id = ?)', user.id, user.id)\n .order('bookmarks.updated_at DESC')\n end", "def bookmark_params\n params.require(:bookmarking).permit(:post_id)\n end", "def bookmarklet\n # @bookmark = Bookmark.new(:tags => [Tag.new])\n @bookmark = Bookmark.where(:url => params[:address], :user_id => session[:user_id]).first_or_initialize(:tags => [Tag.new])\n respond_to do |format|\n format.html # bookmarklet.html.erb\n format.xml { render :xml => @bookmark }\n end\n end", "def savebookmark\n\t\t\t\turl_str = save_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => save_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t render :status => 404\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\t \n\t\t\t @bookmark = Bookmark.new({:title => save_bookmark_params[:title], :description => save_bookmark_params[:description], :url => url, :user_id => doorkeeper_token.resource_owner_id})\t\t\t \n\n\t\t\t tags = save_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\t\t\t \n\t\t\t \n\t\t\t if @bookmark.save\n\t\t\t \trespond_to do |format|\n \t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t\t \n\t\t\t else\n\t\t\t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\t end\t\t\t \n\t\t\tend" ]
[ "0.70674276", "0.6817994", "0.66311955", "0.6623495", "0.6586793", "0.6402623", "0.63414985", "0.6296957", "0.6281445", "0.6278867", "0.6271077", "0.62125784", "0.61521643", "0.61344993", "0.6134425", "0.6131768", "0.61140794", "0.60910213", "0.6083825", "0.6068625", "0.6042265", "0.6039847", "0.60149723", "0.6013141", "0.60023236", "0.60023236", "0.5998355", "0.59811276", "0.5974928", "0.5974928", "0.59737957", "0.5963132", "0.5963132", "0.5959498", "0.5932588", "0.59267336", "0.58933395", "0.5876429", "0.5876429", "0.5876429", "0.5876429", "0.5876429", "0.5876429", "0.5847836", "0.5825831", "0.5805477", "0.5797755", "0.57937664", "0.57937664", "0.57937664", "0.57937664", "0.57937664", "0.57937664", "0.57937664", "0.5787259", "0.57748723", "0.5768649", "0.57685167", "0.57276016", "0.57220525", "0.5697365", "0.5678495", "0.5676851", "0.5670686", "0.5641864", "0.562257", "0.559744", "0.55865663", "0.55855054", "0.55436", "0.5537375", "0.55359036", "0.54872453", "0.5487061", "0.5483366", "0.5462635", "0.54418904", "0.54393166", "0.54367435", "0.5434021", "0.54003614", "0.53981495", "0.5386659", "0.5356569", "0.53555244", "0.53547657", "0.53489214", "0.5339063", "0.53239745", "0.53203315", "0.53149027", "0.53121865", "0.53000253", "0.5298081", "0.529209", "0.52910906", "0.52843595", "0.52803844", "0.52800345", "0.5279237" ]
0.62318027
11
Get a valid bookmark that this user owns
def test_get_bookmark exp_bm = get_bookmark(@bs.user_id, 'http://www.ml-class.com/') act_bm = @bs.get_bookmark(4) assert(exp_bm === act_bm) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_bookmark_for_user(user_id, bookmark_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url \n FROM bookmarks b, users u, web_pages w\n WHERE b.user_id = u.id\n AND b.web_page_id = w.id\n AND b.user_id = $1\n AND b.id = $2\n EOS\n bm = @conn.exec(query, [user_id, bookmark_id]).first\n unless bm == nil\n bm = Bookmark.new(bm)\n end\n bm \n end", "def is_bookmarked user\n Bookmark.find_by(user_id: user_id, post_id: id)\n end", "def bookmark_object(the_user)\n the_user.bookmarked_posts.find_by_post_id(id)\n end", "def bookmark_by(u)\r\n Bookmark.bookmark_by(u, self)\r\n end", "def bookmarked_by_user?(user)\n bookmark_object(user).present?\n end", "def set_bookmark_check_owner\n @bookmark = Bookmark.find(params[:id])\n\n if @bookmark.user != current_user\n respond_to do |format|\n\n format.html { redirect_to root_url, alert: \"You dont have permissions for this action\"}\n\n end\n end\n end", "def bookmarklet\n unless session[:user_id] \n flash[:info] = \"Please Sign In.\"\n session[:return_to] = request.fullpath\n redirect_to login_url\n end\n @bookmark = Bookmark.find_or_create_by(:url => params[:address], :user_id => session[:user_id])\n end", "def remember_bookmark\n @ole.RememberBookmark\n end", "def set_bookmark\n @bookmark = current_user.bookmarks.find(params[:id])\n end", "def bookmarks(user)\n user = Access::Validate.user(user, false)\n Bookmark\n .where('(bookmarks.creator_id = ? OR bookmarks.updater_id = ?)', user.id, user.id)\n .order('bookmarks.updated_at DESC')\n end", "def bookmarked?(user_id)\n !Bookmark.where(story_id: self.id, user_id: user_id).empty?\n end", "def existing_bookmark_for(document_id)\n # to_a, we don't want to go to the database, we want to use cached\n # copy. \n self.bookmarks.to_a.find {|b| b.document_id == document_id}\n end", "def show\n @bookmark = Bookmark.find(params[:id])\n end", "def show\n @bookmark = Bookmark.find(params[:id])\n end", "def set_authorized_bookmark\n @bookmark = Bookmark.find(params[:id])\n redirect_to bookmarks_path, notice: \"Not authorized to operate on this bookmark\" unless current_user == @bookmark.user\n end", "def show\n if session[:user_id]\n @bookmark = Bookmark.first(:conditions => \"id = \" + params[:id].to_s + \" AND user_id = \" + session[:user_id].to_s)\n if @bookmark\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bookmark }\n end\n else\n redirect_to \"/bookmarks/\"\n end\n else\n redirect_to \"/login\"\n end\n end", "def get_bookmark bookmark_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if bookmark_index == ''\n raise 'bookmark index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + bookmark_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmark']\n \n \n rescue Exception=>e\n print e\n end\n end", "def remember_bookmark(value)\n @ole.RememberBookmark = value\n nil\n end", "def set_bookmark\n @user = User.find(session[:usr])\n @receipe = Receipe.find(params[:receipe_id])\n\n end", "def get_bookmarks_for_user(user_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url\n FROM bookmarks b, web_pages w\n WHERE b.web_page_id = w.id\n AND user_id = $1\n EOS\n bms = @conn.exec(query, [user_id])\n Bookmark.build(bms)\n end", "def bookmarks\n @user = User.find(params[:id])\n\n render :status => 404 and return if @user.nil?\n\n # Grab Bookmarks and Render Them Out\n @bookmarks = @user.current_bookmarks\n render_collection_json Serialize::BookmarksSerializer.as_json_with_current_entries(@bookmarks, @user)\n end", "def list_bookmarks(user_id)\n url = \"#{@@request_url}/User.listBookmarks?appid=#{@@appid}&ID=#{user_id}\"\n end", "def create\n bookmark = Bookmark.find_or_create_by_URL(params[:bookmark][:URL])\n\n @user_bookmark = UserBookmark.new(:bookmark_id => bookmark.id, :user_id => current_user.id)\n\n respond_to do |format|\n if @user_bookmark.save\n format.html { redirect_to(bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @user_bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def bookmark_params\n params.permit(:user_id, :raffle_id)\n end", "def index\n @bookmarks = Bookmark.where(owner: current_user)\n end", "def pin_bookmark_for_user(user_id, bookmark_id)\n bm = get_bookmark_for_user(user_id, bookmark_id)\n unless bm == nil\n bm.is_pinned = true\n bm = update_bookmark_for_user(user_id, bm)\n end\n bm\n end", "def set_my_bookmark\n @my_bookmark = MyBookmark.find(params[:id])\n end", "def get_document_bookmark_by_name(request)\n data, _status_code, _headers = get_document_bookmark_by_name_with_http_info(request)\n request_token if _status_code == 401\n data\n end", "def get_pinned_bookmarks_for_user(user_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url\n FROM bookmarks b, web_pages w\n WHERE b.web_page_id = w.id\n AND user_id = $1\n AND is_pinned = TRUE\n EOS\n pbms = @conn.exec(query, [user_id])\n Bookmark.build(pbms)\n end", "def create\n if session[:user_id]\n user = User.find(session[:user_id])\n params[:bookmark][:user] = user\n @bookmark = Bookmark.new(params[:bookmark])\n if params[:tag]\n @tags = params[:tag]\n @tags.each do |tag|\n objTag = Tag.find(tag)\n @bookmark.tags << objTag\n end\n end\n if @bookmark.url.include?(\"http://\")\n else\n @bookmark.url = \"http://\" + @bookmark.url\n end\n \n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to \"/login\"\n end\n end", "def bookmark_exists?(bm_name)\n raise_if_no_document\n @doc.Bookmarks.Exists(bm_name)\n end", "def bookmark_params\n params.require(:bookmark).permit(:user_id, :receipe_id)\n end", "def bookmark_param\n params.require(:bookmark).permit(:user_id, :review_id)\n end", "def set_public_bookmark\n @public_bookmark = PublicBookmark.find(params[:id])\n end", "def parse_bookmark_from(b_node)\n Elements::Bookmark.new(b_node)\n end", "def parse_bookmark_from(b_node)\n Elements::Bookmark.new(b_node)\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def bookmark\n\t\tanswer = $screen.ask(\"bookmark:\",@bookmarks_hist)\n\t\tif answer == nil\n\t\t\t$screen.write_message(\"Cancelled\");\n\t\telse\n\t\t\t$screen.write_message(\"Bookmarked\");\n\t\t\t@bookmarks[answer] = [@row,@col]\n\t\tend\n\tend", "def bookmark?(key)\n\t\t\t@bookmarks[key.to_sym]\n\t\tend", "def bookmark_params\n params.require(:bookmark).permit(:user_id, :record_id)\n end", "def index\n @bookmarks = Bookmark.user_bookmarks(current_user)\n end", "def create\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if Bookmark.create(user_id: session_user, receipe_id: receipe.id)\n redirect_to receipe\n else\n \n end\n\n end", "def get_bookmarks(name, bookmark_path, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_bookmarks_with_http_info(name, bookmark_path, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_bookmarks_with_http_info(name, bookmark_path, opts)\n else\n raise\n end\n return data\n end", "def test_get_by_bookmark_id\n\n comments = Comment.getByBookmarkId(1)\n \n comment = comments[0]\n\n assert_equal 1, comment.commentId\n assert_equal \"This is a comment\", comment.content\n assert_equal 1, comment.bookmarkId\n assert_equal 1, comment.userId\n\n end", "def set_bookmark\n @bookmark = current_user.topics.find(params[:topic_id]).bookmarks.find(params[:id])\n end", "def bookmark_time\n @ole.BookmarkTime\n end", "def test_get_existing_bookmark\n test_url = 'http://www.ml-class.com/'\n num0 = count_bookmarks(@bs.user_id)\n tot0 = count_bookmarks\n assert(get_bookmark(@bs.user_id, test_url) === @bs.add_or_get_bookmark(test_url))\n assert_equal(num0, count_bookmarks(@bs.user_id))\n assert_equal(tot0, count_bookmarks)\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.user_id = current_user.id\n\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @redirect, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: bookmarks_path }\n else\n format.html { redirect_to @redirect, alert: \"Bookmark could not be saved\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmark(url, name = \"\")\n Item.create(:bookmark, {:name => name, :redirect_url => url})\n end", "def author; User.get(self.author_id); end", "def destroy\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if bookmark = Bookmark.find_by(user_id: session_user, receipe_id: receipe.id)\n bookmark.delete\n redirect_to receipe\n else\n \n end\n \n end", "def show\n @end_user = EndUser.find(params[:id])\n @post = @end_user.posts.all\n @bkm = @end_user.bookmarks.all\n end", "def owner\n @address_book_info['principaluri']\n end", "def show\n render json: { bookmark: @bookmark }, status: :ok\n end", "def document_is_bookmarked?(document_id)\n bookmarked_document_ids.include? document_id\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n\t\t@bookmark = Bookmark.find(params[:id])\n\tend", "def edit\n @bookmark = Bookmark.find(params[:id])\n end", "def test_get_by_bookmark_id\n\n validId = BookmarkReport.getById(1)\n\n assert_equal 1, validId.userId\n assert_equal 'something', validId.issue\n assert_equal 'report', validId.description\n\n invalidId = BookmarkReport.getById(0)\n\n assert_nil invalidId\n\n end", "def bookmarklet\n set_bookmarklet_vars(current_user)\n if @account_option.bookmarklet? && @key\n render :bookmarklet\n else\n render :no_access\n end\n end", "def update\n \n @bookmark = Bookmark.find(params[:id])\n \n respond_to do |format|\n if @bookmark.UserMade == current_user.username && @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.owner = current_user\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark.poi }\n format.json { render :show, status: :created, location: @bookmark }\n else\n format.html { redirect_to root_path, alert: t('error', scope: @t_scope) }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end", "def bookmarked?(an_user_id, select=nil)\n return false if self.new_record?\n return (self.send(select).to_i != 0) if !select.nil?\n Bookmark.where(:user_id => an_user_id, :bookmarkable_type => 'MediaElement', :bookmarkable_id => self.id).any?\n end", "def deletebookmark\n\t\t\t\tbookmark = Bookmark.find_by_id(params[:id])\n\t\t\t\tif bookmark.user_id == doorkeeper_token.resource_owner_id\n\t\t\t\t\tbookmark.destroy\n\t\t\t\t\thead :ok\n\t\t\t\telse\n\t\t\t\t\trender :status => 504\n\t\t\t\tend\n\t\t\tend", "def bookmark!(article)\n user_articles.create!( :article_id => article.id )\n end", "def create\n \n #cross-site scripting fix\n headers['Access-Control-Allow-Origin'] = '*'\n headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-Prototype-Version'\n \n u = User.find(params[:id])\n b = Bookmark.where(url: params[:url], user_id: u).first\n c = Category.find(params[:category])\n \n #ensure user does not submit a link more than once\n if b == nil\n Bookmark.create(url: params[:url], title: params[:title], user: u, category: c); \n end\n\n render :nothing => true\n end", "def validate_user_id\n\n # The official bracket doesn't belong to anyone.\n return if self[:is_official]\n\n user = User.first({ :conditions => [\"id = ?\", self[:user_id]] })\n if user.nil?\n errors.add(:user_id, \"must refer to existing record\")\n end\n end", "def is_child_bookmark bookmark_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if bookmark_index == ''\n raise 'bookmark index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + bookmark_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmark']\n \n \n rescue Exception=>e\n print e\n end\n end", "def test_get_by_bookmark_id\n\n resultCreated = Tag.newTag(\"Payroll\", 1);\n\n assert_equal true, resultCreated\n\n results = Tag.getByBookmarkId(1);\n\n result = results[0]\n\n assert_equal \"Payroll\", result.tag\n\n assert_equal 1, results.length\n\n end", "def test_get_unauth_bookmark\n bm = @bs.get_bookmark(15)\n assert(bm.errors.count > 0)\n end", "def atom_feed_for(bookmarks, title, feed_uri, user=nil)\n feed = Atom::Feed.new\n feed.title = title\n most_recent_bookmark = bookmarks.max do |b1,b2|\n b1.timestamp <=> b2.timestamp\n end\n feed.updated = most_recent_bookmark.timestamp\n\n # Link this feed to itself\n self_link = feed.links.new\n self_link['rel'] = 'self'\n self_link['href'] = feed_uri + \".atom\"\n\n # If this list is a list of bookmarks from a single user, that user is\n # the author of the feed.\n if user\n user_to_atom_author(user, feed)\n end\n\n # Turn each bookmark in the list into an entry in the feed.\n bookmarks.each do |bookmark|\n entry = feed.entries.new\n entry.title = bookmark.short_description\n entry.content = bookmark.long_description\n\n # In a real application, a bookmark would have a separate\n # \"modification date\" field which was not under the control of\n # the user. This would also make the Last-Modified calculations\n # more accurate.\n entry.updated = bookmark.timestamp \n\n # First, link this Atom entry to the external URI that the\n # bookmark tracks.\n external_uri = entry.links.new\n external_uri['href'] = bookmark.uri\n\n # Now we give some connectedness to this service. Link this Atom\n # entry to this service's resource for this bookmark.\n bookmark_resource = entry.links.new\n bookmark_resource['rel'] = \"self\"\n bookmark_resource['href'] = bookmark_url(bookmark.user.name, \n bookmark.uri_hash) + \".atom\"\n bookmark_resource['type'] = \"application/xml+atom\"\n\n # Then link this entry to the list of users who've bookmarked\n # this URI.\n other_users = entry.links.new\n other_users['rel'] = \"related\"\n other_users['href'] = uri_url(bookmark.uri_hash) + \".atom\"\n other_users['type'] = \"application/xml+atom\"\n\n # Turn this entry's user into the \"author\" of this entry, unless\n # we already specified a user as the \"author\" of the entire\n # feed.\n unless user\n user_to_atom_author(bookmark.user, entry) \n end\n\n # For each of this bookmark's tags...\n bookmark.tags.each do |tag|\n # ...represent the tag as an Atom category.\n category = entry.categories.new\n category['term'] = tag\n category['scheme'] = user_url(bookmark.user.name) + \"/tags\"\n\n # Link to this user's other bookmarks tagged using this tag.\n tag_uri = entry.links.new\n tag_uri['href'] = tag_url(bookmark.user.name, tag.name) + \".atom\"\n tag_uri['rel'] = 'related'\n tag_uri['type'] = \"application/xml+atom\"\n\n # Also link to all bookmarks tagged with this tag.\n recent_tag_uri = entry.links.new\n recent_tag_uri['href'] = recent_url(tag.name) + \".atom\"\n recent_tag_uri['rel'] = 'related'\n recent_tag_uri['type'] = \"application/xml+atom\"\n end\n end \n return feed.to_xml\n end", "def strip_bookmark_to_json(bookmark)\n\t\t\t\tformatted_tags = []\n\t\t\t\tbookmark.tags.each do |tag|\n\t\t\t\t formatted_tags << tag.tagname\n\t\t\t\tend\t\t\t \t\t\t\t\n\t\t\t\tbookmark_json = {:id => bookmark.id, :url => bookmark.url.url, :title => bookmark.title, :description => bookmark.description, :updated_at => bookmark.updated_at.to_i, :tags => formatted_tags}\n\n\t\t\t\tif bookmark.group_id\n\t\t\t\t\tbookmark_json[:username] = bookmark.user.name\n\t\t\t\t\tbookmark_json[:groupname] = bookmark.group.name\t\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tif bookmark.user_id == doorkeeper_token.resource_owner_id\n\t\t\t\t\tbookmark_json[:my_bookmark] = true\n\t\t\t\telse\n\t\t\t\t\tbookmark_json[:my_bookmark] = false\n\t\t\t\tend\t\t\t\n\t\t\t\tbookmark_json\n\t\t\tend", "def on_behalf_of_user_id\n return @on_behalf_of_user_id\n end", "def index\n# Bookmark.destroy_all\n# @bookmarks = Bookmark.all\n\n# Get all bookmarks related to user where the primary key of User record is in session[:user_id]\n @bookmarks =User.find(session[:user_id]).bookmarks.scoped\n @[email protected](:name)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookmarks }\n end\n end", "def create\n #@bookmark = Bookmark.new(params[:bookmark])\n #\n #respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n # format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n # else\n # format.html { render :action => \"new\" }\n # format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n # end\n #end\n\n #@bookmark = current_user.bookmarks.build(params[:bookmark])\n \n @user = @current_user\n @bookmark = @current_user.bookmarks.build(params[:bookmark])\n @user.bookmarks << @bookmark\n \n #@bookmarkuser = @current_user.bookmarkusers.build(params[:bookmark])\n #\n \n \n \n #@bookmarkuser.save\n \n if @bookmark.save\n flash[:success] = \"Bookmark created!\"\n redirect_to root_path, :flash => { :success => \"Bookmark created!\" }\n else\n render 'pages/home'\n end\n\n end", "def destroy\n @bookmark = Bookmark.find(params[:id])\n @user = User.find(session[:user_id])\n @user.bookmarks.delete(@bookmark)\n\n respond_to do |format|\n format.html { redirect_to(bookmarks_url) }\n format.xml { head :ok }\n end\n end", "def create\n @bookmark = current_user.becomes(LearnUser).bookmarks.new(params[:bookmark])\n\n respond_to do |format|\n if @bookmark.save\n flash[:notice] = 'Bookmark was successfully created.'\n format.html { redirect_to(@bookmark) }\n format.js {redirect_from_facebox(session[:return_to]) }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else \n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity } \n format.js { }\n end\n end\n end", "def user_for_draftsman\n return unless defined?(current_user)\n ActiveSupport::VERSION::MAJOR >= 4 ? current_user.try!(:id) : current_user.try(:id)\n rescue NoMethodError\n current_user\n end", "def owner\n get_user owner_id\n end", "def bookmark_params\n params.require(:bookmark).permit(:bookmark_type, :user_id, :value, :cover)\n end", "def user\n user_id.get_object\n end", "def likely_facebook_account\n facebook_accounts.first.andand.first\n end", "def set_solicitation_bookmark\n @solicitation_bookmark = SolicitationBookmark.find(params[:id])\n end", "def destroy\n if session[:user_id]\n @bookmark = Bookmark.first(:conditions => {:id => params[:id], :user_id => session[:user_id]})\n if @bookmark\n @bookmark = Bookmark.find(params[:id])\n @bookmark.destroy\n \n respond_to do |format|\n format.html { redirect_to(bookmarks_url) }\n format.xml { head :ok }\n end\n else\n redirect_to \"/bookmarks/\"\n end\n else\n redirect_to \"/login\"\n end\n end", "def new_bookmark(username, password, uri, short_description)\n representation = form_encoded({ \"bookmark[uri]\" => uri,\n \"bookmark[short_description]\" => \n short_description })\n begin\n dest = \"#{@service_root}/users/#{URI.encode(username)}/bookmarks\"\n response = open(dest, :method => :post, :body => representation,\n :http_basic_authentication => [username, password])\n puts \"Bookmark posted to #{response.meta['location']}\"\n rescue OpenURI::HTTPError => e\n response_code = e.io.status[0].to_i\n if response_code == 401 # Unauthorized\n puts \"It looks like you gave me a bad password.\"\n elsif response_code == 409 # Conflict\n puts \"It looks like you already posted that bookmark.\"\n else\n raise e\n end\n end \n end", "def destroy\n if session[:user_id] != @bookmark.user_id\n flash[:error] = \"Sorry, you do not have permission to delete this bookmark.\"\n redirect_to root_url\n else \n @bookmark.archive.destroy if @bookmark.archive\n # @bookmark.archive.try(:destroy)\n @bookmark.destroy\n redirect_to root_url, :notice => \"#{@bookmark.title} was deleted!\"\n end\n end", "def create\n\t\tbookmark_params = {\n\t\t\t:owner => Prover.find(params[:owner]),\n\t\t\t:post => Post.find(params[:post])\n\t\t}\n\n\t\t@bookmark = Bookmark.new(bookmark_params)\n\n\t\trespond_to do |format|\n\t\t\tif @bookmark.save\n\t\t\t\tformat.html { render :json => @bookmark }\n\t\t\t\tformat.json { render :show, status: :created, location: @bookmark }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def bookmark_params\n params.permit(:bookmark, :post_id)\n end", "def create\n @bookmarks = if params[:bookmarks]\n permit_bookmarks[:bookmarks]\n else\n [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]\n end\n\n current_or_guest_user.save! unless current_or_guest_user.persisted?\n\n bookmarks_to_add = @bookmarks.reject { |bookmark| current_or_guest_user.bookmarks.where(bookmark).exists? }\n success = ActiveRecord::Base.transaction do\n current_or_guest_user.bookmarks.create!(bookmarks_to_add)\n rescue ActiveRecord::RecordInvalid\n false\n end\n\n if request.xhr?\n success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) : render(json: current_or_guest_user.errors.full_messages, status: \"500\")\n else\n if @bookmarks.any? && success\n flash[:notice] = I18n.t('blacklight.bookmarks.add.success', count: @bookmarks.length)\n elsif @bookmarks.any?\n flash[:error] = I18n.t('blacklight.bookmarks.add.failure', count: @bookmarks.length)\n end\n\n redirect_back fallback_location: bookmarks_path\n end\n end" ]
[ "0.68905103", "0.67919695", "0.67752415", "0.67430377", "0.6659034", "0.637722", "0.62930834", "0.6239914", "0.6209224", "0.5993878", "0.5962502", "0.58072126", "0.57282805", "0.57282805", "0.5720498", "0.57180333", "0.5710632", "0.5710113", "0.5691769", "0.5658541", "0.56357455", "0.5633692", "0.5594017", "0.5582162", "0.5579315", "0.556601", "0.55389965", "0.5538745", "0.55228335", "0.55067205", "0.55015683", "0.5466648", "0.545751", "0.5454313", "0.54538596", "0.54538596", "0.5442269", "0.5442269", "0.5442269", "0.5442269", "0.5442269", "0.5442269", "0.5431058", "0.54240966", "0.5383101", "0.5361961", "0.5348875", "0.5343772", "0.5331817", "0.531543", "0.5312644", "0.5302873", "0.5301737", "0.5300622", "0.5297912", "0.52853733", "0.52844375", "0.5278768", "0.5276584", "0.52691805", "0.5266645", "0.5266645", "0.5266645", "0.5266645", "0.5266645", "0.5266645", "0.5266645", "0.5248971", "0.52268976", "0.5206607", "0.5201687", "0.5192217", "0.51897645", "0.5185701", "0.5157557", "0.51572907", "0.51444405", "0.5128275", "0.5120217", "0.5109044", "0.5101184", "0.5098152", "0.5082423", "0.5076501", "0.50686204", "0.5064475", "0.5051059", "0.5049541", "0.5046687", "0.50458246", "0.50324726", "0.502994", "0.5027024", "0.5026918", "0.502608", "0.501612", "0.50150466", "0.50079954", "0.50072926", "0.5000722" ]
0.5834022
11
Get a valid bookmark that this user does not own
def test_get_unauth_bookmark bm = @bs.get_bookmark(15) assert(bm.errors.count > 0) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_bookmarked user\n Bookmark.find_by(user_id: user_id, post_id: id)\n end", "def bookmark_by(u)\r\n Bookmark.bookmark_by(u, self)\r\n end", "def remember_bookmark\n @ole.RememberBookmark\n end", "def get_bookmark_for_user(user_id, bookmark_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url \n FROM bookmarks b, users u, web_pages w\n WHERE b.user_id = u.id\n AND b.web_page_id = w.id\n AND b.user_id = $1\n AND b.id = $2\n EOS\n bm = @conn.exec(query, [user_id, bookmark_id]).first\n unless bm == nil\n bm = Bookmark.new(bm)\n end\n bm \n end", "def bookmark_object(the_user)\n the_user.bookmarked_posts.find_by_post_id(id)\n end", "def bookmarked_by_user?(user)\n bookmark_object(user).present?\n end", "def bookmarked?(user_id)\n !Bookmark.where(story_id: self.id, user_id: user_id).empty?\n end", "def set_bookmark_check_owner\n @bookmark = Bookmark.find(params[:id])\n\n if @bookmark.user != current_user\n respond_to do |format|\n\n format.html { redirect_to root_url, alert: \"You dont have permissions for this action\"}\n\n end\n end\n end", "def bookmarklet\n unless session[:user_id] \n flash[:info] = \"Please Sign In.\"\n session[:return_to] = request.fullpath\n redirect_to login_url\n end\n @bookmark = Bookmark.find_or_create_by(:url => params[:address], :user_id => session[:user_id])\n end", "def remember_bookmark(value)\n @ole.RememberBookmark = value\n nil\n end", "def existing_bookmark_for(document_id)\n # to_a, we don't want to go to the database, we want to use cached\n # copy. \n self.bookmarks.to_a.find {|b| b.document_id == document_id}\n end", "def test_get_bookmark\n exp_bm = get_bookmark(@bs.user_id, 'http://www.ml-class.com/')\n act_bm = @bs.get_bookmark(4)\n assert(exp_bm === act_bm)\n end", "def list_bookmarks(user_id)\n url = \"#{@@request_url}/User.listBookmarks?appid=#{@@appid}&ID=#{user_id}\"\n end", "def test_get_bookmarks_nouser\n ds = BookmarkStore.new($conn_str)\n assert_raises(RuntimeError) { ds.get_bookmarks }\n end", "def bookmark_exists?(bm_name)\n raise_if_no_document\n @doc.Bookmarks.Exists(bm_name)\n end", "def destroy\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if bookmark = Bookmark.find_by(user_id: session_user, receipe_id: receipe.id)\n bookmark.delete\n redirect_to receipe\n else\n \n end\n \n end", "def parse_bookmark_from(b_node)\n Elements::Bookmark.new(b_node)\n end", "def parse_bookmark_from(b_node)\n Elements::Bookmark.new(b_node)\n end", "def set_authorized_bookmark\n @bookmark = Bookmark.find(params[:id])\n redirect_to bookmarks_path, notice: \"Not authorized to operate on this bookmark\" unless current_user == @bookmark.user\n end", "def bookmarks(user)\n user = Access::Validate.user(user, false)\n Bookmark\n .where('(bookmarks.creator_id = ? OR bookmarks.updater_id = ?)', user.id, user.id)\n .order('bookmarks.updated_at DESC')\n end", "def get_bookmark bookmark_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if bookmark_index == ''\n raise 'bookmark index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + bookmark_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmark']\n \n \n rescue Exception=>e\n print e\n end\n end", "def test_get_nonexisting_bookmark\n bm = @bs.get_bookmark(15000)\n assert(bm.errors.count > 0)\n end", "def strip_bookmark_to_json(bookmark)\n\t\t\t\tformatted_tags = []\n\t\t\t\tbookmark.tags.each do |tag|\n\t\t\t\t formatted_tags << tag.tagname\n\t\t\t\tend\t\t\t \t\t\t\t\n\t\t\t\tbookmark_json = {:id => bookmark.id, :url => bookmark.url.url, :title => bookmark.title, :description => bookmark.description, :updated_at => bookmark.updated_at.to_i, :tags => formatted_tags}\n\n\t\t\t\tif bookmark.group_id\n\t\t\t\t\tbookmark_json[:username] = bookmark.user.name\n\t\t\t\t\tbookmark_json[:groupname] = bookmark.group.name\t\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tif bookmark.user_id == doorkeeper_token.resource_owner_id\n\t\t\t\t\tbookmark_json[:my_bookmark] = true\n\t\t\t\telse\n\t\t\t\t\tbookmark_json[:my_bookmark] = false\n\t\t\t\tend\t\t\t\n\t\t\t\tbookmark_json\n\t\t\tend", "def general_bookmarks\n @general_bookmarks ||=\n Bookmark.with_missing_bookmarkable.or(\n Bookmark.with_bookmarkable_visible_to_registered_user\n ).is_public\n end", "def get_document_bookmark_by_name(request)\n data, _status_code, _headers = get_document_bookmark_by_name_with_http_info(request)\n request_token if _status_code == 401\n data\n end", "def bookmark?(key)\n\t\t\t@bookmarks[key.to_sym]\n\t\tend", "def test_get_existing_bookmark\n test_url = 'http://www.ml-class.com/'\n num0 = count_bookmarks(@bs.user_id)\n tot0 = count_bookmarks\n assert(get_bookmark(@bs.user_id, test_url) === @bs.add_or_get_bookmark(test_url))\n assert_equal(num0, count_bookmarks(@bs.user_id))\n assert_equal(tot0, count_bookmarks)\n end", "def get_pinned_bookmarks_for_user(user_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url\n FROM bookmarks b, web_pages w\n WHERE b.web_page_id = w.id\n AND user_id = $1\n AND is_pinned = TRUE\n EOS\n pbms = @conn.exec(query, [user_id])\n Bookmark.build(pbms)\n end", "def bookmark\n\t\tanswer = $screen.ask(\"bookmark:\",@bookmarks_hist)\n\t\tif answer == nil\n\t\t\t$screen.write_message(\"Cancelled\");\n\t\telse\n\t\t\t$screen.write_message(\"Bookmarked\");\n\t\t\t@bookmarks[answer] = [@row,@col]\n\t\tend\n\tend", "def pin_bookmark_for_user(user_id, bookmark_id)\n bm = get_bookmark_for_user(user_id, bookmark_id)\n unless bm == nil\n bm.is_pinned = true\n bm = update_bookmark_for_user(user_id, bm)\n end\n bm\n end", "def set_bookmark\n @bookmark = current_user.bookmarks.find(params[:id])\n end", "def bookmark_or_not(document)\n unless document.blank?\n if params[:controller] == 'bookmarks'\n context = {\n :url => bookmark_path(document)\n }\n else\n context = {\n :url => facet_catalog_path(document),\n :data_counter => session[:search][:counter].to_i\n }\n end\n end\n end", "def bookmark_params\n params.permit(:user_id, :raffle_id)\n end", "def bookmark(url, name = \"\")\n Item.create(:bookmark, {:name => name, :redirect_url => url})\n end", "def reject_link(hash)\n p hash\n hash.each do |key|\n unless key=='user_id'\n return hash[key].blank?\n end\n end \n # reject if not real link ids (either)\n end", "def get_bookmarks(name, bookmark_path, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_bookmarks_with_http_info(name, bookmark_path, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_bookmarks_with_http_info(name, bookmark_path, opts)\n else\n raise\n end\n return data\n end", "def bookmark_param\n params.require(:bookmark).permit(:user_id, :review_id)\n end", "def index\n @bookmarks = Bookmark.where(owner: current_user)\n end", "def document_is_bookmarked?(document_id)\n bookmarked_document_ids.include? document_id\n end", "def get_bookmarks_for_user(user_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url\n FROM bookmarks b, web_pages w\n WHERE b.web_page_id = w.id\n AND user_id = $1\n EOS\n bms = @conn.exec(query, [user_id])\n Bookmark.build(bms)\n end", "def get_bookmarks\n @logger.debug \"Fetching bookmarks from Delicious\"\n bookmarks = []\n doc = REXML::Document.new(open(\"http://feeds.delicious.com/v2/rss/#{@username}?count=5\"))\n doc.each_element('//channel/item') do |item|\n bookmarks << {\n :title => item.get_text('title'),\n :url => item.get_text('link'),\n :date => Date.parse(item.get_text('pubDate').to_s)\n }\n end\n return bookmarks\n end", "def bookmark_params\n params.require(:bookmark).permit(:user_id, :receipe_id)\n end", "def bookmarklet\n set_bookmarklet_vars(current_user)\n if @account_option.bookmarklet? && @key\n render :bookmarklet\n else\n render :no_access\n end\n end", "def unstar_bookmark(bookmark_id)\n perform_post_with_object('/api/1.1/bookmarks/unstar', {bookmark_id: bookmark_id}, Instapaper::Bookmark)\n end", "def deletebookmark\n\t\t\t\tbookmark = Bookmark.find_by_id(params[:id])\n\t\t\t\tif bookmark.user_id == doorkeeper_token.resource_owner_id\n\t\t\t\t\tbookmark.destroy\n\t\t\t\t\thead :ok\n\t\t\t\telse\n\t\t\t\t\trender :status => 504\n\t\t\t\tend\n\t\t\tend", "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 set_bookmark\n @user = User.find(session[:usr])\n @receipe = Receipe.find(params[:receipe_id])\n\n end", "def create\n if session[:user_id]\n user = User.find(session[:user_id])\n params[:bookmark][:user] = user\n @bookmark = Bookmark.new(params[:bookmark])\n if params[:tag]\n @tags = params[:tag]\n @tags.each do |tag|\n objTag = Tag.find(tag)\n @bookmark.tags << objTag\n end\n end\n if @bookmark.url.include?(\"http://\")\n else\n @bookmark.url = \"http://\" + @bookmark.url\n end\n \n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to \"/login\"\n end\n end", "def destroy\n if session[:user_id] != @bookmark.user_id\n flash[:error] = \"Sorry, you do not have permission to delete this bookmark.\"\n redirect_to root_url\n else \n @bookmark.archive.destroy if @bookmark.archive\n # @bookmark.archive.try(:destroy)\n @bookmark.destroy\n redirect_to root_url, :notice => \"#{@bookmark.title} was deleted!\"\n end\n end", "def bookmark_params\n params.require(:bookmark).permit(:user_id, :record_id)\n end", "def show\n @bookmark = Bookmark.find(params[:id])\n end", "def show\n @bookmark = Bookmark.find(params[:id])\n end", "def show\n if session[:user_id]\n @bookmark = Bookmark.first(:conditions => \"id = \" + params[:id].to_s + \" AND user_id = \" + session[:user_id].to_s)\n if @bookmark\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bookmark }\n end\n else\n redirect_to \"/bookmarks/\"\n end\n else\n redirect_to \"/login\"\n end\n end", "def is_child_bookmark bookmark_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if bookmark_index == ''\n raise 'bookmark index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + bookmark_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmark']\n \n \n rescue Exception=>e\n print e\n end\n end", "def bookmarks\n @user = User.find(params[:id])\n\n render :status => 404 and return if @user.nil?\n\n # Grab Bookmarks and Render Them Out\n @bookmarks = @user.current_bookmarks\n render_collection_json Serialize::BookmarksSerializer.as_json_with_current_entries(@bookmarks, @user)\n end", "def bookmark_time\n @ole.BookmarkTime\n end", "def create\n bookmark = Bookmark.find_or_create_by_URL(params[:bookmark][:URL])\n\n @user_bookmark = UserBookmark.new(:bookmark_id => bookmark.id, :user_id => current_user.id)\n\n respond_to do |format|\n if @user_bookmark.save\n format.html { redirect_to(bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @user_bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @bookmarks = Bookmark.user_bookmarks(current_user)\n end", "def test_get_by_bookmark_id\n\n validId = BookmarkReport.getById(1)\n\n assert_equal 1, validId.userId\n assert_equal 'something', validId.issue\n assert_equal 'report', validId.description\n\n invalidId = BookmarkReport.getById(0)\n\n assert_nil invalidId\n\n end", "def public_bookmarks\n @public_bookmarks ||=\n Bookmark.with_missing_bookmarkable.or(\n Bookmark.with_bookmarkable_visible_to_all\n ).is_public\n end", "def destroy\n @bookmark = Bookmark.find(params[:id])\n @user = User.find(session[:user_id])\n @user.bookmarks.delete(@bookmark)\n\n respond_to do |format|\n format.html { redirect_to(bookmarks_url) }\n format.xml { head :ok }\n end\n end", "def get_document_bookmarks(name, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_bookmarks_with_http_info(name, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_bookmarks_with_http_info(name, opts)\n else\n raise\n end\n return data\n end", "def create\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if Bookmark.create(user_id: session_user, receipe_id: receipe.id)\n redirect_to receipe\n else\n \n end\n\n end", "def test_get_by_bookmark_id\n\n comments = Comment.getByBookmarkId(1)\n \n comment = comments[0]\n\n assert_equal 1, comment.commentId\n assert_equal \"This is a comment\", comment.content\n assert_equal 1, comment.bookmarkId\n assert_equal 1, comment.userId\n\n end", "def set_my_bookmark\n @my_bookmark = MyBookmark.find(params[:id])\n end", "def delete\n\t\treturn self.repo.bookmark( self.name, delete: true )\n\tend", "def create\n \n #cross-site scripting fix\n headers['Access-Control-Allow-Origin'] = '*'\n headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-Prototype-Version'\n \n u = User.find(params[:id])\n b = Bookmark.where(url: params[:url], user_id: u).first\n c = Category.find(params[:category])\n \n #ensure user does not submit a link more than once\n if b == nil\n Bookmark.create(url: params[:url], title: params[:title], user: u, category: c); \n end\n\n render :nothing => true\n end", "def open_bookmark(bm)\n id = bm.shift\n url = Bookmarks.new.bookmark_url(id)\n pexit \"Failure:\".red + \" bookmark #{id} not found\", 1 if url.nil?\n puts 'opening bookmark ' + url + '...'\n openweb(wrap(url))\n open_bookmark bm unless bm.empty?\n end", "def destroy_if_orphaned\n destroy unless has_bookmarks?\n end", "def destroy\n if session[:user_id]\n @bookmark = Bookmark.first(:conditions => {:id => params[:id], :user_id => session[:user_id]})\n if @bookmark\n @bookmark = Bookmark.find(params[:id])\n @bookmark.destroy\n \n respond_to do |format|\n format.html { redirect_to(bookmarks_url) }\n format.xml { head :ok }\n end\n else\n redirect_to \"/bookmarks/\"\n end\n else\n redirect_to \"/login\"\n end\n end", "def set_public_bookmark\n @public_bookmark = PublicBookmark.find(params[:id])\n end", "def bookmark(title = \"My Default Sitewide Bookmark Title\", url=\"#{request.request_uri}\")\n url = 'http://' + request.host_with_port + url\n\n \"javascript:bookmarksite('#{title}=>#{request.request_uri}', '#{url}');\"\n end", "def is_new?\n !self.new_bookmark.nil?\n end", "def display_social_bookmarks?; true end", "def likely_facebook_account\n facebook_accounts.first.andand.first\n end", "def bookmarked?(an_user_id, select=nil)\n return false if self.new_record?\n return (self.send(select).to_i != 0) if !select.nil?\n Bookmark.where(:user_id => an_user_id, :bookmarkable_type => 'MediaElement', :bookmarkable_id => self.id).any?\n end", "def destroy\n @bookmark = Bookmark.where(\"user_id = ? AND raffle_id = ?\", params[:user_id], params[:raffle_id]).first\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to bookmarked_user_path(params[:user_id]), notice: 'Rifa removida de guardadas' }\n format.json { head :no_content }\n end\n end", "def atom_feed_for(bookmarks, title, feed_uri, user=nil)\n feed = Atom::Feed.new\n feed.title = title\n most_recent_bookmark = bookmarks.max do |b1,b2|\n b1.timestamp <=> b2.timestamp\n end\n feed.updated = most_recent_bookmark.timestamp\n\n # Link this feed to itself\n self_link = feed.links.new\n self_link['rel'] = 'self'\n self_link['href'] = feed_uri + \".atom\"\n\n # If this list is a list of bookmarks from a single user, that user is\n # the author of the feed.\n if user\n user_to_atom_author(user, feed)\n end\n\n # Turn each bookmark in the list into an entry in the feed.\n bookmarks.each do |bookmark|\n entry = feed.entries.new\n entry.title = bookmark.short_description\n entry.content = bookmark.long_description\n\n # In a real application, a bookmark would have a separate\n # \"modification date\" field which was not under the control of\n # the user. This would also make the Last-Modified calculations\n # more accurate.\n entry.updated = bookmark.timestamp \n\n # First, link this Atom entry to the external URI that the\n # bookmark tracks.\n external_uri = entry.links.new\n external_uri['href'] = bookmark.uri\n\n # Now we give some connectedness to this service. Link this Atom\n # entry to this service's resource for this bookmark.\n bookmark_resource = entry.links.new\n bookmark_resource['rel'] = \"self\"\n bookmark_resource['href'] = bookmark_url(bookmark.user.name, \n bookmark.uri_hash) + \".atom\"\n bookmark_resource['type'] = \"application/xml+atom\"\n\n # Then link this entry to the list of users who've bookmarked\n # this URI.\n other_users = entry.links.new\n other_users['rel'] = \"related\"\n other_users['href'] = uri_url(bookmark.uri_hash) + \".atom\"\n other_users['type'] = \"application/xml+atom\"\n\n # Turn this entry's user into the \"author\" of this entry, unless\n # we already specified a user as the \"author\" of the entire\n # feed.\n unless user\n user_to_atom_author(bookmark.user, entry) \n end\n\n # For each of this bookmark's tags...\n bookmark.tags.each do |tag|\n # ...represent the tag as an Atom category.\n category = entry.categories.new\n category['term'] = tag\n category['scheme'] = user_url(bookmark.user.name) + \"/tags\"\n\n # Link to this user's other bookmarks tagged using this tag.\n tag_uri = entry.links.new\n tag_uri['href'] = tag_url(bookmark.user.name, tag.name) + \".atom\"\n tag_uri['rel'] = 'related'\n tag_uri['type'] = \"application/xml+atom\"\n\n # Also link to all bookmarks tagged with this tag.\n recent_tag_uri = entry.links.new\n recent_tag_uri['href'] = recent_url(tag.name) + \".atom\"\n recent_tag_uri['rel'] = 'related'\n recent_tag_uri['type'] = \"application/xml+atom\"\n end\n end \n return feed.to_xml\n end", "def show_nouser\n @feed = Feed.find_by_uid!(params[:feed])\n feed_uids = [@feed.uid] + @feed.children.pluck(:uid)\n\n @date = (_parse_date(params) || @feed.last_paper_date || Date.today).to_date\n @range = _parse_range(params) || 1\n @page = params[:page]\n\n if @range == :since_last\n # If we're not signed in, there's no sense\n # in which we can do \"since last\"\n @range = 1\n end\n\n @backdate = @date - (@range-1).days\n\n @recent_comments = _recent_comments(feed_uids)\n\n @papers = _range_query(feed_uids, @backdate, @date, @page)\n end", "def bookmark!(article)\n user_articles.create!( :article_id => article.id )\n end", "def get_document_bookmarks(request)\n data, _status_code, _headers = get_document_bookmarks_with_http_info(request)\n request_token if _status_code == 401\n data\n end", "def create_bookmark\n clear_last_line\n print 'Enter A-Z, a-z or 0-9 to create a bookmark: '\n # print \"\\e[?25h\" # unhide cursor\n key = get_char\n # print \"\\e[?25l\" # hide cursor\n if /^[0-9A-Za-z]$/.match?(key)\n set_bookmark key\n @modified = true\n message \"Created bookmark #{key} for #{File.basename(Dir.pwd)}.\"\n else\n perror 'Bookmark must be alpha character or number.'\n end\nend", "def noreferrer?; end", "def test_get_by_bookmark_id\n\n resultCreated = Tag.newTag(\"Payroll\", 1);\n\n assert_equal true, resultCreated\n\n results = Tag.getByBookmarkId(1);\n\n result = results[0]\n\n assert_equal \"Payroll\", result.tag\n\n assert_equal 1, results.length\n\n end", "def document_not_found!\n doc = ::SolrDocument.find(params[:id])\n # Render the document if the current_user == the depositor of the document\n return doc if current_user && current_user.user_key == doc[\"depositor_ssim\"].first\n raise WorkflowAuthorizationException if doc.suppressed?\n raise CanCan::AccessDenied.new(nil, :show)\n end", "def index\n# Bookmark.destroy_all\n# @bookmarks = Bookmark.all\n\n# Get all bookmarks related to user where the primary key of User record is in session[:user_id]\n @bookmarks =User.find(session[:user_id]).bookmarks.scoped\n @[email protected](:name)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookmarks }\n end\n end", "def new_bookmark(username, password, uri, short_description)\n representation = form_encoded({ \"bookmark[uri]\" => uri,\n \"bookmark[short_description]\" => \n short_description })\n begin\n dest = \"#{@service_root}/users/#{URI.encode(username)}/bookmarks\"\n response = open(dest, :method => :post, :body => representation,\n :http_basic_authentication => [username, password])\n puts \"Bookmark posted to #{response.meta['location']}\"\n rescue OpenURI::HTTPError => e\n response_code = e.io.status[0].to_i\n if response_code == 401 # Unauthorized\n puts \"It looks like you gave me a bad password.\"\n elsif response_code == 409 # Conflict\n puts \"It looks like you already posted that bookmark.\"\n else\n raise e\n end\n end \n end", "def validate_user_id\n\n # The official bracket doesn't belong to anyone.\n return if self[:is_official]\n\n user = User.first({ :conditions => [\"id = ?\", self[:user_id]] })\n if user.nil?\n errors.add(:user_id, \"must refer to existing record\")\n end\n end", "def destroy\n @bookmark.destroy\n flash[:notice] = ts(\"Bookmark was successfully deleted.\")\n redirect_to user_bookmarks_path(current_user)\n end", "def bookmark_params\n params.permit(:bookmark, :post_id)\n end", "def destroy\n @bookmark = Bookmark.find_by_user_id_and_book_id(current_user.id, params[:book_id])\n @bookmark.destroy\n\n respond_to do |format|\n format.html { redirect_to(:back, :notice => \"Bookmark was successfully deleted.\") }\n format.xml { head :ok }\n end\n end", "def bookmarklet\n # @bookmark = Bookmark.new(:tags => [Tag.new])\n @bookmark = Bookmark.where(:url => params[:address], :user_id => session[:user_id]).first_or_initialize(:tags => [Tag.new])\n respond_to do |format|\n format.html # bookmarklet.html.erb\n format.xml { render :xml => @bookmark }\n end\n end", "def bookmarks\n xpath './bookmark'\n end", "def bookmarks_export_url(format, params = {})\n bookmarks_url(params.merge(format: format, encrypted_user_id: encrypt_user_id(current_or_guest_user.id) ))\n end", "def originalFriend \n self.token ? self : User.find_by_facebook_id(Network.find_by_friend_id(self['facebook_id'])['facebook_id'])\n end", "def create_bookmark\n ch = get_single \"Enter A to Z or 0-9 for bookmark: \"\n #ch = get_char\n if ch =~ /^[0-9A-Z]$/\n #$bookmarks[ch] = \"#{Dir.pwd}:#{$cursor}\"\n # \n # The significance of putting a : and not a / is that with a \n # : the dir will be opened with cursor on same object it was on, and not\n # go into the dir. e.g, If bookmark is created with cursor on a dir, we don't want\n # it to go into the dir.\n $bookmarks[ch] = \"#{Dir.pwd}:#{$view[$cursor]}\"\n $modified = true\n else\n perror \"Bookmark must be upper-case character or number.\"\n end\nend", "def unbookmark(article)\n bookmarked_articles.destroy(article)\n end", "def get_paycycle_unassociated_to_user()\n query = \"select id, title\n from `epms_hrcore_payroll_cycle` ehpc\n where not exists\n (select * from `epms_hrcore_employment_detail` where ehpc.id = payroll_cycle)\n and is_deleted = 0\n ORDER BY rand();\"\n return @db[query].first\n end", "def bookmark_params\n params.require(:bookmarking).permit(:post_id)\n end", "def antiuser(user)\n users.where(['users.id <> ?', user.id]).first\n end" ]
[ "0.6234465", "0.618554", "0.6163488", "0.61443484", "0.60697204", "0.60685587", "0.60646415", "0.60524184", "0.59471", "0.58050704", "0.5762584", "0.57196563", "0.5506633", "0.5476419", "0.54485637", "0.54469395", "0.54293144", "0.54293144", "0.5415089", "0.5393074", "0.5383792", "0.5336922", "0.533066", "0.5312387", "0.53051233", "0.5296729", "0.5296093", "0.5291492", "0.5289118", "0.52825505", "0.5268043", "0.52213264", "0.5216204", "0.5212302", "0.5185896", "0.51548827", "0.5153433", "0.51297235", "0.5125146", "0.5118077", "0.50813395", "0.5073989", "0.5070729", "0.506999", "0.5065381", "0.5049265", "0.5042372", "0.5035988", "0.501835", "0.50155234", "0.50149304", "0.50149304", "0.5000329", "0.49961174", "0.49958673", "0.4994259", "0.4985595", "0.4977611", "0.49737492", "0.49711233", "0.49639186", "0.49510705", "0.4949891", "0.49434224", "0.4942041", "0.4936138", "0.49229845", "0.49209353", "0.49026394", "0.48919457", "0.48838228", "0.48802477", "0.4877716", "0.48732698", "0.48569453", "0.48555136", "0.48338276", "0.482925", "0.48262367", "0.4825645", "0.482449", "0.48181725", "0.47914907", "0.4788951", "0.47823337", "0.47679248", "0.47592673", "0.47576034", "0.4750465", "0.4742767", "0.4741815", "0.47349796", "0.47348678", "0.47223425", "0.47190034", "0.4704557", "0.46946546", "0.4692547", "0.46878186", "0.46807098" ]
0.5890509
9
Get a bookmark that does not exist
def test_get_nonexisting_bookmark bm = @bs.get_bookmark(15000) assert(bm.errors.count > 0) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def existing_bookmark_for(document_id)\n # to_a, we don't want to go to the database, we want to use cached\n # copy. \n self.bookmarks.to_a.find {|b| b.document_id == document_id}\n end", "def bookmark_exists?(bm_name)\n raise_if_no_document\n @doc.Bookmarks.Exists(bm_name)\n end", "def bookmark_or_not(document)\n unless document.blank?\n if params[:controller] == 'bookmarks'\n context = {\n :url => bookmark_path(document)\n }\n else\n context = {\n :url => facet_catalog_path(document),\n :data_counter => session[:search][:counter].to_i\n }\n end\n end\n end", "def parse_bookmark_from(b_node)\n Elements::Bookmark.new(b_node)\n end", "def parse_bookmark_from(b_node)\n Elements::Bookmark.new(b_node)\n end", "def get_bookmark bookmark_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if bookmark_index == ''\n raise 'bookmark index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + bookmark_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmark']\n \n \n rescue Exception=>e\n print e\n end\n end", "def bookmark?(key)\n\t\t\t@bookmarks[key.to_sym]\n\t\tend", "def test_get_existing_bookmark\n test_url = 'http://www.ml-class.com/'\n num0 = count_bookmarks(@bs.user_id)\n tot0 = count_bookmarks\n assert(get_bookmark(@bs.user_id, test_url) === @bs.add_or_get_bookmark(test_url))\n assert_equal(num0, count_bookmarks(@bs.user_id))\n assert_equal(tot0, count_bookmarks)\n end", "def test_get_unauth_bookmark\n bm = @bs.get_bookmark(15)\n assert(bm.errors.count > 0)\n end", "def bookmark_by(u)\r\n Bookmark.bookmark_by(u, self)\r\n end", "def is_child_bookmark bookmark_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if bookmark_index == ''\n raise 'bookmark index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + bookmark_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmark']\n \n \n rescue Exception=>e\n print e\n end\n end", "def open_bookmark(bm)\n id = bm.shift\n url = Bookmarks.new.bookmark_url(id)\n pexit \"Failure:\".red + \" bookmark #{id} not found\", 1 if url.nil?\n puts 'opening bookmark ' + url + '...'\n openweb(wrap(url))\n open_bookmark bm unless bm.empty?\n end", "def bookmarks\n xpath './bookmark'\n end", "def bookmark(url, name = \"\")\n Item.create(:bookmark, {:name => name, :redirect_url => url})\n end", "def bookmark_query(q,&blk)\n response = query(q)\n bookmark = response[\"bookmark\"]\n docs = response[\"docs\"]\n\n until !docs || docs.empty?\n yield docs\n q[\"bookmark\"] = bookmark\n response = query(q)\n bookmark = response[\"bookmark\"]\n docs = response[\"docs\"]\n end\n\n docs\n end", "def bookmark\n\t\tanswer = $screen.ask(\"bookmark:\",@bookmarks_hist)\n\t\tif answer == nil\n\t\t\t$screen.write_message(\"Cancelled\");\n\t\telse\n\t\t\t$screen.write_message(\"Bookmarked\");\n\t\t\t@bookmarks[answer] = [@row,@col]\n\t\tend\n\tend", "def test_get_bookmark\n exp_bm = get_bookmark(@bs.user_id, 'http://www.ml-class.com/')\n act_bm = @bs.get_bookmark(4)\n assert(exp_bm === act_bm)\n end", "def test_get_by_bookmark_id\n\n resultCreated = Tag.newTag(\"Payroll\", 1);\n\n assert_equal true, resultCreated\n\n results = Tag.getByBookmarkId(1);\n\n result = results[0]\n\n assert_equal \"Payroll\", result.tag\n\n assert_equal 1, results.length\n\n end", "def remember_bookmark\n @ole.RememberBookmark\n end", "def remember_bookmark(value)\n @ole.RememberBookmark = value\n nil\n end", "def bookmarklet\n unless session[:user_id] \n flash[:info] = \"Please Sign In.\"\n session[:return_to] = request.fullpath\n redirect_to login_url\n end\n @bookmark = Bookmark.find_or_create_by(:url => params[:address], :user_id => session[:user_id])\n end", "def destroy_if_orphaned\n destroy unless has_bookmarks?\n end", "def delete(opts={})\r\n Rakuten::Request.get(\"https://app.rakuten.co.jp/services/api/FavoriteBookmark/Delete/20120627\", Rakuten::Api.merge(opts))\r\n end", "def process_node_bookmark(xn)\n pull_node(xn)\n flag_match_found\n end", "def delete\n\t\treturn self.repo.bookmark( self.name, delete: true )\n\tend", "def get_bookmarks(name, bookmark_path, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_bookmarks_with_http_info(name, bookmark_path, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_bookmarks_with_http_info(name, bookmark_path, opts)\n else\n raise\n end\n return data\n end", "def destroy\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if bookmark = Bookmark.find_by(user_id: session_user, receipe_id: receipe.id)\n bookmark.delete\n redirect_to receipe\n else\n \n end\n \n end", "def test_add_invalid_bookmark\n num_lns0 = count_links\n act_bm = @bs.add_or_get_bookmark('ha ha ha')\n assert(act_bm.errors.count > 0)\n assert_equal(num_lns0, count_links)\n end", "def get_document_bookmark_by_name(request)\n data, _status_code, _headers = get_document_bookmark_by_name_with_http_info(request)\n request_token if _status_code == 401\n data\n end", "def test_update_nonexisting_bookmark\n bm0 = Bookmark.new('id' => 1000, \n 'url' => '/some/url', \n 'title' => 'some title')\n new_bm = @bs.update_bookmark(bm0)\n assert(new_bm.errors.count > 0)\n end", "def test_get_bookmarks_nouser\n ds = BookmarkStore.new($conn_str)\n assert_raises(RuntimeError) { ds.get_bookmarks }\n end", "def unstar_bookmark(bookmark_id)\n perform_post_with_object('/api/1.1/bookmarks/unstar', {bookmark_id: bookmark_id}, Instapaper::Bookmark)\n end", "def bookmarklet\n url_str = params[:url]\n url_str.insert(0, 'http://') if url_str.match('^http').nil?\n \n url = Url.find_by_url(url_str)\n if url.nil?\n url = Url.new({:url => params[:url], :icon => nil})\n if !url.save\n render :status => 404\n end\n end\n\n @bookmark = Bookmark.new({:url => url, :title => params[:title], :description => params[:description], :user => current_user})\n \n params[:tags].split(',').each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end \n \n end", "def get_bookmark_for_user(user_id, bookmark_id)\n query = <<-EOS\n SELECT b.id, b.name, b.notes, b.added_on, w.url \n FROM bookmarks b, users u, web_pages w\n WHERE b.user_id = u.id\n AND b.web_page_id = w.id\n AND b.user_id = $1\n AND b.id = $2\n EOS\n bm = @conn.exec(query, [user_id, bookmark_id]).first\n unless bm == nil\n bm = Bookmark.new(bm)\n end\n bm \n end", "def destroy\n if @bookmark.destroy\n head :no_content\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end", "def unbookmark(article)\n bookmarked_articles.destroy(article)\n end", "def load_bookmarks\n if File.exist? File.expand_path(\"~/Dropbox/test.txt\")\n return YAML.load_stream(open(File.expand_path(\"~/Dropbox/test.txt\"))).documents \n else\n puts \"Add: ./dl.rb url\"\n puts \"Get: ./dl.rb tagname\"\n return open(File.expand_path(\"~/Dropbox/test.txt\"), \"w\")\n end\nend", "def bookmarklet\n # @bookmark = Bookmark.new(:tags => [Tag.new])\n @bookmark = Bookmark.where(:url => params[:address], :user_id => session[:user_id]).first_or_initialize(:tags => [Tag.new])\n respond_to do |format|\n format.html # bookmarklet.html.erb\n format.xml { render :xml => @bookmark }\n end\n end", "def bookmark_object(the_user)\n the_user.bookmarked_posts.find_by_post_id(id)\n end", "def bookmark(title = \"My Default Sitewide Bookmark Title\", url=\"#{request.request_uri}\")\n url = 'http://' + request.host_with_port + url\n\n \"javascript:bookmarksite('#{title}=>#{request.request_uri}', '#{url}');\"\n end", "def test_get_by_bookmark_id\n\n comments = Comment.getByBookmarkId(1)\n \n comment = comments[0]\n\n assert_equal 1, comment.commentId\n assert_equal \"This is a comment\", comment.content\n assert_equal 1, comment.bookmarkId\n assert_equal 1, comment.userId\n\n end", "def get_bookmarks\n @logger.debug \"Fetching bookmarks from Delicious\"\n bookmarks = []\n doc = REXML::Document.new(open(\"http://feeds.delicious.com/v2/rss/#{@username}?count=5\"))\n doc.each_element('//channel/item') do |item|\n bookmarks << {\n :title => item.get_text('title'),\n :url => item.get_text('link'),\n :date => Date.parse(item.get_text('pubDate').to_s)\n }\n end\n return bookmarks\n end", "def get_document_bookmarks(name, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_bookmarks_with_http_info(name, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_bookmarks_with_http_info(name, opts)\n else\n raise\n end\n return data\n end", "def try(prefix, link)\n link\n end", "def document_is_bookmarked?(document_id)\n bookmarked_document_ids.include? document_id\n end", "def show\n @bookmark = Bookmark.find(params[:id])\n end", "def show\n @bookmark = Bookmark.find(params[:id])\n end", "def _delete\n # Set id and cache key\n id = @options[:id]\n cache_key = nil #\"bookmark_#{id}\"\n\n # Retrieve bookmark object\n bookmark = Taupe::Model::Bookmark.load id, cache_key\n fail \"Unknown bookmark ##{id}\" if bookmark.empty?\n\n # Delete it\n Taupe::Model::Tag.exec \"DELETE FROM bookmark_tag WHERE bookmark_id = #{bookmark.bookmark_id}\"\n bookmark.delete\n\n puts 'Bookmark deleted successfully'\n end", "def unarchive_bookmark(bookmark_id)\n perform_post_with_object('/api/1.1/bookmarks/unarchive', {bookmark_id: bookmark_id}, Instapaper::Bookmark)\n end", "def bookmarked?(user_id)\n !Bookmark.where(story_id: self.id, user_id: user_id).empty?\n end", "def load_bookmarks\n $bookmarks = {}\n $bookcodes = []\n\n # check if bookmark file exists\n if FileTest.file?( $SETTINGS[:BOOKMARKS_FILE] )\n fp = File.new( $SETTINGS[:BOOKMARKS_FILE], 'rb' )\n str = fp.read(2**26)\n fp.close\n $bookmarks = JSON.parse( str )\n end\n\n for bcbz, dat in $bookmarks\n $bookcodes << dat[2]\n end\nend", "def bookmarks(bookmarks)\n bookmarks.each_with_object({}) do |b, bs|\n first_image = b.entry.entry_images.min_by(&:pocket_image_id)\n bs[b.id] = {\n id: b.id.to_s,\n title: b.entry.resolved_title,\n url: b.entry.url,\n status: b.status,\n addedAt: b.added_to_pocket_at.to_i,\n archivedAt: b.archived_at&.to_i,\n favorite: b.favorite,\n thumbnailUrl: determine_image_url(first_image),\n }\n end\n end", "def add(bookmark)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'bookmark', bookmark)\n\t\t\tclient.queue_service_action_call('bookmark', 'add', 'bool', kparams)\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn client.do_queue()\n\t\tend", "def test_get_by_bookmark_id\n\n validId = BookmarkReport.getById(1)\n\n assert_equal 1, validId.userId\n assert_equal 'something', validId.issue\n assert_equal 'report', validId.description\n\n invalidId = BookmarkReport.getById(0)\n\n assert_nil invalidId\n\n end", "def goto_bookmark key=nil\n unless key\n clear_last_line\n print 'Enter bookmark char (? to view): '\n key = get_char\n end\n if key == '?'\n view_bookmarks\n return\n end\n\n d = @bookmarks[key]\n if d\n change_dir d\n else\n perror \"#{key} not a bookmark. \"\n end\nend", "def delete_bookmark(name, bookmark_path, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = delete_bookmark_with_http_info(name, bookmark_path, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = delete_bookmark_with_http_info(name, bookmark_path, opts)\n else\n raise\n end\n return data\n end", "def ask_bookmark ch=nil\n unless ch\n ch = @window.getchar\n ch = ch.chr.upcase rescue nil\n return unless ch\n end\n str = $bookmarks[ch.to_sym]\n if str\n display_text str\n # set focus to that in the left list\n set_focus_on str\n else\n $message.value = \"No bookmark for #{ch}. Use m to create.\"\n ## No bookmark, jumping to first char \n listb = @form.by_name[\"mylist\"]; \n listb.set_selection_for_char ch\n end\nend", "def is_bookmarked user\n Bookmark.find_by(user_id: user_id, post_id: id)\n end", "def test_add_pvt_bookmark\n test_url = 'http://www.avilayparekh.com/'\n num_lns0 = count_links\n num_bms0 = count_bookmarks\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_lns0 + 1, count_links)\n assert_equal(num_bms0 + 1, count_bookmarks)\n assert_empty(get_link_title(test_url))\n assert_empty(exp_bm.name)\n delete_link(test_url)\n end", "def url_for_bookmark doc, options = {}\n require 'cgi'\n \n # This branch is the one executed for a search results index page \n if doc and doc[\"DocId\"]\n # IF doc exists and has this field\n Rails.logger.debug(\"Route - returning doc #{doc['DocId']}\" )\n # One mechanism is to return the doc itself (Ruby can recognize that it is an object and create the appropriate url)\n # In that case, the url would be catalog/id\n # but here, we want to ensure we pass the DocId parameter and we are escaping the ID in the parameter \n # Additionally, we tried updating the doc id to be the escaped uri, but that did not work correctly\n # What we are doing here is passing the local name (which has no slashes, etc. that could throw either apache or ruby off)\n # and then utilizing the normal behavior for showing a document but passing in the parameter as well\n # Code on the solr document helper side knows to expect that parameter and utilize that for the solr document id if it exists\n # Not passing in a local name in the url would make the code expect this was some search query, and without a query it jsut\n # goes back to the front page\n id = doc[\"DocId\"]\n uri_sliced = id.split(\"/\")\n local_name = uri_sliced.last\n uri_escaped = CGI::escape(id)\n # This was there originally before but let's try it without this, this would be useful if we were passing back doc\n # instead of passing the parameter in the URL\n # doc[\"id\"] = local_name \n \"/bookmarks/\" + local_name + \"?DocId=\" + id\n else \n #Does what this code would do without our updates \n doc \n end\n \n \n end", "def set_my_bookmark\n @my_bookmark = MyBookmark.find(params[:id])\n end", "def get_child_bookmark parent_index, child_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if parent_index == ''\n raise 'parent index not specified'\n end\n \n if child_index == ''\n raise 'child index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + parent_index.to_s + '/bookmarks/' + child_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmark']\n \n \n rescue Exception=>e\n print e\n end\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def prev_next_needed(prev_doc, next_doc, prev_bookmark=nil, next_bookmark=nil)\n if (params[:controller] == 'bookmarks' || (prev_bookmark.present? || next_bookmark.present?) || (prev_doc.present? || next_doc.present?))\n return true\n end\n end", "def deletebookmark\n\t\t\t\tbookmark = Bookmark.find_by_id(params[:id])\n\t\t\t\tif bookmark.user_id == doorkeeper_token.resource_owner_id\n\t\t\t\t\tbookmark.destroy\n\t\t\t\t\thead :ok\n\t\t\t\telse\n\t\t\t\t\trender :status => 504\n\t\t\t\tend\n\t\t\tend", "def get_document_bookmarks(request)\n data, _status_code, _headers = get_document_bookmarks_with_http_info(request)\n request_token if _status_code == 401\n data\n end", "def strip_bookmark_to_json(bookmark)\n\t\t\t\tformatted_tags = []\n\t\t\t\tbookmark.tags.each do |tag|\n\t\t\t\t formatted_tags << tag.tagname\n\t\t\t\tend\t\t\t \t\t\t\t\n\t\t\t\tbookmark_json = {:id => bookmark.id, :url => bookmark.url.url, :title => bookmark.title, :description => bookmark.description, :updated_at => bookmark.updated_at.to_i, :tags => formatted_tags}\n\n\t\t\t\tif bookmark.group_id\n\t\t\t\t\tbookmark_json[:username] = bookmark.user.name\n\t\t\t\t\tbookmark_json[:groupname] = bookmark.group.name\t\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tif bookmark.user_id == doorkeeper_token.resource_owner_id\n\t\t\t\t\tbookmark_json[:my_bookmark] = true\n\t\t\t\telse\n\t\t\t\t\tbookmark_json[:my_bookmark] = false\n\t\t\t\tend\t\t\t\n\t\t\t\tbookmark_json\n\t\t\tend", "def feed_link_should_not_be_highlighted(feed)\n within '#sidebar #folders-list' do\n expect(page).not_to have_css \"a[data-feed-id='#{feed.id}'].highlighted-link\"\n end\nend", "def is_new?\n !self.new_bookmark.nil?\n end", "def print_bookmark(bookmark)\n puts Paint[(bookmark[:title]).to_s, :bright]\n puts \" #{bookmark[:description]}\" if bookmark[:description]\n puts \" #{bookmark[:url]}\"\n\n return if bookmark[:tags].nil? || bookmark[:tags].empty?\n\n print ' '\n bookmark[:tags].each do |tag|\n print Paint[\"##{tag[:name]}\", tag[:color]]\n print ' '\n end\n puts ''\n end", "def bookmark( *names, **options )\n\t\traise \"expected at least one bookmark name\" if names.empty?\n\n\t\tself.server.run( :bookmark, *names, **options )\n\t\treturn true\n\tend", "def destroy\n\t\tif params[:owner].present? && params[:post].present?\n\t\t\t@bookmark = Bookmark.where(:owner => params[:owner], :post => params[:post])\n\t\telsif params[:id].present?\n\t\t\t@bookmark = Bookmark.where(:id => params[:id])\n\t\tend\n\n\t\[email protected] do |b|\n\t\t\tb.destroy\n\t\tend\n\n\t\trender :text => \"Nothing\"\n\tend", "def set_bookmark\n\t\t@bookmark = Bookmark.find(params[:id])\n\tend", "def bookmark_link(options,no_text=false)\n case options[:site]\n when :delicious\n href = \"http://del.icio.us/post?url=#{options[:page_url]}&title=#{URI.encode(options[:page_title])}\"\n when :google\n href = \"http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=#{options[:page_url]}&title=#{URI.encode(options[:page_title])}\"\n when :reddit\n href = \"http://reddit.com/submit?url=#{options[:page_url]}&title=#{URI.encode(options[:page_title])}\"\n when :digg\n href = \"http://digg.com/submit?phase=2&url=#{options[:page_url]}&title=#{URI.encode(options[:page_title])}\"\n when :yahoo\n href = \"http://myweb2.search.yahoo.com/myresults/bookmarklet?u=#{options[:page_url]}&t=#{URI.encode(options[:page_title])}\"\n when :stumbleupon\n href= \"http://www.stumbleupon.com/refer.php?url=#{options[:page_url]}&title=#{URI.encode(options[:page_title])}\"\n end\n script = \"window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;\"\n # script = \"link_open_window(this.href)\"\n link_text = \"<span class='bookmark_link_text'>#{image_tag((options[:site].to_s + \".png\"), :alt => options[:link_title])}&nbsp;#{options[:site].to_s.capitalize unless no_text}</span>\"\n link_to(link_text, href, {:onclick => script, :title => options[:link_title], :class => \"site_bookmark_link\"})\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end", "def test_add_new_bookmark\n test_url = 'http://gigaom.com'\n title = 'GigaOM'\n num_lns0 = count_links\n tot_bms0 = count_bookmarks\n num_bms0 = count_bookmarks(@bs.user_id)\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_lns0 + 1, count_links)\n assert_equal(tot_bms0 + 1, count_bookmarks)\n assert_equal(num_bms0 + 1, count_bookmarks(@bs.user_id))\n assert_equal(get_link_title(test_url), exp_bm.name)\n delete_link(test_url)\n end", "def destroy\n @bookmarks =\n if params[:bookmarks]\n permit_bookmarks[:bookmarks]\n else\n [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]\n end\n\n success = @bookmarks.all? do |bookmark|\n bookmark = current_or_guest_user.bookmarks.find_by(bookmark)\n bookmark && bookmark.delete && bookmark.destroyed?\n end\n\n if success\n if request.xhr?\n render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } })\n else\n redirect_back fallback_location: bookmarks_path, notice: I18n.t('blacklight.bookmarks.remove.success')\n end\n elsif request.xhr?\n head :internal_server_error # ajaxy request needs no redirect and should not have flash set\n else\n redirect_back fallback_location: bookmarks_path, flash: { error: I18n.t('blacklight.bookmarks.remove.failure') }\n end\n end", "def test_add_bookmark\n test_url = 'http://www.gridgain.com/'\n num_lns0 = count_links\n num_bms0 = count_bookmarks\n act_bm = @bs.add_or_get_bookmark(test_url)\n exp_bm = get_bookmark(@bs.user_id, test_url)\n assert(exp_bm === act_bm)\n assert_equal(num_bms0 + 1, count_bookmarks)\n assert_equal(num_lns0, count_links)\n assert(get_link_title(test_url), exp_bm.name)\n delete_bookmark(@bs.user_id, test_url)\n end", "def not_found; end", "def initialize(bookmark)\n self.url = bookmark.url\n self.title = bookmark.title\n self.description = bookmark.preview_text\n self.date_added = bookmark.date_added\n self.tags = []\n self\n end", "def add(opts={})\r\n Rakuten::Request.get(\"https://app.rakuten.co.jp/services/api/FavoriteBookmark/Add/20120627\", Rakuten::Api.merge(opts))\r\n end", "def bookmarked_by_user?(user)\n bookmark_object(user).present?\n end", "def create\n \n #cross-site scripting fix\n headers['Access-Control-Allow-Origin'] = '*'\n headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-Prototype-Version'\n \n u = User.find(params[:id])\n b = Bookmark.where(url: params[:url], user_id: u).first\n c = Category.find(params[:category])\n \n #ensure user does not submit a link more than once\n if b == nil\n Bookmark.create(url: params[:url], title: params[:title], user: u, category: c); \n end\n\n render :nothing => true\n end", "def bookmark_params\n params.permit(:bookmark, :post_id)\n end", "def doesnt_exist\n\t\tputs \"That item doesn't exist.\"\n\t\tget_item\n\tend", "def create_bookmark\n ch = get_single \"Enter A to Z or 0-9 for bookmark: \"\n #ch = get_char\n if ch =~ /^[0-9A-Z]$/\n #$bookmarks[ch] = \"#{Dir.pwd}:#{$cursor}\"\n # \n # The significance of putting a : and not a / is that with a \n # : the dir will be opened with cursor on same object it was on, and not\n # go into the dir. e.g, If bookmark is created with cursor on a dir, we don't want\n # it to go into the dir.\n $bookmarks[ch] = \"#{Dir.pwd}:#{$view[$cursor]}\"\n $modified = true\n else\n perror \"Bookmark must be upper-case character or number.\"\n end\nend", "def atom_feed_for(bookmarks, title, feed_uri, user=nil)\n feed = Atom::Feed.new\n feed.title = title\n most_recent_bookmark = bookmarks.max do |b1,b2|\n b1.timestamp <=> b2.timestamp\n end\n feed.updated = most_recent_bookmark.timestamp\n\n # Link this feed to itself\n self_link = feed.links.new\n self_link['rel'] = 'self'\n self_link['href'] = feed_uri + \".atom\"\n\n # If this list is a list of bookmarks from a single user, that user is\n # the author of the feed.\n if user\n user_to_atom_author(user, feed)\n end\n\n # Turn each bookmark in the list into an entry in the feed.\n bookmarks.each do |bookmark|\n entry = feed.entries.new\n entry.title = bookmark.short_description\n entry.content = bookmark.long_description\n\n # In a real application, a bookmark would have a separate\n # \"modification date\" field which was not under the control of\n # the user. This would also make the Last-Modified calculations\n # more accurate.\n entry.updated = bookmark.timestamp \n\n # First, link this Atom entry to the external URI that the\n # bookmark tracks.\n external_uri = entry.links.new\n external_uri['href'] = bookmark.uri\n\n # Now we give some connectedness to this service. Link this Atom\n # entry to this service's resource for this bookmark.\n bookmark_resource = entry.links.new\n bookmark_resource['rel'] = \"self\"\n bookmark_resource['href'] = bookmark_url(bookmark.user.name, \n bookmark.uri_hash) + \".atom\"\n bookmark_resource['type'] = \"application/xml+atom\"\n\n # Then link this entry to the list of users who've bookmarked\n # this URI.\n other_users = entry.links.new\n other_users['rel'] = \"related\"\n other_users['href'] = uri_url(bookmark.uri_hash) + \".atom\"\n other_users['type'] = \"application/xml+atom\"\n\n # Turn this entry's user into the \"author\" of this entry, unless\n # we already specified a user as the \"author\" of the entire\n # feed.\n unless user\n user_to_atom_author(bookmark.user, entry) \n end\n\n # For each of this bookmark's tags...\n bookmark.tags.each do |tag|\n # ...represent the tag as an Atom category.\n category = entry.categories.new\n category['term'] = tag\n category['scheme'] = user_url(bookmark.user.name) + \"/tags\"\n\n # Link to this user's other bookmarks tagged using this tag.\n tag_uri = entry.links.new\n tag_uri['href'] = tag_url(bookmark.user.name, tag.name) + \".atom\"\n tag_uri['rel'] = 'related'\n tag_uri['type'] = \"application/xml+atom\"\n\n # Also link to all bookmarks tagged with this tag.\n recent_tag_uri = entry.links.new\n recent_tag_uri['href'] = recent_url(tag.name) + \".atom\"\n recent_tag_uri['rel'] = 'related'\n recent_tag_uri['type'] = \"application/xml+atom\"\n end\n end \n return feed.to_xml\n end", "def resolve_numeric_key key\n d = @bookmarks[key]\n if d\n change_dir d\n return\n end\n\n set_bookmark key\n message \"Created bookmark #{key}.\"\nend", "def list_bookmarks(user_id)\n url = \"#{@@request_url}/User.listBookmarks?appid=#{@@appid}&ID=#{user_id}\"\n end" ]
[ "0.6512553", "0.64234", "0.61317307", "0.6131231", "0.6131231", "0.6053968", "0.59458023", "0.5931119", "0.5865685", "0.5798133", "0.5788846", "0.5774081", "0.5768561", "0.5694397", "0.56336737", "0.5632745", "0.5632575", "0.5603299", "0.5556167", "0.55304044", "0.5520814", "0.55104065", "0.54969186", "0.547476", "0.5463129", "0.5453814", "0.5444813", "0.5431047", "0.5405085", "0.5385716", "0.5347917", "0.53455573", "0.53091866", "0.5296151", "0.52508664", "0.5245835", "0.5218823", "0.52060884", "0.5197753", "0.5176786", "0.5168104", "0.5158066", "0.51291156", "0.5122115", "0.5109121", "0.5096132", "0.5096132", "0.50942093", "0.507946", "0.5056956", "0.5054126", "0.5033639", "0.50296485", "0.50178486", "0.50079364", "0.50002104", "0.498206", "0.49774718", "0.4973636", "0.49711248", "0.4931846", "0.49238536", "0.49229988", "0.49229988", "0.49229988", "0.49229988", "0.49229988", "0.49229988", "0.49068275", "0.4903198", "0.48759606", "0.4871332", "0.48702145", "0.48669556", "0.48520806", "0.4849585", "0.48388535", "0.4834693", "0.48012552", "0.47993812", "0.47993812", "0.47993812", "0.47993812", "0.47993812", "0.47993812", "0.47993812", "0.47957954", "0.47816834", "0.47730792", "0.47448784", "0.47396398", "0.47365144", "0.4731192", "0.4730073", "0.47292367", "0.4719286", "0.47117674", "0.47040766", "0.47012362", "0.4698839" ]
0.67313635
0
Use callbacks to share common setup or constraints between actions.
def set_tipo_usuario @tipo_usuario = TipoUsuario.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 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 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(&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 setup\n #implement in subclass;\n end", "def after_set_callback; 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 setup(easy)\n super\n easy.customrequest = @verb\n end", "def around_hooks; 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 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 shared_action(name, &block)\n @controller.shared_actions[name] = 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", "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.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.53314966", "0.53114754", "0.52984965", "0.52977055", "0.5296272", "0.5260649", "0.5245076", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.5235081", "0.52321917", "0.5228592", "0.5220735", "0.52198535", "0.52139324", "0.5208539", "0.5206585", "0.5178542", "0.5175199", "0.5173538", "0.5167041", "0.51614195", "0.51577675", "0.5153909", "0.51528823", "0.5152225", "0.51429904", "0.5141399", "0.51345575", "0.51145", "0.5114052", "0.5114052", "0.5110216", "0.5108656", "0.50935394", "0.5089196", "0.5081936", "0.5079627", "0.50675833", "0.5056105", "0.5053687", "0.5050475", "0.5050475", "0.503471", "0.5028311", "0.501982", "0.50157547", "0.5013552", "0.50014806", "0.50011593", "0.49976763", "0.4990292", "0.4990292", "0.49882022", "0.4981269", "0.49792367", "0.49766538", "0.4967978", "0.49667212", "0.4958987", "0.49572337", "0.49550423", "0.4954479", "0.4952353", "0.494726", "0.4944055", "0.4935437", "0.4931248", "0.49283475", "0.49281213", "0.49268973", "0.4921738", "0.49204507", "0.4918924", "0.49182287", "0.4916538", "0.49158585", "0.49156788" ]
0.0
-1
Only allow a trusted parameter "white list" through.
def tipo_usuario_params params.require(:tipo_usuario).permit(:nombre) 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 /releases GET /releases.json
def index #@releases = Release.all @releases = Release.where(cashier_id: current_user.cashier.id, view: true) # respond_to do |format| # format.html # index.html.erb # format.json { render json: @releases } # end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @releases = @environment.releases.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @releases }\n end\n end", "def get(*args)\n arguments(args, required: [:owner, :repo, :id]).params\n\n get_request(\"/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}\" , arguments.params)\n end", "def index\n @releases = Release.all\n end", "def index\n @releases = Release.all\n end", "def show\n @release = @environment.releases.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @release }\n end\n end", "def releases(country = nil)\n Birdman::Requester.get(\"movies/#{id}/releases/#{country}\")\n end", "def index\n @releases = Release.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @releases.to_json(:except => [:user_id]) }\n end\n end", "def list_releases(workspace_id)\n # check and reauthenticate\n self.isTokenExpired()\n\n results = []\n url = @api_url + \"/api/workspaces/#{workspace_id}/releases\"\n headers = {:accept => :json, :authorization => \"bearer #{@access_token}\"}\n\n RestClient.proxy = @proxy\n\n begin\n r = RestClient.get url, headers\n rescue RestClient::ExceptionWithResponse => e\n puts e.response\n end\n\n releases = JSON.parse(r.body)['data']\n #release_count = JSON.parse(r.body)['TotalResults']\n\n #puts \"releases dump is #{JSON.pretty_generate(releases)}\\nrelease count is #{release_count}\"\n\n releases.each do |release|\n results.push(release)\n end\n return results\n end", "def release(project_id, release_id, options = {})\n get \"projects/#{project_id}/releases/#{release_id}\", options\n end", "def get_releases(artist_id, options={})\n api_response = @api_client.make_api_request(:GET, \"artist/releases\", {:artistId => artist_id}, options)\n @api_client.release_digestor.list_from_xml(api_response.content.releases)\n end", "def new_releases\n api_call(\"https://api.spotify.com/\",\"/v1/browse/new-releases\")\n end", "def fetch_releases\n require \"open-uri\"\n\n open(RELEASE_URL) { |f| f.read.scan RELEASE_REGEXP }\n end", "def index\n @client_releases = ClientRelease.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @client_releases }\n end\n end", "def releases_in_group(release_group_id, options = {})\n get \"release_groups/#{release_group_id}/releases\", options\n end", "def releases\n repo.releases(changelog.changes)\n end", "def get_release(release_id)\n query_and_build \"releases/#{release_id}\"\n end", "def index\n respond_with releases\n end", "def show\n @release = Release.find(params[:id])\n @total_downloads = 0\n @release.versions.each do |v|\n @total_downloads += v.downloads\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @release }\n end\n end", "def releases\n self.class.releases\n end", "def releases\n self.class.releases\n end", "def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend", "def display_releases(releases)\n url = \"\"\n releases.each do |release|\n puts \"\\n\\n#{release.name} by #{release.artist} on #{release.label}\\n\"\n release.tracks.each_with_index do |track, index|\n puts \"-#{track.name}\"\n url = track.url\n end\n end\n end", "def related_releases\n Rails.cache.fetch(\"releases/release-#{id}\", :expires_in => 1.hour) do\n real_releases.all(:order => 'date DESC', :limit => 15)\n end\n end", "def index\n params[:page] ||= 1\n \n @releases = Release.search_archive(params[:search], params[:page])\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @releases }\n end\n end", "def index\n @press_releases = PressRelease.all\n end", "def get(*args)\n params = arguments(args, required: [:owner, :repo, :id]).params\n\n get_request(\"/repos/#{owner}/#{repo}/releases/assets/#{id}\" , params)\n end", "def get_artists_releases(artist_id, pagination={})\n query_and_build \"artists/#{artist_id}/releases\", pagination\n end", "def list_all_aos_versions(args = {}) \n get(\"/aosversions.json/all\", args)\nend", "def index\n @object_releases = ObjectRelease.all\n end", "def get_release_info(author, repository, options)\n url = Kernel.format(\n 'https://api.github.com/repos/%{author}/%{repository}/releases/%{tag}%{release}',\n author: author,\n repository: repository,\n tag: (options[:is_tag]) ? 'tags/' : '',\n release: options[:release],\n )\n\n release_info_json = fetch_from_url(\n url,\n options[:username],\n options[:password],\n options[:use_auth],\n options[:use_oauth],\n )\n\n return nil unless release_info_json\n\n # Read in release info from JSON file\n\n Puppet.debug('Parsing release info')\n\n # noinspection RubyResolve\n PSON.load(release_info_json)\nend", "def get_release(project)\n info = get_github_api(project, \"releases\")\n release = 'master'\n if info.length > 0\n unpublishedDraftLimit = 5\n x = 0\n release = info[x]['tag_name']\n # Unpublished drafts need to be skipped.\n while (unpublishedDraftLimit > x) && info[x]['draft']\n release = info[x]['tag_name']\n x += 1\n end\n end\n release\n end", "def map_releases\n releases.sort! {|x,y| x[1] <=> y[1] }\n .map { |release|\n {\n \"version\" => release[1],\n \"status\" => \"active\",\n \"description_html\" => \"<p>#{release[0]}</p>\",\n \"description_markdown\" => release[0],\n \"providers\" => [\n {\"name\" => \"virtualbox\", \"url\" => \"#{RELEASE_URL}#{release[0]}\"}\n ]\n }\n }\n end", "def fetch_versions\n http_get(\"#{host}/#{Configuration.versions_file}\").body\n end", "def show\n @os_release = OsRelease.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @os_release }\n end\n end", "def latest(*args)\n arguments(args, required: [:owner, :repo]).params\n\n get_request(\"repos/#{arguments.owner}/#{arguments.repo}/releases/latest\", arguments.params)\n end", "def get_release_notes\n path = '/v3/release-logs.json'\n\n header = {\n 'Content-Type' => 'application/json',\n 'User-Agent' => Config.user_agent\n }\n request = Net::HTTP::Get.new(path, header)\n handle_response(@api_client.request(request), 'get_release_notes')\n end", "def show\n @release = Release.find(params[:id])\n\n # respond_to do |format|\n # format.html show.html.erb\n # format.json { render json: @release }\n # end\n end", "def new_dvd_releases\n return @badfruit.parse_movies_array(JSON.parse(@badfruit.get_lists_action(\"new_releases\")))\n end", "def get_url\n heroku_app = options[:heroku_app]\n uriString = \"https://api.heroku.com/apps/#{heroku_app}/releases\"\n accept = '\"Accept: application/vnd.heroku+json; version=3\"'\n order = '\"Range: version ..; order=desc, max=10;\"'\n uri = URI(uriString)\n puts \"URI: #{uri}\"\n\n res = `curl -n --silent #{uriString} -H #{accept} -H #{order}`\n\n result = JSON.parse(res)\n\n id = nil\n ver = nil\n hash = nil\n result.each { |i|\n puts i\n if !id && i[\"slug\"] && i[\"slug\"][\"id\"] && i[\"slug\"][\"id\"] != \"\"\n id = i[\"slug\"][\"id\"]\n ver = i[\"version\"]\n hash = i[\"description\"]\n end\n }\n\n #puts id if id\n if id != nil\n\n uriStringSlug = \"https://api.heroku.com/apps/#{heroku_app}/slugs/#{id}\"\n uriSlug = URI(uriStringSlug)\n\n resSlug = `curl -n --silent #{uriStringSlug} -H #{accept}`\n resultSlug = JSON.parse(resSlug)\n p \"--------------------------------\"\n p \"Version: #{ver}\"\n p \"Hash: #{hash}\"\n p resultSlug[\"blob\"][\"url\"]\n p \"--------------------------------\"\n end\n end", "def current_dvd_releases\n return @badfruit.parse_movies_array(JSON.parse(@badfruit.get_lists_action(\"current_releases\")))\n end", "def get_latest_release(project, bin)\n api_url = \"https://api.github.com/repos/#{project}/releases/latest\"\n data = URI.parse(api_url).read\n obj = JSON.parse(data)\n version = obj[\"name\"]\n sha_url = \"https://github.com/#{project}/releases/download/#{version}/#{bin}.sha256\"\n sha = URI.parse(sha_url).read\n url = \"https://github.com/#{project}/releases/download/#{version}/#{bin}\"\n sha256 = sha.split(\" \").first\n\n return url, sha256, version\nend", "def release_url(api_url, title)\n # \"subject\": {\n # \"title\": \"v1.4.4\",\n # \"url\": \"https://api.github.com/repos/typed-ember/ember-cli-typescript/releases/13191777\",\n # \"latest_comment_url\": \"https://api.github.com/repos/typed-ember/ember-cli-typescript/releases/13191777\",\n # \"type\": \"Release\"\n # },\n api_index = api_url.index(\"api\")\n repos_index = api_url.index(\"repos\")\n releases_index = api_url.index(\"releases\")\n\n # https://github.com/typed-ember/ember-cli-typescript/releases/tag/v1.4.4\n html_url = api_url[0..api_index - 1] +\n api_url[api_index + \"api.\".length..repos_index - 1] +\n api_url[repos_index + \"repos/\".length..releases_index + \"releases\".length] +\n \"tag/#{title}\"\n html_url\n end", "def index\n response = VersionResponse.new( BUILD_VERSION )\n render json: response, :status => 200\n end", "def index\n @release_items = ReleaseItem.all\n end", "def show\n @environment = @project.environments.find_by_slug!(params[:id])\n @releases = @environment.releases\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @environment }\n end\n end", "def get_last_release\n r = api_get(\"/releases\")\n\n return r[0]['tag_name']\nend", "def get_labels_releases(label_id, pagination={})\n query_and_build \"labels/#{label_id}/releases\", pagination\n end", "def campaign_release(id)\n rest.get(:releasesms, id: id)['data']\n end", "def create\n @release = @environment.releases.new(params[:release])\n\n respond_to do |format|\n if @release.save\n format.html { redirect_to @release, notice: 'Release was successfully created.' }\n format.json { render json: @release, status: :created, location: @release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end", "def get(*args)\n params = args.extract_options!\n @connection.get do |req|\n req.url versioned_path(args), params\n end\n end", "def new\n @release = Release.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end", "def show\n @client_release = ClientRelease.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_release }\n end\n end", "def release\n case new_resource.version\n when 'latest'\n require 'octokit'\n Octokit.releases(repo).first[:tag_name]\n else\n \"v#{new_resource.version}\"\n end\n end", "def get_aos_version_by_name(args = {}) \n get(\"/aosversions.json/version/#{args[:aosVersionName]}\", args)\nend", "def show\n @persons_release = PersonsRelease.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @persons_release }\n end\n end", "def fetch_releases(name)\n releases = {}\n\n sources.each do |source|\n source.fetch(name).each do |dependency|\n releases[dependency.version] ||= dependency\n end\n end\n\n return releases.values\n end", "def show\n render json: JSONAPI::Serializer.serialize(@repo)\n end", "def get_master_release_versions(master_release_id, pagination={})\n query_and_build \"masters/#{master_release_id}/versions\", pagination\n end", "def destroy\n @release = @environment.releases.find(params[:id])\n @release.destroy\n\n respond_to do |format|\n format.html { redirect_to releases_url }\n format.json { head :no_content }\n end\n end", "def get_aos_version(args = {}) \n get(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def index\n @projects = ProjectDecorator.all\n @releases = ReleaseDecorator.recent\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @projects }\n end\n end", "def releases\n all(QTest::Release, project: @id)\n end", "def release\n release_data = EventDate.data_for_release(params[:date_id])\n render json: release_data.to_json\n end", "def get_versions\r\n versions_nodes = BankNodestructure.version_gather(params[:subject], params[:grade])\r\n render json: versions_nodes.to_json\r\n end", "def release_info\n @release_info ||= @connection.get(RELEASE_INFO_PATH)['release']\n end", "def index\n @api_versions = ApiVersion.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @api_versions }\n end\n end", "def release\n configs = store(:get, 'configs').to_s.gsub(\"\\n\", \" \")\n \n # TODO: if error, user need to deploy code first (nothing to deploy) => use a special exit code \n # when code is not pushed or only deploy if app has a correct build\n version = @api.release(@name, configs).to_s.chomp.gsub(\"\\n\", \" \")\n backend = @api.run(@name, :web, version).to_s.chomp.gsub(\"\\n\", \" \")\n @api.route @name, backend\n return version\n end", "def listversions(project=self.project)\n get('listversions.json', project: project)['versions']\n end", "def index\n @api_versions = ApiVersion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @api_versions }\n end\n end", "def new\n @commit = params[:commit]\n @release = @environment.releases.new(\n commit0: @environment.last_commit,\n commit1: @commit)\n if @release.can_read_commits?\n @release.load_commits!\n @release.load_tickets!\n @release.build_changes_from_commits\n end\n if @release.changes.none?\n render :template => \"releases/new_pick_commit\"\n else\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end\n end", "def to_check\n @releases = Release.all\n end", "def show\n @release = Release.find(params[:id])\n \n # send to release page if not archived\n redirect_to(:controller => 'releases', :action => 'show', :id => @release.id) and return if [email protected]\n \n # populate release fixes from mantis\n if @release.mantis_project_version_id\n @issues = Issue.fixed(@release.mantis_project_id, @release.mantis_project_version_name)\n end\n @version_released = @release.released?\n @version_release_date = Time.at(@release.release_date).strftime(\"%Y-%m-%d\") if @version_released && @release.release_date\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @release }\n end\n end", "def versions(module_name)\n path = \"/v3/modules/#{module_name.tr('/','-')}\"\n response = @conn.get(path)\n\n if response.status != 200\n raise R10K::Error.new(\"Request to Puppet Forge '#{path}' failed. Status: #{response.status}\")\n end\n\n releases = response.body['releases'].reject { |r| r['deleted_at'] }\n releases = releases.map do |version_info|\n version_info['version']\n end\n releases.reverse\n end", "def index\n @versions = Version.all\n end", "def info\n validate_arguments!\n\n remotes = self.class.heroku_remotes\n\n # trigger 'No app specified' message\n remotes.push ['--app', app] if remotes.empty? or options[:app]\n\n output = {}\n remotes.map do |remote|\n Thread.new(remote) do |remote, app|\n begin\n # capture stdout\n Thread.current[:output] = []\n\n release = api.get_releases(app).body.sort_by do |release|\n release[\"name\"][1..-1].to_i\n end.last[\"name\"]\n\n # display_header(\"#{app}\")\n puts \"##### #{app} #####\\n\"\n\n # this is simply copied from 3.9.6/lib/heroku/command/releases.rb\n # https://github.com/heroku/heroku/blob/master/lib/heroku/command/releases.rb\n\n # ---------\n release_data = api.get_release(app, release).body\n\n data = {\n 'By' => release_data['user'],\n 'Change' => release_data['descr'],\n 'When' => time_ago(release_data[\"created_at\"])\n }\n\n unless release_data['addons'].empty?\n data['Addons'] = release_data['addons']\n end\n\n\n styled_header(\"Release #{release}\")\n styled_hash(data)\n\n display\n\n styled_header(\"#{release} Config Vars\")\n unless release_data['env'].empty?\n if options[:shell]\n release_data['env'].keys.sort.each do |key|\n display(\"#{key}=#{release_data['env'][key]}\")\n end\n else\n styled_hash(release_data['env'])\n end\n else\n display(\"#{release} has no config vars.\")\n end\n # ---------\n\n # capture stdout\n output[remote] = Thread.current[:output].join\n rescue\n output[remote] = \"Something went wrong fetching releases for #{app}.\"\n end\n end\n end.map(&:join)\n\n output.sort.each do |remote, output|\n puts output\n puts\n end\n end", "def list\n movies = Movie.order(release_date: :desc)\n render :json => movies.to_json\n\tend", "def releases\n Release.branch(self)\n end", "def info\n release = args.shift.downcase.strip rescue nil\n raise(CommandFailed, \"Specify a release\") unless release\n\n release = heroku.release(app, release)\n\n display \"=== Release #{release['name']}\"\n display_info(\"Change\", release[\"descr\"])\n display_info(\"By\", release[\"user\"])\n display_info(\"When\", time_ago(Time.now.to_i - Time.parse(release[\"created_at\"]).to_i))\n display_info(\"Addons\", release[\"addons\"].join(\", \"))\n display_vars(release[\"env\"])\n end", "def show\n @version = Version.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @version }\n end\n end", "def list_all_aos_version_boxes(args = {}) \n get(\"/aosversions.json/aosversionbox\", args)\nend", "def get_versions(project_id_or_key)\n get(\"projects/#{project_id_or_key}/versions\")\n end", "def version_info\n path = File.join(SERVER_ROOT, 'public', 'version_info.json')\n JSON.load File.read(path)\nend", "def all_builds_request_model(session, app_id)\n path = \"#{FABRIC_API_PATH}#{org_app_endpoint(session, app_id)}/beta_distribution/releases\"\n model = Fabricio::Networking::RequestModel.new do |config|\n config.type = :GET\n config.base_url = FABRIC_API_URL\n config.api_path = path\n end\n model\n end", "def release\n _init\n\n @release = Release.find_by_name(params[:release]) if params[:release]\n @release = Release.actived.first unless @release\n\n render :template => 'sprint/release', :layout => 'release'\n end", "def repositories\n response = self.class.get('/repositories').body\n JSON.parse(response)\n end", "def data\n return @data if @data\n\n remote = fetch(ref: RELEASES_REF, path: RELEASES_PATH)\n @sha = remote.sha\n\n content = parse(remote.content)\n raise self::ValidationError unless valid?(content)\n\n unsorted = content.filter_map do |release|\n version_string = release['version']\n release_date = release['date']\n\n next if version_string < self::ENABLED_MIN\n\n if version_string < self::SEMVER_MIN\n version_fix = version_string.gsub(/-p(\\d+)/, '.\\1')\n version_comparable = Gem::Version.new(version_fix)\n else\n version_comparable = Gem::Version.new(version_string)\n end\n\n Release.new(version_string, version_comparable, release_date)\n end\n\n @data ||= unsorted.sort_by(&:comparable).reverse\n end", "def index\n @package_versions = PackageVersion.all\n end", "def index\n @release_mains = ReleaseMain.all\n end", "def list_by_publisher\n @publisher = params[:publisher].gsub(\"-\",\" \")\n \n if (@publisher == \"all\")\n @releases = Release.find(:all, :order => \"release_date DESC\")\n else\n @releases = Release.find(:all, :conditions => [\"publisher = ?\", @publisher], :order => \"release_date DESC\")\n end\n \n respond_to do |format| \n format.html {render :template => \"releases/index\"}\n format.xml {render :template => \"releases/index\", :layout => false} \n end\n end", "def new\n @os_release = OsRelease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @os_release }\n end\n end", "def show\n repo = assets_repo\n @v_asset = repo.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @v_asset }\n end\n end", "def show\n @event = Event.find(params[:event_id])\n @releases = Release.find(:all)\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @event }\n end\n end", "def show\n @discogs_releases = {}\n @artist_name = get_artist_name\n @discogs_releases = get_discogs_releases_paginated(@artist_name) unless @artist_name.blank?\n\n respond_to do |format|\n format.html # show.html.erb\n #format.xml { render :xml => @artist }\n format.js\n end\n end", "def list_repositories\n JSON.parse(request(:get, ''))\n end", "def index\n @file_versions = FileVersion.all\n\n render json: @file_versions\n end", "def create_release(node)\n if node.attributes['id'] and @releases[node.attributes['id']]\n release = @releases[node.attributes['id']]\n else\n release = @factory.new_release\n @releases[node.attributes['id']] = release\n end\n \n # Read all defined data fields\n release.id = node.attributes['id']\n release.title = node.elements['title'].text if node.elements['title']\n release.asin = node.elements['asin'].text if node.elements['asin']\n release.artist = create_artist(node.elements['artist']) if node.elements['artist']\n \n # Read the types\n node.attributes['type'].split(' ').each {|type|\n release.types << Utils.add_namespace(type)\n } if node.attributes['type']\n \n # Read the text representation information.\n if text_representation = node.elements['text-representation']\n release.text_language = text_representation.attributes['language']\n release.text_script = text_representation.attributes['script']\n end\n \n # Read the track list\n read_track_list(node.elements['track-list'], release.tracks) {|track|\n track.artist = release.artist unless track.artist\n track.releases << release\n }\n \n # Read the release event list\n read_release_event_list(node.elements['release-event-list'], release.release_events)\n \n # Read the disc list\n read_disc_list(node.elements['disc-list'], release.discs)\n \n # Read the relation list\n if node.elements['relation-list']\n node.elements.each('relation-list') {|relation_node|\n read_relation_list(relation_node) {|relation|\n release.add_relation relation\n }\n }\n end\n \n # Read the tag list\n read_tag_list(node.elements['tag-list'], release.tags)\n \n return release\n end", "def timeline_releases\n real_releases.order('date DESC').limit(5)\n end", "def index\n repos = CodeburnerUtil.get_repos\n\n render(:json => { \"count\": repos.length, \"results\": repos })\n end", "def get_repo_details\n user = User.find_by(uuid: params[:uuid])\n client = Octokit::Client.new(:access_token => user.password)\n repo_map = {}\n client.repository(:user => user.gh_username, :repo => params[:repo_name]).each { |detail|\n repo_map[detail[0]] = detail[1]\n }\n repo_map['languages'] = client.languages(:user => user.gh_username, :repo => params[:repo_name]).map{ |langArray|\n langArray[0]\n }\n render :json => repo_map\n end", "def index\n @admin_versions = Admin::Version.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_versions }\n end\n end" ]
[ "0.782001", "0.757797", "0.73581696", "0.73581696", "0.72281694", "0.720763", "0.7137632", "0.7023981", "0.7014643", "0.6992209", "0.69265324", "0.6885234", "0.6854652", "0.67636126", "0.67317486", "0.6728395", "0.67004687", "0.66961014", "0.66916806", "0.66916806", "0.6539912", "0.6513567", "0.6497695", "0.6489021", "0.6430932", "0.64303267", "0.6420889", "0.6396055", "0.6381555", "0.6315247", "0.63059354", "0.62594664", "0.624327", "0.6206815", "0.6204274", "0.619151", "0.61896044", "0.6154238", "0.6149055", "0.6083919", "0.6063446", "0.6060363", "0.60328835", "0.6007516", "0.60068816", "0.5996614", "0.5966065", "0.596053", "0.5958586", "0.59465975", "0.5914228", "0.5910439", "0.5907472", "0.59031796", "0.5852306", "0.5841889", "0.5838377", "0.58376884", "0.58263683", "0.5824519", "0.58168995", "0.579455", "0.5784361", "0.5783853", "0.57607454", "0.5736651", "0.57221407", "0.5714958", "0.57112527", "0.56966203", "0.56933504", "0.56859785", "0.56838906", "0.56782115", "0.5677607", "0.5677471", "0.56765854", "0.5674953", "0.5674538", "0.56686574", "0.5667277", "0.5664321", "0.56495786", "0.5647955", "0.5635564", "0.56351525", "0.5632963", "0.5625518", "0.56213576", "0.5587721", "0.55298704", "0.5525705", "0.5521444", "0.5516436", "0.5509765", "0.55087316", "0.54919195", "0.54747766", "0.5470315", "0.5450411" ]
0.6401996
27
GET /releases/1 GET /releases/1.json
def show @release = Release.find(params[:id]) # respond_to do |format| # format.html show.html.erb # format.json { render json: @release } # end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @releases = @environment.releases.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @releases }\n end\n end", "def show\n @release = @environment.releases.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @release }\n end\n end", "def get(*args)\n arguments(args, required: [:owner, :repo, :id]).params\n\n get_request(\"/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}\" , arguments.params)\n end", "def index\n @releases = Release.all\n end", "def index\n @releases = Release.all\n end", "def get_release(release_id)\n query_and_build \"releases/#{release_id}\"\n end", "def release(project_id, release_id, options = {})\n get \"projects/#{project_id}/releases/#{release_id}\", options\n end", "def index\n @releases = Release.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @releases.to_json(:except => [:user_id]) }\n end\n end", "def releases(country = nil)\n Birdman::Requester.get(\"movies/#{id}/releases/#{country}\")\n end", "def new_releases\n api_call(\"https://api.spotify.com/\",\"/v1/browse/new-releases\")\n end", "def show\n @release = Release.find(params[:id])\n @total_downloads = 0\n @release.versions.each do |v|\n @total_downloads += v.downloads\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @release }\n end\n end", "def index\n @client_releases = ClientRelease.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @client_releases }\n end\n end", "def get_release(project)\n info = get_github_api(project, \"releases\")\n release = 'master'\n if info.length > 0\n unpublishedDraftLimit = 5\n x = 0\n release = info[x]['tag_name']\n # Unpublished drafts need to be skipped.\n while (unpublishedDraftLimit > x) && info[x]['draft']\n release = info[x]['tag_name']\n x += 1\n end\n end\n release\n end", "def get_latest_release(project, bin)\n api_url = \"https://api.github.com/repos/#{project}/releases/latest\"\n data = URI.parse(api_url).read\n obj = JSON.parse(data)\n version = obj[\"name\"]\n sha_url = \"https://github.com/#{project}/releases/download/#{version}/#{bin}.sha256\"\n sha = URI.parse(sha_url).read\n url = \"https://github.com/#{project}/releases/download/#{version}/#{bin}\"\n sha256 = sha.split(\" \").first\n\n return url, sha256, version\nend", "def index\n response = VersionResponse.new( BUILD_VERSION )\n render json: response, :status => 200\n end", "def show\n @os_release = OsRelease.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @os_release }\n end\n end", "def list_releases(workspace_id)\n # check and reauthenticate\n self.isTokenExpired()\n\n results = []\n url = @api_url + \"/api/workspaces/#{workspace_id}/releases\"\n headers = {:accept => :json, :authorization => \"bearer #{@access_token}\"}\n\n RestClient.proxy = @proxy\n\n begin\n r = RestClient.get url, headers\n rescue RestClient::ExceptionWithResponse => e\n puts e.response\n end\n\n releases = JSON.parse(r.body)['data']\n #release_count = JSON.parse(r.body)['TotalResults']\n\n #puts \"releases dump is #{JSON.pretty_generate(releases)}\\nrelease count is #{release_count}\"\n\n releases.each do |release|\n results.push(release)\n end\n return results\n end", "def get(*args)\n params = arguments(args, required: [:owner, :repo, :id]).params\n\n get_request(\"/repos/#{owner}/#{repo}/releases/assets/#{id}\" , params)\n end", "def get_releases(artist_id, options={})\n api_response = @api_client.make_api_request(:GET, \"artist/releases\", {:artistId => artist_id}, options)\n @api_client.release_digestor.list_from_xml(api_response.content.releases)\n end", "def get_aos_version_by_name(args = {}) \n get(\"/aosversions.json/version/#{args[:aosVersionName]}\", args)\nend", "def fetch_releases\n require \"open-uri\"\n\n open(RELEASE_URL) { |f| f.read.scan RELEASE_REGEXP }\n end", "def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend", "def get_last_release\n r = api_get(\"/releases\")\n\n return r[0]['tag_name']\nend", "def latest(*args)\n arguments(args, required: [:owner, :repo]).params\n\n get_request(\"repos/#{arguments.owner}/#{arguments.repo}/releases/latest\", arguments.params)\n end", "def releases_in_group(release_group_id, options = {})\n get \"release_groups/#{release_group_id}/releases\", options\n end", "def index\n respond_with releases\n end", "def related_releases\n Rails.cache.fetch(\"releases/release-#{id}\", :expires_in => 1.hour) do\n real_releases.all(:order => 'date DESC', :limit => 15)\n end\n end", "def show\n @environment = @project.environments.find_by_slug!(params[:id])\n @releases = @environment.releases\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @environment }\n end\n end", "def show\n @version = Version.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @version }\n end\n end", "def get_release_info(author, repository, options)\n url = Kernel.format(\n 'https://api.github.com/repos/%{author}/%{repository}/releases/%{tag}%{release}',\n author: author,\n repository: repository,\n tag: (options[:is_tag]) ? 'tags/' : '',\n release: options[:release],\n )\n\n release_info_json = fetch_from_url(\n url,\n options[:username],\n options[:password],\n options[:use_auth],\n options[:use_oauth],\n )\n\n return nil unless release_info_json\n\n # Read in release info from JSON file\n\n Puppet.debug('Parsing release info')\n\n # noinspection RubyResolve\n PSON.load(release_info_json)\nend", "def releases\n self.class.releases\n end", "def releases\n self.class.releases\n end", "def get_aos_version(args = {}) \n get(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def releases\n repo.releases(changelog.changes)\n end", "def index\n params[:page] ||= 1\n \n @releases = Release.search_archive(params[:search], params[:page])\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @releases }\n end\n end", "def get_url\n heroku_app = options[:heroku_app]\n uriString = \"https://api.heroku.com/apps/#{heroku_app}/releases\"\n accept = '\"Accept: application/vnd.heroku+json; version=3\"'\n order = '\"Range: version ..; order=desc, max=10;\"'\n uri = URI(uriString)\n puts \"URI: #{uri}\"\n\n res = `curl -n --silent #{uriString} -H #{accept} -H #{order}`\n\n result = JSON.parse(res)\n\n id = nil\n ver = nil\n hash = nil\n result.each { |i|\n puts i\n if !id && i[\"slug\"] && i[\"slug\"][\"id\"] && i[\"slug\"][\"id\"] != \"\"\n id = i[\"slug\"][\"id\"]\n ver = i[\"version\"]\n hash = i[\"description\"]\n end\n }\n\n #puts id if id\n if id != nil\n\n uriStringSlug = \"https://api.heroku.com/apps/#{heroku_app}/slugs/#{id}\"\n uriSlug = URI(uriStringSlug)\n\n resSlug = `curl -n --silent #{uriStringSlug} -H #{accept}`\n resultSlug = JSON.parse(resSlug)\n p \"--------------------------------\"\n p \"Version: #{ver}\"\n p \"Hash: #{hash}\"\n p resultSlug[\"blob\"][\"url\"]\n p \"--------------------------------\"\n end\n end", "def list_all_aos_versions(args = {}) \n get(\"/aosversions.json/all\", args)\nend", "def release\n case new_resource.version\n when 'latest'\n require 'octokit'\n Octokit.releases(repo).first[:tag_name]\n else\n \"v#{new_resource.version}\"\n end\n end", "def index\n #@releases = Release.all\n @releases = Release.where(cashier_id: current_user.cashier.id, view: true)\n\n # respond_to do |format|\n # format.html # index.html.erb\n # format.json { render json: @releases }\n # end\n end", "def index\n @object_releases = ObjectRelease.all\n end", "def show\n @client_release = ClientRelease.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_release }\n end\n end", "def index\n @press_releases = PressRelease.all\n end", "def new\n @release = Release.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end", "def create\n @release = @environment.releases.new(params[:release])\n\n respond_to do |format|\n if @release.save\n format.html { redirect_to @release, notice: 'Release was successfully created.' }\n format.json { render json: @release, status: :created, location: @release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end", "def release_url(api_url, title)\n # \"subject\": {\n # \"title\": \"v1.4.4\",\n # \"url\": \"https://api.github.com/repos/typed-ember/ember-cli-typescript/releases/13191777\",\n # \"latest_comment_url\": \"https://api.github.com/repos/typed-ember/ember-cli-typescript/releases/13191777\",\n # \"type\": \"Release\"\n # },\n api_index = api_url.index(\"api\")\n repos_index = api_url.index(\"repos\")\n releases_index = api_url.index(\"releases\")\n\n # https://github.com/typed-ember/ember-cli-typescript/releases/tag/v1.4.4\n html_url = api_url[0..api_index - 1] +\n api_url[api_index + \"api.\".length..repos_index - 1] +\n api_url[repos_index + \"repos/\".length..releases_index + \"releases\".length] +\n \"tag/#{title}\"\n html_url\n end", "def campaign_release(id)\n rest.get(:releasesms, id: id)['data']\n end", "def display_releases(releases)\n url = \"\"\n releases.each do |release|\n puts \"\\n\\n#{release.name} by #{release.artist} on #{release.label}\\n\"\n release.tracks.each_with_index do |track, index|\n puts \"-#{track.name}\"\n url = track.url\n end\n end\n end", "def new\n @commit = params[:commit]\n @release = @environment.releases.new(\n commit0: @environment.last_commit,\n commit1: @commit)\n if @release.can_read_commits?\n @release.load_commits!\n @release.load_tickets!\n @release.build_changes_from_commits\n end\n if @release.changes.none?\n render :template => \"releases/new_pick_commit\"\n else\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end\n end", "def fetch_versions\n http_get(\"#{host}/#{Configuration.versions_file}\").body\n end", "def destroy\n @release = @environment.releases.find(params[:id])\n @release.destroy\n\n respond_to do |format|\n format.html { redirect_to releases_url }\n format.json { head :no_content }\n end\n end", "def show\n @release = Release.find(params[:id])\n \n # send to release page if not archived\n redirect_to(:controller => 'releases', :action => 'show', :id => @release.id) and return if [email protected]\n \n # populate release fixes from mantis\n if @release.mantis_project_version_id\n @issues = Issue.fixed(@release.mantis_project_id, @release.mantis_project_version_name)\n end\n @version_released = @release.released?\n @version_release_date = Time.at(@release.release_date).strftime(\"%Y-%m-%d\") if @version_released && @release.release_date\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @release }\n end\n end", "def release\n configs = store(:get, 'configs').to_s.gsub(\"\\n\", \" \")\n \n # TODO: if error, user need to deploy code first (nothing to deploy) => use a special exit code \n # when code is not pushed or only deploy if app has a correct build\n version = @api.release(@name, configs).to_s.chomp.gsub(\"\\n\", \" \")\n backend = @api.run(@name, :web, version).to_s.chomp.gsub(\"\\n\", \" \")\n @api.route @name, backend\n return version\n end", "def show\n render json: JSONAPI::Serializer.serialize(@repo)\n end", "def get_artists_releases(artist_id, pagination={})\n query_and_build \"artists/#{artist_id}/releases\", pagination\n end", "def version_info\n path = File.join(SERVER_ROOT, 'public', 'version_info.json')\n JSON.load File.read(path)\nend", "def latest\n releases.first\n end", "def show\n @persons_release = PersonsRelease.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @persons_release }\n end\n end", "def show\n @revision = Revision.find(params[:id])\n\n render json: @revision\n end", "def new\n @os_release = OsRelease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @os_release }\n end\n end", "def get(*args)\n params = args.extract_options!\n @connection.get do |req|\n req.url versioned_path(args), params\n end\n end", "def show\n repo = assets_repo\n @v_asset = repo.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @v_asset }\n end\n end", "def get_release_notes\n path = '/v3/release-logs.json'\n\n header = {\n 'Content-Type' => 'application/json',\n 'User-Agent' => Config.user_agent\n }\n request = Net::HTTP::Get.new(path, header)\n handle_response(@api_client.request(request), 'get_release_notes')\n end", "def index\n @release_items = ReleaseItem.all\n end", "def release\n _init\n\n @release = Release.find_by_name(params[:release]) if params[:release]\n @release = Release.actived.first unless @release\n\n render :template => 'sprint/release', :layout => 'release'\n end", "def release_info\n @release_info ||= @connection.get(RELEASE_INFO_PATH)['release']\n end", "def show\n @api_version = ApiVersion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_version }\n end\n end", "def info\n release = args.shift.downcase.strip rescue nil\n raise(CommandFailed, \"Specify a release\") unless release\n\n release = heroku.release(app, release)\n\n display \"=== Release #{release['name']}\"\n display_info(\"Change\", release[\"descr\"])\n display_info(\"By\", release[\"user\"])\n display_info(\"When\", time_ago(Time.now.to_i - Time.parse(release[\"created_at\"]).to_i))\n display_info(\"Addons\", release[\"addons\"].join(\", \"))\n display_vars(release[\"env\"])\n end", "def get_history_version(title_number, version)\n\n response = rest_get_call($HISTORIAN_URL + '/' + title_number +'?version=' + version.to_s)\n\n if (response.code != '200') then\n raise \"Failed to retrieve historical version specified: \" + response.body\n end\n\n return JSON.parse(response.body)\nend", "def update\n @release = @environment.releases.find(params[:id])\n\n respond_to do |format|\n if @release.update_attributes(params[:release])\n format.html { redirect_to @release, notice: 'Release was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end", "def map_releases\n releases.sort! {|x,y| x[1] <=> y[1] }\n .map { |release|\n {\n \"version\" => release[1],\n \"status\" => \"active\",\n \"description_html\" => \"<p>#{release[0]}</p>\",\n \"description_markdown\" => release[0],\n \"providers\" => [\n {\"name\" => \"virtualbox\", \"url\" => \"#{RELEASE_URL}#{release[0]}\"}\n ]\n }\n }\n end", "def first_release\n self.releases.where(status: STATUS[:completed]).first\n end", "def index\n @versions = Version.all\n end", "def release\n release_data = EventDate.data_for_release(params[:date_id])\n render json: release_data.to_json\n end", "def latest\n client = XMLRPC::Client.new2(\"http://pypi.python.org/pypi\")\n client.http_header_extra = {\"Content-Type\" => \"text/xml\"}\n client.timeout = 10\n result = client.call(\"package_releases\", @resource[:name])\n result.first\n rescue Timeout::Error => detail\n raise Puppet::Error, \"Timeout while contacting pypi.python.org: #{detail}\";\n end", "def latest\n client = XMLRPC::Client.new2(\"http://pypi.python.org/pypi\")\n client.http_header_extra = {\"Content-Type\" => \"text/xml\"}\n client.timeout = 10\n result = client.call(\"package_releases\", @resource[:name])\n result.first\n rescue Timeout::Error => detail\n raise Puppet::Error, \"Timeout while contacting pypi.python.org: #{detail}\";\n end", "def new_dvd_releases\n return @badfruit.parse_movies_array(JSON.parse(@badfruit.get_lists_action(\"new_releases\")))\n end", "def get_labels_releases(label_id, pagination={})\n query_and_build \"labels/#{label_id}/releases\", pagination\n end", "def version\n api_execute('/version', :get).body\n end", "def show\n @admin_version = Admin::Version.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_version }\n end\n end", "def index\n @projects = ProjectDecorator.all\n @releases = ReleaseDecorator.recent\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @projects }\n end\n end", "def show\n repo = ProjectRepo.new current_user\n @v_project = repo.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @v_project }\n end\n end", "def get_version\n response = self.class.get(\"/service/#{$service_id}/version/#{$service_version}\", {\n headers: {\"Fastly-Key\" => $key}\n })\n end", "def new\n @version = Version.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @version }\n end\n end", "def index\n @package_versions = PackageVersion.all\n end", "def current_dvd_releases\n return @badfruit.parse_movies_array(JSON.parse(@badfruit.get_lists_action(\"current_releases\")))\n end", "def version\n self.class.get(\"/get/version\")\n end", "def create\n # Extract the version info\n release = params[:release]\n version = params[:release][:version]\n release.delete(\"version\")\n \n # Validate input\n if (release[:name] == \"\")\n flash[:notice] = \"You must supply a name for the release\"\n respond_to do |format|\n format.html { redirect_to :action => 'new' }\n format.json { head :no_content }\n end\n elsif (release[:source_url] == \"\")\n flash[:notice] = \"You must supply a source URL\"\n respond_to do |format|\n format.html { redirect_to :action => 'new' }\n format.json { head :no_content }\n end\n else\n # Add http:// prefix to source_url if it doesn't already exist\n release[:source_url] = \"http://#{release[:source_url]}\" if not release[:source_url].starts_with? \"http://\" and not release[:source_url].starts_with? \"https://\"\n \n @release = Release.new(release)\n @release.user = current_user\n \n # Add the version info\n # If the URL doesn't start with http:// or https://, add it\n version[:download_url] = \"http://#{version[:download_url]}\" if not version[:download_url].starts_with? \"http://\" and not version[:download_url].starts_with? \"https://\"\n \n @version = Version.new(version)\n @version.version_number = 1\n @version.release = @release\n @release.versions << @version\n\n respond_to do |format|\n if @release.save\n format.html { redirect_to @release, notice: 'Release was successfully created.' }\n format.json { render json: @release, status: :created, location: @release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def new\n @client_release = ClientRelease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client_release }\n end\n end", "def edit(*args)\n arguments(args, required: [:owner, :repo, :id])\n\n patch_request(\"/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}\", arguments.params)\n end", "def get_master_release_versions(master_release_id, pagination={})\n query_and_build \"masters/#{master_release_id}/versions\", pagination\n end", "def all_builds_request_model(session, app_id)\n path = \"#{FABRIC_API_PATH}#{org_app_endpoint(session, app_id)}/beta_distribution/releases\"\n model = Fabricio::Networking::RequestModel.new do |config|\n config.type = :GET\n config.base_url = FABRIC_API_URL\n config.api_path = path\n end\n model\n end", "def get_aos_version_box_by_name(args = {}) \n get(\"/aosversions.json/aosversionbox/name/#{args[:aosVersionBoxName]}\", args)\nend", "def remote_versions_for(name)\n require 'json'\n\n client.url = \"https://rubygems.org/api/v1/versions/#{name}.json\"\n client.follow_location = true\n client.http_get\n json = JSON.parse(client.body_str)\n json.collect { |version| version['number'] }\n end", "def get_versions(project_id_or_key)\n get(\"projects/#{project_id_or_key}/versions\")\n end", "def index\n @api_versions = ApiVersion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @api_versions }\n end\n end", "def latest_version_uri\n '/api/projects/latest_compiled_version'\n end", "def info\n validate_arguments!\n\n remotes = self.class.heroku_remotes\n\n # trigger 'No app specified' message\n remotes.push ['--app', app] if remotes.empty? or options[:app]\n\n output = {}\n remotes.map do |remote|\n Thread.new(remote) do |remote, app|\n begin\n # capture stdout\n Thread.current[:output] = []\n\n release = api.get_releases(app).body.sort_by do |release|\n release[\"name\"][1..-1].to_i\n end.last[\"name\"]\n\n # display_header(\"#{app}\")\n puts \"##### #{app} #####\\n\"\n\n # this is simply copied from 3.9.6/lib/heroku/command/releases.rb\n # https://github.com/heroku/heroku/blob/master/lib/heroku/command/releases.rb\n\n # ---------\n release_data = api.get_release(app, release).body\n\n data = {\n 'By' => release_data['user'],\n 'Change' => release_data['descr'],\n 'When' => time_ago(release_data[\"created_at\"])\n }\n\n unless release_data['addons'].empty?\n data['Addons'] = release_data['addons']\n end\n\n\n styled_header(\"Release #{release}\")\n styled_hash(data)\n\n display\n\n styled_header(\"#{release} Config Vars\")\n unless release_data['env'].empty?\n if options[:shell]\n release_data['env'].keys.sort.each do |key|\n display(\"#{key}=#{release_data['env'][key]}\")\n end\n else\n styled_hash(release_data['env'])\n end\n else\n display(\"#{release} has no config vars.\")\n end\n # ---------\n\n # capture stdout\n output[remote] = Thread.current[:output].join\n rescue\n output[remote] = \"Something went wrong fetching releases for #{app}.\"\n end\n end\n end.map(&:join)\n\n output.sort.each do |remote, output|\n puts output\n puts\n end\n end", "def index\n @api_versions = ApiVersion.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @api_versions }\n end\n end", "def version\n response = get('/getVersion', {}, false)\n ApiVersion.new(response.body['version'], response.body['builddate'])\n end", "def new\n @version = Version.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @version }\n end\n end" ]
[ "0.7655217", "0.76069975", "0.7481829", "0.7175601", "0.7175601", "0.71647197", "0.70292014", "0.69231915", "0.6885941", "0.6856688", "0.6786493", "0.674057", "0.66668063", "0.65923876", "0.65679425", "0.6559784", "0.65479684", "0.6530027", "0.64978784", "0.648174", "0.6476047", "0.6458187", "0.6454697", "0.64470387", "0.6405186", "0.6376608", "0.6373757", "0.63682723", "0.6350649", "0.63432413", "0.6342444", "0.6342444", "0.6309032", "0.6303659", "0.6268814", "0.6263633", "0.62621367", "0.62569094", "0.62329125", "0.6228846", "0.6222093", "0.62174165", "0.62155586", "0.6207524", "0.6194525", "0.619137", "0.6168049", "0.61586946", "0.61444616", "0.6125023", "0.60537905", "0.6037255", "0.6033944", "0.6019362", "0.60055876", "0.59985024", "0.59869075", "0.5974033", "0.5966407", "0.5961551", "0.59358776", "0.59163845", "0.5890809", "0.5887093", "0.5874364", "0.58639413", "0.5861725", "0.5853713", "0.5850988", "0.5843769", "0.5823093", "0.58184445", "0.5816867", "0.5811875", "0.5811875", "0.58008534", "0.57972515", "0.57967", "0.57775575", "0.5776804", "0.57740325", "0.57565236", "0.57453907", "0.57411534", "0.57397544", "0.573657", "0.57272464", "0.57203627", "0.5718662", "0.57129484", "0.57038516", "0.5701469", "0.5695486", "0.5691332", "0.5685226", "0.5675328", "0.565954", "0.5647021", "0.5646791", "0.5646425" ]
0.63804334
25
GET /releases/new GET /releases/new.json
def new @release = Release.new @cashier = Cashier.find(params[:cashier_id]) #@cashier = current_user.cashier # @release.type_release = params[:type_release] respond_to do |format| format.html # new.html.erb format.json { render json: @release } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_releases\n api_call(\"https://api.spotify.com/\",\"/v1/browse/new-releases\")\n end", "def new\n @release = Release.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end", "def new\n @commit = params[:commit]\n @release = @environment.releases.new(\n commit0: @environment.last_commit,\n commit1: @commit)\n if @release.can_read_commits?\n @release.load_commits!\n @release.load_tickets!\n @release.build_changes_from_commits\n end\n if @release.changes.none?\n render :template => \"releases/new_pick_commit\"\n else\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end\n end", "def create\n @release = @environment.releases.new(params[:release])\n\n respond_to do |format|\n if @release.save\n format.html { redirect_to @release, notice: 'Release was successfully created.' }\n format.json { render json: @release, status: :created, location: @release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @version = Version.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @version }\n end\n end", "def new\n @version = Version.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @version }\n end\n end", "def new\n @os_release = OsRelease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @os_release }\n end\n end", "def new\n @client_release = ClientRelease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client_release }\n end\n end", "def new\n @persons_release = PersonsRelease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @persons_release }\n end\n end", "def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repository }\n end\n end", "def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repository }\n end\n end", "def new\n @distro = Distro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @distro }\n end\n end", "def new\n @distro = Distro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @distro }\n end\n end", "def new\n @published = Published.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @published }\n end\n end", "def new\n repo = assets_repo\n @v_asset = repo.new\n\n respond_to do |format|\n format.html new.html.erb\n format.json { render json: @v_asset }\n end\n end", "def create\n # Extract the version info\n release = params[:release]\n version = params[:release][:version]\n release.delete(\"version\")\n \n # Validate input\n if (release[:name] == \"\")\n flash[:notice] = \"You must supply a name for the release\"\n respond_to do |format|\n format.html { redirect_to :action => 'new' }\n format.json { head :no_content }\n end\n elsif (release[:source_url] == \"\")\n flash[:notice] = \"You must supply a source URL\"\n respond_to do |format|\n format.html { redirect_to :action => 'new' }\n format.json { head :no_content }\n end\n else\n # Add http:// prefix to source_url if it doesn't already exist\n release[:source_url] = \"http://#{release[:source_url]}\" if not release[:source_url].starts_with? \"http://\" and not release[:source_url].starts_with? \"https://\"\n \n @release = Release.new(release)\n @release.user = current_user\n \n # Add the version info\n # If the URL doesn't start with http:// or https://, add it\n version[:download_url] = \"http://#{version[:download_url]}\" if not version[:download_url].starts_with? \"http://\" and not version[:download_url].starts_with? \"https://\"\n \n @version = Version.new(version)\n @version.version_number = 1\n @version.release = @release\n @release.versions << @version\n\n respond_to do |format|\n if @release.save\n format.html { redirect_to @release, notice: 'Release was successfully created.' }\n format.json { render json: @release, status: :created, location: @release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def new\n @repo = Repo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @repo }\n end\n end", "def new\n @fileversion = Fileversion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fileversion }\n end\n end", "def new\n @release_status = ReleaseStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @release_status }\n end\n end", "def new\n @file_version = FileVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @file_version }\n end\n end", "def new\n @git_repo = GitRepo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @git_repo }\n end\n end", "def new\n @deployment = Deployment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @deployment }\n end\n end", "def new\n @gitto = Gitto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gitto }\n end\n end", "def new_dvd_releases\n return @badfruit.parse_movies_array(JSON.parse(@badfruit.get_lists_action(\"new_releases\")))\n end", "def new\n @press = Press.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @press }\n end\n end", "def index\n @releases = @environment.releases.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @releases }\n end\n end", "def create_release(node)\n if node.attributes['id'] and @releases[node.attributes['id']]\n release = @releases[node.attributes['id']]\n else\n release = @factory.new_release\n @releases[node.attributes['id']] = release\n end\n \n # Read all defined data fields\n release.id = node.attributes['id']\n release.title = node.elements['title'].text if node.elements['title']\n release.asin = node.elements['asin'].text if node.elements['asin']\n release.artist = create_artist(node.elements['artist']) if node.elements['artist']\n \n # Read the types\n node.attributes['type'].split(' ').each {|type|\n release.types << Utils.add_namespace(type)\n } if node.attributes['type']\n \n # Read the text representation information.\n if text_representation = node.elements['text-representation']\n release.text_language = text_representation.attributes['language']\n release.text_script = text_representation.attributes['script']\n end\n \n # Read the track list\n read_track_list(node.elements['track-list'], release.tracks) {|track|\n track.artist = release.artist unless track.artist\n track.releases << release\n }\n \n # Read the release event list\n read_release_event_list(node.elements['release-event-list'], release.release_events)\n \n # Read the disc list\n read_disc_list(node.elements['disc-list'], release.discs)\n \n # Read the relation list\n if node.elements['relation-list']\n node.elements.each('relation-list') {|relation_node|\n read_relation_list(relation_node) {|relation|\n release.add_relation relation\n }\n }\n end\n \n # Read the tag list\n read_tag_list(node.elements['tag-list'], release.tags)\n \n return release\n end", "def release\n case new_resource.version\n when 'latest'\n require 'octokit'\n Octokit.releases(repo).first[:tag_name]\n else\n \"v#{new_resource.version}\"\n end\n end", "def create\n @os_release = OsRelease.new(params[:os_release])\n\n respond_to do |format|\n if @os_release.save\n format.html { redirect_to @os_release, notice: 'Os release was successfully created.' }\n format.json { render json: @os_release, status: :created, location: @os_release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @os_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def release(project_id, release_id, options = {})\n get \"projects/#{project_id}/releases/#{release_id}\", options\n end", "def new\n @package_status = PackageStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @package_status }\n end\n end", "def new\n @admin_version = Admin::Version.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @admin_version }\n end\n end", "def new\n @versioned_jnlp_url = MavenJnlp::VersionedJnlpUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @versioned_jnlp_url }\n end\n end", "def new\n @gist = Gist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gist }\n end\n end", "def new\n @git_datum = GitDatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @git_datum }\n end\n end", "def created_release(version)\n puts green(\"Release #{version} created\")\n end", "def new\n @release_loan = ReleaseLoan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release_loan }\n end\n end", "def new\n @versioned_jnlp = MavenJnlp::VersionedJnlp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @versioned_jnlp }\n end\n end", "def new\n @archive = Archive.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @archive }\n end\n end", "def new\n @distribution = Distribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @distribution }\n end\n end", "def new\n @pub = Pub.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pub }\n end\n end", "def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @repository }\n end\n end", "def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @repository }\n end\n end", "def new\n @license = License.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @license }\n end\n end", "def new\n @archiv = Archiv.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @archiv }\n end\n end", "def new_link\n @project = Project.new(user_id: current_user.id)\n fetch_projects\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n \t@pagenav = Page.find_all_by_published('true')\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\r\n @archive = Archive.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @archive }\r\n end\r\n end", "def new\n @release_language = ReleaseLanguage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release_language }\n end\n end", "def new\n @publish = Publish.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @publish }\n end\n end", "def create(*args)\n arguments(args, required: [:owner, :repo]) do\n assert_required :tag_name\n end\n\n post_request(\"/repos/#{arguments.owner}/#{arguments.repo}/releases\",\n arguments.params)\n end", "def index\n @releases = Release.all\n end", "def index\n @releases = Release.all\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 show\n @release = @environment.releases.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @release }\n end\n end", "def new\n @publisher = Publisher.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @publisher }\n end\n end", "def new\n @project_download = ProjectDownload.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @project_download }\n end\n end", "def create\n @press_release = PressRelease.new(press_release_params)\n\n respond_to do |format|\n if @press_release.save\n format.html { redirect_to @press_release, notice: 'Press release was successfully created.' }\n format.json { render action: 'show', status: :created, location: @press_release }\n else\n format.html { render action: 'new' }\n format.json { render json: @press_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @vpn = Vpn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vpn }\n end\n end", "def new\n @vpn = Vpn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vpn }\n end\n end", "def new\n @new_status = NewStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_status }\n end\n end", "def new\n @svn_module = SvnModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @svn_module }\n end\n end", "def new\n @githuber = Githuber.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @githuber }\n end\n end", "def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end", "def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end", "def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end", "def new\n @heroku = Heroku.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @heroku }\n end\n end", "def new\n @deploy_heroku_api_key = DeployHerokuApiKey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @deploy_heroku_api_key }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @publisher = Publisher.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @publisher }\n end\n end", "def new\n @nvs_pack = NvsPack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nvs_pack }\n end\n end", "def new\n @jar = MavenJnlp::Jar.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @jar }\n end\n end", "def new\n @issue = Issue.new\n\n @new = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @issue }\n end\n end", "def create\n @persons_release = PersonsRelease.new(params[:persons_release])\n\n respond_to do |format|\n if @persons_release.save\n format.html { redirect_to @persons_release, notice: 'Persons release was successfully created.' }\n format.json { render json: @persons_release, status: :created, location: @persons_release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @persons_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @installation = Installation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @installation }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new script: \"bundle install\\r\\nbundle exec rake db:setup RAILS_ENV=test\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @project = Project.new\n\n respond_to do |format|\n format.json { render json: @project }\n format.html # new.html.erb\n end\n end", "def create\n @press_release = PressRelease.new(press_release_params)\n\n respond_to do |format|\n if @press_release.save\n format.html { redirect_to @press_release, notice: 'Press release was successfully created.' }\n format.json { render :show, status: :created, location: @press_release }\n else\n format.html { render :new }\n format.json { render json: @press_release.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7606564", "0.73726594", "0.7259423", "0.7206175", "0.7025918", "0.69621646", "0.695169", "0.665543", "0.6646088", "0.6618149", "0.6618149", "0.6528592", "0.6528592", "0.652044", "0.6508119", "0.6506925", "0.6483403", "0.6403102", "0.63954437", "0.6389003", "0.6384176", "0.6362568", "0.6324702", "0.62769216", "0.6264872", "0.6242075", "0.62345004", "0.62283945", "0.6222586", "0.6206183", "0.6193834", "0.6190176", "0.6178781", "0.61776316", "0.6166832", "0.61581343", "0.6152181", "0.61318564", "0.61254925", "0.6103167", "0.6102601", "0.60883665", "0.60883665", "0.6069574", "0.6065544", "0.6059726", "0.6058536", "0.60522", "0.6038163", "0.60326165", "0.60245234", "0.6022958", "0.6022958", "0.6019135", "0.60185385", "0.6009332", "0.60061216", "0.5997425", "0.5996526", "0.5996526", "0.5993251", "0.59878033", "0.598717", "0.5976711", "0.5976711", "0.5976711", "0.5972492", "0.59622097", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5953699", "0.5948585", "0.59410924", "0.59386504", "0.59202725", "0.59185666", "0.5916426", "0.59139043", "0.591351", "0.59055555", "0.59028757" ]
0.0
-1
POST /releases POST /releases.json
def create @cashier = Cashier.find(params[:cashier_id]) @release = @cashier.releases.build(params[:release]) #@release.date_release = post_date Date.today respond_to do |format| if @release.save format.html { redirect_to cashier_path(@cashier), notice: 'Release was successfully created.' } #format.html { redirect_to cashier_release_path(@release.cashier, @release), notice: 'Release was successfully created.' } format.json { render json: @release, status: :created, location: @release } else format.html { render action: "new" } format.json { render json: @release.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @release = @environment.releases.new(params[:release])\n\n respond_to do |format|\n if @release.save\n format.html { redirect_to @release, notice: 'Release was successfully created.' }\n format.json { render json: @release, status: :created, location: @release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_releases\n api_call(\"https://api.spotify.com/\",\"/v1/browse/new-releases\")\n end", "def create(*args)\n arguments(args, required: [:owner, :repo]) do\n assert_required :tag_name\n end\n\n post_request(\"/repos/#{arguments.owner}/#{arguments.repo}/releases\",\n arguments.params)\n end", "def post_release_v2(app_name, slug, dyno_types, user, token,\n slug_url, repo_size)\n slug_url_regex = /https:\\/\\/(.+?)\\.s3\\.amazonaws\\.com\\/(.+?)\\?/\n _, slug_put_key, slug_put_bucket = slug_url.match(slug_url_regex).to_a\n start = Time.now\n payload = {\n # \"head\" => head,\n # \"prev_head\" => commit_hash,\n # \"current_seq\" => current_seq,\n \"slug_put_key\" => slug_put_key,\n \"slug_put_bucket\" => slug_put_bucket,\n \"repo_size\" => repo_size,\n \"release_descr\" => \"sokoban-built release\", # punting for v2\n \"language_pack\" => \"Sokoban\", # punting for v2\n \"buildpack\" => \"Sokoban\", # punting for v2\n \"slug_version\" => 2,\n \"slug_size\" => File.size(slug),\n \"stack\" => \"cedar\",\n \"user\" => user,\n \"process_types\" => dyno_types,\n \"git_log\" => \"\",\n \"run_deploy_hooks\" => false,\n \"addons\" => {},\n \"config_vars\" => {}}\n\n release_name =\n Timeout.timeout(30) do\n uri = URI.parse(release_uri(app_name))\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Post.new(uri.request_uri)\n if uri.scheme == \"https\"\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n request.basic_auth(user, token)\n request[\"Content-Type\"] = \"application/json\"\n request[\"Accept\"] = \"application/json\"\n request.body = JSON.unparse(payload)\n response = http.request(request)\n if (response.code != \"200\")\n error_message = begin\n response.body && JSON.parse(response.body)[\"error\"] || \"failure releasing code\"\n rescue Timeout::Error\n \"timed out releasing code\"\n rescue\n \"failure releasing code\"\n end\n raise(error_message)\n end\n response.body\n end\n release_name\n end", "def write_release(payload)\n info 'Creating new release on GitHub'\n rel = payload[:data][:github_kit].delete(:release)\n release = github_client.create_release(\n rel[:repository],\n rel[:tag_name],\n :name => rel[:name],\n :target_commitish => rel[:reference],\n :prerelease => rel[:prerelease],\n :body => rel[:body]\n )\n\n api_release_url = release.rels[:self].href\n public_release_url = release.rels[:html].href\n\n info 'New release created on GitHub. Uploading assets.'\n assets = rel[:assets].map do |asset|\n debug \"Uploading release asset - #{asset}\"\n response = github_client.upload_asset(\n api_release_url,\n asset_store.get(asset),\n :name => asset.sub(/^.+?_/, ''),\n :content_type => 'application/octet-stream'\n )\n debug \"Completed release asset upload - #{asset}\"\n Smash.new(\n :url => response[:url],\n :browser_url => response[:browser_download_url],\n :name => response[:name],\n :id => response[:id]\n )\n end\n payload.set(:data, :github_kit, :release, :assets, assets)\n payload.set(:data, :github_kit, :release, :api_url, api_release_url)\n payload.set(:data, :github_kit, :release, :public_url, public_release_url)\n\n true\n end", "def create_release(tag, message)\n\n if not is_valid_tag(tag)\n raise \"Invalid tag.\"\n end\n\n if message.empty?\n raise \n message = \"Release for #{tag}\"\n end\n\n message = {\n \"tag_name\": tag,\n \"target_commitish\": \"master\",\n \"name\": tag,\n \"body\": message,\n \"draft\": false,\n \"prerelease\": false\n }.to_json\n\n r = api_post(\"/releases\", message)\n\n if not r.kind_of? Net::HTTPCreated\n raise \"Creation of release unsuccessful.\"\n end\nend", "def create_release(attrs = {})\n release = build_release(attrs)\n release.save\n release\n end", "def add_aos_version(args = {}) \n post(\"/aosversions.json/\", args)\nend", "def create\n # Extract the version info\n release = params[:release]\n version = params[:release][:version]\n release.delete(\"version\")\n \n # Validate input\n if (release[:name] == \"\")\n flash[:notice] = \"You must supply a name for the release\"\n respond_to do |format|\n format.html { redirect_to :action => 'new' }\n format.json { head :no_content }\n end\n elsif (release[:source_url] == \"\")\n flash[:notice] = \"You must supply a source URL\"\n respond_to do |format|\n format.html { redirect_to :action => 'new' }\n format.json { head :no_content }\n end\n else\n # Add http:// prefix to source_url if it doesn't already exist\n release[:source_url] = \"http://#{release[:source_url]}\" if not release[:source_url].starts_with? \"http://\" and not release[:source_url].starts_with? \"https://\"\n \n @release = Release.new(release)\n @release.user = current_user\n \n # Add the version info\n # If the URL doesn't start with http:// or https://, add it\n version[:download_url] = \"http://#{version[:download_url]}\" if not version[:download_url].starts_with? \"http://\" and not version[:download_url].starts_with? \"https://\"\n \n @version = Version.new(version)\n @version.version_number = 1\n @version.release = @release\n @release.versions << @version\n\n respond_to do |format|\n if @release.save\n format.html { redirect_to @release, notice: 'Release was successfully created.' }\n format.json { render json: @release, status: :created, location: @release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n @os_release = OsRelease.new(params[:os_release])\n\n respond_to do |format|\n if @os_release.save\n format.html { redirect_to @os_release, notice: 'Os release was successfully created.' }\n format.json { render json: @os_release, status: :created, location: @os_release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @os_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def release(project_id, release_id, options = {})\n get \"projects/#{project_id}/releases/#{release_id}\", options\n end", "def github_post\n {\n \"create\" => ->(release) { start_deployment(release) },\n \"update_status\" => ->(release) { update_deployment(release) }\n }\n end", "def index\n @releases = @environment.releases.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @releases }\n end\n end", "def create_release(node)\n if node.attributes['id'] and @releases[node.attributes['id']]\n release = @releases[node.attributes['id']]\n else\n release = @factory.new_release\n @releases[node.attributes['id']] = release\n end\n \n # Read all defined data fields\n release.id = node.attributes['id']\n release.title = node.elements['title'].text if node.elements['title']\n release.asin = node.elements['asin'].text if node.elements['asin']\n release.artist = create_artist(node.elements['artist']) if node.elements['artist']\n \n # Read the types\n node.attributes['type'].split(' ').each {|type|\n release.types << Utils.add_namespace(type)\n } if node.attributes['type']\n \n # Read the text representation information.\n if text_representation = node.elements['text-representation']\n release.text_language = text_representation.attributes['language']\n release.text_script = text_representation.attributes['script']\n end\n \n # Read the track list\n read_track_list(node.elements['track-list'], release.tracks) {|track|\n track.artist = release.artist unless track.artist\n track.releases << release\n }\n \n # Read the release event list\n read_release_event_list(node.elements['release-event-list'], release.release_events)\n \n # Read the disc list\n read_disc_list(node.elements['disc-list'], release.discs)\n \n # Read the relation list\n if node.elements['relation-list']\n node.elements.each('relation-list') {|relation_node|\n read_relation_list(relation_node) {|relation|\n release.add_relation relation\n }\n }\n end\n \n # Read the tag list\n read_tag_list(node.elements['tag-list'], release.tags)\n \n return release\n end", "def create\n @press_release = PressRelease.new(press_release_params)\n\n respond_to do |format|\n if @press_release.save\n format.html { redirect_to @press_release, notice: 'Press release was successfully created.' }\n format.json { render :show, status: :created, location: @press_release }\n else\n format.html { render :new }\n format.json { render json: @press_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @press_release = PressRelease.new(press_release_params)\n\n respond_to do |format|\n if @press_release.save\n format.html { redirect_to @press_release, notice: 'Press release was successfully created.' }\n format.json { render action: 'show', status: :created, location: @press_release }\n else\n format.html { render action: 'new' }\n format.json { render json: @press_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def process_payload\n payload = params['release']\n repo = Repo.find_by(github_id: params['repository']['id'])\n\n render nothing: true, status: :forbidden and return if repo.inactive?\n\n release = Release.new(\n repo_id: repo.id,\n github_id: payload['id'],\n html_url: payload['html_url'],\n tag_name: payload['tag_name'],\n body: payload['body'],\n prerelease: payload['prerelease'],\n published_at: Time.iso8601(payload['published_at'])\n )\n\n if release.save\n render nothing: true, status: :created\n else\n render nothing: true, status: :bad_request\n end\n end", "def create\n @client_release = ClientRelease.new(params[:client_release])\n\n respond_to do |format|\n if @client_release.save\n format.html { redirect_to @client_release, notice: 'Client release was successfully created.' }\n format.json { render json: @client_release, status: :created, location: @client_release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @persons_release = PersonsRelease.new(params[:persons_release])\n\n respond_to do |format|\n if @persons_release.save\n format.html { redirect_to @persons_release, notice: 'Persons release was successfully created.' }\n format.json { render json: @persons_release, status: :created, location: @persons_release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @persons_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def created_release(version)\n puts green(\"Release #{version} created\")\n end", "def index\n @releases = Release.all\n end", "def index\n @releases = Release.all\n end", "def deploy_api(name, rev, env, path)\n post(\"/apis/#{name}/revisions/#{rev}/deployments\", {:action => 'deploy', :env => env, :basepath => path})\n end", "def releases(country = nil)\n Birdman::Requester.get(\"movies/#{id}/releases/#{country}\")\n end", "def release\n release_data = EventDate.data_for_release(params[:date_id])\n render json: release_data.to_json\n end", "def create\n @release = Release.new(release_params)\n @release.project = @project\n\n respond_to do |format|\n if @release.save\n format.html { redirect_to [@release.project, @release], notice: 'Release criada com sucesso.' }\n else\n format.html { render :new }\n end\n end\n end", "def request_release(options = {})\n response = JSON.parse(@client.patch(\"items/#{send(:id)}/request_release\", options).body)\n @attributes = response['items']\n true\n end", "def request_release(options = {})\n response = JSON.parse(@client.patch(\"items/#{send(:id)}/request_release\", options).body)\n @attributes = response['items']\n true\n end", "def create\n @object_release = ObjectRelease.new(object_release_params)\n\n respond_to do |format|\n if @object_release.save\n format.html { redirect_to @object_release, notice: 'Object release was successfully created.' }\n format.json { render :show, status: :created, location: @object_release }\n else\n format.html { render :new }\n format.json { render json: @object_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_aos_version_box(args = {}) \n post(\"/aosversions.json/aosversionbox\", args)\nend", "def releases\n repo.releases(changelog.changes)\n end", "def new\n @release = Release.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end", "def new_dvd_releases\n return @badfruit.parse_movies_array(JSON.parse(@badfruit.get_lists_action(\"new_releases\")))\n end", "def release!\n version = Origen.app.version\n body = { version: version.to_s }\n if version.production?\n body[:type] = :production\n else\n body[:type] = :development\n end\n post(\"plugins/#{Origen.app.name}/release\", body: body)\n end", "def release\n case new_resource.version\n when 'latest'\n require 'octokit'\n Octokit.releases(repo).first[:tag_name]\n else\n \"v#{new_resource.version}\"\n end\n end", "def create\n @release_item = ReleaseItem.new(release_item_params)\n\n respond_to do |format|\n if @release_item.save\n format.html { redirect_to @release_item, notice: 'Release item was successfully created.' }\n format.json { render :show, status: :created, location: @release_item }\n else\n format.html { render :new }\n format.json { render json: @release_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_release(build)\n release = Kubernetes::Release.create_release(\n deploy_id: @job.deploy.id,\n deploy_groups: deploy_group_configs,\n build_id: build.try(:id),\n git_sha: @job.commit,\n git_ref: @reference,\n user: @job.user,\n project: @job.project\n )\n\n unless release.persisted?\n raise Samson::Hooks::UserError, \"Failed to create release: #{release.errors.full_messages.inspect}\"\n end\n\n @output.puts(\"Created release #{release.id}\\nConfig: #{deploy_group_configs.to_json}\")\n release\n end", "def release_params\n params.require(:release).permit(:version, :deliver_date, :project_id)\n end", "def create\n @release_main = ReleaseMain.new(release_main_params)\n\n respond_to do |format|\n if @release_main.save\n format.html { redirect_to @release_main, notice: 'Release main was successfully created.' }\n format.json { render :show, status: :created, location: @release_main }\n else\n format.html { render :new }\n format.json { render json: @release_main.errors, status: :unprocessable_entity }\n end\n end\n end", "def release\n configs = store(:get, 'configs').to_s.gsub(\"\\n\", \" \")\n \n # TODO: if error, user need to deploy code first (nothing to deploy) => use a special exit code \n # when code is not pushed or only deploy if app has a correct build\n version = @api.release(@name, configs).to_s.chomp.gsub(\"\\n\", \" \")\n backend = @api.run(@name, :web, version).to_s.chomp.gsub(\"\\n\", \" \")\n @api.route @name, backend\n return version\n end", "def release_params\n params.require(:release).permit(:title, :release_date)\n end", "def release\n git :archive, fetch(:branch), fetch(:project_root), '| tar -x -C', release_path, \"--strip=#{fetch(:project_root).count('/')+1}\"\n end", "def new\n @commit = params[:commit]\n @release = @environment.releases.new(\n commit0: @environment.last_commit,\n commit1: @commit)\n if @release.can_read_commits?\n @release.load_commits!\n @release.load_tickets!\n @release.build_changes_from_commits\n end\n if @release.changes.none?\n render :template => \"releases/new_pick_commit\"\n else\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end\n end", "def release_params\n params.require(:release).permit(:system_id, :versao, :dt_implantacao, :descricao)\n end", "def index\n respond_with releases\n end", "def destroy\n @release = @environment.releases.find(params[:id])\n @release.destroy\n\n respond_to do |format|\n format.html { redirect_to releases_url }\n format.json { head :no_content }\n end\n end", "def index\n @releases = Release.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @releases.to_json(:except => [:user_id]) }\n end\n end", "def map_releases\n releases.sort! {|x,y| x[1] <=> y[1] }\n .map { |release|\n {\n \"version\" => release[1],\n \"status\" => \"active\",\n \"description_html\" => \"<p>#{release[0]}</p>\",\n \"description_markdown\" => release[0],\n \"providers\" => [\n {\"name\" => \"virtualbox\", \"url\" => \"#{RELEASE_URL}#{release[0]}\"}\n ]\n }\n }\n end", "def release_params\n params.require(:release).permit(:title, :subtitle, :released_on, :body)\n end", "def releases_in_group(release_group_id, options = {})\n get \"release_groups/#{release_group_id}/releases\", options\n end", "def release\n action('release')\n end", "def new\n @os_release = OsRelease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @os_release }\n end\n end", "def to_release\n user.releases.find_or_initialize_by(discogs_release_id: discogs_release_id).tap do |release|\n release.catalog_number = catalog_number\n release.label = label\n release.artist = artist\n release.name = name\n release.year = year\n release.genre = genre\n release.format = format\n release.format_quantity = format_quantity\n release.discogs_community_have = discogs_community_have\n release.discogs_community_want = discogs_community_want\n release.discogs_lowest_price = discogs_lowest_price\n release.discogs_number_for_sale = discogs_number_for_sale\n release.discogs_cover_thumb_url = discogs_cover_thumb_url\n release.discogs_api_resource_url = discogs_api_resource_url\n release.discogs_uri = discogs_uri\n end\n end", "def github_release_task\n sh git, 'push', '--tags', remote, remote_branch\n end", "def release!\n welcome\n return if uncommitted_changes?\n\n # Check if everything is up to date with git remotes\n if branch_behind_remote?\n if want_to_pull? \n cmd \"git pull\"\n cmd \"git pull --tags\"\n else\n inform \"Please pull the changes, then run `rake release` again\"\n return\n end\n end\n\n # Gather user input about the release\n get_release_message\n get_release_version_type\n\n # Confirm and execute\n if you_sure?\n update_dist\n update_bower_file\n cmd \"git add .\"\n cmd \"git commit -am '#{@commit_message}'\"\n cmd \"git tag -a v#{@next_version} -m '#{@commit_message}'\"\n cmd \"git push\"\n cmd \"git push --tags\"\n publish! # to github pages\n\n robot_says \"All done :) Thanks for contributing!\"\n else\n inform \"Release cancelled\"\n end\n end", "def create_release_card summary\n # build post object\n url = 'https://api.github.com/projects/columns/%s/cards' % RELEASE\n uri = URI url\n post = Net::HTTP::Post.new uri, HEADERS\n post.body = { 'note' => summary }.to_json\n\n # create connection and send post\n http = Net::HTTP.new uri.host, uri.port\n http.use_ssl = 'https' == uri.scheme\n response = http.request post\n log 'release.log', \"#{response.inspect}: #{response.body}: #{response.uri}\" if response.code >= '400'\nend", "def release_params\n params.require(:release).permit(:name, :description, :project_id, :deadline)\n end", "def release_params\n params.require(:release).permit(:title, :catalogue_number, :format, :country_code, :released_at, :image_data, :artist_id, :query)\n end", "def show\n @release = @environment.releases.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @release }\n end\n end", "def release(options)\n options = options.rekey\n\n unixname = self.unixname\n\n package = options[:package] || metadata.name\n version = options[:version] || metadata.version\n\n date = options[:date] || metadata.released || Time::now.strftime('%Y-%m-%d %H:%M')\n\n changes = options[:changes] || project.history.releases[0].changes\n notes = options[:notes] || project.history.releases[0].note\n\n release = options[:release] || version\n\n files = options[:files] || options[:file] || []\n\n #store = options[:store] || 'pkg'\n\n processor = options[:processor] || 'Any'\n\n is_public = !options[:private]\n\n #raise ArgumentError, \"missing unixname\" unless unixname\n raise ArgumentError, \"missing package\" unless package\n raise ArgumentError, \"missing release\" unless release\n\n # package name has to be 3+ characters.\n if package.size < 3\n package = package + \"'s\"\n end\n\n # sub in for version if %s is used in release name.\n release = release % version if release.index(\"%s\")\n\n release_notes = notes\n release_changes = changes\n\n # Gather package files to release.\n if files.empty?\n files = find_packages(version)\n else\n files = files.map do |file|\n if File.directory?(file)\n find_packages(version, file)\n else\n file\n end\n end\n files = files.flatten\n end\n files = files.select{ |f| File.file?(f) }\n\n abort \"No package files.\" if files.empty?\n\n files.each do |file|\n abort \"Not a file -- #{file}\" unless File.exist?(file)\n puts \"Release file: #{File.basename(file)}\"\n end\n\n # which package types\n #rtypes = [ 'tgz', 'tbz', 'tar.gz', 'tar.bz2', 'deb', 'gem', 'ebuild', 'zip' ]\n #rtypes -= exclude\n #rtypes = rtypes.collect{ |rt| Regexp.escape( rt ) }\n #re_rtypes = Regexp.new('[.](' << rtypes.join('|') << ')$')\n\n puts \"Releasing #{package} #{release} to #{unixname} project...\" #unless options['quiet']\n\n login do\n\n raise ArgumentError, \"missing group_id\" unless group_id\n\n unless package_id = package?(package)\n if trial?\n puts \"Package '#{package}' does not exist.\"\n puts \"Create package #{package}.\"\n abort \"Cannot continue in trial mode.\"\n else\n #unless options['force']\n q = \"Package '#{package}' does not exist. Create?\"\n a = ask(q, 'yN')\n abort \"Task canceled.\" unless ['y', 'yes', 'okay'].include?(a.downcase)\n #end\n puts \"Creating package #{package}...\"\n create_package(package, is_public)\n unless package_id = package?(package)\n raise \"Package creation failed.\"\n end\n end\n end\n if release_id = release?(release, package_id)\n #unless options[:force]\n if trial?\n puts \"Release #{release} already exists.\"\n else\n q = \"Release #{release} already exists. Re-release?\"\n a = ask(q, 'yN')\n abort \"Task canceled.\" unless ['y', 'yes', 'okay'].include?(a.downcase)\n #puts \"Use -f option to force re-release.\"\n #return\n end\n files.each do |file|\n fname = File.basename(file)\n if file_id = file?(fname, package)\n if trial?\n puts \"Remove file #{fname}.\"\n else\n puts \"Removing file #{fname}...\"\n remove_file(file_id, release_id, package_id)\n end\n end\n if trial?\n puts \"Add file #{fname}.\"\n else\n puts \"Adding file #{fname}...\"\n add_file(file, release_id, package_id, processor)\n end\n end\n else\n if trial?\n puts \"Add release #{release}.\"\n else\n puts \"Adding release #{release}...\"\n add_release(release, package_id, files,\n :processor => processor,\n :release_date => date,\n :release_changes => release_changes,\n :release_notes => release_notes,\n :preformatted => '1'\n )\n unless release_id = release?(release, package_id)\n raise \"Release creation failed.\"\n end\n end\n #files.each do |file|\n # puts \"Added file #{File.basename(file)}.\"\n #end\n end\n end\n puts \"Release complete!\" unless trial?\n end", "def index\n @press_releases = PressRelease.all\n end", "def get_release(release_id)\n query_and_build \"releases/#{release_id}\"\n end", "def create\n @release = Release.new(release_params)\n\n # release_title = release_params[:title]\n # artist_name = @artist.name\n #\n # discogs_api_key = ENV.fetch('DISCOGS_API_KEY')\n # discogs_secret_api_key = ENV.fetch('DISCOGS_SECRET_API_KEY')\n #\n # response = HTTParty.get(\"https://api.discogs.com/database/search?release_title=#{release_title}&artist=#{artist_name}&key=#{discogs_api_key}&secret=#{discogs_secret_api_key}\")\n\n # byebug\n\n response['results'].each do |result|\n if result['format'].include? \"Vinyl\"\n @release.artist_id = @artist\n\n release_title = response['title'].split(' - ').last\n @release.title = release_title\n\n format_array = response['format'].split(' ')\n format_type = format_array.select { |format| format == \"LP\" }\n @release.format = format_type.join\n\n @release.released_at = response['year']\n @release.image_data = response['images'][0]['resource_url']\n @release.country_code = response['id']\n @release.format = response['id']\n @release.artist_id = response['id']\n end\n end\n\n respond_to do |format|\n if @release.save\n format.html { redirect_to @release, notice: 'Release was successfully created.' }\n format.json { render :show, status: :created, location: @release }\n else\n format.html { render :new }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end", "def write_repository(product_dir, releases)\n platforms = releases.map { |release| release[:platform] }.uniq\n platforms.each do |platform|\n configuration_directory = File.join(product_dir, platform)\n FileUtils.mkdir_p(configuration_directory)\n releases_by_version = Hash.new { |hash, key| hash[key] = [] }\n releases.each do |release|\n next if release[:platform] != platform\n\n releases_by_version[release[:version]] << extract_release_fields(release)\n end\n releases_by_version.each_pair do |version, version_releases|\n File.write(File.join(configuration_directory, \"#{version.gsub('/', '-')}.json\"),\n JSON.pretty_generate(version_releases))\n end\n end\n end", "def create!\n doc.kubernetes_release.builds = [builds(:docker_build)]\n Kubernetes::ReleaseDoc.create!(\n doc.attributes.except('id', 'resource_template').merge(kubernetes_release: doc.kubernetes_release)\n )\n end", "def index\n @client_releases = ClientRelease.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @client_releases }\n end\n end", "def release_version!\n projects.each { |project| project.release_version!(tag_full_name) }\n print_log 'Versions released'\n slack_notifier.ping(release_message, icon_emoji: ':see_no_evil:')\n end", "def get(*args)\n arguments(args, required: [:owner, :repo, :id]).params\n\n get_request(\"/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}\" , arguments.params)\n end", "def execute_ruby_release(type:)\n version_regex = %r{.version\\s*=\\s*'([\\d\\.]+)'}\n gemspec_path = Dir.glob(\"*.gemspec\").first\n gemspec_contents = File.read(gemspec_path)\n version = gemspec_contents.match(version_regex)[1]\n version = Semverse::Version.new(version)\n new_version = \"0.0.5\"\n gemspec_contents = gemspec_contents.sub(version_regex, \".version = '#{new_version}'\")\n\n gemspec_folder_obj = octokit.contents(@originating_repo,)\n gemspec_file_obj = gemspec_folder_obj.find { |file| file[:name] == gemspec_path }\n gemspec_file = octokit.blob(@originating_repo, gemspec_file_obj[:sha])\n gemspec_obj = octokit.contents(@originating_repo, path: gemspec_path)\n gemspec_sha = gemspec_file['sha']\n contents = Base64.encode64(gemspec_contents)\n json = {\n message: \"Updating to #{new_version}\",\n content: contents,\n sha: gemspec_sha\n }.to_json\n\n gemspec_file_obj = octokit.update_contents(@originating_repo, gemspec_path, \"Release #{new_version}\", gemspec_sha, gemspec_contents)\n octokit.add_comment(@originating_repo, @pr_number, \"Thanks! This is now out in #{new_version}\")\n end", "def list_releases(workspace_id)\n # check and reauthenticate\n self.isTokenExpired()\n\n results = []\n url = @api_url + \"/api/workspaces/#{workspace_id}/releases\"\n headers = {:accept => :json, :authorization => \"bearer #{@access_token}\"}\n\n RestClient.proxy = @proxy\n\n begin\n r = RestClient.get url, headers\n rescue RestClient::ExceptionWithResponse => e\n puts e.response\n end\n\n releases = JSON.parse(r.body)['data']\n #release_count = JSON.parse(r.body)['TotalResults']\n\n #puts \"releases dump is #{JSON.pretty_generate(releases)}\\nrelease count is #{release_count}\"\n\n releases.each do |release|\n results.push(release)\n end\n return results\n end", "def press_release_params\n params.require(:press_release).permit(:title, :article, :published_on)\n end", "def publish!\n release_file = build_role 'release', release\n\n timestamp.replace(release_file)\n\n timestamp_file = build_role 'timestamp', timestamp\n\n bucket.create(release_file.path_with_hash, release_file.body)\n bucket.create(timestamp_file.path, timestamp_file.body)\n end", "def add_key_and_product_to_releases(releases, key, product)\n releases.each do |release|\n release[:repo_key] ||= key unless key.nil?\n release[:product] = product\n end\n end", "def releases=(releases_from_response)\n if !releases_from_response.nil? && !releases_from_response.countries?\n @releases = Enceladus::Release.build_collection(releases_from_response.countries)\n end\n end", "def deploy(release_docs)\n release_docs.each do |release_doc|\n @output.puts \"Creating for #{release_doc.deploy_group.name} role #{release_doc.kubernetes_role.name}\"\n release_doc.deploy\n end\n end", "def destroy\n @press_release.destroy\n respond_to do |format|\n format.html { redirect_to press_releases_url }\n format.json { head :no_content }\n end\n end", "def fetch_releases\n require \"open-uri\"\n\n open(RELEASE_URL) { |f| f.read.scan RELEASE_REGEXP }\n end", "def github_released\n puts green(\"Release completed\")\n end", "def release_url(api_url, title)\n # \"subject\": {\n # \"title\": \"v1.4.4\",\n # \"url\": \"https://api.github.com/repos/typed-ember/ember-cli-typescript/releases/13191777\",\n # \"latest_comment_url\": \"https://api.github.com/repos/typed-ember/ember-cli-typescript/releases/13191777\",\n # \"type\": \"Release\"\n # },\n api_index = api_url.index(\"api\")\n repos_index = api_url.index(\"repos\")\n releases_index = api_url.index(\"releases\")\n\n # https://github.com/typed-ember/ember-cli-typescript/releases/tag/v1.4.4\n html_url = api_url[0..api_index - 1] +\n api_url[api_index + \"api.\".length..repos_index - 1] +\n api_url[repos_index + \"repos/\".length..releases_index + \"releases\".length] +\n \"tag/#{title}\"\n html_url\n end", "def add_release(release_name, package_id, *files)\n page = \"/frs/admin/qrs.php\"\n\n options = (Hash===files.last ? files.pop : {}).rekey\n files = files.flatten\n\n processor = options[:processor]\n release_date = options[:release_date]\n release_changes = options[:release_changes]\n release_notes = options[:release_notes]\n\n release_date ||= Time::now.strftime(\"%Y-%m-%d %H:%M\")\n\n file = files.shift\n puts \"Adding file #{File.basename(file)}...\"\n userfile = open(file, 'rb')\n\n type_id = userfile.path[%r|\\.[^\\./]+$|]\n type_id = FILETYPES[type_id]\n processor_id = PROCESSORS[processor.downcase]\n\n preformatted = '1'\n\n form = {\n \"group_id\" => group_id,\n \"package_id\" => package_id,\n \"release_name\" => release_name,\n \"release_date\" => release_date,\n \"type_id\" => type_id,\n \"processor_id\" => processor_id,\n \"release_notes\" => release_notes,\n \"release_changes\" => release_changes,\n \"preformatted\" => preformatted,\n \"userfile\" => userfile,\n \"submit\" => \"Release File\"\n }\n\n boundary = Array::new(8){ \"%2.2d\" % rand(42) }.join('__')\n boundary = \"multipart/form-data; boundary=___#{ boundary }___\"\n\n html = http_post(page, form, 'content-type' => boundary)\n\n release_id = html[/release_id=\\d+/][/\\d+/].to_i\n puts \"RELEASE ID = #{release_id}\" if $DEBUG\n\n files.each do |file|\n puts \"Adding file #{File.basename(file)}...\"\n add_file(file, release_id, package_id, processor)\n end\n\n release_id\n end", "def create\n @revision = Revision.new(params[:revision])\n\n if @revision.save\n render json: @revision, status: :created, location: @revision\n else\n render json: @revision.errors, status: :unprocessable_entity\n end\n end", "def press_release_params\n params.require(:press_release).permit(:media_type, :media_name, :url, :published_at, :abstract)\n end", "def release_params\n # params.require(:content).permit!(:releases_attributes)\n params.require(:content).permit(releases_attributes: [:screen_id, :_destroy, :id])\n end", "def get_releases(artist_id, options={})\n api_response = @api_client.make_api_request(:GET, \"artist/releases\", {:artistId => artist_id}, options)\n @api_client.release_digestor.list_from_xml(api_response.content.releases)\n end", "def new\n @client_release = ClientRelease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client_release }\n end\n end", "def release\n context.execute \"[ $(ls -A #{release_path} | wc -l) -gt 0 ] || ( cd #{release_path} && tar -xzf #{repo_path}/#{release_timestamp}.tar.gz )\"\n end", "def db_insert_releases(db, org, repo, releases)\n db.transaction do\n releases.each do |release|\n db[\n \"DELETE FROM releases WHERE org=? AND repo=? AND id::int=?\", org, repo, release.id].delete\n\n # Sometimes there is no author. Instead, fill in the data with the first file's uploader\n if(release.author)\n author=release.author.login\n else\n if(release.assets and release.assets[0] and release.assets[0].uploader)\n author=release.assets[0].uploader.login\n # puts \"Unable to find an author for #{release.html_url}; using uploader: #{author}\"\n else\n author=nil\n # puts \"Unable to find an author or uploader for #{release.html_url}\"\n end\n end\n\n\t # only include releases that were published\n\t if(release.published_at)\n\t db[\n \t \"INSERT INTO releases (\n\t org, repo, id, html_url, tarball_url, zipball_url, tag_name, name, body, created_at, published_at, author\n\t )\n\t VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )\",\n\t org, repo, release.id, release.html_url, release.tarball_url, release.zipball_url, release.tag_name, release.name, release.body, release.created_at.to_s,\n\t release.published_at.to_s, author].insert\n\t end\n end\n end\n end", "def post(revision, key, options)\n post_path(\n path_to_post(revision),\n options.merge(key: key),\n get_parser(:object, Tinybucket::Model::BuildStatus)\n )\n end", "def release\n variables[:release]\n end", "def show\n @release = Release.find(params[:id])\n @total_downloads = 0\n @release.versions.each do |v|\n @total_downloads += v.downloads\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @release }\n end\n end", "def release\n _init\n\n @release = Release.find_by_name(params[:release]) if params[:release]\n @release = Release.actived.first unless @release\n\n render :template => 'sprint/release', :layout => 'release'\n end", "def releases\n self.class.releases\n end", "def releases\n self.class.releases\n end", "def create\n response = get_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers/\"+params[:containerID].to_s+\"/deploy.json\"), (sesh :current_token))\n json_respond response.body\n end", "def update\n @release = @environment.releases.find(params[:id])\n\n respond_to do |format|\n if @release.update_attributes(params[:release])\n format.html { redirect_to @release, notice: 'Release was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_softwarerepository_release_with_http_info(softwarerepository_release, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SoftwarerepositoryApi.create_softwarerepository_release ...'\n end\n # verify the required parameter 'softwarerepository_release' is set\n if @api_client.config.client_side_validation && softwarerepository_release.nil?\n fail ArgumentError, \"Missing the required parameter 'softwarerepository_release' when calling SoftwarerepositoryApi.create_softwarerepository_release\"\n end\n # resource path\n local_var_path = '/api/v1/softwarerepository/Releases'\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 # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\n header_params[:'If-None-Match'] = opts[:'if_none_match'] if !opts[:'if_none_match'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(softwarerepository_release)\n\n # return_type\n return_type = opts[:debug_return_type] || 'SoftwarerepositoryRelease'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"SoftwarerepositoryApi.create_softwarerepository_release\",\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(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SoftwarerepositoryApi#create_softwarerepository_release\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def destroy\n @os_release = OsRelease.find(params[:id])\n @os_release.destroy\n\n respond_to do |format|\n format.html { redirect_to os_releases_url }\n format.json { head :no_content }\n end\n end", "def create\n @package = Package.create(package_params)\n\n render json: @package\n end", "def release_params\n params.require(:release).permit(:locale_id)\n end", "def create_release_docs(params)\n params[:deploy_groups].to_a.each do |dg|\n dg[:roles].to_a.each do |role|\n release_docs.create!(deploy_group_id: dg[:id], kubernetes_role_id: role[:id], replica_target: role[:replicas])\n end\n end\n raise 'No Kubernetes::ReleaseDoc has been created' if release_docs.empty?\n end" ]
[ "0.7505364", "0.69592404", "0.68975914", "0.6603602", "0.6592334", "0.65453446", "0.65143144", "0.65005416", "0.64981085", "0.6413345", "0.63938975", "0.6342077", "0.6297878", "0.62877405", "0.61712164", "0.6131038", "0.61087114", "0.6082761", "0.6064941", "0.6031521", "0.5979934", "0.5979934", "0.5979782", "0.5976675", "0.59199953", "0.5917547", "0.59164804", "0.59164804", "0.5906665", "0.5895175", "0.5891999", "0.5879082", "0.5823717", "0.5820119", "0.5808644", "0.5790944", "0.57739234", "0.57665557", "0.5759223", "0.5729568", "0.57248914", "0.5686089", "0.5680827", "0.56734264", "0.5657051", "0.56525666", "0.56476295", "0.5637108", "0.5630602", "0.56092465", "0.56041193", "0.55815", "0.5580613", "0.5577828", "0.5567344", "0.5555935", "0.5539433", "0.55305624", "0.5529168", "0.5482071", "0.54820323", "0.5479549", "0.5471758", "0.5469928", "0.5469273", "0.5452749", "0.5449778", "0.54458123", "0.54383427", "0.5436587", "0.54339564", "0.5418712", "0.53986436", "0.5382199", "0.5378422", "0.53754956", "0.53650814", "0.5350136", "0.5347089", "0.53448635", "0.5338191", "0.5325883", "0.531501", "0.53128695", "0.5290515", "0.5282122", "0.52820915", "0.5281763", "0.52665114", "0.5256591", "0.5252789", "0.52370805", "0.52370805", "0.5227963", "0.5226403", "0.52251524", "0.5222694", "0.5215252", "0.5210677", "0.5209893" ]
0.6215092
14
PUT /releases/1 PUT /releases/1.json
def update @release = Release.find(params[:id]) respond_to do |format| if @release.update_attributes(params[:release]) format.html { redirect_to cashier_release_path(current_user), notice: 'Release was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @release.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @release = @environment.releases.find(params[:id])\n\n respond_to do |format|\n if @release.update_attributes(params[:release])\n format.html { redirect_to @release, notice: 'Release was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit(*args)\n arguments(args, required: [:owner, :repo, :id])\n\n patch_request(\"/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}\", arguments.params)\n end", "def create\n @release = @environment.releases.new(params[:release])\n\n respond_to do |format|\n if @release.save\n format.html { redirect_to @release, notice: 'Release was successfully created.' }\n format.json { render json: @release, status: :created, location: @release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_aos_version(args = {}) \n post(\"/aosversions.json/\", args)\nend", "def update\n @os_release = OsRelease.find(params[:id])\n\n respond_to do |format|\n if @os_release.update_attributes(params[:os_release])\n format.html { redirect_to @os_release, notice: 'Os release was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @os_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @release.update(release_params)\n format.html { redirect_to @release, notice: 'Release was successfully updated.' }\n format.json { render :show, status: :ok, location: @release }\n else\n format.html { render :edit }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end", "def release(project_id, release_id, options = {})\n get \"projects/#{project_id}/releases/#{release_id}\", options\n end", "def execute_ruby_release(type:)\n version_regex = %r{.version\\s*=\\s*'([\\d\\.]+)'}\n gemspec_path = Dir.glob(\"*.gemspec\").first\n gemspec_contents = File.read(gemspec_path)\n version = gemspec_contents.match(version_regex)[1]\n version = Semverse::Version.new(version)\n new_version = \"0.0.5\"\n gemspec_contents = gemspec_contents.sub(version_regex, \".version = '#{new_version}'\")\n\n gemspec_folder_obj = octokit.contents(@originating_repo,)\n gemspec_file_obj = gemspec_folder_obj.find { |file| file[:name] == gemspec_path }\n gemspec_file = octokit.blob(@originating_repo, gemspec_file_obj[:sha])\n gemspec_obj = octokit.contents(@originating_repo, path: gemspec_path)\n gemspec_sha = gemspec_file['sha']\n contents = Base64.encode64(gemspec_contents)\n json = {\n message: \"Updating to #{new_version}\",\n content: contents,\n sha: gemspec_sha\n }.to_json\n\n gemspec_file_obj = octokit.update_contents(@originating_repo, gemspec_path, \"Release #{new_version}\", gemspec_sha, gemspec_contents)\n octokit.add_comment(@originating_repo, @pr_number, \"Thanks! This is now out in #{new_version}\")\n end", "def create\n # Extract the version info\n release = params[:release]\n version = params[:release][:version]\n release.delete(\"version\")\n \n # Validate input\n if (release[:name] == \"\")\n flash[:notice] = \"You must supply a name for the release\"\n respond_to do |format|\n format.html { redirect_to :action => 'new' }\n format.json { head :no_content }\n end\n elsif (release[:source_url] == \"\")\n flash[:notice] = \"You must supply a source URL\"\n respond_to do |format|\n format.html { redirect_to :action => 'new' }\n format.json { head :no_content }\n end\n else\n # Add http:// prefix to source_url if it doesn't already exist\n release[:source_url] = \"http://#{release[:source_url]}\" if not release[:source_url].starts_with? \"http://\" and not release[:source_url].starts_with? \"https://\"\n \n @release = Release.new(release)\n @release.user = current_user\n \n # Add the version info\n # If the URL doesn't start with http:// or https://, add it\n version[:download_url] = \"http://#{version[:download_url]}\" if not version[:download_url].starts_with? \"http://\" and not version[:download_url].starts_with? \"https://\"\n \n @version = Version.new(version)\n @version.version_number = 1\n @version.release = @release\n @release.versions << @version\n\n respond_to do |format|\n if @release.save\n format.html { redirect_to @release, notice: 'Release was successfully created.' }\n format.json { render json: @release, status: :created, location: @release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def destroy\n @release = @environment.releases.find(params[:id])\n @release.destroy\n\n respond_to do |format|\n format.html { redirect_to releases_url }\n format.json { head :no_content }\n end\n end", "def new_releases\n api_call(\"https://api.spotify.com/\",\"/v1/browse/new-releases\")\n end", "def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def post_release_v2(app_name, slug, dyno_types, user, token,\n slug_url, repo_size)\n slug_url_regex = /https:\\/\\/(.+?)\\.s3\\.amazonaws\\.com\\/(.+?)\\?/\n _, slug_put_key, slug_put_bucket = slug_url.match(slug_url_regex).to_a\n start = Time.now\n payload = {\n # \"head\" => head,\n # \"prev_head\" => commit_hash,\n # \"current_seq\" => current_seq,\n \"slug_put_key\" => slug_put_key,\n \"slug_put_bucket\" => slug_put_bucket,\n \"repo_size\" => repo_size,\n \"release_descr\" => \"sokoban-built release\", # punting for v2\n \"language_pack\" => \"Sokoban\", # punting for v2\n \"buildpack\" => \"Sokoban\", # punting for v2\n \"slug_version\" => 2,\n \"slug_size\" => File.size(slug),\n \"stack\" => \"cedar\",\n \"user\" => user,\n \"process_types\" => dyno_types,\n \"git_log\" => \"\",\n \"run_deploy_hooks\" => false,\n \"addons\" => {},\n \"config_vars\" => {}}\n\n release_name =\n Timeout.timeout(30) do\n uri = URI.parse(release_uri(app_name))\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Post.new(uri.request_uri)\n if uri.scheme == \"https\"\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n request.basic_auth(user, token)\n request[\"Content-Type\"] = \"application/json\"\n request[\"Accept\"] = \"application/json\"\n request.body = JSON.unparse(payload)\n response = http.request(request)\n if (response.code != \"200\")\n error_message = begin\n response.body && JSON.parse(response.body)[\"error\"] || \"failure releasing code\"\n rescue Timeout::Error\n \"timed out releasing code\"\n rescue\n \"failure releasing code\"\n end\n raise(error_message)\n end\n response.body\n end\n release_name\n end", "def update\n @release = Release.find(params[:id])\n \n if current_user.id != @release.user.id\n respond_to do |format|\n format.html { redirect_to @release, notice: \"You do not have permission to edit this release\" }\n format.json { head :no_content }\n end\n end\n\n respond_to do |format|\n if @release.update_attributes(:name => params[:release][:name], :description => params[:release][:description])\n format.html { redirect_to @release, notice: 'Release was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.put(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end", "def write_release(payload)\n info 'Creating new release on GitHub'\n rel = payload[:data][:github_kit].delete(:release)\n release = github_client.create_release(\n rel[:repository],\n rel[:tag_name],\n :name => rel[:name],\n :target_commitish => rel[:reference],\n :prerelease => rel[:prerelease],\n :body => rel[:body]\n )\n\n api_release_url = release.rels[:self].href\n public_release_url = release.rels[:html].href\n\n info 'New release created on GitHub. Uploading assets.'\n assets = rel[:assets].map do |asset|\n debug \"Uploading release asset - #{asset}\"\n response = github_client.upload_asset(\n api_release_url,\n asset_store.get(asset),\n :name => asset.sub(/^.+?_/, ''),\n :content_type => 'application/octet-stream'\n )\n debug \"Completed release asset upload - #{asset}\"\n Smash.new(\n :url => response[:url],\n :browser_url => response[:browser_download_url],\n :name => response[:name],\n :id => response[:id]\n )\n end\n payload.set(:data, :github_kit, :release, :assets, assets)\n payload.set(:data, :github_kit, :release, :api_url, api_release_url)\n payload.set(:data, :github_kit, :release, :public_url, public_release_url)\n\n true\n end", "def update\n respond_to do |format|\n if @object_release.update(object_release_params)\n format.html { redirect_to @object_release, notice: 'Object release was successfully updated.' }\n format.json { render :show, status: :ok, location: @object_release }\n else\n format.html { render :edit }\n format.json { render json: @object_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @press_release.update(press_release_params)\n format.html { redirect_to @press_release, notice: 'Press release was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @press_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @release = @environment.releases.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @release }\n end\n end", "def index\n @releases = @environment.releases.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @releases }\n end\n end", "def add_aos_version_box(args = {}) \n post(\"/aosversions.json/aosversionbox\", args)\nend", "def update\n respond_to do |format|\n if @press_release.update(press_release_params)\n format.html { redirect_to @press_release, notice: 'Press release was successfully updated.' }\n format.json { render :show, status: :ok, location: @press_release }\n else\n format.html { render :edit }\n format.json { render json: @press_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @release.update(release_params)\n format.html { redirect_to [@project, @release], notice: 'Release atualizada com sucesso.' }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n @client_release = ClientRelease.find(params[:id])\n\n respond_to do |format|\n if @client_release.update_attributes(params[:client_release])\n format.html { redirect_to @client_release, notice: 'Client release was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @os_release = OsRelease.find(params[:id])\n @os_release.destroy\n\n respond_to do |format|\n format.html { redirect_to os_releases_url }\n format.json { head :no_content }\n end\n end", "def release\n case new_resource.version\n when 'latest'\n require 'octokit'\n Octokit.releases(repo).first[:tag_name]\n else\n \"v#{new_resource.version}\"\n end\n end", "def deploy_api(name, rev, env, path)\n post(\"/apis/#{name}/revisions/#{rev}/deployments\", {:action => 'deploy', :env => env, :basepath => path})\n end", "def put(*args)\n request :put, *args\n end", "def update(dir, name = nil)\n since = Changelog.last_sha(@releases)\n release = Release.new(name)\n release.update(dir, since)\n add_release(release)\n end", "def update\n @persons_release = PersonsRelease.find(params[:id])\n\n respond_to do |format|\n if @persons_release.update_attributes(params[:persons_release])\n format.html { redirect_to @persons_release, notice: 'Persons release was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @persons_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @os_release = OsRelease.new(params[:os_release])\n\n respond_to do |format|\n if @os_release.save\n format.html { redirect_to @os_release, notice: 'Os release was successfully created.' }\n format.json { render json: @os_release, status: :created, location: @os_release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @os_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_release\n @release = Release.find(params[:id])\n end", "def set_release\n @release = Release.find(params[:id])\n end", "def set_release\n @release = Release.find(params[:id])\n end", "def set_release\n @release = Release.find(params[:id])\n end", "def update_release(stuff, release, fields)\r\n\trelease.update(fields)\r\nend", "def request_release(options = {})\n response = JSON.parse(@client.patch(\"items/#{send(:id)}/request_release\", options).body)\n @attributes = response['items']\n true\n end", "def request_release(options = {})\n response = JSON.parse(@client.patch(\"items/#{send(:id)}/request_release\", options).body)\n @attributes = response['items']\n true\n end", "def index\n @releases = Release.all\n end", "def index\n @releases = Release.all\n end", "def update\n respond_to do |format|\n if @deployment.update(deployment_params)\n services_params(@deployment).each do |service_name, version_name|\n version = Version.find_by(name: version_name)\n @deployment.versions << version if version\n end\n @deployment.save\n format.html { redirect_to @deployment, notice: 'Deployment was successfully updated.' }\n format.json { render :show, status: :ok, location: @deployment }\n else\n format.html { render :edit }\n format.json { render json: @deployment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def put(*args)\n request(:put, *args)\n end", "def update\n if @repo.update(repo_params)\n render json: JSONAPI::Serializer.serialize(@repo), status: :ok\n else\n render json: { errors: repo.errors }, status: :unprocessable_entity\n end\n end", "def release\n action('release')\n end", "def set_release\n @release = Admin::Release.find(params[:id])\n end", "def destroy\n @client_release = ClientRelease.find(params[:id])\n @client_release.destroy\n\n respond_to do |format|\n format.html { redirect_to client_releases_url }\n format.json { head :ok }\n end\n end", "def release\n configs = store(:get, 'configs').to_s.gsub(\"\\n\", \" \")\n \n # TODO: if error, user need to deploy code first (nothing to deploy) => use a special exit code \n # when code is not pushed or only deploy if app has a correct build\n version = @api.release(@name, configs).to_s.chomp.gsub(\"\\n\", \" \")\n backend = @api.run(@name, :web, version).to_s.chomp.gsub(\"\\n\", \" \")\n @api.route @name, backend\n return version\n end", "def show\n @release = Release.find(params[:id])\n @total_downloads = 0\n @release.versions.each do |v|\n @total_downloads += v.downloads\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @release }\n end\n end", "def create_release(attrs = {})\n release = build_release(attrs)\n release.save\n release\n end", "def destroy\n @press_release.destroy\n respond_to do |format|\n format.html { redirect_to press_releases_url }\n format.json { head :no_content }\n end\n end", "def create\n @cashier = Cashier.find(params[:cashier_id])\n @release = @cashier.releases.build(params[:release])\n\n #@release.date_release = post_date Date.today\n respond_to do |format|\n if @release.save\n format.html { redirect_to cashier_path(@cashier), notice: 'Release was successfully created.' }\n #format.html { redirect_to cashier_release_path(@release.cashier, @release), notice: 'Release was successfully created.' }\n format.json { render json: @release, status: :created, location: @release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n head :ok\n end", "def release\n _init\n\n @release = Release.find_by_name(params[:release]) if params[:release]\n @release = Release.actived.first unless @release\n\n render :template => 'sprint/release', :layout => 'release'\n end", "def release_version!\n projects.each { |project| project.release_version!(tag_full_name) }\n print_log 'Versions released'\n slack_notifier.ping(release_message, icon_emoji: ':see_no_evil:')\n end", "def update\n respond_to do |format|\n if @release_main.update(release_main_params)\n format.html { redirect_to @release_main, notice: 'Release main was successfully updated.' }\n format.json { render :show, status: :ok, location: @release_main }\n else\n format.html { render :edit }\n format.json { render json: @release_main.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(*args)\n put(*args)\n end", "def update(*args)\n put(*args)\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 update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n respond_to do |format|\n if @release_item.update(release_item_params)\n format.html { redirect_to @release_item, notice: 'Release item was successfully updated.' }\n format.json { render :show, status: :ok, location: @release_item }\n else\n format.html { render :edit }\n format.json { render json: @release_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n self.publish_json\n end", "def vagrant_json_update(image_name, version_entry)\n # Load the vagrant JSON file\n json_file = File.new(\"#{Packer::OUTPUT_DIR}/#{image_name}.json\", 'w+')\n json_str = json_file.read\n \n # Load the JSON data\n begin\n json_data = JSON.load json_str\n rescue JSON::ParserError\n json_data = {\n \"name\" => image_name,\n \"versions\" => []\n }\n end\n\n # This will make sure there are no duplicate\n # entries for each box version specified in the\n # JSON file\n json_data['versions'].each_index do |i|\n box_version = json_data['versions'][i]\n if box_version['version'] == version_entry['version']\n json_data['versions'][i].delete\n break\n end\n end\n\n # Insert the new version entry\n json_data['versions'].push version_entry\n \n # Write the thing\n json_file.puts JSON.dump json_data\nend", "def github_post\n {\n \"create\" => ->(release) { start_deployment(release) },\n \"update_status\" => ->(release) { update_deployment(release) }\n }\n end", "def create(*args)\n arguments(args, required: [:owner, :repo]) do\n assert_required :tag_name\n end\n\n post_request(\"/repos/#{arguments.owner}/#{arguments.repo}/releases\",\n arguments.params)\n end", "def put!\n request! :put\n end", "def update\n @license = License.find(params[:id])\n @license.update_attributes(params[:license])\n respond_with(@license, :location => licenses_path)\n end", "def delete(*args)\n arguments(args, required: [:owner, :repo, :id]).params\n\n delete_request(\"/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}\", arguments.params)\n end", "def tag_release(version)\n system \"git tag v#{version}\"\n system \"git push origin v#{version}\"\n end", "def update\n respond_to do |format|\n if @version.update(version_params)\n format.html { redirect_to @version, notice: 'Version was successfully updated.' }\n format.json { render :show, status: :ok, location: @version }\n else\n format.html { render :edit }\n format.json { render json: @version.errors, status: :unprocessable_entity }\n end\n end\n end", "def release_params\n params.require(:release).permit(:version, :deliver_date, :project_id)\n end", "def release!\n version = Origen.app.version\n body = { version: version.to_s }\n if version.production?\n body[:type] = :production\n else\n body[:type] = :development\n end\n post(\"plugins/#{Origen.app.name}/release\", body: body)\n end", "def test_bump_release_candidate_to_release\n value_ = ::Versionomy.create(:major => 2, :tiny => 1, :release_type => :release_candidate, :release_candidate_version => 2)\n value_ = value_.bump(:release_type)\n assert_equal(2, value_.major)\n assert_equal(0, value_.minor)\n assert_equal(1, value_.tiny)\n assert_equal(0, value_.tiny2)\n assert_equal(:final, value_.release_type)\n assert_equal(0, value_.patchlevel)\n assert_equal(0, value_.patchlevel_minor)\n end", "def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end", "def put url, object = nil\n request url, HTTP::Put, object\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def release\n git :archive, fetch(:branch), fetch(:project_root), '| tar -x -C', release_path, \"--strip=#{fetch(:project_root).count('/')+1}\"\n end", "def release_params\n params.require(:release).permit(:system_id, :versao, :dt_implantacao, :descricao)\n end", "def update\n @sprint.update!(sprint_params)\n json_response(@sprint)\n end", "def releases(country = nil)\n Birdman::Requester.get(\"movies/#{id}/releases/#{country}\")\n end", "def create\n @object_release = ObjectRelease.new(object_release_params)\n\n respond_to do |format|\n if @object_release.save\n format.html { redirect_to @object_release, notice: 'Object release was successfully created.' }\n format.json { render :show, status: :created, location: @object_release }\n else\n format.html { render :new }\n format.json { render json: @object_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n put :update\n end", "def update!(**args)\n @versions = args[:versions] if args.key?(:versions)\n end", "def update!(**args)\n @versions = args[:versions] if args.key?(:versions)\n end", "def update!(**args)\n @versions = args[:versions] if args.key?(:versions)\n end", "def create\n @client_release = ClientRelease.new(params[:client_release])\n\n respond_to do |format|\n if @client_release.save\n format.html { redirect_to @client_release, notice: 'Client release was successfully created.' }\n format.json { render json: @client_release, status: :created, location: @client_release }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client_release.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @release.destroy\n respond_to do |format|\n format.html { redirect_to releases_url, notice: 'Release was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def publish!\n release_file = build_role 'release', release\n\n timestamp.replace(release_file)\n\n timestamp_file = build_role 'timestamp', timestamp\n\n bucket.create(release_file.path_with_hash, release_file.body)\n bucket.create(timestamp_file.path, timestamp_file.body)\n end", "def put(revision, key, options)\n put_path(\n path_to_put(revision, key),\n options,\n get_parser(:object, Tinybucket::Model::BuildStatus)\n )\n end", "def set_release_status\n @release_status = ReleaseStatus.find(params[:id])\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @releases = args[:releases] if args.key?(:releases)\n @unreachable = args[:unreachable] if args.key?(:unreachable)\n end", "def update\n @release = Release.find(params[:id])\n\n @params = params[:payment] || params[:receipt]\n\n respond_to do |format|\n if @release.update_attributes(@params)\n format.html { redirect_to path_of_release(@release), notice: \"Lançamento: #{@release.code} foi atualizado com sucesso!\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @release.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path, params={}, options={})\n request(:put, api_path(path), params, options)\n end", "def new\n @release = Release.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @release }\n end\n end", "def create_release(tag, message)\n\n if not is_valid_tag(tag)\n raise \"Invalid tag.\"\n end\n\n if message.empty?\n raise \n message = \"Release for #{tag}\"\n end\n\n message = {\n \"tag_name\": tag,\n \"target_commitish\": \"master\",\n \"name\": tag,\n \"body\": message,\n \"draft\": false,\n \"prerelease\": false\n }.to_json\n\n r = api_post(\"/releases\", message)\n\n if not r.kind_of? Net::HTTPCreated\n raise \"Creation of release unsuccessful.\"\n end\nend", "def update_softwarerepository_release_with_http_info(moid, softwarerepository_release, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SoftwarerepositoryApi.update_softwarerepository_release ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling SoftwarerepositoryApi.update_softwarerepository_release\"\n end\n # verify the required parameter 'softwarerepository_release' is set\n if @api_client.config.client_side_validation && softwarerepository_release.nil?\n fail ArgumentError, \"Missing the required parameter 'softwarerepository_release' when calling SoftwarerepositoryApi.update_softwarerepository_release\"\n end\n # resource path\n local_var_path = '/api/v1/softwarerepository/Releases/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\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 # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json', 'application/json-patch+json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(softwarerepository_release)\n\n # return_type\n return_type = opts[:debug_return_type] || 'SoftwarerepositoryRelease'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"SoftwarerepositoryApi.update_softwarerepository_release\",\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(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SoftwarerepositoryApi#update_softwarerepository_release\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def destroy\n @release.destroy\n respond_to do |format|\n format.html { redirect_to project_releases_path(@project), notice: 'Release deletada.' }\n end\n end", "def process_payload\n payload = params['release']\n repo = Repo.find_by(github_id: params['repository']['id'])\n\n render nothing: true, status: :forbidden and return if repo.inactive?\n\n release = Release.new(\n repo_id: repo.id,\n github_id: payload['id'],\n html_url: payload['html_url'],\n tag_name: payload['tag_name'],\n body: payload['body'],\n prerelease: payload['prerelease'],\n published_at: Time.iso8601(payload['published_at'])\n )\n\n if release.save\n render nothing: true, status: :created\n else\n render nothing: true, status: :bad_request\n end\n end", "def update\n @version = Version.find(params[:id])\n\n respond_to do |format|\n if @version.update_attributes(params[:version])\n format.html { redirect_to @version, notice: 'Version was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @version.errors, status: :unprocessable_entity }\n end\n end\n end", "def release_params\n params.require(:release).permit(:title, :release_date)\n end" ]
[ "0.69961613", "0.66472304", "0.6548969", "0.6501719", "0.6237336", "0.6217063", "0.61924106", "0.61672974", "0.61118084", "0.610501", "0.6090956", "0.6084025", "0.59731543", "0.58848184", "0.5874233", "0.5872731", "0.5849618", "0.5817447", "0.5811649", "0.58088154", "0.58061963", "0.57990545", "0.5783384", "0.5780944", "0.5748884", "0.57289886", "0.5704665", "0.56910145", "0.5675343", "0.5646731", "0.5636872", "0.56141245", "0.56141245", "0.56141245", "0.56141245", "0.56027466", "0.555006", "0.555006", "0.5545017", "0.5545017", "0.55367506", "0.5535958", "0.55245554", "0.5519754", "0.55153626", "0.5506699", "0.54762405", "0.54743", "0.54741985", "0.54351854", "0.54277945", "0.5397147", "0.53910327", "0.5387902", "0.53828484", "0.5373678", "0.5366792", "0.5366792", "0.53654677", "0.53550315", "0.5350596", "0.5349824", "0.533702", "0.53336877", "0.53265214", "0.53221846", "0.5320122", "0.53190726", "0.53174174", "0.531507", "0.53122056", "0.5304612", "0.53025717", "0.52985066", "0.52932805", "0.5291868", "0.52834326", "0.5281524", "0.52806747", "0.5280657", "0.52799106", "0.5265348", "0.52645403", "0.52645403", "0.52645403", "0.52634704", "0.52622855", "0.5260064", "0.52423716", "0.5238888", "0.52354246", "0.5235157", "0.5233661", "0.52288955", "0.52267736", "0.5226715", "0.5220845", "0.52185625", "0.52162635", "0.5213696" ]
0.6278123
4
DELETE /releases/1 DELETE /releases/1.json
def destroy @release = Release.find(params[:id]) #update_cashier(@release.value * -1) @release.view = false @release.save respond_to do |format| format.html { redirect_to cashier_path(params[:cashier_id]) } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @release = @environment.releases.find(params[:id])\n @release.destroy\n\n respond_to do |format|\n format.html { redirect_to releases_url }\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete(*args)\n arguments(args, required: [:owner, :repo, :id]).params\n\n delete_request(\"/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}\", arguments.params)\n end", "def destroy\n @os_release = OsRelease.find(params[:id])\n @os_release.destroy\n\n respond_to do |format|\n format.html { redirect_to os_releases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_release = ClientRelease.find(params[:id])\n @client_release.destroy\n\n respond_to do |format|\n format.html { redirect_to client_releases_url }\n format.json { head :ok }\n end\n end", "def destroy\n @press_release.destroy\n respond_to do |format|\n format.html { redirect_to press_releases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @release.destroy\n respond_to do |format|\n format.html { redirect_to project_releases_path(@project), notice: 'Release deletada.' }\n end\n end", "def destroy\n @release.destroy\n respond_to do |format|\n format.html { redirect_to releases_url, notice: 'Release was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n repo = assets_repo\n repo.destroy(params[:id])\n\n respond_to do |format|\n format.html { redirect_to v_assets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @press_release.destroy\n respond_to do |format|\n format.html { redirect_to press_releases_url, notice: 'Press release was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @version = Version.find(params[:id])\n @version.destroy\n\n respond_to do |format|\n format.html { redirect_to versions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_version = ApiVersion.find(params[:id])\n @api_version.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_api_versions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @persons_release = PersonsRelease.find(params[:id])\n @persons_release.destroy\n\n respond_to do |format|\n format.html { redirect_to persons_releases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ver.destroy\n respond_to do |format|\n format.html { redirect_to vers_url, notice: 'Ver was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @version.destroy\n respond_to do |format|\n format.html { redirect_to alfred_module_url(@a_module), notice: 'Version was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @object_release.destroy\n respond_to do |format|\n format.html { redirect_to object_releases_url, notice: 'Object release was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @distro.destroy\n respond_to do |format|\n format.html { redirect_to distros_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @package_version.destroy\n respond_to do |format|\n format.html { redirect_to package_versions_url, success: 'Package version was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @file_version = FileVersion.find(params[:id])\n @file_version.destroy\n\n respond_to do |format|\n format.html { redirect_to file_versions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @version.destroy\n respond_to do |format|\n format.html { redirect_to user_app_path(@user, @app), notice: 'Version was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @version = Version.find(params[:id])\n @versionconfig = @version.version_configurations.destroy_all\n @version.destroy\n\n respond_to do |format|\n format.html { redirect_to [@application, @version] }\n format.json { head :no_content }\n end\n end", "def destroy\n @distro = Distro.find(params[:id])\n @distro.destroy\n\n respond_to do |format|\n format.html { redirect_to distros_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_version = ApiVersion.find(params[:id])\n @api_version.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_api_versions_url, flash: {success: t('app.msgs.success_deleted', :obj => t('mongoid.models.api_version.one'))} }\n format.json { head :no_content }\n end\n end", "def destroy\n @fileversion = Fileversion.find(params[:id])\n @fileversion.destroy\n\n respond_to do |format|\n format.html { redirect_to fileversions_url }\n format.json { head :no_content }\n end\n end", "def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end", "def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end", "def destroy\n @manage_app_version.destroy\n respond_to do |format|\n format.html { redirect_to manage_app_versions_url, notice: 'App version was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @deployment = Deployment.find(params[:id])\n @deployment.destroy\n\n respond_to do |format|\n format.html { redirect_to deployments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @release_main.destroy\n respond_to do |format|\n format.html { redirect_to release_mains_url, notice: 'Release main was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @file_version.destroy\n head :no_content\n end", "def destroy\n @concrete_package_version.destroy\n respond_to do |format|\n format.html { redirect_to concrete_package_versions_url, success: 'Concrete package version was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @distro = Distro.find(params[:id])\n removefromaccount(\"distros\", @distro)\n @distro.destroy\n\n respond_to do |format|\n format.html { redirect_to distros_url }\n format.json { head :ok }\n end\n end", "def destroy\n @td_version.destroy\n respond_to do |format|\n format.html { redirect_to td_versions_url, notice: 'Td version was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @version_control.destroy\n respond_to do |format|\n format.html { redirect_to version_controls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @release_item.destroy\n respond_to do |format|\n format.html { redirect_to release_items_url, notice: 'Release item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @translations_versions_test.destroy\n respond_to do |format|\n format.html { redirect_to translations_versions_tests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @design_version.destroy\n respond_to do |format|\n format.html { redirect_to design_versions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @service_version = ServiceVersion.find(params[:id])\n @service_version.destroy\n\n respond_to do |format|\n format.html { redirect_to(service_versions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @revision = Revision.find(params[:id])\n @revision.destroy\n\n head :no_content\n end", "def destroy\n @admin_xampp_version.destroy\n respond_to do |format|\n format.html { redirect_to admin_xampp_versions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @package.status = nil\n @package.save!\n respond_to do |format|\n format.html { redirect_to packages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @release = Release.find(params[:id])\n \n if current_user.id == @release.user.id\n @release.destroy\n respond_to do |format|\n format.html { redirect_to \"/releases\" }\n format.json { head :no_content }\n end\n else\n # Do not have permission to delete this release\n respond_to do |format|\n format.html { redirect_to @release, notice: 'You do not have permission to delete this release'}\n format.json { head :no_content }\n end\n end \n end", "def destroy_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n @instrument_version.destroy\n\n respond_to do |format|\n format.html { redirect_to(instrument_versions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @revision = Revision.find(params[:id])\n @revision.destroy\n\n respond_to do |format|\n format.html { redirect_to @revision.page }\n format.json { head :no_content }\n end\n end", "def destroy\n repo = ProjectRepo.new current_user\n repo.destroy params[:id]\n\n respond_to do |format|\n format.html { redirect_to v_projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @nuage_version.destroy\n respond_to do |format|\n format.html { redirect_to nuage_versions_url, notice: \"Nuage version 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 @repo.destroy\n respond_to do |format|\n format.html { redirect_to repos_url }\n format.json { head :no_content }\n end\n end", "def delete_version( doc_id:, version: )\n params = {}\n params[:backtrace] = @backtrace if @backtrace\n send_request :delete, \"#{url_for_base doc_id}/#{version}\", params, :json\n end", "def destroy\n @dependency.destroy\n respond_to do |format|\n format.html { redirect_to dependencies_url, notice: 'Dependency was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delversion(version, project=self.project)\n post('delversion.json', project: project, version: version)\n end", "def destroy\n @node = Node.find_key(params[:id] || params[:name])\n @node.destroy\n respond_to do |format|\n format.html { redirect_to deployment_path(@node.deployment_id) }\n format.json { render api_delete @node }\n end\n end", "def delete_story_version(id)\n @client.raw('delete', \"/content/story-versions/#{id}\")\n end", "def delete_api_revision(name, rev)\n delete(\"/apis/#{name}/revision/#{rev}\")\n end", "def destroy\n @api_v1_progress.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_progresses_url, notice: 'Progress was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ezii_delta_git.destroy\n respond_to do |format|\n format.html { redirect_to ezii_delta_gits_url, notice: 'Ezii delta git was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @deployment.destroy\n respond_to do |format|\n format.html { redirect_to deployments_url, notice: 'Deployment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @asserted_distribution.destroy\n respond_to do |format|\n format.html { redirect_to asserted_distributions_url, notice: 'Asserted distribution was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\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 @v1_order = V1::Order.find(params[:id])\n @v1_order.destroy\n\n head :no_content\n end", "def destroy\n @client_repo.destroy\n respond_to do |format|\n format.html { redirect_to client_repos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @repo.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Repo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @project_download = ProjectDownload.find(params[:id])\n @project_download.destroy\n\n respond_to do |format|\n format.html { redirect_to project_downloads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @repo.destroy\n respond_to do |format|\n format.html { redirect_to repos_url, notice: 'Repo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @repo.destroy\n respond_to do |format|\n format.html { redirect_to repos_url, notice: 'Repo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @repo = Repo.find(params[:id])\n @repo.destroy\n\n respond_to do |format|\n format.html { redirect_to(repos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @installation.destroy\n respond_to do |format|\n format.html { redirect_to installations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @repository.destroy\n respond_to do |format|\n format.html { redirect_to repositories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sub_package.destroy\n respond_to do |format|\n format.html { redirect_to sub_packages_url, notice: 'Sub package was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @archiv = Archiv.find(params[:id])\n @archiv.destroy\n\n respond_to do |format|\n format.html { redirect_to archivs_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 @apk_bin = ApkBin.find(params[:id])\n @apk_bin.destroy\n\n respond_to do |format|\n format.html { redirect_to apk_bins_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_method = ApiMethod.find(params[:id])\n @api_method.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_api_versions_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n path = format_path(path)\n bucket_path = get_bucket_path(path)\n date = gmtdate\n headers = {\n 'Host' => @aliyun_upload_host,\n 'Date' => date,\n 'Authorization' => sign('DELETE', bucket_path, '', '', date)\n }\n url = path_to_url(path)\n response = RestClient.delete(url, headers)\n response.code == 204 ? url : nil\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def delete\n object.delete(:version_id => @version_id)\n end", "def destroy\n @git_repo = GitRepo.find(params[:id])\n @git_repo.destroy\n\n respond_to do |format|\n format.html { redirect_to(git_repos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @budget_approver.destroy\n respond_to do |format|\n format.html { redirect_to budget_approvers_url, notice: 'Budget approver page was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @verb.destroy\n\n head :no_content\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @ink_varnish = InkVarnish.find(params[:id])\n @ink_varnish.destroy\n\n respond_to do |format|\n format.html { redirect_to ink_varnishes_url }\n format.json { head :ok }\n end\n end", "def destroy\n response = get_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/deployed_containers/\"+params[:id].to_s+\"/destroy_deployed.json\"), (sesh :current_token))\n json_respond response.body\n\n end", "def destroy\n @versioned_jnlp_url = MavenJnlp::VersionedJnlpUrl.find(params[:id])\n @versioned_jnlp_url.destroy\n\n respond_to do |format|\n format.html { redirect_to(maven_jnlp_versioned_jnlp_urls_url) }\n format.xml { head :ok }\n end\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @api_v1_resource.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_resources_url, notice: 'Resource was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n api_client.delete(url)\n end", "def destroy\n @git_datum = GitDatum.find(params[:id])\n @git_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to git_data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @revision = Revision.find(params[:id])\n @revision.destroy\n\n respond_to do |format|\n format.html { redirect_to(revisions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @os_build.destroy\n respond_to do |format|\n format.html { redirect_to os_builds_url, notice: 'Os build was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @repository = Repository.find(params[:id])\n @repository.destroy\n\n respond_to do |format|\n format.html { redirect_to repositories_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @package = Package.find(params[:id])\n @package.destroy\n\n respond_to do |format|\n format.html { redirect_to packages_url }\n format.json { head :ok }\n end\n end", "def destroy\n @genre_dependency.destroy\n respond_to do |format|\n format.html { redirect_to genre_dependencies_url, notice: 'Genre dependency was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @distribution_audit = DistributionAudit.find(params[:id])\n @distribution_audit.destroy\n\n respond_to do |format|\n format.html { redirect_to distribution_audits_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @distribuidor.destroy\n respond_to do |format|\n format.html { redirect_to distribuidors_url, notice: 'El distribuidor a sido eliminado.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.7703194", "0.75675386", "0.75182945", "0.741915", "0.7365901", "0.7125806", "0.7025917", "0.7010802", "0.693972", "0.68947285", "0.6815497", "0.67653763", "0.6761665", "0.6739756", "0.6728975", "0.671844", "0.6710564", "0.6691936", "0.6666579", "0.66623235", "0.6655915", "0.66327524", "0.66319203", "0.66231024", "0.66034466", "0.6563674", "0.653198", "0.6527072", "0.65128887", "0.65085536", "0.6492789", "0.6458496", "0.64520043", "0.6450831", "0.64400256", "0.6421137", "0.64062226", "0.63978577", "0.63950044", "0.6392709", "0.63807267", "0.63632727", "0.63557965", "0.635134", "0.6334418", "0.63239026", "0.6323282", "0.6320703", "0.6312894", "0.63085747", "0.6302586", "0.63020295", "0.6291765", "0.6290711", "0.62896055", "0.6289431", "0.62861586", "0.62817395", "0.62772727", "0.6275226", "0.6263684", "0.62509465", "0.62498367", "0.62468386", "0.6246546", "0.6246546", "0.6238969", "0.62355465", "0.62196845", "0.62161666", "0.6213891", "0.62040377", "0.62040377", "0.62040377", "0.62040377", "0.62039244", "0.6202754", "0.6194204", "0.61826056", "0.61824465", "0.61819386", "0.61791104", "0.6168145", "0.6167967", "0.61651486", "0.6147953", "0.6138078", "0.6131334", "0.6127349", "0.6127349", "0.61264575", "0.61264455", "0.6117307", "0.6113969", "0.6111359", "0.6101295", "0.6100414", "0.6099997", "0.6099801", "0.6096182", "0.6094862" ]
0.0
-1
E.g. converts "attachments,asdf" to [:attachments], assuming permitted: [:attachments]
def parse_include_param(permitted:, default: nil) include_param = params[:include] permitted = permitted.map(&:to_sym) includes = include_param.to_s.split(',').map { |param| param.strip.to_sym } filtered_includes = includes.select { |key, value| permitted.include?(key) } filtered_includes.present? ? filtered_includes : default end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mail_to_parts(mail)\n mail.parts.empty? ? [mail.to_s] : mail.parts.map { |part| part.to_s } \n end", "def adapt_user_ids!(p)\n p[:user_ids] = p[:user_ids].split(',') if p[:user_ids].is_a?(String)\n end", "def permitted_attachments_params\n params.permit(attachments: [])\n end", "def convert_attachments(attachments)\n return nil unless attachments\n\n converted = attachments.map { |a| convert_attachment(a) }.compact\n\n return nil if converted.empty?\n converted\n end", "def convert_attachments(attachments)\n (!attachments && []) || attachments\n .select { |a| a[:kind] == :image }\n .map { |a| { 'type' => 'image', 'url' => a[:image] } }\n end", "def transformed_entries entries\n\t\tentries\n\tend", "def process_attachments(text, attachments)\n attachment_regexp = /\\[attachment=([\\d])+\\]<!-- [\\w]+ -->([^<]+)<!-- [\\w]+ -->\\[\\/attachment\\]?/i\n unreferenced_attachments = attachments.dup\n\n text = text.gsub(attachment_regexp) do\n index = $1.to_i\n real_filename = $2\n unreferenced_attachments[index] = nil\n attachments.fetch(index, real_filename)\n end\n\n unreferenced_attachments = unreferenced_attachments.compact\n text << \"\\n\" << unreferenced_attachments.join(\"\\n\") unless unreferenced_attachments.empty?\n text\n end", "def build_existing_attachments\n attachments = Array(object.send(name))\n\n attachments.map.with_index do |attachment, index|\n if multiple?\n @builder.hidden_field(name, multiple: true, id: (tag_id + \"_#{index}\"), value: attachment.signed_id)\n else\n @builder.hidden_field(name, id: tag_id, value: attachment.signed_id)\n end\n end.join.html_safe\n end", "def get_attachment_list()\n attachment_list = []\n DATA[CARDS][$card_index][ATTACHMENTS].each_index do |item|\n attachment_list.push(DATA[CARDS][$card_index][ATTACHMENTS][item][NAME] + \"-\" + DATA[CARDS][$card_index][ATTACHMENTS][item][URL])\n end\n attachment_list = attachment_list.join(',')\n attachment_list\nend", "def active_storage_param(relation)\n if relation.has_one?\n relation.name.to_s.gsub(/(_attachment)$/, '').to_sym\n else\n { relation.name.to_s.gsub(/(_attachments)$/, '').to_sym => [] }\n end\n end", "def items_to_attach\n array = []\n frm.table(:text=>/Items to attach/).links(:href=>/access.content.attachment/).each { |link| array << link.text }\n array\n end", "def convert_to_array(attr)\n attr = attr.split(',')\n return attr\nend", "def convert_email\n %w[[email protected] [email protected] [email protected] [email protected] [email protected]]\n end", "def attachments\n if attachment_ids\n attachment_ids.map {|id| Attachment.find(id)}\n else\n []\n end\n end", "def attachment_uris\n Array.wrap(attachments).uniq.delete_if(&:empty?)\n end", "def attachments\n model_documents = self.model_documents.reverse\n end", "def attachments\n eco_documents = self.eco_documents.reverse\n eco_documents.delete_if { |d| d.specification? }.reverse\n end", "def attachment_ids=(new_ids)\n super Attachment.where(:id => new_ids).where(post_id: nil).pluck(:id)\n end", "def attachments\n names = []\n frm.ul(:class=>\"attachList indnt1\").links.each { |link| names << link.text }\n return names\n end", "def attachments\n names = []\n frm.ul(:class=>\"attachList indnt1\").links.each { |link| names << link.text }\n return names\n end", "def convertChangesToUploadsDeletes(changes)\n\t\t\tuploads = []\n\t\t\tdeletes = []\n\t\t\tchanges.each do |line|\n\t\t\t\tcontinue if line==\"\"\n\t\t\t\ttabi = line.index(\"\\t\")\n\t\t\t\tstatus = line[0,tabi]\n\t\t\t\tpath = line[tabi+1..-1]\n\t\t\t\tif status.index('D')\n\t\t\t\t\tdeletes << path\n\t\t\t\telse\n\t\t\t\t\tuploads << path\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn uploads,deletes\n\t\tend", "def convert_answer_ids\n ids = params[:quiz_event][:answer_ids] if params[:quiz_event]\n params[:quiz_event][:answer_ids] =\n ids.split.flatten.reject(&:blank?).map(&:to_i) if ids\n end", "def get_field_deserializers()\n return super.merge({\n \"recipients\" => lambda {|n| @recipients = n.get_collection_of_primitive_values(String) },\n })\n end", "def normalize_parameters(value)\n case value\n when Hash\n if value.has_key?(:tempfile)\n upload = value[:tempfile]\n upload.extend(UploadedFile)\n upload.original_path = value[:filename].force_encoding(Encoding::UTF_8)\n upload.content_type = value[:type]\n upload\n else\n h = {}\n value.each { |k, v| h[k] = normalize_parameters(v) }\n h.with_indifferent_access\n end\n when Array\n value.map { |e| normalize_parameters(e) }\n else\n value.force_encoding(Encoding::UTF_8) if value.respond_to?(:force_encoding)\n value\n end\n end", "def get_ingredients \n # get rid of all characters that are not: a-z A-Z 0-9 - [] () . ' / , blank;\n clean_ingredients = self.ingredients.gsub(%r{[^a-zA-Z0-9\\-\\[\\]\\.\\,\\'\\(\\)\\/\\s]}, '')\n return clean_ingredients.split(', ').each { |ingredient| ingredient.strip! }\n end", "def collection_arg arg\r\n if arg.is_a? Array\r\n arg.collect {|e| e.gsub(/[\\\\,]/) {|s| \"\\\\#{s}\" } }.join(',')\r\n else\r\n arg\r\n end\r\n end", "def selected_mime_types\n return [] if mime_types.blank?\n\n mime_types.split(',')\n end", "def multi_upload\n authenticate!\n attachments = []\n (attachment_params[:attachments] || []).each do |key, value|\n if value[:file]\n attachment = value[:file]\n attachment_params = {\n :filename => attachment[:filename],\n :type => attachment[:type],\n :headers => attachment[:head],\n :tempfile => attachment[:tempfile]\n }\n file = ActionDispatch::Http::UploadedFile.new(attachment_params)\n attachments << Attachment.create(file: file, user: current_user)\n end\n end\n {\n code: 0,\n data: attachments\n }\n end", "def attachment_representation\n parametrized_attachment.tap do |attachment|\n %w(filename target_directory max_file_size).each do |attr|\n attachment.public_send(\"#{attr}=\", public_send(attr))\n end\n attachment.readonly!\n end\n end", "def article_params\n if !params[:article][:tags].blank?\n params[:article][:tags] = params[:article][:tags].split(\",\")\n params[:article][:tags].each_with_index do |tag, index|\n params[:article][:tags][index] = tag.strip.titleize\n end\n end\n params.require(:article).permit(:user_id, :link, :title, :image, :is_active, :tags => [])\n end", "def prepare_tags_id\n tags_ids = []\n if params[:source][:tags]\n tags = params[:source][:tags].split(',')\n tags.each do |tag|\n user_tag = current_user.tags.find_by_name(tag)\n unless user_tag then\n user_tag = current_user.tags.create(:name=>tag)\n end\n tags_ids << user_tag.id if user_tag\n end\n params[:source][:tag_ids] = tags_ids if tags_ids\n params[:source].delete(\"tags\")\n end\n end", "def attachments\n (msg['attachments']||{}).map{|attached| Mandrill::WebHook::Attachment[attached.last] }\n end", "def attached_files\n array = []\n frm.ul(:class=>/attachList/).lis.each { |li| array << li.link.text }\n array\n end", "def mandrill_attachments\n attachments.map do |attachment|\n {\n 'type' => attachment.content_type,\n 'name' => attachment.filename,\n 'content' => Base64.encode64(attachment.body.decoded)\n }\n end\n end", "def convert(claims)\n claims.map{|k, v| claim_pair(k, v)}\n end", "def process_attachments!\n child_documents = parsed_form.dig('dependents_application', 'child_supporting_documents')\n spouse_documents = parsed_form.dig('dependents_application', 'spouse_supporting_documents')\n # add the two arrays together but also account for nil arrays\n supporting_documents = [child_documents, spouse_documents].compact.reduce([], :|)\n if supporting_documents.present?\n files = PersistentAttachment.where(guid: supporting_documents.map { |doc| doc['confirmation_code'] })\n files.find_each { |f| f.update(saved_claim_id: id) }\n end\n end", "def admin_cover_concept_upload_list\n %w( [email protected] )\n end", "def strip_unenriched(activities, includes)\n activities.map do |act|\n if act['activities'] # Recurse into activity groups\n act['activities'] = strip_unenriched(act['activities'], includes)\n else\n includes.each do |key|\n # If it's an array (nested enrichment), grab the top level\n key = key.first if key.is_a?(Array)\n # Delete if it's still a string\n act.delete(key.to_s) if act[key.to_s].is_a?(String)\n end\n end\n act\n end\n end", "def attachments_for_export\n []\n end", "def parse_params(params)\n collection, id = params['captures']\n enforce_plural(collection)\n id ? [collection, id] : collection\n end", "def raw_bibtex_entry_params\n params.require(:content).permit(:converted, :subject_list => [], :keyword_list => [])\n end", "def article_representation article\n \n # Get the attributes of the article as an array of strings\n arr = article.attributes.values.map(&:to_s)\n temp_arr =[]\n \n # Iterate attributes \n arr.each do |ele|\n if ele.eql? \"\"\n # Do nothing for empty values\n elsif ele.include? \",\"\n #if there is ',' in value, quote it\n temp_arr << \"\\\"\"+ele+\"\\\"\"\n else\n temp_arr << ele\n end\n end\n \n #Return the representation after joining the values by comma\n temp_arr.join(', ')\n end", "def unpersisted_attachments(method)\n as_relation = @object.send(method)\n if as_relation.is_a?(ActiveStorage::Attached::One) && as_relation.attachment.present? &&\n [email protected]?\n [as_relation.attachment]\n elsif as_relation.is_a?(ActiveStorage::Attached::Many)\n as_relation.reject(&:persisted?)\n else\n []\n end\n end", "def preserve_extensions(data)\n data.map do |from, to|\n [from, \"#{to}#{File.extname(from)}\"]\n end\n end", "def content_type_allowlist\n Rails.configuration.x.file_upload_content_type_allowlist.split(/\\s*,\\s*/)\n end", "def get_field_deserializers()\n return super.merge({\n \"audiences\" => lambda {|n| @audiences = n.get_collection_of_primitive_values(String) },\n \"description\" => lambda {|n| @description = n.get_string_value() },\n \"issuer\" => lambda {|n| @issuer = n.get_string_value() },\n \"name\" => lambda {|n| @name = n.get_string_value() },\n \"subject\" => lambda {|n| @subject = n.get_string_value() },\n })\n end", "def safe_list_sanitizer; end", "def safe_list_sanitizer; end", "def safe_list_sanitizer; end", "def sanitize_keys(value)\n if value.is_a?(Hash)\n value.map { |k, v|\n k = k.to_s.downcase.tr('^a-z0-9_', '_').to_sym\n v = sanitize_keys(v)\n [k, v]\n }.to_h\n elsif value.is_a?(Array) && (value.size > 1)\n value.map { |v| sanitize_keys(v) }\n elsif value.is_a?(Array)\n sanitize_keys(value.first)\n elsif value.is_a?(String) && value.include?(FileFormat::FILE_FORMAT_SEP)\n value.split(FileFormat::FILE_FORMAT_SEP).compact_blank\n else\n value\n end\n end", "def fetch_contacts\n case params[:importer]\n when OTHER_EMAIL then params[:emails].split(',')\n when GMAIL, YAHOO, HOTMAIL, OUTLOOK, LINKEDIN then params[:contacts]\n end\n end", "def attachments\n @attachments ||= []\n end", "def remove_note_list()\n remove_upload_ids = []\n @document.uploads.each do |upload|\n remove_upload_ids << upload\n end\n \n return remove_upload_ids\n end", "def remove_note_list()\n remove_upload_ids = []\n @collection.uploads.each do |upload|\n remove_upload_ids << upload\n end\n \n return remove_upload_ids\n end", "def film_producer(film)\n film[\"producer\"].split(', ').join(\" and \")\nend", "def convert_tags(string)\n if string.nil?\n []\n else\n tags = string.split(',')\n tags.map(&:strip)\n end\n end", "def multipart_build(params, boundary)\n flat = []\n flatten_hash(params) do | keys, value |\n if keys[-1].nil? # warn the user that Camping will never see that\n raise Mosquito::SageAdvice, \n \"Camping will only show you the last element of the array when using multipart forms\"\n end\n \n flat_key = [esc(keys.shift), keys.map{|k| \"[%s]\" % esc(k) }].flatten.join\n if value.respond_to?(:original_filename)\n flat << uploaded_file_segment(flat_key, value, boundary)\n else\n flat << conventional_segment(flat_key, value, boundary)\n end\n end\n flat.sort.join(\"\")+\"--#{boundary}--\\r\"\n end", "def to_words(words)\n words.split\nend", "def attachments(*params)\n id = params[0]\n unnamed = params[1]\n if params[0].class == Hash\n params = params[0]\n id = params[:id] if params.has_key? :id\n unnamed = params[:unnamed] if params.has_key? :unnamed\n end\n unnamed = false if unnamed.to_s == \"0\"\n id = $~[1] if id =~ /ticket\\/(\\d+)/\n resp = @site[\"ticket/#{id}/attachments\"].get\n resp.gsub!(/RT\\/\\d+\\.\\d+\\.\\d+\\s\\d{3}\\s.*\\n\\n/,\"\") # toss the HTTP response\n resp.gsub!(/^\\n/m,\"\") # toss blank lines\n while resp.match(/CF\\.\\{[\\w_ ]*[ ]+[\\w ]*\\}/) #replace CF spaces with underscores\n resp.gsub!(/CF\\.\\{([\\w_ ]*)([ ]+)([\\w ]*)\\}/, 'CF.{\\1_\\3}')\n end\n th = response_to_h(resp)\n list = []\n pattern = /(\\d+:\\s.*?\\))(?:,|$)/\n match = pattern.match(th['attachments'].to_s)\n while match != nil\n list.push match[0]\n s = match.post_match\n match = pattern.match(s)\n end\n attachments = []\n list.each do |v|\n attachment = {}\n m=v.match(/(\\d+):\\s+(.*?)\\s+\\((.*?)\\s+\\/\\s+(.*?)\\)/)\n if m.class == MatchData\n next if m[2] == \"(Unnamed)\" and !unnamed\n attachment[:id] = m[1]\n attachment[:name] = m[2]\n attachment[:type] = m[3]\n attachment[:size] = m[4]\n attachments.push attachment\n end\n end\n attachments\n end", "def convert_ref_tags; end", "def prepare_role_names(role_names)\n Array(role_names).collect! {|role_name| role_name.to_s } \n end", "def normalize_options\n self.options[:whitelist] = self.options[:whitelist].map(&:to_s)\n self.options[:blacklist] = self.options[:blacklist].map(&:to_s)\n self.options[:path] = [self.options[:path]] unless self.options[:path].is_a?(Array)\n end", "def get_note_list\n note = queued_email_note\n note ? note.value.to_s.split(\",\") : nil\n end", "def tag_article article\n tags = article.gsub(/'/,'').split(/\\W+/).join(', ')\n tags\n end", "def tag_article article\n tags = article.gsub(/'/,'').split(/\\W+/).join(', ')\n tags\n end", "def transform\n params.transform_keys! { |key| key.tr('-', '_') }\n end", "def add_to_multivalued_field( data, target, splitter )\n \n if data != nil\n data.split( splitter ).each do |entry|\n target.push( entry )\n end\n end\n \nend", "def attributes_with_association_names\n attributes = super\n add_attachments_to_attributes(attributes)\n Ticket::Article.insert_urls(attributes)\n end", "def to_multipart\n query = @multipart_params.collect { |param| \"--\" + BOUNDARY + \"\\r\\n\" + param.to_multipart }.join(\"\") + \"--\" + BOUNDARY + \"--\"\n return query, CONTENT_TYPE\n end", "def decode_attachments\n self[\"_attachments\"].each do |attachment_id, attachment_properties|\n self[\"_attachments\"][attachment_id][\"data\"] = Base64.decode64 attachment_properties[\"data\"] if attachment_properties[\"data\"] \n end if self[\"_attachments\"]\n end", "def batch_badge_creator(attendees)\n#use map to return the names with the string as a new array\n attendees.map do |attendee|\n \"Hello, my name is #{attendee}.\"\n end\nend", "def item_only_attachments\n @relevant_object = convert_id_to_model(params[:id])\n @images = @relevant_object.media_items\n end", "def transform_params\n params.transform_keys! { |key| key.underscore }\n end", "def content values\n values.map { |value| value.content }.join\nend", "def clean_related(subject)\n \tsubject.gsub!(/\\n/, \"\")\n \tsubject.gsub!(/<[^<>]*>/, \"\")\n \tsubject.to_s\n \tsubject.split('&gt;')\n end", "def image_collection_params\n params.require(:image_collection).permit(:name, attached_images: [])\n end", "def add_attachments(value)\n if value.instance_of? AttachmentJson\n @attachments.push(value)\n end\n end", "def convert_emails(emails, used)\n legal_used = []\n emails.each do |em|\n legal_used << em if legal_emails.include? em\n end\n emails.map do |em|\n convert_if_not_production(em, used, legal_used)\n end\n end", "def normalize(a)\n case a\n when Actor\n a\n when Integer\n Actor.find a\n when Array\n a.map{ |e| Actor.normalize(e) }\n else\n begin\n a.actor\n rescue\n raise \"Unable to normalize actor #{ a.inspect }\" \n end\n end\n end", "def convert_default(tags)\r\n if !tags.match(/,/) && tags.match(/\\s/)\r\n tags = tags.split(/\\s+/).join(',')\r\n end\r\n return clean_tags(tags)\r\n end", "def process(message)\n return message unless message[:attachments]\n\n message = message.dup\n message[:attachments].map! do |attachment|\n next attachment unless attachment[:kind] == :image\n { kind: :image, image: get_groupme_image_url(attachment[:image]) }\n end\n\n message\n end", "def form_encoded_name\n return unless path\n\n options[:multiple] || options[:collection] ? super + '[]' : super\n end", "def transform_to_many(entity_class_or_decider, root: nil)\n items = get_rooted_items(root)\n unless items.is_a?(Array)\n fail Dialers::ImpossibleTranformationError.new(response)\n end\n items.map { |item| transform_attributes_to_object(entity_class_or_decider, item) }\n end", "def upload_note_select_for_collection\n retval = Upload.where(\"user_id = ? AND upload_type = ?\",\n @collection.user_id, \"note\").order(\"upfile_file_name\").collect { |u| [u.upfile_file_name, u.id] }\n end", "def parse\n new_emails = emails.delete(\",\")#removes commas\n individual_emails = new_emails.split.uniq #splits emails and deletes repetes\n end", "def files_content(record, identifier, path, frag_content)\n # preparing attachments\n files = frag_content.split(\"\\n\").collect do |filename|\n file_handler = File.open(File.join(path, filename))\n {\n io: file_handler,\n filename: filename,\n content_type: MimeMagic.by_magic(file_handler)\n }\n end\n\n # ensuring that old attachments get removed\n ids_destroy = []\n if (frag = record.fragments.find_by(identifier: identifier))\n ids_destroy = frag.attachments.pluck(:id)\n end\n\n [files, ids_destroy]\n end", "def temporary_attachments\n self.class.read_inheritable_attribute(:temporary_attachments) || []\n end", "def attachment_types\n @attachment_types ||= []\n end", "def convert_ids(list, input, output)\n begin\n ids = fetch_conversion_job(create_conversion_job(list, input, output))\n ids = ids.split(\"\\n\")\n rescue StandardError => e\n puts e.message, e.backtrace\n retry\n end\n result = {}\n ids.drop(1).each do |id|\n id = id.split(\"\\t\")\n id.drop(1).each do |i|\n result[id[0]] ||= []\n result[id[0]] += i.split(';').map(&:strip).map { |x| (x.empty? || x =~ /^-$/) ? nil : x.upcase }\n end\n end\n result\n end", "def represented\n candidates = contact_actors(:direction => :sent).map(&:id)\n\n contact_subjects(:direction => :received) do |q|\n q.joins(:sent_ties => { :relation => :permissions }).\n merge(Permission.represent).\n where(:id => candidates)\n end\n end", "def convert_participants(participants_string)\n return nil unless participants_string.is_a?(String)\n \n participants_raw_array = participants_string.split(/[,;]/)\n \n participants = participants_raw_array.map do |p|\n p = p.downcase.strip\n user = (p.include?(\"@\") ? User.find_by_primary_email(p) : User.find_by_downcase_nickname(p))\n user ? user.id.to_s : p.blank? ? nil : p\n end\n \n return participants.compact.uniq\n end", "def email_parser(str) \n str.gsub(/, /,\" \").gsub(/,/,\" \").split.uniq\nend", "def get_field_deserializers()\n return super.merge({\n \"attachments\" => lambda {|n| @attachments = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::Attachment.create_from_discriminator_value(pn) }) },\n \"bccRecipients\" => lambda {|n| @bcc_recipients = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::Recipient.create_from_discriminator_value(pn) }) },\n \"body\" => lambda {|n| @body = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::ItemBody.create_from_discriminator_value(pn) }) },\n \"bodyPreview\" => lambda {|n| @body_preview = n.get_string_value() },\n \"ccRecipients\" => lambda {|n| @cc_recipients = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::Recipient.create_from_discriminator_value(pn) }) },\n \"conversationId\" => lambda {|n| @conversation_id = n.get_string_value() },\n \"conversationIndex\" => lambda {|n| @conversation_index = n.get_object_value(lambda {|pn| Base64url.create_from_discriminator_value(pn) }) },\n \"extensions\" => lambda {|n| @extensions = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::Extension.create_from_discriminator_value(pn) }) },\n \"flag\" => lambda {|n| @flag = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::FollowupFlag.create_from_discriminator_value(pn) }) },\n \"from\" => lambda {|n| @from = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Recipient.create_from_discriminator_value(pn) }) },\n \"hasAttachments\" => lambda {|n| @has_attachments = n.get_boolean_value() },\n \"importance\" => lambda {|n| @importance = n.get_enum_value(MicrosoftGraph::Models::Importance) },\n \"inferenceClassification\" => lambda {|n| @inference_classification = n.get_enum_value(MicrosoftGraph::Models::InferenceClassificationType) },\n \"internetMessageHeaders\" => lambda {|n| @internet_message_headers = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::InternetMessageHeader.create_from_discriminator_value(pn) }) },\n \"internetMessageId\" => lambda {|n| @internet_message_id = n.get_string_value() },\n \"isDeliveryReceiptRequested\" => lambda {|n| @is_delivery_receipt_requested = n.get_boolean_value() },\n \"isDraft\" => lambda {|n| @is_draft = n.get_boolean_value() },\n \"isRead\" => lambda {|n| @is_read = n.get_boolean_value() },\n \"isReadReceiptRequested\" => lambda {|n| @is_read_receipt_requested = n.get_boolean_value() },\n \"multiValueExtendedProperties\" => lambda {|n| @multi_value_extended_properties = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::MultiValueLegacyExtendedProperty.create_from_discriminator_value(pn) }) },\n \"parentFolderId\" => lambda {|n| @parent_folder_id = n.get_string_value() },\n \"receivedDateTime\" => lambda {|n| @received_date_time = n.get_date_time_value() },\n \"replyTo\" => lambda {|n| @reply_to = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::Recipient.create_from_discriminator_value(pn) }) },\n \"sender\" => lambda {|n| @sender = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Recipient.create_from_discriminator_value(pn) }) },\n \"sentDateTime\" => lambda {|n| @sent_date_time = n.get_date_time_value() },\n \"singleValueExtendedProperties\" => lambda {|n| @single_value_extended_properties = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::SingleValueLegacyExtendedProperty.create_from_discriminator_value(pn) }) },\n \"subject\" => lambda {|n| @subject = n.get_string_value() },\n \"toRecipients\" => lambda {|n| @to_recipients = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::Recipient.create_from_discriminator_value(pn) }) },\n \"uniqueBody\" => lambda {|n| @unique_body = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::ItemBody.create_from_discriminator_value(pn) }) },\n \"webLink\" => lambda {|n| @web_link = n.get_string_value() },\n })\n end", "def attachments\n mail&.attachments || []\n end", "def uri_normalizer; end", "def convert(content); end", "def convert(content); end", "def preprocess(str)\n str.downcase.gsub(URI_PREFIX, ',')\n end", "def connect_attachments(params)\n json_attachments = params['data'].try(:[], 'relationships').try(:[], 'attachments')\n return if json_attachments.blank?\n\n attachment_list = resource_list('attachment', json_attachments)\n\n attachment_list.each do |attachment|\n attachment.attachable = self\n attachment.save\n end\n end", "def convert_exts\n if Rails.configuration.convertDocs.empty?\n []\n else\n Rails.configuration.convertDocs.split(\"|\")\n end\n end", "def reformat_multiselect_params_format\n params = @associations[\"0\"][:element_id]\n params.each_with_index do |id, idx|\n @associations[(idx + 1).to_s] = { element_id: id, \"_destroy\" => \"0\" } if id.present?\n end\n @associations.delete(\"0\")\n end" ]
[ "0.55583644", "0.55507296", "0.5538301", "0.5465207", "0.5336404", "0.52054614", "0.50935775", "0.5093071", "0.508477", "0.504126", "0.49753997", "0.49150094", "0.4882767", "0.48761272", "0.48559403", "0.4840297", "0.481487", "0.4811684", "0.4786563", "0.4786563", "0.475682", "0.47476104", "0.47330126", "0.47055998", "0.47053605", "0.46927667", "0.4677829", "0.46557906", "0.46546677", "0.4654188", "0.46236402", "0.4615472", "0.46118727", "0.4611843", "0.46117416", "0.46079734", "0.46063113", "0.4603825", "0.46036118", "0.4596549", "0.4595683", "0.45850486", "0.45847976", "0.4581431", "0.45756397", "0.45734292", "0.4571209", "0.4571209", "0.4571209", "0.4570545", "0.45687884", "0.45582232", "0.45495453", "0.45471558", "0.45406502", "0.45365238", "0.45339352", "0.4527245", "0.45229048", "0.4519439", "0.45108768", "0.45093375", "0.44998607", "0.44839123", "0.44839123", "0.44835934", "0.44769678", "0.44719538", "0.44663534", "0.4466232", "0.44636932", "0.44600517", "0.44581777", "0.4452952", "0.44473758", "0.44462118", "0.44441116", "0.4442403", "0.44408968", "0.44362304", "0.44357482", "0.44346255", "0.44338602", "0.4426537", "0.4420678", "0.44196573", "0.4417414", "0.4417195", "0.44162259", "0.4415702", "0.4404879", "0.43990102", "0.4396828", "0.43964982", "0.43933424", "0.43926182", "0.43926182", "0.4390521", "0.43884403", "0.43876943", "0.4386568" ]
0.0
-1
Basically just a wrapper around ActionController::Parameterspermit for now
def parse_filter_params(permitted:) # Symbolize the keys so the values can be used with keyword arguments in the filter scopes. filter_params = params[:filter].try(:permit, permitted).try(:to_h) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filtered_parameters; end", "def filter_parameters; end", "def filter_parameters; end", "def parameterize(value); end", "def params() request.params end", "def get_parameters; end", "def get_parameters; end", "def params\n @_params ||= ActionController::ManagebleParameters.new(request.parameters)\n end", "def query_parameters\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 params; end", "def params=(value); end", "def request_parameters; end", "def param; end", "def param; end", "def query_parameters; end", "def single_param_action(parameter)\n action :single_param_action\n end", "def request_params; end", "def _wrap_parameters(parameters); end", "def filter_parameters=(_arg0); end", "def filter_parameters=(_arg0); end", "def parameters=(_); end", "def to_param; end", "def query_params()\n ActionController::Parameters.new({ })\n end", "def params_to_pass\n settings\n end", "def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end", "def valid_params_request?; end", "def injection_params\n params[:injection]\n end", "def params\n raise NotImplementedError\n end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def blacklight_params\n params = super\n\n # This method needs to be idempotent.\n if params[\"processed\"]\n params\n else\n process_params!(params, params_process_chain)\n end\n end", "def query_params; end", "def parse_parameters; end", "def parameterize(value)\n value.respond_to?(:to_param) ? value.to_param : value\n 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 query_params=(_arg0); end", "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 parsed_params\n \n end", "def parameterReturn(param)\n return param\nend", "def params(*); {}; end", "def params() @param_types end", "def argument_params\n params[:argument]\n end", "def parameters_double_registry; end", "def all_params; end", "def param_whitelist\n [:role, :title]\n end", "def params=(_arg0); end", "def params=(_arg0); end", "def method_missing(name)\n @params.params[name.to_s] || super\n end", "def param( value )\n @paramNum += 1\n @params[@paramNum.to_s] = value\n return \":\" + @paramNum.to_s\n end", "def parameters(params)\n params.each do |key, value|\n send(\"#{key}=\".to_sym, value) if self.respond_to?(key)\n end\n end", "def parameter_string\n\t\tend", "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 params\n controller.params\n end", "def parameters(params)\n allowed = [:start,:num,:type,:id,:filter,:tagged,:search,:state,:email,:password]\n params.merge! defaults if defaults\n params.reject {|key,value| !allowed.include? key }\n end", "def param_encoding(action, param, encoding); end", "def _arg( name )\n\t\tname = name.to_sym\n\t\treturn request.request_parameters[name] || request.query_parameters[name]\n\tend", "def _arg( name )\n\t\tname = name.to_sym\n\t\treturn request.request_parameters[name] || request.query_parameters[name]\n\tend", "def params\n\t\t\treturn @params if @params\n\t\t\t@params = @value.gsub(/\\\\\\|/, @escaped_pipe).split('|').map{|p| p.strip.gsub @escaped_pipe, \"\\\\|\"}\n\t\tend", "def parameters=(_arg0); end", "def params\n @_params\n end", "def params!(params)\n params\n end", "def allow_params_authentication!; end", "def param(type, title, param)\n param_value(catalogue, type, title, param)\nend", "def param(type, title, param)\n param_value(catalogue, type, title, param)\nend", "def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end", "def filter_argument; end", "def atk; param(2); end", "def params\n _params\n end", "def parameter_rule?; end", "def params\n @@params\n end", "def register(params)\r\n @filter_field = params[\"filter\"]\r\n @return_field = params[\"return\"]\r\nend", "def params\n @controller.params\n end", "def params\n @controller.params\n end", "def setupNewParam(_varied)\n _param = {} ;\n @scatterPolicy.each{|_paramName, _policy|\n _param[_paramName] = ( _varied.key?(_paramName) ?\n _varied[_paramName] :\n getValueByPolicy(_policy) ) ;\n }\n return _param ;\n end", "def anonymous_filter_params\n p = params.required('payload')\n # p.permit!('controls_params')\n # p.permit!('columns_params')\n # p.permit!('sorting')\n # p.permit!('global_config')\n p.permit(\n 'name',\n 'controls_list' => [],\n 'controls_hl_mode' => [],\n 'controls_params' => {},\n 'columns_list' => [],\n 'columns_params' => {},\n 'sorting' => {},\n 'global_config' => {}\n ).merge(permit_hashes(p, [\n 'controls_params',\n 'columns_params',\n 'sorting',\n 'global_config'\n ]))\n end", "def params\n # Normal cases\n # raise @params.values.inspect\n # return @params.values.length.inspect\n if %w{ready accesses list_subscribe list_unsubscribe}.include?(@action)\n @params\n elsif @params.values.first.is_a? Hash\n {@params.keys.first => @params.values.first.select{|k,v| v.present? }}\n elsif @params.values.first.is_a? Array\n {@params.keys.first => @params.values.first.select(&:present?)} rescue {}\n end\n # rescue => e\n # {}\n end", "def parameters()\n @melody = params[:melody].upcase.split(\",\") # create array of notes in melody parameter\n @shift = params[:shift] # shift parameter\nend", "def split_params **params\n [\n INTERNAL_PARAMS.each_with_object({}) do |param, acc|\n acc[param] = params.delete(param)\n end.reject { |_, v| v.nil? },\n params\n ]\n end" ]
[ "0.65939003", "0.6592689", "0.6592689", "0.6531635", "0.6356746", "0.6329746", "0.6329746", "0.6328263", "0.6321279", "0.63092273", "0.63031286", "0.63031286", "0.63031286", "0.63031286", "0.63031286", "0.63031286", "0.63031286", "0.63031286", "0.63031286", "0.63031286", "0.63031286", "0.63031286", "0.63031286", "0.63031286", "0.63031286", "0.63031286", "0.63031286", "0.6297225", "0.623881", "0.62299204", "0.62299204", "0.6226646", "0.6207922", "0.61950606", "0.61461717", "0.61437166", "0.61437166", "0.6105634", "0.6075112", "0.6057209", "0.60140777", "0.6002372", "0.5984515", "0.5934839", "0.58907855", "0.58727795", "0.58727795", "0.58727795", "0.58727795", "0.58727795", "0.58727795", "0.58727795", "0.58727795", "0.58686393", "0.5856183", "0.5840807", "0.5840641", "0.5826052", "0.58241713", "0.581321", "0.580864", "0.5804812", "0.5797657", "0.5796504", "0.5788555", "0.57759947", "0.57718664", "0.5765195", "0.57603604", "0.57603604", "0.57556397", "0.5754331", "0.57493675", "0.5747094", "0.5743557", "0.5728716", "0.57285535", "0.572695", "0.57261217", "0.57261217", "0.57254803", "0.57235426", "0.5715897", "0.5701565", "0.5676439", "0.5661322", "0.5661322", "0.56605625", "0.5655801", "0.56553966", "0.5653528", "0.56503195", "0.56437635", "0.564173", "0.5639529", "0.5639529", "0.5639429", "0.56385845", "0.5633231", "0.56214225", "0.5615611" ]
0.0
-1
Changes on which page this rendering manager should act
def page=(page) return if @page == page @page = page @available_renderers = available_renderers.map_value do |key, (value, render_options)| new_render = value.class.new(page) disconnect(value, SIGNAL('updated()')) connect(new_render, SIGNAL('updated()'), self, SIGNAL('updated()')) [new_render, render_options] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_page\n end", "def selected_page\n end", "def set_page\n @articlespage = 'active'\n end", "def page; self end", "def page()\n session[:edit_mode] ||= 0\n# Initialize parts\n @parts = nil\n @js, @css = '', ''\n# find domain name in sites\n @site = dc_get_site\n# site is not defined. render 404 error\n return dc_render_404('Site!') if @site.nil?\n dc_set_options(@site.settings)\n# HOMEPAGE. When no parameters is set\n params[:path] = @site.homepage_link if params[:id].nil? and params[:path].nil?\n# Search for page \n pageclass = @site.page_table.classify.constantize\n if params[:id]\n @page = pageclass.find_by(subject_link: params[:id])\n elsif params[:path]\n# path may point direct to page's subject_link\n @page = pageclass.find_by(subject_link: params[:path])\n end\n# if @page is not found render 404 error\n return dc_render_404('Page!') unless @page\n dc_set_options @page.params\n# find design if defined. Otherwise design MUST be declared in site\n if @page.dc_design_id\n @design = DcDesign.find(@page.dc_design_id)\n return dc_render_404('Design!') unless @design\n end\n# Add to edit menu\n if session[:edit_mode] > 0\n session[:site_id] = @site.id\n session[:site_page_table] = @site.page_table\n session[:page_id] = @page.id\n end\n# perform check every hour. Perhaps if user has rights changes\n session[:last_check] ||= Time.now\n if (session[:last_check] - Time.now) > 3600\n # perform checks\n # TO BE DONE\n \n # update time\n session[:last_check] = Time.now\n end \n @page_title = @page.subject.empty? ? @site.page_title : @page.subject\n get_design_and_render @design\nend", "def page\n\n end", "def page; end", "def page; end", "def page; end", "def page; end", "def page; end", "def page; end", "def page; end", "def page; end", "def page; end", "def page; end", "def page; end", "def page; end", "def current_page; end", "def current_page; end", "def current_page_setter\n @current_page = :user_stories\n end", "def sub_view\n page(NavTabBarPage).select_storytab(\"Action\")\n page(NavTabBarPage).flag_handler(\"Cancel\")\n page(NavTabBarPage).select_storytab(\"Action\")\n page(NavTabBarPage).sub_handler\n page(SubmissionPage).verify_page_elements\n page(SubmissionPage).select_action(\"Submissions\")\n page(SubmissionPage).select_action(\"Comments\")\n page(MorePage).backpage\n end", "def set_page\n @page = @current_site.pages.find(params[:id])\n @program = @page.program\n end", "def display_the_page\n @page.process(request, response)\n # Add backreference to body for returning to edit page\n @response = response\n \n @response.body += '<p><a href=\"' + url_for(\n :controller => 'admin/' + params[:action], \n :id => instance_variable_get(\"@#{params[:action]}\"),\n :action => 'edit'\n ) + '\">Back</a></p>'\n \n @response = nil\n\n # If this is true, Radiant will not use render more.\n @performed_render = true\n end", "def configure\n # fetching page via before filter\n if @page.redirects_to_external?\n render action: 'configure_external', layout: !request.xhr?\n else\n @page_layouts = PageLayout.layouts_with_own_for_select(@page.page_layout, session[:language_id], @page.layoutpage?)\n render layout: !request.xhr?\n end\n end", "def page\n self.class.page\n end", "def change_page(p)\n self.page = p\n self\n end", "def default\r\n can_view, msg = dc_user_can_view(@parent, @page)\r\n return msg unless can_view\r\n\r\n html = \"<div class=\\\"#{@page.div_class} #{@opts[:div_class]}\\\">\"\r\n html << dc_page_edit_menu() if @opts[:edit_mode] > 1\r\n @parent.page_title = @page.title.blank? ? @page.subject : @page.title\r\n html << @page.body\r\n # render poll if defined\r\n if @page.dc_poll_id\r\n @opts.merge!(poll_id: @page.dc_poll_id, return_to: @parent.request.url, method: nil)\r\n comment = DcPollRenderer.new(@parent, @opts)\r\n html << \"<div class='wrap row'>#{comment.render_html}</div>\"\r\n @css << \"\\n#{comment.render_css}\"\r\n end\r\n # also add iframe\r\n html << iframe() << '</div>'\r\nend", "def set_layout\n if current_paciente != nil\n \"pacientes_pages\"\n else\n \"nutriologo_pages\"\n end\n end", "def selected_page=(page)\n end", "def set_resource\n @page = current_site.pages.available.homepage.first!\n end", "def display_the_page\n @page.process(request, response)\n # Add backreference to body for returning to edit page\n @response = response\n \n @response.body += '<p><a href=\"' + url_for(\n :controller => 'admin/' + CGI.escapeHTML(params[:action].pluralize), \n :id => params[:id].to_i,\n :action => 'edit'\n ) + '\">Back</a></p>'\n \n @response = nil\n\n # If this is true, Radiant will not use render more.\n @performed_render = true\n end", "def set_resource_content\n @page = Page.available.homepage.first!\n end", "def page\n @context.registers[:page]\n end", "def show\n \n if Page.count==0\n ensure_homepage\n else\n @page = @page || Page.find_by_alias(app_path)\n # TODO: add the ability for the user to choose whether to render the page or use it as a redirect\n #path = @page.path == '/' ? 'index' : @page.path\n #redirect_to @page.url unless path==app_path\n end\n\n if @page.nil?\n if admin?\n flash[:notice]=\"The page you requested does not exist. Would you like to create it?\"\n @page = Page.new(:path=>app_path)\n @page_template = \"admin\"\n render :action=>'new'\n else\n render :file => \"#{RAILS_ROOT}/public/404.html\", :layout => false, :status => 404\n end\n else\n @[email protected]\n @title = @page.title\n @page_description = @page.description\n\n # Even though the printable pages are rendered in a different layout\n # they also need a different template, since this template should only\n # have a single column\n \n if params[:print] && params[:print] == \"true\"\n @page_template = \"print\"\n elsif @page.url =~ /moving_from_caregivers_menu/\n @page_template = \"template_caregivers\"\n elsif @page.url =~ /moving_from_providers_menu/\n @page_template = \"template_providers\"\n else\n @page_template = @page.template.name\n end\n \n # This isn't really necessary, but it makes the print view very clean\n @pages = [@page]\n\n if params[:popup] && params[:popup] == \"true\"\n render :action => \"show\", :layout => false\n end \n\n if params[:save] && params[:save] == \"true\"\n render_for_save\n end \n \n #Setting the body_id to caregivers to access Noah's customized css. \n #Setting the body_id to caregivers to access Noah's customized css. \n if @page.template.name == 'template_caregivers'\n @body_id = \"Caregivers\" \n @other_perspective, @other_persepective_title = 'moving_from_providers_menu' + $1, 'Health Care Provider Perspective' if @page.url =~ /moving_from_caregivers_menu(.*)/\n elsif @page.template.name == 'template_providers'\n @body_id = \"Providers\" \n @other_perspective, @other_persepective_title = 'moving_from_caregivers_menu' + $1, 'Family Caregiver Perspective' if @page.url =~ /moving_from_providers_menu(.*)/\n elsif @page.template.name == 'template_caregivers_no_menu'\n @body_id = \"Caregivers\" \n elsif @page.template.name == 'template_providers_no_menu'\n @body_id = \"Providers\" \n elsif @page.template.name == 'template_index'\n @body_id = \"Home\" \n end\n \n @left_top_menu = Page.find_by_path 'left_top_menu' \n @left_bottom_menu = Page.find_by_path 'left_bottom_menu' \n \n \n @page_template, @page_type = 'template_pdf', 1 if @page.path == 'CaregiverTool'\n @page_template, @page_type = 'template_pdf', 2 if @page.path == 'ProviderTool'\n \n end\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def set_Page(value)\n set_input(\"Page\", value)\n end", "def page_partial(page)\n page.set_page? ? 'set_page_li' : 'page_li'\n end", "def set_page_info\n unless user_signed_in? && (current_user.is_customer? || current_user.is_vendor? )\n @menus[:general_ledger][:active] = \"active\"\n end\n end", "def edit\n # fetching page via before filter\n if page_is_locked?\n flash[:notice] = _t(\"This page is locked by %{name}\", name: @page.locker_name)\n redirect_to admin_pages_path\n else\n @page.lock!(current_alchemy_user)\n @locked_pages = Page.from_current_site.all_locked_by(current_alchemy_user)\n end\n @layoutpage = @page.layoutpage?\n end", "def edit_page\n self.back_to_top\n edit_page_button\n wait_for_ajax\n self.class.class_eval { include DocumentWidget }\n end", "def set_page\n @page = site.pages.friendly.find(params[:id])\n @_type = @page.page_type.to_s.pluralize\n end", "def correct_page(page_to_render)\n\t\t\"/#{page_to_render}\"\n\tend", "def switch_page(page)\n main.display (@current_page = page)\n @displayed_items = items[current_page * max_items, max_items]\n header_l.draw_path_and_page_number path: current_dir.path, current: current_page + 1, total: total_pages\n end" ]
[ "0.7223673", "0.67566884", "0.65365523", "0.64494294", "0.6282483", "0.6277074", "0.6276437", "0.6276437", "0.6276437", "0.6276437", "0.6276437", "0.6276437", "0.6276437", "0.6276437", "0.6276437", "0.6276437", "0.6276437", "0.6276437", "0.6227069", "0.6227069", "0.61880505", "0.6134827", "0.61335814", "0.6101848", "0.6100416", "0.6081488", "0.6050635", "0.60388315", "0.60217273", "0.59801096", "0.5969611", "0.5968463", "0.5965718", "0.5962456", "0.5950488", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900988", "0.5900868", "0.5900868", "0.5900868", "0.5900493", "0.5900493", "0.5891898", "0.58777773", "0.5876605", "0.58735335", "0.586843", "0.58632743", "0.5861782" ]
0.60078204
29
before_create :send_message def initialize
def send_message response = RestClient::Request.new( :method => :post, :url => "https://api.twilio.com/2010-04-01/Accounts/#{ENV['TWILIO_ACCOUNT_SID']}/Messages.json", :user => ENV['TWILIO_ACCOUNT_SID'], :password => ENV['TWILIO_AUTH_TOKEN'], :payload => { :Body => body, :To => Contact.find(self.contact_id).number, :From => ENV['USER_NUMBER'] } ).execute end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n create_message(params)\n end", "def before_create()\n end", "def send_message\n create_sender_communication\n create_receiver_communication\n update_sent_at\n self.save\n end", "def create_message(data); end", "def create_message(data); end", "def new_message\n end", "def create\n message = Message.new(message_params)\n conversation = Conversation.find(message_params[:conversation_id])\n message.username = message.user.username\n if message.save\n serialized_data = ActiveModelSerializers::Adapter::Json.new(\n MessageSerializer.new(message)).serializable_hash\n MessagesChannel.broadcast_to(conversation, serialized_data)\n # ActionCable.server.broadcast 'conversations_channel', serialized_data\n head :ok\n # binding.pry\n end\n end", "def create\n welcome_message\n super\n end", "def create_notification; end", "def send_on_create_instructions\n send_create_instructions\n end", "def create\n @message = Message.new(message_params)\n create_q(@message)\n end", "def create\n @message = Message.new(message_param)\n @message_thread = MessageThread.find(@message.message_thread_id)\n\n @message.receiver = current_user.equal_user?(@message_thread.started_user) ? @message_thread.to_user : @message_thread.started_user\n @message.sender = current_user\n @message.is_sender_read = true\n @message.is_receiver_read = false\n\n if @message.save\n flash[:success] = \"Message has been sent!\"\n redirect_to @message_thread\n end\n end", "def create\n @message = Message.new(message_params)\n @message.message_type = 'Reqular Message `'\n respond_to do |format|\n if @message.save\n format.html { redirect_to @message, notice: 'Message was successfully created.' }\n format.json { render :show, status: :created, location: @message }\n else\n format.html { render :new }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # les messages sont des tests\n @view = \"interface\" if request.referrer.include?(\"interface\")\n @view = \"chat\"\n @body = params[:message][:body]\n @phone_number = params[:message][:user]\n # création de l'utilisateur s'il n'existe pas\n # sauvegarde du message\n # parsing\n # répartition vers la bonne methode\n @interface = false\n @interface = true if request.referrer.include?(\"interface\")\n\n set_user_create_message_parse_and_point\n end", "def init_message\n @message = Message.new(user_id: current_user.id, cabal_id: params[:id])\n end", "def create\n #initial message hash exist only when comming from offer post. Message from inbox does not contain initial_message\n if(params[:initial_message] == \"true\")\n # Check if the users had sent message between them\n unless Usercontact.where(user_id: current_user.id, contacted_id: params[:user_to_id]).exists?\n messagebox = Messagebox.create()\n\n Usercontact.create(user_id: current_user.id, contacted_id: params[:user_to_id], messagebox_id: messagebox.id)\n # This can be written in callback but dont know how to do it...\n Usercontact.create(user_id: params[:user_to_id], contacted_id: current_user.id, messagebox_id: messagebox.id)\n end\n end\n\n\n @message = Message.new(message_params)\n\n respond_to do |format|\n if @message.save\n\n unless @message.user_to.email.blank?\n MessageNotificationMailer.message_notify(@message).deliver\n end\n\n if(params[:initial_message] == true)\n format.html { redirect_to inbox_index_path, notice: 'Message was successfully created.' }\n else\n format.html { redirect_to inbox_index_path }\n end\n format.json { render :show, status: :created, location: @message }\n else\n format.html { render :new }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @message = Message.new(message_params)\n @message.sent_at = Time.now\n if @message.save\n render text: 'message successfully created.', status: :created\n else\n render json: @message.errors, status: :unprocessable_entity\n end\n end", "def create\n @message = Message.new(message_params)\n @message.sender_id = current_user.id\n @message.recipient_id = params[:recipient_id]\n\n respond_to do |format|\n if @message.save\n flash[:notice] = \"Mesaj gönderildi.\"\n format.json { render json: {success: true} } \n # Pusher.trigger('private-'+params[:recipient_id],'new_message', {:from => current_user.name, \n # :subject => @message.subject})\n else\n flash[:error] = \"Mesaj gönderilemedi.\"\n redirect_to '/'\n end\n end\n end", "def create\n @message = Message.new(params[:message])\n @message.send(:find_apropos)\n if admin_session? and @message.apropos and (not @message.to_user) and (not @message.system_message?)\n @message.from_user = @message.apropos.host\n else\n @message.from_user = current_user # important! Message#sender_authorized_to_send? depends on this being set correctly\n end\n\n respond_to do |format|\n if @message.save\n unless @message.to_user\n case @message.apropos\n when Event\n @message.apropos.create_activity(key: 'event.email', owner: current_user, parameters: {:uuid => @message.uuid})\n end\n end\n format.html { redirect_to :back, notice: 'Your message has been sent.' }\n format.json { render json: {}, status: :created, location: @message }\n else\n format.js { render :json => { :errors => @message.errors.full_messages, :message => \"Problem creating new message\" }, :status => :unprocessable_entity }\n format.html { render_error(:message => \"Trouble saving message.\", :status => 403) }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @message = current_user.send_message params[:message]\n if @message.new_record?\n render :action => \"new\"\n else\n flash[:notice] = \"The message was saved successfully.\"\n redirect_to messages_path\n end\n end", "def create\n message = msg_params\n @msg = Msg.new(msg_params)\n thesender = @msg.sender\n thesentdate = @msg.sent\n theservertime = DateTime.now\n unless @msg.content.empty? || @msg.sender.empty?\n ActionCable.server.broadcast 'room_channel',\n content: @msg.content,\n sender: thesender,\n servertime: theservertime\n end\n end", "def send_message\n if self.id != 1\n admin_sender = User.find(1)\n user_receiver = self\n message = Message.new\n message.subject = \"It's Official! You're in.\"\n message.body = \"As a member of the VVI community, you're now able to contact other volunteers directly, share your own experiences online, and stay active in our mission to make the world of international volunteering more transparent, more organized, and more excellent. \n <br /><br />We can't thank you enough for joining the cause! And we're here if you need anything.\n <br /><br />--VolunteerVoice Team\"\n message.recipient = user_receiver\n message.sender = admin_sender\n message.save\n end\n end", "def create\n @message = Message.new params[:message]\n @message.user_id = current_user.id \n @message.save\n end", "def create\n @room_message = RoomMessage.create user: current_user,\n room: @room,\n watsonmsg: false,\n message: params.dig(:room_message, :message),\n params: @room.params\n\n RoomChannel.broadcast_to @room, @room_message\n \n #check if user is currently reviewing a movie or taking quiz. If they are, send message to sentiment analysis and update rating\n if @room.lastIntent == \"already_seen\" then\n \tputs \"\\n\\n\\n The message you just sent was a review: \" + @room_message.message.to_s + \"\\n\\n\\n\" #debugging\n \t#send @room_message to sentiment analysis\n \t#set rating for movie\n \trate_movie\n\t \n\t #clear lastIntent\n\t @room.lastIntent = \"\"\n\t @room.save\n #check if user is answering quiz question\n\t elsif @room.lastIntent == \"start_quiz\" then\n\t take_quiz\n\t \n\t #clear lastIntent\n\t @room.lastIntent = \"\"\n\t @room.save\n\t #otherwise, get response from watson \n else\n\t \tget_response\n\t end\n end", "def create\n # @message = Message.new(message_params)\n # @message is built by CanCanCan\n respond_to do |format|\n if @message.save\n @message.notify(:commoners, group: @message.conversation) if @message.in_conversation?\n @message.notify(:commoners, group: @message.discussion) if @message.in_discussion?\n format.html { redirect_to success_path, notice: _('Message sent') }\n else\n @new_message = @message\n @messages = Message.where(messageable: messageable)\n format.html { render \"#{messageable.class.class_name.downcase.pluralize}/show\" }\n end\n end\n end", "def after_create; end", "def notification_on_create\n create_notification(:create)\n end", "def initialize\n super(MESSAGE)\n end", "def create\n @message = Message.new(params[:message])\n if @message.save\n MessageMailer.notify_private_message_sent(@message.sender, @message.receiver).deliver\n puts \"FOI\"\n end\n respond_with(@message)\n end", "def create\n message = Message.new(message_params)\n message.user = current_user\n if message.save\n # 'messages' is name of channel we are broadcasting to\n ActionCable.server.broadcast 'messages',\n # Set message and user\n message: message.content,\n user: message.user.first_name\n head :ok\n end\n end", "def create\n\n logger.info params[:message].to_yaml\n @message = Message.new(params[:message])\n\n if @message.save\n UserMailer.new_message(@message).deliver\n redirect_to user_messages_path(@message.receiver)\n else\n # @messages = Message.where(\"(sender_id = ? AND receiver_id = ?) OR (sender_id = ? AND receiver_id = ?)\", current_user.id, @user.id, @user.id, current_user.id)\n render :template => user_messages_path(@message.receiver_id)\n \n end\n \n end", "def create\n @user = User.find(params[:send_to]) if params[:send_to].present?\n @message = Message.new(({:body => params[:body] ,:user_id => current_user.id, :user_status => \"sent\", :message_type => 'sent', :receiver_id => @user.id, :receiver_status => \"unread\"}))\n if @message.save\n UserMailer.message_notification(current_user, @user, @message).deliver if [email protected]_s.blank? and !EmailSetting.exists?(:user_id => @user.id, :alert_type => 'messages', :status => false)\n response_message = {:message => \"Message was successfully sent.\"}\n else\n response_message = [email protected]? ? @message.errors : {:errors => \"Message sending faild. Please try again.\"}\n end\n respond_to do |format|\n format.xml { render :xml => response_message }\n format.json { render :json => response_message }\n end\n end", "def create\n render(status: :forbidden, text: 'Invalid message') and return if params[:message].blank? or params[:message][:content].blank?\n @channel = Channel.find(params[:channel_id])\n @message = @channel.messages.create(params.require(:message).permit(:content))\n @message.user_name = session[:user_name]\n\n if @message.save\n Pusher['presence-channel-' + params[:channel_id]].trigger('message_added', {message: {user_name: h(@message.user_name), content: view_context.auto_link(@message.content)}, time: @message.created_at.localtime.strftime('%H:%M')})\n render status: :created, body: nil\n else\n render status: :forbiden, text: 'The message can\\'t save'\n end\n end", "def create\n @message = Message.new(message_params.merge(read: false))\n\n if @message.sender == @message.message_thread.seller\n @message.receiver = @message.message_thread.buyer\n else\n @message.receiver = @message.message_thread.seller\n end\n\n respond_to do |format|\n if @message.save\n MessageBroadcastController.publish('/messages', @message.detailed_attributes)\n format.json { render json: @message.attributes, status: :created }\n else\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @message = Message.new(params[:message])\n\n respond_to do |format|\n if @message.save\n recipient_phone = Phone.find_by_number(@message.number)\n \t recipient_phone ||= User.create!.phones.create!(:number => @message.number)\n @message.send_SMS(@message.raw_message, recipient_phone, \"\", @message.app.id)\n format.html { redirect_to messages_path, notice: 'Message was successfully sent.' }\n format.json { render json: @message, status: :created, location: @message }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def send_message(message); end", "def send_message(message); end", "def create\n @chat = Chat.new(chat_params)\n @chat.user = current_user\n if @chat.save\n Pusher['global_chat_channel'].trigger('global_chat_event', {\n id: @chat.id,\n message: @chat.message,\n user: @chat.user.email,\n color: 'red',#@chat.user.color,\n created_at: @chat.user.created_at.strftime(\"%I:%M%p\")\n })\n end\n\n render nothing: true\n end", "def create\n @message = Message.new(message_params)\n\n if @message.save\n ActionCable.server.broadcast 'room_channel', content: @message.content, user_name: @message.user.name\n # head :ok\n end\n end", "def create\n @message = Message.new(message_params)\n\n respond_to do |format|\n if @message.save\n whatsapp = WhatsApp.new\n whatsapp.line = @message.sender\n whatsapp.url = @message.url\n whatsapp.appname = @message.appname\n whatsapp.token = @message.token\n whatsapp.messageSend(@message.id, @message.recipient, @message.text)\n #whatsapp.questionSend(@message.id, @message.recipient, @message.text, \"['Sim';'Não']\")\n\n format.html { redirect_to @message, notice: 'Message was successfully created.' }\n format.json { render :show, status: :created, location: @message }\n else\n format.html { render :new }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @message = Message.new(message_params)\n\n buyer = User.find(Purchase.find(Chat.find(message_params[:chat_id]).purchase_id).user_id)\n owner = User.find(Product.find(Purchase.find(Chat.find(message_params[:chat_id]).purchase_id).product_id).user_id)\n email_after_sending_message(buyer, owner)\n\n respond_to do |format|\n if @message.save\n format.js { render nothing: true}\n format.html { redirect_to Chat.find(message_params[:chat_id]), notice: \"Mensaje enviado\" }\n format.json { render :show, status: :created, location: @message }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user = User.find_by(token: params[:token])\n new_message_params = {\n text: message_params[:text],\n conversation_id: message_params[:conversation_id],\n user_id: user.id,\n username: user.username\n }\n @message = Message.new(new_message_params)\n conversation = Conversation.find(message_params[:conversation_id])\n\n if @message.save\n # render json: @message, status: :created, location: @message\n serialized_data = ActiveModelSerializers::Adapter::Json.new(\n MessageSerializer.new(@message)\n ).serializable_hash\n MessagesChannel.broadcast_to conversation, serialized_data\n head :ok\n else\n render json: @message.errors, status: :unprocessable_entity\n end\n end", "def messaging\n end", "def initialize message\n @message = message\n end", "def create\n @message = Message.create(message_params)\n ActionCable.server.broadcast(\"chatting_channel\", {\n data_type: \"message\",\n user_id: @message.user_id, \n content: @message.content,\n created_at: (@message.created_at.strftime(\"%m/%d %H:%M\")),\n }) if @message.present?\n head :ok\n\n end", "def initialize_messenger\n raise NotImplementedError\n end", "def after_database_authentication\n\n \t# If the identifier is nil, then assign random string\n \t# Can be used to identify user if we dont want to use the default id\n\tidentifier = SecureRandom.urlsafe_base64\n\tif self.identifier.nil?\n \tself.update_attribute(:identifier, identifier)\n \tend\n\n \t#Send use the first message from admin\n \tmessages = Message.where('sender_id = ? OR recipient_id = ?', self.id, self.id)\n \tif messages.size == 0\n \t\ttext = \"Hi #{self.id}! Welcome to Witaji!\"\n \t\tMessage.create({ recipient_id: self.id, sender_id: 1, text: text, pusher_channel: \"1-#{self.id}\" });\n \tend\n\n end", "def create\n super\n # slack通知\n c = Payment.create_customer(resource.email, resource.name)\n resource.update(pay_customer_id: c.id)\n notifier = Slack::Notifier.new(Rails.application.config.slack_webhook_url)\n notifier.ping(\"新しく管理人が登録されました!\")\n end", "def create\n\n if session['user_type'] == nil\n redirect_to root_path\n return\n end\n\n @message = Message.new(create_message_data())\n\n if @message.save\n @skills = Skill.all\n @messages = Message.select_message_thread(session[:user_type],session[:user_id],params[:message][:opponent_id]).page(params[:page])\n @new_message = Message.new\n @opponent = Company.find(params[:message][:opponent_id].to_i) if view_context.am_i_engineer?\n @opponent = Engineer.find(params[:message][:opponent_id].to_i) if view_context.am_i_company?\n from_user = Engineer.find(session[:user_id]) if view_context.am_i_engineer?\n from_user = Company.find(session[:user_id]) if view_context.am_i_company?\n to_user = Company.find(params[:message][:opponent_id]) if view_context.am_i_engineer?\n to_user = Engineer.find(params[:message][:opponent_id]) if view_context.am_i_company?\n create_notification()\n flash.now[:notice] = 'メッセージの送信に成功しました'\n redirect_to message_path(@message.id,:opponent_id => params[:message][:opponent_id])\n else\n @engineer_id = params['message']['engineer_id']\n render :new\n end\n\n end", "def non_atomic_create\n messages_requested = @room.messages_requested.increment\n @room.send_message_to_requested_channel(@room.messages_requested.value)\n if @room.messages_posted <= @room.max_messages\n if @message.save\n @room.messages_posted.increment\n @room.send_message_to_posted_channel(@room.messages_posted.value)\n @room.send_message_to_chat_channel(render_message_to_string)\n render nothing: true\n else\n logger.info @message.errors.inspect\n end\n else\n render nothing: true\n end\n end", "def create\n # We only allow from system type useres\n return head :forbidden unless current_user.system?\n @message = current_account.dte_messages.new(message_params)\n #@message.sent_date = Time.parse(message_params[:sent_date]).to_s(:db) unless message_params[:sent_date].nil?\n respond_to do |format|\n if @message.save\n format.html { redirect_to @message, notice: 'Message was successfully created.' }\n format.json { render :show, status: :created, location: @message }\n else\n format.html { render :new }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def onmessage(&blk); super; end", "def create\n params[:message][:to] = User.find_by_fullname(params[:message][:to]).id\n @message = Message.new(params[:message])\n @message.from = current_user.id\n @message.seen = false\n if @message.save\n flash[:notice] = \"Message sent\"\n else\n flash[:notice] = \"Message not sent\"\n end\n redirect_to(:action => 'index')\n end", "def article_create\n NotificationMailer.article_create\n end", "def create\n # if params[:user_id].to_i == current_user[:id]\n # return\n # end\n @message = Message.new(message_params)\n @message.user = current_user\n @message.room_id = params[:room_id]\n @messages = Message.all\n ActionCable.server.broadcast \"room_channel_#{@message.room_id}\", message: @message\n\n if @message.save\n render json: @message\n else\n render plain: \"Failed to create a message\", status: :unprocessable_entity\n end\n end", "def create\n @message = Message.new params[:message]\n @message.save\n respond_with @message, location: after_send_path, notice: t('hyalin.messages.sent_success')\n end", "def create\n message = Message.new({content: params[:message], chatroom_id: params[:chatroomId].to_i, user_id: params[:userId].to_i})\n\n if message.save\n user = message.user\n message_reactions = message.message_reactions\n\n message_reactions.map {|reaction| {reaction: reaction, user: reaction.user}}\n updatedChatroom = Chatroom.find(params[:chatroomId]) \n ActionCable.server.broadcast(\n \"chatroom_#{params[:chatroomId]}\",\n {\n newMessage: {message: message, user: user},\n messageReactions: message_reactions,\n user: user,\n updatedChatroom: updatedChatroom\n }\n )\n end\n end", "def create\n CorreosMailer.create\n end", "def create\n @message = Message.new(message_params)\n @message.sender_id = current_user.id\n @message.sender_name = current_user.name\n @message.read_flag = false\n @message.create_datetime = Time.current\n\n respond_to do |format|\n if @message.save\n format.html { redirect_to @message, notice: 'メッセージを送信しました。' }\n format.json { render :show, status: :created, location: @message }\n else\n format.html { render :new }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @message = current_owner.messages_as_sender.new(message_params)\n respond_to do |format|\n if @message.save\n format.html { redirect_to messages_path, notice: 'Message was successfully created.' }\n format.json { render :show, status: :created, location: @message }\n else\n format.html { render :new }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def message_create(message,user)\n @message=message\n @user=user\n mail to: @user.email, subject: \"New Message created for your Message Board (Socail Trip App)\", from:'[email protected]'\n end", "def create\n @message = Message.new(message_params)\n @message.user = current_user\n if @message.save\n #ActionCable.server.broadcast \"messages_#{params[:authid]}\", message: @message.content, user: current_user.name\n head :ok\n else\n render :edit\n end\n end", "def create\n @message = Message.new\n @message.create_one!(params[:message])\n #Juggernaut.publish(1, parse_chat_message(params[:message][:message], current_user))\n respond_to do |format|\n format.html { redirect_to :index }\n format.js\n end\n end", "def create\n @message = Message.new(message_params)\n respond_to do |format|\n if @message.save\n format.json {render json: :created}\n else\n format.json {render json: \"not created\"}\n end\n end\n end", "def set_form\n # find the maximum number of users possible\n @max_count = User.all.count\n # check if a message already exists\n if !(defined?(@message)).nil?\n @sender = @message.sender\n @reciever = @message.reciever\n else # else the message is then being created\n # set the sender as the user creating the message\n @sender = params[:user_id]\n # let user determine the reciever of his message\n @reciever = nil\n end\n \n end", "def create\n message = Message.new(message_params)\n message.message = params[:message_text]\n message.display_name = params[:display_name]\n message.save!\n render json: message\n end", "def create\n message_reaction = MessageReaction.new({content: params[:reaction], message_id: params[:messageId].to_i, user_id: 1})\n\n if message_reaction.save\n updatedMessage = Message.find(params[:messageId]) \n ActionCable.server.broadcast(\n \"message_#{params[:messageId]}\",\n newMessageReaction: message_reaction,\n updatedMessage: updatedMessage,\n )\n end\n end", "def new_message(message)\n @message = message\n mail\n end", "def init_message(message)\n command = command_factory.instance.build(message)\n command.respond(self)\n end", "def create\n @message = Message.new(params[:message])\n @message.user = User.find_by_username(params[:username])\n @message.sender = @user\n respond_to do |format|\n if @message.save\n flash[:notice] = 'pesan sudah terkirim.'\n format.html { render :action => \"show\" } \n else\n format.html { render :action => \"new\" }\n end \n end\n end", "def create\n @conversation = Conversation.find(params[:conversation_id])\n @message = @conversation.messages.create(:body => params[:message][:body], :user_id => session[:user_id], :user_name => session[:user_name])\n\n #logger.info 'PARAMS@@@@@@@@@@@'\n #logger.info params[:message_body]\n\n respond_to do |format|\n if @message.save\n\n desc = @conversation.topic + \": \\\"\" + @message.body + \"\\\"\"\n add_event( EVENT_NEW_MESSAGE, desc[0,150], EVENTSOURCE_USER, session[:user_id], session[:user_name], nil)\n\n #MessageMailer.welcome_email(current_user).deliver\n\n format.html { redirect_to(pad_conversations_path(@pad), :notice => 'Message was successfully created.') }\n format.xml { render :xml => @message, :status => :created, :location => @message }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @message.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n if !params[:callback].nil? && !params[:id].nil?\n @message_table = MessageTable.where(\"id = ?\", params[:id]).first\n if @message_table.nil?\n render :text => \"#{params[:callback]}({\\\"status\\\" : \\\"error\\\", \\\"msg\\\" : \\\"信息表不存在!\\\"})\"\n elsif !@message_table.effective?\n render :text => \"#{params[:callback]}({\\\"status\\\" : \\\"error\\\", \\\"msg\\\" : \\\"信息表已过期!\\\"})\"\n else\n _message_object = {}\n @message_table.message_columns.each do |message_column|\n if message_column.type_id == 3\n if params[:message_table][message_column.column_name.to_sym].nil?\n _message_object[message_column.column_name] = []\n else\n if params[:message_table][message_column.column_name.to_sym].kind_of?(Array)\n _message_object[message_column.column_name] = params[:message_table][message_column.column_name.to_sym]\n else\n _message_object[message_column.column_name] = [].push(params[:message_table][message_column.column_name.to_sym])\n end\n end\n else\n _message_object[message_column.column_name] = params[:message_table][message_column.column_name.to_sym] || ''\n end\n end\n @message_text = MessageText.new\n @message_text.message_table_id = @message_table.id\n @message_text.text = _message_object\n @message_text.ip = request.remote_ip\n @message_text.created_at = DateTime.now\n @message_text.updated_at = DateTime.now\n if !current_user.nil?\n @message_text.user_id = current_user.uid\n @message_text.user_name = current_user.name\n end\n @message_text.save\n render :text => \"#{params[:callback]}({\\\"status\\\" : \\\"success\\\", \\\"msg\\\" : \\\"信息提交成功!\\\"})\"\n end\n \n end\n end", "def send_message(msg); end", "def new\n \t@message = Message.new\n end", "def create\n begin\n sha256 = OpenSSL::Digest::SHA256.new\n # sig_service berechnen\n digest = sha256.hexdigest(params[:timestamp].to_s + params[:recipientname].to_s + params[:name].to_s + params[:cipher].to_s + params[:iv].to_s + params[:key_recipient_enc].to_s + params[:sig_recipient].to_s)\n # public_key des Users aus der Datenbank holen\n public_key = OpenSSL::PKey::RSA.new(Base64.decode64(User.find_by_name(params[:name]).public_key))\n # sig_service vom Client entschlüsseln\n decrypt_digest = public_key.public_decrypt(Base64.decode64(params[:sig_service]))\n # Prüfen ob der Empfänger existiert\n if User.exists?(name: params[:recipientname]) then\n # sig_service überprüfen\n if decrypt_digest == digest then\n # Überprüfen ob Nachricht nicht älter als fünf Minuten\n if (Time.now.to_i - params[:timestamp].to_i) < 300 and (Time.now.to_i - params[:timestamp].to_i) >= 0 then\n @message = Message.new(message_params)\n @message.is_called = 0\n respond_to do |format|\n # Nachricht speichern\n if @message.save\n format.json { render json: '{\"status\":\"1\"}'}\n else\n format.json { render json: '{\"status\":\"2\"}'}\n end\n end\n else\n respond_to do |format|\n format.json { render json: '{\"status\":\"4\"}'}\n end\n end\n else\n respond_to do |format|\n format.json { render json: '{\"status\":\"5\"}'}\n end\n end\n else\n respond_to do |format|\n format.json { render json: '{\"status\":\"3\"}'}\n end\n end\n rescue Exception => e\n render json: '{\"status\":\"99\"}'\n end\n end", "def create\n\n message = Message.new(message_params)\n message.user = current_user\n if message.content.blank? && !message.file.url.nil?\n message.content = \"Attachment\"\n end\n respond_to do |format|\n if message.save\n message.chatroom.users.uniq.each do |user|\n notification = Notification.where(user: user, notification_type: \"New Message\", notification_object_id: message.chatroom.id).first\n if notification.nil?\n notification = Notification.create!(user: user, notification_type: \"New Message\", notification_object_id: message.chatroom.id, read: false)\n else\n notification.read = false\n notification.save\n end\n end\n format.html {chatroom_path(message.chatroom)}\n else\n format.html {chatroom_path(message.chatroom) }\n end\n end\n\n end", "def message; Message.new; end", "def create\n @message = Message.new(params[:message])\n authorize! :create, Message\n @message.recipient_id = params[:user_id]\n @message.sender_id = current_user.id\n @message.read = false # this should have been defined as default in migration, I know\n\n respond_to do |format|\n if @message.save\n format.html { redirect_to show_user_profile_path(params[:user_id]), notice: 'Message was successfully sent.' }\n format.json { render json: @message, status: :created, location: @message }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @message = Message.new(params[:message])\n @message.user_id = current_user.id\n \n respond_to do |format|\n if @message.save\n format.json { render json: @message, status: :created}\n else\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def create \n @message = Message.new(message_params)\n @message.sender_id = current_user.id\n\n respond_to do |format|\n if @message.save\n format.html { redirect_to @message, notice: 'Message was successfully created.' }\n format.json { render :show, status: :created, location: @message }\n else\n format.html { render :new }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @message = @messagable.received_messages.build(params[:message])\n return redirect_to :back if @messagable.class == Alliance && !user.member_of?(@messagable)\n @message.user = current_user\n if @message.save\n redirect_to polymorphic_path([@messagable, :messages])\n else\n render :action => 'new'\n end\n end", "def create\n puts params['msg']\n receiver = User.find_by(username: params['receiver']).id\n\n @message = Message.new(seen: 0, sender: current_user.id, receiver: receiver, contents: params[:msg], sent_at: Time.now)\n @message.save!\n\n #Load the messages\n m = current_user.chat_with(params['receiver'])\n respond_to do |format|\n format.js { render json: m.to_json }\n format.html\n end\n\n # @message = Message.new(message_params)\n\n # respond_to do |format|\n # if @message.save\n # format.html { redirect_to @message, notice: 'Message was successfully created.' }\n # format.json { render :show, status: :created, location: @message }\n # else\n # format.html { render :new }\n # format.json { render json: @message.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create_welcome_notification\n factory = ActivityFactory.new self\n factory.generate :create, recipient: self\n end", "def after_create(obj); end", "def before_save\n if self.messenger_id_changed?\n self.verification_code = rand(999999).to_s.center(6, rand(5).to_s)\n RedmineMessenger::Messenger.send_message(self.messenger_id, ll(language, :messenger_welcome_message))\n end\n true\n end", "def create\r\n @message = Message.new(message_params).tap do |m|\r\n m.user = current_user\r\n m.channel = @channel\r\n end\r\n\r\n if @message.save\r\n push_notification :add\r\n @message.mark_as_read! for: current_user\r\n end\r\n\r\n render inline: \"{}\"\r\n end", "def creating( msg )\n @log.info \"creating #{msg}\"\n end", "def create\n chatroommessage = ChatroomMessage.new(permitted_params)\n chatroom = Chatroom.find(permitted_params[:chatroom_id])\n if chatroommessage.save\n serialized_data = ActiveModelSerializers::Adapter::Json.new(\n ChatroomMessageSerializer.new(chatroommessage)\n ).serializable_hash\n ChatroomMessagesChannel.broadcast_to chatroom, serialized_data\n head :ok\n end\n end", "def create\n run_callbacks :create do\n true\n end\n end", "def initialize(message)\n super(message)\n end", "def create\n # create an incoming sms object\n sms = Sms::Message.create(:from => params[:sms_test][:from], :body => params[:sms_test][:body], :mission => current_mission)\n\n # submit it to the handle method over in the SmsController and get the reply\n reply = SmsController.handle_sms(sms)\n\n # save the reply and let the sent_at default to now\n reply.save if reply\n\n # render the body of the reply\n render :text => reply ? reply.body : \"<em>#{t('sms_console.no_reply')}</em>\".html_safe\n end", "def intialize(ship_to_address, message)\n# give values to your attr\n# when set post.new its looks at ship_to_address , message\n@ship_to_address = ship_to_address\n@message = message\nend", "def create_message\n @message = Message.new(params[:message])\n @message.sended_at = Time.now.to_f\n respond_to do |format|\n if @message.save\n format.html { redirect_to(\"/chat/update/#{@message.user.id}\") }\n format.xml { render :xml => @message, :status => :created, :location => @message }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @message.errors, :status => :unprocessable_entity }\n end\n end\n end", "def initialize\n @conn=MessageDistributor.instance\n @conn.add_observer(self)\n super(@conn)\n end", "def api_create\n @message = Message.new\n @message.user_id = params[:message][:user_id]\n @message.room_id = params[:message][:room_id]\n @message.content = params[:message][:content]\n @message.save\n\n #Generate de js to publish\n jsScript = createMessage(@message)\n PrivatePub.publish_to(\"/rooms/#{@message.room_id}\", jsScript)\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.json { render json: @message}\n else\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def on_create(instructable, address)\n @instructable = instructable\n if address == @instructable.user.email\n @reason = 'you created this class'\n else\n @reason = 'you are an admin of the system'\n end\n\n mail(to: address, subject: \"Class added: #{@instructable.name}\")\n end", "def create\n\n\n @message = Message.new(message_params)\n @message.user_id = current_user.id\n @message.body = params[:message][:body]\n @message.save\n\n Recipient.create!(:message_id=>@message.id, :user_id=>params[:to_user_id],:sender_id => current_user.id, :receiver_id => params[:to_user_id],:status=>false)\n\n redirect_to \"/profile/#{current_user.id}\"\n end", "def send_on_create_confirmation_instructions; end", "def send_on_create_confirmation_instructions; end", "def send_on_create_confirmation_instructions\n end", "def create\n @message = Message.new(message_params)\n\n respond_to do |format|\n if @message.save\n format.html { redirect_to @message, notice: \"Message sent to #{@message.receiver.full_name}.\" }\n format.json { render :show, status: :created, location: @message }\n else\n format.html { render :new }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.70992315", "0.6909764", "0.68819165", "0.6819651", "0.6819651", "0.67327917", "0.6639944", "0.66332066", "0.662693", "0.6606717", "0.66044635", "0.6579854", "0.65401685", "0.6531621", "0.6524528", "0.65060323", "0.650392", "0.6464165", "0.6455669", "0.6433637", "0.64270896", "0.64265776", "0.641809", "0.6397878", "0.6381962", "0.6379764", "0.6374109", "0.6351797", "0.63451546", "0.63417506", "0.6332252", "0.63312966", "0.63120735", "0.62992024", "0.6291445", "0.628335", "0.628335", "0.6281525", "0.6254127", "0.6253038", "0.6242399", "0.6238166", "0.6236922", "0.6236447", "0.6220295", "0.6216315", "0.6208796", "0.6200779", "0.61968344", "0.61829656", "0.61823773", "0.61705977", "0.6165045", "0.61638165", "0.6163225", "0.6157712", "0.6157591", "0.6153783", "0.6148171", "0.6147877", "0.61445194", "0.6101995", "0.60953206", "0.6094185", "0.6087228", "0.60872054", "0.60754174", "0.60746884", "0.6070173", "0.6069792", "0.6067664", "0.60629904", "0.6062152", "0.605852", "0.60581386", "0.60570097", "0.6055468", "0.6052173", "0.60510474", "0.6044034", "0.60428715", "0.6035184", "0.60316265", "0.60313815", "0.6030444", "0.603023", "0.60280824", "0.60269547", "0.60268784", "0.6026377", "0.6026213", "0.602547", "0.6012766", "0.60118693", "0.6010566", "0.6009946", "0.6004982", "0.59945625", "0.59945625", "0.5992867", "0.5992136" ]
0.0
-1
Builds an array of prime numbers
def find_prime x = 2 while @prime_numbers.count < @total @prime_numbers << x if prime?(x) x += 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def primeArray(number)\n @sieve = Array.new(number)\n \n for count in 2..Math.sqrt(number)\n next if @sieve[count]\n \n for inner_count in 2..number/count\n @sieve[count * inner_count] = true\n end\n end\n @sieve\nend", "def primes(num)\n\twhole_array = (2..num).to_a\n\tprime_array = [whole_array.shift]\n\n\tuntil whole_array == []\n\t\twhole_array.delete_if { |x| x % prime_array.last == 0 }\n\t\tprime_array << whole_array.shift\n\tend\n\tprime_array\nend", "def primes (number)\n primes_array = []\n Prime.each(number) do |p|\n primes_array.push(p)\n end\n\n primes_array\nend", "def primes_array(options = {})\n limit = options[:limit] || ARRAY_DEFAULT_LIMIT\n field = Array.new(limit+1, true)\n # sieve the number field\n 3.step(field.size / 2, 2) do |k|\n (3 * k).step(field.size, 2 * k) do |n|\n field[n] = false\n end\n end\n \n # collect the field into an array, starting with 3\n primes = [ 2 ]\n 3.step(field.size, 2) do |n|\n primes << n if field[n] \n end\n primes\n end", "def prime_num_gen( array_size )\n\n # array_size == array.length\n\n array = []\n\n divisors = []\n\n i = 0\n while( array_size != array.length )\n\n # p i\n\n if( i >= 2 ) # 0 and 1 are not prime\n\n if( i == 2 ) # two is a prime\n # p \" 2 is pushed\"\n array.push(i)\n end\n\n if( i % 2 != 0 ) # prime numbers cannot be even\n\n # p \" i #{i}\"\n # p \" divisors #{divisors}\"\n\n # START extra check - if i has more than 2 divisors\n #\n # IMPROVEMENT!!!!\n #\n # Could have simply called is_prime?( i ) --> returns true if prime\n # if is_prime? ? array.push(i) : p \"do nothing\"\n #\n j = 1\n while( i >= j )\n\n #p \" j #{j}\"\n\n if( i % j == 0)\n\n divisors.push(j)\n # p \" divisors #{divisors}\"\n end #if\n\n j += 1\n end # while\n\n if( divisors.length == 2 ) # prime should have 1 and itself as divisors\n array.push(i)\n # p \"#{i} is pushed\"\n end\n\n divisors.clear\n # p divisors\n\n # END of extra check\n #\n # extra check - if i has more than 2 divisors\n\n end # if (prime numbers cannot be even)\n\n end # if outter most\n\n i += 1\n end # while\n\n p array\n return array\n\nend", "def prime_number(n)\n res = []\n prime = Array.new(n + 1, true)\n (2..n).each do |x|\n num = x * x\n break if num > n\n\n if prime[x]\n (num..n).step(x).each do |multiples|\n prime[multiples] = false\n end\n end\n end\n \n (2..n).each do |primes|\n res << primes if prime[primes]\n end\n res\nend", "def primes(max)\n array = []\n i = 2\n while i < max.abs\n if is_prime?(i)\n array << i\n end\n i += 1\n end\n array\nend", "def arrPrimeFactors (n)\n result = Array.new\n while n != 1\n (2 .. n).each do |i|\n if n % i == 0\n result.push i\n n /= i\n break\n end\n end\n end\n result\nend", "def prime_number(n)\n prime_array = []\n count = 1\n until prime_array.length == n\n if count == 1\n prime_array << 2\n count += 2\n elsif is_prime?(count) == true\n prime_array << count\n count += 2\n else\n count += 2\n end\n end\n prime_array.last\nend", "def prime_set(n)\n\t\tprimes_arr =[]\n\t\ti = 1\n\t\t# keep inserting prime numbers into array until its length is equal to 'n'\n\t\tuntil primes_arr.count == n\n\t\t\tif is_prime(i) == true \n\t\t\t\tprimes_arr << i \n\t\t\tend \n\t\t\ti+=1\n\t\tend \n\t\tp primes_arr\n\tend", "def primes\n arr=Array.new\n arr[1]=false\n (2..1000).each {|i| arr[i]=true}\n (2..1000).each {|i| (i/2).floor\n (2..1000).each {|j| (j/i).floor\n arr[i*j] = false\n }}\n for i in 1..1000\n if arr[i] == true\n puts i\n end\n end\nend", "def prime (n)\n\n\t#create an Array\n\tprime_num = []\n\n\tfor num in (2..n)\n\t\tis_prime = factors(num)\n\t\tif (is_prime.length ==2)\n\t\t\tprime_num.push(num)\n\t\tend\n\tend\n\treturn prime_num\nend", "def primes\n\t\t# primes = []\n\t\t# primes << 2\n\t\tprimes = [2] # combined previous two lines\n\t\tx = 3\n\n\t\tloop do\n\t\t\tbreak if primes.length == @n_primes # End loop when desired number has been calculated\n\t\t# while primes.length < @n_primes # Alternative 1 to loop do, break\n\t\t# until primes.length == @n_primes # Alternative 2 to loop do, break\n\t\t\ty = 3\n\t\t\ty += 2 until x % y == 0 # Loop to test if x is divisible by any odd number below it, y\n\t\t\tprimes << x if x == y # If the (odd) number was not divisible by any (odd) below itself, it is a prime\n\t\t\tx += 2\n\t\tend\n\n\t\treturn primes\n\tend", "def get_primes num\n primes = []\n for i in 0 ... num do\n if check_prime?(i) == true\n primes.push(i)\n end\n end\n p primes\nend", "def primes_less_than(num)\n arr = []\n (2...num).each do |el|\n if is_prime?(el)\n arr << el\n end\n end\n arr\nend", "def find_prime_numbers(num)\n\tarr =[]\n (2..num).each{|x| arr.push(x)}\n\n i = 0\n p = arr[i]\n\n while p != arr[-1]\n\t arr.delete_if{|n| n%p == 0 && n != p}\n\t i+= 1\n\t p = arr[i]\n end\n return arr\nend", "def get_primes\n j = 0\n\n while j < @limit \n prime_number = is_prime\n if prime_number\n @prime_numbers.push(prime_number)\n j += 1\n end\n @count += 1\n end\n\n return @prime_numbers\n end", "def primes()\n return [] if @number < 2\n # build Boolean array to use for sieve with buffer to align indices\n sieve_array = Array.new(2, false) + Array.new(@number-1, true)\n # perform Sieve of Eratosthenes eliminations\n (2..Math.sqrt(@number).to_i).each do |i|\n (i**2..@number).step(i) {|j| sieve_array[j] = false} if sieve_array[i] == true\n end\n # return numbers by corresponding index that are still true\n (2..@number).collect {|index| index if sieve_array[index] == true}.compact\n end", "def sieve(n)\n # initialize an empty array (this will store all primes between 2 and n)\n prime_array = []\n for i in 2..n\n if(is_prime(i))\n # if 'i' is a prime number, add it to the array\n prime_array.push(i)\n end\n end\n # finally, we'll return our array of prime numbers\n return prime_array\nend", "def pretentious_primes(arr, num)\n new_arr = []\n if num > 0\n arr.each do |ele|\n i = ele + 1\n count = 0\n while true\n if is_prime?(i)\n count += 1\n end\n if count == num\n new_arr << i\n break\n end\n i += 1\n end\n end\n else\n num = -1 * num\n end\n new_arr\nend", "def find_primes(num,prime_array=[])\n i = 2\n until num % i == 0 \n i += 1\n end\n prime_array << i\n return prime_array if num == i\n find_primes(num/i, prime_array) \nend", "def prime(number)\n prime_numbers = []\n (2..number).each do |current_number|\n if is_prime? current_number\n prime_numbers << current_number\n end\n end\n return prime_numbers\nend", "def all_primes(number)\n primes = []\n (2...number).each do |num|\n if prime?(num)\n primes << num \n end\n end\n primes\nend", "def primes_below(n)\n a = 2\n output_array = []\n while a < n\n if is_prime?(a)\n output_array.push(a)\n end\n a = a + 1\n end\n return output_array\nend", "def prime_factors(num)\n arr = []\n (1...num).each do |number|\n if is_prime(number) && num % number == 0\n arr << number\n end\n end\n return arr\nend", "def prime_list(number_of_primes)\n return [] if number_of_primes < 1\n prime_numbers = Array.new\n for num in 2..9999999 do\n if is_prime_num(num, prime_numbers)\n prime_numbers.push(num)\n break if prime_numbers.length == number_of_primes\n end\n end\n return prime_numbers\n end", "def primes(n)\n result = []\n i = 2\n while i <= n\n j=2\n prime = true\n while j<=i**0.5\n (prime = false) if i%j==0\n j += 1\n end\n (result << i) if prime\n i +=1\n end\n return result\nend", "def prime_numbers\n s = (0..self).to_a\n s[0] = s[1] = nil\n s.each do |p|\n next unless p\n break if p * p > self\n (p*p).step(self, p) { |m| s[m] = nil }\n end\n s.compact\n end", "def prime_factors(num)\n arr = factors(num)\n new_arr = []\n arr.each do |n|\n new_arr << n if prime?(n)\n end\n new_arr\nend", "def primes\n return [] if self == 0\n return \"don't do that\" if self < 0\n list = [2]\n test = 3\n until list.length == self\n list << test if test.is_prime?\n test += 2\n end\n list\n end", "def prime_factors(num)\n arr = []\n (1..num).each { |n| arr << n if num%n==0 && prime?(n)}\n return arr\nend", "def build_out_prime_list\n new_size = prime_list.size + prime_list.size\n loop_end = Math.sqrt( idx_to_value( new_size ) ).ceil\n\n (prime_list.size..new_size).each { |idx| prime_list[idx] = true }\n\n prime_list.each_with_index do |prime, idx|\n next unless prime\n\n divisor = idx_to_value( idx )\n break if divisor > loop_end\n\n (idx+1..new_size).each { |i| prime_list[i] = false if idx_to_value( i ) % divisor == 0 }\n end\n end", "def prime_factorization(n)\n new_arr = []\n (2...n).each do |i|\n if n % i == 0\n dividend = n / i\n return [*prime_factorization(i), *prime_factorization(dividend)]\n end\n end\n new_arr << n\nend", "def get_primes(limit)\n primes = []\n (2...limit).each do |number|\n primes << number if is_prime?(number)\n end\n primes\nend", "def primes_less_than (num)\n arr=[]\n for n in 2..(num-1)\n if is_prime?(n)\n arr.push(n)\n end\n end\n p arr\n return arr\nend", "def getPrimes()\n oldlimit = $primelimit + 1\n $primelimit *= 2\n\n for i in oldlimit...$primelimit\n isPrime = true\n $primes.each do |p|\n if i % p == 0\n isPrime = false\n break\n end\n end\n if isPrime\n $primes << i\n end\n end\n\nend", "def primes(max)\n primes = []\n number = 2\n \n while number <= max\n primes << number if is_prime? number\n number += 1\n end\n primes\nend", "def primes(max)\n primes = []\n number = 2\n \n while number <= max\n primes << number if is_prime? number\n number += 1\n end\n primes\nend", "def divisors(n)\n i=2\n array=[]\n while i <= n/2\n if n % i == 0\n array << i\n end\n i+=1\n end\n if array.count == 0\n \"#{n} is prime\"\n else\n array\n end \nend", "def primes\n return [] if max_prime < 2\n\n candidates.each do |prime,_|\n # skip numbers we already know NOT to be prime (from previous iterations)\n next if candidates[prime] != :prime\n\n # find the prime number candidates greater than the current prime number\n candidates.select { |n,_| candidates[n].eql?(:prime) && n > prime }\n .each do |num,_|\n # mark numbers evenly divisible by the current prime as NOT PRIME\n @candidates[num] = :not_prime if (num % prime) == 0\n end\n end\n\n # convert numbers still marked as prime to an array of numbers\n candidates.map { |num,value| num if value.eql? :prime }.compact\n end", "def bc_get_prime_numbers(size)\n n = 1\n primes = []\n notprime = Hash.new\n\n until primes.size > size do\n\n n+=1\n\n # if I am known not prime, continue\n if notprime[n] then next end\n\n # check to see if I'm prime (abort instantly on finding divisor)\n (2..Math.sqrt(n)+1).each{|i| print \"Checking #{n} vs #{i}\\n\"; if n%i==0 then notprime[n]=1; print \"NOT A PRIME!\\n\"; next; end}\n\n # I'm prime, so add me to array + mark my multiples as being not\n # prime, but the fewer primes I need to get, the fewer multiples I\n # mark\n\n primes.push(n)\n (2..(size-primes.size())).each{|i| notprime[i*n] = 1}\n end\n primes\nend", "def primes_less_than(num)\n res = []\n (2...num).each do |i|\n res.push(i) if is_prime?(i) == true\n end\n res\nend", "def first_n_primes(n)\n\t return \"n must be an integer.\" unless n.is_a? Integer\n\t return \"n must be greater than 0.\" if (n<=0)\n\n prime_array||=[]\n\tprime = Prime.new\n\tn.times {prime_array << prime.next } \n\tprime_array\nend", "def prime_numbers(range)\n ar = range.to_a\n ar2 = [nil, nil] + [true] * ar.size\n\n i = 2\n while i <= Math.sqrt(ar.max).to_i\n if ar2[i]\n z = i * i\n while z <= ar.max\n ar2[z] = false\n z += i\n end\n end\n i += 1\n end\n ar.delete_if { |e| ar2[e] == nil || ar2[e] == false }\nend", "def prime_factors(num)\n arr = []\n\tPrime.each(num) { |prime| num % prime == 0 ? arr.push(prime) : false }\n return arr\nend", "def prime_factors(integer)\n primes = Prime.take(20)\n arr = []\n i = 0\n loop do \n if integer % primes[i] == 0\n integer = integer / primes[i]\n arr << primes[i]\n else\n i += 1\n end\n break if integer == 1\n end\n arr\nend", "def primes\n range = (min..max).to_a\n primes = (min..max).to_a\n\n range.each do |mod|\n primes.delete_if do |num| \n composite?(num, mod) unless num == mod\n end\n range = primes\n end\n primes\n end", "def first_n_primes(n)\n\n unless n.is_a? Integer\n return \"n must be an integer.\"\n end\n\n if n <= 0\n return \"n must be greater than 0.\"\n end\n \n prime_array = [] if prime_array.nil?\n \n prime = Prime.new\n for num in (1..n)\n prime_array.push(prime.next)\n end\n return prime_array\nend", "def prime_factors(num)\n array = []\n (1..num).each do |number|\n array << number if prime?(number) && num % number == 0\n end\n array.sort!\nend", "def create_array(startNum, untilNum)\n i = startNum\n while i <= untilNum\n if divisible_by?(i,3) or divisible_by?(i,5)\n @euler1_array << i\n end\n i+=1\n end\n end", "def first_n_primes(n)\n\n #unless n.is_a? Integer\n # return \"n must be an integer.\"\n #end\n return \"n must be an integer.\" unless n.is_a? Integer\n\n #if n <= 0\n # return \"n must be greater than 0.\"\n #end\n return \"n must be greater than 0.\" if n <= 0\n \n #prime_array = [] if prime_array.nil?\n prime_array ||= []\n \n prime = Prime.new\n #for num in (1..n)\n # prime_array.push(prime.next)\n #end\n # n.times { prime_array.push(prime.next) }\n n.times { prime_array << prime.next }\n \n #return prime_array\n prime_array # implicit return!\n\nend", "def specific_prime(n)\n\na = (2..n) # list of integers 2 through \nprimes = Array.new\n\nprimes = a.select { |x| (2..Math.sqrt(x)).none? { |d| (x % d).zero? }}\n\nputs primes[10000]\n# answer => 104,743\n\nend", "def first_n_primes(n)\n\n return \"n must be an integer.\" unless n.is_a? Integer\n return \"n must be greater than 0.\" if n <= 0\n \n prime_array ||= []\n \n prime = Prime.new\n n.times {\n prime_array << prime.next \n }\n prime_array\nend", "def first_n_primes(n)\n\n \"n must be an integer.\" unless n.is_a? Integer\n\n \"n must be greater than 0.\" if n <= 0\n \n prime_array ||= []\n \n prime = Prime.new\n n.times { prime_array << prime.next }\nend", "def prime_factors(num)\n #initialize an array\n primeFacts = []\n \n #iterate each number from 1 until num\n (1..num).each do |nums|\n #if the remainder is 0 and nums is prime push nums\n if num % nums == 0 && prime?(nums)\n primeFacts << nums\n end\n end\n return primeFacts\nend", "def collect_primes(number)\n \n sieve = [nil, nil] + (2 .. number).to_a\n \n (2 .. Math.sqrt(number)).each do |n|\n next unless sieve[n]\n (n*n).step(number, n) do |num|\n sieve[num] = nil\n end\n end\n \n primes = []\n sieve.each do |x|\n if x != nil\n primes << x\n end\n end\n return primes\nend", "def prime?(num)\r\n # your code goes here\r\n prime = []\r\n\r\n for i in 1 .. num\r\n if num % i == 0\r\n prime << i\r\n end\r\n end\r\n prime.length == 2\r\nend", "def pretentious_primes(arr, num)\nend", "def primes(max)\n yield \"See Primes below: \"\n parray= []\n Prime.each(max) do |p|\n parray << p\n end\n print parray\nend", "def count_prime(numbers)\n prime_array = []\n \n numbers.each do |num|\n if prime?(num)\n prime_array << num\n end\n end\n output = \"this array has #{numbers.length} numbers and #{prime_array.length} are prime: \" + prime_array.join(\", \")\n output\nend", "def primes_up_to(max)\n repository = (0..max).collect{true} #=> Create flag array\n limit = (max ** 0.5) #=> establish search limit\n\n for index in 2..limit #=> search through flag aray\n next if !repository[index]\n num = (index * 2)\n while num <= max #=> unflag multiples of primes\n repository[num] = false\n num += index\n end\n end\n\n # => convert numbers into arrays\n primes = repository.collect.with_index do |flag, value|\n value if flag\n end\n\n # return cleaned array\n primes.shift\n primes.shift\n primes.compact\nend", "def ruby_prime(n1, n2)\n prime_numbers = []\n (n1..n2).each do |num|\n if Prime.prime?(num)\n prime_numbers << num\n end\n end\n prime_numbers\nend", "def print_prime\n @n_primes = get_n_primes\n return [] if @n_primes == 0\n p_arr_len = @prime_numbers.length\n return @prime_numbers[0..@n_primes] if p_arr_len >= @n_primes\n (p_arr_len > 1) ? (n = @prime_numbers.last) : (n = 3)\n until @prime_numbers.length == @n_primes do\n @prime_numbers.push(n) if @prime_cache[n]\n (@prime_numbers.push(n) && @prime_cache[n] = true) if is_prime(n)\n n += 1\n end\n @prime_numbers\n end", "def get_primes(n)\n primes = [2]\n pp = 0\n i = 3\n while pp < n do\n if i%2 != 0\n counter = 0\n prime = 1\n while counter < primes.length do\n if (i%primes[counter] == 0)\n prime = 0\n break;\n end\n counter += 1\n end\n if prime == 1\n primes.push(i)\n pp +=1\n end\n end\n i+=1\n end\n return primes[n-1]\nend", "def primes (n)\r\n primes = Array.new(n) { |index| index+=1 }\r\n return primes.select { |x| factors(x).length == 2 }\r\nend", "def compute_primes\n nums = (@max_checked..@max_checked * 2).map { |x| x.odd? ? x : nil }.to_a\n 1.upto(@primes.index { |p| p * p > @max_checked * 2 }) do |i|\n start_idx = -@max_checked % @primes[i] # prime[i]'s 1st multiple's index\n\n (start_idx..nums.size).step(@primes[i]) { |x| nums[x] = nil }\n end\n @max_checked *= 2\n @primes += nums.compact\n end", "def squared_primes(array)\n array.find_all{|x| (2..x-1).select(){|i| x % i == 0}.count == 0 && x > 1}.map{|p| p*p}\n\n\n # primes = []\n # array.each do |x|\n # 2.upto(x-1) do |i|\n # if x % i == 0 && x > 2\n # primes << x*x\n # end\n # end\n # end\n # primes\n\n # primes= []\n # array.find_all do |x|\n # if x == 2\n # primes << 2*2\n # end\n\n # if x > 2 && (x % 2 != 0)\n # #(2..x-1).select()\n # # if x % 2 != 0 && x > 1\n # #{|i| x % i == 0}\n # #x.count == 0 && x > 1\n # primes << x * x\n # #end\n # end\n # end\n # # new_array.map{|p| p*p}\n # primes\nend", "def sieve_eratosthenes(len)\r\n\tprimes = [2]\r\n\tn = 2\r\n\r\n\t# Keep finding primes until requested length is reached\r\n\tuntil primes.length == len\r\n\t\t# Increase next number to test by one\r\n\t\tn += 1 \r\n\r\n\t\t# Test n against all numbers in prime array\r\n\t\t# If n is divisible by a prime, break and get next number to test\r\n\t\tis_prime = true\r\n\t\tprimes.each do |p|\r\n\t\t\tif n%p == 0\r\n\t\t\t\tis_prime = false \r\n\t\t\t\tbreak\r\n\t\t\tend\r\n\t\tend\r\n\t\t# If n is not divisible by previous primes, push to primes array\r\n\t\tprimes << n if is_prime\r\n\tend\r\n\tputs primes.last\r\nend", "def prime_numbers(num)\n all_factors = factors(num)\n only_prime = []\n i = 0\n while i < all_factors.length\n if prime?(all_factors[i])\n only_prime += all_factors[i]\n end\n i += 1\n end\n only_prime\n end", "def prime?(int)\r\n\r\n arr = [] # empty array to store results\r\n\r\n i = 4 # modulo of 4 for ints 1, 2 and 3 are never zero\r\n while i < int # iteration to check\r\n arr << i if int % i == 0\r\n i += 1\r\n end\r\n\r\n arr.length == 0 # result \"true/false\"\r\nend", "def prime_numbers\n # start with the first prime number\n primes = [2]\n # find the rest of the prime numbers\n (2..1000).each do |i|\n add_next_prime_number(primes)\n end\n return primes\nend", "def prime_numbers(array_input)\n prime_array = (2..(array_input)).to_a\n i = 0\n while (i < prime_array.length)\n prime_array.delete_if do |number|\n (number % prime_array[i] == 0) & (number != prime_array[i])\n end\n i += 1\n end\n prime_array\nend", "def pick_primes(numbers)\n\tprimes = []\n \tnumbers.each do |num| \n \tif isPrime(num) \n \tprimes.push(num)\n end\n end\n \treturn primes\nend", "def sieve(n)\n primes = nil\n\n OpenTracing.global_tracer.start_active_span(\"sieve\") do |scope|\n # don't really want the first two, but matching index to value makes it easier\n primes = [*0..n]\n primes[0] = nil\n primes[1] = nil\n\n for x in primes do\n next if x.nil? # already marked as composite, skip to the next one\n\n # find all the composites from this number and make them nil\n (2*x..n).step(x) do |c|\n primes[c] = nil\n end\n end\n\n # remove the nils from the array\n primes = primes.compact\n\n # tag the number of primes found\n scope.span.set_tag(\"primes.count\", primes.count)\n end\n\n primes\nend", "def primes\n Prime::EratosthenesGenerator.new.take_while {|i| i <= @base}\n end", "def prime_notation(n)\n prime_array = prime_factor_decomposition(n)\n largest_prime = prime_array.last\n result = []\n #@primes.each do |p|\n i = 0\n j = 0\n last_iteration = @primes.index(largest_prime)\n #amount_of_that_prime = 0\n #run through @primes and note 0 when primes[i] isn't in prime_array\n while i <= last_iteration\n amount_of_that_prime = 0\n if prime_array[j] == @primes[i]\n #prime found\n amount_of_that_prime += 1\n while prime_array[j + 1] == @primes[i]\n amount_of_that_prime += 1\n j += 1\n end\n result << amount_of_that_prime\n j += 1\n else\n #add a spot into the prime_notation to indicate that prime is absent\n result << 0\n end\n i += 1\n end\n return result\n end", "def coprime?(num_1, num_2)\n new_arr = []\n i = 1\n while i < num_1 && i < num_2\n if num_1 % i == 0 && num_2 % i == 0\n new_arr << i \n end\n i += 1\n end\n new_arr.length == 1\nend", "def prime_factors(num)\n all_factors = factors(num)\n output_arr = []\n\n all_factors.each do |el|\n if prime?(el)\n output_arr << el\n end\n end\n\n output_arr.sort\nend", "def mersenne_prime(n)\n arr = []\n k = 2\n i = 3\n until arr.length == n\n if is_prime?(i)\n arr << i\n k += 1\n i = (2 ** k).to_i - 1\n else\n k += 1\n i = (2 ** k).to_i - 1\n end\n end\n arr[-1]\nend", "def listOfPrimesUnderX (x)\n\n#Generate list of numbers 2 through x\n\nnumberList = []\nnumberList = (2..x).to_a\n\n# Create a loop that, first, removes the first number's multiples from numberList\n# and that loops up to the square root of x\n\nprimeList = []\n\n\nwhile numberList[0] < Math.sqrt(x)\n\n\tprimeList << numberList[0]\n\ty = numberList[0]\n\n\tnumberList.delete_if {|a| a % y == 0}\n\nend\n\n# now we have two arrays: primeList, which contains all primes up to the square root of x, and numberList\n# which contains primes between the square root of x and x\n# first we combine them to a single array, primeList, which contains all primes up to x\n\nprimeList = primeList + numberList\n\nreturn primeList\n\nend", "def GetPrimes (maximum)\n\t# Clear the input vector in case there is existing data\n\tprimes = []\n\t\n\t# There are no primes less than 2\n\tif (maximum < 2)\n\t\treturn\n\tend\n\t\n\t# Construct and execute the Sieve\n\tsqrtMaximum = Math.sqrt(maximum).to_i\n\tprimeTracker = Array.new(maximum,true)\n\t\n\tfor i in 2...sqrtMaximum\n\t\tif (!primeTracker[i])\n\t\t\tnext\n\t\tend\n\t\t\n\t\tfor j in ((i+i)...maximum).step(i)\n\t\t\tif (j < 0) # Guard against integer overflow\n\t\t\t\tbreak\n\t\t\tend\n\t\t\t\n\t\t\tprimeTracker[j] = false\n\t\tend\n\tend\n\t\n\treturn primeTracker\nend", "def prime_series\n t = self\n limit = Math.sqrt(t)\n a = (2..t).to_a\n n = 2\n while (n < limit) do\n x = n*2\n begin\n a[x-2]=2\n x+=n\n end until (x > t )\n begin\n n+=1\n end until ( a[n-2] != 2 )\n end\n a.uniq!\n end", "def eratosthenes(n)\r\n array = Array.new((n), true);\r\n index = 2\r\n primes_sum = 0\r\n\r\n until index >= n\r\n j = 0\r\n if array[index]\r\n ((index*2)..(n)).step(index+j) do |j|\r\n array[j] = false;\r\n end\r\n primes_sum += index\r\n end\r\n index += 1\r\n end\r\n primes_sum\r\nend", "def get_primes limit\n\tnums = (1...limit).select { |n| n.prime? }\n\n\tp nums\nend", "def prime_factorization(num)\n primes = [] \n i = 2 \n while num != 1\n while num % i == 0\n if is_prime?(i) \n num = num / i \n primes << i \n else\n i += 1 \n end \n end\n i += 1 \n end\n primes\nend", "def prime_factors(number, array=[])\n 2.upto(number) do |factor|\n if number % factor == 0\n array << factor\n number /= factor\n prime_factors(number, array)\n break\n end\n end\n array\nend", "def eratosthenes(n)\n a = Array.new(n)\n a.each_index do |i|\n a[i] = {i: i, prime: true}\n end\n (2..Math.sqrt(n)).each do |i|\n if a[i][:prime] == true\n j = i * i\n while j < n\n a[j][:prime] = false\n j += i\n end\n end\n end\n a.select {|h| h[:prime] == true}\nend", "def prime?(number)\n a = []\n n = (2...number).to_a\n if number == 1 || number == 0 || number.negative?\n false\n else\n n.collect {|x| a << number % x}\n if a.include?(0)\n false\n else\n true\n end\n end\n # (2...number).to_a.each {|x| (number/x).integer? ? false : true}\nend", "def prime_sieve(limit)\n \n limitn = limit+1\n primes = []\n \n # Fill in prime truth table\n for i in 0..limitn do\n primes[i] = true\n end\n \n primes[0] = false\n primes[1] = false\n \n primes.each_with_index{|prime,i|\n unless i < 2\n range = Range.new(i*i,limitn)\n range.step(i) {|index| primes[index] = false}\n end\n }\n \n true_primes = []\n primes.each_with_index{|value,i|\n true_primes << i if value == true\n }\n \n return true_primes\n \nend", "def prime_factors(number, array = [])\n return if number == 1\n 2.upto(number).each do |num|\n if number % num == 0\n number /= num\n array << num\n else\n end\n end\n prime_factors(number, array)\nend", "def largest_prime(num)\n\tresult = []\n\ti = 2\n\twhile i <= num\n\t\tif is_prime?(i)\n\t\t\tif num % i == 0 # Check for whole number if % by i \n\t\t\t\tnum = num / i # Update the num\n\t\t\t\tresult << i # Add i to the array\n\t\t\t\ti = 2 # Reset i to 2\t\n\t\t\tend\t\n\t\tend\n\t\ti += 1\t\n\tend\n\tresult\nend", "def find_primes\n canidates = (0..@max_num).to_a\n k=2\n while(k<= canidates.size/2)\n j=2\n while(j<= canidates.size/2)\n prod = k*j\n if prod <= @max_num\n canidates[prod] = nil\n end\n j+=1\n end\n k+=1\n end\n res = canidates.compact\n res.shift(2)\n res\n end", "def prime_factors(num)\n arr = (2..Math.sqrt(num).round).to_a\n primes = arr.each do |i|\n arr.select! {|j| j%i != 0 or j==i}\n end\n pfacts = primes.select {|i| num%i == 0}\n\n return [num] if pfacts.empty?\n return pfacts\nend", "def divisors(n)\n arr_of_divisors = (2...n).select { |divisor| n % divisor == 0 }\n arr_of_divisors == [] ? \"#{n} is prime\" : arr_of_divisors\nend", "def sieve(n)\n\tprimes = []\n\ta = Array.new(n, true)\n\t2.step(Math.sqrt(n).to_i) do |i|\n\t\tif a[i]\n\t\t\tprimes.push(i)\n\t\t\t\n\t\t\ti.step(n-1, i) do |k|\n\t\t\t\ta[k] = false\n\t\t\tend\n\t\tend\n\tend\n\n\tMath.sqrt(n).to_i.step(n-1) do |i|\n\t\tif a[i]\n\t\t\tprimes.push(i)\n\t\tend\n\tend\n\n\treturn primes\nend", "def mersenne_prime(n)\n prime = []\n\n i = 2\n while i < 20\n total = 2**i\n prime << total-1 if prime?(total-1)\n i += 1\n end\n prime[n-1]\nend", "def circular_primes_of (n)\n res = [n]\n tmp = origin = n.to_s\n (origin.length-1).times do |i|\n tmp.concat(tmp[0]); tmp[0] = ''\n if prime? tmp.to_i then res << tmp.to_i else return nil end\n end\n res\nend", "def prime_factors(num)\n facs = factors(num)\n p_facs = []\n facs.each{|n| p_facs.push(n) if prime?(n)}\n p_facs\nend", "def problem_77a\n primes = Primes.upto(100)\n\n # off is the offset in the prime array, we can work down :-)\n solve = lambda do |a,off,max|\n n = 0\n while a[off] < max && (a.length-off) >= 2 \n a[off] += a.pop\n n += 1 if (a & primes).length == a.uniq.length\n n += solve.call(a.dup,off+1,a[off]) if a.length - off > 1\n end\n n\n end\n m = 0\n (2..100).each do |num|\n break if (m = solve.call([1] * num,0,num-1)) > 5000\n puts \"#{num} => #{m}\"\n end\n m\nend", "def prime_factors(num)\r\n # your code goes here\r\n prime_factors = []\r\n for i in 1 .. num\r\n if num % i == 0 && prime?(i)\r\n prime_factors << i\r\n end\r\n end\r\n prime_factors\r\nend", "def mersenne_prime(n) #2\n m_prime = []\n num = 0\n until m_prime.length == n\n x_num = 2**num - 1 \n m_prime << x_num if prime?(x_num)\n num += 1\n end\n m_prime[-1]\nend" ]
[ "0.79540586", "0.7770899", "0.754233", "0.7466241", "0.7425772", "0.7425547", "0.736337", "0.73616844", "0.73515874", "0.73021734", "0.7285649", "0.7274986", "0.72748196", "0.7231341", "0.72228384", "0.72217613", "0.7218809", "0.7192315", "0.7143178", "0.7131588", "0.7122674", "0.71205777", "0.7113377", "0.7100032", "0.70940536", "0.70921063", "0.70668787", "0.70544934", "0.70393306", "0.7036458", "0.7031144", "0.69793975", "0.697111", "0.6939051", "0.6887322", "0.68856937", "0.68790555", "0.68790555", "0.68692917", "0.6865676", "0.68489134", "0.6830902", "0.68266875", "0.6821973", "0.6809927", "0.67706966", "0.67538095", "0.6738765", "0.6737606", "0.67356586", "0.67288256", "0.6706013", "0.6687285", "0.66647446", "0.6663699", "0.6647769", "0.66442275", "0.6631497", "0.66223645", "0.6612655", "0.65891504", "0.65884024", "0.65881056", "0.658475", "0.6583467", "0.6575073", "0.65457284", "0.6528224", "0.6527002", "0.65204734", "0.65183294", "0.65144455", "0.6500745", "0.6499157", "0.648447", "0.6473286", "0.6469933", "0.6466738", "0.64585364", "0.6453428", "0.64513075", "0.6450183", "0.64249146", "0.64208466", "0.64083046", "0.6389246", "0.63793457", "0.63790524", "0.6378801", "0.63786334", "0.63731194", "0.6359247", "0.63555455", "0.6350372", "0.634623", "0.63425857", "0.6336507", "0.6326797", "0.6323803", "0.63206834", "0.63193727" ]
0.0
-1
Shows the array of prime numbers as a string
def show_prime @prime_numbers.uniq.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_prime_notation(n)\n prime_notation = prime_notation(n)\n #puts prime_notation\n #print out the prime_notation array on one line\n print \"[\"\n (0...prime_notation.size - 1).each do |i|\n print \"#{prime_notation[i]}, \"\n end\n print \"#{prime_notation[prime_notation.size-1]}]\\n\"\n\n #on the next line print out the primes that they correspond to\n print \"[\"\n (0...prime_notation.size - 1).each do |i|\n print \"#{@primes[i]}, \"\n end\n print \"#{@primes[prime_notation.size-1]}]\\n\"\n end", "def count_prime(numbers)\n prime_array = []\n \n numbers.each do |num|\n if prime?(num)\n prime_array << num\n end\n end\n output = \"this array has #{numbers.length} numbers and #{prime_array.length} are prime: \" + prime_array.join(\", \")\n output\nend", "def print_prime_table\n out = ''\n prime_array = print_prime\n top_line = \"\\t#{prime_array.join(\"\\t\")}\"\n out += top_line + \"\\n\"\n for prime_row in prime_array\n line = \"\"\n line += \"#{prime_row}\\t\"\n for prime_col in prime_array\n line += \"#{prime_row * prime_col}\\t\"\n end\n out += line + \"\\n\"\n end\n out\n end", "def print_prime\n @n_primes = get_n_primes\n return [] if @n_primes == 0\n p_arr_len = @prime_numbers.length\n return @prime_numbers[0..@n_primes] if p_arr_len >= @n_primes\n (p_arr_len > 1) ? (n = @prime_numbers.last) : (n = 3)\n until @prime_numbers.length == @n_primes do\n @prime_numbers.push(n) if @prime_cache[n]\n (@prime_numbers.push(n) && @prime_cache[n] = true) if is_prime(n)\n n += 1\n end\n @prime_numbers\n end", "def showPrimeNumber(num)\nprint \"\\nPrime Numbers Upto #{num} Is:\\n\"\n for i in 2..num\n if isPrime(i) then\n print i,\" \"\n end\n end\nprint \"\\n\"\nend", "def main()\n num = Integer(ARGV[0])\n res = []\n Prime.each(num) {|prime| res << prime}\n puts res.join(\", \")\nend", "def print_prime_table(n_primes)\n out = ''\n prime_array = is_prime_new(n_primes)\n top_line = \"\\t#{prime_array.join(\"\\t\")}\"\n out += top_line + \"\\n\"\n for prime_row in prime_array\n line = \"\"\n line += \"#{prime_row}\\t\"\n for prime_col in prime_array\n line += \"#{prime_row * prime_col}\\t\"\n end\n out += line + \"\\n\"\n end\n out\nend", "def print_prime_multiples\n \ttabs = \"\\t\" * (no_of_primes/2 - 3) rescue \"\\t\"\n print \"\\n #{tabs} Multiplication Table for first #{no_of_primes} Prime numbers \\n\\n\"\n\n prime_array.length.times do |i|\n \t\tprint \" _ _ _\"\n \tend\n \tprint \"\\n\"\n\n \tprime_array.length.times do |i|\n \t\tif(i == 0)\n \t\t\tprint \"| \\t\"\n \t\telse\n \t\t\tprint \"| #{ordinal(i)} \\t\"\n \t\tend\n \tend\n \tprint \"|\\n\"\n \t\n \tprime_array.length.times do |i|\n \t\tprint \" _ _ _\"\n \tend\n \tprint \"\\n\"\n \t\n \toutput_array.each do |i|\n print \"\\n\"\n \t\ti.each do |j|\n \t\t\tprint \"| #{j} \\t\"\n \t\tend\n \t\tprint \"|\\n\"\n \t\ti.each do |j|\n \t\t\tprint \" _ _ _\"\n \t\tend\n \t\tprint \"\\n\"\n \tend\n \treturn\n end", "def divisors(n)\n arr_of_divisors = (2...n).select { |divisor| n % divisor == 0 }\n arr_of_divisors == [] ? \"#{n} is prime\" : arr_of_divisors\nend", "def emirps num\n\ti = 2\n\twhile i < num do\n\t\treverse_i = i.to_s.reverse.to_i\n\t\tif isPrime(i) && isPrime(reverse_i)\n\t\t\tprint i.to_s + \"\\n\"\n\t\tend\n\t\ti = i + 1\n\tend\n\nend", "def find_primes(start_num, end_num)\n (start_num..end_num).select { |num| prime?(num) }.join(', ')\nend", "def primeFactors(n)\r\n Prime.prime_division(n).map do |x|\r\n if x[1] > 1\r\n \"(#{x[0]}**#{x[1]})\"\r\n else\r\n \"(#{x[0]})\"\r\n end\r\n end.join\r\nend", "def print_all_primes(num)\n for i in (2..num)\n is_status = is_prime(i)\n if(is_status)\n puts i\n end\n end\nend", "def primes(max)\n yield \"See Primes below: \"\n parray= []\n Prime.each(max) do |p|\n parray << p\n end\n print parray\nend", "def prime_notation(n)\n prime_array = prime_factor_decomposition(n)\n largest_prime = prime_array.last\n result = []\n #@primes.each do |p|\n i = 0\n j = 0\n last_iteration = @primes.index(largest_prime)\n #amount_of_that_prime = 0\n #run through @primes and note 0 when primes[i] isn't in prime_array\n while i <= last_iteration\n amount_of_that_prime = 0\n if prime_array[j] == @primes[i]\n #prime found\n amount_of_that_prime += 1\n while prime_array[j + 1] == @primes[i]\n amount_of_that_prime += 1\n j += 1\n end\n result << amount_of_that_prime\n j += 1\n else\n #add a spot into the prime_notation to indicate that prime is absent\n result << 0\n end\n i += 1\n end\n return result\n end", "def find_primes(first, last)\n result = []\n (first..last).each { |num| result << num if prime?(num) }\n result.join(', ')\nend", "def printable_display(numbers)\n numbers.each { |i| puts i.join('') }\n end", "def output\n printable_display combined_array(numbers_array)\n end", "def print\n puts \"Multiplication Table of Prime Numbers\"\n table = Terminal::Table.new :title => \"#{(grid.length - 1).to_s} prime numbers\" do |t|\n \n # For each prime number, create a row\n for x in 0..(grid.length - 1) do\n\n # Start each row with the prime number\n row = [nil]\n \n for y in 0..(grid.length - 1) do\n row << grid[x][y]\n end\n \n # Add the row as well as a seperator for every row, except the last\n t << row\n t << :separator unless x == (grid.length)\n end\n \n end\n puts table\n end", "def divisors(n)\n i=2\n array=[]\n while i <= n/2\n if n % i == 0\n array << i\n end\n i+=1\n end\n if array.count == 0\n \"#{n} is prime\"\n else\n array\n end \nend", "def prime_numbers\n i = 2\n # p 2\n while (i < 101)\n # j = i\n if i.even? \n i == 2 ? (p i) : (print \"\")\n elsif (2..i/2).none?{ |x| i % x == 0}\n p i\n end\n i += 1\n end \nend", "def prime_chars(arr)\n num = arr.reduce(:+).size\n (2...num).select {|x| num%x == 0}.empty? ? true : false #test if number is a prime - check if list of divisors other than itself and 1 is empty \nend", "def render(num, array)\n puts\n puts \"Solution #{num+1}\"\n puts \" +---+ \"\n puts \" | #{array[0]} | \"\n puts \"+---+---+---+\"\n puts \"| #{array[1]} | #{array[2]} | #{array[3]} |\"\n puts \"+---+---+---+\"\n puts \"| #{array[4]} | #{array[5]} | #{array[6]} |\"\n puts \"+---+---+---+\"\n puts \" | #{array[7]} | \"\n puts \" +---+ \"\nend", "def pretentious_primes(arr, num)\nend", "def prime_chars?(array)\n string = array.join(\"\")\n number = string.length\n if number < 2\n return false\n else\n is_prime = true\n (2..Math.sqrt(number)).each do |n|\n if number % n == 0\n is_prime = false\n end\n end\n return is_prime\n end\nend", "def print\n number_array.map { |element| @input_hash[element] }.join(' ')\n\n ## DO NOT LIKE(but works)\n # number_array.each_index.inject(\"\") do |return_string, n|\n # return_string += @input_hash[number_array[n]]\n # return_string += \" \" unless (number_array.size-1) == n\n # \n # # need b/c \"unless\" clause returns nil when done\n # return_string \n # end\n\n end", "def stringy(num)\n zero_array = []\n one_array = []\n\n (num / 2).times do\n zero_array << 0\n one_array << 1\n end\n\n if num.odd?\n one_array << 1\n end\n\n one_array.zip(zero_array).flatten.join(\"\")\nend", "def prn\n puts \" #{(0..8).to_a.join(\" \")}\"\n puts \" #{'-' * (2 * 9)}\"\n g.each_with_index do |v, i|\n # ERROR: print function doesn't display values and doesn't use colors\n # puts \"#{i} #{v.join(\" \")}\"\n puts \"#{i} | #{v.map{|t| t.n.to_s.colorize(t.c) }.join(' ')}\"\n end\n end", "def to_s\n # find the largest number of digits in the numbers we\n # are printing\n digits = max_digits @size**2\n\n # create the row divider. flexible based on size of numbers\n # and the square.\n divider = \"+\"+(\"-\"*(@size*(3+digits)-1))+\"+\\n\"\n\n # build each row by formatting the numbers to the max\n # digits needed and adding pipe dividers\n (0...@size).inject(divider) do |output,i|\n output + \"| \" +\n @square[i].map{|x| \"%#{digits}d\" % x}.join(\" | \") +\n \" |\\n\" + divider\n end\n end", "def prime_word(arr)\n arr.map {|nm,n| nm.chars.map {|c| c.ord + n}.any?(&:prime?) ? 1 : 0}\nend", "def prime_set(n)\n\t\tprimes_arr =[]\n\t\ti = 1\n\t\t# keep inserting prime numbers into array until its length is equal to 'n'\n\t\tuntil primes_arr.count == n\n\t\t\tif is_prime(i) == true \n\t\t\t\tprimes_arr << i \n\t\t\tend \n\t\t\ti+=1\n\t\tend \n\t\tp primes_arr\n\tend", "def divisors(num)\n divisors_results = [] \n 2.upto(num - 1) do |n|\n divisors_results << n if num % n == 0\n end\n return \"#{num} is prime\" if divisors_results.empty?\n divisors_results\nend", "def divisors(n)\n div = Array.new\n curr = n - 1\n while curr > 1\n div.unshift(curr) if n % curr == 0\n curr -= 1\n end\n div.empty? ? \"#{n} is prime\" : div\nend", "def output(primes)\n #primes = compute_primes(n)\n prod = {}\n\n #calculate highest number of spaces for padding\n spaces = (primes[-1] * primes[-1]).to_s.length + 4\n padding = \"\"\n (0..spaces).map {padding += \" \"}\n\n #print header row\n puts \"\"\n puts \"Multiplication table for first N prime numbers\"\n puts \"\"\n print padding + \" \"\n primes.each do |row|\n print_data(row, padding)\n end\n puts \"\"\n primes.each do |row|\n (0..spaces+2).map { print \"=\"}\n end\n puts \"\"\n\n #print columns and rows of products\n primes.each do |row|\n print_data(row.to_s + \" | \", padding)\n\n primes.each do |col|\n\n #if we already have a product for this couple, use it otherwise multiply\n if prod[[col,row]]\n prod[[row,col]] = prod[[col,row]]\n else\n prod[[row,col]] = row * col\n end\n\n print_data(prod[[row,col]], padding)\n end\n\n puts \"\"\n end\n\n puts \"\"\n end", "def prime_chars?(array)\n\tmy_string = \"\"\n\tarray.each {|str| my_string << str}\n\tif my_string.size < 2 then return false\n\telse\n\t\tfor i in 2..(my_string.size/2)\n\t\t\tif my_string.size % i == 0 && my_string.size != i\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\t\treturn true\n\tend\nend", "def pandigital_prime\n pandigitals = []\n [4,3,2,1].permutation{|p| pandigitals << p.join.to_i}\n [7,6,5,4,3,2,1].permutation{|p| pandigitals << p.join.to_i}\n pandigitals.sort!.reverse!\n\n pandigitals.each{|number| return number if is_prime?(number)}\nend", "def get_primes num\n primes = []\n for i in 0 ... num do\n if check_prime?(i) == true\n primes.push(i)\n end\n end\n p primes\nend", "def PrimeChecker(num)\n num = num.to_s.split('')\n perm = num.permutation(num.size).to_a\n perm.each do |p|\n return 1 if is_prime?(p.join.to_i) \n end\n return 0\nend", "def prime_num_gen( array_size )\n\n # array_size == array.length\n\n array = []\n\n divisors = []\n\n i = 0\n while( array_size != array.length )\n\n # p i\n\n if( i >= 2 ) # 0 and 1 are not prime\n\n if( i == 2 ) # two is a prime\n # p \" 2 is pushed\"\n array.push(i)\n end\n\n if( i % 2 != 0 ) # prime numbers cannot be even\n\n # p \" i #{i}\"\n # p \" divisors #{divisors}\"\n\n # START extra check - if i has more than 2 divisors\n #\n # IMPROVEMENT!!!!\n #\n # Could have simply called is_prime?( i ) --> returns true if prime\n # if is_prime? ? array.push(i) : p \"do nothing\"\n #\n j = 1\n while( i >= j )\n\n #p \" j #{j}\"\n\n if( i % j == 0)\n\n divisors.push(j)\n # p \" divisors #{divisors}\"\n end #if\n\n j += 1\n end # while\n\n if( divisors.length == 2 ) # prime should have 1 and itself as divisors\n array.push(i)\n # p \"#{i} is pushed\"\n end\n\n divisors.clear\n # p divisors\n\n # END of extra check\n #\n # extra check - if i has more than 2 divisors\n\n end # if (prime numbers cannot be even)\n\n end # if outter most\n\n i += 1\n end # while\n\n p array\n return array\n\nend", "def primes\n arr=Array.new\n arr[1]=false\n (2..1000).each {|i| arr[i]=true}\n (2..1000).each {|i| (i/2).floor\n (2..1000).each {|j| (j/i).floor\n arr[i*j] = false\n }}\n for i in 1..1000\n if arr[i] == true\n puts i\n end\n end\nend", "def primes(num)\n\twhole_array = (2..num).to_a\n\tprime_array = [whole_array.shift]\n\n\tuntil whole_array == []\n\t\twhole_array.delete_if { |x| x % prime_array.last == 0 }\n\t\tprime_array << whole_array.shift\n\tend\n\tprime_array\nend", "def prime_chars?(strings_array)\n sum = 0\n new_array = []\n strings_array.join.split(\"\").each {|x| sum += 1}\n if sum != 1 && (strings_array != [\"\"] && strings_array != [])\n \t(2..sum/2).map {|a| new_array << sum % a }\n !(new_array.include? 0) \n else\n \tfalse\n end\nend", "def primes_less_than (num)\n arr=[]\n for n in 2..(num-1)\n if is_prime?(n)\n arr.push(n)\n end\n end\n p arr\n return arr\nend", "def pretentious_primes(arr, num)\n new_arr = []\n if num > 0\n arr.each do |ele|\n i = ele + 1\n count = 0\n while true\n if is_prime?(i)\n count += 1\n end\n if count == num\n new_arr << i\n break\n end\n i += 1\n end\n end\n else\n num = -1 * num\n end\n new_arr\nend", "def to_s\n variable = 0\n @values.each do |k, v|\n if variable % 9 == 0\n puts \"|\"\n\n puts \".\" * 37\n\n end\n print \"| #{v} \"\n variable += 1\n end\n \"|\"\n end", "def print_prime_multiplication_table(number_of_primes)\n multiplication_table = prime_multiplication_table(number_of_primes)\n pretty_print(multiplication_table)\n end", "def pe50v2()\n\ta = sieveOfErathosthenes(3990)\n\tprim,total,count = [], 0, 0\n\ta.each_with_index do |x, index|\n\t\tif x \n\t\t\ttotal += index\n\t\t\tcount += 1 \n\t\t\tprim.push([total,count])\n\t\tend\n\tend\n\t#p prim\n\tmax = 0\n\tthePrime = 0\n\tseq = prim.map {|k| k }.permutation(2).to_a.each {|x| x.flatten!}\n\tseq.each do |a, b, c , d| \n\t\t#printf \"%d %d %d %d\\n\", a, b, c, d\n\t\te = a - c\n\t\tif(Prime.prime?(e)) then\n\t\t\tif(max < b - d) then\n\t\t\t\tmax = b - d\n\t\t\t\tthePrime = e\n\t\t\t\tprintf \"prime %d with max %d\\n\",e,max\n\t\t\tend\n\t\tend\n\tend\n\tprintf \"the prime is %d with a seqence of %d\\n\",thePrime, max\nend", "def prime_chars?(strings)\n puts strings.join.length.is_prime?\n\nend", "def isPrime(number)\n\t\tdivisores=[]\n\t\t1.upto(number){|num| \n\t\t\tif (number % num == 0 )\n\t\t\t\tdivisores.push num\n\t\t\tend\t\t\n\t\t}\n\t\treturn divisores\n\tend", "def prime?(num)\r\n # your code goes here\r\n prime = []\r\n\r\n for i in 1 .. num\r\n if num % i == 0\r\n prime << i\r\n end\r\n end\r\n prime.length == 2\r\nend", "def prime_chars?(arr)\n num = arr.join.chars.count\n return false if num <= 1\n (2..Math.sqrt(num)).each { |i| return false if num % i == 0 }\n true\nend", "def print_multi_table(separator = ' ')\n primes = find_primes\n header = primes.collect{|prim| format_num(prim)}.join separator\n puts separator * (1+ @num_len) + header\n primes.each{|prime_side,row|\n row= primes.collect{|prime_top,col|\n format_num(prime_top*prime_side)\n }.join(separator)\n puts \"#{format_num(prime_side)} #{row}\"\n }\n end", "def prime (n)\n\n\t#create an Array\n\tprime_num = []\n\n\tfor num in (2..n)\n\t\tis_prime = factors(num)\n\t\tif (is_prime.length ==2)\n\t\t\tprime_num.push(num)\n\t\tend\n\tend\n\treturn prime_num\nend", "def anti_prime?(num)\n max = 0\n sum_i_array = []\n (1..num).each do |n|\n sum_i = 0\n (1..n).each { |i| sum_i += 1 if n % i == 0 }\n sum_i_array << sum_i\n end\n sum_i_array[-1] == sum_i_array.max\nend", "def stringy(number)\n arr = []\n (1..number).each { |num| arr << num }\n\n string = \"\"\n arr.each do |num|\n string << \"0\" if num % 2 == 0\n string << \"1\" if num % 2 == 1\n end\n\n string\nend", "def inspect\n return if @arr.empty?\n w = @arr.compact.collect { |row| row.size }.max\n result = \"\\n \" \n w.times do |y|\n result += '%3d'%y\n end\n result += \"\\n\"\n @arr.each_index do |x|\n result += '%3d:'%x\n if @arr[x]\n @arr[x].each do |val|\n result += val.nil? ? ' ' : '%3d'%val\n end\n end\n result += \"\\n\"\n end\n result\n end", "def primo_factor(number)\t\n\n\tresult =[]\n\n\twhile number != 1\n\t\tfor i in 2..10000\n\t\t\tif number % i == 0 && number > 1\n\t\t\t\tresult << i\n\t\t\t\tnumber = number/i\t\t\t\n\t\n\t \t\tend\n\t\tend\n\tend\n\tputs \"The largest prime factor of #{number} is #{result.inspect}. Congrats!\"\n\nend", "def prime2(nprime)\n\n primes = [2]\n factors = {}\n\n num = 3\n while primes.size < nprime do\n\n root = Math.sqrt(num).floor\n isprime = true\n\n primes.each{ |prime|\n break if prime > root\n if num % prime == 0\n isprime = false\n break\n end\n }\n\n primes << num if isprime\n num += 1\n\n printf(\"\\r%d\", primes.size) if primes.size % 1000.0 == 0\n\n end\n\n return primes\n\nend", "def printMultiplicationTable(numArray)\n puts \"\\nPrime numbers multiplication table\"\n \n # Printing beautified first row with initial margin\n firstRow = \" \"\n numArray.each do |i|\n firstRow += alignTabularValue(i.to_s) + \" | \"\n end\n \n puts firstRow\n \n numArray.each do |i|\n printString = alignTabularValue(i.to_s) + ' | '\n numArray.each do |ii|\n result = (i * ii).to_s\n \n printString += alignTabularValue(result) + ' | '\n end\n puts printString\n end\n \n puts \"\\n\"\n end", "def prime_chars? (arr)\n amount = arr.join.length.to_f\n return false if amount < 2\n 2.upto Math.sqrt(amount) do |i|\n return false if amount % i == 0\n end\n return true\nend", "def prime_checker(num)\n digits = num.to_s.chars\n permutations = digits.permutation(digits.size).map { |n| n.join.to_i }.uniq\n # permutations.reject! { |num| num.to_s.size < digits.size }\n permutations.each do |permutation|\n return 1 if prime?(permutation)\n end\n 0\nend", "def fizzbuzz(num1, num2)\n arr = Array(num1..num2).map! do |num|\n if num % 3 == 0 && num % 5 == 0\n 'FizzBuzz'\n elsif num % 3 == 0\n 'Fizz'\n elsif num % 5 == 0\n 'Buzz'\n else\n num\n end\n end.join(', ')\n print arr\nend", "def primeArray(number)\n @sieve = Array.new(number)\n \n for count in 2..Math.sqrt(number)\n next if @sieve[count]\n \n for inner_count in 2..number/count\n @sieve[count * inner_count] = true\n end\n end\n @sieve\nend", "def prime_chars(arr)\n x = 0\n arr.map! {|y| y.length}\n arr.each { |i| x+=i }\n return x\n if x.downto(2).each {|z| return false if x % z == 0}\n true\n end\nend", "def Fizz2\r\n\t\t(1..100).each do |x|\r\n\t\t\tstr = [(\"Fizz\" if x % 3 == 0),(\"Buzz\" if x % 5 == 0)].compact.join\r\n\t\t\tif str == \"\" then str << x.to_s end\r\n\t\t\tputs str\t\t\r\n\t\tend\r\n\tend", "def prime?(number)\n a = []\n n = (2...number).to_a\n if number == 1 || number == 0 || number.negative?\n false\n else\n n.collect {|x| a << number % x}\n if a.include?(0)\n false\n else\n true\n end\n end\n # (2...number).to_a.each {|x| (number/x).integer? ? false : true}\nend", "def prime_numbers\n s = (0..self).to_a\n s[0] = s[1] = nil\n s.each do |p|\n next unless p\n break if p * p > self\n (p*p).step(self, p) { |m| s[m] = nil }\n end\n s.compact\n end", "def pretentious_primes(arr, n)\n arr.map { |num| replace_with_prime(num, n) }\nend", "def prime(number)\n prime_numbers = []\n (2..number).each do |current_number|\n if is_prime? current_number\n prime_numbers << current_number\n end\n end\n return prime_numbers\nend", "def super_fizzbuzz(array)\n array.map! do |num|\n num =\n \t\tif (num % 3 == 0 && num % 5 == 0)\n \t \"FizzBuzz\"\n \t\telsif (num % 3 == 0)\n \t\"Fizz\"\n \telsif (num % 5 == 0)\n \t\"Buzz\"\n \telse \n \tnum\n \tend\n \tend\n p array\nend", "def prime_number(n)\n prime_array = []\n count = 1\n until prime_array.length == n\n if count == 1\n prime_array << 2\n count += 2\n elsif is_prime?(count) == true\n prime_array << count\n count += 2\n else\n count += 2\n end\n end\n prime_array.last\nend", "def primes(max)\n array = []\n i = 2\n while i < max.abs\n if is_prime?(i)\n array << i\n end\n i += 1\n end\n array\nend", "def prime_numbers(num)\n all_factors = factors(num)\n only_prime = []\n i = 0\n while i < all_factors.length\n if prime?(all_factors[i])\n only_prime += all_factors[i]\n end\n i += 1\n end\n only_prime\n end", "def print_primes(num)\r\n\tlargest_div = 2;\t\t\t\r\n\twhile num > 1\r\n\t\tdiv = 2;\r\n\t\twhile num % div != 0\r\n\t\t\t\tdiv += 1\r\n\t\tend\r\n\t\tnum = num / div\r\n\t\tlargest_div = div\r\n\tend\r\n\treturn largest_div\r\nend", "def primes (number)\n primes_array = []\n Prime.each(number) do |p|\n primes_array.push(p)\n end\n\n primes_array\nend", "def to_s\n\t\t@tam_alto.times do |i|\n\t\t\t@tam_ancho.times do |j|\n\t\t\t\tprint @plano[i][j].to_s + \" \"\n\t\t\tend\n\t\t\tprint \"\\n\"\n\t\tend\n\tend", "def print_numbers(array)\n puts array.join \", \"\nend", "def primos3(array3)\n array3.each do |x|\n if es_numero_primo?(x)\n puts \"El numero #{x} es primo\"\n end\n end\nend", "def find_primes(number)\n\tprimes = []\n\ttry_num = 2\n\tx = 2\n\tfactors = []\n\t\n\twhile primes.length != number\n\t\t#puts \"primes : #{primes}\"\n\t\t#puts \"try_num : #{try_num}\"\n\t\t#puts \"x : #{x}\"\n\t\t#puts \"factors : #{factors}\"\n\t\t\n\t\tif factors.length >= 1 && factors[0] != try_num\n\t\t\t#puts \"#{try_num} is not prime\"\n\t\t\ttry_num += 1\n\t\t\tx = 2\n\t\t\tfactors = []\n\t\t \n\t\telsif try_num % x == 0 && x == try_num\n\t\t\t#puts \"#{try_num} is prime\"\n\t\t\tprimes << try_num\n\t\t\ttry_num += 1\n\t\t\tx = 1\n\t\t\n\t\telsif try_num % x == 0\n\t\t\t#puts \"#{x} is factor of #{try_num}\"\n\t\t\tfactors << x\n\t\telse\n\t\t\n\t\tend\n\t\t\n\t\tx += 1\n\tend\n\tputs primes\n\treturn primes\nend", "def prime?(int)\r\n\r\n arr = [] # empty array to store results\r\n\r\n i = 4 # modulo of 4 for ints 1, 2 and 3 are never zero\r\n while i < int # iteration to check\r\n arr << i if int % i == 0\r\n i += 1\r\n end\r\n\r\n arr.length == 0 # result \"true/false\"\r\nend", "def divisors(n)\nif (2..Math.sqrt(n)).none? {|f| n % f == 0}\n\"#{n} is prime\"\nelse\narray = (1..n).select { |x|n % x == 0}\narray - [n] - [1]\nend\nend", "def primes(n)\n result = []\n i = 2\n while i <= n\n j=2\n prime = true\n while j<=i**0.5\n (prime = false) if i%j==0\n j += 1\n end\n (result << i) if prime\n i +=1\n end\n return result\nend", "def super_fizzbuzz(array)\n\tarray.map! do |num|\n\t\tif num % 15 == 0\n\t\t\tnum = 'FizzBuzz'\n\t\telsif num % 5 == 0\n\t\t\tnum = 'Buzz'\n\t\telsif num % 3 == 0\n\t\t\tnum = 'Fizz'\n\t\telse num\n\t\tend\n\tend\n\tp array\nend", "def show(arr, desc)\n printf \"%20s:\", desc;\n arr.each { |v| printf \" %d\", v }\n printf \"\\n\";\nend", "def primes(num)\n \nend", "def primes(num)\n \nend", "def primes(num)\n \nend", "def primes(num)\n \nend", "def squared_primes(array)\n array.find_all{|x| (2..x-1).select(){|i| x % i == 0}.count == 0 && x > 1}.map{|p| p*p}\n\n\n # primes = []\n # array.each do |x|\n # 2.upto(x-1) do |i|\n # if x % i == 0 && x > 2\n # primes << x*x\n # end\n # end\n # end\n # primes\n\n # primes= []\n # array.find_all do |x|\n # if x == 2\n # primes << 2*2\n # end\n\n # if x > 2 && (x % 2 != 0)\n # #(2..x-1).select()\n # # if x % 2 != 0 && x > 1\n # #{|i| x % i == 0}\n # #x.count == 0 && x > 1\n # primes << x * x\n # #end\n # end\n # end\n # # new_array.map{|p| p*p}\n # primes\nend", "def p10\n\tprimes = []\n\tPrime.each do |prime|\n\t\tbreak if prime >= 2000000\n\t\tprimes << prime\n\tend\n\t# puts primes\n\tprimes.reduce(:+)\nend", "def prime_chars?(x)\n require \"prime\"\n if x ==[]\n return false\n else\n Prime.prime?(x.map { |i| i.length }.inject(:+))\n end\nend", "def fizzbuzz(num1, num2)\n array = []\n (num1..num2).each do |num|\n if num % 3 == 0 && num % 5 == 0\n array << \"FizzBuzz\"\n elsif num % 3 == 0\n array << \"Fizz\"\n elsif num % 5 == 0\n array << \"Buzz\"\n else\n array << num\n end\n end\n puts array.join(\", \")\nend", "def to_s\n array.map { |x| x.map { |y| y.zero? ? ' ' : '█' }.join }.join(\"\\n\")\n end", "def find_primes(quantity)\n primes = []\n x = 2\n while primes.count < quantity\n prime?(x)\n binding.pry\n if prime == true\n primes << x\n end\n x += 1\n end\n \"the first #{quantity} prime numbers are #{primes}\"\nend", "def prime?(integer)\n result = \"\"\n case\n when integer <= 1\n result = false\n else\n prime_check = (2..integer).to_a\n prime_check.each do |x|\n prime_check.delete_if { |y| ( x != y && y % x == 0 ) }\n end\n result = prime_check.include?(integer)\n end\n result\nend", "def to_s\n returned_str = \"\"\n @puzzle.each_with_index do |entry, i|\n returned_str += \"\\n\" if (i%9)==0\n returned_str += entry.to_s + \" \"\n end\n returned_str \n end", "def get_primes limit\n\tnums = (1...limit).select { |n| n.prime? }\n\n\tp nums\nend", "def print_table(n)\n prime_number = PrimeNumber.new(@path)\n prime_and_flag = prime_number.get_prime_numbers(n)\n table = Table.new(prime_and_flag[0])\n puts table.make_products_table\n if prime_and_flag[1]\n diff = prime_and_flag[2]\n File.open(File.expand_path(@path), \"a\") do |f|\n f.puts(prime_and_flag[0][diff..-1])\n end\n end\n end", "def getPrimeSeq(seq, length)\n if seq.length >= length\n return seq[0,length]\n else\n return seq + \"X\"*(length - seq.length)\n end\n end", "def super_fizzbuzz(array)\n array.map! {|num| puts \"#{'Fizz' if num % 3 == 0}#{'Buzz' if num % 5 == 0}#{num if num % 5 != 0 && num % 3 != 0}\"}\nend" ]
[ "0.7420053", "0.7110243", "0.6985472", "0.69466054", "0.69260967", "0.68931305", "0.6855024", "0.65815675", "0.6474151", "0.6442655", "0.64392066", "0.6290671", "0.62807584", "0.62599164", "0.6188199", "0.6181722", "0.6179354", "0.61237085", "0.6063521", "0.60254395", "0.6012145", "0.59839445", "0.59705144", "0.5969651", "0.5950108", "0.5925325", "0.5901728", "0.59004766", "0.58803785", "0.5875763", "0.5870729", "0.5864735", "0.5855303", "0.58324736", "0.58152384", "0.58101547", "0.5795309", "0.5794114", "0.5793295", "0.5781185", "0.5770722", "0.57704765", "0.57673573", "0.57672286", "0.5754696", "0.5709844", "0.5696938", "0.56965446", "0.5696328", "0.56961757", "0.56795853", "0.56733423", "0.5659386", "0.565833", "0.56558836", "0.56546587", "0.5649761", "0.56433094", "0.5636228", "0.56361556", "0.5605868", "0.56027865", "0.5598214", "0.5597409", "0.5595556", "0.5584375", "0.55766", "0.557126", "0.5565308", "0.5562157", "0.55588067", "0.55518776", "0.5550428", "0.55483156", "0.5543294", "0.55392045", "0.55346453", "0.55249166", "0.55203927", "0.5518614", "0.55106056", "0.5501378", "0.54993415", "0.5497346", "0.54966813", "0.54966813", "0.54966813", "0.54966813", "0.54882115", "0.548341", "0.54711425", "0.5469715", "0.54618305", "0.5459536", "0.5453079", "0.5451305", "0.5450729", "0.5445911", "0.5440465", "0.54382515" ]
0.7736279
0
Determines if the provided number is prime
def prime?(number) (2...number).each do |x| return false if (number % x).zero? end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_prime?(number)\n if number < 1\n return false\n end\n divisor = 2\n while number % divisor != 0\n divisor += 1\n if number == divisor\n return true \n end\n end\n return false\n end", "def prime?(number)\n\tx = Math.sqrt(number).ceil\n\tfor num in 2..x\n\t\tif number % num == 0\n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\nend", "def is_prime?(number)\n remainders = (2...number).map { |d| number % d}\n !remainders.include?(0) && number > 1\nend", "def prime?( number )\n self.class.prime? number\n end", "def is_prime(number)\n return false if number < 3 || number.even?\n\n square = Math.sqrt(number).to_i\n\n !(3..square).any? { |x| number % x == 0 }\nend", "def is_prime?(number)\n\tint = 2\n\t\n\twhile int <= (number ** 0.5) + 1\n\t\treturn false if number % int == 0 && int != number\n\t\tint += 1\n\tend\n\treturn true\nend", "def is_prime?(num)\n ('1' * num) !~ /^1?$|^(11+?)\\1+$/\n end", "def prime? num\n return false if num < 2\n (2..Math.sqrt(num)).none? {|n| num % n == 0 }\n end", "def prime?(number)\n if number > 1 \n number_range = (2..number-1).to_a\n number_range.detect{ |test_number| number % test_number == 0} ? false : true\n else\n false\n end\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)\n end", "def is_prime_number(num)\n (2...num).all? {|n| num % n != 0}# has factors\nend", "def prime?(number)\n if number == 0 or number == 1\n return false\n end\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 prime?(integer)\n return false if integer < 2 || (integer.even? && integer != 2)\n\n n = Math.sqrt(integer).floor\n (2..n).none? { |x| (integer % x).zero? }\nend", "def prime?(num)\n Math.sqrt(num).to_i.downto(2).each { |i| return false if (num % i).zero? }\n true\nend", "def prime?(num)\n\t(2..Math.sqrt(num)).each do |x|\n\t\tif num % x == 0\n\t\t\treturn false\n\t\tend\n\tend\n\ttrue\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?(number)\n (2...number).each do |factor|\n if number % factor == 0\n return false\n end\n end\n return true\nend", "def is_prime?(number)\n number = number.abs\n return false if number < 2\n return true if number < 4\n\n factor = 2\n while factor * factor <= number\n return false if number % factor == 0\n factor += 1\n end\n\n true\nend", "def is_prime?(number)\n number = number.abs\n return false if number < 2\n return true if number < 4\n\n factor = 2\n while factor * factor <= number\n return false if number % factor == 0\n factor += 1\n end\n\n true\nend", "def is_prime?(number)\n number = number.abs\n return false if number < 2\n return true if number < 4\n\n factor = 2\n while factor * factor <= number\n return false if number % factor == 0\n factor += 1\n end\n\n true\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 isPrime(num)\n return false if num < 2\n\n sqrt_num = Math.sqrt(num).floor\n 2.upto(sqrt_num){|i|\n if num % i == 0\n return false # 割り切れたら素数でない\n end\n }\n return true\nend", "def is_prime?(number)\n if number <= 1\n # only numbers > 1 can be prime.\n return false\n end\n\n idx = 2\n while idx < number\n if (number % idx) == 0\n return false\n end\n\n idx += 1\n end\n\n return true\nend", "def is_prime?(number)\n if number <= 1\n # only numbers > 1 can be prime.\n return false\n end\n\n idx = 2\n while idx < number\n if (number % idx) == 0\n return false\n end\n\n idx += 1\n end\n\n return true\nend", "def isPrime? num\n\t_limit = Math.sqrt(num).floor\n\t_i = 3\n\n\twhile _i <= _limit\n\t\treturn false unless num % _i != 0\n\n\t\t_i += 2\n\tend\n\n\treturn true\nend", "def is_prime?(number)\n divided_by = number - 1\n while divided_by > 1\n if number % divided_by == 0\n return false\n end\n divided_by -= 1\n end\n return 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 prime?(num)\n\t(2..Math.sqrt(num)).each do |x|\n\t\tif num % x == 0\n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\nend", "def is_prime?(num)\n\t(2..Math.sqrt(num)).each do |target|\n\t\treturn false if num % target == 0\n\tend\n\treturn true\nend", "def is_prime?(number)\n for i in 2..(number-1)\n if (number % i) == 0\n return false\n break\n end\n end\n true\nend", "def is_prime number\n\ti = 1\n\tnot_prime = 0\n\tloop do\n\t\tbreak if i == number / 2\n\t\tif number % i == 0\n\t\t\tnot_prime = 1\n\t\tend\n\t\tbreak if not_prime == 1\n\t\ti = i + 1\n\tend\n\tnot_prime\nend", "def prime?(number)\n if number >= 2\n (2..number - 1).all? do |x|\n number % x != 0\n end\n else\n return false\n end\nend", "def is_prime?(num)\n\t\t return false if num <= 1\n\t\t maxfactor = Math.sqrt(num).to_i\n\t\t (2..maxfactor).each {|i| return false if num % i == 0}\n\t\t true\n\t\tend", "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?(num)\n\tfor i in 2..Math.sqrt(num)\n\t\tif num % i == 0\n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\nend", "def is_prime?(num)\n\tfor i in 2..Math.sqrt(num)\n\t\tif num % i == 0\n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\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 prime?(num)\n\t(2 .. Math.sqrt(num)).each {|i| return false if num % i == 0}\n\treturn true\nend", "def prime?(num)\n\treturn false if num < 2\n\t\n\t(2...num).each do |i|\n\t\treturn false if num % i == 0\n\tend\n\ttrue\nend", "def prime?(integer)\n\ttrial_divisions = (2..1000000).to_a #turns string into array\n\ttest = trial_divisions.detect {|i| (integer % i) == 0 } #checks for first trial_division that evenly divides integer\n\ttest == integer ? true:false #if integer is only divisible by itself (1 isn't included in trial_divisions) then it is prime\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 prime?(int)\n return false if int <= 1\n (2..Math.sqrt(int)).none? { |i| (int % i).zero? }\nend", "def prime?(number)\n (2..(number-1)).each do |possible_factor|\n return false if number % possible_factor == 0\n end\n true\nend", "def isPrime(num)\n\tif num % 2 == 0\n\t\treturn false\n\tend\n\tmax = Math.sqrt(num)\n\tfor i in 3..max \n\t\tif num % i == 0\n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\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 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 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 isPrime?(num)\n\treturn false if num <= 1\n\n\ti = 2\n\twhile i < num\n\t\treturn false if num % i == 0\n\t\ti += 1\n\tend\n\treturn true\nend", "def is_prime?(number)\n i = number - 1\n until i < 2\n if number % i == 0\n return false\n end\n i -= 1\n end\n return true\nend", "def is_prime?(num)\n\tif num > 1\n\t\tmaxn = num**(0.5)\n\t\ti = 2\n\t\twhile i <= maxn\n \t\t\tif num % i === 0\n \t\t\t\treturn false\n \t\t\tend\n \t\t\ti = i+2\n\t\tend\n\t\ttrue\n\telse\n\t\tfalse\n\tend\nend", "def prime number\n return true if number==2\n max = Math.sqrt number\n for i in 2..max\n return false if number%i==0\n end\n return true\nend", "def is_prime?(num)\n\treturn false if (num < 1 || num.class == Float)\n\t(2...num).each { |n| return false if num % n == 0 }\n\ttrue\nend", "def prime?(num)\n\treturn false if num == 1\n\t(2...num).each { |n| return false if num % n == 0 }\n\ttrue\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 PrimeNumber?(number)\n return false if number<2 || number%2 ==0\n (3..number-1).select(&:odd?).each do |i|\n return false if number%i == 0\n end\n 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?(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 is_prime?(number)\n result = true\n\n # 2 is the only even prime number\n if number == 2\n result = true\n elsif number < 2 or number % 2 == 0\n result = false\n else\n # if there aren't any multiples of n before the square root\n # of n, there aren't any at all.\n root = Math.sqrt(number).ceil\n (3..root).each do |i|\n if number % i == 0\n result = false\n break\n end\n end\n end\n return result\nend", "def prime?(number)\n if number <= 1\n return false\n end\n (2..Math.sqrt(number)).each do |n|\n if number%n == 0\n return false\n end\n end\n return true\nend", "def is_prime?(num)\n return true if num == 1\n (2...num).all? {|i| (num % i) != 0}\nend", "def prime?( number )\n return false if number <= 1 # checks in case the number is 0, 1, or a negative number (b/c those are technically not prime numbers)\n\n max = Math.sqrt( number )\n\n (2..max).any? do |i|\n return false if number % i == 0\n end\n\n true\nend", "def prime?(number)\n return false if number == 1\n 2.upto(number - 1) do |index|\n return false if number % index == 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 return if num <= 1\n (2..Math.sqrt(num)).none? { |i| (num % i).zero? }\nend", "def is_prime?(num)\n if num > 2 \n if num % 2 == 0\n return false\n end\n i = 3 # start at 3\n maxn = num**(0.5) # go up to the square root of num\n while i <= maxn\n if num % i === 0\n return false\n end\n i = i+2 # count up by 2 to check only odd numbers\n end\n true\n elsif num == 2 # special case for 2\n true\n else\n false\n end\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?(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 prime?(number)\n is_prime = true\n is_prime = false if number <= 1\n for divisor in (2...number)\n if (number%divisor) == 0\n is_prime = false\n break\n end\n end\n is_prime\nend", "def is_prime(num)\n\tif num <= 1\n\t\treturn false\n\tend\n\tfor x in 2..Math.sqrt(num).floor do\n\t\tif num % x == 0\n\t\t\treturn false\n\t\tend\n\tend\n\t#If not divisible by anything, return the default case true because the number\n\t#therefore is prime\n\treturn true\nend", "def prime?(num)\n return false if num == 1\n return true if num == 2 or num == 3 or num == 5 or num == 7\n return false if num % 2 == 0 or num % 3 == 0 or num % 5 == 0 or num % 7 == 0\n (11..Math.sqrt(num).ceil).each do |i| \n return false if num % i == 0\n end\n true \nend", "def is_prime?(number)\n return false if number < 2\n\n #Start at 2, since anything lower isn't prime\n idx = 2\n\n #Anything above has a conjugatae divisor less than sqrt number.\n while idx < number**0.5\n\n if number%idx==0\n return false\n end\n\n #After 2, only check odd numbers for primeness\n if idx%2==0\n idx += 1\n else\n idx += 2\n end\n end\n\n return true\nend", "def is_prime?(num)\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)\n (2...number).each do |divisor|\n return false if number % divisor == 0\n end\n\n true\n \nend", "def is_prime?(number)\n return false if number < 2\n i = 2\n while i <= Math.sqrt(number) # See below why we stop at square root of number\n return false if number % i == 0\n i += 1\n end\n true\nend", "def prime?(number)\n return false if 2 > number\n (2...number).each { |i| return false if number % i == 0 }\n true\nend", "def prime?(number)\n (2...number).none? { |n| number % n == 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\tdivisor = 2\n\twhile divisor < num\n\t\tif num%divisor == 0\n\t\t\treturn false\n\t\tend\n\t\tdivisor += 1\n\tend\n\treturn true\nend", "def is_prime?(num)\n (2..num/2).none?{|el| num % el == 0}\nend", "def is_prime?(num)\n (2...num).none? { |div| num % div == 0 }\nend", "def prime?(int)\n \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 return false if num < 2\n (2...num).none? { |factor| num % factor == 0}\nend", "def prime?(num)\n return false if num <= 1\n Math.sqrt(num).to_i.downto(2).each {|i| return false if num % i == 0}\n true\n end", "def prime?(num)\n\tif num < 2\n\t\treturn false\n\tend\n \n \t(2...num).each do |factor|\n \tif num % factor == 0\n \treturn false\n end\n end\n \n \treturn true\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 (number)\n if [1,2,3,5,7,11].include?(number)\n return TRUE\n end\n if number % 2 == 0 and number != 2\n # p \"not prime, divisible by 2\"\n return FALSE\n elsif number % 3 == 0 and number != 3\n # p \"not prime, divisible by 3\"\n return FALSE\n elsif number % 5 == 0 and number != 5\n # p \"not prime, divisible by 5\"\n return FALSE\n elsif number % 7 == 0 and number != 7\n # p \"not prime, divisible by 7\"\n return FALSE\n else\n divisor = 2\n # from one to the square root of a number is all the numbers it could be divided by\n # because after the square root you're repeating yourself.\n while divisor <= (Math.sqrt(number)).ceil\n # while divisor is less than the square root of the ( smallest integer greater than the number )\n if number % divisor == 0 and number != divisor\n return FALSE\n elsif (Math.sqrt(number)).ceil == divisor\n # if the divisor is equal to the square root of the ( smallest integer greater than the number )\n return TRUE\n else\n # increment the divisor\n divisor = divisor + 1\n end\n end\n end\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(number)\n prime = 0\n for i in 1..number\n if (number % i == 0)\n prime += 1\n end\n end\n return true if prime == 2\n return false\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?(num)\n 2.upto(num / 2) do |n|\n return false if num % n == 0\n end\n true\nend", "def prime?(num)\r\n if num <= 1 || num == 0 || num == 1\r\n return false\r\n elsif \r\n (2..num - 1).each do |i| \r\n if num % i == 0 \r\n return false \r\n end \r\n end \r\n end \r\n true \r\n end", "def is_prime?(num)\n return false if num <2\n return (2..num/2).none? {|i| num%i==0}\nend", "def prime?(number, primes)\n root = Math.sqrt(number).ceil\n index = primes.index(primes.find { |i| i >= root })\n\n factors = primes.slice(1, index ? index + 1 : primes.count)\n return factors.none? { |i| number % i == 0 }\nend" ]
[ "0.82608944", "0.8258196", "0.8242386", "0.81716", "0.8110411", "0.81054336", "0.81008714", "0.8098817", "0.80936307", "0.8086946", "0.8081761", "0.8079496", "0.80773157", "0.80503285", "0.80313873", "0.8027763", "0.8014631", "0.7991314", "0.7973856", "0.7973856", "0.7973856", "0.79721856", "0.7963101", "0.79588366", "0.79588366", "0.7957684", "0.7954712", "0.79519224", "0.79509896", "0.7945712", "0.7933987", "0.79318655", "0.7931277", "0.7929099", "0.7923814", "0.7921949", "0.7921949", "0.79212314", "0.7920336", "0.7917921", "0.79140437", "0.791292", "0.79023355", "0.78991824", "0.7893936", "0.7893656", "0.7891181", "0.7890366", "0.7890366", "0.7890366", "0.788807", "0.7887917", "0.78878987", "0.7885805", "0.7884874", "0.78847086", "0.78840256", "0.78717935", "0.7870256", "0.78657603", "0.78637767", "0.7858877", "0.78577995", "0.78576034", "0.7847927", "0.7847101", "0.78469706", "0.7842447", "0.7840541", "0.7835104", "0.7835104", "0.7835104", "0.78343797", "0.78336513", "0.7833509", "0.7822326", "0.7819407", "0.7817289", "0.78125954", "0.78107435", "0.7808134", "0.7802849", "0.7799401", "0.7797547", "0.77966344", "0.7795997", "0.77947474", "0.7793162", "0.77913934", "0.7791158", "0.77901125", "0.77847403", "0.7783754", "0.7782148", "0.77811044", "0.77797705", "0.7773007", "0.7772763", "0.77701586", "0.7767334" ]
0.8460171
0
Defualt stopping point if none provided
def default_stop @total ||= 1_000 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stop_0\n @stop = 1\n end", "def stopped_at=(_arg0); end", "def stopped_at=(_arg0); end", "def stopped_at=(_arg0); end", "def stopsig(*) end", "def stop?(*) end", "def stopped_at; end", "def stopped_at; end", "def stopped_at; end", "def stop_for_testing?(stop_point)\n if stop_for_testing = R8::Config[:stop_for_testing]\n if stop_for_testing[stop_point]\n fail Error.new(\"stop for testing at #{stop_point}\")\n end\n end\n end", "def stop_loss(actual_price, stop_loss)\n if stop_loss >= actual_price\n nil\n else\n stop_loss\n end\n end", "def stopping; end", "def skipped?; end", "def skipped?; end", "def skipped?; end", "def skipped?; end", "def stopped?(*) end", "def prepare_result\n\t\t\tsuper\n\t\t\t@lowest_old = MM.get_lowest_old(@current_point, @start_vector, @hd_config, false, @tuning_range)\n if @lowest_old[0] == nil\n\t\t\t\t@initial_run = true\n\t\t\t\tthrow :jump_back\n\t\t\tend\n\t\tend", "def infinite?; end", "def stop\n @max\n end", "def stopped?; end", "def stopped?; end", "def stopped?; end", "def stopped?; end", "def stop\n # no-op\n end", "def stopped?\n self.speed == 0\n end", "def stop\n accelerate((speed > 0) ? -1 : ((speed < 0) ? 1 : 0))\n end", "def stop\r\n accelerate((speed > 0) ? -1 : ((speed < 0) ? 1 :0))\r\n end", "def stop!\n throw :return, 1\n end", "def negative?; end", "def continue?; end", "def calc_next_run\n nil\n end", "def calc_next_run\n nil\n end", "def exploring?; ! exploration_ends_at.nil?; end", "def not_null\n bad_boi_points ||=0\n good_boi_points ||=0\n end", "def break()\n #This is a stub, used for indexing\n end", "def stop?\n\t\t\t\tunless @marked\n\t\t\t\t\[email protected]\n\t\t\t\t\treturn true\n\t\t\t\tend\n\t\t\tend", "def validate_guaranteed_stop_constraints\n return if !guaranteed_stop || (stop_level.nil? ^ stop_distance.nil?)\n\n raise ArgumentError, 'set exactly one of stop_level or stop_distance when guaranteed_stop is true'\n end", "def maybe_pause_evolution\n\n end", "def skip_during; end", "def skip_during; end", "def stop_on_unknown\n @stop_on_unknown = true\n end", "def halt\n StepResult.new(false)\n end", "def stop_hooks_unless(result)\n\t\t\t\t\t(result == true) ? continue(true) : stop(false)\n\t\t\t\tend", "def cancel\n self.break_condition = 1\n end", "def stop!; end", "def passed?; end", "def passed?; end", "def passed?; end", "def end_point=(_arg0); end", "def simulate_stop(step = 1)\n while (@v > 0)\n @t += step\n @s += @v * step\n a = if (@v <= @v_a_max)\n @a_max\n else\n @k / @v\n end\n\n # The train is going to stop, not reverse.\n if (a * step > @v)\n a = @v / step\n @v = 0\n else\n @v -= a * step\n end\n yield @t, @s, @v, -a\n end\n end", "def stop?\n !!@stop\n end", "def validate_run!(speed)\n raise \"Speed #{speed} is < 0\" if speed.negative?\n end", "def stop?(max_steps)\n stop_state? or max_step_reached?(max_steps) or stalled?\n end", "def stop\n\t\t# No-op\n\tend", "def stop_elevator\n return false if stops_remaining?\n @direction = 0 and return true\n end", "def optional default_return_value = NoParameterMarker.instance\n if default_return_value == NoParameterMarker.instance\n repeat 0, 1 # default behaviour\n else\n repeat_with_default 0, 1, default_return_value\n end\n end", "def parkingbrake\n # if @speed == 0\n @parkingbrake = !@parkingbrake\n # end\n end", "def fall_back\n say 'You tried to fool me, human! Start over!' unless text_message?\n return false unless !text_message? || stop_word_used?('Stop')\n stop_questionnaire\n puts 'Fallback triggered!'\n true # to trigger return from the caller on 'and return'\n end", "def failed?; failed_to_start? || (@success == false) end", "def dead?()\n @fitness <= 0\n end", "def goto_false_step\n if goto_false\n return FlowStep.job_flow_step(job_id: self.job_id, flow_step: self.goto_false)\n end\n nil\n end", "def halt!(*)\n @halted = true\n end", "def stop_condition(&block)\n self.gracefully_stop_mark = block\n end", "def positive?; end", "def stop; end", "def stop; end", "def stop; end", "def stop; end", "def stop; end", "def stop; end", "def stop; end", "def skipped!; end", "def halt; end", "def halt; end", "def halt!\n @running = false\n return nil\n end", "def stop\n begin\n pre_stop\n ensure\n begin\n stop_impl\n ensure\n post_stop\n end\n end\n end", "def never?; end", "def infinite?() end", "def stopping?\n @stopping\n end", "def stop!\n @stop = true\n end", "def stop!\n @stop = true\n end", "def should_stop?\n time_is_up? ? more_work? : false\n end", "def stop?\n @stop\n end", "def stop\n prevent_default\n stop_propagation\n end", "def break?\n @break\n end", "def stop_reason()\n #This is a stub, used for indexing\n end", "def missed?; end", "def previously_ran?; end", "def previously_ran?; end", "def tt_forever?\n ttend_at == InfinityValue\n end", "def stopping?\n # This does not need to be synchronized because nothing un-stops\n @stopping\n end", "def force_stopped?\n return true if @anime_speed > 0 || @knockdown_data[0] > 0 ||\n @stopped_movement > 0 || @hookshoting[0] || @angle_fx != 0.0\n return true if @making_spiral\n return false\n end", "def target_reached?\n @current_value == @target_value\n end", "def halted?\n @current >= (@size - 1)\n end", "def pbEndSurf(xOffset,yOffset)\n return false if !$PokemonGlobal.surfing\n x=$game_player.x\n y=$game_player.y\n currentTag=$game_map.terrain_tag(x,y)\n facingTag=Kernel.pbFacingTerrainTag\n if pbIsSurfableTag?(currentTag)&&!pbIsSurfableTag?(facingTag)\n if Kernel.pbJumpToward\n Kernel.pbCancelVehicles\n $game_map.autoplayAsCue\n $game_player.increase_steps\n result=$game_player.check_event_trigger_here([1,2])\n Kernel.pbOnStepTaken(result)\n $FollowingFinishedSurfing = true\n end\n return true\n end\n return false\nend", "def skips=(_arg0); end", "def step\n halt if should_halt?\n stop_elevator or move_elevator\n end", "def default_consequence\n ->(breaches) { context.fail!(breaches) }\n end", "def default_consequence\n ->(breaches) { context.fail!(breaches) }\n end" ]
[ "0.6677213", "0.6391272", "0.6391272", "0.6391272", "0.62266386", "0.6191582", "0.61374426", "0.61374426", "0.61374426", "0.6008185", "0.59539366", "0.5834314", "0.5834218", "0.5834218", "0.5834218", "0.5834218", "0.5756148", "0.57359487", "0.57232577", "0.5706348", "0.5668751", "0.5668751", "0.5668751", "0.5668751", "0.56376755", "0.55904174", "0.557237", "0.5567804", "0.55574566", "0.5547631", "0.55420125", "0.5518288", "0.5518288", "0.5511735", "0.55023336", "0.5492699", "0.54886967", "0.5462222", "0.5424575", "0.54195625", "0.54195625", "0.54180276", "0.5411839", "0.54061234", "0.54006255", "0.5397613", "0.5388452", "0.5388452", "0.5388452", "0.53822845", "0.5373464", "0.5358019", "0.534601", "0.5344137", "0.5341179", "0.53400576", "0.5326803", "0.5323051", "0.53222084", "0.53197664", "0.52987117", "0.52926123", "0.52908856", "0.5284986", "0.5282048", "0.52722067", "0.52722067", "0.52722067", "0.52722067", "0.52722067", "0.52722067", "0.52722067", "0.52720505", "0.52687407", "0.52687407", "0.5265981", "0.5264337", "0.5252818", "0.52491975", "0.5245783", "0.52430594", "0.52430594", "0.52413255", "0.5211577", "0.52109647", "0.51894796", "0.5176493", "0.51756066", "0.51721734", "0.51721734", "0.5171572", "0.51660186", "0.5165625", "0.5160974", "0.5159069", "0.51574785", "0.51549745", "0.51468796", "0.5141455", "0.5141455" ]
0.6447211
1
Returns the currently logged in user or nil if there isn't one
def current_user if @current_user return @current_user end if session[:person_id] @current_user ||= Person.find(session[:person_id]) else authenticate_with_http_basic do |email, password| @current_user = Person.authenticate(email, password) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_user\n if session[:user_id]\n return User.find(session[:id])\n else\n return nil\n end\n end", "def current_user\n if session[:user_id]\n return @user ||= User.find(session[:user_id]['$oid'])\n else\n return nil\n end\n end", "def current_user\n if session[:user_id]\n User.find(session[:user_id])\n else\n nil\n end\n end", "def get_current_user\n if session[:authenticated]\n return User.find_by_id(session[:user_id])\n end\n return nil\n end", "def current_user\n if session[:user_id]\n user = User.find(session[:user_id])\n else\n nil\n end\n end", "def current_user\n\tif(session[:user_id])\n\t\t@u ||= User.first(id: session[:user_id])\n\t\treturn @u\n\telse\n\t\treturn nil\n\tend\nend", "def current_user\n\tif(session[:user_id])\n\t\t@u ||= User.first(id: session[:user_id])\n\t\treturn @u\n\telse\n\t\treturn nil\n\tend\nend", "def current_user\n\tif(session[:user_id])\n\t\t@u ||= User.first(id: session[:user_id])\n\t\treturn @u\n\telse\n\t\treturn nil\n\tend\nend", "def current_user\n\tif(session[:user_id])\n\t\t@u ||= User.first(id: session[:user_id])\n\t\treturn @u\n\telse\n\t\treturn nil\n\tend\nend", "def getLoggedInUser\n if session[:user_id]\n return User.find(session[:user_id])\n else\n return nil\n end\n end", "def get_current_user\n @current_user ||= User.find(session[:user_id]) unless session[:user_id].blank?\n return @current_user\n end", "def get_logged_in_user\n if logged_in?\n user = User.find(session[:current_user_id])\n if user\n return user\n else\n return nil\n end\n end\n \n #default return nil\n nil\n end", "def get_current_user\n unless session[:user_id].blank?\n @current_user = User.find(session[:user_id])\n else\n @current_user = nil\n end\n end", "def current_user\n if session[:user_id]\n User.find(session[:user_id])\n else\n end\n end", "def current_user\n return unless session[:user_id]\n User.find(session[:user_id])\n end", "def user\n return nil if !session[:user]\n @user ||= fetch_user(session[:user])\n end", "def user\n return nil if !session[:user]\n @user ||= fetch_user(session[:user])\n end", "def user\n return nil if !session[:user]\n @user ||= fetch_user(session[:user])\n end", "def current_user\r\n\tif(session[:user_id])\r\n\t\t@u ||= User.first(id: session[:user_id])\r\n\t\treturn @u\r\n\telse\r\n\t\treturn nil\r\n\tend\r\nend", "def get_current_user\n if @current_user\n return @current_user\n else\n @current_user = User.find_by(id: session[:user_id])\n end\n end", "def current_user\n if !session[:user_id] then nil else User.find(session[:user_id]) end\n end", "def get_current_user\n unless session[:user_id]\n @current_user = nil\n return\n end\n @current_user = User.first(:conditions => {:id => session[:user_id] })\n end", "def current_user\n begin\n unless @current_user.nil?\n return @current_user\n else\n if session[:user_id]\n return @current_user = User.find(session[:user_id])\n else\n return nil\n end\n end\n rescue\n return nil\n end\nend", "def find_current_user\n user_id = session[:user_id]\n if user_id\n user = Marty::User.active.find(user_id) rescue nil\n else\n user = try_to_autologin\n end\n\n user\n end", "def current_user\n\t\tif session[:user_id].present?\n\t\t\tUser.find(session[:user_id])\n\t\tend\n\tend", "def current_user\n if valid_session?\n User.find(session[:user_id])\n end\n end", "def current_user\n User.get_user(session[:user_id]) if session[:user_id]\n end", "def current_user\n begin \n User.find(session[:user_id])\n rescue ActiveRecord::RecordNotFound\n nil\n end\n end", "def get_current_user\n if session[:user_id]\n @current_user ||= User.find_by(id: session[\"user_id\"])\n end\n end", "def current_user\n if !@current_user.nil?\n @current_user\n elsif !session[:current_user_id].nil?\n begin\n @current_user = User.find(session[:current_user_id])\n rescue ActiveRecord::RecordNotFound\n @current_user = nil\n end\n end\n end", "def current_user\n if session[:user_id]\n User.find_by(id: session[:user_id])\n end\n end", "def find_current_user\n if is_logged_in?\n @current_user = User.find(session[:user_id])\n else\n @current_user = nil\n end\n end", "def current_user\n if Rails.application.config.use_omniauth\n return nil unless session[:user_info]\n @current_user ||= User.find_user_from_omniauth(session[:user_info])\n else\n @current_user ||= User.where(username: request.env['aker.check'].user.username).first\n end\n end", "def current_user\n\tsession[:user_id] ? User.find(session[:user_id]) : nil\nend", "def current_user\n\tsession[:user_id] ? User.find(session[:user_id]) : nil\nend", "def current_user\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n #return current user or set to this if there isnt a current user\n end", "def current_user\n return nil unless session[:user_id]\n @current_user ||= User.find_by(id: session[:user_id])\n end", "def current_user\n return unless session[:user_id]\n @current_user ||= User.find(session[:user_id])\n end", "def current_user\n return unless session[:user_id]\n @current_user ||= User.find(session[:user_id])\n end", "def current_user\n return unless session[:user_id]\n @current_user ||= User.first(:id => session[:user_id])\n end", "def current_user\n return @current_user ||= User.find(session[:user_id]) unless session[:user_id].nil?\n end", "def current_user\n return @current_user if @current_user.present?\n\n if session[:uid]\n @current_user = User.from_session(session)\n end\n\n @current_user\n end", "def current_user\n @current_user ||= User.find(session[:user_id]) if logged_in?\n end", "def current_user\n @current_user ||= User.find(session[:user_id]) if logged_in?\n end", "def current_user\n return unless session[:user_id]\n @current_user ||= User.find_by_id(session[:user_id])\n end", "def current_user(id = session[:user_id])\n User.get_one id\n end", "def current_user\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n #this way so if no session we don't .find nil\n end", "def current_user\n \t# If the session contains the user_id with non-nil, we have ID of some user\n \t# Return the user object for ID\n \t\n \t# Using instance variable helps limit calls\n \t# \"Or equals\" means \n \t\t# if nil, set it -- if not, return it\n \tif session[:user_id]\n \t@current_user ||= User.find(session[:user_id])\n end\n end", "def current_user\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n return @current_user\n end", "def current_user\n User.find(session[:user_id]) if session[:user_id]\n end", "def current_user\n User.find(session[:user_id]) if session[:user_id]\n end", "def current_user\n if @current_user.nil?\n @current_user = User.find_by(id: session[:user_id])\n else\n @current_user\n end\n end", "def authenticated_user\n if session[:user_id].nil?\n return nil\n else\n return User.find(session[:user_id])\n end\n end", "def current_user\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n #return current user if @current_user already exists.\n #if there's no current user, return the user with ID == session user ID, if there is one.\n end", "def current_user\n logged_in? ? User.find_by_id(session[:user_id]) : nil\n end", "def current_user\n if session\n if session.has_key?(:user_id)\n return @current_user = User.find_by_id(session[:user_id])\n elsif session.has_key?(:farmer_id)\n return @current_user = Farmer.find_by_id(session[:farmer_id])\n else\n nil\n end\n end\n end", "def find_current_user\n if session[:current_user_id]\n @user = User.find_by(id: session[:current_user_id])\n else\n @user = nil\n end\n end", "def current_user\n if session[:user_id].present?\n @current_user = User.find_by(uid: session[:user_id])\n # session.clear if @current_user.nil?\n return @current_user\n end\n end", "def current_user\n if user_signed_in?\n Session.active_sessions.find_by(id: request.headers['sid'], utoken: request.headers['utoken']).user\n else\n nil\n end\n end", "def current_user\n if user_signed_in?\n Session.active_sessions.find_by(id: request.headers['sid'], utoken: request.headers['utoken']).user\n else\n nil\n end\n end", "def current_user\n return nil unless session[:user_id] \n @current_user ||= User.find(session[:user_id])\n end", "def current_user\n return nil unless session[:user_id]\n User.get(session[:user_id])\nend", "def current_user\n User.find_by(uid: session[:user]) if logged_in?\n end", "def current_user\n\t\tif logged_in?\n\t\t\t@current_user ||= User.find(cookies[cookie_id])\n\t\telse\n\t\t\tnil\n\t\tend\n\tend", "def return_current_user\n @current_user ||= User.find(session[:id_of_current_user]) if session[:id_of_current_user]\n end", "def current_user\n @current_user ||= begin\n if session[:user_id]\n user = User.where(id: session[:user_id])\n user[0] if user.any?\n end\n end\n # @current_user ||= User.find session[:user_id] if session[:user_id]\n end", "def current_user\n @user ||= User.find_by(id: session[:user_id]) if session[:user_id]\n end", "def current_user\n @current_user ||= User.find(session[:user_id]) if session[:user_id] rescue nil\n end", "def current_user\n\t\t\tUser.find(session[:user_id])\n\t\tend", "def current_user\n\t\t\tUser.find(session[:user_id])\n\t\tend", "def current_user\n if session[:user_id]\n @current_user ||= User.find(session[:user_id])\n end\n end", "def current_user\n if session[:user_id]\n @current_user ||= User.find(session[:user_id])\n end\n end", "def current_user\n @current_user ||=\n if session[:userid]\n User.find_by_userid(session[:userid])\n end\n end", "def current_user\n \t@current_user || User.find(session[:user_id]) if session[:user_id]\n end", "def current_user\n @current_user || = User.find(session[:user_id]) if session[:user_id]\n end", "def current_user\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n end", "def current_user\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n end", "def current_user\n return nil if session[:session_token].nil?\n @current_user ||= User.find_by_session_token(session[:session_token])\n end", "def current_user\n return nil if session[:session_token].nil?\n @current_user ||= User.find_by(session_token: session[:session_token])\n end", "def get_user\n \n # Retrieve user id if stored in a cookies\n # @TODO Secure ID when stored in cookies\n if cookies[:user]\n return User.find(cookies[:user])\n\n # Retrieve user id if stored in session\n elsif session[:user]\n return User.find(session[:user])\n\n # No user logged in\n else\n return nil\n end\n\n end", "def current_user\n\tif session[:user_id].present?\n\t\tUser.find(session[:user_id])\t\n\tend\nend", "def user\n\t\t\treturn nil if ! logged_in?\n\n\t\t\tPicombo::Session.instance.get('user')\n\t\tend", "def current_user\n if cookies[:session_id]\n @current_user ||= User.where(session_id: cookies[:session_id])[0]\n else\n nil\n end\n end", "def get_current_user\n if session[:user_id].blank?\n redirect_to :login\n else\n @current_user = User.find(session[:user_id])\n end\n end", "def current_user\n return @current_user if defined?(@current_user)\n @current_user = User.find_by_id(session[:user_id])\n end", "def current_user\n # set instance variable to either nil (if session[:user_id] is nil)\n # or to the user with that id\n @current_user ||= session[:user_id] && User.find_by_id(session[:user_id])\n end", "def current_user\n if(@current_user.nil?)\n @current_user = User.find_by(id: session[:user_id])\n else\n @current_user\n end\n end", "def current_user\n\t\tif session[:user_id]\n\t\t @current_user = User.find(session[:user_id])\n\t\telse\n\t\t @current_user = nil\n\t\tend\n\t\t @current_user\n end", "def current_user\n return unless session[:user_id]\n @current_user = User.find_by_id(session[:user_id])\n end", "def current_user\n\t\t# checks to see if session exists, if so, loads user\n\t\t# and saves into @user instance variable\n\t\t@current_user ||= User.find(session[:user_id]) if session[:user_id]\n\tend", "def current_user\n if session[:user_id]\n @current_user ||= User.find_by_id(session[:user_id])\n end\n end", "def current_user\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n # return current user or set it to what is found in cookie, only if there is one to begin with\n end", "def current_user\n if session[:user_id]\n @user = User.find(session[:user_id])\n end\n end", "def current_user\n if session[:user_id]\n @user = User.find(session[:user_id])\n end\n end", "def current_user\n\t return unless session[:user_id]\n\t @current_user ||= User.find_by_id(session[:user_id]) \n\tend", "def current_user\n if session[:user_id]\n @current_user ||= User.find_by(id: session[:user_id])\n end\n end", "def current_user\n\t\t\treturn unless session[:user_id]\n\t\t\t@current_user ||= User.find_by_id(session[:user_id])\n\t\tend", "def current_user\n if session[:user_id]\n @current_user ||= User.find_by(id: session[:user_id])\n end\n end", "def current_user\n if session[:user_id]\n @current_user ||= User.find_by(id: session[:user_id])\n end\n end", "def current_user\n if session[:user_id]\n @current_user ||= User.find_by(id: session[:user_id])\n end\n end", "def current_user\n if session[:user_id]\n @current_user ||= User.find_by(id: session[:user_id])\n end\n end" ]
[ "0.873353", "0.8696872", "0.8696666", "0.85968804", "0.858103", "0.8528413", "0.8528413", "0.8528413", "0.8528413", "0.8510657", "0.8416158", "0.8415876", "0.8392121", "0.83712745", "0.83696145", "0.835804", "0.835804", "0.835804", "0.83247185", "0.83241534", "0.8321151", "0.8317746", "0.8304536", "0.83042616", "0.8303882", "0.83021736", "0.8299185", "0.82452655", "0.82390153", "0.8213042", "0.81848276", "0.818233", "0.81810594", "0.8178061", "0.8178061", "0.81655145", "0.8163824", "0.8162096", "0.8162096", "0.8161172", "0.81502146", "0.81480896", "0.81369096", "0.81369096", "0.8134229", "0.8132432", "0.81302494", "0.8128269", "0.81278056", "0.81253415", "0.81253415", "0.8116722", "0.81116503", "0.8107471", "0.8103835", "0.81035084", "0.81025004", "0.80989236", "0.8096374", "0.8096374", "0.8089878", "0.8081801", "0.80784744", "0.80700463", "0.80641484", "0.806387", "0.8056459", "0.80543786", "0.8050554", "0.8050554", "0.8050255", "0.8050255", "0.8044936", "0.80402416", "0.8035597", "0.8031291", "0.8031291", "0.80293745", "0.8028853", "0.80260074", "0.8022929", "0.8021353", "0.80160064", "0.801211", "0.80089086", "0.8006388", "0.8006153", "0.8005906", "0.80044293", "0.8004185", "0.8003817", "0.80012006", "0.8001174", "0.8001174", "0.79997003", "0.79991406", "0.79982513", "0.79972714", "0.79972714", "0.79972714", "0.79972714" ]
0.0
-1
Filter method to enforce a login requirement Apply as a before_filter on any controller you want to protect
def authenticate logged_in? ? true : access_denied end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login_required\n # Skip this filter if the requested action is not protected\n return true unless protect?(action_name)\n\n # Check if user is logged in and authorized\n return true if logged_in? and authorized?(current_user)\n\n # Store current location so that we can redirect back after login\n store_location\n\n # Call access_denied for an appropriate redirect and stop the filter\n # chain here\n access_denied and return false\n end", "def login_filter\n\t\tif not protect?( action_name )\n\t\t\treturn true \n\t\tend\n\n\t\tif not session[:user_id]\n\t\t\t# user isn't logged in\n\t\t\tstore_location\n\t\t\tredirect_to :controller=>\"account\", :action=>\"login\"\n\t\t\treturn false\n\t\tend\n\n\t\t# initialize the @user variable\n\t\t@user = User.find( session[:user_id] )\n\t\t\n\t\tif not @user.validated?\n\t\t\t# user is logged in, but they haven't been validated\n\t\t\tredirect_to :controller=>\"account\", :action=>\"not_activated\"\n\t\t\treturn false\n\t\telsif not authorized?( @user, action_name )\n\t\t\t# user is logged in and validated, but not authorized\n\t\t\tredirect_to :controller=>\"account\", :action =>\"denied\"\n\t\t\treturn false\n\t\telse\n\t\t\t# user is logged in AND validated AND authorized! let 'em in!\n\t\t\treturn true\t\n\t\tend\n\n\t\t# we shouldn't get here\n\t\traise \"Serious malfunction in 'login_filter' -- please contact manufacturer ([email protected])...\"\n\tend", "def login_required\n not_authorized unless current_user\n end", "def before_request\n self.login if require_login? && !@authenticating\n end", "def authenticate\n CASClient::Frameworks::Rails::Filter.before(self)\n update_current_user(User.eager_load(*eager_loads).find_by(cas_directory_id: session[:cas_user]))\n\n return unless session[:cas_user] && !allow_access\n render(file: File.join(Rails.root, 'public/403.html'), status: :forbidden, layout: false)\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authorize\n redirect_to '/login' unless current_user\n end", "def authorize\n\t\tredirect_to '/login' unless current_user\n\tend", "def login_required\n (logged_in? || (controller_name == 'sessions')) ? true : access_denied\n end", "def authorize\n redirect_to :login unless user_signed_in?\n end", "def check_login\n head :forbidden unless self.current_user\n end", "def signed_in_user_filter\n if signed_in?\n redirect_to root_path, notice: \"Already logged in\"\n end\n end", "def authorize # we can call it anything\n redirect_to '/login' unless current_user # if there is a current user then it will never redirect\n end", "def run_filters\n set_user\n authorize\n end", "def authorize\n redirect_to('/login') unless @current_user\n end", "def check_is_login_required\n authorized_denied unless logged_in?\n end", "def login_required! \n if ! is_logged_in? \n redirect '/login' \n end \n end", "def before_filter\n if current_user\n true\n end\n end", "def login_required\n redirect_to(login_url) unless logged_in? && authorized?\n end", "def authorize\n return if current_user\n\n redirect_to login_url\n end", "def authorized\n redirect_to \"/login\" unless logged_in? \n end", "def require_login\n authorize_request || render_unathorized(\"Access denied\")\n end", "def require_login\n\t\tauthorize_request || render_unauthorized(\"Access Denied\")\n\tend", "def require_login\n return head(:forbidden) unless current_user\n end", "def filter_request(request)\n @token.authenticate(request)\n end", "def login_required\n access_denied unless header_login or session_login or cookie_login\n end", "def login_required\n \n if not protect?(action_name)\n return true \n end\n\n if @session['user'] and authorize?(@session['user'])\n return true\n end\n\n # store current location so that we can \n # come back after the user logged in\n store_location\n \n # call overwriteable reaction to unauthorized access\n access_denied\n return false \n end", "def login_required\n authenticate_user! \n end", "def login_required\n if logged_in?\n return true\n else\n redirect_to(:controller => '/user', :action => 'index')\n return false\n end\n end", "def login_required\n return true unless protect?(action_name)\n\n return true if user? && authorize?(session[:user])\n\n # store current location so that we can\n # come back after the user logged in\n store_location\n\n # call overwriteable reaction to unauthorized access\n access_denied\n false\n end", "def require_authentication\r\n\r\n return true if session_user\r\n\r\n # per security audit, don't even show the login form if admin was requested...take 'em home\r\n if params[:controller] =~ /^admin/i\r\n logger.debug \"Admin request from unauthenticated session, sending to homepage.\" if logger.debug?\r\n redirect_to home_url\r\n else\r\n logger.debug \"Session not authenticated, sending to login screen.\" if logger.debug?\r\n # respond based on the type of request: normal, XHR, etc.\r\n if request.xhr?\r\n render :update do |page|\r\n page.redirect_to login_url(:protocol => 'https://')\r\n end\r\n else\r\n redirect_to login_url(:protocol => 'https://', :redirect_to => request.request_uri)\r\n end\r\n end\r\n\r\n # return false to prevent any other filters from executing\r\n false\r\n end", "def login_required\n return true unless protect?(action_name)\n\n user = session_user\n return true if user && authorize?(user)\n\n # store current location so that we can\n # come back after the user logged in\n store_location\n\n # call overwriteable reaction to unauthorized access\n access_denied\n false\n end", "def require_login\n return head(:forbidden) unless current_user\n end", "def login_required\n access_denied unless session_login || cookie_login\n end", "def authorize\n # First check if user is already logged in\n if (session[:user_id].nil? || session[:user_id] == \"\")\n redirect_to :controller => 'user', :action => 'login'\n return\n end\n end", "def logged_in_authorize\n unless logged_in?\n unauthorized_access\n end\n end", "def authorize\n redirect_to new_session_path unless logged_in?\n end", "def authorize!\n redirect '/' unless logged_in?\n end", "def authorize\n unless @_user = User.find_by_id(session[:user_id])\n# session[:original_uri] = request.request_uri\n flash[:notice] = \"Please login first\"\n redirect_to :controller => :login, :action => :index\n end\n end", "def authorize\n unless User.find_by_id( session[ :user_id ] )\n session[ :original_uri ] = request.request_uri\n flash[ :notice ] = \"Please log in\"\n redirect_to :controller => :login, :action => :login\n end\n end", "def authorize\n unless User.find_by(id: session[:user_id])\n redirect_to login_url, notice: \"Please log in\"\n end\n end", "def require_login\n unless params[\"login\"].nil?\n #Call the devise helper to authenticate the user (returns back to orig dest)\n authenticate_user! if params[\"login\"] == \"true\"\n end\n end", "def frontend_login_required\n logged_in? && allowed? || access_denied(:frontend)\n end", "def require_login\n end", "def login_required\n authorized? || throw(:halt, :access_denied)\n end", "def login_required\n logged_in? ? true : access_denied\n end", "def authorize\n unless User.find_by_id(session[:user_id])\n flash[:notice] = \"Login required\"\n redirect_to(:controller => \"home\", :action => \"login\")\n end\n end", "def authorize\n redirect_to new_session_path unless logged_in?\n end", "def login_required\n if !logged_in?\n redirect \"/login?#{env[\"REQUEST_PATH\"]}\"\n end\n end", "def restrict_access\n unless logged_in?\n flash[:error] = \"You have to login to access this page.\"\n redirect_to login_url\n end\n end", "def login_required\n authorized? || access_denied\n end", "def login_required\n authorized? || access_denied\n end", "def login_required\n authorized? || access_denied\n end", "def login_required\n logged_in? ? true : access_denied\n end", "def authorize\n unless User.find_by_userName(session[:userName])\n flash[:notice] = \"Please log in\"\n redirect_to(:controller => \"logins\" , :action => \"index\" )\n end\n end", "def must_login\n redirect_to :action => 'login', :controller => 'usuarios' if !(controller_is?('usuarios') && action_is?('login')) && current_user.nil?\n end", "def current_user_required\n\t\t# Have to add \".filter(self)\" when not in before_filter line.\n\t\tCASClient::Frameworks::Rails::Filter.filter(self)\n\tend", "def authorize \n unless logged_in?\n flash[:danger] = \"You must be logged in to view that... Please log in.\"\n redirect_to new_session_path unless logged_in?\n end\n end", "def authorize_user\n # simple authorization: kick out anonymous users from backend actions\n=begin\n if !current_user\n redirect_back_or_default(home_page) and return if action_name =~ /index|edit|update|destroy/\n \n # skip checking permission if user is an admin\n elsif !current_user.has_role?('Admin')\n unless current_user.has_permission?(controller_name, action_name, params)\n flash[:warning] = 'Access Denied'\n redirect_back_or_default(home_page) and return\n end\n end\n=end\n end", "def require_login\n return head(:forbidden) unless current_user || current_employee\n end", "def authorize\n unless User.find_by_id(session[:user_id])\n redirect_to login_url, :notice => \"Please log in\"\n end\n end", "def authorize \n redirect_to login_url, notice: \"Please log in\" if session[:user_id].nil?\n end", "def authorize\n redirect_to \"/log_in\", :alert => t('.need_to_be_logged_in') unless signed_in?\n end", "def authorize\n redirect_to login_path, alert: 'You must be logged in to access this page.' if current_user.nil?\n end", "def login_required\n logged_in? || access_denied\n end", "def authorize\n redirect_to new_session_path unless current_user #call method curent_user in sessions_helper\n end", "def authorized\n redirect_to :controller => 'home', :action => 'index' unless logged_in?\n end", "def must_login\n redirect_to login_path unless logged_in?\n end", "def authorize\n \t\t\tunless User.find_by(id: session[:user_id])\n \t\t\t\tredirect_to login_url, notice: \"Please Log-in\"\n \t\t\tend\n \t\tend", "def require_login\n unless params[\"login\"].nil?\n #Call the devise helper to authenticate the user (returns back to orig dest)\n authenticate_user! if params[\"login\"] == \"true\"\n end\n end", "def before_filter; end", "def authorize #:doc:\n unless session[:user_id]\n flash[:notice] = \"Please log in\"\n redirect_to(:controller => \"login\", :action => \"login\")\n end\n end", "def authorize\n unless User.find_by_id(session[:user_id])\n redirect_to :log_in, :notice => \"Please log in\"\n end\n end", "def authorize\n redirect_to login_url, alert: \"Not authorized\" if !current_user\n end", "def login_required\n username, passwd = get_auth_data\n logged_in? && authorized? ? true : access_denied\n end", "def login_required\n return if authorized?\n unauthorized! unless auth.provided?\n bad_request! unless auth.basic?\n unauthorized! unless authorize(*auth.credentials)\n @req.env['REMOTE_USER'] = auth.username\n end", "def login_check\n if current_user\n unless Whitelist.exists?(domain: current_user.email.match(/@.*/).to_s)\n redirect_to('/not_allow')\n end\n else\n redirect_to('/')\n end\n end", "def restrictToAdmin! ; redirect to('/login'),303 unless admin? ; end", "def login_required\n call(Rs(:login)) unless logged_in?\n end", "def authorize\n unless User.find_by_id(session[:user_id])\n flash[:notice] = \"Please log in to access this page\"\n session[:return_to] = request.fullpath\n logger.info \"request refer #{request.fullpath}\"\n redirect_to :controller => \"auth\", :action => \"login\"\n end\n end", "def authorize\n if !(AUTHENTICATOR.authorized?(@session['logged_in'], @session['username'], \n controller_name, action_name, @params[:id]))\n @session['return_to'] = @request.request_uri\n redirect_to :action => 'login'\n return false\n end\n end", "def login_required\n redirect_to login_path unless logged_in?\n end", "def authorize\n @logged_in_user = User.find(session[:user_id])\n rescue\n reset_session\n @logged_in_user = nil\n if User.find(:all).length > 0\n session[:jumpto] = request.parameters\n redirect_to :controller => 'authentication', :action => 'login' and return false\n else\n redirect_to :controller => 'authentication', :action => 'create_admin' and return false\n end\n end", "def require_login\n not_authorized(\"Please sign up or log in above to access this resource.\") unless current_user\n end", "def authorize\n if current_user.nil?\n redirect_to login_path, alert: 'You must be logged in to access this page.'\n end\n end", "def authorize \n user = User.find_by_id(session[:user_id]) \n unless user\n redirect_to login_url, :notice => \"Please log in\"\n end\n end", "def authorize\n @logged_in_user = User.find(session[:user_id])\n rescue\n reset_session\n @logged_in_user = nil\n if User.find(:all).length > 0\n session[:jumpto] = request.parameters\n redirect_to :controller => 'authentication', :action => :login and return false\n else\n redirect_to :controller => 'authentication', :action => :setup and return false\n end\n end", "def authorize\n redirect_to login_url, alert: \"Not authorized\" if current_user.nil?\n end", "def authorize\n redirect_to login_url, alert: \"Not authorized\" if current_user.nil?\n end", "def authorize\n redirect_to login_url, alert: \"Not authorized\" if current_user.nil?\n end", "def check_login\n unless logged_in?\n access_denied\n end\n end", "def require_login\n redirect_to root_path unless logged_in?\n end", "def require_login\n redirect_to root_path unless logged_in?\n end" ]
[ "0.80613875", "0.8022933", "0.7410015", "0.73734117", "0.71964866", "0.7189605", "0.71817356", "0.71453536", "0.71453536", "0.71453536", "0.71453536", "0.71453536", "0.71453536", "0.71453536", "0.71453536", "0.7138094", "0.71061844", "0.7104487", "0.7101725", "0.7094153", "0.7070869", "0.7070088", "0.7066115", "0.702746", "0.70091987", "0.7008276", "0.70033693", "0.69798064", "0.69699293", "0.6967799", "0.69555074", "0.6931365", "0.6908665", "0.6881047", "0.68798053", "0.68646044", "0.6849796", "0.68419755", "0.6837047", "0.68159026", "0.68098474", "0.6797399", "0.67928684", "0.678451", "0.6748444", "0.67409", "0.67407376", "0.6739416", "0.6739274", "0.6732535", "0.6730815", "0.67302924", "0.6726855", "0.6720748", "0.6720251", "0.6719624", "0.67166305", "0.6715613", "0.671312", "0.671312", "0.671312", "0.6709496", "0.66925406", "0.66893613", "0.66888607", "0.6686946", "0.6683014", "0.6682059", "0.6681927", "0.6680448", "0.6679479", "0.6675782", "0.6674062", "0.66631466", "0.6646333", "0.66440856", "0.6643851", "0.66425186", "0.6632853", "0.66260624", "0.6622109", "0.6620132", "0.6620071", "0.6609984", "0.6609154", "0.66062766", "0.66054755", "0.66007733", "0.65913296", "0.65792197", "0.6578376", "0.65757614", "0.65720934", "0.6570284", "0.65692437", "0.65650016", "0.65650016", "0.65650016", "0.6564928", "0.6561803", "0.6561803" ]
0.0
-1
Predicate method to test for a logged in user
def logged_in? current_user.is_a? Person end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logged_in_normal_user?\n normal_user.present?\n end", "def current_user?(user)\n logged_in? and user == current_user\n end", "def authorized?(tmp_user)\n user == tmp_user\n end", "def logged_in_user?(&block)\n if @user\n concat(capture(&block))\n end\n end", "def authorized?(user_id)\n logged_in_user_id == user_id\n end", "def logged_in?\n if @user and @user.respond_to?(:role_id)\n @user\n else\n false\n end\n end", "def user_logged_in?\n session[:user]\n end", "def authorized?(user)\n current_user == user\nend", "def logged_in\n logged_in_user != nil\n end", "def logged_in?()\n if session[:user_id]\n return true\n else \n return false\n end\n end", "def user_logged_in?\n session[:user_id].present?\n end", "def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end", "def logged_in?\n !real_user.nil?\n end", "def current_user?(user)\r\n user == current_user\r\n end", "def is_user?\n user ? true : false\n end", "def user_logged_in?\n current_user.present?\n end", "def user_logged_in?\n current_user.present?\n end", "def logged_in?(user)\n Home.new.signed_in_user == user.email_address\n end", "def current_user?(user) \n user == current_user\n end", "def logged_in?\n session[:user]\n end", "def logged_in?\n return false unless session[:user_id]\n\n User.find_by_id(session[:user_id]).present?\n end", "def logged_in?\n current_user\n end", "def user_authorized?(user)\n user == current_user || is_admin?\n end", "def logged_in?\n current_user\n end", "def logged_in?\n current_user\n end", "def logged_in?\n current_user\n end", "def logged_in?\n current_user\n end", "def logged_in?\n current_user\n end", "def logged_in?\n if current_user\n true\n else \n false\n end\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def logged_in?\n return true if self.current_user\n return false\n end" ]
[ "0.747978", "0.7396226", "0.7389217", "0.7363599", "0.72975105", "0.72852147", "0.72606385", "0.72524583", "0.7237893", "0.72176665", "0.71965015", "0.7189546", "0.718382", "0.71730316", "0.71595126", "0.71503377", "0.71503377", "0.71487397", "0.7146684", "0.71454656", "0.71440744", "0.7141246", "0.7131473", "0.7129049", "0.7129049", "0.7129049", "0.7129049", "0.7129049", "0.7125044", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.71162087", "0.7116098", "0.7114855" ]
0.0
-1
You may assume that both input Arrays are nonempty and that they have the same number of elements INPUT two arrays OUTPUT single array RULES return single array containing all elements from both input arrays take an element from each array in alternation ALGORITHM create new array add element from arr1 into new array add element from arr2 into new array repeat until all elements from input arrays are present in new array START SET inter_arr = [] SET idx = 0 UNTIL idx == length of second input array inter_arr << element from arr1 at idx position inter_arr << element from arr2 at idx position increment idx by 1 RETURN inter_arr
def interleave(arr1, arr2) inter_arr = [] idx = 0 loop do inter_arr << arr1[idx] inter_arr << arr2[idx] idx += 1 break if idx >= arr2.length end inter_arr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def interleave(arr_1, arr_2)\n current_index = 0\n combined_arr = []\n while current_index < arr_1.size\n combined_arr.push(arr_1[current_index])\n combined_arr.push(arr_2[current_index])\n current_index += 1\n end\n \n combined_arr\nend", "def interleave(arr1, arr2)\n\tnew_arr = []\n\tcounter = 0\n\tloop do\n\t\tbreak if counter == arr1.size \n\t\tnew_arr << arr1[counter]\n\t\tnew_arr << arr2[counter]\n\t\tcounter += 1\n\tend\t\n\tnew_arr\nend", "def interleave(array_1, array_2)\n new_array = []\n total_elements = array_1.length + array_2.length\n array_1_current_idx, array_2_current_idx = 0 , 0\n\n total_elements.times do |current_iteration|\n if current_iteration.odd?\n new_array.push(array_2[array_2_current_idx])\n array_2_current_idx += 1\n else\n new_array.push(array_1[array_1_current_idx])\n array_1_current_idx += 1\n end\n end\n\n new_array\nend", "def interleave(array1, array2)\n combo_size = array1.size + array2.size\n combo_array = []\n index = 0\n \n until combo_array.size == combo_size\n combo_array << array1[index] << array2[index]\n index += 1\n end\n \n combo_array\nend", "def interleave(arr1, arr2)\n new_array = []\n for i in 1..(arr1.size)\n new_array << arr1[(i-1)]\n new_array << arr2[(i-1)]\n end\n new_array\nend", "def interleave(array1, array2)\n results_array = []\n counter = 0 \n loop do \n results_array << array1[counter]\n results_array << array2[counter]\n counter += 1 \n break if counter >= array1.size\n end \n \n results_array\nend", "def interleave(arr1, arr2)\n output_arr = []\n arr1.size.times do |idx|\n output_arr << arr1[idx]\n output_arr << arr2[idx]\n end\n output_arr\nend", "def interleave(arr1, arr2)\n index = 0\n output = []\n loop do |num|\n output << arr1[index] \n output << arr2[index]\n index += 1\n break if index == arr1.size\n end\n output\nend", "def interleave(arr1, arr2)\n index = 0\n results = []\n arr1.size.times do\n results << arr1[index] << arr2[index]\n index += 1\n end\n results\nend", "def interleave ( arr1 , arr2 )\n\tc = []\n\tif arr1.length > arr2.length \n\t\ta=arr1\n\t\tb=arr2\n\telse\n \t\ta=arr2\n \t\tb=arr1\n\tend\n\tc = a.slice(b.length..a.length-1)\n\treturn b.zip(a).flatten(1).slice!(0..b.length*2 -1) + c\nend", "def interleave(a1, a2)\n # new_array = []\n # index = 0\n # while index < a1.size\n # new_array.push(a1[index])\n # new_array.push(a2[index])\n # index += 1\n # end\n # new_array\n # LS solution\n # result = []\n # array1.each_with_index do |element, index|\n # result << element << array2[index]\n # end\n # result\n a1.zip(a2).flatten\nend", "def interleave(arr1, arr2)\n counter = 0\n new_arr = []\n while counter < arr1.size\n new_arr << arr1[counter]\n new_arr << arr2[counter]\n counter += 1\n end\n\n new_arr\nend", "def interleave(arr1, arr2)\n return_array = []\n arr1.each_with_index do |element, index|\n return_array << element << arr2[index]\n end\nend", "def interleave(array_1, array_2)\n results_array = []\n array_1.each_with_index do |elem, index|\n results_array << elem << array_2[index]\n end\n results_array\nend", "def interleave(array1, array2)\n return_array = []\n\n until array2.empty?\n return_array << array1.shift(1)\n return_array << array2.shift(1)\n end\n return_array.flatten\nend", "def interleave(arr1, arr2)\n new_arr = []\n arr1.size.times{ |idx| new_arr << arr1[idx] << arr2[idx] }\n new_arr\nend", "def interleave(arr1, arr2)\n idx = 0\n combined = []\n arr1.size.times do\n combined << arr1[idx] << arr2[idx]\n idx += 1\n end\n combined\nend", "def interleave(arr1, arr2)\r\n combined_arr = []\r\n counter = 0\r\n arr1.size.times do\r\n combined_arr << arr1[counter]\r\n combined_arr << arr2[counter]\r\n counter += 1\r\n end\r\n combined_arr\r\nend", "def interleave(arr1, arr2)\n new_arr = []\n arr1.each_with_index do |element, index|\n new_arr << arr1[index]\n new_arr << arr2[index]\n end\n new_arr\nend", "def interleave(array_1, array_2)\n interwoven_array = []\n\n array_1.each_with_index do |element, index|\n interwoven_array << element << array_2[index]\n end\n\n interwoven_array\nend", "def interleave(arr1, arr2)\n return_array = []\n counter = 1\n until arr2.empty?\n if counter.odd?\n return_array << arr1.shift\n counter += 1\n else\n return_array << arr2.shift\n counter += 1\n end\n end\n return_array\nend", "def interleave(arr1, arr2)\n # new_arr = []\n # arr1.size.times do |count|\n # new_arr << arr1[count] << arr2[count]\n # end\n # new_arr\n\n # using Array#zip and Array#flatten\n arr1.zip(arr2).flatten\nend", "def interleave(array1, array2)\n result = []\n array1.size.times do |index|\n result << array1[index] << array2[index]\n end\n result \nend", "def interleave(arr1, arr2)\n return_array = arr1.zip(arr2).flatten\nend", "def interleave(arr1, arr2)\n new_arr = []\n arr1.each_with_index do |_, index|\n new_arr << arr1[index]\n new_arr << arr2[index]\n end\n new_arr\nend", "def interleave(arr1, arr2)\n results = []\n arr1.each.with_index do |el,idx|\n results << el << arr2[idx]\n end\n results\nend", "def interleave(array_1, array_2)\n result = []\n # https://ruby-doc.com/core-2.7.2/Enumerator.html#method-i-each_with_index\n array_1.each_with_index do |element, index|\n result << element << array_2[index]\n end\n result\nend", "def interleave(array1, array2)\n new = []\n size = array1.size\n size.times do |x|\n new.push(array1[x], array2[x])\n end\n new\nend", "def interleave2(arr1, arr2)\n arr1.zip(arr2).flatten\nend", "def interleave(arr1, arr2)\n combined = []\n\n arr1.each_with_index do |item, index|\n combined.push(arr1[index])\n combined.push(arr2[index])\n end\n\n combined\nend", "def interleave(arr1, arr2)\n arr3 = []\n arr1.each_with_index do |element, idx|\n arr3 << element << arr2[idx]\n end\n arr3\nend", "def interleave(arr1, arr2)\n interleaved = []\n\n i = 0\n loop do\n interleaved << arr1[i] << arr2[i]\n i += 1\n break if i >= arr1.size\n end\n\n interleaved\nend", "def interleave2(array1, array2)\n array1.zip(array2).flatten\nend", "def interleave(arr1, arr2)\n result = []\n arr1.each_with_index do |elem, indx|\n result << elem << arr2[indx]\n end\n result\nend", "def merge_arrays(arr_one, arr_two)\n ret = []\n while arr_one.length > 0 || arr_two.length > 0\n if arr_one[0] < arr_two[0]\n ret << arr_one.shift\n elsif arr_two[0] < arr_one[0]\n ret << arr_two.shift\n elsif arr_two.empty?\n ret += arr_one\n elsif arr_one.empty?\n ret += arr_two\n else\n ret\n end\n end\n ret\nend", "def interleave(array1, array2)\n new_array = []\n if array1.size != array2.size\n puts \"Arrays are different size\"\n else\n array1.each_with_index do |v, i|\n new_array << v \n new_array << array2[i]\n end\n end\n new_array\nend", "def interleave(arr_1, arr_2)\n arr_1.zip(arr_2).flatten\nend", "def interleave(arr1, arr2)\n count = arr1.size\n interleaved = []\n count.times do\n interleaved << arr1.shift\n interleaved << arr2.shift\n end\n interleaved\nend", "def interleave(ary1, ary2)\n new_ary = []\n ary1.size == ary2.size ? elements = 3 : elements = 0\n count = 0\n elements.times do\n new_ary << ary1[count]\n new_ary << ary2[count]\n count += 1\n end\n elements != 0 ? new_ary : nil\nend", "def interleave(array1, array2)\n new_array = []\n array1.each_with_index do |element, index|\n new_array << element << array2[index]\n end\n new_array\nend", "def interleave(array1, array2)\n result = []\n array1.each_with_index do |element, index|\n result << element << array2[index]\n end\n result\nend", "def interleave(array1, array2)\n result = []\n array1.each_with_index do |element, index|\n result << element << array2[index]\n end\n result\nend", "def merge arr1, arr2\n\toutput = []\n\ti1 = 0\n\ti2 = 0\n\twhile arr1[i1] && arr2[i2]\n\t\tif arr1[i1] <= arr2[i2]\n\t\t\toutput.push arr1[i1]\n\t\t\ti1 += 1\n\t\telse \n\t\t\toutput.push arr2[i2]\n\t\t\ti2 += 1\n\t\tend\n\tend\n\n\t# output.concat arr1.slice(i1..-1) if arr1[i1]\n\t# ^ same answer as while loop below but creates a new array with slice\n\twhile arr1[i1]\n\t\toutput.push arr1[i1]\n\t\ti1 += 1\n\tend \n\n\t# output.concat arr2.slice(i2..-1) if arr2[i2]\n\t# ^ same answer as while loop below but creates a new array with slice\n\twhile arr2[i2]\n\t\toutput.push arr2[i2]\n\t\ti2 += 1\n\tend \n\toutput\nend", "def interleave(array1, array2)\n counter = 1\n index = 0\n loop do\n array1.insert(counter, array2[index])\n counter += 2\n index += 1\n break if index >= array2.size\n end\n array1\nend", "def interleave a,b\n arr1 = []\n for i in (0...a.size)\n arr1 << a[i] << b[i]\n end\n arr1\nend", "def intersection2(arr1, arr2)\n arr1, arr2, idx1, idx2 = arr1.sort, arr2.sort, 0, 0\n\n intersection = []\n while idx1 < arr1.length && idx2 < arr2.length\n case arr1[idx1] <=> arr2[idx2]\n when -1\n idx1 += 1\n when 0\n intersection << arr1[idx1]\n idx1 += 1\n idx2 += 1\n when 1\n idx2 += 1\n end\n end\n intersection\nend", "def interleave(array1, array2)\n result = []\n array1.each_with_index do |value, index|\n result << value << array2[index]\n end\n result\nend", "def interleave(array1, array2)\n result = []\n array1.each_index { |i| result << [array1[i], array2[i]] }\n result.flatten\nend", "def interleave(arr1, arr2)\n results = []\n\n arr1.each_with_index do |el, i|\n results << el << arr2[i]\n # results << el << arr2[arr1.index(el)] ## if you wanted to do it without index as block param\n end\n\n results\nend", "def interleaver(arr1, arr2)\n arr1.map.with_index { |el, idx| [el, arr2[idx]] }.flatten\nend", "def interleave(arr1, arr2)\n arr1.zip(arr2).flatten\nend", "def interleave(arr1, arr2)\n arr1.zip(arr2).flatten\nend", "def interleave(arr1, arr2)\n arr1.zip(arr2).flatten\nend", "def interleave(arr1, arr2)\n arr1.zip(arr2).flatten\nend", "def interleave(arr1, arr2)\n arr1.zip(arr2).flatten\nend", "def interleave(arr1, arr2)\n arr1.zip(arr2).flatten\nend", "def merge(array_1, array_2)\r\n new_array = []\r\n array_1_pointer = 0\r\n array_2_pointer = 0\r\n\r\n # Run the loop until we've reached end of both arrays:\r\n while array_1_pointer < array_1.length || \r\n array_2_pointer < array_2.length\r\n\r\n # If we already reached the end of the first array,\r\n # add item from second array:\r\n if !array_1[array_1_pointer]\r\n new_array << array_2[array_2_pointer]\r\n array_2_pointer += 1\r\n # If we already reached the end of the second array,\r\n # add item from first array:\r\n elsif !array_2[array_2_pointer]\r\n new_array << array_1[array_1_pointer]\r\n array_1_pointer += 1\r\n # If the current number in first array is less than current\r\n # number in second array, add from first array:\r\n elsif array_1[array_1_pointer] < array_2[array_2_pointer]\r\n new_array << array_1[array_1_pointer]\r\n array_1_pointer += 1\r\n # If the current number in second array is less than or equal\r\n # to current number in first array, add from second array:\r\n else\r\n new_array << array_2[array_2_pointer]\r\n array_2_pointer += 1\r\n end\r\n end\r\n\r\n return new_array\r\nend", "def weave_array(array1, array2)\n result = []\n idx1 = 0\n idx2 = 1\n while #some condition\n temp_array = []\n while idx1 < array1.length && idx2 < array2.length\n if\n temp_array.push(array1[idx1])\n idx1 += 1\n end\n if\n temp_array.push(array2[idx2])\n idx2 += 1\n end\n end\n while idx1 < array1.length\n temp_array.push(array1[idx1])\n idx1 += 1\n end\n while idx2 < array2.length\n temp_array.push(array1[idx2])\n idx2 += 1\n end\n result.push(temp_array)\n end\n result\nend", "def merge(array1, array2)\n composite_array = []\n index1 = 0\n index2 = 0\n \n loop do\n if index1 == array1.size\n index2.upto(array2.size - 1) { |index| composite_array << array2[index] }\n break\n elsif index2 == array2.size\n index1.upto(array1.size - 1) { |index| composite_array << array1[index] }\n break\n end\n \n first_item = array1[index1]\n second_item = array2[index2]\n if first_item <= second_item\n composite_array << first_item\n index1 += 1\n else\n composite_array << second_item\n index2 += 1\n end\n end\n \n composite_array\nend", "def interleave(arr1,arr2)\n arr1.zip(arr2).flatten\nend", "def zip(arr1, arr2)\n result = []\n idx = 0\n loop do\n result << [arr1[idx], arr2[idx]]\n idx += 1\n break if idx == arr1.size\n end\n result\nend", "def merge(arr1, arr2)\n new_arr = []\n i1=0\n i2=0\n while i1 < arr1.length\n if i2 == arr2.length\n new_arr.concat(arr1[i1..-1])\n break\n elsif (arr1[i1] < arr2[i2])\n new_arr << arr1[i1]\n i1 += 1\n else\n new_arr << arr2[i2]\n i2 += 1\n end\n end\n if i2 != arr2.length\n (i2...arr2.length).each { |idx2| new_arr << arr2[idx2] }\n end\n return new_arr\n end", "def merge(array1, array2)\n merged = []\n\n iterator1 = EnumeratorAdaptor.new(array1.to_enum)\n iterator2 = EnumeratorAdaptor.new(array2.to_enum)\n\n while (iterator1.has_next? and iterator2.has_next?)\n if iterator1.item < iterator2.item\n merged << iterator1.next_item\n else\n merged << iterator2.next_item\n end\n end\n\n # Pick up the leftovers from array1\n while (iterator1.has_next?)\n merged << iterator1.next_item\n end\n\n # Pick up the leftovers from array2\n while (iterator2.has_next?)\n merged << iterator2.next_item\n end\n\n merged\nend", "def merge(arr1, arr2)\n counter1, counter2 = 0, 0\n return_arr = []\n \n until counter1 >= arr1.size && counter2 >= arr2.size\n break if arr2[counter2] == nil || arr1[counter1] == nil\n\n if arr1[counter1] == nil || arr1[counter1] >= arr2[counter2]\n return_arr << arr2[counter2]\n counter2 += 1\n else\n return_arr << arr1[counter1]\n counter1 += 1\n end\n end\n return_arr + (arr1[counter1].nil? ? arr2[counter2..-1] : arr1[counter1..-1])\nend", "def interleave(array1, array2)\n array1.zip(array2).flatten\nend", "def interleave(array1, array2)\n array1.zip(array2).flatten\nend", "def interleave(array1, array2)\n array1.zip(array2).flatten\nend", "def merge(arr1, arr2)\n arr1 = arr1.dup\n arr2 = arr2.dup # duplicate to prevent mutation of original array\n result = []\n until arr1.empty? && arr2.empty?\n if arr1.empty?\n result << arr2.shift\n elsif arr2.empty?\n result << arr1.shift\n else\n if arr1[0] <arr2[0]\n result << arr1.shift\n else\n result << arr2.shift\n end\n end\n end\n result\nend", "def process_2arrays(array_1, array_2)\n shared = array_1 & array_2\n shared_count = shared.count\n\n array_1_unshared = array_1 - shared\n array_2_unshared = array_2 - shared\n\n count_1 = array_1_unshared.count\n count_2 = array_2_unshared.count\n unshared = array_1_unshared + array_2_unshared\n unshared_count = unshared.count\n\n [].push(shared_count, unshared_count, count_1, count_2)\nend", "def merge(array1, array2)\n merged = []\n\n iterator1 = ArrayIterator.new(array1)\n iterator2 = ArrayIterator.new(array2)\n\n while (iterator1.has_next? and iterator2.has_next?)\n if iterator1.item < iterator2.item\n merged << iterator1.next_item\n else\n merged << iterator2.next_item\n end\n end\n\n # Pick up the leftovers from array1\n while (iterator1.has_next?)\n merged << iterator1.next_item\n end\n\n # Pick up the leftovers from array2\n while (iterator2.has_next?)\n merged << iterator2.next_item\n end\n\n merged\nend", "def merge(array1, array2)\n ptr1 = 0\n ptr2 = 0\n high1 = array1.length - 1 \n high2 = array2.length - 1 \n array_final = []\n while (ptr1 <= high1) && (ptr2 <= high2) do\n if (array1[ptr1] < array2[ptr2])\n array_final << array1[ptr1]\n ptr1 += 1\n else\n array_final << array2[ptr2]\n ptr2 += 1\n end\n end\n if ptr1 <= high1\n while (ptr1 <= high1) do\n array_final << array1[ptr1]\n ptr1 += 1\n end\n elsif ptr2 <= high2\n while (ptr2 <= high2) do\n array_final << array2[ptr2]\n ptr2 += 1\n end\n end\n return array_final\nend", "def interleave(first, second)\n new_array = []\n\n first.each_with_index do |element, index|\n new_array << element\n new_array << second[index]\n end\n\n new_array\nend", "def merge(arr1, arr2=[])\n ind1 = ind2 = 0\n new_arr = []\n\n loop do\n break if arr1 == [] || arr2 == []\n if arr1[ind1] > arr2[ind2]\n new_arr << arr2[ind2]\n ind2 += 1\n else\n new_arr << arr1[ind1]\n ind1 += 1\n end\n break if ind1 >= arr1.size || ind2 >= arr2.size\n end\n\n if ind1 == arr1.size\n temp = arr2[ind2..-1]\n else\n temp = arr1[ind1..-1]\n end\n\n temp.each {|element| new_arr << element}\n\n new_arr\nend", "def merge(arr1, arr2)\n result = []\n arr1.each {|i| result << i if !result.include?(i)}\n arr2.each {|i| result << i if !result.include?(i)}\n result\nend", "def combine_arrays(arr1, arr2)\n\tcombo = arr1 + arr2\n\tswapped = true\n\n\twhile swapped\n\t\tswapped = false\n\t\t(combo.length-1).times do |i|\n\t\t\tif combo[i] > combo[i+1]\n\t\t\t\tcombo[i], combo[i+1] = combo[i+1], combo[i]\n\t\t\t\tswapped= true\n\t\t\tend\n\t\tend\n\tend\n\tcombo\nend", "def zip(arr_1, arr_2)\n new_arr = []\n arr_1.size.times do |i|\n new_arr << [arr_1[i], arr_2[i]]\n end\n new_arr\nend", "def merge(ary1, ary2)\n merged = []\n i1 = 0\n i2 = 0\n until i1 >= ary1.size && i2 >= ary2.size\n case ary1[i1] <=> ary2[i2]\n when -1\n merged << ary1[i1]\n i1 += 1\n when 1\n merged << ary2[i2]\n i2 += 1\n else\n new_ary << ary1[i1]\n new_ary << ary2[i2]\n i1 += 1\n i2 += 1\n end\n end\n merged.compact\nend", "def interzip(array1, array2)\n array1.zip(array2).flatten\nend", "def merge1(array1, array2)\r\n index2 = 0\r\n result = []\r\n\r\n array1.each do |value|\r\n while index2 < array2.size && array2[index2] <= value\r\n result << array2[index2]\r\n index2 += 1\r\n end\r\n result << value\r\n end\r\n\r\n result.concat(array2[index2..-1])\r\nend", "def join_arrays array_one, array_two\n\t\tarray_one.shift\n\t\tarray_two.pop\n\t\tarray_one & array_two\n\tend", "def interleave(array1, array2)\n p array1.zip(array2).flatten\nend", "def combine_two_lists(array1, array2)\n combined_array = []\n index = 0\n\n loop do\n combined_array << array1[index]\n combined_array << array2[index]\n index += 1\n break if index == array1.size\n \n end\n combined_array\nend", "def merge(arr1, arr2)\n new_arr = []\n while arr1.size > 0 && arr2.size > 0\n compare = arr1[0] <= arr2[0]\n if compare\n new_arr << arr1.shift\n else\n new_arr << arr2.shift\n end\n end\n new_arr + arr1 + arr2\nend", "def merge(array1, array2)\n merged = []\n\n iterator1 = ArrayIterator.new(array1)\n iterator2 = ArrayIterator.new(array2)\n\n while iterator1.has_next? && iterator2.has_next?\n if iterator1.item < iterator2.item\n merged << iterator1.next_item\n else\n merged << iterator2.next_item\n end\n end\n\n while iterator1.has_next?\n merged << iterator1.next_item\n end\n\n while iterator2.has_next?\n merged << iterator2.next_item\n end\n\n merged\nend", "def array_concat(array_1, array_2)\n\n\n newArray = Array.new\n counter = 0\n\n (array_1.length).times do |x|\n newArray[counter] = array_1[x]\n counter = counter + 1\n end\n\n (array_2.length).times do |y|\n newArray[counter] = array_2[y]\n counter = counter + 1\n end\n\n newArray\nend", "def merge(arr1, arr2)\n\tmerged_arr = []\n\tuntil arr1.empty? or arr2.empty?\n\t\tif arr1.first <= arr2.first\n\t\t\tmerged_arr << arr1.shift\n\t\telse\n\t\t\tmerged_arr << arr2.shift\n\t\tend\n\tend\n\treturn merged_arr.concat(arr1).concat(arr2)\nend", "def interleave(ary1, ary2)\n ary = []\n ary1.size == ary2.size ? ary.push(ary1.shift) : ary.push(ary2.shift) until ary2.empty?\n ary\nend", "def merge(arr1, arr2)\n result, idx1, idx2 = [], 0, 0\n until arr1[idx1] == nil || arr2[idx2] == nil\n if arr1[idx1] > arr2[idx2]\n result << arr2[idx2]\n idx2 += 1\n else\n result << arr1[idx1]\n idx1 += 1\n end\n end\n arr2[idx2] == nil ? result << arr1[idx1..-1] : result << arr2[idx2..-1] \n result.flatten\nend", "def merge(first_arr, second_arr)\n return_arr = []\n\n loop do\n break if first_arr.empty? || second_arr.empty?\n if first_arr[0] <= second_arr[0]\n return_arr << first_arr.shift\n else\n return_arr << second_arr.shift\n end\n end\n\n loop do\n break if first_arr.empty? && second_arr.empty?\n if first_arr.empty?\n return_arr << second_arr.shift\n else\n return_arr << first_arr.shift\n end \n end\n\n return_arr\nend", "def merge_sorted_arrays2(arr1, arr2)\n arr1_item = arr1[0]\n arr2_item = arr2[0]\n merged = []\n i = 1\n j = 1\n\n while arr1_item || arr2_item\n if !arr2_item || arr1_item < arr2_item\n merged << arr1_item\n arr1_item = arr1[i]\n i +=1\n else\n merged << arr2_item\n arr2_item = arr2[j]\n j +=1\n end\n end\n merged\nend", "def merge(array_a, array_b)\n a_index = 0\n b_index = 0\n result = []\n\n while a_index < array_a.size && b_index < array_b.size do\n if array_a[a_index] > array_b[b_index]\n result << array_b[b_index]\n b_index += 1\n else\n result << array_a[a_index]\n a_index += 1\n end\n end\n\n (a_index...array_a.size).each { |index| result << array_a[index] }\n (b_index...array_b.size).each { |index| result << array_b[index] }\n\n return result\nend", "def intersection(array1, array2)\n if array1 == nil || array2 == nil\n return []\n end\n\n result_array = []\n i = 0\n\n until i == array1.length\n temp = array1[i]\n j = 0\n until j == array2.length\n if temp == array2[j]\n result_array << temp\n end\n j += 1\n end\n i += 1\n end\n return result_array\nend", "def array_concat(array_1, array_2)\n\tnew_array = []\n\ti = 0\n\twhile i < array_1.length\n\t\tnew_array[i] = array_1[i]\n\t\ti += 1\n\tend\n\tj = 0\n\twhile j < array_2.length\n\t\tnew_array[i+j] = array_2[j]\n\t\tj += 1\n\tend\n\treturn new_array\nend", "def intersection(arr1, arr2)\n arr1 = arr1.sort\n arr2 = arr2.sort\n idx1, idx2 = 0,0\n i = []\n while(idx1 < arr1.length && idx2 < arr2.length)\n case(arr1[idx1] <=> arr2[idx2])\n when 0\n i << arr1[idx1]\n idx1 += 1\n idx2 += 1\n when 1\n idx2 += 1\n when -1\n idx1 += 1\n end\n end\n i\nend", "def custom_zip(arr1, arr2)\n new_nested = []\n arr1.each_with_index do | arr1_value, arr1_index |\n arr2.each_with_index do | arr2_value, arr2_index |\n if arr1_index == arr2_index\n arr3 = [arr1[arr1_index], arr2[arr2_index]]\n new_nested << arr3\n end # end of if\n end # end of do (array 2)\n end # end of do (array 1)\n new_nested\nend", "def merge(arr1, arr2)\n merged = []\n\n until arr1.empty? || arr2.empty?\n if arr1.first < arr2.first\n merged << arr1.shift\n else\n merged << arr2.shift\n end\n end\n\n merged + arr1 + arr2\nend", "def combine_arrays(nums, other_nums)\n \n return nums if other_nums.empty? # not necessary, but good to have\n return other_nums if nums.empty? # not necessary, but good to have\n \n res= []\n \n i, j = 0, 0\n \n while i < nums.length && j < other_nums.length\n a, b = nums[i], other_nums[j]\n \n if a <= b\n res << a\n i+= 1\n else\n res << b\n j+= 1\n end\n end\n \n if j == other_nums.length\n # other_nums was exhausted, but there still remain\n # elements in nums to process\n res.push( *nums[i..-1] )\n elsif i == nums.length\n # nums was exhausted, but there still remain\n # elements in nums to process\n res.push( *other_nums[j..-1] )\n end\n \n res\nend", "def merge(arr1, arr2)\n result = []\n ptr1, ptr2 = 0, 0\n until ptr1 == arr1.length or ptr2 == arr2.length\n if arr1[ptr1] <= arr2[ptr2]\n result << arr1[ptr1]\n ptr1 += 1\n else\n result << arr2[ptr2]\n ptr2 += 1\n end\n end\n\n result = result + arr1[ptr1...arr1.length] + arr2[ptr2...arr2.length]\nend", "def merge(arr_1, arr_2) # works because arr_1 and arr_2 are always sorted\n array = []\n while !arr_1.empty? && !arr_2.empty?\n if arr_1.first <= arr_2.first\n array << arr_1.shift\n else\n array << arr_2.shift\n end\n end\n array += arr_1 + arr_2\nend", "def zip(arr1, arr2)\n Array.new(arr1.size) do |idx|\n [arr1[idx], arr2[idx]]\n end\nend" ]
[ "0.7675738", "0.76539326", "0.76421326", "0.76369315", "0.7629027", "0.75723356", "0.75221044", "0.7520065", "0.75028795", "0.7494494", "0.7492797", "0.7488164", "0.7457966", "0.744886", "0.74477226", "0.74350184", "0.74272233", "0.7403209", "0.7375804", "0.7373888", "0.7364525", "0.736058", "0.735701", "0.7352433", "0.7351946", "0.7343928", "0.732241", "0.72971165", "0.7291855", "0.7284558", "0.7269112", "0.72691095", "0.7257364", "0.72457284", "0.7241749", "0.72342205", "0.72305626", "0.7225006", "0.7220547", "0.7205926", "0.7184644", "0.7184644", "0.71741027", "0.71721053", "0.71673167", "0.71386635", "0.713256", "0.7122942", "0.7116064", "0.70850503", "0.7067286", "0.7067286", "0.7067286", "0.7067286", "0.7067286", "0.7067286", "0.70608974", "0.70605385", "0.704816", "0.70480895", "0.70416844", "0.7027433", "0.70208263", "0.7000635", "0.699545", "0.699545", "0.699545", "0.69917357", "0.6988979", "0.6973092", "0.6972125", "0.6967965", "0.69635016", "0.6954119", "0.6938834", "0.6926005", "0.69082063", "0.6895742", "0.6883298", "0.68827885", "0.68797535", "0.68720967", "0.6870384", "0.68622786", "0.6857286", "0.6851029", "0.68491715", "0.6844909", "0.6843285", "0.68426025", "0.6831126", "0.68282014", "0.67998147", "0.67987204", "0.6798083", "0.6787026", "0.67815626", "0.6779202", "0.6774565", "0.6772336" ]
0.75527716
6
GET /quartiers/1 GET /quartiers/1.json
def show @quartier = Quartier.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @quartier } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getQuartier\r\n \tarrondissement = params[:id]\r\n \trender json: Quartier.where(arrondissement_id: arrondissement)\r\n end", "def show\n @quiniela = Quiniela.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quiniela }\n end\n end", "def show\n @quartet = Quartet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quartet }\n end\n end", "def show\n @qu = Qu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @qu }\n end\n end", "def show\n @qu = Qu.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @qu }\n end\n end", "def show\n @quarter = Quarter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quarter }\n end\n end", "def show\n @quize = Quize.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quize }\n end\n end", "def index\n @qus = Qu.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @qus }\n end\n end", "def show\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end", "def new\n @quartier = Quartier.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quartier }\n end\n end", "def index\n quizzes = Quiz.all\n render json: quizzes, except: [:updated_at, :created_at]\n end", "def show\n @uchronia = Uchronia.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @uchronia }\n end\n end", "def index\n @quizzes = Quiz.all \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @quizzes }\n end\n end", "def show\n @quest = Quest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quest }\n end\n end", "def index\n @quadernis = Quaderni.all\n end", "def show\n @quetion = Quetion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quetion }\n end\n end", "def show\n @cheque = Cheque.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cheque }\n end\n end", "def show\n @quip = Quip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quip }\n end\n end", "def show\n @konyu_rireki = KonyuRireki.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @konyu_rireki }\n end\n end", "def instructor_index\n\t\t\tquizzes = current_instructor.quizzes\n\t\t\trender json: quizzes.as_json(:only => [:id, :name, :created_at, :no_of_MCQ, :no_of_rearrangeQ]), status: 200\n\t\tend", "def index\n @quartets = Quartet.all\n end", "def index\n logement = Logement.find_by(id:params[:logement_id])\n equipement = logement.equi_securites[0].title\n equipements = logement.equi_securites[0]\n\n render json: {\n securites:equipement,\n fichier:equipements\n }\n end", "def show\n @estoque = Estoque.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @estoque }\n end\n end", "def get_one\n question_data = Question.new.get_one( params[:id] )\n return render json: question_data\n end", "def index\n @recipies = Recipy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipies }\n end\n end", "def index\n @quantities = Quantity.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @quantities }\n end\n end", "def show\n @historial = Historial.find(params[:id])\n @receta = Recete.histori(@historial.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @historial }\n end\n end", "def new\n @quiniela = Quiniela.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quiniela }\n end\n end", "def show\n @qurriculum = Qurriculum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qurriculum }\n end\n end", "def index\n @uchronias = Uchronia.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @uchronias }\n end\n end", "def show\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @premio }\n end\n end", "def consulta\n fiesta = Fiesta.all\n render json: fiesta\n end", "def show\n @uchronist = Uchronist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @uchronist }\n end\n end", "def new\n @quartet = Quartet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quartet }\n end\n end", "def show\n @veiculo = Veiculo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @veiculo }\n end\n end", "def index\n @courts = Court.by_name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end", "def show\n @quiz = Quiz.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quiz }\n end\n end", "def show\n @giang_vien = GiangVien.find(params[:id])\n\n respond_to do |format| \n format.json { render json: @giang_vien }\n end\n end", "def show\n @qborentestimate = Qborentestimate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qborentestimate }\n end\n end", "def show\n @itineraire = Itineraire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @itineraire }\n end\n end", "def destroy\n @quartier = Quartier.find(params[:id])\n @quartier.destroy\n\n respond_to do |format|\n format.html { redirect_to quartiers_url }\n format.json { head :no_content }\n end\n end", "def show\n @territorio = Territorio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @territorio }\n end\n end", "def show\n @movimentacao_de_estoque = MovimentacaoDeEstoque.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movimentacao_de_estoque }\n end\n end", "def show\n @craque = Craque.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json \n end\n end", "def show\n @squish = Squish.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @squish }\n end\n end", "def show\n @lieu = Lieu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lieu }\n end\n end", "def show\n @seguro = Seguro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @seguro }\n end\n end", "def show\n @queencell = Queencell.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @queencell }\n end\n end", "def show\n @articulo = Articulo.find(params[:id])\n @noticias = Articulo.where(\"tipo = 'noticia'\").order(\"created_at desc\")\n @title = @articulo.titulo\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @articulo }\n end\n end", "def index\n @itineraires = Itineraire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @itineraires }\n end\n end", "def index\n @uchronists = Uchronist.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @uchronists }\n end\n end", "def index\n @qandas = Qanda.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @qandas }\n end\n end", "def index\n @ruas = Rua.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ruas }\n end\n end", "def show\n @recipy = Recipy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipy }\n end\n end", "def index\n @articulos = Articulo.where(\"tipo = 'articulo'\").order(\"created_at desc\") \n @noticias = Articulo.where(\"tipo = 'noticia' and mostrar_carrusel='1'\").order(\"created_at desc\").limit(3)\n @articulos = @articulos.page(params[:page]).per_page(5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @articulos }\n end\n end", "def show\r\n @equipe_type = EquipeType.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @equipe_type }\r\n end\r\n end", "def show\n @tupian = Tupian.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tupian }\n end\n end", "def show\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clue }\n end\n end", "def show\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clue }\n end\n end", "def index\n @q_resources = QResource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @q_resources }\n end\n end", "def get_all\n\t\trender json: {quests: Quest.all.as_json(include: :images)}\n\tend", "def show\n @rechnung = Rechnung.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rechnung }\n end\n end", "def show\n @leito = Leito.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leito }\n end\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 @guille = Guille.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @guille }\n end\n end", "def show\n @articulo = Articulo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @articulo }\n end\n end", "def show\n @articulo = Articulo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @articulo }\n end\n end", "def show\n @articulo = Articulo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @articulo }\n end\n end", "def show\n @minicurso = Minicurso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @minicurso }\n end\n end", "def show\n @requerimiento ||= Requerimiento.where(:numero => params[:id]).first\n @areas = Area.where(\" nombre like '%DIT%' \")\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @requerimiento }\n end\n end", "def show\n @quay = Quay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @quay }\n end\n end", "def index\n @quants = Quant.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @quants }\n end\n end", "def show\n @qanda = Qanda.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qanda }\n end\n end", "def index\n @specialties = Specialty.all\n\n render json: @specialties\n end", "def show\n @aquarium = Aquarium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @aquarium }\n end\n end", "def show\n @receipe = Receipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @receipe }\n end\n end", "def show\n \t\tquestion = Question.find(params[:id])\n \t\tputs \"QUESTION: #{question.name}\"\n \t\trender json: question\n \tend", "def query\n\n JSON.parse(Net::HTTP.get(self.build_uri))\n\n end", "def show\n @qqcar = Qqcar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qqcar }\n end\n end", "def show\n @guitar = Guitar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @guitar }\n end\n end", "def show\n @cherup = Cherup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cherup }\n end\n end", "def show\n @cuerpo = Cuerpo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cuerpo }\n end\n end", "def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end", "def index\n\t#params[:quest_id]\n #@qrcodes = Qrcode.find_all_by_userid(current_user.id)\n #@qrcodes= Qrcode.all\n@qrcodes = Qrcode.find_all_by_quest_id(params[:quest_id])\n@quest = Quest.find(params[:quest_id])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @qrcodes }\n end\n end", "def show\n @cartucho = Cartucho.find(params[:id])\n @historials [email protected]\n @historial = Historial.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cartucho }\n end\n end", "def show\n @idiom = Idiom.find(params[:id])\n @essays = Essay.where(idiom_id: params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @idiom }\n end\n end", "def index\n @courts = Court.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end", "def show\n @squawk = Squawk.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @squawk }\n end\n end", "def show\n @quantity = Quantity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quantity }\n end\n end", "def show\n @quantity = Quantity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quantity }\n end\n end", "def show\n @sinh_vien = SinhVien.where(ma_sinh_vien: params[:id]).first\n # Resque.enqueue(GvLogger, params[:id])\n if @sinh_vien and @sinh_vien.trucnhat\n respond_to do |format| \n format.json { render json: JSON.parse(@sinh_vien.trucnhat)[\"days\"].sort_by }\n end\n else\n respond_to do |format| \n format.json { render json: nil }\n end\n end\n end", "def show\n @quarter = Quarter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @quarter }\n end\n end", "def show\n @musique = Musique.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @musique }\n end\n end", "def show\n render json: @quiz\n end", "def show\n @cliente = Cliente.find(params[:cliente_id])\n @pago = @cliente.pagos.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pago }\n end\n end", "def show\n @soiree = Soiree.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @soiree }\n end\n end", "def show\n @q_resource = QResource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @q_resource }\n end\n end", "def show\n @inscrito = Inscrito.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inscrito }\n end\n end", "def show\n @trecho = Trecho.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trecho }\n end\n end", "def index\n @pizzas = Pizza.all\n render json: @pizzas\n end" ]
[ "0.73378515", "0.68576986", "0.6804682", "0.65586597", "0.6534483", "0.64916813", "0.6395623", "0.6305016", "0.6302825", "0.6276499", "0.6238748", "0.6212511", "0.61977655", "0.6181055", "0.6166113", "0.6150287", "0.6114974", "0.61138463", "0.6113721", "0.6074688", "0.6059026", "0.6042656", "0.6006553", "0.5993888", "0.599309", "0.596997", "0.5969333", "0.59654766", "0.595995", "0.5945887", "0.5942158", "0.5919489", "0.5911085", "0.5908558", "0.5907593", "0.5902754", "0.58982646", "0.5892308", "0.5889697", "0.58869416", "0.58849955", "0.5880084", "0.58764845", "0.5872233", "0.5853488", "0.58534855", "0.5852755", "0.58478665", "0.5845325", "0.5837082", "0.58335286", "0.58324", "0.58250266", "0.5822666", "0.58173645", "0.5816489", "0.58156556", "0.58091116", "0.58091116", "0.5804915", "0.57994634", "0.5797672", "0.57942045", "0.57916605", "0.57913995", "0.57883793", "0.57883793", "0.57883793", "0.5784894", "0.5773572", "0.57699317", "0.57684255", "0.5768226", "0.57654065", "0.57551944", "0.57477146", "0.5746396", "0.57419646", "0.57418114", "0.5735396", "0.57343423", "0.57325697", "0.57320195", "0.5727744", "0.5722787", "0.5722187", "0.57168853", "0.5716589", "0.5715682", "0.5715682", "0.5711312", "0.5710183", "0.5710167", "0.57058454", "0.5705485", "0.57012826", "0.56996405", "0.5699281", "0.56966555", "0.5694931" ]
0.7306567
1
GET /quartiers/new GET /quartiers/new.json
def new @quartier = Quartier.new respond_to do |format| format.html # new.html.erb format.json { render json: @quartier } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @qu = Qu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @qu }\n end\n end", "def new\n @qu = Qu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @qu }\n end\n end", "def new\n @quiniela = Quiniela.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quiniela }\n end\n end", "def new\n @quartet = Quartet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quartet }\n end\n end", "def new\n @q = Q.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @q }\n end\n end", "def new\n @quest = Quest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quest }\n end\n end", "def new\n @quip = Quip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quip }\n end\n end", "def new\n @quetion = Quetion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quetion }\n end\n end", "def new\n @quarter = Quarter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quarter }\n end\n end", "def new\n @quest = Quest.new\n\t@categories = find_all_categories\n\t\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quest }\n end\n end", "def new\n @spiel = Spiel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spiel }\n end\n end", "def new\n @quize = Quize.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quize }\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 new\n @basis = Base.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @basis }\n end\n end", "def new\n @clue = Clue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clue }\n end\n end", "def new\n @clue = Clue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clue }\n end\n end", "def new\n @agronomiaquimica = Agronomiaquimica.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end", "def new\n @cheque = Cheque.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cheque }\n end\n end", "def new\n @quantity = Quantity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quantity }\n end\n end", "def new\n @premio = Premio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @premio }\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 @lei = Lei.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lei }\n end\n end", "def new\n @tiezi = Tiezi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tiezi }\n end\n end", "def new\n @tupian = Tupian.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tupian }\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 create\n @quartier = Quartier.new(params[:quartier])\n\n respond_to do |format|\n if @quartier.save\n format.html { redirect_to @quartier, notice: 'Quartier was successfully created.' }\n format.json { render json: @quartier, status: :created, location: @quartier }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quartier.errors, status: :unprocessable_entity }\n end\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 @premio = Premio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @premio }\n end\n end", "def new\n @squish = Squish.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @squish }\n end\n end", "def new\n @qa = Qa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @qa }\n end\n end", "def new\n @spieler = Spieler.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spieler }\n end\n end", "def new\n @hasil = Hasil.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hasil }\n end\n end", "def new\n @what = What.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @what }\n end\n end", "def new\n @lieu = Lieu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lieu }\n end\n end", "def new\n @tieu_chi = TieuChi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tieu_chi }\n end\n end", "def new\n @tier = Tier.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @tier }\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 @artigo = Artigo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @artigo }\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 @ram = Ram.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ram }\n end\n end", "def new\n @rock = Rock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rock }\n end\n end", "def new\n @trenton = Trenton.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trenton }\n end\n end", "def new\n @specie = Specie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @specie }\n end\n end", "def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end", "def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end", "def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end", "def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end", "def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end", "def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end", "def new\n @serie = (params[:id] ? Serie.find(params[:id]) : Serie.new)\n @serie_new = params[:id] || true\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @serie }\n end\n end", "def new\n @t = T.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @t }\n end\n end", "def new\n @estoque = Estoque.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @estoque }\n end\n end", "def new\n @pto = Pto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pto }\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 new\n @rechnung = Rechnung.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rechnung }\n end\n end", "def new\n @dossier = Dossier.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dossier }\n end\n end", "def new\n @trecho = Trecho.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trecho }\n end\n end", "def create\n @quiniela = Quiniela.new(params[:quiniela])\n\n respond_to do |format|\n if @quiniela.save\n format.html { redirect_to @quiniela, notice: 'Quiniela was successfully created.' }\n format.json { render json: @quiniela, status: :created, location: @quiniela }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quiniela.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @quest_tree = QuestTree.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quest_tree }\n end\n end", "def new\n @qanda = Qanda.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @qanda }\n end\n end", "def new\n @qanda = Qanda.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @qanda }\n end\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 @ridol = Ridol.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ridol }\n end\n end", "def new\n @chaine = Chaine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @chaine }\n end\n end", "def new\n @ski = Ski.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ski }\n end\n end", "def new\n @ski = Ski.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ski }\n end\n end", "def new\n @uchronia = Uchronia.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @uchronia }\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 @phile = Phile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @phile }\n end\n end", "def new\n @carrera = Carrera.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @carrera }\n end\n end", "def new\n render :json => @fiestas.push(params[:fiesta])\n end", "def new\n @seguro = Seguro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seguro }\n end\n end", "def new\n @troop = Troop.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @troop }\n end\n end", "def new\n @idiom = Idiom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @idiom }\n end\n end", "def new\n @lore = Lore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lore }\n end\n end", "def new\n @u = U.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @u }\n end\n end", "def new\n @guille = Guille.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @guille }\n end\n end", "def new\n @guitar = Guitar.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @guitar }\n end\n end", "def create\n @qu = Qu.new(params[:qu])\n\n respond_to do |format|\n if @qu.save\n format.html { redirect_to @qu, :notice => 'Qu was successfully created.' }\n format.json { render :json => @qu, :status => :created, :location => @qu }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @qu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @qu = Qu.new(params[:qu])\n\n respond_to do |format|\n if @qu.save\n format.html { redirect_to @qu, :notice => 'Qu was successfully created.' }\n format.json { render :json => @qu, :status => :created, :location => @qu }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @qu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @click = Click.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @click }\n end\n end", "def new\n @court = Court.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @court }\n end\n end", "def new\r\n @intern_question = InternQuestion.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @intern_question }\r\n end\r\n end", "def new\n @itineraire = Itineraire.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @itineraire }\n end\n end", "def new\n @title = t('view.firms.new_title')\n @firm = Firm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @firm }\n end\n end", "def new\n @craque = Craque.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @craque }\n end\n end", "def new\n @articulo = Articulo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @articulo }\n end\n end", "def new\n @articulo = Articulo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @articulo }\n end\n end", "def new\n @articulo = Articulo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @articulo }\n end\n end", "def new\n @articulo = Articulo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @articulo }\n end\n end", "def new\n @requisition = Requisition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @requisition }\n end\n end", "def new\n @trtype = Trtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trtype }\n end\n end", "def new\n puts 'NEW METHOD'\n @pessoa = Pessoa.new\n @pessoa.enderecos.build\n 2.times { @pessoa.telefones.build }\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pessoa }\n end\n end", "def new\n @sitio = Sitio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sitio }\n end\n end", "def new\n @spawner = Spawner.new\n @fieldtrips = Fieldtrip.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spawner }\n end\n end", "def new\n @court = Court.new\n\n respond_to do |format|\n format.html { render \"new\", :layout=>false}\n format.json { render json: @court }\n end\n end", "def new\n @quote = Quote.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quote }\n end\n end", "def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request }\n end\n end", "def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request }\n end\n end" ]
[ "0.7472352", "0.7472352", "0.74581677", "0.7214666", "0.71439546", "0.71135354", "0.7073486", "0.70176154", "0.70083934", "0.6997093", "0.69833636", "0.6966258", "0.69537586", "0.69427913", "0.69345564", "0.69345564", "0.6931064", "0.69270194", "0.69263315", "0.69263256", "0.6910177", "0.690984", "0.6905806", "0.6899636", "0.68893254", "0.68825316", "0.68755245", "0.68641156", "0.6860636", "0.68595636", "0.6856078", "0.6849156", "0.6831281", "0.6817451", "0.681319", "0.6808394", "0.68005645", "0.67966527", "0.6795055", "0.6789429", "0.6783614", "0.6781415", "0.67805755", "0.67716193", "0.67716193", "0.67716193", "0.67716193", "0.67716193", "0.67716193", "0.676989", "0.67627555", "0.67571425", "0.6756555", "0.6755935", "0.6755935", "0.6749954", "0.6744048", "0.6743945", "0.6743389", "0.67417645", "0.6740275", "0.6740275", "0.6735121", "0.6732121", "0.67295015", "0.6728485", "0.6728485", "0.67177397", "0.67137873", "0.67109746", "0.67108315", "0.6709591", "0.67079383", "0.67048335", "0.6695372", "0.66943675", "0.66939616", "0.66939497", "0.6691313", "0.66904867", "0.66904867", "0.66865", "0.66842777", "0.66828704", "0.6682018", "0.6676902", "0.66763747", "0.66730237", "0.66730237", "0.66730237", "0.66730237", "0.66715574", "0.66692746", "0.6667748", "0.6665467", "0.66646683", "0.66636616", "0.6653929", "0.6652181", "0.6652181" ]
0.7629509
0
POST /quartiers POST /quartiers.json
def create @quartier = Quartier.new(params[:quartier]) respond_to do |format| if @quartier.save format.html { redirect_to @quartier, notice: 'Quartier was successfully created.' } format.json { render json: @quartier, status: :created, location: @quartier } else format.html { render action: "new" } format.json { render json: @quartier.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @quaderni = Quaderni.new(quaderni_params)\n\n respond_to do |format|\n if @quaderni.save\n format.html { redirect_to quaderni_url(@quaderni), notice: \"Quaderni was successfully created.\" }\n format.json { render :show, status: :created, location: @quaderni }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @quaderni.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quartet = Quartet.new(params[:quartet])\n\n respond_to do |format|\n if @quartet.save\n format.html { redirect_to @quartet, notice: 'Quartet was successfully created.' }\n format.json { render json: @quartet, status: :created, location: @quartet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quartet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quiniela = Quiniela.new(params[:quiniela])\n\n respond_to do |format|\n if @quiniela.save\n format.html { redirect_to @quiniela, notice: 'Quiniela was successfully created.' }\n format.json { render json: @quiniela, status: :created, location: @quiniela }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quiniela.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @qu = Qu.new(params[:qu])\n\n respond_to do |format|\n if @qu.save\n format.html { redirect_to @qu, :notice => 'Qu was successfully created.' }\n format.json { render :json => @qu, :status => :created, :location => @qu }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @qu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @qu = Qu.new(params[:qu])\n\n respond_to do |format|\n if @qu.save\n format.html { redirect_to @qu, :notice => 'Qu was successfully created.' }\n format.json { render :json => @qu, :status => :created, :location => @qu }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @qu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @quartet = Quartet.new(quartet_params)\n\n respond_to do |format|\n if @quartet.save\n format.html { redirect_to @quartet, notice: 'Quartet was successfully created.' }\n format.json { render :show, status: :created, location: @quartet }\n else\n format.html { render :new }\n format.json { render json: @quartet.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @quartier = Quartier.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quartier }\n end\n end", "def create\n @quiebre = Quiebre.new(quiebre_params)\n\n respond_to do |format|\n if @quiebre.save\n format.html { redirect_to @quiebre, notice: 'Quiebre was successfully created.' }\n format.json { render action: 'show', status: :created, location: @quiebre }\n else\n format.html { render action: 'new' }\n format.json { render json: @quiebre.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quinto = Quinto.new(quinto_params)\n \n @quinto.anio = params[:anio]\n @quinto.mes = params[:mes]\n \n \n respond_to do |format|\n if @quinto.save\n format.html { redirect_to @quinto, notice: 'Quinto was successfully created.' }\n format.json { render :show, status: :created, location: @quinto }\n else\n format.html { render :new }\n format.json { render json: @quinto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quiz = Quiz.new(quiz_params)\n questions_arr.each do |i|\n question = Question.new(question_params(i))\n choices_arr(i).each do |j|\n choice = Choice.new(choice_params(j))\n choice.save\n question.choices << choice\n end\n @quiz.questions << question\n end\n\n if @quiz.save\n User.find(params[:user_id]).quizzes << @quiz\n render json: @quiz, status: :created, location: @quiz\n else\n render json: @quiz.errors, status: :unprocessable_entity\n end\n end", "def create\n @quize = Quize.new(params[:quize])\n\n respond_to do |format|\n if @quize.save\n format.html { redirect_to @quize, notice: 'Quize was successfully created.' }\n format.json { render json: @quize, status: :created, location: @quize }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quize.errors, status: :unprocessable_entity }\n end\n end\n end", "def getQuartier\r\n \tarrondissement = params[:id]\r\n \trender json: Quartier.where(arrondissement_id: arrondissement)\r\n end", "def create\n params.permit(:intitule, :estObligatoire, :nombreDeCaractere, :ordre, :sondage_id)\n ajout = QuestionOuverteService.instance.creerQuestionOuverte(params[:intitule], params[:estObligatoire], params[:nombreDeCaractere], params[:ordre], params[:sondage_id])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\n end", "def create\n @question = Question.new(question_params)\n @question.zavrseno = \"N\"\n @question.user = @current_user\n @question.uposlenik = User.find(params[:uposlenik_id])\n respond_to do |format|\n if @question.save\n format.json { render json: @question, status: :created, location: api_question_url(@question) }\n else\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quiver = Quiver.new(quiver_params)\n\n respond_to do |format|\n if @quiver.save\n format.html { redirect_to @quiver, notice: 'Quiver was successfully created.' }\n format.json { render :show, status: :created, location: @quiver }\n else\n format.html { render :new }\n format.json { render json: @quiver.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @categoria_quarto = CategoriaQuarto.new(categoria_quarto_params)\n\n respond_to do |format|\n if @categoria_quarto.save\n format.html { redirect_to @categoria_quarto, notice: 'Categoria quarto was successfully created.' }\n format.json { render :show, status: :created, location: @categoria_quarto }\n else\n format.html { render :new }\n format.json { render json: @categoria_quarto.errors, status: :unprocessable_entity }\n end\n end\n end", "def panier_params\n params.require(:panier).permit(:semaine, :quantity)\n end", "def create\n @quatum = Quatum.new(quatum_params)\n\n respond_to do |format|\n if @quatum.save\n format.html { redirect_to @quatum, notice: 'Quatum was successfully created.' }\n format.json { render action: 'show', status: :created, location: @quatum }\n else\n format.html { render action: 'new' }\n format.json { render json: @quatum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @estoque = Estoque.new(params[:estoque])\n\n respond_to do |format|\n if @estoque.save\n format.html { redirect_to @estoque, notice: 'Estoque was successfully created.' }\n format.json { render json: @estoque, status: :created, location: @estoque }\n else\n format.html { render action: \"new\" }\n format.json { render json: @estoque.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params.permit(:id_groupe, :id_question)\n ajout = GroupeService.instance.ajouterQuestion(params[:id_groupe], params[:id_question])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\n end", "def create\n @quetion = Quetion.new(params[:quetion])\n\n respond_to do |format|\n if @quetion.save\n format.html { redirect_to @quetion, notice: 'Quetion was successfully created.' }\n format.json { render json: @quetion, status: :created, location: @quetion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quetion.errors, status: :unprocessable_entity }\n end\n end\n end", "def quarto_params\n params.require(:quarto).permit(:numero, :piso)\n end", "def create\n @qux = Qux.new(qux_params)\n\n respond_to do |format|\n if @qux.save\n format.html { redirect_to @qux, notice: 'Qux was successfully created.' }\n format.json { render :show, status: :created, location: @qux }\n else\n format.html { render :new }\n format.json { render json: @qux.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quarto = Quarto.new(quarto_params)\n\n respond_to do |format|\n if @quarto.save\n format.html { redirect_to @quarto, notice: 'Quarto was successfully created.' }\n format.json { render :show, status: :created, location: @quarto }\n else\n format.html { render :new }\n format.json { render json: @quarto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @agronomiaquimica = Agronomiaquimica.new(params[:agronomiaquimica])\n\n respond_to do |format|\n if @agronomiaquimica.save\n format.html { redirect_to @agronomiaquimica, notice: 'Agronomiaquimica was successfully created.' }\n format.json { render json: @agronomiaquimica, status: :created, location: @agronomiaquimica }\n else\n format.html { render action: \"new\" }\n format.json { render json: @agronomiaquimica.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quandary= current_user.quandaries.build(quandary_params)\n\n respond_to do |format|\n if @quandary.save\n format.html { redirect_to @quandary, notice: 'Quandary was successfully created.' }\n format.json { render :show, status: :created, location: @quandary }\n else\n format.html { render :new }\n format.json { render json: @quandary.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t\tquiz = Quiz.new(quiz_params)\n\t\t\tif quiz.save\n\t\t\t\tcurrent_instructor.quizzes << quiz\n\t\t\t\trender json: { id: quiz.id }, status: 201\n\t\t\telse\n\t\t\t\trender json: { error: quiz.errors }, status: 422\n\t\t\tend\n\t\tend", "def create\n respond_to do |format|\n aux= params[:item_pautum][:questao_id]\n if aux.size > 1\n for x in aux\n if x == \"\"\n break#a ultima posição do array e um \"\" e isso não é um id por tanto da erro entao esse if resolve isso\n end\n\n @questao=Questao.find(x) #aqui eupego a pessoa com o id q ta no x\n @item_pautum = ItemPautum.new(item_pautum_params)\n @pautum = Pautum.find(@item_pautum.pautum) \n if ItemPautum.search(@questao.id, @pautum.id) == [] #com esse if eu evito que se convoque a mesma pessoa 2 vezes\n @item_pautum.questao=@questao# passo o objeto questao para item pauta\n @item_pautum.pautum=@pautum# passo o objeto pauta para item pauta\n if Ponto.buscarPonto(@item_pautum.questao.id).size >=1\n @item_pautum.save\n end\n end\n end\n\n format.html { redirect_to @pautum, notice: 'Questões alocadas com sucesso.' }\n format.json { render :show, status: :created, location: @pautum }\n else\n\n\n format.html { redirect_to pautum_path(@item_pautum.pautum), notice: 'Desculpe mas,você não selecionou as questões.' }\n end\n end\n end", "def create\n @requiero = Requiero.new(requiero_params)\n\n respond_to do |format|\n if @requiero.save\n format.html { redirect_to @requiero, notice: 'Requiero was successfully created.' }\n format.json { render :show, status: :created, location: @requiero }\n else\n format.html { render :new }\n format.json { render json: @requiero.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @qor = Qor.new(qor_params)\n\n respond_to do |format|\n if @qor.save\n format.html { redirect_to @qor, notice: 'Qor was successfully created.' }\n format.json { render :show, status: :created, location: @qor }\n else\n format.html { render :new }\n format.json { render json: @qor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quack = Quack.new(quack_params)\n\n respond_to do |format|\n if @quack.save\n format.html { redirect_to @quack, notice: 'Quack was successfully created.' }\n format.json { render :show, status: :created, location: @quack }\n else\n format.html { render :new }\n format.json { render json: @quack.errors, status: :unprocessable_entity }\n end\n end\n end", "def quiebre_params\n params.require(:quiebre).permit(:pedido, :nombrecliente, :fechaquiebre)\n end", "def quinto_params\n params.require(:quinto).permit(:anio, :employee_id, :mes, :rem_actual, :rem_mes, :asignacion, :hextras, :otros1, :mes_proy, :rem_proyectada, :gratijulio, :gratidic, :bonextra, :otros2, :ene1, :feb1, :mar1, :abr1, :may1, :jun1, :jul1, :ago1, :set1, :oct1, :nov1, :renta_bruta, :deduccion7, :total_renta, :renta_impo1, :renta_impo2, :renta_impo3, :renta_impo4, :renta_impo5, :total_renta_impo, :ene2, :feb2, :mar2, :abr2, :may2, :jun2, :jul2, :ago2, :set2, :oct2, :nov2, :dic2, :renta_impo_ret, :mes_pendiente, :retencion_mensual,:gratijulio1)\n end", "def create\n @quay = Quay.new(params[:quay])\n\n respond_to do |format|\n if @quay.save\n flash[:notice] = 'Quay was successfully created.'\n format.html { redirect_to(@quay) }\n format.xml { render :xml => @quay, :status => :created, :location => @quay }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @quay.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @qishi = Qishi.new(qishi_params)\n\n respond_to do |format|\n if @qishi.save\n format.html { redirect_to @qishi, notice: 'Qishi was successfully created.' }\n format.json { render :show, status: :created, location: @qishi }\n else\n format.html { render :new }\n format.json { render json: @qishi.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movimentode_estoque = MovimentodeEstoque.new(movimentode_estoque_params)\n\n respond_to do |format|\n if @movimentode_estoque.save\n format.html { redirect_to @movimentode_estoque, notice: 'Movimentode estoque was successfully created.' }\n format.json { render :show, status: :created, location: @movimentode_estoque }\n else\n format.html { render :new }\n format.json { render json: @movimentode_estoque.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quip = Quip.new(params[:quip])\n\n respond_to do |format|\n if @quip.save\n format.html { redirect_to @quip, notice: 'Quip was successfully created.' }\n format.json { render json: @quip, status: :created, location: @quip }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quip.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @q = Q.new(params[:q])\n\n respond_to do |format|\n if @q.save\n format.html { redirect_to @q, notice: 'Q was successfully created.' }\n format.json { render json: @q, status: :created, location: @q }\n else\n format.html { render action: \"new\" }\n format.json { render json: @q.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @quartier = Quartier.find(params[:id])\n @quartier.destroy\n\n respond_to do |format|\n format.html { redirect_to quartiers_url }\n format.json { head :no_content }\n end\n end", "def new\n @quartet = Quartet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quartet }\n end\n end", "def new\n @quiniela = Quiniela.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quiniela }\n end\n end", "def relatorio_params\r\n params.require(:relatorio).permit(:tipo, :quantidade_total, :quantidade_erros)\r\n end", "def quartet_params\n params.require(:quartet).permit(:country, :uri, :image, :year, :title)\n end", "def add_question\n\t\t\tif(current_instructor.quizzes.exists?(:id => params[:quiz_id]))\n\t\t\t\tquiz = current_instructor.quizzes.find(params[:quiz_id])\n\t\t\t\tno = quiz.no_of_MCQ + quiz.no_of_rearrangeQ\t\n\t\t\t\tno.times do |n|\n\t\t\t\t\tquestion = Question.create((params[\"_json\"][n]).permit([:text, :mark, :right_answer, :choices => []]))\n\t\t\t\t\tquiz.questions << question\n\t\t\t\tend\n\t\t\t\trender json: { info: \"created\"}, status: 201\n\t\t\telse\n\t\t\t\trender json: { error:\"Quiz is not found\" }, status: 422\n\t\t\tend\n\t\tend", "def create\n\t# Finding the current surgeon \n\tsurgeon = current_user\n\t# creating the question with current surgeon\n\tquestion = surgeon.questions.new(question_params)\n\tif question.save\n\t# response to the JSON\n\t\trender json: { success: true,message: \"Question Successfully Created.\", response: QuestionSerializer.new(question).as_json(root: false) },:status=>200\n else\n render :json=> { success: false, message: question.errors },:status=> 203\n end\n\tend", "def create\n @q = Q.new(q_params)\n\n respond_to do |format|\n if @q.save\n format.html { redirect_to @q, notice: 'Q was successfully created.' }\n format.json { render action: 'show', status: :created, location: @q }\n else\n format.html { render action: 'new' }\n format.json { render json: @q.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quize = Quize.new(quize_params)\n @quize.user_id = current_user.id\n respond_to do |format|\n if @quize.save\n format.html { redirect_to edit_quize_path(@quize), notice: 'Quize was successfully created.' }\n format.json { render :show, status: :created, location: @quize }\n else\n format.html { render :new }\n format.json { render json: @quize.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movimentacao_de_estoque = MovimentacaoDeEstoque.new(params[:movimentacao_de_estoque])\n\n respond_to do |format|\n if @movimentacao_de_estoque.save\n format.html { redirect_to @movimentacao_de_estoque, notice: 'Movimentacao de estoque was successfully created.' }\n format.json { render json: @movimentacao_de_estoque, status: :created, location: @movimentacao_de_estoque }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movimentacao_de_estoque.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @plan_quirurgico = PlanQuirurgico.new(plan_quirurgico_params)\n @plan_quirurgico.servicios = params[:servicios]\n @plan_quirurgico.estatus = \"En Proceso\"\n puts params\n puts @plan_quirurgico.examen \n respond_to do |format|\n if @plan_quirurgico.save\n format.html { redirect_to @plan_quirurgico, notice: 'El plan quirurgico fue registrado exitosamente.' }\n format.json { render :show, status: :created, location: @plan_quirurgico }\n else\n format.html { render :new }\n format.json { render json: @plan_quirurgico.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n @survey = Survey.new(json)\n respond_to do |format|\n if @survey.save\n format.html { redirect_to @survey, notice: 'Survey was successfully created.' }\n format.json { render json: @survey, status: :created, location: @survey }\n else\n format.html { render action: \"new\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def quandary_params\n params.require(:quandary).permit(:title, :description, :rating, :image)\n end", "def create\n @quest = Quest.new(quest_params)\n respond_to do |format|\n if @quest.save\n format.html { redirect_to @quest, notice: 'Quest was successfully created.' }\n format.json { render :show, status: :created, location: @quest }\n else\n format.html { render :new }\n format.json { render json: @quest.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_quest = UserQuest.new(params[:user_quest])\n\n respond_to do |format|\n if @user_quest.save\n format.html { redirect_to @user_quest, notice: 'User quest was successfully created.' }\n format.json { render json: @user_quest, status: :created, location: @user_quest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_quest.errors, status: :unprocessable_entity }\n end\n end\n end", "def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end", "def new\n @quarter = Quarter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quarter }\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 quiz = Quiz.new(set_quiz_params)\n\n respond_to do |format|\n format.json do\n \n if quiz.valid?\n if quiz.save!\n render json: success_api({ question: quiz.question }, \"You fill correct answer!\")\n else\n render json: failed_api({ question: quiz.question }, \"You fill incorrect answer!\")\n end\n else\n render json: failed_api({}, quiz.errors.full_messages.first)\n end\n end\n end\n end", "def create\n @quest_item = QuestItem.new(quest_item_params)\n\n respond_to do |format|\n if @quest_item.save\n format.html { redirect_to admin_quest_items_url, notice: 'Всё норм' }\n format.json { head :no_content }\n else\n format.html { render :new }\n format.json { render json: @quest_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quete = Quete.new(quete_params)\n\n respond_to do |format|\n if @quete.save\n format.html { redirect_to @quete, notice: 'quete was successfully created.' }\n format.json { render :show, status: :created, location: @quete }\n else\n format.html { render :new }\n format.json { render json: @quete.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quiz = Quiz.new(quiz_params)\n\n respond_to do |format|\n if @quiz.save\n @quiz.refrence_id = @quiz.id\n @quiz.save\n format.json { render json: @quiz.show_full_details }\n else\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @questao = Questao.new(questao_params)\n\n respond_to do |format|\n if @questao.save\n format.html { redirect_to @questao, notice: 'Questao was successfully created.' }\n format.json { render :show, status: :created, location: @questao }\n else\n format.html { render :new }\n format.json { render json: @questao.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quimicos_serigrafia_producto = QuimicosSerigrafiaProducto.new(quimicos_serigrafia_producto_params)\n\n respond_to do |format|\n if @quimicos_serigrafia_producto.save\n format.html { redirect_to @quimicos_serigrafia_producto, notice: 'Quimicos serigrafia producto was successfully created.' }\n format.json { render :show, status: :created, location: @quimicos_serigrafia_producto }\n else\n format.html { render :new }\n format.json { render json: @quimicos_serigrafia_producto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quadra = Quadra.new(quadra_params)\n respond_to do |format|\n if @quadra.save\n format.html { redirect_to quadras_url, notice: 'Quadra criada com sucesso.' }\n format.json { render :show, status: :created, location: @quadra }\n else\n format.html { render :new }\n format.json { render json: @quadra.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quarter = Quarter.new(params[:quarter])\n\n respond_to do |format|\n if @quarter.save\n format.html { redirect_to(@quarter, :notice => 'Quarter was successfully created.') }\n format.xml { render :xml => @quarter, :status => :created, :location => @quarter }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @quarter.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @qurriculum = current_user.qurriculums.new(params[:qurriculum])\n\n respond_to do |format|\n if @qurriculum.save\n format.html { redirect_to @qurriculum, notice: 'Qurriculum was successfully created.' }\n format.json { render json: @qurriculum, status: :created, location: @qurriculum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @qurriculum.errors, status: :unprocessable_entity }\n end\n end\n end", "def quaderni_params\n params.require(:quaderni).permit(:title, :release_date, :file_doc, speaker_ids: [])\n end", "def create\n @ruta = Ruta.new(ruta_params)\n respond_to do |format|\n if params[:parada_inicial] != \"\"\n @inicio = Parada.find(params[:parada_inicial])\n @ruta.parada.push(@inicio)\n @ruta_parada = @ruta.ruta_parada.find_by(parada_id: @inicio.id)\n @ruta_parada.tipo = 1\n @ruta_parada.save\n end\n if params[:parada_final] != \"\"\n @final = Parada.find(params[:parada_final])\n @ruta.parada.push(@final)\n @ruta_parada = @ruta.ruta_parada.find_by(parada_id: @final.id)\n @ruta_parada.tipo = -1\n @ruta_parada.save\n end\n if params[:grupo_paradas] != \"\"\n @paradas = Parada.where(:id => params[:grupo_paradas])\n @ruta.parada << @paradas\n end\n if @ruta.save\n format.html { redirect_to @ruta, notice: 'Ruta was successfully created.' }\n format.json { render :show, status: :created, location: @ruta }\n else\n format.html { render :new }\n format.json { render json: @ruta.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @enqury = Enqury.new(enqury_params)\n\n respond_to do |format|\n if @enqury.save\n format.html { redirect_to @enqury, notice: 'Enqury was successfully created.' }\n format.json { render :show, status: :created, location: @enqury }\n else\n format.html { render :new }\n format.json { render json: @enqury.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end", "def new\n @quize = Quize.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quize }\n end\n end", "def create\n post_params = {\n name: params[:name].downcase,\n units: params[:units] || 0\n }\n render json: Ingredient.create!(post_params), status: :created\n end", "def quizz_params\n params.require(:quizz).permit(:title, :description, :difficulty)\n end", "def create\n @tiezi = Tiezi.new(params[:tiezi])\n\n respond_to do |format|\n if @tiezi.save\n format.html { redirect_to @tiezi, notice: 'Tiezi was successfully created.' }\n format.json { render json: @tiezi, status: :created, location: @tiezi }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tiezi.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @qanda = Qanda.new(params[:qanda])\n\n respond_to do |format|\n if @qanda.save\n format.html { redirect_to @qanda, notice: 'Q & A was successfully created.' }\n format.json { render json: @qanda, status: :created, location: @qanda }\n else\n format.html { render action: \"new\" }\n format.json { render json: @qanda.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @uchronia = Uchronia.new(params[:uchronia])\n\n respond_to do |format|\n if @uchronia.save\n format.html { redirect_to @uchronia, notice: 'Uchronia was successfully created.' }\n format.json { render json: @uchronia, status: :created, location: @uchronia }\n else\n format.html { render action: \"new\" }\n format.json { render json: @uchronia.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cheque = Cheque.new(params[:cheque])\n\n respond_to do |format|\n if @cheque.save\n format.html { redirect_to @cheque, notice: 'Cheque was successfully created.' }\n format.json { render json: @cheque, status: :created, location: @cheque }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cheque.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @paroquia = Paroquia.new(params[:paroquia])\n\n respond_to do |format|\n if @paroquia.save\n flash[:notice] = 'Paroquia was successfully created.'\n format.html { redirect_to(@paroquia) }\n format.xml { render :xml => @paroquia, :status => :created, :location => @paroquia }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @paroquia.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @estoquemp = Estoquemp.new(estoquemp_params)\n @estoquemp.cliente_id = current_user.cliente_id\n \n \n if !Estoquemp.where(cliente_id: current_user.cliente_id, item: @estoquemp.item).empty? && @estoquemp.atualizar == \"Entrada\"\n quantidade_velha = Estoquemp.where(cliente_id: current_user.cliente_id, item: @estoquemp.item).last.quantidade_atual\n quantidade_nova = @estoquemp.quantidade_atual\n @estoquemp.quantidade_atual = quantidade_nova + quantidade_velha\n end\n \n \n if !Estoquemp.where(cliente_id: current_user.cliente_id, item: @estoquemp.item).empty? && @estoquemp.atualizar == \"Saída\"\n quantidade_velha = Estoquemp.where(cliente_id: current_user.cliente_id, item: @estoquemp.item).last.quantidade_atual\n quantidade_nova = @estoquemp.quantidade_atual\n @estoquemp.quantidade_atual = quantidade_velha - quantidade_nova\n @estoquemp.fornecedor = Estoquemp.where(cliente_id: current_user.cliente_id, item: @estoquemp.item).last.fornecedor\n end\n \n \n respond_to do |format|\n if @estoquemp.save\n format.html { redirect_to new_estoquemp_path, flash: { success: 'Item adicionado com sucesso ao estoque' } }\n format.json { render :show, status: :created, location: @estoquemp }\n else\n format.html { render :new }\n format.json { render json: @estoquemp.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 @equipe = Equipe.new(equipe_params)\n\n respond_to do |format|\n if @equipe.save\n format.html { redirect_to @equipe, notice: 'Equipe foi Adicionada.' }\n format.json { render :show, status: :created, location: @equipe }\n else\n format.html { render :new }\n format.json { render json: @equipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @qu = Qu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @qu }\n end\n end", "def new\n @qu = Qu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @qu }\n end\n end", "def create\n @tipomaquinat = Tipomaquinat.new(tipomaquinat_params)\n #@tipomaquinat = Tipomaquinat.new\n #@tipomaquinat.id=401\n #@tipomaquinat.tipomaquina = \"KLK\" #params.require(:tipomaquinat).permit(:tipomaquina)\n #@tipomaquinat.descripcion = \"YOOOO\" #params.require(:tipomaquinat).permit(:descripcion)\n #descripcion\n\n # params.require(:tipomaquinat).permit(:tipomaquina, :descripcion,\n\n respond_to do |format|\n if @tipomaquinat.save\n format.html { redirect_to @tipomaquinat, notice: 'Tipomaquinat was successfully created.' }\n format.json { render :show, status: :created, location: @tipomaquinat }\n else\n format.html { render :new }\n format.json { render json: @tipomaquinat.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @uzser = Uzser.new(uzser_params)\n\n respond_to do |format|\n if @uzser.save\n format.html { redirect_to @uzser, notice: 'Uzser was successfully created.' }\n format.json { render :show, status: :created, location: @uzser }\n else\n format.html { render :new }\n format.json { render json: @uzser.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @arrived_qatar = ArrivedQatar.new(arrived_qatar_params)\n\n respond_to do |format|\n if @arrived_qatar.save\n format.html { redirect_to @arrived_qatar, notice: 'Arrived qatar was successfully created.' }\n format.json { render :show, status: :created, location: @arrived_qatar }\n else\n format.html { render :new }\n format.json { render json: @arrived_qatar.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if !params[:_json].blank?\n params[:_json] = JSON.parse params[:_json] if params[:_json].is_a? String\n \n #Routine de transformation en CSV\n json = params[:_json][0]\n headers = []\n values = []\n csv_string = CSV.generate do |csv|\n json.each do |key, value|\n if (!key.blank? && !value.blank? && value!=\"Autre\")\n #Exclusion de certain champs Limesurvey\n if !['id','Complété','Dernière page vue','Langue de départ', 'FusionQuestion', 'Code'].include?(key)\n #Nettoyage des champs du type \"champs [other]\"\n if key.include?(\" [other]\")\n #puts \"test [other]\"\n key = key.split(\" [other]\")[0] \n end\n headers << key\n values << value \n end\n end\n end\n csv << headers\n csv << values\n end\n \n @questionnaire = Questionnaire.new(params[:questionnaire])\n @questionnaire.content = csv_string\n profil_id, category_id = json['FusionQuestion'].to_s.split(\"/\")\n @questionnaire.profil = Profil.find(id=profil_id)\n @questionnaire.category = Category.find(id=category_id)\n end\n \n respond_to do |format|\n if @questionnaire.save\n format.html { redirect_to @questionnaire, notice: 'Questionnaire was successfully created.' }\n format.json { render json: @questionnaire, status: :created, location: @questionnaire }\n else\n format.html { render action: \"new\" }\n format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def create\n @inquilino = Inquilino.new(inquilino_params)\n respond_to do |format|\n if @inquilino.save\n #@pagamento = Pagamento.create(mes: @inquilino.dataVencimento.to_s, pago: @inquilino.pago, inquilino_id: @inquilino.id)\n #@mensalidade = Mensalidade.create(inquilino_id: @inquilino.id, pagamento_id: @pagamento.id)\n #@mensalidade = Mensalidade.create(pago: @inquilino.pago, inquilino_id: @inquilino.id)\n @mesa = @inquilino.dataVencimento\n @cont = 0\n 12.times do\n @cont += 1\n @mes = @mesa + @cont.month\n @mensalidades = Mensalidade.create(inquilino_id: @inquilino.id, mes: @mes, pago: false)\n end\n #\n @whatsapp = Whatsapp.create(inquilino_id: @inquilino.id, numero: \" \", endereco: \" \")\n\n format.html {redirect_to @inquilino, notice: 'Inquilino criado com sucesso!.'}\n format.json {render :show, status: :created, location: @inquilino}\n else\n format.html {render :new}\n format.json {render json: @inquilino.errors, status: :unprocessable_entity}\n end\n end\n end", "def new\n render :json => @fiestas.push(params[:fiesta])\n end", "def test_submit_rent\n quote_details = SAMPLE_QUOTE_DETAILS.deep_dup\n quote_details['fixed_price_services_requested']['price'] = 1200\n params_hash = {\n udprn: '123456',\n services_required: SAMPLE_SERVICES_REQUIRED,\n payment_terms: SAMPLE_PAYMENT_TERMS,\n quote_details: quote_details.to_json\n }\n first_params_hash = params_hash.deep_dup\n first_params_hash[:quote_details] = SAMPLE_QUOTE_DETAILS.to_json\n post :new_quote_for_property, first_params_hash\n post :new, params_hash\n assert_response 200\n\n quote = Agents::Branches::AssignedAgents::Quote.last\n ### Now lets submit the quote\n post :submit, { udprn: '123456', quote_id: quote.id }\n response = Oj.load(@response.body)\n assert_response 200\n assert_equal response['message'], 'The quote is accepted'\n end", "def create\n @itineraire = Itineraire.new(params[:itineraire])\n\n respond_to do |format|\n if @itineraire.save\n format.html { redirect_to @itineraire, :notice => 'L\\'itinéraire a bien été créé' }\n format.json { render :json => @itineraire, :status => :created, :location => @itineraire }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @itineraire.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @trainees = TraineeBatch.new(params[:participants][:ids], params[:training_calendar_id])\n respond_to do |format|\n if @trainees.save\n format.html { redirect_to training_calendar_path(params[:training_calendar_id]), :notice => 'The participant(s) were successfully added.' }\n format.json { render :json => @trainees, :status => :created, :location => @trainees }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @trainees.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @queuing = Queuing.new(params[:queuing])\n\n respond_to do |format|\n if @queuing.save\n format.html { redirect_to @queuing, notice: 'queuing was successfully created.' }\n format.json { render json: @queuing, status: :created, location: @queuing }\n else\n format.html { render action: \"new\" }\n format.json { render json: @queuing.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tenki = Tenki.new(tenki_params)\n\n respond_to do |format|\n if @tenki.save\n format.html { redirect_to @tenki, notice: 'Tenki was successfully created.' }\n format.json { render :show, status: :created, location: @tenki }\n else\n format.html { render :new }\n format.json { render json: @tenki.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quiz = Quiz.find(params[:quiz_id])\n @question = Question.new(question_params) \n #respond_to do |format|\n if @question.save\n link_quiz_question(@quiz, @question)\n #format.json { render :show, status: :created, location: @question }\n else\n redirect_to quizzes_path\n flash[:notice] = 'Falha em criar pergunta'\n #format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n #end\n end", "def create\n @altoq = Altoq.new(altoq_params)\n\n respond_to do |format|\n if @altoq.save\n format.html { redirect_to @altoq, notice: 'Altoq was successfully created.' }\n format.json { render :show, status: :created, location: @altoq }\n else\n format.html { render :new }\n format.json { render json: @altoq.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @premio = Premio.new(params[:premio])\n\n respond_to do |format|\n if @premio.save\n format.html { redirect_to @premio, :notice => 'Premio was successfully created.' }\n format.json { render :json => @premio, :status => :created, :location => @premio }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def movimentode_estoque_params\n params.require(:movimentode_estoque).permit(:data, :quantidade, :pessoa, :operacao, :produto)\n end", "def create\n @movimento_de_estoque = MovimentoDeEstoque.new(movimento_de_estoque_params)\n\n respond_to do |format|\n if @movimento_de_estoque.save\n format.html { redirect_to @movimento_de_estoque, notice: 'Movimento de estoque was successfully created.' }\n format.json { render :show, status: :created, location: @movimento_de_estoque }\n else\n format.html { render :new }\n format.json { render json: @movimento_de_estoque.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n quizzes = Quiz.all\n render json: quizzes, except: [:updated_at, :created_at]\n end", "def create\n @solicitacao = Solicitacao.new(solicitacao_params)\n\n respond_to do |format|\n if @solicitacao.save\n @solicitacao.produto_solicitados.each do |item|\n i = Produto.find(item.produto_id)\n i.quantidade = i.quantidade - item.quantidade\n i.save\n end\n format.html { redirect_to @solicitacao, notice: 'Solicitacao was successfully created.' }\n format.json { render action: 'show', status: :created, location: @solicitacao }\n else\n format.html { render action: 'new' }\n format.json { render json: @solicitacao.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.63357705", "0.6203391", "0.6184371", "0.605641", "0.605641", "0.60297656", "0.600455", "0.5882824", "0.58737", "0.58430725", "0.5741812", "0.56960183", "0.5665037", "0.56619453", "0.56455624", "0.56213903", "0.55918944", "0.5590717", "0.5585319", "0.55746824", "0.5566193", "0.5541079", "0.553318", "0.55219823", "0.5518871", "0.55168515", "0.55111015", "0.5504468", "0.54920346", "0.54912597", "0.5490756", "0.5482291", "0.545821", "0.5456199", "0.5455142", "0.5438467", "0.54295814", "0.5429023", "0.5414981", "0.54052234", "0.53801376", "0.5369073", "0.5362613", "0.5344106", "0.5326973", "0.53149295", "0.5304744", "0.5299899", "0.52838385", "0.52827144", "0.5279795", "0.5277433", "0.5275536", "0.5272295", "0.52642316", "0.52631783", "0.526045", "0.5258542", "0.5255505", "0.5249973", "0.5249029", "0.5247421", "0.52450824", "0.5242971", "0.52254", "0.5223704", "0.52157557", "0.5209979", "0.5205345", "0.5204749", "0.5200209", "0.51964515", "0.51925236", "0.5183211", "0.51826286", "0.5181559", "0.51762563", "0.5172563", "0.51649004", "0.51595384", "0.5152526", "0.5152526", "0.51514703", "0.51503366", "0.51487863", "0.5147647", "0.51436454", "0.5142427", "0.51393855", "0.51369816", "0.51331645", "0.51308495", "0.5127992", "0.5115203", "0.5114785", "0.5110531", "0.51104975", "0.5106222", "0.51026356", "0.5101436" ]
0.6929035
0
PUT /quartiers/1 PUT /quartiers/1.json
def update @quartier = Quartier.find(params[:id]) respond_to do |format| if @quartier.update_attributes(params[:quartier]) format.html { redirect_to @quartier, notice: 'Quartier was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @quartier.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @quartet = Quartet.find(params[:id])\n\n respond_to do |format|\n if @quartet.update_attributes(params[:quartet])\n format.html { redirect_to @quartet, notice: 'Quartet was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quartet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @quiniela = Quiniela.find(params[:id])\n\n respond_to do |format|\n if @quiniela.update_attributes(params[:quiniela])\n format.html { redirect_to @quiniela, notice: 'Quiniela was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quiniela.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @quaderni.update(quaderni_params)\n format.html { redirect_to quaderni_url(@quaderni), notice: \"Quaderni was successfully updated.\" }\n format.json { render :show, status: :ok, location: @quaderni }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @quaderni.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @qu = Qu.find(params[:id])\n respond_to do |format|\n if @qu.update_attributes(params[:qu])\n format.html { redirect_to @qu, :notice => 'Qu was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @qu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @qu = Qu.find(params[:id])\n respond_to do |format|\n if @qu.update_attributes(params[:qu])\n format.html { redirect_to @qu, :notice => 'Qu was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @qu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @quartet.update(quartet_params)\n format.html { redirect_to @quartet, notice: 'Quartet was successfully updated.' }\n format.json { render :show, status: :ok, location: @quartet }\n else\n format.html { render :edit }\n format.json { render json: @quartet.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 @quarter = Quarter.find(params[:id])\n\n respond_to do |format|\n if @quarter.update_attributes(params[:quarter])\n format.html { redirect_to @quarter, notice: 'Quarter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quarter.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @quize = Quize.find(params[:id])\n\n respond_to do |format|\n if @quize.update_attributes(params[:quize])\n format.html { redirect_to @quize, notice: 'Quize was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quize.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @quatum.update(quatum_params)\n format.html { redirect_to @quatum, notice: 'Quatum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @quatum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @quize.update(quize_params)\n format.html { redirect_to @quize, notice: 'Quize was successfully updated.' }\n format.json { render :show, status: :ok, location: @quize }\n else\n format.html { render :edit }\n format.json { render json: @quize.errors, status: :unprocessable_entity }\n end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def actualizacion \n fiesta.update (params[:id]) \n render json: fiesta\n end", "def update\n @estoque = Estoque.find(params[:id])\n\n respond_to do |format|\n if @estoque.update_attributes(params[:estoque])\n format.html { redirect_to @estoque, notice: 'Estoque was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @estoque.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @quiver.update(quiver_params)\n format.html { redirect_to @quiver, notice: 'Quiver was successfully updated.' }\n format.json { render :show, status: :ok, location: @quiver }\n else\n format.html { render :edit }\n format.json { render json: @quiver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @q = Q.find_by_unique_id(params[:id])\n\n respond_to do |format|\n if @q.update_attributes(params[:q])\n format.html { redirect_to @q, notice: 'Q was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @q.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n @survey = Survey.find(params[:id])\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n\n respond_to do |format|\n if @survey.update_attributes(json)\n format.html { redirect_to @survey, notice: 'Survey was successfully updated.' }\n format.json { render json: @survey }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n query = {\n 'name' => params[:name]\n }\n response = HTTParty.put(url, :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n redirect_to unit_path(params[:id]), notice: 'Unit was successfully updated.'\n else\n redirect_to unit_path(params[:id]), notice: 'Sheesh! Minor hiccup...run that again!'\n end\n end", "def update\n @quay = Quay.find(params[:id])\n\n respond_to do |format|\n if @quay.update_attributes(params[:quay])\n flash[:notice] = 'Quay was successfully updated.'\n format.html { redirect_to(@quay) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @quay.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put!\n request! :put\n end", "def update\n respond_to do |format|\n if @quarto.update(quarto_params)\n format.html { redirect_to @quarto, notice: 'Quarto was successfully updated.' }\n format.json { render :show, status: :ok, location: @quarto }\n else\n format.html { render :edit }\n format.json { render json: @quarto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quartier = Quartier.new(params[:quartier])\n\n respond_to do |format|\n if @quartier.save\n format.html { redirect_to @quartier, notice: 'Quartier was successfully created.' }\n format.json { render json: @quartier, status: :created, location: @quartier }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quartier.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @quarter = Quarter.find(params[:id])\n\n respond_to do |format|\n if @quarter.update_attributes(params[:quarter])\n format.html { redirect_to(@quarter, :notice => 'Quarter was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @quarter.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @quip = Quip.find(params[:id])\n\n respond_to do |format|\n if @quip.update_attributes(params[:quip])\n format.html { redirect_to @quip, notice: 'Quip was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quip.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @quartier = Quartier.find(params[:id])\n @quartier.destroy\n\n respond_to do |format|\n format.html { redirect_to quartiers_url }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @qux.update(qux_params)\n format.html { redirect_to @qux, notice: 'Qux was successfully updated.' }\n format.json { render :show, status: :ok, location: @qux }\n else\n format.html { render :edit }\n format.json { render json: @qux.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @quinto.anio = params[:anio]\n @quinto.mes = params[:mes]\n \n \n \n respond_to do |format|\n if @quinto.update(quinto_params)\n format.html { redirect_to @quinto, notice: 'Quinto was successfully updated.' }\n format.json { render :show, status: :ok, location: @quinto }\n else\n format.html { render :edit }\n format.json { render json: @quinto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n question = Question.find(params[:id_question])\n if question.update(params_question)\n render json: question, status: 200\n else\n render json: question.errors, status: 422\n end\n\n end", "def edit_question\n\t\t\tquizzes = current_instructor.quizzes\n\t\t\t@found = 0\n\t\t\tquizzes.each do |quiz|\n\t\t\t\tif(quiz.questions.exists?(:id => params[:question_id]))\n\t\t\t\t\t@found = @found + 1\n\t\t\t\tend \n\t\t\tend\n\t\t\tif (@found > 0)\n\t\t\t\tquestion = Question.find(params[:question_id])\n\t\t\t\tif (question.update(question_params))\n\t\t\t\t\trender json: { success: true, data: { :question => question }, info:{} }, status: 200\n\t\t\t\telse\n\t\t\t\t\trender json: { error: question.errors }, status: 422 \n\t\t\t\tend\t\n\t\t\telse\n\t\t\t\trender json: { error:\"Question is not found\" }, status: 422\n\t\t\tend\n\t\tend", "def update\n Neo4j::Transaction.run do\n @q_resource = QResource.find(params[:id])\n @q_resource.update_attributes!(params[:q_resource])\n respond_to do |format|\n if @q_resource.update_attributes(params[:q_resource])\n format.html { redirect_to @q_resource, :notice => 'Q resource was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @q_resource.errors, :status => :unprocessable_entity }\n end\n end\n end\n end", "def update\n respond_to do |format|\n if @quack.update(quack_params)\n format.html { redirect_to @quack, notice: 'Quack was successfully updated.' }\n format.json { render :show, status: :ok, location: @quack }\n else\n format.html { render :edit }\n format.json { render json: @quack.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @quetion = Quetion.find(params[:id])\n\n respond_to do |format|\n if @quetion.update_attributes(params[:quetion])\n format.html { redirect_to @quetion, notice: 'Quetion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quetion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @quandary.update(quandary_params)\n format.html { redirect_to @quandary, notice: 'Quandary was successfully updated.' }\n format.json { render :show, status: :ok, location: @quandary }\n else\n format.html { render :edit }\n format.json { render json: @quandary.errors, status: :unprocessable_entity }\n end\n end\n end", "def update #saves and redirects, saves changes\n @line_item = LineItem.find(params[:id])\n @line_item.quantity = params[:quantity]\n @line_item.size_id = params[:size_id]\n @line_item.save\n render json: @line_item\n end", "def update\n respond_to do |format|\n if @qor.update(qor_params)\n format.html { redirect_to @qor, notice: 'Qor was successfully updated.' }\n format.json { render :show, status: :ok, location: @qor }\n else\n format.html { render :edit }\n format.json { render json: @qor.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(id, json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\" \n return HTTParty.put(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end", "def update\n megam_rest.update_quotas(to_hash)\n end", "def update\n respond_to do |format|\n if @qishi.update(qishi_params)\n format.html { redirect_to @qishi, notice: 'Qishi was successfully updated.' }\n format.json { render :show, status: :ok, location: @qishi }\n else\n format.html { render :edit }\n format.json { render json: @qishi.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @quartier = Quartier.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quartier }\n end\n end", "def set_quaderni\n @quaderni = Quaderni.find(params[:id])\n end", "def update\n respond_to do |format|\n if @quimicos_serigrafia_producto.update(quimicos_serigrafia_producto_params)\n format.html { redirect_to @quimicos_serigrafia_producto, notice: 'Quimicos serigrafia producto was successfully updated.' }\n format.json { render :show, status: :ok, location: @quimicos_serigrafia_producto }\n else\n format.html { render :edit }\n format.json { render json: @quimicos_serigrafia_producto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @categoria_quarto.update(categoria_quarto_params)\n format.html { redirect_to @categoria_quarto, notice: 'Categoria quarto was successfully updated.' }\n format.json { render :show, status: :ok, location: @categoria_quarto }\n else\n format.html { render :edit }\n format.json { render json: @categoria_quarto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @quest = Quest.find(params[:id])\n\n respond_to do |format|\n if @quest.update_attributes(params[:quest])\n format.html { redirect_to @quest, notice: 'Quest was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quest.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t\t\t\n\t\t\t\ttparams = params.require(:testimony).permit :quote,:author,:sort,:created_at,:updated_at\n\n\t\t\t\t@testimony = Testimony.find params[:id]\n\n\t\t\t\tif @testimony.update(tparams)\n\n\t\t\t\t\trender json: nil,status: 200\n\n\t\t\t\telse\n\n\t\t\t\t\trender json: nil,status: 422\n\n\t\t\t\tend\n\n\t\t\tend", "def set_quartet\n @quartet = Quartet.find(params[:id])\n end", "def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end", "def update\n respond_to do |format|\n if @tipomaquinat.update(tipomaquinat_params)\n format.html { redirect_to @tipomaquinat, notice: 'Tipomaquinat was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipomaquinat }\n else\n format.html { render :edit }\n format.json { render json: @tipomaquinat.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @queuing = Queuing.find(params[:id])\n\n respond_to do |format|\n if @queuing.update_attributes(params[:queuing])\n format.html { redirect_to @queuing, notice: 'queuing was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @queuing.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n if @agronomiaquimica.update_attributes(params[:agronomiaquimica])\n format.html { redirect_to @agronomiaquimica, notice: 'Agronomiaquimica was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @agronomiaquimica.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_method\n :put_json\n end", "def update\n update_resource @ride, ride_params\n end", "def put(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_put(@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 params.require(%i[id units])\n retrieve_and_validate_put.update!(units: params[:units])\n head :no_content\n end", "def update\n @squish = Squish.find(params[:id])\n \n respond_to do |format|\n if @squish.update_attributes(params[:squish])\n format.html { redirect_to @squish, notice: 'Squish was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @squish.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n render json: Item.update(params[\"id\"], params[\"item\"])\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n respond_to do |format|\n if @q.update(q_params)\n format.html { redirect_to @q, notice: 'Q was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @q.errors, status: :unprocessable_entity }\n end\n end\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 update_radios_for_array(args = {}) \n put(\"/radios.json/#{args[:arrayId]}\", args)\nend", "def update\n @squishee_cup = SquisheeCup.find(params[:id])\n puts params.to_json\n respond_to do |format|\n if @squishee_cup.update_attributes(params[:squishee_cup])\n format.html { redirect_to @squishee_cup, notice: 'Squishee cup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @squishee_cup.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(*args)\n request :put, *args\n end", "def update\n respond_to do |format|\n\n format.json { render json: Axis.find(params[:id]).update( name: params[:name]) }\n end\n\n # end\n end", "def set_quizz\n @quizz = Quizz.find(params[:id])\n end", "def update\n @clique = Clique.find(params[:id])\n\n respond_to do |format|\n if @clique.update_attributes(params[:clique])\n flash[:notice] = 'Clique was successfully updated.'\n format.html { redirect_to(@clique) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @clique.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 respond_to do |format|\n if @arquife.update(arquife_params)\n format.html { redirect_to @arquife, notice: 'Arquive was successfully updated.' }\n format.json { render :show, status: :ok, location: @arquife }\n else\n format.html { render :edit }\n format.json { render json: @arquife.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path, data = {})\n # Allow format override\n format = data.delete(:format) || @format\n # Clear cache\n expire_matching \"#{parent_path(path)}.*\"\n # Extract return unit params\n query_params = {}\n query_params[:returnUnit] = data.delete(:returnUnit) if data[:returnUnit]\n query_params[:returnPerUnit] = data.delete(:returnPerUnit) if data[:returnPerUnit]\n # Create PUT request\n put_params = {\n :verbose => DEBUG,\n :method => \"put\",\n :body => form_encode(data)\n }\n put_params[:params] = query_params unless query_params.empty?\n put = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", put_params)\n # Send request\n do_request(put, format)\n end", "def set_quizz\n @quizz = Quizz.find(params[:id])\n end", "def update\n if @v1_question.update(v1_question_params)\n render json: @v1_question, status: :ok\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end", "def getQuartier\r\n \tarrondissement = params[:id]\r\n \trender json: Quartier.where(arrondissement_id: arrondissement)\r\n end", "def update\n @qurriculum = current_user.qurriculums.find(params[:id])\n\n respond_to do |format|\n if @qurriculum.update_attributes(params[:qurriculum])\n format.html { redirect_to @qurriculum, notice: 'Qurriculum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @qurriculum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @questao.update(questao_params)\n format.html { redirect_to @questao, notice: 'Questao was successfully updated.' }\n format.json { render :show, status: :ok, location: @questao }\n else\n format.html { render :edit }\n format.json { render json: @questao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @aquarium = Aquarium.find(params[:id])\n\n respond_to do |format|\n if @aquarium.update_attributes(params[:aquarium])\n format.html { redirect_to @aquarium, notice: 'Aquarium was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @aquarium.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @quizzes_question.update(quizzes_question_params)\n if params[:commit] =~ /add/i\n format.html { redirect_to edit_quiz_question_path(@question.quiz, @question) }\n else\n format.html { redirect_to quiz_questions_path(@question.quiz), notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @quizzes_question }\n end\n else\n format.html { render :edit }\n format.json { render json: @quizzes_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n client=Client.find_by_id params[:id]\n if client!= nil\n client.cedula=params[:cedula] ? params[:cedula]: client.cedula\n client.sector=params[:sector] ? params[:sector]: client.sector\n client.nombre=params[:nombre] ? params[:nombre]: client.nombre\n client.telefono=params[:telefono] ? params[:telefono]: client.telefono\n client.pagina=params[:pagina] ? params[:pagina]: client.pagina\n client.direccion=params[:direccion] ? params[:direccion]: client.direccion\n if client.save\n render(json: client, status: 201)\n end \n else\n render(json: client.errors, status: 404)\n end \n end", "def set_quimicos_serigrafia_producto\n @quimicos_serigrafia_producto = QuimicosSerigrafiaProducto.find(params[:id])\n end", "def raw_put(path, body, options = {})\n # Allow format override\n format = options.delete(:format) || @format\n # Clear cache\n expire_matching \"#{parent_path(path)}.*\"\n # Create PUT request\n put = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", \n :verbose => DEBUG,\n :method => \"put\",\n :body => body,\n :headers => { :'Content-type' => options[:content_type] || content_type(format) }\n )\n # Send request\n do_request(put, format)\n end", "def update\n @cheque = Cheque.find(params[:id])\n\n respond_to do |format|\n if @cheque.update_attributes(params[:cheque])\n format.html { redirect_to @cheque, notice: 'Cheque was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cheque.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path, params={})\n RestClient.put request_base+path, params\n end", "def update\n respond_to do |format|\n if @quest.update(quest_params)\n format.html { redirect_to @quest, notice: 'Quest was successfully updated.' }\n format.json { render :show, status: :ok, location: @quest }\n else\n format.html { render :edit }\n format.json { render json: @quest.errors, status: :unprocessable_entity }\n end\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 put(path, data = {})\n request 'PUT', path, body: data.to_json\n end", "def update\n @estoques = Estoque.find(params[:id])\n\n respond_to do |format|\n if @estoques.update_attributes(params[:estoque])\n flash[:notice] = 'ESTOQUE SALVO COM SUCESSO.'\n format.html { redirect_to(@estoques) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estoques.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @requiero.update(requiero_params)\n format.html { redirect_to @requiero, notice: 'Requiero was successfully updated.' }\n format.json { render :show, status: :ok, location: @requiero }\n else\n format.html { render :edit }\n format.json { render json: @requiero.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.json { render :json => 'Question updated OK' }\n format.xml { head :ok }\n else\n format.json { render :json => @question.errors }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n # exception if not HTTP POST\n raise \"Only POST to this route!\" unless env[\"REQUEST_METHOD\"] == \"POST\"\n body = env[\"rack.input\"].read\n astr = body.split(\"&\")\n params = {}\n astr.each do |a|\n name, val = a.split \"=\"\n params[name] = val\n end\n quote = FileModel.find(params[\"id\"].to_i)\n quote[\"submitter\"] = params[\"submitter\"]\n quote.save\n\n render :quote, :obj => quote\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 @sinh_vien = SinhVien.find(params[:id])\n\n respond_to do |format|\n if @sinh_vien.update_attributes(params[:sinh_vien]) \n format.json { head :no_content }\n else \n format.json { render json: @sinh_vien.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_quandary\n @quandary = Quandary.find(params[:id])\n end", "def update\n respond_to do |format|\n if @cheque.update(cheque_params)\n format.html { redirect_to @cheque, notice: 'Cheque was successfully updated.' }\n format.json { render :show, status: :ok, location: @cheque }\n else\n format.html { render :edit }\n format.json { render json: @cheque.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def update\n @chronicle = Chronicle.find(params[:id])\n\n respond_to do |format|\n if @chronicle.update_attributes(params[:chronicle])\n format.html { redirect_to @chronicle, notice: 'Chronicle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @chronicle.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @quadra.update(quadra_params)\n format.html { redirect_to quadras_url, notice: 'Quadra atualizada com sucesso.' }\n format.json { render :show, status: :ok, location: @quadra }\n else\n format.html { render :edit }\n format.json { render json: @quadra.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @quiebre.update(quiebre_params)\n format.html { redirect_to @quiebre, notice: 'Quiebre was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @quiebre.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @inquilino.update(inquilino_params)\n\n format.html {redirect_to @inquilino, notice: 'Inquilino atualizado com sucesso!.'}\n format.json {render :show, status: :ok, location: @inquilino}\n else\n format.html {render :edit}\n format.json {render json: @inquilino.errors, status: :unprocessable_entity}\n end\n end\n end", "def update\n respond_to do |format|\n if @movimentode_estoque.update(movimentode_estoque_params)\n format.html { redirect_to @movimentode_estoque, notice: 'Movimentode estoque was successfully updated.' }\n format.json { render :show, status: :ok, location: @movimentode_estoque }\n else\n format.html { render :edit }\n format.json { render json: @movimentode_estoque.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @estoquemp = Estoquemp.new(estoquemp_params)\n \n \n respond_to do |format|\n if @estoquemp.update(estoquemp_params)\n format.html { redirect_to saidamp_path, flash: { success: 'Estoque foi atualizado com sucesso!' } }\n format.json { render :show, status: :ok, location: @estoquemp }\n else\n format.html { render :edit }\n format.json { render json: @estoquemp.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @paroquia = Paroquia.find(params[:id])\n\n respond_to do |format|\n if @paroquia.update_attributes(params[:paroquia])\n flash[:notice] = 'Paroquia was successfully updated.'\n format.html { redirect_to(@paroquia) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @paroquia.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_method\n :http_put\n end", "def create_method\n :http_put\n end" ]
[ "0.62870973", "0.6216404", "0.6142401", "0.6108412", "0.6108412", "0.60980576", "0.5995492", "0.5926216", "0.59142363", "0.5902625", "0.5878378", "0.58767843", "0.5857434", "0.5810647", "0.5791117", "0.57909423", "0.57608956", "0.5723608", "0.5706876", "0.5699816", "0.5692743", "0.56912744", "0.56828433", "0.5666162", "0.56618994", "0.5653473", "0.56505", "0.5643608", "0.5642489", "0.56422174", "0.56232387", "0.56137633", "0.56125623", "0.55885714", "0.5587881", "0.5572862", "0.55663216", "0.55564153", "0.5534625", "0.55164933", "0.5512354", "0.5502962", "0.54963803", "0.5496012", "0.54939514", "0.5483279", "0.54793376", "0.54638976", "0.54626673", "0.54481786", "0.5444255", "0.54407954", "0.5438457", "0.5438384", "0.54372865", "0.54371816", "0.54340285", "0.5427815", "0.54193974", "0.54192877", "0.5415922", "0.5396687", "0.5394758", "0.539068", "0.53866297", "0.5384257", "0.53816724", "0.5366557", "0.53594667", "0.53574705", "0.53550005", "0.5354347", "0.5351268", "0.5343613", "0.53395885", "0.53331095", "0.5325407", "0.53251463", "0.53247386", "0.5320065", "0.53181595", "0.5318076", "0.5311338", "0.5309964", "0.5301076", "0.53003484", "0.5297179", "0.5296707", "0.5291678", "0.5288966", "0.52854675", "0.52830416", "0.5281506", "0.5279236", "0.5277789", "0.527724", "0.52768546", "0.5276216", "0.52733487", "0.52733487" ]
0.6713708
0
DELETE /quartiers/1 DELETE /quartiers/1.json
def destroy @quartier = Quartier.find(params[:id]) @quartier.destroy respond_to do |format| format.html { redirect_to quartiers_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @quiniela = Quiniela.find(params[:id])\n @quiniela.destroy\n\n respond_to do |format|\n format.html { redirect_to quinielas_url }\n format.json { head :ok }\n end\n end", "def destroy\n @quatum.destroy\n respond_to do |format|\n format.html { redirect_to quata_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @quinto.destroy\n respond_to do |format|\n format.html { redirect_to quintos_url, notice: 'Quinto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @qu = Qu.find(params[:id])\n @qu.destroy\n\n respond_to do |format|\n format.html { redirect_to qus_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @qu = Qu.find(params[:id])\n @qu.destroy\n respond_to do |format|\n format.html { redirect_to qus_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @quaderni.destroy\n\n respond_to do |format|\n format.html { redirect_to quadernis_url, notice: \"Quaderni was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @quartet = Quartet.find(params[:id])\n @quartet.destroy\n\n respond_to do |format|\n format.html { redirect_to quartets_url }\n format.json { head :ok }\n end\n end", "def destroy\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n @agronomiaquimica.destroy\n\n respond_to do |format|\n format.html { redirect_to agronomiaquimicas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @quiebre.destroy\n respond_to do |format|\n format.html { redirect_to quiebres_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @aquarium = Aquarium.find(params[:id])\n @aquarium.destroy\n\n respond_to do |format|\n format.html { redirect_to aquaria_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @quartet.destroy\n respond_to do |format|\n format.html { redirect_to quartets_url, notice: 'Quartet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @quay = Quay.find(params[:id])\n @quay.destroy\n\n respond_to do |format|\n format.html { redirect_to(quays_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estoque = Estoque.find(params[:id])\n @estoque.destroy\n\n respond_to do |format|\n format.html { redirect_to estoques_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @uchronia = Uchronia.find(params[:id])\n @uchronia.destroy\n\n respond_to do |format|\n format.html { redirect_to uchronias_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @quize = Quize.find(params[:id])\n @quize.destroy\n\n respond_to do |format|\n format.html { redirect_to quizes_url }\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 delete(path)\n RestClient.delete request_base+path\n end", "def delete\n render json: Item.delete(params[\"id\"])\n end", "def destroy\n # @bill_quorum = BillQuorum.find(params[:id])\n @bill_quorum.destroy\n\n respond_to do |format|\n format.html { redirect_to bill_quorums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @thought = Thought.find(params[:id])\n @quast = @thought.quastion\n @thought.destroy\n\n respond_to do |format|\n format.html { redirect_to quastion_path(@quast) }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @qa = Qa.find(params[:id])\n @qa.destroy\n\n respond_to do |format|\n format.html { redirect_to qas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @qux.destroy\n respond_to do |format|\n format.html { redirect_to quxes_url, notice: 'Qux was successfully destroyed.' }\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 @clique = Clique.find(params[:id])\n @clique.destroy\n\n respond_to do |format|\n format.html { redirect_to(cliques_url) }\n format.xml { head :ok }\n end\n end", "def delete\n request(:delete)\n end", "def destroy\n @quandary.destroy\n respond_to do |format|\n format.html { redirect_to quandaries_url, notice: 'Quandary was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @quize.destroy\n respond_to do |format|\n format.html { redirect_to quizes_url, notice: 'Quize was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cheque = Cheque.find(params[:id])\n @cheque.destroy\n\n respond_to do |format|\n format.html { redirect_to cheques_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @arquife.destroy\n respond_to do |format|\n format.html { redirect_to arquives_url, notice: 'Arquive was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @rnaseq = Rnaseq.find(params[:id])\n @rnaseq.destroy\n\n respond_to do |format|\n format.html { redirect_to rnaseqs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @quete.destroy\n respond_to do |format|\n format.html { redirect_to quetes_url, notice: 'quete was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_item(id)\n record \"/todos/delete_item/#{id}\"\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 @quetion = Quetion.find(params[:id])\n @quetion.destroy\n\n respond_to do |format|\n format.html { redirect_to quetions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dynamique = Dynamique.find(params[:id])\n @dynamique.destroy\n\n respond_to do |format|\n format.html { redirect_to dynamiques_url }\n format.json { head :no_content }\n end\n end", "def destroy\n #na real, cada question pertence a um quiz, basta achar a question de mesma id\n @qq = QuizQuestion.where(question: @question)\n @qq.destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @giang_vien = GiangVien.find(params[:id])\n @giang_vien.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def destroy\n @quest_item.destroy\n respond_to do |format|\n format.html { redirect_to admin_quest_items_url, notice: 'Всё норм' }\n format.json { head :no_content }\n end\n end", "def destroy\n @q = Q.find_by_unique_id(params[:id])\n @q.destroy\n\n respond_to do |format|\n format.html { redirect_to qs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @questao = Questao.find(params[:id])\n @questao.destroy\n\n respond_to do |format|\n format.html { redirect_to(questoes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @requiero.destroy\n respond_to do |format|\n format.html { redirect_to requieros_url, notice: 'Requiero was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(*rest) end", "def destroy\n @requerimiento = Requerimiento.find(params[:id])\n @requerimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to requerimientos_url }\n format.json { head :ok }\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 @sinh_vien = SinhVien.find(params[:id])\n @sinh_vien.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def destroy\n @cheque.destroy\n respond_to do |format|\n format.html { redirect_to cheques_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @quarto.destroy\n respond_to do |format|\n format.html { redirect_to quartos_url, notice: 'Quarto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def borrar \n\n fiesta.destroy\n render json: fiesta \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 @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @movimentacao_de_estoque = MovimentacaoDeEstoque.find(params[:id])\n @movimentacao_de_estoque.destroy\n\n respond_to do |format|\n format.html { redirect_to movimentacao_de_estoques_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipomaquinat.destroy\n respond_to do |format|\n format.html { redirect_to tipomaquinats_url, notice: 'Tipomaquinat was successfully destroyed.' }\n format.json { head :no_content }\n end\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 @paroquia = Paroquia.find(params[:id])\n @paroquia.destroy\n\n respond_to do |format|\n format.html { redirect_to(paroquias_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 @quadra.destroy\n respond_to do |format|\n format.html { redirect_to quadras_url, notice: 'Quadra deletada com sucesso.' }\n format.json { head :no_content }\n end\n end", "def delete(options={})\n connection.delete(\"/\", @name)\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @uginuce.sheep.update status:'na farmi'\n @uginuce.destroy\n respond_to do |format|\n format.html { redirect_to uginuces_url }\n format.json { head :no_content }\n end\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\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 url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def destroy\n # render plain: @disqux.inspect\n @disqux.destroy\n respond_to do |format|\n format.html { redirect_to project_disquxes_path(@project), notice: 'Disqux was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @quimicos_serigrafia_producto.destroy\n respond_to do |format|\n format.html { redirect_to quimicos_serigrafia_productos_url, notice: 'Quimicos serigrafia producto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete!\n request! :delete\n end", "def destroy\n @ruby.destroy\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @uchronist = Uchronist.find(params[:id])\n @uchronist.destroy\n\n respond_to do |format|\n format.html { redirect_to uchronists_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @racquet.destroy\n respond_to do |format|\n format.html { redirect_to racquets_url, notice: t('racquets.destroy.success') }\n format.json { head :no_content }\n end\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\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 @veiculo = Veiculo.find(params[:id])\n @veiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to veiculos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @craque = Craque.find(params[:id])\n @craque.destroy\n\n respond_to do |format|\n format.html { redirect_to craques_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @squish = Squish.find(params[:id])\n @squish.destroy\n \n respond_to do |format|\n format.html { redirect_to squishes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @aliquotum = Aliquotum.find(params[:id])\n @aliquotum.destroy\n\n respond_to do |format|\n format.html { redirect_to aliquota_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @qborentestimate = Qborentestimate.find(params[:id])\n @qborentestimate.destroy\n\n respond_to do |format|\n format.html { redirect_to qborentestimates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @chronicle.destroy\n respond_to do |format|\n format.html { redirect_to chronicles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @soiree = Soiree.find(params[:id])\n @soiree.destroy\n\n respond_to do |format|\n format.html { redirect_to soirees_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exura = Exura.find(params[:id])\n @exura.destroy\n\n respond_to do |format|\n format.html { redirect_to exuras_url }\n format.json { head :no_content }\n end\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 @articulo = Articulo.find(params[:id])\n @articulo.destroy\n\n respond_to do |format|\n format.html { redirect_to articulos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @articulo = Articulo.find(params[:id])\n @articulo.destroy\n\n respond_to do |format|\n format.html { redirect_to articulos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @articulo = Articulo.find(params[:id])\n @articulo.destroy\n\n respond_to do |format|\n format.html { redirect_to articulos_url }\n format.json { head :ok }\n end\n end", "def delete\n \n end", "def destroy\n @jedi = Jedi.find(params[:id])\n @jedi.destroy\n\n respond_to do |format|\n format.html { redirect_to jedis_url }\n format.json { head :no_content }\n end\n end", "def delete\n sql = \"DELETE FROM albums WHERE id = $1\"\n values = [@id]\n SqlRunner.run(sql, values)\nend", "def destroy\n @six.destroy\n respond_to do |format|\n format.html { redirect_to sixes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @humanidades3 = Humanidades3.find(params[:id])\n @humanidades3.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades3s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tieu_chi = TieuChi.find(params[:id])\n @tieu_chi.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_tieu_chis_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @diaque = Diaque.find(params[:id])\n @diaque.destroy\n\n respond_to do |format|\n format.html { redirect_to(diaquen_url) }\n format.xml { head :ok }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @squawk = Squawk.find(params[:id])\n @squawk.destroy\n\n respond_to do |format|\n format.html { redirect_to squawks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan_quirurgicos = PlanQuirurgico.find(params[:id])\n @plan_quirurgicos.estatus = \"I\"\n @plan_quirurgicos.save \n respond_to do |format|\n format.html { redirect_to plan_quirurgicos_url, notice: 'El Plan quirurgico fue eliminado exitosamente' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tiezi = Tiezi.find(params[:id])\n @tiezi.destroy\n\n respond_to do |format|\n format.html { redirect_to tiezis_url }\n format.json { head :ok }\n end\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end" ]
[ "0.7257976", "0.7106223", "0.70359844", "0.7032195", "0.7014962", "0.6994533", "0.69638085", "0.69634825", "0.69094443", "0.688485", "0.68433696", "0.67736524", "0.6756191", "0.6730024", "0.6697799", "0.6689893", "0.6688174", "0.6665252", "0.6647299", "0.66252637", "0.66243297", "0.6621371", "0.66125816", "0.66083467", "0.6602709", "0.65971357", "0.6588932", "0.65866137", "0.65826523", "0.657779", "0.657338", "0.6570289", "0.65612227", "0.6558889", "0.65561104", "0.6555586", "0.6553967", "0.6548876", "0.6546609", "0.65461546", "0.6541112", "0.65387243", "0.65383536", "0.65371114", "0.65368307", "0.6531754", "0.65291184", "0.65281105", "0.65274143", "0.65271807", "0.6526286", "0.6519693", "0.6518694", "0.65125626", "0.6511851", "0.651119", "0.6505973", "0.6505544", "0.65055406", "0.65033835", "0.65003693", "0.6499695", "0.64970535", "0.6496495", "0.6496495", "0.6492987", "0.6491568", "0.64886034", "0.6485109", "0.6484755", "0.64826643", "0.6482356", "0.64792717", "0.64792717", "0.64792717", "0.64792717", "0.6478693", "0.6478018", "0.6477398", "0.64677894", "0.6467687", "0.64662147", "0.6464503", "0.64627", "0.64614713", "0.64608735", "0.64608735", "0.64608735", "0.6459333", "0.64578253", "0.6457357", "0.64542973", "0.645225", "0.6451202", "0.64493227", "0.64474785", "0.64432377", "0.64418703", "0.6440345", "0.64394844" ]
0.747771
0
need to override the json view to return what full_calendar is expecting.
def as_json(options = {}) { :id => self.id, :title => self.title, :description => self.description || "", :start => (starts_at).to_datetime.iso8601, :end => (ends_at).to_datetime.iso8601, :allDay => self.all_day, :recurring => false, :url => Rails.application.routes.url_helpers.main_event_event_path(self.main_event.id, id) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => unless starts_at.blank? then starts_at.rfc822 else \"\" end,\n :end => unless ends_at.blank? then ends_at.rfc822 else \"\" end,\n :allDay => self.all_day,\n :recurring => false,\n #:url => Rails.application.routes.url_helpers.event_path(id),\n #:color => \"red\"\n }\n end", "def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => starts_at.rfc822,\n :end => ends_at.rfc822,\n :allDay => self.all_day,\n :recurring => false,\n :url => Rails.application.routes.url_helpers.event_path(id),\n #:color => \"red\"\n }\n\n end", "def as_json(*)\n CalendarJSON.rent(self)\n end", "def show\n render json: @evento.formatted_data.as_json()\n end", "def render_json\n end", "def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => self.starts_at.rfc822,\n :end => self.ends_at.rfc822,\n :allDay => self.all_day,\n :recurring => false,\n :color => self.color.nil? ? \"blue\" : self.color,\n :location => self.location,\n :notes => self.notes,\n :url => self.edit_url #Rails.application.routes.url_helpers.edit_event_path(id)\n }\n end", "def show\n render json: format_event(@event)\n end", "def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => starts_at.rfc822,\n :end => ends_at.rfc822,\n :allDay => self.all_day,\n :recurring => false,\n :backgroundColor => bgColor\n\n #:url => Rails.application.routes.url_helpers.team_event_path(self.team, self.id),\n #:color => \"red\"\n }\n\n end", "def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => starts_at.rfc822,\n :end => ends_at.rfc822,\n :allDay => self.all_day,\n :recurring => false,\n :url => Rails.application.routes.url_helpers.event_path(id)\n }\n \n end", "def as_json(options = {})\n {\n :id => self.id,\n :title => self.titre,\n :description => self.contenu || \"\",\n :start => start_at.rfc822,\n :end => end_at.rfc822,\n :allDay => self.all_day,\n :recurring => false,\n :url => Rails.application.routes.url_helpers.event_path(id)\n }\n end", "def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => starts_at.rfc822,\n :end => ends_at && !ends_at.blank? ? ends_at.rfc822 : '',\n :allDay => self.all_day,\n :color => self.person ? self.person.bg_color : \"#f3f2f2\",\n :borderColor => self.person ? self.person.bg_color : \"#ddd\",\n :textColor => self.person ? self.person.txt_color : \"#666\",\n :className => \"event #{'unsinged' unless self.person}\",\n :recurring => false,\n :resource => self.person ? self.person.id : \"\",\n :resourceId => self.person ? self.person.id : \"\",\n :url => Rails.application.routes.url_helpers.event_path(id)\n }\n \n end", "def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => start_time.rfc822,\n :end => end_time.rfc822,\n :allDay => false,\n :recurring => false,\n :color => self.event_status,\n :textColor => 'black',\n :url => Rails.application.routes.url_helpers.event_path(id)\n }\n end", "def as_json(options = {})\n {\n :id => self.ID,\n :title => self.listing,\n :description => self.summary,\n :start => setTimes(self.eventstartdate, self.eventstarttime),\n :end => setTimes(self.eventenddate, self.eventendtime),\n :allDay => holiday?,\n :recurring => false,\n :url => get_url,\n :color => get_color,\n :textColor => get_text_color\n }\n end", "def fullcalendar_events_json\n events.map do |event|\n {\n id: event.id.to_s,\n title: event.name,\n start: event.starts_at.strftime('%Y-%m-%d %H:%M:%S'),\n end: event.ends_at.strftime('%Y-%m-%d %H:%M:%S'),\n allDay: event.all_day,\n url: event_path(event)\n }\n end\n end", "def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => (starts_at + 5.hours),\n :end => (ends_at + 5.hours),\n :allDay => self.all_day,\n :recurring => false,\n :url => Rails.application.routes.url_helpers.event_path(id)\n }\n \n end", "def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => starts_at.rfc822,\n :end => ends_at.rfc822,\n :url => Rails.application.routes.url_helpers.event_path(id)\n }\n end", "def show\n \trender json: @event\n end", "def show_json\n end", "def index\n respond_to do |format|\n format.html\n format.json { render json: @events }\n end\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def as_json(options = {})\n {\n :id => self.id,\n :title => self.title,\n :description => self.description || \"\",\n :start => self.starts_at.rfc822,\n :end => self.ends_at.rfc822,\n :allDay => self.all_day,\n :recurring => false\n }\n\n end", "def as_json(options = {})\n {\n :id => self.id,\n :title => self.name,\n :description => self.description || \"\",\n :start => starts_at.rfc822,\n :end => ends_at.rfc822,\n :url => Rails.application.routes.url_helpers.select_path(id),\n #:color => \"red\"\n }\n\n end", "def show\n render json: @clock_event\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def format\n :json\n end", "def index\n @events = Event.where('user_id = ?', current_user)\n formatted_events = @events.map do |event|\n format_event event\n end\n\n render json: formatted_events\n end", "def as_json(options = {})\n {\n :id => self.id,\n :title => self.purpose,\n :start => start_time.rfc822,\n :end => end_time.rfc822,\n :allDay => self.allDay,\n :recurring => false,\n :url => Rails.application.routes.url_helpers.reservation_path(id),\n }\n end", "def index\n @events = Event.all\n respond_to do |format|\n format.html \n format.json do\n render :json => {events: @events}\n end\n end\n end", "def index_for_calendar\n # build_calendar_data --> AppointmentsHelper method\n render json: build_calendar_data, status: 200\n end", "def jsonize\n {id: self.id, title: self.title, start: self.start_date.strftime('%a %b %d %Y'), end: self.end_date.strftime('%a %b %d %Y'), resource: self.resource_id}\n end", "def show\n respond_to do |format|\n format.html \n # format.json { render json: @day_availability }\n end\n end", "def render(*)\n respond_to do |format|\n format.jsonapi { super }\n format.json { super }\n end\n end", "def show_events\n render json: current_user\n end", "def json\n {\"creation_date\" => @creation_date}\n end", "def upcoming_events\n @events = Event.upcoming\n respond_to do |format|\n format.html { render :partial=>\"home/upcoming_events\", :locals=>{:upcoming_events=>@events} }\n format.json { render :layout => false, :json => @events }\n format.js\n end\n end", "def show\n @calendar_event = CalendarEvent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @calendar_event }\n end\n end", "def as_json(options = {})\n {\n :id => self.id,\n :title => self.title+\" by \"+self.counselor.full_name,\n :start => start_at.rfc822,\n :end => end_at.rfc822,\n :allDay => 0,\n :recurring => false\n # :url => '/'+self.counselor.class.to_s.downcase+'/dashboards'\n }\n\n end", "def show\n render json: @event_configuration.to_json\n end", "def index\n @histories = History.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: json_out = {\n \"timeline\"=>\n {\n \"headline\"=>\"The Main Timeline Headline Goes here\",\n \"type\"=>\"default\",\n \"text\"=>\"<p>Intro body text goes here, some HTML is ok</p>\",\n \"asset\"=> {\n \"media\"=>\"http://www.exglam.com/wp-content/uploads/2013/02/Kajal-agarwal-in-Blue-and-white-Fade-Short-with-white-Top-and-a-Blue-bow-in-hair.jpg\",\n \"credit\"=>\"Credit Name Goes Here\",\n \"caption\"=>\"Caption text goes here\"\n },\n\n \"date\"=> @histories.map { |timeline| {\"startDate\" => timeline.startdate.strftime(\"%Y,%m,%d\"),\"endDate\" => timeline.enddate.strftime(\"%Y,%m,%d\"),\"headline\" => timeline.headline,\"text\" => timeline.content, \"asset\" => {\"media\" => timeline.media}}},\n\n\n \"era\"=> [\n {\n \"startDate\"=>\"2011,12,10\",\n \"endDate\"=>\"2011,12,11\",\n \"headline\"=>\"Headline Goes Here\",\n \"text\"=>\"<p>Body text goes here, some HTML is OK</p>\",\n \"tag\"=>\"This is Optional\"\n }\n\n ]\n }\n } }\n end\n end", "def render\n Oj.dump(to_json)\n end", "def fullcalendarify\n\t\t{\n\t\t\tid: id,\n\t\t\tstart: start_date.iso8601,\n\t\t\tend: end_date.iso8601,\n\t\t\ttitle: title + (showtime ? \"\\n#{start_date.strftime \"%l:%M %p\"} - #{end_date.strftime \"%l:%M %p\"}\" : \"\"),\n\t\t\turl: \"/events/#{id}\",\n\t\t\tcolor: color\n\t\t}\n\tend", "def as_json(options = {})\n {\n :title => self.title,\n :start => self.start_time,\n :end => self.end_time,\n :description => self.description\n }\n end", "def show\n render json: @dia_evento\n end", "def index\n # @weekdays = Weekday.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Oj.dump(@weekdays, mode: :compat) }\n end\n end", "def show\n render json: EventSerializer.new(@event).as_json, status: 200\n end", "def show\n render json: @business_event.to_json(\n :methods => [:activity_types],\n include: {\n business_addresses: {only: [:id, :name, :address, :latitude, :longitude]},\n event_activities: {except: []}\n }),\n status: 200\n end", "def show\n @calendar_date = CalendarDate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @calendar_date }\n end\n end", "def as_json\n # if it belongs to a department, user_id = 0\n user_id = self.user ? self.user.id : 0 \n {\n :id => self.id,\n :notify => self.notify,\n :kind => self.kind,\n :current_state => self.status,\n :title => self.overview,\n :tag => self.tag,\n :long_description => self.content,\n :editable => true,\n :start => self.started,\n :finish => self.finished,\n :end => self.finished,\n :department_id => self.department_id,\n :user_id => user_id,\n :allDay => false,\n :url => Rails.application.routes.url_helpers.activity_path(id) \n }\n end", "def show\n render json: @formato\n end", "def show\n render json: @event_requirement\n end", "def index\n @events = Event.all\n respond_to do |format|\n format.html \n format.json \n end\n end", "def index\n @events = @category.events\n render json: @events \n end", "def show\n @event = Event.find(params[:id])\n\n # ^^^^ + show.json.jbuilder + builder.key_format camelize: :lower in environment.rb will\n # convert ruby's model_properties into json's modelProperties.\n # Verify by viewing http://localhost:3000/events/1926.json and seeing camelcase, not snakecase.\n # and it replaces the code below:\n\n # respond_to do |format|\n # format.html\n # format.json { render :json => @event }\n # end\n end", "def as_json(options = {})\r\n\t\tsuper\r\n\t\t {type: type,\r\n\t\t \t Title: Title,\r\n\t\t \t Authors: authors,\r\n\t\t \t With: with,\r\n\t\t \t Details: details,\r\n\t\t \t Year: year\r\n\t\t \t }\r\n\tend", "def new\n @calendar_event = CalendarEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @calendar_event }\n end\n end", "def as_json(options = {})\n if self.category == 'platform' && self.status == 'unconfirmed'\n bck_color = '#d2322d'\n text_color = '#fff'\n elsif self.category == 'platform'\n bck_color = '#60A869'\n text_color = '#004203'\n elsif self.category == 'sync'\n bck_color = '#aaa'\n text_color = '#7e7e7e'\n else\n #bck_color = '#91C9DF'\n #text_color = '#2B6379'\n bck_color = '#808080'\n text_color = '#444444'\n end\n if self.category == 'sync'\n title = 'Busy Time (sync)'\n else\n title = [self.user_name, self.user ? self.user.name : nil, self.therapy_name, self.title, 'Appointment'].reject{ |c| !c.present? }\n title = title[0]\n end\n {\n id: self.id,\n title: title,\n address: self.address || \"\",\n start: self.service_starts_at,\n # fullCalendar stores end time as exclusive\n end: service_ends_at + 1.second,\n color: bck_color,\n textColor: text_color\n }\n end", "def render\n Oj.dump(to_json)\n end", "def as_json(options = {})\n {\n :id => self.id,\n :title => self.subject.name,\n :description => self.description || \"\",\n :start => starts_at.rfc822,\n :end => ends_at.rfc822,\n :allDay => self.all_day,\n :recurring => false,\n :url => Rails.application.routes.url_helpers.routine_path(id)\n }\n end", "def formatJSON\n # @formattedContents = .... whatever puts it into JSON\n end", "def show\n @venue = Venue.find(params[:id])\n\n respond_to do |format|\n #format.html # show.html.erb\n format.json { render :json => @venue.to_json(:except=>[:display, :user_id, :modified_user_id]), :callback=>params[:callback] }\n end\n end", "def show\n render json: @day, include: [:activities]\n end", "def index\n # @schedules = Schedule.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Oj.dump(@schedules, mode: :compat) }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event_import_result }\n end\n end", "def show\n render json: @service_schedule\n end", "def to_json\n Formatter::JSON.render(self)\n end", "def as_json(options={})\n\t\tsuper(:methods => [:display_result,:display_normal_biological_interval,:display_count_or_grade,:display_comments_or_inference,:test_is_abnormal,:test_is_ready_for_reporting,:test_is_verified, :successfully_updated_by_lis])\n\tend", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @holiday }\n end\n end", "def show\n @calendar = Calendar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @calendar }\n end\n end", "def show\n @calendar = Calendar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @calendar }\n end\n end", "def dayIndex\n render json: Restaurant.restaurantsDay\n end", "def new\n @calendar = Calendar.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @calendar }\n end\n end", "def show\n render json: @event, status: :ok\n end", "def dates\n render json: @standings\n end", "def votecannotbecast\t\t\n\t\trespond_to do |format|\n\t\t\tformat.js {}\n\t\tend\n\tend", "def new\n @calendar_date = CalendarDate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @calendar_date }\n end\n end", "def index\n \n @events = current_user.events\n \n \n respond_to do |format|\n format.html {}\n format.json { render json: Event.events_to_json(@events) }\n end\n end", "def tojson\n\t\tend", "def json\n {}\n end", "def as_json(options={})\n super(:except => [:created_at, :updated_at])\n end", "def as_json(options={})\n super(:except => [:created_at, :updated_at])\n end", "def as_json(options={})\n super(:except => [:created_at, :updated_at])\n end", "def show\n @event = Event.find(params[:id])\n if ((@event.opening_bands == nil or @event.opening_bands == \"\") and @event.bands)\n @event.opening_bands = \"\";\n @event.bands.each do |b|\n if (@event.band and b.name != @event.band.name)\n @event.opening_bands = @event.opening_bands + \" \" + b.name\n end\n end\n end\n if (@event.event_datetime.hour == 00)\n if (@event.venue.default_time != nil)\n @event.timestr = @event.venue.default_time.strftime(\"%l %p\")\n else\n @event.timestr = \"\"\n end\n else\n @event.timestr = @event.event_datetime.strftime(\"%l %p\")\n end\n puts @event.timestr\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event.to_json(:methods => [:timestr]) }\n end\n end", "def new\n @calendar = Calendar.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @calendar }\n end\n end", "def new\n @calendar = Calendar.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @calendar }\n end\n end", "def get_events\t\t\t\n @task = UserEvent.where(\"user_id\"=>current_user.id)\n events = []\n @task.each do |task|\n events << {:id => task.id, :title => task.title, :start => DateTime.parse(task.start.to_s).strftime(\"%Y-%m-%d\"), :end => DateTime.parse(task.end.to_s).strftime(\"%Y-%m-%d\") }\n end\n render :text => events.to_json \n end", "def index\n @event = Event.all\n render json: @event\n end", "def as_json(*)\n super(except: %i[created_at updated_at deleted_at])\n end", "def index\n @events = Event.all\n render json: @events\n end", "def events_jsonify(events)\n\t\t\tevents.collect do |event|\n\t\t\t\t{ id: event.id,\n\t\t\t\t\tname: event.name,\n\t\t\t\t\tsummary: event.summary,\n\t\t\t\t\tstart_era: event.start_era,\n\t\t\t\t\tstart_date: \"#{event.start_date or 0}/#{event.start_month or 0}/#{event.start_year}\",\n\t\t\t\t\tend_date: \"#{event.end_date or 0}/#{event.end_month or 0}/#{event.end_year or event.start_year}\",\n\t\t\t\t\tarcs: event.arcs,\n\t\t\t\t\tentities: event.entities }\n\t\t\tend.to_json\n\t\tend", "def index\n respond_with(events) do |format|\n format.ics { send_data(events_as_ical, filename: \"#{current_user.username}-#{current_instance.subdomain}-calendar.ics\", type: Mime::Type.lookup_by_extension('ics')) }\n format.json { render json: fullcalendar_events_json }\n end\n end", "def index\n @events = @calendar.events.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @events }\n end\n end", "def index\n @events = Event.all\n\n render json: @events\n end", "def to_json\n attributes = self.values\n attributes[:date_published] = self.date_published_iso8601\n return attributes.to_json\n end", "def list\n @events = Event.coming_events\n respond_to do |format|\n format.html do\n render layout: 'events'\n end\n format.json do \n events = @events.map {|event| {event: event, users: event.users, applied: event.users.include?(current_user) }}\n render json: events \n end\n end\n end", "def as_json(options=nil)\n if options && options[:presenter_action] && json_presenter_class\n json_presenter_class.new(self).as_json(options)\n else\n super(options)\n end\n end" ]
[ "0.74432015", "0.7395977", "0.73539627", "0.7333909", "0.7332232", "0.72645205", "0.7234801", "0.7228743", "0.7222693", "0.71649045", "0.71444577", "0.71275014", "0.70618075", "0.7060224", "0.7038122", "0.7007454", "0.6857755", "0.67946815", "0.67614126", "0.6721101", "0.6721101", "0.6721101", "0.6721101", "0.6721101", "0.6645688", "0.6624477", "0.66208696", "0.6614907", "0.6614907", "0.6592085", "0.65904886", "0.65770876", "0.65606046", "0.65455055", "0.6538538", "0.65316844", "0.65230674", "0.65218943", "0.64861435", "0.64655316", "0.64584756", "0.6456597", "0.6452053", "0.6443604", "0.64285535", "0.64230824", "0.64227533", "0.6419853", "0.6418022", "0.6401142", "0.637914", "0.63778067", "0.6368243", "0.63614464", "0.63479394", "0.6347822", "0.6339534", "0.633338", "0.6330171", "0.6322412", "0.6321814", "0.6302819", "0.62931865", "0.6288712", "0.62849945", "0.6278364", "0.6270554", "0.6265628", "0.62649566", "0.62608755", "0.62580436", "0.62497663", "0.62450796", "0.62450796", "0.62448883", "0.62428755", "0.6239873", "0.62325275", "0.62245446", "0.62226224", "0.6221883", "0.6221525", "0.6207872", "0.6202459", "0.6202459", "0.6202459", "0.6201881", "0.61950827", "0.61950827", "0.61932147", "0.61931664", "0.61882615", "0.61849797", "0.6184722", "0.61832535", "0.6181839", "0.6173582", "0.6171957", "0.61653835", "0.61614954" ]
0.7032366
15
This software may be used and distributed solely under the terms of the MIT license (License). You should find a copy of the License in LICENSE.TXT or at By downloading or using this software you accept the terms and the liability disclaimer in the License.
def affiliations_xml <<-NODE <iq type='result' from='pubsub.shakespeare.lit' to='[email protected]' id='affil1'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <affiliations> <affiliation node='node1' affiliation='owner'/> <affiliation node='node2' affiliation='owner'/> <affiliation node='node3' affiliation='publisher'/> <affiliation node='node4' affiliation='outcast'/> <affiliation node='node5' affiliation='member'/> <affiliation node='node6' affiliation='none'/> </affiliations> </pubsub> </iq> NODE end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def check_license()\n return true\n end", "def terms_of_use\n end", "def northern_irish_driving_licence; end", "def library; end", "def library; end", "def license\n File.read file_path('LICENSE') if license?\n end", "def standalone; end", "def vendor; end", "def license\n @header.license\n end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def licensed?\n end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def implementation; end", "def implementation; end", "def copyright_generator\n PersonalSiteViewTool::Renderer.copyright 'Gustavo Valenzuela', 'All rights reserved.'\n end", "def external; end", "def src; end", "def src; end", "def src; end", "def how_it_works\r\n end", "def public; end", "def public; end", "def cobasysprog\n end", "def schubert; end", "def dh; end", "def internal; end", "def conscientious_require; end", "def license\n read_property 'License'\n end", "def main\n\n end", "def license\n FFI::GDAL.GDALVersionInfo('LICENSE')\n end", "def ios; end", "def requirements; end", "def requirements; end", "def requirements; end", "def requirements; end", "def contract; end", "def contract; end", "def server_software; end", "def usage; end", "def usage; end", "def test_copyright\n assert_equal ' 2014 Tribune Content Agency, LLC', @loader.copyright[1..-1]\n end", "def main; end", "def about_us; end", "def strain; end", "def license_title\n case self.license\n when \"cc-by-sa-3.0\"\n \"Creative Commons Attribution ShareAlike 3.0\"\n when \"cc-by-nc-sa-2.0-uk\"\n \"Creative Commons Attribution-NonCommerical-ShareAlike 2.0 UK: England & Wales\"\n end\n end", "def private_method\n end", "def main\n end", "def credits; end", "def who_we_are\r\n end", "def upload_licenses\n \n end", "def verdi; end", "def def_version; end", "def copyright\n contexts.shorttext7\n end", "def scientist; end", "def header; end", "def header; end", "def header; end", "def source() end", "def opening; end", "def opening; end", "def opening; end", "def version()\n $stderr.puts WOL_VERSION\n $stderr.puts 'Written by Kevin R. Bullock.'\n $stderr.puts\n $stderr.puts 'Copyright (C) 2004 Kevin R. Bullock.'\n $stderr.puts 'This is free software; see the source for copying conditions. There is NO'\n $stderr.puts 'warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.'\n end" ]
[ "0.6296303", "0.6276106", "0.61861044", "0.6066651", "0.6016199", "0.6016199", "0.5958701", "0.5822583", "0.58213276", "0.5749377", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5737651", "0.5698839", "0.56407803", "0.56407803", "0.56407803", "0.56407803", "0.56407803", "0.56407803", "0.56407803", "0.56407803", "0.56407803", "0.56407803", "0.56407803", "0.56407803", "0.56407803", "0.56407803", "0.56407803", "0.56407803", "0.56407803", "0.5639098", "0.5639098", "0.56161803", "0.55975413", "0.5581679", "0.5581679", "0.5581679", "0.55407685", "0.5518624", "0.5518624", "0.54814476", "0.54791546", "0.54563445", "0.54477835", "0.54422843", "0.54400164", "0.54324615", "0.54181397", "0.5416805", "0.5414972", "0.5414972", "0.5414972", "0.5414972", "0.5410617", "0.5410617", "0.5408956", "0.54032314", "0.54032314", "0.53904706", "0.53894305", "0.53535014", "0.5352874", "0.534945", "0.53463984", "0.5341236", "0.5309792", "0.5300895", "0.53008634", "0.52938825", "0.52900445", "0.5286251", "0.5283084", "0.5271085", "0.5271085", "0.5271085", "0.52708745", "0.5259797", "0.5259797", "0.5259797", "0.52595973" ]
0.0
-1
p my_hash_finding_method(my_family_pets_ages, 3) Identify and describe the Ruby method(s) you implemented. Person 2
def my_array_modification_method!(source, thing_to_modify) source.collect! do |x| if x.is_a?(Integer) x+=thing_to_modify else x end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_hash_finding_method(my_family_pets_ages, thing_to_find)\n my_family_pets_ages.select{|name, age| age == thing_to_find}.keys #for each name/age pair in the my_family_pets_ages hash, see if age is equal to the thing_to_find. If it is, add the name/age pair to a new hash. Then, .keys returns a new array of all the keys in that new hash.\nend", "def my_hash_finding_method(source, thing_to_find)\n final_answer = source.select{|key, value| value == thing_to_find}\n p final_answer.keys\nend", "def my_hash_finding_method(source, thing_to_find)\n final_answer = source.select{|key, value| value == thing_to_find}\n p final_answer.keys\nend", "def my_hash_finding_method(source, thing_to_find)\n solution = source.select { |key, value| value == thing_to_find }\n solution.keys\nend", "def my_hash_finding_method(my_hash, number)\n\t\n\tif !number.is_a?(Fixnum)\nraise ArgumentError.new('The Second Argument Should be a Fixnum')\n\tend\n\n\treturn my_hash.select {|key, value| value == number}.keys\nend", "def my_hash_finding_method(source, thing_to_find)\n answer = Hash.new\n source.each do |key, value|\n if value == thing_to_find\n answer.store(key, value)\n end\n end\n p answer.keys\nend", "def test_Hash_InstanceMethods_index\n\t\th = {'a'=>100, 'b'=>200}\n\t\t# TODO\n\tend", "def my_hash\n who_am_i = {\n name: \"Kelly\",\n age: \"31\",\n home: \"NYC\"\n }\nend", "def method(hash)\n p hash # {\"location\"=>\"SF\", \"color\"=>\"red\", \"size\"=>100}\nend", "def my_hash_finding_method(source, thing_to_find)\n source.select {|k, v| v == thing_to_find}.keys\nend", "def method(hash)\n p hash # {\"location\"=>\"SF\", \"color\"=>\"red\", \"size\"=>100}\nend", "def hash()\n #This is a stub, used for indexing\nend", "def my_method_hash(attrs = {})\n puts \"Name is #{attrs[:name]}\"\nend", "def my_hash_finding_method(source, thing_to_find)\n output_array = []\n i = 0\n source.each_pair { |key,value|\n if value == thing_to_find\n output_array[i] = key\n i += 1\n end\n }\n return output_array\nend", "def hash_code; end", "def most_interesting_man_in_the_world; end", "def my_hash_finding_method(hash, number)\n hash.select {|key, value| value == number}.keys\nend", "def my_hash_finding_method(source, thing_to_find)\n new_array = []\n source.map do |k, v|\n if v == thing_to_find\n new_array << k\n end\n end\n return new_array\nend", "def find_people_around_football_pitch_around_jindigeling\n find_shops\nend", "def my_hash_finding_method(source, thing_to_find)\n source.select! do|key, value|\n value == thing_to_find\n end\n return source.keys\nend", "def hash(*) end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash()\n #This is a stub, used for indexing\n end", "def hash_for(expression)\n\n end", "def find_answer(hash={})\n hash[:answer]\nend", "def method_information(bound_method); end", "def hash(key); end", "def my_hash\n{:Artists => \"Beyonce\"}\nend", "def my_hash_modification_method!(my_family_pets_ages, thing_to_modify)\n my_family_pets_ages.each do |key, value|\n my_family_pets_ages[key] = value + thing_to_modify\n end\nend", "def find_answer(h={})\n h[:answer]\nend", "def call_hash\n raise NotImplementedException.new(\"Must implement call_hash\")\n end", "def test_Hash_InstanceMethods_key?\n\t\ta = {'Father'=>'Jedi', 'Mother'=>'Becky'}\n\t\tassert_equal(true, a.key?('Father'))\n\t\tassert_equal(true, a.key?('Mother'))\n\tend", "def find; end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def print_price hash\n p hash[:price]\nend", "def likes_to_eat(person, food)\nreturn person[:favourites][:snacks].include?(food)\nend", "def my_hash_creator(key, value)\n # return a hash that includes the key and value parameters passed into this method\n {key => value}\nend", "def the_hash\n puts put_in_hash(get_symbols, get_prices, 20)\nend", "def my_hash_modification_method(source, thing_to_find)\n source.each{|key, value|\n source[key] = value + thing_to_find\n }\nend", "def hopper\n\tprogrammer_hash = \n \t\t{\n :grace_hopper => {\n :known_for => \"COBOL\",\n :languages => [\"COBOL\", \"FORTRAN\"]\n },\n :alan_kay => {\n :known_for => \"Object Orientation\",\n :languages => [\"Smalltalk\", \"LISP\"]\n },\n :dennis_ritchie => {\n :known_for => \"Unix\",\n :languages => [\"C\"]\n }\n }\n programmer_hash[:grace_hopper]\nend", "def get_area_code(somehash, key)\n#\nend", "def say_persons_name(person)\n puts \"#{person[:person_name]} is from #{person[:person_hometown]}\"\nend", "def my_hash_sorting_method(source)\n source.sort_by { |pet, age| age }\nend", "def pioneer\n{:name =>'Grace Hopper'}\nend", "def func_find(hash)\n # Check and return the first object that satisfies either of the following properties:\n # 1. There is a [key, value] pair where the key and value are both Integers and the value is < 20\n # 2. There is a [key, value] pair where the key and value are both Strings and the value starts with `a`.\n hash.find do |key, value|\n if key.is_a?(Integer) && value.is_a?(Integer)\n return [key, value] if value < 20\n end\n\n if key.is_a?(String) && value.is_a?(String)\n return [key, value] if value[0].eql?('a')\n end\n\n []\n end\nend", "def hash\n code.hash\n end", "def favourite_foods(person, food)\n return person[:favourites][:things_to_eat].include?(food)\nend", "def lookups; end", "def bornin _method, _class = [\n Fixnum,\n Float,\n String,\n Array,\n Hash,\n Range,\n Regexp,\n Math\n]\n\n # to colorize output\n require 'colorize'\n\n # Check\n if _method==nil\n return puts \"=> please pass first arg as a string\".red\n end\n\n # the patten to grep for\n re = Regexp.new '^' + _method.to_s + '$'\n\n # born in BasicObject?\n if BasicObject.instance_methods(false).grep(re).size==1\n return puts \"=> #{_method} : \" +\n \". born in BasicObject as an instance method\".green\n # born in Kernel?\n elsif Kernel.instance_methods(false).grep(re).size==1\n return puts \"=> #{_method} : \" +\n \".. born in Kernel as an instance method\".green\n # born in Object?\n elsif Object.instance_methods(false).grep(re).size==1\n return puts \"=> #{_method} : \" +\n \"... born in Object as an instance method\".green\n # born in Module?\n elsif Module.instance_methods(false).grep(re).size==1\n return puts \"=> #{_method} : \" +\n \".... born in Module as an instance method\".green\n end\n\n # puts \"check what class is _class\"\n # check what class is _class\n if _class.class == String\n _class = eval(_class)\n elsif _class.class == Symbol\n _class = Kernel.const_get(_class.to_s)\n # relying on some very basic classes listed above when\n # _class was not passed as a param\n elsif _class.is_a? Array\n _class.each do |e|\n # puts \"Checking #{_method} in #{e} ...\"\n output = bornin2 _method, e\n output || break\n # return\n end\n else\n bornin2 _method, _class\n end\n\nend", "def method_missing(method, *args, &block)\n if @hash.key?(method.to_s.to_sym)\n @hash[method.to_s.to_sym]\n else\n @hash.send(method, *args, &block)\n end\n end", "def test_hash_crossing_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 2; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=2\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\" ) {ruby_rush.hash_crossing_search}\n end", "def hash\n code = 17\n code = 37*code + @x.hash\n code = 37*code + @y.hash\n # Add lines like this for each significant instance variable\n code # Return the resulting code\n end", "def family(mother, father)\n p \"When #{mother} met #{father}\"\nend", "def total_hash_search(hash_to_find=@hash_to_find, stop_on_success=@sos, verbose=true)\n matches={}\n while(true)\n case @hash_type\n when 'MD4'\n result = leakdb_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('api.leakdb.abusix.com', result)\n break if stop_on_success\n end\n when 'MD5'\n result = leakdb_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('api.leakdb.abusix.com', result)\n break if stop_on_success\n end\n\n result = darkbyte_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('md5.darkbyte.ru', result)\n break if stop_on_success\n end\n\n result = gromweb_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('md5.gromweb.com', result)\n break if stop_on_success\n end\n\n result = md5comcn_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('md5.com.cn', result)\n break if stop_on_success\n end\n\n result = md5onlinenet_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('md5online.net', result)\n break if stop_on_success\n end\n\n result = md5onlineorg_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('md5online.org', result)\n break if stop_on_success\n end\n\n result = myaddr_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('md5.my-addr.com', result)\n break if stop_on_success\n end\n\n result = noisette_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('md5.noisette.ch', result)\n break if stop_on_success\n end\n\n result = netmd5crack_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('netmd5crack.com', result)\n break if stop_on_success\n end\n\n result = sans_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('isc.sans.edu', result)\n break if stop_on_success\n end\n\n result = stringfunction_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('stringfunction.com', result)\n break if stop_on_success\n end\n when 'LM'\n result = it64_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('rainbowtables.it64.com', result)\n break if stop_on_success\n end\n\n result = leakdb_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('api.leakdb.abusix.com', result)\n break if stop_on_success\n end\n when 'NTLM'\n result = leakdb_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('api.leakdb.abusix.com', result)\n break if stop_on_success\n end\n when 'LM:NTLM'\n result = leakdb_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('api.leakdb.abusix.com', result)\n break if stop_on_success\n end\n when 'MYSQL'\n result = leakdb_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('api.leakdb.abusix.com', result)\n break if stop_on_success\n end\n when 'SHA1'\n result = leakdb_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('api.leakdb.abusix.com', result)\n break if stop_on_success\n end\n\n result = sans_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('isc.sans.edu', result)\n break if stop_on_success\n end\n\n result = stringfunction_hash_search(hash_to_find, verbose)\n if not result.nil?\n matches.store('stringfunction.com', result)\n break if stop_on_success\n end\n end\n break # tried all sites by now...\n end\n return matches\n end", "def test_funcall_hash_means_lookup\n assert_evals_to 3, \"((hash (1 1) (2 2) (3 3)) 3)\"\n end", "def result(hash, key)\n hash[key]\nend", "def hash_key(name); end", "def get_area_code(somehash, key)\n puts somehash[key]\n\nend", "def method_missing(method, *args)\n hash.send(method, *args)\n end", "def method_missing(method, *args)\n hash.send(method, *args)\n end", "def my_hash_modification_method!(hash, age_diff)\n hash.each { |name, age| hash[name] = (age + age_diff) }\nend", "def print_method(hash)\n\thash.each do |grocery, quantity| #print out in in different line\n\tputs \"In your bag you have #{quantity} #{grocery}\" #mulitple lines of string\n\tend\nend", "def like_food?(food, person)\n person[:favourites][:things_to_eat].include?(food)\nend", "def get_family_members (people, family)\n people.select { |key,person| person.family == family }\nend", "def num_points_scored(name)\n game_hash.each do |location, team_hash|\n \n #the below is actually iterating through the keys of the hash containing the team info, because the value of game_hash is....another hash\n team_hash.each do |key, vals|\n if key == :players # this makes sure I'm only iterating through the right pair to begin with\n return vals[name][:points] if vals[name] # the return keyword ensures it will pop out of the method once the answer has been found \n end\n end\n end\nend", "def my_key(h, i)\n p [h, i]\nend", "def hash_for_location(offense); end", "def method_symbol; end", "def hash\n end", "def hash\n end", "def hash\n end", "def get_city_names(somehash)\n# Write code here\nsomehash.keys\nend", "def get_social_reach(person)\n\nend", "def find_answer\nend", "def get_area_code(somehash, key)\n# Write code here\nsomehash[key]\nend", "def geohash(key, member); end", "def my_hash_sorting_method(source)\n source.sort_by {|name, age| age}\nend", "def famous_birthdays # This example is to illustrate what a hash is\n birthdays = {\n 'Ludwig Van Beethoven' => Date.new(1770, 12, 16),\n 'Dave Brubeck' => Date.new(1920, 12, 6),\n 'Buddy Holly' => Date.new(1936, 9, 7),\n 'Keith Richards' => Date.new(1943, 12, 18) \n }\n end", "def bornin2 _method, _class\n\n # the patten to grep for\n re = Regexp.new '^' + _method.to_s + '$'\n\n _class.ancestors.each do |ancestor|\n\n #- in methods?\n if ancestor.methods(false).grep(re).size==1\n return puts \"=> #{_method} : \" +\n\t\"..... born in #{ancestor} as a method\".green\n end\n\n #- in instance_methods?\n if ancestor.instance_methods(false).grep(re).size==1\n return puts \"=> #{_method} : \" +\n\t\"...... born in #{ancestor} as an instance method\".green\n end\n\n end # scanning ancestors\n\nend", "def print_price hash \n\thash[:price]\nend", "def get_hash(*params); raise('Stub or mock required.') end", "def finder_methods; end", "def test_Hash_InstanceMethods_compare_by_identity\n\t\tkey = \"key\"\n\t\th = { key=>100, 99=>\"ninety nine\" }\n\t\tassert_equal(100, h[key])\n\t\tassert_equal(100, h[\"key\"])\n\t\tassert_equal(\"ninety nine\", h[99])\n\n\t\th.compare_by_identity\n\t\tassert_equal(nil, h[key])\n\t\tassert_equal(nil, h[\"key\"])\n\t\tassert_equal(\"ninety nine\", h[99])\n\tend", "def iron_man \n #this should return our hash of Iron Man and all of his properties\n\nend", "def doubles_by_method_name; end", "def get_city_names(somehash)\n somehash.keys\n# Write code here\nend" ]
[ "0.70698136", "0.6199392", "0.6199392", "0.61049", "0.61013764", "0.6021777", "0.6015965", "0.6010945", "0.59921443", "0.59800994", "0.5974329", "0.5917655", "0.5882972", "0.57855433", "0.5768528", "0.5748793", "0.57204425", "0.5671409", "0.562974", "0.56264347", "0.56046534", "0.5582549", "0.5582549", "0.5582549", "0.5582549", "0.5582549", "0.5582549", "0.5582549", "0.5582549", "0.5582549", "0.5582549", "0.5581708", "0.55602396", "0.55284965", "0.5509914", "0.55067664", "0.54837924", "0.5476096", "0.5466349", "0.5455397", "0.54541844", "0.54207516", "0.5413905", "0.5413905", "0.5413905", "0.5413905", "0.5413905", "0.5413905", "0.5413905", "0.5413096", "0.5407435", "0.53972185", "0.5394956", "0.5384298", "0.5379049", "0.5359978", "0.53587675", "0.53569114", "0.5355247", "0.53509384", "0.5330357", "0.53121334", "0.52966076", "0.5296402", "0.5295501", "0.52900255", "0.52896243", "0.5285387", "0.52822983", "0.52774954", "0.5268805", "0.52581924", "0.52566785", "0.5242787", "0.5242787", "0.5241912", "0.52403015", "0.52351415", "0.5233513", "0.5227342", "0.52256197", "0.5221693", "0.5221273", "0.52209646", "0.52209646", "0.52209646", "0.52162194", "0.5210629", "0.52087307", "0.5185688", "0.518272", "0.5181957", "0.5180935", "0.5179744", "0.51728815", "0.51601285", "0.5158895", "0.5150298", "0.5147025", "0.514201", "0.51404244" ]
0.0
-1
Identify and describe the Ruby method(s) you implemented. I used collect! to iterate through the array to alter its contents. Since the method has to be destructuve, I added the "!" at the end of "collect". I used is_a? to check if each element in the array is an integer. This method returns true if the element is an integer, in which case "thing_to_modify" will be added to it. I used each to iterate through the hash to modify the values. The values can be changed by accessing the key through "source[key] =". Person 3
def my_array_sorting_method(source) source.sort_by { |x| x.to_s } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_array_modification_method!(source, thing_to_modify)\n source.each_index do |x|\n if (source[x].is_a?(Integer))\n source[x]+=thing_to_modify\n end\n end\n source\nend", "def my_array_modification_method(source, thing_to_modify)\n source.map! do |x|\n \t\tif x.is_a?(Integer) \n \t\t\tx + thing_to_modify\n \t\telse\n \t\t\tx\n \t\tend\n \tend\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |item| # Array#collect! overrides original array\n if item.is_a? Integer #searches for integers and modifies them\n item + thing_to_modify\n else\n item #leaves non intgers alone\n end\n end\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |item| # Array#collect! overrides original array\n if item.is_a? Integer #searches for integers and modifies them\n item + thing_to_modify\n else\n item #leaves non intgers alone\n end\n end\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup\n i_want_pets.map!{|number| number.is_a?(Integer) ? number + 1 : number}\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! { |x|\n if x.is_a?(Integer)\n x + thing_to_modify\n else\n x\n end\n }\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! {|elem|\n if elem.is_a?(Integer)\n elem += thing_to_modify\n else\n elem\n end\n }\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map!{ |item|\n item += thing_to_modify if item.is_a?(Integer)\n item\n }\nend", "def my_array_modification_method(source, thing_to_modify)\n source.map {|element| element.is_a?(Integer)? element + thing_to_modify : element}\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! { |word| word.is_a?(Integer) ? word + thing_to_modify : word }\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |x| \n if x.is_a?(Integer) \n x+=thing_to_modify\n else x\n end\n end\n\n\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |x| \n if x.is_a?(Integer) \n x+=thing_to_modify\n else x\n end\n end\n\n\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! do |n|\n if n.is_a? Integer\n n += thing_to_modify\n else\n n\n end\n end\nend", "def my_array_modification_method!(source, thing_to_modify)\nsource.map! do |x|\n if x.is_a?(Integer)\n x + num_of_pets_wanted\n else\n x\n end\n end\n return source\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! { |i| i.is_a?(Integer)? (i + thing_to_modify) : i }\nend", "def my_array_modification_method(source, thing_to_modify)\n return source.map! {|i| i.is_a?(Integer) ? (i + thing_to_modify) : i}\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |item|\n if item.is_a? Integer\n item += thing_to_modify\n else item\n end\n end\n return source\nend", "def my_array_modification_method(source, thing_to_modify)\n new_array = []\n source.each { |a|\n if a.is_a? Integer\n new_array << a + thing_to_modify\n else\n new_array << a\n end\n }\n source.replace(new_array)\nend", "def my_array_modification_method(source, thing_to_modify)\n source.each_with_index do |element, i|\n source[i] += thing_to_modify if element.is_a?(Numeric)\n end\n source\n end", "def my_array_modification_method!(source, thing_to_modify)\n\nreturn source.collect! { |item| item.is_a?(Fixnum) ? item + thing_to_modify : item}\nend", "def my_array_modification_method(source, thing_to_modify)\n source.each_with_index do |value, index|\n if value.is_a? Integer\n source[index] += thing_to_modify\n end\n end\nend", "def my_array_modification_method!(source, thing_to_modify)\n\n source.map! do |x|\n\n if x.class == Fixnum\n\n x + thing_to_modify\n else\n x\n end\n\n end\n\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! do |x| \n if x.is_a?(Integer) then x += thing_to_modify else x end\n end\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! do |element|\n if element.class == Fixnum\n element += thing_to_modify\n else\n element = element\n end\n end\nend", "def my_hash_modification_method(source, thing_to_modify)\n newsource=Hash[source.map{|key, value| [key, value.is_a?(Integer)? value + thing_to_modify : value]}]\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! {|var|\n if var.is_a?(Integer)\n var + thing_to_modify\n else\n next var\n end\n }\n p source\nend", "def my_array_modification_method(source, thing_to_modify)\n\t# #source[-1],source[2] = source[-1] + 1, source[2 ]+ 1 \n # source.collect! do |item|\n # # # if item.is_a?(Integer)\n # # # item = item + thing_to_modify\n # # # else \n # # # \titem = item\n # # end\n \n # item.is_a?(Integer) ? item = item + thing_to_modify : item = item\n # end\n source.collect! { |item| item.is_a?(Integer) ? item += thing_to_modify : item = item } \n source\nend", "def my_array_modification_method(source, thing_to_modify)\n\tanswer = []\n\tsource.each do |x|\n\t x = x + thing_to_modify if x.class == Fixnum\n\t answer << x\n\tend\n\treturn answer\nend", "def my_array_modification_method(source, thing_to_modify)\n mod_array = Array.new\n source.each { |x|\n if x.is_a? Integer\n mod_array << x += thing_to_modify\n else\n mod_array << x\n end\n }\n mod_array\nend", "def my_array_modification_method!(source, num_of_pets_wanted)\n source.map! do |x|\n if x.is_a?(Integer)\n x + num_of_pets_wanted\n else\n x\n end\n end\n return source\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! do |e|\n if e.class == Fixnum\n e = e + thing_to_modify\n elsif e.class == String\n e = e\n end\n end\n return source\nend", "def my_array_modification_method(source, thing_to_modify)\n # Your code here!\nend", "def my_array_modification_method(source, thing_to_modify)\n # Your code here!\nend", "def my_array_modification_method(source, thing_to_modify)\n # Your code here!\nend", "def my_array_modification_method(source, thing_to_modify)\n # Your code here!\nend", "def my_array_modification_method(source, thing_to_modify)\n # Your code here!\nend", "def my_array_modification_method(source, thing_to_modify)\n # Your code here!\nend", "def my_array_modification_method(source, thing_to_modify)\n # Your code here!\nend", "def my_array_modification_method(source, thing_to_modify)\n # Your code here!\nend", "def my_array_modification_method!(i_want_pets, thing_to_modify)\n i_want_pets.map! {|element| element.is_a?(Integer)? (element + thing_to_modify) : element}\nend", "def my_array_modification_method!(pets, thing_to_modify)\n pets.map! do |x|\n if x.is_a? Integer\n x += thing_to_modify\n else\n x\n end\n end\nend", "def my_array_modification_method(source, thing_to_modify)\n new_array = []\n source.each do |num|\n if num.is_a? Integer\n num += thing_to_modify\n new_array.push num\n else\n new_array.push num \n end\n end\n return new_array\nend", "def my_hash_modification_method!(source, thing_to_modify)\n source.map do |k, v|\n source[k] = v += thing_to_modify\n end\n return source\nend", "def my_array_modification_method!(array, increase)\r\n array.map! do |x| \r\n if x.is_a? Integer\r\n x += increase\r\n else \r\n x\r\n end\r\n end\r\nend", "def my_array_modification_method(source, thing_to_modify)\n source.map!{ |x| (x==/\\d/ ? x+thing_to_modify : x) }\nend", "def my_array_modification_method!(source, thing_to_modify)\n\n for x in 0..(source.length - 1)\n if source[x].to_s =~ /\\A[-+]?[0-9]+\\z/\n source[x] = source[x].to_i + thing_to_modify.to_i\n end\n end\n # p source\n return source\nend", "def my_array_modification_method!(arry, num)\n p arry.map! {|x|\n if x.is_a?(Integer)\n x + num\n else\n x\n end\n }\nend", "def my_array_modification_method(source, thing_to_find)\n source.each_with_index {|elem, index|\n if elem.is_a?(Integer)\n source[index] = (elem + thing_to_find)\n end\n }\nend", "def my_array_modification_method!(array, num)\n array.map! { |x| x.is_a?(Integer)? (x + num) : x } #attempted .each, but the values were not updating, seems to work with map.\nend", "def my_array_modification_method(source, n)\n source.map{|i| \n if i.is_a? Integer \n i += n \n end \n i}\n p source\nend", "def my_hash_modification_method!(source, thing_to_modify)\n# source = Hash[source.map {|k,v| [k, thing_to_modify + v ]}]\nsource.each do |key, value|\n source[key] = value + thing_to_modify\nend\nend", "def my_hash_modification_method!(source, thing_to_modify)\n\tsource.each {|k, v| source[k] = v + thing_to_modify}\nend", "def my_array_modification_method!(source, thing_to_modify)\n first_integer = []\n first_integer.push(i_want_pets[2])\n i_want_pets.delete_at(2)\n i_want_pets.insert(2, (first_integer.join.to_i + thing_to_modify) )\n\n second_integer = []\n second_integer.push(i_want_pets[7])\n i_want_pets.delete_at(7)\n i_want_pets.push(second_integer.join.to_i + thing_to_modify)\n\nend", "def my_hash_modification_method(source, thing_to_modify)\n source.each do |key, value|\n source[key]+= thing_to_modify\n end\nend", "def my_hash_modification_method!(source, thing_to_modify)\n\nreturn source.each_with_object(source) { |(key, value), hash| hash[key] = value + thing_to_modify}\nend", "def my_array_modification_method(array, number)\n\tarray = array.map! do |x|\n\t\tif x.is_a?(Integer)\n\t\t\tx + number\n\t\telse\n\t \tx\n\t end\nend\nend", "def my_hash_modification_method!(source, years_to_add)\n source.each do |name, old_age|\n source[name] = old_age + years_to_add\n end\n return source\nend", "def my_array_modification_method(ary, number)\n\tif !number.is_a?(Fixnum)\n\t\traise ArgumentError.new('The Second Argument Should be a Fixnum')\t\t\n\tend\n\n\treturn ary.collect! {|element| element.is_a?(Fixnum) ? (element + number) : element}\n\nend", "def my_hash_modification_method(source, things_to_modify)\n source.each {|k, v| source[k] = v + things_to_modify}\nend", "def my_hash_modification_method!(my_family_pets_ages, thing_to_modify)\n my_family_pets_ages.each do |key, value|\n my_family_pets_ages[key] = value + thing_to_modify\n end\nend", "def my_array_modification_method!(array, numadd)\n array.map!{|element| element.is_a?(Integer) ? element + numadd : element}\nend", "def my_array_modification_method!(sentence_array, increment)\n sentence_array.map! do |word|\n if word.is_a?(Integer)\n word += increment\n else\n word # no change, but needs to be specified or word goes to nil\n end\n end\n return sentence_array\nend", "def my_array_modification_method!(source, thing_to_modify)\r\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\r\nend", "def my_hash_modification_method(source, thing_to_find)\n source.each{|key, value|\n source[key] = value + thing_to_find\n }\nend", "def my_array_modification_method!(array, number)\n array.map! {|x|\n x.is_a?(Integer) ? (x + number): x}\nend", "def my_array_modification_method!(list, quantity_to_add)\n list.map! do |x|\n if x.is_a? Integer\n x = x + quantity_to_add\n end\n x\n end\n return list\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_modification_method!(input_array, add_num)\n input_array.each_with_index do |item, index|\n if item.is_a?(Numeric)\n input_array[index] += add_num\n end\n end\nreturn input_array\nend", "def my_array_modification_method(source, thing_to_modify)\n len = source.length; # find the number of elements in the array\n # for each element in the array see if it is a string\n 0.upto(len - 1) do |loc|\n # if the element is NOT a string, add thing_to_modify to it\n if source[loc].is_a?(String) === false\n source[loc] += thing_to_modify\n end\n end\n return source\nend", "def my_hash_modification_method!(hash, num)\n hash.collect {|key,value|\n hash[key] = value + num}\n return hash\n end", "def ele_replace!(array, hash)\n array.map! do |ele| #go through the array\n if hash.has_key?(ele) #hash contains a key thats also in the array arr = [4,2,0,2] vs hash = {2=>two, 0 => zero} \n hash[ele] #convert array values with corresponding hash values -> [ ... ,two,zero,two]\n else\n ele #if array value doesnt correspond with hash key, place array index back to original position -> [ 4,...,...,...]\n end\n end\nend", "def my_hash_modification_method!(source, thing_to_modify)\n modded_hash = source.update(source){|k, v| v + thing_to_modify}\n p modded_hash\nend", "def age_increase(pet_arr)\n pet_arr.each do |x|\n x.age += 1\n end\nend", "def my_hash_modification_method!(hash, age_diff)\n hash.each { |name, age| hash[name] = (age + age_diff) }\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup\ndel=[]\nsource.each do |item|\n if item.is_a? Integer\n del << item\n next\n elsif item.include?(thing_to_delete)\n next\n else\n del << item\n end\n end\n return source=del\nend", "def my_array_modification_method!(array, num)\n array[2] = array[2] + num\n array[-1] = array[-1] + num\n array\nend", "def mutliplied(array)\nend", "def selected_map!(arr, proc_1, proc_2)\n arr.each.with_index do |ele, idx|\n if proc_1.call(ele)\n arr[idx] = proc_2.call(ele)\n end\n end\n nil\nend", "def map_to_no_change(array)\n return array\nend", "def method_map(arr, meth,*args)\n arr.map {|e| e.send(meth,*args) }\n end", "def some_array_methods\n teachers = ['James', 'Jim', 'Adriana']\n # p teachers.first\n # p teachers.last\n # p teachers.sample\n # reverse_teachers = teachers.reverse\n # teachers.delete_at(0)\n # p teachers.index('aldskjflskdjf')\n teachers.insert(0 , 'Angie')\n # p teachers.count do |name|\n # name == 'Jim'\n # end\n # p teachers.length\n # p teachers\n # teachers.each do |teacher|\n # p teacher\n # end\n new_teachers = teachers.map do |teacher|\n teacher += ' is a teacher.'\n end\n p new_teachers\nend", "def test_collect_transforms_elements_of_an_array\n array = [1, 2, 3]\n new_array = array.collect { |item| item + 10 }\n assert_equal [11, 12, 13], new_array\n\n another_array = array.map { |item| item + 10 }\n assert_equal [11, 12, 13], another_array\n end" ]
[ "0.7336543", "0.71791273", "0.7174057", "0.7174057", "0.7116724", "0.69928366", "0.6990382", "0.69749117", "0.69692445", "0.69631255", "0.69597197", "0.69597197", "0.6958297", "0.6936574", "0.6921604", "0.6916574", "0.68876874", "0.6859251", "0.6838147", "0.68364656", "0.68086994", "0.6792351", "0.67758894", "0.67470443", "0.67174065", "0.66995275", "0.6653927", "0.6620174", "0.6614161", "0.6569808", "0.6568807", "0.6555257", "0.6555257", "0.6555257", "0.6555257", "0.6555257", "0.6555257", "0.6555257", "0.6555257", "0.6511456", "0.6502824", "0.6500017", "0.6494648", "0.6481967", "0.644802", "0.64292765", "0.64137477", "0.6382289", "0.6317713", "0.62980825", "0.627533", "0.6237075", "0.62236655", "0.6196199", "0.6182177", "0.61723393", "0.6136197", "0.6040205", "0.6032621", "0.6003917", "0.5986578", "0.59243387", "0.5855225", "0.58535546", "0.58532786", "0.5827481", "0.579674", "0.579674", "0.579674", "0.579674", "0.579674", "0.579674", "0.579674", "0.579674", "0.579674", "0.579674", "0.579674", "0.579674", "0.579674", "0.579674", "0.579674", "0.579674", "0.579674", "0.579674", "0.579674", "0.579674", "0.57627094", "0.56743467", "0.5560856", "0.5542382", "0.55138355", "0.54346263", "0.53132606", "0.5278969", "0.52064526", "0.51907724", "0.5171166", "0.513855", "0.5134469", "0.5126703", "0.5100416" ]
0.0
-1
p my_array_deletion_method!(["cat", "dog", "iguana", "shoe"], "o") Identify and describe the Ruby method(s) you implemented. Person 4
def my_array_deletion_method!(source, thing_to_delete) source.delete_if {|item| item.to_s.include?(thing_to_delete)} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_array_deletion_method!(source, thing_to_delete)\nend", "def my_array_deletion_method(source, thing_to_delete)\n\t\nend", "def my_array_deletion_method(source, thing_to_delete)\n #Your code here!\nend", "def my_array_deletion_method(source, thing_to_delete)\n #Your code here!\nend", "def my_array_deletion_method(source, thing_to_delete)\n #Your code here!\nend", "def my_array_deletion_method(source, thing_to_delete)\n #Your code here!\nend", "def my_array_deletion_method(source, thing_to_delete)\n #Your code here!\nend", "def my_array_deletion_method(source, thing_to_delete)\n #Your code here!\nend", "def my_array_deletion_method!(source, thing_to_delete)\r\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\r\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method!(source, thing_to_delete)\n\nreturn source.delete_if {|element| element == thing_to_delete}\n\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.delete_if{|x| x.to_s.include?(thing_to_delete)}\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.delete_if { |x| x.to_s.include?(thing_to_delete)}\nend", "def my_array_deletion_method(source, thing_to_delete)\n\tsource.delete_if {|i| i.to_s.include? thing_to_delete}\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.delete_if { |a| a.include?(thing_to_delete) }\nend", "def my_array_deletion_method(source, thing_to_delete)\n\tsource.delete_if {|element| element.to_s.include?(thing_to_delete)}\nend", "def my_array_deletion_method(source, thing_to_delete)\n p source.delete_if {|thing_to_modify| thing_to_modify.to_s.include? (thing_to_delete)}\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.delete_if {|x| x.to_s.include?(thing_to_delete)}\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.delete_if {|x| x.to_s.include?(thing_to_delete)}\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.delete_if { |word| word.to_s.include? thing_to_delete }\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.each {|x| \n source.delete(x) if (x.is_a?(String) && x.index(thing_to_delete) != nil)\n }\n p source\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.reject! {|s| s.to_s.include?(thing_to_delete.to_s) }\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.reject! {|word| word.to_s.rindex(thing_to_delete) != nil}\n return source\nend", "def my_array_deletion_method!(source, thing_to_delete)\n # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend", "def my_array_deletion_method(source, thing_to_delete)\t\n\tsource.delete_if {|x| x.class.to_s == \"String\" && x.include?(thing_to_delete) == true}\n\t\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.delete_if do |item| \n item.to_s.include? thing_to_delete\n end\n source\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.each do |thing|\n if thing.to_s.downcase.include?(thing_to_delete)\n source.delete(thing)\n end\n end\n source\nend", "def my_array_deletion_method(source, thing_to_delete)\n source.delete_if { |word| word.to_s.include?(thing_to_delete) }\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.each do |substring|\n if substring.class == thing_to_delete.class && substring.include?(thing_to_delete) == true\n source.delete(substring)\n end\n end\n return source\n end", "def my_array_deletion_method(source, thing_to_delete)\n\t\tsource.delete_if { |i| i =~ /#{thing_to_delete}/}\n\t\tprint source\nend", "def my_array_deletion_method!(i_want_pets, letter)\n i_want_pets.delete_if { |item| item.to_s.include?(letter) }\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.reject! {|user_string| user_string.to_s.index(thing_to_delete) != nil}\nend", "def my_array_deletion_method(source, thing_to_delete)\n source.reject!{ |x| x.to_s.include?(thing_to_delete) }\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.delete_if {|x| x.to_s.include? thing_to_delete}\nend", "def my_array_deletion_method(source, thing_to_delete)\n source.delete_if{|x| x.to_s.include?(thing_to_delete)}\n return source\nend", "def my_array_deletion_method(source, thing_to_delete)\n source.delete_if{|x| x.to_s.include?(thing_to_delete)}\n return source\nend", "def my_array_deletion_method(source, thing_to_delete)\n \tsource.each do |x|\n \t\t#puts x\n \t\tif x.to_s.include? \"#{thing_to_delete}\"\n \t\t\tsource.delete(x)\n \t\tend\n \tend\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.select! {|el| el.to_s.include?(thing_to_delete) == false}\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.reject! {|user_string| user_string.to_s.index(thing_to_delete) != nil}\n return source\nend", "def my_array_deletion_method(source, thing_to_delete)\n source.delete_if {|element| element.to_s.include? (thing_to_delete)} \nend", "def my_array_deletion_method(source, thing_to_delete)\n source.delete_if {|x| x.to_s.include?(thing_to_delete) == true}\nend", "def my_array_deletion_method(source, thing_to_delete)\n\tsource.each do |word| if word.to_s.split(\"\").include? thing_to_delete\n\t\tsource.delete word\n\tend\nend\n\t source \nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.each do |items|\n if items.to_s.downcase.include?(thing_to_delete)\n source.delete(items)\n end\n end\n source\nend", "def my_array_deletion_method(source, thing_to_delete)\n source.delete_if{|item| item.to_s.include?(thing_to_delete.to_s)}\nend", "def my_array_deletion_method(source, thing_to_delete)\n source.each do |x|\n \tif x.to_s.split(\"\").include?(thing_to_delete) \n \t\tsource.delete(x)\n\tend\n end\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.each {|word| remove_word = word.to_s\n if remove_word.include?(thing_to_delete) == true\n source.delete(string)\n p source\n end\n }\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.delete_if {|item| item.is_a?(String) && item.include?(thing_to_delete)}\nend", "def using_delete(array, string)\n array.delete(string)\n \nend", "def my_array_deletion_method!(source, thing_to_delete)\n\n var_to_delete = thing_to_delete\n\n source.map! {|str| str.to_s}\n p source.delete_if {|str| str.include?(var_to_delete)}\n\nend", "def using_delete(array, str)\n array.delete(str)\nend", "def my_array_deletion_method!(array, letter)\n array.delete_if {|x| x.to_s.include?(letter) }\nend", "def using_delete(array, string)\n array.delete(string)\nend", "def my_array_deletion_method(source, thing_to_delete)\n\nsource = source.delete_if {|element| element.class == String && element.include?(thing_to_delete)\n}\nend", "def my_array_deletion_method!(source, thing_to_delete)\n\n indexChange = 0\n for x in 0..(source.length - 1)\n sourceString = source[x - indexChange].to_s\n\n if sourceString.include? thing_to_delete\n source[x - indexChange,source.length] = source[x + 1 - indexChange, source.length]\n indexChange = indexChange + 1\n end\n end\n # p source\n return source\nend", "def using_delete(array,string)\n array.delete(string)\nend", "def using_delete(array,string)\n array.delete(string)\nend", "def using_delete(array, string)\n array.delete(string)\nend", "def using_delete(array, string)\n array.delete(string)\nend", "def using_delete(array, string)\n array.delete(string)\nend", "def using_delete(array, string)\n array.delete(string)\nend", "def my_array_deletion_method!(source, thing_to_delete)\r\n words_to_delete = source.find_all { |f| f.to_s.include?(thing_to_delete)}\r\n words_to_delete.each do |word|\r\n source.delete(word)\r\n end\r\n p source\r\nend", "def using_delete(array, string)\n array.delete(string)\n array\nend", "def my_array_deletion_method(array, letter)\n array.delete_if { |data| data.to_s.match(letter.to_s)}\n return array\n end", "def my_array_deletion_method!(source, thing_to_delete)\n source.dup\ndel=[]\nsource.each do |item|\n if item.is_a? Integer\n del << item\n next\n elsif item.include?(thing_to_delete)\n next\n else\n del << item\n end\n end\n return source=del\nend", "def using_delete(array, string)\n \n array.delete(string)\n \nend", "def my_array_deletion_method!(source, thing_to_delete)\n \n duplicate = source.dup\n\n i = 0\n while i < duplicate.length\n word = duplicate[i]\n if word.is_a?(Fixnum)\n i += 1\n next\n end\n if word.include?(thing_to_delete)\n source.delete(word)\n end\n i += 1\n end \n source\nend", "def using_delete_at(array, index)\n array.delete_at(index)\nend", "def using_delete_at(array, index)\n array.delete_at(index)\nend", "def using_delete (array, string)\n return array.delete(string)\nend", "def using_delete(arr, str)\n arr.delete(str)\nend", "def using_delete(arr, str)\n arr.delete(str)\nend", "def my_array_deletion_method!(source, thing_to_delete)\n remove_letter = source.find_all { |letter| letter.to_s.include?(thing_to_delete)}\n\n remove_letter.each { |word| source.delete(word)}\n\n p source\nend", "def using_delete(array,string)\n array.delete(string)\n end", "def my_array_deletion_method!(array, a)\n array.delete_if { |value| value.to_s.include?(a) }\nend", "def using_delete_at(array, integer)\n deleted_robot = array.delete(array[integer])\nend", "def del(*args); end", "def using_delete_at(arr, index)\n arr.delete_at(index)\nend", "def using_delete_at (array,integer)\n array.delete_at(integer)\nend", "def using_delete_at(array, integer)\n array.delete_at(integer)\nend", "def using_delete_at(array, integer)\n array.delete_at(integer)\nend" ]
[ "0.8403863", "0.81641227", "0.8079928", "0.8079928", "0.8079928", "0.8079928", "0.8079928", "0.8079928", "0.75605303", "0.7547214", "0.7547214", "0.7547214", "0.7547214", "0.7547214", "0.7547214", "0.7547214", "0.7547214", "0.7547214", "0.7547214", "0.7547214", "0.7547214", "0.7547214", "0.7547214", "0.7547214", "0.7547214", "0.7547214", "0.7547214", "0.7547214", "0.7547214", "0.7484245", "0.74620795", "0.7439079", "0.74386984", "0.743744", "0.7410182", "0.74045265", "0.7401498", "0.7401498", "0.7396479", "0.7386552", "0.7373439", "0.7369314", "0.73574084", "0.7349607", "0.7347249", "0.7342823", "0.7342404", "0.7324404", "0.7319913", "0.7316223", "0.731128", "0.7305306", "0.72952765", "0.7289121", "0.7289121", "0.7263862", "0.72571015", "0.7232244", "0.72234476", "0.7219057", "0.7198978", "0.7190465", "0.71528286", "0.7152745", "0.71437454", "0.71331614", "0.71015495", "0.70933956", "0.69830495", "0.6963082", "0.6958749", "0.69571", "0.6956666", "0.69402605", "0.69402605", "0.6928232", "0.6928232", "0.6928232", "0.6928232", "0.6927024", "0.69230264", "0.68840206", "0.6882906", "0.68785393", "0.6783522", "0.6769302", "0.67371833", "0.67371386", "0.66454834", "0.66454834", "0.65674037", "0.65177596", "0.64996797", "0.6472534", "0.64173084", "0.6399885", "0.6385506", "0.63189584", "0.63189584" ]
0.73251194
48
Identify and describe the Ruby method(s) you implemented. Person 5
def my_array_splitting_method(source) new_array=[[], []] source.each do |x| if x.is_a?(Integer) new_array[0]<<x else new_array[1]<<x end end new_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def methods() end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def extract_method_details; end", "def methods; end", "def methods; end", "def methods; end", "def methods; end", "def describeMethod(cname, type, mname)\n \n # If the class name part is ambiguous, then we have a join to\n # do\n \n method_list = methods_matching(cname, type, mname)\n\n case method_list.size\n \n when 0\n @op.error(\"Cannot find method `#{cname}#{type}#{mname}'\")\n throw :exit, 3\n \n when 1\n meth = method_list[0]\n @op.putMethodDescription do\n @op.putMethodHeader(meth.class_name, meth.typeAsSeparator, meth.name, meth.callseq)\n printFragments(meth) unless @synopsis\n end\n \n else\n\n @op.putListOfMethodsMatchingName(mname) do\n @op.putMethodList(method_list.collect { |m| \n \"#{m.class_name}#{m.typeAsSeparator}#{m.name}\" \n })\n end\n end\n end", "def method_name\n\n end", "def method_name\n\n end", "def method_name\n\n end", "def method_name\n end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def name_of_method\n # method body goes here\nend", "def method_symbol; end", "def method_information(bound_method); end", "def method_signature\n case @opcode.arguments.size\n when 0\n @file.puts \" def #{method_name}\"\n when 1\n @file.puts \" def #{method_name}(arg1)\"\n when 2\n @file.puts \" def #{method_name}(arg1, arg2)\"\n end\n end", "def display_method_info\n end", "def signature\n raise NotImplementedError, _(\"%{class} has not implemented method %{method}\") %{class: self.class, method: __method__}\n end", "def method\r\nend", "def print_method(*) end", "def expected_method; end", "def findAndDescribe(name)\n methods = MethodIndex.findMethods(name)\n \n if methods.size.zero?\n @op.error(\"Don't know anything about a method called `#{name}'.\")\n throw :exit, 4\n end\n \n if methods.size == 1\n methods[0] =~ /^(#{CN_PATTERN})(\\.|\\#|::)(.+)/\n describeMethod($1, $2, $3)\n else\n @op.putListOfMethodsMatchingName(name) do\n @op.putMethodList(methods)\n end\n end\n end", "def yet_another_method\n puts \"I'm a method\"\nend", "def firstMethod()\n p \"hey this is first method ok\"\n p \"here i show how can create method in ruby\"\n p \" know time end \"\nend", "def method1; end", "def report_method_stuff(requested_method_name, methods)\n entries = methods.find_all {|m| m.name == requested_method_name and (\n !@onlyLoadedClasses or \n Object.class_eval \"defined? #{m.nameSpace.full_name}\" ) }\n case entries.size\n when 1\n method = @ri_reader.get_method(entries.first)\n @display.display_method_info(method)\n when 0\n puts \"No loaded methods matched your request\"\n else\n @display.display_method_list(entries)\n end\n end", "def signature\n \"#{klass_name}#{method_name}\"\n end", "def method(arg1 = default_value, arg2, etc.) # Defines a method with the name method and arguments.\n # Code goes here, for example:\n puts \"Hello, #{arg1} #{arg2}!\"\nend", "def display_method_list\n end", "def my_method_param(name) #Define method \"my_method_param\"\n print \"Hello #{name}!\"\nend", "def methodname\n # contents of method\nend", "def method_missing(meth, *args, &block)\n __describe_and_send__(meth, *args, &block)\n end", "def method_description(method)\n call(\"System.methodDescription\", method)\n end", "def demoMethod\n\t\traise \"Ceci est une methode abstraite. This is an abstact method.\";\n\tend", "def describe\n raise NotImplementedError\n end", "def simple_method\n puts \"I am a simple method!\"\nend", "def type\n 'Method'\n end", "def display_method name\n found = load_methods_matching name\n raise NotFoundError, name if found.empty?\n filtered = filter_methods found, name\n out = RDoc::Markup::Document.new\n out << RDoc::Markup::Heading.new(1, name)\n out << RDoc::Markup::BlankLine.new\n filtered.each do |store, methods|\n methods.each do |method|\n out << RDoc::Markup::Paragraph.new(\"(from #{store.friendly_path})\")\n unless name =~ /^#{Regexp.escape method.parent_name}/ then\n out << RDoc::Markup::Heading.new(3, \"Implementation from #{method.parent_name}\")\n end\n out << RDoc::Markup::Rule.new(1)\n if method.arglists then\n arglists = method.arglists.chomp.split \"\\n\"\n arglists = arglists.map { |line| line + \"\\n\" }\n out << RDoc::Markup::Verbatim.new(*arglists)\n out << RDoc::Markup::Rule.new(1)\n end\n out << RDoc::Markup::BlankLine.new\n out << method.comment\n out << RDoc::Markup::BlankLine.new\n end\n end\n display out\n end", "def greeting(name)\n \"Hello and welcome to Ruby methods \" + name + \"!\"\nend", "def my_method\nend", "def my_method\n end", "def method\n @method\n end", "def report_methods cm\n return if cm.method_list.empty?\n\n report = []\n\n cm.each_method do |method|\n next if method.documented? and @coverage_level.zero?\n\n if @coverage_level > 0 then\n params, undoc = undoc_params method\n\n @num_params += params\n\n unless undoc.empty? then\n @undoc_params += undoc.length\n\n undoc = undoc.map do |param| \"+#{param}+\" end\n param_report = \" # #{undoc.join ', '} is not documented\\n\"\n end\n end\n\n next if method.documented? and not param_report\n\n line = method.line ? \":#{method.line}\" : nil\n scope = method.singleton ? 'self.' : nil\n\n report << \" # in file #{method.file.full_name}#{line}\\n\"\n report << param_report if param_report\n report << \" def #{scope}#{method.name}#{method.params}; end\\n\"\n report << \"\\n\"\n end\n\n report\n end", "def defined_method()\n p \"success\"\nend", "def calls_by_method_name; end", "def hey_hey; end", "def method # test comment\n# ^^^ meta.function.method.without-arguments.ruby keyword.control.def.ruby\n# ^^^^^^ meta.function.method.without-arguments.ruby entity.name.function.ruby\n# ^ comment.line.number-sign.ruby punctuation.definition.comment.ruby\n# ^^^^^^^^^^^^^ comment.line.number-sign.ruby\n hello, world = [1,2]\n# ^^^^^ variable.other.ruby\n# ^ punctuation.separator.object.ruby\n# ^^^^^ variable.other.ruby\n# ^ keyword.operator.assignment.ruby\n# ^ punctuation.section.array.begin.ruby\n# ^ constant.numeric.ruby\n# ^ punctuation.separator.object.ruby\n# ^ constant.numeric.ruby\n# ^ punctuation.section.array.end.ruby\n end", "def example_method\n # code\n end", "def display_method name\n found = load_methods_matching name\n\n raise NotFoundError, name if found.empty?\n\n filtered = filter_methods found, name\n\n out = method_document name, filtered\n\n @history.go name, out, nil\n\n display out\n end", "def meth(arg1)\nend", "def internal_methods; 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 do_methods\n @content.scan(%r%rb_define_\n (\n singleton_method |\n method |\n module_function |\n private_method\n )\n \\s*\\(\\s*([\\w\\.]+),\n \\s*\"([^\"]+)\",\n \\s*(?:RUBY_METHOD_FUNC\\(|VALUEFUNC\\(|\\(METHOD\\))?(\\w+)\\)?,\n \\s*(-?\\w+)\\s*\\)\n (?:;\\s*/[*/]\\s+in\\s+(\\w+?\\.(?:cpp|c|y)))?\n %xm) do |type, var_name, meth_name, function, param_count, source_file|\n\n # Ignore top-object and weird struct.c dynamic stuff\n next if var_name == \"ruby_top_self\"\n next if var_name == \"nstr\"\n\n var_name = \"rb_cObject\" if var_name == \"rb_mKernel\"\n handle_method(type, var_name, meth_name, function, param_count,\n source_file)\n end\n\n @content.scan(%r%rb_define_global_function\\s*\\(\n \\s*\"([^\"]+)\",\n \\s*(?:RUBY_METHOD_FUNC\\(|VALUEFUNC\\()?(\\w+)\\)?,\n \\s*(-?\\w+)\\s*\\)\n (?:;\\s*/[*/]\\s+in\\s+(\\w+?\\.[cy]))?\n %xm) do |meth_name, function, param_count, source_file|\n handle_method(\"method\", \"rb_mKernel\", meth_name, function, param_count,\n source_file)\n end\n\n @content.scan(/define_filetest_function\\s*\\(\n \\s*\"([^\"]+)\",\n \\s*(?:RUBY_METHOD_FUNC\\(|VALUEFUNC\\()?(\\w+)\\)?,\n \\s*(-?\\w+)\\s*\\)/xm) do |meth_name, function, param_count|\n\n handle_method(\"method\", \"rb_mFileTest\", meth_name, function, param_count)\n handle_method(\"singleton_method\", \"rb_cFile\", meth_name, function,\n param_count)\n end\n end", "def method\r\n\t1\r\nend", "def methods_accepting_symbol; end", "def name\n 'method 2'\n end", "def how_it_works\r\n end", "def method\n @method\n end", "def method\n @method\n end", "def method_shark es, method_name\n es.select {|e| e.method_name == method_name }\n .map {|e| \"\\n\\n\\n#{e.date}\\n\\n#{e.method_body}\" }\nend", "def meth(arg1,arg2)\nend", "def meth(arg1,arg2)\nend", "def add_method_documentation out, klass\n klass.method_list.each do |method|\n begin\n add_method out, method.full_name\n rescue NotFoundError\n next\n end\n end\n end", "def whatever\n end", "def runnable_methods; end", "def runnable_methods; end", "def required_operations1\n raise NotImplementedError, \"#{self.class} has not implemented method '#{__method__}'\"\n end", "def get_method_description(class_name, method_name = nil)\n ApipieDSL.debug(\"Getting #{class_name}##{method_name} documentation\")\n crumbs = class_name.split('#')\n method_name = crumbs.pop if method_name.nil?\n class_name = crumbs.join('#')\n class_description = get_class_description(class_name)\n raise ArgumentError, \"Class #{class_name} does not exists.\" if class_description.nil?\n\n class_description.method_description(method_name.to_sym)\n end", "def walk_method(name); end" ]
[ "0.7144192", "0.7030672", "0.7030672", "0.7030672", "0.7030672", "0.7030672", "0.7030672", "0.7030672", "0.7030672", "0.7030672", "0.7030672", "0.7030672", "0.7030672", "0.6951385", "0.68914163", "0.68914163", "0.68914163", "0.68914163", "0.6845223", "0.6793544", "0.6793544", "0.6793544", "0.6783549", "0.67805564", "0.67805564", "0.67805564", "0.67805564", "0.67805564", "0.67805564", "0.67805564", "0.67805564", "0.67805564", "0.67805564", "0.67805564", "0.67805564", "0.67795163", "0.67667294", "0.6741895", "0.67294997", "0.6726204", "0.666247", "0.6658481", "0.6649394", "0.66460615", "0.66315526", "0.6559414", "0.6527457", "0.65019655", "0.64998204", "0.6488273", "0.6453586", "0.64475846", "0.6427431", "0.6399014", "0.6376277", "0.63458115", "0.6334365", "0.6327143", "0.63208646", "0.6318502", "0.6315475", "0.6309246", "0.6304992", "0.6294064", "0.6272566", "0.6266656", "0.62443453", "0.62321985", "0.62075096", "0.6204848", "0.61607003", "0.6154697", "0.61518025", "0.614699", "0.6137053", "0.6137053", "0.6137053", "0.6137053", "0.6137053", "0.6137053", "0.6137053", "0.6137053", "0.6137053", "0.6137053", "0.61204946", "0.61150235", "0.6113433", "0.61126316", "0.61121863", "0.61121815", "0.61121815", "0.60841584", "0.608053", "0.608053", "0.6055033", "0.6049334", "0.60490596", "0.60490596", "0.6036352", "0.6034377", "0.6025764" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_profile @profile = current_user.profile 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 profile_params params.require(:profile).permit(:first_name, :last_name, :phone, :emergency_contact_name, :emergency_contact_no) 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 valid_params_request?; end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n 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 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 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 user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\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 ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\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 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 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 filter_params\n params.require(:filters).permit(:letters)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def permit_request_params\n params.permit(:address)\n end", "def sensitive_params=(params)\n @sensitive_params = params\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 backend_user_params\n params.permit!\n end", "def url_params\n params[:url].permit(:full)\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 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.6981273", "0.6783789", "0.67460483", "0.6742222", "0.67354137", "0.65934366", "0.65028495", "0.6497783", "0.64826745", "0.6479415", "0.6456823", "0.6440081", "0.63800216", "0.6376521", "0.636652", "0.6319898", "0.6300256", "0.62994003", "0.6293621", "0.6292629", "0.6291586", "0.629103", "0.6282451", "0.6243152", "0.62413", "0.6219024", "0.6213724", "0.62103724", "0.61945", "0.61786324", "0.61755824", "0.6173267", "0.6163613", "0.6153058", "0.61521065", "0.6147508", "0.61234015", "0.61168665", "0.6107466", "0.6106177", "0.6091159", "0.60817343", "0.6071238", "0.6062299", "0.6021663", "0.60182893", "0.6014239", "0.6011563", "0.60080767", "0.60080767", "0.60028875", "0.60005623", "0.59964156", "0.5993086", "0.5992319", "0.5992299", "0.59801805", "0.59676576", "0.59606016", "0.595966", "0.59591126", "0.59589803", "0.5954058", "0.5953234", "0.5944434", "0.5940526", "0.59376484", "0.59376484", "0.5935253", "0.5930846", "0.5926387", "0.59256274", "0.5917907", "0.5910841", "0.590886", "0.59086543", "0.59060425", "0.58981544", "0.5898102", "0.5896809", "0.5895416", "0.58947027", "0.58923644", "0.5887903", "0.58830196", "0.5880581", "0.5873854", "0.58697754", "0.5869004", "0.58669055", "0.5866886", "0.58664906", "0.5864619", "0.58630043", "0.5862495", "0.5861368", "0.5859712", "0.5855544", "0.58551925", "0.5851284", "0.5850602" ]
0.0
-1
To use relative find option it could be called as follows targetUiElement = FindChildOf(:class, 'SettingsView', :name, 'BtnBack')
def FindChildOf(parentByStrat, parentIdentifier, childByStrat, childIdentifier) parent = find_element(parentByStrat, parentIdentifier) return nil if parent==nil return parent.find_element(childByStrat, childIdentifier) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lp_back_button\n find_element(:xpath, \"//UIAApplication[1]/UIAWindow[1]/UIANavigationBar[1]/UIAButton[1]\")\n end", "def go_back\n back\n wait { find_ele_by_predicate_include(class_name: ui_ios.navbar, value: 'UICatalog') }\n end", "def btn_container\n\tbrowser.find_element(class: 'button-container')\n end", "def go_back\n back\n wait { !exists { id 'ArrowButton' } } # successfully transitioned back\n end", "def go_back\n back\n wait { !exists { id 'ArrowButton' } } # successfully transitioned back\n end", "def go_back\n @browser.back\n end", "def back\r\n @browser.navigate.back\r\n end", "def click_on_back_button\n\n click_button BACK_BUTTON\n sleep(THREAD_SLEEP_1)\n\n end", "def back\n driver.navigate.back\n end", "def back\n driver.navigate.back\n end", "def search_button\n @browser.find_element(:id, 'defaultToolbar').find_element(:class, 'search-inline-container').find_element(:class, 'search-inline-container-icon-search')\n end", "def last_button\n # uiautomator index doesn't support last\n # and it's 0 indexed\n button_index = tags(::Appium::Android::BUTTON).length\n button_index -= 1 if button_index.positive?\n image_button_index = tags(::Appium::Android::IMAGE_BUTTON).length\n image_button_index -= 1 if image_button_index.positive?\n\n _button_visible_selectors_xpath(button_index: button_index,\n image_button_index: image_button_index)\n end", "def check_back_button_present\n if back_button.is_present?\n true\n end\n end", "def last_button\n # uiautomator index doesn't support last\n # and it's 0 indexed\n button_index = tags(BUTTON).length\n button_index -= 1 if button_index.positive?\n image_button_index = tags(IMAGE_BUTTON).length\n image_button_index -= 1 if image_button_index.positive?\n\n find_element :uiautomator,\n _button_visible_selectors(button_index: button_index,\n image_button_index: image_button_index)\n end", "def check_if_back_button_is_displayed\n\n page.should have_button(BACK_BUTTON)\n sleep(THREAD_SLEEP_1)\n\n end", "def last_button\n last_ele UIAButton\n end", "def navigate(direction)\n if direction==\"back\"\n\t $driver.navigate.back\n else\n $driver.navigate.forward\n end\nend", "def back\n @driver.navigate.back\n @after_hooks.run\n end", "def back\n navigate.back\n end", "def back\n navigate.back\n end", "def back\n navigate.back\n end", "def linkwizard_find_button\n $tracer.trace(__method__)\n return ToolTag.new(button.className(\"/ats-search_button/\") ,__method__)\n end", "def first_button\n find_element :uiautomator, _button_visible_selectors(button_index: 0, image_button_index: 0)\n end", "def navigate_into\n title_element.when_present.click\n end", "def foresee_check\n if element_present?(:css, \"#fsrOverlay\")\n puts \" I found the foresee dialog.\"\n no_thanks_button = @driver.find_element(:link_text, \"No, thanks\")\n puts \" I found the 'No, Thanks' button.\"\n no_thanks_button.click\n puts \" I just clicked the 'No, thanks' button.\"\n end\nend", "def create_back_button(x, y)\n\t\tbutton = Button.new(@window, \n\t\t\t\t\t\t\[email protected]_messages.message(:back), \n\t\t\t\t\t\t\tConstants::BT_TEXT_HEIGHT,\n\t\t\t\t\t\t\tConstants::FONT_NAME)\n\t\tbutton.add_callback(:release, lambda {@main.current_menu = @parent})\n\t\tbutton.x = x\n\t\tbutton.y = y\n\t\tbutton\n\tend", "def ClickDropDownButton(buttonName)\n dropdown = findElementNamed(\"Filter-Drop-Down\")\n buttons = dropdown.find_elements(:name, \"Placeholder-Text\")\n return false if buttons == nil\n for button in buttons\n puts \"trying button named #{button.text}\"\n if button.text == buttonName\n button.click\n puts \"Clicked #{button.text}\"\n return true\n end\n end\n return false\nend", "def first_button\n first_ele UIAButton\n end", "def page_back_button_path\n registered_applications_path\n end", "def click_icon()\n return @driver.find_element(:xpath => '//*[@id=\"layout\"]/up-header-visitor-primary-nav/nav/div/div[2]/div[1]/up-header-search/up-c-on-click-outside/form/div/div/button[2]')\n end", "def go_back\r\n command 'goBack'\r\n end", "def go_back\r\n command 'goBack'\r\n end", "def test_link_back(link, parent_title, expected_title, lowercase = false, timeout = 5, dont_scroll = false)\n $logger.info(\"Link for \" + expected_title)\n wait = Selenium::WebDriver::Wait.new(timeout: timeout)\n\n if !dont_scroll\n js_scroll_up(link,true)\n end\n wait.until { link.displayed? }\n link.click\n begin\n if lowercase\n wait.until { $test_driver.title.downcase.include? expected_title }\n else\n wait.until { $test_driver.title.include? expected_title }\n end\n rescue Selenium::WebDriver::Error::TimeOutError\n fail(\"Error loading page \" + expected_title)\n end\n #Go back; some browsers have problems navigating back the first time\n num_retry = 0\n begin\n $test_driver.navigate.back\n wait.until { $test_driver.title.include? parent_title }\n rescue Selenium::WebDriver::Error::TimeOutError\n num_retry += 1\n retry if num_retry == 1\n fail(\"Error navigating back from \" + expected_title)\n end\nend", "def navigate(direction)\n if direction == 'back'\n\t $driver.navigate.back\n else\n $driver.navigate.forward\n end\nend", "def click_button_with_caption(caption, opts={})\r\n all_buttons = button_elements\r\n matching_buttons = all_buttons.select{|x| x.attribute('value') == caption}\r\n if matching_buttons.size > 0\r\n\r\n if opts && opts[:index]\r\n\t\t\t\t\t\tthe_index = opts[:index].to_i() - 1\r\n puts \"Call matching buttons: #{matching_buttons.inspect} => #{the_index}\"\r\n first_match = matching_buttons[the_index]\r\n first_match.click\r\n\t\t\t\t\telse\r\n\t the_button = matching_buttons[0]\r\n\t the_button.click\r\n end\r\n\r\n else\r\n raise \"No button with value: #{caption} found\"\r\n end\r\n end", "def button_exact(value)\n find_element :uiautomator, _button_exact_string(value)\n end", "def index_of_navbar_button (name)\n titles = query(\"navigationButton\", :accessibilityLabel)\n titles.index(name)\nend", "def set_btn_name\n !(@target =~ /invoice/i).nil? ? 'Next' : 'Save'\n end", "def go_back\n begin\n @driver.back\n\n rescue Exception => e\n @@logger.an_event.error \"browser go back : #{e.message}\"\n raise Errors::Error.new(BROWSER_NOT_GO_BACK, :values => {:browser => name}, :error => e)\n\n else\n\n @@logger.an_event.debug \"browser go back\"\n\n ensure\n\n end\n end", "def all_topic_follow_unfollow_buttons\n @browser.buttons(:class => \"btn-default icon\")\n end", "def find(locator)\n @browser.find_element locator\n end", "def set_navigation_back_or_menu(back_title = 'Back')\n if parent_screen.is_a?(PrimeResideMenu::SidebarContainerScreen)\n set_navigation_left_button 'Menu', image: 'images/navigation/menu_button.png', action: :show_sidebar\n else\n set_navigation_back_button back_title, icon: 'images/navigation/back_icon.png'\n end\n end", "def goBack(sender)\n web_view.goBack\n end", "def continue_button\n\tfind(\".btn--large\").click\nend", "def back_button_to(path, text = t('back'))\n link_to path, class: 'button small secondary' do\n concat text\n end\n end", "def wait_for_shibboleth_button_element()\n wait_for_element_by_class :btn, \"Error waiting for shibboleth button\"\n end", "def wait_for_shibboleth_button_element()\n wait_for_element_by_class :btn, \"Error waiting for shibboleth button\"\n end", "def goto_previous_page(browser_handle)\n browser_handle.back\nend", "def back\n $LOG.info \"Browser navigating backward\"\n begin\n $driver.navigate.back\n rescue Exception => e\n $LOG.error \"Browser navigating backward error \"+e.message\n $driver.save_screenshot(\"log/webscreenshot/webScreenshot_#{$webscreenshot}.png\")\n $webscreenshot = $webscreenshot+1\n raise \"Browser navigating backward error \\n Error Message :: \"+e.message\n end\n end", "def back_click\n back\nend", "def button(name, locator)\n self.finders[name] = ElementFinder.new(:find_button, locator)\n end", "def move_to element_name, right_by = nil, down_by = nil\n begin\n $driver.action.move_to(el(element_name), right_by, down_by).perform\n rescue Exception => e\n $LOG.error \"error in moving element \\n element name : #{element_name}, right: #{right_by} and down: #{down_by} \"+e.message\n $driver.save_screenshot(\"log/webscreenshot/webScreenshot_#{$webscreenshot}.png\")\n $webscreenshot = $webscreenshot+1\n raise \"error in moving element \\n element name : #{element_name}, right: #{right_by} and down: #{down_by} \"+e.message\n end\n end", "def widget_from_path(relative_path)\n raise 'relative_path must be a string' unless relative_path.class == String\n raise 'relative_path should not start with / (hence \"relative\")' if relative_path =~ /^\\//\n \n path_components = relative_path.split(/\\//)\n path_components.shift if path_components[0] == '.'\n # RAILS_DEFAULT_LOGGER.debug(\"starting search at self: #{self.name}, self.parent: #{self.parent.name}, self.root: #{self.root.name}\")\n \n start = self\n while path_components[0] == '..'\n # RAILS_DEFAULT_LOGGER.debug(\"path components: #{path_components.to_json}\")\n start = self.parent\n path_components.shift\n end\n \n path_components.each do |w|\n # RAILS_DEFAULT_LOGGER.debug(\"start: #{start.name}\")\n break if start.nil?\n start = start.find_widget(w)\n end\n start\n end", "def back_url\r\n \"/classes/main?k=#{self.id}\"\r\n end", "def isButtonOnPage_Caption (caption , frameName = \"\" )\n\n fname = getFunctionName()\n log fname + ' Starting. Trying to find button with caption: ' + caption if $debuglevel >=0\n buttonToUse = nil\n #begin\n \n # we have to find the button\n container = getObjectContainer( caption , \"\" , frameName )\n \n container.all.each do |c|\n next unless buttonToUse == nil\n begin\n if c.value == caption\n buttonToUse = c\n end\n rescue \n # this element probably doesnt have a value\n end\n end\n\n if buttonToUse == nil\n # the button wasnt found\n return false \n else\n # We found the button \n return true\n end\n\n #rescue\n return false\n #end\n end", "def previous_page\n @current_page = @agent.page.links.find { |l| l.text == \"← Previous\" }.click\n rescue\n nil\n end", "def button(value)\n # Don't use ele_index because that only works on one element type.\n # Android needs to combine button and image button to match iOS.\n if value.is_a? Numeric\n index = value\n raise \"#{index} is not a valid index. Must be >= 1\" if index <= 0\n\n # 1 indexed\n return find_element :uiautomator, _button_visible_selectors(index: index)\n end\n\n find_element :uiautomator, _button_contains_string(value)\n end", "def back_button_should_not_be_displayed\n\n page.should_not have_button(BACK_BUTTON)\n sleep(THREAD_SLEEP_1)\n\n end", "def uia_element\r\n if @locators[:value]\r\n uia_window = UiaDll::element_from_handle(@window.hwnd)\r\n begin\r\n uia_window.read_pointer\r\n rescue FFI::NullPointerError => e\r\n raise UnknownElementException, \"Window with handle #{@window.hwnd} does not exist\"\r\n end\r\n uia_control = UiaDll::find_child_by_name(uia_window, @locators[:value].to_s)\r\n begin\r\n uia_control.read_pointer\r\n rescue FFI::NullPointerError => e\r\n raise UnknownElementException, \"#{@locators[:value]} does not exist\"\r\n end\r\n uia_control\r\n else\r\n super\r\n end\r\n end", "def show_update_account_button\n page.execute_script \"document.getElementById('edit-profile-submit').scrollIntoView(true);\"\n page.execute_script \"window.scrollBy(0,-100);\"\nend", "def navigate_to_NBA_fanzone\n\n find(NBA_FANZONE_ICON_WITHIN_LEFT_HAND_SIDE).click\n\n end", "def find_element(obj, prev_obj=nil)\n # puts \"finding: #{obj.locator} parent: #{prev_obj.locator unless prev_obj.nil?}\"\n begin\n if obj.find_by == :xpath && obj.locator.include?('html')\n @element = page.find(:xpath, obj.locator, :visible => true)\n elsif obj.parent_element != nil && obj.parent_element.locator != nil\n @element = find_element(obj.parent_element, obj)\n else\n #TODO: this does not account for selectors after the id. I.E. #this that.overthere\n # need to do a split and do multiple finds based on the results of the split\n if obj.find_by == :css && obj.locator.include?('#')\n @element = page.find(:id, obj.locator.gsub('#', ''), :visible => true)\n else\n @element = page.find(obj.find_by, obj.locator, :visible => true)\n end\n end\n #TODO: There may be a flaw in this logic. Need to come back and review at some point\n if prev_obj\n if prev_obj.find_by == :css && prev_obj.locator.include?('#')\n @element = page.find(:id, prev_obj.locator.gsub('#', ''), :visible => true)\n else\n @element = @element.find(prev_obj.find_by, prev_obj.locator, :visible => true)\n end\n\n end\n rescue\n raise DATPages::Errors::ElementNotFound.new(obj.locator)\n end\n @element\n end", "def touch_alert_button_by_position(position)\n touch query(\"AppCompatButton id:'button#{position}'\")\nend", "def back_button(back_route)\n link_to(\"<i class=\\\"icon-white icon-arrow-left\\\"></i> Voltar\".html_safe, back_route, :class => 'btn btn-inverse',:title => 'voltar')\n end", "def find_element_button(browser, element_name, execution=false)\n button = nil\n not_found = \"element not found\"\n\n if browser.button(visible_text: element_name).present?\n button = browser.button(visible_text: element_name)\n puts button.text\n elsif browser.input(type: \"submit\", value: element_name)\n button = browser.input(type: \"submit\", value: element_name)\n puts button.value\n elsif browser.li(visible_text: element_name).present?\n button = browser.li(visible_text: element_name)\n puts button.text\n elsif browser.a(visible_text: element_name).present?\n button = browser.a(visible_text: element_name)\n puts button.text\n elsif browser.div(visible_text: element_name).present?\n button = browser.div(visible_text: element_name)\n puts button.text\n elsif browser.span(visible_text: element_name).present?\n button = browser.span(visible_text: element_name)\n puts button.text\n else\n #print not found if the element was not found\n puts not_found\n return nil\n end\n #click if the element found--function\n unless execution == false\n button.click\n end\n return \"ok\"\nend", "def navigate_back_to(window, presenter)\n until window.presenter_stack.last == presenter\n window.presenter_stack.pop\n window.presenter_state_stack.pop\n end\nend", "def linkwizard_next_button\n $tracer.trace(__method__)\n return ToolTag.new(button.className(\"/ats-search_button/\") ,__method__)\n end", "def search_for_ previous_element(_start_element, _style)\n unless _start_element.nil?\n # have we already found what we're looking for?\n if _start_element.name == _style\n return _start_element\n end\n # _start_element is a div.block and not the _start_element itself\n if _start_element[:class] == \"block\" && _start_element[:id] != @start_here[:id]\n # begin recursion with last child inside div.block\n from_child = search_for_ previous_element(_start_element.children.last, _style)\n if(from_child)\n return from_child\n end\n end\n # begin recursion with previous element\n from_child = search_for_ previous_element(_start_element.previous, _style) \n return from_child ? from_child : false\n else\n return false\n end\nend", "def back\n history_navigate(delta: -1)\n end", "def navigate_to(button)\n find('.navbar-toggle').click unless has_css?('.glyphicon.glyphicon-cog')\n find('.ng-binding', text: button).click\n end", "def find_relative(uri, base, options)\n nil\n end", "def link_back(text = t(\"common.link_back\"))\n link_to_function text, \"self.history.back();\", :class => 'back'\n end", "def button_exact(value)\n i = find_elements :xpath, _button_exact_string_xpath(BUTTON, value)\n e = find_elements :xpath, _button_exact_string_xpath(IMAGE_BUTTON, value)\n\n raise_no_such_element_if_empty(i + e)\n\n (i + e)[0]\n end", "def locate_element(how, what)\n return super unless @nokogiri\n\n el = @query_scope.browser.doc.send(\"at_#{how}\", what)\n Watigiri::Element.new element: el, selector: {how => what}\n end", "def search_buttons(file_name)\r\n\r\n @doc.xpath('//object[@class = \"GtkButton\"]/property[@name = \"image\"]').each do |b|\r\n\r\n if (b.parent.to_s !~ /tooltip_text/)\r\n @button = b.parent.xpath('./property [@name=\"image\"]/text()')\r\n\r\n button_item = search_stockitem(@button)\r\n\r\n b.add_next_sibling(\"\\n<property name=\\\"tooltip_text\\\" translatable=\\\"yes\\\">#{TEXTS[\"#{button_item}\"]}</property>\")\r\n end\r\n end\r\n if (@button)\r\n printf(\"%s\\n\", file_name)\r\n write_new_file(file_name)\r\n rename_file(file_name)\r\n end\r\n @button = FALSE\r\n\r\nend", "def navigate_click(classname, location)\n btn = find(classname)\n @emberHelper.ember_transition_click btn\n expect(current_path).to eq(\"/#{locale}/app/#{location}\")\n end", "def navigate_click(classname, location)\n btn = find(classname)\n @emberHelper.ember_transition_click btn\n expect(current_path).to eq(\"/#{locale}/app/#{location}\")\n end", "def navigate_click(classname, location)\n btn = find(classname)\n @emberHelper.ember_transition_click btn\n expect(current_path).to eq(\"/#{locale}/app/#{location}\")\n end", "def find_root_element\n if parent\n parent.find_root_element\n else\n self\n end\n end", "def buttons_exact(value)\n find_elements :uiautomator, _button_exact_string(value)\n end", "def click_search_icon\n click SEARCH_BUTTON\n end", "def complex_find_exact(class_name, value)\n find_element :uiautomator, string_visible_exact(class_name, value)\n end", "def back_button(path:, name: :BACK.t, **args, &block)\n content = block ? capture(&block) : \"\"\n html_options = {\n class: \"\", # usually also btn\n data: { toggle: \"tooltip\", placement: \"top\", title: name }\n }.merge(args)\n\n link_to(path, html_options) do\n [content, link_icon(:back)].safe_join\n end\n end", "def get_element(locator, base_element = nil)\n (base_element ? base_element : @browser).find_element(locator)\n end", "def forward\n driver.navigate.forward\n end", "def forward\n driver.navigate.forward\n end", "def find_element(*args)\n sleep 0.1\n how, what, timeout = extract_args(args)\n by = Selenium::WebDriver::SearchContext::FINDERS[how.to_sym]\n wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => \"element not found\"})\n wait.until {\n bridge.find_element_by by, what.to_s, ref\n }\n rescue Selenium::WebDriver::Error::TimeOutError => e\n return nil\n #raise Selenium::WebDriver::Error::NoSuchElementError\n end", "def first_button\n _button_visible_selectors_xpath(button_index: 0, image_button_index: 0)\n end", "def on_load\n set_nav_bar_button :left, title: \"Back\", action: :close_help_screen\n end", "def find_native_element(native_element)\n find_element(native_element[:locator], native_element[:element])\nend", "def shipping_add_back_button\n # unit_test_no_generate: shipping_add_back_button, button.className(create_ats_regex_string(\"ats-wis-backtoshipaddedit\"))\n\t\t$tracer.trace(__method__)\n\t return ToolTag.new(button.className(create_ats_regex_string(\"ats-wis-backtoshipaddedit\")), __method__)\n\tend", "def back\n fetch(\"_sahi.go_back()\")\n end", "def root_back\n src = 'arrow-left-circle.svg'\n alt = :back\n return link_image( src, alt, root_path )\n end", "def locate\n self\n end", "def bring_to_front\n {\n method: \"Page.bringToFront\"\n }\n end", "def select_menu_item(value)\n #checking for reach end of list( get_source is current screen id)\n current_screen = get_source\n previous_screen = \"\"\n\n until (exists {find_element(id:\"design_navigation_view\").find_element(xpath:\"//android.widget.CheckedTextView[@text='#{value}']\")}) || (current_screen == previous_screen) do\n Appium::TouchAction.new.swipe(start_x:0.5,start_y: 0.8,end_x:0.5,end_y:0.2,duration:500).perform\n previous_screen = current_screen\n current_screen = get_source\n end\n #add more information in case of errors\n if exists {find_element(id:\"design_navigation_view\").find_element(xpath:\"//android.widget.CheckedTextView[@text='#{value}']\")}\n find_element(id:\"design_navigation_view\").find_element(xpath:\"//android.widget.CheckedTextView[@text='#{value}']\").click\n else\n fail(\"Element #{value} was not found in menu\")\n end\nend", "def voiceResult(best:String)\n Log.d('bullshit', \"best result = #{best}\")\n\n start_voice_rec\n\n # Find the corresponding button and trigger it\n top_layout = LinearLayout(findViewById(R.id.game_top_layout))\n Log.d('bullshit', \"this ll has #{top_layout.getChildCount} children\")\n 0.upto(top_layout.getChildCount - 1) do |i|\n row_layout = LinearLayout(top_layout.getChildAt(i))\n 0.upto(row_layout.getChildCount - 1) do |j|\n btn = Button(row_layout.getChildAt(j))\n if btn.getText.toString.equals(best)\n btn.performClick\n #btn.setBackgroundColor(int(0xFFFF0000))\n return nil\n end\n Log.d('bullshit', \"this btn is labeled #{btn.getText}\")\n end\n end\n\n nil\n end", "def browse\n click_mobile_menu\n get_mobile_menu_element('browse')\n end", "def click_on(what)\n if what.is_a? Integer\n child_elements = children\n child_elements[what - 1].click if what - 1 <= child_elements.count\n else\n click_label what\n end\n end", "def find_element(*args)\n sleep 0.4\n how, what, timeout = extract_args(args)\n by = Selenium::WebDriver::SearchContext::FINDERS[how.to_sym]\n wait = Object::Selenium::WebDriver::Wait.new(timeout: timeout, message: 'element not found')\n wait.until do\n begin\n bridge.find_element_by(by, what.to_s, ref)\n rescue\n false\n end\n end\n rescue Selenium::WebDriver::Error::TimeOutError\n puts \"element not found #{how} #{what}\" if timeout > 3\n nil\n end", "def goto relative_url\n destination = File.join(@site.origin, relative_url) \n @browser.goto destination\n end" ]
[ "0.68438077", "0.6045786", "0.56996936", "0.5551243", "0.5551243", "0.54766047", "0.5469208", "0.5453421", "0.52884436", "0.52884436", "0.5264842", "0.5255649", "0.5235375", "0.52099055", "0.51614887", "0.5152129", "0.5139528", "0.5128947", "0.5113548", "0.5113548", "0.5113548", "0.5107353", "0.50565237", "0.50525296", "0.5020697", "0.50072634", "0.50031215", "0.5001227", "0.4997745", "0.49915987", "0.49853235", "0.49853235", "0.49771672", "0.4958922", "0.4953256", "0.4921046", "0.49201545", "0.4913749", "0.49067238", "0.49028406", "0.48830128", "0.487001", "0.48691094", "0.48635146", "0.4849473", "0.48415953", "0.48415953", "0.48362085", "0.48266703", "0.4822051", "0.48166925", "0.48157898", "0.4793494", "0.47904223", "0.47874898", "0.47854203", "0.47670126", "0.4765683", "0.47639218", "0.4743019", "0.47401798", "0.47281897", "0.47216952", "0.4705026", "0.46985614", "0.46968582", "0.46948707", "0.46889794", "0.46858168", "0.4682056", "0.46691802", "0.46690208", "0.4647897", "0.4645665", "0.46392715", "0.46318936", "0.46318936", "0.46318936", "0.46314487", "0.46132863", "0.46066535", "0.46008858", "0.45925817", "0.45898783", "0.45862952", "0.45862952", "0.45858696", "0.4581282", "0.45790964", "0.45716047", "0.45627207", "0.45625922", "0.4562428", "0.4558942", "0.45561472", "0.45529583", "0.45514756", "0.45496032", "0.45457757", "0.45423502", "0.4531482" ]
0.0
-1
To use relative find option it could be called as follows targetUiElement = FindChildOf(:class, 'SettingsView', :name, 'BtnBack')
def ClickDropDownButton(buttonName) dropdown = findElementNamed("Filter-Drop-Down") buttons = dropdown.find_elements(:name, "Placeholder-Text") return false if buttons == nil for button in buttons puts "trying button named #{button.text}" if button.text == buttonName button.click puts "Clicked #{button.text}" return true end end return false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lp_back_button\n find_element(:xpath, \"//UIAApplication[1]/UIAWindow[1]/UIANavigationBar[1]/UIAButton[1]\")\n end", "def go_back\n back\n wait { find_ele_by_predicate_include(class_name: ui_ios.navbar, value: 'UICatalog') }\n end", "def btn_container\n\tbrowser.find_element(class: 'button-container')\n end", "def go_back\n back\n wait { !exists { id 'ArrowButton' } } # successfully transitioned back\n end", "def go_back\n back\n wait { !exists { id 'ArrowButton' } } # successfully transitioned back\n end", "def go_back\n @browser.back\n end", "def back\r\n @browser.navigate.back\r\n end", "def click_on_back_button\n\n click_button BACK_BUTTON\n sleep(THREAD_SLEEP_1)\n\n end", "def back\n driver.navigate.back\n end", "def back\n driver.navigate.back\n end", "def search_button\n @browser.find_element(:id, 'defaultToolbar').find_element(:class, 'search-inline-container').find_element(:class, 'search-inline-container-icon-search')\n end", "def last_button\n # uiautomator index doesn't support last\n # and it's 0 indexed\n button_index = tags(::Appium::Android::BUTTON).length\n button_index -= 1 if button_index.positive?\n image_button_index = tags(::Appium::Android::IMAGE_BUTTON).length\n image_button_index -= 1 if image_button_index.positive?\n\n _button_visible_selectors_xpath(button_index: button_index,\n image_button_index: image_button_index)\n end", "def check_back_button_present\n if back_button.is_present?\n true\n end\n end", "def last_button\n # uiautomator index doesn't support last\n # and it's 0 indexed\n button_index = tags(BUTTON).length\n button_index -= 1 if button_index.positive?\n image_button_index = tags(IMAGE_BUTTON).length\n image_button_index -= 1 if image_button_index.positive?\n\n find_element :uiautomator,\n _button_visible_selectors(button_index: button_index,\n image_button_index: image_button_index)\n end", "def check_if_back_button_is_displayed\n\n page.should have_button(BACK_BUTTON)\n sleep(THREAD_SLEEP_1)\n\n end", "def last_button\n last_ele UIAButton\n end", "def navigate(direction)\n if direction==\"back\"\n\t $driver.navigate.back\n else\n $driver.navigate.forward\n end\nend", "def back\n @driver.navigate.back\n @after_hooks.run\n end", "def back\n navigate.back\n end", "def back\n navigate.back\n end", "def back\n navigate.back\n end", "def linkwizard_find_button\n $tracer.trace(__method__)\n return ToolTag.new(button.className(\"/ats-search_button/\") ,__method__)\n end", "def first_button\n find_element :uiautomator, _button_visible_selectors(button_index: 0, image_button_index: 0)\n end", "def navigate_into\n title_element.when_present.click\n end", "def foresee_check\n if element_present?(:css, \"#fsrOverlay\")\n puts \" I found the foresee dialog.\"\n no_thanks_button = @driver.find_element(:link_text, \"No, thanks\")\n puts \" I found the 'No, Thanks' button.\"\n no_thanks_button.click\n puts \" I just clicked the 'No, thanks' button.\"\n end\nend", "def create_back_button(x, y)\n\t\tbutton = Button.new(@window, \n\t\t\t\t\t\t\[email protected]_messages.message(:back), \n\t\t\t\t\t\t\tConstants::BT_TEXT_HEIGHT,\n\t\t\t\t\t\t\tConstants::FONT_NAME)\n\t\tbutton.add_callback(:release, lambda {@main.current_menu = @parent})\n\t\tbutton.x = x\n\t\tbutton.y = y\n\t\tbutton\n\tend", "def first_button\n first_ele UIAButton\n end", "def page_back_button_path\n registered_applications_path\n end", "def click_icon()\n return @driver.find_element(:xpath => '//*[@id=\"layout\"]/up-header-visitor-primary-nav/nav/div/div[2]/div[1]/up-header-search/up-c-on-click-outside/form/div/div/button[2]')\n end", "def go_back\r\n command 'goBack'\r\n end", "def go_back\r\n command 'goBack'\r\n end", "def test_link_back(link, parent_title, expected_title, lowercase = false, timeout = 5, dont_scroll = false)\n $logger.info(\"Link for \" + expected_title)\n wait = Selenium::WebDriver::Wait.new(timeout: timeout)\n\n if !dont_scroll\n js_scroll_up(link,true)\n end\n wait.until { link.displayed? }\n link.click\n begin\n if lowercase\n wait.until { $test_driver.title.downcase.include? expected_title }\n else\n wait.until { $test_driver.title.include? expected_title }\n end\n rescue Selenium::WebDriver::Error::TimeOutError\n fail(\"Error loading page \" + expected_title)\n end\n #Go back; some browsers have problems navigating back the first time\n num_retry = 0\n begin\n $test_driver.navigate.back\n wait.until { $test_driver.title.include? parent_title }\n rescue Selenium::WebDriver::Error::TimeOutError\n num_retry += 1\n retry if num_retry == 1\n fail(\"Error navigating back from \" + expected_title)\n end\nend", "def navigate(direction)\n if direction == 'back'\n\t $driver.navigate.back\n else\n $driver.navigate.forward\n end\nend", "def click_button_with_caption(caption, opts={})\r\n all_buttons = button_elements\r\n matching_buttons = all_buttons.select{|x| x.attribute('value') == caption}\r\n if matching_buttons.size > 0\r\n\r\n if opts && opts[:index]\r\n\t\t\t\t\t\tthe_index = opts[:index].to_i() - 1\r\n puts \"Call matching buttons: #{matching_buttons.inspect} => #{the_index}\"\r\n first_match = matching_buttons[the_index]\r\n first_match.click\r\n\t\t\t\t\telse\r\n\t the_button = matching_buttons[0]\r\n\t the_button.click\r\n end\r\n\r\n else\r\n raise \"No button with value: #{caption} found\"\r\n end\r\n end", "def button_exact(value)\n find_element :uiautomator, _button_exact_string(value)\n end", "def index_of_navbar_button (name)\n titles = query(\"navigationButton\", :accessibilityLabel)\n titles.index(name)\nend", "def set_btn_name\n !(@target =~ /invoice/i).nil? ? 'Next' : 'Save'\n end", "def go_back\n begin\n @driver.back\n\n rescue Exception => e\n @@logger.an_event.error \"browser go back : #{e.message}\"\n raise Errors::Error.new(BROWSER_NOT_GO_BACK, :values => {:browser => name}, :error => e)\n\n else\n\n @@logger.an_event.debug \"browser go back\"\n\n ensure\n\n end\n end", "def all_topic_follow_unfollow_buttons\n @browser.buttons(:class => \"btn-default icon\")\n end", "def find(locator)\n @browser.find_element locator\n end", "def set_navigation_back_or_menu(back_title = 'Back')\n if parent_screen.is_a?(PrimeResideMenu::SidebarContainerScreen)\n set_navigation_left_button 'Menu', image: 'images/navigation/menu_button.png', action: :show_sidebar\n else\n set_navigation_back_button back_title, icon: 'images/navigation/back_icon.png'\n end\n end", "def goBack(sender)\n web_view.goBack\n end", "def continue_button\n\tfind(\".btn--large\").click\nend", "def back_button_to(path, text = t('back'))\n link_to path, class: 'button small secondary' do\n concat text\n end\n end", "def wait_for_shibboleth_button_element()\n wait_for_element_by_class :btn, \"Error waiting for shibboleth button\"\n end", "def wait_for_shibboleth_button_element()\n wait_for_element_by_class :btn, \"Error waiting for shibboleth button\"\n end", "def goto_previous_page(browser_handle)\n browser_handle.back\nend", "def back\n $LOG.info \"Browser navigating backward\"\n begin\n $driver.navigate.back\n rescue Exception => e\n $LOG.error \"Browser navigating backward error \"+e.message\n $driver.save_screenshot(\"log/webscreenshot/webScreenshot_#{$webscreenshot}.png\")\n $webscreenshot = $webscreenshot+1\n raise \"Browser navigating backward error \\n Error Message :: \"+e.message\n end\n end", "def back_click\n back\nend", "def button(name, locator)\n self.finders[name] = ElementFinder.new(:find_button, locator)\n end", "def move_to element_name, right_by = nil, down_by = nil\n begin\n $driver.action.move_to(el(element_name), right_by, down_by).perform\n rescue Exception => e\n $LOG.error \"error in moving element \\n element name : #{element_name}, right: #{right_by} and down: #{down_by} \"+e.message\n $driver.save_screenshot(\"log/webscreenshot/webScreenshot_#{$webscreenshot}.png\")\n $webscreenshot = $webscreenshot+1\n raise \"error in moving element \\n element name : #{element_name}, right: #{right_by} and down: #{down_by} \"+e.message\n end\n end", "def widget_from_path(relative_path)\n raise 'relative_path must be a string' unless relative_path.class == String\n raise 'relative_path should not start with / (hence \"relative\")' if relative_path =~ /^\\//\n \n path_components = relative_path.split(/\\//)\n path_components.shift if path_components[0] == '.'\n # RAILS_DEFAULT_LOGGER.debug(\"starting search at self: #{self.name}, self.parent: #{self.parent.name}, self.root: #{self.root.name}\")\n \n start = self\n while path_components[0] == '..'\n # RAILS_DEFAULT_LOGGER.debug(\"path components: #{path_components.to_json}\")\n start = self.parent\n path_components.shift\n end\n \n path_components.each do |w|\n # RAILS_DEFAULT_LOGGER.debug(\"start: #{start.name}\")\n break if start.nil?\n start = start.find_widget(w)\n end\n start\n end", "def back_url\r\n \"/classes/main?k=#{self.id}\"\r\n end", "def isButtonOnPage_Caption (caption , frameName = \"\" )\n\n fname = getFunctionName()\n log fname + ' Starting. Trying to find button with caption: ' + caption if $debuglevel >=0\n buttonToUse = nil\n #begin\n \n # we have to find the button\n container = getObjectContainer( caption , \"\" , frameName )\n \n container.all.each do |c|\n next unless buttonToUse == nil\n begin\n if c.value == caption\n buttonToUse = c\n end\n rescue \n # this element probably doesnt have a value\n end\n end\n\n if buttonToUse == nil\n # the button wasnt found\n return false \n else\n # We found the button \n return true\n end\n\n #rescue\n return false\n #end\n end", "def previous_page\n @current_page = @agent.page.links.find { |l| l.text == \"← Previous\" }.click\n rescue\n nil\n end", "def button(value)\n # Don't use ele_index because that only works on one element type.\n # Android needs to combine button and image button to match iOS.\n if value.is_a? Numeric\n index = value\n raise \"#{index} is not a valid index. Must be >= 1\" if index <= 0\n\n # 1 indexed\n return find_element :uiautomator, _button_visible_selectors(index: index)\n end\n\n find_element :uiautomator, _button_contains_string(value)\n end", "def back_button_should_not_be_displayed\n\n page.should_not have_button(BACK_BUTTON)\n sleep(THREAD_SLEEP_1)\n\n end", "def uia_element\r\n if @locators[:value]\r\n uia_window = UiaDll::element_from_handle(@window.hwnd)\r\n begin\r\n uia_window.read_pointer\r\n rescue FFI::NullPointerError => e\r\n raise UnknownElementException, \"Window with handle #{@window.hwnd} does not exist\"\r\n end\r\n uia_control = UiaDll::find_child_by_name(uia_window, @locators[:value].to_s)\r\n begin\r\n uia_control.read_pointer\r\n rescue FFI::NullPointerError => e\r\n raise UnknownElementException, \"#{@locators[:value]} does not exist\"\r\n end\r\n uia_control\r\n else\r\n super\r\n end\r\n end", "def show_update_account_button\n page.execute_script \"document.getElementById('edit-profile-submit').scrollIntoView(true);\"\n page.execute_script \"window.scrollBy(0,-100);\"\nend", "def navigate_to_NBA_fanzone\n\n find(NBA_FANZONE_ICON_WITHIN_LEFT_HAND_SIDE).click\n\n end", "def find_element(obj, prev_obj=nil)\n # puts \"finding: #{obj.locator} parent: #{prev_obj.locator unless prev_obj.nil?}\"\n begin\n if obj.find_by == :xpath && obj.locator.include?('html')\n @element = page.find(:xpath, obj.locator, :visible => true)\n elsif obj.parent_element != nil && obj.parent_element.locator != nil\n @element = find_element(obj.parent_element, obj)\n else\n #TODO: this does not account for selectors after the id. I.E. #this that.overthere\n # need to do a split and do multiple finds based on the results of the split\n if obj.find_by == :css && obj.locator.include?('#')\n @element = page.find(:id, obj.locator.gsub('#', ''), :visible => true)\n else\n @element = page.find(obj.find_by, obj.locator, :visible => true)\n end\n end\n #TODO: There may be a flaw in this logic. Need to come back and review at some point\n if prev_obj\n if prev_obj.find_by == :css && prev_obj.locator.include?('#')\n @element = page.find(:id, prev_obj.locator.gsub('#', ''), :visible => true)\n else\n @element = @element.find(prev_obj.find_by, prev_obj.locator, :visible => true)\n end\n\n end\n rescue\n raise DATPages::Errors::ElementNotFound.new(obj.locator)\n end\n @element\n end", "def touch_alert_button_by_position(position)\n touch query(\"AppCompatButton id:'button#{position}'\")\nend", "def back_button(back_route)\n link_to(\"<i class=\\\"icon-white icon-arrow-left\\\"></i> Voltar\".html_safe, back_route, :class => 'btn btn-inverse',:title => 'voltar')\n end", "def find_element_button(browser, element_name, execution=false)\n button = nil\n not_found = \"element not found\"\n\n if browser.button(visible_text: element_name).present?\n button = browser.button(visible_text: element_name)\n puts button.text\n elsif browser.input(type: \"submit\", value: element_name)\n button = browser.input(type: \"submit\", value: element_name)\n puts button.value\n elsif browser.li(visible_text: element_name).present?\n button = browser.li(visible_text: element_name)\n puts button.text\n elsif browser.a(visible_text: element_name).present?\n button = browser.a(visible_text: element_name)\n puts button.text\n elsif browser.div(visible_text: element_name).present?\n button = browser.div(visible_text: element_name)\n puts button.text\n elsif browser.span(visible_text: element_name).present?\n button = browser.span(visible_text: element_name)\n puts button.text\n else\n #print not found if the element was not found\n puts not_found\n return nil\n end\n #click if the element found--function\n unless execution == false\n button.click\n end\n return \"ok\"\nend", "def navigate_back_to(window, presenter)\n until window.presenter_stack.last == presenter\n window.presenter_stack.pop\n window.presenter_state_stack.pop\n end\nend", "def linkwizard_next_button\n $tracer.trace(__method__)\n return ToolTag.new(button.className(\"/ats-search_button/\") ,__method__)\n end", "def search_for_ previous_element(_start_element, _style)\n unless _start_element.nil?\n # have we already found what we're looking for?\n if _start_element.name == _style\n return _start_element\n end\n # _start_element is a div.block and not the _start_element itself\n if _start_element[:class] == \"block\" && _start_element[:id] != @start_here[:id]\n # begin recursion with last child inside div.block\n from_child = search_for_ previous_element(_start_element.children.last, _style)\n if(from_child)\n return from_child\n end\n end\n # begin recursion with previous element\n from_child = search_for_ previous_element(_start_element.previous, _style) \n return from_child ? from_child : false\n else\n return false\n end\nend", "def back\n history_navigate(delta: -1)\n end", "def navigate_to(button)\n find('.navbar-toggle').click unless has_css?('.glyphicon.glyphicon-cog')\n find('.ng-binding', text: button).click\n end", "def find_relative(uri, base, options)\n nil\n end", "def link_back(text = t(\"common.link_back\"))\n link_to_function text, \"self.history.back();\", :class => 'back'\n end", "def button_exact(value)\n i = find_elements :xpath, _button_exact_string_xpath(BUTTON, value)\n e = find_elements :xpath, _button_exact_string_xpath(IMAGE_BUTTON, value)\n\n raise_no_such_element_if_empty(i + e)\n\n (i + e)[0]\n end", "def locate_element(how, what)\n return super unless @nokogiri\n\n el = @query_scope.browser.doc.send(\"at_#{how}\", what)\n Watigiri::Element.new element: el, selector: {how => what}\n end", "def search_buttons(file_name)\r\n\r\n @doc.xpath('//object[@class = \"GtkButton\"]/property[@name = \"image\"]').each do |b|\r\n\r\n if (b.parent.to_s !~ /tooltip_text/)\r\n @button = b.parent.xpath('./property [@name=\"image\"]/text()')\r\n\r\n button_item = search_stockitem(@button)\r\n\r\n b.add_next_sibling(\"\\n<property name=\\\"tooltip_text\\\" translatable=\\\"yes\\\">#{TEXTS[\"#{button_item}\"]}</property>\")\r\n end\r\n end\r\n if (@button)\r\n printf(\"%s\\n\", file_name)\r\n write_new_file(file_name)\r\n rename_file(file_name)\r\n end\r\n @button = FALSE\r\n\r\nend", "def navigate_click(classname, location)\n btn = find(classname)\n @emberHelper.ember_transition_click btn\n expect(current_path).to eq(\"/#{locale}/app/#{location}\")\n end", "def navigate_click(classname, location)\n btn = find(classname)\n @emberHelper.ember_transition_click btn\n expect(current_path).to eq(\"/#{locale}/app/#{location}\")\n end", "def navigate_click(classname, location)\n btn = find(classname)\n @emberHelper.ember_transition_click btn\n expect(current_path).to eq(\"/#{locale}/app/#{location}\")\n end", "def find_root_element\n if parent\n parent.find_root_element\n else\n self\n end\n end", "def buttons_exact(value)\n find_elements :uiautomator, _button_exact_string(value)\n end", "def click_search_icon\n click SEARCH_BUTTON\n end", "def complex_find_exact(class_name, value)\n find_element :uiautomator, string_visible_exact(class_name, value)\n end", "def back_button(path:, name: :BACK.t, **args, &block)\n content = block ? capture(&block) : \"\"\n html_options = {\n class: \"\", # usually also btn\n data: { toggle: \"tooltip\", placement: \"top\", title: name }\n }.merge(args)\n\n link_to(path, html_options) do\n [content, link_icon(:back)].safe_join\n end\n end", "def get_element(locator, base_element = nil)\n (base_element ? base_element : @browser).find_element(locator)\n end", "def find_element(*args)\n sleep 0.1\n how, what, timeout = extract_args(args)\n by = Selenium::WebDriver::SearchContext::FINDERS[how.to_sym]\n wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => \"element not found\"})\n wait.until {\n bridge.find_element_by by, what.to_s, ref\n }\n rescue Selenium::WebDriver::Error::TimeOutError => e\n return nil\n #raise Selenium::WebDriver::Error::NoSuchElementError\n end", "def forward\n driver.navigate.forward\n end", "def forward\n driver.navigate.forward\n end", "def first_button\n _button_visible_selectors_xpath(button_index: 0, image_button_index: 0)\n end", "def on_load\n set_nav_bar_button :left, title: \"Back\", action: :close_help_screen\n end", "def find_native_element(native_element)\n find_element(native_element[:locator], native_element[:element])\nend", "def root_back\n src = 'arrow-left-circle.svg'\n alt = :back\n return link_image( src, alt, root_path )\n end", "def back\n fetch(\"_sahi.go_back()\")\n end", "def shipping_add_back_button\n # unit_test_no_generate: shipping_add_back_button, button.className(create_ats_regex_string(\"ats-wis-backtoshipaddedit\"))\n\t\t$tracer.trace(__method__)\n\t return ToolTag.new(button.className(create_ats_regex_string(\"ats-wis-backtoshipaddedit\")), __method__)\n\tend", "def locate\n self\n end", "def bring_to_front\n {\n method: \"Page.bringToFront\"\n }\n end", "def voiceResult(best:String)\n Log.d('bullshit', \"best result = #{best}\")\n\n start_voice_rec\n\n # Find the corresponding button and trigger it\n top_layout = LinearLayout(findViewById(R.id.game_top_layout))\n Log.d('bullshit', \"this ll has #{top_layout.getChildCount} children\")\n 0.upto(top_layout.getChildCount - 1) do |i|\n row_layout = LinearLayout(top_layout.getChildAt(i))\n 0.upto(row_layout.getChildCount - 1) do |j|\n btn = Button(row_layout.getChildAt(j))\n if btn.getText.toString.equals(best)\n btn.performClick\n #btn.setBackgroundColor(int(0xFFFF0000))\n return nil\n end\n Log.d('bullshit', \"this btn is labeled #{btn.getText}\")\n end\n end\n\n nil\n end", "def select_menu_item(value)\n #checking for reach end of list( get_source is current screen id)\n current_screen = get_source\n previous_screen = \"\"\n\n until (exists {find_element(id:\"design_navigation_view\").find_element(xpath:\"//android.widget.CheckedTextView[@text='#{value}']\")}) || (current_screen == previous_screen) do\n Appium::TouchAction.new.swipe(start_x:0.5,start_y: 0.8,end_x:0.5,end_y:0.2,duration:500).perform\n previous_screen = current_screen\n current_screen = get_source\n end\n #add more information in case of errors\n if exists {find_element(id:\"design_navigation_view\").find_element(xpath:\"//android.widget.CheckedTextView[@text='#{value}']\")}\n find_element(id:\"design_navigation_view\").find_element(xpath:\"//android.widget.CheckedTextView[@text='#{value}']\").click\n else\n fail(\"Element #{value} was not found in menu\")\n end\nend", "def browse\n click_mobile_menu\n get_mobile_menu_element('browse')\n end", "def click_on(what)\n if what.is_a? Integer\n child_elements = children\n child_elements[what - 1].click if what - 1 <= child_elements.count\n else\n click_label what\n end\n end", "def find_element(*args)\n sleep 0.4\n how, what, timeout = extract_args(args)\n by = Selenium::WebDriver::SearchContext::FINDERS[how.to_sym]\n wait = Object::Selenium::WebDriver::Wait.new(timeout: timeout, message: 'element not found')\n wait.until do\n begin\n bridge.find_element_by(by, what.to_s, ref)\n rescue\n false\n end\n end\n rescue Selenium::WebDriver::Error::TimeOutError\n puts \"element not found #{how} #{what}\" if timeout > 3\n nil\n end", "def goto relative_url\n destination = File.join(@site.origin, relative_url) \n @browser.goto destination\n end" ]
[ "0.68443733", "0.6045651", "0.56981456", "0.55520684", "0.55520684", "0.54762036", "0.54685616", "0.545441", "0.52879673", "0.52879673", "0.5264524", "0.52568436", "0.52361417", "0.52107376", "0.51617014", "0.5152375", "0.5139827", "0.5128613", "0.5113316", "0.5113316", "0.5113316", "0.5106576", "0.5056527", "0.50517684", "0.50194085", "0.5008124", "0.5001249", "0.4998339", "0.49920544", "0.49857736", "0.49857736", "0.4976865", "0.49593598", "0.4953111", "0.49214762", "0.49209785", "0.49129167", "0.4907226", "0.49018452", "0.48823193", "0.48710963", "0.48691297", "0.48628286", "0.4849952", "0.4841789", "0.4841789", "0.48353508", "0.48272353", "0.4822095", "0.48179457", "0.48151028", "0.47967982", "0.47892785", "0.47880897", "0.47853005", "0.4768321", "0.4765887", "0.47633398", "0.47418225", "0.47391003", "0.4726152", "0.47226366", "0.47060707", "0.46993652", "0.4695129", "0.4694438", "0.46887755", "0.46865493", "0.46826854", "0.4671194", "0.46694136", "0.4649237", "0.4644227", "0.46400204", "0.46315876", "0.46315876", "0.46315876", "0.463107", "0.4613834", "0.46074605", "0.45987222", "0.4594152", "0.45894513", "0.45850283", "0.45847228", "0.45847228", "0.45811048", "0.45797575", "0.45713672", "0.45635763", "0.45628956", "0.45619774", "0.45579326", "0.45550424", "0.4551985", "0.45518854", "0.45504305", "0.45465672", "0.45413744", "0.4533127" ]
0.5003179
26
Convenience method to peform a swipe. Note that iOS 7 simulators have broken swipe.
def swipe(opts) start_x = opts.fetch :start_x, 0 start_y = opts.fetch :start_y, 0 end_x = opts.fetch :end_x, 0 end_y = opts.fetch :end_y, 0 duration = opts.fetch :duration, 2 action = Appium::TouchAction.new.press(x: start_x, y: start_y).move_to(x: end_x, y: end_y).release action.perform end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def swipe(direction, duration=700)\n # @option opts [int] :start_x Where to start swiping, on the x axis. Default 0.\n # @option opts [int] :start_y Where to start swiping, on the y axis. Default 0.\n # @option opts [int] :end_x Where to end swiping, on the x axis. Default 0.\n # @option opts [int] :end_y Where to end swiping, on the y axis. Default 0.\n # @option opts [int] :duration How long the actual swipe takes to complete in milliseconds.\n screen_resolution = $driver.window_size\n up = {\n start_x: screen_resolution.width/2,\n start_y: screen_resolution.height/2,\n end_x: screen_resolution.width/2,\n end_y: 0001,\n duration: duration\n }\n down = {\n start_x: screen_resolution.width/2,\n start_y: screen_resolution.height/2,\n end_x: screen_resolution.width/2,\n end_y: screen_resolution.height - 10,\n duration: duration\n }\n left = {\n start_x: screen_resolution.width - 10,\n start_y: screen_resolution.height/2,\n end_x: 0200,\n end_y: screen_resolution.height/2,\n duration: duration\n }\n right = {\n start_x: 0200,\n start_y: screen_resolution.height/2,\n end_x: screen_resolution.width - 10,\n end_y: screen_resolution.height/2,\n duration: duration\n }\n\n case direction.to_s.downcase\n when 'up'\n $driver.swipe(up)\n when 'down'\n $driver.swipe(down)\n when 'left'\n $driver.swipe(left)\n when 'right'\n $driver.swipe(right)\n else\n raise \"#{direction} is not a valid option\"\n end\n\n end", "def swipe direction, obj = nil, wait = 0.2\n move_mouse_to obj, wait: 0 if obj\n Mouse.swipe direction\n sleep wait\n end", "def swipe_left_element(element_to_swipe)\n $home_page.user_swipe_left_element(element_to_swipe)\nend", "def swipe_element_to_left(xpath)\r\n\r\n #get 'mobile element' form xpath\r\n mobile_element = get_mobile_element xpath\r\n\r\n if mobile_element.nil? or mobile_element.to_s.empty?\r\n raise \"Element Not Found. XPATH => ''#{xpath}''\"\r\n end\r\n\r\n begin\r\n\r\n found_bounds = get_bounds_from_element(mobile_element) do |x1, y1, x2, y2|\r\n ym = (y1 + y2) >> 1\r\n adb_exec(\"shell input swipe 10000 #{ym} #{x2} #{ym}\")\r\n #puts \"EXEC SHELL => shell input swipe #{x1} #{ym} 10000 #{ym}\"\r\n end\r\n\r\n result = !found_bounds.nil?\r\n\r\n return result\r\n\r\n rescue Exception => e\r\n raise \"swipe_element_to_rigth => EXCEPTION => #{e.message}\"\r\n\r\n end\r\n\r\nend", "def handle_swipe(sender)\n @egg.add_code(sender.direction)\n end", "def swipe_element_to_rigth(xpath)\r\n\r\n #get 'mobile element' form xpath\r\n mobile_element = get_mobile_element xpath\r\n\r\n if mobile_element.nil? or mobile_element.to_s.empty?\r\n raise \"Element Not Found. XPATH => ''#{xpath}''\"\r\n end\r\n\r\n begin\r\n\r\n found_bounds = get_bounds_from_element(mobile_element) do |x1, y1, x2, y2|\r\n ym = (y1 + y2) >> 1\r\n adb_exec(\"shell input swipe #{x1} #{ym} 10000 #{ym}\")\r\n #puts \"EXEC SHELL => shell input swipe #{x1} #{ym} 10000 #{ym}\"\r\n end\r\n\r\n result = !found_bounds.nil?\r\n\r\n return result\r\n\r\n rescue Exception => e\r\n raise \"swipe_element_to_rigth => EXCEPTION => #{e.message}\"\r\n\r\n end\r\n\r\nend", "def scroll_down\r\n $driver.swipe(start_y: 0.9, end_y: 0.5, start_x: 0.9, end_x: 0.9, duration: 800)\r\n end", "def swipe(track_data)\r\n @PARAM_HASH['SWIPE'] = track_data\r\n # Regex matchers \r\n # track1_and_track2 = /(%B)\\d{0,19}\\^([\\w\\s]*)\\/([\\w\\s]*)([\\s]*)\\^\\d{7}\\w*\\?;\\d{0,19}=\\d{7}\\w*\\?/.match(track_data).to_s\r\n # track2 = /;\\d{0,19}=\\d{7}\\w*\\?/.match(track_data).to_s\r\n end", "def swipe(track_data)\r\n @PARAM_HASH['SWIPE'] = track_data\r\n # Regex matchers \r\n # track1_and_track2 = /(%B)\\d{0,19}\\^([\\w\\s]*)\\/([\\w\\s]*)([\\s]*)\\^\\d{7}\\w*\\?;\\d{0,19}=\\d{7}\\w*\\?/.match(track_data).to_s\r\n # track2 = /;\\d{0,19}=\\d{7}\\w*\\?/.match(track_data).to_s\r\n end", "def tom_likes_walker\n Swipe.create!({\n swiped_yes: true,\n swiper_id: 23,\n swipee_id: 24\n })\nend", "def swipe_right_and_wait_to_animate(wait_time, element_to_animate)\n\t\tif ENV['PLATFORM'] == 'android'\n\t\t\tperformAction('swipe', 'right')\n\t\t\twait_to_animate(wait_time, element_to_animate)\n\t\telse\n\t\t\tif ENV['PLATFORM'] == 'iPhone'\n\t\t\t\t#TODO Suhas Pls add Iphone swipe test\n\t\t\tend\n\t\tend\n\tend", "def partial_slide(step)\n [start_pos[0] + move_dir[0] * step, start_pos[1] + move_dir[1] * step]\n end", "def swipe_left_and_wait_to_animate(wait_time, element_to_animate)\n\t\tif ENV['PLATFORM'] == 'android'\n\t\t\tperformAction('swipe', 'left')\n\t\t\twait_to_animate(wait_time, element_to_animate)\n\t\telse\n\t\t\tif ENV['PLATFORM'] == 'iPhone'\n\t\t\t\t#TODO Suhas Pls add Iphone swipe test\n\n\t\t\tend\n\t\tend\n\tend", "def scroll_left (x1,x2,y1,y2)\r\n #driver.swipe(start_x: 1000, end_x: 100, start_y: y, end_y: y, duration: 1000)\r\n #driver.swipe(start_x: x1, end_x: x2, start_y: y1, end_y: y2, duration: 1000)\r\n scroll_in_any_direction(x1,x2,y1,y2)\r\n end", "def swipes_to_template_on_the_screen(template_path, direction = \"down\", max_swipes = 5)\n logc(\"method: #{__method__}, params: #{template_path}, #{direction}, #{max_swipes}\")\n direction_list = [\"up\", \"down\", \"left\", \"right\"]\n assert_true_custom(direction_list.include?(direction),\n \"Wrong param 'direction'. Should be one of #{direction_list}, but found '#{direction}'\")\n\n #wait for swipes numbers reached OR expectation reached\n res_of_finding = nil\n res_image_path = nil\n occurrences = nil\n is_expectation_reached = false\n attempt_counter = 1\n while true\n logc(\"Attempt: '#{attempt_counter}'\")\n res_of_finding, res_image_path = get_templates_on_the_screen(template_path, 0.85)\n occurrences = res_of_finding[\"point_clouds\"].to_i\n is_expectation_reached = occurrences > 0\n\n if is_expectation_reached || (attempt_counter > max_swipes)\n break\n else\n swipe(direction)\n attempt_counter += 1\n end\n end\n\n assert_true_custom(is_expectation_reached,\n \"During #{attempt_counter} swipes, found '#{occurrences}' occurrences templates '#{File.basename(template_path)}' on the screen.\" +\n \" Check report folder '#{@report_path}' to details.\")\n # remove_file_if_exist(res_image_path) if is_expectation_reached\nend", "def perform_slide(move)\n raise IllegalMoveError.new unless slides.include? move\n\n perform_move(move)\n end", "def drag_element_to_element(xpath_element_origin, xpath_element_fate, duration = nil)\r\n\r\n result = false\r\n mobile_element_source = get_mobile_element xpath_element_origin\r\n mobile_element_fate = get_mobile_element xpath_element_fate\r\n duration_time = duration.nil? ? 1000 : (duration.to_i * 1000)\r\n xm1 = nil\r\n ym1 = nil\r\n xm2 = nil\r\n ym2 = nil\r\n\r\n if mobile_element_source.nil? or mobile_element_source.to_s.empty?\r\n raise \"Element sourse Not Found. XPATH => ''#{xpath_element_origin}''\"\r\n end\r\n\r\n if mobile_element_fate.nil? or mobile_element_fate.to_s.empty?\r\n raise \"Element fate Not Found. XPATH => ''#{xpath_element_fate}''\"\r\n end\r\n\r\n begin\r\n\r\n fb_1 = get_bounds_from_element(mobile_element_source) do |x1, y1, x2, y2|\r\n xm1 = (x1 + x2) >> 1\r\n ym1 = (y1 + y2) >> 1\r\n end\r\n\r\n fb_2 = get_bounds_from_element(mobile_element_fate) do |x1, y1, x2, y2|\r\n xm2 = (x1 + x2) >> 1\r\n ym2 = (y1 + y2) >> 1\r\n end\r\n\r\n if !fb_1.nil? and !fb_2.nil?\r\n result = true\r\n end\r\n\r\n puts(\"shell input swipe #{xm1} #{ym1} #{xm2} #{ym2} #{duration_time}\")\r\n adb_exec(\"shell input swipe #{xm1} #{ym1} #{xm2} #{ym2} #{duration_time}\")\r\n\r\n return result\r\n\r\n rescue Exception => e\r\n raise \"drag_element_to_element => EXCEPTION => #{e.message}\"\r\n\r\n end\r\n\r\nend", "def scroll_to_down(drag_to = nil)\r\n\r\n #get 'mobile element' form xpath\r\n xpath = \"(//node[./node/node])[last()]\"\r\n drag = drag_to.nil? ? 100 : drag_to.to_s.to_i\r\n\r\n mobile_element = get_mobile_element xpath\r\n\r\n if mobile_element.nil? or mobile_element.to_s.empty?\r\n raise \"Element Not Found. XPATH => ''#{xpath}''\"\r\n end\r\n\r\n begin\r\n\r\n found_bounds = get_bounds_from_element(mobile_element) do |x1, y1, x2, y2|\r\n if (x1 + y1 + x2 + y2) == 0\r\n screen_size = get_screen_size\r\n xm = screen_size[:width] >> 1\r\n ym = screen_size[:height] >> 1\r\n yf = ym - drag\r\n else\r\n xm = (x1 + x2) >> 1\r\n ym = (y1 + y2) >> 1\r\n yf = y1 - drag\r\n end\r\n\r\n adb_exec(\"shell input swipe #{xm} #{ym} #{xm} #{yf}\")\r\n #puts(\"shell input swipe #{xm} #{ym} #{xm} #{yf}\")\r\n end\r\n\r\n result = !found_bounds.nil?\r\n\r\n return result\r\n\r\n rescue Exception => e\r\n raise \"scroll_to_down => EXCEPTION => #{e.message}\"\r\n\r\n end\r\n\r\nend", "def touch_moved(touch); end", "def drag_element_to(xpath_element_origin, x_fate, y_fate, duration = nil)\r\n\r\n result = false\r\n mobile_element_source = get_mobile_element xpath_element_origin\r\n\r\n duration_time = duration.nil? ? 500 : duration\r\n xm1 = nil\r\n ym1 = nil\r\n xm2 = x_fate\r\n ym2 = y_fate\r\n\r\n if mobile_element_source.nil? or mobile_element_source.to_s.empty?\r\n raise \"Element sourse Not Found. XPATH => ''#{xpath_element_origin}''\"\r\n end\r\n\r\n begin\r\n\r\n fb_1 = get_bounds_from_element(mobile_element_source) do |x1, y1, x2, y2|\r\n xm1 = (x1 + x2) >> 1\r\n ym1 = (y1 + y2) >> 1\r\n #puts(\"shell input swipe #{xm1} #{ym1} #{xm2} #{ym2} #{duration_time}\")\r\n adb_exec(\"shell input swipe #{xm1} #{ym1} #{xm2} #{ym2} #{duration_time}\")\r\n end\r\n\r\n result = !fb_1.nil?\r\n\r\n unless result\r\n raise \"drag_element_to => Fail => no fue posible hacer scroll down => '#{xpath_element_origin}'.\"\r\n end\r\n\r\n return result\r\n\r\n rescue Exception => e\r\n raise \"drag_element_to_element => EXCEPTION => #{e.message}\"\r\n\r\n end\r\n\r\nend", "def gesture!\n unless @ws.nil?\n data = JSON \"enableGestures\" => true\n options[:enable_gesture] = ws.send data\n end\n end", "def scroll_to_up(drag_to = nil)\r\n\r\n #get 'mobile element' form xpath\r\n xpath = \"(//node[./node/node])[1]\"\r\n drag = drag_to.nil? ? 100 : drag_to.to_s.to_i\r\n\r\n mobile_element = get_mobile_element xpath\r\n\r\n if mobile_element.nil? or mobile_element.to_s.empty?\r\n raise \"Element Not Found. XPATH => ''#{xpath}''\"\r\n end\r\n\r\n begin\r\n\r\n found_bounds = get_bounds_from_element(mobile_element) do |x1, y1, x2, y2|\r\n xm = (x1 + x2) >> 1\r\n ym = (y1 + y2) >> 1\r\n yf = ym + drag\r\n adb_exec(\"shell input swipe #{xm} #{ym} #{xm} #{yf}\")\r\n #puts(\"shell input swipe #{xm} #{ym} #{xm} #{yf}\")\r\n end\r\n\r\n result = !found_bounds.nil?\r\n\r\n return result\r\n\r\n rescue Exception => e\r\n raise \"scroll_to_down => EXCEPTION => #{e.message}\"\r\n\r\n end\r\n\r\nend", "def moves\n # overridden in slideable/stepable modules\n end", "def wander\n perturb_direction\n walk\n end", "def setup_slide\n return TSBS.error(@acts[0], 4, @used_sequence) if @acts.size < 5\n stop_all_movements\n xpos = (flip && !@ignore_flip_point ? -@acts[1] : @acts[1])\n ypos = @acts[2]\n slide(xpos, ypos, @acts[3], @acts[4], @acts[5] || 0)\n end", "def slide(direction, ensured_position)\n sibling = get_sibling(direction)\n\n if sibling\n slide_to_sibling(direction, sibling, ensured_position)\n else\n push(direction == :increase ? :highest : :lowest)\n end\n end", "def swipe_up_element_until(expected_element, element_to_swipe)\n while $home_page.user_expect_not_displayed?(expected_element) do\n $home_page.user_swipe_up_element(element_to_swipe)\n end\n return true \nend", "def swipe_down_element_until(expected_element, element_to_swipe)\n while $home_page.user_expect_not_displayed?(expected_element) do\n $home_page.user_swipe_down_element(element_to_swipe)\n end\n return true\nend", "def half_page_down() [\"moveDown:\"] * 6 * @number_prefix end", "def swipe_down_until(expected_element)\n while $home_page.user_expect_not_displayed?(expected_element) do\n $home_page.user_swipe_down\n end\nend", "def move(start_peg, end_peg) #nums 0,1,2\n piece = @pegs[start_peg].shift\n @pegs[end_peg].unshift(piece)\n end", "def slide(dir)\n @row, @col = slide_pos(dir)\n make_king\n nil\n end", "def drag_and_drop_by(source, right_by, down_by, device: T.unsafe(nil)); end", "def swipe_up_until(expected_element)\n while $home_page.user_expect_not_displayed?(expected_element) do\n $home_page.user_swipe_up\n end\nend", "def slide_move!(end_pos)\n board[end_pos] = self\n board.set_to_empty(self.pos)\n self.pos = end_pos\n end", "def slide(direction)\n x, y = @block_to_loc[Block.new(0)]\n # Marshal is needed to perform a deep copy of the object\n new_rows = Marshal::load(Marshal.dump(@rows))\n return_nil = true\n unless is_invalid_move?(x, y, direction, new_rows)\n return_nil = false\n swap_blocks(x, y, direction, new_rows)\n end\n if return_nil == false\n return new_rows.flatten \n else\n return nil\n end\n end", "def slide(x, y, dur, jump, height = 0)\n slide_x = self.x + x\n slide_y = self.y + y\n goto(slide_x, slide_y, dur, jump, height) unless moving?\n end", "def slide(x, y, dur, jump, height = 0)\n slide_x = self.x + x\n slide_y = self.y + y\n goto(slide_x, slide_y, dur, jump, height) unless moving?\n end", "def step\n newHead = [head.first,head.last]\n case direction\n when :left\n newHead[1] -= 1\n when :right\n newHead[1] += 1\n when :up\n newHead[0] -= 1\n when :down\n newHead[0] += 1\n end\n parts.unshift(newHead)\n parts.pop\n end", "def perform_slide(end_pos)\n board[@pos] = nil\n @pos = end_pos\n board[@pos] = self\n end", "def tilt(degrees)\n @pan_servo.move_to degrees\n end", "def pedestal(view, time)\n direction = Geom::Vector3d.new(0,0,1)\n direction.reverse! if( (@keys & DOWN_ARROW) != 0 )\n self.move(view, time, direction, @speedy)\nend", "def pan(direction = :left, distance_bp = (self.length_bp.to_f/5).round)\n upstream_slice = self.class.sketch.slices.select{|s| s.start_cumulative_bp < @start_cumulative_bp}.sort_by{|s| s.start_cumulative_bp}[-1]\n downstream_slice = self.class.sketch.slices.select{|s| s.start_cumulative_bp > @start_cumulative_bp}.sort_by{|s| s.stop_cumulative_bp}[0]\n\n #Check if we actually _can_ pan. Can't do that if the slice in the panned\n #direction has less basepairs than what we want to add to our slice in focus\n if ( direction == :left and upstream_slice.length_bp > distance_bp ) or\n ( direction == :right and downstream_slice.length_bp > distance_bp )\n\n #Just so we can always add the distance_pixel\n if direction == :left\n distance_bp = -distance_bp\n end\n\n @start_cumulative_bp += distance_bp\n @stop_cumulative_bp += distance_bp\n self.fetch_sequence\n\n upstream_slice.stop_cumulative_bp = @start_cumulative_bp - 1\n downstream_slice.start_cumulative_bp = @stop_cumulative_bp + 1\n [upstream_slice, downstream_slice].each do |s|\n s.length_bp = s.stop_cumulative_bp - s.start_cumulative_bp + 1\n s.resolution = s.length_pixel.to_f/s.length_bp\n s.range_cumulative_bp = Range.new(s.start_cumulative_bp, s.stop_cumulative_bp)\n s.fetch_sequence\n end\n self.class.sketch.slices.each{|s| s.format_resolution}\n\n self.class.sketch.buffer_images[:zoomed] = self.class.sketch.draw_zoomed_buffer\n self.class.sketch.buffer_images[:information_panel] = self.class.sketch.draw_information_panel\n end\n end", "def slide_from(direction, options={}, more_options={}, &after)\n if options.is_a? Numeric\n size = options\n options = more_options\n else\n size = options[:size]\n end\n\n options[:from_current] = false unless options.key?(:from_current)\n window_size = UIApplication.sharedApplication.windows[0].frame.size\n\n case direction\n when :left\n size ||= window_size.width\n self.center = CGPoint.new(self.center.x - size, self.center.y)\n self.delta_to([size, 0], options, &after)\n when :right\n size ||= window_size.width\n self.center = CGPoint.new(self.center.x + size, self.center.y)\n self.delta_to([-size, 0], options, &after)\n when :top, :up\n size ||= window_size.height\n self.center = CGPoint.new(self.center.x, self.center.y - size)\n self.delta_to([0, size], options, &after)\n when :bottom, :down\n size ||= window_size.height\n self.center = CGPoint.new(self.center.x, self.center.y + size)\n self.delta_to([0, -size], options, &after)\n else\n raise \"Unknown direction #{direction.inspect}\"\n end\n return self\n end", "def perform_moves!(move_sequence)\n if move_sequence.count == 1\n if perform_slide?(move_sequence[0])\n perform_slide(move_sequence[0])\n else \n perform_jump(move_sequence[0])\n end\n else\n move_sequence.each do |move|\n perform_jump(move)\n end\n end\n end", "def setup_slide\n return unless PONY::ERRNO.check_sequence(current_act)\n stop_all_movements\n xpos = (flip && !@ignore_flip_point ? -@acts[1] : @acts[1])\n ypos = @acts[2]\n slide(xpos, ypos, @acts[3], @acts[4], @acts[5] || 0)\n @acts[4].times do\n method_wait\n end\n end", "def perform_slide(end_pos)\n return false unless valid_slide?(end_pos)\n\n move!(end_pos)\n true\n end", "def scroll_and_touch(element, options = {})\n scroll_until_i_see(element, options)\n touch(element)\n end", "def touchesMoved(touches, withEvent: event)\n return unless @valid_start_location\n touch = touches.anyObject\n point = touch.locationInView(self)\n case @current_tool\n when :squiggle\n a = @points[-1]\n b = point\n if (b - a).magnitude > Constants::MAGNITUDE_DISTANCE_BETWEEN_POINTS\n @points << point\n setNeedsDisplay\n end\n when :grab\n case @mode\n when :toys_only, :scene, :toy_selected\n if @delegate.is_a?(ActionAdderViewController)\n @drag = true\n @delegate.close_popover\n end\n touch_move_scene(point)\n else\n @current_point = point\n end\n setNeedsDisplay\n when :line, :circle\n @points[1] = point\n setNeedsDisplay\n end\n end", "def slide_moves\n dirs = (@dir == :up ? UP_DIRS : DOWN_DIRS)\n dirs = DOWN_DIRS + UP_DIRS if king\n\n dirs.each_with_object([]) do |dir, moves|\n new_square = add_dir(pos, dir)\n unless [email protected]_board?(new_square) || @board[*new_square]\n moves << [pos, new_square]\n end\n end\n end", "def perform_slide target_position\n current_position = self.pos\n if valid_slide?(target_position)\n move!(target_position)\n return true\n else\n return false\n end\n end", "def forward(steps)\n move(steps)\n end", "def move \n self.send(@orientation.current.to_sym)\n end", "def perform_slide(next_pos)\n\t\t#return true or false if move is legal\n\t\t#move is legal if our possible moves include the next position and the board is empty at that position\n\t\t#make move by changing board and piece's position value\n\t\tif slide_moves.include?(next_pos)\n\t\t\tmove!(next_pos)\n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend", "def interpret_move(step_left = distance_per_frame)\r\r\n if @move_poll.size > 0\r\r\n current_move = @move_poll.shift()\r\r\n d = current_move[0]\r\r\n horz = (d - 1) % 3 - 1\r\r\n vert = 1 - ((d - 1) / 3)\r\r\n turn_ok = current_move[1]\r\r\n set_direction(d) if turn_ok\r\r\n check_event_trigger_touch_front\r\r\n processed = false\r\r\n if (d % 2 == 0 && passable?(@x, @y, d)) || (d % 2 != 0 && diagonal_passable?(@x, @y, horz, vert))\r\r\n process_move(horz, vert)\r\r\n processed = true\r\r\n elsif d % 2 != 0 && !diagonal_passable?(@x, @y, horz, vert)\r\r\n if passable?(@x, @y, horz + 5)\r\r\n set_direction(horz + 5) if turn_ok\r\r\n process_move(horz, 0)\r\r\n processed = true\r\r\n end\r\r\n if passable?(@x, @y, 5 - vert * 3)\r\r\n set_direction(5 - vert * 3) if turn_ok\r\r\n process_move(0, vert)\r\r\n processed = true\r\r\n end\r\r\n end\r\r\n \r\r\n if(processed)\r\r\n pixelstep = CXJ::FREE_MOVEMENT::PIXELS_PER_STEP / 32.0\r\r\n if(step_left > pixelstep && !@move_poll.empty?)\r\r\n interpret_move(step_left - pixelstep)\r\r\n elsif(jumping? && !@move_poll.empty?)\r\r\n interpret_move(0)\r\r\n end\r\r\n else\r\r\n @move_poll.clear\r\r\n end\r\r\n \r\r\n @move_succeed = processed\r\r\n current_move\r\r\n end\r\r\n end", "def move_forward\n case @direction\n when 2\n move_down(false)\n when 4\n move_left(false)\n when 6\n move_right(false)\n when 8\n move_up(false)\n end\n end", "def zoom(percentage = 200, auto_perform = true)\n fail ArgumentError(\"Can't zoom to smaller then screen size.\") if percentage < 100\n\n p = 100 / Float(percentage)\n i = 1 - p\n\n top = TouchAction.new\n top.swipe start_x: i, start_y: i, end_x: 1, end_y: 1, duration: 1\n\n bottom = TouchAction.new\n bottom.swipe start_x: p, start_y: p, end_x: 1, end_y: 1, duration: 1\n\n zoom = MultiTouch.new\n zoom.add top\n zoom.add bottom\n return zoom unless auto_perform\n zoom.perform\n end", "def setup_target_slide\n return TSBS.error(@acts[0], 4, @used_sequence) if @acts.size < 5\n args = [@acts[1], @acts[2], @acts[3], @acts[4], @acts[5] || 0]\n if area_flag\n target_array.each do |target|\n target.slide(*args)\n end\n return\n end\n target.slide(*args)\n end", "def moveUpAndDown(dis)\n vector = getCurrentDirection\n vector.length = dis\n moveTransformation = Geom::Transformation.translation(vector)\n @@componentInstance.transform! moveTransformation\n updateAvatarLocation\n updateTransformation\n updateViewPort\n\n \n\n end", "def move(direction)\n \n end", "def switchGesture _obj, _args\n \"_obj switchGesture _args;\" \n end", "def synthesize_scroll_gesture(x:, y:, x_distance: nil, y_distance: nil, x_overscroll: nil, y_overscroll: nil, prevent_fling: nil, speed: nil, gesture_source_type: nil, repeat_count: nil, repeat_delay_ms: nil, interaction_marker_name: nil)\n {\n method: \"Input.synthesizeScrollGesture\",\n params: { x: x, y: y, xDistance: x_distance, yDistance: y_distance, xOverscroll: x_overscroll, yOverscroll: y_overscroll, preventFling: prevent_fling, speed: speed, gestureSourceType: gesture_source_type, repeatCount: repeat_count, repeatDelayMs: repeat_delay_ms, interactionMarkerName: interaction_marker_name }.compact\n }\n end", "def setup_smooth_slide\n tx = @acts[1] + x || 0\n ty = @acts[2] + y || 0\n dur = @acts[3] || 25\n rev = @acts[4]\n rev = true if rev.nil?\n smooth_move(tx,ty,dur,rev)\n end", "def setup_smooth_slide\n tx = @acts[1] + x || 0\n ty = @acts[2] + y || 0\n dur = @acts[3] || 25\n rev = @acts[4]\n rev = true if rev.nil?\n smooth_move(tx,ty,dur,rev)\n end", "def pile(w)\n w.drag_to(@current)\n w.set_default_refresh_loc('tl')\n @current.x += PILE_OFFSET\n end", "def scroll_action(x, duration)\n width = (x * 2)\n move = SKAction.moveByX(-width, y: 0, duration: duration * width)\n reset = SKAction.moveByX(width, y: 0, duration: 0)\n\n SKAction.repeatActionForever(SKAction.sequence([move, reset]))\n end", "def scroll_action(x, duration)\n width = (x * 2)\n move = SKAction.moveByX(-width, y: 0, duration: duration * width)\n reset = SKAction.moveByX(width, y: 0, duration: 0)\n\n SKAction.repeatActionForever(SKAction.sequence([move, reset]))\n end", "def move(point, dx, dy)\n [point[0] + dx, point[1] + dy]\n end", "def move\n\t\t# move 5px to the left\n\t @x = @x - 5\n\t # move up or down based on the Y velocity\n\t @y = @y + @vy\n\tend", "def move(direction)\n @x += @velocity if direction == :right\n @x -= @velocity if direction == :left\n end", "def topping; end", "def move(dir)\n old_pos = @pos\n\n case dir\n when 'U'\n @pos -= @sides if @pos > @sides\n when 'R'\n @pos += 1 if @pos % @sides != 0\n when 'D'\n @pos += @sides if @pos <= @sides ** 2 - @sides\n when 'L'\n @pos -= 1 if (@pos - 1) % @sides != 0\n else\n raise ParseError, \"Invalid input: #{dir}\"\n end\n\n @pos = old_pos if pos.eql? ' '\n end", "def forward_steps(new_row) # ahhh all the logic to see if this should be added or not should be in here awesome, yeah helper methods *are* supposed to be like this right to better help modularize things nice\n f_steps = Array.new\n one_step = [new_row, @pos[1]] \n two_step_row = new_row + forward_dir # if it can jump you've gotta increment this by another step lol can't believe you forgot this about pawns wow\n if (two_step_row >= 0) && (two_step_row <= 7) # ah lmfao didn't fucking check if it's a NullPiece there or not LOL amazing bug catching god debugger is god mode\n (f_steps << [two_step_row, @pos[1]]) if (at_start_row? && @board.grid[two_step_row][@pos[1]].is_a?(NullPiece) && @board.grid[new_row][@pos[1]].is_a?(NullPiece)) # if the pawn is at the start step then add this new step if it's valid otherwise don't note can't do self.at_start_row? because this is invalid. # also added another check here wow so many things to watch out for you can't double step past a square that's occupied by another piece so have to check that the one step piece is also a NullPiece amazing catch man so much to catch lol\n end\n f_steps << one_step if @board.grid[new_row][@pos[1]].is_a?(NullPiece) # only allow this move if the new row is in bounds and there is no piece in that position\n f_steps\n end", "def move(pos, down, right)\n\t\t[pos[0] + down, pos[1] + right]\n\tend", "def perform_slide?(to_pos)\n if @king\n valid_moves = self.king_slides\n else\n valid_moves = self.pawn_slides\n end\n \n if valid_moves.include?(to_pos)\n self.maybe_promote(to_pos) if @king == false\n return true\n end\n \n false\n end", "def move_directional_vector args\n dx = 0\n dx += 1 if args.inputs.keyboard.d\n dx -= 1 if args.inputs.keyboard.a\n dy = 0\n dy += 1 if args.inputs.keyboard.w\n dy -= 1 if args.inputs.keyboard.s\n if dx != 0 && dy != 0\n dx *= 0.7071\n dy *= 0.7071\n end\n [dx, dy]\nend", "def setup_target_slide\n return unless PONY::ERRNO::check_sequence(current_act)\n args = [@acts[1], @acts[2], @acts[3], @acts[4], @acts[5] || 0]\n current_action_targets.each do |target|\n target.slide(*args)\n end\n end", "def U\r\n move_method(4) \r\nend", "def update!(**args)\n @gesture_sensing = args[:gesture_sensing] if args.key?(:gesture_sensing)\n @omniswipe_gesture_capable = args[:omniswipe_gesture_capable] if args.key?(:omniswipe_gesture_capable)\n @tap_gesture_capable = args[:tap_gesture_capable] if args.key?(:tap_gesture_capable)\n end", "def arrastar_para(direction)\n positions = [0, 0, 0, 0] # [ 'from_x', 'to_x', 'from_y', 'to_y' ]\n\n case (direction)\n when 'baixo'\n positions = [30, 30, 60, 30]\n when 'cima'\n positions = [80, 80, 60, 90]\n when 'esquerda'\n positions = [90, 20, 80, 80]\n when 'direita'\n positions = [20, 90, 80, 80]\n else\n raise 'Não foi possivel arrastar'\n end\n perform_action('drag', positions[0], positions[1],\n positions[2], positions[3], 15)\n sleep(1)\n end", "def generate_slide_moves(current_pos, board, owner)\n return if out_of_bounds?(current_pos)\n\n next_piece = board.locate_piece(current_pos)\n return if next_piece&.owner == owner\n\n return [current_pos] if next_piece\n\n next_pos = [current_pos[0] + @move[0], current_pos[1] + @move[1]]\n next_moves = generate_slide_moves(next_pos, board, owner)\n return [current_pos] unless next_moves\n\n next_moves.reduce([current_pos]) { |current_moves, deep_moves| current_moves.push(deep_moves) }\n end", "def shift(index, pivot, collection)\n index.upto(pivot) do |i|\n collection[i] = collection[i + 1]\n end\n collection\nend", "def move; end", "def move; end", "def move_by_input\r\r\n return if !movable? || $game_map.interpreter.running?\r\r\n if CXJ::FREE_MOVEMENT::ENABLE_DIAGONAL && Input.dir8 > 0 && Input.dir8 % 2 != 0\r\r\n d = Input.dir8\r\r\n horz = (d == 1 || d == 7 ? 4 : 6)\r\r\n vert = (d == 1 || d == 3 ? 2 : 8)\r\r\n move_diagonal(horz, vert)\r\r\n elsif Input.dir4 > 0\r\r\n move_straight(Input.dir4)\r\r\n end\r\r\n end", "def move_left\n # @dx = -8\n @x -= 8\n end", "def my_rotate(arr, offset=1)\n offset = offset % 4\n arr_take = arr.take(offset)\n arr_drop = arr.drop(offset)\n arr_drop + arr_take\nend", "def position_for_next_harvest()\n turn_right()\n move()\n turn_right()\n end", "def slide(i, l)\n \"[2, 2, 3, 2, 2] => [2, 2, 2, 3, 2]\"\n if (i + 1) < l.length\n l[i + 1] = 3\n l[i] = 2\n end\n l\nend", "def make_move(moves)\n if moves[1][1].is_a?(Array)\n return multiple_jumps(moves)\n end\n\n check_input(moves)\n\n from, to = moves\n y,x = from\n\n piece = @rows[y][x]\n y,x = to\n\n # check if it can slide\n if piece.possible_slide?(y,x)\n # if it can slide... SLIDE IT!\n piece.slide_to(y,x)\n else\n # check if it can jump\n if valid_jump?(moves)\n # if can jump... JUMP IT!\n piece.jump_to(y,x)\n between = between(from, to)\n # kill the piece in between\n self[between].current_pos = nil\n else\n raise \"Invalid move.\"\n end\n end\n end", "def slide(seconds)\n self.class.new(beginning + seconds, ending + seconds, exclude_end?)\n end", "def interpret(ps)\n # change z.\n ps.z = @size\n # move down.\n ps.v += @size\n end", "def drag_and_drop(source, target, device: T.unsafe(nil)); end", "def shift!(offset); @tstart += offset ; @tend += offset; @as_range = nil end", "def move_down\n\t\tmove([0,1])\n\tend", "def do_sharp s; move_pointer(s); end", "def swim(index)\n end", "def move\n if $window.button_down?(Gosu::KbD)\n @facing = :right\n @x += speed unless out_of_bounds?(@x + speed, @y)\n end\n \n if $window.button_down?(Gosu::KbA)\n @facing = :left\n @x -= speed unless out_of_bounds?(@x - speed, @y)\n end\n \n if $window.button_down?(Gosu::KbW)\n @facing = :up\n @y -= speed unless out_of_bounds?(@x, @y - speed)\n end\n \n if $window.button_down?(Gosu::KbS)\n @facing = :down\n @y += speed unless out_of_bounds?(@x, @y + speed)\n end\n \n sprinting?\n end", "def scroll_right(distance)\n if loop_horizontal?\n @display_x += distance\n @display_x %= @map.width * 256\n @parallax_x += distance\n else\n last_x = @display_x\n @display_x = [@display_x + distance, (width - 17) * 256].min\n @parallax_x += @display_x - last_x\n end\n end", "def move_straight(step, x)\n comp(:position).add!(x * step)\n on_move\n end" ]
[ "0.69509816", "0.6540213", "0.6073967", "0.6002281", "0.588508", "0.5718026", "0.5652447", "0.53592443", "0.53592443", "0.5313849", "0.5265659", "0.52088654", "0.5142895", "0.512369", "0.50739413", "0.49735633", "0.49143434", "0.481616", "0.47914976", "0.47774407", "0.4738076", "0.46730244", "0.4602962", "0.45577928", "0.45499548", "0.4496849", "0.44786146", "0.44549838", "0.44233376", "0.44184417", "0.4395967", "0.4357541", "0.43517166", "0.4319042", "0.43186647", "0.43093", "0.4297543", "0.4297543", "0.42973462", "0.42942706", "0.42834893", "0.42793897", "0.42647412", "0.42640796", "0.42507213", "0.42480668", "0.4245607", "0.42433122", "0.4237016", "0.42366678", "0.42350316", "0.42326015", "0.4215332", "0.4214386", "0.4174411", "0.41546082", "0.415299", "0.4152293", "0.41377443", "0.41355753", "0.4133701", "0.41211143", "0.41142443", "0.41142443", "0.41036367", "0.4101668", "0.4101668", "0.4100392", "0.4097734", "0.40938887", "0.40922117", "0.40844476", "0.40843916", "0.40770894", "0.40670854", "0.40560585", "0.40429792", "0.40354759", "0.40334877", "0.40223885", "0.40135777", "0.40097237", "0.4001069", "0.4001069", "0.39956293", "0.39942092", "0.3987663", "0.39802766", "0.3962856", "0.3949017", "0.39473283", "0.39387468", "0.3927193", "0.39253965", "0.3916532", "0.3908695", "0.39057544", "0.3899714", "0.38972813", "0.38895994" ]
0.6769638
1
input 2 arguments => array of current people in line string of new person at back of the line output string of persons name with index+1 (place in line)
def take_a_number(array, name) length = array.length case length when 0 array.push(name) puts "Welcome, #{array[0]}. You are number 1 in line." else array.push(name) puts "Welcome, #{name}. You are number #{array.length} in line." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def take_a_number(katz_deli, person)\n katz_deli.push(person)\n new_person_in_line = \" \"\n katz_deli.each_with_index do |item,index|\n new_person_in_line = \"Welcome, #{item}. You are number #{index + 1} in line.\"\n end\n puts new_person_in_line\n end", "def line(katz_deli)\n\n #The line_string variable contains a string\n #We will add to this string in the each_with_index block below\n\n line_string = \"The line is currently:\"\n\n #If the line is empty, the method outputs \"The line is currently empty.\"\n #Otherwise, we iterate through the katz_deli array\n #During each iteration, we add a string to line_string containing the line number & name of each element\n #We calculate the line number by adding 1 to the index number\n\n if katz_deli == []\n puts \"The line is currently empty.\"\n else\n katz_deli.each_with_index do |person, index|\n line_string += \" #{index+1}. #{person}\"\n end\n\n #Lastly, we output the newly modified line_string\n\n puts line_string\n end\nend", "def line(katz_deli)\n if katz_deli.empty?\n puts \"The line is currently empty.\"\n else\n current_line = katz_deli.collect.with_index do |person, index|\n \"#{index + 1}. #{person}\"\n end\n string = current_line.join(\" \")\n puts \"The line is currently: #{string}\"\n end\nend", "def line(katz_deli)\n if katz_deli.empty? #if the line is empty\n puts \"The line is currently empty.\"\n else\n new_array = [] #this is a variable to hold the output string for the #line method\n katz_deli.each_with_index { |name, index| new_array.push(\"#{index+1}. #{name}\")} #note: name can be called anything\n final_sentence = \"The line is currently: \" + new_array.join(\" \") #.join(\" \") adds a space between each 'index. name' pair (.to_s was giving me the wrong output, with \"quotes\" around 'index. name' pairs)\n puts final_sentence\n end #end if..elsif statement\nend", "def line(ppl)\n \n # If the line is empty...\n if ppl.length == 0\n\n # Tell us the line is empty.\n puts \"The line is currently empty.\"\n\n # If there are people in line... \n else\n crnt_ln = []\n \n ppl.each_with_index do |nm, ndx|\n ln = ndx + 1\n crnt_ln << \" #{ln}. #{nm}\"\n end\n \n crnt_ln.unshift(\"The line is currently:\")\n puts crnt_ln.join\n end\nend", "def line(katz_deli)\n\nline_array = []\n if katz_deli != []\n katz_deli.each.with_index(1) do |person, index| \n line_array << (\"#{index}. #{person} \")\n end\n \n line_array_last = line_array.pop ## removes last element with extra space\n line_array_last[line_array_last.length-1] = \"\" ## determines length to elminiate extra space\n line_array << line_array_last ## shovels last element without extra space to the array\n puts \"The line is currently: #{line_array.join}\"\n else\n puts \"The line is currently empty.\" \n end \nend", "def line(array)\n if array.size >0\n str = \"The line is currently:\"\n array.each_with_index do |name,index|\n str += \" #{index+1}. #{name}\"\n end\n puts str\n else\n puts \"The line is currently empty.\"\n end\n\nend", "def change_name(name)\r\n\t#store new name in new variable, downcase, split in an array and reverse order\r\n\tnew_name = name.downcase.split(' ').reverse.join(' ')\r\n\t#return the array of all the letters\r\n\t#p new_name\r\n\t#puts new_name.length\r\n\t#p new_name\r\n\talias_and_real_name = []\r\n\tindex = 0\r\n\tvowel_list = \"aeiou\"\r\n\tconsonant_list = \"bcdfghjklmnpqrstvwxyz\"\r\n\twhile index < new_name.length\r\n\t\t#[index] takes and integer and retunrs char, .index takes a char\r\n\t\t#and returns integer**\r\n\t\t#Does the letter at the # index of new_name match the vowel_list string\r\n\t\tif vowel_list.include?(new_name[index])\r\n\t\t\t#next_vowel_index is a #\r\n\t\t\t#it equals the vowel string at the letter index \r\n\t\t\t#from new_name's # index\r\n\t\t\t#Then get the next number\r\n\t\t\tnext_vowel_index = vowel_list.index(new_name[index]).next\r\n\t\t\t#new_name at that index # now equal this new # \r\n\t\t\t#Equals the vowel list at index of the next #\r\n\t\t\tnew_name[index] = vowel_list[next_vowel_index]\r\n\t\t\t\t#Solve for edge cases\r\n\t\t\t\t#If the letter is the name is going to be the last letter \r\n\t\t\t\t#in the vowel string, change it automatically to \r\n\t\t\t\t#the first on\r\n\t\t\r\n\t\t\t\r\n\t\telsif consonant_list.include?(new_name[index])\r\n\t\t\tnext_consonant_index = consonant_list.index(new_name[index]).next\r\n\t\t\tnew_name[index] = consonant_list[next_consonant_index]\r\n\r\n\t\tend #End if statement\r\n\t\t#Incriment outside of if statment but inside while loop\r\n\t\tindex += 1\r\n\t\r\n\tend #End While loop\r\n\r\n\t#return the new alias name\r\n\tnew_name\r\n\t\r\n\t#Take the alias name and stoe it in an array, new name first and real \r\n\t#name second\r\n\talias_and_real_name << new_name << name\r\n\t\r\n#End method\t\t\r\nend", "def swap_name(str)\n str.split(\"\\n\").map do |name|\n n = name.split(\" \")\n n[1] + \", \" + n[0]\n end.join\nend", "def line(people_in_line = [])\n if (people_in_line.size == 0)\n puts \"The line is currently empty.\"\n return\n end\n line_message = \"The line is currently:\"\n people_in_line.each_index do |current_spot|\n line_message << \" #{current_spot + 1}. #{people_in_line[current_spot]}\"\n end\n puts line_message\nend", "def line(array)\n if array.length == 0\n puts \"The line is currently empty.\"\n else\n string = \"The line is currently:\"\n array.each_with_index do |name, index|\n string.concat(\" #{index+1}. #{name}\")\n end\n puts string\n end\nend", "def take_a_number(katz_deli, customer_name)\n if katz_deli == []\n katz_deli << customer_name\n katz_deli.map.with_index do |name, place|\n puts \"Welcome, #{name}. You are number #{place + 1} in line.\"\n end\n else\n katz_deli << customer_name\n katz_deli.map.with_index do |name, place|\n end\n last_customer = katz_deli.last\n last_place = katz_deli.index(last_customer)\n puts \"Welcome, #{last_customer}. You are number #{last_place + 1} in line.\"\n end\n #line(katz_deli)\nend", "def edit_name(index)\n puts \"What name do you want to change it to?\"\n new_name = gets.chomp\n @contact_book[index - 1][:name] = new_name\nend", "def line(katz_deli)\n current_line = \"The line is currently:\"\n if katz_deli == []\n current_line = \"The line is currently empty.\"\n else\n katz_deli.map.with_index do |name, place|\n current_line << \" #{place + 1}. #{name}\"\n end\n end\n puts current_line\nend", "def line(array)\n line_status_string = \"The line is currently:\"\n if array == []\n puts \"The line is currently empty.\"\n elsif array != []\n array.each_with_index {|person, place_number|\n line_status_string += \" #{place_number+1}. #{person}\"\n }\n puts line_status_string\n end\nend", "def alias_name\n first_name = \"lia\".chars\nlast_name = \"hogan\".chars\np first_name.class\nfirst_name[3] = last_name[0]\nfirst_name[4] = last_name[1]\nfirst_name[5] = last_name[2]\nfirst_name[6] = last_name[3]\nfirst_name[7] = last_name[4]\np first_name\n\nlast_name[5] = first_name[0]\nlast_name[6] = first_name[1]\nlast_name[7] = first_name[2]\np last_name\nfirst_name.delete_at(0)\nfirst_name.delete_at(0)\nfirst_name.delete_at(0)\np first_name\nlast_name.delete_at(0)\nlast_name.delete_at(0)\nlast_name.delete_at(0)\nlast_name.delete_at(0)\nlast_name.delete_at(0)\np last_name\n \n full_name = first_name + last_name\n index = 0 \n str_back = \"\"\n while index < full_name.length\n str_back[index]\n if full_name[index] == \"a\"\n str_back[index] = \"e\"\n elsif full_name[index] == \"b\" \n str_back[index] = \"c\"\n elsif full_name[index] == \"c\" \n str_back[index] = \"d\" \n elsif full_name[index] == \"d\" \n str_back[index] = \"f\"\n elsif full_name[index] == \"e\" \n str_back[index] = \"i\"\n elsif full_name[index] == \"f\" \n str_back[index] = \"g\"\n elsif full_name[index] == \"g\" \n str_back[index] = \"h\"\n elsif full_name[index] == \"h\" \n str_back[index] = \"j\"\n elsif full_name[index] == \"i\" \n str_back[index] = \"o\"\n elsif full_name[index] == \"j\" \n str_back[index] = \"k\"\n elsif full_name[index] == \"k\" \n str_back[index] = \"l\"\n elsif full_name[index] == \"l\" \n str_back[index] = \"m\"\n elsif full_name[index] == \"m\" \n str_back[index] = \"n\"\n elsif full_name[index] == \"n\" \n str_back[index] = \"p\"\n elsif full_name[index] == \"o\" \n str_back[index] = \"u\"\n elsif full_name[index] == \"p\" \n str_back[index] = \"q\"\n elsif full_name[index] == \"q\" \n str_back[index] = \"r\"\n elsif full_name[index] == \"r\" \n str_back[index] = \"s\"\n elsif full_name[index] == \"s\" \n str_back[index] = \"t\"\n elsif full_name[index] == \"t\" \n str_back[index] = \"v\"\n elsif full_name[index] == \"u\" \n str_back[index] = \"y\"\n elsif full_name[index] == \"v\" \n str_back[index] = \"w\"\n elsif full_name[index] == \"w\" \n str_back[index] = \"x\"\n elsif full_name[index] == \"x\" \n str_back[index] = \"z\"\n elsif full_name[index] == \"y\" \n str_back[index] = \"a\"\n elsif full_name[index] == \"z\" \n str_back[index] = \"b\"\n else \n str_back[index] = \" \"\n end\n index += 1 \n end\n str_back\nend", "def name_handler(name)\n name = name.downcase.chars #takes the input and makes it downcase and breaks it into an array to increment through\n name_new = name.map do |letter| #create a new array called name_new and start block to increment through each array\n letter_change(letter)\n end\n #Code addressing capitalization and swapping first / last\n namearr = name_new.join('').split #join the new_name array back into a string\n p namearr\n first_name = namearr[0] #assign first name to a new variable based on index\n last_name = namearr[1] #assign first name to a new variable based on index\n name_new = last_name.capitalize! + \" \" + first_name.capitalize! #capitalize and swap first for last\nend", "def take_a_number(katz_deli, name)\n #the take_a_number method should puts the person's name along with their postion in line --use .push(element) to add a person's name to the line\n katz_deli.push(name)\n\n puts \"Welcome, #{name}. You are number #{katz_deli.length} in line.\"\nend", "def line(other_deli)\n if(other_deli.length == 0)\n puts \"The line is currently empty.\"\n else\n result = \"The line is currently: \"\n other_deli.each_with_index do |name, index|\n result += \"#{index + 1}. #{name}\"\n if(index != other_deli.length - 1)\n result += \" \"\n end\n end\n puts result\n end\nend", "def take_a_number(katz_deli, name)\n # add person to end of line\n katz_deli << name\n # call out (`puts`) the person's name along with their position in line\n puts \"Welcome, #{name}. You are number #{katz_deli.size} in line.\"\nend", "def line(the_line)\n if the_line.empty?\n puts \"The line is currently empty.\"\n else\n current_line = \"The line is currently:\"\n the_line.each_with_index do |customer, index|\n current_line << \" #{index + 1}. #{customer}\"\n end\n puts current_line\n end \nend", "def line(katz_deli)\n if katz_deli.size == 0\n puts \"The line is currently empty.\"\n else\n in_line = \"The line is currently:\"\n \n katz_deli.each do |name|\n in_line = in_line + \" \" + (katz_deli.index(name)+1).to_s + \". \" + name \n end\n puts in_line \n end\nend", "def next_vowcon(oldlet) #actually takes in the whole name (not just 1 letter), since it is only split to an array of [first_name, last_name]\r\n vowel = ['a','e','i','o','u']\r\n rot_vow = vowel.rotate #reverses vowel array\r\n consonant = 'bcdfghjklmnpqrstvwxzy'.split('')\r\n rot_cons= consonant.rotate #reverses consonant array\r\n i=0\r\n while i < oldlet.length\r\n if vow_index = vowel.index(oldlet[i])\r\n oldlet[i] = rot_vow[vow_index]\r\n else\r\n cons_index = consonant.index(oldlet[i])\r\n oldlet[i] = rot_cons[cons_index]\r\n end\r\n i +=1\r\n end\r\n return oldlet\r\nend", "def first_to_last(name)\r\n\t# convert name into array\r\n\tnames = name.split(\" \")\r\n\t# swap first and last\r\n\tl = names.length - 1\r\n\ttemp = names[0]\r\n\tnames[0] = names[l]\r\n\tnames[l] = temp\r\n\t# convert array back into new string\r\n\tnew_name = names.join(\" \")\r\n\treturn new_name\r\nend", "def line (katz_deli)\n if katz_deli == [] #If there are no names in the array, desired output string is sent\n puts \"The line is currently empty.\"\n else\n output = \"The line is currently:\" #Establish the stem of the output string for when the line is occupied\n i = 1 #Initialize a counter so that the place in line can be added to output string\n katz_deli.each do |person| #Iterate through the name array for each name\n output = output + \" \" + \"#{i}\" + \". #{person}\" #Append current iteration number and index value to the output string, following desired format.\n i += 1 #increment counter to keep track of the number of entries\n end\n puts output #Send the compiled output string\n end\nend", "def take_a_number(array, name)\n place = array.length+1\n if array == []\n array.push(name)\n puts \"Welcome, \" + array.join(', ') + \". You are number #{place} in line.\"\n array\n\n # if there are already people in line, it should add a person to the end of the line\n # adding multiple people in a row should correctly build the line\n else array != []\n array.push(name)\n puts \"Welcome, #{name}. You are number #{place} in line.\"\n array\n end\nend", "def alias_creator(name_split)\r\n vowels = \"aeiou\"\r\n consonants = \"bcdfghjklmnpqrstvwxy\"\r\n\r\n name_split.map! do |string|\r\n if vowels.index(string) != nil\r\n new_vowel = vowels.index(string) + 1\r\n string = vowels[new_vowel]\r\n elsif consonants.index(string) != nil\r\n new_consonant = consonants.index(string) + 1\r\n string = consonants[new_consonant]\r\n else\r\n string = string\r\n end\r\n end\r\nend", "def line(katz_deli)\n if katz_deli.size == 0 \n puts \"The line is currently empty.\"\n else\n order_string = \"\"\n katz_deli.each_with_index do |person, index| \n order_string << \" #{index + 1}. #{person}\"\n end\n puts \"The line is currently:#{order_string}\"\n end\nend", "def alias_creator(name)\n puts \"Your name backwards is #{name.split(' ').rotate!.join(' ')}.\"\nend", "def spy_name(real_name) ####Still in progress...######\nnew_name = real_name.downcase\nadjust = new_name.split(' ')\nfirst_n = adjust[0].split('')\nlast_n = adjust[1].split('')\n\n\tindex = 0\n\tuntil index == first_n.last\n\tvowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n\t\t\tif first_n[index] == [\"a\", \"e\", \"i\", \"o\"]\n\t\t\t\tfirst_n[index] = vowels.next\n\t\t\telsif first_n[index] == \"u\"\n\t\t\t\tfirst_n[index] = \"a\"\n\t\t\telsif first_n[index] == \"z\"\n\t\t\t\tfirst_n[index] = \"b\"\n\t\t\telse first_n[index].next\n\t\t\t\tfirst_n[index] = first_n[index].next\n\t\tend\n\t\tindex += 1\n\tend\n#don't forget to return the method\n\tindex = 0\n\tuntil index == last_n.last\n\tvowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n\t\t\tif last_n[index] == [\"a\", \"e\", \"i\", \"o\"]\n\t\t\t\tlast_n[index] = vowels.next\n\t\t\telsif last_n[index] == \"u\"\n\t\t\t\tlast_n[index] = \"a\"\n\t\t\telsif last_n[index] == \"z\"\n\t\t\t\tlast_n[index] = \"b\"\n\t\t\telse last_n[index].next\n\t\t\t\tlast_n[index] = last_n[index].next\n\t\tend\n\t\tindex += 1\n\tend\n\n\nend", "def roll_call_dwarves(names)\n new_array = []\n names.each.with_index(1) do |name, index|\n new_array << \"#{index}. #{name}\"\n end\n puts new_array.join(\" \")\nend", "def line(katz_deli)\n if katz_deli.empty?\n puts \"The line is currently empty.\"\n else\n current_line = \"The line is currently:\"\n line_count = 1\n katz_deli.each do |person|\n current_line << \" #{line_count}. #{person}\"\n line_count += 1\n end\n puts current_line\n end\nend", "def next_letter(name)\n vowels = \"aeiou\".split(\"\")\n consonants = \"bcdfghjklmnpqrstvwxyz\".split(\"\")\n spy_name = []\n \n name.split(\"\").map do |letter|\n if vowels.include?(letter)\n vowels.index(letter)\n index = vowels.index(letter)\n new_letter = vowels[index + 1]\n new_letter\n elsif consonants.include?(letter)\n consonants.index(letter)\n index = consonants.index(letter)\n new_letter = consonants[index + 1]\n new_letter\n elsif letter == \" \"\n new_letter = \" \"\n new_letter\n end\n spy_name.push(new_letter)\n end\n \n spy_name.join(\"\")\nend", "def line(katz_deli)\n if katz_deli.length >= 1\n array = []\n counter = 1 \n katz_deli.each do |name|\n array.push(\"#{counter}. #{name}\")\n counter += 1 \n end\n puts \"The line is currently: #{array.join(\" \")}\"\n else\n puts \"The line is currently empty.\"\n end \nend", "def take_a_number(katz_deli, name)\n katz_deli.push(name)\n# return the person's name along with their position in line by using the hashtag, swingly brackets to call every arguement's iteration\n puts \"Welcome, #{name}. You are number #{katz_deli.length} in line.\"\nend", "def get_spy_name(names)\n # no space in between names or too manynames\n if names.count(\" \") == 0\n print \"Enter 2 names\"\n return nil\n elsif names.count(\" \") > 1\n print \"Enter just 2 names\"\n return nil\n end\n\n names_arr = swap_names(names)\n\n names_arr.map!{ |name|\n chars_array = name.chars\n\n chars_array.map!{ |char|\n char = next_letter(char)\n }\n }\n\n # capitalize first letter of both names\n names_arr[0][0].capitalize!\n names_arr[1][0].capitalize!\n\n #insert space after new first name\n names_arr.insert(1, ' ')\n\n return names_arr.join()\nend", "def make_up_name(name)\nchanged_name = [] #empty array to push letters from name into when it goes through iteration\nvowels = \"aeiou\"\n\nconsonant = \"bcdfghjklmnpqrstvwxyz\"\n\n\n#if the index of the name provided is a consonant then change it to the next letter.\n\nindex = 0 #start at 0\n \n while index < name.length\n \t\tletter = name[index] #takes every index of every letter in name and stores it in a variable\n \t\tif vowels.include?(letter) #deals with edge case\n \t\t\tif letter == \"u\"\n \t\t\t\tchanged_name.push(\"a\")\n \t\t\telse #need to make it so every other vowel changes to next vowel letter.next\n \t\t\tend\n \t\telsif consonant.inlcude?(letter)\n \t\t\tif letter == \"z\" #deals with edge case\n \t\t\t\tchanged_name.push(\"b\")\n \t\t\telse #everything else will need to be next letter using letter.next \t\t \t\t\n \t\t\tend\n \t\telsif letter == \" \"\n \t\t\t\tchanged_name.push(\" \")\n \t\t\tend\n \t\t \t index += 1\n \tend\nnew_name_array = changed_name.join('') #takes all the letters in the array above and puts it in a new array\nnew_name_array.each {|name| p name.capitalize}\nend", "def take_a_number(katz_deli, name) # Takes deli line and a new customer name as input.\n katz_deli.push(name) # Add new customer to deli line.\n puts \"Welcome, #{name}. You are number #{katz_deli.size} in line.\" # Returns the required string.\nend", "def advance(string)\n\n vowels_str = 'aeioua'\n vowels_arr = vowels_str.split('')\n consonants_str = 'bcdfghjklmnpqrstvwxyzb'\n consonants_arr = consonants_str.split('')\n \n string0 = string.downcase.split[1] + \" \" + string.downcase.split[0]\n str1 = string0.split('')\n\n str_new = str1.map do |char|\n if vowels_arr.include?(char)\n vowels_arr.rotate(1)[vowels_arr.index(char)]\n elsif consonants_arr.include?(char)\n consonants_arr.rotate(1)[consonants_arr.index(char)]\n else\n char\n end\n end\n\n newname = str_new.join #joining the array into a string\n spyname = newname.split.map(&:capitalize).join(' ') #splitting that string to capitalize the first letter, then rejoining\n p spyname\n realname = string.split.map(&:capitalize).join(' ')\n $codenames << [spyname, realname]\nend", "def swap_name(str)\n arr = str.split\n p arr[1] + ', ' + arr[0]\nend", "def line(array)\n if array.empty?\n puts \"The line is currently empty.\"\n else\n string = \"The line is currently:\"\n array.each.with_index(1) { |name, index| string << \" #{index}. #{name}\"}\n puts string\n end\nend", "def nick_change_line(line)\n other_person = /-!- ([^ ]+) is now known as ([^ ]+)/.match(line)\n you_person = /-!- You're now known as ([^ ]+)/.match(line)\n if other_person\n old_nick, new_nick = other_person.captures\n<<-END\n<span class=\"old_nick\">#{old_nick}</span> is now known as <span class=\"new_nick\">#{new_nick}</span>\nEND\n elsif you_person\n new_nick = other_person.captures.first\n<<-END\nYou're now known as <span class=\"new_nick\">#{new_nick}</span>\nEND\n end\nend", "def replace(arr)\n puts \"Please enter the name to replace:\"\n old_name = gets.chomp\n index = arr.index(old_name)\n puts \"Please enter the name to include instead:\"\n new_name = gets.chomp\n arr[index] = new_name\nend", "def line(array)\n arr = []\n if array.length == 0\n puts \"The line is currently empty.\"\n else\n array.each.with_index(1) do |name, index|\n arr.push(\"#{index}. #{name}\")\n end\n puts \"The line is currently: #{arr.join(\" \")}\"\n end\nend", "def name_change(normal_name)\nvowels = \"aeiouAEIOU\".split(\"\")\nconsonants = \"bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ\".split(\"\")\n\nchanged_name = normal_name.split(\" \")\nchanged_name[0], changed_name[1] = changed_name[1], changed_name[0]\n split_name = changed_name.join(\" \")\nname = split_name.split(\"\")\n\nnew_name = \"\"\nname.each_with_index do |letter, letter_index|\n if vowels.include?(letter)\n vowels.each_with_index do |vowel, vowel_index|\n if letter === vowel\n if letter === \"u\"\n new_name << \"a\"\n elsif letter === \"U\"\n new_name << \"A\"\n else\n new_name << vowels[vowel_index+1]\n end\n end\n end\nend\n if consonants.include?(letter)\n consonants.each_with_index do |consonant, consonant_index|\n if letter === consonant\n if letter === \"z\"\n new_name << \"b\"\n elsif letter === \"Z\"\n new_name << \"B\"\n else\n new_name << consonants[consonant_index+1]\n end\n end\n end\nend\n if letter === \" \"\n new_name << \" \"\n end\n end\n new_name\nend", "def name_change(agent)\r\n\tcode_list = []\r\n\tname = agent\r\n\tcoded_name = name.split('')\r\n\r\n# After the user enters a name, the name will be split into separate letters, which will be placed in an array.\r\n\r\n\tcoded_name.map! { |code| code.next }\r\n\r\n# Each letter in the array will then be changed to the letter that follows it in the alphabet.\r\n\r\n\tcoded_name\r\n\tfalse_name = coded_name.join('')\r\n\r\n# Finally, the letters will be joined back into a new string. This string is the result of the original name being changed by this method.\r\n\r\n\tcode_list << false_name\r\n\r\n# The above line will store the changed names in an array, which was initialized at the beginning of the method.\r\n\r\nend", "def flip_first_last_name(name)\n fixed_name = name.split(\", \")\n if fixed_name[1] \n fixed_name[1] + ' ' + fixed_name[0]\n else\n name\n end\n end", "def translate_name(name)\nreversed_name = name.split(' ').reverse\nnew_first = reversed_name[0].chars.map {|x|\n x.next\n }\nnew_last = reversed_name[1].chars.map {|x|\n x.next\n }\nnew_name = \"#{new_first.join} #{new_last.join}\"\nend", "def alias_creator(nickname)\nvowels=\"aeiou\"\nconsonants=\"bcdfghjklmnpqrstvwxyz\"\n#consonants exclude all vowels\n\nnickname_split=nickname.split(\"\")\nnew_nickname=[]\n#The translated nickname will be saved in the new_nickname arrawy\n\nnickname_split.map! do |x|\n\tif vowels.include?(x)\n\t\tnew_nickname << vowels[vowels.index(x)+1]\n\telsif consonants.include?(x)\n\t\tnew_nickname << consonants[consonants.index(x)+1]\n\telsif x == \" \"\n\t\tnew_nickname << \" \"\n\tend\nend\nnew_nickname.join(\"\").split.map {|x| x.capitalize}.join(\" \")\n#We are doing this so that we capitalize the first letter of both words\nend", "def fix_names(w)\n row = 2\n changed = 0\n until (name = w[row, 2]).empty?\n fixed = fix_name(name)\n if fixed != name\n puts '%-3s: %s\\n %s' % [row, name, fixed]\n w[row, 2] = fixed\n changed += 1\n end\n row += 1\n end\n puts 'changed %s' % changed\nend", "def line(katz_deli)\n line_position = []\n if katz_deli == []\n puts \"The line is currently empty.\"\n else katz_deli != []\n katz_deli.each_with_index { |name, index|\n line_position << \"#{index+1}. #{name}\" } ##make the array the way you want the texts to display*\n puts \"The line is currently: #{line_position.join(\" \")}\" #convert into string*\n end\nend", "def alias_creator(full_name)\n full_name = full_name.downcase\n name = full_name.split(' ').to_a\n first_name = name[0]\n last_name = name[1]\n first_name_letters = first_name.split('')\n last_name_letters = last_name.split('')\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\", \"a\"]\n consonants = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\", \"b\"]\n \n first_name_letters.map! do |letter|\n if vowels.include?(letter)\n letter_index = vowels.index(letter)\n new_letter_index = letter_index + 1\n letter = vowels[new_letter_index]\n elsif consonants.include?(letter)\n letter_index = consonants.index(letter)\n new_letter_index = letter_index + 1\n letter = consonants[new_letter_index]\n end\n end\n new_first_name = first_name_letters.join('').capitalize\n \n last_name_letters.map! do |letter|\n if vowels.include?(letter)\n letter_index = vowels.index(letter)\n new_letter_index = letter_index + 1\n letter = vowels[new_letter_index]\n elsif consonants.include?(letter)\n letter_index = consonants.index(letter)\n new_letter_index = letter_index + 1\n letter = consonants[new_letter_index]\n end\n end\n new_last_name = last_name_letters.join('').capitalize\n\n new_name = new_last_name + \" \" + new_first_name\n return new_name\n \nend", "def spy_name_map(str)\n# reverse first and last name\n\t# str = str.downcase\n\tsplit_name = str.split(' ')\n\treverse_name = split_name.reverse\n\tspy_name = reverse_name.join(' ')\n\tstored_names = []\n\nletters = spy_name.split('')\ni = 0\n\n\tletters.map! { |letter| letter.next }\n\tspy_final = letters.join('')\n# if spy_final.include? '!'\nspy_final = spy_final.gsub!('!', ' ')\n\tstored_names << spy_final\n\tp spy_final\nend", "def fake_identities(real_name)\n\n # input is downcase, split, and has reverse positions\n new_alias = real_name.downcase.split(' ').reverse\n # use map! to mutate name\n new_alias.map! {|name_info| name_info.split('')}\n\n new_alias.map! do |name_info|\n name_info.map! do |vowel|\n\n if vowel == \"z\"\n vowel = \"a\"\n elsif next_vowels(vowel) == vowel\n vowel.next!\n if next_vowels(vowel) != vowel\n vowel.next!\n end\n vowel\n else\n next_vowels(vowel)\n end\n end\n # returns a string and capitalizes first letter\n name_info.join('').capitalize\n end\n new_alias.join(' ') # keeps blank space here, otherwise it doesnt work\nend", "def take_a_number(katz_deli, name) #defines the take_a_number method using an array's (katz_deli) coorindnates with an assosicated sequence of names.\n katz_deli.push(name) # .push takes the names and adds them to end of the array (katz_deli), pushing forward the next person in line.\n position = katz_deli.index(name) # .index takes the names' positions within the array to to create a queue of people waiting in line. Ascribing the names to position within the array katz_deli.\n puts \"Welcome, #{name}. You are number #{katz_deli.index(name)+1} in line.\" #\"puts\" sends a message with the name of the ticket taker and their ticket number, which is their place within the array and adds 1 (Ruby array indexing starts at 0.) Also, an index of -1 indicates the last element of the array, -2 is the next to last element in the array, and so on.\n return name, position #returns the name and position of the following person to move the line.\nend", "def firstname(firstname, direction = :push)\n if direction == :push\n firstname[0..33]\n else\n firstname\n end\n end", "def line(katz_deli)\n if katz_deli.empty? \n # .empty? returns true if the array has no elements\n puts \"The line is currently empty.\"\n else\n lineup = \"The line is currently:\"\n katz_deli.each_with_index do |customer, index| \n # .each_with_index returns the element and its index\n lineup << \" #{index + 1}. #{customer}\" \n # << appends the the succeeding term to the preceeding one\n end\n puts lineup\n end\nend", "def line(deli)\nif deli == []\n puts \"The line is currently empty.\"\nelse\n output = \"The line is currently:\"\n deli.each_with_index do |name, index|\n output << \" #{index+1}. #{name}\"\n end\n puts output\nend\nend", "def names\n nameparts = name.split(' ')\n firstinitial = nameparts.second ? \"#{firstname[0, 1]}.\" : ''\n secondname = nameparts.third ? nameparts.second : ''\n secondinitial = nameparts.third ? \"#{secondname[0, 1]}.\" : ''\n middlenames = nameparts.length > 2 ? nameparts.from(1).to(nameparts.from(1).length - 2) : []\n middleinitials = ''\n middlenames.each_with_index do |name, index|\n middleinitials << ' ' if index.positive?\n middleinitials << \"#{name.to_s[0, 1]}.\"\n end\n lastname = nameparts.last\n names = []\n names << full_name # Joseph Aloysius Hansom\n names << \"#{title} #{name}\" if titled? # Sir Joseph Aloysius Hansom\n names += aka # Boz, Charlie Cheese, and Crackers\n names << \"#{title} #{firstinitial} #{middleinitials} #{lastname}\" if titled? && nameparts.length > 2\n names << \"#{title} #{firstinitial} #{lastname}\" if titled? && nameparts.length > 1\n names << name if name != full_name # Joseph Aloysius Hansom\n if name.include? ',' # George Inn, Barcombe\n names << name.split(/,/).first\n return names\n end\n names << \"#{title} #{name.split(/ of /).first}\" if name.include?(' of ') && titled? # King Charles II [of England]\n names << name.split(/ of /).first if name.include?(' of ') # [King] Charles II [of England]\n names << \"#{firstname} #{middleinitials} #{lastname}\" if nameparts.length > 2 # Joseph A[loysius]. R[obert]. Hansom\n names << \"#{firstinitial} #{middleinitials} #{lastname}\" if nameparts.length > 2 # J. A. R. Hansom\n names << \"#{firstname} #{nameparts.second} #{lastname}\" if nameparts.length > 2 # Joseph Aaron Hansom\n names << \"#{firstname} #{secondinitial} #{lastname}\" if nameparts.length > 2 # Joseph A. Hansom\n names << \"#{firstinitial} #{secondname} #{lastname}\" if nameparts.length > 2 # J. Aaron Hansom\n names << \"#{title} #{firstname} #{lastname}\" if nameparts.length > 2 && titled? # Sir Joseph Hansom\n names << \"#{firstname} #{lastname}\" if nameparts.length > 2 # Joseph Hansom\n names << \"#{firstinitial} #{lastname}\" if nameparts.length > 1 # J. Hansom\n names << \"#{title} #{lastname}\" if titled? # Lord Carlisle\n names << \"#{title} #{firstname}\" if titled? # Sir William\n names << firstname if nameparts.length > 1 # Charles\n names << lastname if nameparts.length > 1 # Kitchener\n names.uniq\n end", "def list \n @people.each_with_index do |a,i|\n puts \"Entry \" + (i+1).to_s + \": \" + a.fullname\n end\n end", "def line(katz_deli)\n\n if katz_deli.length == 0\n puts \"The line is currently empty.\"\n else\n current_line = []\n katz_deli.each.with_index(1) do |name,index|\n current_line << \"#{index}. #{name}\"\n end\n puts \"The line is currently: #{current_line.join(\" \")}\"\n\n\n end\n end", "def create_lineage(names)\n new_names = []\n i = 0\n names_index = -1\n name_combos = {}\n\n while i < 25\n name = {}\n names_index = (names_index + 1) % names.length\n name[:last_name] = last_name\n\n first_name = names[names_index]\n name[:first_name] = first_name\n middle_name = (new_names.length > 2 ? new_names[new_names.length - 2][:first_name] : '')\n name[:middle_name] = middle_name\n name[:middle_name] = (if i == 0\n 'Allen'\n else\n (if i == 1\n 'Dimitri'\n else\n (i == 2 ? 'John' : name[:middle_name])\n end)\n end)\n middle_name = name[:middle_name]\n\n combo_name = \"#{first_name}_#{middle_name}\"\n if name_combos[combo_name].nil?\n name_combos[combo_name] = 1\n else\n name_combos[combo_name] += 1\n end\n title = name_combos[combo_name]\n\n name[:suffix] = Character.romanize title unless title == 1\n\n name[:age_at_son] = rand(23..35)\n\n name[:birth_year] =\n (i == 0 ? age_at_son + birth_year : new_names[new_names.length - 1][:birth_year] + new_names[new_names.length - 1][:age_at_son])\n\n death_age = rand(63..76)\n name[:death_year] = name[:birth_year] + death_age\n i += 1\n\n new_names << name\n end\n\n new_names\n end", "def add_name(line, name, after: nil)\n if after\n replace_name(line, after, \"#{after} #{name}\")\n else\n return if line !~ /^([^\\s]+)(\\s+)/\n\n i = $~.end(2)\n \"#{$1}#{$2}#{name} #{line[i..-1]}\"\n end\n end", "def add_name(line, name, after: nil)\n if after\n replace_name(line, after, \"#{after} #{name}\")\n else\n return if line !~ /^([^\\s]+)(\\s+)/\n\n i = $~.end(2)\n \"#{$1}#{$2}#{name} #{line[i..-1]}\"\n end\n end", "def line(katz_deli)\n if(katz_deli == [])\n puts \"The line is currently empty.\"\n else\n line = [];\n katz_deli.each_with_index {|name, index| line.push(\"#{index + 1}. #{name}\")};\n puts \"The line is currently: #{line.join(\" \")}\";\n end\nend", "def next_letter(reversed_name)\n vowels = 'aeioua'\n consonants = 'bcdfghjklmnpqrstvwxy'\n #reversed name to array\n reversed_name_array = reversed_name.split('')\n #check if letter is vowel if so make it next vowel\n #check if letter is consonant if so make it next consonant\n reversed_name_array.map! { |letter|\n if vowels.index(letter) != nil\n new_vowel = vowels.index(letter) + 1\n letter = vowels[new_vowel]\n elsif consonants.index(letter) != nil\n new_consonant = consonants.index(letter) + 1\n letter = consonants[new_consonant]\n else\n letter = letter\n end\n }\n reversed_name_array_joined = reversed_name_array.join\nend", "def vowels_consonant_movement2(name)\n name = name.downcase.split(\" \")\nfirst_name = name[0]\nsecond_name = name[1]\n consonants = \"bcdfghjklmnpqrstvwxyz\"\n vowels = \"aeiou\"\n translated_name = []\n translated_name2 = []\n\n#adjust first name \n x = 0 \n while x < first_name.length\n if first_name[x] == \"z\"\n first_name[x] = \"b\"\n translated_name << first_name[x]\n elsif\n first_name[x] == \"u\"\n first_name[x] = \"a\"\n translated_name << first_name[x]\n \n elsif consonants.include?first_name[x]\n \n new_position = consonants.index(first_name[x]) + 1 \n \n first_name[x] = consonants[new_position]\n translated_name << first_name[x]\n \n elsif vowels.include?first_name[x]\n newer_position = vowels.index(first_name[x]) + 1\n first_name[x] = vowels[newer_position]\n translated_name << first_name[x]\n \n end\n \n x += 1\n end\n \n#adjust second name \n x = 0 \n while x < second_name.length\n if second_name[x] == \"z\"\n second_name[x] = \"b\"\n translated_name2 << second_name[x]\n elsif\n second_name[x] == \"u\"\n second_name[x] = \"a\"\n translated_name2 << second_name[x]\n \n elsif consonants.include?second_name[x]\n \n new_position = consonants.index(second_name[x]) + 1 \n \n second_name[x] = consonants[new_position]\n translated_name2 << second_name[x]\n \n elsif vowels.include?second_name[x]\n newer_position = vowels.index(second_name[x]) + 1\n second_name[x] = vowels[newer_position]\n translated_name2 << second_name[x]\n \n end\n \n x += 1\n end\n \n first_letter = translated_name[0].upcase\n translated_name.delete_at(0)\n translated_name.insert(0, first_letter)\n \n first_letter2 = translated_name2[0].upcase\n translated_name2.delete_at(0)\n translated_name2.insert(0, first_letter2)\n \n return translated_name2.join(\"\") + \" \" + translated_name.join(\"\")\n \n \nend", "def swap_name(name)\n name.split(' ')[1] + ', ' + name.split(' ')[0]\nend", "def alias_creator(name)\n name.downcase!\n name_array = name.split(' ')\n name_array.reverse!\n # insert method for changing vowels here\n post_vowels = next_vowel(name_array)\n # insert method for changing consonants here#\n new_name = next_consonant(post_vowels)\n # re-capitalize the first letter of each name\n new_name.map! {|word| word.capitalize}\n # take our array and turn it into a string\n puts \"Your automatically generated alias is:\"\n p new_name * \" \"\nend", "def next_vowel(name)\n\tvowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n\tindex = 0\n\tname = name.split('') # string to array\n\tname_change1 = name.map do |letter| \n\t\tif vowels.include? letter \n\t\t\tvowels.rotate(1)[vowels.index(letter)]\n\t\telse\n\t\t\tletter\n\t\tend\n\tend\n\tname_change1.join # new array convert back to string\nend", "def fakeName(name)\r\n\tnameLen = name.length\r\n\tnameIndex = 0\r\n\tvowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\r\n\tcons = [\"b\", \"c\",\"d\", \"f\",\"g\", \"h\",\"j\", \"k\",\"l\", \"m\",\"n\", \"p\",\"q\", \"r\",\"s\", \"t\",\"v\", \"x\", \"z\",\"w\", \"y\"]\r\n\tnewName = \"\"\r\n\twhile nameIndex < nameLen\r\n\t\tvowelArrayIndex = 0\r\n\t\tvowels.each do |vow|\r\n\t\t\tif name[nameIndex] == vow\r\n\t\t\t\tnextchar = next_vowel(vowelArrayIndex)\r\n\t\t\t\tnewName = newName + nextchar\r\n\t\t\tend\r\n\t\t\tvowelArrayIndex += 1\r\n\t\tend\r\n\t\tvowelArrayIndex = 0\r\n\t\tconsArrayIndex = 0\r\n\t\tcons.each do |cons|\r\n\t\t\tif name[nameIndex] == cons\r\n\t\t\t\tnextchar = next_cons(consArrayIndex)\r\n\t\t\t\tnewName = newName + nextchar\r\n\t\t\tend\r\n\t\t\tconsArrayIndex += 1\r\n\t\tend\r\n\t\tnameIndex += 1\r\n\tend\r\n\treturn newName\r\nend", "def take_a_number(array, name)\n array.push(name)\n\n place = array.index(name)\n place = place.to_i\n place += 1\n\n puts \"Welcome, #{name}. You are number #{place} in line.\"\nend", "def swap_name(str)\n \"#{str.split[1]}, #{str.split[0]}\"\nend", "def name_swap(name_to_be_altered)\n\t#STEP \t1) Breaking it into a word array\n\n\tname_arrayed = name_to_be_altered.split(' ')\n\t# STEP\t2) Doing a method that switches the first and second elements in the array\n\tname_arrayed.insert(0, name_arrayed.delete_at(1))\nend", "def name_converter(first_name, last_name)\n #1. swap the order names\n swapped_names = fake_name(first_name, last_name)\n #2 break swappedNames into array\n character_array = swapped_names.split('')\n #3. iterate through array\n vowel = [\"a\",\"e\",\"i\",\"o\",\"u\"]\n consonant = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\",\"y\",\"z\"]\n\n result = ''\n character_array.each do |character|\n if vowel.include?(character)\n #move forward next vowel in vowel array\n if character == 'u'\n result += 'a'\n next\n end \n \n current_index = vowel.index (character)\n new_index = current_index + 1\n #3. go to vowel array with new_index and retrieve that letter\n # next_letter = 'i'\n # add next_letter to result\n result += vowel[new_index]\n\n #follow same steps for moving forward next vowel for consonant \n\n elsif consonant.include?(character)\n if character == \"z\"\n result += 'b'\n next\n end\n\n current_index = consonant.index (character)\n new_index = current_index + 1\n\n result += consonant [new_index]\n\n result += character \n # add new letter to result\n end\n end\n #4. if the character is a vowel do a vowel swap\n #5. elsif the character is a consonant do a consonant swap\n \n result\nend", "def swap_name(string)\n \"#{string.split[1]}, #{string.split[0]}\"\nend", "def roll_call_dwarves(dwarf_names) # code an argument here\n # Your code here\n dwarf_names.each_with_index { |name, index| \n puts (index + 1).to_s + \". \" + name }\nend", "def concat_personal_name\n fields = %w(100 700)\n fields.each do |field|\n people = node.xpath(\"//marc:datafield[@tag='#{field}']\", NAMESPACE)\n people.each do |person|\n name_a = person.xpath(\"marc:subfield[@code='a']\", NAMESPACE).first rescue nil\n name_b = person.xpath(\"marc:subfield[@code='b']\", NAMESPACE).first rescue nil\n if name_a && name_b \n last_name = name_a.content rescue \"\"\n first_name = name_b.content rescue \"\" \n full_name = \"#{last_name}, #{first_name}\"\n name_a.content = full_name\n name_b.remove\n end\n end\n end\n end", "def line(katz_deli)\n\n line_string = \"The line is currently:\"\n if katz_deli[0] == \"\" || katz_deli[0] == \" \" || katz_deli[0] == nil\n line_string = \"The line is currently empty.\"\n else\n katz_deli.each_with_index do |name, index|\n line_string << \" #{index + 1}. #{name}\"\n end\n end\n puts line_string\nend", "def split_flip_name\n p \"what is your first and last name? (type 'print' to quit)\"\n name = gets.chomp.downcase\n old_name_array = []\n old_name_array << name\n p old_name_array\n split_name = name.split(' ')\n #more elegant to use reverse method\n flip_name = split_name[1], split_name[0]\n #p flip_name\n join_name = flip_name.join(' ').chars\n #p join_name\nend", "def index( contacts )\n contacts.each_with_index do |contact , i|\n puts \"#{i+1}) #{contact[:name]}\"\n end\nend", "def swap_name(string)\n new_string = ''\n arr = string.split(' ')\n new_string << \"#{arr[-1]}, #{arr[0]}\"\nend", "def line(deli)\n if deli.empty? then\n puts \"The line is currently empty.\"\n else\n output = \"The line is currently:\"\n deli.each_with_index{ |customer, index|\n output += \" #{index + 1}. #{customer}\"\n }\n\n puts output\n end\nend", "def print_line(queue)\n queue.map.with_index do |person, i|\n \" #{i + 1 }. #{person}\"\n end\nend", "def line(katz_deli)\n if katz_deli.empty?\n puts \"The line is currently empty.\"\n else\n current_line = []\n katz_deli.each_with_index do |customer, index|\n current_line.push( \"#{index + 1}. #{customer}\")\n end\n puts \"The line is currently: \" + current_line.join(\" \")\n end\nend", "def byline\n (name != user_name) ? name + \" (\" + user_name + \")\" : name\n end", "def byline\n (name != user_name) ? name + \" (\" + user_name + \")\" : name\n end", "def take_a_number(array, new_customer)\n \n array << new_customer\n customer_index = array.find_index(new_customer)\n \n customer_status = \"Welcome, #{new_customer}. You are number #{customer_index + 1} in line.\"\n \n puts customer_status\n \nend", "def take_a_number(the_deli, name)\n the_deli << \"#{name}\" #names to be added into the_deli array\n puts \"Welcome, #{name}. You are number #{the_deli.length} in line.\"\nend", "def nameswap(name)\n name_reverse = []\n nameary = name.split(' ')\n counter = 1 \n loop do \n name_reverse << nameary[counter]\n counter -= 1\n break if counter < 0\n end\n \n name_reverse.join(', ')\nend", "def print_line(student, index)\n cohort_merge = \"(\" + student[:cohort].to_s + \" cohort)\"\n index_string = (index+1).to_s + \".\"\n puts \"#{index_string.to_s.center(3)} #{student[:name].center(30)} #{cohort_merge.center(20)}, Hobbies:#{student[:hobbies].to_s.center(30)}, COB:#{student[:cob].to_s.center(10)}, Height:#{student[:height].to_s.center(6)}\"\nend", "def swap_name_order(name)\n # Split input into first name and last name\n first_name = name.split(' ')[0].capitalize\n last_name = name.split(' ')[1].capitalize\n fake_name_1 = last_name + \" \" + first_name\nend", "def all_deputies_last_names(full_names)\n last_names = []\n\n full_names.each_with_index do |name, index|\n last_names << name if index.even?\n end\n\n last_names\nend", "def change_name(name)\n\t\t# create alphabet range\n\t\tvowels = 'aeiou'\n\t\tvowel_change = vowels.split('').reverse\n\t\tconsonants = 'abcdefghijklmnopqrstuvwxyz'\n\t\tconsonant_change = consonants.delete('aeiou').split('').reverse\n\n\t\toriginal_name = name\n\t\tname_reverse = original_name.downcase.split.reverse.join('').split('')\n\n\n\t\tnew_name = name_reverse.map do |letter|\n\t\t\tif vowels.include?(letter)\n\t\t\t\tvowel_change[vowel_change.index(letter)-1]\n\t\t\telsif consonants.include?(letter)\n\t\t\t\tconsonant_change[consonant_change.index(letter)-1]\n\t\t\telse\n\t\t\t\tletter\n\t\t\tend\nend\n\nfinal_name = new_name.join.split.map { |name| name.capitalize}.join('')\nend", "def line(katz_deli)\n length = \"The line is currently:\"\n#i'm using a string class method (.length) here to calculate the character length of the array \"katz_deli.\"\n if katz_deli.length == 0\n puts \"The line is currently empty.\"\n else\n#I'm enumerating the katz_deli array to get the name of the customer and index to calculate the customer's position on line.\n katz_deli.each_with_index do |name, index|\n#I'm using shorthand operator += to signify my variable \"length\" is equal to variable \"length\" variable \"index+1 + name\"\n#Additionally, I'm interpolating my variables below to make my code clean, and legible.\n length += \" #{index+1}. #{name}\"\n end\n puts \"#{length}\"\n end\nend", "def printer( attendees )\n newlist = []\n attendees.each_with_index do |attendee, index|\n puts \"Hello, my name is #{attendee}.\"\n newlist << \"Hello, #{attendee}! You'll be assigned to room #{index + 1}!\"\n end\n newlist.map {|person| puts person }\nend", "def first_last_swap (full_name_string)\n swapped_full_name_array = full_name_string.split(' ').rotate(1)\n swapped_full_name_string = swapped_full_name_array.join(' ')\nend", "def pirates_say_arrrrrrrrr(string)\n \n arr = string.downcase.split('') # turning into an array and making lowercase\n \n index_no = arr.each_index.select { |r| arr[r] == 'r' } # finding the index no of each r\n \n new_index_no = index_no.map {|n| n + 1} # adding 1 to each index no\n \n p new_index_no.map {|i| arr[i] }.join # mapping the index no to the original arr and chaning to a str\n \nend", "def line(deli)\n if deli.empty?\n puts \"The line is currently empty.\"\n else\n currentLine = \"The line is currently:\"\n deli.each_with_index do |name, index|\n currentLine << \" #{index+1}. #{name}\"\n end\n puts currentLine\n end\nend", "def aliasMaker(name)\r\n\tnewName = []\r\n\tnewName2 = []\r\n\tvowels = [\"a\",\"e\",\"i\",\"o\",\"u\"]\r\n\tconsonants = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\"]\r\n\tstep1 = name.split(\" \")\r\n\ti = 0\r\n\tj = 0\r\n\r\n\twhile i <= step1.length\r\n\t\tnewName.push(step1[i])\r\n\t\ti += 1\r\n\tend\r\n\tnewName = newName.reverse\r\n\tnewName = newName.join(\" \")\r\n\tstep2 = newName\r\n\twhile j <= step2.length\r\n\t\tif isConsonant(step2[j]) == true\r\n\t\t\tnewName2.push(nextConsonant(step2[j]))\r\n\t\telsif isVowel(step2[j]) == true\r\n\t\t\tnewName2.push(nextVowel(step2[j]))\r\n\t\telse newName2.push(step2[j])\r\n\t\tend\r\n\t\tj += 1\r\n\tend\r\n\tanswer = newName2.join(\"\")\r\n\r\nend", "def alias_manager(name)\n name = name.downcase\n name = name.split(\" \").reverse.join(\" \")\n name = name.split(\"\")\n index = 0\n consonant = \"bcdfghjklmnpqrstvwqyz\"\n vowel = \"aeiou\"\n while index < name.length\n if\n !consonant.index(name[index]) && !vowel.index(name[index])\n elsif\n index_of_letter = vowel.index(name[index])\n new_letter = vowel[index_of_letter + 1]\n name[index] = new_letter\n else\n index_of_letter = consonant.index(name[index])\n new_letter = consonant[index_of_letter + 1]\n name[index]= new_letter\n end\n index += 1\n end\n name.join(\"\")\nend" ]
[ "0.6911081", "0.6592283", "0.64158297", "0.6247763", "0.62327456", "0.61858046", "0.6155296", "0.61350864", "0.6126264", "0.61102134", "0.60736257", "0.60499185", "0.60320425", "0.6014515", "0.6013078", "0.6007297", "0.5965102", "0.59359145", "0.5925291", "0.59165186", "0.590048", "0.58870703", "0.58817226", "0.5846501", "0.5843078", "0.58341575", "0.58268946", "0.58066213", "0.57944083", "0.57835776", "0.5777557", "0.5758884", "0.57363206", "0.57269317", "0.56977403", "0.56963986", "0.56906086", "0.56875306", "0.5684908", "0.5677306", "0.56761223", "0.5657816", "0.5652448", "0.5640811", "0.56278145", "0.5617213", "0.56095505", "0.56041265", "0.55817306", "0.55771613", "0.55739105", "0.55701023", "0.5567461", "0.5566627", "0.55640507", "0.5556411", "0.55405545", "0.55363935", "0.5536201", "0.5527978", "0.55273926", "0.55199635", "0.5519372", "0.5519372", "0.55065644", "0.55053616", "0.5494956", "0.5492093", "0.5488221", "0.5483815", "0.54835427", "0.547499", "0.5472386", "0.5465924", "0.5460458", "0.5457796", "0.5457487", "0.54497147", "0.5448736", "0.54474574", "0.54467475", "0.54449487", "0.5436537", "0.54245687", "0.54232585", "0.5418899", "0.5418899", "0.54183257", "0.5411924", "0.54109687", "0.5405371", "0.54041874", "0.5393231", "0.53928924", "0.5381925", "0.53791994", "0.5376239", "0.53646326", "0.5362432", "0.53530616", "0.53500545" ]
0.0
-1
input is an array position(element) of string and integer output is a string of persons name (use index and name) a string when there is no one in line (array is at 0) use length
def now_serving(array) case array.length when 0 puts "There is nobody waiting to be served!" else puts "Currently serving #{array[0]}." array.shift end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def line(katz_deli)\n\nline_array = []\n if katz_deli != []\n katz_deli.each.with_index(1) do |person, index| \n line_array << (\"#{index}. #{person} \")\n end\n \n line_array_last = line_array.pop ## removes last element with extra space\n line_array_last[line_array_last.length-1] = \"\" ## determines length to elminiate extra space\n line_array << line_array_last ## shovels last element without extra space to the array\n puts \"The line is currently: #{line_array.join}\"\n else\n puts \"The line is currently empty.\" \n end \nend", "def line(array)\n if array.size >0\n str = \"The line is currently:\"\n array.each_with_index do |name,index|\n str += \" #{index+1}. #{name}\"\n end\n puts str\n else\n puts \"The line is currently empty.\"\n end\n\nend", "def line(katz_deli)\n\n #The line_string variable contains a string\n #We will add to this string in the each_with_index block below\n\n line_string = \"The line is currently:\"\n\n #If the line is empty, the method outputs \"The line is currently empty.\"\n #Otherwise, we iterate through the katz_deli array\n #During each iteration, we add a string to line_string containing the line number & name of each element\n #We calculate the line number by adding 1 to the index number\n\n if katz_deli == []\n puts \"The line is currently empty.\"\n else\n katz_deli.each_with_index do |person, index|\n line_string += \" #{index+1}. #{person}\"\n end\n\n #Lastly, we output the newly modified line_string\n\n puts line_string\n end\nend", "def line(array)\n if array.length == 0\n puts \"The line is currently empty.\"\n else\n string = \"The line is currently:\"\n array.each_with_index do |name, index|\n string.concat(\" #{index+1}. #{name}\")\n end\n puts string\n end\nend", "def line(katz_deli)\n if katz_deli.empty? #if the line is empty\n puts \"The line is currently empty.\"\n else\n new_array = [] #this is a variable to hold the output string for the #line method\n katz_deli.each_with_index { |name, index| new_array.push(\"#{index+1}. #{name}\")} #note: name can be called anything\n final_sentence = \"The line is currently: \" + new_array.join(\" \") #.join(\" \") adds a space between each 'index. name' pair (.to_s was giving me the wrong output, with \"quotes\" around 'index. name' pairs)\n puts final_sentence\n end #end if..elsif statement\nend", "def line(array)\n if array.empty?\n puts \"The line is currently empty.\"\n else\n string = \"The line is currently:\"\n array.each.with_index(1) { |name, index| string << \" #{index}. #{name}\"}\n puts string\n end\nend", "def line (katz_deli)\n if katz_deli == [] #If there are no names in the array, desired output string is sent\n puts \"The line is currently empty.\"\n else\n output = \"The line is currently:\" #Establish the stem of the output string for when the line is occupied\n i = 1 #Initialize a counter so that the place in line can be added to output string\n katz_deli.each do |person| #Iterate through the name array for each name\n output = output + \" \" + \"#{i}\" + \". #{person}\" #Append current iteration number and index value to the output string, following desired format.\n i += 1 #increment counter to keep track of the number of entries\n end\n puts output #Send the compiled output string\n end\nend", "def line(katz_deli)\n length = \"The line is currently:\"\n#i'm using a string class method (.length) here to calculate the character length of the array \"katz_deli.\"\n if katz_deli.length == 0\n puts \"The line is currently empty.\"\n else\n#I'm enumerating the katz_deli array to get the name of the customer and index to calculate the customer's position on line.\n katz_deli.each_with_index do |name, index|\n#I'm using shorthand operator += to signify my variable \"length\" is equal to variable \"length\" variable \"index+1 + name\"\n#Additionally, I'm interpolating my variables below to make my code clean, and legible.\n length += \" #{index+1}. #{name}\"\n end\n puts \"#{length}\"\n end\nend", "def line(array)\n arr = []\n if array.length == 0\n puts \"The line is currently empty.\"\n else\n array.each.with_index(1) do |name, index|\n arr.push(\"#{index}. #{name}\")\n end\n puts \"The line is currently: #{arr.join(\" \")}\"\n end\nend", "def take_a_number(katz_deli, person)\n katz_deli.push(person)\n new_person_in_line = \" \"\n katz_deli.each_with_index do |item,index|\n new_person_in_line = \"Welcome, #{item}. You are number #{index + 1} in line.\"\n end\n puts new_person_in_line\n end", "def line(katz_deli)\n if katz_deli.length >= 1\n array = []\n counter = 1 \n katz_deli.each do |name|\n array.push(\"#{counter}. #{name}\")\n counter += 1 \n end\n puts \"The line is currently: #{array.join(\" \")}\"\n else\n puts \"The line is currently empty.\"\n end \nend", "def line(array)\n line_status_string = \"The line is currently:\"\n if array == []\n puts \"The line is currently empty.\"\n elsif array != []\n array.each_with_index {|person, place_number|\n line_status_string += \" #{place_number+1}. #{person}\"\n }\n puts line_status_string\n end\nend", "def line(katz_deli)\n if katz_deli.empty?\n puts \"The line is currently empty.\"\n else\n current_line = katz_deli.collect.with_index do |person, index|\n \"#{index + 1}. #{person}\"\n end\n string = current_line.join(\" \")\n puts \"The line is currently: #{string}\"\n end\nend", "def pirates_say_arrrrrrrrr(string)\n \n arr = string.downcase.split('') # turning into an array and making lowercase\n \n index_no = arr.each_index.select { |r| arr[r] == 'r' } # finding the index no of each r\n \n new_index_no = index_no.map {|n| n + 1} # adding 1 to each index no\n \n p new_index_no.map {|i| arr[i] }.join # mapping the index no to the original arr and chaning to a str\n \nend", "def take_a_number(katz_deli, customer_name)\n if katz_deli == []\n katz_deli << customer_name\n katz_deli.map.with_index do |name, place|\n puts \"Welcome, #{name}. You are number #{place + 1} in line.\"\n end\n else\n katz_deli << customer_name\n katz_deli.map.with_index do |name, place|\n end\n last_customer = katz_deli.last\n last_place = katz_deli.index(last_customer)\n puts \"Welcome, #{last_customer}. You are number #{last_place + 1} in line.\"\n end\n #line(katz_deli)\nend", "def take_a_number(array, name)\n place = array.length+1\n if array == []\n array.push(name)\n puts \"Welcome, \" + array.join(', ') + \". You are number #{place} in line.\"\n array\n\n # if there are already people in line, it should add a person to the end of the line\n # adding multiple people in a row should correctly build the line\n else array != []\n array.push(name)\n puts \"Welcome, #{name}. You are number #{place} in line.\"\n array\n end\nend", "def list(arr)\n return \"\" if arr.empty?\n\n str = []\n\n arr.each do |hsh|\n hsh.each do |k, v|\n str << v\n end\n end\n \n return str[0] if str.length < 2\n\n names = ''\n idx = 0\n\n until idx == str.length - 2\n names << str[idx] + ', '\n idx += 1\n end\n names << str[-2] + ' & '\n names << str[-1]\n \nend", "def line(katz_deli)\n line_position = []\n if katz_deli == []\n puts \"The line is currently empty.\"\n else katz_deli != []\n katz_deli.each_with_index { |name, index|\n line_position << \"#{index+1}. #{name}\" } ##make the array the way you want the texts to display*\n puts \"The line is currently: #{line_position.join(\" \")}\" #convert into string*\n end\nend", "def line(ppl)\n \n # If the line is empty...\n if ppl.length == 0\n\n # Tell us the line is empty.\n puts \"The line is currently empty.\"\n\n # If there are people in line... \n else\n crnt_ln = []\n \n ppl.each_with_index do |nm, ndx|\n ln = ndx + 1\n crnt_ln << \" #{ln}. #{nm}\"\n end\n \n crnt_ln.unshift(\"The line is currently:\")\n puts crnt_ln.join\n end\nend", "def take_a_number (katz_deli, name)\n katz_deli << name\n if katz_deli == 0\n puts \"The line is currently empty.\"\n else\n# .length returns number of names in katz_deli array.\n puts \"Welcome, #{name}. You are number #{katz_deli.length} in line.\"\n end\nend", "def name_muddler (array)\nvowels = [\"a\",\"e\",\"i\",\"o\",\"u\"]\nconsonants = \"bcdfghjklmnpqrstvwxyz\"\nconsonant_array = consonants.chars \nnew_name = []\nindex = 0\nwhile index < array.length\n if array[index] == \"u\"\n new_name[index] = \"a\"\n elsif vowels.include?(array[index])\n new_name[index] = vowels[vowels.index(array[index]).next]\n elsif array[index] == \"z\"\n new_name[index] = \"b\"\n else new_name[index] = consonant_array[consonant_array.index(array[index]).next]\n end\n index += 1\nend \nreturn new_name\nend", "def get_place_or_person_string(input_array, element_string)\n\n begin\n\n element_temp = get_element(input_array)\n\n result_string = ''\n\n if element_temp != ''\n if element_string != '' then\n result_string = result_string + ', '\n end\n result_string = result_string + element_temp\n end\n\n rescue => error\n log_error(__method__, __FILE__, error)\n raise\n end\n\n return result_string\n\n end", "def pirates_say_arrrrrrrrr(string)\n r_indexes = []\n string.split(\"\").each_with_index{|letter, index| r_indexes << index if letter.downcase == \"r\"}\n plusoneindex = r_indexes.map{|index| index + 1}\n answer = \"\"\n plusoneindex.map{|index| string.split(\"\")[index]}.join\n\nend", "def line(katz_deli)\n if katz_deli.size == 0 \n puts \"The line is currently empty.\"\n else\n order_string = \"\"\n katz_deli.each_with_index do |person, index| \n order_string << \" #{index + 1}. #{person}\"\n end\n puts \"The line is currently:#{order_string}\"\n end\nend", "def nth_char(arr)\n str = ''\n 0.upto(arr.size - 1) do |idx|\n str += arr[idx][idx]\n end\n str\nend", "def alias_name\n first_name = \"lia\".chars\nlast_name = \"hogan\".chars\np first_name.class\nfirst_name[3] = last_name[0]\nfirst_name[4] = last_name[1]\nfirst_name[5] = last_name[2]\nfirst_name[6] = last_name[3]\nfirst_name[7] = last_name[4]\np first_name\n\nlast_name[5] = first_name[0]\nlast_name[6] = first_name[1]\nlast_name[7] = first_name[2]\np last_name\nfirst_name.delete_at(0)\nfirst_name.delete_at(0)\nfirst_name.delete_at(0)\np first_name\nlast_name.delete_at(0)\nlast_name.delete_at(0)\nlast_name.delete_at(0)\nlast_name.delete_at(0)\nlast_name.delete_at(0)\np last_name\n \n full_name = first_name + last_name\n index = 0 \n str_back = \"\"\n while index < full_name.length\n str_back[index]\n if full_name[index] == \"a\"\n str_back[index] = \"e\"\n elsif full_name[index] == \"b\" \n str_back[index] = \"c\"\n elsif full_name[index] == \"c\" \n str_back[index] = \"d\" \n elsif full_name[index] == \"d\" \n str_back[index] = \"f\"\n elsif full_name[index] == \"e\" \n str_back[index] = \"i\"\n elsif full_name[index] == \"f\" \n str_back[index] = \"g\"\n elsif full_name[index] == \"g\" \n str_back[index] = \"h\"\n elsif full_name[index] == \"h\" \n str_back[index] = \"j\"\n elsif full_name[index] == \"i\" \n str_back[index] = \"o\"\n elsif full_name[index] == \"j\" \n str_back[index] = \"k\"\n elsif full_name[index] == \"k\" \n str_back[index] = \"l\"\n elsif full_name[index] == \"l\" \n str_back[index] = \"m\"\n elsif full_name[index] == \"m\" \n str_back[index] = \"n\"\n elsif full_name[index] == \"n\" \n str_back[index] = \"p\"\n elsif full_name[index] == \"o\" \n str_back[index] = \"u\"\n elsif full_name[index] == \"p\" \n str_back[index] = \"q\"\n elsif full_name[index] == \"q\" \n str_back[index] = \"r\"\n elsif full_name[index] == \"r\" \n str_back[index] = \"s\"\n elsif full_name[index] == \"s\" \n str_back[index] = \"t\"\n elsif full_name[index] == \"t\" \n str_back[index] = \"v\"\n elsif full_name[index] == \"u\" \n str_back[index] = \"y\"\n elsif full_name[index] == \"v\" \n str_back[index] = \"w\"\n elsif full_name[index] == \"w\" \n str_back[index] = \"x\"\n elsif full_name[index] == \"x\" \n str_back[index] = \"z\"\n elsif full_name[index] == \"y\" \n str_back[index] = \"a\"\n elsif full_name[index] == \"z\" \n str_back[index] = \"b\"\n else \n str_back[index] = \" \"\n end\n index += 1 \n end\n str_back\nend", "def string_extractor(array, index=0)\n\t\t\t\tstring = String.new; next_index = nil\n\t\t\t\t(index..index+9000).each do |item|\n\t\t\t\t\tcurr = array[item]; next_index = item+1\n\t\t\t\t\tnext_item = array[next_index]\n\t\t\t\t\tif not curr.nil? \n\t\t\t\t\t\tstring << curr.chr\n\t\t\t\t\telsif next_item.nil? && string.length >= 1\n\t\t\t\t\t\tbreak \n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t@index = next_index\n\t\t\t\tstring.chomp\n\t\t\tend", "def line(katz_deli)\n if(katz_deli == [])\n puts \"The line is currently empty.\"\n else\n line = [];\n katz_deli.each_with_index {|name, index| line.push(\"#{index + 1}. #{name}\")};\n puts \"The line is currently: #{line.join(\" \")}\";\n end\nend", "def line(deli)\nif deli == []\n puts \"The line is currently empty.\"\nelse\n output = \"The line is currently:\"\n deli.each_with_index do |name, index|\n output << \" #{index+1}. #{name}\"\n end\n puts output\nend\nend", "def nth_char(arr)\n arr.map.with_index { |word, idx| word[idx] }.join\nend", "def input_to_index(argument)\n index=argument.to_i-1\n\n # arrray=[\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",]\n # array[index]=\"x\"\nend", "def line(other_deli)\n if(other_deli.length == 0)\n puts \"The line is currently empty.\"\n else\n result = \"The line is currently: \"\n other_deli.each_with_index do |name, index|\n result += \"#{index + 1}. #{name}\"\n if(index != other_deli.length - 1)\n result += \" \"\n end\n end\n puts result\n end\nend", "def line(people_in_line = [])\n if (people_in_line.size == 0)\n puts \"The line is currently empty.\"\n return\n end\n line_message = \"The line is currently:\"\n people_in_line.each_index do |current_spot|\n line_message << \" #{current_spot + 1}. #{people_in_line[current_spot]}\"\n end\n puts line_message\nend", "def line arr\n if arr.empty? == true\n puts \"The line is currently empty.\"\n else\n #for i in (0...arr.length)\n # puts \"Line is currently: #{i + 1}. #{arr[i]}\"\n #end\n string_array = []\n arr.each_with_index do |val, idx|\n string_array.push(\"#{idx + 1}. #{val}\")\n end\n puts \"The line is currently: #{string_array.join(\" \")}\"\n end\nend", "def take_a_number(array, name)\n length = array.length \n case length\n when 0 \n array.push(name)\n puts \"Welcome, #{array[0]}. You are number 1 in line.\"\n else \n array.push(name)\n puts \"Welcome, #{name}. You are number #{array.length} in line.\"\n end\n end", "def list_dwarves(array)\narray.each_with_index do |charachter, position|\n p \"#{position + 1}. #{charachter}\"\nend\nend", "def print_A_student(arr_name)\n\tprint(arr_name.select { |name| name[:names].slice(0) == 'A'})\nend", "def line(katz_deli)\n if katz_deli.empty? \n # .empty? returns true if the array has no elements\n puts \"The line is currently empty.\"\n else\n lineup = \"The line is currently:\"\n katz_deli.each_with_index do |customer, index| \n # .each_with_index returns the element and its index\n lineup << \" #{index + 1}. #{customer}\" \n # << appends the the succeeding term to the preceeding one\n end\n puts lineup\n end\nend", "def line(katz_deli)\n current_line = \"The line is currently:\"\n if katz_deli == []\n current_line = \"The line is currently empty.\"\n else\n katz_deli.map.with_index do |name, place|\n current_line << \" #{place + 1}. #{name}\"\n end\n end\n puts current_line\nend", "def take_a_number(katz_deli, name)\n katz_deli.push(name)\n# return the person's name along with their position in line by using the hashtag, swingly brackets to call every arguement's iteration\n puts \"Welcome, #{name}. You are number #{katz_deli.length} in line.\"\nend", "def take_a_number(katz_deli, name)\n katz_deli << name\n\n# katz_deli.each_with_index do |name, index|\n puts \"Welcome, #{name}. You are number #{katz_deli.length} in line.\"\n# end\nend", "def take_a_number(katz_deli, name)\n #the take_a_number method should puts the person's name along with their postion in line --use .push(element) to add a person's name to the line\n katz_deli.push(name)\n\n puts \"Welcome, #{name}. You are number #{katz_deli.length} in line.\"\nend", "def line(katz_deli)\n\n if katz_deli.length == 0\n puts \"The line is currently empty.\"\n else\n current_line = []\n katz_deli.each.with_index(1) do |name,index|\n current_line << \"#{index}. #{name}\"\n end\n puts \"The line is currently: #{current_line.join(\" \")}\"\n\n\n end\n end", "def take_a_number (array, name)\n\narray.push(name)\nposition = array.length\n\n puts \"Welcome, #{name}. You are number #{position} in line.\"\n\nend", "def alias_creator(name_split)\r\n vowels = \"aeiou\"\r\n consonants = \"bcdfghjklmnpqrstvwxy\"\r\n\r\n name_split.map! do |string|\r\n if vowels.index(string) != nil\r\n new_vowel = vowels.index(string) + 1\r\n string = vowels[new_vowel]\r\n elsif consonants.index(string) != nil\r\n new_consonant = consonants.index(string) + 1\r\n string = consonants[new_consonant]\r\n else\r\n string = string\r\n end\r\n end\r\nend", "def get_spy_name(names)\n # no space in between names or too manynames\n if names.count(\" \") == 0\n print \"Enter 2 names\"\n return nil\n elsif names.count(\" \") > 1\n print \"Enter just 2 names\"\n return nil\n end\n\n names_arr = swap_names(names)\n\n names_arr.map!{ |name|\n chars_array = name.chars\n\n chars_array.map!{ |char|\n char = next_letter(char)\n }\n }\n\n # capitalize first letter of both names\n names_arr[0][0].capitalize!\n names_arr[1][0].capitalize!\n\n #insert space after new first name\n names_arr.insert(1, ' ')\n\n return names_arr.join()\nend", "def assign_rooms(array)\n array.map.with_index do |name, i|\n \"Hello, #{name}! You'll be assigned to room #{i+1}!\"\n end\nend", "def position_array_personne_epenser(journaliste)\n \tputs \"Reponse :\"\n \tputs \"@epenser est sur la ligne #{journaliste.index(\"@epenser\")}\"\n \tputs\nend", "def line(katz_deli)\n current_position = []# current position is to show the line is empty.\n if katz_deli.empty?# if the line is currently empty\n puts \"The line is currently empty.\"#print the phrase\n else\n !katz_deli.empty?# If the line is not empty. this line is not required in the code but helps me understand it easier\n counter = 1# there is now 1 person in line\n katz_deli.each do |customer|\n current_position << \"#{counter}. #{customer}\"# to display the current position of the elements of the array\n counter += 1\n end\n puts \"The line is currently: #{current_position.join(\" \")}\"# display the current position in a linear way.\n end\nend", "def take_a_number(katz_deli, name)\n # add person to end of line\n katz_deli << name\n # call out (`puts`) the person's name along with their position in line\n puts \"Welcome, #{name}. You are number #{katz_deli.size} in line.\"\nend", "def line(katz_deli)\n\n line_string = \"The line is currently:\"\n if katz_deli[0] == \"\" || katz_deli[0] == \" \" || katz_deli[0] == nil\n line_string = \"The line is currently empty.\"\n else\n katz_deli.each_with_index do |name, index|\n line_string << \" #{index + 1}. #{name}\"\n end\n end\n puts line_string\nend", "def input_to_index(user_input) \n #converts the user's input (a string) into an integer / would use .to_i\n #converts the user's input from the user-friendly format (on a 1-9 scale) to the array-friendly format (where the first index starts at 0) \n user_input.to_i - 1\n end", "def line(katz_deli)\n if katz_deli.size == 0\n puts \"The line is currently empty.\"\n else\n in_line = \"The line is currently:\"\n \n katz_deli.each do |name|\n in_line = in_line + \" \" + (katz_deli.index(name)+1).to_s + \". \" + name \n end\n puts in_line \n end\nend", "def persons_text\n if self.persons.length == 0\n 'n/a'\n elsif self.persons.length == 1\n self.persons[0]\n else\n persons = self.persons[0..-3] + [self.persons[-2..-1].join(' and ')]\n persons.join(', ')\n end\n end", "def line(katz_deli)\n # we are defining the method line thats take the arguement of katz_deli\n\n if(katz_deli.length == 0)\n# if the above statment is true than it will run the code below\n\n puts \"The line is currently empty.\"\n#what will be out put if the if statment = true\n\n else\nline_with_guest = \"The line is currently:\"\n\nkatz_deli.each_with_index {|name, index| line_with_guest += \" #{index + 1}. #{name}\"}\n# what we are doing is creating a variable line_with_guest that is the greeting\n# after the gretting its just a list of the people name and their number on line\n# so this each operator is going to take each element in the deli (the name) and also take a index number as a paramter\n# it will take the variable line_with_guest and for each element in the katz_deli array\n# it will add index number + 1 and the name to the variable line_with_guest\n# if you wanted it with the do loop look below\n# katz_deli.each_with_index do |name, index|\n# line_with_guest += \" #{index +1}. #{name}\"\n# once it has done this for all the elements in the array it will now put the finsihed line_with_guest\n\nputs line_with_guest\n# once the each operator is finished we will out put that variable that would give us our list\n\nend\n# end the if statement\nend", "def take_a_number(the_deli, name)\n the_deli << \"#{name}\" #names to be added into the_deli array\n puts \"Welcome, #{name}. You are number #{the_deli.length} in line.\"\nend", "def create_index1(word)\n word.chars.sort!.join\n end", "def capital_index\n\n user_input = gets.chomp.to_s\n\n input_array = []\n input_array << user_input.split(//) \n\n input_array.each_with_index do |input, index|\n if input.upcase\n puts index\n else\n puts input\n end\n end\n\nend", "def index_letter\n last_name[0..0]\n end", "def input_to_index(input)\n #converts the user's input (a string) into an integer\n #converts the user's input from the user-friendly format (on a 1-9 scale) to the array-friendly format (where the first index starts at 0)\n input.to_i - 1\n end", "def sentence_maker(a_single_argument)\n items = a_single_argument.count.to_i\n output = a_single_argument.values_at(0..(items-1)).join(\" \").capitalize\n return output + \".\"\nend", "def pirates_say_arrrrrrrrr(string)\n\tarray_1 = string.downcase.split\"\"\n\tarray_2 = []\n\nloop do \n\tarrr = array_1.index(\"r\")\n\tbreak if arrr == nil\n\tarray_1.delete_at(arrr)\n\tarray_2 << array_1[arrr]\n\t\nend\n\narray_2.join\n\nend", "def print_names_less_than_x_characters\n puts \"Please set the max character length of names to display\"\n number = STDIN.gets.chomp\n match_array = []\n #Will not continue unless input is an integer, and avoided cases in which to_i for a string returns 0, AKA an integer\n while number.to_i.to_s != number\n puts \"Please enter an integer\"\n number = STDIN.gets.chomp\n end\n @students.each_with_index do |student, index|\n if student[:name].length <= number.to_i\n match_array.push(student)\n end\n end\n print(match_array)\n if match_array.length == 1\n puts \"We have found #{match_array.size} student with a name of #{number} characters or less\"\n elsif match_array.length > 1\n puts \"We have found #{match_array.size} students with names of #{number} characters or less\"\n end\nend", "def sentence_maker (array)\n index = 0\n sentence = \"\"\n array = array.map {|x| x.to_s}\n\nuntil index == array.length-1\n sentence += array[index] + \" \"\n index += 1\nend\n\nsentence += array[-1] + \".\"\nreturn sentence.capitalize\n\nend", "def take_a_number(katz_deli, name) #defines the take_a_number method using an array's (katz_deli) coorindnates with an assosicated sequence of names.\n katz_deli.push(name) # .push takes the names and adds them to end of the array (katz_deli), pushing forward the next person in line.\n position = katz_deli.index(name) # .index takes the names' positions within the array to to create a queue of people waiting in line. Ascribing the names to position within the array katz_deli.\n puts \"Welcome, #{name}. You are number #{katz_deli.index(name)+1} in line.\" #\"puts\" sends a message with the name of the ticket taker and their ticket number, which is their place within the array and adds 1 (Ruby array indexing starts at 0.) Also, an index of -1 indicates the last element of the array, -2 is the next to last element in the array, and so on.\n return name, position #returns the name and position of the following person to move the line.\nend", "def input_name(arr, multi = false, index = name)\n s = @name_prefix.blank? ? arr.to_s : \"#{@name_prefix}[#{arr}]\"\n s << \"[#{index}]\" if index\n s << \"[]\" if multi\n s\n end", "def input_to_index(user_input)\n user_input = user_input.to_i # converts string into integer\n index = user_input - 1 # Change user input to array index.\nend", "def pirates_say_arrrrrrrrr(string)\n\n string_array = string.chars\n indexes = string_array.each_with_index.map {|char, index| char.downcase == 'r' ? index : nil}.compact # gives an array of the indexes we want\n indexes.map {|x| string_array[x+1]}.join # iterates through each index for string_array \n\nend", "def all_deputies_first_names(full_names)\n first_names = []\n\n full_names.each_with_index do |name, index|\n first_names << name if index.odd?\n end\n\n first_names\nend", "def names\n nameparts = name.split(' ')\n firstinitial = nameparts.second ? \"#{firstname[0, 1]}.\" : ''\n secondname = nameparts.third ? nameparts.second : ''\n secondinitial = nameparts.third ? \"#{secondname[0, 1]}.\" : ''\n middlenames = nameparts.length > 2 ? nameparts.from(1).to(nameparts.from(1).length - 2) : []\n middleinitials = ''\n middlenames.each_with_index do |name, index|\n middleinitials << ' ' if index.positive?\n middleinitials << \"#{name.to_s[0, 1]}.\"\n end\n lastname = nameparts.last\n names = []\n names << full_name # Joseph Aloysius Hansom\n names << \"#{title} #{name}\" if titled? # Sir Joseph Aloysius Hansom\n names += aka # Boz, Charlie Cheese, and Crackers\n names << \"#{title} #{firstinitial} #{middleinitials} #{lastname}\" if titled? && nameparts.length > 2\n names << \"#{title} #{firstinitial} #{lastname}\" if titled? && nameparts.length > 1\n names << name if name != full_name # Joseph Aloysius Hansom\n if name.include? ',' # George Inn, Barcombe\n names << name.split(/,/).first\n return names\n end\n names << \"#{title} #{name.split(/ of /).first}\" if name.include?(' of ') && titled? # King Charles II [of England]\n names << name.split(/ of /).first if name.include?(' of ') # [King] Charles II [of England]\n names << \"#{firstname} #{middleinitials} #{lastname}\" if nameparts.length > 2 # Joseph A[loysius]. R[obert]. Hansom\n names << \"#{firstinitial} #{middleinitials} #{lastname}\" if nameparts.length > 2 # J. A. R. Hansom\n names << \"#{firstname} #{nameparts.second} #{lastname}\" if nameparts.length > 2 # Joseph Aaron Hansom\n names << \"#{firstname} #{secondinitial} #{lastname}\" if nameparts.length > 2 # Joseph A. Hansom\n names << \"#{firstinitial} #{secondname} #{lastname}\" if nameparts.length > 2 # J. Aaron Hansom\n names << \"#{title} #{firstname} #{lastname}\" if nameparts.length > 2 && titled? # Sir Joseph Hansom\n names << \"#{firstname} #{lastname}\" if nameparts.length > 2 # Joseph Hansom\n names << \"#{firstinitial} #{lastname}\" if nameparts.length > 1 # J. Hansom\n names << \"#{title} #{lastname}\" if titled? # Lord Carlisle\n names << \"#{title} #{firstname}\" if titled? # Sir William\n names << firstname if nameparts.length > 1 # Charles\n names << lastname if nameparts.length > 1 # Kitchener\n names.uniq\n end", "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 line(array)\n if array.length == 0\n puts \"The line is currently empty.\"\n else\n new_array=[]\n for i in 0...array.length\n new_array.push(\"#{i+1}. #{array[i]}\")\n end\n puts \"The line is currently: #{new_array.join(\" \")}\"\n end\nend", "def accum(s)\n\t# your code\n arr = s.split(\"\")\n arr.map!.with_index do |el, idx|\n mapper = el * (idx+1)\n mapper = mapper.capitalize\n puts mapper\n mapper\n end \n\n arr.join(\"-\")\nend", "def take_a_number(array, name)\n if array == []\n array.push(name)\n puts \"Welcome, #{array[0]}. You are number #{array.length} in line.\"\n elsif array != []\n array.push(name)\n puts \"Welcome, #{array.last}. You are number #{array.length} in line.\"\n end\nend", "def name(arr)\n\tarr.join(' ')\nend", "def mix_names(girls_array, boys_array)\n b_i = 0 \n boys_array.length.times do \n girls_array << boys_array[b_i]\n b_i += 1 \n end \n output = girls_array\n return output\nend", "def line(deli_array) #define line method referring to katz_deli array\n if deli_array.length >= 1 #if statment wants to find if there is anything in the array. Then interpolate on each element (number in line and name)\n storage_array = [] #creating a space to store the new output of this method\n counter = 1 #create counter for each element (>=1) starting at 1.\n deli_array.each do |guest| #here we interpolate over each element of katz_deli array.\n storage_array.push(\"#{counter}. #{guest}\") #call .push on the new array to fill with interpolated operations\n counter += 1\n end\n puts \"The line is currently: #{storage_array.join(\" \")}\"\n else\n puts \"The line is currently empty.\"\n end #if there is no one in the line, meaning the katz_deli array is empty, puts \"the line is empty\".\nend", "def pirates_say_arrrrrrrrr(string)\n array_1 = string.downcase.split\"\"\n array_2 = []\n \n loop do\n arrr = array_1.index(\"r\")\n break if arrr == nil\n array_1.delete_at(arrr)\n array_2 << array_1[arrr]\n end\n \narray_2.join\n\nend", "def all_deputies_last_names(full_names)\n last_names = []\n\n full_names.each_with_index do |name, index|\n last_names << name if index.even?\n end\n\n last_names\nend", "def length_finder(input_array)\n\toutput_array = input_array.map{ |string| string.length}\nend", "def line(array)\n if array == []\n puts \"The line is currently empty.\"\n elsif\n new_line = []\n array.each_with_index do |val, index|\n new_line.push(\"#{index +1}. #{val}\")\n end\n new_line = new_line.join(' ').to_s\n puts \"The line is currently: #{new_line}\"\n end\nend", "def name_handler(name)\n name = name.downcase.chars #takes the input and makes it downcase and breaks it into an array to increment through\n name_new = name.map do |letter| #create a new array called name_new and start block to increment through each array\n letter_change(letter)\n end\n #Code addressing capitalization and swapping first / last\n namearr = name_new.join('').split #join the new_name array back into a string\n p namearr\n first_name = namearr[0] #assign first name to a new variable based on index\n last_name = namearr[1] #assign first name to a new variable based on index\n name_new = last_name.capitalize! + \" \" + first_name.capitalize! #capitalize and swap first for last\nend", "def index( contacts )\n contacts.each_with_index do |contact , i|\n puts \"#{i+1}) #{contact[:name]}\"\n end\nend", "def pirates_say_arrrrrrrrr(string)\n arr = string.downcase.split(\"\")\n r_array = []\n arr.each_with_index do |elem, index|\n if elem == \"r\"\n r_array << index + 1\n end\n end\n final = []\n r_array.each {|x| final << arr[x]}\n return final.join(\"\")\nend", "def print_students(students)\n\tstudents.each_with_index do |student , index| \n\t\tputs \"#{index + 1} - #{student}\" if student.start_with? \"A\"\n\tend\n\nend", "def print_each_with_index(arr_name)\n\t# each.with_index \n\tarr_name.each.with_index(1) do |stu, i|\n\t\tputs \"#{i}: #{stu[:names]} (#{stu[:cohort]} - cohort)\"\n\tend\nend", "def main_thing(arr, delimiter = \"\")\n\njoin_word = \"\"\n\narr.each do |i|\n if arr.index(i) > 0\n join_word += delimiter\n end\n join_word += i\n end\n p join_word\n end", "def pirates_say_arrrrrrrrr(string)\n # split(\"r\") \n # print out 2 position of each string - the first word\n array = []\n string.split(\"\").each_with_index do |letter, i|\n if letter == 'r' or letter == \"R\"\n array << string[1+i]\n \n end\n end\n array.join(\"\")\nend", "def input_to_index(user_input) #this method takes one argument (the users input)\n new_user_input = user_input.to_i #this specific .to converts the string into an intergeer\n new_user_input -= 1 #this subtracts it by 1 since arrays start with 0\nend", "def create_arrays(file)\n file.each do |line|\n new_string = line.split\n if new_string.last.is_number?\n # array_location removes the number character and converts it to an\n # integer\n # this variable will then be subtracted by 1 to determine the correct\n # index number later\n array_location = new_string.pop.to_i\n new_string.reverse!\n if (array_location) <= new_string.length\n puts new_string[array_location - 1]\n end\n end\n end\nend", "def input_to_index(position)\nindex = position.strip.to_i - 1\nreturn index\nend", "def vowels_consonant_movement2(name)\n name = name.downcase.split(\" \")\nfirst_name = name[0]\nsecond_name = name[1]\n consonants = \"bcdfghjklmnpqrstvwxyz\"\n vowels = \"aeiou\"\n translated_name = []\n translated_name2 = []\n\n#adjust first name \n x = 0 \n while x < first_name.length\n if first_name[x] == \"z\"\n first_name[x] = \"b\"\n translated_name << first_name[x]\n elsif\n first_name[x] == \"u\"\n first_name[x] = \"a\"\n translated_name << first_name[x]\n \n elsif consonants.include?first_name[x]\n \n new_position = consonants.index(first_name[x]) + 1 \n \n first_name[x] = consonants[new_position]\n translated_name << first_name[x]\n \n elsif vowels.include?first_name[x]\n newer_position = vowels.index(first_name[x]) + 1\n first_name[x] = vowels[newer_position]\n translated_name << first_name[x]\n \n end\n \n x += 1\n end\n \n#adjust second name \n x = 0 \n while x < second_name.length\n if second_name[x] == \"z\"\n second_name[x] = \"b\"\n translated_name2 << second_name[x]\n elsif\n second_name[x] == \"u\"\n second_name[x] = \"a\"\n translated_name2 << second_name[x]\n \n elsif consonants.include?second_name[x]\n \n new_position = consonants.index(second_name[x]) + 1 \n \n second_name[x] = consonants[new_position]\n translated_name2 << second_name[x]\n \n elsif vowels.include?second_name[x]\n newer_position = vowels.index(second_name[x]) + 1\n second_name[x] = vowels[newer_position]\n translated_name2 << second_name[x]\n \n end\n \n x += 1\n end\n \n first_letter = translated_name[0].upcase\n translated_name.delete_at(0)\n translated_name.insert(0, first_letter)\n \n first_letter2 = translated_name2[0].upcase\n translated_name2.delete_at(0)\n translated_name2.insert(0, first_letter2)\n \n return translated_name2.join(\"\") + \" \" + translated_name.join(\"\")\n \n \nend", "def pirates_say_arrrrrrrrr(string)\n array = string.split(\"\")\n collection = []\n \n for i in 0...(array.length) do\n #puts \"#{i} 1\"\n if array[i] == \"r\" || array[i] == \"R\" then\n #puts \"#{i} 2\"\n collection << array[i + 1]\n end\n end\n\n collection.join\nend", "def first_to_last(name)\r\n\t# convert name into array\r\n\tnames = name.split(\" \")\r\n\t# swap first and last\r\n\tl = names.length - 1\r\n\ttemp = names[0]\r\n\tnames[0] = names[l]\r\n\tnames[l] = temp\r\n\t# convert array back into new string\r\n\tnew_name = names.join(\" \")\r\n\treturn new_name\r\nend", "def search_gen(input_arr,artists)\n len = input_arr.count\n singer_name = input_arr[2,len - 1] * \" \"\n if(artists.key?(singer_name))\n puts artists[singer_name]\n else\n puts \"Invalid artist name.\"\n end\n end", "def process(line)\n rtn = []\n line.split(\"\").each do |char|\n \tif rtn[-1] == char\n \t\trtn << 2\n \telsif rtn[-1] == nil || rtn[-1].to_i == 0\n \t\trtn << char\n \telsif rtn[-2] == char\n \t\trtn[-1] += 1\n \telse\n \t\trtn << char\n \tend\n end\n return rtn.join\nend", "def list_apt(arr)\n for i in (0...arr.length)\n puts \"#{i+1}. #{arr[i][0]}\"\n puts arr[i][1]\n puts arr[i][2]\n puts \"\"\n end\nend", "def change_name(name)\r\n\t#store new name in new variable, downcase, split in an array and reverse order\r\n\tnew_name = name.downcase.split(' ').reverse.join(' ')\r\n\t#return the array of all the letters\r\n\t#p new_name\r\n\t#puts new_name.length\r\n\t#p new_name\r\n\talias_and_real_name = []\r\n\tindex = 0\r\n\tvowel_list = \"aeiou\"\r\n\tconsonant_list = \"bcdfghjklmnpqrstvwxyz\"\r\n\twhile index < new_name.length\r\n\t\t#[index] takes and integer and retunrs char, .index takes a char\r\n\t\t#and returns integer**\r\n\t\t#Does the letter at the # index of new_name match the vowel_list string\r\n\t\tif vowel_list.include?(new_name[index])\r\n\t\t\t#next_vowel_index is a #\r\n\t\t\t#it equals the vowel string at the letter index \r\n\t\t\t#from new_name's # index\r\n\t\t\t#Then get the next number\r\n\t\t\tnext_vowel_index = vowel_list.index(new_name[index]).next\r\n\t\t\t#new_name at that index # now equal this new # \r\n\t\t\t#Equals the vowel list at index of the next #\r\n\t\t\tnew_name[index] = vowel_list[next_vowel_index]\r\n\t\t\t\t#Solve for edge cases\r\n\t\t\t\t#If the letter is the name is going to be the last letter \r\n\t\t\t\t#in the vowel string, change it automatically to \r\n\t\t\t\t#the first on\r\n\t\t\r\n\t\t\t\r\n\t\telsif consonant_list.include?(new_name[index])\r\n\t\t\tnext_consonant_index = consonant_list.index(new_name[index]).next\r\n\t\t\tnew_name[index] = consonant_list[next_consonant_index]\r\n\r\n\t\tend #End if statement\r\n\t\t#Incriment outside of if statment but inside while loop\r\n\t\tindex += 1\r\n\t\r\n\tend #End While loop\r\n\r\n\t#return the new alias name\r\n\tnew_name\r\n\t\r\n\t#Take the alias name and stoe it in an array, new name first and real \r\n\t#name second\r\n\talias_and_real_name << new_name << name\r\n\t\r\n#End method\t\t\r\nend", "def assign_rooms(attendees)\n#use #each_with_index to create a room pair for each name. use map to return as new array\n attendees.each_with_index.map do |attendee, index|\n#index+1 to start index count from 1 instead of 0\n \"Hello, #{attendee}! You'll be assigned to room #{index+1}!\"\n end\nend", "def weasley(values)\nweasley = values.map do |entry|\n last_names_only = entry[1].split.last\n if last_names_only == \"Weasley\"\n first_names = entry[1].split.first\n last_names = entry[1].split.last\n puts \"#{first_names.to_s} Badger #{last_names.to_s.chomp}\"\n end\nend\nend", "def take_a_number(katz_deli, name) # Takes deli line and a new customer name as input.\n katz_deli.push(name) # Add new customer to deli line.\n puts \"Welcome, #{name}. You are number #{katz_deli.size} in line.\" # Returns the required string.\nend" ]
[ "0.63600785", "0.6344948", "0.63084775", "0.62896425", "0.6201454", "0.61371", "0.6118455", "0.6090272", "0.60339344", "0.5994789", "0.599185", "0.59891075", "0.5953024", "0.59346443", "0.59270513", "0.58932877", "0.5891583", "0.5880233", "0.5838522", "0.58171344", "0.5791915", "0.5740924", "0.57338357", "0.57121927", "0.56931746", "0.56670815", "0.5662026", "0.56571263", "0.563603", "0.5633741", "0.5621292", "0.5616799", "0.5608871", "0.5601713", "0.55948263", "0.5587009", "0.5581981", "0.5578579", "0.55719215", "0.55717087", "0.55387765", "0.5537577", "0.55295116", "0.5504953", "0.54973763", "0.54844886", "0.547738", "0.5476304", "0.5456407", "0.5448803", "0.543914", "0.54292256", "0.5426309", "0.5414467", "0.54101443", "0.53975403", "0.53960043", "0.53929895", "0.5372427", "0.5367918", "0.53639126", "0.53576493", "0.53507155", "0.53427625", "0.53305197", "0.5329702", "0.5315329", "0.5305567", "0.53052026", "0.52977824", "0.5291975", "0.5281993", "0.5280634", "0.5277308", "0.52709556", "0.5260823", "0.5258802", "0.5251301", "0.5249919", "0.52487344", "0.5239398", "0.523822", "0.5237732", "0.5224353", "0.52233225", "0.5215624", "0.5214418", "0.5202208", "0.52018064", "0.5200566", "0.5196101", "0.51899487", "0.5186547", "0.51861507", "0.5185255", "0.5185117", "0.51818484", "0.51794976", "0.5170832", "0.5166591", "0.51596016" ]
0.0
-1
Given an array of prices add them all together and return the total
def total(prices) amount = 0 #From this: #index = 0 #while index < prices.length # amount+= prices[index] # index += 1 #end #To this: prices.each do |price| amount += price end amount end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total(prices)\n amount = 0\n prices.each do |price|\n amount += price\n end\n amount\nend", "def total(prices)\n amount = 0\n prices.each do |price|\n amount += price\n end\n amount\nend", "def total(prices)\n total = 0\n i = 0\n while i < prices.length\n total += prices[i]\n i += 1\n end\n total\nend", "def total_price\n items.map(&:price).sum\n end", "def total\n\t\tprices = line_items.map {|li| li.price}\n\t\tprices.reduce(0) {|it0, it1| it0+it1}\n\tend", "def subtotal\n items.map(&:price).reduce(&:+)\n end", "def total_price\n @file.map { |f| f[2..3].map(&:to_f) }.flatten.reduce(:+)\n end", "def regular_price(arr)\n arr.map { |id| Product.find(id).price }.sum\n end", "def total\n total = @products.map do |product, price|\n price\n end\n\n return (total.sum * 1.074).round(2)\n end", "def total_product_price\n total_price = @products.map{|product| product.price}\n total_price.reduce(:+) \n end", "def calc_total(prices, shoppingList)\n filtered = shoppingList.split.select { |item| prices.has_key?(item) }\n \"%.2f\" % filtered.inject(0.00) { |total, item| prices[item] + total } \nend", "def sum_all_the_prices(products)\n sum = 0\n products.each do |product|\n sum = sum + ( product[:price] * product[:quantity])\n end\n sum\nend", "def total_price\n # convert to array so it doesn't try to do sum on database directly\n @total = 0\n line_items.each do |item|\n @total = item.price\n end\n line_items.to_a.sum {|item| (item.quantity * item.price) }\n end", "def total\n return 0 if @products.empty?\n total = (@products.sum { |name, price| price } * 1.075).round(2)\n return total\n end", "def add_all_quantity_prices(str_prices)\n sums = 0\n\n str_prices.split(\",\").each do |price| \n sums += price.to_i \n end\n\n sums\n end", "def sum_prices(products)\n sum = 0.0\n products.each do |product|\n product[VARIANTS_FIELD].each do |variant_product|\n sum += variant_product[PRICE_VARIANT_FIELD].to_f\n end\n end\n sum.round(2)\nend", "def total(array_of_numbers)\n return array_of_numbers.reduce(:+)\nend", "def product_tot_sales(array_item)\n\tprice_only = array_item[\"purchases\"].map {| my_price | my_price[\"price\"]}\n \tprice_only.inject(:+)\nend", "def total_price\n line_items.to_a.sum {|item| item.total_price}\n end", "def total(array)\n\tarray.inject(:+)\nend", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total(array)\n sum = 0.0\n result = 0.0\n if array.length > 0 then\n array.each do |item|\n sum += item\n end\n result = sum \n end\n return result\nend", "def sum (array)\n total = 0.0\n array.each { |elem| total += elem }\n total\nend", "def total\n total = 0\n @products.values.each do |price|\n total += price\n end\n total += (0.075 * total).round(2)\n end", "def summ\n result = 0.0\n self.propose_items.each do |item|\n result += item.price\n end\n return result\n end", "def total\n add_products = 0\n @products.each_value do |cost|\n add_products += cost\n end\n total = (add_products + (add_products * 0.075)).round(2)\n return total\n end", "def total\n sum = 0\n subtotal = @products.values\n subtotal.each do |price|\n sum += price.to_f\n end\n\n total = (sum * 1.075).round(2)\n return total\n end", "def total_price\n line_items.map { |line_item| line_item.item.price * line_item.quantity }.sum\n end", "def total_price\n sum = 0\n line_items.to_a.sum do |check|\n check.total_price.to_i\n end\n\t\nend", "def total(array)\n array.inject(:+)\nend", "def total(an_array)\n an_array.reduce(:+)\nend", "def sum\n return chosen_options.collect(&:price).sum\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price}\n end", "def total(array1)\n sum=0.0\n array1.each do|i|\n sum+=i\n end\n return sum\n end", "def total\n product_total = 0\n subtotal = 0\n @products.each_value do |prices|\n subtotal += prices\n end\n product_total = (subtotal * 0.075).round(2)+ subtotal\n return product_total\n\n end", "def sum(array)\n total = 0.0\n array.each { |num| total += num }\n return total\nend", "def total (array)\n\tsum = 0\n\n\tarray.each {|x| sum = sum + x}\n\treturn sum\nend", "def total(array)\n\tsum = 0\n\tarray.each do |x|\n\t\tsum = sum + x\n\tend\n\tsum\nend", "def total(array)\n sum = 0\n array.each {|x| sum += x}\n return sum\nend", "def running_total\n sum = 0.00\n @items.each { |item| sum += item[\"price\"] }\n return sum\n end", "def calc_sum_of_exp(expenses)\n prices = []\n expenses.each do |num|\n prices << num['price'].to_f\n end\n return prices.inject(0, :+)\nend", "def total(array)\n sum = 0\n array.each { |i| sum += i }\n return sum\nend", "def sum_prices(price_mapping)\n sum = 0\n\n price_mapping.each do |name, price|\n sum += price\n end\n\n return sum\nend", "def total(numbers)\n return numbers.reduce(:+)\nend", "def total(array)\n sum = array.inject(:+)\n sum\nend", "def total(arr)\n return arr.inject(:+)\nend", "def total(array)\n sum = 0\n array.each { |i| sum += i}\n return sum\nend", "def total(array)\n\treturn array.inject { |sum, x| sum + x }\nend", "def total_price\n\t\tline_items.to_a.sum{|item| item.total_price}\n\tend", "def total_price\n\t\tline_items.to_a.sum { |item| item.total_price }\n\tend", "def total (array)\n sum = 0\n array.each do |i|\n sum + i\n end\n return sum\nend", "def add_elements(decimal_array)\n total = 0\n decimal_array.each do |number|\n total += number\n end\n return total\nend", "def total\n array = @products.values\n if array != []\n tally = array.reduce(:+)\n tally += (0.075 * tally)\n return tally.round(2)\n else\n return 0\n end\n end", "def calculated_price\n recipe_ingredients.map(&:price).sum\n end", "def total(array)\n\tsum = 0\n\tarray.each { |a| sum += a }\n\treturn sum\nend", "def total(numbers)\n numbers.reduce(:+)\nend", "def total_price(cart)\n cart.sum {|item| item.price} \n end", "def total_price\n \tresult = 0;\n \titems = self.order_items\n\n \titems.each do |item|\n \t\tresult += item.price\n \tend\n \treturn result\n end", "def money(trips)\n revenue_array = []\n\n trips.each do |trip|\n revenue_array << trip[:cost]\n end\n\n total_money = revenue_array.sum\n return total_money\nend", "def total(arr)\n arr.inject(:+)\nend", "def total(array_of_numbers)\n sum = 0\n array_of_numbers.each do |num|\n sum += num\n end\n return sum\nend", "def total(array)\n\tsum = 0\n\tarray.each { |x| sum += x }\t\n\tsum\nend", "def total(array)\n sum = 0\n array.each do |x|\n sum = sum + x\n end\n sum\nend", "def total(array)\n sum = 0\n array.each{ |x| sum += x }\nend", "def total(array)\n sum = 0\n array.each{ |x| sum += x }\nend", "def total(list)\n list.reduce(:+)\nend", "def total_price\n \tresult = 0;\n \titems = self.temp_order_items\n\n \titems.each do |item|\n \t\tresult += item.price\n \tend\n \treturn result\n end", "def total(array)\n\ttotal = 0\n\tarray.each do |x|\n\t\ttotal += x\n\tend\n\treturn total\nend", "def total ( numbers )\r\n\r\n\treturn numbers.reduce(:+);\r\n\r\nend", "def total(numbers)\n\tnumbers.inject(:+)\nend", "def total_full_price\n # convert to array so it doesn't try to do sum on database directly\n line_items.to_a.sum(&:total_full_price)\n end", "def total(array)\n\tsum = 0\n\tarray.each do |i|\n\t\tsum += i\n\tend\n\treturn sum\nend", "def total(arr)\n x = arr.reduce(:+)\n return x\nend", "def total_of_array(array)\n array.reduce(:+)\nend", "def price\n booking_price + options.map(&:price).sum\n end", "def total_price\n res = product.price * count\n if product_options.any?\n res = res + product_options.map { |po| po.price }.sum * count\n end\n res\n end", "def total_price\n total = 0\n cart_items.collect do |item|\n total += item.total_price\n end\n\n total\n end", "def total(array)\n sum = 0\n array.each do |number|\n sum = sum += number\n end\n sum\nend", "def total array\n\tsum = 0\n\tarray.each do |x|\n\t\tsum = sum + x\n\tend\n\treturn sum\nend", "def total_price\n total = 0\n self.transactions.each do |t|\n total += t.price\n end\n total\n end", "def total_order\n total = 0.00 #initializing total\n @selected_prices.each do |cost| #for each selected item add the total cost\n total += cost\n end\n total\n end", "def total(array)\n\tarray.inject{|result, element|result+element}\nend", "def total_price\r\n\t\[email protected](0.0) { |sum, i| sum + i.total_unit_price * i.quantity }\r\n\tend", "def sum_array(expenses)\n total_expense = 0;\n expenses.each do |entry|\n total_expense += entry\n end\n return total_expense\nend", "def total(my_array)\n my_array.reduce( :+ )\n end", "def total(array)\n\tarray.inject { |sum, x| sum + x }\nend", "def total(my_array)\n result=0\n my_array.each { |a| result= result + a }\n return result\n end", "def total (array)\n\tsum=0\n\tarray.each do |n| sum += n\n\tend\n\treturn sum\nend", "def total(array_to_total)\n\t# Declare new sum variable and set to zero\n\tsum = 0\n\t# For each member of array_to_total, add to the sum variable\n\tarray_to_total.each do |x|\n\t\tsum += x\n\tend\n\t# Return the sum variable\n\treturn sum\nend", "def total(array)\n\tsum = array.inject(0, :+)\nend", "def total(array)\n \tsum = 0\n \tarray.each do |num|\n sum += num\n end\t\n return sum\n end", "def total_earned\n totals = []\n\n self.orders.each do |order|\n totals << order.total_price\n end \n\n return totals.inject{ |sum, n| sum + n } \n end", "def total(array)\n\tsum = 0\n\tarray.each {|number| sum += number}\n\tsum\nend", "def total(arr)\n\t output = 0\n\t arr.each do |x|\n\t output += x\n\t end\n\t output\nend", "def total(arr)\n\t output = 0\n\t arr.each do |x|\n\t output += x\n\t end\n\t output\nend", "def total(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n return sum\nend", "def total(arr)\n\tsum = 0\n\tarr.each do |i|\n\t\tsum = sum + i\n\tend\n\treturn sum\nend" ]
[ "0.8137551", "0.80798495", "0.79904795", "0.764584", "0.76190805", "0.761145", "0.73859763", "0.7376361", "0.73627096", "0.73535717", "0.73500705", "0.73165846", "0.722756", "0.7223032", "0.7203295", "0.7194074", "0.7146743", "0.7108413", "0.7077179", "0.7075131", "0.7069444", "0.7069444", "0.7069444", "0.7069444", "0.7064335", "0.70483893", "0.7043597", "0.702701", "0.7026841", "0.70239127", "0.7012568", "0.70039797", "0.70028466", "0.6996841", "0.6994716", "0.6969574", "0.695811", "0.6949472", "0.6945496", "0.6937968", "0.69302845", "0.6919492", "0.691746", "0.69135475", "0.69094014", "0.6907306", "0.6906056", "0.69052434", "0.6903574", "0.68976724", "0.689674", "0.68842953", "0.68807554", "0.6876005", "0.6867841", "0.686645", "0.6864962", "0.68616176", "0.68570966", "0.6851965", "0.68508416", "0.68504214", "0.6849685", "0.6849165", "0.68474597", "0.68463045", "0.68380755", "0.68380755", "0.68348473", "0.6834767", "0.68327343", "0.6831014", "0.68255544", "0.6824562", "0.68237305", "0.68233705", "0.6806559", "0.6806482", "0.6793986", "0.6791656", "0.67904943", "0.67863965", "0.6785231", "0.6779465", "0.6768668", "0.67641944", "0.6756792", "0.6756583", "0.67555106", "0.6754224", "0.67479664", "0.6735194", "0.6733847", "0.67330927", "0.6727594", "0.67232615", "0.67168516", "0.67168516", "0.67087966", "0.67066914" ]
0.7516752
6
Locks the middleware stack to ensure no further modifications are made.
def lock! @handlers.freeze end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lock\n post :lock\n end", "def lock!\n freeze!\n @locked = true\n self\n end", "def lock!\n @locked = true\n end", "def lock!\n @locked = true\n end", "def lock\n @locked = true\n self\n end", "def lock\n end", "def lock!; end", "def lock\n self.is_locked = true\n self\n end", "def do_LOCK(req, res)\n end", "def lock\n # Flush everything to start with a clean state\n # and to protect the @locked variable\n flush\n\n with_flock(File::LOCK_EX) do\n replay\n result = yield\n flush\n result\n end\n end", "def locked; end", "def lock\n shaz_nolock_lock if !@nolock\n end", "def lock\n @mutex.lock\n end", "def locked\n end", "def lock!\n self.for_update!\n end", "def mon_enter\n mon_try_enter ||\n ActiveSupport::Dependencies.interlock.permit_concurrent_loads { super }\n end", "def middleware(&block)\n @@middleware << block\n end", "def lock; end", "def lock; end", "def lock; end", "def with_lock\n lock!(true)\n yield\n ensure\n unlock!\n end", "def middleware(&block); end", "def lock\n @mutex.synchronize do\n @locked = true\n end\n self\n end", "def middleware_clear!\n @middleware.clear\n build_rack_app\n end", "def middleware(&block)\n if block_given?\n self._middleware = block\n end\n end", "def middlewares(&)\n time_freeze_middleware { insecure_middleware(&) }\n end", "def lock\n if block_given?\n raise 'Race condition' if locking?\n\n @locking = true\n yield\n return @locking = false\n end\n @locking = true\n end", "def lock(&block)\n # TODO: only use replace strategy when server is executing the lock\n return call_strategy unless (locked_token = locksmith.lock(&block))\n\n locked_token\n end", "def with_lock\n lock\n begin\n yield if block_given?\n ensure\n unlock\n end\n end", "def middleware; end", "def lock\n @privkey = nil\n @locked = true\n end", "def lock\n\t\t@lock += 1\n\t\treturn self\n\tend", "def try_lock\n end", "def synchronize\n lock\n yield\n ensure\n unlock\n end", "def sync\n @lock.synchronize do\n if @cache.in_transaction?\n @cache.abort_transaction\n @cache.flush\n PEROBS.log.fatal \"You cannot call sync() during a transaction: \\n\" +\n Kernel.caller.join(\"\\n\")\n end\n @cache.flush\n end\n end", "def lock(opts={})\n super\n end", "def lock(opts={})\n super\n end", "def lock(opts={})\n super\n end", "def lock_write\n write_sync_mutex.lock\n\n begin\n @writer = true\n\n exclusive_mutex.lock\n\n @owner = Thread.current\n ensure\n write_sync_mutex.unlock\n end\n end", "def time_freeze_middleware(&)\n if @time_freeze\n freeze_time(&)\n else\n yield\n end\n end", "def lock_self_and_visits!\n self.lock!\n self.visits(:lock => true)\n end", "def lock_changes\n begin\n @lock_count += 1\n yield\n ensure\n @lock_count -= 1\n end\n end", "def unguarded(&block)\n @guard_count += 1\n super\n end", "def middleware\n @middleware ||= []\n end", "def sync\n @mutex.synchronize{yield}\n end", "def sync\n @mutex.synchronize{yield}\n end", "def sync\n @mutex.synchronize{yield}\n end", "def sync\n @mutex.synchronize{yield}\n end", "def lock\n @@lock ||= Monitor.new\n end", "def lock\n @unlocked = false\n \"Diary is now locked\"\n end", "def middleware(&block)\n return @middleware ||= [] unless block_given?\n middleware << block\n end", "def lock _obj, _args\n \"_obj lock _args;\" \n end", "def use(new_middleware)\n @mutex.synchronize do\n return if @disabled_middleware.include?(new_middleware)\n return if @middlewares.include?(new_middleware)\n\n @middlewares << new_middleware\n end\n end", "def lock!\n create_lock_file!\n if have_first_lock?(false)\n @locked = true\n else\n cleanup_lock_file!\n false\n end\n end", "def reload_lock\n @reload_lock ||= Concurrent::ReadWriteLock.new\n end", "def unlock_access!; end", "def middleware\n @middleware ||= []\n end", "def setup_middleware middleware_stack\n where = OpenCensus::Trace.configure.middleware_placement\n case where\n when Class\n middleware_stack.insert_before where, RackMiddleware\n when :begin\n middleware_stack.unshift RackMiddleware\n else\n middleware_stack.use RackMiddleware\n end\n end", "def lock\n @@locks.synchronize do\n @@locks[@path] ||= Monitor.new\n @@locks[@path]\n end\n end", "def lock(name, mode)\n yield\n end", "def access_locked?; end", "def middlewares_stack; end", "def middleware\n @middleware ||= Rails::Configuration::MiddlewareStackProxy.new\n end", "def middleware\n @middleware ||= self.class.default_middleware.dup\n end", "def without_locking(&block)\n current = ActiveRecord::Base.lock_optimistically\n ActiveRecord::Base.lock_optimistically = false if current\n begin\n block.call\n ensure\n ActiveRecord::Base.lock_optimistically = true if current\n end\n end", "def app_middleware; end", "def middleware\n @middleware ||= ExceptionalMiddleware::MiddlewareStack.new\n end", "def synchronize\n lock\n begin\n yield\n ensure\n unlock\n end\n end", "def unlock\n @mutex.unlock\n end", "def lock\n @lock ||= Monitor.new\n end", "def unlock\n @locking = false\n end", "def login_lock!\n config = sorcery_config\n attributes = {\n config.lock_expires_at_attr_name => Time.current + config.login_lock_time_period,\n config.unlock_token_attr_name => self.class.generate_random_token\n }\n sorcery_orm_adapter.update_attributes(attributes)\n\n if config.unlock_token_mailer_disabled || config.unlock_token_mailer.nil?\n return\n end\n\n send_unlock_token_email!\n end", "def acquire_lock_on_fresh_hooks\n hook_model_klass.lock_fresh_hooks(@lock_identifier)\n end", "def lock\n request_body = {\"index\" => {\"blocks\" => {\"write\" => true}}}.to_json\n @client.put(\"_settings\", request_body, content_type: :json)\n end", "def freeze\n @opts.freeze\n @middleware.freeze\n super\n end", "def unlock\n end", "def synchronize # :yields:\n lock\n yield\n ensure\n unlock\n end", "def mutex; end", "def mutex; end", "def mutex; end", "def mutex; end", "def synchronize\n @rwlock.with_write_lock { yield }\n end", "def clear_middleware!\n @middleware = []\n end", "def lock_token\n env['HTTP_LOCK_TOKEN'] || nil\n end", "def unlock; end", "def interceptors_mutex(&block)\n @interceptors_mutex ||= begin\n require 'monitor'\n Monitor.new\n end\n @interceptors_mutex.synchronize(&block)\n end", "def middlewares; end", "def middlewares\n @middlewares.dup\n end", "def synchronize\n lock(&block)\n end", "def push\n begin\n write_data\n rescue LockMethod::Locked\n sleep 0.5\n push\n end\n end", "def middleware\n return @middleware unless block_given?\n\n @middleware = ::Middleware::Builder.new do |b|\n b.use @middleware if @middleware\n yield b\n end\n end", "def lock\n doc['lock']\n end", "def synchronize\n @mutex.synchronize do\n yield\n end\n end", "def safely_mutate_state\n File.open(@lockfile, File::RDWR|File::CREAT, 0644) do |lock|\n Timeout::timeout(2) { lock.flock(File::LOCK_EX) }\n input = if File.exists?(@datafile)\n contents = File.read(@datafile)\n contents.strip.empty? ? [] : JSON.parse(contents)\n else\n []\n end\n output = yield input\n File.write(@datafile, output.to_json)\n end\n end", "def lockWp _obj, _args\n \"_obj lockWp _args;\" \n end", "def use\n reload_if_needed\n \n raise(@exception) if @exception\n \n @storage.lock.shared {yield}\n end", "def synchronize_write\n lock_write\n begin\n yield\n ensure\n unlock_write\n end\n end", "def acquire_lock\n\t\t@@logger.info { \"Acquiring a lock in the database.\" } if have_logger?\n\t\tTournament.dataset.filter(:id => self.id, :locked => false).update(:locked => true) != 0\n\tend", "def if_access_locked; end", "def lock(*args, &block)\n args = web_dav_args args\n map_method :lock, args, &block\n end" ]
[ "0.6852519", "0.6586164", "0.63761896", "0.6314826", "0.6294935", "0.62870705", "0.6227263", "0.6158333", "0.6136505", "0.612237", "0.6074853", "0.60657173", "0.6043082", "0.60342884", "0.60031444", "0.59981024", "0.5975979", "0.5968261", "0.5968261", "0.5968261", "0.5936253", "0.5855126", "0.5841921", "0.57232517", "0.5690181", "0.5678013", "0.5644624", "0.56384134", "0.56279796", "0.562144", "0.5571177", "0.5557373", "0.5509924", "0.5507484", "0.5498521", "0.54887766", "0.54887766", "0.54887766", "0.5476406", "0.5472693", "0.54657406", "0.5453873", "0.5441107", "0.54386765", "0.54329234", "0.54329234", "0.54329234", "0.54329234", "0.5431297", "0.54282117", "0.54016054", "0.53996605", "0.53979063", "0.5382479", "0.53799874", "0.5375293", "0.5352182", "0.53212684", "0.53178996", "0.5314461", "0.531304", "0.53109807", "0.5296652", "0.5287415", "0.52788687", "0.5264448", "0.52638745", "0.52566904", "0.5251148", "0.5236954", "0.5236091", "0.52343637", "0.52280676", "0.5220267", "0.5214972", "0.52038646", "0.5200398", "0.51969457", "0.51969457", "0.51969457", "0.51969457", "0.51742786", "0.5169876", "0.5167816", "0.51661545", "0.51653856", "0.51642036", "0.51623094", "0.51494217", "0.51457936", "0.5145257", "0.5143764", "0.5141332", "0.5129607", "0.5127179", "0.5122344", "0.51189", "0.51126134", "0.51039106", "0.509707" ]
0.68016756
1
Processes a Request into a Response by passing it through this Builder's middleware stack.
def build_response(connection, request) app.call(build_env(connection, request)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process\n klass.new(request).process\n end", "def handler_request!\n response = Core::HandlerResponse.new(\n @req.body,\n @req.code,\n @req.header.to_hash.inspect\n )\n populate_properties! if response.request_successful? && check_request\n end", "def run(request)\n @request = request\n @response = request.response\n validate\n extract\n end", "def process_request req, res\n req_headers = req.header\n req_query = req.query\n req_body = Oaf::HTTPServer.get_request_body req\n file = Oaf::Util.get_request_file(@options[:path], req.path,\n req.request_method, @options[:default_response])\n out = Oaf::Util.get_output(file, req.path, req_headers, req_body,\n req_query)\n res_headers, res_status, res_body = Oaf::HTTPServer.parse_response out\n Oaf::HTTPServer.set_response! res, res_headers, res_body, res_status\n end", "def process(request); end", "def build_response(connection, request); end", "def do_request(request)\n response = nil\n\n do_request_arguments = DoRequestArguments.new(request, response)\n emit('doRequest', [do_request_arguments])\n (request, response) = do_request_arguments.to_a\n\n # If nothing modified response, we're using the default behavior.\n if response.nil?\n super(request)\n else\n response\n end\n end", "def call(request)\n handler.call(request)\n end", "def process_request(request)\n request['User-Agent'] = \"Ruby/#{RUBY_VERSION}\"\n\n request['Cookie'] = cookie if cookie\n logger.debug { redact_passwords(%(REQUEST: #{request.method} #{to_s}#{request.path} HEADERS: #{request.to_hash.inspect} #{log_request_body and request.request_body_permitted? ? \"BODY: #{format_body_for_log_output(request)}\" : ''})) }\n\n response = http.request(request)\n logger.debug { %(RESPONSE: #{response.inspect} HEADERS: #{response.to_hash.inspect} #{log_response_body and response.respond_to?(:body) ? \"BODY: #{format_body_for_log_output(response)}\" : ''}) }\n\n response\n end", "def handle( request )\n\t\tresponse = nil\n\n\t\t# Dispatch the request after allowing plugins to to their thing\n\t\tstatus_info = catch( :finish ) do\n\t\t\tself.log.debug \"Starting dispatch of request %p\" % [ request ]\n\n\t\t\t# Run fixup hooks on the request\n\t\t\trequest = self.fixup_request( request )\n\t\t\tself.log.debug \" done with request fixup\"\n\t\t\tresponse = self.handle_request( request )\n\t\t\tself.log.debug \" done with handler\"\n\t\t\tresponse = self.fixup_response( response )\n\t\t\tself.log.debug \" done with response fixup\"\n\n\t\t\tnil # rvalue for the catch\n\t\tend\n\n\t\t# Status response\n\t\tif status_info\n\t\t\tself.log.debug \"Preparing a status response: %p\" % [ status_info ]\n\t\t\treturn self.prepare_status_response( request, status_info )\n\t\tend\n\n\t\treturn response\n\trescue => err\n\t\tself.log.error \"%s: %s %s\" % [ err.class.name, err.message, err.backtrace.first ]\n\t\terr.backtrace[ 1..-1 ].each {|frame| self.log.debug(' ' + frame) }\n\n\t\tstatus_info = { :status => HTTP::SERVER_ERROR, :message => 'internal server error' }\n\t\treturn self.prepare_status_response( request, status_info )\n\tend", "def request_response(request: nil, call: nil, method: nil, metadata: nil, &block)\n rc = Gruf::Outbound::RequestContext.new(\n type: :request_response,\n requests: [request],\n call: call,\n method: method,\n metadata: metadata\n )\n call(request_context: rc, &block)\n end", "def handle_request( req )\n\t\tself.log.debug \"[:negotiation] Wrapping response with hypermedia presentation.\"\n\n\t\tresponse = super\n\t\tresponse.presenter = self.presenter\n\n\t\treturn response\n\tend", "def handle( request ) # note: all 'handle's return 'ml_response' in a chain\n\n ml_response =\n case\n when request.get? then handle_get_muffin(request)\n when request.post? then handle_post(request)\n end\n end", "def call( env )\n resource_request = RESTRack::ResourceRequest.new( :request => Rack::Request.new(env) )\n unless @request_hook.nil? or (RESTRack::CONFIG.has_key?(:PRE_PROCESSOR_DISABLED) and RESTRack::CONFIG[:PRE_PROCESSOR_DISABLED])\n @request_hook.pre_processor(resource_request)\n end\n response = RESTRack::Response.new(resource_request)\n unless @request_hook.nil? or (RESTRack::CONFIG.has_key?(:POST_PROCESSOR_DISABLED) and RESTRack::CONFIG[:POST_PROCESSOR_DISABLED])\n @request_hook.post_processor(response)\n end\n return response.output\n end", "def build_middleware(builder)\n builder.request :json\n builder.response :json\n end", "def request(req)\n self.class.paths << req.path\n self.class.params << req.body\n response = self.class.responses.shift\n if response.respond_to? :call then\n response.call req\n else\n res = Net::HTTPResponse.new '1.0', 200, 'OK'\n res.body = response\n res\n end\n end", "def apply_request(request_env)\n raise \"response didn't finish yet\" unless finished?\n @env = request_env.merge @env\n return self\n end", "def handle_request( request, &block )\n\t\tif block\n\t\t\treturn block.call( request )\n\t\telse\n\t\t\treturn request.response\n\t\tend\n\tend", "def create_response(request)\n response = Response.new\n end", "def handle( request ) # note: all 'handle's return 'mlResponse' in a chain\n\n request.record_arrival_time\n mlResponse =\n case\n when request.get? then handle_get_muffin(request)\n when request.post? then handle_post(request)\n end\n request.record_completion_time\n mlResponse\n end", "def wrap_request\n outer_most = !request_info\n\n self.request_info = {} if outer_most\n yield\n ensure\n self.request_info = nil if outer_most\n end", "def request(&_)\n if block_given?\n @request ||= Request.new\n yield @request\n end\n @request\n end", "def call(env)\n @req = Rack::Request.new(env)\n @res = Rack::Response.new\n handle_request\n @res.finish\n end", "def handle_request request, usecase=Usecase, &block\n usecase = build_usecase( request, usecase, &block )\n usecase.response\n end", "def call(request)\n result = invoke(decompose(request))\n if result.success?\n on_success(request, result)\n else\n on_failure(request, result)\n end\n end", "def process_http_request\n route_http_request\n end", "def process(*args)\n req = Request.create self, *args\n req.apply\n req\n end", "def call(env)\n @req = Rack::Request.new(env)\n @res = Rack::Response.new\n handle_request\n @res.finish\n end", "def call(env)\n @request = Rack::Request.new(env)\n @params = @path_params.merge(@request.params.symbolize_keys)\n process_response(instance_exec(self, params, request, &@block))\n end", "def handle_request( request )\n\t\tself.log.debug \"[:negotiation] Wrapping response with HTTP content negotiation.\"\n\n\t\tresponse = super\n\t\tresponse.negotiate\n\n\t\treturn response\n\tend", "def middleware\n @middleware ||= proc do |builder|\n builder.request(:desk_encode_dates)\n builder.request(:desk_encode_json)\n builder.request(*authorize_request)\n builder.request(:desk_retry)\n\n builder.response(:desk_parse_dates)\n builder.response(:desk_follow_redirects)\n builder.response(:desk_raise_error, DeskApi::Error::ClientError)\n builder.response(:desk_raise_error, DeskApi::Error::ServerError)\n builder.response(:desk_parse_json)\n\n builder.adapter(Faraday.default_adapter)\n end\n end", "def execute!\n validate_request!\n\n build_response!\n end", "def process_request( rack_env )\n request = Rack::Request.new(rack_env)\n state = Harness::State.build(self, request)\n result = process(state) \n\n if result.complete? then\n status = result.status\n headers = result.headers\n content = result.response\n \n # body = []\n # content.write_to(body)\n # [status, headers, body]\n Rack::Response.new(nil, status, headers).finish do |stream|\n content.write_to(stream)\n end\n else\n [500, {\"Content-type\" => \"text/plain\"}, [\"Scaffold failed to produce a result. For obvious reasons, this should not happen.\"]]\n end\n end", "def call(request)\n headers = request.fetch(:request_headers)\n headers[\"Content-Type\"] = \"application/json\"\n\n @app.call(request)\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 handle_request_intern(req)\n return handler_for_request(req).handle_request(req)\n end", "def handle( request ) # note: all 'handle's return 'ml_response' in a chain\n\n# not yet request.record_arrival_time\n ml_response =\n case\n when request.get? then handle_get_muffin(request)\n when request.post? then handle_post(request)\n end\n# not yet request.record_completion_time\n ml_response\n end", "def call(env)\n request = Rack::Request.new(env)\n if redirect_trailing_slash? && (request.head? || request.get?) && request.path_info[-1] == ?/\n response = Rack::Response.new\n response.redirect(request.path_info[0, request.path_info.size - 1], 302)\n response.finish\n else\n response = recognize(request)\n env['router'] = self\n if response.is_a?(RoutingResponse)\n [response.status, response.headers, []]\n elsif response && response.route.dest && response.route.dest.respond_to?(:call)\n process_params(env, response)\n consume_path!(request, response) if response.partial_match?\n response.route.dest.call(env)\n else\n @default_app.call(env)\n end\n end\n end", "def on_request &b\n @request_proc = b\n self\n end", "def call(original_request, local_options = {})\n request = build_request(original_request, request_options.deep_merge(local_options))\n response = build_response(original_request, run_request(request), response_options)\n response.rack_response\n end", "def execute!\n validate_request!\n perform_request!\n\n build_response\n end", "def execute!\n validate_request!\n perform_request!\n\n build_response\n end", "def middleware\n connection.builder\n end", "def process position, env\n process_call([Request2.new(env), env[RESPONSE]],\n [stack[position + 1], position + 1])\n end", "def middleware\n connection.builder\n end", "def request_handler(request_data)\n # assume request_data is a single line with a possible newline trailing.\n request = JSON.load(request_data.chomp)\n if 2 == request.keys.size && request.has_key?(LAST_EXIT_CODE_KEY) && request.has_key?(LAST_ERROR_MESSAGE_KEY)\n # pop the next action from the queue.\n command = @callback.call(:respond, request)\n return JSON.dump(NEXT_ACTION_KEY => command) + \"\\n\";\n end\n raise ArgumentError, \"Invalid request\"\n rescue Exception => e\n return JSON.dump(:Error => \"#{e.class}: #{e.message}\", :Detail => e.backtrace.join(\"\\n\")) + \"\\n\"\n end", "def request\n response.request\n end", "def process(request, response)\n # Make sure this has been a POST as required for XMLRPC.\n request_method = request.params[Mongrel::Const::REQUEST_METHOD] || Mongrel::Const::GET\n if request_method != \"POST\"\n response.start(405) { |head, out| out.write(\"Method Not Allowed\") }\n return\n end\n\n # Make sure the user has sent text/xml data.\n request_mime = request.params[\"CONTENT_TYPE\"] || \"text/plain\"\n if parse_content_type(request_mime).first != \"text/xml\"\n response.start(400) { |head, out| out.write(\"Bad Request\") }\n return\n end\n\n # Make sure there is data in the body at all.\n length = request.params[Mongrel::Const::CONTENT_LENGTH].to_i\n if length <= 0\n response.start(411) { |head, out| out.write(\"Length Required\") }\n return\n end\n\n # Check the body to be valid.\n if request.body.nil? or request.body.size != length\n response.start(400) { |head, out| out.write(\"Bad Request\") }\n return\n end\n\n info = client_info(request)\n\n # All checks above passed through\n response.start(200) do |head, out|\n head[\"Content-Type\"] = \"text/xml; charset=utf-8\"\n begin\n out.write(@xmlrpc_server.process(request.body, info))\n rescue => detail\n puts detail.backtrace\n raise\n end\n end\n end", "def process_request!\n job = Thread.current[:redis_blocking].brpop(Scales::Storage::REQUEST_QUEUE, 0).last\n id, response = nil, nil\n \n Thread.current[:post_process_queue] = []\n id, response = process!(job)\n post_process!(job)\n @status.put_response_in_queue!(response)\n Thread.current[:redis_nonblocking].publish(Scales::Storage::RESPONSE_CHANNEL, JSON.generate(response))\n \n [id, response]\n end", "def call(env)\n res = nil\n\n call_next = catch(:next) do\n env[@mid.opts[:middleware_env_var]] = true\n res = @mid.call(env)\n false\n end\n\n if call_next\n res = @app.call(env)\n\n if modified_headers = env.delete('roda.response_headers')\n res[1] = modified_headers.merge(res[1])\n end\n end\n\n if handle_result = @mid.opts[:middleware_handle_result]\n handle_result.call(env, res)\n end\n\n res\n end", "def process(external_request, response)\n # The response_wrapper stores the response and modifies it as a side effect.\n # The caller will use the original response\n response_wrapper = Puppet::Network::HTTP::Response.new(self, response)\n request = make_generic_request(external_request)\n\n set_puppet_version_header(response)\n\n respond_to_errors(response_wrapper) do\n with_request_profiling(request) do\n find_route_or_raise(request).process(request, response_wrapper)\n end\n end\n end", "def process(request)\n XMLRPCRequest.new(*XMLRPC::Marshal.load_call(request.raw_post))\n end", "def apply_request(request_env); end", "def response\n parse_request\n do_something\n put_response\n end", "def handle\n @response.response_code = response_code\n @response.content = view\n @response.layout = set_layout\n @response.output_format = @request.path_info.split(\".\").last\n end", "def call(env)\n request_id = id_generator.call\n logger.info formatter.message_from_request_body(env, request_id)\n app.call(env).on_complete do |env|\n logger.info formatter.message_from_response_body(env, request_id)\n end\n end", "def response(&_)\n if block_given?\n @response ||= Response.new\n yield @response\n end\n @response\n end", "def handle_request( req )\n\t\tres = req.response\n\t\tres.content_type = 'text/plain'\n\t\tres.status = HTTP::OK\n\n\t\t@runcount += 1\n\t\treq.session.counter ||= 0\n\t\treq.session.counter += 1\n\n\t\tself.log.debug \"Request session is: %p\" % [ req.session ]\n\t\tres.puts \"Session [%s]: session counter: %d, run counter: %d\" %\n\t\t\t[ req.session.session_id, req.session.counter, @runcount ]\n\n\t\treturn res\n\tend", "def process!\n if Server.environment == 'development'\n puts \"----------request--------------\\n#{controller.request.inspect}\"\n puts controller.request.body.read\n controller.request.body.rewind\n end\n\n controller.response.body = controller.send(controller.action_name)\n\n if Server.environment == 'development'\n puts \"----------response--------------\\n#{controller.response.inspect}\"\n end\n end", "def handle(request, env)\n params = @params.dup\n path_info, script_name = env[\"PATH_INFO\"], env[\"SCRIPT_NAME\"]\n \n return unless request_conditions.all? do |method_name, condition|\n # TODO: Refactor this... it lacks awesome\n next true unless request.respond_to?(method_name)\n matched, captures = condition.match(request)\n if matched\n params.merge!(captures)\n if method_name == :path_info\n new_path_info = @path_info.dup if @path_info\n new_path_info ||= env[\"PATH_INFO\"].sub(/^#{Regexp.escape(matched)}/, '')\n new_path_info.gsub!(SEGMENT_REGEXP) { |s| params[$2.to_sym] }\n env[\"SCRIPT_NAME\"] = Utils.normalize(request.env[\"SCRIPT_NAME\"] + matched)\n env[\"PATH_INFO\"] = Utils.normalize(new_path_info)\n end\n true\n end\n end\n \n env[\"rack_router.route\"] = self\n env[\"rack_router.params\"].merge! params\n \n @app.call(env)\n ensure\n env[\"PATH_INFO\"], env[\"SCRIPT_NAME\"] = path_info, script_name\n end", "def call env\n return @app.call(env) unless should_handle?(env)\n\n # Wrap request and response\n env['rack.input'].rewind\n env['rails3amf.request'] = RocketAMF::Envelope.new.populate_from_stream(env['rack.input'].read)\n env['rails3amf.response'] = RocketAMF::Envelope.new\n\n # Pass up the chain to the request processor, or whatever is layered in between\n result = @app.call(env)\n\n # Calculate length and return response\n if env['rails3amf.response'].constructed?\n @logger.info \"Sending back AMF\"\n begin\n response = env['rails3amf.response'].to_s\n rescue Exception => e\n File.open('systemstackerror.log', 'a') do |file|\n file.write(\"\\n\\n\\nError occurred at #{Time.now}\")\n file.write(\"\\n\\n#{e.inspect}\")\n file.write(\"\\n\\nAMF Version: #{env['rails3amf.response'].amf_version}\".force_encoding(\"UTF-8\"))\n file.write(\"\\n\\nHeaders: #{env['rails3amf.response'].headers}\".force_encoding(\"UTF-8\"))\n file.write(\"\\n\\nMessages: #{env['rails3amf.response'].messages}\".force_encoding(\"UTF-8\"))\n file.write(\"\\n\\nrequest: #{env['rails3amf.request'].inspect}\".force_encoding(\"UTF-8\"))\n file.write(\"\\n\\nresponse: #{env['rails3amf.response'].inspect}\".force_encoding(\"UTF-8\"))\n end\n\n raise e\n end\n\n @logger.info \"Responding\"\n return [200, {\"Content-Type\" => Mime::AMF.to_s, 'Content-Length' => response.length.to_s}, [response]]\n else\n return result\n end\n end", "def getResponse(request)\n filter(request) || super\n end", "def prepare_response\n self.send(route, parse_query)\n end", "def call env #:nodoc:\n return @app.call(env) unless should_handle?(env)\n\n # Wrap request and response\n env['rack.input'].rewind\n env['rack-amf.request'] = RocketAMF::Envelope.new.populate_from_stream(env['rack.input'].read)\n env['rack-amf.response'] = RocketAMF::Envelope.new\n\n # Call handle on \"inheriting\" class\n handle env\n\n # Calculate length and return response\n response = env['rack-amf.response'].to_s\n [200, {\"Content-Type\" => APPLICATION_AMF, 'Content-Length' => response.length.to_s}, [response]]\n end", "def trace_http_request( request )\n return yield unless NewRelic::Agent.is_execution_traced?\n\n begin\n t0, segment = start_trace( request )\n response = yield\n ensure\n finish_trace( t0, segment, request, response )\n end\n\n return response\n end", "def response_handler( request, response )\n return response if response.scope.out? || !response.text? ||\n response.code == 304\n\n if ignore_responses?\n page = Page.from_data(\n url: response.url,\n response: response.to_h\n )\n else\n page = response.to_page\n end\n\n page = update_forms( page, request, response )\n\n print_info \" * #{page.forms.size} forms\"\n print_info \" * #{page.links.size} links\"\n print_info \" * #{page.cookies.size} cookies\"\n print_info \" * #{page.jsons.size} JSON\"\n print_info \" * #{page.xmls.size} XML\"\n\n @pages << page.dup\n end", "def handle(http_request, response)\n start = Time.now\n request = Merb::Request.new(http_request)\n Merb.logger.info(\"Params: #{request.params.inspect}\")\n Merb.logger.info(\"Cookies: #{request.cookies.inspect}\")\n # user friendly error messages\n if request.route_params.empty?\n raise ControllerExceptions::BadRequest, \"No routes match the request\"\n elsif request.controller_name.nil?\n raise ControllerExceptions::BadRequest, \"Route matched, but route did not specify a controller\" \n end\n Merb.logger.debug(\"Routed to: #{request.route_params.inspect}\")\n # set controller class and the action to call\n klass = request.controller_class\n dispatch_action(klass, request.action, request, response)\n rescue => exception\n Merb.logger.error(Merb.exception(exception))\n exception = controller_exception(exception)\n dispatch_exception(request, response, exception)\n end", "def response #:nodoc:\n current_params = request.params\n @response ||= {}\n return @response[current_params] if @response.has_key? current_params\n response_object = Response.new self\n response_object.load_data\n @response[current_params] = response_object\n end", "def do_request\n\t\t\tself.response = post_request(options)\n\t\tend", "def do_POST(request, response)\n\n content_type = request['Content-Type']\n\n # For JSON, pull the instructions from the body. Otherwise, take them from the query string.\n if content_type == 'application/json'\n body = JSON.parse(request.body)\n delay_ms = body['delay_ms']\n status = body['status']\n else\n query = Rack::Utils.parse_nested_query(request.query_string)\n delay_ms = query['delay_ms']\n status = query['status']\n end\n\n reflect response, delay_ms, status\n rescue JSON::ParserError => e\n msg = \"Unable to parse request as JSON: #{e.message}\"\n $logger.error msg\n response.status = 418\n rescue StandardError => e\n $logger.error \"Invalid request: #{e.message}\"\n response.status = 500\n end", "def call(env)\n @request = Dolphy::Request.new(env)\n @response = Dolphy::Response.new\n\n router.find_route_for(request).each do |matcher, block|\n if match = router.find_match_data_for(request, with: matcher)\n response.body = [block.call(*match.captures)]\n end\n end\n\n response.status = 404 if response.body.empty?\n response.body << \"Page not found.\" if response.body.empty?\n response.finish\n end", "def process(request, response)\n indirection, method, key, params = uri2indirection(http_method(request), path(request), params(request))\n\n check_authorization(indirection, method, key, params)\n\n send(\"do_#{method}\", indirection, key, params, request, response)\n rescue SystemExit,NoMemoryError\n raise\n rescue Exception => e\n return do_exception(response, e)\n end", "def initialize( request )\n @request = request\n @response = Rack::Response.new\n end", "def make_request(request)\n puts \"\\n\\n\"\n puts \"==> Request, action='#{request.path}', params = #{request.query}...\"\n\n action = request.path.to_s.split(\"/\")[-1]\n\n if action && @app.valid?(action) then\n response = @app.send(action.to_sym, request.query)\n\n return response\n end\n\n return \"Error: Unrecognised action: #{action}\"\n rescue Exception => e\n $stderr.puts \"*** [E]: #{e}\\n#{e.backtrace.join(\"\\n\")}\"\n return \"Error: #{e}\"\n end", "def call(env)\n begin\n request_bump\n\n # expected to return the response in an array of\n # [http_status, {headers}, [enumerable body]]\n response = dispatch_request(env)\n rescue Exception => ex\n # log exception\n msg = \"EventMachine incoming request failed for #{env['REQUEST_PATH']} with: #{EMUtils.small_back_trace(ex, 15)}\"\n logger.error(msg)\n response = ErrorResponse\n end\n response\n end", "def process_request(request, body, socket)\n raise \"You must implement process_request\"\n end", "def call(req)\n ThreadAccessor.clean_thread_context(logger: logger) { @app.call(req) }\n end", "def request\n self.response = prepare_response(http_communication.content)\n end", "def process_request\n api_response = self.class.post(api_url, :body => build_xml)\n puts api_response if @debug\n response = parse_response(api_response)\n if success?(response)\n success_response(api_response, response)\n else\n failure_response(api_response, response)\n end\n end", "def build(request, response)\n @actions = []\n @namespaces = []\n @request = request\n @response = response\n @namespaces << Snap::App::Namespace::Base.new('/', self.class.start_opts, &self.class.start_block)\n @namespaces.first.execute(self)\n end", "def call!(env)\n @env = env.dup\n status, @headers, response = @app.call(@env)\n if processable_request?\n @headers.delete('Content-Length')\n response = Rack::Response.new(\n nice_typography(response.respond_to?(:body) ? response.body : response.to_s),\n status,\n @headers\n )\n response.finish\n response.to_a\n else\n [status, @headers, response]\n end\n end", "def process_request(uri, env)\n env['HTTP_COOKIE'] ||= cookie_jar.for(uri)\n @last_request = Rack::Request.new(env)\n status, headers, body = @app.call(env).to_a\n\n @last_response = MockResponse.new(status, headers, body, env['rack.errors'].flush)\n close_body(body)\n cookie_jar.merge(last_response.headers['set-cookie'], uri)\n @after_request.each(&:call)\n @last_response.finish\n\n yield @last_response if block_given?\n\n @last_response\n end", "def response(env)\n response = Colloquy::Response.new\n\n begin\n parameters = {}\n parameters = validate_request(env)\n parameters = sanitize_parameters(parameters)\n logger.debug \"REQUEST flow: #{parameters[:flow_name]}, msisdn: #{parameters[:msisdn]}, \\\n session_id: #{parameters[:session_id]}, input: #{parameters[:input]}, other: #{parameters[:params].inspect}\"\n rescue Exception => e\n logger.error \"Exception #{e.inspect} when trying to validate request flow: #{parameters[:flow_name]}, \\\n msisdn: #{parameters[:msisdn]}, session_id: #{parameters[:session_id]}, input: #{parameters[:input]}\"\n logger.debug \"#{e.backtrace.inspect}\"\n logger.info 'Responding with default error message'\n\n response = Colloquy::Response.new(Colloquy::Renderer::DEFAULT_ERROR_MESSAGE)\n response.flow_state = :notify\n end\n\n response = @renderer.apply(parameters[:flow_name], parameters[:msisdn], parameters[:session_id], parameters[:input], parameters[:params]) if response.empty?\n\n body = case parameters[:params][:accept]\n when 'text/plain'\n response.to_s\n else\n Yajl.dump({ response: response, flow_state: response.flow_state })\n end\n\n [200, {}, body]\n end", "def process_request(request)\n request['User-Agent'] = @user_agent\n request['Content-Type'] = 'application/json'\n request['X-BitPay-Plugin-Info'] = 'Rubylib' + VERSION\n\n begin\n response = @https.request request\n rescue => error\n raise BitPay::ConnectionError, \"#{error.message}\"\n end\n\n if response.kind_of? Net::HTTPSuccess\n return JSON.parse(response.body)\n elsif JSON.parse(response.body)[\"error\"]\n raise(BitPayError, \"#{response.code}: #{JSON.parse(response.body)['error']}\")\n else\n raise BitPayError, \"#{response.code}: #{JSON.parse(response.body)}\"\n end\n\n end", "def request_response(request:, call:, method:)\n return yield if !newrelic_enabled?\n\n service_name = get_service_name(method)\n\n return yield if @ignored_services.include?(service_name)\n\n # NewRelic::Agent::Tracer.in_transaction is introduced in Newrelic v6.0.0.\n # We can use it for custom instrumentation.\n # cf. https://github.com/newrelic/rpm/blob/6.0.0.351/lib/new_relic/agent/tracer.rb#L42-L55\n transaction_options = {\n partial_name: get_partial_name(method),\n category: :rack,\n options: {\n request: get_request(method, call),\n filtered_params: filter(request.to_h),\n }\n }\n NewRelic::Agent::Tracer.in_transaction(transaction_options) do\n yield\n end\n end", "def service(request, response)\n if @valid_ip\n raise WEBrick::HTTPStatus::Forbidden unless @valid_ip.any? { |ip| request.peeraddr[3] =~ ip }\n end\n\n if request.request_method != \"POST\"\n raise WEBrick::HTTPStatus::MethodNotAllowed,\n \"unsupported method `#{request.request_method}'.\"\n end\n\n raise WEBrick::HTTPStatus::BadRequest if parse_content_type(request['Content-type']).first != \"text/xml\"\n\n length = (request['Content-length'] || 0).to_i\n\n raise WEBrick::HTTPStatus::LengthRequired unless length > 0\n\n data = request.body\n\n raise WEBrick::HTTPStatus::BadRequest if data.nil? or data.size != length\n\n resp = process(data, client_request(request))\n raise WEBrick::HTTPStatus::InternalServerError if resp.nil? or resp.size <= 0\n\n response.status = 200\n response['Content-Length'] = resp.size\n response['Content-Type'] = \"text/xml; charset=utf-8\"\n response.body = resp\n end", "def middleware\n return @middleware unless block_given?\n\n @middleware = ::Middleware::Builder.new do |b|\n b.use @middleware if @middleware\n yield b\n end\n end", "def do_POST(request, response)\n\n @aspecto_repeater.repeat request\n @bugsnag_repeater.repeat request\n\n # Turn the WEBrick HttpRequest into our internal HttpRequest delegate\n request = Maze::HttpRequest.new(request)\n\n content_type = request['Content-Type']\n if %r{^multipart/form-data; boundary=([^;]+)}.match(content_type)\n boundary = WEBrick::HTTPUtils::dequote($1)\n body = WEBrick::HTTPUtils.parse_form_data(request.body, boundary)\n hash = {\n body: body,\n request: request,\n response: response\n }\n else\n # \"content-type\" is assumed to be JSON (which mimics the behaviour of\n # the actual API). This supports browsers that can't set this header for\n # cross-domain requests (IE8/9)\n digests = check_digest request\n hash = {\n body: JSON.parse(request.body),\n request: request,\n response: response,\n digests: digests\n }\n end\n if @schema\n schema_errors = @schema.validate(hash[:body])\n hash[:schema_errors] = schema_errors.to_a\n end\n add_request(hash)\n\n # For the response, delaying if configured to do so\n response_delay_ms = Server.response_delay_ms\n if response_delay_ms.positive?\n $logger.info \"Waiting #{response_delay_ms} milliseconds before responding\"\n sleep response_delay_ms / 1000.0\n end\n\n set_response_header response.header\n response.status = post_status_code\n rescue JSON::ParserError => e\n msg = \"Unable to parse request as JSON: #{e.message}\"\n if Maze.config.captured_invalid_requests.include? @request_type\n $logger.error msg\n Server.invalid_requests.add({\n reason: msg,\n request: request,\n body: request.body\n })\n else\n $logger.warn msg\n end\n rescue StandardError => e\n if Maze.config.captured_invalid_requests.include? @request_type\n $logger.error \"Invalid request: #{e.message}\"\n Server.invalid_requests.add({\n invalid: true,\n reason: e.message,\n request: {\n request_uri: request.request_uri,\n header: request.header,\n body: request.inspect\n }\n })\n else\n $logger.warn \"Invalid request: #{e.message}\"\n end\n end", "def call(env) # :nodoc:\n return @app.call(env) if env['warden'] && env['warden'].manager != self\n\n env['warden'] = Proxy.new(env, self)\n result = catch(:warden) do\n env['warden'].on_request\n @app.call(env)\n end\n\n result ||= {}\n case result\n when Array\n handle_chain_result(result.first, result, env)\n when Hash\n process_unauthenticated(env, result)\n when Rack::Response\n handle_chain_result(result.status, result, env)\n end\n end", "def execute!\n stack = InternalMiddleware.batch_stack(self)\n format_response(stack.call(middleware_env))\n end", "def requestParser(request)\n # Grab the method and path of the request\n method, path = request.lines[0].split;\n \n # Return the path, method and the parsed headers\n { path: path, method: method, headers: parseHeaders(request) }\nend", "def call(env)\n @middleware.call(env)\n end", "def process(request_buffer=nil)\n raise NotImplementedError\n end", "def state_request_body\n if @in.size >= @request.content_length\n @request.parse_body(@in.slice!([email protected]_length))\n set_state(:state_response)\n end\n end", "def call(request)\r\n self\r\n end", "def request(req, body = nil, &block)\n response = alias_for_request(req, body)\n\n if NetRecorder.recording?\n scope = NetRecorder.scope || 'global'\n path = \"http://#{req.bauth if req.bauth}#{req['host']}#{req.path}\"\n\n existing_fake = @@fakes.detect{|fake| fake[0] == path && fake[1][scope] && fake[1][scope][:method] == req.method}\n existing_fake[1][scope][:response] << {:response => response} and return response if existing_fake\n\n @@fakes << [path, {scope => {:method => req.method, :response => [{:response => response}]}}]\n end\n\n yield response if block\n response\n end", "def wrap_request(request)\n return TingYun::Http::CurbRequest.new(request),\n TingYun::Http::CurbResponse.new(request)\n end", "def process(env)\n call_stack(:before, :process)\n\n req = Request.new(env)\n res = Response.new\n\n # set response format based on request\n res.format = req.format\n\n @context = AppContext.new(req, res)\n\n set_initial_cookies\n\n @found = false\n catch(:halt) {\n call_stack(:before, :route)\n\n @found = @router.perform(context, self) {\n call_stack(:after, :match)\n }\n\n call_stack(:after, :route)\n\n unless found?\n handle(404, false)\n\n if config.app.errors_in_browser\n response[\"Content-Type\"] = 'text/html'\n\n view_file = File.join(File.expand_path('../../', __FILE__), 'views', 'errors', '404.html')\n content = File.open(view_file).read\n\n path = String.normalize_path(request.path)\n path = '/' if path.empty?\n\n content.gsub!('{view_path}', path == '/' ? 'index.html' : \"#{path}.html\")\n content.gsub!('{route_path}', path)\n\n response.body = []\n response.body << content\n end\n end\n }\n\n set_cookies\n\n call_stack(:after, :process)\n\n response.finish\n rescue StandardError => error\n call_stack(:before, :error)\n\n request.error = error\n\n handle(500, false) unless found?\n\n if config.app.errors_in_browser\n response[\"Content-Type\"] = 'text/html'\n\n view_file = File.join(File.expand_path('../../', __FILE__), 'views', 'errors', '500.html')\n content = File.open(view_file).read\n\n path = String.normalize_path(request.path)\n path = '/' if path.empty?\n\n nice_source = error.backtrace[0].match(/^(.+?):(\\d+)(|:in `(.+)')$/)\n\n content.gsub!('{file}', nice_source[1].gsub(File.expand_path(Config.app.root) + '/', ''))\n content.gsub!('{line}', nice_source[2])\n\n content.gsub!('{msg}', CGI.escapeHTML(error.to_s))\n content.gsub!('{trace}', error.backtrace.map { |bt| CGI.escapeHTML(bt) }.join('<br>'))\n\n response.body = []\n response.body << content\n end\n\n call_stack(:after, :error)\n\n response.finish\n end", "def setup_response\n begin\n @response = @interceptor.intercept(request: @request) # TODO: ignored_routes, matched_routes, robots_json, & check_static_files options\n rescue SnapSearch::Exception => exception\n @config.on_exception.nil? ? raise(exception) : @config.on_exception.call(exception)\n end\n end", "def call(env)\n @s2cgi_page_id = self.generate_page_id\n @page_id = @s2cgi_page_id\n @env = env\n self.request = ::Rack::Request.new(env)\n self.response = ::Rack::Response.new\n @validate = Seasar::Validate::Context.new\n @tpl_stack = []\n @auto_render = true\n\n unless ::Rack::MethodOverride::HTTP_METHODS.member?(@request.request_method)\n raise \"unsupport request method. [#{@env['rack.methodoverride.original_method']} -> #{@request.request_method}]\"\n end\n\n self.init\n method_name = @request.request_method.downcase.to_sym\n validate_method_name = \"validate_#{method_name}\"\n\n validate_result = true\n validators = @@validators[self.class].nil? ? {} : @@validators[self.class]\n if validators.key?(:all)\n validate_result = self.instance_eval(&validators[:all])\n end\n\n if validate_result == true\n if validators.key?(method_name)\n validate_result = self.instance_eval(&validators[method_name])\n elsif self.respond_to?(validate_method_name)\n validate_result = self.method(validate_method_name).call\n end\n if validate_result == true && self.respond_to?(method_name)\n self.method(method_name).call\n end\n end\n\n render if @auto_render && @response.body.size == 0 && @response.status == 200\n return self.out\n end" ]
[ "0.63388455", "0.61693895", "0.5949508", "0.59195703", "0.5902849", "0.5900626", "0.5857656", "0.5849027", "0.5819243", "0.57861006", "0.5753923", "0.57421637", "0.5715293", "0.5700912", "0.5685569", "0.56431687", "0.56385857", "0.56356794", "0.56223404", "0.562024", "0.559146", "0.5586963", "0.5539298", "0.55291396", "0.5521967", "0.55171293", "0.5516741", "0.55116504", "0.5506912", "0.549798", "0.5472877", "0.5471398", "0.5436844", "0.5398372", "0.538687", "0.53690493", "0.53361374", "0.533535", "0.53029454", "0.5283117", "0.5253976", "0.5249397", "0.52237886", "0.5221317", "0.5219388", "0.5219109", "0.51998925", "0.5188854", "0.51824725", "0.5181139", "0.5172246", "0.5167712", "0.5161191", "0.5159134", "0.5154331", "0.5152937", "0.51521903", "0.51323366", "0.51320887", "0.5127719", "0.5126856", "0.5126627", "0.5124552", "0.5118495", "0.51153225", "0.5112496", "0.5101618", "0.5096137", "0.5086653", "0.50784564", "0.5075219", "0.5073572", "0.50725335", "0.5058541", "0.5055129", "0.50517106", "0.5043661", "0.504366", "0.50350237", "0.503202", "0.5027203", "0.50250745", "0.5023727", "0.5017661", "0.50174296", "0.5008422", "0.5007122", "0.49887303", "0.49845937", "0.49800417", "0.4977156", "0.49711198", "0.49710807", "0.49696776", "0.49597767", "0.49523097", "0.4948709", "0.49311325", "0.49256718", "0.49219516" ]
0.6191159
1
The "rack app" wrapped in middleware. All requests are sent here. The builder is responsible for creating the app object. After this, the builder gets locked to ensure no further modifications are made to the middleware stack. Returns an object that responds to `call` and returns a Response.
def app @app ||= begin lock! to_app end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_app\n Rack::Builder.new do\n Scrapple.middleware_stack.middleware.each do |ware|\n use ware[0], *ware[1], &ware[2]\n end\n\n run Scrapple.middleware_stack.endpoint\n end \n end", "def build_rack_app\n app = base_rack_app_callable(use_new_dispatch_api?)\n\n @middleware.reverse_each do |args, bl|\n mid, *args = args\n app = mid.new(app, *args, &bl)\n app.freeze if opts[:freeze_middleware]\n end\n\n @app = app\n end", "def to_app(app)\n b = Rack::Builder.new\n for middleware in stack\n b.use *middleware\n end\n b.run app\n b.to_app\n end", "def rackup(app); return @@rack.call(app); end", "def use(*args, &block)\n @middleware << [args, block].freeze\n build_rack_app\n end", "def call(env)\n @app ||= build_rack_app\n @app.call(env)\n end", "def call(env)\n middleware_module = lookup_middleware_module\n app_wrapped_with_middleware = middleware_module.new(@app, *@args_for_middleware_new, &@block_for_middleware_new)\n app_wrapped_with_middleware.call(env) \n end", "def rack_app\n ctx = @context\n proc do |env|\n request_ctx = ctx.child\n request_ctx.templates = {}\n\n # If there are trailing slashes in path, don't dispatch\n if match = env['PATH_INFO'].match(/^(.+)(?<!\\$)\\/$/)\n\n # Remove trailing slash in the path and redirect\n loc = match[1]\n loc << \"?#{env['QUERY_STRING']}\" unless env['QUERY_STRING'].empty?\n [301, {'Location' => loc, 'Content-Type' => 'text/html; charset=utf-8'}, []]\n\n else\n\n # Dispatch controller chain for the current path\n request_ctx.env = env\n result = ::Tanuki::ControllerBehavior.dispatch(request_ctx, ctx.i18n ? ::Tanuki::I18n : ctx.root_page,\n Rack::Utils.unescape(env['PATH_INFO']).force_encoding('UTF-8'))\n\n # Handle dispatch result\n case result[:type]\n when :redirect then\n [302, {'Location' => result[:location], 'Content-Type' => 'text/html; charset=utf-8'}, []]\n when :page then\n [200, {'Content-Type' => 'text/html; charset=utf-8'}, build_body(result[:controller], request_ctx)]\n else\n [404, {'Content-Type' => 'text/html; charset=utf-8'}, build_body(result[:controller], request_ctx)]\n end\n\n end # if\n\n end\n end", "def call_rails\n @status, @headers, @response = @app.call(@env)\n end", "def call!(env)\n @env = env.dup\n status, @headers, response = @app.call(@env) \n if should_clean?\n @headers.delete('Content-Length')\n response = Rack::Response.new(\n tidy_markup(response.respond_to?(:body) ? response.body : response),\n status,\n @headers\n )\n response.finish\n response.to_a\n else\n [status, @headers, response]\n end\n end", "def call!(env)\n before_call(env)\n\n begin\n response = @app.call(env)\n rescue Exception => ex # rubocop:disable Lint/RescueException\n notify_airbrake(ex)\n raise ex\n end\n\n exception = framework_exception(env)\n notify_airbrake(exception) if exception\n\n response\n ensure\n # Clear routes for the next request.\n RequestStore.clear\n end", "def call(env)\n env.response = handle_response(env)\n @app.call(env)\n end", "def call env\n app.call env\n end", "def call env\n app.call env\n end", "def build(*args, &bk)\n builder = ::Rack::Builder.new\n builder.use ::Sinatra::ShowExceptions if show_exceptions?\n builder.use ::Rack::CommonLogger if logging?\n builder.use ::Rack::Head\n middleware.each { |c,a,b| builder.use(c, *a, &b) }\n maps.each { |p,b| builder.map(p, &b) }\n app = self\n builder.map \"/\" do\n run app.new!(*args, &bk)\n end\n builder\n end", "def rack_app\n return unless router\n\n @rack_app ||= router.to_rack_app\n end", "def app\n @app ||= Rack::Cascade.new([self, Rack::File.new(path)])\n end", "def mock_app(options)\n builder = Rack::Builder.new\n builder.use Rack::YandexMetrika, options\n builder.run controller\n @app = builder.to_app\n end", "def rack_app\n opts = { host: @host.host,\n scheme: @host.scheme,\n force_ssl: @host.scheme == 'https' }\n\n Lotus::Router.new(opts).tap do |router|\n router.get(INDEX_PATH, to: Coach::Handler.new(Routes::Index))\n router.get(GC_CALLBACK_PATH, to: build_gc_callback_handler)\n router.post(SLACK_MESSAGES_PATH, to: build_slack_messages_handler)\n router.get(ADD_CUSTOMER_PATH, to: build_add_customer_handler)\n router.get(ADD_CUSTOMER_SUCCESS_PATH, to: build_add_customer_success_handler)\n router.post(GC_WEBHOOKS_PATH, to: build_gc_webhooks_handler)\n end\n end", "def delegate\n @app.call(@env)\n end", "def call!(env)\n @env = env.dup\n status, @headers, response = @app.call(@env)\n if processable_request?\n @headers.delete('Content-Length')\n response = Rack::Response.new(\n nice_typography(response.respond_to?(:body) ? response.body : response.to_s),\n status,\n @headers\n )\n response.finish\n response.to_a\n else\n [status, @headers, response]\n end\n end", "def call(env) # :nodoc:\n return @app.call(env) if env['warden'] && env['warden'].manager != self\n\n env['warden'] = Proxy.new(env, self)\n result = catch(:warden) do\n env['warden'].on_request\n @app.call(env)\n end\n\n result ||= {}\n case result\n when Array\n handle_chain_result(result.first, result, env)\n when Hash\n process_unauthenticated(env, result)\n when Rack::Response\n handle_chain_result(result.status, result, env)\n end\n end", "def app\n @rack_app || fail(\"Missing @rack_app\")\n end", "def call(env)\n\t\t\t\tbegin\n\t\t\t\t\tresponse = @app.call(env)\n\t\t\t\trescue Exception => ex\n\t\t\t\t\tnotify_riemann(ex, env)\n\t\t\t\t\traise ex\n\t\t\t\tend\n\n\t\t\t\t# The internal framework middlewares store exceptions inside the Rack\n\t\t\t\t# env. See: https://goo.gl/Kd694n\n\t\t\t\texception = env['action_dispatch.exception'] || env['sinatra.error']\n\t\t\t\tnotify_riemann(exception, env) if exception\n\n\t\t\t\tresponse\n\t\t\tend", "def call(env)\n @app.call(env)\n end", "def call(env)\n log_request(env)\n @app.call(env)\n end", "def use(*args, &block)\n @middleware.insert(@position, [args, block])\n @app.send(:build_rack_app)\n @position += 1\n nil\n end", "def call(env)\n app.call(env)\n end", "def call(env)\n app.call(env)\n end", "def call(env)\n to_app.call(env)\n end", "def call(env)\n to_app.call(env)\n end", "def app\n @app || configure_middleware!\n end", "def run_app(app, env)\n setup_rack(app).call(env)\nend", "def rack_builder; end", "def setup_rack(app = nil)\n app ||= block if block_given?\n Rack::Builder.new do\n use SessionApp\n use Warden::Manager\n run app\n end\nend", "def call(env, options = {})\n req = Request.new(env)\n convert_params(env, req) if path_matches?(req)\n app.call(env)\n end", "def call(req)\n ThreadAccessor.clean_thread_context(logger: logger) { @app.call(req) }\n end", "def call(env)\n super\n perform_request env\n @app.call env\n end", "def call env #:nodoc:\n return @app.call(env) unless should_handle?(env)\n\n # Wrap request and response\n env['rack.input'].rewind\n env['rack-amf.request'] = RocketAMF::Envelope.new.populate_from_stream(env['rack.input'].read)\n env['rack-amf.response'] = RocketAMF::Envelope.new\n\n # Call handle on \"inheriting\" class\n handle env\n\n # Calculate length and return response\n response = env['rack-amf.response'].to_s\n [200, {\"Content-Type\" => APPLICATION_AMF, 'Content-Length' => response.length.to_s}, [response]]\n end", "def to_app\n files = Ramaze::Files.new(*public_roots)\n app = Current.new(Route.new(url_map), Rewrite.new(url_map))\n Rack::Cascade.new([files, app])\n end", "def call(env)\n @app.call(env)\n end", "def call(env)\n @env = env\n\n deserialize!\n @app.call(@env)\n serialize!\n end", "def application!\n res = get!(APPLICATION_PATH)\n build_application(res)\n end", "def build(app, &block)\n app ||= block\n raise \"MiddlewareStack#build requires an app\" unless app\n Skylight::Core::Probes::Middleware::Probe.add_instrumentation(app, default_name: \"Rack App\", category: \"rack.app\")\n build_without_sk(app)\n end", "def call(env)\n\n begin\n result = @app.call(env)\n rescue ::Exception => ex\n env['squash.notified'] = ::Squash::Ruby.notify(ex, squash_rack_data(env))\n raise ex\n end\n\n result\n end", "def build_app(app)\n options[:environment] = ENV['SHELF_ENV'] || options[:environment]\n\n middleware[options[:environment]].reverse.each do |middleware|\n middleware = middleware.call(self) if middleware.respond_to?(:call)\n\n next unless middleware\n\n klass, *args = middleware\n app = klass.new(app, *args)\n end\n\n app\n end", "def call env\n env[\"rack.logger\"] = logger\n trace_id = extract_trace_id(env)\n logger.add_trace_id trace_id\n\n begin\n @app.call env\n ensure\n logger.delete_trace_id\n end\n end", "def call(env)\n validate(env)\n @app.call(env)\n rescue ValidateError => ex\n unprocessable_response(ex)\n end", "def call(env)\n application.call(env)\n end", "def call(env)\n logger = env[\"rack.logger\"]\n\n began_at = Time.now\n\n log_request_begin(logger, env)\n status, header, body = @app.call(env)\n log_exception(logger, env['sinatra.error']) if env['sinatra.error']\n log_request_end(logger, status, header, began_at)\n\n return [status, header, body]\n rescue Exception => e\n log_exception(logger, e)\n raise\n end", "def app_or_dsl_block\n @app_to_run || Rack::Builder.new(&@dsl_block)\n end", "def call(env)\n # rubocop:disable Lint/RescueException\n begin\n response = @app.call(env)\n rescue Exception => ex\n notify_airbrake(ex, env)\n raise ex\n end\n # rubocop:enable Lint/RescueException\n\n exception = framework_exception(env)\n notify_airbrake(exception, env) if exception\n\n response\n end", "def build_rack_app\n super if @build_app\n end", "def call!(env)\n @default_options.each { |k,v| env[k] ||= v }\n @env = env\n \n if (@request = Request.new(@env.dup.freeze)).for_sprockets?\n Response.new(@env.dup.freeze, @request.source.to_js).to_rack\n else\n @app.call(env)\n end\n end", "def call(env)\n return @app.call(env) unless self.class.instrumented?\n\n method = env[\"REQUEST_METHOD\"]\n\n tags = {\n :component => \"rack\",\n :\"span.kind\" => \"server\",\n :\"http.method\" => method,\n :\"http.url\" => env[\"REQUEST_URI\"]\n }\n\n scope = OpenTracing.global_tracer.start_active_span(method, :tags => tags)\n span = scope&.span\n\n return @app.call(env) if span.nil?\n\n env[\"rack.span\"] = span\n\n @app.call(env).tap do |status_code, _headers, _body|\n span.set_tag(\"http.status_code\", status_code)\n rails_controller = env[\"action_controller.instance\"]\n route = \"#{env['REQUEST_METHOD']} #{rails_controller.controller_name.camelcase}.#{rails_controller.action_name}\" if rails_controller\n span.operation_name = route if route\n end\n rescue StandardError => e\n span&.set_tag(\"error\", true)\n span&.log_kv(:event => \"error\",\n :\"error.kind\" => e.class.to_s,\n :\"error.object\" => e,\n :message => e.message,\n :stack => e.backtrace.join(\"\\n\"))\n\n raise\n ensure\n scope&.close\n end", "def call env\n return @app.call(env) unless should_handle?(env)\n\n # Wrap request and response\n env['rack.input'].rewind\n env['rails3amf.request'] = RocketAMF::Envelope.new.populate_from_stream(env['rack.input'].read)\n env['rails3amf.response'] = RocketAMF::Envelope.new\n\n # Pass up the chain to the request processor, or whatever is layered in between\n result = @app.call(env)\n\n # Calculate length and return response\n if env['rails3amf.response'].constructed?\n @logger.info \"Sending back AMF\"\n begin\n response = env['rails3amf.response'].to_s\n rescue Exception => e\n File.open('systemstackerror.log', 'a') do |file|\n file.write(\"\\n\\n\\nError occurred at #{Time.now}\")\n file.write(\"\\n\\n#{e.inspect}\")\n file.write(\"\\n\\nAMF Version: #{env['rails3amf.response'].amf_version}\".force_encoding(\"UTF-8\"))\n file.write(\"\\n\\nHeaders: #{env['rails3amf.response'].headers}\".force_encoding(\"UTF-8\"))\n file.write(\"\\n\\nMessages: #{env['rails3amf.response'].messages}\".force_encoding(\"UTF-8\"))\n file.write(\"\\n\\nrequest: #{env['rails3amf.request'].inspect}\".force_encoding(\"UTF-8\"))\n file.write(\"\\n\\nresponse: #{env['rails3amf.response'].inspect}\".force_encoding(\"UTF-8\"))\n end\n\n raise e\n end\n\n @logger.info \"Responding\"\n return [200, {\"Content-Type\" => Mime::AMF.to_s, 'Content-Length' => response.length.to_s}, [response]]\n else\n return result\n end\n end", "def call(env)\n notify_request_handlers(env)\n request = env.dup\n app.call(env).on_complete do |env|\n notify_response_handlers(request, env)\n end\n end", "def app\n path = File.expand_path('../config.ru', File.dirname(__FILE__))\n @app ||= Rack::Builder.parse_file(path).first\n end", "def call(env)\n # Set the trace context (e.g. distributed tracing)\n if configuration[:distributed_tracing] && Tracing.active_trace.nil?\n original_trace = Tracing::Propagation::HTTP.extract(env)\n Tracing.continue_trace!(original_trace)\n end\n\n return @app.call(env) if Sinatra::Env.datadog_span(env)\n\n Tracing.trace(\n Ext::SPAN_REQUEST,\n service: configuration[:service_name],\n span_type: Tracing::Metadata::Ext::HTTP::TYPE_INBOUND\n ) do |span|\n begin\n # this is kept nil until we set a correct one (either in the route or with a fallback in the ensure below)\n # the nil signals that there's no good one yet and is also seen by profiler, when sampling the resource\n span.resource = nil\n\n Sinatra::Env.set_datadog_span(env, span)\n\n response = @app.call(env)\n ensure\n Contrib::Rack::HeaderTagging.tag_request_headers(span, env, configuration)\n\n span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)\n span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_REQUEST)\n\n request = ::Sinatra::Request.new(env)\n\n span.set_tag(Tracing::Metadata::Ext::HTTP::TAG_URL, request.path)\n span.set_tag(Tracing::Metadata::Ext::HTTP::TAG_METHOD, request.request_method)\n\n datadog_route = Sinatra::Env.route_path(env)\n\n span.set_tag(Ext::TAG_ROUTE_PATH, datadog_route) if datadog_route\n\n if request.script_name && !request.script_name.empty?\n span.set_tag(Ext::TAG_SCRIPT_NAME, request.script_name)\n end\n\n # If this app handled the request, then Contrib::Sinatra::Tracer OR Contrib::Sinatra::Base set the\n # resource; if no resource was set, let's use a fallback\n span.resource = env['REQUEST_METHOD'] if span.resource.nil?\n\n rack_request_span = env[Contrib::Rack::Ext::RACK_ENV_REQUEST_SPAN]\n\n # This propagates the Sinatra resource to the Rack span,\n # since the latter is unaware of what the resource might be\n # and would fallback to a generic resource name when unset\n rack_request_span.resource ||= span.resource if rack_request_span\n\n if response\n if (status = response[0])\n sinatra_response = ::Sinatra::Response.new([], status) # Build object to use status code helpers\n\n span.set_tag(Tracing::Metadata::Ext::HTTP::TAG_STATUS_CODE, sinatra_response.status)\n span.set_error(env['sinatra.error']) if sinatra_response.server_error?\n end\n\n if (headers = response[1])\n Contrib::Rack::HeaderTagging.tag_response_headers(span, headers, configuration)\n end\n end\n\n # Set analytics sample rate\n Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled?\n\n # Measure service stats\n Contrib::Analytics.set_measured(span)\n end\n end\n end", "def set_app!(options = {})\n old_app = self.app\n self.app = Rack::Builder.app do\n use Rack::Session::Cookie, secret: 'ultra_strong_secret'\n use OmniAuth::Strategies::Zendesk, options\n run lambda{|env| [404, {'env' => env}, [\"HELLO!\"]]}\n end\n if block_given?\n yield\n self.app = old_app\n end\n self.app\n end", "def call(env)\n @domain = Rack::Request.new(env).host\n app = domain_matches? ? app_or_dsl_block : @next_app\n app.call(env)\n end", "def call!(env)\n env['rack.logger'] = @logger\n\n status, headers, body = nil, nil, nil\n benchmark = Benchmark.measure do\n status, headers, body = @app.call(env)\n end\n log_error(env['deas.error'])\n env['deas.time_taken'] = RoundedTime.new(benchmark.real)\n\n [status, headers, body]\n end", "def as_rack_app\n #routes = Rack::Mount::RouteSet.new_without_optimizations do |set|\n routes = Rack::Mount::RouteSet.new do |set|\n @set = set\n self.add_routes\n add_route %r{^.*$}, :action => \"render_static\"\n end\n return routes\n end", "def call(env)\n res = nil\n\n call_next = catch(:next) do\n env[@mid.opts[:middleware_env_var]] = true\n res = @mid.call(env)\n false\n end\n\n if call_next\n res = @app.call(env)\n\n if modified_headers = env.delete('roda.response_headers')\n res[1] = modified_headers.merge(res[1])\n end\n end\n\n if handle_result = @mid.opts[:middleware_handle_result]\n handle_result.call(env, res)\n end\n\n res\n end", "def call(env)\n @app.call(env)\n rescue Rack::JsonSchema::Error => exception\n exception.to_rack_response\n end", "def call(*args)\n if request = rack_request(*args)\n rack_response base_call(request: request)\n else\n base_call(*args)\n end\n end", "def call(env)\n\t\tcase env['PATH_INFO']\n\t\twhen '/sync'\n\t\t\tself.sync\n\t\twhen '/async'\n\t\t\tself.async\n\t\tend\n\t\t\n\t\treturn @app.call(env)\n\tend", "def call(env)\n @req = Rack::Request.new(env)\n @res = Rack::Response.new\n handle_request\n @res.finish\n end", "def call(env)\n @req = Rack::Request.new(env)\n @res = Rack::Response.new\n handle_request\n @res.finish\n end", "def build_direct_endpoint\n app = Class.new(App)\n app.opts[:shrine_class] = self\n app.app\n end", "def build_direct_endpoint\n app = Class.new(App)\n app.opts[:shrine_class] = self\n app.app\n end", "def app\n eval \"Rack::Builder.new {( \" + File.read(File.dirname(__FILE__) + '/../config.ru') + \"\\n )}\"\nend", "def __call(env)\n if env['REQUEST_URI'] == '/healthcheck'.freeze\n [200, HEADER, PAYLOAD]\n else\n @app.call(env)\n end\n end", "def call(env)\n if env['HTTPS'] == 'on'\n env['SCRIPT_URI'].sub!(/^http:/, 'https:')\n env['SERVER_PORT'] = '443'\n\n # for reasons I don't understand, Passenger on whimsy doesn't\n # forward root directory requests directly, so as a workaround\n # these requests are rewritten and the following code maps\n # the requests back:\n if env['PATH_INFO'] == '/index.html'\n env['PATH_INFO'] = '/'\n env['SCRIPT_URI'] += '/'\n end\n end\n\n return @app.call(env)\n end", "def call(env)\n aroundware = new_aroundware(env)\n\n aroundware_resp = aroundware.pre_process\n\n hook_into_callback_chain(env, aroundware)\n\n downstream_resp = @app.call(env)\n\n # if downstream resp is final, pass it to the aroundware; it will invoke\n # the callback chain at its leisure. Our response is *always* async.\n if final_response?(downstream_resp)\n aroundware.call(downstream_resp)\n end\n return Goliath::Connection::AsyncResponse\n end", "def app\n @rack_app ||= Rack::Builder.parse_file('config.ru').first\nend", "def call(env)\n start = Time.now\n begin\n status, headers, response = @app.call(env)\n rescue Exception => ex\n status = 500\n exception = ex\n end\n stop = Time.now\n\n unless @client\n sender = @sender || Channel::AsynchronousSender.new\n sender.send_interval = @send_interval\n queue = Channel::AsynchronousQueue.new sender\n queue.max_queue_length = @buffer_size\n channel = Channel::TelemetryChannel.new nil, queue\n\n @client = TelemetryClient.new @instrumentation_key, channel\n end\n\n request = ::Rack::Request.new env\n id = rand(16**32).to_s(16)\n start_time = start.iso8601(7)\n duration = format_request_duration(stop - start)\n success = status.to_i < 400\n options = {\n :name => \"#{request.request_method} #{request.path}\",\n :http_method => request.request_method,\n :url => request.url\n }\n\n @client.track_request id, start_time, duration, status, success, options\n\n if exception\n @client.track_exception exception, handled_at: 'Unhandled'\n raise exception\n end\n\n [status, headers, response]\n end", "def call(env)\n app.call(env)\n rescue => error\n render_exception(error)\n end", "def use(middleware, *args)\n @app = middleware.new(@app, *args)\n end", "def app\n Rack::Lint.new(@app)\nend", "def app\n defined?(@app) ? @app : build_app\n end", "def initialize(app, response_builder = DEFAULT_BUILDER)\n @app = app\n @response_builder = response_builder\n end", "def call(env)\n status, headers, response = @app.call(env)\n\n # filter by route so that we don't have any unexpected behaviour\n if env[\"PATH_INFO\"] != \"/\"\n # don't modify response\n return [status, headers, [response.body.to_s]]\n end\n\n # modify response\n new_response = self.class.addScript(response.body.to_s)\n\n # also must reset the Content-Length header if changing body\n headers['Content-Length'] = new_response.length.to_s\n [status, headers, [new_response]]\n end", "def call(env)\n builder.call(env)\n end", "def app\n # Load the application defined in config.ru\n Rack::Builder.parse_file('config.ru').first\n end", "def set_app!(tent_options = {})\n old_app = self.app\n self.app = Rack::Builder.app do\n use OmniAuth::Strategies::Tent, tent_options\n run lambda{|env| [404, {'env' => env}, [\"HELLO!\"]]}\n end\n if block_given?\n yield\n self.app = old_app\n end\n self.app\n end", "def call(env)\n if env[\"PATH_INFO\"] =~ @config[:endpoint_path]\n begin\n req = Rack::Request.new(env)\n # find service\n service = KingSoa.find(req.params[\"name\"])\n # TODO rescue service class not found\n raise \"The service: #{req.params[\"name\"]} could not be found\" unless service\n # authenticate\n authenticated?(service, req.params[\"auth\"])\n # perform method with decoded params\n result = service.perform(*service.decode( req.params[\"args\"] ))\n # encode result\n encoded_result = service.encode({\"result\" => result})\n # and return\n [\n 200,\n {'Content-Type' => 'application/json', 'Content-Length' => \"#{encoded_result.length}\"},\n [encoded_result]\n ]\n\n rescue Exception => e\n if service\n encoded_error = service.encode({\"error\" => e})\n [500, {'Content-Type' => 'application/json', 'Content-Length' => \"#{encoded_error.length}\"}, [encoded_error]]\n else\n encoded_error = {\"error\" => \"An error occurred => #{e.message}\"}.to_json\n [500, {'Content-Type' => \"application/json\", 'Content-Length' => \"#{encoded_error.length}\"}, [encoded_error]]\n end\n end\n else\n @app.call(env)\n end\n end", "def call(env)\n @middleware.call(env)\n end", "def app\n Rack::Lint.new(Verge::Server::Base.new)\n end", "def new_sixjo_rack_app (next_app, options={})\n\n App.new(next_app, @routes, @helpers, @configures, options)\n end", "def _call(env)\n Jsus.logger.buffer.clear\n path = Utils.unescape(env[\"PATH_INFO\"])\n return @app.call(env) unless handled_by_jsus?(path)\n path.sub!(path_prefix_regex, \"\")\n components = path.split(\"/\")\n return @app.call(env) unless components.size >= 2\n\n request_options[:path] = path\n if components[0] == \"require\"\n generate_requires(components[1])\n elsif components[0] == \"compressed\"\n request_options[:compress] = true\n generate_requires(components[1])\n elsif components[0] == \"include\"\n generate_includes(components[1])\n else\n not_found!\n end\n end", "def _call(env)\n start = Time.now\n @status, @headers, @response = @app.call(env)\n duration = Time.now - start\n\n inject_headers(duration) if (defined? Rails && Rails.env.development?) || env['RACK_ENV'] == 'development'\n \n [@status, @headers, self]\n end", "def rack_standard(env)\n @req = Rack::Request.new(env)\n # puts \"here in standard rack handler\"\n @res = Rack::Response.new\n @res.write(\"Hey from a standard rack app\")\n @res.finish\n end", "def app\n # Load the application defined in config.ru\n Rack::Builder.parse_file('config.ru').first\nend", "def app\n # Load the application defined in config.ru\n Rack::Builder.parse_file('config.ru').first\nend", "def app\n # Load the application defined in config.ru\n Rack::Builder.parse_file(\"config.ru\").first\nend", "def call(env)\n env = Rack::Utils::HeaderHash.new(env)\n\n if transform_request?(env)\n env[ENV_PAYLOAD_KEY] = Oj.load(env[ENV_RACK_INPUT_KEY])\n end\n\n status, headers, body = @app.call(env)\n headers = Rack::Utils::HeaderHash.new(headers)\n\n if transform_response?(headers, body)\n body = Oj.dump(body) unless body.is_a?(String)\n headers[CONTENT_LENGTH_KEY] = body.length.to_s\n body = [body] unless body.respond_to?(:each)\n end\n\n [status, headers, body]\n end", "def call(env)\r\n env['HTTP_ACCEPT'] = 'application/json'\r\n @app.call env\r\n end", "def call(message)\n # Assign local variables to the proper apps, etc for readability.\n app = @app\n success_channel = @success_channel\n error_channel = @error_channel\n intake_name = @intake_name\n # Enqueue the proc to be run in by the deferred thread pool.\n @evm.defer(proc do\n # Create the base environment that is understood by the Rackish apps.\n env = {}\n env[MESSAGE_TYPE_KEY] = message.message_type.to_s if(\n message.respond_to? :message_type)\n env[MESSAGE_KEY] = message\n env[INTAKE_KEY] = intake_name\n # Actually run the Rackish app, protected by a rescue block.\n # Push the results to their respective channels when finished.\n begin\n results = app.call env\n success_channel.push(results) if success_channel\n rescue => e\n # It was an error, so we have to create a Rackish response array.\n # We push a SERVER_ERROR status along with an enhanced\n # headers section: the exception and original message.\n error_channel.push([\n SERVER_ERROR,\n env.merge({ X_EXCEPTION => e}),\n ['']]) if error_channel\n end\n end)\n end", "def get_rack_app(env)\n raise 'No Routes!' unless @route_obj\n\n @route_obj.check_url(\n request_url(env['PATH_INFO']),\n env['REQUEST_METHOD'],\n request_query_params(env['QUERY_STRING'])\n )\n end" ]
[ "0.75081575", "0.7201688", "0.7051585", "0.68423927", "0.6821686", "0.6709449", "0.6691695", "0.6642308", "0.664097", "0.6609931", "0.6581618", "0.6562447", "0.64991105", "0.64991105", "0.6495539", "0.6442085", "0.6414543", "0.64062184", "0.6403297", "0.63671625", "0.63623613", "0.6362164", "0.63615334", "0.63455623", "0.6285635", "0.62793696", "0.62573767", "0.6257075", "0.6257075", "0.6250029", "0.6250029", "0.6220633", "0.6188742", "0.61627245", "0.61603606", "0.6160297", "0.6159358", "0.6159352", "0.61568755", "0.6152477", "0.6141319", "0.6122082", "0.6100148", "0.6094508", "0.60606086", "0.60192126", "0.6014518", "0.6007637", "0.5991522", "0.59868634", "0.59784913", "0.59719217", "0.5965283", "0.5959068", "0.5940731", "0.5910963", "0.5904793", "0.590469", "0.5902539", "0.5883664", "0.5878179", "0.58759516", "0.5871124", "0.5863354", "0.5829544", "0.5819534", "0.5802681", "0.58020383", "0.57706416", "0.57646275", "0.57646275", "0.573955", "0.57292813", "0.5723435", "0.5718046", "0.5695513", "0.56924003", "0.5690716", "0.56904906", "0.56803674", "0.56801134", "0.5674548", "0.5662307", "0.56592995", "0.56510925", "0.5640822", "0.563591", "0.56323117", "0.5619451", "0.56113803", "0.55916184", "0.55890596", "0.5577879", "0.55770737", "0.55770737", "0.5571894", "0.55702835", "0.556937", "0.5562114", "0.55543983" ]
0.5639332
86
ENV Keys :http_method a symbolized request HTTP method (:get, :post) :body the request body that will eventually be converted to a string. :url URI instance for the current request. :status HTTP response status code :request_headers hash of HTTP Headers to be sent to the server :response_headers Hash of HTTP headers from the server :parallel_manager sent if the connection is in parallel mode :request Hash of options for configuring the request. :timeout open/read timeout Integer in seconds :open_timeout read timeout Integer in seconds :proxy Hash of proxy options :uri Proxy Server URI :user Proxy server username :password Proxy server password :ssl Hash of options for configuring SSL requests.
def build_env(connection, request) exclusive_url = connection.build_exclusive_url( request.path, request.params, request.options.params_encoder ) Env.new(request.http_method, request.body, exclusive_url, request.options, request.headers, connection.ssl, connection.parallel_manager) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(host, port = 80, context = {}, ssl = nil, ssl_version = nil, proxies = nil, username = '', password = '')\n self.hostname = host\n self.port = port.to_i\n self.context = context\n self.ssl = ssl\n self.ssl_version = ssl_version\n self.proxies = proxies\n self.username = username\n self.password = password\n\n # Take ClientRequest's defaults, but override with our own\n self.config = Http::ClientRequest::DefaultConfig.merge({\n 'read_max_data' => (1024*1024*1),\n 'vhost' => self.hostname,\n })\n\n # XXX: This info should all be controlled by ClientRequest\n self.config_types = {\n 'uri_encode_mode' => ['hex-normal', 'hex-all', 'hex-random', 'hex-noslashes', 'u-normal', 'u-random', 'u-all'],\n 'uri_encode_count' => 'integer',\n 'uri_full_url' => 'bool',\n 'pad_method_uri_count' => 'integer',\n 'pad_uri_version_count' => 'integer',\n 'pad_method_uri_type' => ['space', 'tab', 'apache'],\n 'pad_uri_version_type' => ['space', 'tab', 'apache'],\n 'method_random_valid' => 'bool',\n 'method_random_invalid' => 'bool',\n 'method_random_case' => 'bool',\n 'version_random_valid' => 'bool',\n 'version_random_invalid' => 'bool',\n 'uri_dir_self_reference' => 'bool',\n 'uri_dir_fake_relative' => 'bool',\n 'uri_use_backslashes' => 'bool',\n 'pad_fake_headers' => 'bool',\n 'pad_fake_headers_count' => 'integer',\n 'pad_get_params' => 'bool',\n 'pad_get_params_count' => 'integer',\n 'pad_post_params' => 'bool',\n 'pad_post_params_count' => 'integer',\n 'uri_fake_end' => 'bool',\n 'uri_fake_params_start' => 'bool',\n 'header_folding' => 'bool',\n 'chunked_size' => 'integer',\n 'partial' => 'bool'\n }\n\n\n end", "def request_setup request_context\n http_method = case request_context[:method]\n when :get\n Net::HTTP::Get\n when :post\n Net::HTTP::Post\n when :put\n Net::HTTP::Put\n when :delete\n Net::HTTP::Delete\n else\n raise \"Only :get, :post and :delete http method types are allowed.\"\n end\n headers = request_context[:headers] || {}\n setup = http_method.new request_context[:uri].request_uri\n setup.initialize_http_header headers\n setup.basic_auth(request_context[:uri].user, request_context[:uri].password) if request_context[:uri].user && request_context[:uri].password\n setup\n end", "def http_request(action, data, method_type = 'POST', binary_key = nil)\n\n uri = \"#{@api_uri}/#{action}\"\n if method_type != \"POST\" && (!method_type.is_a? String)\n uri += \"?\" + data.map{ |key, value| \"#{CGI::escape(key.to_s)}=#{CGI::escape(value.to_s)}\" }.join(\"&\")\n end\n\n req = nil\n\n _uri = URI.parse(uri)\n\n headers = {\n \"Content-Type\": \"text/json\",\n \"Api-Key\":\"#{@api_key}\"\n }\n\n if method_type == 'POST'\n req = set_up_post_request(\n _uri, data, headers, binary_key\n )\n\n else\n request_uri = \"#{_uri.path}?#{_uri.query}\"\n if method_type == 'DELETE'\n req = Net::HTTP::Delete.new(request_uri, headers)\n else\n req = Net::HTTP::Get.new(request_uri, headers)\n end\n end\n\n begin\n http = Net::HTTP::Proxy(@proxy_host, @proxy_port).new(_uri.host, _uri.port)\n\n if _uri.scheme == 'https'\n http.ssl_version = :TLSv1\n http.use_ssl = true\n http.set_debug_output $stderr\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @verify_ssl != true # some openSSL client doesn't work without doing this\n http.ssl_timeout = @opts[:http_ssl_timeout] || 5\n end\n http.open_timeout = @opts[:http_open_timeout] || 5\n http.read_timeout = @opts[:http_read_timeout] || 10\n http.close_on_empty_response = @opts[:http_close_on_empty_response] || true\n\n\n response = http.start do\n http.request(req)\n end\n\n rescue Timeout::Error, Errno::ETIMEDOUT => e\n raise UnavailableError, \"Timed out: #{_uri}\"\n rescue => e\n raise ClientError, \"Unable to open stream to #{_uri}: #{e.message}\"\n end\n\n response.body || raise(ClientError, \"No response received from stream: #{_uri}\")\n end", "def create_http_request(http_method,path,*arguments)\n http_method=http_method.to_sym\n if [:post,:put].include?(http_method)\n data=arguments.shift\n end\n headers=(arguments.first.is_a?(Hash) ? arguments.shift : {})\n case http_method\n when :post\n request=Net::HTTP::Post.new(path,headers)\n request[\"Content-Length\"]=0 # Default to 0\n when :put\n request=Net::HTTP::Put.new(path,headers)\n request[\"Content-Length\"]=0 # Default to 0\n when :get\n request=Net::HTTP::Get.new(path,headers)\n when :delete\n request=Net::HTTP::Delete.new(path,headers)\n when :head\n request=Net::HTTP::Head.new(path,headers)\n else\n raise ArgumentError, \"Don't know how to handle http_method: :#{http_method.to_s}\"\n end\n if data.is_a?(Hash)\n request.set_form_data(data)\n elsif data\n request.body=data.to_s\n request[\"Content-Length\"]=request.body.length\n end\n request\n 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 build_request(method, path, body, request_options)\n request = {}\n request[:method] = method.downcase\n request[:path] = build_uri_path(path, request_options.params)\n request[:body] = build_body(body, request_options, method)\n request[:headers] = generate_headers(request_options)\n request[:timeout] = request_options.timeout\n request[:connect_timeout] = request_options.connect_timeout\n request\n end", "def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n # prepare request\n req = HTTParty::Request.new http_method, path, req_options\n req.options[:timeout] = CityGrid.custom_timeout if req.options && CityGrid.custom_timeout_set?\n\n # Sanitized request for logs\n safe_req_options = strip_unsafe_params(http_method, req_options)\n req_to_output = HTTParty::Request.new http_method, path, safe_req_options\n req_for_airbrake = { :method => http_method, :path => path, :options => safe_req_options }\n\n begin\n response = req.perform\n rescue => ex \n if defined?(Rails.logger)\n Rails.logger.error safe_req_options\n Rails.logger.error req_to_output\n Rails.logger.error req_for_airbrake\n Rails.logger.error ex\n end\n raise CityGridExceptions::RequestError.new req_for_airbrake, nil, ex.message, req_to_output.to_curl\n ensure\n if CityGrid.print_curls? \n if defined?(Rails.logger)\n Rails.logger.info req_to_output.to_curl\n puts req_to_output.to_curl\n else\n puts req_to_output.to_curl\n end\n end\n end\n\n response_status = parse_response_status response\n \n begin \n # catch unparsable responses (html etc)\n if !response.parsed_response.is_a?(Hash)\n #pp \"[gem] the response was unparsable (response was not a hash)\"\n raise CityGridExceptions::ResponseParseError.new req_for_airbrake, response, \"the response was unparsable (response was not a hash)\", req_to_output.to_curl\n else\n # Parse and handle new response codes \n if !response_status.nil? && response_status[\"code\"] != \"SUCCESS\" && response_status[\"code\"] != 200\n raise CityGridExceptions.appropriate_error(response_status[\"code\"]).new req_for_airbrake, response, response_status[\"message\"].to_s, req_to_output.to_curl\n else\n return CityGrid::API::Response.new response\n end\n end\n rescue => ex\n pp \"API ERROR: #{ex}\"\n raise ex if CityGrid.raise_errors?\n end\n end", "def create_http_request(http_method, path, *arguments)\n http_method = http_method.to_sym\n\n if [:post, :put, :patch].include?(http_method)\n data = arguments.shift\n end\n\n # if the base site contains a path, add it now\n uri = URI.parse(site)\n path = uri.path + path if uri.path && uri.path != '/'\n\n headers = arguments.first.is_a?(Hash) ? arguments.shift : {}\n\n case http_method\n when :post\n request = Net::HTTP::Post.new(path,headers)\n request[\"Content-Length\"] = '0' # Default to 0\n when :put\n request = Net::HTTP::Put.new(path,headers)\n request[\"Content-Length\"] = '0' # Default to 0\n when :patch\n request = Net::HTTP::Patch.new(path,headers)\n request[\"Content-Length\"] = '0' # Default to 0\n when :get\n request = Net::HTTP::Get.new(path,headers)\n when :delete\n request = Net::HTTP::Delete.new(path,headers)\n when :head\n request = Net::HTTP::Head.new(path,headers)\n else\n raise ArgumentError, \"Don't know how to handle http_method: :#{http_method.to_s}\"\n end\n\n if data.is_a?(Hash)\n request.body = OAuth::Helper.normalize(data)\n request.content_type = 'application/x-www-form-urlencoded'\n elsif data\n if data.respond_to?(:read)\n request.body_stream = data\n if data.respond_to?(:length)\n request[\"Content-Length\"] = data.length.to_s\n elsif data.respond_to?(:stat) && data.stat.respond_to?(:size)\n request[\"Content-Length\"] = data.stat.size.to_s\n else\n raise ArgumentError, \"Don't know how to send a body_stream that doesn't respond to .length or .stat.size\"\n end\n else\n request.body = data.to_s\n request[\"Content-Length\"] = request.body.length.to_s\n end\n end\n\n request\n end", "def http_options; end", "def build_request\n\n uri = URI.parse(@endpoint)\n # add uri\n params = [uri.host, uri.port]\n # add proxy\n params += @proxy.values_at(:host, :port, :user, :pass) unless @proxy.empty?\n\n @http = Net::HTTP.new(*params)\n # add ssl\n if @endpoint.start_with?('https')\n @http.use_ssl = true\n @http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n end\n\n net_http = Kernel.const_get('Net::HTTP::' + @request_method[:method].capitalize)\n @request = add_request_headers(net_http.new(uri.request_uri))\n\n end", "def http_post_request(req_body)\n\t\t#New http request (uri library deals with port and host on its own when parsing the url)\n\t\thttp = Net::HTTP.new(@uri.host, @uri.port)\n\t\t#Original api url get does not need SSL (bad solution but any other way would not seem to work properly)\n\t\tif caller[1][/`.*'/].nil? or not (caller[1][/`.*'/][1..-2] == \"initialize\")\n\t\t\t#Https security stuff (don't need security when getting initial api url)\n\t\t\thttp.use_ssl = true\n\t\t\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\t\tend\n\t\t#Post request using uri\n\t\trequest = Net::HTTP::Post.new(@uri.request_uri)\n\t\t#Sets request to use basic authentication using the given username and api_key\n\t\trequest.basic_auth(@username, @api_key)\n\t\t#Sets request to use json content type\n\t\trequest.content_type = \"application/json\"\n\t\t#Sets request body to json file passed\n\t\trequest.body = req_body\n\t\t#Executes setup request and returns body\n\t\thttp.request(request).body\n\tend", "def run_request(method, url, body, headers); end", "def http_request_options(env)\n opts = {}\n if [:put, :post].include? @request[:method]\n opts[:body] = @request[:body] || extract_request_body(env)\n end\n opts\n end", "def restclient_option_keys\n [:method, :url, :payload, :headers, :timeout, :open_timeout,\n :verify_ssl, :ssl_client_cert, :ssl_client_key, :ssl_ca_file]\n end", "def build_request(http_method, path, opts = {})\n url = build_request_url(path)\n http_method = http_method.to_sym.downcase\n\n header_params = @default_headers.merge(opts[:header_params] || {})\n query_params = opts[:query_params] || {}\n form_params = opts[:form_params] || {}\n\n\n # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)\n _verify_ssl_host = @config.verify_ssl_host ? 2 : 0\n\n req_opts = {\n :method => http_method,\n :headers => header_params,\n :params => query_params,\n :params_encoding => @config.params_encoding,\n :timeout => @config.timeout,\n :ssl_verifypeer => @config.verify_ssl,\n :ssl_verifyhost => _verify_ssl_host,\n :sslcert => @config.cert_file,\n :sslkey => @config.key_file,\n :verbose => @config.debugging,\n :proxy => @config.proxy\n }\n\n # set custom cert, if provided\n req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert\n\n if [:post, :patch, :put, :delete].include?(http_method)\n req_body = build_request_body(header_params, form_params, opts[:body])\n req_opts.update :body => req_body\n if @config.debugging\n @config.logger.debug \"HTTP request body param ~BEGIN~\\n#{req_body}\\n~END~\\n\"\n end\n end\n\n request = Typhoeus::Request.new(url, req_opts)\n download_file(request) if opts[:return_type] == 'File'\n request\n end", "def http_call( opts )\n # [review] - Don't use DEBUG inside Remote class but pull from calling method's class?\n # [review] - Not sure if this is the best/proper way to do things but it works...\n\n # Identify method entry\n debug_print \"#{ self.class } : #{ __method__ }\\n\"\n\n # Merge default options with those passed in by user to form complete opt list\n opts = HTTP_opts.merge(opts)\n\n\n # Check URL in hash and get URI from it, then set up HTTP connection\n if opts[:url] =~ /^#{URI::regexp}$/\n _uri = URI(opts[:url])\n else\n debug_print \"No URL specified in input opts, exiting HTTP call\\n\"\n return false\n end\n\n _http = Net::HTTP.new(_uri.host, _uri.port)\n\n # Print out verbose HTTP request if :verbose is set\n # For hardcore debugging when shit really doesn't work\n _http.set_debug_output $stderr if opts[:verbose] == true\n\n # If SSL is set in hash, set HTTP connection to use SSL\n _http.use_ssl = true if opts[:ssl] == true\n\n # Create request based on HTTP method\n # [review] - Not sure if to fail with no method or default to GET?\n case opts[:method].upcase\n when \"GET\"\n _req = Net::HTTP::Get.new(_uri.request_uri)\n\n when \"POST\"\n _req = Net::HTTP::Post.new(_uri.request_uri)\n\n else\n debug_print \"No method specified, cannot make HTTP request\\n\"\n return false\n end\n\n # Check for basic authentication key in hash\n if opts[:basic_auth].size == 2\n _req.basic_auth(opts[:basic_auth][0], opts[:basic_auth][1])\n end\n\n # Check for Authentication token key in hash to be used in header\n # I think this is pretty universal, but specifically works for GitHub\n # This is standard for OAuth I think...\n if opts[:auth]\n _req[\"Authorization\"] = \"token #{ opts[:auth] }\"\n end\n\n # But sometimes we need we need other headers\n # Set specific header (GitLab requires PRIVATE_TOKEN)\n opts[:headers].each do |header|\n _req[\"#{ header[:field] }\"] = header[:value]\n end\n\n\n # [review] - Add :data_format to use set_form_data vs json body?\n # For now, use Hash or Array, this is to differentiate between\n # putting post data in body vs putting it in the form\n\n # If a POST method, :data is present, and is a Hash, fill request body with data\n if opts[:method].upcase == \"POST\" && opts[:data] && opts[:data].is_a?(Hash)\n _req.body = opts[:data].to_json\n end\n\n # If a POST method, :data is present, and is an Array, use set_form_data\n if opts[:method].upcase == \"POST\" && opts[:data] && opts[:data].is_a?(Array)\n _req.set_form_data(opts[:data][0])\n end\n\n # Make HTTP request\n _resp = _http.request(_req)\n\n # Debug prints for status and message\n debug_print \"HTTP Response Code: #{ _resp.code }\\n\"\n debug_print \"HTTP Response Msg: #{ _resp.message }\\n\"\n\n # [fix] - Not sure if 401 is the only code that gives nonparseable body?\n # Figure out what other response codes are bad news for JSON.parse\n _json = _resp.code == \"401\" ? Hash.new : JSON.parse(_resp.body)\n debug_print \"JSON: \\n #{ _json }\\n\"\n\n # [review] - Returning hash of json + response the right thing to do?\n # return {:json => _json, :resp => _resp}\n return _json, _resp\n end", "def _request(url, type, key)\n url = URI(url)\n type ||= :GET\n req_path = \"#{url.path}?#{url.query}\"\n\n if type == :GET\n req = Net::HTTP::Get.new(req_path)\n elsif type == :POST\n req = Net::HTTP::Post.new(req_path)\n end\n\n req.add_field('X-Vermillion-Key', key)\n req.add_field('Accept', 'application/json')\n req.add_field('Cache-Control', 'no-cache')\n req.add_field('From', @config.get(:user))\n req.add_field('User-Agent', 'Vermillion Client 1.0')\n\n res = Net::HTTP.new(url.host, url.port).start do |http|\n http.request(req)\n end\n\n res\n end", "def build_request(req, http_method, path, opts = {})\n opts[:query_params].each_key do |key|\n if opts[:query_params][key].kind_of?(Array)\n opts[:query_params][key] = opts[:query_params][key].join[\",\"]\n end\n end\n if @config.http_request_timeout > 0\n req.options.timeout = @config.http_request_timeout\n end\n req.url path.sub(/^\\/+/, '')\n req.headers = opts[:header_params]\n req.params = opts[:query_params]\n req.body = build_request_body(req.headers, opts[:body], opts[:files])\n set_headers(req.headers)\n if @config.debugging\n @config.logger.debug \"HTTP request\\nMethod: #{req.method}\\nPath: #{req.path}\\nParams: #{req.params}\\nHeaders: #{req.headers}\\nBody: #{req.body}\\n\"\n end\n end", "def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n req = HTTParty::Request.new http_method, path, req_options\n\n begin\n response = req.perform\n rescue => ex\n raise RequestError.new req, ex\n end\n \n if defined?(Rails.logger)\n Rails.logger.info req.to_curl\n else\n puts req.to_curl\n end\n \n if !response.parsed_response.is_a?(Hash)\n raise ResponseParseError.new req, response\n elsif response[\"errors\"]\n raise ResponseError.new req, response[\"errors\"], response\n elsif response[\"message\"] && response[\"message\"] == \"Invalid Token or Expired\"\n raise InvalidAuthToken.new\n else\n return CityGrid::API::Response.new response\n end\n \n rescue => ex\n raise ex if CityGrid.raise_errors?\n end", "def execute_http_request (method, url, args)\n @http_request = method, url.clone, args.clone\n self.http_response = HTTParty.send method, url, args\n Log.debug \"#{@http_response.request.http_method.to_s.split('::').last.upcase} - URL: #{@http_response.request.last_uri}\"\n Log.debug 'HEADER:'\n Log.debug http_response.request.options[:headers]\n # Log.debug @http_response.request.options[:body] if @http_response.request.options[:body]\n Log.debug 'BODY:' if http_response\n Log.debug http_response if http_response\n http_response\n end", "def ident_http_request(method, uri_string, credentials=nil, headers={}, data=nil, limit = 3, open_timeout=15, read_timeout=15)\n\n response = nil\n begin\n\n # set user agent\n user_agent = \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36\"\n headers[\"User-Agent\"] = user_agent\n\n attempts=0\n max_attempts=limit\n found = false\n timeout = false\n\n uri = URI.parse uri_string\n\n # keep track of redirects\n response_urls = [\"#{uri}\"]\n\n unless uri\n _log error \"Unable to parse URI from: #{uri_string}\"\n return\n end\n\n until( found || attempts >= max_attempts)\n @task_result.logger.log \"Getting #{uri}, attempt #{attempts}\" if @task_result\n attempts+=1\n\n if $global_config\n if $global_config.config[\"http_proxy\"]\n proxy_config = $global_config.config[\"http_proxy\"]\n proxy_addr = $global_config.config[\"http_proxy\"][\"host\"]\n proxy_port = $global_config.config[\"http_proxy\"][\"port\"]\n proxy_user = $global_config.config[\"http_proxy\"][\"user\"]\n proxy_pass = $global_config.config[\"http_proxy\"][\"pass\"]\n end\n end\n\n # set options\n opts = {}\n if uri.instance_of? URI::HTTPS\n opts[:use_ssl] = true\n opts[:verify_mode] = OpenSSL::SSL::VERIFY_NONE\n end\n\n http = Net::HTTP.start(uri.host, uri.port, proxy_addr, proxy_port, opts)\n http.open_timeout = open_timeout\n http.read_timeout = read_timeout\n\n path = \"#{uri.path}\"\n path = \"/\" if path==\"\"\n\n # add in the query parameters\n if uri.query\n path += \"?#{uri.query}\"\n end\n\n ### ALLOW DIFFERENT VERBS HERE\n if method == :get\n request = Net::HTTP::Get.new(uri)\n elsif method == :post\n # see: https://coderwall.com/p/c-mu-a/http-posts-in-ruby\n request = Net::HTTP::Post.new(uri)\n request.body = data\n elsif method == :head\n request = Net::HTTP::Head.new(uri)\n elsif method == :propfind\n request = Net::HTTP::Propfind.new(uri.request_uri)\n request.body = \"Here's the body.\" # Set your body (data)\n request[\"Depth\"] = \"1\" # Set your headers: one header per line.\n elsif method == :options\n request = Net::HTTP::Options.new(uri.request_uri)\n elsif method == :trace\n request = Net::HTTP::Trace.new(uri.request_uri)\n request.body = \"blah blah\"\n end\n ### END VERBS\n\n # set the headers\n headers.each do |k,v|\n request[k] = v\n end\n\n # handle credentials\n if credentials\n request.basic_auth(credentials[:username],credentials[:password])\n end\n\n # USE THIS TO PRINT HTTP REQUEST\n #request.each_header{|h| _log_debug \"#{h}: #{request[h]}\" }\n # END USE THIS TO PRINT HTTP REQUEST\n\n # get the response\n response = http.request(request)\n\n if response.code==\"200\"\n break\n end\n\n if (response.header['location']!=nil)\n newuri=URI.parse(response.header['location'])\n if(newuri.relative?)\n newuri=URI.parse(\"#{uri}#{response.header['location']}\")\n end\n response_urls << ident_encode(newuri.to_s)\n uri=newuri\n\n else\n found=true #resp was 404, etc\n end #end if location\n end #until\n\n final_url = uri\n\n ### TODO - create a global $debug config option\n \n rescue ArgumentError => e\n #puts \"Unable to connect #{uri}: #{e}\"\n rescue Net::OpenTimeout => e\n #puts \"Unable to connect #{uri}: #{e}\"\n timeout = true\n rescue Net::ReadTimeout => e\n #puts \"Unable to connect #{uri}: #{e}\"\n timeout = true\n rescue Errno::ENETDOWN => e\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue Errno::ETIMEDOUT => e\n #puts \"Unable to connect #{uri}: #{e}\" \n timeout = true\n rescue Errno::EINVAL => e\n #puts \"Unable to connect #{uri}: #{e}\"\n rescue Errno::ENETUNREACH => e\n #puts \"Unable to connect #{uri}: #{e}\"\n rescue Errno::EHOSTUNREACH => e\n #puts \"Unable to connect #{uri}: #{e}\"\n rescue URI::InvalidURIError => e\n #\n # XXX - This is an issue. We should catch this and ensure it's not\n # due to an underscore / other acceptable character in the URI\n # http://stackoverflow.com/questions/5208851/is-there-a-workaround-to-open-urls-containing-underscores-in-ruby\n #\n #puts \"Unable to connect #{uri}: #{e}\"\n rescue OpenSSL::SSL::SSLError => e\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue Errno::ECONNREFUSED => e\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue Errno::ECONNRESET => e\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue Net::HTTPBadResponse => e\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue Zlib::BufError => e\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue Zlib::DataError => e # \"incorrect header check - may be specific to ruby 2.0\"\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue EOFError => e\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue SocketError => e\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue Encoding::InvalidByteSequenceError => e\n #puts \"Encoding issue #{uri}: #{e}\" \n rescue Encoding::UndefinedConversionError => e\n #puts \"Encoding issue #{uri}: #{e}\" \n end\n\n # generate our output\n out = {\n :timeout => timeout,\n :start_url => uri_string,\n :final_url => final_url.to_s,\n :request_type => :ruby,\n :request_method => method,\n :request_credentials => credentials,\n :request_headers => headers,\n :request_data => data,\n :request_attempts_limit => limit,\n :request_attempts_used => attempts,\n :request_user_agent => user_agent,\n :request_proxy => proxy_config,\n :response_urls => response_urls,\n :response_object => response\n }\n\n # verify we have a response before adding these\n if response\n out[:response_headers] = response.each_header.map{|x| ident_encode \"#{x}: #{response[x]}\" }\n out[:response_body] = ident_encode(response.body)\n end\n\n out\n end", "def build_request(http_method, path, opts = {})\n url = build_request_url(path)\n http_method = http_method.to_sym.downcase\n\n header_params = @default_headers.merge(opts[:header_params] || {})\n query_params = opts[:query_params] || {}\n form_params = opts[:form_params] || {}\n\n\n # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)\n _verify_ssl_host = @config.verify_ssl_host ? 2 : 0\n\n req_opts = {\n :method => http_method,\n :headers => header_params,\n :params => query_params,\n :params_encoding => @config.params_encoding,\n :timeout => @config.timeout,\n :ssl_verifypeer => @config.verify_ssl,\n :ssl_verifyhost => _verify_ssl_host,\n :sslcert => @config.cert_file,\n :sslkey => @config.key_file,\n :verbose => @config.debugging\n }\n\n # set custom cert, if provided\n req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert\n\n if [:post, :patch, :put, :delete].include?(http_method)\n req_body = build_request_body(header_params, form_params, opts[:body])\n req_opts.update :body => req_body\n if @config.debugging\n @config.logger.debug \"HTTP request body param ~BEGIN~\\n#{req_body}\\n~END~\\n\"\n end\n end\n\n request = Typhoeus::Request.new(url, req_opts)\n download_file(request) if opts[:return_type] == 'File'\n request\n end", "def request(method, path, options)\n conn = connection(options)\n conn.instance_variable_set(:@parallel_manager, options[:parallel_manager]) if options[:parallel_manager]\n #binding.pry\n response = conn.send(method) do |request|\n #path = formatted_path(path) unless options[:unformatted] # || default_request?\n params = get_params(options)\n case method\n when :get, :delete\n request.url(path, params)\n # binding.pry\n when :post, :put\n request.path = path\n #if options['fileData']\n # request.headers['Content-type'] = 'multipart/form-data'\n # request.body = options\n #else\n #request.headers['Content-Type'] = 'application/json; charset=utf-8'\n request.body = params unless params.empty?\n #end\n end\n if options[:parallel_manager]\n env = request.to_env(conn)\n conn.parallel_manager.responses[env[:url].to_s] = {}\n conn.parallel_manager.responses[env[:url].to_s]['env'] = env\n end\n end\n #\n #binding.pry\n options[:raw] ? response : response.body\n #binding.pry\n end", "def build_request(http_method, path, opts = {})\n url = build_request_url(path, opts)\n http_method = http_method.to_sym.downcase\n\n header_params = @default_headers.merge(opts[:header_params] || {})\n query_params = opts[:query_params] || {}\n form_params = opts[:form_params] || {}\n follow_location = opts[:follow_location] || true\n\n update_params_for_auth! header_params, query_params, opts[:auth_names]\n\n # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)\n _verify_ssl_host = @config.verify_ssl_host ? 2 : 0\n\n req_opts = {\n :method => http_method,\n :headers => header_params,\n :params => query_params,\n :params_encoding => @config.params_encoding,\n :timeout => @config.timeout,\n :ssl_verifypeer => @config.verify_ssl,\n :ssl_verifyhost => _verify_ssl_host,\n :sslcert => @config.cert_file,\n :sslkey => @config.key_file,\n :verbose => @config.debugging,\n :followlocation => follow_location\n }\n\n # set custom cert, if provided\n req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert\n\n if [:post, :patch, :put, :delete].include?(http_method)\n req_body = build_request_body(header_params, form_params, opts[:body])\n req_opts.update :body => req_body\n if @config.debugging\n @config.logger.debug \"HTTP request body param ~BEGIN~\\n#{req_body}\\n~END~\\n\"\n end\n end\n\n request = Typhoeus::Request.new(url, req_opts)\n download_file(request) if opts[:return_type] == 'File'\n request\n end", "def http_request\n @http_request ||= begin\n request = request_for_verb\n add_post_data(request)\n add_bearer_token(request)\n add_headers(request)\n request\n end\n end", "def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n # prepare request\n req = HTTParty::Request.new http_method, path, req_options\n\n # Sanitized request for logs\n safe_req_options = strip_unsafe_params(http_method, req_options)\n req_to_output = HTTParty::Request.new http_method, path, safe_req_options\n req_for_airbrake = { :method => http_method, :path => path, :options => safe_req_options }\n\n begin\n response = req.perform\n rescue => ex\n raise CityGridExceptions::RequestError.new req_for_airbrake, ex\n ensure\n if CityGrid.print_curls? \n if defined?(Rails.logger)\n Rails.logger.info req_to_output.to_curl\n else\n puts req_to_output.to_curl\n end\n end\n end\n\n \n begin \n # catch unparsable responses (html etc)\n if !response.parsed_response.is_a?(Hash)\n #pp \"[gem] the response was unparsable (response was not a hash)\"\n raise CityGridExceptions::ResponseParseError.new req_for_airbrake, response\n # catch responses not in new response format\n elsif response[\"errors\"]\n #pp \"[gem] An error in the old response format was caught. Raising a general response error...\"\n raise CityGridExceptions::ResponseError.new req_for_airbrake, response[\"errors\"], response\n\n # Parse and handle new response codes \n elsif (response[\"response\"] && response[\"response\"][\"code\"] != \"SUCCESS\") && \n (response[\"response\"] && response[\"response\"][\"code\"] != 200) && \n (response[\"response\"] && response[\"response\"][\"code\"] != 400) \n error_code = response[\"response\"][\"code\"]\n #pp \"[gem] The response was contained in the first level of the response hash. Below:\"\n #pp response\n #pp \"found error code: #{error_code}\"\n #pp \"****************************************************************************\"\n raise CityGridExceptions.appropriate_error(error_code).new req_for_airbrake, response, response[\"response\"][\"message\"].to_s #+ \" \" + CityGridExceptions.print_superclasses(error_code)\n # if the response is a nested hash/nested hash containing arrays\n elsif response[\"totalNumEntries\"] && response[\"response\"].nil?\n #pp \"[gem] now parsing a response with multiple entries: #{response}\"\n error_code = parse_multiple_responses(response)\n #pp \"the error code that came back is #{error_code}\"\n if error_code.nil? || error_code == []\n #pp \"[gem] passing over this for now\"\n return CityGrid::API::Response.new response # pass over for now\n elsif error_code[0] == \"SUCCESS\" || error_code[0] == 200 || error_code[0] == 400\n return CityGrid::API::Response.new response\n else \n #pp \"[gem] we found an error and it was #{error_code[1]}\"\n raise CityGridExceptions.appropriate_error(error_code[0]).new req_for_airbrake, response, error_code[1].to_s + \" \"# + CityGridExceptions.print_superclasses(error_code[0])\n end\n else\n return CityGrid::API::Response.new response\n end\n rescue => ex\n pp \"The gem threw an error: #{ex}\"\n raise ex if CityGrid.raise_errors?\n end\n end", "def build_request()\n @http = Net::HTTP.new(@uri.host, @uri.port)\n @http.use_ssl = true\n @http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n end", "def initialize\n @isRequest = nil\t# true, false and nil\n @httpVersion = 'HTTP/1.1'\n @bodyType = nil\n @bodyCharset = nil\n @bodySize = nil\n @bodyDate = nil\n @headerItem = []\n @chunked = false\n @responseStatusCode = nil\n @reasonPhrase = nil\n @requestMethod = nil\n @requestUri = nil\n @requestQueryUri = nil\n @requestViaProxy = false\n end", "def request(http_method, path, params = {})\n response = connection.send(http_method) do |request|\n case http_method\n when :get, :delete\n request.url(path, params)\n when :post, :put\n request.path = path\n request.body = params unless params.empty?\n end\n end\n\n response.body['response']\n end", "def build_request(http_method, path, opts = {})\n url = build_request_url(path, opts)\n header_params = @default_headers.merge(opts[:header_params] || {})\n query_params = opts[:query_params] || {}\n form_params = opts[:form_params] || {}\n\n update_params_for_auth! header_params, query_params, opts[:auth_names]\n\n # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)\n _verify_ssl_host = @config.verify_ssl_host ? 2 : 0\n\n req_opts = {\n :method => http_method,\n :headers => header_params,\n :query => transform_hash(query_params),\n :timeout => @config.timeout,\n :verify_peer => @config.verify_ssl,\n :verify => _verify_ssl_host,\n :verbose => @config.debugging,\n :http_proxyaddr => @config.http_proxyaddr,\n :http_proxyport => @config.http_proxyport,\n :http_proxyuser => @config.http_proxyuser,\n :http_proxypass => @config.http_proxypass\n }\n\n req_opts[:pem] = File.read(@config.cert_file) if @config.cert_file\n req_opts[:pem_password] = File.read(@config.key_file) if @config.key_file\n\n opts[:stream_body] = true if opts[:return_type] == 'File'\n\n # set custom cert, if provided\n req_opts[:ssl_ca_file] = File.read(@config.ssl_ca_cert) if @config.ssl_ca_cert\n\n if [\"POST\", \"PATCH\", \"PUT\", \"DELETE\"].include?(http_method.const_get(:METHOD))\n req_body = build_request_body(header_params, form_params, opts[:body])\n req_opts.update :body => req_body\n if @config.debugging\n @config.logger.debug \"HTTP request body param ~BEGIN~\\n#{req_body}\\n~END~\\n\"\n end\n end\n\n HTTParty::Request.new(http_method, url, req_opts)\n end", "def request(http_method, path, body = '', headers = {})\n puts \"#{http_method}: #{path} - [#{body}]\" if @http_debug\n @request_client.request(http_method, path, body, headers)\n end", "def request_params\n rid = create_uuid\n request_type = params[:request_type]\n request_url = params[:url]\n request_parameters = params[:request_parameters]\n request_headers = params[:request_headers]\n request_payload = params[:request_payload]\n username = params[:username]\n password = params[:password]\n private_request = params[:private_request]\n\n request = Faraday.new\n\n # If authentication is filled out, apply it.\n request.basic_auth(username, password) if username.present?\n\n # Be nice and send a descriptive user agent. Also handy for debugging and\n # tracking down potential problems.\n request.headers['User-Agent'] = 'ReHTTP/v1.0'\n\n # Split the additional headers out into the name and value and then apply\n # then to the request.\n request_headers.split(\"\\r\\n\").each do |header|\n header_components = header.split(':')\n request.headers[header_components[0]] = header_components[1]\n end\n\n # Ensure the parameters are available before trying to create a new hash\n # from them.\n if request_parameters.present?\n request_params = Hash[request_parameters.split(\"\\r\\n\").map {|params| params.split('=') }]\n else\n request_params = {}\n end\n\n case request_type\n when 'GET'\n response = request.get(request_url, request_params)\n when 'POST'\n response = request.post(request_url, request_payload)\n when 'PUT'\n response = request.put(request_url, request_params)\n when 'DELETE'\n response = request.delete request_url\n when 'OPTIONS'\n response = request.options request_url\n when 'HEAD'\n response = request.head request_url\n when 'PATCH'\n response = request.patch request_url\n end\n\n {\n rid: rid,\n request_type: request_type,\n url: request_url,\n private_request: private_request,\n request_data: {\n headers: request.headers,\n data: {}\n }.to_json,\n response_data: {\n headers: response.headers,\n body: response.body,\n status: response.status\n }.to_json\n }\n end", "def make_request(type, headers = nil, body = nil)\n request = \"#{type.to_s.upcase} #{@path} HTTP/1.0\\r\\n\"\n request << add_headers(headers) if headers\n request << \"\\r\\n\"\n request << body if body\n request\n end", "def request(method, path, body = nil)\n\t #Puppet.debug(\"REAQUEST URL #{method} #{@url} #{path} #{@connect_timeout} #{body}\")\n response = Excon.send(method, @url, :path => path, :headers => web_proxy_headers, :body => body, :connect_timeout => @connect_timeout)\n end", "def build_request(http_method, path, opts = {})\n url = build_request_url(path)\n http_method = http_method.to_sym.downcase\n\n header_params = @default_headers.merge(opts[:header_params] || {})\n query_params = opts[:query_params] || {}\n form_params = opts[:form_params] || {}\n\n update_params_for_auth! header_params, query_params, opts[:auth_names]\n\n # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)\n _verify_ssl_host = @config.verify_ssl_host ? 2 : 0\n\n req_opts = {\n :method => http_method,\n :headers => header_params,\n :params => query_params,\n :params_encoding => @config.params_encoding,\n :timeout => @config.timeout,\n :ssl_verifypeer => @config.verify_ssl,\n :ssl_verifyhost => _verify_ssl_host,\n :sslcert => @config.cert_file,\n :sslkey => @config.key_file,\n :verbose => @config.debugging\n }\n\n # set custom cert, if provided\n req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert\n\n if [:post, :patch, :put, :delete].include?(http_method)\n req_body = build_request_body(header_params, form_params, opts[:body])\n req_opts.update :body => req_body\n if @config.debugging\n @config.logger.debug \"HTTP request body param ~BEGIN~\\n#{req_body}\\n~END~\\n\"\n end\n end\n\n request = Typhoeus::Request.new(url, req_opts)\n download_file(request) if opts[:return_type] == 'File'\n request\n end", "def http; end", "def request(method, path, params, options)\n params = params.billyfy_keys!\n auth = {username: api_key, password: \"\"}\n case method.to_sym\n when :get\n response = HTTParty.get(endpoint + path, :query => params, :basic_auth => auth)\n when :post\n response = HTTParty.post(endpoint + path, :body => MultiJson.encode(params), :basic_auth => auth)\n when :delete\n response = HTTParty.delete(endpoint + path, :query => params, :basic_auth => auth)\n when :put\n response = HTTParty.put(endpoint + path, :body => MultiJson.encode(params), :basic_auth => auth)\n else\n end\n\n options[:raw] ? response : response.parsed_response.rubyify_keys!\n end", "def params\n {\n \"add-header\" => nil,\n \"burst-length\" => nil,\n \"client\" => nil,\n \"close-with-reset\" => nil,\n \"debug\" => nil,\n \"failure-status\" => nil,\n \"hog\" => nil,\n \"http-version\" => nil,\n \"max-connections\" => nil,\n \"max-piped-calls\" => nil,\n \"method\" => nil,\n \"no-host-hdr\" => nil,\n \"num-calls\" => nil,\n \"num-conns\" => nil,\n \"period\" => nil,\n \"port\" => nil,\n \"print-reply\" => nil,\n \"print-request\" => nil,\n \"rate\" => nil,\n \"recv-buffer\" => nil,\n \"retry-on-failure\" => nil,\n \"send-buffer\" => nil,\n \"server\" => nil,\n \"server-name\" => nil,\n \"session-cookies\" => nil,\n \"ssl\" => nil,\n \"ssl-ciphers\" => nil,\n \"ssl-no-reuse\" => nil,\n \"think-timeout\" => nil,\n \"timeout\" => nil,\n \"uri\" => nil,\n \"verbose\" => nil,\n \"version\" => nil,\n \"wlog\" => nil,\n \"wsess\" => nil,\n \"wsesslog\" => nil,\n \"wset\" => nil\n }\n end", "def request(method, uri, headers, body, opts)\n # Create the client\n client = Net::HTTP.new(uri.host, uri.port)\n\n # Use SSL if requesting a secure connection\n if uri.scheme == 'https'\n client.use_ssl = true\n client.verify_mode = OpenSSL::SSL::VERIFY_PEER\n client.ca_file = opts[:cacert] if opts[:cacert]\n client.cert = OpenSSL::X509::Certificate.new(File.read(opts[:cert])) if opts[:cert]\n client.key = OpenSSL::PKey::RSA.new(File.read(opts[:key])) if opts[:key]\n end\n\n # Build the request\n request = Net::HTTP.const_get(method).new(uri.request_uri, headers)\n\n # Build the query if there's data to send\n request.body = body if body\n\n # Send the request\n client.request(request)\n rescue StandardError => e\n raise TaskHelper::Error.new(\n \"Failed to connect to #{uri}: #{e.message}\",\n 'http_request/connect-error'\n )\n end", "def make_request(method, path, query, headers = {}, body = nil)\n full_path = @api_base_path + path\n\n request = ProxyClientUtils.build_request(method, full_path, query, headers, body)\n\n begin\n response = @connection.request(request)\n\n from_headers = ProxyClientUtils.normalize_headers(\n ProxyClientUtils.filter_response_headers(response.to_hash)\n )\n\n [response.code.to_i, from_headers, [response.body]]\n rescue Errno::ECONNREFUSED => e\n raise RemoteConnectionError.new(\"#{self.class.base_uri} - #{e.class}: #{e.message}\")\n end\n end", "def perform(uri, request, http_options)\n http = Net::HTTP.new(uri.host, uri.port, :ENV)\n # set http options to the net http object\n http_options.each { |key, value| http.send(\"#{key}=\", value) }\n\n # print debug information to the standard out\n http.set_debug_output($stdout) if @debug\n # perform\n http.start { |connection| connection.request(request) }\n end", "def build_request(action, url, headers, options = {})\n # If the Expect header isn't set uploads are really slow\n headers['Expect'] ||= ''\n\n Request.new.tap do |req|\n req.action = action\n req.headers = self.headers.merge headers\n req.automatic_content_encoding = options.fetch :automatic_content_encoding, self.automatic_content_encoding\n req.timeout = options.fetch :timeout, self.timeout\n req.connect_timeout = options.fetch :connect_timeout, self.connect_timeout\n req.dns_cache_timeout = options.fetch :dns_cache_timeout, self.dns_cache_timeout\n req.low_speed_time = options.fetch :low_speed_time, self.low_speed_time\n req.low_speed_limit = options.fetch :low_speed_limit, self.low_speed_limit\n req.force_ipv4 = options.fetch :force_ipv4, self.force_ipv4\n req.max_redirects = options.fetch :max_redirects, self.max_redirects\n req.username = options.fetch :username, self.username\n req.password = options.fetch :password, self.password\n req.proxy = options.fetch :proxy, self.proxy\n req.proxy_type = options.fetch :proxy_type, self.proxy_type\n req.auth_type = options.fetch :auth_type, self.auth_type\n req.insecure = options.fetch :insecure, self.insecure\n req.ssl_version = options.fetch :ssl_version, self.ssl_version\n req.http_version = options.fetch :http_version, self.http_version\n req.cacert = options.fetch :cacert, self.cacert\n req.ignore_content_length = options.fetch :ignore_content_length, self.ignore_content_length\n req.buffer_size = options.fetch :buffer_size, self.buffer_size\n req.download_byte_limit = options.fetch :download_byte_limit, self.download_byte_limit\n req.progress_callback = options.fetch :progress_callback, self.progress_callback\n req.multipart = options[:multipart]\n req.upload_data = options[:data]\n req.file_name = options[:file]\n\n base_url = self.base_url.to_s\n url = url.to_s\n raise ArgumentError, \"Empty URL\" if base_url.empty? && url.empty?\n uri = URI.parse(base_url.empty? ? url : File.join(base_url, url))\n query = uri.query.to_s.split('&')\n query += options[:query].is_a?(Hash) ? Util.build_query_pairs_from_hash(options[:query]) : options[:query].to_s.split('&')\n uri.query = query.join('&')\n uri.query = nil if uri.query.empty?\n url = uri.to_s\n req.url = url\n end\n end", "def http_request(verb, uri, options = {})\n opts = {\n :form_data => resource[:http_post_form_data],\n :body => resource[:http_request_body],\n :headers => resource[:http_request_headers],\n :content_type => resource[:http_request_content_type],\n :http_user => resource[:http_user],\n :http_pass => resource[:http_pass],\n }.merge(options)\n\n case verb.to_sym\n when :head\n req = Net::HTTP::Head.new(uri.request_uri)\n when :get\n req = Net::HTTP::Get.new(uri.request_uri)\n when :post\n req = Net::HTTP::Post.new(uri.request_uri)\n end\n (opts[:headers] || {}).each do |header, value|\n req[header] = value\n end\n req.body = opts[:body]\n req.content_type = opts[:content_type] || ''\n if not opts[:http_user].nil? or not opts[:http_pass].nil?\n req.basic_auth opts[:http_user], opts[:http_pass]\n end\n req.set_form_data(opts[:form_data] || {}) if verb.to_sym == :post\n req\n end", "def initialize text, client_ip=nil\n \n \n @client = client_ip ? client_ip : \"\"\n @complete_request = ''\n @verb = ''\n @resource = ''\n @http_version = [0,0]\n @extra_args = {}\n \n \n # if text is nil at this point, we will leave it at a stub request\n # for debugging purposes.\n return if text.nil?\n \n \n #\n # Separate and chomp each line into array.\n headlines = text.each_line(\"\\r\\n\").map{|line| line.chomp }.to_a\n \n #\n # Rip off the first line and store it as complete request\n requestLine = headlines.shift\n @complete_request = requestLine\n \n #\n # Split request line.\n requestComponents = requestLine.split(/ /) # split on single-space exactly.\n raise HTTPStandardError.new(400, self) unless requestComponents.count == 3 # Bad Request\n \n # We now know there are three parts to the request line.\n @verb, @resource, versionString = requestComponents\n raise HTTPStandardError.new(501, self) unless HTTPHandler::ImplementedVerbs.include?(@verb) # Not Implemented\n raise HTTPStandardError.new(400, self) unless @resource.length > 0 && @resource[0] == '/'\n \n @http_version = version_from versionString\n \n #\n # Having gotten the request, parse the additional information:\n headlines.each do |messageHeader|\n next if messageHeader.length == 0\n \n #\n # Split leading token from the rest.\n headParts = messageHeader.split(':', 2) # Limit split to 2 pcs. b/c rest may contain colons\n raise HTTPStandardError.new(400, self) unless headParts.count == 2\n \n #\n # We take all keys as lowercase, and disallow any key\n # which contains a Token Separator.\n fieldName, fieldValue = headParts\n fieldName.downcase! ; fieldValue.strip!\n TokenSeparators.each {|sep| raise HTTPStandardError 400 if fieldName.include?(sep) }\n \n #\n # Add to dictionary.\n if @extra_args[fieldName]\n # Field already specified; comma-append the new value:\n @extra_args[fieldName] = \"#{@extra_args[fieldName]},#{fieldValue}\"\n else\n @extra_args[fieldName] = fieldValue\n end\n end\n \n end", "def request_from_env(env)\n request = {}\n request['path'] = env['REQUEST_URI'].to_s\n request['method'] = env['REQUEST_METHOD']\n request['query'] = env['QUERY_STRING'].to_s\n request['Body'] = env['rack.input'].read\n\n env.each do |key, value|\n if key.match(/HTTP_(.+)/)\n request[$1.downcase.gsub('_','-')] ||= value\n end\n end\n request\n end", "def http_request\n req = VanillaRequest.new @http_method, @uri.request_uri, @headers\n\n if @oauth\n req['Authorization'] =\n SimpleOAuth::Header.new(@http_method, @uri, {}, self.oauth).to_s\n elsif @auth && @auth[:username]\n req.basic_auth @auth[:username], @auth[:password]\n end\n\n # Stream Multipart\n if Kronk::Multipart === @body\n req.body_stream = @body.to_io\n\n # Stream IO\n elsif @body.respond_to?(:read)\n req.body_stream = @body\n\n else\n req.body = @body\n end\n\n b = req.body || req.body_stream\n\n if b.respond_to?(:bytesize)\n req['Content-Length'] = b.bytesize.to_s\n elsif b.respond_to?(:size) && b.size\n req['Content-Length'] = b.size.to_s\n elsif b.nil?\n req['Content-Length'] = \"0\"\n end\n\n req['Transfer-Encoding'] = 'chunked' if !req['Content-Length']\n\n req\n end", "def request_over_http(options, http_method, endpoint)\n if http_method == :get\n api_call = endpoint + \"?\" + options.collect{|k,v| \"#{k}=#{CGI.escape(v.to_s)}\"}.join('&')\n URI.parse(api_call).read\n else\n Net::HTTP.post_form(URI.parse(endpoint), options).body\n end\n end", "def run\n\n action Colors.grey(\"REQUEST \") + Colors.light_blue(\"#{options[:method].upcase} #{url}\")\n Console.instance.indent\n # run the request\n options[:ssl_verifypeer] = false\n options[:followlocation] = true\n\n Injector.decorate(options)\n\n # convert all headers keys to strings to avoid having symbols like :\"header\" when\n # declaring headers with colons instead of arrows\n if options.key?(:headers)\n new_opts = {}\n options[:headers].map do |k, v|\n new_opts[k.to_s] = v\n end\n options[:headers] = new_opts\n end\n\n if options.key?(:headers) and options[:headers].key?('Content-Type')\n ctype = options[:headers]['Content-Type']\n if ctype.include?('application/json')\n # automatically encode json content\n options[:body] = JSON.generate(options[:body], quirks_mode: true)\n end\n end\n\n\n\n self.response = Typhoeus::Request.new(url, options).run\n\n self.req_response = RequestResponse.new.tap { |r|\n r.raw_body = response.body\n r.headers = response.headers\n r.code = response.code\n r.total_time = response.total_time\n\n if !r.headers.nil? && r.headers.key?('Content-Type') && r.headers['Content-Type'].include?('application/json')\n r.body = JSON.parse(response.body)\n else\n r.body = response.body\n end\n }\n\n # reset assertion counter\n self.assert_no = 1\n\n # evaluate response against expectations\n begin\n instance_eval(&expectations)\n rescue AssertionException\n error error_msg + \" at #{expectations.source_location}\"\n raise RequestException\n rescue StandardError => e\n error 'Exception ' + e.message\n info e.backtrace.inspect\n _debug_info\n error error_msg\n raise RequestException\n ensure\n Console.instance.unindent\n end\n\n req_response\n\n end", "def request(uri, method, cookies)\n #puts \"Current URI: #{uri}\"\n uri = URI(uri)\n http = nil\n if USE_PROXY\n \t http = Net::HTTP.new(uri.host, uri.port, PROXY_HOST, PROXY_PORT)\n else\n \t http = Net::HTTP.new(uri.host, uri.port)\n end\n\n http.read_timeout = 4 # 4 seconds read timeout\n http.open_timeout = 4\n if uri.scheme == \"https\"\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n request = nil\n if method == \"OPTIONS\"\n request = Net::HTTP::Options.new(uri.request_uri, cookies)\n else # otherwise GET\n request = Net::HTTP::Get.new(uri.request_uri, cookies)\n end\n \n begin\n\t response = http.request(request)\n\n\t case response\n\t when Net::HTTPSuccess\n\t then \n\t return response\n\t when Net::HTTPRedirection # if you get a 3xx response\n\t then \n\t # handles stupid implementations like Location: /Login\n\t location = response['Location']\n\t #puts \"Location redirect to: #{location}\"\n\t if response['Set-cookie'] != nil && !@current_cookies.include?(response['Set-cookie'])\n\t \t@current_cookies += response['Set-cookie']\n\t end\n\t cookies = {'Cookie'=> @current_cookies}\n\n\t if location.start_with?(\"/\")\n\t \tlocation = \"#{uri.scheme}://#{uri.host}:#{uri.port}#{location}\"\n\t \t#puts \"Final location: #{location}\"\n\t end\n\t return request(location, \"GET\", cookies)\n\t else\n\t return [nil, \"Response error\"]\n\t end\n # ctaching different exceptions in case we need to do something on it in the future\n rescue SocketError => se # domain not resolved\n \treturn [nil, \"Domain not resolved\"]\n rescue Timeout::Error => timeout # timeout in open/read\n \treturn [nil, \"Timeout in open or read\"]\n rescue Errno::ECONNREFUSED => refused # connection refused\n \treturn [nil, \"Connection refused\"]\n rescue Exception => e\n \t#puts e.message\n \t#puts e.backtrace\n \treturn [nil, e.message]\n end\nend", "def send_request(url, post_vars, method)\n \n if method.to_s.downcase == \"get\"\n @request.query_string_params = post_vars\n else\n @request.post_params = post_vars\n end\n \n # If there is some stuff in the URL to be used as a query string, why ignore it?\n url, qs_from_url = url.split(/\\?/)\n \n relativize_url!(url)\n \n @request.append_to_query_string(qs_from_url) if qs_from_url\n \n # We do allow the user to override that one\n @request['REQUEST_METHOD'] = method\n \n @request['SCRIPT_NAME'] = '/' + @class_name_abbr.downcase\n @request['PATH_INFO'] = '/' + url\n \n @request['REQUEST_URI'] = [@request.SCRIPT_NAME, @request.PATH_INFO].join('').squeeze('/')\n unless @request['QUERY_STRING'].blank?\n @request['REQUEST_URI'] += ('?' + @request['QUERY_STRING']) \n end\n \n if @cookies\n @request['HTTP_COOKIE'] = @cookies.map {|k,v| \"#{k}=#{Camping.escape(v)}\" }.join('; ')\n end\n \n # Inject the proboscis if we haven't already done so\n pr = Mosquito::Proboscis\n eval(\"#{@class_name_abbr}.send(:include, pr) unless #{@class_name_abbr}.ancestors.include?(pr)\")\n \n # Run the request\n @response = eval(\"#{@class_name_abbr}.run @request.body, @request\")\n @assigns = Mosquito::unstash\n \n # We need to restore the cookies separately so that the app\n # restores our session on the next request. We retrieve cookies and\n # the session in their assigned form instead of parsing the headers and\n # doing a deserialization cycle \n @cookies = @assigns[:cookies] || H[{}]\n @state = @assigns[:state] || H[{}]\n \n if @response.headers['X-Sendfile']\n @response.body = File.read(@response.headers['X-Sendfile'])\n end\n end", "def initialize(options = {})\n options[:host] ||= Defaults::Request.host\n options[:port] ||= Defaults::Request.port\n options[:ssl] ||= Defaults::Request.ssl\n options[:headers] ||= Defaults::Request.headers\n @path = options[:path] || Defaults::Request.path\n\n http = Net::HTTP.new(options[:host], options[:port])\n http.use_ssl = options[:ssl]\n http.read_timeout = 8\n http.open_timeout = 4\n\n @http = http\n end", "def form_request(client)\n # read and tokenize the first line\n # we want to parse this line to retrieve the port, hostname, version, and filename\n first_line_tokens = client.gets.split\n\n # read the headers and store them in a hash\n header_hash = Hash.new()\n \n while next_line = client.gets do\n break if next_line.eql?(\"\\r\\n\") \n # we expect this line to be of the form (header): (header value)\n first_colon_index = next_line.index(\":\")\n unless first_colon_index.nil?\n header_hash[next_line[0..first_colon_index-1]] = next_line[first_colon_index+1..next_line.length - 1]\n end\n end\n\n #populate our metadata with temporary values\n port = 80\n version = \"\"\n filename = \"/\"\n request_type = first_line_tokens[0]\n \n if (!first_line_tokens[0].eql?(\"GET\") && !first_line_tokens[0].eql?(\"POST\"))\n # then this is not a GET or POST request, and we return nil\n return nil\n else\n # then this is a GET or POST request, and we will parse out the\n # port, hostname, version, and filename associated with this request\n\n # the rest of our attributes can be parsed from the second token, and\n # the token should be of the form: http://(hostname)(:port)/(filename)\n # or of the form: /(filename)\n url = first_line_tokens[1]\n # ignore the prefix\n url = url.split(\"//\")[1]\n\n # now, extract the hostname and port\n first_slash_index = url.index(\"/\")\n first_colon_index = url.index(\":\")\n if first_colon_index.nil? || first_colon_index>first_slash_index\n # then the port was not specified. Default to 80\n port = 80\n # then the hostname is the substring up to the first slash, or it\n # is instead specified in a header\n if first_slash_index > 0\n header_hash[\"Host\"] = url[0..first_slash_index-1]\n end\n else first_colon_index<first_slash_index\n # then the port is specified\n port = url[first_colon_index+1..first_slash_index-1]\n header_hash[\"Host\"] = url[0..first_colon_index-1]\n end\n \n # extract the filename from the url\n filename = url[first_slash_index..url.length-1]\n end\n return Request.new(header_hash[\"Host\"], port, filename, url, header_hash, request_type)\nend", "def initialize(url, options = {})\n @method = options[:method] || :get\n @params = options[:params]\n @body = options[:body]\n @timeout = options[:timeout]\n @connect_timeout = options[:connect_timeout]\n @interface = options[:interface]\n @headers = options[:headers] || {}\n @user_agent = options[:user_agent] || Typhoeus::USER_AGENT\n @cache_timeout = options[:cache_timeout]\n @follow_location = options[:follow_location]\n @max_redirects = options[:max_redirects]\n @proxy = options[:proxy]\n @proxy_type = options[:proxy_type]\n @ipresolve = options[:ipresolve]\n @proxy_username = options[:proxy_username]\n @proxy_password = options[:proxy_password]\n @proxy_auth_method = options[:proxy_auth_method]\n @disable_ssl_peer_verification = options[:disable_ssl_peer_verification]\n @disable_ssl_host_verification = options[:disable_ssl_host_verification]\n @ssl_cert = options[:ssl_cert]\n @ssl_cert_type = options[:ssl_cert_type]\n @ssl_key = options[:ssl_key]\n @ssl_key_type = options[:ssl_key_type]\n @ssl_key_password = options[:ssl_key_password]\n @ssl_cacert = options[:ssl_cacert]\n @ssl_capath = options[:ssl_capath]\n @verbose = options[:verbose]\n @username = options[:username]\n @password = options[:password]\n @auth_method = options[:auth_method]\n @attempt_retry = !options.has_key?(:retry) || options[:retry]\n @performed = false\n\n if @method == :post\n @url = url\n else\n @url = @params ? \"#{url}?#{params_string}\" : url\n end\n\n @parsed_uri = URI.parse(@url)\n\n @on_complete = nil\n @on_retry = nil\n @after_complete = nil\n @handled_response = nil\n end", "def make_request url, method: ::Rack::GET, body: nil, headers: []\n env = Testing.build_standard_env URI(url), headers\n env[::Rack::REQUEST_METHOD] = method\n env[::Rack::RACK_INPUT] = ::StringIO.new body if body\n ::Rack::Request.new env\n end", "def build_net_http_request request\n\n # Net::HTTP adds a content-type header automatically unless its set\n # and this messes with request signature signing. Also, it expects\n # all header values to be strings (it call strip on them).\n headers = { 'content-type' => '' }\n request.headers.each_pair do |key,value|\n headers[key] = value.to_s\n end\n\n request_class = case request.http_method\n when 'GET' then Net::HTTP::Get\n when 'PUT' then Net::HTTP::Put\n when 'POST' then Net::HTTP::Post\n when 'HEAD' then Net::HTTP::Head\n when 'DELETE' then Net::HTTP::Delete\n else raise \"unsupported http method: #{request.http_method}\"\n end\n\n net_http_req = request_class.new(request.uri, headers)\n net_http_req.body = request.body\n net_http_req\n\n end", "def http_request\n lines = []\n request = data[:request]\n\n verb, override = method_and_override(request[:verb])\n\n lines << \"%s %s HTTP/1.1\" % [verb, request[:path]]\n\n lines << \"X-Http-Method-Override: #{override}\" if override\n\n lines << \"Host: #{host}\"\n\n (request[:headers] || {}).each_pair do |key, value|\n lines << \"#{key}: #{value}\"\n end\n\n if request[:data]\n lines << \"Content-Type: application/json; charset=utf-8\"\n lines << \"\"\n lines << JSON.pretty_generate(request[:data])\n end\n\n lines.join(\"\\n\")\n end", "def http_request(url, options = {})\n\t\t\treq = Net::HTTP::Get.new(url)\n\t\t\treq[\"user-agent\"] = @@user_agent # ensure returns XML\n\t\t\treq[\"cookie\"] = \"cookieMenu=all; cookieLangId=\" + options[:lang] + \"; cookies=true;\"\n\t\t\t\n\t\t\treq[\"cookie\"] += options[:cookie] if options[:cookie]\n\n\t\t\turi = URI.parse(URI.escape(url))\n\t\t\t\n\t\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\t\n\t\t\tif (options[:secure])\n\t\t\t\tputs \"Secure authentication\" if options[:debug]\n\n\t\t\t\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\t\t\t\thttp.use_ssl = true\n\t\t\tend\n\t\t \n\t\t\t\n\t\t\tbegin\n\t\t\t\ttries = 0\n\t\t\t http.start do\n\t\t\t\t puts \"Get URL \"+ url if options[:debug]\n\t\t\t res = http.request req\n\t\t\t\t\t# response = res.body\n\t\t\t\t\t\n\t\t\t\t\t# FIXME WoW Armory rate limiter. Simple version\n\t\t\t\t\t# Needs to work across instances and not sleep for 1.5 if the\n\t\t\t\t\t# request took more than 1.5\n\t\t\t\t\t# just need a 1.5 second wait until the start of the next request\n \n if options[:rate_limit]\n\t\t\t\t\t puts \"Sleeping for 1.5 seconds\" if options[:debug]\n \t\t\t\t\tsleep 1.5\n\t\t\t\t\tend\n\n\t\t\t\t\tresponse = case res\n\t\t\t\t\t\twhen Net::HTTPSuccess, Net::HTTPRedirection\n\t\t\t\t\t\t\tres.body\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ttries += 1\n\t\t\t\t\t\t\tif tries > @@max_connection_tries\n\t\t\t\t\t\t\t\traise Wowr::Exceptions::NetworkTimeout.new('Timed out')\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tredo\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t end\n\t\t\trescue Timeout::Error => e\n raise Wowr::Exceptions::NetworkTimeout.new('Timed out - Timeout::Error Exception')\n\t\t\trescue SocketError, Net::HTTPExceptions => e\n\t\t\t\traise Wowr::Exceptions::ServerDoesNotExist.new('Specified server at ' + url + ' does not exist.')\n\t\t\tend\n\t\tend", "def request(host, port, method, uri, params = {}, data = {}, headers = {}, auth = nil, timeout = nil) # rubocop:disable Metrics/MethodLength\n auth ||= @auth\n headers = generate_headers(method, headers)\n uri = build_uri(uri)\n\n if @logger\n @logger.debug('--BEGIN Twilio API Request--')\n @logger.debug(\"Request Method: <#{method}>\")\n\n headers.each do |key, value|\n @logger.debug(\"#{key}:#{value}\") unless key.downcase == 'authorization'\n end\n\n url = URI(uri)\n @logger.debug(\"Host:#{url.host}\")\n @logger.debug(\"Path:#{url.path}\")\n @logger.debug(\"Query:#{url.query}\")\n @logger.debug(\"Request Params:#{params}\")\n end\n\n response = @http_client.request(\n host,\n port,\n method,\n uri,\n params,\n data,\n headers,\n auth,\n timeout\n )\n\n if @logger\n @logger.debug(\"Response Status Code:#{response.status_code}\")\n @logger.debug(\"Response Headers:#{response.headers}\")\n @logger.debug('--END TWILIO API REQUEST--')\n end\n\n response\n end", "def set_up_connection # :doc:\n uri = URI.parse(@config.host)\n @http = Net::HTTP.new(uri.host, uri.port, p_user = @config.proxy_user, p_pass = @config.proxy_pass)\n @http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n @http.use_ssl = @config.use_ssl\n if @config.ssl_verify_peer\n @http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n @http.ca_file = @config.ssl_ca_file\n else\n @http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n @http.open_timeout = @config.timeout\n @http.read_timeout = @config.timeout\n end", "def http_proxy; end", "def run_request(method, url, body, headers)\n if !METHODS.include?(method)\n raise ArgumentError, \"unknown http method: #{method}\"\n end\n\n # Resets temp_proxy\n @temp_proxy = proxy_for_request(url)\n\n request = build_request(method) do |req|\n req.options = req.options.merge(:proxy => @temp_proxy)\n req.url(url) if url\n req.headers.update(headers) if headers\n req.body = body if body\n yield(req) if block_given?\n end\n\n builder.build_response(self, request)\n end", "def generate_request(request)\n\n\t\t\trequest_uri = request[:uri].request_uri\n\n\t\t\tcase request[:method]\n\t\t\twhen :get\n\t\t\t\treq = Net::HTTP::Get.new request_uri\n\t\t\twhen :post\n\t\t\t\treq = Net::HTTP::Post.new request_uri, {'Content-Type' => \"application/json\"}\n\t\t\t\treq.body = request[:body]\n\t\t\t\treq\n\t\t\twhen :put\n\t\t\t\treq = Net::HTTP::Put.new request_uri, {'Content-Type' => \"application/json\"}\n\t\t\t\treq.body = request[:body]\n\t\t\t\treq\n\t\t\twhen :patch\n\t\t\t\treq = Net::HTTP::Patch.new request_uri, {'Content-Type' => \"application/json\"}\n\t\t\t\treq.body = request[:body]\n\t\t\t\treq\n\t\t\twhen :delete\n\t\t\t\treq = Net::HTTP::Delete.new request_uri\n\t\t\tend\n\t\tend", "def http_post\n req = Net::HTTP::Post.new @uri.request_uri, request_headers\n req.set_form_data params\n req.basic_auth @proxy_user, @proxy_pass if @proxy_pass && @proxy_user\n req\n end", "def initialize params = {}\n defaults = {\n :port => 80,\n :user_agent => 'Net::HTTP::RestClient'\n }\n if params[:port]==443 && !params[:ssl]\n defaults.merge! :ssl => {\n :use_ssl => true,\n :verify_mode => OpenSSL::SSL::VERIFY_NONE\n } \n end\n @params = defaults.merge(params)\n @cookies = {}\n @headers = {}\n @params[:headers] && @headers=@params[:headers]\n @params[:cookies] && @cookies=@params[:cookies]\n end", "def make_http_request( url, options, auth_info = {} )\n try_count = 0\n \n begin\n request = Net::HTTP::Post.new(url.path)\n request.basic_auth auth_info[:hapi_username], auth_info[:hapi_password] unless auth_info.empty?\n request.set_form_data(options)\n request.add_field('User-Agent', USER_AGENT)\n \n http = Net_HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.request(request)\n rescue Errno::ECONNREFUSED\n if try_count < 2\n try_count += 1\n sleep 1\n retry\n else\n raise Backend, \"Connection refused trying to contact hAPI at #{@hapi_hostname}\"\n end\n end\n end", "def _http_request(method, url, *args)\n request_args = get_hash_args(*args)\n url = get_url url unless url.to_s.start_with?('http://')\n request_args[:header] = @head\n request_args[:body] = \\\n JSON.dump(request_args[:body]) if request_args[:body]\n\n res = @http_session.request(method, url, request_args)\n status = res.status\n raise HTTPError, 'HTTPError: %s %s'\\\n % [status, (JSON.load(res.content)['message'] rescue res.reason)]\\\n if status >= 400 && status < 600\n res\n end", "def connection_options\n { :request => {\n :timeout => options[:timeout],\n :open_timeout => options[:timeout] },\n :proxy => options[:proxy_uri]\n }\n end", "def init_http\r\n http = Net::HTTP.new(HOST, PORT)\r\n http.use_ssl = true\r\n http.set_debug_output(@parameters.http_debug_stream) if @parameters.http_debug_stream\r\n http\r\n end", "def start_http(server,path,port,scheme,headers) # :nodoc:\n if (@http[server].nil?)\n begin\n @http[server] = Net::HTTP::Proxy(self.proxy_host, self.proxy_port).new(server,port)\n if scheme == \"https\"\n @http[server].use_ssl = true\n @http[server].verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n @http[server].start\n rescue\n raise OpenStack::Compute::Exception::Connection, \"Unable to connect to #{server}\"\n end\n end\n end", "def http_request(url, options = {})\n\t\t\treq = Net::HTTP::Get.new(url)\n\t\t\treq[\"user-agent\"] = \"Mozilla/5.0 Gecko/20070219 Firefox/2.0.0.2\" # ensure returns XML\n\t\t\treq[\"cookie\"] = \"cookieMenu=all; cookieLangId=\" + options[:lang] + \"; cookies=true;\"\n\t\t\t\n\t\t\treq[\"cookie\"] += options[:cookie] if options[:cookie]\n\t\t\t\n\t\t\turi = URI.parse(url)\n\t\t\t\n\t\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\t\n\t\t\tif (options[:secure])\n\t\t\t\tputs \"Secure authentication\" if options[:debug]\n\n\t\t\t\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\t\t\t\thttp.use_ssl = true\n\t\t\tend\n\t\t \n\t\t\t\n\t\t\tbegin\n\t\t\t http.start do\n\t\t\t res = http.request req\n\t\t\t\t\t# response = res.body\n\t\t\t\t\t\n\t\t\t\t\ttries = 0\n\t\t\t\t\tresponse = case res\n\t\t\t\t\t\twhen Net::HTTPSuccess, Net::HTTPRedirection\n\t\t\t\t\t\t\tres.body\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ttries += 1\n\t\t\t\t\t\t\tif tries > @@max_connection_tries\n\t\t\t\t\t\t\t\traise Wowr::Exceptions::NetworkTimeout.new('Timed out')\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tretry\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t end\n\t\t\trescue \n\t\t\t\traise Wowr::Exceptions::ServerDoesNotExist.new('Specified server at ' + url + ' does not exist.');\n\t\t\tend\n\t\tend", "def initialize (settings = {})\n # {{{\n @header = {}\n @cookies = {}\n @get = {}\n @post = {}\n\n # Internal attributes\n @status = nil\n @reasonPhrase = nil\n @setcookies = []\n @output_started = false;\n @output_allowed = false;\n\n @mod_ruby = false\n @env = ENV.to_hash\n\n if defined?(MOD_RUBY)\n @output_method = \"mod_ruby\"\n @mod_ruby = true\n elsif @env['SERVER_SOFTWARE'] =~ /^Microsoft-IIS/i\n @output_method = \"nph\"\n else\n @output_method = \"ph\"\n end\n\n unless settings.is_a?(Hash)\n raise TypeError, \"settings must be a Hash\"\n end\n @settings = settings\n\n unless @settings.has_key?(\"safe\")\n @settings[\"safe\"] = 1\n end\n\n if $SAFE < @settings[\"safe\"]\n $SAFE = @settings[\"safe\"]\n end\n\n unless @settings.has_key?(\"cache\")\n @settings[\"cache\"] = false\n end\n\n # mod_ruby sets no QUERY_STRING variable, if no GET-Parameters are given\n unless @env.has_key?(\"QUERY_STRING\")\n @env[\"QUERY_STRING\"] = \"\"\n end\n\n # Now we split the QUERY_STRING by the seperators & and ; or, if\n # specified, settings['get seperator']\n unless @settings.has_key?(\"get seperator\")\n get_args = @env['QUERY_STRING'].split(/[&;]/)\n else\n get_args = @env['QUERY_STRING'].split(@settings['get seperator'])\n end\n\n get_args.each do | arg |\n arg_key, arg_val = arg.split(/=/, 2)\n arg_key = Rweb::unescape(arg_key)\n arg_val = Rweb::unescape(arg_val)\n\n # Parse names like name[0], name['text'] or name[]\n pattern = /^(.+)\\[(\"[^\\]]*\"|'[^\\]]*'|[0-9]*)\\]$/\n keys = []\n while match = pattern.match(arg_key)\n arg_key = match[1]\n keys = [match[2]] + keys\n end\n keys = [arg_key] + keys\n\n akt = @get\n last = nil\n lastkey = nil\n keys.each do |key|\n if key == \"\"\n # No key specified (like in \"test[]\"), so we use the\n # lowerst unused Integer as key\n key = 0\n while akt.has_key?(key)\n key += 1\n end\n elsif /^[0-9]*$/ =~ key\n # If the index is numerical convert it to an Integer\n key = key.to_i\n elsif key[0].chr == \"'\" || key[0].chr == '\"'\n key = key[1, key.length() -2]\n end\n if !akt.has_key?(key) || !akt[key].class == Hash\n # create an empty Hash if there isn't already one\n akt[key] = {}\n end\n last = akt\n lastkey = key\n akt = akt[key]\n end\n last[lastkey] = arg_val\n end\n\n if @env['REQUEST_METHOD'] == \"POST\"\n if @env.has_key?(\"CONTENT_TYPE\") && @env['CONTENT_TYPE'] == \"application/x-www-form-urlencoded\" && @env.has_key?('CONTENT_LENGTH')\n unless @settings.has_key?(\"post seperator\")\n post_args = $stdin.read(@env['CONTENT_LENGTH'].to_i).split(/[&;]/)\n else\n post_args = $stdin.read(@env['CONTENT_LENGTH'].to_i).split(@settings['post seperator'])\n end\n post_args.each do | arg |\n arg_key, arg_val = arg.split(/=/, 2)\n arg_key = Rweb::unescape(arg_key)\n arg_val = Rweb::unescape(arg_val)\n\n # Parse names like name[0], name['text'] or name[]\n pattern = /^(.+)\\[(\"[^\\]]*\"|'[^\\]]*'|[0-9]*)\\]$/\n keys = []\n while match = pattern.match(arg_key)\n arg_key = match[1]\n keys = [match[2]] + keys\n end\n keys = [arg_key] + keys\n\n akt = @post\n last = nil\n lastkey = nil\n keys.each do |key|\n if key == \"\"\n # No key specified (like in \"test[]\"), so we use\n # the lowerst unused Integer as key\n key = 0\n while akt.has_key?(key)\n key += 1\n end\n elsif /^[0-9]*$/ =~ key\n # If the index is numerical convert it to an Integer\n key = key.to_i\n elsif key[0].chr == \"'\" || key[0].chr == '\"'\n key = key[1, key.length() -2]\n end\n if !akt.has_key?(key) || !akt[key].class == Hash\n # create an empty Hash if there isn't already one\n akt[key] = {}\n end\n last = akt\n lastkey = key\n akt = akt[key]\n end\n last[lastkey] = arg_val\n end\n else\n # Maybe we should print a warning here?\n $stderr.print(\"Unidentified form data recived and discarded.\")\n end\n end\n\n if @env.has_key?(\"HTTP_COOKIE\")\n cookie = @env['HTTP_COOKIE'].split(/; ?/)\n cookie.each do | c |\n cookie_key, cookie_val = c.split(/=/, 2)\n\n @cookies [Rweb::unescape(cookie_key)] = Rweb::unescape(cookie_val)\n end\n end\n\n if defined?(@env['HTTP_USER_AGENT'])\n @user_agent = @env['HTTP_USER_AGENT']\n else\n @user_agent = nil;\n end\n\n if defined?(@env['REMOTE_ADDR'])\n @remote_addr = @env['REMOTE_ADDR']\n else\n @remote_addr = nil\n end\n # }}}\n end", "def options\n\t\t# we don't support sending a payload in options' body.\n\t\treq = Net::HTTP::Options.new(@uri.path)\n\t\tdo_http req\n\tend", "def http_post_request\n begin\n return http_client.post(http_path_query, compressed_request, http_headers)\n rescue APIKeyError\n log 'error - you must set your api_key.'\n rescue TimeoutError\n log 'fail - timeout while contacting the api server.'\n rescue Exception => e\n log \"fail - exception raised during http post. (#{e.class.name}: #{e.message})\"\n end\n nil\n end", "def http_request\n req = VanillaRequest.new @http_method, @uri.request_uri, @headers\n\n req.basic_auth @auth[:username], @auth[:password] if\n @auth && @auth[:username]\n\n req\n end", "def request(params)\n\n # Add auth header\n headers = params[:headers] || {}\n headers['x-vcloud-authorization'] = @auth_key if !@auth_key.nil? || !@auth_key.equal?('')\n\n # set connection options\n options = {:url => params[:url],\n :body => params[:body] || '',\n :expects => params[:expects] || 200,\n :headers => headers || {},\n :method => params[:method] || 'GET'\n }\n\n # connect\n res = RestClient::Request.execute options\n\n raise res if (res.code!=params[:expects] && res.code!=200)\n\n res\n\n\n end", "def build_request(method); end", "def request(http_method: :get, path:'/', body: nil, query: {}, headers: {}, response_block: nil, expects: [200, 201, 204], host: nil, port: nil, auth: true, gzip: true)\n\n retried ||= false\n\n if auth && token_expired?\n raise Excon::Error::Unauthorized, \"Token expired or not valid, you need to login again, use: kontena #{token_is_for_master? ? \"master\" : \"cloud\"} login\"\n end\n\n request_headers = request_headers(headers, auth: auth, gzip: gzip)\n\n if body.nil?\n body_content = ''\n request_headers.delete(CONTENT_TYPE)\n else\n body_content = encode_body(body, request_headers[CONTENT_TYPE])\n request_headers.merge!('Content-Length' => body_content.bytesize)\n end\n\n uri = URI.parse(path)\n host_options = {}\n\n if uri.host\n host_options[:host] = uri.host\n host_options[:port] = uri.port\n host_options[:scheme] = uri.scheme\n path = uri.request_uri\n else\n host_options[:host] = host if host\n host_options[:port] = port if port\n end\n\n request_options = {\n method: http_method,\n expects: Array(expects),\n path: path_with_prefix(path),\n headers: request_headers,\n body: body_content,\n query: query\n }.merge(host_options)\n\n request_options.merge!(response_block: response_block) if response_block\n\n # Store the response into client.last_response\n @last_response = http_client.request(request_options)\n\n parse_response(@last_response)\n rescue Excon::Error::Unauthorized\n if token\n debug { 'Server reports access token expired' }\n\n if retried || !token || !token['refresh_token']\n raise Kontena::Errors::StandardError.new(401, 'The access token has expired and needs to be refreshed')\n end\n\n retried = true\n retry if refresh_token\n end\n raise Kontena::Errors::StandardError.new(401, 'Unauthorized')\n rescue Excon::Error::HTTPStatus => error\n if error.response.headers['Content-Encoding'] == 'gzip'\n error.response.body = Zlib::GzipReader.new(StringIO.new(error.response.body)).read\n end\n\n debug { \"Request #{error.request[:method].upcase} #{error.request[:path]}: #{error.response.status} #{error.response.reason_phrase}: #{error.response.body}\" }\n\n handle_error_response(error.response)\n end", "def run_request(method, path, body, headers)\n klass = Net::HTTP.const_get(method.to_s.capitalize)\n req.klass.new(path, headers)\n req.body = body if body\n request(req)\n end", "def send_request(method, path, options={}) #:nodoc:\n raise ArgumentError, 'only get, post, put and delete methods are supported' unless %w[get post put delete].include?(method.to_s)\n raise ArgumentError, ':headers must be a hash' if options[:headers] && !options[:headers].is_a?(Hash)\n raise ArgumentError, ':basic_auth must be a hash' if options[:basic_auth] && !options[:basic_auth].is_a?(Hash)\n uri = URI.parse(\"#{base_uri}#{path}\")\n existing_query = uri.query ? \"#{uri.query}&\" : ''\n uri.query = if options[:query].blank?\n existing_query + default_params.to_query\n else\n existing_query + (options[:query].is_a?(Hash) ? default_params.merge(options[:query]).to_query : options[:query])\n end\n klass = Net::HTTP.const_get method.to_s.downcase.capitalize\n request = klass.new(uri.request_uri)\n request.body = options[:body].is_a?(Hash) ? options[:body].to_query : options[:body] unless options[:body].blank?\n basic_auth = options.delete(:basic_auth) || @auth\n request.initialize_http_header headers.merge(options[:headers] || {})\n # note to self: self, do not put basic auth above headers because it removes basic auth\n request.basic_auth(basic_auth[:username], basic_auth[:password]) if basic_auth\n response = http(uri).request(request)\n @format ||= format_from_mimetype(response['content-type'])\n \n case response\n when Net::HTTPSuccess\n parse_response(response.body)\n else\n response.instance_eval { class << self; attr_accessor :body_parsed; end }\n begin; response.body_parsed = parse_response(response.body); rescue; end\n response.error! # raises exception corresponding to http error Net::XXX\n end\n\n end", "def http *xs\n env.http *xs\n end", "def build_http(host, port)\n params = [host, port]\n params += @proxy_options.values_at(:host, :port, :user, :pass) unless @proxy_options.empty?\n http = add_ssl(Net::HTTP.new(*params))\n http = add_http_options(http) unless @http_options.empty?\n http\n end", "def build_request\n uri = @config[:endpoint]\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.start\n request = build_request_stream(uri)\n return http, request\n end", "def create_http(_url = nil)\n\n\n if !request_endpoint.nil?\n _url = request_endpoint\n end\n\n\n if _url.nil? || _url[0] =~ /^\\//\n our_uri = URI.parse(site)\n else\n our_uri = URI.parse(_url)\n end\n\n\n if proxy.nil?\n http_object = Net::HTTP.new(our_uri.host, our_uri.port)\n else\n proxy_uri = proxy.is_a?(URI) ? proxy : URI.parse(proxy)\n http_object = Net::HTTP.new(our_uri.host, our_uri.port, proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password)\n end\n\n http_object.use_ssl = (our_uri.scheme == 'https')\n\n if @options[:ca_file] || CA_FILE\n http_object.ca_file = @options[:ca_file] || CA_FILE\n http_object.verify_mode = OpenSSL::SSL::VERIFY_PEER\n http_object.verify_depth = 5\n else\n http_object.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n http_object.read_timeout = http_object.open_timeout = @options[:timeout] || 30\n http_object.open_timeout = @options[:open_timeout] if @options[:open_timeout]\n\n http_object\n end", "def create_request(method, uri, data = nil)\r\n method = method.upcase\r\n if(method == 'GET')\r\n return Net::HTTP::Get.new(uri)\r\n elsif(method == 'POST')\r\n request = Net::HTTP::Post.new(uri)\r\n request.body = data.to_json\r\n return request\r\n elsif(method == 'PUT')\r\n request = Net::HTTP::Put.new(uri)\r\n request.body = data.to_json\r\n return request\r\n elsif(method == 'DELETE')\r\n return Net::HTTP::Delete.new(uri)\r\n else\r\n raise CLXException, 'Unknown HTTP method'\r\n end\r\n end", "def request(method, path, options)\n connection_method = if options.present? && options.delete(:request_token)\n token_connection(options.delete(:params) || {})\n else\n connection\n end\n http_response = connection_method.send(method) do |request|\n case method\n when :get\n formatted_options = format_options(options)\n request.url(path, formatted_options)\n when :post, :put\n request.headers['Content-Type'] = 'application/json'\n request.body = options.to_json unless options.empty?\n request.url(path)\n end\n request.options.timeout = 120 # read timeout\n request.options.open_timeout = 300 # connection timeout\n end\n\n data = Response.create(http_response.body)\n response = {}\n\n response['data'] = data\n response\n end", "def request(method, path, params, headers = {})\n url = \"https://#{@host}/api/#{@version}#{path}\"\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n\n assign_verify_mode(http)\n request = create_request(method, uri, params, headers)\n\n res = http.request(request) if request\n parse_body(res)\n rescue SocketError => e\n raise ConnectionError, e.message\n end", "def do_request(uri, parse, method = \"GET\", args = {})\n uri = URI(uri)\n\n case method\n when \"POST\"\n req = Net::HTTP::Post.new(uri.request_uri)\n when \"PATCH\"\n req = Net::HTTP::Post.new(uri.request_uri)\n else\n req = Net::HTTP::Get.new(uri.request_uri)\n end\n\n if not args.empty?\n req.body = args.to_json\n end\n\n req.basic_auth AUTH[\"user\"], AUTH[\"pw\"]\n\n http = Net::HTTP.new(uri.host, uri.port)\n if uri.scheme.eql? \"https\"\n http.use_ssl = true\n end\n res = http.start do |http| http.request(req) end\n if parse\n res = JSON.parse(res.body)\n else\n res = res.body\n end\n res\n end", "def send_request\n \t\taz = @args[:authorization] and az = \"Authorization: #{az}\\r\\n\"\n body = @args.delete(:body)\n headers = @args.delete(:headers)\n body.strip! if body\n content_type = @args[:content_type]\n \t\tr = [\n \t\t \t\"#{@args[:verb]} #{@args[:uri]} HTTP/#{@args[:version] || \"1.1\"}\\r\\n\",\n \t\t\t\"Host: #{@args[:host_header] || \"_\"}\\r\\n\",\n \t\t\taz || \"\",\n \t\t\t\"Content-Length: #{body.nil? ? 0 : body.size}\\r\\n\",\n \t\t\t\"Date: #{Time.now.httpdate}\\r\\n\",\n \t\t\tcontent_type.nil? ? \"\" : \"Content-Type: #{content_type}\\r\\n\"\n \t] + \n (headers.nil? ? [] : headers.keys.map{|key| \"#{key}: #{headers[key]}\\r\\n\"}) +\n [\"\\r\\n\", body]\n \n \t\[email protected]_data(r.join)\n \tend", "def make_request(method, url, params = {})\n path = \"#{EbanqApi.base_url}/#{url}\"\n response = case method\n when :get then get(path, headers, params)\n when :post then post(path, headers, params)\n when :put then put(path, headers, params)\n when :delete then delete(path, headers)\n else raise 'Error'\n end\n process_raw_response(response)\n rescue RestClient::ResourceNotFound, SocketError, Errno::ECONNREFUSED => e\n raise e\n end", "def initialize(key, proxy = nil)\n\n ##\n # Setting initial options for the request\n\n @options = {\n user: key,\n password: \"\",\n method: :post,\n url: \"#{API_URL}/#{@type}\",\n ssl_ca_file: File.dirname(__FILE__) + '/../data/cacert.pem'\n }\n\n @proxy = proxy\n\n ##\n # Request data, which will be sent do API server\n\n @data = {}\n end", "def request(params, &block)\n begin\n # connection has defaults, merge in new params to override\n params = @connection.merge(params)\n params[:headers] = @connection[:headers].merge(params[:headers] || {})\n params[:headers]['Host'] ||= '' << params[:host] << ':' << params[:port]\n\n # if path is empty or doesn't start with '/', insert one\n unless params[:path][0, 1] == '/'\n params[:path].insert(0, '/')\n end\n\n if params[:mock]\n for stub, response in Excon.stubs\n # all specified non-headers params match and no headers were specified or all specified headers match\n if [stub.keys - [:headers]].all? {|key| stub[key] == params[key] } &&\n (!stub.has_key?(:headers) || stub[:headers].keys.all? {|key| stub[:headers][key] == params[:headers][key]})\n case response\n when Proc\n return Excon::Response.new(response.call(params))\n else\n return Excon::Response.new(response)\n end\n end\n end\n # if we reach here no stubs matched\n raise(Excon::Errors::StubNotFound.new('no stubs matched ' << params.inspect))\n end\n\n # start with \"METHOD /path\"\n request = params[:method].to_s.upcase << ' '\n if @proxy\n request << params[:scheme] << '://' << params[:host] << ':' << params[:port]\n end\n request << params[:path]\n\n # add query to path, if there is one\n case params[:query]\n when String\n request << '?' << params[:query]\n when Hash\n request << '?'\n for key, values in params[:query]\n if values.nil?\n request << key.to_s << '&'\n else\n for value in [*values]\n request << key.to_s << '=' << CGI.escape(value.to_s) << '&'\n end\n end\n end\n request.chop! # remove trailing '&'\n end\n\n # finish first line with \"HTTP/1.1\\r\\n\"\n request << HTTP_1_1\n\n # calculate content length and set to handle non-ascii\n unless params[:headers].has_key?('Content-Length')\n params[:headers]['Content-Length'] = case params[:body]\n when File\n params[:body].binmode\n File.size(params[:body])\n when String\n if FORCE_ENC\n params[:body].force_encoding('BINARY')\n end\n params[:body].length\n else\n 0\n end\n end\n\n # add headers to request\n for key, values in params[:headers]\n for value in [*values]\n request << key.to_s << ': ' << value.to_s << CR_NL\n end\n end\n\n # add additional \"\\r\\n\" to indicate end of headers\n request << CR_NL\n\n # write out the request, sans body\n socket.write(request)\n\n # write out the body\n if params[:body]\n if params[:body].is_a?(String)\n socket.write(params[:body])\n else\n while chunk = params[:body].read(CHUNK_SIZE)\n socket.write(chunk)\n end\n end\n end\n\n # read the response\n response = Excon::Response.parse(socket, params, &block)\n\n if response.headers['Connection'] == 'close'\n reset\n end\n\n response\n rescue Excon::Errors::StubNotFound => stub_not_found\n raise(stub_not_found)\n rescue => socket_error\n reset\n raise(Excon::Errors::SocketError.new(socket_error))\n end\n\n if params.has_key?(:expects) && ![*params[:expects]].include?(response.status)\n reset\n raise(Excon::Errors.status_error(params, response))\n else\n response\n end\n\n rescue => request_error\n if params[:idempotent] && [Excon::Errors::SocketError, Excon::Errors::HTTPStatusError].include?(request_error)\n retries_remaining ||= 4\n retries_remaining -= 1\n if retries_remaining > 0\n retry\n else\n raise(request_error)\n end\n else\n raise(request_error)\n end\n end", "def make_request url, parameters={}, method=:get, settings={}\n raise 'not implemented'\n end", "def api_request(path, method, body)\n uri = call_uri(path)\n req = Net::HTTP.const_get(method)\n .new(uri,\n \"Content-Type\": 'application/json; charset=utf-8',\n \"Cache-Control\": 'no-cache')\n req.body = body\n Net::HTTP.new(uri.hostname, uri.port).start { |http| http.request(req) }\n end", "def forward_request(chef_server, request)\n \n case request.method\n when \"GET\"\n req = Net::HTTP::Get.new(request.fullpath)\n logger.debug \" forward_request: created GET request with #{request.fullpath}\"\n when \"POST\"\n req = Net::HTTP::Post.new(request.fullpath)\n req.body = request.body.string\n logger.debug \" forward_request: created POST request with #{request.fullpath}\"\n when \"PUT\"\n req = Net::HTTP::Put.new(request.fullpath)\n req.body = request.body.string\n logger.debug \" forward_request: created PUT request with #{request.fullpath}\"\n when \"DELETE\"\n req = Net::HTTP::Delete.new(request.fullpath)\n logger.debug \" forward_request: created DELETE request with #{request.fullpath}\"\n else\n logger.warn \" forward_request: invalid request.method\"\n return nil\n end\n\n #logger.debug \" forward_request: req.body: #{req.body}\"\n\n headers_list = [\"Content-Type\", \"Content-Length\", \"X-Chef-Version\", \"X-Ops-Sign\", \"X-Ops-Userid\", \"X-Ops-Content-Hash\", \"X-Ops-Timestamp\", \"X-Remote-Request-Id\"]\n (1..9).to_a.each do |key|\n headers_list << \"X-Ops-Authorization-#{key}\"\n end\n headers_list.each do |header|\n if request.headers[header]\n #logger.debug \" forward_request: adding header #{header}: #{request.headers[header]}\"\n req[header] = request.headers[header]\n end\n end\n\n uri = URI.parse(chef_server[:url])\n res = Net::HTTP.start(uri.hostname, uri.port) { |http|\n http.request(req)\n }\n\n #logger.debug \" forward_request: {status => #{res.code}, message => #{res.message}, body => #{res.body}\"\n return {\"status\" => res.code, \"message\" => res.message, \"body\" => res.body}\n\nend", "def http(method, url, options = {}, &block)\n case method.to_s.downcase\n when *%w(get put head post delete options patch)\n send method, url, options, &block\n else\n raise \"Invalid method: #{method}\"\n end\n end", "def request(method, path, body = nil)\n Excon.send(method, @url, :path => path, :headers => web_proxy_headers, :body => body, :connect_timeout => @connect_timeout)\n end", "def send_request(req_type, host, port, url, fields_hash, up_file, ssl)\n res = false\n conn_start(host, port, ssl) do |http|\n request = Module.module_eval(\"Net::HTTP::#{req_type}\").new(url)\n fields_hash.each_pair{|n,v| request[n] = v} # Add user defined header fields\n request.content_length = up_file.lstat.size \n request.body_stream = up_file # For uploads using streaming\n begin\n response = http.request(request)\n \n rescue Exception => ex\n response = ex.to_s\n end\n\n # Handle auth errors and other errors!\n if !response.is_a?(Net::HTTPOK)\n #puts 'Failed to upload!'\n #log_request(request, response)\n else\n res = true\n end\n end\nend", "def job_client(target_uri, query, access_token, method)\n return {} if target_uri.nil? || method.nil?\n\n uri = URI.parse(target_uri)\n https = Net::HTTP.new(uri.host, uri.port)\n https.use_ssl = true\n\n begin\n req = Net::HTTP::Post.new(uri.request_uri)\n req[\"Content-Type\"] = \"application/json; charset=utf-8\"\n req[\"Authorization\"] = \"Bearer #{access_token}\"\n req.body = query\n\n response = https.request(req)\n\n puts \"code -> #{response.code}\"\n puts \"body -> #{response.body}\"\n\n case response\n when Net::HTTPSuccess\n body = response.body\n JSON.parse(body)\n else\n puts [uri.to_s, response.value].join(\" : \")\n return nil\n end\n rescue => e\n logger.error [uri.to_s, e.class, e].join(\" : \")\n return nil\n end\n\n end", "def http\n HTTP .headers(accept: \"application/json\")\n # .via(\"127.0.0.1\", 8888)\n end", "def request(request_method, request_path = self.request_path, headers = {}, data = {})\n url = [RSpec.configuration.base_url, request_path].join('')\n request = HTTP.headers(headers)\n data = data.to_json unless data.is_a?(String) # TODO: Switch to using data as an argument rather than stringified JSON.\n response = request.send(request_method.downcase, url, body: data)\n log(request_method, request_path, headers, data)\n\n JSON.parse(response.body.readpartial)\n end", "def parse_request(request_http)\n lines = request_http.split(\"\\n\")\n\n request_line = lines.shift\n method, path, version = request_line.split\n\n headers = {}\n loop do\n line = lines.shift\n break if line =~ /^\\s*$/\n\n key, value = line.split(':', 2)\n headers[key] = value.strip\n end\n\n body = lines.join(\"\\n\")\n\n {\n 'method' => method,\n 'path' => path,\n 'version' => version,\n 'headers' => headers,\n 'body' => body,\n }\n end" ]
[ "0.708227", "0.6855678", "0.677044", "0.67122096", "0.66025454", "0.65804905", "0.6520179", "0.64744437", "0.6469615", "0.64537364", "0.64322484", "0.64288735", "0.64247936", "0.64215344", "0.64008856", "0.63978016", "0.63692707", "0.63568306", "0.63567543", "0.6353613", "0.6320516", "0.6319907", "0.6304445", "0.63041914", "0.63032585", "0.6302367", "0.6283746", "0.6268612", "0.62390274", "0.6218891", "0.62135416", "0.6211016", "0.62065226", "0.62059516", "0.6198104", "0.6192759", "0.61689395", "0.6168715", "0.61284125", "0.6128043", "0.612625", "0.61154383", "0.6106911", "0.6104206", "0.60831255", "0.60790586", "0.60778755", "0.60700995", "0.6067517", "0.6058403", "0.60519874", "0.6048733", "0.60324097", "0.60316646", "0.6019843", "0.6014794", "0.60047877", "0.60046005", "0.5979352", "0.5975065", "0.59692484", "0.5967164", "0.5962323", "0.59546745", "0.595159", "0.5950629", "0.5947548", "0.5946794", "0.5939478", "0.5938506", "0.59375453", "0.59298795", "0.5928632", "0.59265184", "0.5925675", "0.59083337", "0.5896215", "0.5894651", "0.5891718", "0.5886611", "0.58742464", "0.5873456", "0.5871941", "0.58701974", "0.58622277", "0.5855326", "0.5853484", "0.58482105", "0.58476585", "0.5834479", "0.5828943", "0.58282965", "0.58148885", "0.5811729", "0.5809821", "0.579779", "0.57969606", "0.57946813", "0.5790046", "0.5789387", "0.577851" ]
0.0
-1
param needs to be there to be arrity compatible with one we're overriding, even though we do nothing with it.
def export_as_openurl_ctx_kev(ignored_param = nil) unless defined? @_ctx_kev @_ctx_kev = to_openurl.kev end return @_ctx_kev end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def param; end", "def param; end", "def overrides=(_arg0); end", "def PO114=(arg)", "def extra=(_arg0); end", "def params=(_); end", "def PO115=(arg)", "def special\n override\n end", "def base=(_arg0); end", "def PO109=(arg)", "def isolated=(_arg0); end", "def isolated=(_arg0); end", "def overrides; end", "def param(_param)\n @param = @param.deep_merge(_param)\n end", "def PO113=(arg)", "def PO106=(arg)", "def safe_by_default=(_arg0); end", "def PO105=(arg)", "def PO104=(arg)", "def PRF02=(arg)", "def PO107=(arg)", "def PO102=(arg)", "def PO103=(arg)", "def override_value(param, value)\n self.instance_variable_set(\"@#{param}\", value)\n end", "def ignore_method_conflicts=(_arg0); end", "def PO108=(arg)", "def autofinish=(_arg0); end", "def before=(_arg0); end", "def overload; end", "def strategy=(_arg0); end", "def PO101=(arg)", "def probers=(_arg0); end", "def PO111=(arg)", "def parameters=(_); end", "def PRF04=(arg)", "def old_value=(_arg0); end", "def params=(_arg0); end", "def params=(_arg0); end", "def param_default( param, value )\n param = value unless ( param && param.length > 0 )\n end", "def PO110=(arg)", "def method=(_arg0); end", "def method=(_arg0); end", "def method=(_arg0); end", "def public=(_arg0); end", "def PRF03=(arg)", "def treat_reserved_as_conflict=(_arg0); end", "def patch=(_arg0); end", "def in_kwarg=(_arg0); end", "def PRF01=(arg)", "def meth(\n # this is important\n arg)\nend", "def explicit=(_arg0); end", "def pass_by!\n end", "def SE02=(arg)", "def params=(value); end", "def override(name, val = NULL_ARG)\n @overrides[name] = val unless val.equal?(NULL_ARG)\n @overrides[name]\n end", "def offences_by=(_arg0); end", "def permitted=(_arg0); end", "def override( name, *args, &block )\n\t\tname = name.to_sym\n\t\traise ArgumentError,\n\t\t\t\"no parameter %p defined; perhaps you meant to use #add?\" % [ name.to_s ] unless\n\t\t\tself.constraints.key?( name )\n\n\t\tself.log.debug \"Overriding parameter %p\" % [ name ]\n\t\tself.constraints[ name ] = Constraint.for( name, *args, &block )\n\n\t\tself.validated = false\n\tend", "def origin=(_arg0); end", "def called_from=(_arg0); end", "def called_from=(_arg0); end", "def ITD07=(arg)", "def PO112=(arg)", "def in_kwarg; end", "def wrapped_in=(_arg0); end", "def arg; end", "def SAC06=(arg)", "def api_only=(_arg0); end", "def SAC07=(arg)", "def pass=(_arg0); end", "def tag; raise 'Override this method'; end", "def foo(...)\n super(...)\nend", "def parameters=(_arg0); end", "def SAC02=(arg)", "def stubbed_params=(_arg0); end", "def active=(_arg0); end", "def active=(_arg0); end", "def default=(_arg0); end", "def attribute=(_arg0); end", "def attribute=(_arg0); end", "def foo(param = \"no\")\r\n \"yes\"\r\nend", "def SAC05=(arg)", "def whiny=(_arg0); end", "def checked=(_arg0); end", "def exclude=(_arg0); end", "def SE01=(arg)", "def preflight=(_arg0); end", "def set_param\n if self.param.blank?\n self.param = self.name.parameterize.downcase unless self.name.nil?\n end\n end", "def method(c=c)\r\nend", "def parameter_rule?; end", "def ITD03=(arg)", "def meth( x = nil)\nend", "def param_set (_id, _value, _display = true)\n critical_error('the param_set method was not overridden after being included in a database class')\n end", "def foo(param = \"no\") #this is default param\n \"yes\"\nend", "def SAC04=(arg)", "def meth(\n # this is important\n important_arg,\n # a default, because we're not animals!\n default=nil)\nend", "def safe=(_arg0); end", "def argument?; end", "def source(override); end", "def SAC03=(arg)", "def interface=(_arg0); end" ]
[ "0.68352705", "0.68352705", "0.67828035", "0.64904994", "0.6456034", "0.6437997", "0.6401613", "0.63760763", "0.63744754", "0.6372114", "0.63044477", "0.63044477", "0.62971455", "0.6275492", "0.6264658", "0.625603", "0.62498426", "0.6240562", "0.623103", "0.62217796", "0.6206676", "0.62033397", "0.6200357", "0.6185128", "0.6166782", "0.6160741", "0.61587864", "0.6143451", "0.61375695", "0.61306566", "0.6094273", "0.6088371", "0.60838753", "0.60681057", "0.6043508", "0.6028066", "0.60235804", "0.60235804", "0.60081947", "0.60075295", "0.59772265", "0.59772265", "0.59772265", "0.5962256", "0.59479636", "0.59460044", "0.59413666", "0.59300655", "0.5916701", "0.59159756", "0.5911245", "0.5909089", "0.590791", "0.58887887", "0.58806217", "0.5874886", "0.5865268", "0.5859965", "0.5837888", "0.5822288", "0.5822288", "0.581149", "0.57894945", "0.5784865", "0.57790893", "0.57740086", "0.57723814", "0.5766099", "0.57636017", "0.57546276", "0.5753694", "0.57483757", "0.5745085", "0.5744608", "0.57259136", "0.57247716", "0.57247716", "0.5724487", "0.5720701", "0.5720701", "0.57194996", "0.57187223", "0.571743", "0.5715188", "0.57122976", "0.570996", "0.5701315", "0.5690246", "0.5684869", "0.5658418", "0.5641795", "0.56394434", "0.56379503", "0.5635434", "0.5631578", "0.5612435", "0.56005746", "0.559479", "0.5591995", "0.5591263", "0.55852646" ]
0.0
-1
GET /mycoins/1 GET /mycoins/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_coins\n get(\"/getcoins\")\n end", "def coins\n\t\tres = {}\n\t\tuser = User.find_by_token(params[:token])\n\t\tif user\n\t\t\tres[:status] = \"0\"\n\t\t\tres[:coins] = user.coins\n\t\telse\n\t\t\tres[:status] = \"1\"\n\t\tend\n\t\trender json: res\n\tend", "def show\n @mint_coin = @coin.mint_coins.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @mint_coin }\n end\n end", "def index\n # this whole process is updating the users coins with the currnet price from the api. pulls the users coins and if a coin matches then update the price in usd. and return the coin.\n coins = HTTParty.get(BASE_URL) # this will bring back the top 100 coins in an array\n user_coins = current_user.coins\n user_coins.each do |coin|\n res_coin = coins.find { |c| c['id'] == coin.cmc_id }\n coin.update(price: res_coin['price_usd']) if res_coin \n end \n render json: current_user.coins # if we don't authenticate_user before then we cant user current_user. it is a built in devise function\n end", "def list_coins\n endpoint = \"#{HOST}/v1/cryptocurrency/map\"\n get(endpoint)\n end", "def show\n @our_coin = OurCoin.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @our_coin }\n end\n end", "def index\n @coins = Coin.all\n render \"index.json.jbuilder\"\n end", "def show\n coin = Coin.find(params[:id]) \n require 'net/http'\n url = url = \"https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=#{coin.coin_api_id}&order=market_cap_desc&per_page=100&page=1&sparkline=false&price_change_percentage=1h\"\n request = URI.parse(url)\n response = Net::HTTP.get_response(request)\n crypto_hash = JSON.parse(response.body)\n coin.image = crypto_hash[0]['image']\n coin.current_price = crypto_hash[0]['current_price']\n coin.price_change_percentage_1h_in_currency = crypto_hash[0]['price_change_percentage_1h_in_currency']\n coin.high_24h = crypto_hash[0]['high_24h']\n coin.low_24h = crypto_hash[0]['low_24h']\n coin.total_volume = crypto_hash[0]['total_volume']\n coin.market_cap = crypto_hash[0]['market_cap']\n coin.market_cap_rank = crypto_hash[0]['market_cap_rank']\n coin.circulating_supply = crypto_hash[0]['circulating_supply']\n\n # Serializer\n # render json: CoinSerializer.new(coin)\n render json: coin\n end", "def index\n @users = User.all\n render json: @users.to_json(include: ['coins']) \n end", "def get_coin\n @coin = Coin.find(params[:coin_id])\n end", "def get_coin\n @coin = Coin.find(params[:coin_id])\n end", "def index\n @coin_attributes = @coin.coin_attributes\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @coin_attributes }\n end\n end", "def index\n @coins = Coin.all\n end", "def main_page_api\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n # converts response to a Ruby hash \n @coins = JSON.parse(@response)\n @my_coins = [\"XLM\", \"BTC\", \"ADA\", \"STEEM\", \"ETH\"] \n end", "def show_coins_list\n coins_list(coins)\n end", "def index\n @money = Money.all\n require 'net/http'\n require 'json'\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_money = JSON.parse(@response)\n end", "def index\n @mint_coins = @coin.mint_coins\n\n @mint_coins_by_grouping = group_mint_coins(@mint_coins)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @mint_coins }\n end\n end", "def show\n @coin_attribute = @coin.coin_attributes.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @coin_attribute }\n end\n end", "def show\n\t\t\t\tcoin = Coin.find(params[:id])\n\t\t\t\trender json: {status: 'Success!', message: 'Loaded Coin', data:coin.render_to_string('index.html')},status: :ok\n\t\t\tend", "def show\n @coin_set = CoinSet.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @coin_set }\n end\n end", "def show\n set_coin\n render \"show.json.jbuilder\"\n end", "def new\n @our_coin = OurCoin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @our_coin }\n end\n end", "def new\n @coin_set = CoinSet.new\n @coin = Coin.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @coin_set }\n end\n end", "def index\n @bitcoins = Bitcoin.all\n end", "def index\n @cryptocurrencies = Cryptocurrency.all\n\n require 'net/http'\n require 'json'\n\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_crypto = JSON.parse(@response)\n\n @profit_loss = 0\n end", "def set_mycoin\n @mycoin = Mycoin.find(params[:id])\n end", "def show\n @money = Money.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @money }\n end\n end", "def get_coin_data\n response = HTTParty.get(API_URL)\n coindata = response.parsed_response\n end", "def display_coins\n end", "def credit\n handle_response(get(\"/credit.json\"))\n end", "def new\n @mint_coin = @coin.mint_coins.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @mint_coin }\n end\n end", "def show\n @utilized_bitcoin_wallet = UtilizedBitcoinWallet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @utilized_bitcoin_wallet }\n end\n end", "def index\n @utilized_bitcoin_wallets = UtilizedBitcoinWallet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @utilized_bitcoin_wallets }\n end\n end", "def index_coin\n @nodes = Node.where(coin: params[:coin].upcase).order(client_type: :asc ,name: :asc, version: :desc)\n\n render json: @nodes\n end", "def index\n user_coin_transactions = get_user_coin_transactions\n if user_coin_transactions\n json_response(user_coin_transactions)\n else \n json_response({:status => false, :message => 'no transaction'})\n end\n end", "def index\n @cryptocurrencies = Cryptocurrency.all\n require 'net/http'\n require 'json'\n @url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?start=1&limit=100&CMC_PRO_API_KEY=8e364003-38f2-410d-81af-9166deca3a6f'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @array1 = JSON.parse(@response).to_a\n @array2 = @array1[1].to_a\n @lookup_crypto = @array2[1].to_a\n @profit_loss = 0\n end", "def get_coin_data(url, key)\n begin\n response = RestClient.get url\n json_response = JSON.parse(response)\n if (!json_response['result'])\n logger.error 'ERROR OBJECT AT ' + url\n logger.error json_response['error'][0]\n return nil\n elsif (key != '') \n return json_response['result'][key]\n else\n # otherwise return w/o looking for a key\n return json_response['result']\n end\n\n rescue => error\n # if there was an http error, then show it - however return an empty array, so there is something there\n logger.error 'error retrieving url ------------------ ' + url\n logger.error error\n return nil\n end\n end", "def get_blockchain_stats\n stats = HTTParty.get(\"http://webbtc.com/stats.json\")\nend", "def current_price\n # hard coded currency but can be used in future to get data for multiple currencies\n response = Faraday.get(\"https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd&include_24hr_change=true\")\n if response.success? # happy path\n render json: JSON.parse(response.body), status: response.status\n else # sad path\n render json: { errors: JSON.parse(response.body) }, status: response.status\n end\n end", "def update\n if @coin.update(coin_params)\n render :show, status: :ok, location: @coin\n else\n render json: @coin.errors, status: :unprocessable_entity\n end\n end", "def credit\n handle_response(self.class.get(\"/credit.json\"))\n end", "def set_coin\n @coin = Coin.find(params[:id])\n end", "def set_coin\n @coin = Coin.find(params[:id])\n end", "def set_coin\n @coin = Coin.find(params[:id])\n end", "def update\n @mint_coin = @coin.mint_coins.find(params[:id])\n\n respond_to do |format|\n if @mint_coin.update_attributes(params[:mint_coin])\n format.html { redirect_to coin_mint_coins_url([@coin]), :notice => 'Mint coin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @mint_coin.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_coin\n @coin = Coin.find(params[:id])\n end", "def set_coin\n @coin = Coin.find(params[:id])\n end", "def create\n @mycoin = Mycoin.new(mycoin_params)\n\n \n respond_to do |format|\n if @mycoin.save\n format.html { redirect_to @mycoin, notice: 'Mycoin was successfully created.' }\n format.json { render :show, status: :created, location: @mycoin }\n else\n format.html { render :new }\n format.json { render json: @mycoin.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @wallet = Wallet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @wallet }\n end\n end", "def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end", "def update\n respond_to do |format|\n if @mycoin.update(mycoin_params)\n format.html { redirect_to @mycoin, notice: 'Mycoin was successfully updated.' }\n format.json { render :show, status: :ok, location: @mycoin }\n else\n format.html { render :edit }\n format.json { render json: @mycoin.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @cryptostables = Cryptostable.all\n\n require 'uri'\n require 'net/http'\n require 'openssl'\n\n @url = \"https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?CMC_PRO_API_KEY=#{ENV.fetch('CRYPTO')}&start=1&limit=500\"\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_cryptos = JSON.parse(@response)\n @profit_loss = 0\n end", "def getdifficulty\n @api.request 'getdifficulty'\n end", "def create\n @coin = Coin.new(coin_params)\n\n if @coin.save\n render :show, status: :created, location: @coin\n else\n render json: @coin.errors, status: :unprocessable_entity\n end\n end", "def total_coins_value\n json_response({:total_coins_value => @total_coins_val, :status => true, :message => 'calculated'})\n end", "def display_resource(coin)\n \"#{coin.name} (#{coin.symbol})\"\n end", "def coin_params\n params.require(:coin).permit(:coin_api_id, :name, :symbol)\n end", "def create\n\t\t\t\tif api_check(params[:query])\n\t\t\t\t\tcoin = Coin.new(coin_params)\n\t\t\t\t\tcoin[:name].downcase!\n\t\t\t\t\tif coin_name_check(coin[:name])\n\t\t\t\t\t\tcoin[:api_key] = params[:query]\n\t\t\t\t\t\tif coin.save\n\t\t\t\t\t\t\ttransaction = Transaction.new(transaction_params)\n\t\t\t\t\t\t\ttransaction[:api_key] = params[:query]\n\t\t\t\t\t\t\tif transaction.save\n\t\t\t\t\t\t\t\trender json: {status: 'Success!', message: 'Saved Coins', data:coin},status: :ok\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\trender json: {status: 'Error!', message: 'Transaction Not Saved', data:transaction.errors},status: :unprocessable_entity\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\trender json: {status: 'Error!', message: 'Coin Not Saved. ', data:coin.errors},status: :unprocessable_entity\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\trender json: {status: 'Error!', message: 'The only accepted coins are: Adamentium Coin, Carbonite Coin, Amazonium Coin, or Vibranium Coin'},status: :unprocessable_entity\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\trender json: {status: 'Error!', message: 'Your API-Key was not accepted. Please use one of the following: Aa11, Bb22, Cc33, or Dd44'},status: :unprocessable_entity\n\t\t\t\tend\n\t\t\tend", "def update\n\t\t\t\tcoin = Coin.find(params[:id])\n\t\t\t\tif coin.update_attributes(coin_params)\n\t\t\t\t\trender json: {status: 'Success!', message: 'Updated Coin', data:coin},status: :ok\n\t\t\t\telse\n\t\t\t\t\trender json: {status: 'Error!', message: 'Coin Not Updated', data:coin.errors},status: :unprocessable_entity\n\t\t\t\tend\n\n\t\t\tend", "def initialize\n @api_data = CryptoMarket::Api.fetch_coin_data\n @coins = []\n end", "def getdifficulty\n request :getdifficulty\n end", "def show\n require 'net/http'\n require 'json'\n\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @show_crypto = JSON.parse(@response)\n end", "def client_choose(offset = 10, limit = 20)\n response = Net::HTTP.get(\n URI(\"https://pokeapi.co/api/v2/pokemon/?offset=#{offset}&limit=#{limit}\")\n )\n \n JSON.parse(response)\nend", "def show\n @currency = Currency.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @currency }\n end\n end", "def show_page_api\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n # converts response to a Ruby hash \n @show_crypto = JSON.parse(@response)\n end", "def getLatestPrice(api_uri,curr)\n\n api_server = 'https://api.coinmarketcap.com'\n url = \"#{api_server}#{api_uri}/?convert=#{curr}\"\n api_json = getJsonObject(url)\n json_hash = Hash[*api_json.flatten]\n puts(json_hash['price_inr'])\n return json_hash['price_inr']\nend", "def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end", "def show\n @chain = Chain.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chain }\n end\n end", "def create\n @coin = Coin.new(coin_params)\n\n respond_to do |format|\n if @coin.save\n format.html { redirect_to @coin, notice: 'Coin was successfully created.' }\n format.json { render :show, status: :created, location: @coin }\n else\n format.html { render :new }\n format.json { render json: @coin.errors, status: :unprocessable_entity }\n end\n end\n end", "def getaccount(namecoin_address)\n request :getaccount, namecoin_address\n end", "def update\n respond_to do |format|\n if @coin.update(coin_params)\n format.html { redirect_to @coin, notice: 'Coin was successfully updated.' }\n format.json { render :show, status: :ok, location: @coin }\n else\n format.html { render :edit }\n format.json { render json: @coin.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @credito = Credito.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @credito }\n end\n end", "def show\n @credit = Credit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @credit }\n end\n end", "def show\n @credit = Credit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @credit }\n end\n end", "def wonky_coins(n)\n\nend", "def index\n @incomes = Income.all\n\n respond_to do |format|\n format.json { render json: @incomes }\n end\n end", "def show\n @income = Income.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @income }\n end\n end", "def index\n @chains = Chain.where(\"user_id = ?\", current_user.id)\n #@chains = Chain.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => {:tag=>\"chainlist\", :success=>true, :error=>false, :result=>@chains }}\n end\n end", "def show\n @chain = Chain.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @chain }\n end\n end", "def destroy\n @mint_coin = @coin.mint_coins.find(params[:id])\n @mint_coin.destroy\n\n respond_to do |format|\n format.html { redirect_to coin_mint_coins_url([@coin]) }\n format.json { head :no_content }\n end\n end", "def index\n @specialties = Specialty.all\n\n render json: @specialties\n end", "def coin_params\n params.require(:coin).permit(:reward, :post_id, :user_id)\n end", "def coin_params\n params.require(:coin).permit(:number)\n end", "def coin_params\n params.require(:coin).permit(:value, :name)\n end", "def show\n @pay = Pay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pay }\n end\n end", "def coin_change(coins, amount)\n make_change(coins, amount, 0, {})\nend", "def getblockchaininfo\n @api.request 'getblockchaininfo'\n end", "def prices (currency='TWD')\n get '/prices/' + currency\n end", "def query_coinmarketcap\n logger.debug 'Querying CoinMarketCap...'\n\n rparams = { limit: coins_num + coins_num_more }\n if price_additional_currency.present?\n rparams[:convert] = price_additional_currency\n end\n\n response = fetch_url('https://api.coinmarketcap.com/v1/ticker/', :get, rparams)\n unless response_ok?(response)\n log_unsuccessful(response)\n return\n end\n\n data_arr = JSON.parse(response[:body])\n unless data_arr.is_a?(Array)\n logger.debug \"RESPONSE BODY: #{response[:body]}\"\n logger.error('Response from CoinMarketCap is not an Array!')\n return\n end\n\n logger.debug \"RESPONSE ARRAY: #{data_arr}\"\n\n unless data_arr.length\n logger.error('Received response array is Empty!')\n return\n end\n\n logger.info 'CoinMarketCap queried Successfully'\n\n # Look for coins existing in DB\n coins = Coin.first(coins_num)\n\n # Is it a first query and there is nothing in DB ?\n if coins.count.zero?\n logger.info \"Coins table is empty! Let's fill it with a maximum of #{coins_num} coins received.\"\n\n coins.clear\n\n res = Coin.create(data_arr[0, coins_num])\n\n logger.info \"Inserted #{res.count} coins.\"\n res.clear\n\n coins = Coin.first(coins_num)\n end\n\n known_coins = coins.list\n known_coins_count = coins.count\n\n # Fill a new history data\n coins_info = []\n\n price_add_col = (price_additional_currency.present? ? ('price_' + price_additional_currency.downcase) : nil)\n\n known_coins.each do |coin|\n found = data_arr.select { |x| x['symbol'] == coin['symbol'] }.first\n next if found.blank?\n\n store_coin_info(coin, found, coins_info, price_add_col)\n end\n\n if known_coins_count > coins_info.length\n coins_wo_data = known_coins.map { |x| x['id'] } - coins_info.map { |x| x[:coin_id] }\n\n coins_wo_data = known_coins.select { |x| coins_wo_data.include?(x['id']) }\n\n logger.warn \"Some coins are absent in TOP #{coins_num + coins_num_more} List. Let's try to query each one separately...\"\n logger.warn \"Absent coins are #{coins_wo_data.map { |x| x['mcap_id'] }}\"\n\n found_coins = []\n rparams = {}\n rparams[:convert] = price_additional_currency if price_additional_currency.present?\n\n coins_wo_data.each do |coin|\n response = fetch_url(\"https://api.coinmarketcap.com/v1/ticker/#{coin['mcap_id']}/\", :get, rparams)\n next unless response_ok?(response)\n\n found = data_of(response[:body])\n next if found.nil?\n\n found_coins << found['id']\n store_coin_info(coin, found, coins_info, price_add_col, false)\n end\n\n if known_coins_count >= coins_info.length\n coins_wo_data = coins_wo_data.map { |x| x['mcap_id'] } - found_coins\n logger.error \"Unable to find data for #{coins_wo_data.length} coins: #{coins_wo_data}\"\n end\n end\n\n # Save to DB\n if coins_info.length\n CoinsHistory.increase_sequence(:query_num)\n\n response = CoinsHistory.create(data_fields(coins_info), data_values(coins_info))\n if response.count == coins_info.length\n logger.debug \"#{response.count} rows Inserted into coins_history Successfully\"\n else\n logger.error 'Insert of new coins history is Failed'\n end\n\n response.clear\n end\n\n known_coins.clear\n end", "def account_information\n response = get \"account\"\n data = JSON.parse response.body\n data[\"account\"][\"credits\"]\n end", "def account_information\n response = get \"account\"\n data = JSON.parse response.body\n data[\"account\"][\"credits\"]\n end", "def index\n @consents = Consent.all\n render json: @consents\n end", "def create\n @mint_coin = @coin.mint_coins.build(params[:mint_coin])\n \n respond_to do |format|\n if @mint_coin.save\n format.html { redirect_to coin_mint_coins_url([@coin]), :notice => 'Mint coin was successfully created.' }\n format.json { render :json => @mint_coin, :status => :created, :location => @mint_coin }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @mint_coin.errors, :status => :unprocessable_entity }\n end\n end\n end", "def checkout\n user = User.find(params[:id])\n\n render json: {\n cost: user.checkout,\n transaction: 'success'\n }\n\n\n end", "def denomination\n params[:coin]\n @coins = Coin.where(denomination: params[:denomination])\n end", "def credits(count = 10)\n params = { command: 'account_credits', count: count }\n get('/json.php', params)\n end", "def bitcoin\n @bitcoin_data = {\n price: @api_hash[\"RAW\"][\"BTC\"][\"USD\"][\"PRICE\"],\n change_usd: @api_hash[\"RAW\"][\"BTC\"][\"USD\"][\"CHANGE24HOUR\"].round(2),\n change_percent: @api_hash[\"RAW\"][\"BTC\"][\"USD\"][\"CHANGEPCT24HOUR\"].round(2)\n }\nend", "def new\n @coin_attribute = @coin.coin_attributes.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @coin_attribute }\n end\n end", "def index\n @purchases = Purchase.where(user_id: get_current_user.id.to_i)\n\n render json: @purchases\n end", "def credits\n return nil unless have_key?\n url = \"/v1/credits\"\n #Hashie::Mash.new(\n self.class.post(url, :headers => headers_for(url)).parsed_response\n end", "def mine(**params)\n path = File.join(plural_resource_path, \"mine\").to_s\n api_request(:get, path, params: params)\n end" ]
[ "0.84082484", "0.753926", "0.7383669", "0.7280798", "0.71560216", "0.7153468", "0.71490777", "0.7071821", "0.69310087", "0.68784136", "0.68784136", "0.67587876", "0.6739173", "0.6729109", "0.6688378", "0.668214", "0.66332483", "0.6594243", "0.65897954", "0.6559238", "0.65318984", "0.6485142", "0.6433555", "0.63488096", "0.6346965", "0.63040984", "0.62163574", "0.62131816", "0.62045366", "0.6127068", "0.6100534", "0.6088923", "0.60316426", "0.60257566", "0.60144883", "0.59556633", "0.59282154", "0.5908276", "0.5906863", "0.5893639", "0.58870983", "0.5884246", "0.5884246", "0.5884246", "0.5840124", "0.58329505", "0.58158845", "0.57993567", "0.5770761", "0.57597333", "0.57239145", "0.5722409", "0.5714076", "0.57135653", "0.56985563", "0.56907654", "0.5673059", "0.5664497", "0.56531566", "0.5647132", "0.56467927", "0.56453615", "0.56213415", "0.56104213", "0.56052214", "0.55966234", "0.5592872", "0.5592368", "0.55913407", "0.558786", "0.5585351", "0.5571698", "0.5557927", "0.5557927", "0.55542654", "0.5548863", "0.5548298", "0.5535417", "0.5532897", "0.5531817", "0.55257004", "0.5519627", "0.55142117", "0.5506566", "0.5495455", "0.54881316", "0.54773474", "0.5477211", "0.5471582", "0.54690284", "0.54690284", "0.5462603", "0.54598427", "0.5458138", "0.5457706", "0.5453428", "0.54518855", "0.54500455", "0.54449505", "0.5441948", "0.54340464" ]
0.0
-1
POST /mycoins POST /mycoins.json
def create @mycoin = Mycoin.new(mycoin_params) respond_to do |format| if @mycoin.save format.html { redirect_to @mycoin, notice: 'Mycoin was successfully created.' } format.json { render :show, status: :created, location: @mycoin } else format.html { render :new } format.json { render json: @mycoin.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @mint_coin = @coin.mint_coins.build(params[:mint_coin])\n \n respond_to do |format|\n if @mint_coin.save\n format.html { redirect_to coin_mint_coins_url([@coin]), :notice => 'Mint coin was successfully created.' }\n format.json { render :json => @mint_coin, :status => :created, :location => @mint_coin }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @mint_coin.errors, :status => :unprocessable_entity }\n end\n end\n end", "def coin_params\n params.require(:coin).permit(:reward, :post_id, :user_id)\n end", "def coins\n\t\tres = {}\n\t\tuser = User.find_by_token(params[:token])\n\t\tif user\n\t\t\tres[:status] = \"0\"\n\t\t\tres[:coins] = user.coins\n\t\telse\n\t\t\tres[:status] = \"1\"\n\t\tend\n\t\trender json: res\n\tend", "def create\n @our_coin = OurCoin.new(params[:our_coin])\n\n respond_to do |format|\n if @our_coin.save\n format.html { redirect_to @our_coin, :notice => 'Our coin was successfully created.' }\n format.json { render :json => @our_coin, :status => :created, :location => @our_coin }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @our_coin.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @coin = Coin.new(coin_params)\n\n respond_to do |format|\n if @coin.save\n format.html { redirect_to @coin, notice: 'Coin was successfully created.' }\n format.json { render :show, status: :created, location: @coin }\n else\n format.html { render :new }\n format.json { render json: @coin.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @coin = Coin.new(coin_params)\n\n if @coin.save\n render :show, status: :created, location: @coin\n else\n render json: @coin.errors, status: :unprocessable_entity\n end\n end", "def create_coins_from_attributes\n @api_data.each do |coin|\n create_coin(coin)\n end\n end", "def coin_params\n params.require(:coin).permit(:value, :name)\n end", "def coin_params\n params.require(:coin).permit(:coin_api_id, :name, :symbol)\n end", "def get_coins\n get(\"/getcoins\")\n end", "def new\n @mint_coin = @coin.mint_coins.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @mint_coin }\n end\n end", "def mycoin_params\n params.require(:mycoin).permit(:category, :coinname, :price, :user_id,:deposit)\n end", "def create\n\t\t\t\tif api_check(params[:query])\n\t\t\t\t\tcoin = Coin.new(coin_params)\n\t\t\t\t\tcoin[:name].downcase!\n\t\t\t\t\tif coin_name_check(coin[:name])\n\t\t\t\t\t\tcoin[:api_key] = params[:query]\n\t\t\t\t\t\tif coin.save\n\t\t\t\t\t\t\ttransaction = Transaction.new(transaction_params)\n\t\t\t\t\t\t\ttransaction[:api_key] = params[:query]\n\t\t\t\t\t\t\tif transaction.save\n\t\t\t\t\t\t\t\trender json: {status: 'Success!', message: 'Saved Coins', data:coin},status: :ok\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\trender json: {status: 'Error!', message: 'Transaction Not Saved', data:transaction.errors},status: :unprocessable_entity\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\trender json: {status: 'Error!', message: 'Coin Not Saved. ', data:coin.errors},status: :unprocessable_entity\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\trender json: {status: 'Error!', message: 'The only accepted coins are: Adamentium Coin, Carbonite Coin, Amazonium Coin, or Vibranium Coin'},status: :unprocessable_entity\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\trender json: {status: 'Error!', message: 'Your API-Key was not accepted. Please use one of the following: Aa11, Bb22, Cc33, or Dd44'},status: :unprocessable_entity\n\t\t\t\tend\n\t\t\tend", "def coin_params\n params.require(:coin).permit(:number)\n end", "def run\n create_coins_from_attributes\n end", "def index\n # this whole process is updating the users coins with the currnet price from the api. pulls the users coins and if a coin matches then update the price in usd. and return the coin.\n coins = HTTParty.get(BASE_URL) # this will bring back the top 100 coins in an array\n user_coins = current_user.coins\n user_coins.each do |coin|\n res_coin = coins.find { |c| c['id'] == coin.cmc_id }\n coin.update(price: res_coin['price_usd']) if res_coin \n end \n render json: current_user.coins # if we don't authenticate_user before then we cant user current_user. it is a built in devise function\n end", "def new\n @our_coin = OurCoin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @our_coin }\n end\n end", "def coin_params\n\t\t\t\tparams.permit(:name, :value, :api_key)\n\t\t\tend", "def create\n @transaction = Transaction.new(transaction_params)\n\n # Assigns the correct user_id in case the user puts another user's ID\n\n @transaction.user_id = User.find_by(api_key: params[:api_key]).id\n\n if @transaction.save\n\n @coin = Coin.find(@transaction.coin_id)\n\n # If deposit, increment @coin's value, else decrement \n # Also, send email if value is less than 4\n\n if @transaction.transaction_type == 1\n @coin.update_attributes(value: @coin.value+1)\n if @coin.value < 4\n LowFundsMailer.low_funds(@coin).deliver\n end\n\n else\n\n # If withdraw, must ensure the value is > 0\n\n if (@coin.value > 0)\n @coin.update_attributes(value: @coin.value-1)\n if @coin.value < 4\n LowFundsMailer.low_funds(@coin).deliver\n end\n else\n render json: [\"Sorry! There are no more of those coins.\"], status: 422\n end\n end\n @coin.save\n\n # Return the transaction \n \n render json: @transaction\n else\n render json: @transaction.errors.full_messages, status: 422\n end\n end", "def new\n @coin_set = CoinSet.new\n @coin = Coin.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @coin_set }\n end\n end", "def accept_coins(coins_hash)\n coins_hash[:valid][:coins].each do |k, v|\n while v > 0\n @coins << Coin.new(k)\n v -= 1\n end\n end\n end", "def create\n @coin_ico = CoinIco.new(coin_ico_params)\n\n respond_to do |format|\n if @coin_ico.save\n format.html { redirect_to coin_icos_path, notice: 'Coin ico was successfully created.' }\n format.json { render :show, status: :created, location: @coin_ico }\n else\n format.html { render :new }\n format.json { render json: @coin_ico.errors, status: :unprocessable_entity }\n end\n end\n end", "def transaction_params\n params.permit(:user_id, :coin_id)\n end", "def new\n @coin_attribute = @coin.coin_attributes.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @coin_attribute }\n end\n end", "def create\n @coin_set = CoinSet.new(params[:coin_set])\n\n respond_to do |format|\n if @coin_set.save\n format.html { redirect_to root_path, notice: 'Coin set was successfully created.' }\n format.json { render json: @coin_set, status: :created, location: @coin_set }\n else\n format.html { render action: \"new\" }\n format.json { render json: @coin_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def coin_params\n params.permit(:name, :currency, :symbol, :logo_url, :price, :rank, :price_date, :market_cap, :circulating_supply, :max_supply, :high, :high_timestamp, :max_sold)\n end", "def set_mycoin\n @mycoin = Mycoin.find(params[:id])\n end", "def create_coin(coin)\n name = coin['name']\n price_usd = coin['price_usd']\n price_btc = coin['price_btc']\n market_cap_usd = coin['market_cap_usd']\n percent_change_24h = coin['percent_change_24h']\n last_updated_unix = coin['last_updated']\n CryptoMarket::Coin.new(name, price_usd, price_btc, market_cap_usd,\n percent_change_24h, last_updated_unix).tap do |new_coin|\n coins << new_coin\n end\n end", "def index\n @mint_coins = @coin.mint_coins\n\n @mint_coins_by_grouping = group_mint_coins(@mint_coins)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @mint_coins }\n end\n end", "def index\n @users = User.all\n render json: @users.to_json(include: ['coins']) \n end", "def create\n @coin_attribute = @coin.coin_attributes.build(params[:coin_attribute])\n\n \n respond_to do |format|\n if @coin_attribute.save\n format.html { redirect_to coin_coin_attributes_url([@coin]), :notice => 'Attribute was successfully created.' }\n format.json { render :json => @coin_attribute, :status => :created, :location => @coin_attribute }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @coin_attribute.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n if params.has_key?(:unbound_contributions)\n user = User.find_by(id: params[:user_id])\n ride = Ride.find_by(id: params[:ride_id])\n price = ride[:price]\n distance = user.rides.find_by(id: params[:ride_id])[:realtime_km]\n project_id = ride.project[:id]\n\n contribution_amount = price*distance\n user.update_attribute(:unbound_contributions, contribution_amount)\n user.contributions.update_attributes(amount: contribution_amount, project_id: project_id)\n user.rides.find_by(id: ride.id).update_attribute(:is_paid, true)\n render json: {:status => 200}\n else\n ride = Ride.find_by(id: params[:ride_id])\n new_ride = ride.requests.create!(passenger_id: params[:user_id], requested_from: params[:requested_from],\n request_to: params[:requested_to])\n unless new_ride.nil?\n respond_with ride: new_ride, anfrage: true, status: :created\n else\n respond_with ride: new_ride, anfrage: false, status: :bad_request\n end\n end\n end", "def index\n @coin_attributes = @coin.coin_attributes\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @coin_attributes }\n end\n end", "def create\n @currency = Currency.first\n @wallet = Wallet.new(wallet_params)\n @wallet.user_id = current_user.id\n \n respond_to do |format|\n if @wallet.save\n format.html { redirect_to @wallet, notice: 'Wallet was successfully created.' }\n format.json { render :show, status: :created, location: @wallet }\n else\n format.json { render json: @wallet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n if params[:type] == 'deposit'\n transaction = Transaction.create(user: @user, coin: @user_coin, transaction_type: params[:transaction_type], value: params[:value])\n \n transaction.update(:transaction_type => 'deposit')\n increment_coin(params[:value])\n deposited_coin = get_deposited_coin(transaction)\n json_response({:transaction => transaction, :deposited_coin => deposited_coin, :user => @user}, :created)\n \n elsif params[:type] == 'withdraw'\n \n withdraw_status = decrement_coin(params[:value])\n if withdraw_status == true\n transaction = Transaction.create(user: @user, coin: @user_coin, transaction_type: params[:transaction_type], value: params[:value])\n transaction.update(:transaction_type => 'withdrawal')\n deposited_coin = get_deposited_coin(transaction)\n json_response({:transaction => transaction, :deposited_coin => deposited_coin, :user => @user}, :created)\n else\n json_response({:message => 'coin value too low'}, :created)\n end\n end\n end", "def update\n @mint_coin = @coin.mint_coins.find(params[:id])\n\n respond_to do |format|\n if @mint_coin.update_attributes(params[:mint_coin])\n format.html { redirect_to coin_mint_coins_url([@coin]), :notice => 'Mint coin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @mint_coin.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @coins = Coin.all\n render \"index.json.jbuilder\"\n end", "def create\n @utilized_bitcoin_wallet = UtilizedBitcoinWallet.new(params[:utilized_bitcoin_wallet])\n\n respond_to do |format|\n if @utilized_bitcoin_wallet.save\n format.html { redirect_to @utilized_bitcoin_wallet, notice: 'Utilized bitcoin wallet was successfully created.' }\n format.json { render json: @utilized_bitcoin_wallet, status: :created, location: @utilized_bitcoin_wallet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @utilized_bitcoin_wallet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @mycoin.update(mycoin_params)\n format.html { redirect_to @mycoin, notice: 'Mycoin was successfully updated.' }\n format.json { render :show, status: :ok, location: @mycoin }\n else\n format.html { render :edit }\n format.json { render json: @mycoin.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t\t\tcoin = Coin.find(params[:id])\n\t\t\t\tif coin.update_attributes(coin_params)\n\t\t\t\t\trender json: {status: 'Success!', message: 'Updated Coin', data:coin},status: :ok\n\t\t\t\telse\n\t\t\t\t\trender json: {status: 'Error!', message: 'Coin Not Updated', data:coin.errors},status: :unprocessable_entity\n\t\t\t\tend\n\n\t\t\tend", "def create\n cb = Coin.retrieve_from_api(transaction_params[\"CB_apikey\"])\n cs = Coin.retrieve_from_api(transaction_params[\"CS_apikey\"])\n\n @transaction = Transaction.new(transaction_params.merge(wallet_id: current_user.wallet.id, CBought_id: cb, CSold_id: cs))\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, status: :unprocessable_entity }\n format.json { render json: @transaction.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bitcoin = Bitcoin.new(bitcoin_params)\n @bitcoin.user = current_user\n respond_to do |format|\n if @bitcoin.save\n format.html { redirect_to bitcoin_steps_path, notice: 'Add images and enter payment details' }\n format.json { render :show, status: :created, location: @bitcoin }\n else\n format.html { render :new }\n format.json { render json: @bitcoin.errors, status: :unprocessable_entity }\n end\n end\n end", "def make_coinbase_request verb, path, options\n\n key = payment_method.preferred_api_key\n secret = payment_method.preferred_api_secret\n\n base_uri = \"https://integracion-2017-dev.herokuapp.com/\"\n nonce = (Time.now.to_f * 1e6).to_i\n message = nonce.to_s + base_uri + path + options.to_json\n #signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new('sha256'), secret, message)\n\n headers = {\n 'ACCESS_KEY' => key,\n #'ACCESS_SIGNATURE' => signature,\n 'ACCESS_NONCE' => nonce.to_s,\n \"Content-Type\" => \"application/json\",\n }\n\n #r = self.class.send(verb, base_uri + path, {headers: headers, body: options.to_json})\n JSON.parse(r.body)\n end", "def donate_cash\n @donation_cash = DonationCash.new(donation_cash_params)\n @sender = User.find(@donation_cash.user_id)\n @donation_cash.pot = @pot\n @donation_cash.user = @sender\n @pot.cash_collected = @pot.cash_collected + @donation_cash.amount\n\n respond_to do |format|\n if @donation_cash.save && @pot.save\n format.json\n else\n format.json { render json: @donation_cash.errors, status: :unprocessable_entity }\n end\n end\n end", "def list_coins\n endpoint = \"#{HOST}/v1/cryptocurrency/map\"\n get(endpoint)\n end", "def create\n @bitcoin_transaction = BitcoinTransaction.new(bitcoin_transaction_params)\n\n respond_to do |format|\n if @bitcoin_transaction.save\n format.html { redirect_to @bitcoin_transaction, notice: 'Bitcoin transaction was successfully created.' }\n format.json { render :show, status: :created, location: @bitcoin_transaction }\n else\n format.html { render :new }\n format.json { render json: @bitcoin_transaction.errors, status: :unprocessable_entity }\n end\n end\n end", "def total_coins_value\n json_response({:total_coins_value => @total_coins_val, :status => true, :message => 'calculated'})\n end", "def create\n render json: ::Transaction::CreditSerializer.new( do_credit! ), status: :created\n end", "def create\n @bonu = Bonu.new(bonu_params)\n @user = @bonu.user\n\n respond_to do |format|\n if @bonu.save\n @user.addValue(@bonu.amount)\n format.html { redirect_to root_url, notice: 'Bonu was successfully created.' }\n format.json { render :show, status: :created, location: @bonu }\n else\n format.html { render :new }\n format.json { render json: @bonu.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @money = current_user.money.build(params[:money])\n # @money = Money.new(params[:money])\n\n respond_to do |format|\n if @money.save\n format.html { redirect_to @money, notice: 'Money was successfully created.' }\n format.json { render json: @money, status: :created, location: @money }\n else\n format.html { render action: \"new\" }\n format.json { render json: @money.errors, status: :unprocessable_entity }\n end\n end\n end", "def postTransaction(useridgiving, useridreceiving, amount)\n parameters={useridgiving: useridgiving.to_i, useridreceiving: useridreceiving.to_i, amount: amount.to_f, state: \"initial\"}\n options = {\n :body => parameters.to_json,\n :headers => {\n 'Content-Type' => 'application/json'\n }\n }\n results = HTTParty.post(\"http://192.168.99.101:4050/transactions\", options) # create initial state\n return results\n end", "def update\n if @coin.update(coin_params)\n render :show, status: :ok, location: @coin\n else\n render json: @coin.errors, status: :unprocessable_entity\n end\n end", "def coinrate_params\n params.require(:coinrate).permit(:sale, :buy, :todate, :ratetype_id)\n end", "def create\n @money = Money.new(money_params)\n\n respond_to do |format|\n if @money.save\n format.html { redirect_to @money, notice: 'Money was successfully created.' }\n format.json { render :show, status: :created, location: @money }\n else\n format.html { render :new }\n format.json { render json: @money.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cryptocurrency = Cryptocurrency.new(cryptocurrency_params)\n\n respond_to do |format|\n if @cryptocurrency.save\n format.html { redirect_to @cryptocurrency, notice: \"Cryptocurrency was successfully created.\" }\n format.json { render :show, status: :created, location: @cryptocurrency }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @cryptocurrency.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_money!(json)\n put_inside!(money_from_json(json))\n end", "def give_coins(token, amount)\n raise 'Only Game or action resolvers should call this method' if token != @action_token\n @coins += amount\n end", "def create\n @cryptocurrency = Cryptocurrency.new(cryptocurrency_params)\n\n respond_to do |format|\n if @cryptocurrency.save\n format.html { redirect_to @cryptocurrency, notice: 'Cryptocurrency was successfully created.' }\n format.json { render :show, status: :created, location: @cryptocurrency }\n else\n format.html { render :new }\n format.json { render json: @cryptocurrency.errors, status: :unprocessable_entity }\n end\n end\n end", "def transactions_nequi_wompi(pesos, reference, customer_email, phone_number)\n data = {\n # Metodo: encargado de generar el token de aceptacion de abeas data necesario para trabajar con Wompi\n acceptance_token: accept_token_wompi,\n amount_in_cents: pesos.to_i*100,# se agregan 2 ceros para los los centavos\n currency: \"COP\",\n customer_email: customer_email,\n reference: reference,\n payment_method: {\n type: \"NEQUI\",\n phone_number: phone_number\n }\n }\n\n require 'uri'\n\t require 'net/http'\n \n uri = URI.parse(BASE_URL_WOMPI+'transactions')\n https = Net::HTTP.new(uri.host,uri.port)\n https.use_ssl = true\n https.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(uri, initheader = {'Content-Type' =>'application/json'})\n\n request['Accept'] = 'application/json'\n request['Accept-language'] = 'en'\n request['authorization'] = PRIVATE_KEY_WOMPI\n\n request.body = data.to_json\n request = https.request(request)\n\n response = JSON.parse(request.body)\n add_amount = response[\"data\"][\"amount_in_cents\"].to_i/100\n self.update!(id_wompi: response[\"data\"][\"id\"], amount: add_amount, status: response[\"data\"][\"status\"])\n # update amount driver\n current_amount = self.trip.driver.amount.to_i\n self.trip.driver.update(amount: (add_amount+current_amount))\n\n response\n end", "def coin_change(coins, amount)\n make_change(coins, amount, 0, {})\nend", "def test_create_transaction\n params = {\n bank_transaction: {\n bank_account_id: 1,\n date: Time.local(2012, 4, 16),\n amount: 55\n }\n }\n\n post '/api/banks/1/transactions', params\n data = ActiveSupport::JSON.decode last_response.body\n\n assert last_response.successful?\n assert_match('application/json', last_response.content_type)\n assert BankTransaction.find(data['id'])\n end", "def send_money(params)\n fail ArgumentError, 'Hash is expected as params' unless params.is_a?(Hash)\n fail ArgumentError, 'String is expected as :amount' unless params[:amount].is_a?(String)\n fail ArgumentError, 'String is expected as :address' unless params[:address].is_a?(String)\n fail ArgumentError, 'Invalid amount format' unless params[:amount] =~ /^\\d+\\.\\d+$/\n fail ArgumentError, 'Invalid address format' unless params[:address] =~ /^[A-Za-z0-9]+$/\n Cubits.connection.post(\n '/api/v1/send_money',\n amount: params[:amount], address: params[:address]\n )\n end", "def checkout\n user = User.find(params[:id])\n\n render json: {\n cost: user.checkout,\n transaction: 'success'\n }\n\n\n end", "def update\n respond_to do |format|\n if @coin.update(coin_params)\n format.html { redirect_to @coin, notice: 'Coin was successfully updated.' }\n format.json { render :show, status: :ok, location: @coin }\n else\n format.html { render :edit }\n format.json { render json: @coin.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @mint_coin = @coin.mint_coins.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @mint_coin }\n end\n end", "def new\n @utilized_bitcoin_wallet = UtilizedBitcoinWallet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @utilized_bitcoin_wallet }\n end\n end", "def bitcoin\n @bitcoin_data = {\n price: @api_hash[\"RAW\"][\"BTC\"][\"USD\"][\"PRICE\"],\n change_usd: @api_hash[\"RAW\"][\"BTC\"][\"USD\"][\"CHANGE24HOUR\"].round(2),\n change_percent: @api_hash[\"RAW\"][\"BTC\"][\"USD\"][\"CHANGEPCT24HOUR\"].round(2)\n }\nend", "def set_coin\n @coin = Coin.find(params[:id])\n end", "def set_coin\n @coin = Coin.find(params[:id])\n end", "def set_coin\n @coin = Coin.find(params[:id])\n end", "def create\n @wallet = Wallet.build_secure_wallet(wallet_params)\n\n respond_to do |format|\n if @wallet.save\n format.html { redirect_to @wallet, notice: 'Wallet was successfully created.' }\n format.json { render :show, status: :created, location: @wallet }\n else\n format.html { render :new }\n format.json { render json: @wallet.errors, status: :unprocessable_entity }\n end\n end\n end", "def credit\n handle_response(get(\"/credit.json\"))\n end", "def user_withdrawal\n @coin = Coin.find(params[:coin_name])\n if @coin.blank?\n render json: {error: \"Sorry, this coin is unavailable.\",\n status: 400}\n elsif @coin.amount <= 0\n render json: {error: \"Sorry, not enough amount for withdrawal\",\n status: 400}\n else\n @withdrawal = Transaction.create(transaction_type: \"Withdrawal\", coin_name: params[:coin_name], user_id: user.id)\n @coin.decrement(:amount)\n @withdrawal.save\n render json: @withdrawal\n end\n # emails an alert if the amount of the coin is less than 4\n if @coin.amount < 4\n AdminAlert.coin_required(@coin).deliver\n end\n\n end", "def donate_credit\n @donation_credit = DonationCredit.new(donation_credit_params)\n @sender = User.find(@donation_credit.user_id)\n @donation_credit.pot = @pot\n @donation_credit.user = @sender\n @pot.credits_collected = @pot.credits_collected + @donation_credit.quantity\n\n respond_to do |format|\n if @donation_credit.save && @pot.save\n format.json\n else\n format.json { render json: @donation_credit.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pay = Pay.new(params[:pay])\n\n respond_to do |format|\n if @pay.save\n format.html { redirect_to @pay, notice: 'Pay was successfully created. Happy!.' }\n format.json { render json: @pay, status: :created, location: @pay }\n #@user.rest = @user.rest - @pay.amount\n else\n format.html { render action: \"new\" }\n format.json { render json: @pay.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(user_id, options={})\n request(:post, \"/users/#{user_id}/payments.json\", default_params(options))\n end", "def create\n @users_wallet = Users::Wallet.new(users_wallet_params)\n\n respond_to do |format|\n if @users_wallet.save\n format.html { redirect_to @users_wallet, notice: \"Wallet was successfully created.\" }\n format.json { render :show, status: :created, location: @users_wallet }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @users_wallet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_item()\n\n request_body = {\n 'name' => 'Milkshake',\n 'variations' => [\n {\n 'name' => 'Small',\n 'pricing_type' => 'FIXED_PRICING',\n 'price_money' => {\n 'currency_code' => 'USD',\n 'amount' => 400\n }\n }\n ]\n }\n\n response = Unirest.post CONNECT_HOST + '/v1/' + LOCATION_ID + '/items',\n headers: REQUEST_HEADERS,\n parameters: request_body.to_json\n\n if response.code == 200\n puts 'Successfully created item:'\n puts JSON.pretty_generate(response.body)\n return response.body\n else\n puts 'Item creation failed'\n puts response.body\n return nil\n end\nend", "def index\n @coins = Coin.all\n end", "def destroy\n @mint_coin = @coin.mint_coins.find(params[:id])\n @mint_coin.destroy\n\n respond_to do |format|\n format.html { redirect_to coin_mint_coins_url([@coin]) }\n format.json { head :no_content }\n end\n end", "def set_coin\n @coin = Coin.find(params[:id])\n end", "def main_page_api\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n # converts response to a Ruby hash \n @coins = JSON.parse(@response)\n @my_coins = [\"XLM\", \"BTC\", \"ADA\", \"STEEM\", \"ETH\"] \n end", "def create\n @credit = Credit.new(params[:credit])\n \n @credit.amount = 0 if params[:credit][:amount].empty?\n current_credit = Credit.find_by_customer_id(session[:cust_id])\n \n authorise_amount @credit.amount\n\n if current_credit \n current_credit.amount += @credit.amount\n @credit = current_credit\n else\n @credit.customer_id = session[:cust_id]\n # @credit.save\n end\n\n\n\n\n respond_to do |format|\n if @credit.save\n format.html { redirect_to credits_url, notice: 'Credit was successfully created.' }\n format.json { render json: @credit, status: :created, location: @credit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @credit.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @our_coin = OurCoin.find(params[:id])\n\n respond_to do |format|\n if @our_coin.update_attributes(params[:our_coin])\n format.html { redirect_to @our_coin, :notice => 'Our coin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @our_coin.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put_coin(value)\n @calculator.add_pending value\n end", "def create\n @income = current_user.incomes.new(params[:income])\n\n respond_to do |format|\n if @income.save\n format.html { redirect_to incomes_path, notice: 'Income was successfully created.' }\n format.json { render json: @income, status: :created, location: @income }\n else\n format.html { render action: \"new\" }\n format.json { render json: @income.errors, status: :unprocessable_entity }\n end\n end\n end", "def buy(params)\n fail ArgumentError, 'Hash is expected as params' unless params.is_a?(Hash)\n fail ArgumentError, 'Hash is expected as :sender' unless params[:sender].is_a?(Hash)\n sender = params[:sender]\n fail ArgumentError, 'String is expected as sender[:currency]' unless sender[:currency].is_a?(String)\n fail ArgumentError, 'String is expected as sender[:amount]' unless sender[:amount].is_a?(String)\n fail ArgumentError, 'Invalid amount format' unless sender[:amount] =~ /^\\d+\\.\\d+$/\n Cubits.connection.post(\n '/api/v1/buy',\n sender: {\n currency: sender[:currency],\n amount: sender[:amount]\n }\n )\n end", "def create\n account = Account.find(params[:account_id].to_i)\n @transaction = account.transactions.build(transaction_params)\n if @transaction.save\n account.update(balance: account.get_balance)\n transaction_json = TransactionSerializer.new(@transaction).serialized_json\n render json: transaction_json\n else\n render json: {\n errors: @transaction.errors.full_messages\n }\n end\n end", "def create\n megam_rest.post_accounts(to_hash)\n end", "def post_request(secureNetId, secureKey, url)\n uri = URI.parse(url) # Parse the URI\n http = Net::HTTP.new(uri.host, uri.port) # New HTTP connection\n http.use_ssl = true # Must use SSL!\n req = Net::HTTP::Post.new(uri.request_uri) # HTTP POST request \n body = {} # Request body hash\n yield body # Build body of request\n req.body = body.to_json # Convert hash to json string\n req[\"Content-Type\"] = 'application/json' # JSON body\n req[\"Origin\"] = 'worldpay.com' # CORS origin\n req.basic_auth secureNetId, secureKey # HTTP basic auth\n res = http.request(req) # Make the call\n return JSON.parse(res.body) # Convert JSON to hashmap\nend", "def create\n @account = Account.new(account_params)\n\n if @account.save\n if params[\"account\"][\"income\"]\n @incomes.each do |income|\n if params[\"account\"][\"income\"][\"#{income.id}\"]\n account_income = @account.account_incomes.new(name: income.name, value: income.value)\n account_income.save\n end\n end\n end\n if params[\"account\"][\"outcome\"]\n @outcomes.each do |outcome|\n if params[\"account\"][\"outcome\"][\"#{outcome.id}\"]\n account_outcome = @account.account_outcomes.new(name: outcome.name, value: outcome.value)\n account_outcome.save\n end\n end\n end\n start_balance = params['account']['start_balance']\n if not start_balance\n start_balance = 0\n else \n start_balance = start_balance.to_i\n end\n if start_balance > 0\n account_income = @account.account_incomes.new(name: 'Начальные средства', value: start_balance)\n account_income.save\n elsif start_balance < 0\n account_outcome = @account.account_outcomes.new(name: 'Начальные средства', value: -start_balance)\n account_outcome.save\n end\n\n update_money(@account)\n @account.save\n\n redirect_to @account\n else\n render :new\n end\n end", "def coin_ico_params\n params.require(:coin_ico).permit(:launcher_id,:description,:coin_name,:rate,:total_supply,:website,:presentation_link,:facebook_link,:twitter_link,:telegram_link,:coin_logo,:cover_photo,:white_paper,:country,:accepts,:token_symbol,{rounds: {}})\n \n end", "def pay_beer\n @player = Player.find(params[:id])\n @player.beer_paid = @player.beer_paid + 1\n @res = @player.save\n \n respond_to do |format|\n format.json {\n render json: {\n :status => @res,\n :player => @player\n }\n }\n end\n end", "def bitcoin_params\n params.require(:bitcoin).permit(:cardamount, :number, :user_id, :bitcoinnumber, :mobilemoneyname, :mobilemoneynumber, :terms, :photos_attributes => [:gcpicture])\n end", "def show\n coin = Coin.find(params[:id]) \n require 'net/http'\n url = url = \"https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=#{coin.coin_api_id}&order=market_cap_desc&per_page=100&page=1&sparkline=false&price_change_percentage=1h\"\n request = URI.parse(url)\n response = Net::HTTP.get_response(request)\n crypto_hash = JSON.parse(response.body)\n coin.image = crypto_hash[0]['image']\n coin.current_price = crypto_hash[0]['current_price']\n coin.price_change_percentage_1h_in_currency = crypto_hash[0]['price_change_percentage_1h_in_currency']\n coin.high_24h = crypto_hash[0]['high_24h']\n coin.low_24h = crypto_hash[0]['low_24h']\n coin.total_volume = crypto_hash[0]['total_volume']\n coin.market_cap = crypto_hash[0]['market_cap']\n coin.market_cap_rank = crypto_hash[0]['market_cap_rank']\n coin.circulating_supply = crypto_hash[0]['circulating_supply']\n\n # Serializer\n # render json: CoinSerializer.new(coin)\n render json: coin\n end", "def set_coin\n @coin = Coin.find(params[:id])\n end", "def cash_params\n params.require(:cash).permit(:concept, :coin, :entry, :egress, :register, :created_at)\n end", "def bonu_params\n params.require(:bonu).permit(:user_id, :amount)\n end", "def settle\n \n\n if params[\"code\"]\n auth_code = params[\"code\"]\n end \n url = \"https://api.venmo.com/v1/oauth/access_token\"\n @response = HTTParty.post(url, :query => {:client_id => '1916', :client_secret => 'eGcyNHaysfbFGZ6xkMffUw3gGrKFzksG', :code => auth_code})\n user = @response[\"user\"]\n @access_token = @response[\"access_token\"]\n @refresh_token = @response[\"refresh_token\"]\n @email = params[:email]\n @amount = params[:amount]\n \n url = \"https://api.venmo.com/v1/payments\"\n @amount = HTTParty.post(url, :query => { \"access_token\" => @access_token, :email => @email, :amount => @amount, :note => 'PayUp'})\n redirect_to bets_path\n end", "def get_coin\n @coin = Coin.find(params[:coin_id])\n end" ]
[ "0.67880285", "0.6718918", "0.6638327", "0.66376436", "0.6620706", "0.655323", "0.6550608", "0.64727485", "0.6425487", "0.6424369", "0.6400119", "0.6386561", "0.636734", "0.63596565", "0.629563", "0.6102046", "0.592336", "0.5900385", "0.5881751", "0.5863372", "0.5841663", "0.57947475", "0.5786961", "0.5768212", "0.5763353", "0.57575524", "0.5743053", "0.5733235", "0.5684004", "0.567447", "0.5670435", "0.56571424", "0.56462425", "0.5639066", "0.56199265", "0.56140167", "0.5577918", "0.5570201", "0.55665505", "0.5508336", "0.5498028", "0.54902977", "0.548856", "0.5468803", "0.5465079", "0.5449206", "0.5444989", "0.5407752", "0.5402956", "0.53478235", "0.5345119", "0.53442675", "0.53377783", "0.5334426", "0.5324771", "0.5322944", "0.5306655", "0.5294094", "0.5284887", "0.52821946", "0.527751", "0.5261823", "0.5257976", "0.5241231", "0.5238394", "0.52259856", "0.5212918", "0.5211197", "0.5211197", "0.5211197", "0.5208874", "0.5192804", "0.51847064", "0.5180672", "0.5170434", "0.5167359", "0.5160462", "0.515679", "0.51453036", "0.51385474", "0.5131476", "0.51278025", "0.51202387", "0.51192605", "0.5114426", "0.5097036", "0.5091527", "0.50873667", "0.5086811", "0.5082775", "0.50739175", "0.5071953", "0.5070237", "0.5069833", "0.5065687", "0.5060153", "0.50586426", "0.5041324", "0.5040059", "0.5035205" ]
0.7042763
0
PATCH/PUT /mycoins/1 PATCH/PUT /mycoins/1.json
def update respond_to do |format| if @mycoin.update(mycoin_params) format.html { redirect_to @mycoin, notice: 'Mycoin was successfully updated.' } format.json { render :show, status: :ok, location: @mycoin } else format.html { render :edit } format.json { render json: @mycoin.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @mint_coin = @coin.mint_coins.find(params[:id])\n\n respond_to do |format|\n if @mint_coin.update_attributes(params[:mint_coin])\n format.html { redirect_to coin_mint_coins_url([@coin]), :notice => 'Mint coin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @mint_coin.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @coin.update(coin_params)\n format.html { redirect_to @coin, notice: 'Coin was successfully updated.' }\n format.json { render :show, status: :ok, location: @coin }\n else\n format.html { render :edit }\n format.json { render json: @coin.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @our_coin = OurCoin.find(params[:id])\n\n respond_to do |format|\n if @our_coin.update_attributes(params[:our_coin])\n format.html { redirect_to @our_coin, :notice => 'Our coin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @our_coin.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @coin_attribute = @coin.coin_attributes.find(params[:id])\n \n respond_to do |format|\n if @coin_attribute.update_attributes(params[:coin_attribute])\n format.html { redirect_to coin_coin_attributes_url([@coin]), :notice => 'Attribute was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @coin_attribute.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @coin_set = CoinSet.find(params[:id])\n \n respond_to do |format|\n if @coin_set.update_attributes(params[:coin_set])\n # an update should be coming from the coin_set show page.\n format.html { redirect_to @coin_set, notice: 'Coin set was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @coin_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @coin.update(coin_params)\n render :show, status: :ok, location: @coin\n else\n render json: @coin.errors, status: :unprocessable_entity\n end\n end", "def update\n\t\t\t\tcoin = Coin.find(params[:id])\n\t\t\t\tif coin.update_attributes(coin_params)\n\t\t\t\t\trender json: {status: 'Success!', message: 'Updated Coin', data:coin},status: :ok\n\t\t\t\telse\n\t\t\t\t\trender json: {status: 'Error!', message: 'Coin Not Updated', data:coin.errors},status: :unprocessable_entity\n\t\t\t\tend\n\n\t\t\tend", "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 patch!\n request! :patch\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update\n respond_to do |format|\n if @coin_ico.update(coin_ico_params)\n format.html { redirect_to coin_icos_path, notice: 'Coin ico was successfully updated.' }\n format.json { render :show, status: :ok, location: @coin_ico }\n else\n format.html { render :edit }\n format.json { render json: @coin_ico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bitcoin.update(bitcoin_params)\n format.html { redirect_to @bitcoin, notice: 'Bitcoin was successfully updated.' }\n format.json { render :show, status: :ok, location: @bitcoin }\n else\n format.html { render :edit }\n format.json { render json: @bitcoin.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @supermarket = Supermarket.find(params[:id]) \n respond_to do |format|\n if @supermarket.update(supermarket_params)\n format.json { render json: @supermarket, status: :ok }\n end\n end\n end", "def update\n @money = Money.find(params[:id])\n\n respond_to do |format|\n if @money.update_attributes(params[:money])\n format.html { redirect_to @money, notice: 'Money was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @money.errors, status: :unprocessable_entity }\n end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n respond_to do |format|\n if @coinrate.update(coinrate_params)\n format.html { redirect_to exchanges_path, notice: 'La cotizacion se ha modificado con exito.' }\n format.json { render :show, status: :ok, location: @coinrate }\n else\n format.html { render :edit }\n format.json { render json: @coinrate.errors, status: :unprocessable_entity }\n end\n end\n end", "def updateMoney(money, id)\n parameters={money: money}\n options = {\n :body => parameters.to_json,\n :headers => {\n 'Content-Type' => 'application/json'\n }\n }\n results = HTTParty.put(\"http://192.168.99.101:4051/users/update_money?id=\" + id.to_s , options)\n return results\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update # PATCH\n raise NotImplementedError\n end", "def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end", "def update\n @interest = Interest.find(params[:id])\n \n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.json { head :ok }\n else\n format.json { render :json => @interest.errors,\n :status => :unprocessable_entity }\n end\n end\n end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end", "def patch(path, **args); end", "def update!(**args)\n @requests = args[:requests] if args.key?(:requests)\n end", "def update!(**args)\n @requests = args[:requests] if args.key?(:requests)\n end", "def update!(**args)\n @requests = args[:requests] if args.key?(:requests)\n end", "def update!(**args)\n @requests = args[:requests] if args.key?(:requests)\n end", "def update\n standard_update(Interest, params[:id], interest_params)\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 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(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n contract = Contract.find_by_id(params[:id])\n (head :unauthorized unless contract) and return\n \n # try to update the attributes\n if contract.update_attributes(edit_contract_params)\n render json: contract\n else\n render json: { errors: contract.error.full_messages}\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!(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 update\n @request = @skill.requests.find(params[:id])\n\n respond_to do |format|\n if @request.update_attributes(params[:request])\n format.html { redirect_to myrequests_path, notice: 'request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(path)\n output { patch(path, params) }\n end", "def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end", "def update\n respond_to do |format|\n if @bits_1.update(bits_1_params)\n format.html { redirect_to @bits_1, notice: 'Bits 1 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bits_1.errors, status: :unprocessable_entity }\n end\n end\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 #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 @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 respond_to do |format|\n if @money.update(money_params)\n format.html { redirect_to @money, notice: 'Money was successfully updated.' }\n format.json { render :show, status: :ok, location: @money }\n else\n format.html { render :edit }\n format.json { render json: @money.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n put :update\n end", "def update\n @chain = Chain.find(params[:id])\n\n respond_to do |format|\n if @chain.update_attributes(params[:chain])\n format.html { redirect_to @chain, :notice => 'Chain was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @chain.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n cb = Coin.retrieve_from_api(transaction_params[\"CB_apikey\"])\n cs = Coin.retrieve_from_api(transaction_params[\"CS_apikey\"])\n\n respond_to do |format|\n if @transaction.update_values(transaction_params.merge(wallet_id: current_user.wallet.id, CBought_id: cb, CSold_id: cs))\n format.html { redirect_to @transaction, notice: \"Transaction was successfully updated.\" }\n format.json { render :show, status: :ok, location: @transaction }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @transaction.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @kitten = Kitten.find(params[:id])\n\n respond_to do |format|\n if @kitten.update_attributes(params[:kitten])\n format.html { redirect_to @kitten, notice: 'Kitten was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kitten.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @stuff = Stuff.find(params[:id])\n\n respond_to do |format|\n if @stuff.update_attributes(params[:stuff])\n format.html { redirect_to @stuff, :notice => 'Stuff was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @stuff.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @chain = Chain.find(params[:id])\n\n respond_to do |format|\n if @chain.update_attributes(params[:chain])\n format.html { redirect_to @chain, notice: 'Chain was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @chain.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @complaint = Complaint.find(params[:id])\n\n if @complaint.update_attributes(params[:complaint])\n head :no_content\n else\n render json: @complaint.errors, status: :unprocessable_entity\n end\n end", "def update\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.html { redirect_to @interest, :notice => 'Interest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @interest.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @client = args[:client] if args.key?(:client)\n @list_update_requests = args[:list_update_requests] if args.key?(:list_update_requests)\n end", "def update\n # if @bonus.update(bonus_params)\n # render :show, status: :ok, location: @bonus\n # else\n # render json: @bonus.errors, status: :unprocessable_entity\n # end\n end", "def update\n @bowl = Bowl.find(params[:id])\n \n # set bowl modify time\n @bowl.modified = Time.now\n \n respond_to do |format|\n if @bowl.update_attributes(params[:bowl])\n \n Rails.logger.info \"Updating Bowl Contents\"\n \n # remove all contents for this bowl and add new\n @bowl.contents.delete_all(\"bowl_id=\" + @bowl.id)\n \n params.keys.each do |param|\n if param.start_with?(\"input_\") and (params[param] != \"\") \n @bowl.contents.create(:bowl_id => @bowl.id, :dryfruit_id => param[6, 2], :quantity => params[param]) \n end\n end\n\n format.html { redirect_to bowls_path, :notice => 'Bowl was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bowl.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @borrow_request = BorrowRequest.find(params[:id])\n\n respond_to do |format|\n if @borrow_request.update_attributes(params[:borrow_request])\n format.html { redirect_to @borrow_request, notice: 'Borrow request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @borrow_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def put!\n request! :put\n end", "def update\n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.html { redirect_to @interest, :notice => 'Интересот е успешно ажуриран.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @interest.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @pay = Pay.find(params[:id])\n\n respond_to do |format|\n if @pay.update_attributes(params[:pay])\n format.html { redirect_to @pay, notice: 'Pay was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pay.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @utilized_bitcoin_wallet = UtilizedBitcoinWallet.find(params[:id])\n\n respond_to do |format|\n if @utilized_bitcoin_wallet.update_attributes(params[:utilized_bitcoin_wallet])\n format.html { redirect_to @utilized_bitcoin_wallet, notice: 'Utilized bitcoin wallet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @utilized_bitcoin_wallet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.html { redirect_to @interest, notice: 'Interest was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interest.errors, status: :unprocessable_entity }\n end\n end\n end", "def coin_change(coins, amount)\n make_change(coins, amount, 0, {})\nend", "def patch(path, data, params = {}, request_options = {})\n request(:patch, path, data, params)\n end", "def update(*args)\n put(*args)\n end", "def update(*args)\n put(*args)\n end", "def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend", "def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend", "def update\n # TODO: Add cron_str updating\n respond_to do |format|\n if @chore.update_attributes(params[:chore])\n format.html { redirect_to @chore, notice: 'Chore was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @chore.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @credito = Credito.find(params[:id])\n\n respond_to do |format|\n if @credito.update_attributes(params[:credito])\n format.html { redirect_to @credito, notice: 'Credito was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @credito.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n # this whole process is updating the users coins with the currnet price from the api. pulls the users coins and if a coin matches then update the price in usd. and return the coin.\n coins = HTTParty.get(BASE_URL) # this will bring back the top 100 coins in an array\n user_coins = current_user.coins\n user_coins.each do |coin|\n res_coin = coins.find { |c| c['id'] == coin.cmc_id }\n coin.update(price: res_coin['price_usd']) if res_coin \n end \n render json: current_user.coins # if we don't authenticate_user before then we cant user current_user. it is a built in devise function\n end", "def update\n recipe.update(recipe_params)\n render json: recipe\n end", "def update \n user = User.find(params[:id])\n # byebug\n user.update(user_params)\n\n render json: user\n end", "def update\n @moose = Moose.find(params[:id])\n\n respond_to do |format|\n if @moose.update_attributes(params[:moose])\n format.html { redirect_to @moose, notice: 'Moose was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @moose.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @income = Income.find(params[:id])\n\n respond_to do |format|\n if @income.update_attributes(income_params)\n format.html { redirect_to @income, notice: 'Income was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @income.errors, status: :unprocessable_entity }\n end\n end\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 @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 @kit = Kit.find(params[:id])\n\n respond_to do |format|\n if @kit.update_attributes(params[:kit])\n format.html { redirect_to @kit, notice: 'Kit was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kit.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @interested = Interested.find(params[:id])\n\n respond_to do |format|\n if @interested.update_attributes(params[:interested])\n format.html { redirect_to @interested, notice: 'Interested was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interested.errors, status: :unprocessable_entity }\n end\n end\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_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend", "def updatePendingPay\n if !(Integer(params[:id]) rescue false)\n renderError(\"Not Acceptable (Invalid Params)\", 406, \"The parameter id is not an integer\")\n return -1\n end\n options = {\n :body => params.to_json,\n :headers => {\n 'Content-Type' => 'application/json'\n }\n }\n resul = HTTParty.get(\"http://192.168.99.101:4055/lists/\"+params[:id])\n user = resul[\"user_id\"]\n if user == (@current_user[\"id\"]).to_i\n results = HTTParty.put(\"http://192.168.99.101:4055/lists/\"+params[:id], options)\n if results.code == 201\n head 201\n else\n render json: results.parsed_response, status: results.code\n end\n else\n renderError(\"Not Acceptable (Invalid Params)\", 403, \"The user does not have permmision\")\n end\n end", "def patch(path, data, options = {})\n uri = build_uri(path, options)\n\n request = Net::HTTP::Patch.new(uri.request_uri)\n set_authorisation_header(request)\n request.set_form_data(data)\n\n response = https_client(uri).request(request)\n end", "def update\n respond_to do |format|\n if @cashbox.update(cashbox_params)\n format.html { redirect_to @cashbox, notice: 'Cashbox was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cashbox.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bounty = Bounty.find(params[:id])\n @chore = Chore.find(@bounty.chore_id)\n if @chore.nil?\n puts \"OH GOD WHY JESUS USE VALIDATORS COME ON NOW SERRIOUSLY GUYS\"\n end\n @chore.value=params[:value][:val].to_i\n @chore.save\n respond_to do |format|\n if @bounty.save\n format.html { redirect_to @bounty, :notice => 'bounty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bounty.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(data, &block)\n request :patch, @data[:id], data, &block\n end", "def patch(path, params)\n time(\"PATCH #{path}\") { Cloudflarer.new.patch(path, params) }\n end", "def patch\n end", "def update\n respond_to do |format|\n if @cash.update(cash_params)\n format.html { redirect_to action: \"index\", notice: 'Cash was successfully updated.' }\n format.json { render :show, status: :ok, location: @cash }\n else\n format.html { render :edit }\n format.json { render json: @cash.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cookbook.update(cookbook_params)\n format.html { redirect_to cookbook_path(@cookbook), notice: 'Cookbook was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cookbook.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n calculate_nutrients \n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n render json: Item.update(params[\"id\"], params[\"item\"])\n end", "def update\n @ski = Ski.find(params[:id])\n\n respond_to do |format|\n if @ski.update_attributes(params[:ski])\n format.html { redirect_to @ski, notice: 'Ski was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ski.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ski = Ski.find(params[:id])\n\n respond_to do |format|\n if @ski.update_attributes(params[:ski])\n format.html { redirect_to @ski, notice: 'Ski was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ski.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bounty.update(bounty_params)\n format.html { redirect_to @bounty, notice: 'Bounty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bounty.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end", "def update\n @specialty = Specialty.find(params[:id])\n\n if @specialty.update(specialty_params)\n head :no_content\n else\n render json: @specialty.errors, status: :unprocessable_entity\n end\n end", "def update\n @climb = Climb.find(params[:id])\n\n respond_to do |format|\n if @climb.update_attributes(params[:climb])\n format.html { redirect_to @climb, notice: 'Climb was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @climb.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(id, attributes)\n # attributes = {name: 'chocolate and peanuts', calories: 10}\nend", "def patch(url, options = {}, &block)\n request HttpPatch, url, options, &block\n end", "def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { respond_with_bip(@item) }\n else\n format.html { render action: 'edit' }\n format.json { respond_with_bip(@item) }\n end\n end\n end" ]
[ "0.7056684", "0.66152626", "0.65133774", "0.6398108", "0.6364747", "0.6345327", "0.6341038", "0.62709826", "0.6223703", "0.60864305", "0.6062356", "0.6058811", "0.6048507", "0.6043911", "0.60191005", "0.60119724", "0.5994841", "0.5966423", "0.5960222", "0.5957424", "0.5894995", "0.58922815", "0.5803609", "0.57983476", "0.57983476", "0.57983476", "0.57983476", "0.5776309", "0.57739574", "0.57739574", "0.5768297", "0.5768297", "0.57627296", "0.57545376", "0.5751953", "0.57466274", "0.57446617", "0.5744056", "0.5742633", "0.57310253", "0.5712968", "0.57042116", "0.56937456", "0.5691419", "0.5689813", "0.5687238", "0.5673273", "0.5666121", "0.5658295", "0.56553864", "0.565233", "0.56491166", "0.564743", "0.56379044", "0.56378347", "0.5636142", "0.5634933", "0.5626513", "0.5622719", "0.56184816", "0.56116617", "0.56068516", "0.5601868", "0.5598024", "0.5598024", "0.5587224", "0.5587224", "0.5576778", "0.5575391", "0.5575314", "0.556821", "0.5567583", "0.5563037", "0.5560416", "0.555384", "0.5553424", "0.5545748", "0.5544474", "0.5544028", "0.55415136", "0.55344164", "0.5529904", "0.55298984", "0.5525351", "0.5521844", "0.5515521", "0.5512849", "0.5511588", "0.5508993", "0.5508817", "0.55081975", "0.55072045", "0.55072045", "0.55059254", "0.5503963", "0.550365", "0.55020446", "0.54985267", "0.5498403", "0.54973453" ]
0.6759136
1
DELETE /mycoins/1 DELETE /mycoins/1.json
def destroy @mycoin.destroy respond_to do |format| format.html { redirect_to mycoins_url, notice: 'Mycoin was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @mint_coin = @coin.mint_coins.find(params[:id])\n @mint_coin.destroy\n\n respond_to do |format|\n format.html { redirect_to coin_mint_coins_url([@coin]) }\n format.json { head :no_content }\n end\n end", "def destroy\n @our_coin = OurCoin.find(params[:id])\n @our_coin.destroy\n\n respond_to do |format|\n format.html { redirect_to our_coins_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @coin.destroy\n respond_to do |format|\n format.html { redirect_to coins_url, notice: 'Coin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @coin_attribute = @coin.coin_attributes.find(params[:id])\n @coin_attribute.destroy\n\n respond_to do |format|\n format.html { redirect_to coin_coin_attributes_path([@coin]) }\n format.json { head :no_content }\n end\n end", "def destroy\n @bitcoin.destroy\n respond_to do |format|\n format.html { redirect_to bitcoins_url, notice: 'Bitcoin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @coin.destroy\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @coin_set = CoinSet.find(params[:id])\n @coin_set.destroy\n\n respond_to do |format|\n format.html { redirect_to coin_sets_url }\n format.json { head :ok }\n end\n end", "def destroy\n @coinrate.destroy\n respond_to do |format|\n format.html { redirect_to exchanges_path, notice: 'La cotizacion se ha eliminado con exito.' }\n format.json { head :no_content }\n end\n end", "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def destroy\n\t\t\t\tcoin = Coin.find(params[:id])\n\t\t\t\tif coin.save\n\t\t\t\t\ttransaction = Transaction.new(name: coin.name, value:coin.value, api_key: coin.api_key, transaction_type: \"Withdrawal\")\n\t\t\t\t\tif transaction.save\n\t\t\t\t\t\tif coin.destroy\n\t\t\t\t\t\t\tcoins = Coin.order('created_at DESC')\n\t\t\t\t\t\t\t@check = inventory_check\n\n\t\t\t\t\t\t\trender json: {status: 'Success!', message: 'Deleted Coin', data:@check},status: :ok\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\trender json: {status: 'Error!', message: 'Transaction Not Saved. Ensure coin creation JSON object includes transaction_type.', data:transaction.errors},status: :unprocessable_entity\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\trender json: {status: 'Error!', message: 'Something went wrong.', data:coin.errors},status: :unprocessable_entity\t\n\t\t\t\tend\n\t\t\tend", "def delete path\n make_request(path, \"delete\", {})\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @coin_ico.destroy\n respond_to do |format|\n format.html { redirect_to coin_icos_url, notice: 'Coin ico was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @v1_chore = Chore.where(id: params[:id])\n if @v1_chore.destroy\n head(:ok)\n else\n head(:unprocessable_entity)\n end\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end", "def destroy\n @utilized_bitcoin_wallet = UtilizedBitcoinWallet.find(params[:id])\n @utilized_bitcoin_wallet.destroy\n\n respond_to do |format|\n format.html { redirect_to utilized_bitcoin_wallets_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n #binding.pry\n @balance = Balance.find(params[:id])\n @balance.destroy\n respond_to do |format|\n format.html { redirect_to balances_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "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 delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete\n render json: Item.delete(params[\"id\"])\n end", "def delete\n request(:delete)\n end", "def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end", "def delete!\n request! :delete\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 delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end", "def destroy\n @pay = Pay.find(params[:id])\n @pay.destroy\n\n respond_to do |format|\n format.html { redirect_to pays_url }\n format.json { head :no_content }\n end\n end", "def delete(options={})\n connection.delete(\"/\", @name)\n end", "def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end", "def delete()\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(*args)\n request(:delete, *args)\n end", "def destroy\n @basis = Base.find(params[:id])\n @basis.destroy\n\n respond_to do |format|\n format.html { redirect_to bases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @credito = Credito.find(params[:id])\n @credito.destroy\n\n respond_to do |format|\n format.html { redirect_to creditos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @interest = Interest.find(params[:id])\n @interest.destroy\n\n respond_to do |format|\n format.json { head :ok }\n end \n end", "def delete_slip(id:)\n empty_param_error('id') if id.to_s.eql? ''\n resource :delete, \"api/v1/users/me/slips/#{id}\"\n end", "def destroy\n @supermarket = Supermarket.find(params[:id]) \n @supermarket.destroy\n respond_to do |format|\n format.json { render json: @supermarket, status: :ok }\n end\n end", "def delete(*args)\n commit(\"delete\", *args)\n end", "def destroy\n @money.destroy\n respond_to do |format|\n format.html { redirect_to money_index_url, notice: 'Money was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @bits_1.destroy\n respond_to do |format|\n format.html { redirect_to bits_1s_url }\n format.json { head :no_content }\n end\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete(path)\n request(:delete, path)\n end", "def destroy\n @chore = Chore.find(params[:id])\n @chore.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :ok }\n end\n end", "def destroy\n @income = Income.find(params[:id])\n @income.destroy\n\n respond_to do |format|\n format.html { redirect_to incomes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @chore = Chore.find(params[:id])\n @chore.destroy\n\n respond_to do |format|\n format.html { redirect_to chores_url }\n format.json { head :no_content }\n end\n end", "def delete(name)\n\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end", "def delete *args, &block\n res = @conn.delete *args, &block\n handle res, parse: false\n end", "def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end", "def deletes_to(path,opts={},&block) #:nodoc: \n crud_to(:delete,path,opts[:params] || {},opts,&block)\n end", "def destroy\n @subsidy = Subsidy.find(params[:id])\n @subsidy.destroy\n\n respond_to do |format|\n format.html { redirect_to subsidies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mydebt = Mydebt.find(params[:id])\n @mydebt.destroy\n\n respond_to do |format|\n format.html { redirect_to mydebts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @myth.destroy\n respond_to do |format|\n format.html { redirect_to myths_url, notice: 'Myth was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(*args)\n commit(\"delete\", *args)\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def delete\n render json: Like.delete(params[\"id\"])\n end", "def destroy\n @stats_money_transaction = Stats::MoneyTransaction.find(params[:id])\n @stats_money_transaction.destroy\n\n respond_to do |format|\n format.html { redirect_to stats_money_transactions_url }\n format.json { head :ok }\n end\n end", "def destroy\n @secubat_client = SecubatClient.find(params[:id])\n @secubat_client.destroy\n\n respond_to do |format|\n format.html { redirect_to secubat_clients_url }\n format.json { head :ok }\n end\n end", "def destroy\n @bounty = Bounty.find(params[:id])\n @bounty.destroy\n respond_to do |format|\n format.html { redirect_to controller: 'home', action: 'bounty_market' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cash.destroy\n respond_to do |format|\n format.html { redirect_to cashes_url, notice: 'Cash was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @climb = Climb.find(params[:id])\n @climb.destroy\n\n respond_to do |format|\n format.html { redirect_to climbs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @my = My.find(params[:id])\n @my.destroy\n\n respond_to do |format|\n format.html { redirect_to(mies_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @credit = Credit.find(params[:id])\n @credit.destroy\n\n respond_to do |format|\n format.html { redirect_to credits_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @credit = Credit.find(params[:id])\n @credit.destroy\n\n respond_to do |format|\n format.html { redirect_to credits_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @credit = Credit.find(params[:id])\n @credit.destroy\n\n respond_to do |format|\n format.html { redirect_to credits_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n request 'DELETE', path\n end", "def delete_data\n response = WebPay.client.delete([path, 'data'].join('/'))\n response['deleted']\n end", "def destroy\n @wallet.destroy\n respond_to do |format|\n format.html { redirect_to wallets_url, notice: 'Wallet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @bloom = Bloom.find(params[:id])\n @bloom.destroy\n\n respond_to do |format|\n format.html { redirect_to blooms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client.delete( name )\n end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end", "def delete\n render json: User.delete(params[\"id\"])\n end", "def destroy\n @api_v1_item.destroy\n render json: {message: 'deletado com sucesso'}\n end", "def destroy\n @client_transaction = ClientTransaction.find(params[:id])\n @client_transaction.destroy\n\n respond_to do |format|\n format.html { redirect_to client_transactions_url }\n format.json { head :ok }\n end\n end", "def destroy\n @ruby = Ruby.find(params[:id])\n @ruby.destroy\n\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end", "def delete(path, params)\n parse_response @client[path].delete(:params => params)\n end", "def delete\n \n end", "def destroy\n # @bill_quorum = BillQuorum.find(params[:id])\n @bill_quorum.destroy\n\n respond_to do |format|\n format.html { redirect_to bill_quorums_url }\n format.json { head :no_content }\n end\n end", "def delete\n \n end", "def destroy\n @much_withdraw.destroy\n respond_to do |format|\n format.html { redirect_to much_withdraws_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @borrow = Borrow.find(params[:id])\n @borrow.destroy\n\n respond_to do |format|\n format.html { redirect_to borrows_url }\n format.json { head :ok }\n end\n end", "def destroy\n @ruby.destroy\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gain = Gain.find(params[:id])\n @gain.destroy\n\n respond_to do |format|\n format.html { redirect_to gains_url }\n format.json { head :ok }\n end\n end", "def destroy\n @bitcoin_transaction.destroy\n respond_to do |format|\n format.html { redirect_to bitcoin_transactions_url, notice: 'Bitcoin transaction was successfully destroyed.' }\n format.json { head :no_content }\n end\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 delete(path)\n make_call(mk_conn(path), :delete)\n end", "def destroy\n @users_wallet.destroy\n respond_to do |format|\n format.html { redirect_to users_wallets_url, notice: \"Wallet was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete_item(item_id)\n response = Unirest.delete CONNECT_HOST + '/v1/' + LOCATION_ID + '/items/' + item_id,\n headers: REQUEST_HEADERS\n\n if response.code == 200\n puts 'Successfully deleted item'\n return response.body\n else\n puts 'Item deletion failed'\n puts response.body\n return nil\n end\nend", "def recipe_delete # /v1/user/:id/recipes/:recipe_id (DELETE)\n params[:recipes] = params[:recipe_id]\n recipes_delete\n end", "def destroy\n @twenty.destroy\n respond_to do |format|\n format.html { redirect_to twenties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @chain = Chain.find(params[:id])\n @chain.destroy\n\n respond_to do |format|\n format.html { redirect_to chains_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.744106", "0.73111403", "0.7100537", "0.6864171", "0.68539053", "0.68439144", "0.6825783", "0.67375666", "0.6736706", "0.6608597", "0.6585013", "0.65613866", "0.65609366", "0.65452105", "0.65399355", "0.65252656", "0.64747334", "0.645256", "0.63808227", "0.63786685", "0.63644665", "0.6353026", "0.6311459", "0.62930346", "0.62903416", "0.628219", "0.6274512", "0.6258021", "0.6246604", "0.62357086", "0.6232358", "0.6230184", "0.6230184", "0.6230184", "0.6230184", "0.6216812", "0.6215915", "0.62144893", "0.6195366", "0.6192254", "0.61919147", "0.61864793", "0.61862814", "0.6183122", "0.61813384", "0.61813384", "0.6180494", "0.617771", "0.6176211", "0.61567193", "0.6154043", "0.615025", "0.6149821", "0.6148096", "0.6143922", "0.61432296", "0.61411905", "0.61387724", "0.6132188", "0.61251384", "0.6122909", "0.61196446", "0.6116509", "0.610986", "0.6107865", "0.6104504", "0.60996485", "0.6099282", "0.6097989", "0.6094968", "0.60930055", "0.60930055", "0.60930055", "0.608917", "0.60881966", "0.60875756", "0.60858303", "0.60849214", "0.6083079", "0.60796446", "0.60724187", "0.6071348", "0.6069313", "0.60689545", "0.60675704", "0.6067549", "0.6062507", "0.60615796", "0.60583895", "0.6058332", "0.60580283", "0.6056838", "0.605431", "0.605285", "0.6052462", "0.60497767", "0.6049199", "0.60429645", "0.6040958", "0.60394347" ]
0.7361596
1
Use callbacks to share common setup or constraints between actions.
def set_mycoin @mycoin = Mycoin.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 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 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(&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 setup\n #implement in subclass;\n end", "def after_set_callback; 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 setup(easy)\n super\n easy.customrequest = @verb\n end", "def around_hooks; 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 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 shared_action(name, &block)\n @controller.shared_actions[name] = 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", "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.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.53314966", "0.53114754", "0.52984965", "0.52977055", "0.5296272", "0.5260649", "0.5245076", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.5235081", "0.52321917", "0.5228592", "0.5220735", "0.52198535", "0.52139324", "0.5208539", "0.5206585", "0.5178542", "0.5175199", "0.5173538", "0.5167041", "0.51614195", "0.51577675", "0.5153909", "0.51528823", "0.5152225", "0.51429904", "0.5141399", "0.51345575", "0.51145", "0.5114052", "0.5114052", "0.5110216", "0.5108656", "0.50935394", "0.5089196", "0.5081936", "0.5079627", "0.50675833", "0.5056105", "0.5053687", "0.5050475", "0.5050475", "0.503471", "0.5028311", "0.501982", "0.50157547", "0.5013552", "0.50014806", "0.50011593", "0.49976763", "0.4990292", "0.4990292", "0.49882022", "0.4981269", "0.49792367", "0.49766538", "0.4967978", "0.49667212", "0.4958987", "0.49572337", "0.49550423", "0.4954479", "0.4952353", "0.494726", "0.4944055", "0.4935437", "0.4931248", "0.49283475", "0.49281213", "0.49268973", "0.4921738", "0.49204507", "0.4918924", "0.49182287", "0.4916538", "0.49158585", "0.49156788" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def mycoin_params params.require(:mycoin).permit(:category, :coinname, :price, :user_id,:deposit) 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
Create a new filter. params[:filter] should contain JSON for a new filter.
def create Filter.create! :json_contents => params[:filter] render json: { success: true } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @filter = Filter.new(params[:filter])\n\n respond_to do |format|\n if @filter.save\n format.html { redirect_to @filter, notice: 'Filter was successfully created.' }\n format.json { render json: @filter, status: :created, location: @filter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @filter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @filter = Filter.new(params[:filter])\n\n respond_to do |format|\n if @filter.save\n format.html { redirect_to @filter, notice: 'Filter was successfully created.' }\n format.json { render json: @filter, status: :created, location: @filter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @filter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @filter = Filter.new(filter_params)\n\n respond_to do |format|\n if @filter.save\n format.html { redirect_to @filter, notice: 'Filter was successfully created.' }\n format.json { render :show, status: :created, location: @filter }\n else\n format.html { render :new }\n format.json { render json: @filter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admin_filter = Admin::Filter.new(params[:admin_filter])\n\n respond_to do |format|\n if @admin_filter.save\n format.html { redirect_to @admin_filter, notice: 'Filter was successfully created.' }\n format.json { render json: @admin_filter, status: :created, location: @admin_filter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_filter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_filter(**args)\n params = parameters(args) do\n required_params :name, :conditions, :type\n optional_params :name, :conditions, :type\n end\n request(:post, 'filters', params)\n end", "def create\n @filter = Filter.find_or_create_by_name( params[:filter][:name], :group => params[:filter][:group], :pattern => params[:filter][:pattern] )\n\n Auditlog( self.class.name, @filter )\n\n respond_to do |format|\n if @filter\n format.html { redirect_to @filter, notice: 'Filter was successfully created.' }\n format.json { render json: @filter, status: :created, location: @filter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @filter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @filter = Filter.new(filter_params)\n \n respond_to do |format|\n if @filter.save\n format.html { redirect_to filters_path(:template_id => @filter.template), notice: 'Filter was successfully created.' }\n format.json { render action: 'show', status: :created, location: @filter }\n else\n format.html { render action: 'new' }\n format.json { render json: @filter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \t@query = current_user.queries.find(params[:query_id])\n @filter = current_user.queries.find(params[:query_id]).filters.new(params[:filter])\n\n respond_to do |format|\n if @filter.save\n format.html { redirect_to @query, notice: 'Filter was successfully created.' }\n format.json { render json: @filter, status: :created, location: @filter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @filter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_filter(options = {})\n context = options.delete(:context)\n context = [ context ] unless context.kind_of? Array\n options['context[]'] = context\n \n perform_request_with_object(:post, '/api/v1/filters',\n options, Mastodon::Filter)\n end", "def create\n @filter = Filter.valid_filter filter_params\n @filter.save\n respond_to do |format|\n format.html { redirect_to Filter.find(@filter.id), notice: 'Filter was successfully created.' }\n format.json { render :show, status: :created, location: @filter }\n end\n end", "def create\n @filter = Filter.new(filter_params)\n @filter.profile = current_profile\n\n respond_to do |format|\n if @filter.save\n format.html { redirect_to [@profile, @filter], notice: 'Filter was successfully created.' }\n format.json { render action: 'show', status: :created, location: [@profile, @filter] }\n else\n format.html { render action: 'new' }\n format.json { render json: @filter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @filter = Object::Filter.new(params[:filter])\n @filter.source = @source\n\n respond_to do |format|\n if @filter.save\n flash[:notice] = 'Filter was successfully created.'\n format.html { redirect_to(@source) }\n format.xml { render :xml => @filter, :status => :created, :location => @filter }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @filter.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @filter_method = FilterMethod.new(filter_method_params)\n\n respond_to do |format|\n if @filter_method.save\n format.html { redirect_to @filter_method, notice: 'Filter method was successfully created.' }\n format.json { render :show, status: :created, location: @filter_method }\n else\n format.html { render :new }\n format.json { render json: @filter_method.errors, status: :unprocessable_entity }\n end\n end\n end", "def filter_params\n params.require(:filter).permit(:template, :name, :code)\n end", "def create\n @query_filter = QueryFilter.new(params[:query_filter])\n @query_filter.owner = @account\n \n respond_to do |format|\n if @query_filter.save\n flash[:notice] = 'Filter was successfully created.'\n format.html { redirect_to(account_path(@account)) }\n format.xml { render :xml => @query_filter, :status => :created, :location => [@account, @query_filter] }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @query_filter.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @filter = Filter.new(params[:filter])\n @area = Area.where(name: @filter.area).first\n @filter.polygon = @area.points\n\n @filter.name = \"#{@area.name} Listings\"\n\n respond_to do |format|\n if @filter.save\n format.html { redirect_to @filter, notice: 'Filter was successfully created.' }\n format.json { render json: @filter, status: :created, location: @filter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @filter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n respond_to do |format|\n if @filter_param.save\n format.html { redirect_to(@filter_param, :notice => 'Filter param was successfully created.') }\n format.xml { render :xml => @filter_param, :status => :created, :location => @filter_param }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @filter_param.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n render_json_auto @survey.add_filter(params[:filter]) and return\n end", "def filter_params\n params.require(:filter).permit(:name, :slug)\n end", "def filter_params\n params.require(:filter).permit(:name)\n end", "def filter_params\n params.require(:filter).permit(:name, :description, :opt_in)\n end", "def filter_create(payload, opts = {})\n data, _status_code, _headers = filter_create_with_http_info(payload, opts)\n data\n end", "def create\n filter = Filter.create!(\n attach_vehicle_info: params[:attach_vehicle_info],\n value: params[:value]\n )\n render json: filter, status: :ok\n rescue => e\n render json: { error: e }, status: :bad_request\n end", "def create(params)\n klass.create(params.merge(options[\"$query\"][\"$filter\"]))\n end", "def create_filter(title, expression)\n filter = {\n \"userFilter\" => {\n \"content\" => {\n \"expression\" => expression\n },\n \"meta\" => {\n \"category\" => \"userFilter\",\n \"title\" => title\n }\n }\n }\n puts filter.to_json\n GoodData.post \"/gdc/md/#{@project_id}/obj\", filter\n end", "def filter_params\n params.require(:filter).permit(:name, :brand, :description, :notes)\n end", "def create\n @inquiry_filter = InquiryFilter.new(inquiry_filter_params)\n\n respond_to do |format|\n if @inquiry_filter.save\n format.html { redirect_to @inquiry_filter, notice: 'Inquiry filter was successfully created.' }\n format.json { render :show, status: :created, location: @inquiry_filter }\n else\n format.html { render :new }\n format.json { render json: @inquiry_filter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_filter_attribute = UserFilterAttribute.new(params[:user_filter_attribute])\n\n respond_to do |format|\n if @user_filter_attribute.save\n format.html { redirect_to @user_filter_attribute, notice: 'User filter attribute was successfully created.' }\n format.json { render json: @user_filter_attribute, status: :created, location: @user_filter_attribute }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_filter_attribute.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @data_filter = Probe::DataFilter.new(params[:data_filter])\n\n respond_to do |format|\n if @data_filter.save\n flash[:notice] = 'Probe::DataFilter.was successfully created.'\n format.html { redirect_to(@data_filter) }\n format.xml { render :xml => @data_filter, :status => :created, :location => @data_filter }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @data_filter.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add_filter(filter)\n @filters << filter\n end", "def new\n @filter = Filter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @filter }\n end\n end", "def new\n @filter = Filter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @filter }\n end\n end", "def new\n @filter = Filter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @filter }\n end\n end", "def new\n @filter = Filter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @filter }\n end\n end", "def add_filter\n choice = Choice.find(params[:id])\n recommendation = Integer(params[:recommendation])\n product_filter_feature = case params[:type_filter]\n when \"product\" then ProductFilter::ProductFilterSimple.create_from_product(Product.find(params[:product_id]), recommendation)\n when \"feature\" then ProductFilter::ProductFilterFeature.create_from_feature(Feature.find(params[:feature_id]), recommendation)\n when \"rating\" then ProductFilter::ProductFilterRating.create_from_rating(Feature.find(params[:feature_id]), recommendation)\n end\n choice.product_filters << product_filter_feature\n redirect_to(edit_question_path(choice.question_id))\n end", "def filter_create_with_http_info(payload, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FilterApi.filter_create ...'\n end\n # verify the required parameter 'payload' is set\n if @api_client.config.client_side_validation && payload.nil?\n fail ArgumentError, \"Missing the required parameter 'payload' when calling FilterApi.filter_create\"\n end\n # resource path\n local_var_path = '/filters'\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/vnd.feedpushr.filter.v1+json', 'application/vnd.goa.error'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml', 'application/gob', 'application/x-gob'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(payload) \n\n # return_type\n return_type = opts[:return_type] || 'Filter' \n\n # auth_names\n auth_names = opts[:auth_names] || []\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(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FilterApi#filter_create\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def filter_params\n params.require(:filter).permit(:title, :department, :user, :commit)\n end", "def filter_params\n params.fetch(:filter, {}).permit(:text, :type)\n end", "def add_filter(filter)\n @filters << filter\n self\n end", "def create\n @layer_filter = LayerFilter.new(params[:layer_filter])\n respond_to do |format|\n if @layer_filter.save\n flash[:notice] = 'LayerFilter was successfully created.'\n format.html { redirect_to(@layer_filter) }\n format.xml { render :xml => @layer_filter, :status => :created, :location => @layer_filter }\n format.json { render :json => @layer_filter }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @layer_filter.errors, :status => :unprocessable_entity }\n format.json { render :json => @layer_filter.errors }\n end\n end\n end", "def filter(filter)\n @filters << CGI.escape(filter)\n self\n end", "def set_filter\n @filter = Filter.find(params[:id])\n end", "def set_filter\n @filter = Filter.find(params[:id])\n end", "def set_filter\n @filter = Filter.find(params[:id])\n end", "def add_filter(filter)\n @filters <<\n if filter =~ /\\./\n filter\n else\n \"solr.#{filter}FilterFactory\"\n end\n end", "def filter(new_filters)\n new_filters = JSON.parse(new_filters) if new_filters.is_a?(String)\n if filters = query['_filter']\n filters = JSON.parse(filters)\n filters = [filters] unless filters.is_a?(Array)\n filters.push(new_filters)\n else\n filters = new_filters\n end\n query('_filter' => filters.to_json)\n end", "def addFilter(filter_type, id)\n\t\tfilter = ReportFilter.new(filter_type,id)\n\t\[email protected](filter)\n\tend", "def add_filter(filter = nil, &block)\n id = \"#{filter.inspect}/#{block.inspect}\".hash\n\n @filters[id] = if filter.is_a?(Filter)\n filter\n elsif filter.is_a?(String)\n StringFilter.new(filter)\n elsif filter.is_a?(Regexp)\n RegexpFilter.new(filter)\n elsif block\n BlockFilter.new(block)\n else\n raise ArgumentError, \"Please specify either a string, \" \\\n \"filter, or block to filter source files with!\"\n end\n\n true\n end", "def add_filter\n @filter = true \n end", "def filter_params\n params.require(:filter).permit(:source, :max_dist, :max_time)\n end", "def new\n @admin_filter = Admin::Filter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @admin_filter }\n end\n end", "def create_filter(filter)\n return nil,nil if filter.nil?\n\n db_adapter = MongoDBConv.new(@current_var, true) #do push 'or'\n\n db_expr,hop_expr = filter.db_conv(@parent, db_adapter) \n end", "def create\n @ifilter = Ifilter.create(params[:ifilter])\n \n #get header filters\n if params.include?('ifilter_headers')\n @ifilter.stuffing_filter_headers = params[:ifilter_headers]\n end\n \n \n @ifilter.stuffing_headers = []\n if params.include?('ifilter_headers')\n params[:ifilter_headers].each do |header|\n @ifilter.stuffing_headers << {\n :id => header[0],\n :val => header[1]\n }\n end\n end\n\n respond_to do |format|\n if @ifilter.save\n format.html { redirect_to @ifilter, notice: 'Ifilter was successfully created.' }\n format.json { render json: @ifilter, status: :created, location: @ifilter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ifilter.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_filter\n @filter = Filter.friendly.find(params[:id])\n end", "def new\n @filter = Object::Filter.new\n @filter.source = @source\n\n if params[:positive] == 'false'\n @filter.positive = false\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @filter }\n end\n end", "def add_filter(filter)\n filter = filter.filterhash if filter.respond_to? \"filterhash\"\n if @filterChainHash[:cifilterlist].nil?\n @filterChainHash[:cifilterlist] = [ filter ]\n else\n @filterChainHash[:cifilterlist].push(filter)\n end\n return @filterChainHash\n end", "def parse_filter_params(permitted:)\n # Symbolize the keys so the values can be used with keyword arguments in the filter scopes.\n filter_params = params[:filter].try(:permit, permitted).try(:to_h)\n end", "def create\n @data_file_filter = DataFileFilter.new(params[:data_file_filter])\n\n respond_to do |format|\n if @data_file_filter.save\n flash[:notice] = 'Filter was successfully created.'\n format.html { redirect_to(data_file_filters_path) }\n format.iphone { redirect_to(data_file_filters_path) }\n format.xml { render :xml => @data_file_filter, :status => :created, :location => @data_file_filter }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @data_file_filter.errors, :status => :unprocessable_entity }\n end\n end\n end", "def filter\n @filter ||= filter_class.new default_filter\n end", "def filter(filter)\n @query[:q] << \"filter:#{filter}\"\n self\n end", "def new\n\t\t@query = current_user.queries.find(params[:query_id])\n\t\t@filter = @query.filters.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @filter }\n end\n end", "def add_filter filter = nil, &block\n @filters.push( filter ) unless filter.blank?\n @filters.push( block ) if block_given?\n end", "def create_filter_info(position, options = {})\n filter = Filter.new(position, options)\n\n ajax_filters << filter\n\n filter\n end", "def add_filters(filters); end", "def object_filter(filter)\n raise ArgumentError, \"object_filter expects an instance of SoftLayer::ObjectFilter\" if filter.nil? || !filter.kind_of?(SoftLayer::ObjectFilter)\n\n # we create a new object in case the user wants to store off the\n # filter chain and reuse it later\n APIParameterFilter.new(self.target, @parameters.merge({:object_filter => filter}));\n end", "def filter_params\n params.require(:filter).permit(family: [], number: [], sub_fam: [], sub_num: [], enhancement: [], enh_sub_fam: [], enh_sub_num: [])\n end", "def new\n @user_filter_attribute = UserFilterAttribute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_filter_attribute }\n end\n end", "def create\n @csv_filter = CsvFilter.new(csv_filter_params)\n binding.pry\n respond_to do |format|\n if @csv_filter.save\n format.html { redirect_to project_csv_type_csv_attribute_csv_filters_path(@csv_filter.csv_attribute.csv_type.project, @csv_filter.csv_attribute.csv_type, @csv_filter.csv_attribute), notice: 'Csv type was successfully created.' }\n format.json { render :show, status: :created, location: @csv_filter }\n else\n format.html { render :new }\n format.json { render json: @csv_filter.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @ifilter = Ifilter.new\n \n @ifilter_headers = @ifilter.get_ifilter_headers\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ifilter }\n end\n end", "def add(name, filter_dsl)\n filter = @f.translate(filter_dsl)\n filter[:name] = name\n @f.add(filter)\n end", "def laura_filter_params\n params.require(:laura_filter).permit(:charity_number, :subno, :name)\n end", "def create\n @cell_filtering = CellFiltering.new(cell_filtering_params)\n\n respond_to do |format|\n if @cell_filtering.save\n format.html { redirect_to @cell_filtering, notice: 'Cell filtering was successfully created.' }\n format.json { render :show, status: :created, location: @cell_filtering }\n else\n format.html { render :new }\n format.json { render json: @cell_filtering.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_requirement( filter )\n\t\t\t@filterlist << filter\n\t\tend", "def add_filter(filter)\n @filters = (@filters << filter).sort_by do |f|\n f.respond_to?(:weight) ? f.weight : DEFAULT_WEIGHT\n end.reverse!\n end", "def filter_params\n @filter_params_cache ||= clean_hash(params[:filter]).with_indifferent_access\n end", "def create\n @game = current_user.games.build(game_params)\n @game.filter_id = params[:filter_id]\n if @game.save\n redirect_to root_path\n else\n render 'new'\n end\n end", "def push_filter(filter)\r\n filter.line_end_format = @current_format\r\n @current_filter.append(filter)\r\n @current_filter = filter\r\n end", "def filter(filter)\n raise_method_not_available(__method__, 'is nested asset') if nested_asset?\n assets = client.get(asset_type, {}, { query: { filter: filter } })\n assets.map { |data| self.new_from_payload(data) }\n end", "def filter_params\n params.permit(*resource_filter_permitted_params)\n end", "def filter\n params['filter_field'] || '*'\n end", "def add_filter(filter_argument = T.unsafe(nil), &filter_proc); end", "def csv_filter_params\n params.require(:csv_filter).permit(:name, :csv_attribute_id, :before_value, :after_value, :compare_value, :csv_operator_id)\n end", "def addfilter( newfilter )\n if not subfilter\n @subfilter = newfilter\n else\n subfilter.addfilter( newfilter )\n end\n return self\n end", "def addFilter(expression)\r\n if expression.is_a? Nagios::MkLiveStatus::Filter\r\n if @filters == nil\r\n @filters=Array.new\r\n end\r\n \r\n @filters.push(expression)\r\n else\r\n raise QueryException.new(\"The filter must be a filter expression.\")\r\n end\r\n end", "def build\n \"filter=#{filters.join(',')}\"\n end", "def set_filter_method\n @filter_method = FilterMethod.find(params[:id])\n end", "def record_filter_params\n permitted_params = [\n :name,\n :record_created_by,\n :is_destroyed,\n :record_created_on,\n :record_created_after,\n :record_created_before,\n :filename,\n :file_content_type,\n :file_size,\n :file_size_less_than,\n :file_size_greater_than,\n :file_md5hashsum,\n project_affiliation_filter_term_attributes: [:id, :project_id, :_destroy],\n annotation_filter_terms_attributes: [:id, :created_by, :term, :context, :_destroy]\n ]\n params.require(:record_filter).permit(permitted_params)\n end", "def add_file_filter(file_filter)\n @filter_file = file_filter\n end", "def add_file_filter(file_filter)\n @filter_file = file_filter\n end", "def filter\n @filter = params[:q]\n end", "def add_transaction_filter(filter)\n @transaction_filters << filter\n end", "def initialize(filter_type, &block)\n if FILTER_TYPES.include?(filter_type)\n @filter_type = filter_type\n else\n raise ArgumentError, \"invalid type #{filter_type}, allowed: #{FILTER_TYPES.join(', ')}\"\n end\n @block = block\n end", "def add(filter, args=nil)\n args = RDig.config.crawler.send(args) if args.is_a? Symbol\n case filter\n when Symbol\n if args.nil?\n @filters << lambda { |document|\n begin\n UrlFilters.send(filter, document)\n rescue Exception\n @logger.error \"error in URL filter #{filter}: #{$!}\"\n @logger.error $!.backtrace.join(\"\\n\")\n nil\n end\n }\n else\n @filters << lambda { |document|\n begin\n UrlFilters.send(filter, document, args)\n rescue Exception\n @logger.error \"error in URL filter #{filter}: #{$!}\"\n @logger.error $!.backtrace.join(\"\\n\")\n nil\n end\n }\n end\n when Class\n if args.nil?\n if filter.respond_to?(:instance)\n filter_instance = filter.instance\n else\n filter_instance = filter.new\n end\n else\n filter_instance = filter.new(args)\n end\n @filters << lambda { |document|\n filter_instance.apply(document)\n }\n end\n end", "def add_filter(name, assertion, equals)\n @filters << Filter.new(name, assertion, equals)\n end", "def add_filter(filter_symbol)\n filters << filter_symbol\n end", "def initialize(filter_type)\n @filter_type = filter_type\n begin\n filter_module = self.class.const_get(filter_type.to_s.gsub(/^([a-z])/) {|e| $1.upcase })\n self.extend(filter_module)\n rescue NameError\n raise FilterNotFoundError\n end\n end", "def set_filters\n @filters ||= begin\n filters = []\n filters << { attribute: Gemgento::ProductAttribute.find_by!(code: 'color'), value: params[:color] } unless params[:color].blank?\n filters\n end\n end", "def add_filter!(filter, condition)\n if @root_filter.nil?\n @root_filter = filter\n else\n get_last_filter.set_next_filter!(filter, condition)\n end\n end", "def create\n @filtration = Filtration.new(filtration_params)\n\n respond_to do |format|\n if @filtration.save\n format.html { redirect_to @filtration, notice: 'Filtration was successfully created.' }\n format.json { render :show, status: :created, location: @filtration }\n else\n format.html { render :new }\n format.json { render json: @filtration.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_aws_tag_filter(body, opts = {})\n data, _status_code, _headers = create_aws_tag_filter_with_http_info(body, opts)\n data\n end" ]
[ "0.8008522", "0.8008522", "0.7968216", "0.76918185", "0.7645773", "0.76049215", "0.7578487", "0.74827754", "0.7482206", "0.7421159", "0.73157597", "0.72239846", "0.7207327", "0.71313983", "0.7102057", "0.7024703", "0.69755477", "0.6968274", "0.6899808", "0.6896703", "0.6865027", "0.6849334", "0.68445456", "0.68185896", "0.6750647", "0.6740578", "0.67331535", "0.67312", "0.6717609", "0.66512954", "0.6616019", "0.6616019", "0.6616019", "0.6616019", "0.6536011", "0.653253", "0.6525034", "0.6511715", "0.6489076", "0.6453111", "0.6439575", "0.64059526", "0.64059526", "0.64059526", "0.632649", "0.6322584", "0.63218284", "0.6314592", "0.6299979", "0.6283931", "0.62527406", "0.6235172", "0.6228301", "0.6216863", "0.6216461", "0.6209661", "0.6188891", "0.61562526", "0.6139673", "0.61367136", "0.61360544", "0.61252445", "0.6050713", "0.6031949", "0.6021672", "0.6016746", "0.6000266", "0.5983756", "0.5943873", "0.59160274", "0.5908848", "0.5899143", "0.5882912", "0.58794016", "0.5874422", "0.5865158", "0.5854047", "0.585401", "0.5831813", "0.5831478", "0.5823497", "0.5821054", "0.582103", "0.57997304", "0.5781455", "0.57764745", "0.577379", "0.57688046", "0.57688046", "0.5765866", "0.57585996", "0.5741373", "0.5733108", "0.5718058", "0.57034445", "0.5702356", "0.5688887", "0.56845725", "0.5683993", "0.5670661" ]
0.7960388
3
conditional is needed to check that title exists and not null, otherwise error will occur when trying to capitalize
def capitalize_title self.title.capitalize! if title end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_title_case\n if title.split.any?{|w|w[0].upcase != w[0]}\n errors.add(:title, \"Title must be in title case\")\n end\n end", "def capitalize_title\n self.title = title.capitalize if title.present?\n end", "def check_title\n if self.title.blank? && st = (url && Site.by_link(self.url))\n self.title = (st.yield :Title, st.sampleURL)[:Title] || \"\"\n self.title = self.trimmed_title\n else\n self.title\n end\n end", "def title\n t = nil\n # default to long title\n long_titles = self.courses.map(&:long_title)\n return t if (t = long_titles.find(&:present?)).present?\n\n # then try specific title. then short title\n return self.specific_title if self.specific_title.present?\n\n short_titles = self.courses.map(&:short_title)\n return t if (t = short_titles.find(&:present?)).present?\n\n return '(Title Unavailable)'\n end", "def title?\n [email protected]_s.empty?\n end", "def title?\n !title.nil? && !title.empty?\n end", "def title?\n !title.nil? && !title.empty?\n end", "def title_check\n \n\n if self.title\n \n if !self.title.include? \"Believe\" || \"Won't\" || \"Secret\"\n true\n else\n false\n end\n else\n false\n end\n end", "def post_title\n if !self.title.nil?\n phrases = [\"Won\\'t Believe\", \"Secret\", \"Top\", \"Guess\"]\n if !phrases.any? {|phrase| self.title.include?(phrase)}\n errors.add(:title, \"Not enough!\")\n end\n else\n errors.add(:title, \"Not enough!\")\n end\n end", "def cleanTitle(str)\n str.nil? and return str\n r = Sanitize.clean(str).strip\n str.empty? and return str\n r = (r[0].match(/[^\\w]/)) ? r[1..-1].strip : r\n r.sub(/^(The|A|An) /i, '').capitalize\nend", "def custom_slug_or_title\n title.presence\n end", "def titled?\n title.present? && (title != DEFAULT_TITLE)\n end", "def title_is(title = nil)\n title_is_empty if title.nil? || title.empty?\n @title = title\n end", "def title_valid(title)\n if !title.empty?\n self.title = title\n return true\n else\n return false\n end\n end", "def title_blank?\n self.title.blank?\n end", "def check_title(name)\n # titleize without the botched 'S (apostrophe-s) issue\n name = name.humanize.strip.squeeze(' ').gsub(/\\b([a-z])/) { $1.capitalize }.gsub(/\\'S/, '\\'s')\n\n match = TITLE_CONVERSION_LIST.keys.select { |t| name.match(/#{Regexp.escape(t)}/i) }\n unless match.empty?\n match = match.sort.reverse[0] # select the longest match (most accurate)\n name = TITLE_CONVERSION_LIST[match]\n end\n\n log(\"checked display name is [#{name}]\", :debug)\n name\n end", "def has_title?\n @title != nil\n end", "def capitalize_title\n self.title.capitalize!\n end", "def titlecase(input)\n input.titlecase unless input.nil?\n end", "def display_name\n title.present? && title || _('Untitled')\n end", "def title_with_page_title_check\n return @page.title if @page && [email protected]?\n title_without_page_title_check\n end", "def title\nbase_title = \"MatterMouth\"\nif @title.nil?\nbase_title\nelse\n\"#{base_title} | #{@title}\"\nend\nend", "def hasTitle\n if @title then\n true\n else\n false\n end\n end", "def expected_title(expected_title)\n define_method(\"has_expected_title?\") do\n has_expected_title = expected_title.kind_of?(Regexp) ? expected_title =~ title : expected_title == title\n raise \"Expected title '#{expected_title}' instead of '#{title}'\" unless has_expected_title\n has_expected_title\n end\n end", "def titlecase_title\n self.title = self.title.titlecase\n end", "def validate_title(item)\n error(msg: 'Title may not be blank', item: __method__.to_s) if blank?(item)\n end", "def full_title(page_title)\n page_title.blank? ? \"My Defi Pie\" : \"My Defi Pie | #{page_title}\"\n end", "def titleize(title)\n results = []\n #get all the words\n bad_words = ['a', 'and', 'or', 'of', 'over', 'the']\n words = title.split(' ')\n # iterate over words with INDEX\n words.each_with_index do |word, i|\n word.downcase!\n if i == 0\n results << word.capitalize\n elsif bad_words.include?(word)\n results << word\n else\n results << word.capitalize\n end\n end\n #capitalize if first word\n #capitalize unless the included in the bad list\n results.join(' ')\nend", "def title_case(title, minor_words = '')\n # capitalize all words in the original title, split them up into\n # an array and check the elements against the minor_words array\n # if they match, return the word, otherwise capitalize them\n proper_title = title.capitalize.split.map do |word|\n minor_words.downcase.split.include?(word) ? word : word.capitalize\n end\n proper_title.join(' ') # join the elements of the array into a string\nend", "def capitalize_title\n \t\tself.title = self.title.split(/\\s+/).map(&:downcase).\n map(&:capitalize).join(' ')\n end", "def upcased_title\n title.upcase\n end", "def upcased_title\n title.upcase\n end", "def titleize(title)\n title_array = title.split(\" \")\n for word in title_array\n if word == title_array[0]\n word = word.capitalize!\n elsif word.downcase == \"and\" or word.downcase == \"over\" or word.downcase == \"of\" or word.downcase == \"the\" or word.downcase == \"an\" or word.downcase == \"for\" or word.downcase == \"nor\" or word.downcase ==\"but\" or word.downcase ==\"or\" or word.downcase ==\"yet\" or word.downcase == \"so\" \n word = word.downcase!\n else word = word.capitalize!\n end\n end\n print title_array.join(\" \")\nend", "def regulate_title\n self.title = self.title.strip\n self.title.downcase!\n end", "def title\n alternate_title.blank? ? course_titles(\" / \") : alternate_title\n end", "def title?\n !name? && tagline\n end", "def title_for_google\n google_title.present? ? google_title : name\n end", "def capitalize_title\n self.title = title.capitalize\n end", "def verify_title(test_data)\n verify_values_match(test_data[UseOfCollections::TITLE.name], element_value(title_input))\n end", "def title\n\t\tlowers = %w(a an and but in of the)\n\t\ttitle_array = @title.split\n\t\ttitle_array.each do |word|\n\t\t\tif lowers.include?(title_array[0])\n\t\t\t\tword.capitalize!\n\t\t\telsif lowers.include?(word)\n\t\t\t\tword\n\t\t\telse\n\t\t\t\tword.capitalize!\n\t\t\tend\n\t\tend\n\t\ttitle_array.join(\" \")\n\tend", "def titlecase_title\n self.title=(title().titlecase())\n end", "def verify_title(test_data)\n verify_values_match(test_data[CoreUseOfCollectionsData::TITLE.name], element_value(title_input))\n end", "def inferred_title?(document); end", "def display_name\n name.present? && name || title.present? && title || _('Untitled')\n end", "def title_create?(title)\n if create?\n not titles_create_exception.include? title\n else\n titles_create_exception.include? title\n end\n end", "def titleize(title)\n sm_words = ['a', 'and', 'of', 'over', 'the']\n title.capitalize.split(\" \").map{ |wrd| sm_words.include?(wrd) ? wrd : wrd.capitalize }.join(\" \")\nend", "def should_extract_title(doc)\n return true\n end", "def page_title_is_correct\n ( text =~ self.class.page_title_validation_value ) !=nil\n end", "def titlecase\n title_case = []\n # titleize first word in title separately \n #(might contain exception words)\n title_case.push titleize_word @title.split[0], true \n\n @title.split.drop(1).each do |word|\n title_case.push titleize_word(word)\n end \n\n title_case.join(\" \")\n end", "def capitalize_description_if_needed(description)\n return description if description.match(/\\p{Lower}/) # Some lowercase in there, do nothing\n description = UnicodeUtils.downcase(description) # There's no capitalize method!?\n description[0] = UnicodeUtils.upcase(description[0])\n description\nend", "def title_case(title, minor_words='')\n\ttitle_array = title.downcase.split(' ')\n\tminor_words_array = minor_words.downcase.split(' ')\n\ttitle_array.map!{|e|\n\t\tif minor_words_array.include?(e) == false || title_array[0] == e\n\t\t\te.capitalize\n\t\telse \n\t\t\te\n\t\tend \n\t} \n\ttitle_array.join(' ')\nend", "def complete_title\n if self.title.present?\n self.title\n else\n I18n.translate(\"bento_search.missing_title\")\n end\n end", "def title(title_input)\n words_no_cap = [\"and\", \"or\", \"the\", \"over\", \"to\", \"the\", \"a\", \"but\", \"is\", \"in\"]\n post_title = title_input.split(\" \").map {|word|\n if words_no_cap.include?(word)\n word\n else\n word.capitalize!\n end\n }\n post_title[0] = post_title[0].capitalize\n post_title.join(\" \")\n end", "def title_case(title, minor_words = \"\")\n if title == nil\n return nil\n else \n minor_words_array = minor_words.split(' ').map do |word|\n word.downcase\n end \n title_array = title.split(\" \").map do |word|\n word.downcase\n end \n titled = title_array.map do |word| \n if !minor_words_array.include?(word)\n word.capitalize \n else \n word.downcase \n end\n end \n titled[0] = titled[0].capitalize \n titled.join(\" \")\n binding.pry\n end\nend", "def title_case(str, exceptions='')\n str_arr = str.split\n exception_arr = exceptions.downcase.split\n \n str_arr.each_with_index do |word, idx|\n word.capitalize! if idx == 0\n \n \n if exception_arr.include?(word.downcase)\n word.downcase! unless idx == 0\n else\n word.capitalize!\n end\n end\n str_arr.join(' ')\nend", "def validate_title\n errors.add(:title, :must_be_null_in_this_slide) if !self.allows_title? && !self.title.nil?\n end", "def title\n if @title == nil\n \"Movie not found!\"\n else\n @title\n end\n end", "def accurate_title\n nil\n end", "def title\n [email protected]?\n end", "def titleize_word word, first_word=false \n exceptions = [\"the\", \"and\", \"in\", \"an\", \"over\", \"of\", \"a\"] \n\n if exceptions.include? word and first_word == false \n word\n else\n word[0].upcase + word.chars.drop(1).join \n end \n end", "def titleize(word)\n words = word.split(\" \")\n little_words = [\"and\", \"or\", \"the\", \"but\", \"over\"]\n first_word = words.first\n\n words.each do |word|\n banned_word = false\n\n # Check if the word is a little word \n little_words.each do |banned|\n if(banned == word)\n banned_word = true\n end\n end\n\n # If its the first word of the title or not a banned word it can be capitalized\n if((first_word == word) || (banned_word == false))\n word.capitalize!\n end\n end\n words.join(\" \")\nend", "def full_title(page_title)\n base_title = \"Ruby on Rails Tutorial Sample App\"\n if page_title.empty?\n else\n \"#{base_title} | #{page_title}\"\n end\nend", "def format_title_description\n if description.present? && title.present?\n self.description = description.strip.capitalize\n self.title = title.strip.capitalize\n end\n end", "def page_title?\n @_page_title.present?\n end", "def format_title_description\n if description.present? && title.present?\n self.description = description.strip.capitalize\n self.title = title.strip.capitalize\n end\n end", "def format_title_description\n if description.present? && title.present?\n self.description = description.strip.capitalize\n self.title = title.strip.capitalize\n end\n end", "def titleize(title)\n\ttitle_split = title.split(\" \")\n\ttitle_split.map do |word|\n\t\tif word == \"over\"\n\t\t\t#word = word\n\t\t\treturn word\n\t\telsif word == \"and\"\n\t\t\t#word = word\n\t\t\treturn word\n\t\telsif word == \"the\" && title_split[0] != word\n\t\t\t#word = word\n\t\t\treturn word\n\t\telse\n\t\t\treturn word.capitalize\n\t\tend\n\tend\nend", "def is_title?(title)\n results = @client.find_game(title)\n title_names = results.collect{|game| game.name}\n title_names.uniq!\n title_names_downcase = title_names.map {|game| game.downcase}\n title_names_downcase.include? title.downcase\n end", "def title?\n return false unless title\n return @display_title if defined?(@display_title)\n\n @display_title = (@text !~ %r!title=false!i)\n end", "def is_title\n false\n end", "def ensure_title\n self.title = self.parent_message.title if self.title.nil?\n end", "def title?; end", "def check_title\n if title.to_s == '' && audio_file.present?\n str = File.basename(audio_file_url).gsub(/[_]/, ' ') \n self.title = str.gsub(/[.mp3]/, '')\n self.save\n end\n end", "def get_title(n)\n description = Nokogiri::HTML(@description_xpath[n].text).text\n if description.include?(\"IF YOU GO\")\n description = description.split(\"IF YOU GO\")[1]\n if description.include?(\"Where\")\n title = description.split(\"Where\")[0]\n # Title must fit on single line\n title.gsub!(\"\\n\", \" \").strip!\n title\n else\n super(n)\n end\n else\n super(n)\n end\n end", "def guess_title(resource)\n resource.try title_field_finder.find\n end", "def bypass_title_validation?\n bypass_title_validation\n end", "def title_case(title, minor_words = nil)\n title = title.downcase.split(\" \")\n title.map! {|word| minor_words && minor_words.downcase.split(\" \").include?(word) ? word : word.capitalize}\n title[0] = title[0].capitalize if title[0]\n return title.join(\" \")\nend", "def check_title\n @page_title = \"FauxTwitter\"\n end", "def title_case(title, minor_words = '')\n minor_words_arr = minor_words.downcase.split\n title_words = title.split\n title_words.each_with_index do |title_word, index|\n if index == 0 || !minor_words_arr.include?(title_word.downcase)\n title_words[index] = title_words[index].capitalize\n else\n title_words[index] = title_words[index].downcase\n end\n end\n title_words.join(' ')\nend", "def full_title(page_title) # Method definition\n base_title = \"Express yourself\"\t\t\t \t\t\t # Variable assignment\n if page_title.empty? # Boolean test\n base_title # Implicit return\n else\n \"#{base_title} | #{page_title}\" # String interpolation\n end\n end", "def titleize_proper_names\n self.author = self.author.titleize\n self.editor = self.editor.titleize if self.editor\n self.buyed_from = self.buyed_from.titleize if self.buyed_from\n end", "def fallback_title\n exception = StandardError.new(\"page title missing: #{controller_name}##{action_name}\")\n raise exception if Rails.application.config.consider_all_requests_local\n Sentry.capture_exception(exception)\n\n title ''\n end", "def title_with_page_title_check\n return @content_node.title if @content_node && !@content_node.title.blank?\n title_without_page_title_check\n end", "def ensure_unique_board_title\n unless self.has_unique_title\n errors.add_to_base(\"please choose another title\")\n end\n end", "def full_title(page_title)\r\n\tbase_title = \"whichizrite\"\r\n\tif page_title.empty?\r\n\t\tbase_title\r\n\telse\r\n\t\t\"#{base_title} | #{page_title}\"\r\n\tend\r\nend", "def full_title(page_title)\n base_title = \"Scirate\"\n if page_title.empty?\n base_title\n else\n sanitize(\"#{base_title} | #{page_title}\")\n end\n end", "def contains_only_capital_letters\n if ! Configs.get_config('allow_capitalssubj').to_bool && ! (self.title =~ /^([0-9\\32-\\64\\[\\]\\/\\^\\_\\`\\{\\}\\|\\~]*[\\75-\\77]*[A-Z]+[0-9\\32-\\64\\[\\]\\/\\^\\_\\`\\{\\}\\|\\~]*)+$/).nil?\n self.errors.add('title', I18n.t(:cap_letters))\n end\n end", "def title\n base_title = \"StkUp - Simple, Purposeful Comparisons\"\n @title.nil? ? base_title : \"#{base_title} | #{@title}\"\n end", "def titleize_name\n self.name = self.name.titleize unless self.name.blank?\n end", "def titleize(title)\n # split title into words\n\n little_words = %w[a and of over the]\n\n words = title.split.map.with_index do |word, idx|\n if !little_words.include?(word.downcase) || idx == 0\n word.capitalize\n else\n word.downcase\n end\n end\n\n words.join(' ')\nend", "def title_case(title, minor_words = true)\n title_words = title.downcase.split\n \n return title_words.map! {|word| word.capitalize!}.join(' ') if minor_words == true\n \n minor_words_split = minor_words.downcase.split \n \n title_words.map!.with_index do |word,index|\n if index == 0 or !minor_words_split.include?(word)\n word.capitalize!\n else\n word\n end\n end.join(' ')\n \nend", "def render_title\n @title ? @title : \"I Live Yoga - #{@city.capitalize} :: All Studios. All Classes.\"\n end", "def expected_title expected_title\n define_method 'has_expected_title?' do\n has_expected_title = expected_title.kind_of?(Regexp) ? expected_title =~ @browser.title : expected_title == @browser.title\n raise \"Expected title '#{expected_title}' instead of '#{@browser.title}'\" unless has_expected_title\n end\n end", "def seo_title\n meta_title.blank? ? name : meta_title\n end", "def titleize(s)\n\ttitle = s.capitalize\n\ttitle = title.split.map {|x| ((x != \"the\") && (x != \"and\") && (x != \"over\")) ?\n\t\t\tx.capitalize : x}.join(\" \")\nend", "def validate_title\n if self.title.length < 3\n errors.add :base, :invalid, message: \"The title is invalid\"\n end\n end", "def smart_titlecase\n small_re = %w( is a an and as at but by en for if in of on or the to v[.]? via vs[.]? ).join('|')\n\n # Original Perl version by: John Gruber (daringfireball.net) 2008-05-10\n # Adapted to Ruby by: Marshall Elfstrand (vengefulcow.com/ 2008-05-21\n # Improved and customized: Jacob Duffy (duffy.jp) 2011-01-25\n # License: http://www.opensource.org/licenses/mit-license.php\n\n # if source is all uppercase, use all lowercase instead. -- jpd\n string = (self.upcase == self)? self.downcase : self\n\n result = \"\"\n string.gsub('_', ' ').split(/( [:.;?!][ ] | (?:[ ]|^)[\"\"] )/x).each do |s|\n s.gsub!(/ \\b( [[:alpha:]] [[:lower:].'']* )\\b /x) do |w|\n # Skip words with inresult dots, e.g. \"del.icio.us\" or \"example.com\"\n (w =~ / [[:alpha:]] [.] [[:alpha:]] /x) ? w : w.capitalize\n end\n\n # Lowercase our list of small words:\n s.gsub!(/\\b(#{small_re})\\b/io) { |w| w.downcase }\n\n # If the first word in the title is a small word, then capitalize it:\n s.gsub!(/\\A([[:punct:]]*)(#{small_re})\\b/io) { |w| $1 + $2.capitalize }\n\n # If the last word in the title is a small word, then capitalize it:\n s.gsub!(/\\b(#{small_re})([[:punct:]]*)\\Z/io) { |w| $1.capitalize + $2 }\n\n # Append current substring to output\n result += s\n end #each\n\n # Special Cases:\n upcase_re = (Array(Duffy.configuration.upcase_custom) + Array(Duffy.configuration.upcase_default)).uniq.join(\"|\")\n\n # Names with apostrophes; O'Brian, De'Wayne. 3+ Skips \"I've\" \"Haven't\" etc.\n result.gsub!(/([A-Z][a-z]*)'([a-z]{3,})/) { \"#{$1}'#{$2.capitalize}\" }\n\n result.gsub!(/ V(s?)\\. /, ' v\\1. ') # \"v.\" and \"vs.\"\n\n result.gsub!(/([''])S\\b/, '\\1s') # 'S (otherwise you get \"the SEC'S decision\")\n\n result.gsub!(/\\b(#{upcase_re})\\b/i) { |w| w.upcase } unless upcase_re.blank?\n\n # Squash repeated whitespace characters\n result.gsub!(/\\s+/, ' ')\n\n # Strip leading / tailing whitespace and return\n result.strip\n end", "def title_for_search\n (title || \"\").strip.sub(/\\Athe\\s+/i, \"\").sub(/\\Aan?\\s+/i, \"\")\n end", "def title?\n @assigned_paragraph_type == :title\n end", "def title\n base_title = \"S.Hukin ltd - Sheffield, UK. Speciality wholesale foods.\"\n if @title.nil?\n base_title\n else\n \"#{base_title} | #{@title}\"\n end\n end" ]
[ "0.79957825", "0.7451677", "0.7428102", "0.7410179", "0.73497176", "0.72852767", "0.72852767", "0.7264714", "0.7242843", "0.7217544", "0.7199664", "0.71892285", "0.71670467", "0.71654975", "0.7139259", "0.71011055", "0.7050629", "0.6987702", "0.6911543", "0.69110924", "0.6891807", "0.6841864", "0.68338335", "0.683152", "0.6816507", "0.6810869", "0.6810295", "0.680653", "0.6802955", "0.6792839", "0.67593634", "0.67593634", "0.67566335", "0.6750068", "0.67492425", "0.6747663", "0.6725473", "0.670578", "0.66999274", "0.66989946", "0.6688884", "0.6688658", "0.668421", "0.6679252", "0.6670039", "0.66666603", "0.66648257", "0.6663051", "0.6657639", "0.66496617", "0.66485745", "0.66446686", "0.66301143", "0.6622305", "0.6618364", "0.66146225", "0.6613675", "0.6597525", "0.6591318", "0.6590984", "0.658411", "0.6578942", "0.6578905", "0.65786415", "0.65777206", "0.65777206", "0.65765965", "0.6565536", "0.65639216", "0.6563035", "0.65621316", "0.6558942", "0.65492225", "0.6537068", "0.65355355", "0.6534012", "0.6533566", "0.65331024", "0.65305924", "0.6528478", "0.6522779", "0.6511333", "0.6511148", "0.6508437", "0.649829", "0.64951223", "0.6487089", "0.64804333", "0.6478472", "0.6476802", "0.6464298", "0.6444046", "0.64440316", "0.64397746", "0.64396596", "0.64387304", "0.64326924", "0.64318573", "0.643038", "0.642729" ]
0.76986045
1
TODO: implement sorting by related resources
def ja_sort [{ :created_at => :desc }] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ordered_resources\n resources_graph.topsort.to_a\n end", "def ordered(resource)\n\n children = resource.children\n dir = resource.url\n\n ordered_simple(children, dir)\n end", "def resources\n self.collection.find({}, :sort => [:_id, :asc]).map do |hash|\n self.normalize hash\n end\n end", "def serialized_content\n resources = ActiveModel::ArraySerializer.new(Post.published.sorted).as_json | ActiveModel::ArraySerializer.new(Tweet.published.sorted).as_json\n\n resources.sort_by { |i| i[:published_date] }.reverse\n end", "def order\n order = \"#{@rules[:s]}\".split(' ')\n @resource = order.blank? ? @resource : @resource.order_by(order)\n end", "def index\n @resource_items = ResourceItem.page(params[:page]).order(\"updated_at DESC\")\n end", "def get_nested_resource_objects\n end", "def get_author_resources\n # Get the user and author ids for the current resource\n author = self.author_id\n user = self.user_id\n\n rel_resource_list = {}\n # If an author is assigned use that\n if author\n Resource.where('author_id=? OR user_id=?', author, author).find_each do |rel_resource|\n if rel_resource.id != self.id\n if rel_resource.author_id == author\n rel_resource_list[rel_resource.id] = rel_resource.title\n elsif rel_resource.author_id == nil and rel_resource.user_id == user\n rel_resource_list[rel_resource.id] = rel_resource.title\n end\n end\n end\n # If not, use the user who created the Resource\n else\n Resource.where('author_id=? OR user_id=?', user, user).find_each do |rel_resource|\n if rel_resource.id != self.id\n if rel_resource.author_id == user\n rel_resource_list[rel_resource.id] = rel_resource.title\n elsif rel_resource.author_id == nil and rel_resource.user_id == user\n rel_resource_list[rel_resource.id] = rel_resource.title\n end\n end\n end\n end\n return rel_resource_list\n end", "def index\n @resource = Resource.find(params[:resource_id])\n @presenters = resources_in_dataset.map { |i| StashDatacite::ResourcesController::DatasetPresenter.new(i) }\n @sort_column = sort_column\n manual_sort!(@presenters, @sort_column)\n end", "def add_ordered_resources_to_result(resources, result)\n arr_of_resources = resources.zip_offset(1)\n \n arr_of_resources.each do |first, second|\n result.add_edge!(first, second) unless result.edge?(first, second) or result.edge?(second, first)\n add_ordered_resources_to_result(first.resources, result)\n end\n end", "def index\n respond_with Page.sort(:published_on.desc, :created_at.desc)\n end", "def nested_pages(resource)\n children = resource.children.find_all { |r| nav_title(r) }\n Naturally.sort_by(children) do |r|\n [r.data['nav-weight'] || 100, nav_title(r).downcase]\n end\n end", "def sort_entries; end", "def manipulate_resource_list(resources)\n new_resources = []\n\n # Set up date pages if the appropriate templates have been specified\n @blog_data.articles.group_by { |a| a.date.year }.each do |year, year_articles|\n new_resources << year_page_resource(year, year_articles) if @generate_year_pages && @year_template\n\n year_articles.group_by { |a| a.date.month }.each do |month, month_articles|\n new_resources << month_page_resource(year, month, month_articles) if @generate_month_pages && @month_template\n\n month_articles.group_by { |a| a.date.day }.each do |day, day_articles|\n new_resources << day_page_resource(year, month, day, day_articles) if @generate_day_pages && @day_template\n end\n end\n end\n\n resources + new_resources\n end", "def sort_links\n resource_service.sortable_fields.collect do |key,value|\n \tlink_to key, params.dup.update(:sort => key), :class => ((params[:sort].to_s==key.to_s) ? 'current' : '')\n end.join(' | ')\n end", "def sort_name\n sort_constituent\n end", "def related_resources_recursive(result = [])\n Array(related_resources).each do |related_resource|\n unless result.include?(related_resource)\n result << related_resource\n if related_resource.respond_to?(:related_resources_recursive)\n related_resource.related_resources_recursive(result)\n end\n end\n end\n return result\n end", "def sort\n @student_entities = StudentEntity.all\n @student_entities = @student_entities.sort_by { |stu| stu.created_at }\n render json: @student_entities, status: 200\n end", "def show\n @resources = @incident.resources.order(:category, :order_number)\n @resource = Resource.new\n end", "def general\n @topics = Topic.non_project.unscheduled.includes(:votes)\n @topics.sort!{|x,y| y.votes.count <=> x.votes.count }\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end", "def extract_titles(resources)\n titles = []\n\n resources.each do |resource|\n titles << resource[:resource_id]\n end\n\n titles\nend", "def posts\n self.object.posts.sort_by{|post| post.id}.reverse\n end", "def includes_for_sorting\n []\n end", "def sort\n raise l(:priority_sort_no_project_error) if !parent_object\n \n @priorities = parent_object.priorities\n \n params.keys.select{|k| k.include? UL_ID }.each do |key|\n Priority.sort_priorities(@priorities, params[key])\n end\n \n render :nothing => true\n end", "def index\n @contents = Content.all(:order => \"resource_type, resource_id\")\n @types = Content.all(:select => \"distinct resource_type\") \n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @contents }\n end\n end", "def resource_list\n self.resources\n end", "def tie_breaking_sort\n { \"content_id\" => { order: \"asc\" } }\n end", "def sort_by_title\n @links = Link.all.order(:title)\n both = separate_public_and_private(links)\n link_pub = both.first\n link_priv = both.last\n respond_to do |format|\n format.html\n format.json { render json: { links: link_pub.as_json } }\n end\n end", "def sorted_tags\n tags.order('id ASC')\n end", "def sort_by_metric_title rel\n rel.joins(sort_join(\"right_id = sort.id\"))\n .order(\"sort.key #{@sort_args[:sort_order]}\")\n end", "def index\n @photos = Photo.order(:priority)\n end", "def index\n unless params[:resource_group_id].blank?\n @resource_group = ResourceGroup.find(params[:resource_group_id])\n @resources = @resource_group.resources.includes(:resource_group, :users).order(\"resource_groups.name, resources.name\").paginate(:page => params[:page], :per_page => current_user.preferred_items_per_page)\n else\n # TODO FIXME for some reason the includes below stopped working when :permission_types is included\n # 'PGError: ERROR: column permission_types.activated does not exist' but not sure why it thinks it should exist at this point\n @resources = Resource.includes(:resource_group, :users).order(\"resource_groups.name, resources.name\").paginate(:page => params[:page], :per_page => current_user.preferred_items_per_page)\n end\n @resource_groups = ResourceGroup.order('name').all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @resources }\n end\n end", "def index\n @resources = Resource.order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resources }\n end\n end", "def sort_by_type!\n children.sort! do |x, y|\n if x.is_a?(PBXGroup) && y.is_a?(PBXFileReference)\n -1\n elsif x.is_a?(PBXFileReference) && y.is_a?(PBXGroup)\n 1\n else\n x.display_name <=> y.display_name\n end\n end\n end", "def sort_by_type!\n children.sort! do |x, y|\n if x.is_a?(PBXGroup) && y.is_a?(PBXFileReference)\n -1\n elsif x.is_a?(PBXFileReference) && y.is_a?(PBXGroup)\n 1\n else\n x.display_name <=> y.display_name\n end\n end\n end", "def get_resources_by_parent parent_resource_uuid, name=nil\n parent_resource_uuid = parent_resource_uuid if parent_resource_uuid.is_a?(Resource)\n \n @resources.find_all{|res|res.parent_uuid == parent_resource_uuid && (name.blank? || res.name == name)}\n end", "def sort_files!\n site.collections.each_value { |c| c.docs.sort! }\n site.pages.sort_by!(&:name)\n site.static_files.sort_by!(&:relative_path)\n end", "def ordered_by_qualifications (collection)\n collection.sort_by {|x| [x[:years_of_experience], x[:github_points]]}.reverse!\nend", "def by_priority; end", "def related_resources(resource)\n if resource.respond_to?(:related_resources_recursive)\n return resource.related_resources_recursive\n else\n return []\n end\n end", "def index\n @patients = Patient.all.sort_by { |p| [p.approved.to_s, p.first_name] }\n @drivers = Driver.all.sort_by { |d| [d.trained.to_s, d.first_name] }\n @appointments = Appointment.all.sort_by { |a| [a.status, a.datetime] }\n end", "def index\n proposed_changes = StashEngine::ProposedChange.includes(identifier: :resources)\n .joins(identifier: :resources).where(approved: false, rejected: false)\n params[:sort] = 'score' if params[:sort].blank?\n params[:direction] = 'desc' if params[:direction].blank?\n @proposed_changes = proposed_changes.order(helpers.sortable_table_order).page(@page).per(@page_size)\n return unless @proposed_changes.present?\n\n @resources = StashEngine::Resource.latest_per_dataset.where(identifier_id: @proposed_changes&.map(&:identifier_id))\n end", "def index\n reset_session\n params.each do |key, value|\n session[key] = value\n end\n @sort_by = params[:sort_by].to_s\n if @sort_by.nil? || (@sort_by != \"location\" && @sort_by != \"title\")\n @sort_by = \"updated_at\"\n end\n\n # TODO (if API GET requests available for non-admins)\n # if an Admin making API call, show all resources\n # else show only resources that have approval_status = 1\n\n # this functionality was meant for the web app\n # but has been removed\n #\n # if (@resources == nil || @resources.length == 0)\n # # if no results, suggests to search again with exact same params but instead uses parent location\n # @parent_location = Location.get_parent(params[:location])\n # @parent_params = params\n # @parent_params[:location] = @parent_location\n\n # @parent_query = \"/resources.html?\" + @parent_params.except(:controller, :action, :format).to_unsafe_h.to_query\n # else\n # @resources = @resources.order(sort_by)\n # end\n @resources = Resource.location_helper(resource_params)\n\n\n # process the data differently depending if an API call or a webpage\n respond_to do |format|\n format.json {\n @resources = @resources.order(@sort_by)\n\n render json: @resources\n }\n format.html {\n # no one using the web app is allowed to view unapproved\n params[:approval_status] = 1\n\n @has_many_hash = self.has_many_value_hash\n @filters = {}\n @has_many_hash.each do |association, values|\n @valid_associations = []\n values.each do |value|\n if association.classify.constantize.count(value) > 0\n @valid_associations.push(value)\n end\n end\n @filters[association] = @valid_associations\n end\n\n @has_many_hash = @filters\n\n @locations = Location.get_locations\n @child_locations = Hash.new\n\n @locations[\"location\"].each { |value|\n children = Location.child_locations(value)\n @child_locations[value] = children\n }\n # attempt to eager load all resources\n @all_resources = Resource.where(approval_status: 1).includes(:types, :audiences, :client_tags, :population_focuses, :campuses, :colleges, :availabilities, :innovation_stages, :topics, :technologies)\n\n @resources_json = @all_resources.as_json(include: Resource.include_has_many_params)\n\n @resources_json.map! do |resource|\n resource = json_fix(resource)\n end\n }\n end\n end", "def generate_resources_list\n resources = YARD::Registry.all(:resource).uniq.sort_by {|resource| resource.name.to_s}\n generate_full_list(resources, 'Resource', 'resources')\nend", "def sort_books\n # sort by starting with A - Z \n # iterate over all book titles, looking at the first letter of the title\n # title is alphabetized\n # return the list of books in order\n\n # need all books\n self.all.sort_by { |book| book.title }\n end", "def sort\r\n ContentImage.sort(params[:content_image])\r\n render :nothing => true\r\n end", "def show_resources\r\n @resources_pages = Paginator.new self, \r\n Resource.count, \r\n Resource.get(\"resources_paginator_count\").to_i, \r\n params[:page] \r\n @resources = Resource.find :all, :order => 'name',\r\n :limit => @resources_pages.items_per_page,\r\n :offset => @resources_pages.current.offset \r\n end", "def index\n @resources = Resource.find(:all, :conditions => {:parent_id => nil}, :order => 'created_at DESC')\n @deliverable_keys = Deliverable.all.collect{ |d| d.key_resource_id }.uniq.sort\n @project_keys = Project.all.collect{ |p| p.key_resource_id }.uniq.sort\n #@key_array = (@deliverable_keys + @project_keys).uniq.sort\n respond_to do |format|\n format.html { render :layout => false if request.xhr? }# index.html.erb\n format.xml { render :xml => @resources }\n end\n end", "def relate_resources(resources)\n if resources.kind_of?(Enumerable)\n resources.each { |r| relate_resource(r) }\n else\n relate_resource(resources)\n end\n end", "def get_related_resources(resource, limit=nil)\n name = resource.class.name.split(\"::\")[0]\n\n related = collect_related_items(resource)\n\n #Authorize\n authorize_related_items(related)\n\n order_related_items(related)\n\n #Limit items viewable, and put the excess count in extra_count\n related.each_key do |key|\n if limit && related[key][:items].size > limit && [\"Project\", \"Investigation\", \"Study\", \"Assay\", \"Person\", \"Specimen\", \"Sample\", \"Run\", \"Workflow\", \"Sweep\", \"Network\"].include?(resource.class.name)\n related[key][:extra_count] = related[key][:items].size - limit\n related[key][:items] = related[key][:items][0...limit]\n end\n end\n\n return related\n end", "def sorted_tags\n tag_set = Set.new\n articles.each do |item|\n tag_set.merge(item[:tags]) if item[:tags]\n end\n tag_set.to_a.sort\nend", "def descriptive_resources\n find_related_frbr_objects( :is_described_by, :which_resources?) \n end", "def descriptive_resources\n find_related_frbr_objects( :is_described_by, :which_resources?) \n end", "def index\n if params[:sort]\n @topics = Topic.includes(:comments).sort_by { |topic| topic.comments.count }.reverse\n elsif params[:sort_upvotes]\n @topics = Topic.includes(:upvotes).sort_by { |topic| topic.upvotes.count}.reverse\n else\n @topics = Topic.all.order('created_at DESC')\n end\n end", "def index\n @catalogs_user_resources = Catalogs::UserResource.search(params[:search]).order(\"#{sort_column} #{sort_direction}\").paginate(per_page: 15, page: params[:page])\n end", "def sort_params; end", "def sort_params; end", "def all_objects_in_order\n all_objects\n end", "def sorted(tasks)\r\n tasks.sort_by {|task| task[\"priority\"]}\r\nend", "def sorted_tags\n tags.order(:name)\n end", "def index\n @relatives = Relative.includes(:organizations, :representative)\n .group_by { |relative| relative.representative }\n end", "def sort_docs_by_key!; end", "def index\n\n # TODO: Refactor this!!!\n sort_function = (params[:sort] == 'name' ? :name : :count)\n\n @tags = Factoid.tag_counts.sort_by {|tag| tag.send(sort_function)}.reverse\n\n if params[:direction] == 'desc'\n @tags.reverse!\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tags }\n end\n end", "def sorted_line_items\n line_items.includes(:item).order(\"items.name\")\n end", "def sorts_with_links\n [\n [search_merge(sort: 'best_match', order: 'desc', page: '1'), 'Relevancy'],\n\n [search_merge(sort: 'date', order: 'asc', page: '1'), 'Published Earliest'],\n [search_merge(sort: 'date', order: 'desc', page: '1'), 'Published Latest'],\n\n [search_merge(sort: 'title', order: 'asc', page: '1'), 'Title A-Z'],\n [search_merge(sort: 'title', order: 'desc', page: '1'), 'Title Z-A']\n ]\n end", "def fulltree_arranged(*args)\n Relationship.arranged_rels_to_resources(fulltree_rels_arranged(*args))\n end", "def index\n # @cloud_resources = CloudResource.all\n root = CloudResource.find_root\n root = params[:id] || root.id\n @cloud_resource = CloudResource.find root.to_i\n @cloud_resources = @cloud_resource.children(params[:page] || 1).order(\"name DESC\")\n end", "def index\n if current_user.role?(:admin)\n if params[:search]\n @resources = Resource.search(params[:search]).paginate(:page => params[:page]).per_page(10)\n elsif params[:resource]\n @resources = Resource.tagged_with(params[:resource][:tagged_with]).paginate(:page => params[:page]).per_page(10)\n else\n @resources = Resource.all.paginate(:page => params[:page]).per_page(10)\n end\n else\n if params[:search]\n @resources = Resource.search(params[:search]).active.paginate(:page => params[:page]).per_page(10)\n elsif params[:resource]\n @resources = Resource.tagged_with(params[:resource][:tagged_with]).active.paginate(:page => params[:page]).per_page(10)\n else\n @resources = Resource.active.paginate(:page => params[:page]).per_page(10)\n end\n end\n end", "def repos\n super.sort\n end", "def sort\n raise l(:todo_sort_no_project_error) if !parent_object\n \n #@todos = Todo.for_project(@project.id)\n @todos = parent_object.todos\n \n params.keys.select{|k| k.include? UL_ID }.each do |key|\n Todo.sort_todos(@todos,params[key])\n end\n \n render :nothing => true\n #render :action => \"sort.rjs\"\n end", "def sort_files!\n site.generated_pages.sort_by!(&:name)\n site.static_files.sort_by!(&:relative_path)\n end", "def index\n @galleries = Gallery.find_all_by_private(:false)\n \n @galleries.sort! { |a,b| b.created_at<=>a.created_at }\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @galleries }\n end\n end", "def resources(resources_hash)\n commodities(resources_hash['Commodities'])\n agents(resources_hash['Agents'])\n end", "def ar_retrieve_resources\n run_callbacks :ar_retrieve_resources do\n if params[:_search]\n # Fulltext search\n\n @resources = ar_model.search(params[:_search])\n @resources_count = @resources.count\n else\n intf = ar_model.interfaces[:rest]\n\n @resources_relation ||= ar_model.all\n\n # Authorization\n if intf.authorization_required?\n @resources_relation = @resources_relation.with_capability(aaa_context)\n end\n\n @authorized_resources_relation = @resources_relation\n\n # Filters\n @resources_relation = apply_scopes_to_relation(@resources_relation)\n @resources_relation = apply_json_filter_to_relation(@resources_relation)\n @resources_relation = apply_simple_filter_to_relation(@resources_relation)\n\n # Display filters\n @resources_relation = apply_sorting_to_relation(@resources_relation)\n @paginated_resources_relation = apply_pagination_to_relation(@resources_relation)\n\n @resources = @paginated_resources_relation\n @resources_count = @resources_relation.count\n end\n end\n\n @resources\n rescue ActiveRecord::RecordNotFound => e\n raise Exception::NotFound.new(e.message,\n :retry_possible => false)\n end", "def index\n self.resources = resource_class.all.paginate(per_page: 15, page: (params[:page] || 1).to_i)\n end", "def index\n @resources = Catalogs::Level.search(params[:search]).order(\"#{sort_column} #{sort_direction}\").paginate(per_page: 11, page: params[:page])\n authorize @resources\n end", "def sorted_articles\n require 'time'\n articles.sort_by do |a|\n attribute_to_time(a[:created_at])\n end.reverse\n end", "def posts\n Post.all(self).sort_by { |entry| entry.created }.reverse\n end", "def index\n @posts = Post.global.main.sorted\n end", "def tags\n object.tags.pluck(:title).sort\n end", "def index\n if params[:sort] == \"created_at\"\n @topics = Topic.order(sort_column + ' ' + sort_direction).page(params[:page]).per(8)\n\n else\n @topics = Topic.page(params[:page]).per(8).left_joins(:comments)\n .group(:id)\n .order('COUNT(comments.id) DESC')\n end\n\n end", "def posts_of course\n course.posts.sort_by{ |item| last_interation(item) }.reverse\n end", "def sort_schemas_by_category(schemas)\n sorted_schemas=[]\n categories = {\n documents: %w(document invoice credit_note order estimate payment_reminder recurring line_item divider_item sub_total_item),\n contacts: %w(contact address),\n templates: %w(pdf_template email_template text_template export_template),\n system: %w(company user language sub auth_permission),\n supportive: %w(task tag email comment attachment export payment product),\n accounting: %w(account account_entry account_billing),\n }\n categories.each do |cat, obj_types|\n sorted_schemas << cat\n sorted_schemas << schemas.select{|obj| obj_types.include?(obj[:title]) }.sort{|a,b| a[:title].humanize <=> b[:title].humanize }\n end\n sorted_schemas\nend", "def resources\n ([self] + parent_groups).reverse.inject({}) do |memo, group|\n begin\n memo.merge(group.poise_spec_helpers[:resources] || {})\n rescue NoMethodError\n memo\n end\n end\n end", "def list_resource\n resource_class.all_but_other\n end", "def index\n @resources = Group.search(params[:search]).where(id: current_user.admin_groups).order(\"#{sort_column} #{sort_direction}\").paginate(per_page: 11, page: params[:page])\n authorize @resources\n end", "def articles_asc\n articles.sort_by(&:published)\n end", "def sort\n @entries = DependencySorter.new(@entries).sorted_items\n end", "def index\n @categories = Category.includes(:topic).order('topics.order', :order).all\n end", "def apply_sorting(relation)\n relation.order(@q.sorting.to_sql)\n end", "def index\n\n #checking params type whether file or image and the perticaular file types will be sorted\n @type = params[:type]\n\n if @type == 'image'\n @resources = Resource.all_images.paginate({\n :page => params[:page],\n :per_page => resource_per_page\n })\n elsif @type == 'file'\n @resources = Resource.all_files.paginate({\n :page => params[:page],\n :per_page => resource_per_page\n })\n else\n @resources = Resource.paginate({\n :page => params[:page],\n :per_page => resource_per_page\n })\n end\n\n respond_to do |format|\n format.html{}\n end\n end", "def concat(resources)\n relate_resources(resources)\n super\n end", "def index\n #@agenda_reserv_resources = Agenda::ReservResource.all\n @agenda_reserv_resources = Agenda::ReservResource.search(params[:search]).order(\"#{sort_column} #{sort_direction}\").paginate(per_page: 15, page: params[:page])\n end", "def canonicalize(_context, resources)\n resources.each do |r|\n if r[:reservedipranges]\n if r[:reservedipranges] == 'unset'\n r[:reservedipranges] = []\n else\n r[:reservedipranges].sort_by! { |k| k['start'] }.sort_by! { |k| k['end'] }\n end\n end\n r[:fixedipassignments] = {} if r[:fixedipassignments] && r[:fixedipassignments] == 'unset'\n end\n end", "def get_sort(collection, params)\n if params[:sort] && sort = cached_source(params[:sort])\n collection.joins(:results)\n .where(\"results.source_id = ?\", sort.id)\n .order(\"results.total DESC\")\n elsif params[:sort] == \"created_at\"\n collection.order(\"works.created_at ASC\")\n else\n collection.order(\"works.issued_at DESC\")\n end\n end", "def index\n @resources = Resource.eager_load(:resource_type).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resources }\n end\n end", "def all_activities\n activities = []\n self.expenses.each do |expense|\n activities += [{:type => \"expense\", :object => expense}]\n end\n self.charges.each do |charge|\n activities += [{:type => \"charge\", :object => charge}]\n end\n activities.sort do |a, b|\n # TODO: what is this printing for?\n puts \"A\", a\n puts \"B\", b\n b[:object].created_at <=> a[:object].created_at\n end\n end", "def index\n #Sorting\n sort_init 'provincia'\n sort_update 'provincia' => 'provinces.name',\n 'regione' => \"regions.name\"\n\n @provinces = Province.find(:all, :include => :region ,:order => sort_clause )\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @provinces }\n end\n end", "def index\n @posts = Post.all.sort{ |x,y| y.created_at <=> x.created_at }\n end", "def index\n @student_actions = StudentAction.all.sort! { |a, b| b.created_at <=> a.created_at }\n end", "def sort_alpha\n @assets = @assets.sort_by { |h| h[:name] }\n #redirect_to user_path\n end" ]
[ "0.7103373", "0.6793567", "0.6656269", "0.644793", "0.6329379", "0.6042379", "0.6025476", "0.6016506", "0.6010833", "0.596091", "0.59522825", "0.5924344", "0.59237415", "0.5858654", "0.5856437", "0.58447605", "0.5841473", "0.58362025", "0.58116984", "0.5789317", "0.5746036", "0.5745327", "0.5744817", "0.57438534", "0.57267153", "0.57233477", "0.57149833", "0.57120055", "0.56942445", "0.56826055", "0.5681307", "0.56805706", "0.56768054", "0.5648604", "0.5638736", "0.5633567", "0.56310534", "0.5626906", "0.5625915", "0.5605329", "0.55975986", "0.55956477", "0.5592675", "0.55840653", "0.5572656", "0.5569358", "0.55609125", "0.55547875", "0.55512404", "0.55430526", "0.55403876", "0.5534824", "0.5534824", "0.5524316", "0.5521311", "0.55147016", "0.55147016", "0.5502014", "0.5501691", "0.5496684", "0.54922587", "0.54727983", "0.54704964", "0.54656196", "0.5451735", "0.54516655", "0.5439639", "0.5437326", "0.5428874", "0.5428825", "0.54283243", "0.5424708", "0.54232717", "0.54174125", "0.54146904", "0.54139495", "0.54121196", "0.54109746", "0.5406402", "0.54052263", "0.5404362", "0.5401924", "0.5400591", "0.5400222", "0.5399876", "0.5399506", "0.5399185", "0.5397099", "0.53961426", "0.53912216", "0.538679", "0.5379678", "0.5370863", "0.53696126", "0.53642005", "0.5363013", "0.53598285", "0.5358612", "0.535701", "0.5354076", "0.53538626" ]
0.0
-1
Return the physical path within the repository Takes care of symbolic links
def relative_path_to(path, relative_to = nil) if relative_to path = File.expand_path( # symlink, e.g. "../../../../grid5000/environments/etch-x64-base-1.0.json" path, # e.g. : File.join("/", File.dirname("grid5000/sites/rennes/environments/etch-x64-base-1.0")) File.join('/', File.dirname(relative_to)) ).gsub(%r{^/}, '') end path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def repo_path\n @path\n end", "def abspath\n \"#{repo_base_path}/#{self.git_repo_path}\"\n end", "def absolute_repository_path\n File.join(\n OpenProject::Revisions::Git::GitoliteWrapper.gitolite_global_storage_path,\n git_path\n )\n end", "def relative_path\n File.join(@repo, @bundle)\n end", "def local_path\n src = if %i(direct repo).include?(new_resource.source)\n package_metadata[:url]\n else\n new_resource.source.to_s\n end\n ::File.join(Chef::Config[:file_cache_path], ::File.basename(src))\n end", "def path\n \"repos/#{@user}/#{name}\"\n end", "def repo_path\n if !self.cmd_opt.empty?\n self.fake_path = repo_name\n # real path is something like /jupiler_home/repositories/username/repo_name\n self.real_path = Settings.jup_sh.home + '/' +\n self.username_from_cmd + \"/\" +\n self.fake_path\n return self.real_path\n end\n end", "def repository_root\n File.expand_path(@repo.path + \"/../\")\n end", "def linked_path\n File.readlink current_directory\n end", "def git_path\n File.join(\n user.storage_path,\n 'repositories',\n 'scratchpad')\n end", "def repo_path\n current_user = User.current\n # root dir is the system home folder, need to exist prior to app launch\n # e.g. /home\n root_dir = Pathname(Settings.repos.root_dir)\n\n # base dir is aq_git user home folder, need to exist prior to app launch\n # e.g. /home/aq_git\n\n base_dir = root_dir + Settings.repos.repo_user\n\n if self.kind == \"git\"\n repo_path = Settings.git.repo_path\n end\n\n # git dir is where the repositories are gonna be stored, creating if needed\n # e.g. /home/aq_git/git or /home/aq_git/hg\n scm_dir = base_dir + repo_path\n scm_dir.mkdir if base_dir.exist? && !scm_dir.exist?\n\n # repo dir is the repository own path\n # e.g. /home/aq_git/git/username\n if self.owner\n repo_dir = scm_dir + self.owner.login\n elsif current_user\n repo_dir = scm_dir + current_user.login\n end\n repo_dir.mkdir if !repo_dir.exist?\n\n # the dot dir is the .git (or .hg) located in the repository\n # e.g. /home/aq_git/git/username/some_repo.git\n if self.is_git?\n dot_dir = repo_dir + (self.name + \".#{self.kind}\")\n dot_dir.mkdir if !dot_dir.exist?\n end\n\n self.path = dot_dir.to_s\n end", "def virtual_path\n\t\tself.class.local_file_path_from_hash( Pathname.new('/managed_file_resource_images/'), self.file_hash ).to_s\n end", "def repo_path\n DeliveryGolang::Helpers.repo_path(node)\n end", "def repo_path\n @repo_path ||= Pathname.new(Dir.pwd).descend { |p| break p if (p + '.git').directory? }\n end", "def repo_path\n # root dir is system home folder, need to exist prior to app launch\n # /home\n root_dir = Pathname(Settings.application.root_dir)\n\n # base dir is aq_git user home folder, need to exist prior to app launch\n # /home/aq_git\n base_dir = root_dir + Settings.application.repo_user\n\n if self.kind == \"git\"\n repo_path = Settings.application.repo_git_path\n end\n\n # git_dir is where the repositories are gonna be stored, creating if needed\n # /home/aq_git/git or /home/aq_git/hg\n scm_dir = base_dir + repo_path\n scm_dir.mkdir if base_dir.exist? && !scm_dir.exist?\n\n # repo dir is the repository own path\n # /home/aq_git/git/username\n if self.owner\n repo_dir = scm_dir + self.owner.login\n elsif current_user\n repo_dir = scm_dir + current_user.login\n end\n repo_dir.mkdir if !repo_dir.exist?\n\n # the dot dir is the .git (or .hg) located in the repository\n # /home/aq_git/git/username/reposit.git\n if self.is_git?\n dot_dir = repo_dir + (self.name + \".#{self.kind}\")\n dot_dir.mkdir if !dot_dir.exist?\n end\n\n self.path = dot_dir.to_s\n end", "def repo_dir; end", "def repo_path\n @config.get_value('GIT_REPO_ROOT')\n end", "def repo_path(path)\n File.join(File.expand_path('../../..', $0), path)\n end", "def git_path\n if bare\n \"#{path}\"\n else\n \"#{path}/.git\"\n end\n end", "def path\n return github_url if github_url.is_local_dir?\n\n path_to_name = File.join( @@strategies_location, username, name )\n File.join path_to_name, get_github_repo_name(github_url)\n end", "def repo_path\n @repo.dirstate.copy_map[@path] || @path\n end", "def repo_root; end", "def pathSourceHyper\n\t\"../../HyperOpen/\"\nend", "def repo_path\n if !self.cmd_opt.empty?\n if self.is_git?\n self.fake_path = self.cmd_opt.gsub(\"'\",\"\").split(\"/\")[-1]\n self.real_path = Settings.aq_sh.user_home + \"/\" +\n Settings.aq_sh.user_name + \"/\" +\n Settings.git.repo_path + \"/\" +\n self.username_from_cmd + \"/\" +\n self.fake_path\n return self.real_path\n elsif self.is_hg?\n self.fake_path = self.cmd_opt.split(\" \")[1]\n self.real_path = Settings.aq_sh.user_home + \"/\" +\n Settings.aq_sh.user_name + \"/\" +\n Settings.hg.repo_path + \"/\" +\n self.fake_path\n return self.real_path\n end\n end\n end", "def maven_repository_path\n command = \"#{package_management_command} help:evaluate -Dexpression=settings.localRepository -q -DforceStdout\"\n command += \" #{@maven_options}\" unless @maven_options.nil?\n stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(command) }\n raise \"Command '#{command}' failed to execute: #{stderr}\" unless status.success?\n\n Pathname(stdout)\n end", "def getRealPath(path) Pathname.new(path).realpath.to_s; end", "def getRealPath(path) Pathname.new(path).realpath.to_s; end", "def local\n return Global.git_repository_directory + @address_digest\n end", "def full_path\n container.root.join(path)\n end", "def full_path\n container.root.join(path)\n end", "def repo_store_root\n Pathname(Razor.config['repo_store_root'])\n end", "def repos_path\n ::File.expand_path(@repos_path)\n end", "def gitpath\n %x{git config --get remote.origin.url | sed \"s;^.*root/;;\" | sed \"s;\\.git$;;\"}.squish\n end", "def src_path(path)\n File.join(@git.dir.to_s, path)\n end", "def primary_repo_base_dir\n File.expand_path(\n setting(:relative_path_to_primary_repo),\n base_dir(:rtfile_dir)\n ).sub(/\\/?\\z/, '') + '/'\n end", "def get_path(commit)\n repos_path = File.expand_path('repos')\n File.join(repos_path, commit)\n end", "def raw_gitdir\n\t\t\twith_dir do\n\t\t\t\treturn Pathname.new(%x/git rev-parse --git-dir/.chomp)\n\t\t\tend\n\t\tend", "def relative_directory; end", "def path\n File.join Dubya.root_path, 'vendor/wiki'\n end", "def blob_path(relative = true)\n blob_path = File.join(self.class.name, hash.to_s)\n if relative\n blob_path\n else\n File.join(repository_path, blob_path)\n end\n end", "def getRepositoryPath\n return @REPOSITORYPATHORSELECT\n end", "def relative_path; end", "def relative_path; end", "def relative_path; end", "def relative_path; end", "def relative_path; end", "def git_dir; end", "def relative_path\n @relative_path ||= absolute_path.sub(/^#{Bookshelf::remote_folder}\\/?/,'')\n end", "def remote_path_for(package)\n File.join(\n Config.artifactory_base_path,\n package.metadata[:name],\n package.metadata[:version],\n publish_platform(package),\n publish_platform_version(package),\n package.metadata[:basename],\n )\n end", "def path\n File.join(self.drive.path, self.relative_path)\n end", "def repo_path\n @repo_path ||= \"/tmp/extension-repo-#{id}\"\n end", "def full_path_to_remote_dir\n (remote_dir[0] == ?/ ? remote_dir : \"$(pwd)/#{remote_dir}\").chomp('/')\n end", "def dir\n # config.repos_dir + @name\n end", "def path\n real_path = Pathname.new(root).realpath.to_s\n full_path.sub(%r{^#{real_path}/}, '')\n end", "def calc_dir(page_base)\n page_full_path = File.join(GIT_REPO, unwiki(page_base))\n end", "def relative_path\n @local_path.relative_path_from(@platform.local_path)\n end", "def in_path(repository_name)\n File.join(SETTINGS[\"repositories_path\"], repository_name)\n end", "def path\n Rails.root.join(ROOT, type, name, executable).to_s\n end", "def cache_repository_path\n File.absolute_path(File.join(Rails.root, 'cache', cached_directory))\n end", "def public_path_for(sling)\n return home_path_for(sling) + \"/public\"\n end", "def data_path(filename)\n File.join(File.dirname(__FILE__), 'repo', filename)\n end", "def relative_path\n return self.avatar.match(/http[^|]*/)[0].to_s\n end", "def relative_path(from, to); end", "def public_path\n # TODO: this might present an attack vector if the file is outside the web_root\n options[:web_root].to_s + '/' + self.relative_path.gsub(\"\\\\\", \"/\")\n end", "def relative_directory\n return '' unless @directory_root\n @path - @directory_root - name\n end", "def path\n @directory.path\n end", "def path()\n return ::File.join(@root, @name)\n end", "def base_path\n Dir.pwd + \"/\"\n end", "def ref_path(dir, subdir, path)\n # this stuff is overkill, and doesn't work anyways:\n #depth = dir.split(File::SEPARATOR).reject{ |d| d.empty? }.count\n #parent_dirs = Array.new(depth, '..')\n File.join('..', ContentRepo::ResourceNode::PATHNAME, path )\n end", "def disk_path\n project.full_path\n end", "def source\n return BASE_SOURCE_URL + '/' + repo_id unless path_extension\n BASE_SOURCE_URL + '/' + repo_id + '/' + path_extension.sub(%r{^\\s*/}, '').sub(%r{/\\s*$}, '')\n end", "def path\n native.path\n end", "def path\n File.join(@base, @target)\n end", "def path\n return @path\n end", "def uri\n \"file://\" + self.repos_path\n end", "def path\n @base\n end", "def path_of(path)\n File.join(self.path, path)\n end", "def clone_dir\n \"#{RdocInfo.config[:tmp_dir]}/#{@project.owner}/#{@project.name}/blob/#{@project.commit_hash}\"\n end", "def getFullPath(relativePath)\n return baseDir + relativePath\n end", "def determine_path\n if source_line.file == SourceLine::DEFAULT_FILE\n return source_line.file\n end\n\n full_path = File.expand_path(source_line.file)\n pwd = Dir.pwd\n\n if full_path.start_with?(pwd)\n from = Pathname.new(full_path)\n to = Pathname.new(pwd)\n\n return from.relative_path_from(to).to_s\n else\n return full_path\n end\n end", "def path(key = '')\n @path ||= File.join(File.expand_path(@options[:repo]), key)\n end", "def path(key = '')\n @path ||= File.join(File.expand_path(@options[:repo]), key)\n end", "def path() end", "def path() end", "def path() end", "def path\n @svn_name\n end", "def realpath\n if(self.page)\n return Rails.application.routes.url_helpers.page_path(self.page)\n end\n '/' + self.explicit_path\n end", "def virtual_path; end", "def virtual_path; end", "def virtual_path; end", "def home_path\n @ssh_home\n end", "def path\n File.join(@base, @name)\n end", "def path\n # TODO: is this trip really necessary?!\n data.fetch(\"path\") { relative_path }\n end", "def path(rel)\n File.join(File.dirname(__FILE__), \"..\", rel)\nend", "def custom_repo_path(org_label, environment_label, product_label, repo_label)\n prefix = [org_label, environment_label].map { |x| x.gsub(/[^-\\w]/, \"_\") }.join(\"/\")\n prefix + custom_content_path(product_label, repo_label)\n end", "def path\n driver.getPath\n end", "def full_path\n path\n end", "def path\n @link.TargetPath\n end", "def working_directory\n @link.WorkingDirectory\n end", "def relative_path\n name\n end" ]
[ "0.76176834", "0.7288794", "0.7199333", "0.7054408", "0.70526856", "0.70484394", "0.7033288", "0.7008346", "0.6925168", "0.6921327", "0.6901449", "0.6885142", "0.68739384", "0.6863467", "0.68331283", "0.6827163", "0.67837936", "0.6766695", "0.67578685", "0.67453045", "0.674343", "0.674101", "0.67260265", "0.6713778", "0.67123556", "0.6668369", "0.6668369", "0.6654482", "0.6644287", "0.6644287", "0.6643625", "0.6637783", "0.6632643", "0.66109854", "0.6606674", "0.6601913", "0.6591776", "0.65802306", "0.6575463", "0.65688425", "0.6562326", "0.6552027", "0.6552027", "0.6552027", "0.6552027", "0.6552027", "0.65409", "0.65312004", "0.6521107", "0.6519852", "0.65031326", "0.6495923", "0.64824766", "0.64590245", "0.6437337", "0.64050347", "0.6382224", "0.63580364", "0.63553596", "0.63342994", "0.6326033", "0.6301082", "0.62898546", "0.62807095", "0.62764394", "0.6261019", "0.6253361", "0.6246982", "0.6236523", "0.6216655", "0.6211352", "0.62035304", "0.61961836", "0.61898315", "0.61893934", "0.6185872", "0.6181023", "0.61803997", "0.6179454", "0.6171908", "0.6170409", "0.6170409", "0.6165445", "0.6165445", "0.6165445", "0.6163728", "0.6157601", "0.61439735", "0.61439735", "0.61439735", "0.61421275", "0.61381865", "0.61355543", "0.6134577", "0.612986", "0.61194175", "0.6110822", "0.61054844", "0.61037177", "0.61014205" ]
0.6307605
61
Implementing git log behavior with Walker from libgit2 can results in slow responses. Filtering on path for each commit is time consuming. Adapted from:
def entry_changed?(commit, path) parent = commit.parents[0] entry = commit.tree.path(path) rescue nil # if at a root commit, consider it changed if we have this file; # i.e. if we added it in the initial commit if !parent return entry != nil end parent_entry = begin parent.tree.path(path) rescue Rugged::TreeError begin parent.tree.path(path + '.json') rescue Rugged::TreeError nil end end # does exist in either, no change if !entry && !parent_entry false # only in one of them, change elsif !entry || !parent_entry true # otherwise it's changed if their ids arent' the same else entry[:oid] != parent_entry[:oid] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_git_log(dir)\n\n name = `git config --global --get user.email`.strip\n git_cmd = \"git log --stat --since='1 day ago' --author='#{name}'\"\n\n out = []\n Dir.foreach(dir) do |d|\n next if d == \".\" or d == \"..\"\n t = dir + '/' + d\n next if not File.directory?(t)\n if File.exists?(t + '/.git') and File.directory?(t + '/.git') then\n\n c = \"\"\n Dir.chdir(t) do |r|\n ci = `#{git_cmd}`\n next if ci.empty?\n\n ci.each_line do |l|\n #puts l\n c = \"#{l[0..12]}... \" if l.start_with?(\"commit\")\n\n out << (c + l.delete(\"\\n\")) if l.include?(\"files changed\") or l.include?(\"file changed\")\n end\n end\n end\n end\n out\nend", "def log(opts = {})\n max_count = opts[:max_count]\n skip = opts[:skip]\n start = opts[:start]\n raise ArgumentError, \"Invalid commit: #{start}\" if start.to_s =~ /^\\-/\n log = git_log('--pretty=tformat:%H%n%P%n%T%n%an%n%ae%n%at%n%cn%n%ce%n%ct%n%x00%s%n%b%x00',\n skip ? \"--skip=#{skip.to_i}\" : nil,\n max_count ? \"--max-count=#{max_count.to_i}\" : nil, start, '--', *opts[:path]).split(/\\n*\\x00\\n*/)\n commits = []\n log.each_slice(2) do |data, message|\n data = data.split(\"\\n\")\n parents = data[1].empty? ? nil : data[1].split(' ').map {|id| Reference.new(:repository => self, :id => id) }\n commits << Commit.new(:repository => self,\n :id => data[0],\n :parents => parents,\n :tree => Reference.new(:repository => self, :id => data[2]),\n :author => User.new(data[3], data[4], Time.at(data[5].to_i)),\n :committer => User.new(data[6], data[7], Time.at(data[8].to_i)),\n :message => message.strip)\n end\n commits\n rescue CommandError => ex\n return [] if ex.output =~ /bad default revision 'HEAD'/i\n raise\n end", "def git_log(directory)\n `git log --since=\"28 days ago\" --stat --oneline -- --relative= ../#{directory}`\nend", "def chunked_git_log(path, options, &block)\n skip = 0\n\n revisions = revisions_for_git_cmd(options)\n\n chunk_size = options[:chunk_size] || default_chunk_size\n\n while true\n\n if options[:limit]\n chunk_size = [options[:limit] - skip, chunk_size].min\n end\n\n cmd_args = %w{log --date=iso --date-order --name-status --no-color}\n cmd_args << \"--format=#{options[:format]}\"\n\n cmd_args << '--all' if revisions.empty? && options[:all]\n cmd_args << \"--encoding=#{path_encoding}\"\n cmd_args << \"--skip=#{skip}\" << \"--max-count=#{chunk_size}\"\n cmd_args << '--stdin'\n\n if path && !path.empty?\n cmd_args << '--' << scm_iconv(path_encoding, 'UTF-8', path)\n end\n\n git_log = nil\n git_cmd(cmd_args) do |stdin, stdout|\n stdin.binmode\n stdin.puts(revisions.join(\"\\n\"))\n stdin.close\n git_log = stdout.read.force_encoding(path_encoding)\n end\n\n begin\n return nil if git_log.blank?\n\n rescue ArgumentError #invalid byte sequence in UTF-8\n git_log = remove_invalid_characters(git_log)\n end\n\n # get patch_ids for commits\n\n git_patch_ids = patch_ids(path, revisions, chunk_size, skip)\n\n block.call(git_log, git_patch_ids)\n\n skip += chunk_size\n end\n end", "def build_log(sha, options)\n # Instantiate a Walker and add the SHA hash\n walker = Rugged::Walker.new(rugged)\n walker.push(sha)\n\n commits = []\n skipped = 0\n current_path = options[:path]\n current_path = nil if current_path == ''\n\n limit = options[:limit].to_i\n offset = options[:offset].to_i\n skip_merges = options[:skip_merges]\n\n walker.sorting(Rugged::SORT_DATE)\n walker.each do |c|\n break if limit > 0 && commits.length >= limit\n\n if skip_merges\n # Skip merge commits\n next if c.parents.length > 1\n end\n\n if !current_path ||\n commit_touches_path?(c, current_path, options[:follow], walker)\n\n # This is a commit we care about, unless we haven't skipped enough\n # yet\n skipped += 1\n commits.push(c) if skipped > offset\n end\n end\n\n walker.reset\n\n commits\n end", "def parse!\n return if @parsed\n \n log_data = `git log -1 HEAD 2> /dev/null`\n \n unless log_data.empty?\n # DETERMINING PARENTS\n commit = log_data[/^commit (.+)$/, 1]\n dad = commit ? commit[0..6] : nil\n mom = nil\n \n if log_data =~ /^Merge: (.+)\\.\\.\\. (.+)\\.\\.\\.$/ # Merge: 1c002dd... 35cfb2b...\n dad = $1 # just have them both use the short name, nbd\n mom = $2\n end\n \n @parents = [dad, mom].compact.map {|p| Changeset.new @repo, p }\n else\n @parents = []\n end\n @parsed = true\n end", "def commit_paths_NO_LOGGING\n queries = path_as_report_groups.collect {|group| group.find_by_hash[\"commit_path\"]}.compact\n return commits.inject([]) {|commit_paths, commit| commit_paths | commit.paths} if queries.empty?\n queries.inject(nil) do |common_commit_paths, query|\n match = eval(query[\"match\"]) rescue nil\n omit = eval(query[\"omit\"]) rescue nil\n all_matching_paths = commits.inject([]) do |commit_paths, commit|\n commit_paths | commit.paths.select {|commit_path| (match.nil? || commit_path.path =~ match) && (omit.nil? || (commit_path.path =~ omit).nil?)}\n end\n (common_commit_paths ? common_commit_paths & all_matching_paths : all_matching_paths).sort!\n end\n end", "def getChangesOfCommit(commit_id = false)\n my_commit = ((commit_id == false and @repo.commits.size > 0) ? @repo.commits.first : @repo.commit(commit_id))\n if my_commit == nil\n return false\n end\n \n # get list of changed files and parse it\n @filelist = Hash.new\n options = {:r => true, :name_status => true, :no_commit_id => true}\n if @repo.commit(my_commit.sha).parents[0] == nil # if my_commit is the first commit\n options[:root] = true\n end\n changed_files_list = @git.diff_tree(options, my_commit.id).strip\n if changed_files_list.class == String and changed_files_list.length > 0\n changed_files_list.split(\"\\n\").each do |f|\n commit = my_commit\n operation = f[0,1] # D/M/A\n filepath = f[2..-1] # path+filename\n path = \"/\" + filepath.match(/^.+\\//).to_s # just path\n status = \"created\"\n if operation =~ /^D$/i # deleted\n # the file was deleted, so get the blob from the parent-commit\n commit = @repo.commit(my_commit.parents[0].sha)\n status = \"deleted\"\n elsif operation =~ /^M$/i # modified\n status = \"updated\"\n end\n blob = commit.tree/(filepath)\n\n #name = filepath.gsub(path[1..-1], '') #blob.name\n path = path.gsub(/\\/private\\/[0-9]+\\//,'')\n \n \n \n @filelist[\"/\" + filepath] = {\"uploaded\" => '1', \"status\" => status, \"blob_hash\" => blob.id, \"name\" => blob.name, \"path\" => \"/#{path}\", \"size\" => blob.size, \"filetype\" => blob.mime_type, \"filedate\" => @repo.commit(commit.sha).date.strftime('%T %F').to_s}\n \n \n end\n end\n\n if @filelist.size > 0\n return @filelist\n else\n return false\n end\n end", "def generate_git_commit_log(rev=ENV['GIT_PREVIOUS_SUCCESSFUL_COMMIT'] || 'HEAD^^^^^')\n g = Git.open(ENV['PWD'], :log => Logger.new(STDOUT))\n begin\n change_log = g.log.between(rev).map { |c| \"- \" + c.message.lines.first.chomp }.join \"\\n\"\n \"Commit Log:\\n\\n#{change_log}\\n\"\n rescue\n \"Unable to parse commit logs\"\n end\nend", "def process_git_log_into_time\n distribute_entries_to_authors( load_git_log_entries( path_to_git_repo ) )\n return prepare_rows_for_csv\n end", "def list( by_line=false )\n\n path_to_dot_git = File.join( @git_folder_path, \".git\" )\n line_by_line = by_line ? \"-v\" : \"\"\n\n git_log_cmd = \"git --git-dir=#{path_to_dot_git} --work-tree=#{@git_folder_path} status #{line_by_line}\"\n log.info(x) { \"[git] status command => #{git_log_cmd}\" }\n git_log_output = %x[#{git_log_cmd}]\n\n git_log_output.log_debug if by_line\n git_log_output.log_info unless by_line\n\n end", "def all_file_commits_data(path)\n time = ` cd /tmp/#{@repo} && git log --format=%ct #{path} `.split(\"\\n\").map{|time| time.to_i}\n ins_del = ` cd /tmp/#{@repo} && git log --numstat --format=%h #{path} | grep #{path} `.split(\"\\n\").map{|line| line.split(\" \")[0..1]}.map{|insert| insert.map{|x| x.to_i}}\n time.zip(ins_del)\n end", "def get_log\n if @format == :markdown\n log = `git log --pretty=format:\"* %ad %s %n%b\" --date=short #{@since}`\n log.gsub /^$\\n/, ''\n else\n `git log --pretty=format:\"*<li>%ad %s%n%b</li>\" --date=short #{@since}`\n end\nend", "def git(path, cmd, log=true)\n $stdout.puts(\"#{path.sub(ROOT_PATH, '')}: git #{cmd}\") if log\n git_path = path / '.git'\n git_index = git_path / 'index'\n\n # The env can become polluted; breaking git. This will avoid that.\n %x[GIT_DIR=#{git_path}; GIT_WORK_TREE=#{path}; GIT_INDEX_FILE=#{git_index}; git #{cmd}]\nend", "def update_commitlist(h)\n h.map do |entry|\n sha = entry[\"commit\"].to_s.strip\n n = entry[\"note\"]\n # First, try to look it up in our existing repo\n if commit_exists?(sha) || sha.empty?\n entry # do nothing, put it back in the hash\n else\n # Ok, we know it doesn't exist. Now look it up in gitlog.json\n if @gitlog_json.key? sha\n m = @gitlog_json[sha][\"message\"]\n svn_id = m.lines.select {|l| l.match? /git-svn-id/ }.join.strip\n grep_cmd = <<~EOS.strip\n git -C ./tmp/src rev-list --all --grep=\"#{svn_id}\" --\n EOS\n stdout, stderr, status = Open3.capture3(grep_cmd)\n if stderr.empty?\n {\n \"commit\" => stdout.strip,\n \"note\" => <<~EOS.strip\n #{entry[\"note\"].to_s.lines.join(\"\\n\")}\n\n Formerly #{sha} before HTTPD rewrote Git history.\n EOS\n }\n else\n warn \"ERROR getting commit #{sha}. #{stderr}\"\n entry\n end\n else\n warn \"ERROR commit #{sha} does not exist in gitlog.json\"\n entry\n end\n end\n end\nend", "def committed_files sha\n array_output_of \"git diff-tree --no-commit-id --name-only -r #{sha}\"\nend", "def commit_grep(pattern, treeish=head) # :yields: commit\n options = pattern.respond_to?(:merge) ? pattern.dup : {:grep => pattern}\n options.delete_if {|key, value| nil_or_empty?(value) }\n options[:format] = \"%H\"\n \n sandbox do |git, work_tree, index_file|\n git.log(options, treeish).split(\"\\n\").each do |sha|\n yield grit.commit(sha)\n end\n end\n self\n end", "def add_entries_info(entries, path)\n # use the git reflog to get a list of pushes\n reflog = @repo.ref('refs/heads/master').log.reverse\n # walk through all the commits until this revision's +@commit+ is found\n # (this is needed to advance the reflog to the right point, since +@commit+ may be between two pushes)\n walker_entries = entries.dup\n last_commit = @repo.last_commit\n reflog_entries = {}\n reflog_entries[last_commit.oid] = { index: -1 }\n found = false\n walker = Rugged::Walker.new(@repo)\n walker.sorting(Rugged::SORT_TOPO)\n walker.push(last_commit.oid)\n walker.each do |commit|\n current_reflog_entry = GitRepository.try_advance_reflog!(reflog, reflog_entries, commit)\n found = true if @commit.oid == commit.oid\n next unless found\n # check entries that were modified\n mod_keys = walker_entries.keys.select { |entry_name| entry_changed?(File.join(path, entry_name), commit) }\n mod_entries = walker_entries.extract!(*mod_keys)\n mod_entries.each do |_, mod_entry|\n mod_entry.last_modified_revision = commit.oid\n mod_entry.last_modified_date = commit.time.in_time_zone\n mod_entry.submitted_date = current_reflog_entry[:time]\n mod_entry.changed = commit.oid == @revision_identifier\n mod_entry.user_id = commit.author[:name]\n end\n break if walker_entries.empty?\n end\n end", "def commit_sha commit_message\n output_of \"git log --grep='#{commit_message}' --format='%h' -1\"\nend", "def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}, &block)\r\n logger.debug \"<cvs> revisions path:'#{path}',identifier_from #{identifier_from}, identifier_to #{identifier_to}\"\r\n \r\n path_with_project=\"#{url}#{with_leading_slash(path)}\"\r\n cmd = \"#{CVS_BIN} -d #{root_url} rlog\"\r\n cmd << \" -d\\\">#{time_to_cvstime(identifier_from)}\\\"\" if identifier_from\r\n cmd << \" #{shell_quote path_with_project}\"\r\n shellout(cmd) do |io|\r\n state=\"entry_start\"\r\n \r\n commit_log=String.new\r\n revision=nil\r\n date=nil\r\n author=nil\r\n entry_path=nil\r\n entry_name=nil\r\n file_state=nil\r\n branch_map=nil\r\n \r\n io.each_line() do |line| \r\n \r\n if state!=\"revision\" && /^#{ENDLOG}/ =~ line\r\n commit_log=String.new\r\n revision=nil\r\n state=\"entry_start\"\r\n end\r\n \r\n if state==\"entry_start\"\r\n branch_map=Hash.new\r\n if /^RCS file: #{Regexp.escape(root_url_path)}\\/#{Regexp.escape(path_with_project)}(.+),v$/ =~ line\r\n entry_path = normalize_cvs_path($1)\r\n entry_name = normalize_path(File.basename($1))\r\n logger.debug(\"Path #{entry_path} <=> Name #{entry_name}\")\r\n elsif /^head: (.+)$/ =~ line\r\n entry_headRev = $1 #unless entry.nil?\r\n elsif /^symbolic names:/ =~ line\r\n state=\"symbolic\" #unless entry.nil?\r\n elsif /^#{STARTLOG}/ =~ line\r\n commit_log=String.new\r\n state=\"revision\"\r\n end \r\n next\r\n elsif state==\"symbolic\"\r\n if /^(.*):\\s(.*)/ =~ (line.strip) \r\n branch_map[$1]=$2\r\n else\r\n state=\"tags\"\r\n next\r\n end \r\n elsif state==\"tags\"\r\n if /^#{STARTLOG}/ =~ line\r\n commit_log = \"\"\r\n state=\"revision\"\r\n elsif /^#{ENDLOG}/ =~ line\r\n state=\"head\"\r\n end\r\n next\r\n elsif state==\"revision\"\r\n if /^#{ENDLOG}/ =~ line || /^#{STARTLOG}/ =~ line \r\n if revision\r\n \r\n revHelper=CvsRevisionHelper.new(revision)\r\n revBranch=\"HEAD\"\r\n \r\n branch_map.each() do |branch_name,branch_point|\r\n if revHelper.is_in_branch_with_symbol(branch_point)\r\n revBranch=branch_name\r\n end\r\n end\r\n \r\n logger.debug(\"********** YIELD Revision #{revision}::#{revBranch}\")\r\n \r\n yield Revision.new({ \r\n :time => date,\r\n :author => author,\r\n :message=>commit_log.chomp,\r\n :paths => [{\r\n :revision => revision,\r\n :branch=> revBranch,\r\n :path=>entry_path,\r\n :name=>entry_name,\r\n :kind=>'file',\r\n :action=>file_state\r\n }]\r\n }) \r\n end\r\n \r\n commit_log=String.new\r\n revision=nil\r\n \r\n if /^#{ENDLOG}/ =~ line\r\n state=\"entry_start\"\r\n end\r\n next\r\n end\r\n \r\n if /^branches: (.+)$/ =~ line\r\n #TODO: version.branch = $1\r\n elsif /^revision (\\d+(?:\\.\\d+)+).*$/ =~ line\r\n revision = $1 \r\n elsif /^date:\\s+(\\d+.\\d+.\\d+\\s+\\d+:\\d+:\\d+)/ =~ line\r\n date = Time.parse($1)\r\n author = /author: ([^;]+)/.match(line)[1]\r\n file_state = /state: ([^;]+)/.match(line)[1]\r\n #TODO: linechanges only available in CVS.... maybe a feature our SVN implementation. i'm sure, they are\r\n # useful for stats or something else\r\n # linechanges =/lines: \\+(\\d+) -(\\d+)/.match(line)\r\n # unless linechanges.nil?\r\n # version.line_plus = linechanges[1]\r\n # version.line_minus = linechanges[2]\r\n # else\r\n # version.line_plus = 0\r\n # version.line_minus = 0 \r\n # end \r\n else \r\n commit_log << line unless line =~ /^\\*\\*\\* empty log message \\*\\*\\*/\r\n end \r\n end \r\n end\r\n end\r\n end", "def get_commit_log(last_version)\n range = \"v#{last_version}...\"\n `git log #{range} --no-merges --pretty=format:'%H\\t%s\\t%aN\\t%ad'`.chomp\nend", "def altered_files; `git show --name-only #{node} 2> /dev/null`.split(\"\\n\"); end", "def getPastTagLogs(past1 = 1, past2 = 2, filter = true)\n # only return git logs that don't contain fastlane or private\n # use those keywords for your commit to be stealth in the build change logs\n to_exec = \"git log --oneline #{past1}...#{past2}\"\n if filter == true\n to_exec += \" | { egrep -vi 'fastlane|skip_ci|Merge' || true; }\"\n end\n changes = sh(to_exec)\n changes = changes[0...12_000]\n\n f = File.new(\"./tmp/changelog.txt\", \"w\")\n f.write(changes)\n f.close\n\n UI.important(\"CHANGES SINCE LAST PROD: \")\n UI.important(changes)\n\n return changes\nend", "def files_at_commit(pr_id, filter = lambda{true})\n q = <<-QUERY\n select c.sha\n from pull_requests p, commits c\n where c.id = p.base_commit_id\n and p.id = ?\n QUERY\n\n def lslr(tree, path = '')\n all_files = []\n for f in tree.map{|x| x}\n f[:path] = path + '/' + f[:name]\n if f[:type] == :tree\n begin\n all_files << lslr(repo.lookup(f[:oid]), f[:path])\n rescue Exception => e\n STDERR.puts e\n all_files\n end\n else\n all_files << f\n end\n end\n all_files.flatten\n end\n\n base_commit = db.fetch(q, pr_id).all[0][:sha]\n begin\n files = lslr(repo.lookup(base_commit).tree)\n files.select{|x| filter.call(x)}\n rescue Exception => e\n STDERR.puts \"Cannot find commit #{base_commit} in base repo\"\n []\n end\n end", "def files_at_commit(pr_id, filter = lambda{true})\n q = <<-QUERY\n select c.sha\n from pull_requests p, commits c\n where c.id = p.base_commit_id\n and p.id = ?\n QUERY\n\n base_commit = db.fetch(q, pr_id).all[0][:sha]\n files = repo.lstree(base_commit, :recursive => true)\n\n files.select{|x| filter.call(x)}\n end", "def all_commit_times\n `git --git-dir=#{git_dir} log --all --pretty='%at'`.split(/\\n/).uniq\n end", "def update_commit_history\n raw_commits = `cd #{project_repo_path} && git fetch && git checkout #{self.trunk_branch} && git log --pretty='%H -::- %an -::- %s -::- %ai'`\n raw_commits.each do |raw_commit|\n # commit format\n # 0 => hash\n # 1 => author name\n # 2 => commit message\n # 3 => commit date\n commit = raw_commit.split(\"-::-\")\n commit.collect!(&:strip)\n # avoid issues with git log header and footer information \n if commit.count == 4\n author = GitAuthor.find_or_create_by_name(commit[1])\n # note that this breaks if two projects manage to get the same hash\n obj = GitCommit.find_by_commit_hash(commit[0])\n attributes = {\n :commit_hash => commit[0],\n :project => self, \n :git_author => author, \n :subject => commit[2], \n :commit_at => Time.parse(commit[3])\n }\n if obj.nil?\n GitCommit.create!(attributes)\n else\n # for now, assume you cannot update a commit\n # makes this run much faster\n # obj.attributes = attriubtes\n # obj.save!\n end\n end\n end\n end", "def all_commits\n `git --git-dir=#{git_dir} log --all --pretty='%H'`.split(/\\n/).uniq\n end", "def files_at_commit(pr, filter = lambda { |x| true })\n sha = pr[:base_commit]\n begin\n files = lslr(git.lookup(sha).tree)\n rescue StandardError => e\n log pr[:id]\n log \"Cannot find commit #{sha} in base repo\" # some are in the other branches\n return nil # not to the default branch\n end\n\n # # find the eariler than and closest to the creation time of commit\n # sha = commit_closest_earlier_pr(pr)\n # begin\n # files = sha.nil? ? [] : lslr(git.lookup(sha).tree)\n # rescue StandardError => e\n # log \"Cannot find commit #{sha} in base repo\" # some are in the other branches\n # files = [] # no files found before the pr\n # end\n\n\n if files.size <= 0\n log \"No files for commit #{sha}\"\n end\n files.select { |x| filter.call(x) }\n\n end", "def files_commits(num_commits)\n @repo = Grit::Repo.new(@directory)\n related_files = []\n commits_all(num_commits) do |commits|\n commits.each do |commit|\n paths = []\n begin\n commit.diffs.each do |diff|\n if diff.a_path != diff.b_path\n related_files += [[diff.a_path, diff.b_path]]\n end\n paths += [diff.a_path, diff.b_path]\n end\n rescue Grit::Git::GitTimeout\n puts \"Failed to diff for %s\" % commit.sha\n end\n paths.uniq!\n yield commit, paths, related_files\n end\n end\n end", "def commit_touches_path?(commit, walker)\n entry = tree_entry(commit)\n\n num_treesame = 0\n if commit.parents.empty?\n # This is the root commit, return true if it has +path+ in its tree\n return !entry.nil?\n end\n\n commit.parents.each do |parent|\n parent_entry = tree_entry(parent)\n\n # Only follow the first TREESAME parent for merge commits\n if num_treesame > 0\n walker.hide(parent)\n next\n end\n\n if entry.nil? && parent_entry.nil?\n num_treesame += 1\n elsif entry && parent_entry && entry[:oid] == parent_entry[:oid]\n num_treesame += 1\n end\n end\n\n case num_treesame\n when 0\n true\n else false\n end\n end", "def parse!\n return if @parsed\n \n # the parents\n log_data = `git log -1 #{node}^ 2> /dev/null`\n \n # DETERMINING PARENTS\n dad = log_data[/^commit (.+)$/, 1]\n dad = dad ? dad[0..6] : nil\n mom = nil\n \n if log_data =~ /^Merge: (.+)\\.\\.\\. (.+)\\.\\.\\.$/ # Merge: 1c002dd... 35cfb2b...\n dad = $1 # just have them both use the short name, nbd\n mom = $2\n end\n \n @parents = [dad, mom].compact.map {|r| Changeset.new repo, r }\n \n # the actual changeset\n log_data = `git log -1 #{node} 2> /dev/null`\n \n # DETERMINING DATE\n @date = Time.parse log_data[/^Date:\\s+(.+)$/, 1]\n \n # DETERMINING USER\n @user = log_data[/^Author:\\s+(.+)$/, 1]\n \n # DETERMINING DESCRIPTION\n @description = log_data.split(\"\\n\")[4..-1].map {|l| l.strip }.join \"\\n\"\n \n # ALTERED FILES\n @altered_files = `git log -1 #{node} --pretty=oneline --name-only 2> /dev/null`.split(\"\\n\")[1..-1]\n \n # ALL FILES\n # @all_files is also sorted. Hooray!\n @all_files = `git ls-tree -r #{node}`.split(\"\\n\").map do |line|\n # 100644 blob cdbeb2a42b714a4db49293c87fec4e180d07d44f .autotest\n line[/^\\d+ \\w+ \\w+\\s+(.+)$/, 1]\n end\n \n @parsed = true\n end", "def extract_changelog!(repo)\n changelog = ''\n in_changelog = false\n repo.git_show(sha1).send(LINE_ITERATOR) do |line|\n if line =~ /^diff --git/\n in_changelog = false\n elsif line =~ /^\\+\\+\\+.*changelog$/i\n in_changelog = true\n elsif in_changelog && line =~ /^\\+\\s*\\*/\n changelog << line\n end\n end\n update_attribute(:changelog, changelog)\n end", "def sha commit_message\n cmd = \"git reflog --grep-reflog='commit\"\n cmd += ' (initial)' if commit_message == 'Initial commit'\n cmd += \": #{commit_message.strip}' --format='%H'\"\n result = ''\n %w[developer developer_secondary].each do |user|\n next unless result.empty?\n in_repository(user) { result = output_of cmd }\n end\n result\nend", "def extract_changelog\n changelog = ''\n in_changelog = false\n git_show.send(LINE_ITERATOR) do |line|\n if line =~ /^diff --git/\n in_changelog = false\n elsif line =~ /^\\+\\+\\+.*changelog$/i\n in_changelog = true\n elsif in_changelog && line =~ /^\\+\\s*\\*/\n changelog << line\n end\n end\n changelog\n end", "def process\n filename = \"index.markdown\"\n markdowns = {filename => []} \n state = :message\n message = [\"\\n\"]\n patch = []\n commit = nil\n (@gitlogp.split(\"\\n\")+[\"DONE\"]).each { |line|\n words=line.split\n if line.slice(0,1)==\" \" || words.length==0\n # commit messages start with 4 spaces, diff contents with 1 space\n if state==:message\n if words[0]==\"OUTPUT_FILE:\"\n filename = words[1]\n markdowns[filename] ||= []\n else\n message << \"#{line.slice(4..-1)}\"\n end\n else\n patch << \" #{line}\" if state==:patch\n end\n elsif words[0]==\"commit\" or words[0]==\"DONE\"\n if !commit.nil?\n # replace the short description line with a named link\n shortlog = message[2]\n message[2] = \"<a name='#{shortlog}'> </a>\"\n markdowns[filename] += message.map {|l|\n if l==\"SHOW_PATCH\"\n (patch+[\"{: .diff}\\n\"]).join(\"\\n\")\n else\n l\n end\n }\n series = tags[commit].slice(-2..-1)\n markdowns[filename] << \"\\n#{tags[commit]}: [view on github](#{@commit_link_base}#{commit}), [download #{series}-#{shortlog}.patch](#{@patch_link_base}/#{series}-#{shortlog}.patch)\\n{: .commit}\\n\"\n end\n \n message=[\"\\n\"]\n patch=[]\n\n commit = words[1]\n state = :message\n elsif [\"Author:\", \"Date:\", \"new\", \"index\", \"---\", \"+++\", '\\\\'].include?(words[0])\n # chomp\n elsif words[0]==\"diff\"\n state = :patch\n left = words[2].slice(2..-1)\n right = words[3].slice(2..-1)\n if left==right\n patch << \" ::: #{right}\"\n else\n patch << \" ::: #{left} -> #{right}\"\n end\n elsif words[0]==\"@@\"\n # git tries to put the function or class name after @@. This\n # works great for C diffs, but it only finds the class name in\n # Ruby, which is usually similar to the file name, Therefore\n # it's distracting cruft. Toss it.\n patch << \" #{words.slice(0,4).join(\" \")}\"\n else\n message << \"#{line.slice(4..-1)}\" if state==:message\n patch << \" #{line}\" if state==:patch \n end\n }\n output = {}\n markdowns.each do |fn, markdown|\n output[fn] = markdown.join(\"\\n\")\n Rails.logger.info(output[fn]) if respond_to? :Rails\n end\n return output\n end", "def get_committed_files\n # set the current branch name to be the current branch you're on --> need to check that this works as part of push\n curr_branch_name = `git rev-parse --abbrev-ref HEAD`\n\n # raw_sha_list lists all the local, unpushed commit SHAs from your current branch\n raw_sha_list = `git log --graph --pretty=format:'%H' #{curr_branch_name}`\n\n committed_files = []\n # loop through the raw_sha_list and push properly formatted SHAs into the all_shas arr\n raw_sha_list.each_line { |sha|\n # using the .tr method on the sha makes a copy of the sha and replaces instances that matches with the to_str (second arg),\n # unless the range starts with a ^ carrot, in which case, it replaces on matches outside the range\n curr_sha = sha.tr('^A-Za-z0-9', '')\n\n # this `git diff-tree --no-commit-id --name-only -r <SHA>` will list the files of an individual commit when you add the SHA\n # on each iteration, set the changed_files variable to be the list of files from a particular commit, based its SHA\n changed_files = `git diff-tree --no-commit-id --name-only -r #{curr_sha}`\n\n # loop over the changed_files and add in each file that's part of a commit and add into the committed_files arr\n changed_files.each_line { |file|\n # remove any trailing whitespace from the file name and add into our arr\n committed_files << file.rstrip()\n }\n }\n # return the final, no-repeat array of committed files in this push\n return committed_files.uniq\nend", "def generate_git_commit_log(rev=ENV['LAST_SUCCESS_REV'])\n g = Git.open(Dir.getwd)\n change_log = g.log.between(rev).map { |c| \"- \" + c.message.lines.first.chomp }.join \"\\n\"\n \"Commit Log:\\n\\n#{change_log}\\n\"\nend", "def generate_git_commit_log(rev=ENV['LAST_SUCCESS_REV'])\n g = Git.open(Dir.getwd)\n change_log = g.log.between(rev).map { |c| \"- \" + c.message.lines.first.chomp }.join \"\\n\"\n \"Commit Log:\\n\\n#{change_log}\\n\"\nend", "def extract_change_count_from_git_log(log_text)\n lines = log_text.split(\"\\n\" )\n change_lines=lines.find_all do | line |\n line.include?('changed')\n end\n change_lines.length\nend", "def file_log(filename)\n o, e, s = exec_cmd(\"log\", %w[--follow --date=iso --], \"'#{filename}'\")\n raise \"Failed to get git log for #{filename}!!\\n#{e}\" if s.exitstatus != 0\n\n process_log_output(o)\n end", "def dir_git(git,branch='master',reg=nil)\n path = http_uri + git + '/trees/master' \n raw = raw_file(path)\n # find all files\n array = Array.new\n reg = Regexp.new(reg) if reg.is_a?(String)\n raw.scan(/file.*\\n.*<a href=\"\\/.*>(.*)<\\/a>.*<\\/td>/) do |name|\n if reg\n array << name.to_s if name.to_s.match(reg)\n else \n array << name.to_s\n end\n end\n return array\n end", "def test_log_commits\n a = @lib.log_commits :count => 10\n assert(a.first.is_a?(String))\n assert_equal(10, a.size)\n\n a = @lib.log_commits :count => 20, :since => \"#{Date.today.year - 2006} years ago\"\n assert(a.first.is_a?(String))\n assert_equal(20, a.size)\n\n a = @lib.log_commits :count => 20, :since => '1 second ago'\n assert_equal(0, a.size)\n\n a = @lib.log_commits :count => 20, :between => ['v2.5', 'v2.6']\n assert_equal(2, a.size)\n\n a = @lib.log_commits :count => 20, :path_limiter => 'ex_dir/'\n assert_equal(1, a.size)\n\n a = @lib.full_log_commits :count => 20\n assert_equal(20, a.size)\n end", "def branches_containing_commit(commit_ref); end", "def branches_containing_commit(commit_ref); end", "def tree_grep(pattern, treeish=head) # :yields: path, tree\n options = pattern.respond_to?(:merge) ? pattern.dup : {:e => pattern}\n options.delete_if {|key, value| nil_or_empty?(value) }\n \n unless commit = grit.commit(treeish)\n raise \"unknown commit: #{treeish}\"\n end\n \n sandbox do |git, work_tree, index_file|\n postfix = options.empty? ? '' : begin\n grep_options = git.transform_options(options)\n \" | grep #{grep_options.join(' ')}\"\n end\n \n stdout, stderr = git.sh(\"#{Grit::Git.git_binary} ls-tree -r --name-only #{git.e(commit.id)} #{postfix}\")\n stdout.split(\"\\n\").each do |path|\n yield(path, commit.tree / path)\n end\n end\n self\n end", "def tree_entry(commit)\n pathname = Pathname.new(path)\n tmp_entry = nil\n\n pathname.each_filename do |dir|\n if tmp_entry.nil?\n tmp_entry = commit.tree[dir]\n else\n tmp_entry = rugged.lookup(tmp_entry[:oid])\n return nil unless tmp_entry.type == :tree\n tmp_entry = tmp_entry[dir]\n end\n end\n\n tmp_entry\n end", "def get_commit_stats(sha)\n `git show --shortstat --oneline #{sha}`.split(\"\\n\").last\nend", "def git_status(path_r)\n Dir.chdir(path_r) do\n fill = 80 - path_r.size()\n fill = 0 if fill < 0\n puts path_r + '-'*fill\n puts `git status`\n end\nend", "def log_commits_by_files(logopts=nil)\n\t\t\tr={}\n\t\t\tfiles=run_simple(\"git log #{DefaultLogOptions} --name-only --format=\"\" #{logopts}\", chomp: :lines)\n\t\t\tuniq=files.uniq\n\t\t\tuniq.each do |file|\n\t\t\t\tr[file]=files.count(file)\n\t\t\tend\n\t\t\tr\n\t\tend", "def git_changed_line\n `git diff | grep ' #{name} (' | grep '+ '`\n end", "def last_commits\n sh(\"git log --topo-order --pretty=format:'%H' | head\").split(\"\\n\")\n end", "def fetch_commit_hash_list()\n `git rev-list --all --reverse`.strip.split(/\\n/)\nend", "def history(field)\n commits = self.git.log('master', \"#{model_folder}/#{model_id}/#{field}.txt\")\n commits.collect {|c| (c.tree/model_folder/model_id/\"#{field}.txt\").data }\n end", "def logs target, file_path, reverse: true, branch: 'master', tag: 'HEAD'\n repo = get_repo target\n\n walker = Rugged::Walker.new repo\n walker.push last_commit_id(repo, branch: branch, tag: tag)\n walker.sorting Rugged::SORT_TOPO | Rugged::SORT_REVERSE\n get_object_id = ->(commit) { object_id_of(repo, commit.tree, file_path) }\n commits = walker.each.select(&get_object_id).uniq(&get_object_id)\n commits.reverse! if reverse\n\n groups = (0...commits.size).to_a.map {|i| [commits[i], commits[i + 1] || commits[i].parents.first] }\n tag_hash = oid_tag_hash repo\n groups.map do |new, old|\n {\n message: new.message,\n author: new.author,\n tags: tag_hash[new.oid].try(:map, &:name),\n diff: diff_between(repo, old, new, only: file_path)\n }\n end\n end", "def file_revisions(file)\n file = file.gsub(%r{^/}, '')\n output = sh_string(\"git log --format='%h|%s|%aN|%ai' -n100 #{ShellTools.escape(file)}\")\n output.to_s.split(\"\\n\").map do |log_result|\n commit, subject, author, date = log_result.split('|')\n date = Time.parse(date.sub(' ', 'T')).utc.iso8601\n { commit: commit, subject: subject, author: author, date: date }\n end\n end", "def commits_on_pr_files(pr, months_back)\n\n oldest = Time.at(Time.at(pr[:created_at]).to_i - 3600 * 24 * 30 * months_back)\n commits = commit_entries(pr, at_open = true)\n\n commits_per_file = commits.flat_map { |c|\n unless c[:files].nil?\n JSON.parse(c[:files]).map { |f|\n [c[:sha], f[\"filename\"]]\n }\n else\n []\n end\n }.select{|x| x.size > 1}.group_by {|c|\n c[1]\n }\n\n commits_per_file.keys.reduce({}) do |acc, filename|\n commits_in_pr = commits_per_file[filename].map{|x| x[0]} # get the shas of pr related commits\n\n walker = Rugged::Walker.new(git)\n walker.sorting(Rugged::SORT_DATE)\n walker.push(pr[:base_commit])\n\n commit_list = walker.select do |c|\n c.time > oldest\n end.reduce([]) do |acc1, c|\n if c.diff(paths: [filename.to_s]).size > 0 and\n not commits_in_pr.include? c.oid # (oid is the object id - c.oid gets the commit sha). this commit is not part of pr's commits\n acc1 << c.oid\n end\n acc1\n end\n acc.merge({filename => commit_list})\n end\n end", "def extract_changes(str)\n str.lines.map do |line|\n new_git_change(*Regexp.last_match.captures) if line.match(/\\t(.*:)?(.*)/)\n end.compact # in case there were any non matching lines left\n end", "def status\n unless block_given?\n return status {|sha| sha}\n end\n \n lines = []\n git.status.each_pair do |path, state|\n ab, xyz, target = path.split('/', 3)\n source = \"#{ab}#{xyz}\"\n \n sha = assoc_sha(source, target)\n type = assoc_type(source, target)\n \n status = case assoc_type(source, target)\n when :create\n type = self[sha]['type']\n [type || 'doc', yield(sha)]\n when :link\n ['link', \"#{yield(source)} to #{yield(target)}\"]\n when :update\n ['update', \"#{yield(target)} was #{yield(source)}\"]\n when :delete\n ['delete', yield(sha)]\n else\n ['unknown', path]\n end\n \n if status\n status.unshift state_str(state)\n lines << status\n end\n end\n \n indent = lines.collect {|(state, type, msg)| type.length }.max\n format = \"%s %-#{indent}s %s\"\n lines.collect! {|ary| format % ary }\n lines.sort!\n lines.join(\"\\n\")\n end", "def regex_process_commit(arr)\n message = \"\"\n filepaths = {}\n end_message_index = 0\n hash = Hash.new\n in_files = false # Have we gotten to the file portion yet? After the ;;; delimiter\n\n #index 5 should be the start\n #of the message\n (5..arr.size-1).each do |i|\n #add lines to message string if they are not identifers of lines we want to get later\n if not arr.fetch(i) =~ (/^git-svn-id:/) and\n not arr.fetch(i) =~ (/^Review URL:/) and\n not arr.fetch(i) =~ (/^BUG/) and\n not arr.fetch(i) =~ (/^R=/)\n\n #concat the message into 1\n #string\n message = message + \" \" + arr.fetch(i)\n else\n #get the last index of the \n #message, is it multiple\n #lines\n end_message_index = i\n break\n end\n end\n\n hash[:message] = message\n arr[5] = message\n\n #remove the multi line message since we condensed it\n (6..end_message_index).each do |i| \n arr.delete(i) \n end\n\n arr.each do |element|\n if fast_match(element, /^Review URL:/)\n @reviews_to_update[element[/(\\d)+/].to_i] = arr[0].strip\n\n elsif fast_match(element, /^BUG=/)\n hash[:bug] = element.strip.sub(\"BUG=\", \"\")\n\n elsif fast_match(element, /^;;;/)\n in_files = true\n\n elsif in_files and element.include?('|') # stats output needs to have a pipe\n # collect the filepath and churn count, store in the filepath hash\n split = element.split('|')\n filepaths[split[0].strip] = split[1].to_i\n \n end#if\n\n end#arr.each\n hash[\"filepaths\"] = filepaths\n \n\n return arr, hash\n\n end", "def get_ls(path)\n #repo = @repo\n #head = repo.commits.first\n #tree = head.tree @branch\n\n tree = @repo.tree @branch\n\n #strip trailing /\n path.sub! /[\\/]*$/, ''\n\n # find dir\n while !path.empty?\n tdir = tree / path\n break if tdir.is_a?(Grit::Tree)\n # strip last conponent to /\n path.sub! /(^|\\/)[^\\/]*$/, ''\n end\n\n if path.empty?\n tdir = tree\n else\n path += '/'\n end\n print \"path:\", path, \"\\n\"\n print \"tdir:\", tdir, \"\\n\"\n\n files = tdir.blobs.map do |b|\n { path: \"#{path}#{b.name}\", name: b.name, siz: b.size }\n end\n dirs = tdir.trees.map do |t|\n { path: \"#{path}#{t.name}\", name: t.name}\n end\n if !path.empty?\n dirs.push( { path: path.sub(/(^|\\/)[^\\/]*\\/$/, ''),\n name: '..'} )\n end\n\n [files, dirs, path]\n end", "def files_in branch:\n array_output_of(\"git ls-tree -r --name-only #{branch}\")\nend", "def quarterly_committers(start_month, year=Time.now.year)\n \"git log --since='#{start_month}/1/#{year}' --until='#{start_month + 2}/31/#{year}' | git shortlog -n -s\"\nend", "def extract_branch(changed_watched_paths)\n \n\t\tfirst_path=changed_watched_paths[0][1..-1]\n\t\tfirst_path.strip!\n\t\[email protected](\"first_path is=\"<< first_path)\n \n\t\tret=''\n\t\tif first_path =~ /trunk/\n\t\t\[email protected](\"returning=\"<< \"trunk\")\n\t\t\treturn \"trunk\"\n\t\tend\n\t\tif first_path =~ /ceDev/\n\t\t\[email protected](\"returning=\"<< \"ceDev\")\n\t\t\treturn \"ceDev\"\n\t\tend\n ret=''\n for i in 1..2\n\t\[email protected](\"i=\"<< i)\n if(first_path.length>ret.length)\n index=first_path.index('/', ret.length)\n if(index!=nil)\n ret << first_path[ret.length .. index]\n else\n break\n end\n end\n end\n\t\[email protected](\"returning=\"<< ret)\n return ret\n\n\tend", "def recent_branches_fast\n\t\trefs = []\n\t\trefs.concat Pathname.glob(dot_git + 'refs/heads/**/*')\n\t\trefs.concat Pathname.glob(dot_git + 'refs/remotes/**/*')\n\n\t\tbranches = refs.reject {|r| r.directory? }.sort_by {|r| r.mtime }.last(@opts[:max_num]).map {|r|\n\t\t\tref = r.read.chomp\n\t\t\tif name = ref[/ref: (.+)/, 1]\n\t\t\t\tbegin\n\t\t\t\t\t(dot_git + name).read.chomp\n\t\t\t\trescue\n\t\t\t\t\t`git rev-parse #{name}`.chomp\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tref\n\t\t\tend\n\t\t}\n\t\tretrieve_branch_details(branches)\n\tend", "def parse_commit_line!(commit_line)\n # Parse the full commit line\n line_parts = commit_line.split(\"\\t\")\n sha = line_parts.fetch(0)\n message = line_parts.fetch(1)\n author = line_parts.fetch(2)\n date = Time.parse(line_parts.fetch(3))\n message_data = parse_commit_message!(message)\n pr_number = message_data.fetch(\"pr_number\")\n\n attributes =\n {\n \"sha\" => sha,\n \"message\" => message,\n \"author\" => author,\n \"date\" => date,\n \"pr_number\" => pr_number\n }\n\n # Parse the stats\n stats = get_commit_stats(attributes.fetch(\"sha\"))\n if /^\\W*\\p{Digit}+ files? changed,/.match(stats)\n stats_attributes = parse_commit_stats!(stats)\n attributes.merge!(stats_attributes)\n end\n\n attributes\nend", "def commit_entries(pr_id)\n q = <<-QUERY\n select c.sha as sha\n from pull_requests pr, pull_request_commits prc, commits c\n where pr.id = prc.pull_request_id\n and prc.commit_id = c.id\n and pr.id = ?\n QUERY\n commits = db.fetch(q, pr_id).all\n\n commits.reduce([]){ |acc, x|\n a = mongo.find(:commits, {:sha => x[:sha]})[0]\n acc << a unless a.nil?\n acc\n }.select{|c| c['parents'].size <= 1}\n end", "def count_commits(repo)\n walker = Rugged::Walker.new(repo)\n walker.push(repo.head.target_id)\n return walker.count\nend", "def changes_since_last_tag\n `git --no-pager log $(git describe --tags --abbrev=0)..HEAD --grep=\"Merge\" --pretty=format:\"%t - %s%n%b%n\"`\nend", "def grit_update\n grit_repo = Repo.new(self.aq_repository.path)\n new_commits_count = grit_repo.commit_count(self.name) - self.commits.count\n count = 0\n while (count < new_commits_count)\n commits = grit_repo.commits(self.name, 10, count)\n commits.each do |c|\n if not self.commits.find_by_sha(c.id)\n a_commit = AqCommit.new(:sha => c.id,\n :log => c.message,\n :author_name => c.author.name,\n :created_at => c.committed_date,\n :committed_time => c.committed_date,\n :repository => self.aq_repository)\n c.diffs.each do |diff|\n begin\n a_file = AqFile.find_by_path(diff.b_path, :conditions => [\"aq_branch_id = ?\", self.id])\n rescue\n a_file = nil\n end\n if !a_file\n a_file = AqFile.new(:name => diff.b_path.split(\"/\").last, :path => diff.b_path)\n a_file.branch = self\n end\n self.files << a_file if !a_file.branch\n self.aq_repository.files << a_file if !a_file.repository\n a_commit.aq_files << a_file\n end\n a_commit.author = self.aq_repository.owner\n self.commits << a_commit\n self.save\n end\n end\n diff_c = new_commits_count - count\n if (diff_c > 10)\n count += 10\n else\n count += diff_c\n end\n end\n if self.aq_repository.owner.nil?\n the_user = User.our_current_user.login || \"error: cant get user login\"\n else\n the_user = self.aq_repository.owner.login\n end\n aq_logger(Settings.logs.scm, \"User #{the_user}, Branch : #{self.name}, #{count} commits treated.\")\n end", "def build_log(sha)\n bloblist = []\n # Instantiate a Walker and add the SHA hash\n walker = Rugged::Walker.new(rugged)\n commit_head = rugged.lookup sha\n walker.push(commit_head)\n walker.sorting(Rugged::SORT_DATE)\n walker.each do |c|\n if commit_touches_path?(c, walker)\n tree = rugged.lookup c.tree_id\n blob = tree.path path\n blobdata = rugged.read(blob[:oid]).data\n image = {\n name: blob[:name],\n data: blobdata\n }\n bloblist << [image , c]\n end\n end\n\n walker.reset\n\n bloblist\n end", "def commit_log(first_ref, last_ref)\n puts \"running commit log\"\n return @commit_log unless @commit_log.nil?\n\n git = find_git_repo\n\n begin\n raise \"Ref missing\" if first_ref.nil? || last_ref.nil? # jump to rescue block.\n\n log_results = git.log.between(first_ref, last_ref)\n\n @commit_log = log_results.map do |log|\n {\n :author => log.author.name,\n :date => log.date,\n :email => log.author.email,\n :sha => log.sha,\n :message => log.message\n }\n end\n\n rescue\n [ DEFAULT_COMMIT_LOG_ENTRY ]\n end\n end", "def git\n require 'parsedate'\n puts 'Doing local Git commit...'\n d = Time.new()\n git_comment = \"#{d}\"\n `git add ../.`\n `git commit ../. -m \"#{git_comment}\"`\nend", "def diff_files_from(commit)\n git_args = ['diff', '--stat', '--name-only', commit]\n result = default_repository.git_output(git_args).lines.map { |line| line.strip }.sort\n # not sure if git would ever mention directories in a diff, but ignore them.\n result.delete_if { |item| ::File.directory?(item) }\n return result\n end", "def trace\n \n path = WikiPath.new\n \n page = self\n\n wikipage = Wikipedia.find(title)\n\n # If page has a parent we must stop (we can fetch the cached path or it's a loop)\n # If there's no page... we reached the end of the road\n while !page.blank? and page.parent_id.blank? \n \n path.pages << page\n \n # We must get rid of infoboxes, metadata and Image and FIle links before we get the link title\n first_link_title = wikipage.content.gsub(\"\\n\", \"\").gsub(/\\{\\{[^\\}]*\\}\\}/, \"\").gsub(\"[[Image:\", \"\").gsub(\"[[File:\", \"\").match(/\\[\\[[^\\]]*\\]\\]/)[0]\n first_link_title = first_link_title.split(\"|\").first.gsub(\"]\", \"\").gsub(\"[\", \"\") unless first_link_title.nil?\n\n if first_link_title.nil?\n page.update_attributes :is_root => true\n page = nil\n else\n\n wikipage = Wikipedia.find(first_link_title)\n\n parent_page = WikiPage.find_by_title(first_link_title)\n parent_page ||= WikiPage.create :url => \"\", :title => first_link_title, :fetched_at => Time.now\n\n page.update_attributes :parent_id => parent_page.id\n\n\n page = parent_page \n end\n end\n\n unless page.blank?\n path.pages << page\n unless page.parent_id.blank?\n \n parent_pos = path.pages.index page.parent\n # If parent is not in the path then we have a cached path\n if parent_pos.nil?\n path.pages.concat(page.ancestors.reverse)\n else # If parent is in the path then we have a loop\n\n # remove pages from path\n roots = path.pages.slice! parent_pos, path.pages.length - parent_pos\n\n # create a tree\n tree = WikiTree.create :name => roots.map(&:title).join(\" - \")\n # we remove the parent page to every root and indicate it's a root\n roots.each do |root|\n root.update_attributes :is_root => true, :parent_id => nil\n end\n\n end\n\n end\n end\n\n path.pages.each do |page|\n tree.pages << page\n page.reload\n end\n\n path\n\n end", "def grep(pattern, treeish=head) # :yields: path, blob\n options = pattern.respond_to?(:merge) ? pattern.dup : {:e => pattern}\n options.delete_if {|key, value| nil_or_empty?(value) }\n options = options.merge!(\n :cached => true,\n :name_only => true,\n :full_name => true\n )\n \n unless commit = grit.commit(treeish)\n raise \"unknown commit: #{treeish}\"\n end\n \n sandbox do |git, work_tree, index_file|\n git.read_tree({:index_output => index_file}, commit.id)\n git.grep(options).split(\"\\n\").each do |path|\n yield(path, (commit.tree / path))\n end\n end\n self\n end", "def parse_entries\n @time_cache ||= {}\n\n if /\\A((?:.*\\n){,3})commit\\s/ =~ @content\n class << self; prepend Git; end\n parse_info($1)\n return parse_entries\n end\n\n entries = []\n entry_name = nil\n entry_body = []\n\n @content.each_line do |line|\n case line\n when /^\\s*$/ then\n next\n when /^\\w.*/ then\n entries << [entry_name, entry_body] if entry_name\n\n entry_name = $&\n\n begin\n time = parse_date entry_name\n @time_cache[entry_name] = time\n rescue ArgumentError\n entry_name = nil\n end\n\n entry_body = []\n when /^(\\t| {8})?\\*\\s*(.*)/ then # \"\\t* file.c (func): ...\"\n entry_body << $2.dup\n when /^(\\t| {8})?\\s*(\\(.*)/ then # \"\\t(func): ...\"\n entry = $2\n\n if entry_body.last =~ /:/ then\n entry_body << entry.dup\n else\n continue_entry_body entry_body, entry\n end\n when /^(\\t| {8})?\\s*(.*)/ then\n continue_entry_body entry_body, $2\n end\n end\n\n entries << [entry_name, entry_body] if entry_name\n\n entries.reject! do |(entry,_)|\n entry == nil\n end\n\n entries\n end", "def extract_commits(path)\n files = []\n Dir.foreach(path) { |file| files << file }\n commits = files.select { |f| f != '.' && f != '..' }\n .map { |f| YAML::load_file(path + f) }\n .flatten\n .shuffle\n if @do_tests\n split_point = (commits.length * 0.9).floor\n [commits[0...split_point], commits[split_point...commits.length]]\n else\n [commits, []]\n end\n end", "def initialize(path)\n @path = path\n \n rev,path = path.split(\":\",2)\n raise ArgumentError.new(\"Must supply a git revision\") unless rev\n path = File.expand_path(path) if path\n init_git(path || '.')\n @file_pattern = if @search_path == ''\n \"**.rb\"\n elsif @search_path =~ /\\.rb#{File::SEPARATOR}$/\n # So appending each piece into the search path during init_git\n # causes the search path to always end with a /\n @search_path[0...-1]\n else\n File.join(@search_path,\"**.rb\")\n end\n \n @files = []\n \n FileUtils.cd(@working_dir) do\n git_list = git \"ls-tree -r #{rev}\"\n git_list.each_line do |line|\n file = GitFile.new(*line.chomp.split(/\\s+/,4))\n \n if file.type == 'blob' and File.fnmatch(@file_pattern, file.name)\n @files << file \n end\n end\n end\n \n end", "def load_from_remote_last_commit_info\n #need to change into remote dir then change back once done...always change back\n pwd = Dir.pwd\n begin\n FileUtils.cd(@remote_path)\n log = eval(GIT_LOG_CMD)\n #parse output\n match = /^commit\\s+(.+)\\nAuthor:\\s+(.+)\\nDate:\\s+(.+)\\n+\\s+(.+)/.match(log)\n raise \"Error in parsing log:\\n#{log}\" unless match && match.length > 0\n @remote_head = match[1]\n @remote_author = match[2]\n @remote_date = match[3]\n @remote_commit_log = match[4]\n ensure\n FileUtils.cd(pwd)\n end\n end", "def commit_refs(commit, repo_param)\n commit.refs.map{ |r| commit_ref(r, repo_param) }.join(\"\\n\")\n end", "def get_prog_log(repo_hash)\n time = Time.now.getutc.to_s\n if (repo_hash[:source] == \"github\")\n [repo_hash[:name], repo_hash[:name].hash, repo_hash[:source], repo_hash[:repo][:html_url], repo_hash[:repo][:default_branch], repo_hash[:version], \"\", time, \"\", \"\", \"\"]\n elsif (repo_hash[:source] == \"rubygems\")\n [repo_hash[:name], repo_hash[:name].hash, repo_hash[:source], \"\", \"\", \"\", repo_hash[:version], time, \"\", \"\"]\n else\n raise \"Unexpected source of repo #{r[:name]}: #{repo_hash[:source]}\"\n end\nend", "def commit_entries(pr_id)\n q = <<-QUERY\n select c.sha as sha\n from pull_requests pr, pull_request_commits prc, commits c\n where pr.id = prc.pull_request_id\n and prc.commit_id = c.id\n and pr.id = ?\n QUERY\n commits = db.fetch(q, pr_id).all\n\n commits.reduce([]){ |acc, x|\n a = mongo['commits'].find_one({:sha => x[:sha]})\n acc << a unless a.nil?\n acc\n }.select{|c| c['parents'].size <= 1}\n end", "def history(rsha = nil, klass = Wiki)\n access = GitAccess.new\n seen = false\n @history ||= repos.git.log(\"master\", path).\n map{|commit|\n access.tree(commit.sha).select {|b|\n b.path == path\n }.map { |b|\n if commit.sha == self.commit.sha\n seen = true\n nil\n elsif seen\n blob = b.blob(repos.git)\n klass.new(blob, commit, b.path)\n end\n }.compact\n }.flatten\n\n if rsha\n return history.select{|his| his.sha == rsha}.first\n end\n\n access.refresh\n @history\n end", "def file_listing(commit)\n # The only reason this doesn't work 100% of the time is because grit doesn't :/\n # if i find a fix, it'll go upstream :D\n count = 0\n out = commit.diffs.map do |diff|\n count = count + 1\n if diff.deleted_file\n %(<li class='file_rm'><a href='#file_#{count}'>#{diff.a_path}</a></li>)\n else\n cla = diff.new_file ? \"add\" : \"diff\"\n %(<li class='file_#{cla}'><a href='#file_#{count}'>#{diff.a_path}</a></li>)\n end\n end\n \"<ul id='files'>#{out.join}</ul>\"\n end", "def create_log(forward=true,start=1, stop=-1)\n @entries = []\n cmd = \"bzr log \" << @path\n offsets = []\n arr = IO.popen(cmd).readlines\n arr.each_index { |x| offsets.push(x) if arr[x].strip.chomp == Log::SEPARATOR }\n while not offsets.empty?\n hash = {}\n start = @_tmp || offsets.shift\n stop = if offsets.empty? \n -1\n else \n @_tmp = offsets.shift\n @_tmp\n end\n _arr = arr[start..stop]\n _arr.each_index { |x| _arr.delete_at(x) if _arr[x].strip.chomp == Log::SEPARATOR }\n _arr.each_with_index do |line,i| \n if line.match('message:') \n hash['message'] = _arr[i+1].chomp.strip unless _arr[i+1].nil?\n else\n line.gsub!('branch nick:', 'branch_nick:') if line.match('branch nick:') \n ['revno:','committer:','branch_nick:','timestamp:','merged:'].each do |thing|\n if line.match(thing)\n hash[line.split(':',2)[0].chomp.strip] = line.split(':',2)[1].chomp.strip\n end\n end\n end\n end\n @entries.push(Commit.new(hash['revno'],hash['committer'], hash['branch_nick'], hash['timestamp'], hash['message'],hash['merged']))\n end\n @log = Log.new(@entries)\n end", "def process_git_log_into_summary\n distribute_entries_to_authors( load_git_log_entries( path_to_git_repo ) )\n return prepare_rows_for_summary_csv\n end", "def repo_all_commits_structures(repo_dir, commits_file, structures_dir)\n sdir = Pathname.new(Dir.pwd) + Pathname.new(structures_dir)\n base_dir = Pathname.new(repo_dir).basename.to_s\n FileUtils.mkdir_p(sdir + \"dir\")\n FileUtils.mkdir_p(sdir + \"dep\")\n lang = detect_language(repo_dir) # Detect programming language \n i = MCommits.new(commits_file).all_commits.size # Reverse order\n file_kenc = KeyEncoder.new\n make_temp_dir do |tmpdir|\n # Copy repo to temp folder\n FileUtils.cp_r repo_dir, tmpdir\n temp_repo_dir = tmpdir + \"/\" + base_dir\n \n chdir_return(temp_repo_dir) do\n keep_going = true\n while keep_going do\n i -= 1\n # Generate Directory Structure Graph\n puts \"Generating Dir Structure Graph\"\n directory_graph(\".\", \"%s/%d.txt\" % [(sdir+\"dir\").relative_path_from(Pathname.new Dir.pwd).to_s, i], file_kenc)\n\n key_count = file_kenc.key_count\n\n # Generate dependency graph if language is supported\n unless lang.nil?\n case lang\n when :ruby\n puts \"Generating Dependency Graph\"\n RubyFilesMatcher.new('.').dependency_graph_to_file(\"%s/%d.txt\" % [(sdir+\"dep\").relative_path_from(Pathname.new Dir.pwd).to_s, i], file_kenc)\n else\n puts \"Unsupported Programming Language\"\n end\n raise \"Dependency Graph is not supposed to generate more keys!\" if key_count != file_kenc.key_count\n end\n\n puts \"Rewinding...\"\n stdin, stdout, stderr = Open3.popen3(\"git reset --hard HEAD~1\")\n keep_going = false if stderr.readlines.length > 0 # While not getting \"...unknown revision or path not in the working tree...\"\n end\n end\n \n end\n raise \"Number of Commits Don't Match\" if i != 0\n file_kenc.to_file(sdir + \"file_key.txt\")\nend", "def git_tree_version\n if File.directory?(\".git\")\n @tree_version ||= `git describe`.strip.sub('-', '.')\n @tree_version << \".0\" unless @tree_version.count('.') == 2\n else\n $: << \"lib\"\n require 'rack'\n @tree_version = Rack.release\n end\n @tree_version\nend", "def git_version(paths)\n return if paths.nil?\n\n paths.map { |path| Licensed::Git.version(path) }\n .reject { |sha| sha.to_s.empty? }\n .max_by { |sha| Licensed::Git.commit_date(sha) }\n end", "def git_dir; end", "def get_changed_file_list\n command = \"git log -m -1 --name-only --pretty='format:' $(git rev-parse origin/master)\"\n file_paths = []\n features = {}\n features.compare_by_identity\n\n Open3.popen3(command) do |stdin, stdout, stderr|\n files = stdout.read.gsub! \"\\n\", \",\"\n file_paths = files.split(\",\")\n puts \"Found files:\\n#{file_paths}\"\n end\n\n puts \"Count files in push: #{file_paths.count}\"\n\n file_paths.each do |file_path|\n if file_path.include?(\".feature\")\n puts \"Added: #{file_path}\"\n folder = get_name_folder_from_path file_path\n features.store(folder, file_path)\n end\n end\n\n puts \"\\n\"\n puts \"Count feature files: #{features.count}\"\n features.sort\nend", "def history\n @history ||= @repo.log.path(path).to_a\n end", "def git_tags\n git(\"log --tags --simplify-by-decoration --pretty='format:%ai %d'\")\n # TODO: fix\n end", "def list(path=nil)\n sha = path_to_sha(path)\n # ensure correct operation even if path doesn't exist in repo\n t = sha ? tree(sha) : tree(@current_branch, (path ? [path] : []))\n t ? tree_contents( t ) : {}\n end", "def show_changed_files(status)\n status.each_line do |line|\n if line =~ /^#\\t/ # only print out the changed files (I think)\n if line =~ /new file:|modified:|deleted:/\n puts \" #{line}\" \n else\n puts \" #{line.chop}\\t\\t(may need to be 'git add'ed)\" \n end\n end\n end\nend", "def traverse path\n entries = Dir.glob(\"#{View.expand_path(path)}/*\", File::FNM_DOTMATCH).\n select {|i| i !~ /\\/\\.(\\.*|svn|git)$/}. # Exclude some dirs (exclude entensions here too?)\n sort\n\n # Process dirs\n entries.each{ |f|\n next unless File.directory?(f)\n cleaned = clean f\n @res += \"#{cleaned.sub(/(^ *)/, \"\\\\1- \")}/\\n\"\n traverse f\n }\n\n # Process files\n entries.each{ |f|\n next unless File.file?(f)\n cleaned = clean f\n @res += \"#{cleaned.sub(/(^ *)/, \"\\\\1+ \")}\\n\"\n }\n\n end", "def commit(opts = {:use_dirstate => true, :update_dirstate => true})\n valid = false # don't update the DirState if this is set!\n \n commit = ((modified || []) + (added || [])).sort\n remove = removed\n xtra = extra.dup\n branchname = xtra[\"branch\"]\n text = description\n \n p1, p2 = parents.map {|p| p.node }\n c1 = repo.changelog.read(p1) # 1 parent's changeset as an array\n c2 = repo.changelog.read(p2) # 2nd parent's changeset as an array\n m1 = repo.manifest.read(c1[0]).dup # 1st parent's manifest\n m2 = repo.manifest.read(c2[0]) # 2nd parent's manifest\n \n if opts[:use_dirstate]\n oldname = c1[5][\"branch\"]\n tests = [ commit.empty?, remove.empty?, !opts[:force],\n p2 == NULL_ID, branchname == oldname ]\n if tests.all?\n UI::status \"nothing changed\"\n return nil\n end\n end\n \n xp1 = p1.hexlify\n xp2 = p2 == NULL_ID ? \"\" : p2.hexlify\n \n Hook.run_hook :pre_commit\n journal = Amp::Mercurial::Journal.new(:opener => repo.store_opener)\n \n fresh = {} # new = reserved haha i don't know why someone wrote \"haha\"\n changed = []\n link_rev = repo.size\n \n (commit + (remove || [])).each {|file| UI::status file }\n \n # foreach file in commit:\n # commit_file file\n # end\n commit.each do |file|\n versioned_file = self[file]\n fresh[file] = versioned_file.commit :manifests => [m1, m2],\n :link_revision => link_rev,\n :journal => journal ,\n :changed => changed\n \n new_flags = versioned_file.flags\n \n # TODO\n # Clean this shit up\n if [ changed.empty? || changed.last != file, \n m2[file] != fresh[file]\n ].all?\n changed << file if m1.flags[file] != new_flags\n end\n m1.flags[file] = new_flags\n \n repo.staging_area.normal file if opts[:use_dirstate]\n end\n \n # add_manifest_entry\n man_entry, updated, added = *add_manifest_entry(:manifests => [m1, m2],\n :changesets => [c1, c2],\n :journal => journal ,\n :link_rev => link_rev,\n :fresh => fresh ,\n :remove => remove ,\n :changed => changed )\n\n # get_commit_text\n text = get_commit_text text, :added => added, :updated => updated,\n :removed => removed, :user => user ,\n :empty_ok => opts[:empty_ok] ,\n :use_dirstate => opts[:use_dirstate]\n \n # atomically write to the changelog\n # add_changelog_entry\n # for the unenlightened, rents = 'rents = parents\n new_rents = add_changelog_entry :manifest_entry => man_entry,\n :files => (changed + removed),\n :text => text,\n :journal => journal,\n :parents => [p1, p2],\n :user => user,\n :date => date,\n :extra => xtra\n \n \n # Write the dirstate if it needs to be updated\n # basically just bring it up to speed\n if opts[:use_dirstate] || opts[:update_dirstate]\n repo.dirstate.parents = new_rents\n removed.each {|f| repo.dirstate.forget(f) } if opts[:use_dirstate]\n repo.staging_area.save\n end\n \n # The journal and dirstates are awesome. Leave them be.\n valid = true\n journal.close\n \n # if an error and we've gotten this far, then the journal is complete\n # and it deserves to stay (if an error is thrown and journal isn't nil,\n # the rescue will destroy it)\n journal = nil\n \n # Run any hooks\n Hook.run_hook :post_commit, :added => added, :modified => updated, :removed => removed, \n :user => user, :date => date, :text => text,\n :revision => repo.changelog.index_size\n return new_rents\n rescue StandardError => e\n if !valid\n repo.dirstate.invalidate!\n end\n if e.kind_of?(AbortError)\n UI::warn \"Abort: #{e}\"\n else\n UI::warn \"Got exception while committing. #{e}\"\n UI::warn e.backtrace.join(\"\\n\")\n end\n \n # the journal is a vestigial and incomplete file.\n # destroyzzzzzzzzzzz\n journal.delete if journal\n end", "def commit_info(params)\n user, repo = params[\"user\"], params[\"repo\"]\n shas = get_last_30_days_commits(user, repo)\n commit_hash = {}\n file_arr = []\n hydra = Typhoeus::Hydra.new\n shas.each do |sha|\n request = Typhoeus::Request.new(\"#{GithubApiConstants::GITHUB_ROOT}/repos/#{user}/#{repo}/commits/#{sha}?access_token=#{GITHUB_ACCESS_TOKEN}\")\n request.on_complete do |response|\n if response.success?\n parsed_sha_info = JSON.parse(response.response_body)\n author = parsed_sha_info[\"commit\"][\"author\"][\"name\"]\n files = parsed_sha_info[\"files\"].collect { |f| f[\"filename\"] }\n commit_hash[files] = author\n file_arr << files\n else\n raise RepoExceptionHandler::GithubAPILimitReached.new(GithubApiConstants::GITHUB_API_LIMIT_REACHED_MESSAGE)\n end\n end\n hydra.queue(request)\n end\n hydra.run\n return commit_hash, file_arr\n end", "def patch_ids(path, revisions, limit, skip)\n git_patch_ids = ''\n git_cmd(%w{patch-id}) do |i_patch_id, o_patch_id|\n i_patch_id.binmode\n\n cmd_args = %w{log -p --no-color --date-order --format=%H}\n cmd_args << '--all' if revisions.empty?\n cmd_args << \"--encoding=#{path_encoding}\"\n cmd_args << \"--skip=#{skip}\" << \"--max-count=#{limit}\"\n cmd_args << '--stdin'\n\n if path && !path.empty?\n cmd_args << '--' << scm_iconv(path_encoding, 'UTF-8', path)\n end\n\n git_cmd(cmd_args) do |i_log, o_log|\n i_log.binmode\n i_log.puts(revisions.join(\"\\n\"))\n i_log.close\n IO.copy_stream(o_log, i_patch_id)\n end\n\n i_patch_id.close\n git_patch_ids = o_patch_id.read.force_encoding(path_encoding)\n end\n git_patch_ids\n end", "def link_commits(repo_path, username, repo_name)\n\n # create a partial repo URL for GitHub repository\n partial_URL = \"https://github.com/#{username}/#{repo_name}/commit/\"\n \n # access the repository at the given repo_path\n repo = Grit::Repo.new(repo_path)\n \n all_commits = get_all_commits(repo)\n \n #all_commits.each{ |commit|\n # puts \"[#{commit.sha}](#{partial_URL + commit.sha})\\n\\n\"\n #}\n\n return all_commits.map do |commit|\n \"[#{commit.sha}](#{partial_URL + commit.sha})\\n\\n\"\n end\nend" ]
[ "0.6871297", "0.66156656", "0.6473258", "0.63975114", "0.61808044", "0.61529064", "0.6081708", "0.60423076", "0.6013339", "0.60048395", "0.59839517", "0.5968312", "0.5918237", "0.59051895", "0.5895297", "0.5890388", "0.5822074", "0.58176994", "0.57792914", "0.5770118", "0.57632905", "0.57424533", "0.5719346", "0.5709292", "0.5707719", "0.56325436", "0.5630466", "0.56060725", "0.55985737", "0.559265", "0.55889714", "0.55859685", "0.55845106", "0.55731004", "0.5568852", "0.5557433", "0.55513036", "0.5539509", "0.5539509", "0.5529468", "0.5524877", "0.5520752", "0.55193084", "0.55065656", "0.55051965", "0.5502527", "0.5492171", "0.54699725", "0.54699117", "0.54685473", "0.54188377", "0.5414878", "0.53756785", "0.5374799", "0.5368814", "0.53610855", "0.5359133", "0.5355419", "0.5353513", "0.53443056", "0.53378665", "0.5337306", "0.53310513", "0.5328686", "0.5314402", "0.5310994", "0.53090423", "0.5296816", "0.5293891", "0.52849424", "0.52839595", "0.5280869", "0.5270342", "0.52512777", "0.5230976", "0.52260983", "0.52232015", "0.5194138", "0.5192938", "0.5192008", "0.51865333", "0.51837754", "0.5174861", "0.5163765", "0.5158772", "0.515873", "0.5158371", "0.5156038", "0.5155467", "0.5153367", "0.51530486", "0.51471484", "0.51462615", "0.5144086", "0.51393443", "0.51380193", "0.5134256", "0.51330554", "0.5132106", "0.51162916", "0.5114976" ]
0.0
-1
This will define the initialize method which will populate every instance of Grade with the same attributes. These are required inputs to create an instance.
def initialize(name, grade_number, num_of_pupils, teacher) @name = name @grade_number = grade_number @num_of_pupils = num_of_pupils @teacher = teacher if grade_number == "kindergarten" puts "Welcome to #{grade_number}, #{name}. You have #{num_of_pupils.to_i - 1} classmates this year, and your teacher is #{teacher}." else puts "Welcome to #{grade_number} grade, #{name}. You have #{num_of_pupils.to_i - 1} classmates this year, and your teacher is #{teacher}." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(student)\n @number_grade = set_number_grade(student)\n @letter_grade = set_letter_grade\n end", "def initialize(name, grade, id = nil) #the name attribute can be accessed, the grade attribute can be accessed\n @name = name \n @grade = grade\n @id = id\n end", "def initialize(name, grade)\n self.name = name\n self.grade = grade\n end", "def initialize(name, grade, id=nil)\n @name = name\n @grade = grade\nend", "def initialize(first_name, last_name, grades)\n @first_name = :first_name\n @last_name = :last_name\n @grades = :grades\n end", "def initialize_0(name: nil, grade: nil, id: nil)\n @name = name\n @grade = grade\n @id = id\n end", "def initialize\n self.grades = Array.new\n end", "def initialize(name,grade ,id=nil)\n @name= name\n @grade= grade\n @id=id\n end", "def initialize(name, grade, id=nil)\n \t@name = name\n \t@grade = grade\n \t@id = id\n end", "def initialize(attributes={}) #can set instance variables when creating the instance\n @name = attributes[:name]\n @major = attributes[:major]\n @course = attributes[:course]\n @grade = attributes[:grade]\n end", "def initialize(id = nil, name, grade)\n@name = name\n@grade = grade\n@id = id\nend", "def initialize(name, grade, id=nil)\n @name = name\n @grade = grade\n @id = id\n end", "def initialize(name, grade, id = nil)\n @name = name\n @grade = grade\n @id = id\n end", "def initialize(name, grade, id = nil)\n @name = name\n @grade = grade\n @id = id\n end", "def initialize(id, name, grades)\n @id = id\n @name = name\n @grades = grades\n end", "def initialize(id, name, grades)\n @id = id\n @name = name\n @grades = grades\n end", "def initialize(id, name, grades)\n @id = id\n @name = name\n @grades = grades\n end", "def initialize(id=nil, name, grade)\n @id = id\n @name = name\n @grade = grade\nend", "def initialize(id=nil, name, grade)\n @id = id\n @name = name\n @grade = grade\nend", "def initialize ( name, grade, id = nil)\n @name = name \n @id = id \n @grade = grade\n @@all << self \n end", "def initialize(id = nil, name, grade)\n @id = id \n @name = name \n @grade = grade \n end", "def initialize(name, grade=9, school)\n ALL << self\n @name = name\n @grade = grade\n @school = school\n end", "def initialize(id=nil, name, grade) # The id should default to nil.\n @id = id\n @name = name\n @grade = grade\n end", "def initialize(params={})\n @full_name = params[:full_name]\n @course_name = params[:course_name]\n @grade_level = params[:grade_level]\n end", "def initialize(name, code, grade)\n @name = name\n @code = code\n @grade = grade\n end", "def initialize(id=nil, name, grade)\n @id = id\n @name = name\n @grade = grade\n end", "def initialize(id = nil, name, grade)\n @id = id\n @name = name\n @grade = grade\n end", "def initialize(attributes = {})\n self.class.set_attrb_accessors\n\n #cheeto = Student.new(name: \"cheeto\", grade: 6)\n attributes.each do |property, value|\n #interpolation converts symbol to string\n self.send(\"#{property}=\", value)\n end\n end", "def initialize (name, major, grade)\n\t\t@name = name\n\t\t@major = major\n\t\t@grade = \"\"\n\tend", "def initialize(student_hash)\n # Metaprogramming + Mass assignment\n # .send calls method name that's is key's name, with an arg of the value \n student_hash.each {|key, value| self.send((\"#{key.to_s}=\"), value)}\n \n # Same as:\n # @name = student_hash[:name]\n # @location = student_hash[:location]\n # @profile_url = student_hash[:profile_url]\n \n # Every time an instance of the class is initialized\n # Adds new student to the Student class' collection of all existing students\n # stored in `@@all` class variable\n @@all << self\n end", "def initialize(name, location, ranking, students, instructors)\n\t# Since we were asked to put in a parameter for each instance variable, here you can pass in a hash as an argument\n\t# for students and instructors and it will be placed in the array. It could also just be left as a blank array \n\t# so you can use the methods defined later to add students (but there is no instructor method).\n\t#OverthinkingIt\n\t\t@name = name\n\t\t@location = location\n\t\t@ranking = ranking\n\t\t@students = [students]\n\t\t@instructors = [instructors]\n\t\tSCHOOLS.push(self)\n\tend", "def initialize(name:, id:, anual_income:)\n @name = name\n @id = id\n @anual_income = anual_income\n @grades = []\n end", "def initialize\n @db = Hash.new {|hash,grade| hash[grade] = [] }\n end", "def initialize(student_hash)\n # @name = student_hash[:name]\n # @location = student_hash[:location]\n student_hash.each do |k, v|\n self.send((\"#{k}=\"), v)\n end\n @@all << self\n end", "def initialize(n, a, g) # initialize gets called when we use .new\n @name = n\n @age = a\n @gender = g\n end", "def initialize(student, test_name, status, instructor)\n @student = student\n @test_name = test_name\n @status = status\n @instructor = instructor\n @@all << self\n end", "def initialize(student_hash)\n student_hash.each {|key,value| self.send((\"#{key}=\"),value)}\n @@all << self\n end", "def initialize(student_hash)\n student_hash.each {|key, value| self.send((\"#{key}=\"), value)\n }\n @@all << self\n end", "def initialize(student, test_name, status, instructor)\n @student = student\n @test_name = test_name\n @status = status\n @instructor = instructor\n @@all << self # add every initialized instance to array of all BoatingTest instance\n end", "def initialize(name)\n @name = name\n @roster = {}\n # or you could do @roster = Hash.new {|h, k| h[k] = []}\n # which essentially does @roster[grade] ||= [] for you \n end", "def initialize(name, stomach, allergies) #initializing the three attributes\n\t\t@name=name\n\t\t@stomach=stomach\n\t\t@allergies=allergies\n\tend", "def initialize(*args)\n @args = args\n assign_attributes\n end", "def initialize(atts = nil)\n initialize_attributes\n self.update_attributes(atts || {})\n end", "def initialize(attributes)\n super\n end", "def initialize(attributes)\n super\n end", "def initialize(attributes={})\n super\n end", "def initialize(attributes={})\n super\n end", "def initialize(attributes={})\n super\n end", "def initialize(name:, age:, credit_score:)\n @name, @age, @credit_score = name, age, credit_score\n end", "def initialize(student_hash)\n #for each student in hash, create a k/v pair via mass asign (.send)\n student_hash.each {|k,v| self.send((\"#{k}=\"), v)}\n self.save\n end", "def initialize(attributes)\n super(attributes)\n end", "def initialize(school_name)\n @school_name = school_name\n @roster = {}\n # Roster should be an empty hash upon initialization but will be built out to contain keys of grade levels.\n # The value of each key will be an array of student names, i.e {10 => [\"Mike Trevino\"]}.\n end", "def initialize (hash)\n @student = hash[:student]\n @name = hash[:name]\n @status = hash[:status]\n @teacher = hash[:teacher]\n BoatingTest.all << self\n end", "def initialize(attributes = {})\n super\n end", "def initialize(attributes={})\n super(*DEFAULTS.merge(attributes).values_at(*members))\n\n validate!\n end", "def initialize(student,boating_test_name,boating_test_status,instructor)\n @student = student\n @boating_test_name = boating_test_name\n @boating_test_status = boating_test_status\n @instructor = instructor\n @@all << self\n end", "def initialize(lastName, firstName, studentID)\n @lastName = lastName\n @firstName = firstName\n @studentID = studentID\n end", "def initialize\n\t\t@constraints = {}\n\t\t@fields = {}\n\n\t\tself.reset\n\tend", "def initialize(student_id,semister_id)\n @student_id=student_id\n @semister_id=semister_id\n end", "def initialize(attributes = {})\n super(attributes)\n end", "def initialize(id)\n @student_id=id\n end", "def initialize(hair_color, eye_color, gender, shoe_size, name, age, height)\n @hair_color = hair_color\n @eye_color = eye_color\n @gender = gender\n @shoe_size = shoe_size\n @name = name\n @age = age\n @height = height \n end", "def initialize_attributes(attributes); end", "def initialize(student, bt_name, bt_status, instructor)\n @student = student\n @bt_name = bt_name\n @bt_status = bt_status\n @instructor = instructor\n @@all << self\n end", "def initialize(params = {})\n self.attributes = params\n end", "def create\n @course = Course.find(params[:course_id])\n #@grade = Grade.new(params[:grade])\n end", "def initialize(attributes = {})\n assign_attributes(attributes) if attributes\n\n super()\n end", "def initialize(name, age, health, strength)\n @name = name\n @age = age\n @health = health\n @strength = strength\n end", "def initialize\n set_name # generally not a good idea to include logic in initialize method, so will encapsulate that logic into set_name method\n @score = 0\n end", "def initialize\n\t\tself.first = Uniform.new( [:Rock, :Paper, :Scissors]).next(0)\n\t\tself.last = {:Rock => 0, :Paper => 0, :Scissors => 0}\n\tend", "def initialize(attrs = {})\n super()\n self.class.description[\"fields\"].each do |field|\n self.send(\"#{field[\"name\"]}=\", field[\"defaultValueFormula\"])\n end\n self.attributes=(attrs)\n end", "def initialize\n @gender = \"male\"\n @age = 37\n @color = \"black\"\n end", "def initialize(*attrs)\n set_attributes(attrs.extract_options!)\n end", "def initialize (name, age)\r\n # \"@\" is the \"instance value\".\r\n @name = name\r\n @age = age\r\n @@num_of_students += 1\r\n end", "def initialize(attributes)\n\t\t\tsuper\n\n\t\t\t# The wrapper to the API does not judge original values, so I initialize them here\n\t\t\t@max_weight ||= 100000000000\n\t\t\t@min_weight ||= 0\n\t\t\t@max_depth ||= 100000000000\n\t\t\t@min_depth \t||= 0\n\t\t\t@max_height ||= 100000000000\n\t\t\t@min_height ||= 0\n\t\t\t@max_width \t||= 100000000000\n\t\t\t@min_width \t||= 0\n\t\t\t@max_value \t||= 100000000000\n\t\t\t@min_value \t||= 0\n\n\t\tend", "def initialize\n \n end", "def initialize(attributes = nil)\n assign_attributes(attributes)\n super()\n end", "def initialize(*_)\n super\n end", "def initialize(name, age, style)\n # - We assign our attributes (instance variables) here!\n @name = name\n @age = age\n @style = style\n\n # - As well as pushed all instances inside of our @@all\n @@all << self\n end", "def initialize(name, fur_color, age) #doesn't have to be that but if you want those to be dynamic it does, if you didn't list one here and made a variable hard coded it would always be that value\n @name = name\n @fur_color = fur_color\n @age = age\n end", "def initialize(hair_color, eye_color, gender, shoe_size, name, age, height)\n @hair_color = hair_color\n @eye_color = eye_color\n @gender = gender\n @shoe_size = shoe_size\n @name = name\n @age = age\n @height = height\n end", "def initialize(title, levels, starsRequired)\n\t\t@title = title\n\t\t@levels = levels\n\t\t@starsRequired = starsRequired\n\tend", "def initialize(attributes=[]) #this gives a default value if no array is passed\n @last_name = attributes[0]\n @first_name = attributes[1]\n @npi = attributes[2]\n @practice_name = attributes[3]\n @address_line_1 = attributes[4]\n @address_line_2 = attributes[5]\n @city = attributes[6]\n @state = attributes[7]\n @zip = attributes[8]\n @speciality = attributes[9]\n end", "def initialize(**attributes)\n @attr = {}\n attributes\n end", "def initialize(options={})\n\t\t@age = options[:age]\n\t\t@gender = options[:gender]\n\tend", "def initialize(year, bed_type) # add add bed_type param\n super(year) # add \n @bed_type = bed_type # add\n end", "def initialize(attributes={})\n\t\t\t@attributes = attributes\n\t\tend", "def initialize\n @knowledge = [] # When we make a new student, that instance of a student will create an array tied to that specific student\n end", "def initialize(attrs={})\n @attrs = attrs\n end", "def initialize(attrs={})\n @attrs = attrs\n end", "def initialize(attrs={})\n load_attributes!(attrs)\n end", "def initialize(name, age, gender) # Set our instance variables when we create each person.\n @name = name\n @age = age\n @gender = gender\n end", "def initialize()\n @sides = DEFAULTS[:sides]\n @num_dice = DEFAULTS[:num_dice]\n @players = DEFAULTS[:players]\n @speed = DEFAULTS[:speed]\n @target_score = DEFAULTS[:target_score]\n end", "def initialize(attrs = {})\n @attrs = attrs\n end", "def initialize\n end", "def initialize(name, age, gender)\n @name=name\n @age = age\n @gender = gender\n end", "def initialize(attributes = {})\n\t\tsuper # must allow the active record to initialize!\n\t\tattributes.each do |name, value|\n\t\t\tsend(\"#{name}=\", value)\n\t\tend\n\tend", "def initialize # rubocop:disable Lint/UselessMethodDefinition\n super()\n end", "def initialize # rubocop:disable Lint/UselessMethodDefinition\n super()\n end", "def initialize # rubocop:disable Lint/UselessMethodDefinition\n super()\n end" ]
[ "0.76288193", "0.74194777", "0.7232502", "0.7169807", "0.71658593", "0.71543574", "0.70550203", "0.7051208", "0.6970033", "0.6931684", "0.69181067", "0.6903284", "0.6891237", "0.6891237", "0.68507415", "0.68507415", "0.68507415", "0.6805139", "0.6805139", "0.67915344", "0.6786896", "0.675322", "0.6702228", "0.66731584", "0.66594386", "0.6641331", "0.6588576", "0.65784", "0.6480062", "0.64347416", "0.6395998", "0.63746136", "0.62011546", "0.6195024", "0.6172743", "0.616972", "0.6169436", "0.61570793", "0.6134466", "0.61154765", "0.6076695", "0.6070129", "0.60688657", "0.6067928", "0.60652095", "0.60518223", "0.60518223", "0.60518223", "0.60387355", "0.60359615", "0.60296357", "0.6028383", "0.6016162", "0.601439", "0.6007691", "0.6000923", "0.59951276", "0.59847873", "0.5984429", "0.5979527", "0.5973532", "0.59719926", "0.5951197", "0.5949526", "0.59485465", "0.5941007", "0.59391904", "0.59343225", "0.59298354", "0.5926232", "0.590476", "0.5896145", "0.5891008", "0.58854795", "0.5885224", "0.5883675", "0.58719134", "0.58646667", "0.586278", "0.58611155", "0.58584195", "0.5855066", "0.5852882", "0.58520764", "0.5846921", "0.58337694", "0.5824036", "0.5816552", "0.58105695", "0.58105695", "0.58006954", "0.5792292", "0.57902485", "0.57849747", "0.57826763", "0.5780302", "0.5773325", "0.57697004", "0.57697004", "0.57697004" ]
0.582711
86
Every time a new instance of Grade is produced, the greeting will be printed out with a puts (put string)method. You can create new methods, or actions, to perform on each instance of Grade. Using dot notation to combine methods and objects, you can manipulate them. Here's another method definition:
def dismissal if @grade_number == "kindergarten" puts "Dismissal time for #{grade_number} is 1:00." else puts "Regular Grades are dismissed at 3:00." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def greet\r\n self.yell_name + \" says hi.\" # self specifies method within the class\r\n end", "def letter_grade # getter\n self.class.letter_grade(grade)\n end", "def grade!\n # default method does nothing and leaves a score of 0\n end", "def greeting(name)\n \"Hello and welcome to Ruby methods \" + name + \"!\"\nend", "def grade(student_grade)\n roster[student_grade]\nend", "def sayHi\n puts \"Hello Class\"\nend", "def initialize(name, grade)\n self.name = name\n self.grade = grade\n end", "def grade(grade)\n @roster[grade]\nend", "def print_method(*) end", "def grade(grade)\n\t\t@roster[grade]\n\tend", "def grade\n @grade\n end", "def greeting(person)\n puts \"Hello, \" + person\nend", "def greeting\n\t\t#make a greeting for both student and teacher\n\t\tputs \"Hi, my name is #{@name}!\"\n\tend", "def excited_greet(name)\nend", "def grade(student_grade)\n roster[student_grade]\n end", "def greeting(name) \n puts \"Hello, \"+name\nend", "def first_method(name, age)\n puts \"Hello #{name}. You are #{age} years old\"\nend", "def test\nspongebob = Student.new(\"Spongebob\")\npatrick = Student.new(\"Patrick\")\nplankton = Student.new(\"Plankton\")\n\nmrs_puff = Instructor.new(\"Mrs. Puff\")\nsquidward = Instructor.new(\"Squidward Tentacles\")\n\nspongebob_test1 = spongebob.add_boating_test(\"parking_test\", \"Fail\", mrs_puff)\nspongebob.add_boating_test(\"braking_test\", \"Fail\", mrs_puff)\nspongebob.add_boating_test(\"speeding_test\", \"Pass\", squidward)\n\npatrick.add_boating_test(\"parking_test\", \"Fail\", mrs_puff)\npatrick.add_boating_test(\"speeding_test\", \"Pass\", squidward)\n\nplankton.add_boating_test(\"parking_test\", \"Pass\", squidward)\nplankton.add_boating_test(\"braking_test\", \"Pass\", squidward)\n\nputs \"Student Test\"\nputs \"------------\"\nprint \"Student has first name: \"\nputs spongebob.first_name == \"Spongebob\"\nprint \"Student.all returns all student objects: \"\nputs Student.all == [spongebob, patrick, plankton]\nprint \"#add_boating_test creates a new boating test: \"\nputs spongebob_test1.class == BoatingTest\n\nputs \"------------\"\nputs \"Instructor Test\"\nputs \"------------\"\nprint \"Instructor has name: \"\nputs squidward.name == \"Squidward Tentacles\"\nprint \"Instructor.all returns all instructors: \"\nputs Instructor.all == [mrs_puff, squidward]\nprint \"#pass students: \"\nmrs_puff.pass_student(spongebob, \"parking_test\")\nputs spongebob_test1.status == \"Pass\"\nprint \"#fail_student\"\nmrs_puff.fail_student(spongebob, \"parking_test\")\nputs spongebob_test1.status == \"Fail\"\n\nputs \"------------\"\nputs \"BoatingTest Test\"\nputs \"------------\"\nprint \"has a student: \"\nputs spongebob_test1.student == spongebob\nprint \"has a name: \"\nputs spongebob_test1.test_name == \"parking_test\"\nprint \"has a status: \"\nputs spongebob_test1.status == \"Fail\"\nprint \"has an instructor: \"\nputs spongebob_test1.instructor == mrs_puff\n\nend", "def salute\n\t\tputs \"Hi, I am a #{self.class.to_s}. My name is #{name}\"\n\tend", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def grade(grade)\n @roster[grade]\n end", "def grade(grade)\n @roster[grade]\n end", "def grade(grade)\n @roster[grade]\n end", "def greeting \r\n puts \"Hi, Ruby programmer!\"\r\nend", "def initialize(name, grade_number, num_of_pupils, teacher)\n @name = name\n @grade_number = grade_number\n @num_of_pupils = num_of_pupils\n @teacher = teacher\n if grade_number == \"kindergarten\"\n puts \"Welcome to #{grade_number}, #{name}. You have #{num_of_pupils.to_i - 1} classmates this year, and your teacher is #{teacher}.\"\n else\n puts \"Welcome to #{grade_number} grade, #{name}. You have #{num_of_pupils.to_i - 1} classmates this year, and your teacher is #{teacher}.\"\n end\n end", "def introduction(target) # created a new method called introduction that works on a specified target\n puts \"Hi #{target}, I'm #{first_name}!\" # Gotta get the console to print it\n end", "def greet person\n\t'Hello, ' + person + '!'\nend", "def greeting(name)\n \"Hello, \" + name\nend", "def methods() end", "def greeter\nend", "def greet(person)\n puts \"Hello, \" + person\nend", "def greet(person)\n puts \"Hello, \" + person\nend", "def grade(*args)\n process_using(*args.unshift(:grade))\n end", "def greet name\t\t\t# name is a \"parameter\" of the method.\n\tputs \"Hello #{name}!\"\nend", "def introduce \n puts \"Hi, my name is #{self.name}\"\n end", "def change_grade(new_grade)\n @grade = new_grade\nend", "def speak\n #useses the name variable that all GoodDog objects are assigned at creation. Different for each instance\n \"#{@name} says Arf!\"\n end", "def introduction(target) #introduction method\n puts \"Greetings #{target}, I'm #{first_name}!\"\n end", "def greeting_a_person(name)\n puts \"Hello #{name}\"\nend", "def print4(nyc)\n\t4.times do puts nyc\n\n\tend\n\n#Prints an uppercase version of the argument given\ndef printupcase (live)\n\n\tputs live.upcase\nend\n\n#Object with two attributes and one method.\n\nclass Dog\nattr_accessor :name, :trait\n\nend\n\nfirst_dog = Dog.new\nfirst_dog.name = \"Bob\"\nfirst_dog.trait = \"annoying\"\n\ndef bark\n\tputs \"au au au\"\n\nend\nend", "def grade(grade)\r\n @roster[grade]\r\n end", "def grade(*args)\n process_using(*args.unshift(:grade))\n end", "def initialize(name, grade, id=nil)\n @name = name\n @grade = grade\nend", "def say_that_thing_you_say\n \"#{self.name} always says: #{self.catchphrase}\"\nend", "def another_greetings\n puts 'Hello'; puts 'Motherfucker'\nend", "def greeting\n puts \"Welcome to the world of practical effects\"\n end", "def say_hello\n \"Hello #{object.email}!\"\n end", "def say_hello\n \"Hello #{object.email}!\"\n end", "def greeting(name)\n puts \"Aloha \" + name\nend", "def talk\r\n puts \"Hi I'm #{@name}\"\r\n self\r\n end", "def greeting()\n \"#{hello} #{world}\"\nend", "def print\n\t\tputs name + \" \" + className + \" says \" + call\n\tend", "def greeting(name)\n \"Hello, \" + name + \". How are you doing?\"\nend", "def greeting\n puts 'Hello!'\nend", "def greeting\n puts 'Hello!'\nend", "def greeting\n puts 'Hello!'\nend", "def greeting\n puts 'Hello!'\nend", "def greeting\n puts 'Hello!'\nend", "def greeter(name)\n #some code here\nend", "def greeting(name)\n \"Hello there, \" + name + \"!\"\nend", "def greet person\n puts \"Hello, #{person}!\"\nend", "def greeting(name)\n \"Hello,\" + name + \". How are you doing?\"\nend", "def greeting\n puts \"Hello!\"\nend", "def greeting\n puts \"Hello!\"\nend", "def print_text\n\t\tputs self # First object\n\t\tputs \"this is instance method to print some text\"\n\tend", "def print\r\n\t\tputs name + \" \" + className + \" says \" + call\r\n\tend", "def meow\n puts \"meow!\"\n # when we call on the method .meow\n # it will put meow\n end", "def call_friend(friend)\n friend.happiness +=3\n self.happiness +=3\n \"Hi #{friend.name}! It's #{self.name}. How are you?\"\nend", "def greeting(name)\n \"Howdy #{name}, welcome back!\"\nend", "def greeting(name)\n\tputs \"Hello \" + name + \". Have a nice day!\"\nend", "def greeting(name)\n \"Good Morning #{name}!\"\nend", "def greeting \n puts \"Hello World\"\nend", "def sayMessage(person)\r\n puts \"Hello \" + person + \".\"\r\n \r\nend", "def greeting(name)\n puts \"Good day \"+name.capitalize\nend", "def initialize ( name, grade, id = nil)\n @name = name \n @id = id \n @grade = grade\n @@all << self \n end", "def greeting(name)\n\tputs \"Hello, \" + name + \". How are you doing?\"\nend", "def initialize(name, grade, id = nil) #the name attribute can be accessed, the grade attribute can be accessed\n @name = name \n @grade = grade\n @id = id\n end", "def greet(name)\nend", "def greeting(name)\n \"Good to see you #{name}\"\nend", "def grader (user_grade)\n if user_grade > 1\n elsif user_grade < 0.6\n return \"F\"\n elsif user_grade >= 9.0\n return \"A\"\n elsif user_grade >= 0.8\n return \"B\"\n elsif user_grade >= 0.7\n return \"C\"\n\n end\n\n#Write a method smash that takes an array of words and smashes them together into a sentence and returns the sentence.\ndef smash (words)\n \"#{words}\".chomp\nend\nend", "def print_name\r\nputs \"Person called #{@name}\"\r\nend", "def to_s # to_s is a default method for a class. it returns a string when you call the class later.\n \treturn \"I'm a student.\"\n end", "def method\r\nend", "def another_greeting()\n return greet() + \" there!\"\nend", "def greeting\n puts \"hello\"\nend", "def report_card\n puts self.get_gpa\n grades = self.registrations.includes(:course)\n # puts \"Your grades for each class are as follows:\\n\"\n tp grades, {\"Subject\" => {:display_method => lambda{|x| x.course.subject}}}, {\"Grades\" => {:display_method => lambda{|x| numeric(x.grade)}}}\n end", "def print_grades\n @learn_grades.each do |grade|\n puts grade.which_course?.foreground(:yellow) + \": \".foreground(:yellow)\n puts grade.summary\n end\n end", "def badge_maker(name)\n \"Hello, my name is #{name}.\";\nend", "def badge_maker(name)\n \"Hello, my name is #{name}.\"\nend", "def badge_maker(name)\n \"Hello, my name is #{name}.\"\nend" ]
[ "0.60621995", "0.57469565", "0.55793154", "0.5548945", "0.5541698", "0.54349023", "0.54314744", "0.5413042", "0.540696", "0.5378676", "0.53664005", "0.53643113", "0.5351526", "0.53321534", "0.53284186", "0.53153235", "0.5315051", "0.5313958", "0.53074193", "0.53047436", "0.53047436", "0.53047436", "0.53047436", "0.53047436", "0.53047436", "0.53047436", "0.53047436", "0.53047436", "0.53047436", "0.53047436", "0.53047436", "0.5301846", "0.5301846", "0.5301846", "0.5284992", "0.52798617", "0.52777183", "0.5271772", "0.5268598", "0.52611184", "0.52594614", "0.52428824", "0.52428824", "0.52421725", "0.52419835", "0.5235079", "0.52272254", "0.5219647", "0.52051204", "0.52032834", "0.5199128", "0.51982313", "0.5197861", "0.51849633", "0.51746273", "0.5168697", "0.516292", "0.515574", "0.515574", "0.51414824", "0.5141268", "0.513642", "0.5127357", "0.5127173", "0.5122351", "0.5122351", "0.5122351", "0.5122351", "0.5122351", "0.5121723", "0.5119995", "0.51063913", "0.51036835", "0.5101244", "0.5101244", "0.50974184", "0.50943553", "0.5094026", "0.50869364", "0.5085067", "0.5083416", "0.50771284", "0.5073549", "0.50734967", "0.5072174", "0.5069573", "0.50659806", "0.50595844", "0.5059018", "0.5056087", "0.5055853", "0.50522375", "0.5051371", "0.50507814", "0.50465834", "0.5035503", "0.5034969", "0.50332624", "0.50269413", "0.5024428", "0.5024428" ]
0.0
-1
csv_header spss_header csv_answer spss_answer load_csv_answer
def csv_header(header_prefix) @csv_header << header_prefix end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def import_csv_full\n \n end", "def import_csv_smart\n \n end", "def load_csv\n # read each line frmo csv and append to recipes collection\n CSV.foreach(@csv_file) do |row|\n # puts \"#{row[0]} | #{row[1]}\"\n @recipes << Recipe.new(name: row[0], description: row[1], cooking_time: row[2], difficulty: row[3], tested: row[4])\n end\n end", "def get_csv_data(csv_file)\n\t\tcsv_file = File.read(csv_file)\n\t\tcsv = CSV.parse(csv_file, :headers => true)\t\n\t\tcsv\n\tend", "def export_survey_answers(csv_survey_answers, survey_id)\n survey = Survey.find(survey_id)\n header = journal_csv_header.keys + ['follow_up'] + survey.variables.map {|v| v.var}\n \n csv_rows = csv_survey_answers.inject([]) do |rows,csa|\n puts \"csa.journal.nil? #{csa.inspect} #{csa.journal.inspect} sa: #{csa.survey_answer.inspect}\" if csa.journal.nil?\n\n journal_entry = JournalEntry.where(\n survey_answer_id: csa.survey_answer_id,\n center_id: csa.center_id, \n group_id: csa.team_id).first\n info = \n if !journal_entry.nil? && journal_entry.answer_info\n journal_entry.answer_info.split(\";\")\n elsif csa.journal_info\n csa.journal_info.split(\";;\")\n elsif csa.survey_answer\n csa.survey_answer.info.values\n else\n puts \"no answer_info found in journal_entry or survey_answer: #{csa.inspect} je: #{csa.journal_entry.inspect}\"\n [\"ingen info: sa_id: #{csa.survey_answer_id} csa: #{csa.inspect} \"]\n end\n\n if !csa || !csa.answer\n puts \"No csa: #{info.inspect}\"\n end\n rows << info + [FollowUp.to_value(csa.follow_up)] + (csa && csa.answer && csa.answer.split(';;') || [] )\n rows\n end\n\n output = CSV.generate(:col_sep => \";\", :row_sep => :auto, :encoding => 'utf-8') do |csv_output|\n csv_output << header\n csv_rows.each { |line| csv_output << line }\n end\n end", "def export_survey_answers(csv_survey_answers, survey_id)\n survey = Survey.find(survey_id)\n header = journal_csv_header.keys + survey.variables.map {|v| v.var}\n \n csv_rows = csv_survey_answers.inject([]) do |rows,csa|\n header_values = csa.journal_info.split(';;')\n rows << header_values + csa.answer.split(';;')\n rows\n end\n\n output = FasterCSV.generate(:col_sep => \";\", :row_sep => :auto, :encoding => 'u') do |csv_output|\n csv_output << header\n csv_rows.each { |line| csv_output << line }\n end\n end", "def csv\n @csv_table ||= begin\n csv_raw = File.read(CSV_PATH)\n CSV.parse(csv_raw, headers: true)\n end\n\nend", "def load_questions\n CSV.foreach(\"questions.csv\", { :col_sep => ' | ' }) do |row|\n key = row[0]\n value = row[1]\n RESPONSES[key] = value\n end\n puts \"Questions and responses loaded!\"\n puts \"\"\nend", "def show_section_for_csv(csv, phase, section, headings, unanswered, hash)\n section[:questions].each do |question|\n next if remove_list(hash).include?(question[:id])\n\n answer = self.answer(question[:id], false)\n answer_text = ''\n if answer.present?\n answer_text += answer.question_options.pluck(:text).join(', ') if answer.question_options.any?\n answer_text += answer.text if answer.answered? && answer.text.present?\n elsif unanswered\n answer_text += _('Not Answered')\n end\n single_line_answer_for_csv = sanitize_text(answer_text).gsub(/\\r|\\n/, ' ')\n flds = (hash[:phases].many? ? [phase[:title]] : [])\n if headings\n question_text = if question[:text].is_a? String\n question[:text]\n else\n (if question[:text].many?\n question[:text].join(', ')\n else\n question[:text][0]\n end)\n end\n flds << [section[:title], sanitize_text(question_text),\n single_line_answer_for_csv]\n else\n flds << [single_line_answer_for_csv]\n end\n csv << flds.flatten\n end\n end", "def prepare_csv\n unparsed_file = File.open(csv.path)\n self.parsed_csv_string = \"\"\n string = unparsed_file.readlines()\n string.each_with_index do |line,i|\n parsed_line = line.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').gsub(/,\\\"\\\"/,'')\n # for some reason the iRacing CSV file is buggy.\n unless parsed_line == \"\\n\"\n if i == 5 or i == 6\n parsed_line = parsed_line.gsub(/\\n/,\"\\r\\n\")\n end\n self.parsed_csv_string << parsed_line\n end\n end\n unparsed_file.close\n end", "def read_scores_from\n teams_data = []\n\n CSV.foreach('scores.csv', headers: true, header_converters: :symbol) do |row|\n teams_data << row.to_hash\n end\n teams_data\nend", "def read_csv(file, header)\n FasterCSV.read(file, {:header_converters => :symbol, :headers => header } )\nend", "def load_csv\n options = { headers: :first_row, header_converters: :symbol }\n\n CSV.foreach(@csv_path, options) do |row|\n row[:id] = row[:id].to_i\n row[:price] = row[:price].to_i\n @elements << Meal.new(row)\n end\n @next_id = @elements.empty? ? 1 : @elements.last.id + 1\n end", "def parse_file\n if @csv_source == \"siteimprove\"\n column_seperator = \"\\t\" \n # If using CharlockHolmes Encoding Detector, uncomment this\n #detection = CharlockHolmes::EncodingDetector.detect(contents)\n #@csv_encoding = detection[:encoding]\n @csv_encoding = \"UTF-16LE\"\n elsif @csv_source == \"google\" \n column_seperator = \",\"\n # If using CharlockHolmes Encoding Detector, uncomment this \n #detection = CharlockHolmes::EncodingDetector.detect(contents)\n #@csv_encoding = detection[:encoding]\n @csv_encoding = \"ISO-8859-1\"\n end\n contents = File.read(@csv_filename)\n output_encoding = @csv_encoding + \":UTF-8\"\n arr_csv_contents = CSV.read(@csv_filename, { :encoding => output_encoding, :headers => true, :col_sep => column_seperator, :skip_blanks => true })\n if @csv_source == \"siteimprove\"\n @site_name = \"Graduate Research\"\n @site_addr = \"http://gradresearch.unimelb.edu.au\"\n arr_csv_contents.each { |row| \n @arr_of_titles << row[0]\n @arr_of_urls << row[1]\n } \n # delete the first two rows of the array\n @arr_of_titles = @arr_of_titles.drop(2)\n @arr_of_urls = @arr_of_urls.drop(2) \n elsif @csv_source == \"google\" \n #@site_name = \"Grainger Museum\"\n @site_name = \"Varied-Sample\"\n @site_addr = \"http://www.unimelb.edu.au/\"\n arr_csv_contents.each { |row| \n @arr_of_titles << row[0]\n @arr_of_urls << row[7] #1 for grainger\n } \n end\n end", "def load_data(csv)\n @hash.each do |sentence, count|\n csv << [sentence, count]\n end\n end", "def get_csv_data(csv_data)\r\n csv_file = nil\r\n\r\n #Get the path and name of the CSV file\r\n if csv_data.to_s.include? '.csv'\r\n csv_file = File.join(File.dirname(__FILE__), \"../venture/config/csv_data/#{csv_data}\")\r\n elsif (\r\n csv_file = File.join(File.dirname(__FILE__), \"../venture/config/csv_data/#{csv_data}.csv\")\r\n )\r\n end\r\n\r\n csv_arr = CSV.read( csv_file, {:headers => true, :header_converters => :symbol, :encoding => 'UTF-8'} )\r\n keys = csv_arr.headers.to_a\r\n # read attribute example => csv[index][:column1]\r\n return csv_arr.to_a.map {|row| Hash[ keys.zip(row) ] }\r\nend", "def load_csv\n CSV.foreach(@csv_file_path) do |row|\n @recipes << Recipe.new(name: row[0], description: row[1], rating: row[2], prep_time: row[3], tried: row[4])\n end\n end", "def load\n CSV.foreach(@csv_file, headers: :first_row, header_converters: :symbol) do |row|\n @meals << Meal.new(row)\n end\n end", "def import_csv\n @records = CSV.read(@filename, :headers => true, :row_sep => :auto)\n unless @records.blank?\n @linenum = 0\n if @filename.index('att') || @filename.index('Att')\n @school_year = Time.parse(@records[0][\"AbsenceDate\"]).year\n end\n @records.each { |rec |\n @linenum += 1\n @record = rec\n next unless check_record(@record)\n seed_record(@record)\n process_record(@record, rec2attrs(@record)) if rec2attrs(@record) != false\n }\n end \n end", "def test_parse_headers\n tmpdbfile = Tempfile.new('tmp.db')\n args = [\"--header\", \n \"--source\", \"header_test.csv\", \n \"--save-to\", tmpdbfile.path, \n \"--ifs=\" \",\",\n \"--table-name\",\"header_test\"]\n Csvql.run(args)\n\n db = SQLite3::Database.new tmpdbfile.path\n headers_from_db = db.execute2('select * from header_test;')[0]\n headers_from_file = File.open('header_test.csv').each_line.first.gsub(/\\n/,'').split(',')\n\n #binding.pry\n assert_equal headers_from_db, headers_from_file\n end", "def recommendation_csv_inputs csv_path\n valid_inputs = []\n\n CSV.foreach(csv_path, {headers: true, header_converters: :symbol}) do |row|\n row = row.to_h\n valid_inputs << row if valid_recommendation_hash?(row)\n end\n\n valid_inputs\n\n rescue => e\n valid_inputs\n end", "def load_csv(csv_path)\n raise Error::InvalidCSV unless File.exist? csv_path\n begin\n vals = CSV.read(csv_path)\n rescue CSV::MalformedCSVError\n raise Error::InvalidCSV\n end \n\n raise Error::BlankCSV if vals.length == 0\n raise Error::InvalidCSV if vals[0].length != 3\n\n # remove optional header\n vals.shift if vals[0][0] == HEADER_VAL\n\n @data = vals.collect do |data|\n {\n \"image_path\" => data[0],\n \"id\" => data[1],\n \"label\" => data[2]\n }\n end\n end", "def load_file (filename = \"students.csv\")\n CSV.foreach(filename) do |row|\n name, cohort, food = row.map{ |element| element.chomp}\n add_student(name, cohort, food)\n end\nend", "def load_students(filename = \"students.csv\")\n # CSV.open(filename, \"r\") {|file|\n CSV.foreach(filename) do |line| # contains name, cohort\n # file.readlines.each do |line|\n name, cohort = line\n student_into_array(name, cohort.to_sym)\n end\n\nend", "def read_parameters_from_csv(csv)\r\n\t\tbegin\r\n\t\t\ttemp = CSV.read(csv)\r\n\t\trescue Exception\r\n\t\t\traise ArgumentError, \"It wasn't possible to read from #{csv} file.\"\r\n\t\tend\r\n\t\ttemp.each_with_index do |row,index|\r\n\t\t\t@actual_parameters[index] = row[0].split(';')\r\n\t\tend\r\n\tend", "def initialize_csv\n CSV.open(\"results.csv\", \"wb\") do |csv|\n csv << [\"class\", \"title of course\", \"credits\"]\n end\nend", "def parse_csv\n if self.csv_file.present?\n csv_text = Paperclip.io_adapters.for(self.csv_file).read\n csv = CSV.parse(csv_text, :headers => false)\n\n csv_columns = ['l', 'r', 'units']\n\n csv_to_save = {}\n\n csv.each_with_index do |row, i|\n if i == 0\n csv_to_save['weight'] = row[1].split(':')[1] # string is like Weight:201, only want the number\n csv_to_save['shoe_size'] = row[2].split(':')[1] # string is like Shoe Size:9\n elsif i >= 3\n row.each_with_index do |field, j|\n if j >= 1 and !field.blank?\n csv_to_save[generate_csv_row_key(csv_columns, row, i, j)] = field\n end\n end\n end\n end\n\n # Check to see if any of the fields are nil, then we must have not received the correct file\n is_clean = true\n csv_to_save.each do |key, val|\n if val.nil?\n is_clean = false\n break\n end\n end\n\n CsvFile.create!(csv_to_save) if is_clean\n end\n end", "def csv(csv_file)\n Slacker.get_csv(csv_file)\n end", "def loadStructure(file)\n csv_text = File.read(file)\n return CSV.parse(csv_text, :headers => true)\n \nend", "def read_vote_csv(file_name)\n begin\n # @type [Array<Array<String>>]\n csv = CSV.read(file_name)\n rescue Errno::ENOENT\n warn format('Sorry, the file %<File>s does not exist', File: file_name)\n exit 1\n end\n csv.delete_if { |line| line.join('') =~ /^\\s*$/ } # delete blank lines\n csv\nend", "def parse_csv(file)\n\t\tdata = []\n\t\t# Break open CSV and go through rows\n\t\tbegin\n\t\t\tdata = CSV.read(file, :headers => true,:skip_blanks => true,:header_converters => :symbol, :encoding => 'UTF-8')\n\t\trescue\n\t\t\t# Convert to UTF-8 if necessary\n\t\t\tdata = CSV.read(file, :headers => true,:skip_blanks => true,:header_converters => :symbol, :encoding => 'Windows-1252:UTF-8')\n\t\tend\n\t\tdata\n\tend", "def load_csv(csv_file_or_object, table_name, log_name = nil)\n log_name ||= \"load_csv '#{csv_file_or_object.kind_of?(CSV::Table) ? 'CSV Object' : csv_file_or_object }', 'table_name'\"\n csv_object = case csv_file_or_object\n when String then Slacker.get_csv(csv_file_or_object)\n when CSV::Table then csv_file_or_object\n when Array then Slacker.hash_array_to_csv(csv_file_or_object)\n end\n\n Slacker.load_csv(example, csv_object, table_name, log_name)\n end", "def parse_to_load_file(csv)\n csv.each_with_index do |student, index|\n student = {month: csv[index][0] , name: csv[index][1], city: csv[index][2], hobby: csv[index][3]}\n @students << student\n end\nend", "def load_csv(csv_filepath)\n gifts = []\n CSV.foreach(csv_filepath) do |row|\n gifts << row[0] # Nosso csv só tem uma coluna\n end\n return gifts\nend", "def populate_csv(csv, headers)\n @source_csv.each do |row|\n csv << [].tap do |arr|\n headers.each do |k, v|\n arr.push(row.to_h.fetch(k, nil))\n end\n end\n end\n end", "def csv_data\n case\n when google_key || url then Curl::Easy.perform(uri).body_str\n when file then File.open(uri).read\n end\n end", "def import_from_csv\n puts 'Which file would you like to import?'\n file_path = gets.chomp\n CsvImporter.new(@database, file_path).import\n puts 'Import complete.'\n rescue FileNotFoundError\n puts 'The specified file was not found.'\n rescue CsvInvalidError => e\n puts e.message\n end", "def loadCSV\n csvFile = File.open(\"app/assets/csv/test.csv\", \"r\") #Open file with readpermissions\n if csvFile #if file was successfully opened \n csvRowArray = IO.readlines(csvFile) # Turn each row into an array element\n rowId=1 #0 is the Header Row, 1 is the first dataset.\n recordsArray = Array.new(csvRowArray.size-1)\n while csvRowArray[rowId] do #for each row that exists \n rowEntry = csvRowArray[rowId]\n rowEntry.gsub!(/\"/,'') # Remove all the '\"'s\n wordArr = rowEntry.split(\",\") #Split the array on ','s into a new array \n newRecord = Record.new\n newRecord.REF_DATE = wordArr[0]\n newRecord.GEO = wordArr[1]\n newRecord.DGUID = wordArr[2]\n newRecord.Sex = wordArr[3]\n newRecord.Age_group = wordArr[4]\n newRecord.Student_response = wordArr[5]\n newRecord.UOM = wordArr[6]\n newRecord.UOM_ID = wordArr[7]\n newRecord.SCALAR_FACTOR = wordArr[8]\n newRecord.SCALAR_ID = wordArr[9]\n newRecord.VECTOR = wordArr[10]\n newRecord.COORDINATE = wordArr[11]\n newRecord.VALUE = wordArr[12]\n newRecord.STATUS = wordArr[13]\n newRecord.SYMBOL = wordArr[14]\n newRecord.TERMINATED = wordArr[15]\n newRecord.DECIMALS = wordArr[16]\n newRecord.save\n puts rowId\n rowId = rowId+1 \n end\n return recordsArray\n else #file not opened\n puts \"Unable to open file\" \n return \n end \n end", "def read_in_csv_data(csv_file_name)\n begin\n CSV.foreach(csv_file_name, headers: true) do |row|\n @songs << Song.new(row['name'], row['location'])\n end\n rescue Exception\n @songs = nil\n end\n @songs\n end", "def get_zips\n zips = CSV.read('./zips.csv', :headers => true)\n return zips\nend", "def parse_csv(b, a, b_a, l, p)\n keys = [\"books\", \"authors\", \"books_authors\", \"languages\", \"publishers\"]\n x = 0\n CSV.foreach(BOOKS_FILE, encoding: \"UTF-8\") do |col|\n if \"====== \" + keys[x].to_s + \" ======\" == col[0]\n x += 1\n end\n\n case x\n when 1 then\n b.push(col)\n when 2 then\n a.push(col)\n when 3 then\n b_a.push(col)\n when 4 then\n l.push(col)\n when 5 then\n p.push(col)\n end\n end\n return b, a, b_a, l, p\nend", "def csv(handle, path = nil)\n @dsd = DataSourceDownload.get(handle)\n raise \"handle '#{handle}' does not exist\" if @dsd.nil? and handle != \"manual\"\n path = (handle == \"manual\") ? DataSourceDownload.flex(path) : @dsd.save_path_flex \n @handle = handle\n @csv ||= {}\n if @csv[path].nil? \n download_handle unless @dsd.nil?\n #puts path\n begin\n @csv[path] = CSV.read(path)\n @new_data = true\n rescue\n #resolve one ugly known file formatting problem with faster csv\n alternate_csv_load = alternate_fastercsv_read(path) #rescue condition if this fails\n #return \"READ_ERROR:CSV FORMAT OR FILE PROBLEM\" if alternate_csv_load.nil? \n @csv[path] = alternate_csv_load\n @new_data = true\n end\n end\n @csv[path]\n end", "def csv_header\n #empty by default\n []\n end", "def csv_header\n #empty by default\n []\n end", "def read_csv_file(csv_table_path)\r\n \r\n table_dimensions = detect_state_table_dim(csv_table_path)\r\n \r\n if table_dimensions==:one_d\r\n return read_1d_csv_file(csv_table_path)\r\n elsif table_dimensions==:two_d\r\n return read_2d_csv_file(csv_table_path)\r\n else\r\n raise \"Error: CSV File dimensions: #{table_dimensions}\"\r\n end # end if else \r\n \r\n end", "def update_summary_csv(summary_csv_path, line)\n puts \"updating summary csv: #{summary_csv_path}\"\n\n # the results row is a string rather than an array so handle as file rather than csv\n File.open(summary_csv_path, \"a+\") do |f|\n f << line\n end\nend", "def load_students\n puts \"Loading file\"\n # Open the file with \"read\" privilages\n file = File.open(\"students.csv\", \"r\")\n # Go through each line of the file\n file.readlines.each do |line|\n # .. picking out the name and cohort columns\n name, cohort = line.chomp.split(',')\n # Add them to the student variable as a hash\n @students << {name: name, cohort: cohort.to_sym}\n end\n # Close the file\n file.close\nend", "def load\n csv = csv_data\n @data = TableFu.new(csv_data, @table_opts[:column_options] || {})\n if @table_opts[:faceting]\n @data.col_opts[:ignored] = [@table_opts[:faceting][:facet_by]]\n @facets = @data.faceted_by @table_opts[:faceting][:facet_by]\n end\n @data.delete_rows! @table_opts[:dead_rows] if @table_opts[:dead_rows]\n end", "def load_students\n puts \"Which file do you want to load?\"\n file = STDIN.gets.chomp\n CSV.foreach(file) do |row|\n @name, cohort = row.shift\n write_students\n end\nend", "def read_csv(file_path)\n CSV.parse(File.read(file_path), headers: true)\nend", "def import_csv(csv_file)\n data, header = parse_csv(csv_file)\n validate_header(header)\n return if @rollback\n process_data(data, header)\n end", "def import_from_csv(file_name)\r\n #implementation goes here\r\n csv_text = File.read(file_name)\r\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\r\n # #8 iterate over table rows, create hash for each, then convert to Entry using 'add_entry' method\r\n csv.each do |row|\r\n row_hash = row.to_hash\r\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\r\n end #end csv.each loop\r\n end", "def upload_csv\n datafile = params['csv-file']\n begin\n response = Request.post_request(URL_QUESTION, {\n questions: parse_json(datafile['tempfile'])\n })\n rescue\n redirect '/upload-csv'\n end\n @questions = []\n if response.success?\n data = Request.manage_response(response)\n data.each do |question|\n @questions << Question.new(question)\n end\n erb :table, layout: :session\n end\nend", "def load_students(filename = \"students.csv\")\n file = File.open(filename, \"r\")\n file.readlines.each do |line|\n name, cohort, hobby, country = line.chomp.split(\",\")\n add_student_to_array(name, cohort, hobby, country)\n end\n file.close\nend", "def loadCSVFile(filePath)\n data = []\n CSV.foreach(filePath, :headers => true) do |row|\n row = row.to_h\n row.each do |k, v|\n v = v.to_s\n row[k] = v\n end\n data << row\n end\n data\n end", "def load_report(path)\n plain_data = CSV.parse(File.read(path))\n # PP.pp plain_data, $stderr\n csv_data = []\n # do some debug logging of csv_data\n\n plain_data.each do |row|\n csv_data_row = {}\n row.each_with_index do |column,index|\n csv_data_row[@columns[index]] = column\n end\n if csv_data_row.has_key?('idx')\n csv_data.push csv_data_row\n end\n end\n csv_data\nend", "def generate_survey_data\n @survey_data = CSV.parse(@survey_file, headers: true, header_converters: :symbol).map(&:to_hash)\n end", "def prepare_data\n data = CSV.read('input.csv', { col_sep: SEPARATOR })\n\n CSV.open('output.csv','wb') do |csv|\n data.each do |row|\n csv << prepare_row(row)\n end\n end\n\n rescue Errno::ENOENT\n puts 'No valid input.csv file present'\n end", "def csv(section = 'main', q='google',date='ytd',geo='')\n trend_params = {\"graph\"=>\"all_csv\", \"sa\" => \"N\"}\n trend_params[\"q\"] = q\n trend_params[\"date\"] = date\n if !geo || geo != ''\n trend_params[\"geo\"] = geo\n end\n\n data = @client.get_content(URI.parse(@url_Export), trend_params)\n # empty to return all data\n if section == ''\n return CSV.parse(data)\n end\n # split data into sections\n segments = data.split(\"\\n\\n\\n\")\n if section == 'main'\n section = ['Week', 'Year', 'Day','Month']\n else\n section = [section]\n end\n\n for x in segments do\n if section.include? x.split(',')[0].strip\n maindata = CSV.parse(x)\n return maindata\n end\n end\n end", "def load_students(filename = \"students.csv\")\n file = File.open(filename, \"r\")\n file.readlines.each do |line|\n name, cohort, hobbies = line.strip.split(',')\n add_student({name: name, cohort: cohort.to_sym, hobbies: hobbies})\n end\n file.close\nend", "def read_problems_csv(book)\n if problems_csv_has_been_read then fatal_error(\"read_problems_csv appears to have been called more than once\") end\n file = find_problems_csv(book)\n n_good_lines = 0\n File.readlines(file).each { |line|\n if line=~/(.*),(.*),(.*),(.*),(.*)/ then\n n_good_lines = n_good_lines+1\n b,ch,num,label,soln = [$1,$2.to_i,$3,$4,$5.to_i] # note num is string, since \"number\" can be like \"g7\"\n split_problem_number_into_letter_and_number(num) # dies with fatal error if syntax is wrong\n if b==book && label!=\"deleted\" then\n if !($label_to_num[label].nil?) then \n fatal_error(\"label #{label} is multiply defined in file #{file} for book #{book}\")\n end\n $label_to_num[label] = [ch,num]\n if !($num_to_label[[ch,num]].nil?) then\n fatal_error(\"problem #{ch}-#{num} has two labels defined, #{$num_to_label[[ch,num]]} and #{label}, both for book #{book}\")\n end\n $num_to_label[[ch,num]] = label\n $has_solution[[ch,num]] = (soln==1)\n end\n end\n }\n if n_good_lines==0 then fatal_error(\"in read_problems_csv(#{book}), reading file #{file}, no good lines read\") end\nend", "def create_item_rows_from_csv \n item_rows = []\n CSV.foreach('./data/items.csv', headers: true, header_converters: :symbol) do |row|\n item_rows << row\n end \n return item_rows\n end", "def parse_csv(filename)\n @file=CSV.read(filename)\n # Read order of headers\n headers = @file.shift\n @file.each do |line|\n next if line.length==0 || (line.length==1 && line[0]==nil)\n # Read fields from line based on headers\n value=ReturnValue.new( line[headers.index('label')],\n line[headers.index('name') || headers.index('label')],\n line[headers.index('type')],\n line[headers.index('unit')],\n line[headers.index('per_unit')],\n line[headers.index('default')] )\n @values.push value\n end\n validate\n end", "def load_students(filename = \"students.csv\")\n # option 4. load the list from students.csv\n file = File.open(filename, \"r\")\n file.readlines.each do |line| # readlines\n name, cohort = line.chomp.split(\",\") # parallel assignment\n @students << { name: name, cohort: cohort.to_sym }\n end\n file.close\nend", "def initMetaDataFromCSV(csvfile)\n\t\tif not File.exist?(csvfile)\n\t\t\traise StandardError \"file not exist!\"\n\t\tend\n\t\tbasename = File.basename(csvfile, \".csv\")\n\t\tcase basename\n\t\t#处理角色名,用来随机用\n\t\twhen 'JiaoSeMing'\n\t\t\tinitPlayerNameMetaData(csvfile)\n\t\t#英雄配表\n\t\twhen 'WuJiang'\n\t\t\t@heroMetaMap = {}\n\t\t\tinitMetaData(csvfile,@heroMetaMap,\"generalID\")\n\t\t\t#自有兵法列表\n\t\t\t@selfBookList = []\n\t\t\[email protected]_value do |hero| \n\t\t\t\tselfBook = hero.gInitialWarcraft.to_i\n\t\t\t\tif selfBook > 0 and not @selfBookList.include?(selfBook)\n\t\t\t\t\t@selfBookList << selfBook\n\t\t\t\tend\n\t\t\tend #generalID \n\t\t#招募配表\n\t\twhen 'ZhaoMu'\n\t\t\t@recuriteMetaMap = {}\n\t\t\tinitMetaData(csvfile,@recuriteMetaMap,\"recruitName\")\n\t\t#情义(命运)\n\t\twhen 'MingYun'\n\t\t\t@fateMetaMap = {}\n\t\t\tinitMetaData(csvfile,@fateMetaMap,\"fateID\")\n\t\t#角色级别与经验值\n\t\twhen 'JiaoSeShengJiJingY'\n\t\t\t@playerLevelMetaMap = {}\n\t\t\tinitMetaData(csvfile, @playerLevelMetaMap ,\"characterLevel\")\n\t\t#英雄级别与经验值配表\n\t\twhen 'WuJiangDengJi'\n\t\t\t@heroLevelMetaMap = {}\n\t\t\tinitMetaData(csvfile, @heroLevelMetaMap ,\"levelGeneral\")\n\t\t#英雄进阶\n\t\twhen 'WuJiangJinJie'\n\t\t\t@heroAdancedLevelMetaMap = {}\n\t\t\tinitMetaData(csvfile, @heroAdancedLevelMetaMap ,\"advancedTime\")\n\t\t#装备-武器防具坐骑\n\t\twhen 'ZhuangBei'\n\t\t\t@equipmentMap = {}\n\t\t\tinitMetaData(csvfile, @equipmentMap ,\"equipmentID\")\n\t\t#兵法\n\t\twhen 'BingFa'\n\t\t\t@bookMap = {}\n\t\t\tinitMetaData(csvfile,@bookMap,\"bookID\")\n\t\t#宝物\n\t\twhen 'DaoJu'\t\n\t\t\t@propMap = {}\n\t\t\tinitMetaData(csvfile,@propMap,\"propID\")\n\t\twhen 'PeiYang'\n\t\t\tinitHeroBringupMetaData(csvfile)\n\t\t#VIP表\n\t\twhen 'Vip'\n\t\t\t@vipMap = {}\n\t\t\tinitMetaData(csvfile,@vipMap,\"vipLevel\")\n\t\t#强化表\n\t\twhen 'ZhuangBeiQiangHua'\n\t\t\t@strengthenMap = {}\n\t\t\tinitStrengthenMapMetaData(csvfile,@strengthenMap)\n\t\t#进阶表\n\t\twhen 'BingFaJinJie'\n\t\t\t@bookAdvancedMap = {}\n\t\t\tinitBookAdvancedMapMetaData(csvfile,@bookAdvancedMap)\n\t\t#兵法碎片\n\t\twhen 'BingFaSuiPian'\n\t\t\t@bookFragment = {}\n\t\t\tinitMetaData(csvfile,@bookFragment,\"fragmentID\")\n\t\t#flag , 游戏配置,标记 等表\n\t\twhen 'Flag'\n\t\t\t@flagMap = {}\n\t\t\tinitMetaData(csvfile,@flagMap,\"name\")\n\t\twhen 'ZhanYi'\n\t\t\tinitBattle(csvfile)\n\t\twhen 'NPC'\n\t\t\t@npcMetaMap = {}\n\t\t\tinitMetaData(csvfile, @npcMetaMap, \"npcID\")\n\t\twhen 'ChengZhangRenWu'\n\t\t\tinitTaskMetaData(csvfile)\n\t\telse\n\t\tend\n\tend", "def mark_csv_headers\n \"Username,Name,Tutorial,Task,ID,Student's Last Comment,Your Last Comment,Status,New Grade,New Comment\"\n end", "def new_qa(category_input_push)\n\n category = category_input_push\n link = \"#{category}.csv\"\n\n puts \"Please input the question\"\n print \"> \"\n question = $stdin.gets.chomp\n puts \"Please input the answer\"\n print \"> \"\n answer = $stdin.gets.chomp\n # skip past the headers by setting the headers to true\n CSV.open(link, 'a+') do |csv_file|\n # add a row to the csv file\n csv_file << [question, answer]\n end\n new_qa_opt\nend", "def load_and_train(csv_file_name, model_options)\n input_data = CSV.read(csv_file_name, headers: true)\n num_fields = input_data[0].length\n\n # last column is target\n # all other are features\n target = input_data.map{|a| a[num_fields-1]}\n features = input_data.map{|a| a.fields((0...num_fields-1))}\n\n return train(features, target, model_options)\nend", "def load\n CSV.foreach(@csv_file, headers: :first_row, header_converters: :symbol) do |row|\n @data << Employee.new(row)\n end\n end", "def load_students(students)\n # open file for read\n file = File.open(\"students.csv\", \"a+\")\n # iterate over lines and read student name and cohort\n file.readlines.each do |line|\n name, cohort = line.chomp.split(\",\")\n students << {name: name, cohort: cohort.to_sym}\n end\n file.close\nend", "def load_students (filename = \"students.csv\")\n #open the filename or students.csv as default\n File.open(filename, \"r\") do |file|\n #iterate over each line in the file\n file.readlines.each do |line|\n #split at the comma and parallel assign name to the first value, cohort to the second\n name, cohort = line.chomp.split(\",\")\n #create a hash and push to the @students array using method\n @students << {name: name, cohort: cohort}\n end\n end\nend", "def initialize(csv_file_path)\n # take recipe from csv file\n @csv_file_path = csv_file_path\n @recipes = []\n parse\n end", "def csv_parsed\n transform_to_hash(@csv_array, @header)\n end", "def parse_csv(file_path)\n record_list = []\n header = []\n is_header = true\n \n CSV.foreach(file_path) do |row|\n if (is_header)\n\theader = row\n\tis_header = false\n else\n\trecord = Record.new\n\trecord.create(header, row)\n\trecord_list.push(record)\n end\n end\n return record_list\n end", "def parse_csv(csv_string)\n csv_data = FasterCSV.parse(csv_string)\n header = csv_data.shift\n [csv_data.map{|row| Hash[*header.zip(row).flatten] }, header]\n end", "def parse_headers!(csv_file)\n csv = CSV.open(csv_file, :headers => true)\n csv.gets\n csv.headers\n end", "def parse_csv\n raise InvalidStateError, \"#{state.inspect} is not a valid Data state for method 'to_csv'\" unless state == :raw\n\n file_options = @options[:file_options]\n parse_options = @options[:parse_options]\n\n begin\n csv = CSVWrapper.parse(@content, parse_options)\n csv = csv.drop(1) if file_options[:has_headers] == true # drop the first row if it is a header\n rescue => e\n Logger.new(@options).print(@path, :parse, e)\n end\n\n @state = :parsed\n Data.new(@path, csv, @state, @options)\n end", "def parse_csv(csv, &row_block)\n CSV.parse(Encoding.to_utf_8(File.read(\"#{install_path}/Edit Scripts/#{csv}.csv\", mode: 'rb'))).each(&row_block)\n end", "def from_csv path, opts={}\n daru_options, opts = from_csv_prepare_opts opts\n # Preprocess headers for detecting and correcting repetition in\n # case the :headers option is not specified.\n hsh =\n if opts[:headers]\n from_csv_hash_with_headers(path, opts)\n else\n from_csv_hash(path, opts)\n .tap { |hash| daru_options[:order] = hash.keys }\n end\n Daru::DataFrame.new(hsh,daru_options)\n end", "def load_csv\n CSV.foreach(@file_path) do |row|\n # Our CSV stores strings only - so we must initialize all our recipes\n recipe = Recipe.new(row[0],row[1])\n # We push them into the cookbook recipes array\n @recipes << recipe\n end\n end", "def import_from_csv(file)\n entries = Keybox::Convert::CSV.from_file(file)\n entries.each do |entry|\n @db << entry\n end\n hsay \"Imported #{entries.size} records from #{file}.\", :information\n end", "def load_students(filename = \"students.csv\")\n file = File.open(filename, \"r\")\n file.readlines.each do |line|\n name, cohort = line.chomp.split(',') \n @students << {name: name, cohort: cohort.to_sym}\n end\n file.close\nend", "def load_students(filename = \"students.csv\")\n\n File.open(\"students.csv\",\"r\") do |file|\n stored_cohort = file.readline.chomp\n set_default_cohort(stored_cohort.to_sym)\n file.readlines.each do |line|\n name, cohort = line.chomp.split(\",\")\n add_student(name, cohort.to_sym)\n end\n end\n @saved = @students.count\n #file.close\n clear_terminal\n puts \"#{@students.count} Students loaded from #{filename}\"\n pause_program\nend", "def import(filename = 'yhd.csv')\n # Load CSV rows\n puts 'Attempting to load CSV...'\n data = CsvLoader.load_csv filename\n\n # Error if no data\n unless data\n puts 'ERROR: unable to load data from CSV. Terminating.'\n return\n end\n\n # Extract headers (first row)\n headers = data[0]\n\n puts 'Normalising header names...'\n norm_headers = normalise_headers headers\n\n # Define data rows as the rest of the CSV\n row_range = 1..data.size\n\n # Get data from each row (process it line at a time)\n puts 'Loading data...'\n load_data_from_rows(norm_headers, data[row_range])\n\n puts 'Creating relationships between definitions...'\n create_definition_associations\n\n puts 'Done!'\n\n @error_reporter.print\n end", "def load_students(filename = \"students.csv\")\n file = File.open(filename, \"r\")\n file.readlines.each do |line|\n name, cohort = line.chomp.split(\",\")\n @students << {name: name, cohort: cohort.to_sym}\n end\n file.close\nend", "def load_csv (csv_file)\n\tret = []\n\tFile.open(csv_file, \"r\") do |f|\n\t\tf.each_line do |line|\n\t\t\t#puts line\n\t\t\tret << line.split(';')\n\t\tend\n\tend\n\treturn ret\nend", "def assign_csv_report\n unless @csv.nil?\n csv_header = ['Time', 'Req/s', 'Avg. resp. (ms)']\n @csvexport = Ralphttp::CsvExport.new(csv_header)\n end\n end", "def parseCSV(csvfile)\n begin\n if csvfile != nil && csvfile != \"\"\n file_ext = File.extname(csvfile.original_filename)\n if file_ext == \".csv\"\n content = File.read(csvfile.tempfile)\n arr_of_arrs = CSV.parse(content)\n return arr_of_arrs, 0\n else\n return nil, 4\n end\n else\n return nil, 1\n end\n rescue ArgumentError\n return nil, 2\n rescue CSV::MalformedCSVError\n return nil, 3\n end\n end", "def parseCSV(csvfile)\n begin\n if csvfile != nil\n file_ext = File.extname(csvfile.original_filename)\n if file_ext == \".csv\"\n content = File.read(csvfile.tempfile)\n arr_of_arrs = CSV.parse(content)\n return arr_of_arrs, 0\n else\n return nil, 4\n end\n else\n return nil, 1\n end\n rescue ArgumentError\n return nil, 2\n rescue CSV::MalformedCSVError\n return nil, 3\n end\n end", "def load_sites_from_csv(csv_path)\n CSV.foreach(csv_path, headers: true, encoding: 'BOM|UTF-8:UTF-8') do |row|\n trials = Trial.where(nct_id: row[0])\n trials.each do |trial|\n site = Site.create(row.to_hash.except('nct_id'))\n trial.sites << site\n end\n end\nend", "def import_from_csv(file_name)\n csv_text = File.read(file_name)\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\n # #8 iterate over the CSV::Table rows then create a hash for each row, convert each row_hash\n #to an Entry by using the add_entry method\n csv.each do |row|\n row_hash = row.to_hash\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\n end\n end", "def csv_row\n #empty by default\n []\n end", "def csv_row\n #empty by default\n []\n end", "def load_file full_name\n file = FasterCSV.open( full_name , { :col_sep => \"\\t\"} ) \n @header = file.shift\n @data = file.readlines\n #puts @header\n @header.each do |col|\n #puts \"col=#{col}= mapped to =#{@mapping[col]}=\"\n end\n index = 0\n while index < @data.length\n row = @data[index]\n #puts \"row is \" + row.join(\"--\")\n @mapping.each do |key,val|\n #puts \"Row:#{val} at #{@mapping.index(val)} is --#{@header.index(@mapping.index(val))}--value---\"\n #puts \"--#{at_in(val,row)}--\" if @header.index(@mapping.index(val))\n end\n prod = get_product(row)\n set_attributes_and_image( prod , row )\n set_taxon(prod , row)\n #puts \"saving -\" + prod.description + \"- at \" + at_in(:price,row) #if at_in(:price,row) == \"0\"\n prod.save!\n throw \"no master for #{prod.name}\" if prod.master == nil \n# pr = get_product( row )\n# puts \"TAXONs #{pr.taxons}\"\n \n puts \"saved -\" + prod.description + \"- at \" + at_in(:price,row) #if at_in(:price,row) == \"0\"\n index = slurp_variants(prod , index + 1) #read variants if there are, returning the last read line\n end\n\n end", "def load(contents, opts={})\n table = infer_csv_contents(contents, opts)\n return nil unless contents\n table.each do |row|\n self.add(*row)\n end\n end", "def from_csv path, opts={}\n daru_options, opts = from_csv_prepare_opts opts\n\n # Preprocess headers for detecting and correcting repetition in\n # case the :headers option is not specified.\n hsh =\n if opts[:headers]\n from_csv_hash_with_headers(path, opts)\n else\n from_csv_hash(path, opts)\n .tap { |hash| daru_options[:order] = hash.keys }\n end\n\n Daru::DataFrame.new(hsh,daru_options)\n end", "def process(csv_data)\n unless csv_data.headers == SOA_CSV_STRUCTURE\n LOGGER.error(\"Structure of #{csv_filename} does not match:\\nExpected: #{SOA_CSV_STRUCTURE.inspect}.\\nActual: #{csv_data.headers.inspect}.\\nContent: #{csv_file}\")\n abort('ABORTED!')\n end\n\n index = 0\n csv_data.delete_if do |row|\n index += 1\n retval = row[:buchungstag].nil? || row[:wertstellung].nil? || row[:umsatzart].nil?\n LOGGER.info(\"- Record nbr. #{index} not processed due to empty field(s): #{row.inspect}\") if retval\n retval\n end\n\n csv_data.sort_by { |row| DateTime.parse(row[:buchungstag]) }\n end", "def datat_read\n \n #Read in the csv file\n @@datat_array = CSV.read(@@datat_path_specific)\n \n #Delete the row which contains the database title.\n @@datat_array.delete_at(0)\n \n ######################################\n #puts @@datat_array[2]\n #Verify the conversion has taken place\n #puts @database + \" CSV file converted\"\n ######################################\n \n end", "def load_data(row, columns, headers)\n #// HEADER EXCLUSION LIST:\n #// ----------------------\n exclusion_list = [\n 'Option_Types'\n ]\n attr_hash = {}\n exception_hash = {}\n sanitized_headers_array = []\n header_return_array = []\n \n for i in columns[0]..columns[1]\n exclusion_list.each do |exclusion|\n if headers[i] =~ /#{exclusion}/i\n exception_hash[exclusion] = row[i]\n elsif headers[i] == exclusion\n exception_hash[exclusion] = row[i]\n else\n attr_hash[headers[i]] = row[i] unless row[i].nil?\n sanitized_headers_array << headers[i]\n end\n end\n \n end\n header_return_array[0] = attr_hash\n header_return_array[1] = exception_hash\n header_return_array[2] = sanitized_headers_array\n return header_return_array\n end", "def from_csv(filename)\n @successes = []\n @problems = []\n @unfound_vita_partners = []\n\n @headers = CSV.foreach(filename).first\n return unless headers_aligned? == true\n\n data = CSV.read(filename, headers: true)\n\n state_routing_pairs = generate_state_routing_pairs(data)\n\n create_records_for_state_routing_pairs(state_routing_pairs)\n\n print_script_messages\n true\n end", "def generate_all_csv_answers\n generate_csv_answers(csv_answers_values)\n end" ]
[ "0.6545457", "0.64624006", "0.6358659", "0.6289967", "0.6254917", "0.6253156", "0.62218475", "0.6173473", "0.6159406", "0.6158068", "0.6135107", "0.6132076", "0.6083586", "0.60813946", "0.60739803", "0.6053666", "0.6043436", "0.6039961", "0.6022485", "0.6021724", "0.60078704", "0.60071295", "0.59867364", "0.59795606", "0.5962796", "0.5959039", "0.59233576", "0.5919271", "0.5912049", "0.59097445", "0.590884", "0.5901652", "0.58986115", "0.58976567", "0.58940953", "0.5889218", "0.5887962", "0.5885545", "0.5885203", "0.58826035", "0.5826932", "0.5826244", "0.5824104", "0.5824104", "0.5820007", "0.5812628", "0.5804879", "0.5792447", "0.5789955", "0.578765", "0.57831943", "0.5781219", "0.57686454", "0.57665783", "0.57601565", "0.5745306", "0.5743437", "0.57337797", "0.5724541", "0.57227105", "0.5707364", "0.5706087", "0.57043344", "0.57038283", "0.5701175", "0.56940204", "0.5691053", "0.56891507", "0.567707", "0.5676426", "0.5665393", "0.56508344", "0.56489885", "0.5647293", "0.5621754", "0.56203234", "0.56182796", "0.5612084", "0.5609932", "0.56088793", "0.56018007", "0.5599097", "0.5597778", "0.55947006", "0.55880785", "0.55875224", "0.55868936", "0.55847013", "0.5583931", "0.5579184", "0.55770046", "0.5572701", "0.5572701", "0.5572255", "0.55700815", "0.557004", "0.5562434", "0.55618685", "0.55604494", "0.555981", "0.5559762" ]
0.0
-1
def get_item_id(index) return nil if index.blank? index = index.to_i 1 self.issue["items"][index]["id"] end
def get_item_id(index) return nil if index.blank? raise "您填写的内容不像是个数字啊(#{index})!" unless only_num?(index) index = index.to_i - 1 raise "您确定有这个选项吗(#{index})?" unless (0..(self.issue["items"].count)).include? index self.issue["items"][index]["id"] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def item_id\n return @item_id\n end", "def item_id\n return @item_id\n end", "def item_id\n return @item_id\n end", "def item_id\n id\n end", "def item_id\n params['item_number'] || params['custom']\n end", "def item_id\n params['item_number'] || params['custom']\n end", "def item_id\n\tparams['item_number'] || params['custom']\n end", "def item_lookup_id\n item.blank? ? nil : item.item_id\n end", "def item_lookup_id\n item.blank? ? nil : item.item_id\n end", "def item_lookup_id\n item.blank? ? nil : item.item_id\n end", "def item_entry_id\n return @item_entry_id\n end", "def item_entry_id\n return @item_entry_id\n end", "def get_item(index)\n # TODO\n end", "def item_id\n item_hash.deep_find(:item_id)\n end", "def item_number(item)\n return nil if item.nil?\n container = item_container(item.class)\n container ? container[item.id] || 0 : 0\n end", "def item_id=(value)\n @item_id = value\n end", "def item_id=(value)\n @item_id = value\n end", "def item_id=(value)\n @item_id = value\n end", "def get_item(index)\n @get_items[index]\n end", "def entity(index)\n i = get_field_index_by_external_id(index,@fields[:entity])\n fields(index, i)['item_id'].to_i unless i.nil?\n end", "def item_number(item_id)\r\n # ハッシュに個数データがあればその数値を、なければ 0 を返す\r\n return @items.include?(item_id) ? @items[item_id] : 0\r\n end", "def item_number\n self[:item_number]\n end", "def live_lookup_item_id\n id || folio_item&.id || barcode\n end", "def item_id\r\n params['Ref'] \r\n end", "def record_id\n attributes['item_id']\n end", "def invoice_num\n item_id\n end", "def id\n raise \"Item.id not set\" unless @id\n $stderr.puts \"Item.id >#{@id}<\"\n @id\n end", "def invoice_num\n item_id\n end", "def line_item_id\n @row[\"売上詳細ID\"].to_s\n end", "def id(index)\n i = get_field_index_by_external_id(index,@fields[:id])\n fields(index, i).to_i unless i.nil?\n end", "def id(index)\n i = get_field_index_by_external_id(index,@fields[:id])\n fields(index, i).to_i unless i.nil?\n end", "def item(index = self.index)\n @data[index]\n end", "def item(index)\n each_with_index { |item, ix| return item if index == ix } && nil\n end", "def get_item(index)\r\n @list[index]\r\n end", "def storage_item_number(item)\n container = storage_item_container(item.class)\n container ? container[item.id] || 0 : 0\n end", "def workspace_id(index)\n i = get_field_index_by_external_id(index,@fields[:workspace])\n fields(index, i)['item_id'].to_i unless i.nil?\n end", "def item_id(input_name:, op:)\n fv = op.input(input_name)\n fv.part.try(:id) || fv.item.id\n end", "def get_id(ind)\n\t\treturn @tile_Array[ind].return_id\n\tend", "def app_item_id\n read_integer('app_item_id')\n end", "def item_number(selected_item = item)\n $game_party.item_number(selected_item)\n end", "def item_number(selected_item = item)\n $game_party.item_number(selected_item)\n end", "def next_id(items)\n max_id = items.map { |item| item[:id] }.max || 0\n max_id + 1\nend", "def test_can_return_id_of_item\n assert_equal 263515158, item.id\n end", "def item(index = self.index)\n return @data[index]\n end", "def item_id\n params['cs1']\n end", "def item; @data && index >= 0 ? @data[index] : nil; end", "def post_item_id(doc)\n href = doc.search('.subtext > a:nth-child(3)').map { |link| link['href'] }\n href[0].match(/\\d+/)\n end", "def get_item(index_num)\r\n @arr.fetch(index_num)\r\n end", "def issue_id\n return @issue_id if defined?(@issue_id)\n\n @issue_id = nil\n\n @issue_id = issue.id if issue\n end", "def item_at(index)\n @todos[index]\n end", "def get_item(list_item_idx)\n @list[list_item_idx]\n end", "def [](index)\n return @items[index]\n end", "def get_id_of_first_result\n if @items.size > 0\n @items[0].each_element_with_attribute('name', 'id' ) { |element| return element.text() }\n end\n end", "def get_item(index_number)\n @chores[index_number]\n end", "def item\n return @data[@index] if @index >= 0\n @data[@old_index]\n end", "def item_number(item)\n case item\n when RPG::Item\n number = @items[item.id]\n when RPG::Weapon\n number = @weapons[item.id]\n when RPG::Armor\n number = @armors[item.id]\n end\n return number == nil ? 0 : number\n end", "def item_by_id(id)\n @items[id]\n end", "def item; @data[@index]; end", "def item\n $data_items[1]\n end", "def item_number(item)\n article = article_from_item(item)\n article ? article.quantity : 0\n end", "def get(index)\n @list[index] || -1\n end", "def item_id\n unescape params['x_invoice_num']\n end", "def item index\n @items[index-1]\n end", "def id\n @data['id'].to_i\n end", "def id\n @data['id'].to_i\n end", "def item_key(item_param)\n Ticket.items[item_param]\n end", "def [](index)\n @items[index]\n end", "def [](index)\n @items[index]\n end", "def item_id\n unescape params['x_invoice_num']\n end", "def trackable_id\n params['id'] || first_item_on_page_id\n end", "def [](idx)\n items[idx]\n end", "def add_id\n @item.key = @bib.id\n end", "def get_item_id\n @doc.css('.subtext > .age > a:first-child').map{|ele| ele['href']}.map {|x| x[/\\d+/]}.join\n end", "def item=(i)\n\t\t@item = i\n\tend", "def ids\n (1..get_item_count).map do |index|\n get_item_identifier index\n end\n end", "def item\n @data[@index];\n end", "def parse_url_for_item_id\n return nil if not self.item_id \n if self.item_id.match(/\\D+/).to_s.length != 0\n self.item_id.match(/item=\\d+\\D/).to_s.gsub!(/\\D+/, \"\") ||\n self.item_id.match(/-\\/\\d+/).to_s.gsub!(/\\D+/, \"\")\n else\n return self.item_id\n end\n end", "def item; @data[self.index]; end", "def app_item_id\n read('app_item_id')\n end", "def area(index)\n i = get_field_index_by_external_id(index,@fields[:area])\n fields(index, i)['item_id'].to_i unless i.nil?\n end", "def item_identity(item)\n # noinspection RubyMismatchedReturnType\n [self, self.class].find do |obj|\n %i[sid_value id_value].find do |meth|\n result = obj.try(meth, item) and return result\n end\n end\n end", "def item(id)\n Item.find(id)\n end", "def [](id)\n @items[id]\n end", "def item_id\n params['m_payment_id']\n end", "def item_id\n params['USER1']\n end", "def page_index(item_index) \n return -1 if !(item_index < item_count) || item_index < 0\n @collection[item_index]\n end", "def manifest_item_id(item)\n result = error = nil\n case item\n when ManifestItem then result = item.id\n when Hash then result = item[:manifest_item_id] || item[:id]\n when Integer then result = item.to_s\n when String then result = item\n else error = \"invalid item #{item.inspect}\"\n end\n result&.to_s&.presence || { error: (error || \"no ID for #{item.inspect}\") }\n end", "def web_order_line_item_id\n read('web_order_line_item_id')\n end", "def item_id\n params['vendor_order_id'] || params['merchant_order_id']\n end", "def submission_id(item)\n # noinspection RubyMismatchedReturnType\n case item\n when Upload, AwsS3::Message::SubmissionRequest\n item.submission_id\n when Hash\n item[:submission_id] || item['submission_id']\n when String\n item\n else\n Log.warn { \"#{__method__}: unexpected: #{item.inspect}\" }\n end\n end", "def item\n @item ||= item_class.where(id: item_id).first if item_class\n end", "def set_intitem\n @intitem = Intitem.find(params[:id])\n end", "def id\n _id rescue nil\n end", "def on_get_item_attr(i)\n nil\n end", "def id3(index)\n i = get_field_index_by_external_id(index,@fields[:id_3])\n fields(index, i).to_i unless i.nil?\n end", "def get_id(what, item)\n case what.keys[0]\n when :study\n /^study_(?<s_id>\\d+)_manage_link$/.match(item['id'])[:s_id]\n when :study_group\n /^study_group_(?<sg_id>\\d+)_manage_link$/.match(item['id'])[:sg_id]\n when :site\n raise \"don't know how to search for site id\"\n when :team\n raise \"don't know how to search for team id\"\n else\n nil\n end\n end", "def item id\n ljcall :getevents, :selecttype => \"one\",\n :lastsync => \"1970-01-01 00:00:00\",\n :itemid => id\n end", "def current_event_id\n return @data[@index][:id]\n end", "def selected_item\n return (self.index < 0 ? nil : @data[self.index])\n end", "def selected_item\n return (self.index < 0 ? nil : @data[self.index])\n end" ]
[ "0.74608386", "0.74608386", "0.74608386", "0.7437478", "0.74029404", "0.74029404", "0.7320078", "0.7313053", "0.7313053", "0.7312211", "0.7140663", "0.7140663", "0.7100038", "0.7046582", "0.6988008", "0.6892233", "0.6892233", "0.6892233", "0.68241984", "0.6823998", "0.6808094", "0.68050086", "0.67851895", "0.67258954", "0.66736126", "0.66328", "0.6623734", "0.6523391", "0.65043646", "0.64836496", "0.64836496", "0.64130116", "0.63991636", "0.6351325", "0.6332657", "0.6330071", "0.6309977", "0.63053745", "0.6297761", "0.6278871", "0.6278871", "0.6265398", "0.6248197", "0.6240886", "0.6234747", "0.62226796", "0.6210947", "0.6210532", "0.619665", "0.61939687", "0.6189985", "0.6186829", "0.6174073", "0.61729705", "0.6155467", "0.6134154", "0.6127733", "0.61127424", "0.61099327", "0.609862", "0.6097883", "0.60765004", "0.607344", "0.6067082", "0.6067082", "0.60537565", "0.6036007", "0.6036007", "0.60297084", "0.6026842", "0.60054135", "0.6001357", "0.5981983", "0.59761196", "0.59749293", "0.596415", "0.59583056", "0.595721", "0.594665", "0.5943921", "0.5939529", "0.59260076", "0.5919918", "0.5909851", "0.59049356", "0.58846796", "0.58782715", "0.5871624", "0.5869739", "0.58665687", "0.58624464", "0.5861456", "0.5855577", "0.58503073", "0.5846988", "0.58422923", "0.5815136", "0.5810065", "0.58088136", "0.58088136" ]
0.87208825
0
POST /auth/ Authenticate, generate token and add header
def authenticate(username = nil, password = nil, options = {}, &block) if username.is_a?(Hash) or password.is_a?(Hash) options = username.is_a?(Hash) ? username : password end options["username"] = username if username and !username.is_a?Hash options["password"] = password if password and !password.is_a?Hash options = set_options(options, &block) #TODO: Raise error if doesn't find username and password key in options @response = post('auth', options) if @response.has_key?("success") and @response['success'] add_header("X-Auth-Token", @response['token']) end @response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def auth\n build_response(\"token\") do\n connection.post do |req|\n req.headers.delete(\"Authorization\")\n req.url \"auth/\"\n req.body = { username: username, password: password }.to_json\n end\n end\n end", "def create_set_and_add_token\n token = SecureRandom.urlsafe_base64\n @user.token = token\n response.headers['X-AUTH-TOKEN'] = token\n end", "def authenticate_api_token\n if request.headers[\"Authorization\"].present?\n \n auth_header = request.headers['Authorization'].split(' ').last\n \n #try to get the data from jwt token\n @payload = decode auth_header\n \n #couldnt get data for whatever reason\n if !@payload\n render json: { error: \"Problem med autentiseringssträngen. Försök att logga in igen.\" }, status: :bad_request \n #success!\n else\n @payload\n end\n #no token was sent with header \n else\n render json: { error: \"En autentiseringssträng krävs.\"}, status: :forbidden # The header isn´t present\n end\n end", "def token(auth_code = T.unsafe(nil), headers = T.unsafe(nil)); end", "def authenticate\n response = post('login')\n @access_token = response['access-token']\n @client_id = response['client-id']\n end", "def retrieve_auth_token\n http = Net::HTTP.new(auth_endpoint.host, auth_endpoint.port)\n\n request = Net::HTTP::Post.new(auth_endpoint.request_uri)\n\n request.basic_auth(\n TodoableApi.configuration.username,\n TodoableApi.configuration.password\n )\n\n handle_auth_response(http.request(request))\n end", "def api_authenticate\n if request.headers[\"Authorization\"].present?\n auth_header = request.headers['Authorization'].split(' ').last\n @token_payload = decodeJWT auth_header.strip\n if !@token_payload\n render json: { error: 'The provided token wasn´t correct' }, status: :bad_request \n end\n else\n render json: { error: 'Need to include the Authorization header' }, status: :forbidden # The header isn´t present\n end\n end", "def api_auth\n creator = Creator.find_by(username: request.headers[:username])\n if creator && creator.authenticate(request.headers[:password])\n render json: { auth_token: encodeJWT(creator) }\n else\n render json: { error: 'Invalid username or password' }, status: :unauthorized\n end\n end", "def authenticate\n auth_token =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n # kindly refactor and add more keys to the response object when needed\n response = { \n status: Message.success,\n data: {\n token: auth_token\n } \n }\n json_response(response, 200)\n end", "def auth_header\n { :token => @token, :seq => @seqid }\n end", "def api_authenticate\n if request.headers[\"Authorization\"].present?\n # Take the last part in The header (ignore Bearer)\n auth_header = request.headers['Authorization'].split(' ').last\n # Are we feeling alright!?\n @token_payload = decodeJWT auth_header.strip\n if !@token_payload\n render json: { error: 'The provided token wasn´t correct' }, status: :bad_request\n end\n else\n render json: { error: 'Need to include the Authorization header' }, status: :forbidden # The header isn´t present\n end\n end", "def token_auth(*args, &block); end", "def authenticate!\n error!(\"401 Unauthorized\", 401) unless check_auth_token \n end", "def login\n response = @session.create\n @auth_token = response[\"token\"]\n @rest.default_headers = { 'Content-Type' => 'application/json', 'Auth-Token' => @auth_token }\n response\n end", "def api_auth\n # output the APIkey from the header\n # puts request.headers[\"X-APIkey\"];\n creator = Creator.find_by(creator: request.headers[:creator])\n if creator && creator.authenticate(request.headers[:password])\n render json: { auth_token: encodeJWT(creator), id: creator.id}\n else\n render json: { error: 'Invalid username or password' }, status: :unauthorized\n end\n end", "def request_token\n @token = current_client_application.create_request_token\n if @token\n render :text => @token.to_query\n else\n render :nothing => true, :status => 401\n end\n end", "def token\n if request.headers[\"Authorization\"].present?\n if !login_from_authorization(request.headers['Authorization'].split(\" \")[1])\n response.set_header('WWW-Authenticate', \"Basic realm=\\\"red\\\"\")\n render json: {\"errors\":[{\"code\":\"UNAUTHORIZED\"}]} , status: 401\n return\n end\n else\n render json: {}, status: 401\n return\n end\n\n token = Portus::JwtToken.new(params[:account], params[:service], authorize_scopes)\n logger.tagged(\"jwt_token\", \"claim\") { logger.debug token.claim }\n render json: token.encoded_hash\n end", "def request_token\n username = @credentials['username']\n password = @credentials['password']\n # app_name = @credentials['app_name']\n app_name = @credentials['app_name']\n vendor_name = @credentials['vendor_name']\n bus_num = @credentials['bus_num']\n scope = @credentials['scope']\n\n payload_hash = {\n 'grant_type' => 'password',\n 'username' => username,\n 'password' => password,\n 'scope' => scope\n }\n\n # The user name for inContact's API takes the form\n # app_api_name = \"#{app_name}\" + \"@\" + \"#{vendor_name}\" + \":\" + \"#{bus_num}\"\n api_app_name = \"#{app_name}\" + \"@\" + \"#{vendor_name}\"\n\n puts \"Authorizing... \\n\"\n\n # Specify token URL.\n url = URI('https://api.incontact.com/InContactAuthorizationServer/Token')\n # url = URI('https://api-c71.nice-incontact.com/InContactAuthorizationServer/Token')\n\n # Create connection object\n connection = Net::HTTP.new(url.host, url.port)\n # At *work*:\n # connection = Net::HTTP.new(url.host, url.port, 'asqproxy.vzbi.com', 80)\n # For *Fiddler*\n # connection = Net::HTTP.new(url.host, url.port, '127.0.0.1', 8888)\n\n connection.use_ssl = true\n # Uncomment the following line to tell Ruby to ignore invalid security certs.\n # connection.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n # Create post object\n post = Net::HTTP::Post.new(url)\n\n # OAuth 2 token requests are usually the 'user' + 'pass' base64 encoded\n post.basic_auth(api_app_name, bus_num)\n\n # get the POST post _fileheaders\n # post['Content-Type'] = 'audio/flac'\n post['Content-Type'] = 'application/json; charset=UTF-8'\n post['Accept'] = 'application/json'\n # \"Accept-Encoding\" => \"gzip, deflate, sdch, br\",\n post['Accept-Encoding'] = 'none'\n post['Connection'] = 'keep-alive'\n\n # Prepare the HTTP message body to be posted with the request.\n # Convert the payload_hash hash to a json string.\n payload = payload_hash.to_json\n # It will be the message body (payload) of the HTTP post.\n post.body = payload\n\n # Make the HTTP post request and store the response.\n # The 'begin' & 'rescue' is an aborted attempt to put\n # error/exception handling around the http post\n # *begin*\n # *rescue* StandardError\n # *end*\n response = connection.request(post)\n\n # http_status_code = response.code.to_i\n http_status_code = response.code.strip\n if http_status_code.chr != '2'\n # Show me http status code\n puts \"/n http_status_code: #{http_status_code}\"\n end\n\n if response.is_a?(Net::HTTPSuccess)\n puts \"response is a Net::HTTPSuccess object\"\n # if response is OK then parese it to a Ruby data structure\n access_token_hash = JSON.parse(response.body)\n # access_token = access_token_hash['access_token']\n end\n\n access_token_hash\n end", "def token\n request.headers['Authorization']\n end", "def request_token\n @token=current_client_application.create_request_token\n if @token\n render :text=>@token.to_query\n else\n render :nothing => true, :status => 401\n end\n end", "def authenticate_token\n render json: {message: \"Unauthorized\"}, status: 401 unless decode_token(bearer_token)\n end", "def auth_header # gets the authorization header from the request\n # { Authorization: 'Bearer <token>' }\n request.headers['Authorization']\n end", "def token\n request.headers[\"Authorization\"]\n end", "def auth(key)\n\t\t#TODO\n\t\t#return response\n\t\tstatus 201\n\tend", "def create\n self.resource = warden.authenticate!(scope: :user)\n token = Tiddle.create_and_return_token(resource, request)\n render json: { authentication_token: token }\n end", "def authenticate!\n if !authenticated?\n response = request_token\n\n @token = response[\"token\"]\n @expires_at = DateTime.parse(response[\"expires_at\"])\n end\n\n [@token, @expires_at]\n end", "def authenticate(uri)\n request = Net::HTTP::Get.new(uri)\n request['Accept'] = 'application/json'\n request['Authorization'] = \"Bearer #{@session_token}\"\n request\n end", "def authenticate_request\n auth_header_token = request.headers[\"Authorization\"]\n @current_user = AuthorizeApiRequest.new(auth_header_token).call\n render json: { error: \"Not Authorized\" }, status: 401 unless @current_user\n end", "def authorise\n #FIRST SINGLE USE TOKEN WILL BE RECEIVED HERE..\n token = params[:token]\n #PREPAIRING FOR SECOND REQUEST WITH AUTH TOKEN IN HEADER.. WHICH WILL BE EXCHANED FOR PERMANENT AUTH TOKEN.\n uri = URI.parse(\"https://www.google.com\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n path = '/accounts/AuthSubSessionToken'\n headers = {'Authorization'=>\"AuthSub token=#{token}\"}\n\n #GET REQUEST ON URI WITH SPECIFIED PATH...\n resp, data = http.get(path, headers)\n #SPLIT OUT TOKEN FROM RESPONSE DATA.\n if resp.code == \"200\"\n token = ''\n data.split.each do |str|\n if not (str =~ /Token=/).nil?\n token = str.gsub(/Token=/, '')\n end\n end \n return redirect_to(:action => 'import', :token => token)\n else\n redirect_to root_url , :notice => \"fail\"\n end\n end", "def token\n\n authenticate_with_http_basic do |email, password|\n user = User.find_by(email: email)\n if user && user.authenticate(password) \n render json: { token: user.api_token }\n else\n render json: { error: 'Incorrect credentials' }, status: 401\n end\n\n end\n end", "def auth_token\n\t\trequest.headers['X-AUTH-TOKEN']\n\tend", "def authenticate_with_token\n # get the token from the header\n # get the token from the post body\n # get the token from json post\n \n token = request.headers[\"HTTP_AUTHORIZATION\"]\n \n if (!token)\n if (not_protected self.controller_name, self.action_name)\n return nil\n end\n\n redirect_to controller: 'application', action: 'index' \n end\n\n #@user = get_user_by_token(token)\n end", "def new\n response.headers['WWW-Authenticate'] = Rack::OpenID.build_header(\n :identifier => \"https://www.google.com/accounts/o8/id\",\n :required => [\"http://axschema.org/contact/email\",\n \"http://axschema.org/namePerson/first\",\n \"http://axschema.org/namePerson/last\"],\n :return_to => session_url,\n :method => 'POST')\n head 401\n end", "def auth_token\n @auth_token ||= request.headers.fetch('Authorization', '').split(' ').last\n end", "def auth\n { \"Authorization\" => \"Bearer #{auth_token}\" }\n end", "def http_auth_token\n\n @http_auth_token ||= if request.headers.present?\n request.headers[\"HTTP_AUTH_TOKEN\"]\n end\n end", "def auth_token\n @auth_token ||= ActionController::HttpAuthentication::Token.token_and_options(request)\n end", "def http_auth_token\n @http_auth_token ||= if request.headers['Authorization'].present?\n request.headers['Authorization'].split(' ').last\n end\n end", "def get_token\n request.headers[\"Authorization\"]\n end", "def post(opts = {})\n with_monitoring do\n connection.post(opts[:path]) do |req|\n prefix = opts[:access_token] ? 'Bearer' : 'Basic'\n suffix = opts[:access_token] || opts[:claims_token]\n req.headers = headers.merge('Authorization' => \"#{prefix} #{suffix}\")\n end\n end\n end", "def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n\n if auth_token\n authenticate_with_auth_token auth_token\n # else\n # authentication_error\n end\n end", "def api_token\n if @token.nil?\n raise ArgumentError, 'username is missing' if username.blank?\n raise ArgumentError, 'password is missing' if password.blank?\n response = connection.post do |req|\n req.url '/Authentication/V2.0'\n req.headers['x-dnb-user'] = username\n req.headers['x-dnb-pwd'] = password\n end\n @token = response.headers['Authorization']\n end\n @token\n end", "def set_auth_header(token)\n\t\t\tActiveResource::Base.headers['Authorization'] = \"Bearer #{token}\"\n\t\t\tnil\n\t\tend", "def set_header(token)\n response.headers['Authorization'] = \"Bearer #{token.to_jwt}\"\n end", "def http_auth_token\n @http_auth_token ||= if request.headers['Authorization'].present?\n request.headers['Authorization'].split(' ').last\n end\n end", "def token\n authenticated\n end", "def auth_token\n Auth.decode(header_token)\n end", "def add_authentication(_, request)\n request.headers['X-User-Email'] = self.class.api_user_email\n request.headers['X-User-Token'] = self.class.api_token\n end", "def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n\n if auth_token\n authenticate_with_auth_token auth_token\n else\n authentication_error\n end\n end", "def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n\n if auth_token\n authenticate_with_auth_token auth_token\n else\n authentication_error\n end\n end", "def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n\n if auth_token\n authenticate_with_auth_token auth_token\n else\n authenticate_error\n end\n end", "def authenticate\n json_response(\n auth_token: AuthenticateUser.new(\n auth_params[:username],\n auth_params[:password]\n ).call\n )\n end", "def authenticate_token\n authenticate_with_http_token do |token, options|\n token == 'ABC'\n end\n end", "def auth(controller)\n #controller.reset_session\n token = controller.params[:access_token]\n user = User.where(:access_token => token).first\n if user\n controller.sign_in(user)\n\n ## TODO: We should change the token here.\n\n data = \"<login\"\n data += \" name='#{user.name}'\"\n data += \" email='#{user.email}'\"\n data += \" roles='#{user.role_symbols.join(\",\")}'\"\n data += \" authToken='#{token}'\"\n data += \"/>\"\n controller.render :xml => data, :status => 200\n else\n controller.render :xml => \"<NoWay/>\", :status => 404\n end\n end", "def authenticate\n auth_token =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n json_response(auth_token: auth_token)\n end", "def token_auth\n Hash['type' => 'token',\n 'token' => @token,]\n end", "def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n client_id = request.headers['Client-ID']\n\n if auth_token\n authenticate_with_auth_token(auth_token, client_id)\n else\n authentication_error\n end\n end", "def authenticate(admin: false)\n if admin\n @key = api_keys(:admin_api_key).key\n else\n @key = api_keys(:default_api_key).key\n end\n\n request.headers['Authorization'] = \"Token token=#{@key}\"\n end", "def request_token(params)\n header = {}\n\n if @endpoint_auth == :basic\n header = { authorization: 'Basic ' + Base64.encode64(\"#{@client_id}:#{@client_secret}\") }\n else\n params[:client_id] = @client_id\n params[:client_secret] = @client_secret\n end\n\n request = Net::HTTP::Post.new(@token_endpoint, header)\n request.form_data = params\n Net::HTTP.start(@host.hostname, @host.port, use_ssl: true) { |http| http.request(request) }\n end", "def auth(opts = {})\n query = QueryBuilder.new\n .options(:without_api_path)\n .with('/api/login')\n .header(:content_type,\n 'application/x-www-form-urlencoded')\n .data(j_username: opts[:username])\n .data(j_password: opts[:password])\n .build\n\n @token = post(query, raw: true)\n self.class.send(:headers, 'Authorization' => @token)\n\n @token\n end", "def authenticate\n \n authenticate_or_request_with_http_token do |token|\n begin\n decoded = decode(token)\n @current_user = User.find_by(id: decoded[0][\"user_id\"]) \n \n rescue JWT::DecodeError\n render json: {authorized: false }, status: 401 \n end\n end \n end", "def auth_header\n if token\n { \"Authorization\" => \"Bearer #{token}\" }\n else\n {}\n end\n end", "def authentication_token\n generate_token(:authentication_token)\n end", "def jwt_token_authen!\n data = jwt_verify(headers[\"Token\"])\n return error!('401 Unauthorized', 401) if data.nil?\n end", "def authenticate_request!\n payload, header = JsonWebToken.verify(http_token)\n header if false # Commeent this line\n @requested_user = {\n email: payload['https://sassbox.com/email'],\n first_name: payload['https://sassbox.com/first_name'],\n last_name: payload['https://sassbox.com/last_name']\n }\n rescue JWT::VerificationError, JWT::DecodeError\n render json: { errors: ['Not Authenticated'] }, status: :unauthorized\n end", "def login(username, password)\n resp = post(data['hosts']['auth'] + '/login', {\n headers: {\n 'Content-Type' => 'application/json'\n },\n body: {\n username: username,\n password: password\n }\n }).expect {\n assert(code == 200)\n assert(body.is_a? Hash)\n assert(body.length > 0)\n assert(body.key?('token'))\n }\n\n # add this authorization header to all future requests\n add_header(:Authorization, \"Bearer #{resp.body['token']}\")\n resp\nend", "def authenticate_token\n @is_authenticated = false\n if request.headers[\"TOKEN\"]\n if request.headers[\"TOKEN\"] == \"AppDipre\"\n @is_authenticated = true\n end\n end\n end", "def authenticate_token\n @is_authenticated = false\n if request.headers[\"TOKEN\"]\n if request.headers[\"TOKEN\"] == \"AppDipre\"\n @is_authenticated = true\n end\n end\n end", "def authenticate\n token = request.headers[\"Authorization\"].split(' ')[1]\n payload = JWT.decode(token, @@jwt_secret, true, { algorithm: 'HS512' })[0]\n @username = payload[\"username\"]\n rescue StandardError\n render json: { error: \"Invalid token\" }, status: :unauthorized\n end", "def authenticate\n @discogs = Discogs::Wrapper.new(\"Test OAuth\")\n request_data = @discogs.get_request_token(DISCOGS_API_KEY, DISCOGS_API_SECRET, \"http://127.0.0.1:3000/callback\")\n \n session[:request_token] = request_data[:request_token]\n \n redirect_to request_data[:authorize_url]\n end", "def get_authentication_header\n \"#{token_type} #{token}\"\n end", "def auth_header\n { 'Authorization': \"Bearer #{@auth.token}\" }.with_indifferent_access\n end", "def auth_header\n # headers: { 'Authorization': 'Bearer <token>' }\n\n request.headers['Authorization']\n # => 'Bearer <token>'\n end", "def token\n authenticate_with_http_basic do |username, password|\n\n user = User.find_by(username: username)\n if user && user.password == password\n render json: { token: user.token }\n else\n render json: { error: 'Incorrect credentials' }, status: 401\n end\n\n end\n end", "def authenticate\n auth_token = AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n user = User.find_by(email: auth_params[:email])\n # HTTP-only cookie stored with refresh_token\n # Note - May be needed before launching production: SameSite: \"Strict\"\n # cookies.signed[:jwt] = {value: auth_token, httponly: true, same_site: :none, expires: 2.hours.from_now}\n response.set_header('Authorization', auth_token)\n json_response(user, :ok, user_options)\n # render json: user, include: user_options\n # json_response(message: \"Successfully authenticated.\" , user_role: user.role,user_id: user.id)\n end", "def request_token(auth, opts)\n case auth[:method]\n when 'token'\n auth_token(auth)\n when 'userpass'\n auth_userpass(auth, opts)\n else\n raise ValidationError, \"Unknown auth method: #{auth[:method]}\"\n end\n end", "def get_authentication_header\n acquire_token if token_expired\n \"#{token_type} #{token}\"\n end", "def request_token\n json = cli.perform_quietly %Q(curl -u '#{username}:#{password}' -d '{\"scopes\": [\"repo\"], \"notes\": \"Octopolo\"}' https://api.github.com/authorizations)\n self.auth_response = JSON.parse json\n end", "def authenticate_with_token!\n render json: { errors: 'Acesso não autorizado!' }, status: 401 unless user_logged_in?\n end", "def getHeader\n #updateToken\n {'Content-Type' => 'application/json', 'Authorization' => 'Bearer ' + @token}\n end", "def api_auth \n # output the APIkey from the header\n # puts request.headers[\"X-APIkey\"]; \n user = User.find_by(email: params[:email].downcase)\n if user && user.authenticate(params[:password])\n render json: { auth_token: encodeJWT(user) }\n else\n render json: { error: 'Invalid username or password' }, status: :unauthorized\n end\n end", "def authenticate!\n Authenticator.verify!(params['token'])\n end", "def add_auth_headers\n @client.headers['Auth-Email'] = '...'\n @client.headers['Auth-Token'] = '...'\n end", "def request_http_token_authentication(realm = \"Application\", message='HTTP Token: Access denied. You did not provide an valid API key.')\n self.headers[\"WWW-Authenticate\"] = %(Token realm=\"#{realm.gsub(/\"/, '')}\")\n unauthenticated!\n end", "def get_authentication_header\n acquire_token if token_expired?\n \"#{token_type} #{token}\"\n end", "def post_token_request()\r\n # Create REST request header\r\n header = get_header()\r\n begin\r\n # Post REST request \r\n response = RestClient.post(@token_request_uri, @token_request_body, header) \r\n if (response.code == 200 || response.code == 201)\r\n return JSON.parse(response.body)\r\n else\r\n @logger.trace(\"Rest client response from ADD API ['#{response}']\")\r\n raise (\"Failed to get AAD token: http code \" + response.code.to_s)\r\n end\r\n rescue RestClient::ExceptionWithResponse => ewr\r\n @logger.trace(\"Rest client response from ADD API ['#{ewr.response}']\")\r\n raise (\"Failed to get AAD token: http code \" + ewr.response.code.to_s)\r\n end\r\n end", "def get_auth_token \n # Can't send params as form-encoded, actually need to send a JSON or XML\n # body, argh. \n \n body = <<-EOS\n {\n \"UserId\":\"#{configuration.user_id}\",\n \"Password\":\"#{configuration.password}\"\n }\n EOS\n \n s_time = Time.now\n response = http_client.post(configuration.auth_url, body, {'Accept' => \"application/json\", \"Content-type\" => \"application/json\"})\n Rails.logger.debug(\"EDS timing AUTH: #{Time.now - s_time}s\") \n \n unless HTTP::Status.successful? response.status\n raise EdsCommException.new(\"Could not get auth\", response.status, response.body)\n end\n \n response_hash = nil\n begin\n response_hash = MultiJson.load response.body\n rescue MultiJson::DecodeError\n end\n \n unless response_hash.kind_of?(Hash) && response_hash.has_key?(\"AuthToken\")\n raise EdsCommException.new(\"AuthToken not found in auth response\", response.status, response.body)\n end\n \n return response_hash[\"AuthToken\"] \n end", "def auth_header\n # { Authorization: 'Bearer <token>' }\n request.headers['Authorization']\n end", "def auth_header\n\t\t# { Authorization: 'Bearer <token>' }\n\t\trequest.headers['Authorization']\n\tend", "def authenticate\n res = HTTParty.post(\n authenticate_url,\n body: body.to_json,\n headers: { 'Content-Type' => 'application/json' }\n )\n\n check_for_error(res)\n\n res.parsed_response\n end", "def authenticate\n \t# get token from header\n \tauthentication_token = request.headers['token']\n \t@user = User.find_by_authentication_token authentication_token if authentication_token\n \t\n \tunless @user\n \t\trender json: {success: false, message: I18n.t('unauthorized'), data: {}}, status: :unauthorized\n \t\treturn false\n \tend\n end", "def exchange_auth_token\n @id_token = from_client_to_id_token(@client_token)\n render 'exchange_auth_token', formats: 'json', handlers: 'jbuilder'\n end", "def authenticate\n #Hace el llamado de la clase AuthenticaUser, manda los parametros de :username y :password\n #Realiza el metodo call para obtener el Token del user_id\n #Arroja el token como Json_response\n auth_token = AuthenticateUser.new(auth_params[:username], auth_params[:password]).call \n json_response(auth_token: auth_token)\n end", "def token\n @request = Request.new(params)\n\n if authenticate_client!\n response = @request.client_credentials.get_access_token\n\n respond_to do |format|\n format.html { redirect_to Http::Uri.build(@request.redirect_uri, response.to_hash) }\n format.json { render json: response.to_json, location: @request.redirect_uri }\n end\n else\n respond_to do |format|\n format.html { redirect_to Http::Uri.build(@request.redirect_uri, Oauth::Error::UnauthorizedClient.to_hash) }\n format.json { render json: Oauth::Error::UnauthorizedClient.to_json, location: @request.redirect_uri }\n end\n end\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 authenticate\n #render :text => params[:action]\n if (params[:controller] != \"api/sessions\")\n if (params[:controller] == \"api/users\" && params[:action] == \"create\")\n return\n end\n user = User.find_by(token: params[:token])\n if !user || user.valid_up < DateTime.now\n render json: '{\"error\":\"Unauthorized\"}', status: 401\n end\n end\n if (params[:controller] == \"api/sessions\" && params[:action] == \"chekToken\")\n user = User.find_by(token: params[:token])\n if !user || user.valid_up < DateTime.now\n render json: '{\"error\":\"Unauthorized\"}', status: 401\n end\n end\n #\"controller\":\"users\",\"action\":\"show\",\"id\":\"login\" si se va a registrar dejar pasar\n #@product = '[{\"mytoken\":\"'+params[:token]+'\"}]'\n # if !User.find_by(token: params[:token])\n # #render json: '[{\"error\":\"Unauthorized\"}]', status: 401\n # end\n end", "def generate_authorization_token\n \t# create the token that contains the necessary elements to authorize the user\t\n \t# using a nested array because the alphabetical order must be maintained\n \ttoken = [['credentials', self.user.to_credential_string,], ['identity', self.user.to_identity_string], ['time', Time.now.to_i.to_s]]\n \tencoded_parms = token.collect {|pair| pair[1] = CGI.escape(pair[1]); pair.join('=')}.join('&')\n\n digest = Digest::SHA2.new\n digest.update(encoded_parms)\n\n hmac = HMAC::SHA256.new(self.options[:shared_secret])\n hmac.update(encoded_parms)\n\n # add the hashed digital signature to the end of the query parameters\n encoded_parms += \"&signature=#{hmac.hexdigest}\"\n end", "def http_auth_token\n request.headers['Authorization']&.split(' ')&.last\n end", "def add_authentication_to(request=nil)\n if @auth_token\n request.headers['Cookie'] = \"AuthToken=#{@auth_token}\"\n request.headers['AuthToken'] = @auth_token\n else\n raise \"The connection can't authenticate. Check if the auth_token is being set by the server\"\n end\n end", "def authenticate\n \n authenticate_token || render_unauthorized\n end", "def authenticate\n authenticated_user = AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n response = { message: Message.logged_in, auth_token: authenticated_user[:auth_token], is_doctor: authenticated_user[:is_doctor], doctor_id: authenticated_user[:doctor_id], fullname: authenticated_user[:fullname], date_of_birth: authenticated_user[:date_of_birth] }\n json_response(response)\n end" ]
[ "0.75020164", "0.7068762", "0.7028924", "0.69227207", "0.68898046", "0.68744516", "0.6855017", "0.6841688", "0.6833473", "0.6829393", "0.68290335", "0.6824104", "0.68062234", "0.6785159", "0.6760981", "0.67287433", "0.6723888", "0.6723038", "0.6722622", "0.67125356", "0.67023665", "0.6694277", "0.66921455", "0.668784", "0.66855454", "0.6670745", "0.6654255", "0.6623448", "0.66226673", "0.6608698", "0.6606728", "0.6597428", "0.6596531", "0.6588624", "0.65825254", "0.6580917", "0.6548475", "0.65475696", "0.6535532", "0.6534767", "0.65341914", "0.65273446", "0.6525936", "0.6521498", "0.65201414", "0.65101135", "0.64864385", "0.648626", "0.64775676", "0.64775676", "0.64695346", "0.6466678", "0.6455926", "0.6452692", "0.64512694", "0.64323056", "0.642067", "0.6419854", "0.6416714", "0.6415339", "0.6413378", "0.6412486", "0.6408722", "0.64015317", "0.63967365", "0.6394167", "0.63917744", "0.63917744", "0.6386065", "0.63844776", "0.63787276", "0.6373258", "0.63632935", "0.63625526", "0.6362282", "0.63524395", "0.63516307", "0.6350743", "0.6347372", "0.63387865", "0.63382024", "0.632929", "0.6327945", "0.6325546", "0.6319353", "0.6314381", "0.6314074", "0.6308721", "0.6306967", "0.6300284", "0.62961483", "0.6293461", "0.6292197", "0.6283985", "0.6281075", "0.62772757", "0.62716967", "0.62666404", "0.62566155", "0.6252398", "0.62486875" ]
0.0
-1
DELETE /auth/:token Delete auth token
def logout auth_token = get_connection_object.headers['X-Auth-Token'] raise "Can't find any authorization token to logout." unless auth_token @response = delete("/auth/#{auth_token}") if @response.has_key?("success") and @response['success'] get_connection_object.headers.delete("X-Auth-Token") end @response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_token(token = nil)\n token = token || settings.token\n delete \"authToken/#{token.to_s}\"\n end", "def delete_apn_token\n if params[:id] == current_user.id.to_s\n # A user can delete tokens for themself\n @user = current_user\n return render_error(500, \"must specify a token to remove\") unless token = params.delete(:token)\n\n # remove the token from the user's collection\n @user.pull(:bh => token)\n\n @status = 200\n else\n @status = 401\n end\n end", "def destroy\n unless User.admin_by_token?(request.cookies[\"token\"])\n render json: { error: \"invalid_token\" }, status: :unauthorized\n return\n end\n\n @resource.destroy\n head :no_content\n end", "def destroy\n @token = Token.find(params[:id])\n @token.destroy\n\n head :no_content\n end", "def delete_token(token)\n delete token_path(token)\n end", "def destroy\n @token = Token.find(params[:id])\n @token.destroy\n \n respond_to do |format|\n format.html { redirect_to tokens_url }\n format.json { head :ok }\n end\n end", "def destroy\n @token.destroy\n\n head :no_content\n end", "def destroy\n current_user.remove_token\n render json: { status: :success, data: 'Successfully signed out' }\n end", "def destroy\n @token = @user.tokens.find(params[:id])\n @user.tokens.delete(@token)\n @user.save\n\n respond_to do |format|\n format.html { redirect_to user_tokens_url }\n format.json { head :no_content }\n end\n end", "def delete(path, params={}, args={})\n inject_token_auth_headers!(args)\n response = self.class.delete(request_url(path, params), args)\n update_token_auth_headers(response)\n return response\n end", "def destroy\n @token.destroy\n respond_to do |format|\n format.html { redirect_to admin_tokens_url, notice: 'Token was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @oauth_token = OauthToken.find(params[:id])\n @oauth_token.destroy\n\n respond_to do |format|\n format.html { redirect_to(scaffold_oauth_tokens_url) }\n format.xml { head :ok }\n end\n end", "def logout(token)\n request(\n __method__,\n :post,\n \"#{api_base}/auth/logout\",\n nil,\n Authorization: token\n )\n end", "def logout(token)\n request(\n __method__,\n :post,\n \"#{api_base}/auth/logout\",\n nil,\n Authorization: token\n )\n end", "def destroy\n\t\tcookies.delete(:auth_token)\n\t\tredirect_to root_url\n\tend", "def delete_credit_card_token token\n request :delete, \"/merchant/#{merchant_id}/token/#{token}\"\n end", "def deauthenticate\n token = params[:tok]\n if @user = Droom::User.find_by(authentication_token: token)\n @user.reset_session_id!\n @user.reset_authentication_token!\n render json: @user\n else\n head :unauthorized\n end\n end", "def destroy\n # expire auth token \n\t @user=User.where(:authentication_token=>params[:api_key]).first\n\t if @user.present?\n\t #@user.reset_authentication_token!\n token = Devise.friendly_token[0,20]\n unless @user.authentication_token == token\n @user.update_attributes(:authentication_token => token)\n end\n\t render :json => { :message => [\"Session deleted.\"], :success => true, :status => :ok}\n\t else\n\t\t respond_to do |format|\n format.json{ render :json => { :error => \"Api key is invalid.\" }}\n end\n\t end\n end", "def destroy\n # Validations\n if request.format != :json\n render( status: 406, json: { success: false, message: I18n.t(\"api.errors.request_must_be_json\") } )\n return\n end\n\n # Fetch params\n user = User.find_for_database_authentication( authentication_token: params[:user_token] )\n\n if user.nil?\n render( status: 404, json: { success: false, message: I18n.t(\"api.errors.invalid_token\") } )\n else\n user.reload\n user.authentication_token = nil\n user.save!\n render( status: :ok, json: { success: true, message: I18n.t(\"api.errors.log_out_successful\") } )\n end\n end", "def destroy\n @api_token = ApiToken.find(params[:id])\n \n @api_token.destroy unless @api_token.user_id != current_user.id\n\n respond_to do |format|\n format.html { redirect_to(api_tokens_url) }\n format.xml { head :ok }\n end\n end", "def delete\n request('delete').auth_required!\n end", "def destroy\n @globus_token.destroy\n\n respond_to do |format|\n format.html { redirect_to globus_tokens_url, notice: \"Globus token was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete\n user = getUserByAuthToken(request)\n user.soft_delete\n head :no_content\n end", "def log_out\n message = ''\n auth_token = params[:token]\n if auth_token.include?(':')\n user_id = auth_token.split(':').first\n user = User.where(id: user_id).first\n token = auth_token.split(':').last\n if user\n device = user.devices.find_by(token: token)\n if device && Devise.secure_compare(device.token, token)\n device.delete\n message = 'access revoked'\n sign_out(user)\n end\n end\n end\n render json: {message: message}\n end", "def destroy\n @access_token = AccessToken.find(params[:id])\n @access_token.destroy\n\n respond_to do |format|\n format.html { redirect_to access_tokens_url }\n format.json { head :no_content }\n end\n end", "def delete_cookie\n cookies.delete :auth_token\n end", "def destroy\n @auth = Auth.find(params[:id])\n @auth.destroy\n\n respond_to do |format|\n format.html { redirect_to auths_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_token = UserToken.find(params[:id])\n @user_token.destroy\n\n respond_to do |format|\n format.html { redirect_to user_tokens_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user=User.where(:authentication_token=>params[:api_key]).first\n @user.reset_authentication_token!\n render :json => { :message => [\"Session deleted.\"] }, :success => true, :status => :ok\n end", "def delete\n token = existing_payload[:token]\n\n checkin_params = { token: token, return_to: cdl_checkin_success_iiif_auth_api_url(params[:id]) }\n redirect_to \"#{Settings.cdl.url}/checkin?#{checkin_params.to_param}\"\n end", "def destroy\n\n api_key = ApiKey.where(access_token: token).first\n\n api_key.access_token = ''\n api_key.expires_at = Time.now\n\n if api_key.save\n render json: {}, status: 200\n else\n render json: {}, status: 422\n end\n end", "def logout\n auth_token = request.headers['Authorization']\n if auth_token == nil\n \n auth_token = params[\"Authorization\"]\n end\n\t#if there is no token then you cant logout\n if auth_token == nil\n return json_response({message: \"Invalid token\", status_code: '422'})\n end\n is_token_valid = JsonWebToken.decode(auth_token)\n \n result = JsonWebToken.invalidate(auth_token)\n \n if result != nil\n respose = json_response({message: \"You have succesfully logged out...\", status_code: result})\n else\n response = json_response({message: \"Something went wrong...\", status_code: '422'})\n end\n \n return response\n end", "def sign_out\n send_request('sign_out', :delete) do |req|\n req.body = { auth_token: @auth_token }\n end\n end", "def destroy\n @apn_token.destroy\n respond_to do |format|\n format.html { redirect_to apn_tokens_url, notice: 'Apn token was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @access_token = AccessToken.find(params[:id])\n @access_token.destroy\n\n respond_to do |format|\n format.html { redirect_to(access_tokens_url) }\n format.xml { head :ok }\n end\n end", "def delete(path, data = {})\n self.class.delete path, :body => data.merge(:u => access_token)\n end", "def delete\n resp = if token.present?\n chip_client.delete(token:)\n else\n Faraday::Response.new(body: check_in.unauthorized_message.to_json, status: 401)\n end\n response.build(response: resp).handle\n end", "def delete_access_token(account_number, token)\r\n # the base uri for api requests\r\n query_builder = Configuration.base_uri.dup\r\n\r\n # prepare query string for API call\r\n query_builder << '/accounts/{account_number}/access-tokens/{token}'\r\n\r\n # process optional query parameters\r\n query_builder = APIHelper.append_url_with_template_parameters query_builder, {\r\n 'account_number' => account_number,\r\n 'token' => token\r\n }\r\n\r\n # validate and preprocess url\r\n query_url = APIHelper.clean_url query_builder\r\n\r\n # prepare headers\r\n headers = {\r\n 'user-agent' => 'APIMATIC 2.0',\r\n 'X-Auth-Token' => Configuration.x_auth_token\r\n }\r\n\r\n # invoke the API call request to fetch the response\r\n response = Unirest.delete query_url, headers: headers\r\n\r\n # Error handling using HTTP status codes\r\n if response.code == 401\r\n raise APIException.new 'You are not authenticated', 401, response.raw_body\r\n elsif response.code == 403\r\n raise APIException.new 'This action needs a valid WSSE header', 403, response.raw_body\r\n elsif response.code == 404\r\n raise APIException.new 'Resource not found', 404, response.raw_body\r\n elsif response.code == 400\r\n raise APIException.new 'Http bad request', 400, response.raw_body\r\n elsif !response.code.between?(200, 206) # [200,206] = HTTP OK\r\n raise APIException.new 'HTTP Response Not OK', response.code, response.raw_body\r\n end\r\n\r\n response.body\r\n end", "def sign_out\n @token.destroy\n render json: { message: 'Sign-out successfully' }, status: :ok\n end", "def destroy\n @facebook_token.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def delete(url, params)\n params = convert_hash_keys(params)\n @access_token = params.delete('access_token') if params['access_token']\n return connection.delete(url)\n end", "def destroy\n # Delete the user access tokens on logout\n User.find(session[:user_id]).delete\n # Delete the session as well\n session = {}\n \n redirect_to root_path\n end", "def delete(token)\n @store.delete(key_for(token))\n end", "def revoke_oauth_token\n current_user.revoke_token\n end", "def delete(params = {})\n case @api.version\n when 'v1'\n response = self.class.post(@api.delete_config[:url],\n :query => { :auth_token => @token }.merge(params),\n :headers => @api.headers\n )\n when 'v2'\n response = self.class.delete(@api.delete_config[:url],\n :query => { :auth_token => @token },\n :headers => @api.headers\n )\n end\n\n ErrorHandler.response_code_to_exception_for :user, user_id, response\n true\n end", "def logout\n auth_token = get_connection_object.headers['X-Auth-Token']\n raise \"Can't find any authorization token to logout.\" unless auth_token\n delete(\"/auth/#{auth_token}\")\n if @response.has_key?(\"success\") and @response['success']\n get_connection_object.headers.delete(\"X-Auth-Token\")\n end\n @response\n end", "def delete_access_token(id:)\n client.make_request('/delete-access-token', 'post', params: {id: id})\n end", "def destroy\n head :unauthorized\n end", "def delete(path, params = {})\n Chirpy.request params.merge({:path => path, :method => 'delete'}.merge(authentication))\n end", "def delete\n decoded_access_token = JWT.decode(params[:accessToken], 's3cr3t', true, algorithm: 'HS256')\n decoded_refresh_token = JWT.decode(params[:refreshToken], 's3cr3t', true, algorithm: 'HS256')\n # Check if token was decoded\n if decoded_access_token && decoded_refresh_token\n @user = User.find_by(id: decoded_access_token[0]['user_id'])\n if @user # user exists\n Blacklist.find_by(jwt: params[:accessToken]).delete\n Blacklist.find_by(jwt: params[:refreshToken]).delete\n User.find_by(id: @user.id).delete\n render json: {status: \"User was succesfully deleted\"}\n else\n render json: {error: \"Invalid User\"}\n end\n else # token is null\n render json: {error: \"Invalid Tokens\"}\n end\n end", "def destroy\n @payment_token.destroy\n respond_to do |format|\n format.html { redirect_to payment_tokens_url, notice: 'Payment token was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def remove_token\n update(token: nil)\n end", "def destroy\n current_user.authentication_token = nil\n current_user.save\n render json: {success: true, message: \"Logged out successfully\"}\n end", "def revoke\n @token = current_user.tokens.where(token: params[:token]).first!\n @token.invalidate!\n\n respond_with(@token) do |format|\n format.html { redirect_to([:client_applications], notice: \"You've revoked the authorization for the application '#{@token.client_application.name}'.\") }\n end\n end", "def destroy\n @guest_chat_token.destroy\n respond_to do |format|\n format.html { redirect_to admin_guest_chat_tokens_url, notice: 'Гостевой чат-токен было успешно удалён.' }\n format.json { head :no_content }\n end\n end", "def sign_out\n token = AccessToken.find_by(access_token: @token)\n token.destroy unless token.nil?\n msg = { status: STATUS_SUCCESS, message: SUCCESS_MESSAGE }\n\n render json: msg\n end", "def destroy\n @auth_user.destroy\n end", "def destroy\n @model.destroy\n respond_to do |format|\n format.html { redirect_to access_tokens_url, notice: 'Access token was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete operation, *args\n request(args) do |attrs, headers|\n @oauth_access_token.send(:delete, \"/#{API_VERSION}/#{operation}.#{API_FORMAT}\", headers)\n end\n end", "def revoke_token(token, params = nil, opts = nil)\n case token\n when OAuth2::AccessToken\n token = token.token\n when Hash\n h = token.deep_symbolize_keys\n token = h[:access_token] || h[:token] || h.dig(:credentials, :token)\n end\n if token.blank?\n Log.warn(\"#{__method__}: no token\")\n return\n end\n\n # Prepare data values including the token.\n meth = options[:token_method]\n auth = Authenticator.new(id, secret, options[:auth_scheme])\n params = auth.apply(params || {}).merge!(token: token)\n\n # Prepare headers and other options.\n opts = opts&.dup || {}\n headers = opts[:headers]&.dup || {}\n headers.merge!(params.delete(:headers) || {})\n if meth == :get\n opts[:params] = params\n else\n opts[:body] = params\n headers['Content-Type'] = 'application/x-www-form-urlencoded'\n end\n opts[:headers] = headers\n opts[:raise_errors] = false unless opts.key?(:raise_errors)\n\n # noinspection RubyMismatchedArgumentType\n request(meth, options[:revoke_url], opts)\n end", "def destroy\n @oauth_remote_access_token = OauthRemoteAccessToken.find(params[:id])\n @oauth_remote_access_token.destroy\n\n respond_to do |format|\n format.html { redirect_to(oauth_remote_access_tokens_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n\t\t\t\tcurrent_user.reset_authentication_token!\n\t\t\t\trender_success\n\t\t\tend", "def destroy\n # id = @current_user.id\n # user = User.find(id)\n # user.newvo_token = nil\n # @current_user = nil\n render json: {success: true, message: \"Signout was successful\"}\n end", "def destroy\n @push_token = PushToken.find(params[:id])\n mag = @push_token.magazine\n @push_token.destroy\n\n respond_to do |format|\n format.html { redirect_to push_tokens_url(id:mag.apps_id) }\n format.json { head :no_content }\n end\n end", "def revoke_user_token(token)\n body = {\n token: token\n }\n @client.post('/auth/oauth2/revoke', body, {}, {'Content-Type' => 'application/x-www-form-urlencoded'})\n end", "def destroy\n @adword_auth.destroy\n respond_to do |format|\n format.html { redirect_to adword_auths_url }\n format.json { head :no_content }\n end\n end", "def destroy\n destroy = REDIS_LOGIN.del(\"token:#{headers[\"Access-Token\"]}\")\n if destroy == 1\n render json: { status: \"Logged out\" }, status: 200\n else\n render json: { error: \"Trouble logging out. Make sure the user isn't already logged out\" }, status: 200\n end\n end", "def delete_webhook_with_token(webhook_id, webhook_token)\n route = Route.new(:DELETE, '/webhooks/%{webhook_id}/%{webhook_token}',\n webhook_id: webhook_id, webhook_token: webhook_token)\n request(route)\n end", "def destroy\n @autho.destroy\n respond_to do |format|\n format.html { redirect_to authos_url, notice: 'Autho was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def revoke\n # The authorization server first validates the client credentials\n if doorkeeper_token && doorkeeper_token.accessible?\n # Doorkeeper does not use the token_type_hint logic described in the RFC 7009\n # due to the refresh token implementation that is a field in the access token model.\n revoke_token(request.POST['token']) if request.POST['token']\n end\n # The authorization server responds with HTTP status code 200 if the\n # token has been revoked successfully or if the client submitted an invalid token\n render json: {}, status: 200\n end", "def revoke\n oauth_access_token.revoke\n head :ok\n end", "def test_should_delete_token_on_logout\n login_as :quentin\n get :logout\n assert_equal @response.cookies[\"auth_token\"], []\n end", "def destroy\n # Remove the api token for this user.\n current_user.disable_api!\n respond_to do |format|\n format.json { render :json => current_user }\n end\n\n end", "def nuke_auth_token\n\t\t\tfile = get_access_token_file\n\t\t\[email protected] \"Removing persisted access token: #{file}\"\n\t\t\tFile.delete file\n\t\t\tset_access_token(nil)\n\t\t\tset_auth_header ''\n\t\tend", "def revoke_token(token, params = nil, opts = nil)\n super\n .tap { |result| __ext_debug(\"--> #{result.inspect}\") }\n end", "def delete_registration_token_with_http_info(token, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ManagementPlaneApiAaaApi.delete_registration_token ...'\n end\n # verify the required parameter 'token' is set\n if @api_client.config.client_side_validation && token.nil?\n fail ArgumentError, \"Missing the required parameter 'token' when calling ManagementPlaneApiAaaApi.delete_registration_token\"\n end\n # resource path\n local_var_path = '/aaa/registration-token/{token}'.sub('{' + 'token' + '}', token.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:DELETE, 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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementPlaneApiAaaApi#delete_registration_token\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def revoke_token\n request @google + '/accounts/AuthSubRevokeToken'\n\n @session_token = false\n end", "def destroy\n\n if(params[:token].nil?)\n response.status = 400\n render json: {msg: \"Token is not defined\"}\n return\n end\n\n session = validate_session(params[:token])\n\n if session.nil?\n response.status = 401\n render json: {}\n return\n end\n\n begin\n obj = User.find(params[:id])\n\n unless session.user.id == obj.id\n response.status = 403\n render json: {}\n return\n end\n\n # This is what slows down the response.\n # Big DB transactions that delete by foreign key.\n obj.time_sessions.destroy_all\n obj.login_sessions.destroy_all\n\n obj.destroy\n response.status = 20\n render json: {msg: obj.time_sessions.methods}\n rescue ActiveRecord::RecordNotFound => e\n response.status = 404\n render json: {}\n rescue Exception => e\n response.status = 500\n render json: {msg: e}\n end\n\n end", "def destroy\n patient = get_patient(@body[\"token\"])\n if patient != @patient\n render json: {message: \"failed to authenticate\"}, status: :unprocessable_entity\n elsif @patient.destroy\n render json: {message: \"success\"}\n else\n render json: {message: \"failed\"}, status: :unprocessable_entity\n end\n end", "def delete_request(uri, token = nil, manage_errors = true)\n request = Net::HTTP::Delete.new(uri.request_uri, initheader = build_headers(token))\n return do_request(uri, request, manage_errors)\n end", "def destroy\n current_user.deauthorize!\n head :ok\n end", "def logout_user\n cookies.delete(:auth_token)\n end", "def logout\n response = @session.delete\n @auth_token = nil\n @rest.default_headers = { 'Content-Type' => 'application/json' }\n response\n end", "def revoke_token\n raise 'To be implemented in child classes'\n end", "def invalidate_auth_token\n self.update_columns(auth_token: nil)\n end", "def invalidate_auth_token\n self.update_columns(auth_token: nil)\n end", "def delete_access_token(access_token_id)\n @redis.del(auth_domain_key(access_token_id))\n end", "def remove_devise_auth_token(authentication_token)\n authorization = Authorization.where(:provider => 'devise', :token => authentication_token).first\n\n unless authorization.blank?\n if authorization.destroy\n return true\n end\n end\n\n return false\n end", "def destroy\n __log_activity(\"LOGOUT #{current_user}\")\n __debug_route\n __debug_request\n user = current_user&.account&.dup\n opt = BS_AUTH ? { no_revoke: true?(params[:no_revoke]) } : {}\n delete_auth_data(**opt)\n super\n api_clear(user: user)\n set_flash_notice(user: user, clear: true)\n rescue => error\n auth_failure_redirect(message: error)\n end", "def logout\r\n self.update(token: nil) \r\n end", "def destroy\n id = request.headers[\"id\"]\n user = User.where(id: id).first\n if user.present?\n user.device_token = nil\n user.save\n render_destroy_success(user)\n else\n render_destroy_error\n end\n end", "def destroy_current_access_token\n AccessToken.find(current_access_token_id).destroy\n end", "def revoke_token\n http_client = Carto::Http::Client.get('gdrive')\n response = http_client.get(\"https://accounts.google.com/o/oauth2/revoke?token=#{token}\")\n if response.code == 200\n true\n end\n rescue => ex\n raise AuthError.new(\"revoke_token: #{ex.message}\", DATASOURCE_NAME)\n end", "def destroy\n current_user.authentication_token = nil\n signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))\n render json: {status:0, data: nil}\n end", "def destroy\n result = access_token.delete(\"/api/v1/emails/#{params[:id]}\")\n display_api_response( result )\n respond_with(\"\",:location => :back)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def destroy\n @auth_user.destroy\n respond_to do |format|\n format.html { redirect_to auth_users_url, notice: 'Auth user was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n logout\n render json: {:ok => true}\n end", "def delete path\n make_request(path, \"delete\", {})\n end" ]
[ "0.815367", "0.77766246", "0.7587209", "0.75869095", "0.75727856", "0.7473823", "0.74708533", "0.74280477", "0.73880243", "0.7295512", "0.7284652", "0.7212292", "0.71979445", "0.71979445", "0.7176711", "0.71505785", "0.71470386", "0.7061725", "0.70295316", "0.70237345", "0.7001633", "0.6995584", "0.69895834", "0.6987447", "0.6933279", "0.69223654", "0.6908139", "0.6893139", "0.6887189", "0.6885234", "0.68786913", "0.6822228", "0.6809038", "0.6782744", "0.675461", "0.67508715", "0.6736937", "0.6724047", "0.67222387", "0.67173564", "0.6699588", "0.6679005", "0.6670299", "0.66329163", "0.66242105", "0.6615669", "0.6603349", "0.6556498", "0.65293664", "0.65283096", "0.6508776", "0.64975387", "0.649128", "0.6489683", "0.64835936", "0.64806336", "0.6479475", "0.6475056", "0.64577204", "0.64495134", "0.64383113", "0.6418091", "0.64039856", "0.63914716", "0.6387294", "0.63868093", "0.6383854", "0.63812464", "0.63791776", "0.6375645", "0.6366116", "0.6357616", "0.635208", "0.6344631", "0.6343448", "0.6316399", "0.6301941", "0.62916905", "0.6291405", "0.6274134", "0.6274037", "0.6273778", "0.6267566", "0.62464833", "0.6236818", "0.6236818", "0.6232418", "0.6222526", "0.6218113", "0.6216432", "0.6207676", "0.6205308", "0.61987746", "0.61919475", "0.6191064", "0.61801875", "0.61801875", "0.6176136", "0.6174567", "0.61711645" ]
0.70132047
20
GET /photo_tag_references GET /photo_tag_references.json
def index @photo_tag_references = PhotoTagPhoto.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_photo_tag_reference\n @photo_tag_reference = PhotoTagPhoto.find(params[:id])\n end", "def index\n @tag_refs = TagRef.all\n end", "def photo_tag_reference_params\n params.require(:photo_tag_photo).permit(:photo_id, :photo_tag_id)\n end", "def show\n @tag = Tag.find(params[:id])\n if current_admin\n if params[:pin]\n @tag.photo_id = params[:pin]\n @tag.save\n end\n end\n # @category_photo = @tag.photo\n @photos = Photo.includes(:tags).where(:tags => {:name => @tag.name})\n @untagged_photos = []\n Photo.all.each do |p|\n @untagged_photos << p if p.tags.count == 0\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tag }\n end\n end", "def tags\n _get(\"/query/image/tags\") { |json| json }\n end", "def show\n @taggable = current_user.taggables.find(params[:id])\n @tags = @taggable.tags\n @url_no_path = URI.parse(@taggable.photo.url).path[%r{[^/]+\\z}]\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taggable }\n end\n end", "def tags_from_reference(reference)\n response = client.get(\"2.0/tracks/reference/#{reference}/tags\")\n\n response.map { |tag| Struct::Tag.new(tag) }\n end", "def destroy\n @photo_tag_reference.destroy\n respond_to do |format|\n format.html { redirect_to photo_tag_references_url, notice: 'Photo tag reference was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n @photo_tag_reference = PhotoTagPhoto.new(photo_tag_reference_params)\n\n respond_to do |format|\n if @photo_tag_reference.save\n format.html { redirect_to @photo_tag_reference, notice: 'Photo tag reference was successfully created.' }\n format.json { render :show, status: :created, location: @photo_tag_reference }\n else\n format.html { render :new }\n format.json { render json: @photo_tag_reference.errors, status: :unprocessable_entity }\n end\n end\n end", "def convert_ref_tags; end", "def update\n respond_to do |format|\n if @photo_tag_photo.update(photo_tag_reference_params)\n format.html { redirect_to @photo_tag_reference, notice: 'Photo tag reference was successfully updated.' }\n format.json { render :show, status: :ok, location: @photo_tag_reference }\n else\n format.html { render :edit }\n format.json { render json: @photo_tag_reference.errors, status: :unprocessable_entity }\n end\n end\n end", "def photo_tags\n all_tags = Hash.new {|h,k| h[k]=[]}\n self.tags.find_each do |t|\n all_tags[t.field] << t.value\n end\n all_tags\n end", "def get_refs(way)\n return [] if !way.tags.has_key?('ref')\n return way.tags['ref'].split(/(;|,)/).collect {|ref| ref.strip}\n end", "def tags\n get('tags')\n end", "def references\n @references ||= ApiFactory.new 'GitData::References'\n end", "def index\n @photo_tags = PhotoTag.select_by_locale(params[:locale])\n\t@curTag = PhotoTag.find_by_id(params[:tag_id])\n\t@photos = []\n\t@photos = @curTag.photos if [email protected]?\n end", "def index\n if params[:tag] == nil\n @photos = Photo.where('user_id=?',session[:user_id]).latest.paginate(:page=>params[:page], :per_page=>10)\n else\n @photos = Photo.tagged_with(params[:tag]).where('user_id=?',session[:user_id]).latest.paginate(:page=>params[:page],:per_page=>10)\n end\n @tags = Photo.tag_counts_on(:tags)\n @tag_name=params[:tag]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @photos }\n end\n end", "def show\n # Pull the selected photo album.\n @photo_tag = PhotoTag.find(params[:id])\n\n respond_to do |format|\n format.json do\n render json: @photo_tag\n end\n end\n end", "def references\n references_hash.to_json\n end", "def set_tag_ref\n @tag_ref = TagRef.find(params[:id])\n end", "def get_tags_uri\n @get_tags_uri ||= \"#{base_uri}/gettags\"\n end", "def references\n (headers['References']||'').scan(/(<[^<]+?>)/).flatten\n end", "def photo(photo, options = {})\n get(\"photos/#{photo}\", options).pop\n end", "def tags\n get.tagGuids\n end", "def print_each_photo(api_key, tag)\n # Build the URI\n uri = \"http://www.flickr.com/services/rest?method=flickr.photos.search\" +\n \"&api_key=#{api_key}&tags=#{tag}\"\n\n # Make the HTTP request and get the entity-body.\n response = open(uri).read\n\n # Parse the entity-body as an XML document.\n doc = REXML::Document.new(response)\n\n # For each photo found...\n REXML::XPath.each(doc, '//photo') do |photo| \n # ...generate and print its URI\n puts small_photo_uri(photo) if photo\n end\nend", "def set_photo_tag\n @photo_tag = PhotoTag.find(params[:id])\n end", "def index\n @taggables = current_user.taggables\n @taggable_center = current_user.taggables.first\n \n\n if !@taggable_center.nil?\n @url_no_path = URI.parse(@taggable_center.photo.url(:editable)).path[%r{[^/]+\\z}]\n @url_path = URI.parse(@taggable_center.photo.url(:editable)).path\n @tags = @taggable_center.tags\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @taggables }\n end\n end", "def parse_references\n globbed_references = body.scan(/(.*?\\))/)\n\n globbed_references.each do |reference|\n url = reference.first.scan(/(?<=\\().*(?=\\))/).first\n next unless url\n\n if url.include?('users')\n # Do nothing for now when it's a mention of a user\n # FIXME - this is junk\n elsif url.include?('ideas') && idea = Idea.find_by_sha(url.gsub('/ideas/', ''))\n # When this is an idea we know about, make a hard link\n self.idea_references.build(:referenced_id => idea.id)\n else\n # Just leave it in the body without doing anything.\n end\n end\n end", "def photos options={}\n response = client.get(\"/#{id}/photos\", options)\n end", "def references\n @references ||= []\n end", "def tags\n @audio_file = AudioFile.find(params[:id])\n @tags = @audio_file.tags\n\n respond_to do |format|\n format.html # tags.html.erb\n format.xml { render :xml => @tags }\n format.json { render :json => @tags }\n end\n end", "def get_photos\n tag = [\"urbanlandscape\",\"architecture\",\"buildings\",\"archidaily\"].sample\n return_hash = HTTParty.get(\"https://api.instagram.com/v1/tags/#{tag}/media/recent?client_id=#{INSTAGRAM_CLIENT_ID}\")\n @instagram_photos = [return_hash[\"data\"].sample[\"images\"][\"low_resolution\"][\"url\"], return_hash[\"data\"].sample[\"images\"][\"low_resolution\"][\"url\"],return_hash[\"data\"].sample[\"images\"][\"low_resolution\"][\"url\"],\n return_hash[\"data\"].sample[\"images\"][\"low_resolution\"][\"url\"]]\n end", "def references\n GameContent.where reference_id: self.id\n end", "def references; end", "def references; end", "def index\n params[:tag] ? @photos = Photo.tagged_with(params[:tag]) : @photos = Photo.all\n album = params[:album_id]\n @photos = current_user.photos.all.where(album_id: album).with_attached_pictures\n\n end", "def show\n @tags_ids = @document.tags.ids\n end", "def get_tags_by_url\n url = Url.find_by(id: params[:id])\n tags = url.tags\n render json: {code: 200, tags: tags}\n end", "def photos_tagged_user(uid)\n query = \"select pid, src_big, src_small from photo where pid in (select pid from photo_tag where subject = #{uid}) and owner=#{ATC_GID} order by created\"\n return MiniFB.call(FB_API_KEY, FB_SECRET_KEY, \"FQL.query\", \"query\" => query, \"session_key\" => FB_SESSION_KEY, \"expires\" => 0)\n end", "def show\n @photo = Photo.find(params[:id])\n @commentable = @photo\n @comments = @commentable.comments\n @comment = Comment.new\n\n if params[:tag]\n @photos = Photo.tagged_with(params[:tag])\n else\n @photos = Photo.all\n @comment = Comment.new\n end\n\n end", "def references\n @references\n end", "def linked_tags\n taggings.map {|tagging| tagging.tag.value}\n end", "def fetch_tags params\n encoded_image = Base64.strict_encode64(params[:image_file].tempfile.read)\n api_key = ENV[\"GOOGLE_API_KEY\"]\n api_url = \"https://vision.googleapis.com/v1/images:annotate?key=#{api_key}\"\n\n body = {\n requests: [{\n image: {\n content: encoded_image\n },\n features: [\n {\n type: 'LABEL_DETECTION', maxResults: 10\n }\n ]\n }]\n }\n # Send request.\n uri = URI.parse(api_url)\n https = Net::HTTP.new(uri.host, uri.port)\n https.use_ssl = true\n request = Net::HTTP::Post.new(uri.request_uri)\n request[\"Content-Type\"] = \"application/json\"\n response = https.request(request, body.to_json)\n\n # Add the generated labels to the list of tag\n JSON.parse(response.body)[\"responses\"].each do |res|\n res[\"labelAnnotations\"].each do |tag|\n @image.tags.prepend(tag[\"description\"], \",\")\n end\n end\n @image.tags = @image.tags.delete_suffix(',')\n end", "def gather_internal_refs\n #@files.each.with_object({}) do |(_, x), refs|\n @files.keys.each_with_object({}) do |i, refs|\n #x[:attachment] and next\n @files.get(i,:attachment) and next\n #file, = targetfile(x, read: true)\n file, = @files.targetfile_id(i, read: true)\n Nokogiri::XML(file)\n .xpath(ns(\"//bibitem[@type = 'internal']/\" \\\n \"docidentifier[@type = 'repository']\")).each do |d|\n a = d.text.split(%r{/}, 2)\n a.size > 1 or next\n refs[a[0]] ||= {}\n refs[a[0]][a[1]] = true\n end\n end\n end", "def refs(ref=nil)\n prefix = ref ? \"#{path_prefix}/refs/#{ref}\" : \"#{path_prefix}/refs\"\n Ghee::API::Repos::Git::Refs::Proxy.new(connection, prefix)\n end", "def tags\n @tags_with_count = Asset.tag_counts_on(:tags)\n \n @tags = @tags_with_count.map{|tag_hash| tag_hash = tag_hash.name }\n \n respond_to do |format|\n format.html\n format.json { render :json => @tags }\n end\n end", "def photo\n if @api && photo_link\n @api._get(photo_link)\n end\n end", "def taglist\n @tags = Note.tag_counts.map {|tag| tag.name}\n\n respond_to do |format|\n format.json { render json: @tags }\n end\n end", "def show\n @tags = @image.tag_list\n end", "def related\n @related ||= begin\n response = Fleakr::Api::MethodRequest.with_response!('tags.getRelated', :tag => value)\n (response.body/'rsp/tags/tag').map {|e| Tag.new(e) }\n end\n end", "def get_referencing_images(base_image_uuid)\n images = SLICE_REF.get_object(\"images\", :images)\n images.select! { |image|\n image.respond_to?(:base_image_uuid) && image.base_image_uuid == base_image_uuid && image.uuid != base_image_uuid\n }\n end", "def photos_for_merge\n photo_urls - ignored_photo_urls\n end", "def get_photo\n \n @photo = Photo.find_by_ref(params[:ref]) unless params[:ref].nil?\n \n # Only continue action if a photo was associated with the request, otherwise, redirect user\n if @photo.nil?\n \n # Notice message\n flash[:notice] = \"Something went wrong\"\n \n respond_to do |format|\n format.html { redirect_to :back }\n format.json { render :json => false }\n end\n \n else\n \n # Check if the user is the owner of the photo\n @is_owner = @user.id == @photo.user_id\n \n end\n \n end", "def tagged( params={} )\n tagged = get_connections(\"tagged\", params)\n return map_connections tagged, :to => Facebook::Graph::Tagge\n end", "def update\n # creates tag objects for photos\n tag_array = tag_params['tags'].split(',').each do |x|\n x.strip!\n end\n tag_array.each do |x| \n if Tag.find_by(name: x)\n @tag = Tag.find_by(name: x)\n else\n @tag = Tag.create(name: x)\n end\n Tagging.create(photo_id: @photo.id, tag_id: @tag.id)\n end\n\n respond_to do |format|\n if @photo.update(photo_params)\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { render :show, status: :ok, location: @photo }\n else\n format.html { render :edit }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def tags( params={} )\n tags = get_connections(\"tags\", params)\n return map_connections tags, :to => Facebook::Graph::Generic\n end", "def tags\n object.tags.map {|tag| tag.id}\n end", "def refs\n @refs ||= load_refs\n end", "def tag\n # NB: the PageRefsController handles a GET request to set up tagging, taking params[:extractions] into account\n if current_user\n update_options = { :skip_landing => true } # We're not going to wait for the entity to process\n # Collectibles include both PageRefs and other entities (Recipe, Site, etc.) that HAVE PageRefs\n # Furthermore, when initially collecting a URL, we may be tagging the entity BY REFERENCE to its PageRef, in\n # which case we need to tag the corresponding entity, either by picking one or making a new one.\n # #edittable_proxify() sorts all that out, returning an editable model and (for a POST call) parameters for modification\n model, modelparams = edittable_proxy # A page_ref may proxify into the associated Recipe or Site, or another PageRef\n if @page_ref\n @page_ref.adopt_extractions params[:extractions] if params[:extractions]\n @page_ref.save if (@page_ref != model) && (!@page_ref.persisted? || @page_ref.changed?) # Trigger launch as nec.\n update_options[:needs] = [ :picurl, :title ]\n end\n modelname = model.model_name.param_key\n params[modelname] = modelparams\n\n # The editable tag tokens need to be set through the decorator, since Taggable\n # doesn't know what tag types pertain.\n # So, first we pull the misc_tag_tokens from the params...\n misc_tag_tokens = params[modelname].delete :editable_misc_tag_tokens\n # Now the parameters should reflect the target type, and we can proceed as usual\n update_options.merge! (request.method == 'GET') ?\n { touch: :collect } : # Ensure that it's collected before editing\n # We have to provide update parameters, in case the model name doesn't match the controller\n { update_attributes: true, attribute_params: strong_parameters(modelname) }\n\n update_and_decorate model, update_options\n # ...now we apply the misc tag tokens (if any) according to the constraints of the decorator\n @decorator.send @decorator.misc_tags_name_expanded('editable_misc_tag_tokens='), misc_tag_tokens if misc_tag_tokens\n if resource_errors_to_flash @decorator, preface: 'Couldn\\'t save.'\n render :errors\n else\n unless request.method == 'GET'\n flash[:popup] = \"#{@decorator.human_name} saved\"\n render 'collectible/update.json'\n else\n response_service.title = @decorator.title.truncate(20) # Get title (or name, etc.) from the entity\n smartrender\n end\n end\n else\n respond_to do |format|\n format.html {# This is for capturing a new recipe and tagging it using a new page.\n # Defer request, redirecting it for JSON\n login_required :format => :json\n }\n format.json {\n # Not logged in => have to store recipe parameters (url, title, comment) in a safe place pending login\n # session[:pending_recipe] = params[:recipe].merge page_ref_id: page_ref.id\n # After login, we'll be returned to this request to complete tagging\n login_required\n }\n end\n end\n end", "def tags_url\n view_context.tags_url\n end", "def references\n return @references\n end", "def addTags(photo,tags)\n photo = photo.id if photo.class == Flickr::Photo\n tstr = tags.join(',')\n @flickr.call_method('flickr.photos.addTags',\n 'photo_id' => photo, 'tags' => tstr)\n end", "def tag_ref_params\n params.require(:tag_ref).permit(:tag_id, :article_id)\n end", "def photos( params={} )\n photos = get_connections(\"photos\", params)\n return map_connections photos, :to => Facebook::Graph::Photo\n end", "def get_img_tags\n @tp = Temp.find_by_id(params[:id])\n @tp.included_images \n render :json => @tp.included_images\n # render :text => @tp.included_images \n end", "def refs(test_case)\n all_tags(test_case).select{|tag| tag.name =~/(?:jira|ref)_/}.map{|ticket| /(?:jira|ref)_(\\w+-\\d+)$/.match(ticket.name)[1]}.uniq.join(\",\")\n end", "def show\n @images = Image.tagged_with @tag\n end", "def get_tags(node, tag_attr_references)\n tag_attr_references.flat_map do |ref|\n v = node[ref]\n node.delete(ref) if ref.start_with? TAG_ATTR_PREFIX\n v\n end\n end", "def search(tags, params)\n begin\n server = XMLRPC::Client.new2(self.service_uri)\n flickr_arguments = {:api_key => self.api_key, \n :tag_mode => \"all\", \n :page => params[:page].to_i,\n :per_page => params[:per_page].to_i, \n :tags => tags.downcase.split().join(','),\n :sort => flickerize_sort(params[:sort_by]),\n :extras => \"tags, date_upload\"}\n flickr_response = server.call(\"flickr.photos.search\", flickr_arguments)\n flickr_response = @ic.iconv(flickr_response)\n document = REXML::Document.new flickr_response\n rescue Exception => e\n puts \"Fehler beim Flickrrequest: #{e.to_s}\"\n document = REXML::Document.new\n else\n #the response dependent attributes\n resource_list = General::ResourceList.new(:tagging_system => self,\n :resources => Array.new,\n :total_pages => document.root.attributes[\"pages\"].to_i,\n :total_results => document.root.attributes[\"total\"].to_i,\n :actual_page => params[:page].to_i)\n if document.root.has_elements?\n #get the resourceproperties\n document.root.each_element do |photo|\n photo_id = photo.attributes[\"id\"]\n photo_title = photo.attributes[\"title\"]\n photo_upload_date = human_time(photo.attributes[\"dateupload\"])\n photo_tags = photo.attributes[\"tags\"].downcase.split\n # resource url relevant properties\n photo_farm = photo.attributes[\"farm\"]\n photo_server = photo.attributes[\"server\"]\n photo_secret = photo.attributes[\"secret\"]\n photo_description = nil\n \n resource = General::Resource.new(:resource_id => photo_id,\n :title => photo_title,\n :upload_date => photo_upload_date,\n :tags => photo_tags,\n :description => photo_description,\n :list_thumb_url => get_url_for(photo_farm, photo_server, photo_id, photo_secret, \"t\"),\n :js_thumb_url => get_url_for(photo_farm, photo_server, photo_id, photo_secret, \"m\"))\n \n resource_list.resources.push(resource)\n end\n end\n return resource_list\n end\n end", "def index\n # @photos = Photo.order(sort_column + \" \" + sort_direction).paginate(page: params[:page], per_page: 10)\n\n @photos = Photo.paginate(page: params[:page])\n\n if params[:tag]\n @photos = @photos.tagged_with(params[:tag])\n end\n\n end", "def photo_urls\n photos = item_hash.deep_find([:picture_details, :picture_url])\n return [] if photos.nil?\n (photos.is_a?(Array)) ? photos : [photos]\n end", "def photo_link_entry\n self[\"link\"].find { |l| l.rel == \"http://schemas.google.com/contacts/2008/rel#photo\" }\n end", "def references\n @references ||= message.references || []\n end", "def get_related_tags(tag)\r\n\t\tsimilar_tags = lastfm.tag.get_similar(tag)\r\n\t\tputs tag + \" had these similar tags: \" + similar_tags\r\n\t\tsimilar_tags.each do |st|\r\n\t\t\[email protected] \"INSERT INTO xref_tag_relations (tag_a, tag_b) VALUES (?,?)\", tag, st\r\n\t\tend\r\n\r\n\tend", "def get_collection_object_references\n # get ids of collection object links\n link_ids = CollectionobjectLink.where(\"resource_id = ?\", self.id).pluck(:id)\n resource_ids = MediaFile.where(\"sourceable_id IN (?)\", link_ids).pluck(:resource_id)\n\n #\n rel_resource_ids = RelatedResource.where(\"to_resource_id = ?\", self.id).pluck(:resource_id)\n\n all_resource_ids = rel_resource_ids + resource_ids\n\n begin\n Resource.find(all_resource_ids)\n rescue\n return []\n end\n end", "def tags\n @obj['tags']\n end", "def tag_attachment\n @tag_attachment = TagAttachment.find(params[:id])\n end", "def references(collection)\n target.try(:references, collection) || []\n end", "def media_file_references\n mf_references = {}\n\n self.collectionobject_links.each do |co_link|\n begin\n co_resource = Resource.find(co_link.resource_id)\n\n MediaFile.where('sourceable_id=? AND resource_id=?', co_link.id, self.id).find_each do |media_resource|\n if media_resource.access == 1 and media_resource.display_collectionobject_link == 1\n mf_references[co_resource.id] = [co_resource.title, co_resource.collection_identifier]\n end\n end\n rescue => e\n # noop\n end\n end\n return mf_references\n end", "def parse_attachment_reference_uuids_from_content(content)\n ids = []\n doc = Nokogiri::HTML(content)\n doc.css('img').each do |image|\n id = parse_attachment_reference_uuid_from_url(image['src'])\n ids << id if id\n end\n\n ids\n end", "def parse_attachment_reference_ids_from_content(content)\n ids = []\n doc = Nokogiri::HTML(content)\n doc.css('img').each do |image|\n id = parse_attachment_reference_id_from_url(image['src'])\n ids << id if id\n end\n\n ids\n end", "def index\n @image_tags = ImageTag.all\n end", "def tags() ; info[:tags] ; end", "def tags() ; info[:tags] ; end", "def index\n @references = Reference.all\n\n render json: @references\n end", "def linkbaseRef_tags\n attribute_tags.map do |attr_tag|\n attr_tag.annotation_tags.map do |anno_tag|\n anno_tag.appInfo_tags.map do |appinfo|\n appinfo.extend_children_with_tag(NS_LINK, 'linkbaseRef', ::XBRL::Linkbase::LinkbaseRef)\n end\n end\n end.flatten\n end", "def refs\n @refs\n end", "def tags\n @tags ||= ApiFactory.new 'GitData::Tags'\n end", "def plugin_refs(ref: nil, depth: 0)\n return [] if depth > 2\n\n introspector = LiquidTagFinder.new(content)\n plugin_names = introspector.plugin_names\n collector = plugin_names.empty? ? [] : [[plugin_names[0], ref]]\n introspector.partial_refs.each do |partial, child_ref|\n child_partial = LiquidPartial.where(title: partial).first\n next if child_partial.blank?\n\n collector += child_partial.plugin_refs(ref: child_ref, depth: depth + 1)\n end\n collector.uniq\n end", "def get_v1_related_tags_with_http_info(tag_list, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TagApi.get_v1_related_tags ...'\n end\n # verify the required parameter 'tag_list' is set\n if @api_client.config.client_side_validation && tag_list.nil?\n fail ArgumentError, \"Missing the required parameter 'tag_list' when calling TagApi.get_v1_related_tags\"\n end\n # resource path\n local_var_path = '/v1/related-tags'\n\n # query parameters\n query_params = {}\n query_params[:'tag_list'] = tag_list\n query_params[:'include_deleted'] = opts[:'include_deleted'] if !opts[:'include_deleted'].nil?\n query_params[:'bucket'] = opts[:'bucket'] if !opts[:'bucket'].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\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\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 => 'RelatedTagResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TagApi#get_v1_related_tags\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def tagged( params={} )\n tagged = get_connections(\"tagged\", params)\n return map_connections tagged, :to => Facebook::Graph::Generic\n end", "def tags\n @data['tags']\n end", "def references\n @data[:refs].map { |ref|\n ref[:id] = nil\n ref[:doi] = nil if ref[:doi].nil?\n ref[:volume] = nil if ref[:volume].nil?\n ref[:journal_name] = nil if ref[:journal_name].nil?\n RefEm::Entity::Reference.new(ref)\n }\n end", "def get_tags(blob)\n\n #Rails.logger.info(\"[LIB] [SOCIAL_FETCH] [FETCHER] [FACEBOOK] [get_tags] Entering\")\n\n tags = []\n\n tags = ::Api::Helpers::Parser.get_tags({:text =>blob[\"message\"]}) if !blob[\"message\"].blank?\n\n #Rails.logger.info(\"[LIB] [SOCIAL_FETCH] [FETCHER] [FACEBOOK] [get_tags] Leaving\")\n tags\n rescue => e\n Rails.logger.error(\"[LIB] [SOCIAL_FETCH] [FETCHER] [FACEBOOK] [get_tags] **** RESCUE **** => #{e.message} for #{blob.inspect}\")\n []\n end", "def extract_tags!\n @tagmap = {}\n data.gsub!(/(.?)\\[\\[(.+?)\\]\\]([^\\[]?)/m) do\n if $1 == \"'\" && $3 != \"'\"\n \"[[#{$2}]]#{$3}\"\n elsif $2.include?('][')\n if $2[0..4] == 'file:'\n pre = $1\n post = $3\n parts = $2.split('][')\n parts[0][0..4] = \"\"\n link = \"#{parts[1]}|#{parts[0].sub(/\\.org/,'')}\"\n id = Digest::SHA1.hexdigest(link)\n @tagmap[id] = link\n \"#{pre}#{id}#{post}\"\n else\n $&\n end\n else\n id = Digest::SHA1.hexdigest($2)\n @tagmap[id] = $2\n \"#{$1}#{id}#{$3}\"\n end\n end\n nil\n end", "def get_untagged(args = {})\r\n PhotoList.new('flickr.photos.getUntagged', args)\r\n end", "def photos(id, group = 'checkin', options = {})\n get(\"venues/#{id}/photos\", {:group => group }.merge(options)).photos\n end", "def photo( photo_id )\n Photo.find( photo_id, self )\n end", "def index\n @references = Reference.all\n end", "def index\n @references = Reference.all\n end" ]
[ "0.68515515", "0.6600326", "0.6443113", "0.63678175", "0.6323055", "0.61629534", "0.6062828", "0.5960789", "0.59396493", "0.593711", "0.5936961", "0.5933352", "0.58903474", "0.5790465", "0.57846105", "0.57844365", "0.57674474", "0.57613236", "0.57411736", "0.5731385", "0.5708273", "0.5676804", "0.5676517", "0.5617869", "0.5595998", "0.55820054", "0.5570235", "0.5563059", "0.55501723", "0.55012774", "0.5490165", "0.54615945", "0.5461121", "0.54378194", "0.54378194", "0.54329515", "0.54297745", "0.54193443", "0.54143023", "0.5413388", "0.5407791", "0.54000854", "0.53858864", "0.5379844", "0.53767467", "0.53754413", "0.5374616", "0.53554654", "0.5354085", "0.53100514", "0.53096306", "0.5305678", "0.52965593", "0.52887374", "0.52817535", "0.5276817", "0.5265241", "0.5263191", "0.52619326", "0.52501434", "0.52384186", "0.52225274", "0.52184576", "0.5216164", "0.52132195", "0.52007145", "0.51955795", "0.5193697", "0.51889986", "0.5184441", "0.5168135", "0.5165632", "0.5150054", "0.51477534", "0.5116652", "0.5114626", "0.51103103", "0.51094997", "0.51052487", "0.51050156", "0.51023203", "0.50990295", "0.5093254", "0.5093254", "0.50921184", "0.5089807", "0.5087989", "0.5084247", "0.50798976", "0.50655085", "0.50653756", "0.5062191", "0.50533074", "0.50515294", "0.50503874", "0.504963", "0.50492346", "0.5047516", "0.50433576", "0.50433576" ]
0.78492594
0
GET /photo_tag_references/1 GET /photo_tag_references/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @photo_tag_references = PhotoTagPhoto.all\n end", "def set_photo_tag_reference\n @photo_tag_reference = PhotoTagPhoto.find(params[:id])\n end", "def index\n @tag_refs = TagRef.all\n end", "def show\n @tag = Tag.find(params[:id])\n if current_admin\n if params[:pin]\n @tag.photo_id = params[:pin]\n @tag.save\n end\n end\n # @category_photo = @tag.photo\n @photos = Photo.includes(:tags).where(:tags => {:name => @tag.name})\n @untagged_photos = []\n Photo.all.each do |p|\n @untagged_photos << p if p.tags.count == 0\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tag }\n end\n end", "def photo_tag_reference_params\n params.require(:photo_tag_photo).permit(:photo_id, :photo_tag_id)\n end", "def show\n @taggable = current_user.taggables.find(params[:id])\n @tags = @taggable.tags\n @url_no_path = URI.parse(@taggable.photo.url).path[%r{[^/]+\\z}]\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taggable }\n end\n end", "def tags\n _get(\"/query/image/tags\") { |json| json }\n end", "def destroy\n @photo_tag_reference.destroy\n respond_to do |format|\n format.html { redirect_to photo_tag_references_url, notice: 'Photo tag reference was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n @photo_tag_reference = PhotoTagPhoto.new(photo_tag_reference_params)\n\n respond_to do |format|\n if @photo_tag_reference.save\n format.html { redirect_to @photo_tag_reference, notice: 'Photo tag reference was successfully created.' }\n format.json { render :show, status: :created, location: @photo_tag_reference }\n else\n format.html { render :new }\n format.json { render json: @photo_tag_reference.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @photo_tag_photo.update(photo_tag_reference_params)\n format.html { redirect_to @photo_tag_reference, notice: 'Photo tag reference was successfully updated.' }\n format.json { render :show, status: :ok, location: @photo_tag_reference }\n else\n format.html { render :edit }\n format.json { render json: @photo_tag_reference.errors, status: :unprocessable_entity }\n end\n end\n end", "def tags_from_reference(reference)\n response = client.get(\"2.0/tracks/reference/#{reference}/tags\")\n\n response.map { |tag| Struct::Tag.new(tag) }\n end", "def show\n # Pull the selected photo album.\n @photo_tag = PhotoTag.find(params[:id])\n\n respond_to do |format|\n format.json do\n render json: @photo_tag\n end\n end\n end", "def set_tag_ref\n @tag_ref = TagRef.find(params[:id])\n end", "def convert_ref_tags; end", "def references\n @references ||= ApiFactory.new 'GitData::References'\n end", "def references\n references_hash.to_json\n end", "def get_refs(way)\n return [] if !way.tags.has_key?('ref')\n return way.tags['ref'].split(/(;|,)/).collect {|ref| ref.strip}\n end", "def photo(photo, options = {})\n get(\"photos/#{photo}\", options).pop\n end", "def index\n if params[:tag] == nil\n @photos = Photo.where('user_id=?',session[:user_id]).latest.paginate(:page=>params[:page], :per_page=>10)\n else\n @photos = Photo.tagged_with(params[:tag]).where('user_id=?',session[:user_id]).latest.paginate(:page=>params[:page],:per_page=>10)\n end\n @tags = Photo.tag_counts_on(:tags)\n @tag_name=params[:tag]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @photos }\n end\n end", "def set_photo_tag\n @photo_tag = PhotoTag.find(params[:id])\n end", "def photo_tags\n all_tags = Hash.new {|h,k| h[k]=[]}\n self.tags.find_each do |t|\n all_tags[t.field] << t.value\n end\n all_tags\n end", "def index\n @photo_tags = PhotoTag.select_by_locale(params[:locale])\n\t@curTag = PhotoTag.find_by_id(params[:tag_id])\n\t@photos = []\n\t@photos = @curTag.photos if [email protected]?\n end", "def get_tags_uri\n @get_tags_uri ||= \"#{base_uri}/gettags\"\n end", "def parse_references\n globbed_references = body.scan(/(.*?\\))/)\n\n globbed_references.each do |reference|\n url = reference.first.scan(/(?<=\\().*(?=\\))/).first\n next unless url\n\n if url.include?('users')\n # Do nothing for now when it's a mention of a user\n # FIXME - this is junk\n elsif url.include?('ideas') && idea = Idea.find_by_sha(url.gsub('/ideas/', ''))\n # When this is an idea we know about, make a hard link\n self.idea_references.build(:referenced_id => idea.id)\n else\n # Just leave it in the body without doing anything.\n end\n end\n end", "def print_each_photo(api_key, tag)\n # Build the URI\n uri = \"http://www.flickr.com/services/rest?method=flickr.photos.search\" +\n \"&api_key=#{api_key}&tags=#{tag}\"\n\n # Make the HTTP request and get the entity-body.\n response = open(uri).read\n\n # Parse the entity-body as an XML document.\n doc = REXML::Document.new(response)\n\n # For each photo found...\n REXML::XPath.each(doc, '//photo') do |photo| \n # ...generate and print its URI\n puts small_photo_uri(photo) if photo\n end\nend", "def related\n @related ||= begin\n response = Fleakr::Api::MethodRequest.with_response!('tags.getRelated', :tag => value)\n (response.body/'rsp/tags/tag').map {|e| Tag.new(e) }\n end\n end", "def tags\n get('tags')\n end", "def tags\n @audio_file = AudioFile.find(params[:id])\n @tags = @audio_file.tags\n\n respond_to do |format|\n format.html # tags.html.erb\n format.xml { render :xml => @tags }\n format.json { render :json => @tags }\n end\n end", "def references\n (headers['References']||'').scan(/(<[^<]+?>)/).flatten\n end", "def index\n @taggables = current_user.taggables\n @taggable_center = current_user.taggables.first\n \n\n if !@taggable_center.nil?\n @url_no_path = URI.parse(@taggable_center.photo.url(:editable)).path[%r{[^/]+\\z}]\n @url_path = URI.parse(@taggable_center.photo.url(:editable)).path\n @tags = @taggable_center.tags\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @taggables }\n end\n end", "def photo\n if @api && photo_link\n @api._get(photo_link)\n end\n end", "def get_tags_by_url\n url = Url.find_by(id: params[:id])\n tags = url.tags\n render json: {code: 200, tags: tags}\n end", "def show\n @photo = Photo.find(params[:id])\n @commentable = @photo\n @comments = @commentable.comments\n @comment = Comment.new\n\n if params[:tag]\n @photos = Photo.tagged_with(params[:tag])\n else\n @photos = Photo.all\n @comment = Comment.new\n end\n\n end", "def gather_internal_refs\n #@files.each.with_object({}) do |(_, x), refs|\n @files.keys.each_with_object({}) do |i, refs|\n #x[:attachment] and next\n @files.get(i,:attachment) and next\n #file, = targetfile(x, read: true)\n file, = @files.targetfile_id(i, read: true)\n Nokogiri::XML(file)\n .xpath(ns(\"//bibitem[@type = 'internal']/\" \\\n \"docidentifier[@type = 'repository']\")).each do |d|\n a = d.text.split(%r{/}, 2)\n a.size > 1 or next\n refs[a[0]] ||= {}\n refs[a[0]][a[1]] = true\n end\n end\n end", "def references; end", "def references; end", "def references\n @references ||= []\n end", "def fetch_tags params\n encoded_image = Base64.strict_encode64(params[:image_file].tempfile.read)\n api_key = ENV[\"GOOGLE_API_KEY\"]\n api_url = \"https://vision.googleapis.com/v1/images:annotate?key=#{api_key}\"\n\n body = {\n requests: [{\n image: {\n content: encoded_image\n },\n features: [\n {\n type: 'LABEL_DETECTION', maxResults: 10\n }\n ]\n }]\n }\n # Send request.\n uri = URI.parse(api_url)\n https = Net::HTTP.new(uri.host, uri.port)\n https.use_ssl = true\n request = Net::HTTP::Post.new(uri.request_uri)\n request[\"Content-Type\"] = \"application/json\"\n response = https.request(request, body.to_json)\n\n # Add the generated labels to the list of tag\n JSON.parse(response.body)[\"responses\"].each do |res|\n res[\"labelAnnotations\"].each do |tag|\n @image.tags.prepend(tag[\"description\"], \",\")\n end\n end\n @image.tags = @image.tags.delete_suffix(',')\n end", "def references\n GameContent.where reference_id: self.id\n end", "def taglist\n @tags = Note.tag_counts.map {|tag| tag.name}\n\n respond_to do |format|\n format.json { render json: @tags }\n end\n end", "def get_photos\n tag = [\"urbanlandscape\",\"architecture\",\"buildings\",\"archidaily\"].sample\n return_hash = HTTParty.get(\"https://api.instagram.com/v1/tags/#{tag}/media/recent?client_id=#{INSTAGRAM_CLIENT_ID}\")\n @instagram_photos = [return_hash[\"data\"].sample[\"images\"][\"low_resolution\"][\"url\"], return_hash[\"data\"].sample[\"images\"][\"low_resolution\"][\"url\"],return_hash[\"data\"].sample[\"images\"][\"low_resolution\"][\"url\"],\n return_hash[\"data\"].sample[\"images\"][\"low_resolution\"][\"url\"]]\n end", "def photos options={}\n response = client.get(\"/#{id}/photos\", options)\n end", "def tags\n @tags_with_count = Asset.tag_counts_on(:tags)\n \n @tags = @tags_with_count.map{|tag_hash| tag_hash = tag_hash.name }\n \n respond_to do |format|\n format.html\n format.json { render :json => @tags }\n end\n end", "def update\n # creates tag objects for photos\n tag_array = tag_params['tags'].split(',').each do |x|\n x.strip!\n end\n tag_array.each do |x| \n if Tag.find_by(name: x)\n @tag = Tag.find_by(name: x)\n else\n @tag = Tag.create(name: x)\n end\n Tagging.create(photo_id: @photo.id, tag_id: @tag.id)\n end\n\n respond_to do |format|\n if @photo.update(photo_params)\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { render :show, status: :ok, location: @photo }\n else\n format.html { render :edit }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def refs(ref=nil)\n prefix = ref ? \"#{path_prefix}/refs/#{ref}\" : \"#{path_prefix}/refs\"\n Ghee::API::Repos::Git::Refs::Proxy.new(connection, prefix)\n end", "def get_photo\n \n @photo = Photo.find_by_ref(params[:ref]) unless params[:ref].nil?\n \n # Only continue action if a photo was associated with the request, otherwise, redirect user\n if @photo.nil?\n \n # Notice message\n flash[:notice] = \"Something went wrong\"\n \n respond_to do |format|\n format.html { redirect_to :back }\n format.json { render :json => false }\n end\n \n else\n \n # Check if the user is the owner of the photo\n @is_owner = @user.id == @photo.user_id\n \n end\n \n end", "def tag_attachment\n @tag_attachment = TagAttachment.find(params[:id])\n end", "def photo_link_entry\n self[\"link\"].find { |l| l.rel == \"http://schemas.google.com/contacts/2008/rel#photo\" }\n end", "def show\n @tags_ids = @document.tags.ids\n end", "def get_v1_related_tags_with_http_info(tag_list, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TagApi.get_v1_related_tags ...'\n end\n # verify the required parameter 'tag_list' is set\n if @api_client.config.client_side_validation && tag_list.nil?\n fail ArgumentError, \"Missing the required parameter 'tag_list' when calling TagApi.get_v1_related_tags\"\n end\n # resource path\n local_var_path = '/v1/related-tags'\n\n # query parameters\n query_params = {}\n query_params[:'tag_list'] = tag_list\n query_params[:'include_deleted'] = opts[:'include_deleted'] if !opts[:'include_deleted'].nil?\n query_params[:'bucket'] = opts[:'bucket'] if !opts[:'bucket'].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\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\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 => 'RelatedTagResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TagApi#get_v1_related_tags\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @tags = @image.tag_list\n end", "def tags\n get.tagGuids\n end", "def index\n @references = Reference.all\n\n render json: @references\n end", "def photos_tagged_user(uid)\n query = \"select pid, src_big, src_small from photo where pid in (select pid from photo_tag where subject = #{uid}) and owner=#{ATC_GID} order by created\"\n return MiniFB.call(FB_API_KEY, FB_SECRET_KEY, \"FQL.query\", \"query\" => query, \"session_key\" => FB_SESSION_KEY, \"expires\" => 0)\n end", "def parse_reference_ids full_document\n full_document.gsub(/%r(\\d+)/) do\n if Reference.exists? $1\n reference = Reference.find($1)\n reference.decorate.to_link\n else\n broken_markdown_link \"reference\", $1\n end\n end\n end", "def ref(logical_id)\n {\"Ref\" => xref(logical_id)}\n end", "def photo( photo_id )\n Photo.find( photo_id, self )\n end", "def linked_tags\n taggings.map {|tagging| tagging.tag.value}\n end", "def tag\n # NB: the PageRefsController handles a GET request to set up tagging, taking params[:extractions] into account\n if current_user\n update_options = { :skip_landing => true } # We're not going to wait for the entity to process\n # Collectibles include both PageRefs and other entities (Recipe, Site, etc.) that HAVE PageRefs\n # Furthermore, when initially collecting a URL, we may be tagging the entity BY REFERENCE to its PageRef, in\n # which case we need to tag the corresponding entity, either by picking one or making a new one.\n # #edittable_proxify() sorts all that out, returning an editable model and (for a POST call) parameters for modification\n model, modelparams = edittable_proxy # A page_ref may proxify into the associated Recipe or Site, or another PageRef\n if @page_ref\n @page_ref.adopt_extractions params[:extractions] if params[:extractions]\n @page_ref.save if (@page_ref != model) && (!@page_ref.persisted? || @page_ref.changed?) # Trigger launch as nec.\n update_options[:needs] = [ :picurl, :title ]\n end\n modelname = model.model_name.param_key\n params[modelname] = modelparams\n\n # The editable tag tokens need to be set through the decorator, since Taggable\n # doesn't know what tag types pertain.\n # So, first we pull the misc_tag_tokens from the params...\n misc_tag_tokens = params[modelname].delete :editable_misc_tag_tokens\n # Now the parameters should reflect the target type, and we can proceed as usual\n update_options.merge! (request.method == 'GET') ?\n { touch: :collect } : # Ensure that it's collected before editing\n # We have to provide update parameters, in case the model name doesn't match the controller\n { update_attributes: true, attribute_params: strong_parameters(modelname) }\n\n update_and_decorate model, update_options\n # ...now we apply the misc tag tokens (if any) according to the constraints of the decorator\n @decorator.send @decorator.misc_tags_name_expanded('editable_misc_tag_tokens='), misc_tag_tokens if misc_tag_tokens\n if resource_errors_to_flash @decorator, preface: 'Couldn\\'t save.'\n render :errors\n else\n unless request.method == 'GET'\n flash[:popup] = \"#{@decorator.human_name} saved\"\n render 'collectible/update.json'\n else\n response_service.title = @decorator.title.truncate(20) # Get title (or name, etc.) from the entity\n smartrender\n end\n end\n else\n respond_to do |format|\n format.html {# This is for capturing a new recipe and tagging it using a new page.\n # Defer request, redirecting it for JSON\n login_required :format => :json\n }\n format.json {\n # Not logged in => have to store recipe parameters (url, title, comment) in a safe place pending login\n # session[:pending_recipe] = params[:recipe].merge page_ref_id: page_ref.id\n # After login, we'll be returned to this request to complete tagging\n login_required\n }\n end\n end\n end", "def reference\n @refs ||= strip(:reference)\n end", "def get_img_tags\n @tp = Temp.find_by_id(params[:id])\n @tp.included_images \n render :json => @tp.included_images\n # render :text => @tp.included_images \n end", "def orchio_get_by_ref(ref)\n response = client.send_request :get, inst_args(ref: ref)\n Result.new(\n status: orchio_status(response, 200),\n response: response,\n results: [ Document.new(\n response.body.to_hash,\n Metadata.new(\n :collection => ocollection,\n :key => @id,\n :ref => response.header.etag\n ))]\n )\n end", "def references\n @references\n end", "def tag_ref_params\n params.require(:tag_ref).permit(:tag_id, :article_id)\n end", "def get_image_reference\n image_id = $redis.hget(\"#{remote_ip}.#{session}.image_reference\", :image_id)\n [{ image_id: image_id }] if image_id\n end", "def get_referencing_images(base_image_uuid)\n images = SLICE_REF.get_object(\"images\", :images)\n images.select! { |image|\n image.respond_to?(:base_image_uuid) && image.base_image_uuid == base_image_uuid && image.uuid != base_image_uuid\n }\n end", "def destroy\n @image_reference.destroy\n respond_to do |format|\n format.html { redirect_to image_references_url }\n format.json { head :no_content }\n end\n end", "def tags\n object.tags.map {|tag| tag.id}\n end", "def create\n @tag_ref = TagRef.new(tag_ref_params)\n @article = Article.find(params[:article])\n\n respond_to do |format|\n if @tag_ref.save\n format.html {redirect_to article_tags_article_path(@article), notice: 'Dodano Tag do artykułu.' }\n format.json { render :show, status: :created, location: @tag_ref }\n else\n format.html { render :new }\n format.json { render json: @tag_ref.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n params[:tag] ? @photos = Photo.tagged_with(params[:tag]) : @photos = Photo.all\n album = params[:album_id]\n @photos = current_user.photos.all.where(album_id: album).with_attached_pictures\n\n end", "def search(tags, params)\n begin\n server = XMLRPC::Client.new2(self.service_uri)\n flickr_arguments = {:api_key => self.api_key, \n :tag_mode => \"all\", \n :page => params[:page].to_i,\n :per_page => params[:per_page].to_i, \n :tags => tags.downcase.split().join(','),\n :sort => flickerize_sort(params[:sort_by]),\n :extras => \"tags, date_upload\"}\n flickr_response = server.call(\"flickr.photos.search\", flickr_arguments)\n flickr_response = @ic.iconv(flickr_response)\n document = REXML::Document.new flickr_response\n rescue Exception => e\n puts \"Fehler beim Flickrrequest: #{e.to_s}\"\n document = REXML::Document.new\n else\n #the response dependent attributes\n resource_list = General::ResourceList.new(:tagging_system => self,\n :resources => Array.new,\n :total_pages => document.root.attributes[\"pages\"].to_i,\n :total_results => document.root.attributes[\"total\"].to_i,\n :actual_page => params[:page].to_i)\n if document.root.has_elements?\n #get the resourceproperties\n document.root.each_element do |photo|\n photo_id = photo.attributes[\"id\"]\n photo_title = photo.attributes[\"title\"]\n photo_upload_date = human_time(photo.attributes[\"dateupload\"])\n photo_tags = photo.attributes[\"tags\"].downcase.split\n # resource url relevant properties\n photo_farm = photo.attributes[\"farm\"]\n photo_server = photo.attributes[\"server\"]\n photo_secret = photo.attributes[\"secret\"]\n photo_description = nil\n \n resource = General::Resource.new(:resource_id => photo_id,\n :title => photo_title,\n :upload_date => photo_upload_date,\n :tags => photo_tags,\n :description => photo_description,\n :list_thumb_url => get_url_for(photo_farm, photo_server, photo_id, photo_secret, \"t\"),\n :js_thumb_url => get_url_for(photo_farm, photo_server, photo_id, photo_secret, \"m\"))\n \n resource_list.resources.push(resource)\n end\n end\n return resource_list\n end\n end", "def refs\n @refs ||= load_refs\n end", "def tag\n Tag.find(tag_id)\n end", "def reference\n @data['reference']\n end", "def destroy\n @tag_ref.destroy\n respond_to do |format|\n format.html { redirect_to tag_refs_url, notice: 'Usunięto Tag z artykułu.' }\n format.json { head :no_content }\n end\n end", "def create\n @photo_tag = PhotoTag.new(photo_tag_params)\n\n respond_to do |format|\n if @photo_tag.save\n format.html { redirect_to @photo_tag, notice: 'Photo tag was successfully created.' }\n format.json { render :show, status: :created, location: @photo_tag }\n else\n format.html { render :new }\n format.json { render json: @photo_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_related_tags(tag)\r\n\t\tsimilar_tags = lastfm.tag.get_similar(tag)\r\n\t\tputs tag + \" had these similar tags: \" + similar_tags\r\n\t\tsimilar_tags.each do |st|\r\n\t\t\[email protected] \"INSERT INTO xref_tag_relations (tag_a, tag_b) VALUES (?,?)\", tag, st\r\n\t\tend\r\n\r\n\tend", "def index\n @references = Reference.all\n end", "def index\n @references = Reference.all\n end", "def tags\n @tags ||= ApiFactory.new 'GitData::Tags'\n end", "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/photos/#{params[:id]}.json?token=#{ENV['API_KEY']}\"\n\t response = RestClient.get(url)\n\t @photo = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/photos.json?token=#{ENV['API_KEY']}\"\n response = RestClient.get(url)\n @photos = JSON.parse(response.body)\t\t \n\tend\n end", "def tag\n @favors = Favor.tagged_with(params[:tag], :order => @order)\n @tag = params[:tag]\n\n respond_to do |format|\n format.html # tag.html.erb\n format.json { render json: @favors }\n end\n end", "def tags_url\n view_context.tags_url\n end", "def test_get_tags\n post '/repos', {:name => GIT_REPO}\n post \"/repos/#{GIT_REPO}.git/branches/master/files\", {:name => \"myfile.txt\", :data => \"Hello There\", :encoding => \"utf-8\", :user => \"Rune Madsen\", :email => \"[email protected]\", :message => \"My First Commit\"}\n sha = JSON.parse(last_response.body)[\"commit_sha\"]\n post \"/repos/#{GIT_REPO}.git/tags\", {:tag => \"version1\", :message => \"hello\", :sha => sha, :type => \"commit\", :user => \"Rune Madsen\", :email => \"[email protected]\"}\n get \"/repos/#{GIT_REPO}.git/tags\"\n end", "def show\n @images = Image.tagged_with @tag\n end", "def get_untagged(args = {})\r\n PhotoList.new('flickr.photos.getUntagged', args)\r\n end", "def deli_tags(uri, id)\n begin\n md5 = Digest::MD5.hexdigest(uri)\n target = \"http://badges.del.icio.us/feeds/json/url/data?hash=#{md5}\"\n json = open(target).read\n deli = JSON.load(json)[0]\n tags = \"\"\n if deli['top_tags'].class == Hash then\n all_tags = deli['top_tags'].sort_by {|k,v| v}.reverse.map{|i|i[0]}\n if all_tags.size > 8 then\n all_tags = all_tags.first(8) << '...'\n end\n tags = '(' << all_tags.join(', ') << ')'\n end\n if deli['total_posts'].to_i > 0 then\n response = \"#{id}: (deli) #{deli['total_posts']} links, tagged #{tags}\"\n $q_meta.enq response\n end\n rescue\n puts \"problem fetching deli for #{uri}\"\n end\nend", "def references\n return @references\n end", "def parse_attachment_reference_uuids_from_content(content)\n ids = []\n doc = Nokogiri::HTML(content)\n doc.css('img').each do |image|\n id = parse_attachment_reference_uuid_from_url(image['src'])\n ids << id if id\n end\n\n ids\n end", "def index\n @image_tags = ImageTag.all\n end", "def parse_attachment_reference_ids_from_content(content)\n ids = []\n doc = Nokogiri::HTML(content)\n doc.css('img').each do |image|\n id = parse_attachment_reference_id_from_url(image['src'])\n ids << id if id\n end\n\n ids\n end", "def destroy\n @photo_tag.destroy\n respond_to do |format|\n format.html { redirect_to photo_tags_url, notice: 'Photo tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def tag_image_id name, pages = 1\n url = API + \"tags/#{name}/media/recent/?access_token=\" + @access_token\n pages.times do\n get(url)['data'].map do |image|\n unless image['user_has_liked']\n @image_ids << image['id']\n end\n end\n url = get(url)['pagination']['next_url']\n end\n export(@image_id_list, @image_ids)\n end", "def references\n @data[:refs].map { |ref|\n ref[:id] = nil\n ref[:doi] = nil if ref[:doi].nil?\n ref[:volume] = nil if ref[:volume].nil?\n ref[:journal_name] = nil if ref[:journal_name].nil?\n RefEm::Entity::Reference.new(ref)\n }\n end", "def photos_for_merge\n photo_urls - ignored_photo_urls\n end", "def tags\n @obj['tags']\n end", "def get_collection_object_references\n # get ids of collection object links\n link_ids = CollectionobjectLink.where(\"resource_id = ?\", self.id).pluck(:id)\n resource_ids = MediaFile.where(\"sourceable_id IN (?)\", link_ids).pluck(:resource_id)\n\n #\n rel_resource_ids = RelatedResource.where(\"to_resource_id = ?\", self.id).pluck(:resource_id)\n\n all_resource_ids = rel_resource_ids + resource_ids\n\n begin\n Resource.find(all_resource_ids)\n rescue\n return []\n end\n end", "def media_file_references\n mf_references = {}\n\n self.collectionobject_links.each do |co_link|\n begin\n co_resource = Resource.find(co_link.resource_id)\n\n MediaFile.where('sourceable_id=? AND resource_id=?', co_link.id, self.id).find_each do |media_resource|\n if media_resource.access == 1 and media_resource.display_collectionobject_link == 1\n mf_references[co_resource.id] = [co_resource.title, co_resource.collection_identifier]\n end\n end\n rescue => e\n # noop\n end\n end\n return mf_references\n end", "def tagged( params={} )\n tagged = get_connections(\"tagged\", params)\n return map_connections tagged, :to => Facebook::Graph::Tagge\n end", "def tag(name, options = {})\n get_path(\n path_to_tag(name),\n options,\n get_parser(:collection, Tinybucket::Model::Commit)\n )\n end", "def show\n @look_book = LookBook.find(params[:id])\n\n @photos = @look_book.photos\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @look_book }\n end\n end" ]
[ "0.7644032", "0.69248235", "0.6507964", "0.6310063", "0.6292115", "0.6140941", "0.6124623", "0.60348076", "0.6002396", "0.59820753", "0.5949577", "0.5936829", "0.5898569", "0.58960676", "0.5880373", "0.57771295", "0.56927085", "0.56813", "0.56791455", "0.5653899", "0.56453687", "0.55946815", "0.55860704", "0.55634946", "0.55525315", "0.5533974", "0.55244225", "0.5506423", "0.54849225", "0.5478246", "0.5466618", "0.541299", "0.54029584", "0.5364254", "0.5341441", "0.5341441", "0.53378665", "0.5337627", "0.53286093", "0.5326444", "0.5322996", "0.53224456", "0.53168833", "0.5308891", "0.53055394", "0.5303835", "0.530352", "0.5293134", "0.5289053", "0.5270673", "0.52705395", "0.52603185", "0.5235039", "0.5234922", "0.52305555", "0.5214187", "0.5194805", "0.5176506", "0.5174281", "0.5174123", "0.517087", "0.5161256", "0.51451844", "0.5134482", "0.5127742", "0.51246864", "0.5117887", "0.5115859", "0.51136816", "0.51061785", "0.5097751", "0.5097325", "0.50861734", "0.50811946", "0.5080493", "0.50771195", "0.5076175", "0.506739", "0.506739", "0.50611335", "0.505897", "0.5041693", "0.503021", "0.5025855", "0.5025195", "0.50242865", "0.5019741", "0.5015102", "0.50109893", "0.4988522", "0.4985478", "0.4979395", "0.49778798", "0.49757323", "0.49731705", "0.49711147", "0.49676925", "0.49644935", "0.4961187", "0.49608567", "0.49591392" ]
0.0
-1
POST /photo_tag_references POST /photo_tag_references.json
def create @photo_tag_reference = PhotoTagPhoto.new(photo_tag_reference_params) respond_to do |format| if @photo_tag_reference.save format.html { redirect_to @photo_tag_reference, notice: 'Photo tag reference was successfully created.' } format.json { render :show, status: :created, location: @photo_tag_reference } else format.html { render :new } format.json { render json: @photo_tag_reference.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def photo_tag_reference_params\n params.require(:photo_tag_photo).permit(:photo_id, :photo_tag_id)\n end", "def set_photo_tag_reference\n @photo_tag_reference = PhotoTagPhoto.find(params[:id])\n end", "def index\n @photo_tag_references = PhotoTagPhoto.all\n end", "def create\n @tag_ref = TagRef.new(tag_ref_params)\n @article = Article.find(params[:article])\n\n respond_to do |format|\n if @tag_ref.save\n format.html {redirect_to article_tags_article_path(@article), notice: 'Dodano Tag do artykułu.' }\n format.json { render :show, status: :created, location: @tag_ref }\n else\n format.html { render :new }\n format.json { render json: @tag_ref.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @photo_tag_photo.update(photo_tag_reference_params)\n format.html { redirect_to @photo_tag_reference, notice: 'Photo tag reference was successfully updated.' }\n format.json { render :show, status: :ok, location: @photo_tag_reference }\n else\n format.html { render :edit }\n format.json { render json: @photo_tag_reference.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @photo_tag = PhotoTag.new(photo_tag_params)\n\n respond_to do |format|\n if @photo_tag.save\n format.html { redirect_to @photo_tag, notice: 'Photo tag was successfully created.' }\n format.json { render :show, status: :created, location: @photo_tag }\n else\n format.html { render :new }\n format.json { render json: @photo_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def convert_ref_tags; end", "def create\n @taggable = current_user.taggables.new(params[:taggable], :user_id => current_user.id)\n \n respond_to do |format|\n if @taggable.save\n # if the DB commit was successful then try to tag faces.\n logger.debug(@taggable.photo.path)\n faceArray = findFaces(@taggable.photo.path(:editable))\n \n faceArray.each do |rect|\n @tag = @taggable.tags.new(:upperLeftX => rect[0],\n :upperLeftY => rect[1],\n :lowerRightX => rect[2],\n :lowerRightY => rect[3],\n :person => \"Random Person\")\n @tag.save\n end\n\n format.html { redirect_to \"/tagging/#{@taggable.id}\", notice: 'Taggable was successfully created.' }\n format.json { render json: @taggable, status: :created, location: @taggable }\n else\n format.html { render action: \"new\" }\n format.json { render json: @taggable.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @photo_tag_reference.destroy\n respond_to do |format|\n format.html { redirect_to photo_tag_references_url, notice: 'Photo tag reference was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def update\n # creates tag objects for photos\n tag_array = tag_params['tags'].split(',').each do |x|\n x.strip!\n end\n tag_array.each do |x| \n if Tag.find_by(name: x)\n @tag = Tag.find_by(name: x)\n else\n @tag = Tag.create(name: x)\n end\n Tagging.create(photo_id: @photo.id, tag_id: @tag.id)\n end\n\n respond_to do |format|\n if @photo.update(photo_params)\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { render :show, status: :ok, location: @photo }\n else\n format.html { render :edit }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def tag_ref_params\n params.require(:tag_ref).permit(:tag_id, :article_id)\n end", "def set_tag_ref\n @tag_ref = TagRef.find(params[:id])\n end", "def create\n @photo = Photo.new(photo_params)\n @photo.user = current_user\n\n set_tags\n\n respond_to do |format|\n if @photo.save\n format.html { redirect_to @photo, notice: 'Photo was successfully created.' }\n format.json { render :show, status: :created, location: @photo }\n else\n format.html { render :new }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @photo = Photo.new(params[:photo])\n @photo.user_id = session[:user_id]\n @tagcontent = params[:tag]\n if (@tagcontent!=\"\")\n tag = Tag.find_by_content(@tagcontent)\n if (tag !=nil)\n @tag_id = tag.id\n else\n @newtag = Tag.new\n @newtag.content = @tagcontent\n @newtag.save\n @tag_id = @newtag.id\n end\n end\n\n respond_to do |format|\n if @photo.save\n if (@tagcontent!=\"\")\n @hastag = Hastag.new\n @hastag.photo_id = @photo.id\n @hastag.tag_id = @tag_id\n @hastag.save\n end\n format.html { redirect_to '/home', notice: 'You have uploaded a new photo'}\n format.json { render json: @photo, status: :created, location: @photo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def addTags(photo,tags)\n photo = photo.id if photo.class == Flickr::Photo\n tstr = tags.join(',')\n @flickr.call_method('flickr.photos.addTags',\n 'photo_id' => photo, 'tags' => tstr)\n end", "def add_tags(tags)\n rsp = @flickr.send_request('flickr.photos.addTags', {:photo_id => self.id, :tags => tags}, :post)\n true\n end", "def create\n params[:tag][:name].downcase!\n params[:tag][:name] = params[:tag][:name].gsub(/[^a-z0-9]+/,'-')\n\n \n @find = Tag.find(:first, :conditions => \"name = '#{params[:tag][:name]}'\")\n if @find.nil?\n @tag = Tag.new(params[:tag])\n @tag_link = @tag.tag_links.build(params[:tag_link])\n @tag.save\n render :json => {:msg => \"Created and added #{@tag.name} to list of tags\",:tag=>@tag.name}\n else\n @link_find = TagLink.find(:first, :conditions => {:tag_id => @find.id, :taggable_type => params[:tag_link][:taggable_type],:taggable_id => params[:tag_link][:taggable_id]})\n if @link_find.nil?\n @tag_link = @find.tag_links.build(params[:tag_link])\n @find.save\n render :json => {:msg=>\"Added #{@find.name} to list of tags\",:tag=>@find.name}\n else\n render :json => {:msg=>\"This object is already tagged with #{@find.name}\",:tag=>@find.name}\n end\n end\n end", "def create_tag(project, tag_name, ref)\n post(\"/projects/#{project}/repository/tags\", body: {tag_name: tag_name, ref: ref})\n end", "def add_to_campaign\n photo = current_user.photos.find params[:id]\n campaign = Campaign.find params[:campaign_id]\n\n @photo_tags = photo.add_to_campaign campaign\n\n respond_to do |format|\n format.json do\n if @photo_tags\n render json: @photo_tags\n else\n render :status => 422, text: photo.errors.full_messages.to_sentence\n end\n end\n end\n \n end", "def set_photo_tag\n @photo_tag = PhotoTag.find(params[:id])\n end", "def parse_references\n globbed_references = body.scan(/(.*?\\))/)\n\n globbed_references.each do |reference|\n url = reference.first.scan(/(?<=\\().*(?=\\))/).first\n next unless url\n\n if url.include?('users')\n # Do nothing for now when it's a mention of a user\n # FIXME - this is junk\n elsif url.include?('ideas') && idea = Idea.find_by_sha(url.gsub('/ideas/', ''))\n # When this is an idea we know about, make a hard link\n self.idea_references.build(:referenced_id => idea.id)\n else\n # Just leave it in the body without doing anything.\n end\n end\n end", "def tags_from_reference(reference)\n response = client.get(\"2.0/tracks/reference/#{reference}/tags\")\n\n response.map { |tag| Struct::Tag.new(tag) }\n end", "def create\n @image = Image.find params[:image_id]\n @tag = @image.tags.new(tag_params)\n\n if @tag.save\n redirect_to image_path(@tag.image) , notice: 'Tag was successfully created.'\n else\n render :new\n end\n end", "def photo_tag_params\n params.require(:photo_tag).permit(:name)\n end", "def tag\n # NB: the PageRefsController handles a GET request to set up tagging, taking params[:extractions] into account\n if current_user\n update_options = { :skip_landing => true } # We're not going to wait for the entity to process\n # Collectibles include both PageRefs and other entities (Recipe, Site, etc.) that HAVE PageRefs\n # Furthermore, when initially collecting a URL, we may be tagging the entity BY REFERENCE to its PageRef, in\n # which case we need to tag the corresponding entity, either by picking one or making a new one.\n # #edittable_proxify() sorts all that out, returning an editable model and (for a POST call) parameters for modification\n model, modelparams = edittable_proxy # A page_ref may proxify into the associated Recipe or Site, or another PageRef\n if @page_ref\n @page_ref.adopt_extractions params[:extractions] if params[:extractions]\n @page_ref.save if (@page_ref != model) && (!@page_ref.persisted? || @page_ref.changed?) # Trigger launch as nec.\n update_options[:needs] = [ :picurl, :title ]\n end\n modelname = model.model_name.param_key\n params[modelname] = modelparams\n\n # The editable tag tokens need to be set through the decorator, since Taggable\n # doesn't know what tag types pertain.\n # So, first we pull the misc_tag_tokens from the params...\n misc_tag_tokens = params[modelname].delete :editable_misc_tag_tokens\n # Now the parameters should reflect the target type, and we can proceed as usual\n update_options.merge! (request.method == 'GET') ?\n { touch: :collect } : # Ensure that it's collected before editing\n # We have to provide update parameters, in case the model name doesn't match the controller\n { update_attributes: true, attribute_params: strong_parameters(modelname) }\n\n update_and_decorate model, update_options\n # ...now we apply the misc tag tokens (if any) according to the constraints of the decorator\n @decorator.send @decorator.misc_tags_name_expanded('editable_misc_tag_tokens='), misc_tag_tokens if misc_tag_tokens\n if resource_errors_to_flash @decorator, preface: 'Couldn\\'t save.'\n render :errors\n else\n unless request.method == 'GET'\n flash[:popup] = \"#{@decorator.human_name} saved\"\n render 'collectible/update.json'\n else\n response_service.title = @decorator.title.truncate(20) # Get title (or name, etc.) from the entity\n smartrender\n end\n end\n else\n respond_to do |format|\n format.html {# This is for capturing a new recipe and tagging it using a new page.\n # Defer request, redirecting it for JSON\n login_required :format => :json\n }\n format.json {\n # Not logged in => have to store recipe parameters (url, title, comment) in a safe place pending login\n # session[:pending_recipe] = params[:recipe].merge page_ref_id: page_ref.id\n # After login, we'll be returned to this request to complete tagging\n login_required\n }\n end\n end\n end", "def create(tag)\n api_client.tags.multi_add(resource_hrefs: [api_client.get_instance.href], tags: [tag])\n end", "def photo_params\n params.require(:photo).permit(:tags, :picture)\n end", "def index\n @tag_refs = TagRef.all\n end", "def show\n @tag = Tag.find(params[:id])\n if current_admin\n if params[:pin]\n @tag.photo_id = params[:pin]\n @tag.save\n end\n end\n # @category_photo = @tag.photo\n @photos = Photo.includes(:tags).where(:tags => {:name => @tag.name})\n @untagged_photos = []\n Photo.all.each do |p|\n @untagged_photos << p if p.tags.count == 0\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tag }\n end\n end", "def add_tag\n url = Url.find_by(id: params[:id])\n tag = Tag.find_by(name: params[:tag])\n if tag\n ## TODO: handle tag with url in backend\n # if not url.tags.where(:tag_id => tag.id).any?\n # url.tags << tag\n # end\n url.tags << tag\n else\n tag = Tag.new(name: params[:tag])\n url.tags << tag\n end\n render json: {code: 200, tags: url.tags}\n end", "def tag!(params = {})\n self.post params, edge: :tags\n end", "def update_remote_tags!(new_file=nil)\n Cloudinary::Api.update(my_public_id, tags: tags)\n end", "def photo_tags\n all_tags = Hash.new {|h,k| h[k]=[]}\n self.tags.find_each do |t|\n all_tags[t.field] << t.value\n end\n all_tags\n end", "def add(params = {})\n\t album_id = params[:album_id]\n\t\tphoto_id = params[:photo_id]\n\t\ttag_name = params[:tag_name]\n\t\traise(ArgumentError, \"You must specify album_id when providing photo_id\") if photo_id && !album_id\n\t\traise(ArgumentError, \"You must specify adding tag name\") if !tag_name\n\t\t\n\t\tpath = \"/data/feed/api/user/#{user_id}\"\n\t\tpath << \"/albumid/#{album_id}\" if album_id\n\t\tpath << \"/photoid/#{photo_id}\" if photo_id\n\t\t\n\t\ttemplate = Template.new(\"adding_tag\", {:tag_name => tag_name})\n\t\t\n\t\turi = URI.parse(path)\n\t\tparsed_body = Connection.new(credentials).post(uri.path, template.render)\n\t\tPresenter::Photo.new(parsed_body[\"entry\"])\n\t end", "def references\n @references ||= ApiFactory.new 'GitData::References'\n end", "def image_tag_params\n params.require(:image_tag).permit(:image_id, :tag)\n end", "def create\n\n @event = Event.new(event_params)\n\n tag_array = event_params2['tags'].split(',')\n tag_array.each do |x|\n @tag = Tag.create(desc: x)\n @event.tags << @tag\n end\n EventTag.create(event_id: @event.id, tag_id: @tag.id)\n\n respond_to do |format|\n if @event.save\n params[:event]['images'].each do |a|\n @event_photo = @event.event_photos.create!(:image => a, :event_id => @event.id)\n end\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def photo_params\n params.require(:photo).permit(:image_url, :caption,\n :cat_ids => [],\n :hashtags => [])\n end", "def create\n @image_reference = ImageReferenceServices.find_or_initialize params[:image_reference][:url]\n notice = \"Image was successfully #{@image_reference.persisted? ? 'fetched' : 'created'}.\"\n respond_to do |format|\n if @image_reference.save\n format.html { redirect_to @image_reference, notice: notice }\n format.json { render json: @image_reference, status: :created, location: @image_reference }\n else\n format.html { render action: 'new' }\n format.json { render json: @image_reference.errors, status: :unprocessable_entity }\n end\n end\n end", "def tag_follow(tag)\n tag_follows.create(tag_id: tag.id)\n end", "def tag_set(id, tags)\n wf_event_id?(id)\n tags = Array(tags)\n tags.each { |t| wf_string?(t) }\n api.post([id, 'tag'].uri_concat, tags, 'application/json')\n end", "def references\n references_hash.to_json\n end", "def create\n #Refactor maybe is this the best way to associate a post with the current user?\n @post = current_user.posts.build(post_params.slice(:content, :user_id, :asset))\n #@post.tag_list = @post.extract_tags\n @post.build_tags(params[:tag_list])\n\n if @post.save\n render json: @post, status: :created\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end", "def create\n @photo = Photo.new(params[:photo].merge(poster_id: session_guest.id))\n respond_to do |format|\n if @photo.save\n taggable_guests = [groom, bride]\n\n taggable_guests.each do |taggable_guest|\n if (params.has_key?(:taglist) and params[:taglist][taggable_guest.id.to_s] == \"true\") \n @photo.guests << taggable_guest unless @photo.guests.include?(taggable_guest)\n else\n @photo.guests.delete(taggable_guest) if @photo.guests.include?(taggable_guest)\n end\n end\n format.html { redirect_to photos_path, notice: 'Photo was successfully created.' }\n format.json { render json: @photo, status: :created, location: @photo }\n else\n format.html { redirect_to photos_path, alert: 'Error uploading photo.' }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params[:tag_names].split(',').each do |name|\n @tag = Tag.find_or_create_by_name name.strip\n @tagging = Tagging.new(params[:tagging])\n @tagging.tag = @tag\n @tags_saved = @tagging.save\n end\n \n respond_to do |format|\n if @tags_saved\n format.html { redirect_to @tagging.taggable, notice: 'Tagged.' }\n format.json { render json: @tagging, status: :created, location: @tagging }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tagging.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @reference = Reference.new(reference_params)\n\n if @reference.save\n render json: @reference, status: :created, location: @reference\n else\n render json: @reference.errors, status: :unprocessable_entity\n end\n end", "def fetch_tags params\n encoded_image = Base64.strict_encode64(params[:image_file].tempfile.read)\n api_key = ENV[\"GOOGLE_API_KEY\"]\n api_url = \"https://vision.googleapis.com/v1/images:annotate?key=#{api_key}\"\n\n body = {\n requests: [{\n image: {\n content: encoded_image\n },\n features: [\n {\n type: 'LABEL_DETECTION', maxResults: 10\n }\n ]\n }]\n }\n # Send request.\n uri = URI.parse(api_url)\n https = Net::HTTP.new(uri.host, uri.port)\n https.use_ssl = true\n request = Net::HTTP::Post.new(uri.request_uri)\n request[\"Content-Type\"] = \"application/json\"\n response = https.request(request, body.to_json)\n\n # Add the generated labels to the list of tag\n JSON.parse(response.body)[\"responses\"].each do |res|\n res[\"labelAnnotations\"].each do |tag|\n @image.tags.prepend(tag[\"description\"], \",\")\n end\n end\n @image.tags = @image.tags.delete_suffix(',')\n end", "def create\n @post = Post.new(params[:post])\n\n if params['tag_field'] != nil\n tags_array = params['tag_field'].split(\",\")\n tags_array.each do |tag|\n @post.tags << Tag.find_or_create_by_etiqueta_and_post_id(tag.strip, @post.id)\n end\n end\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n p_attr = params[:photo]\n p_attr.permit!\n @photo = Photo.new(p_attr)\n\n respond_to do |format|\n if @photo.save\n #save new link between photo and post\n if (params[:post_id].length)\n\n countInPost = PostPhoto.where(post_id: params[:post_id]).count\n @photo.sort = (countInPost+1)*100\n @photo.save\n\n #check post\n post = Post.find(params[:post_id])\n if (!post.present?)\n raise 'Post is not found'\n end\n\n if (post.main_photo.to_i < 1)\n post.main_photo = @photo.id\n post.save\n end\n\n post_photo = PostPhoto.find_or_initialize_by(post_id: params[:post_id], photo_id: @photo.id)\n post_photo.save\n\n end\n\n format.html {\n render :json => [@photo.to_jq_upload].to_json,\n :content_type => 'text/html',\n :layout => false\n }\n format.json { render json: {files: [@photo.to_jq_upload]}, status: :created, location: @photo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @tag_ref.destroy\n respond_to do |format|\n format.html { redirect_to tag_refs_url, notice: 'Usunięto Tag z artykułu.' }\n format.json { head :no_content }\n end\n end", "def auto_tag!\n tags = self.body.scan(/(?<=#)\\S+/).map{ |ts| J::Tag.find_or_create_by(name: ts) }\n self.tags = tags\n end", "def photo_params\n params.require(:photo).permit(:photo_images, :all_tags)\n end", "def test_get_tags\n post '/repos', {:name => GIT_REPO}\n post \"/repos/#{GIT_REPO}.git/branches/master/files\", {:name => \"myfile.txt\", :data => \"Hello There\", :encoding => \"utf-8\", :user => \"Rune Madsen\", :email => \"[email protected]\", :message => \"My First Commit\"}\n sha = JSON.parse(last_response.body)[\"commit_sha\"]\n post \"/repos/#{GIT_REPO}.git/tags\", {:tag => \"version1\", :message => \"hello\", :sha => sha, :type => \"commit\", :user => \"Rune Madsen\", :email => \"[email protected]\"}\n get \"/repos/#{GIT_REPO}.git/tags\"\n end", "def create\n @tag = Tag.new(tag_params)\n @tag.user = current_user\n\n respond_to do |format|\n if @tag.save\n image_path = view_context.cl_image_path(@tag.photo.key)\n tag_hash = AwsTextExtractService.new.scan(image_path)\n\n @tag.update(\n plate: tag_hash[\"PLACA\"],\n maker: tag_hash[\"MARCAMODELO/VERSÃO\"],\n year: tag_hash[\"ANOMODELO\"]\n )\n\n format.html { redirect_to edit_tag_path(@tag), notice: \"Tag was successfully created.\" }\n format.json { render :show, status: :created, location: @tag }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @image_reference.destroy\n respond_to do |format|\n format.html { redirect_to image_references_url }\n format.json { head :no_content }\n end\n end", "def add_tag_to_contact\n\t\t\t\t# add a tag to this contact\n\t\t\t\t# collect and clean the params\n\t\t\t\ttag_text = params[:tag_text].match(/[A-Za-z0-9-]+/)[0]\n\t\t\t\tcontact_id = params[:contact_id].match(/[A-Fa-f0-9]+/)[0]\n\t\t\t\t# let's see if this tag exists. if so, set tag to equal its corresponding object \n\t\t\t\ttag = Tag.where(:tag => tag_text).first\n\t\t\t\t# see if we got one\n\t\t\t\tif !tag\n\t\t\t\t\t# if we don't find the tag, make one\n\t\t\t\t\ttag = Tag.new\n\t\t\t\t\ttag.tag = tag_text\n\t\t\t\t\ttag.save\n\t\t\t\tend\n\t\t\t\t# after we have a tag, let's add it to the contact\n\t\t\t\t# find the parent contact\n\t\t\t\tcontact = Contact.where(:id => contact_id).first\n\t\t\t\tif !contact\n\t\t\t\t\t# something way fucked happened\n\t\t\t\tend\n\t\t\t\t# append tag to tags list\n\t\t\t\tcontact.tags << tag\n\t\t\t\t# save it\n\t\t\t\tcontact.save\n\t\t\t\t\n\t\t\t\t# send it back to the client\n\t\t\t\trender json: {:status => \"success\", :contact => contact}\n\t\t\tend", "def photo_params\n params.require(:photo).permit(:image, :views, :likes, :downloads, :image_cache, :remove_image, :remote_image_url, attachments: [], tags_attributes: [:id, :tag, :_destroy])\n end", "def create\n @post = Post.new(post_params)\n check_published\n if(post_params[:tag_ids])\n @post.tags = Tag.find(post_params[:tag_ids])\n end\n respond_to do |format|\n if @post.save\n url = @post.link\n format.html { redirect_to url, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: url }\n else\n get_instance_vars\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_new_tag\n puts \"******* add_new_tag *******\"\n puts \" ** params: #{params.inspect}\"\n\n @post_id = params[:post_id]\n\n # == create brand new tag; add to Tags\n if params[:new_tag] != \"new\"\n\n # == check if tag already exists\n check_tag = Tag.where(tag_name: params[:new_tag])\n puts \" ** check_tag.length: #{check_tag.length.inspect}\"\n\n # == create new tag if not existing and assign to post\n if check_tag.length == 0\n @tag = Tag.create(tag_name: params[:new_tag], tag_rank: 0)\n @post_tag = PostTag.create(post_id: params[:post_id], tag_id: @tag[:id])\n puts \" ** NEW TAG @post_tag: #{@post_tag.inspect}\"\n end\n end\n\n # == assign existing tag if selected from select box (not \"ng\")\n if params[:tag_id] != \"ng\"\n\n # == check if tag already assigned to post\n check_tag = PostTag.where(post_id: params[:post_id], tag_id: params[:tag_id])\n puts \" ** check_tag.length: #{check_tag.length.inspect}\"\n\n if check_tag.length == 0\n @post_tag = PostTag.create(post_id: params[:post_id], tag_id: params[:tag_id])\n puts \" ** EXISTING TAG @post_tag: #{@post_tag.inspect}\"\n end\n end\n @post_tags = PostTag.where(post_id: params[:post_id])\n @post_tag_ids = @post_tags.map{|pt| pt.tag_id }\n @post_no_tags = Tag.where(\"id NOT IN (?)\", @post_tag_ids)\n @tags = Tag.where(id: @post_tag_ids)\n render json: { tags: @tags, post_no_tags: @post_no_tags, post_id: @post_id}\n end", "def remove_tag\n \n success = false\n message = \"\"\n \n # Only the owner of the photo, or the tagged person are allowed to remove the tag\n if @user.id == @face.photo.user_id || @user.id == @face.user_id\n \n # Remove tag\n @face.remove_tag\n \n # Action was a success\n success = true\n \n # Notice message\n message = \"Tag was successfully removed\"\n \n end\n \n flash[:notice] = message\n \n respond_to do |format|\n format.html { redirect_to :back }\n format.json { render :json => { :success => success, :message => message } }\n end\n \n end", "def tags\n _get(\"/query/image/tags\") { |json| json }\n end", "def create\n # decide if link url already exists in db\n @potentialLink = Link.find_by(url: links_params[:url])\n @link = current_user.links.new(title: links_params[:title], url: links_params[:url])\n # cleans up link so that it always has http://\n if @link.url.include?('http://')\n @link.save\n else\n @link.url.insert(0, 'http://')\n @link.save\n end\n # @keyword = self.keywords\n\n # captures string of tags\n @inputtedtags = (links_params[:link_tags_attributes]['0'][:tag_attributes][:name]).gsub(/,/, '').downcase.split(' ').flatten\n\n # Decide if tag is already in the database\n @inputtedtags.each do |tag|\n potentialTag = Tag.find_by(name: tag)\n # if tag is already in db, create a new association between new link and old tag\n if potentialTag\n @link_tag = @link.link_tags.build(link_id: @link.id, tag_id: potentialTag.id)\n @link_tag.save\n # otherwise, save new tag\n else\n @link.tags.build(name: tag)\n @link.save\n end\n end\n # render tags dynamically without reloading page\n respond_to do |format|\n if @link.save\n format.json { render json: @link, include: :tags, status: :created }\n else\n format.json { render json: @link.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @blog = Blog.create(blog_params)\n params[:tags][:tag_id].each do |p|\n @tagging = Tagging.create(tag_id: p.to_i, blog_id: @blog.id)\n end\n respond_to do |format|\n\n format.html { redirect_to @blog, notice: 'Blog was successfully created.' }\n format.json { render :show, status: :created, location: @blog }\n\n end\nend", "def add_reference(post, identification)\n auth, trans_id = identification.split(';')\n post[:authnum] = auth\n post[:transid] = trans_id\n end", "def create \n @idea = Idea.new(idea_params)\n @idea.user_id = current_user.id\n @idea.save!\n if params[:idea][:tags]\n params[:idea][:tags].each do |new_tag|\n tag_title = new_tag[:title]\n tag = Tag.find_by title: tag_title\n if tag.present?\n tag.used = tag.used + 1\n tag.save!\n else\n tag = Tag.new\n tag.title = tag_title.downcase\n tag.used = 1 \n tag.save!\n end\n @idea.tags << tag\n end\n end\n Notification.generate(current_user, @idea)\n Notification.push(@idea) \n render json: @idea.to_json(include: [{user: {only: [:name, :id, :image_url]}}, {comments: {include: {user: {only: [:name, :image_url]}}}}], methods: [:voted])\n end", "def create\n @tag_relationship = TagRelationship.new(tag_relationship_params)\n\n respond_to do |format|\n if @tag_relationship.save\n format.html { redirect_to @tag_relationship, notice: 'Tag relationship was successfully created.' }\n format.json { render action: 'show', status: :created, location: @tag_relationship }\n else\n format.html { render action: 'new' }\n format.json { render json: @tag_relationship.errors, status: :unprocessable_entity }\n end\n end\n end", "def extract_tags!\n @tagmap = {}\n data.gsub!(/(.?)\\[\\[(.+?)\\]\\]([^\\[]?)/m) do\n if $1 == \"'\" && $3 != \"'\"\n \"[[#{$2}]]#{$3}\"\n elsif $2.include?('][')\n if $2[0..4] == 'file:'\n pre = $1\n post = $3\n parts = $2.split('][')\n parts[0][0..4] = \"\"\n link = \"#{parts[1]}|#{parts[0].sub(/\\.org/,'')}\"\n id = Digest::SHA1.hexdigest(link)\n @tagmap[id] = link\n \"#{pre}#{id}#{post}\"\n else\n $&\n end\n else\n id = Digest::SHA1.hexdigest($2)\n @tagmap[id] = $2\n \"#{$1}#{id}#{$3}\"\n end\n end\n nil\n end", "def update\n respond_to do |format|\n if @photo_tag.update(photo_tag_params)\n format.html { redirect_to @photo_tag, notice: 'Photo tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @photo_tag }\n else\n format.html { render :edit }\n format.json { render json: @photo_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_tag_associations(tags)\n tags.each do |tag|\n t = Tag.find_by_tag(tag)\n if t\n self.tags << t\n else\n t = Tag.new(:tag => tag)\n self.tags << t if t.save\n end\n end \n end", "def update\n # myParams = photo_params\n respond_to do |format|\n if @photo.update(photo_params)\n\n # save tags\n save_tags true\n\n PostPhoto.delete_all(photo_id: @photo.id)\n if (params[:posts].length > 0)\n posts = params[:posts].split(',').uniq\n posts.each do |post_id|\n post_photo = PostPhoto.find_or_initialize_by(post_id: post_id, photo_id: @photo.id)\n post_photo.save\n end\n end\n\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json {\n render json: {\n status: :ok,\n photo: @photo\n }\n }\n else\n format.html { render :edit }\n format.json {\n render json: {\n errors => @photo.errors,\n status => :error\n },\n status: :unprocessable_entity\n }\n end\n end\n end", "def create_tag(recipe_id, tags)\n\t\t\t\tdestroy_tags = RecipeTag.where(recipe_id: recipe_id)\n\t\t\t\tif !destroy_tags.blank? \n\t\t\t\t\tdestroy_tags.delete_all\n\t\t\t\tend\n\t\t\t\ttags.each do |recipe_tag|\n\t\t\t\t\ttag = RecipeTag.new\n\t\t\t\t\ttag.recipe_id = recipe_id\n\t\t\t\t\ttag.tag = recipe_tag\n\t\t\t\t\ttag.save!\n\t\t\t\tend\n\t\t\tend", "def create\n #@tag = params[:post][:tags_attributes]\n\n # shanghai-zhou(105703655) 10:31:32 写的另一种方法\n # tags = ['he', 'll', 'o']\n # @tags = tags.map do |t|\n # if Tag.find_by_name(t).blank?\n # Tag.create(:name=>t)\n # end\n # Tag.find_by_name t\n # end\n # @post.tags = @tags\n # @post.save\n\n @tagarr = params[:post][:tags_attributes][\"0\"][:name].split(\" \")\n @tag = {}\n @tagarr.each_with_index do |tag,i|\n #@tagarr.each do |tag|\n @tag[i] = {:name => tag}\n end\n\n @postreset = params[:post]\n @postreset[\"tags_attributes\"] = @tag\n @post = Post.new(@postreset)\n \n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_tags\n\tend", "def create\n @photo = Photo.new(photo_params)\n @photo.vote =0\n respond_to do |format|\n if @photo.save\n current_user.photos.push @photo\n format.html { redirect_to photos_path, notice: 'Photo was successfully created.' }\n format.json { render :show, status: :created, location: @photo }\n\n else\n format.html { render :new }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @photo_tag.destroy\n respond_to do |format|\n format.html { redirect_to photo_tags_url, notice: 'Photo tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def post_params\n # params.permit(:content, :color, taggings_attributes: [:id, :tag])\n params.permit(:content, :color, tag_ids: [], asset_ids: [])\n end", "def new\n @image = Image.find params[:image_id]\n @tag = @image.tags.new\n end", "def create\n @asset = Asset.find(params[:asset_id])\n \t@tag = @asset.tags.build(params[:tag])\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to(asset_manager_asset_tag_path(@asset, @tag), :notice => 'Tag was successfully created.') }\n format.xml { render :xml => asset_manager_asset_tag_path(@asset, @tag), :status => :created, :location => @tag }\n else\n format.html { render :action => :new }\n format.xml { render :xml => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @news = News.new\n @news.build_image_reference\n @news.image_references.build\n @news.image_references.build\n# @news.image_references_attributes = [{:content_type=>\"news\"}]\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news }\n end\n end", "def create\n @tag_relation = TagRelation.new(tag_relation_params)\n\n respond_to do |format|\n if @tag_relation.save\n format.html { redirect_to @tag_relation, notice: 'Tag relation was successfully created.' }\n format.json { render :show, status: :created, location: @tag_relation }\n else\n format.html { render :new }\n format.json { render json: @tag_relation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @work = Work.new(params[:work])\n @media_asset = MediaAsset.all\n\n if params.include? 'tags'\n params['tags'].each do |name|\n next if name.empty?\n tag = Tag.new\n tag.name = name\n tag.work_id = @work.id\n tag.save!\n end\n end\n\n\n respond_to do |format|\n if @work.save\n format.html { redirect_to @work, notice: 'Work was successfully created.' }\n format.json { render json: @work, status: :created, location: @work }\n else\n format.html { render action: \"new\" }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate_reference = @candidate.references.build(candidate_reference_params)\n\n respond_to do |format|\n if @candidate_reference.save\n flash[:success] = 'Reference was successfully created.' \n format.html { redirect_to edit_candidate_references_path(params[:candidate_id])}\n format.json { render :show, status: :created, location: @candidate_reference }\n else\n flash[:failure] = 'Reference creation unsuccessful.' \n format.html { redirect_to edit_candidate_references_path(params[:candidate_id]) }\n format.json { render json: @candidate_reference.errors, status: :unprocessable_entity }\n end\n end\n end", "def extract_tags(data)\n data.gsub!(/(.?)\\[\\[(.+?)\\]\\]([^\\[]?)/m) do\n if $1 == \"'\" && $3 != \"'\"\n \"[[#{$2}]]#{$3}\"\n elsif $2.include?('][')\n if $2[0..4] == 'file:'\n pre = $1\n post = $3\n parts = $2.split('][')\n parts[0][0..4] = \"\"\n link = \"#{parts[1]}|#{parts[0].sub(/\\.org/,'')}\"\n id = Digest::SHA1.hexdigest(link)\n @tagmap[id] = link\n \"#{pre}#{id}#{post}\"\n else\n $&\n end\n else\n id = Digest::SHA1.hexdigest($2)\n @tagmap[id] = $2\n \"#{$1}#{id}#{$3}\"\n end\n end\n data\n end", "def update_tags(tags)\n rescue_extra_data\n tags = tags.split(\",\").strip\n post_tags = post_type.post_tags\n post_tags = post_tags.where.not(name: tags) if tags.present?\n term_relationships.where(\"term_taxonomy_id in (?)\", post_tags.pluck(\"#{CamaleonCms::TermTaxonomy.table_name}.id\")).destroy_all\n tags.each do |f|\n post_tag = post_type.post_tags.where({name: f}).first_or_create(slug: f.parameterize)\n term_relationships.where({term_taxonomy_id: post_tag.id}).first_or_create\n end\n update_counters(\"tags\")\n end", "def photo!(options)\n return if identifier.nil?\n \n if upload_url = find_upload_url\n data = http_client.post(upload_url, 'file1' => options[:source])\n parsed_response = MultiJson.decode(data.body)\n \n @target.photos.save(parsed_response.merge('caption' => options[:message]))\n end\n end", "def photo!(options)\n return if identifier.nil?\n \n if upload_url = find_upload_url\n data = http_client.post(upload_url, 'file1' => options[:source])\n parsed_response = MultiJson.decode(data.body)\n \n @target.photos.save(parsed_response.merge('caption' => options[:message]))\n end\n end", "def update\n begin\n entity = Tagger::EntityTag.create_entity_tags(params)\n render json: { \"#{Tagger.tagged_resource}\": entity, tags: entity.tags }, status: 201\n rescue Exception => e\n render json: { error: \"Unprocessable entity\" }, status: 422\n end\n end", "def addRefs2Target(filePath,targets,group)\n\tfile_refs = []\n\tDir.foreach(filePath) do |file|\n\t\tif file.to_s.end_with?(keyword) then\n\t\t\tpathNeed = File.join(filePath,file)\n\t\t\t# puts path\n\t\t\tfile_ref = group.new_reference(pathNeed)\n\t\t\tfile_refs.push(file_ref)\n\t\t\t# target.resources_build_phase.add_file_reference(file_ref, true)\n\t\tend\n\tend\n\t# add_file_references\n\ttargets.each do |target|\n\t\ttarget.add_resources(file_refs)\n\tend\nend", "def update\n respond_to do |format|\n if @tag_ref.update(tag_ref_params)\n format.html { redirect_to @tag_ref, notice: 'Zmodyfikowano Tag.' }\n format.json { render :show, status: :ok, location: @tag_ref }\n else\n format.html { render :edit }\n format.json { render json: @tag_ref.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @photo = Photo.new(params[:photo])\n @photo.user = current_user\n\n respond_to do |format|\n if @photo.save\n format.html { redirect_to request.env[\"HTTP_REFERER\"] || @photo.photoable, notice: 'Photo added!' }\n format.json { render json: @photo, status: :created, location: @photo }\n else\n format.html { redirect_to request.env[\"HTTP_REFERER\"] }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def tag_attachment_params\n params.require(:tag_attachment).permit(:file, :remark, :attachment_path)\n end", "def create\n @photo = Photo.new(photo_params)\n @photo.slug = (photo_params[:start].to_s.mb_chars.downcase+photo_params[:text].to_s.mb_chars.downcase).gsub(/[^a-z0-9äöåÄÖÅ\\s]/i, '')\n @photo.views = 0\n @photo.secret_id = Time.now.to_i.to_s + '_' + SecureRandom.hex.to_s\n @photo.url = '/images/'[email protected]_id.to_s+'.jpg'\n\n @photo.addtext(@photo.url.to_s)\n @photo.add_to_view_count(5)\n\n respond_to do |format|\n if @photo.save\n format.html { redirect_to @photo }\n format.json { render :show, status: :created, location: @photo }\n else\n format.html { render :new }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_tag(*tags)\n tags.each_with_index do |tag, i|\n case tag\n when Tags::Tag\n @tags << tag\n when Tags::RefTag\n @ref_tags << tag\n else\n raise ArgumentError, \"expected Tag or RefTag, got #{tag.class} (at index #{i})\"\n end\n end\n end", "def create\n @ref = Ref.new(ref_params)\n\n respond_to do |format|\n if @ref.save\n format.html { redirect_to @ref, notice: 'Ref was successfully created.' }\n format.json { render :show, status: :created, location: @ref }\n else\n format.html { render :new }\n format.json { render json: @ref.errors, status: :unprocessable_entity }\n end\n end\n end", "def references; end", "def references; end", "def references=(value)\n @references = value\n end", "def photo_params\n params.require(:photo).permit(:user_id, :content_type, :title, :body, :likes, :image, :tag_list)\n end", "def create\n @posttag = Posttag.new(params[:posttag])\n\n respond_to do |format|\n if @posttag.save\n format.html { redirect_to @posttag, :notice => 'Posttag was successfully created.' }\n format.json { render :json => @posttag, :status => :created, :location => @posttag }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @posttag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def upload_referenced_images(directory,filename,locale)\n version = Settings[:CURRENT_VERSION]\n begin\n doc_path = \"#{directory}/#{filename}\"\n relative_directory = File.dirname(doc_path) \n content_doc = Nokogiri::XML(open(doc_path)){|config| config.noent }\n content_doc.remove_namespaces!\n # Find each img element\n content_doc.xpath('//img').each do |img|\n # Steps for uploading content\n # 1. Create a hash of the file\n # 2. Get a unique path.\n # 3. Get the filename of the referenced document for the\n # attachment name\n # 4. Check to see if that document exists, if it does, compare\n # the hashes and only upload if it has changed.\n\n # If the image starts with a / assume the file will be in the public directory\n unless (img['src'].start_with?('/'))\n mime_type = get_mime_type(img['src'][/(?:.*)(\\..*$)/, 1])\n\n # Get the directory from the filename\n dir_match_re = /(.*)\\//\n file_dir = dir_match_re.match(filename)[1]\n\n # Fix relative paths here\n path_from_source = (Pathname.new img['src'])\n image_path = (Pathname.new(\"#{file_dir}/#{img['src']}\")).cleanpath.to_s\n id = \"#{Settings[:APP_NAME]}.#{image_path}.#{locale}.#{version}\"\n \n full_image_path = (Pathname.new(\"#{directory}/#{image_path}\")).cleanpath.to_s\n\n # Get the hash of the file on the filesystem\n np = Digest::MD5.file(full_image_path)\n attachment_hash = \"md5-#{Base64.encode64(np.digest)}\".strip\n \n # Look at the attachments on the document in the database\n # If there is an existing attachment with the same name, check the hash value.\n # If it's the same, don't upload it.\n # If it's different, upload it.\n\n #doc fields to create, if needed\n newDoc = {\n '_id' => id,\n :name => image_path,\n :locale => locale,\n :version => version,\n :updated => Time.now.to_date.iso8601,\n :content_hash => attachment_hash }\n \n #doc fields to update, if needed\n updatedDoc = {\n :updated => Time.now.to_date.iso8601,\n :content_hash => attachment_hash }\n \n #upsert the document\n upsert_doc(@db, newDoc, updatedDoc, :content_hash, @log)\n \n doc = @db.get(id)\n doc_attachments = JSON.parse(doc.to_json)[\"_attachments\"]\n\n # If there are no attachments, then doc_attachments will be Nil\n if (doc_attachments.is_a? Hash)\n # If there is already an attachment with the same name, check the hash.\n # If the hash is different, update it.\n unless (doc_attachments.has_key?(image_path) && doc_attachments[image_path][\"digest\"].eql?(attachment_hash))\n begin\n @db.put_attachment(doc, image_path, open(full_image_path, &:read), :content_type => mime_type)\n rescue RestClient::Conflict\n @log.warn \"Hit a conflict. Deleting the attachment and trying again.\"\n begin\n @db.delete_attachment(doc,image_path,true)\n begin\n # Have to get the document again, since the _rev has changed\n doc = @db.get(id)\n @db.put_attachment(doc, image_path, open(full_image_path, &:read), :content_type => mime_type)\n rescue => e\n @log.error\"The attachment was deleted, but could not be re-added.\"\n @log.error e.class\n @log.error e.message\n end\n rescue => e\n @log.warn \"Something went wrong when deleting the attachment. Unknown state.\"\n @log.error e.class\n @log.error e.message\n end\n rescue => e\n @log.error \"Something went wrong when adding an attachment - #{img['src']} on #{doc_path}\"\n @log.error e.message\n @log.error e.class\n end\n end\n else\n # There are no attachments on this document. Add this one.\n @db.put_attachment(doc, image_path, open(full_image_path, &:read), :content_type => mime_type)\n end\n end\n end\n rescue => e\n# @log.error \"Something went wrong when adding an attachment - #{img['src']} on #{doc_path}\"\n @log.error e.message\n @log.error e.class\n end\n end" ]
[ "0.69959605", "0.6750295", "0.6590501", "0.6211269", "0.6173671", "0.61552715", "0.6083645", "0.6070497", "0.6057032", "0.5977463", "0.583303", "0.5794752", "0.57838273", "0.57782066", "0.5652392", "0.56314397", "0.5596663", "0.55630195", "0.5559896", "0.5536033", "0.5486907", "0.5481512", "0.5436317", "0.5430655", "0.5397596", "0.53843623", "0.53557247", "0.53286594", "0.53262275", "0.5326205", "0.53255", "0.527665", "0.5267646", "0.52647394", "0.5252853", "0.52329534", "0.5217856", "0.5210776", "0.52044034", "0.51705843", "0.51694226", "0.51655495", "0.51645595", "0.51450944", "0.51447636", "0.5143333", "0.51363254", "0.51299626", "0.5121728", "0.5113913", "0.5112012", "0.51103795", "0.5098992", "0.50969607", "0.5076876", "0.5071164", "0.50682455", "0.5062888", "0.50608206", "0.50598705", "0.5056228", "0.5049515", "0.50329655", "0.5032762", "0.5013315", "0.5011868", "0.5008001", "0.4987516", "0.49852592", "0.49643293", "0.49573877", "0.4950626", "0.4945455", "0.49453002", "0.49438697", "0.4940723", "0.49391463", "0.49381107", "0.49377242", "0.49338382", "0.49273494", "0.49263546", "0.4923484", "0.49178636", "0.4917003", "0.4917003", "0.49165773", "0.49118865", "0.4909783", "0.49059594", "0.49058247", "0.49024215", "0.49012432", "0.48971054", "0.4891586", "0.4891586", "0.48840967", "0.4883743", "0.48818856", "0.4878518" ]
0.70961
0
PATCH/PUT /photo_tag_references/1 PATCH/PUT /photo_tag_references/1.json
def update respond_to do |format| if @photo_tag_photo.update(photo_tag_reference_params) format.html { redirect_to @photo_tag_reference, notice: 'Photo tag reference was successfully updated.' } format.json { render :show, status: :ok, location: @photo_tag_reference } else format.html { render :edit } format.json { render json: @photo_tag_reference.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_photo_tag_reference\n @photo_tag_reference = PhotoTagPhoto.find(params[:id])\n end", "def update\n # creates tag objects for photos\n tag_array = tag_params['tags'].split(',').each do |x|\n x.strip!\n end\n tag_array.each do |x| \n if Tag.find_by(name: x)\n @tag = Tag.find_by(name: x)\n else\n @tag = Tag.create(name: x)\n end\n Tagging.create(photo_id: @photo.id, tag_id: @tag.id)\n end\n\n respond_to do |format|\n if @photo.update(photo_params)\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { render :show, status: :ok, location: @photo }\n else\n format.html { render :edit }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def photo_tag_reference_params\n params.require(:photo_tag_photo).permit(:photo_id, :photo_tag_id)\n end", "def update\n respond_to do |format|\n if @photo_tag.update(photo_tag_params)\n format.html { redirect_to @photo_tag, notice: 'Photo tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @photo_tag }\n else\n format.html { render :edit }\n format.json { render json: @photo_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n set_tags\n\n respond_to do |format|\n if @photo.update(photo_params)\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { render :show, status: :ok, location: @photo }\n else\n format.html { render :edit }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tag_ref.update(tag_ref_params)\n format.html { redirect_to @tag_ref, notice: 'Zmodyfikowano Tag.' }\n format.json { render :show, status: :ok, location: @tag_ref }\n else\n format.html { render :edit }\n format.json { render json: @tag_ref.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_photo_tag\n @photo_tag = PhotoTag.find(params[:id])\n end", "def update_remote_tags!(new_file=nil)\n Cloudinary::Api.update(my_public_id, tags: tags)\n end", "def update\n # myParams = photo_params\n respond_to do |format|\n if @photo.update(photo_params)\n\n # save tags\n save_tags true\n\n PostPhoto.delete_all(photo_id: @photo.id)\n if (params[:posts].length > 0)\n posts = params[:posts].split(',').uniq\n posts.each do |post_id|\n post_photo = PostPhoto.find_or_initialize_by(post_id: post_id, photo_id: @photo.id)\n post_photo.save\n end\n end\n\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json {\n render json: {\n status: :ok,\n photo: @photo\n }\n }\n else\n format.html { render :edit }\n format.json {\n render json: {\n errors => @photo.errors,\n status => :error\n },\n status: :unprocessable_entity\n }\n end\n end\n end", "def set_tag_ref\n @tag_ref = TagRef.find(params[:id])\n end", "def update\n respond_to do |format|\n if @image_tag.update(image_tag_params)\n format.html { redirect_to @image_tag, notice: 'Image tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @image_tag }\n else\n format.html { render :edit }\n format.json { render json: @image_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @photo_tag_references = PhotoTagPhoto.all\n end", "def update\n @image_tags = ActsAsTaggableOn::Tag.all\n\n tag_list = params[:image][:tag_list]\n @image.tag_list = tag_list.keys.select{|t| tag_list[t] == \"1\"}\n\n\n respond_to do |format|\n if @image.update(image_params)\n format.html { redirect_to @image, notice: \"Image was successfully updated.\" }\n format.json { render :show, status: :ok, location: @image }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @photo_tag_reference = PhotoTagPhoto.new(photo_tag_reference_params)\n\n respond_to do |format|\n if @photo_tag_reference.save\n format.html { redirect_to @photo_tag_reference, notice: 'Photo tag reference was successfully created.' }\n format.json { render :show, status: :created, location: @photo_tag_reference }\n else\n format.html { render :new }\n format.json { render json: @photo_tag_reference.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n update_and_respond(@tag, tag_params)\n end", "def update\n @photo = Photo.find(params[:id])\n if photo_authorize(@photo)\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n taggable_guests = [groom, bride]\n\n taggable_guests.each do |taggable_guest|\n if params.has_key?(:taglist) and params[:taglist][taggable_guest.id.to_s] == \"true\" \n @photo.guests << taggable_guest unless @photo.guests.include?(taggable_guest)\n else\n @photo.guests.delete(taggable_guest) if @photo.guests.include?(taggable_guest)\n end\n end\n format.html { redirect_to photos_path, notice: 'Photo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def modify_tag tag\n data = {\n \"tag\" => params\n }\n temp = data[\"servers\"]\n data[\"servers\"] = { \"server\" => temp }\n\n json = JSON.generate data\n\n response = put \"tag/#{tag}\", json\n return response unless response.code == 200\n\n body = JSON.parse response.body\n body[\"tag\"]\n end", "def update\n @photo = Photo.find(params[:id])\n @photo_oldtag = @photo.gettag\n @tagcontent = params[:tag]\n if @photo.hastag\n if @tagcontent != @photo_oldtag\n @deletehastag = Hastag.find_by_photo_id(@photo.id)\n @deletehastag.destroy\n if (@tagcontent!=\"\")\n tag = Tag.find_by_content(@tagcontent)\n if (tag !=nil)\n @tag_id = tag.id\n else\n @newtag = Tag.new\n @newtag.content = @tagcontent\n @newtag.save\n @tag_id = @newtag.id\n @hastag = Hastag.new\n @hastag.photo_id = @photo.id\n @hastag.tag_id = @tag_id\n @hastag.save\n end\n end \n end\n \n else\n if (@tagcontent!=\"\")\n tag = Tag.find_by_content(@tagcontent)\n if (tag !=nil)\n @tag_id = tag.id\n else\n @newtag = Tag.new\n @newtag.content = @tagcontent\n @newtag.save\n @tag_id = @newtag.id\n end\n @hastag = Hastag.new\n @hastag.photo_id = @photo.id\n @hastag.tag_id = @tag_id\n @hastag.save\n end\n end\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n params = image_params\n params[\"tags\"] = params[\"tags\"].delete_suffix(',')\n\n respond_to do |format|\n if @image.update(params)\n format.html { redirect_to @image, notice: \"Image was successfully updated.\" }\n format.json { render :show, status: :ok, location: @image }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(options: {}, **data)\n\n refresh_with(parse(client.put(\"/tags/#{gid}\", body: data, options: options)).first)\n end", "def update\n begin\n entity = Tagger::EntityTag.create_entity_tags(params)\n render json: { \"#{Tagger.tagged_resource}\": entity, tags: entity.tags }, status: 201\n rescue Exception => e\n render json: { error: \"Unprocessable entity\" }, status: 422\n end\n end", "def destroy\n @photo_tag_reference.destroy\n respond_to do |format|\n format.html { redirect_to photo_tag_references_url, notice: 'Photo tag reference was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def update\n render json: @tag.errors unless @tag.update(tag_params)\n end", "def update\n if @tag.update(tag_params)\n render json: @tag\n else\n render json: @tag.errors, status: :unprocessable_entity\n end\n end", "def update!(**args)\n @update_photo_requests = args[:update_photo_requests] if args.key?(:update_photo_requests)\n end", "def update!(**args)\n @photo_ids = args[:photo_ids] if args.key?(:photo_ids)\n end", "def update\n respond_to do |format|\n if @image_reference.update_attributes image_reference_params\n format.html { redirect_to @image_reference, notice: 'Image was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @image_reference.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n real_post_path = @tag.post\n respond_to do |format|\n if @tag.update(tag_params)\n format.html { redirect_to post_path(real_post_path), notice: 'updated tag' }\n format.json { render :show, status: :ok, location: @tag }\n else\n format.html { render :edit }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @image = Image.find(params[:id])\n unless params[:image][:tags].nil?\n @image.tag_with params[:image]['tags']\n params[:image].delete(\"tags\")\n end\n respond_to do |format|\n if @image.update_attributes(params[:image])\n flash[:notice] = 'Image was successfully updated.'\n format.html { redirect_to([:admin, @image]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @image.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n params[:post][:tag_ids] ||= []\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to [@post.user, @post], notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_photo(album_id, photo_id, file, filename)\n \n end", "def update!(**args)\n @references = args[:references] if args.key?(:references)\n end", "def update\n @tag = Tag.find(params[:id])\n respond_to do |format|\n if @tag.update(tag_params)\n format.json { render :show, status: :ok, location: @tag }\n else\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @api_tag = Api::Tag.find(params[:id])\n\n respond_to do |format|\n if @api_tag.update_attributes(params[:api_tag])\n format.html { redirect_to @api_tag, notice: 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @api_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @asset = Asset.find(params[:asset_id])\n @tag = @asset.tags.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to(asset_manager_asset_tags_path(@tag.asset_id), :notice => 'Tag was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => :new }\n format.xml { render :xml => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post = Post.find(params[:id])\n current_user.tag(@post, :with => params[:post][:tag_list], :on => :tags)\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def patch(operation, path, value = nil)\n ensure_client && ensure_uri\n body = [{ 'op' => operation, 'path' => path, 'value' => value }]\n patch_options = { 'If-Match' => @data['eTag'] }\n response = @client.rest_patch(@data['uri'], patch_options.merge('body' => body), @api_version)\n @client.response_handler(response)\n end", "def update\n puts y params['photo'].keys\n params['photo'].keys.each do |photo_id|\n photo = Photo.find(photo_id)\n photo.update_attributes(params['photo'][photo_id])\n end\n respond_to do |format|\n if true \n format.html { redirect_to photos_path, notice: 'Photos were successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"index\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tag_relationship.update(tag_relationship_params)\n format.html { redirect_to @tag_relationship, notice: 'Tag relationship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tag_relationship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @matching_image_reference_key = args[:matching_image_reference_key] if args.key?(:matching_image_reference_key)\n end", "def update\n respond_to do |format|\n if @note.update_attributes(params[:note])\n Tag.update_parent_tags(@note, params[:tag_value])\n format.html { redirect_to @note, notice: 'Note was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @note.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respondent = SurveyRespondent.find(params[:respondent_id])\n tag_context = params[:context] # tag context\n tag_list = params[:tags] # comma seperated list of tags\n\n if getTagOwner\n getTagOwner.tag(respondent, :with => tag_list, :on => tag_context)\n else\n respondent.set_tag_list_on(tag_context, tag_list) # set the tag list on the respondent for the context\n end\n \n respondent.save\n \n render :layout => 'content'\n end", "def update\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo.photoable, notice: 'Photo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\", layout: \"forms\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_to_campaign\n photo = current_user.photos.find params[:id]\n campaign = Campaign.find params[:campaign_id]\n\n @photo_tags = photo.add_to_campaign campaign\n\n respond_to do |format|\n format.json do\n if @photo_tags\n render json: @photo_tags\n else\n render :status => 422, text: photo.errors.full_messages.to_sentence\n end\n end\n end\n \n end", "def update\n photo_params = params[:photo].clone\n if photo_params[:retakeable]\n photo_params[:retakeable] = %(yes true 1).include?(photo_params[:retakeable].to_s.downcase)\n photo_params[:retakeable] = nil if params[:photo][:retakeable] == 'unknown'\n end\n if photo_params[:accessibility]\n photo_params[:accessibility] = nil if params[:photo][:accessibility] == 'unknown'\n end\n respond_to do |format|\n if @photo.update_attributes(photo_params)\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task.tags.each { |t| t.delete}\n\n respond_to do |format|\n if @task.update(task_params)\n create_multiple_tags(task_params[\"tag\"], @task.id)\n\n format.html { redirect_to @task.list, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def tag_ref_params\n params.require(:tag_ref).permit(:tag_id, :article_id)\n end", "def update\n respond_to do |format|\n if @tag_relation.update(tag_relation_params)\n format.html { redirect_to @tag_relation, notice: 'Tag relation was successfully updated.' }\n format.json { render :show, status: :ok, location: @tag_relation }\n else\n format.html { render :edit }\n format.json { render json: @tag_relation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tag = Tag.find(params[:id])\n\n if @tag.update_attributes(params[:tag])\n render json: JSON.parse(@tag.to_json)\n else\n render json: JSON.parse(@tag.errors.to_json)\n end\n end", "def update\n @posttag = Posttag.find_by_permalink(params[:id])\n\n respond_to do |format|\n if @posttag.update_attributes(params[:posttag])\n format.html { redirect_to @posttag, notice: 'Posttag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @posttag.errors, status: :unprocessable_entity }\n end\n end\n \nend", "def update\n @song = Song.find(params[:id])\n\n params[:song].each do |tag, value|\n if TagInfo::USEFULL_TAGS.include?(tag)#tag on file is a useful tag\n @song[tag] = value #update the useful tag in DB\n end\n end\n respond_to do |format|\n begin\n Song.transaction do #update both file and DB or neither\n @song.update_tags_on_file(params[:song])\n @song.save!\n end\n format.html { redirect_to @song, notice: 'Song was successfully updated.' }\n format.json { head :ok }\n rescue Exception=>e\n format.html { render action: \"edit\" }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tags = tag_list_from_param\n respond_to do |format|\n if @note.update(note_params) && (@tags.empty? || Tag.update_note_tags(current_user, @note.id, @tags))\n format.html { redirect_to @note, notice: 'Note was successfully updated.' }\n format.json { render :show, status: :ok, location: @note }\n else\n format.html { render :edit }\n format.json { render json: @note.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_ref_id(ref_id)\r\n node_set = self.datastreams[\"VRA\"].ng_xml.xpath('/vra:vra/vra:image[@refid]')\r\n node_set[0].set_attribute(\"refid\", ref_id)\r\n self.datastreams[\"VRA\"].content = self.datastreams[\"VRA\"].ng_xml.to_s\r\n end", "def update\n respond_to do |format|\n if @asset_tag.update(asset_tag_params)\n format.html { redirect_to @asset_tag, notice: 'Asset tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @asset_tag }\n else\n format.html { render :edit }\n format.json { render json: @asset_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @photo = Photo.find(params[:id])\n # url = @photo.song_url\n url = params[:photo][:song_url]\n embedly_photo(url)\n \n @photo.save\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @joke = Joke.find(params[:id])\n\n respond_to do |format|\n str_tags = params[:joke][:tags].split(',')\n @tags = str_tags.map {|tag_name|\n Tag.find_or_create_by_name(tag_name)\n }\n @joke.tags = @tags\n \n if @joke.update_attributes(params[:joke].except(:tags))\n format.html { redirect_to @joke, :notice => 'Joke was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @joke.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @post = Post.find(params[:id])\n @tagarr = params[:post][\"tags_attributes\"][\"0\"][:name].split(\" \")\n puts @tagarr\n @tag = {}\n @tagarr.each_with_index do |tag,i|\n @tag[i] = {:name =>tag}\n end\n\n @tagreset = params[:post]\n @tagreset[\"tags_attributes\"] ={}\n @tagreset[\"tags_attributes\"] = @tag\n @post.tags=[]\n #puts @tagreset\n #render :layout => false\n respond_to do |format|\n if @post.update_attributes(@tagreset)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize @ticket\n @ticket.tag_list.add @tags\n if @ticket.save\n render :json => @ticket.reload.tags\n else\n error!(:invalid_resource, @ticket.errors, \"Tags have not been saved\")\n end\n end", "def update\n tag_array = event_params2['tags'].split(',')\n tag_array.each do |x|\n if Tag.find_by(desc: x)\n @tag = Tag.find_by(desc: x)\n else\n @tag = Tag.create(desc: x)\n end\n @event.tags << @tag\n # EventTag.create(event_id: @event.id, tag_id: @tag.id)\n end\n\n\n respond_to do |format|\n store_photos\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # @post.delete_all_tags\n # @post.tag(post_params[:tags], current_user) if post_params[:tags]\n respond_to do |format|\n if @post.update_attributes(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @has_tag.update(has_tag_params)\n format.html { redirect_to @has_tag, notice: 'Has tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @has_tag }\n else\n format.html { render :edit }\n format.json { render json: @has_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n post = Post.find(params[:post][:id])\n post.body = params[:post][:body]\n\n # //location\n post.location.name = params[:post][:location][:name]\n post.location.lat = params[:post][:location][:lat]\n post.location.long = params[:post][:location][:long]\n # images\n for new_img in params[:post][:images]\n flag = 0\n for old_img in post.images\n if old_img.id == new_img[:id]\n flag = 1\n break\n end\n end\n if flag == 0\n img = Image.find new_img[:id]\n img.update_attributes(post_id: post.id, active: 1)\n end\n end\n\n for old_img in post.images\n flag = 0\n for new_img in params[:post][:images]\n if old_img.id == new_img[:id]\n flag = 1\n break\n end\n end\n if flag == 0\n old_img.destroy\n end\n end\n\n if post.save\n render json: {\n status: \"success\",\n data: post.as_json(\n include: [\n {\n user:\n {\n only: [:id, :name, :avatar]\n }\n },\n :location,\n {\n images: {\n only: [:id, :src]\n }\n },\n :rates\n ])}, status: :ok\n else\n render json: post.errors, status: 404\n end\n\n end", "def update\n # ref = request.referrer\n @picture = current_user.pictures.find(params[:id])\n\n respond_to do |format|\n if @picture.update_attributes(params[:picture])\n format.html { redirect_to session[:ref] , notice: 'Picture was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(uri, options = T.unsafe(nil)); end", "def update\n @post.update_attributes(post_params)\n @post.tag_list=(params[:tag_list])\n respond_with @post\n end", "def photo_tag_params\n params.require(:photo_tag).permit(:name)\n end", "def update\n if @tag.update(tag_params)\n redirect_to image_path(@tag.image), notice: 'Tag was successfully updated.'\n else\n render :edit\n end\n end", "def update\n @tag = Tag.find(params[:id])\n \n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to @tag, notice: 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @attachment_data_ref = args[:attachment_data_ref] if args.key?(:attachment_data_ref)\n end", "def orchio_put_if_match(document, ref)\n response = client.send_request :put, inst_args(json: document, ref: ref)\n set_ref_value response\n orchio_status response, 201\n end", "def update\n @user_follow_tag = UserFollowTag.find(params[:id])\n\n respond_to do |format|\n if @user_follow_tag.update_attributes(params[:user_follow_tag])\n format.html { redirect_to @user_follow_tag, notice: 'User follow tag was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_follow_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tag = Tag.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to @tag, :notice => 'Tag was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @tag = Tag.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to tags_url, :notice => 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_conversation_tags(id, tags)\n data = { tags: tags }\n put(\"conversations/#{id}/tags\", { body: data })\n end", "def update_photo_node(user,images_directory,previous_picture)\n Rails.logger.debug \"Call to photo.update_node\"\n if self.valid? #Validate if the Photo object is valid\n Rails.logger.debug \"The photo is valid!\"\n file = self.file #Set the photo file object\n if !file.blank? #Validate if a file was supplied by the user\n images_directory =images_directory.blank? ? @@images_directory : images_directory #Validate if an image_directory was supplied, otherwise we use the default one\n file_s3_path = Util.upload_image(images_directory,file) #Upload the new image\n if !previous_picture.blank?#Validate if there was a previous image file tied to the photo node\n Util.delete_image(previous_picture) #Delete the previous image file\n end\n else\n file_s3_path = self.file #If none was provided, keep the original file\n end\n #Create a raw photo object\n photo_req = { 'title'=>self.title,\n 'description'=>self.description,\n 'url'=>file_s3_path,\n 'date'=> Util.date_to_epoch(self.date), #Turn the date to epoch\n 'ownerId'=> self.owner_id \n } \n reqUrl = \"/api/photo/#{self.id}\" #Set the request url\n\n rest_response = MwHttpRequest.http_put_request(reqUrl,photo_req,user['email'],user['password']) #Make the PUT call to the server with the required parameters\n Rails.logger.debug \"Response from server: #{rest_response.code} #{rest_response.message}: #{rest_response.body}\"\n if rest_response.code == \"200\" #Validate if the response from the server is 200, which means OK\n photo = Photo.rest_to_photo(rest_response.body)\n return true, photo #Return success\n else\n return false, \"#{rest_response.code}\", \"#{rest_response.message}\" #Return error\n end\n else\n Rails.logger.debug self.errors.full_messages\n return false, self.errors.full_messages #Return invalid object error\n end\n end", "def photo_params\n params.require(:photo).permit(:tags, :picture)\n end", "def update\n tag = @user.tags.find_by_tid(params[:id])\n if tag.nil?\n render json_status_response(404, \"Tag not found\")\n return\n end\n\n if not tag.update_attributes(params[:location])\n render json_status_response(400, \"Could not update tag location\")\n return\n end\n\n render json_status_response(200, \"Successfully updated tag\")\n end", "def update\n @tag = @category.tags.find_by_permalink!(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to([@category,@tag], :notice => 'Tag was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if params[:resource][:document].present?\n @resource.document.purge\n @resource.document.attach(params[:resource][:document])\n end\n if params[:resource][:sample].present?\n @resource.sample.purge\n @resource.sample.attach(params[:resource][:sample])\n end\n respond_to do |format|\n if @resource.update(resource_params)\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @resource }\n else\n format.html { render :edit }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @note.update(body: note_params['body'])\n oldtag = @note.tag\n oldsecond = @note.second\n @note.update_tag(note_params['tag'].chomp.downcase, current_user.id)\n @note.update_second(note_params['second'].chomp.downcase, @note.tag.id, current_user.id)\n oldtag.cleanup\n oldsecond.cleanup\n respond_to do |format|\n if @note.save\n format.html { redirect_to notes_path, notice: 'Note was successfully updated.' }\n format.json { render :show, status: :ok, location: @note }\n else\n format.html { redirect_to notes_path, notice: @note.errors}\n format.json { render json: @note.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo, :notice => 'Photo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action=> \"edit\" }\n format.json { render :json => @photo.errors, :status=> :unprocessable_entity }\n end\n end\n end", "def update\n @photo = Photo.find( params[:id])\n if @photo.update_attributes(params[:photo])\n flash[:notice] = \"Photo updated!\"\n if params[:bucket_id]\n redirect_to bucket_album_photo_path( params[:bucket_id], params[:album_id], @photo )\n elsif params[:album_id]\n redirect_to album_photo_path( params[:album_id], @photo )\n else\n redirect_to @photo\n end\n else\n render :action => :edit\n end\n end", "def update\n @photo = Photo.with_attached_pictures.find(params[:id])\n @photo.user_id = current_user.id\n #@photo.update\n # raise @photo.inspect\n respond_to do |format|\n if @photo.update(photo_params)\n # raise @photo.inspect\n format.html { redirect_to album_photos_path, notice: \"Photo was successfully updated.\" }\n format.json { render :show, status: :ok, location: @photo }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @taggable = current_user.taggables.find(params[:id])\n\n respond_to do |format|\n logger.debug(params)\n if @taggable.update_attributes(params[:taggable])\n format.html { redirect_to @taggable, notice: 'Taggable was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @taggable.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @photo1 = Photo1.find(params[:id])\n\n respond_to do |format|\n if @photo1.update_attributes(params[:photo1])\n format.html { redirect_to @photo1, notice: 'Photo1 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo1.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @work = Work.find(params[:id])\n @media_asset = MediaAsset.all\n # tag = Tag.new\n # tag.work_id = params[:id]\n # tag.name = params[:tag]\n\n if params.include? 'tags'\n tag = Tag.new\n tag.name = params[:tags]\n tag.work_id = @work.id\n tag.save!\n end\n\n @work.media_id = params[:media_value]\n respond_to do |format|\n if @work.update_attributes(params[:work])\n format.html { redirect_to @work, notice: 'Work was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @posttag = Posttag.find(params[:id])\n\n respond_to do |format|\n if @posttag.update_attributes(params[:posttag])\n format.html { redirect_to @posttag, :notice => 'Posttag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @posttag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @pictures = Picture.all.order(created_at: :desc)\n @picture.update(picture_params)\n render json: @pictures\n # head :no_content\n end", "def update\n\n if @structure_photo.update(structure_photo_params)\n render json: @structure_photo, status: :ok\n else\n render json: @structure_photo.errors, status: :unprocessable_entity\n end\n end", "def update\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo, :notice => 'Photo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @photo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def photo_params\n params.require(:vote).permit(:photo_id)\n end", "def update\n respond_to do |format|\n if @tag_one.update(tag_one_params)\n format.html { redirect_to @tag_one, notice: 'Tag one was successfully updated.' }\n format.json { render :show, status: :ok, location: @tag_one }\n else\n format.html { render :edit }\n format.json { render json: @tag_one.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @tag = Tag.find(params[:id])\n if current_admin\n if params[:pin]\n @tag.photo_id = params[:pin]\n @tag.save\n end\n end\n # @category_photo = @tag.photo\n @photos = Photo.includes(:tags).where(:tags => {:name => @tag.name})\n @untagged_photos = []\n Photo.all.each do |p|\n @untagged_photos << p if p.tags.count == 0\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tag }\n end\n end", "def update\n @post = Post.find(params[:id])\n @post.tag_list = params[:tags]\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_tags(metricDefinition)\n @client.http_put(\"/#{@resource}/#{metricDefinition.id}/tags\",metricDefinition.hash[:tags])\n end", "def update\n respond_to do |format|\n if @photo.update(photo_params)\n save_to_json\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { render :show, status: :ok, location: @photo }\n else\n format.html { render :edit }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6825852", "0.6774827", "0.6622745", "0.64420795", "0.6418615", "0.62085545", "0.6106002", "0.6028779", "0.5949675", "0.5885303", "0.585909", "0.58474535", "0.5829722", "0.5811459", "0.5748328", "0.57446533", "0.5697312", "0.5687181", "0.5678905", "0.56371164", "0.5636402", "0.5633488", "0.5609114", "0.5602855", "0.55847555", "0.5529525", "0.55291986", "0.5522969", "0.55117285", "0.5509717", "0.5466203", "0.5447708", "0.5419921", "0.53960836", "0.5376158", "0.5371458", "0.5366555", "0.5352985", "0.53460056", "0.534445", "0.53437644", "0.5338556", "0.53299546", "0.53263533", "0.5326032", "0.53086823", "0.53051233", "0.5300175", "0.52965945", "0.52936304", "0.5288397", "0.52854514", "0.52834326", "0.52745026", "0.5263786", "0.5260756", "0.52601165", "0.5258306", "0.52457225", "0.5228752", "0.5225731", "0.5212783", "0.5203592", "0.5184492", "0.51796806", "0.5173796", "0.51689214", "0.51554203", "0.51504314", "0.5150043", "0.5149568", "0.5149243", "0.5141987", "0.51404834", "0.5128979", "0.512859", "0.51278484", "0.5125624", "0.5124851", "0.5122583", "0.5112853", "0.5108674", "0.510861", "0.5107479", "0.5105707", "0.5105086", "0.5104864", "0.51013464", "0.51009923", "0.51006955", "0.50994366", "0.50994366", "0.50994366", "0.50994366", "0.5098694", "0.5096936", "0.50965273", "0.50910604", "0.5088474", "0.5088345" ]
0.72623074
0
DELETE /photo_tag_references/1 DELETE /photo_tag_references/1.json
def destroy @photo_tag_reference.destroy respond_to do |format| format.html { redirect_to photo_tag_references_url, notice: 'Photo tag reference was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @image_reference.destroy\n respond_to do |format|\n format.html { redirect_to image_references_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo_tag.destroy\n respond_to do |format|\n format.html { redirect_to photo_tags_url, notice: 'Photo tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @hastags = Hastag.where(:photo_id => @photo.id)\n @hastags.destroy_all\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to '/home', notice: 'You have deleted the picture' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tag_ref.destroy\n respond_to do |format|\n format.html { redirect_to tag_refs_url, notice: 'Usunięto Tag z artykułu.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.photo.destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to request.env[\"HTTP_REFERER\"] || @photo.photoable, notice: 'Photo removed!' }\n format.json { head :no_content }\n end\n end", "def delete photo_id\n @flickr.photos.delete(photo_id: photo_id)\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to @photo.photoable }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to uploads_url }\n format.json { head :no_content }\n end\n end", "def delete(photo)\n photo = photo.id if photo.class == Flickr::Photo\n res = @flickr.call_method('flickr.photos.delete',\n 'photo_id'=>photo)\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to uploads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_news_link_photo.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_news_link_photos_url, notice: 'News link photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo1 = Photo1.find(params[:id])\n @photo1.destroy\n\n respond_to do |format|\n format.html { redirect_to photo1s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n\n head :no_content\n end", "def destroy\n @image_tag.destroy\n respond_to do |format|\n format.html { redirect_to image_tags_url, notice: 'Image tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(tag)\n api_client.tags.multi_delete(resource_hrefs: [api_client.get_instance.href], tags: [tag])\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to @photo.item }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @photo = Photo.find(params[:id])\r\n @photo.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to photos_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\r\n @photo = Photo.find(params[:id])\r\n @photo.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to photos_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n head :no_content\n end", "def delete_tag tag\n delete \"tag/#{tag}\"\n end", "def destroy\n @image.tags.destroy_all\n @image.destroy\n respond_to do |format|\n format.html { redirect_to images_url, notice: 'Image was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @uploadphoto.destroy\n respond_to do |format|\n format.html { redirect_to uploadphotos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @structure_photo.destroy\n render json: {message: 'Foto Excluida'} , status: :ok\n end", "def destroy\n @sample_photo.destroy\n render json: {message: 'Foto Excluida'} , status: :ok\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to(photos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to(photos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to(photos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to(photos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @reference = Reference.find(params[:id])\n @reference.destroy\n\n respond_to do |format|\n format.html { redirect_to references_url }\n format.json { head :no_content }\n end\n end", "def destroy\n #@document = current_user.documents.find(params[:document_id])\n @document_photo = @document.document_photos.find(params[:id])\n if @document_photo\n \n @document_photo.destroy\n\n respond_to do |format|\n format.html { redirect_to document_itemimages_url(@document) }\n format.json { head :no_content }\n end\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n query = \"created_by = \\\"#{current_user.email}\\\"\"\n @photo = Photo.where(query).with_attached_images.find(params[:id])\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_path, notice: 'Destroyed successfully.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = @allbum.photos.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to allbum_photos_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo_blog.destroy\n respond_to do |format|\n format.html { redirect_to photo_blogs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo_library = PhotoLibrary.find(params[:id])\n @photo_library.destroy\n\n respond_to do |format|\n format.html { redirect_to photo_libraries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @post_photo.destroy\n respond_to do |format|\n format.html { redirect_to post_photos_url, notice: 'Post photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n File.delete(Rails.root.join(\"app\",'assets','images',@photo.path))\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n gallery = @photo.gallery\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to gallery_path(gallery) }\n format.json { head :no_content }\n end\n end", "def remove(photo)\n response = connection.delete(\"/collections/#{id}/remove\", photo_id: photo.id)\n (200..299).include?(response.status)\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to user_album_photos_url(@user, @album) }\n format.xml { head :ok }\n end\n end", "def destroy\n \t@album = Album.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :ok }\n end\n end", "def delete(photo_id)\r\n Net::Flickr.instance().request('flickr.photos.delete',\r\n 'photo_id' => photo_id)\r\n true\r\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to edit_admin_gallery_path(:id=>@gallery.id) }\n format.json { render :json => true }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @asset = Asset.find(params[:id])\n @asset.photo.destroy\n @asset.save\n redirect_to :back\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ref.destroy\n respond_to do |format|\n format.html { redirect_to refs_url, notice: 'Ref was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo_set = PhotoSet.find(params[:id])\n @photo_set.destroy\n\n respond_to do |format|\n format.html { redirect_to(photo_sets_url) }\n format.xml { head :ok }\n end\n end", "def delete\n photo_id = params[:photoId]\n photo = Photo.find(photo_id)\n\n if (photo.nil?)\n raise Exceptions::PhotoHuntError.new(404, 'Photo with given ID does not exist')\n elsif (photo.owner_user_id != session[:user_id])\n raise Exceptions::PhotoHuntError.new(404, 'Photo with given ID does not exist')\n else\n photo.destroy\n end\n\n # TODO(samstern): Figure out why this method works but the Android client\n # reports failure\n render json: 'Photo successfully deleted'\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\tCloudinary::Api.delete_resources([@foto.public_id])\n @foto.destroy\n respond_to do |format|\n format.html { redirect_to @proyecto, notice: 'Foto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @plate_photo = PlatePhoto.find(params[:id])\n @plate_photo.destroy\n\n respond_to do |format|\n format.html { redirect_to plate_photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to(photos_path.add_param(:blurb_image => @blurb_image)) }\n format.xml { head :ok }\n end\n end", "def destroy\n [email protected]\n @photo.destroy\n save_to_json\n respond_to do |format|\n format.html { redirect_to album_path(album), notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n real_post_path = @tag.post\n @tag.destroy\n respond_to do |format|\n format.html { redirect_to post_path(real_post_path), notice: 'tag deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @home_categories_products_indices_photo = Home::Categories::Products::Indices::Photo.find(params[:id])\n @home_categories_products_indices_photo.destroy\n\n respond_to do |format|\n format.html { redirect_to home_categories_products_indices_photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n photo.destroy\n respond_to do |format|\n format.html { redirect_to admin_photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n #@team_photo = TeamPhoto.find(params[:id])\n @team_photo.destroy\n\n respond_to do |format|\n format.html { redirect_to team_photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @flat_photo.destroy\n respond_to do |format|\n format.html { redirect_to flat_photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe_photo.destroy\n respond_to do |format|\n format.html { redirect_to recipe_photos_url, notice: 'Recipe photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @rock_photo.destroy\n render json: {message: 'Foto Excluida'} , status: :ok\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: \"投稿を削除しました.\" }\n format.json { head :no_content }\n end\n \n end", "def destroy\n @photo_detail.destroy\n respond_to do |format|\n format.html { redirect_to photo_details_url, notice: 'Photo detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @photo.destroy\r\n respond_to do |format|\r\n format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @photo = Photo.find(params[:id])\n\t@album = Album.find(@photo.album_id)\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to album_path(@album) }\n format.json { head :ok }\n end\n end", "def destroy\n @user_photo = UserPhoto.find(params[:id])\n @user_photo.destroy\n\n respond_to do |format|\n format.html { redirect_to user_photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project_photo = ProjectPhoto.find(params[:id])\n @project_photo.destroy\n\n respond_to do |format|\n format.html { redirect_to project_photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ref = Ref.find(params[:id])\n @ref.destroy\n\n respond_to do |format|\n format.html { redirect_to(refs_url) }\n format.xml { head :ok }\n end\n end" ]
[ "0.72668993", "0.7183108", "0.7113497", "0.70694256", "0.69641674", "0.6859285", "0.6857697", "0.6793", "0.67763734", "0.67498916", "0.67401063", "0.6716383", "0.67146635", "0.67146635", "0.67146635", "0.67146635", "0.67146635", "0.67146635", "0.6712148", "0.6712148", "0.6712148", "0.6712148", "0.6712148", "0.6709994", "0.6699131", "0.66895264", "0.6688332", "0.6687555", "0.667314", "0.667314", "0.6670618", "0.6665958", "0.6665958", "0.6650552", "0.66415274", "0.66397405", "0.6632652", "0.66166306", "0.6592699", "0.6582865", "0.6582865", "0.6582865", "0.6582865", "0.65757626", "0.6574438", "0.657125", "0.65546024", "0.65366966", "0.6529301", "0.650481", "0.65002626", "0.6490343", "0.6488937", "0.6485008", "0.64722216", "0.64597344", "0.6453806", "0.64511365", "0.645052", "0.6443719", "0.64428186", "0.6442617", "0.6442617", "0.6442617", "0.6442617", "0.6442617", "0.6442617", "0.6442617", "0.6442617", "0.6442617", "0.6442617", "0.6442617", "0.6442617", "0.6442617", "0.6442617", "0.6442617", "0.6442617", "0.6442617", "0.6438967", "0.64355063", "0.6419999", "0.64198416", "0.6418282", "0.64070225", "0.64047295", "0.6397139", "0.6393709", "0.6382361", "0.63781047", "0.637133", "0.6371034", "0.6370476", "0.6366234", "0.636441", "0.63631654", "0.63631314", "0.63620347", "0.6355435", "0.635392", "0.6352284" ]
0.79156494
0
Use callbacks to share common setup or constraints between actions.
def set_photo_tag_reference @photo_tag_reference = PhotoTagPhoto.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 photo_tag_reference_params params.require(:photo_tag_photo).permit(:photo_id, :photo_tag_id) 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
Try to focus on using correct technical vocabulary. Use the to create a new comment Build a Bear Declare function build_a_bear
def build_a_bear(name, age, fur, clothes, special_power) # Create variable greeting greeting = "Hey partner! My name is #{name} - will you be my friend?!" # Create variable demographics demographics = [name, age] # Create power_saying variable power_saying = "Did you know that I can #{special_power}?" # Create variable build_bear with values built_bear = { # give value to basic_info 'basic_info' => demographics, # Give value to clothes 'clothes' => clothes, # Give value to exterior 'exterior' => fur, # Give value to cost 'cost' => 49.99, # give value to sayings 'sayings' => [greeting, power_saying, "Goodnight my friend!"], # Give value to is_cuddly 'is_cuddly' => true, } # return variable return built_bear # end of function end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_a_bear(name, age, fur, clothes, special_power)\n# Interpulate the parameter name into a string for the variable greeting.\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n# Assign an array of name and age for the demographics variable.\n demographics = [name, age]\n# Interpulate the parameter of special_power into a string of the variable power_saying.\n power_saying = \"Did you know that I can #{special_power}?\"\n# Sart to model a built_bear with a hash.\n built_bear = {\n# Assign basic_info to the variable demographics.\n 'basic_info' => demographics,\n# Assign clothes to the parameter clothes.\n 'clothes' => clothes,\n# Assign exterior to the parameter fur.\n 'exterior' => fur,\n# Assign cost to a floating point integer.\n 'cost' => 49.99,\n# Assign sayings to an array of greeting, power_saying, and the string \"Goodnight my friend!\"\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n# Assign is_cuddly to a boolean value of true.\n 'is_cuddly' => true,\n# End model\n }\n# Return a built_bear. \n return built_bear\n# End block of code. \nend", "def build_a_bear(name, age, fur, clothes, special_power)\n# a variable that sets a greeting for the bear; this greeting includes interpolation of the bear's name\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n# a variable defined by an array containing the bear's name and age\n demographics = [name, age]\n# a variable that sets a statement of what power the bear has and includes interpolation of the bear's power\n power_saying = \"Did you know that I can #{special_power}?\"\n# a hash with all sorts of information about the bear, including interpolation of previously defined variables\n built_bear = {\n# assigning key 'basic_info' to the previously defined value demographics\n 'basic_info' => demographics,\n# assigning key 'clothes' to the value 'clothes' that was previously defined when the bear was first built\n 'clothes' => clothes,\n# assigning key 'exterior' to the value 'fur', similar to last line this was defined on bear creation\n 'exterior' => fur,\n# assigning key 'cost' to 49.99. a pricy bear for sure, but perhaps it's worth it with its powers?\n 'cost' => 49.99,\n# assigning key 'sayings' to an array containing three objects; the bear's previously assigned greeting and power_saying, along with a new string\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n# assigning key 'is_cuddly' to a boolean; in this case, making is_cuddly true. great job on making sure your boolean is equal to an \"is_<variable>\" value rather than simply a <variable>\n 'is_cuddly' => true,\n# closing the hash\n }\n# returns the fully built bear into the console\n return built_bear\n# closes our build_a_bear function\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n#behavior to interpolate the name variable into the greeting action\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n#creating an array for the demographics variable that includes the name and age arguments\n demographics = [name, age]\n#behavioir to interpolate the special power into the power saying variable\n power_saying = \"Did you know that I can #{special_power}?\"\n#creating a hash out for info about a built bear.\n built_bear = {\n 'basic_info' => demographics,\n 'clothes' => clothes,\n 'exterior' => fur,\n 'cost' => 49.99,\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n 'is_cuddly' => true,\n }\n#presenting this information once created\n return built_bear\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n # declare the variable 'greeting' to a string\n # Ask the partner if they will be your friend. Also state your name.\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # declare the variable 'demographics' to an array\n # place name and age within the array\n demographics = [name, age]\n # declare the variable power_saying to a string\n # Ask if they knew about their special_power\n power_saying = \"Did you know that I can #{special_power}?\"\n # create a hash that contains the keys/values\n # basic_info/demographics\n # clothes/clothes\n # exterior/fur\n # cost/49.99\n # sayings/[greeting, power_saying, \"Goodnight, my friend!\"]\n # is_cuddly/true\n built_bear = {\n 'basic_info' => demographics,\n 'clothes' => clothes,\n 'exterior' => fur,\n 'cost' => 49.99,\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n 'is_cuddly' => true,\n }\n # return the built bear\n return built_bear\n # ends the method\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n#Defines the variable greeting as a string which includes the argument \"name\"\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n#Defines the variable demographics as the arguments name and age\n demographics = [name, age]\n#Defines the variable power_saying as a string which includs the argument special_power\n power_saying = \"Did you know that I can #{special_power}?\"\n#Defines an array named built_bear\n built_bear = {\n#The first key of the array is \"basic_info\" which is paired with the value \"demographics\".\n 'basic_info' => demographics,\n#The 2nd key is \"clothes\" and has the value \"clothes\".\n 'clothes' => clothes,\n#The 3rd key is \"exterior\" and has the value \"fur\".\n 'exterior' => fur,\n#The 4th key is cost and has the value 49.99\n 'cost' => 49.99,\n#The 5th key is the array named sayings which has the values greeting, power_saying, and \"Goodnight my friend!\"\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n#The 6th key is_cuddly has the value \"true\"\n 'is_cuddly' => true,\n }\n#The array built_bear is returned.\n return built_bear\n#Ends the definition of the method\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n # sets the variable greeting to return the following phrase when called\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # sets name and age to the variable demographics\n demographics = [name, age]\n # sets power_saying to return the following phrase when called\n power_saying = \"Did you know that I can #{special_power}?\"\n # creates a hash called built_bear with basic_info, clothes, exterior, cost, sayings, and is_cuddly\n built_bear = {\n 'basic_info' => demographics,\n 'clothes' => clothes,\n 'exterior' => fur,\n 'cost' => 49.99,\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n 'is_cuddly' => true,\n }\n return built_bear\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n # Setting variable greeting to a string with interpolation \n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # setting demographics variable to an array with name and age inside\n demographics = [name, age]\n # Setting variable power saying with a string that has interpolation\n power_saying = \"Did you know that I can #{special_power}?\"\n # Builidng a hash with built_bear as the name of it\n built_bear = {\n # Basic info is the variable name with demographics being its string value demographics\n 'basic_info' => demographics,\n # Clothes variable set to string value clothes\n 'clothes' => clothes,\n # exterior variable set to string value fur\n 'exterior' => fur,\n # cost variable set to float value 49.99\n 'cost' => 49.99,\n # saying variable is set to an array consisting of two variables and one string value\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # is cuddly variable set to boolean value true\n 'is_cuddly' => true,\n }\n # Stores built_bear hash\n return built_bear\n # ends the function\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n# establish variables greeting (with string with interpolation), demographics (array), power_saying (string with interpolation)\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n demographics = [name, age]\n power_saying = \"Did you know that I can #{special_power}?\"\n# create hash for variable built_bear\n built_bear = {\n # key = basic_info, value = demographics\n 'basic_info' => demographics,\n # kay = clothes, value = clothes\n 'clothes' => clothes,\n # key = exterior, value = fur\n 'exterior' => fur,\n # key = cost, value = 49.99\n 'cost' => 49.99,\n # key = sayings, value = array\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # key = is_cuddly, value = boolean (true)\n 'is_cuddly' => true,\n # close hash\n }\n # stops method execution flow and returns built_bear\n return built_bear\n# end code block\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n#Declare a variable called greeting, whose value is a string that contains the above name argument\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n#Declare a variable called demographics which is assigned to an array with name and age values\n demographics = [name, age]\n#Declare a variable call power_saying whose value is a string that containsthe above special_power argument\n power_saying = \"Did you know that I can #{special_power}?\"\n#Declare a variable called built_bear whos value is a hash with 6 elements\n built_bear = {\n#The built_bear hash includes the key 'basic_info' whose value is the above demographics variable\n 'basic_info' => demographics,\n#The built_bear hash includes the key clothes, whose value is the clothes argument in line 7\n 'clothes' => clothes,\n#The built_bear hash includes the key exterior, whose value is the fur argument in line 7\n 'exterior' => fur,\n#The built_bear hash includes the key cost, which is assigned the constant value 49.99\n 'cost' => 49.99,\n#The built_bear hash includes the key sayings, whose value is an array of 3 elements (2 aforementioned variables and new unique string)\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n##The built_bear hash includes the key 'is_cuddly', which is assigned the boolean value true.\n 'is_cuddly' => true,\n#Conclude the hash with a curly bracket\n }\n#As the last step of the build_a_bear method, retun the value for built_bear\n return built_bear\n#End the build_a_bear method\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n # greeting variable set to a string with the name interpolated\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # demographics variable set as an array with name and age\n demographics = [name, age]\n # power_saying variable set to a string with special_power interpolated\n power_saying = \"Did you know that I can #{special_power}?\"\n # built_bear set as a hash to collect data on six variables\n built_bear = {\n # 'basic_info' key set to demographics array with name and age\n 'basic_info' => demographics,\n # 'clothes' key set to clothes attribute\n 'clothes' => clothes,\n # 'exterior' set to fur attribute\n 'exterior' => fur,\n # 'cost' set to static float number 49.99\n 'cost' => 49.99,\n # 'sayings' set to array that includes the greeting and power_saying variables and a string\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # 'is_cuddly' set to boolean true\n 'is_cuddly' => true,\n }\n # returns or runs built_bear\n return built_bear\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n # Create a variable called 'greeting' and assign it to a string that includes the string interpolation 'name'.\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # Create a variable called 'demographics' and assign an array with the parameters 'name' and 'age'\n demographics = [name, age]\n # Create a variable called 'power_saying' and assign it to a string that includes the string interpolation 'special_power'.\n power_saying = \"Did you know that I can #{special_power}?\"\n # Create a variable called 'built_bear' as a hash, storing 6 keys with their corresponding values\n built_bear = {\n 'basic_info' => demographics,\n 'clothes' => clothes,\n 'exterior' => fur,\n 'cost' => 49.99,\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n 'is_cuddly' => true,\n }\n # Create a method to return the details of your built_bear hash as a return statement\n return built_bear\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n# Set greeting variable equal to string with name argument interpolated\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n# Set demographic variable to an array of name and age arguments\n demographics = [name, age]\n# Set power_saying variable to a string with special_power argument interpolated\n power_saying = \"Did you know that I can #{special_power}?\"\n#Set built_bear variable to a hash\n built_bear = {\n# Create key basic_info connected to demographics array\n 'basic_info' => demographics,\n # Create key clothes connected to clothes argument\n 'clothes' => clothes,\n # Create key exterior connected to fur argument\n 'exterior' => fur,\n # Create key cost connected to integer 49.99\n 'cost' => 49.99,\n # Create key sayings connected to array with string values: greeting variable, power_saying variable, and other string\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # Create key is-cuddly connected to boolean true.\n 'is_cuddly' => true,\n }\n # Return all the info in the built_bear hash.\n return built_bear\n# Close out the method\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n# Assign a string to a variable called 'greeting' and interpolate the 'name'\n# variable within the string.\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n# Assign an array to a variable called 'demographics' containing the 'say_name'\n# and 'age' variables.\n demographics = [name, age]\n# Assign a string to a variable called 'power_saying' and interpolate the\n# 'special_power' variable.\n power_saying = \"Did you know that I can #{special_power}?\"\n# Create a hash called built_bear\n built_bear = {\n# Create a key/value pair using a string as the key and the demographics variable as the value.\n 'basic_info' => demographics,\n# Create a key/value pair using a string as the key and the clothes variable as the value.\n 'clothes' => clothes,\n# Create a key/value pair using a string as the key and the fur variable as the value.\n 'exterior' => fur,\n# Create a key/value pair using a string as the key and a float as the value.\n 'cost' => 49.99,\n# Create a key/value pair using a string as the key and an array containing two\n# variables and a string as the value.\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n# Create a key/value pair using a string as the key and a boolean value as the value.\n 'is_cuddly' => true,\n# Curly bracket to close out the hash.\n }\n# Return the built_bear hash.\n return built_bear\n# End the definition of the build_a_bear method.\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n # Declare variables\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\" # Declare concatenated string variable\n demographics = [name, age] # Declare array variable\n power_saying = \"Did you know that I can #{special_power}?\" # Declare concatenated string variable\n\n built_bear = { # Declare hash variables\n 'basic_info' => demographics, # String variable within hash\n 'clothes' => clothes, # String variable within hash\n 'exterior' => fur, # String variable within hash\n 'cost' => 49.99, # Integer variable within hash\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"], # Array variable within hash\n 'is_cuddly' => true, # Boolean variable within hash\n }\n return built_bear\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n# Assigns the variable \"greeting\" to a string.\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n#Assigns the variable demographics to an array with name and age inside.\n demographics = [name, age]\n# Assigns the variable power_saying to a string.\n power_saying = \"Did you know that I can #{special_power}?\"\n# Assigns the variable built_bear to a hash containing keys and values.\n built_bear = {\n# Assigns the key \"basic_info\" to the value/string \"demographics\".\n 'basic_info' => demographics,\n# Assigns the key \"clothes\" to the value/string \"clothes\".\n 'clothes' => clothes,\n# Assigns the key \"exterior\" to the value/string \"fur\".\n 'exterior' => fur,\n# Assigns the key \"cost\" to the value/float 49.99.\n 'cost' => 49.99,\n# Assigns the key \"sayings\" to a value/array with greeting, power_saying, and \"Goodnight my friend!\".\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n# Assigns the key \"is_cuddly\" to a value/boolean \"true\".\n 'is_cuddly' => true,\n }\n# Stops the method and returns the values in the hash \"built_bear\".\n return built_bear\n# Ends the method.\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n #define variable greeting\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n #define variable demographics with 2 arguments\n demographics = [name, age]\n #define variable power_saying as a string with interpolation\n power_saying = \"Did you know that I can #{special_power}?\"\n #define built_bear as a hash and set variables inside\n built_bear = {\n #set basic_info to string\n 'basic_info' => demographics,\n #set clothes to string\n 'clothes' => clothes,\n #set exterior to a string\n 'exterior' => fur,\n #set cost to a float\n 'cost' => 49.99,\n #set sayings as an array\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n #set is_cuddly to a boolean\n 'is_cuddly' => true,\n #close hash\n }\n #return the built_bear hash\n return built_bear\n #close the build_a_bear method\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n #greeting should be a string that has the name argument\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n #demographics should an array that has elements: name and age\n demographics = [name, age]\n #power_saying should be a string that includes the special_power argument\n power_saying = \"Did you know that I can #{special_power}?\"\n #built_bearshould be a hash with elements: basic_info, clothes, exterior, cost, sayings, is_cuddly\n built_bear = {\n 'basic_info' => demographics,\n 'clothes' => clothes,\n 'exterior' => fur,\n 'cost' => 49.99,\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n 'is_cuddly' => true,\n }\n #return build_bear\n return built_bear\n #end\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n # Declare four variables greeting, demographics, power_saying, AND built_bear\n # Assign greeting to a string that uses interpolation to include the name\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # Assign demographics to an array containing name and age in that order\n demographics = [name, age]\n # Assign power_saying to a string that uses interpolation to include special_power\n power_saying = \"Did you know that I can #{special_power}?\"\n # Assign built_bear to a hash with key values: basic_info, clothes, exterior,\n # cost, and sayings\n built_bear = {\n # Assign the key basic_info to return the value in the variable demographics\n 'basic_info' => demographics,\n # Assign the key clothes to return the value in the variable clothes\n 'clothes' => clothes,\n # Assign the key exterior to return the value in the variable fur\n 'exterior' => fur,\n # Assign the key cost to float value 49.99\n 'cost' => 49.99,\n # Assign the key sayings to an array containing the values in greeting, power_saying\n # and the string 'Goodnight my friend!'\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # Assign the key is_cuddly to a boolean value of true.\n 'is_cuddly' => true,\n }\n # Return the result of the variable, built_bear\n return built_bear\n# end\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n #defines new method called 'build a bear' with several parameters\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n #defines string with name variable\n demographics = [name, age]\n #defines demographics with array\n power_saying = \"Did you know that I can #{special_power}?\"\n #defines string with special_power variable\n\n built_bear = {\n #this creates a hash which stores info about built_bear.\n 'basic_info' => demographics,\n #this assigns 'basic info' to 'demographics'\n 'clothes' => clothes,\n #assigns clothes to value 'clothes'\n 'exterior' => fur,\n #assigns 'exterior' to value 'fur'\n 'cost' => 49.99,\n #assings 'cost' to float'49.99'\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n #assigns 'saying' to array that calls methods 'greeting' and 'power_saying', as well as string 'Goodnight my friend!'\n 'is_cuddly' => true,\n } #assigns value 'is cuddly' to boolean.\n return built_bear\n #\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n #defined greeting variable\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # provided demographics via an array\n demographics = [name, age]\n # variable defined for power_saying\n power_saying = \"Did you know that I can #{special_power}?\"\n # hash for key/value pairs for built_bear\n built_bear = {\n # ties basic_info to array demographics\n 'basic_info' => demographics,\n # clothes is tied to argument clothes in method build_a_bear\n 'clothes' => clothes,\n # defines exterior to argument fur in mthod build_a_bear\n 'exterior' => fur,\n # cost is tied to float 49.99\n 'cost' => 49.99,\n #sayings is tied to array with greeting, power_saying and a string\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # is_cuddly is tied to true I dont think booleans are allowed in hashes but this is a set value correct?\n 'is_cuddly' => true,\n # ends hash\n }\n # prints key/value pairs in built_bear hash\n return built_bear\n # ends method\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n #defines a variable, greeting, as a string with the parameter name interpolated\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n #defines a variable, demographics, as an array whose elements are the parameters name and age\n demographics = [name, age]\n #defines a variable, power_saying, as a string with an awkward interpolation of the parameter special_power\n power_saying = \"Did you know that I can \" + special_power + \" ?\"\n #defines a variable, built_bear, as a hash with six key/data pairs\n built_bear = {\n basic_info: demographics,\n clothes: clothes,\n exterior: fur,\n cost: 49.99,\n sayings: [greeting, power_saying, \"Goodnight my friend!\"],\n is_cuddly: true,\n }\n #sets the output to built_bear\n return built_bear\n#ends the method build_a_bear\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n # sets a variable to string interpolated with the name provided in first argument above\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # sets a variable to an array containing the first and second arguments above\n demographics = [name, age]\n # sets a variable to a string interpolated with 5th argument\n power_saying = \"Did you know that I can #{special_power}?\"\n # sets variable to a hash containing attributes of the bear being built\n built_bear = {\n # sets hash key to refer to demographics variable created above\n 'basic_info' => demographics,\n # sets hash key to refer to the clothes argument\n 'clothes' => clothes,\n # sets hash key to refer to fur argument\n 'exterior' => fur,\n # sets hash key to refer to cost of bear (in float data type)\n 'cost' => 49.99,\n # sets hash key to refer to an array of strings, including two string variables created above\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # sets hash key to refer to a boolean value\n 'is_cuddly' => true,\n }\n #outputs the hash object created above\n return built_bear\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n # assign a variable to a string that includes interpolation\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # assign a variable to an array that includes interpolation\n demographics = [name, age]\n # assign a variable to a string that includes interpolation\n power_saying = \"Did you know that I can #{special_power}?\"\n # assign a variable to a hash\n built_bear = {\n # assign a key with a variable value\n 'basic_info' => demographics,\n # assign a key with a variable value\n 'clothes' => clothes,\n # assign a key with a variable value\n 'exterior' => fur,\n # assign a key with a float value\n 'cost' => 49.99,\n # assign a key with an array value that includes variables and a string\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # assign a key with a Boolean value\n 'is_cuddly' => true,\n # end the hash with a closing curly bracket\n }\n # output the variable\n return built_bear\n# end the method definition\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n # this line assigns a string variable with a parameter interpolated in\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # this line assigns an array variable\n demographics = [name, age]\n # this line assigns a string variable with a parameter interpolated in\n power_saying = \"Did you know that I can #{special_power}?\"\n # this line defines a has variable\n built_bear = {\n # this line defines a string key and an array variable value pair\n 'basic_info' => demographics,\n # this lines defines a string key and uses an argument passed in as the value\n 'clothes' => clothes,\n # this lines defines a string key and uses an argument passed in as the value\n 'exterior' => fur,\n # this line defines a string key and float value pair\n 'cost' => 49.99,\n # this line defines a string key and an array value that includes a previously\n # defined string variable, a parameter passed in, and a string\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # this line defines a string key and a boolean value pair\n 'is_cuddly' => true,\n # this ends the hash value\n }\n # this line defines the returned value of the method which is the has variable\n # previously created\n return built_bear\n# this ends the build_a_bear method definition\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n#defines a variable named greeting, as a string interpolated with one of the arguments from above\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n#defines a variable named demographics, as an array containing two of the arguments from above\n demographics = [name, age]\n#defines a variable named power_saying, as a string interpolated with one of the arguments from above\n power_saying = \"Did you know that I can #{special_power}?\"\n#defines a variable named built_bear, as a hash\n built_bear = {\n#this key points to the variable array above\n 'basic_info' => demographics,\n#this key points to the method argument clothes\n 'clothes' => clothes,\n#this key points to the method argument fur\n 'exterior' => fur,\n#this key points to a float for the cost\n 'cost' => 49.99,\n#this key points to an array of two string variables from above, and another string\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n#this key points to a boolean, telling if the object is cuddly or not\n 'is_cuddly' => true,\n }\n#this tells the console to log the results of the hash\n return built_bear\n#end method codeblock\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n # declare a variable called greeting with a value that's a string with the name parameter interpolated in\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # declare a variable called demographics; value is an array with 2 elements: the name and age parameters\n demographics = [name, age]\n # declare a variable called power_saying; value is a string with special_power parameter interpolated in\n power_saying = \"Did you know that I can #{special_power}?\"\n # declare a variable called built_bear; value is a hash with keys: basic_info, clothes, exterior, cost, sayings, is_cuddly\n built_bear = {\n 'basic_info' => demographics,\n 'clothes' => clothes,\n 'exterior' => fur,\n 'cost' => 49.99,\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n 'is_cuddly' => true,\n }\n # when method is called, it will return the built_bear hash\n return built_bear\n# close the method\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n\n#assigning a variable \"greeting\" to a string message with\n# the name argument interpolated inside the string\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n\n#assigning a variable \"demographics\" to an array containing\n#arguments \"name\" and \"age\"\n demographics = [name, age]\n\n#assigning a variable \"power_saying\" to a string\n#that has the special_power argument interpolated within\n power_saying = \"Did you know that I can #{special_power}?\"\n\n# Assigning the built_bear variable to a hash\n built_bear = {\n\n# assigning the key basic_info to a value of a variable demographics\n 'basic_info' => demographics,\n\n#assigning the key clothes to a value of the argument clothes\n#within the build_a_bear method\n 'clothes' => clothes,\n\n#assigning the key exterior to a value of the argument fur\n#within the build_a_bear method\n 'exterior' => fur,\n\n#Assigning the key cost to a float value\n 'cost' => 49.99,\n\n#Assign the key sayings to an array that contains the variables\n#greeting and power_saying, along with a string\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n\n# assign the key is_cuddly to a boolean value\n 'is_cuddly' => true,\n }\n# outputs the data within the hash of the variable built_bear\n return built_bear\n# end of the method build_a_bear\nend", "def build_a_bear(name, age, fur, clothes, special_power) #initializes a method that takes 5 inputs.\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\" # Creates a variable named greeting, a string. Uses interpolation to put one of inputs into string.\n demographics = [name, age] # creates an array variable\n power_saying = \"Did you know that I can #{special_power}?\" #creates a string variable, with string interpolation\n built_bear = {\n 'basic_info' => demographics,\n 'clothes' => clothes,\n 'exterior' => fur,\n 'cost' => 49.99,\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n 'is_cuddly' => true,\n } # creates a hash of a built bear.\n return built_bear # 'saves' the information to the method\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n # assigns greeting to string\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # assigns demographics to array with name and age in it.\n demographics = [name, age]\n # assigns power_saying to string with special_power interpolation\n power_saying = \"Did you know that I can #{special_power}?\"\n # assigns built_bear to hash\n built_bear = {\n # assigns basic_info to demographics\n 'basic_info' => demographics,\n # assigns clothes to clothes\n 'clothes' => clothes,\n # assigns exterior to fur\n 'exterior' => fur,\n # assigns cost to float 49.99\n 'cost' => 49.99,\n # assigns sayings to array\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # assigns is_cuddly to boolean value of true\n 'is_cuddly' => true,\n # closes hash\n }\n # returns built_bear hash\n return built_bear\n # ends function\nend", "def build_a_bear(name, age, fur, clothes, special_power) #Defining a function/method called `build_a_bear` which takes 5 parameters (name, age, fur, clothes, special_power)\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\" #Setting a local variable `greeting` to a string which interpolates the `name` variable\n demographics = [name, age] #setting a local variable `demographics` equal to an array containing the `[name, age]` parameters.\n power_saying = \"Did you know that I can #{special_power}?\" #setting local variable `power_saying` to a string which interpolates the `special_power` parameter\n built_bear = { #creates a hash `built_bear` containing the keys `:basic_info, :clothes, :exterior, :cost, :sayings, and :is_cuddly`\n 'basic_info' => demographics, #assigns variable array `demographics` as value for key `basic_info`\n 'clothes' => clothes, #assigns parameter `clothes` as value for `:clothes` key\n 'exterior' => fur, #assigns `fur` parameter as value for `exterior` key\n 'cost' => 49.99, #assigns `49.99` as value for `cost` key\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"], #assigns array containing `greeting, power_saying` variables and a new string as the value for `sayings` key\n 'is_cuddly' => true, #assigns `is_cuddly` key boolean value of true\n }\n return built_bear #returns `built_bear` hash\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n # defines a variable called greeting - that has a value of an interpolated string.\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # defines a variable that has a value of an array\n demographics = [name, age]\n # defines a variable that has an interpolated string value\n power_saying = \"Did you know that I can #{special_power}?\"\n # defines a variable assigned to a hash\n built_bear = {\n # this defines the basic_info variable with a value of the variable demographics\n 'basic_info' => demographics,\n # this defines the clothes variable with the argument clothes\n 'clothes' => clothes,\n # this defines the exterior variable with the argument fur\n 'exterior' => fur,\n # this defines the cost variable with the float value of 49.99\n 'cost' => 49.99,\n # this defines the sayings variable with an array that consists of 2 of the variables defined above and a string\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # this defines an is_cuddly variable that yeilds a boolean value of true\n 'is_cuddly' => true,\n }\n # explicit return of the built_bear hash variable\n return built_bear\n#ends the method\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n#assigns variable greeting to a string which uses interpolation with the name argument.\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n#assigns variable demographics to an array made of the name and age arguments\n demographics = [name, age]\n#assings variable power_saying to a string which uses interpolation of the special_power argument\n power_saying = \"Did you know that I can #{special_power}?\"\n#creates a hash named built_bear\n built_bear = {\n#Key named basic_info assigned to value demographics from arguments\n 'basic_info' => demographics,\n#Key named clothes assigned to value clothes from arguments\n 'clothes' => clothes,\n#Key named exterior assigned to value exterior from arguments\n 'exterior' => fur,\n#Key named cost assigned to float value of 49.99\n 'cost' => 49.99,\n#Key named sayings assigned to array with greeting, power_saying arguments and string 'Goodnight my friend!'\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n#Key named is_cuddly assigned to boolean value of true\n 'is_cuddly' => true,\n }\n#returns variable built_bear with the completed information from the hash using interpolation.\n return built_bear\n#ends the method\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n # declare a variable of greeting - value is a string with the name parameter interpolated in\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # declare a variable of demographics - value is and arry with two element(name & age) both are parameters\n demographics = [name, age]\n # declare a variable of power_saying - value is a string with the special_power parameter interploated ine\n power_saying = \"Did you know that I can #{special_power}?\"\n # declare a variable of built_bear - value is a hash with 6 keys and values in it\n built_bear = {\n # declare a key basic_info with the value the variable demographics\n 'basic_info' => demographics,\n # declare a key clothes with the value the parameter clothes\n 'clothes' => clothes,\n # declare a key exterior with the value the parameter fur\n 'exterior' => fur,\n # declare a key cost with the value an integer\n 'cost' => 49.99,\n # declare a key sayings with the value an array of the variable greeting, the parameter power_saying, and a string\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # declare a key is_cuddly with a boolean value\n 'is_cuddly' => true,\n }\n # when function is called it will return the built_bear hash\n return built_bear\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n #initializes a variable greeting with an interpolated string\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n #initializes a variable demographic with an array\n demographics = [name, age]\n #initializes a variable power_saying with an interpolated string\n power_saying = \"Did you know that I can #{special_power}?\"\n #initializes a variable built bear containing a hash\n built_bear = {\n #creates a string key and assigns is to value demographics\n 'basic_info' => demographics,\n #creates a string key and assigns is to value clothes\n 'clothes' => clothes,\n #creates a string key and assigns is to value fur\n 'exterior' => fur,\n #creates a string key and assigns is to a float value\n 'cost' => 49.99,\n #creates a string key and assigns is to an array value\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n #creates a string key and assigns is to a boolean value\n 'is_cuddly' => true,\n }\n #calls the hash built_bear\n return built_bear\n#closes the class\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n # Declares local varriable \"greeting\" and assigns it a string value with the\n # name paramter interpolated into the string.\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # Declares the local varriable \"demographics\" and assigns the value of an\n # array with the elements being two paramters: name and age.\n demographics = [name, age]\n # Declares the local varriable \"power_saying\" and assigns a string value that\n # has the parameter \"special_power\" interpolated in.\n power_saying = \"Did you know that I can #{special_power}?\"\n # Declares a hash map called \"built_bear\"\n built_bear = {\n # Assigning the value of the local varraible \"demographics\" to the key\n # 'basic info'\n 'basic_info' => demographics,\n # Assigning the value of the parameter \"clothes\" to the key 'clothes'\n 'clothes' => clothes,\n # Assigning the value of the parameter \"fur\" to the key 'exterior'\n 'exterior' => fur,\n # Assigning the float 49.99 to the key 'cost'\n 'cost' => 49.99,\n # Assigning an array containing the elemetnts of local varriable `greeting`,\n # local varriable `power_saying`, and the string \"Goodnight my friend!\" to\n # the key 'sayings'\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # Assigning the boolean `true` to the key `\"is_cuddly\"`\n 'is_cuddly' => true,\n # Closes out the hash map\n }\n # Ends the `build_a_bear` method at the `return` statement, returns `built bear`\n return built_bear\n # Signifies the end of the `build_a_bear` method definitions.\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n# variable greeting assigned to the string with interpolation of name argument\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n# variable demographics assigned to array of name and age arguments\n demographics = [name, age]\n #variable power_saying assigned to string with interpolation of special_power\n power_saying = \"Did you know that I can #{special_power}?\"\n# hash build_bear assigned the key value pairs basic_info, clothes, exterior, cost, sayings, is_cudly\n built_bear = {\n 'basic_info' => demographics,\n 'clothes' => clothes,\n 'exterior' => fur,\n 'cost' => 49.99,\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n 'is_cuddly' => true,\n }\n return built_bear\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n #This prints out a string with the name argument interpolated into it\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n #This creates a variable that is set equal to an array holding name and age\n demographics = [name, age]\n #This sets a variable equal to a string that has the special_power interpolated into it\n power_saying = \"Did you know that I can #{special_power}?\"\n #This sets a variable equal to a hash which holds basic_info, clothes, exterior, cost, sayings and is_cuddly as keys\n built_bear = {\n 'basic_info' => demographics,\n 'clothes' => clothes,\n 'exterior' => fur,\n 'cost' => 49.99,\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n 'is_cuddly' => true,\n }\n #This returns the hash that was created in the method\n return built_bear\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n # Assigns an interpolated string to the variable greeting.\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # Assigns an array to the variable demographics.\n demographics = [name, age]\n # Assigns an interpolated string to the variable power_saying.\n power_saying = \"Did you know that I can #{special_power}?\"\n # Assigns a hash to the variable built_bear.\n built_bear = {\n # Assigns value that is a variable to a key.\n 'basic_info' => demographics,\n # Assigns value that is a variable to a key.\n 'clothes' => clothes,\n # Assigns value that is a variable to a key.\n 'exterior' => fur,\n # Assigns value that is a float to a key.\n 'cost' => 49.99,\n # Assigns value that is an array to a key.\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # Assigns a value that is a bloolean to a key.\n 'is_cuddly' => true,\n }\n # Returns value of the hash built_bear.\n return built_bear\n# Closes method.\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n # declare variable \"greeting\" and assign it to a string impterpolated with\n # \"name\" argument from the method parameter\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # declare variable \"demographic\" and assign it to an array using \"name\"\n # and \"age\" arguments from the method paramters\n demographics = [name, age]\n # declare variable \"power_saying\" and assign it to a string interpolated with\n # \"special_power\" argument from the method paramters\n power_saying = \"Did you know that I can #{special_power}?\"\n # declare variable \"built_bear\" and assign it to a hash with 6 keys\n built_bear = {\n # declare hash key \"basic info\" assign to the local variable\n # \"demographics\" as the value\n 'basic_info' => demographics,\n # declare hash key \"clothes\" and assign \"clothes\" argument from the method parameter\n 'clothes' => clothes,\n # declare hash key \"fur\" and assign \"fur\" argument from the method parameter\n 'exterior' => fur,\n # delcare hash key \"cost\" and assign to integar \"49.99\"\n 'cost' => 49.99,\n # declare hash key \"sayings\" and assign to array with 3 parameters, \"greeting\"\n # local variable, \"power_saying\" local variable, and a string\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # declare hash key \"is_cuddly\" and assign to boolean \"true\"\n 'is_cuddly' => true,\n # end hash\n }\n # method return value local variable \"built_bear\", a hash\n return built_bear\n # end method \"build_a_bear\"\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n #Sets a greeting variable equal to a string interpolating 1 argument\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n #Sets a demographics variable equal to an array taking in 2 arguments\n demographics = [name, age]\n #Sets a power_saying variable equal to a string interpolating 1 argument\n power_saying = \"Did you know that I can #{special_power}?\"\n #Makes a hash with 6 key/value pairs, starts with curly bracket\n built_bear = {\n #Sets a key 'basic_info' paired to value with variable demographics\n 'basic_info' => demographics,\n #Sets a key 'clothes' paired to value with argument clothes\n 'clothes' => clothes,\n #Sets a key 'exterior' paired to value with argument fur\n 'exterior' => fur,\n #Sets a key 'cost' paired to value with float 49.99\n 'cost' => 49.99,\n #Sets a key 'sayings' paired to value with mixed array\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n #Sets a key 'is cuddly' to value with true boolean\n 'is_cuddly' => true,\n #Ends hash with curly bracket\n }\n #Returns all the info put into the hash made\n return built_bear\n #Ends the function\nend", "def generate_keywords\n all_keywords = {\n minions: [],\n tokens: [],\n mechanics: []\n }\n\n pt = plain_text.downcase\n\n Mechanic.names.each do |mechanic|\n next unless pt.include?(\" #{mechanic.downcase}\") || pt.include?(\"#{mechanic.downcase} \")\n\n p mechanic.downcase\n all_keywords[:mechanics].push(mechanic)\n pt.slice!(mechanic.downcase)\n end\n\n Card.names.each do |name|\n next unless pt.include?(\" #{name.downcase}\") || pt.include?(\"#{name.downcase} \")\n\n p Card.find_by(name: name).name\n all_keywords[:minions].push(name)\n pt.slice!(name)\n end\n pt\n end", "def create\n if text.match(/\\_QUOTE/)\n require 'organismo/element/quote'\n Organismo::Element::Quote.new(text, location)\n elsif text.match(/\\_SRC/)\n require 'organismo/element/code'\n Organismo::Element::Code.new(text, location)\n elsif text.match(/\\_EXAMPLE/)\n require 'organismo/element/example'\n Organismo::Element::Example.new(text, location)\n elsif text.match(/\\*/)\n require 'organismo/element/header'\n Organismo::Element::Header.new(text, location)\n elsif text.match(/\\[\\[\\S*(\\.png)|(\\jpg)|(\\.jpeg)\\]\\]/)\n require 'organismo/element/image'\n Organismo::Element::Image.new(text, location)\n elsif text.match(/\\[\\[\\S*\\]\\]/)\n require 'organismo/element/link'\n Organismo::Element::Link.new(text, location) \n elsif text.match(/\\-/)\n require 'organismo/element/plain_list'\n Organismo::Element::PlainList.new(text, location)\n else\n require 'organismo/element/text'\n Organismo::Element::Text.new(text, location)\n end\n end", "def initialize()\n @name = \"Friendly Looking Traveller\"\n @encounter_intro = \" The #{@name} Friendly Traveller offers to share their baked cherry pie with you! They seem to look genuine and happy.\"\n \n @options = []\n @options.push(\"Gladly accept their offer to share their baked cherry pie.\")\n @options.push(\"Politely decline.\")\n @options.push(\"Attack them immediately with all the fury of the elements.\")\n @options.push(\"Simpply walk away.\")\n\n @consequences = []\n @consequences.push(\"You eat the pie, feel woozy, black out, and wake up named with all your gold having been stolen.\")\n @consequences.push(\"You politely decline, saying you have an allergy to cherries, thanking the traveller- you walk away.\")\n @consequences.push(\"You attack and defeat the traveller. costing 5 stamina and losing 5 health but gaining 10 gold from the bloody corpse of the smiling and non deceased friendly traveller.\")\n @consequences.push(\"As you walk away the traveller throws the hot pie at you, dealing 2 damage. \")\n \n @art = \"\"\\\n \" .------\\\\ /------. \\n\"\\\n \" | - | \\n\"\\\n \" | | \\n\"\\\n \" | | \\n\"\\\n \" | | \\n\"\\\n \"_______________________ \\n\"\\\n \"===========.=========== \\n\"\\\n \" / ~~~~~ ~~~~~ \\ \\n\"\\\n \" /| | | \\ \\n\"\\\n \" W --- / \\ --- W \\n\"\\\n \" \\\\. |o o| .// \\n\"\\\n \" | | \\n\"\\\n \" \\\\ ######### // \\n\"\\\n \" \\\\ ## ----- ## // \\n\"\\\n \" \\\\## ##// \\n\"\\\n \" \\_____v_____/ \\n\"\\\n \n puts \n end", "def build_a_bear(name, age, fur, clothes, special_power)\n # variable assigned to string with interpolation\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # variable to an array\n demographics = [name, age]\n # variable with another string interpolation\n power_saying = \"Did you know that I can #{special_power}?\"\n\n # variable to a hash\n built_bear = {\n # hash string key assigned to value\n 'basic_info' => demographics,\n # hash string key assigned to value\n 'clothes' => clothes,\n # hash string key assigned to value\n 'exterior' => fur,\n # hash string key assigned to float value\n 'cost' => 49.99,\n # hash string key assigned to array with variables and a string\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # hash string key assigned to boolean value\n 'is_cuddly' => true,\n # close hash\n }\n # return the value without printing it. \n return built_bear\nend", "def create\n @headword = Headword.new(params[:headword].permit(allowed_params))\n\n respond_to do |format|\n if @headword.save\n flash[:notice] = 'Headword was successfully created.'\n format.html { redirect_to(@headword) }\n format.xml { render xml: @headword, status: :created, location: @headword }\n else\n format.html { render action: 'new' }\n format.xml { render xml: @headword.errors, status: :unprocessable_entity }\n end\n end\n end", "def above_fold_terms\n [:maker,\n :date_original,\n :date_published,\n :resource_type,\n :genre_string,\n :identifier,\n :rights,\n ]\n end", "def existing_kases_list_header_in_words(kind)\n case kind\n when :idea then \"Existing Ideas in the Community\".t\n when :question then \"Existing Questions in the Community\".t\n when :problem then \"Existing Problems in the Community\".t\n when :praise then \"Existing Praise in the Community\".t\n else \"Existing Cases in the Community\".t\n end\n end", "def build_a_bear(name, age, fur, clothes, special_power)\n #declares a variable with a string assignment and includes string interpolation of first parameter of method\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n #declares a variable with an array assignment & includes name & age parameters\n demographics = [name, age]\n #declares a variable with a string assignment & includes string interpolation of special_power\n power_saying = \"Did you know that I can #{special_power}?\"\n #declares a hash with 6 key-value pairs\n built_bear = {\n #creates key-value pair\n 'basic_info' => demographics,\n #creates key-value pair\n 'clothes' => clothes,\n #creates key-value pair\n 'exterior' => fur,\n #creates key-value pair\n 'cost' => 49.99,\n #creates key-value pair in which the value is an array\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n #creates key-value pair\n 'is_cuddly' => true,\n }\n #the value of the built_bear hash is being returned\n return built_bear\n #closes the method\nend", "def\n \nend\n\n\n# 6. sentence_maker refactored solution", "def essay_writer( title, thing, year, thesis, type )\n \n if type.thing == \"male\" or type.thing == \"female\"\n \tword1 = type.single.capitalize + \" did a lot. \"\n \tname = thing.split\n \tword2 = name[0]\n else\n \tword1 = \"I find \" + type.single + \" facinating. \"\n \tword2 = thing\n end \n\n # title\n puts title\n\n # blank line\n puts\n\n # first sentence\n print thing + \" was an important \" + type.thing + \" in \" + year.to_s + \". \"\n\n # second sentence\n print word1\n\n # third sentence\n print \"I want to learn more about \" + type.object + \". \"\n\n # thesis\n print thesis + \" \"\n\n # last sentence\n puts word2 + \"'s contribution is important.\"\n\nend", "def a_brief_about_yourself_params\n params.require(:a_brief_about_yourself).permit(:body)\n end", "def new\n @brief = Brief.find(params[:brief_id]) \n @item = @brief.items.new\n @item.kind = params[:kind].blank? ? 'design' : params[:kind]\n end", "def create\n new_word = Dinosaurus.new\n \n end", "def build_a_bear(name, age, fur, clothes, special_power)\n # declares the local variable <greeting> and assigns it to a string value with the function argument <name> interpolated.\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n # declares the local variable <demographics> and sets it equal to an array with the funtion argument <name> in index position 0, and the function argument <age> in index position 1.\n demographics = [name, age]\n # declares the local variable <power_saying> and assigns it a string value with the function argument <special_power> interpolated.\n power_saying = \"Did you know that I can #{special_power}?\"\n # declares the local variable <built_bear> and assigns it to a hash value with six key/value pairs.\n built_bear = {\n # <'basic_info'> string key, assigned to the value of local variable <demographics>\n 'basic_info' => demographics,\n # <'clothes'> string key, assigned to the value of function argument <clothes>\n 'clothes' => clothes,\n # <'exterior'> string key, assigned to the value of function argument <fur>\n 'exterior' => fur,\n # <'cost'> string key, assigned to the float value <49.99>.\n 'cost' => 49.99,\n # <'saying'> string key, assigned to an array value with local variable <greeting> assigned to index 0, local variable <power_saying> assigned to index 1, and index 3 assigned to the string value \"Goodnight my friend!\"\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n # <'is_cuddly'> string key, assigned to the boolean value <true>.\n 'is_cuddly' => true,\n# denotes the end of the <built_bear> hash\n }\n # explicit return with the hash value built_bear\n return built_bear\nend", "def nasa_space_craft; end", "def start_bridge_quest\n slowly do\n\"\"\"\nWhat should Duncan do? \n There's bacon!! Dash across that bridge and hunt! -- Press 1\n Carefully approach and investigate the scenario. -- Press 2\n Use special power! -- Press 3\n\"\"\" \n end\n end", "def initialize \n @story_keywords = [] # Creates the array that will hold the part of speech keywords\n end", "def create_parts_and_annotations_mcd(part)\n \n puts\n puts \"== Creating/finding SD part for #{part.biofab_id} ==\"\n\n sd_sequence = part.sequence[$msd1]\n sd_part = Part.find_by_sequence(sd_sequence)\n if !sd_part\n sd_part = Part.new\n sd_part.sequence = sd_sequence\n sd_part.description = \"The Shine-Dalgarno / RBS sequence in a mono-cistronic design.\"\n sd_part.part_type = $sd_type\n sd_part.save!\n puts \"--created sd part\"\n else\n puts \"--found sd part\"\n end\n puts \"---- #{sd_part.sequence}\"\n\n puts\n puts \"== Creating start part for #{part.biofab_id} ==\"\n\n start_sequence = part.sequence[$mstart]\n start_part = Part.find_by_sequence(start_sequence)\n if !start_part\n start_part = Part.new\n start_part.sequence = start_sequence\n start_part.description = \"Start codon.\"\n start_part.part_type = $start_type\n start_part.save!\n puts \"--created start part\"\n else\n puts \"--found start part\"\n end\n \n puts\n puts \"== Annotating #{part.biofab_id} ==\"\n\n annot_type_name = \"Mono-cistronic 5' UTRs\"\n annot_type = AnnotationType.find_by_name(annot_type_name)\n if !annot_type\n annot_type = AnnotationType.new\n annot_type.name = annot_type_name\n annot_type.save!\n puts \"-- created annotation type for mono-cistronic 5' UTRs\"\n else\n puts \"-- found annotation type for mono-cistronic 5' UTRs\"\n end\n \n sd_label = \"Mutated SD\"\n start_label = \"Start\"\n\n create_annotation(part, sd_part, annot_type, $msd1.begin, $msd1.end, sd_label)\n create_annotation(part, start_part, annot_type, $mstart.begin, $mstart.end, start_label)\n\nend", "def create_new_sheet(title,description, keys, level)\n\tacai = Keyword.find_by_name(\"ACAI\") #default skill keywords required\n\tsheet = Sheet.new\n\tsheet.title = title.split(\":\").last.humanize \n\tsheet.id_dokuwiki = title\n\tif(level.to_s.match(/[0-3]/))\n\t\tsheet.level = level\n\telse \n\t\tsheet.level = 1\t#default level\n\tend\t \n\tsheet.keywords << keys\n\tsheet.description = description \n\tif !sheet.valid?\n\t\tsheet.keywords << acai\n\tend\t\n\tsheet.save\nend", "def getKnowledge\n\t\t\n\tend", "def eval_lecture_head\n b = \"\"\n b << \"\\\\kurskopf{#{title.escape_for_tex}}\"\n b << \"{#{profs.map { |p| p.fullname.escape_for_tex }.join(' / ')}}\"\n b << \"{#{returned_sheets}}\"\n b << \"{#{id}}\"\n b << \"{#{t(:by)}}\\n\\n\"\n unless note.nil? || note.strip.empty?\n b << RT.small_header(I18n.t(:note))\n b << note.strip\n b << \"\\n\\n\"\n end\n b\n end", "def create\n render :template => '/pages/bot_detected' and return unless params[:javascript_enabled] == 'true'\n \n @document = Document.public.find(params[:id])\n \n params[:document][:state] = nil # prevent auto approval hack (FIXME: use attr_protected)\n\n if @document.meta_definition_for(params[:label]).allowed? current_user, 'create'\n\n new_document = Document.new(params[:document])\n new_document.parent = @document\n new_document.label = params[:label]\n new_document.author = current_user || User.anonymous\n new_document.published_at = Time.now\n\n if new_document.save\n flash[:notice] = new_document.meta_definition.flash_messages['create'] || \"Your #{params[:label]} has been saved\"\n if new_document.meta_definition.notify_admins\n DocumentMailer.deliver_new_document(new_document)\n end\n redirect_to document_path(@document)\n else\n flash.now[:notice] = 'Could not be saved'\n eval(\"@new_#{params[:label]} = new_document\")\n setup_view_environment\n render :template => view_for\n end\n else\n render :text => 'Not Allowed' and return\n end\n end", "def definition_builder; end", "def definition_builder; end", "def enchantment; end", "def wookie_sentence; end", "def construct_all_the_notes\n # All the release note text\n release_notes = process_repos\n\n build_frontmatter\n\n [\n @frontmatter, '---', \"\\n\",\n headfoot(@header), \"\\n\\n\",\n release_notes.join(\"\\n\\n\"),\n headfoot(@footer), \"\\n\",\n @footer_locations.join(\"\\n\"), \"\\n\\n\",\n find_terms(release_notes).join(\"\\n\")\n ].join('').gsub(\"\\r\\n\", \"\\n\").gsub(/\\n{4,}/m, \"\\n\\n\\n\")\nend", "def build_a_bear(name, age, fur, clothes, special_power)\n #define method variables (name is interpolated)\n greeting = \"Hey partner! My name is #{name} - will you be my friend?!\"\n #define array\n demographics = [name, age]\n #interp\n power_saying = \"Did you know that I can #{special_power}?\"\n #hash, redefines a few variables in keys/values such as exterior, cost\n built_bear = {\n 'basic_info' => demographics,\n 'clothes' => clothes,\n 'exterior' => fur,\n 'cost' => 49.99,\n 'sayings' => [greeting, power_saying, \"Goodnight my friend!\"],\n 'is_cuddly' => true,\n }\n#execute\n return built_bear\nend", "def create_keyword_instance(name, card)\n case name.downcase\n # Expansions\n when 'Base'.downcase\n CardKeyword.create!({\n name: 'Base (1st Edition)',\n category: 'Expansion',\n description: 'First release of Dominion (2008).',\n card: card\n })\n # Card types\n when 'Action'.downcase\n CardKeyword.create!({\n name: 'Action',\n category: 'Card Type',\n description: 'Standard card type',\n card: card\n })\n when 'Reaction'.downcase\n CardKeyword.create!({\n name: 'Reaction',\n category: 'Card Type',\n description: 'Can be played after another player plays an Attack card',\n card: card\n })\n when 'Attack'.downcase\n CardKeyword.create!({\n name: 'Attack',\n category: 'Card Type',\n description: 'Causes a negative effect to all other players.',\n card: card\n })\n when 'Victory'.downcase\n CardKeyword.create!({\n name: 'Victory',\n category: 'Card Type',\n description: 'Award victory points at the end of the game.',\n card: card\n })\n # Subtypes\n # Attack Subtypes\n when 'Handsize Attack'.downcase\n CardKeyword.create!({\n name: 'Handsize Attack',\n category: 'Subtype',\n description: 'Forces players to discard cards.',\n card: card\n })\n when 'Deck Inspection Attack'.downcase\n CardKeyword.create!({\n name: 'Deck Inspection Attack',\n category: 'Subtype',\n description: 'Allows you to see other player\\'s cards and choose whether they keep or discard them.',\n card: card\n })\n when 'Trashing Attack'.downcase\n CardKeyword.create!({\n name: 'Trashing Attack',\n category: 'Subtype',\n description: 'Forces other players to trash cards.',\n card: card\n })\n when 'Curser'.downcase\n CardKeyword.create!({\n name: 'Curser',\n category: 'Subtype',\n description: 'Gives other players curse cards.',\n card: card\n })\n\n\n # Trasher Subtypes\n when 'Trash-For-Benefit'.downcase\n CardKeyword.create!({\n name: 'Trash-For-Benefit',\n category: 'Subtype',\n description: 'Allow you to trash a card and gain an additional benefit.',\n card: card\n })\n\n # Archetypes\n when 'Blocker'.downcase\n CardKeyword.create!({\n name: 'Blocker',\n category: 'Archetype',\n description: 'Nullifies the effects of Attacks against you.',\n card: card\n })\n when 'Sifter'.downcase\n CardKeyword.create!({\n name: 'Sifter',\n category: 'Archetype',\n description: 'Enables players to cycle through junk cards in their deck faster.',\n card: card\n })\n\n when 'Trasher'.downcase\n CardKeyword.create!({\n name: 'Trasher',\n category: 'Archetype',\n description: 'Allows player to remove one or more cards from their deck.',\n card: card\n })\n when 'Deck Discarder'.downcase\n CardKeyword.create!({\n name: 'Deck Discarder',\n category: 'Archetype',\n description: 'Allows you to discard your deck, allowing you to draw recently bought cards more quickly.',\n card: card\n })\n when '+Buy'.downcase\n CardKeyword.create!({\n name: '+Buy',\n category: 'Archetype',\n description: 'Grants you one or more additional Buys',\n card: card\n })\n when 'Gainer'.downcase\n CardKeyword.create!({\n name: 'Gainer',\n category: 'Archetype',\n description: 'Allows you to obtain a Card during your Action Phase without consuming a Buy.',\n card: card\n })\n when \"One-Shot\".downcase\n CardKeyword.create!({\n name: 'One-Shot',\n category: 'Archetype',\n description: 'Card that can only be played once, then is removed from your deck.',\n card: card\n })\n when 'Smithies'.downcase\n CardKeyword.create!({\n name: 'Smithies',\n category: 'Archetype',\n description: 'Allows you to draw 2 or more cards.',\n card: card\n })\n when 'Virtual Coin'.downcase\n CardKeyword.create!({\n name: 'Virtual Coin',\n category: 'Archetype',\n description: 'Non-Treasure card that gives Coins on the turn it is played.',\n card: card\n })\n when 'Throne Room'.downcase, 'Duplicator'.downcase\n CardKeyword.create!({\n name: 'Throne Room',\n category: 'Archetype',\n description: 'Duplicates the effect of another card.',\n card: card\n })\n when 'Draw'.downcase\n CardKeyword.create!({\n name: 'Draw',\n category: 'Archetype',\n description: 'Draws you two or more cards.',\n card: card\n })\n when 'Digger'.downcase\n CardKeyword.create!({\n name: 'Digger',\n category: 'Archetype',\n description: 'Searches the deck for a particular card type',\n card: card\n })\n # Terminality\n when 'Non-Terminal'.downcase\n CardKeyword.create!({\n name: 'Non-Terminal',\n category: 'Terminality',\n description: 'Refunds the Action spent to use this card, allowing additional Action cards to be played.',\n card: card\n })\n when 'Terminal'.downcase\n CardKeyword.create!({\n name: 'Terminal',\n category: 'Terminality',\n description: 'Consumes the Action spent to use this card.',\n card: card\n })\n when 'Village'.downcase, 'Splitter'.downcase\n if(CardKeyword.where(name: 'Splitter / Village').any?)\n return\n end\n \n CardKeyword.create!({\n name: 'Splitter / Village',\n category: 'Terminality',\n description: 'Refunds the Action spent to use this card plus provides one or more additional Actions.',\n card: card\n })\n when 'Cantrip'.downcase\n CardKeyword.create!({\n name: 'Cantrip',\n category: 'Terminality',\n description: 'Refunds the Action spent to use this card and draws you an additional card, effectively taking up no space in your deck.',\n card: card\n })\n # Strategies\n when 'Trashing'.downcase, 'Deckthinning'.downcase\n CardKeyword.create!({\n name: 'Deckthinning / Trashing',\n category: 'Strategy',\n description: 'Removing as many low-value cards from your deck as possible to more consistently draw your strongest cards.',\n card: card\n })\n when 'Engine'.downcase\n CardKeyword.create!({\n name: 'Engine',\n category: 'Strategy',\n description: 'Focusing on extra actions and card draw to build towards big turns that combo multiple effects.',\n card: card\n })\n when 'Rush'.downcase\n CardKeyword.create!({\n name: 'Rush',\n category: 'Strategy',\n description: 'Attempt to end the game early by depleting victory card piles as fast as possible.',\n card: card\n })\n when 'Alt-VP'.downcase\n CardKeyword.create!({\n name: 'Alt-VP',\n category: 'Strategy',\n description: 'Focus on obtaining victory points through card effects rather than traditional victory cards.',\n card: card\n })\n when 'Big Money'.downcase\n CardKeyword.create!({\n name: 'Big Money',\n category: 'Strategy',\n description: 'Focus on high-value Treasure cards and card draw.',\n card: card\n })\n else\n raise \"Invalid keyword creation request. Params name: '#{name}' card: '#{card}'\"\n end\nend", "def mk_body\n skills = @skills.join(', ')\n skills += \", m.v.\" if @skills.length > 1\n\n body = \"Jeg søger stillingen som #{@position} i jeres virksomhed.\\n\"\n body += \"Jeg føler min erfaring inden for brugen af #{skills} kunne gavne jer.\\n\" unless @skills.nil?\n body += \"#{@extra}\\n\" unless @extra.nil?\n return body\n end", "def wine_comment\n end", "def modeler_description\n return 'Gather orientation and story specific construction, fenestration (including overhang) specific information'\n end", "def create\n @show_tables = session[:show_tables]\n @title = params[:title]\n kw = keyword_params[:value].downcase.strip\n site_id = keyword_params[:site_id] || 0\n\n @keyword = Keyword.find_by(:value => kw, :site_id => site_id)\n if @keyword && @keyword.created_at < 24.hours.ago\n @keyword.destroy\n @keyword = nil\n end\n unless @keyword\n @keyword = Keyword.new(keyword_params)\n results = query_ebay(kw, site_id)\n @keyword.suggested_categories = get_suggested_categories(kw)\n @keyword.suggestions = results.map {|resp| Suggestion.from_ebay_response *resp }\n end\n logger.info @keyword.suggested_categories\n respond_to do |format|\n if @keyword.save\n format.html { render action: 'show' }\n else\n format.html { render action: 'new' }\n end\n end\n end", "def technical_word_params\n params.require(:technical_word).permit(:name, :description)\n end", "def required_keywords; end", "def create\n @keyword = Keyword.new(keyword_params)\n # @easterEgg = 'Enjoy your work and have a nice day! --wang ziyue'\n @notice = 'Keyword was successfully created.'\n if params[:keyword][:name] == '好累'\n @notice = @easterEgg\n end\n respond_to do |format|\n if @keyword.save\n format.html { redirect_to @keyword, notice: \"#{@notice}\" }\n format.json { render :show, status: :created, location: @keyword }\n else\n format.html { render :new }\n format.json { render json: @keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @enword = Enword.new(params[:enword])\n\[email protected]_id = (params[:encategory])\n respond_to do |format|\n if @enword.save\n flash[:notice] = 'Enword was successfully created.'\n format.html { redirect_to(@enword) }\n format.xml { render :xml => @enword, :status => :created, :location => @enword }\n else\n format.html { render :action =>\"new\" }\n format.xml { render :xml => @enword.errors, :status => :unprocessable_entity }\n end\n end\n end", "def body\n\n @r = rand(3)\n if @r == 1 \n \"\\n\\n\" + get_content('Intro', 'component') + \" \" + \n get_content(@emphasis, \"emphasis\") + \"\\n\\n\" +\n get_content(@ideologyKey, \"ideology\") + \"\\n\\n\" +\n if @geography != \"Other\" \n get_content(@geography, \"geography\") \n end \n elsif @r == 2 \n \"\\n\\n\" + get_content('Intro', 'component') + \" \" +\n get_content(@ideologyKey, \"ideology\") +\n \"\\n\\n\" + get_content(@emphasis, \"emphasis\") +\n\tif @geography != \"Other\" \n\t\"\\n\\n\" + get_content(@geography, \"geography\") \n\tend \n else \n\t \"\\n\\n\" + get_content('Intro', 'component') + \" \" +\n\t get_content(@emphasis, \"emphasis\") +\n\t if @geography != \"Other\" \n\t \"\\n\\n\" + get_content(@geography, \"geography\") \t\t \n\t end +\n\t \"\\n\\n\" + get_content(@ideologyKey, \"ideology\")\n end \t\nend", "def generate_rdf_specific(b,ty)\n case ty\n when 'thesis'\n th = setup_thesis_info(to_marc)\n typ = th[:type].to_s\n Rails.logger.debug \"********es287_dev #{__FILE__} #{__LINE__} #{__method__} #{th.inspect}\"\n b.z(:type,typ)\n else\n end\n end", "def guideline_params\n params.require(:guideline).permit(:description, :text, :brand_id)\n end", "def buzzword; end", "def buzzword; end", "def build_frontmatter\n cockpit_title = \"Cockpit #{@cockpit_version}\"\n\n @frontmatter = {\n title: cockpit_title,\n author: @user,\n date: Time.now.strftime('%F'),\n tags: @tags.join(', '),\n slug: slugify(cockpit_title),\n category: 'release',\n summary: ''\n }.to_yaml.gsub(/^:/, '')\nend", "def create\n @spec_keyword = SpecKeyword.new(spec_keyword_params)\n @chapter = @spec_keyword.spec.function.requirement.section.chapter\n\n respond_to do |format|\n if @spec_keyword.save\n format.html { redirect_to chapter_path(@chapter) }\n format.json { render :show, status: :created, location: @spec_keyword }\n else\n format.html { render :new }\n format.json { render json: @spec_keyword.errors, status: :unprocessable_entity }\n end\n end\n end", "def generate\n\t\t@vs = \"vitalsource\"\n\t\t@question = [\"What is your Student ID number?\",\"What is your favorite color?\",\"In what city were you born?\",\"What is your pet's name?\",\"What is your mother's maiden name?\"]\n\tend", "def create\n @technical_word = TechnicalWord.new(technical_word_params)\n\n respond_to do |format|\n if @technical_word.save\n format.html { redirect_to @technical_word, notice: 'Technical word was successfully created.' }\n format.json { render :show, status: :created, location: @technical_word }\n else\n format.html { render :new }\n format.json { render json: @technical_word.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_guide(title, description)\n result = \"\"\n result << \"<div class='explanation-unit'>\"\n result << \"<h1>#{title}</h1>\"\n result << \"<p>#{description}</p>\"\n result << \"</div>\"\n end", "def create_guide(title, description)\n result = \"\"\n result << \"<div class='explanation-unit'>\"\n result << \"<h1>#{title}</h1>\"\n result << \"<p>#{description}</p>\"\n result << \"</div>\"\n end", "def create_guide(title, description)\n result = \"\"\n result << \"<div class='explanation-unit'>\"\n result << \"<h1>#{title}</h1>\"\n result << \"<p>#{description}</p>\"\n result << \"</div>\"\n end", "def create\n\n if params[:sample]\n analyse = Ca::Analyse.new(HTMLReader.instance.page(params[:sample][:address]));\n end\n if params[:text]\n analyse = Ca::Analyse.new(params[:text][:content]);\n end\n descript = analyse.description\n @problems = descript.problems\n @text = descript.text\n @best_phrases = Hash[analyse.description.first_n]\n @nr_of_chars = descript.text_number_of_chars\n @nr_of_words = descript.text_number_of_words\n @nr_of_nodes = descript.nr_of_nodes\n @score = descript.score\n @plagiarism = descript.plagiarism\n @html = descript.text.to_s.force_encoding(\"UTF-8\")\n @tags_problem = descript.tag_problem_flag\n end", "def create\t\n\tquestion_param = question_params.merge(:words => in_words(question_params[\"answer\"].to_i))\n @question = Question.new(question_param)\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n\t#=end\n end", "def king_richard_iii; end", "def cloze_text(text)\n tagger = EngTagger.new\n note_with_tags = tagger.get_readable(text).split(' ')\n # Find the word_pairs in the note that we'll hide.\n candidate_words_to_hide_with_tag = Set.new\n note_with_tags.each do |word_tag_pair|\n _, tag = word_tag_pair.split('/')\n # Hide numbers and proper nouns.\n if tag == 'CD' || tag == 'NNP'\n candidate_words_to_hide_with_tag.add(word_tag_pair)\n end\n end\n # Shuffle the set so that we don't hide the first N words, but randomly dispersed words.\n candidate_words_to_hide_with_tag =\n Set.new(candidate_words_to_hide_with_tag).to_a.sample(MIN_WORDS_TO_HIDE + MAX_WORDS_TO_HIDE)\n # Build the content and hide candidates.\n card_content = ''\n hide_count = 0\n # This is non-sense that I hope we can remove one day.\n # Cloze must have at least 1 deletion so if there are no candidates above we hide the first word.\n note_with_tags.each_with_index do |word_tag_pair, index|\n word, tag = word_tag_pair.split('/')\n is_first_index = index.zero?\n can_add_space = !is_first_index && !POS_PUNCTUATION.include?(tag) # Not punctuation\n if (candidate_words_to_hide_with_tag.member?(word_tag_pair) && hide_count < MAX_WORDS_TO_HIDE) ||\n (candidate_words_to_hide_with_tag.empty? && hide_count == 0)\n hide_count += 1\n word = \"{{c1::#{word}}}\"\n end\n card_content << ' ' if can_add_space\n card_content << word\n end\n card_content\nend", "def setup\n @bear = Bear.new(\"Charles\", [])\n\n\n#fish_1 = Fish.new(\"Tuna Turner\") need to define fish first, because you are putting it into the river later\n#@fish_2 = Fish.new(\"Margaret\")\n#fish = [fish_1, fish_2]\n#@river = River.new(\"Forth\", fish)\n#end\n\n end", "def introduce\n puts \"Hi my name is #{@name}. I am a #{@species}. I had #{@foods_eaten.join (\" and \")} for brunch\"\n end", "def modeler_description\n return 'Adds typical refrigeration equipment to a building'\n end", "def initialize(confileinstance)\n\n #Duck typing check :)\n return unless confileinstance.instance_of?(File)\n \n #An Array based DS maintaining Keywords list\n @words_list=Array.new \n\n #A DS maintaining list of String which mark the beginning of single line comment in the programming language\n @single_line=Array.new\n \n #A DS maintaining pair of symbols as Hash which mark the beginning and end of multi line comment in the programming language\n @multi_line=Hash.new\n\n #boolean value to check if we are in the comment section of the conf file yet\n in_comment_section=false\n #boolean to check if we are in multicomment block\n in_multi_comment_section=false\n\n #Reading the file line by line\n confileinstance.each do |line|\n \n #Remove trailing newlines\n line.chomp!\n\n #Check if Essay type, if yes then we dont need to go through all the pain of parsing all the parameters\n break if line==\"Essay:\" \n\n #Skip the line which says 'Keywords:'\n next if line=='Keywords:'\n\n line_split=line.split(\" \")\n if line_split[0]==\"NoIdentifier:\"\n in_comment_section=true\n @no_identifiers=line_split[1...line_split.length]\n end\n\n #Once we encounter the line 'Comments:' we know we are in comments block\n if line=='Comments:'\n in_comment_section=true\n next\n end\n\n if line=='Multi:'\n in_multi_comment_section=true\n next\n end\n\n #Add the words as kewords if not in comment block\n @words_list.push(line) if in_comment_section==false \n \n #Add the comment demarkator to single_line DS \n @single_line.push(line) if in_comment_section==true && in_multi_comment_section==false \n\n #Add the comment demarkator to multi_line DS if in_multi_comment_section? is true\n #The two adjancent indexes will contain the begin and end demarkator\n if in_multi_comment_section==true then\n comment_starter=line.split\n @multi_line[comment_starter[0]]=[comment_starter[1]]\n end\n end\n \n confileinstance.close\n \n end", "def keyword\n\t\t\tlegal = legal_record_type_id == 0 ? legal_record_type.name : custom_legal_record_type\n\t\t\talley = is_alley == 1 ? 'Hẻm' : 'Mặt tiền'\n\n\t\t\tkeyword = \n\t\t\t\t\"#{name}, #{purpose.name} #{real_estate_type.name} quận #{district.name}, #{real_estate_type.name} #{legal}, #{real_estate_type.name} #{alley}, #{alley} quận #{district.name}, #{street.name} quận #{district.name}, #{purpose.name}, #{province.name}, #{real_estate_type.name}, #{legal}\"\n\t\tend", "def create\n @cancerword = Cancerword.new(params[:cancerword])\n\n respond_to do |format|\n if @cancerword.save\n format.html { redirect_to(@cancerword, :notice => 'Cancerword was successfully created.') }\n format.xml { render :xml => @cancerword, :status => :created, :location => @cancerword }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cancerword.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @knowledge = current_user.knowledges.new(params[:knowledge])\n\n respond_to do |format|\n if @knowledge.save\n format.html { redirect_to @knowledge, notice: 'Knowledge was successfully created.' }\n format.json { render json: @knowledge, status: :created, location: @knowledge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @knowledge.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6031328", "0.5966727", "0.59379524", "0.5900155", "0.58082837", "0.575506", "0.5718518", "0.5684076", "0.56754506", "0.56603974", "0.5659542", "0.56561536", "0.5615543", "0.56151944", "0.56143266", "0.56134504", "0.56023705", "0.5572671", "0.5568915", "0.55657417", "0.5528004", "0.5512063", "0.550745", "0.55013275", "0.5479424", "0.5476387", "0.54754114", "0.54590017", "0.54566085", "0.5455801", "0.54283583", "0.5405886", "0.5390504", "0.5390456", "0.5380243", "0.5337315", "0.53339046", "0.5332152", "0.53220296", "0.5265282", "0.5229579", "0.5218738", "0.52128696", "0.52124524", "0.520795", "0.51976824", "0.51805884", "0.51780796", "0.5165935", "0.51622254", "0.5156607", "0.515461", "0.51355493", "0.5119436", "0.5117016", "0.5109742", "0.5103431", "0.50938255", "0.50756145", "0.50676334", "0.50636554", "0.5061758", "0.50604606", "0.50604606", "0.5047759", "0.50375664", "0.50362605", "0.50343907", "0.5020611", "0.5012128", "0.5006525", "0.50039643", "0.49940473", "0.49908242", "0.4984343", "0.49738663", "0.4971744", "0.4965915", "0.4957687", "0.4949998", "0.49419412", "0.49419412", "0.49372256", "0.4934351", "0.49321365", "0.49216384", "0.4921428", "0.4921428", "0.4921428", "0.49213523", "0.49167347", "0.49012417", "0.49001473", "0.4895572", "0.48922175", "0.48843956", "0.4881854", "0.48798025", "0.4877313", "0.4870473" ]
0.58235306
4
Metodo para ordenar una array mediante each con ordenamiento por insercion
def ordenEachMenus (array) ordenado = [] array.each do |nodo| if ordenado.empty? ordenado.push(nodo) else indice = 0 while indice < ordenado.length aporteActual = (nodo.collect { |alimento| alimento.valorEnergeticoKcal}).reduce(:+) aporteSiguiente = (ordenado[indice].collect { |alimento| alimento.valorEnergeticoKcal}).reduce(:+) if aporteActual <= aporteSiguiente ordenado.insert(indice, nodo) break elsif indice == ordenado.length-1 ordenado.insert(indice+1, nodo) break end indice+=1 end end end return ordenado end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mutliplied(array)\nend", "def double_array(array)\n array + array\nend", "def merge(array1, array2)\n # (array1 + array2).uniq\n array1 | array2\nend", "def my_array_modification_method!(i_want_pets, thing_to_modify)\n i_want_pets.map! {|element| element.is_a?(Integer)? (element + thing_to_modify) : element}\nend", "def double_array(array)\n array.concat(array)\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! do |n|\n if n.is_a? Integer\n n += thing_to_modify\n else\n n\n end\n end\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! { |i| i.is_a?(Integer)? (i + thing_to_modify) : i }\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |item|\n if item.is_a? Integer\n item += thing_to_modify\n else item\n end\n end\n return source\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! {|elem|\n if elem.is_a?(Integer)\n elem += thing_to_modify\n else\n elem\n end\n }\nend", "def custom_union(arr1, arr2)\n arr1.dup.concat(arr2).uniq # dup is make orizal array not changed\nend", "def my_array_modification_method(source, thing_to_modify)\n return source.map! {|i| i.is_a?(Integer) ? (i + thing_to_modify) : i}\nend", "def my_array_modification_method!(source, thing_to_modify)\n first_integer = []\n first_integer.push(i_want_pets[2])\n i_want_pets.delete_at(2)\n i_want_pets.insert(2, (first_integer.join.to_i + thing_to_modify) )\n\n second_integer = []\n second_integer.push(i_want_pets[7])\n i_want_pets.delete_at(7)\n i_want_pets.push(second_integer.join.to_i + thing_to_modify)\n\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! do |element|\n if element.class == Fixnum\n element += thing_to_modify\n else\n element = element\n end\n end\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! do |x| \n if x.is_a?(Integer) then x += thing_to_modify else x end\n end\nend", "def inst_custom_union(arr1, arr2)\n arr1.dup.concat(arr2).uniq # yes thats really it!!\nend", "def my_array_modification_method(source, thing_to_modify)\n\t# #source[-1],source[2] = source[-1] + 1, source[2 ]+ 1 \n # source.collect! do |item|\n # # # if item.is_a?(Integer)\n # # # item = item + thing_to_modify\n # # # else \n # # # \titem = item\n # # end\n \n # item.is_a?(Integer) ? item = item + thing_to_modify : item = item\n # end\n source.collect! { |item| item.is_a?(Integer) ? item += thing_to_modify : item = item } \n source\nend", "def my_array_modification_method(source, thing_to_modify)\n source.map {|element| element.is_a?(Integer)? element + thing_to_modify : element}\nend", "def merge(array1, array2)\n array1 | array2\nend", "def my_array_modification_method!(pets, thing_to_modify)\n pets.map! do |x|\n if x.is_a? Integer\n x += thing_to_modify\n else\n x\n end\n end\nend", "def my_array_modification_method(source, thing_to_modify)\n mod_array = Array.new\n source.each { |x|\n if x.is_a? Integer\n mod_array << x += thing_to_modify\n else\n mod_array << x\n end\n }\n mod_array\nend", "def my_array_modification_method!(source, thing_to_modify)\n\n source.map! do |x|\n\n if x.class == Fixnum\n\n x + thing_to_modify\n else\n x\n end\n\n end\n\nend", "def union(*arr)\n arr.inject {|acc, array| acc + array}\nend", "def my_array_modification_method(source, thing_to_modify)\n new_array = []\n source.each { |a|\n if a.is_a? Integer\n new_array << a + thing_to_modify\n else\n new_array << a\n end\n }\n source.replace(new_array)\nend", "def loop_through\n self.map! do |element| \n if !element.is_a?(Array)\n element\n elsif element.is_a?(Array)\n element = element.dup\n element = element.loop_through\n end\n end\n end", "def my_array_modification_method!(array, num)\n array.map! { |x| x.is_a?(Integer)? (x + num) : x } #attempted .each, but the values were not updating, seems to work with map.\nend", "def my_array_modification_method(source, thing_to_modify)\n source.each_with_index do |value, index|\n if value.is_a? Integer\n source[index] += thing_to_modify\n end\n end\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |x| \n if x.is_a?(Integer) \n x+=thing_to_modify\n else x\n end\n end\n\n\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |x| \n if x.is_a?(Integer) \n x+=thing_to_modify\n else x\n end\n end\n\n\nend", "def sum_using_each(array)\n end", "def custom_each(array)\r\n i = 0 \r\n while i < array.length \r\n yield array[i]\r\n i += 1\r\n end\r\nend", "def add_to_array!(array, item)\n array << item\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! { |word| word.is_a?(Integer) ? word + thing_to_modify : word }\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map!{ |item|\n item += thing_to_modify if item.is_a?(Integer)\n item\n }\nend", "def merge(arr1, arr2)\n arr1 | arr2\nend", "def merge(arr1, arr2)\n arr1 | arr2\nend", "def merge(arr1, arr2)\n arr1 | arr2\nend", "def custom_each(array)\n i = 0\n while i < array.length\n yield array[i]\n i += 1\n end\nend", "def array_add?(array, els)\n Array(els).inject(array) { |a, el| a.include?(el) ? a : a + [el] }\n end", "def my_array_modification_method!(source, thing_to_modify)\n\nreturn source.collect! { |item| item.is_a?(Fixnum) ? item + thing_to_modify : item}\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |item| # Array#collect! overrides original array\n if item.is_a? Integer #searches for integers and modifies them\n item + thing_to_modify\n else\n item #leaves non intgers alone\n end\n end\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |item| # Array#collect! overrides original array\n if item.is_a? Integer #searches for integers and modifies them\n item + thing_to_modify\n else\n item #leaves non intgers alone\n end\n end\nend", "def array_or(a,b)\n c = []\n for i in 0...a.length\n if a[i] or b[i]\n c[i] = true\n else\n c[i] = false\n end\n end\n c\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.each_index do |x|\n if (source[x].is_a?(Integer))\n source[x]+=thing_to_modify\n end\n end\n source\nend", "def my_array_modification_method(source, thing_to_modify)\n source.map! do |x|\n \t\tif x.is_a?(Integer) \n \t\t\tx + thing_to_modify\n \t\telse\n \t\t\tx\n \t\tend\n \tend\nend", "def ary_add(array)\n if array.length.even?\n ary_couples = array.each_slice(2)\n final_ary = []\n ary_couples.each do |duo|\n ary_sum = duo[0] + duo[-1]\n final_ary << ary_sum \n end\n return final_ary\n else\n last_obj = array.pop\n ary_couples = array.each_slice(2)\n final_ary = []\n ary_couples.each do |duo|\n ary_sum = duo[0] + duo[-1]\n final_ary << ary_sum \n \n end\n return final_ary << last_obj\n end \nend", "def company_array(arr)\n companies_array = []\n arr.each {|comp| companies_array << comp }\n companies_array \nend", "def union(input, arr)\n if ( input.kind_of?(Array) )\n input | arr\n else\n []\n end\n end", "def my_array_modification_method(array, number)\n\tarray = array.map! do |x|\n\t\tif x.is_a?(Integer)\n\t\t\tx + number\n\t\telse\n\t \tx\n\t end\nend\nend", "def union(*arr)\n final =[] #setting up an array to populate\n #--- Iterate through outer and inner arrays to shovel in single elements\n arr.each do |inner_array|\n inner_array.each do |elem|\n final << elem\n end\n end\n #--- Return a single array with elements\n return final\n end", "def array_looper(array)\n\tarray.each do |a|\n\t\tputs a\n\tend\nend", "def |(other)\n other = Maglev::Type.coerce_to(other, Array, :to_ary)\n hash = {}\n ary = []\n i = 0\n lim = self.__size\n while i < lim\n el = self.__at(i)\n unless hash.include? el\n ary.__push( el )\n hash[el] = el\n end\n i = i + 1\n end\n\n i = 0\n lim = other.__size\n while i < lim\n el = other[i]\n unless hash.include? el\n ary.__push( el )\n hash[el] = el\n end\n i = i + 1\n end\n ary\n end", "def map(arr) # creating our own map method\n\tnewArr = [] # declaring an empty array to push our results inside\n\tarr.each do |i| # run the block of code to iterate inside each elements in an array\n\t\tnewArr << yield(i) # push the modified elements inside our newArr []\n\tend\n\tnewArr\nend", "def my_array_modification_method(source, thing_to_modify)\n source.each_with_index do |element, i|\n source[i] += thing_to_modify if element.is_a?(Numeric)\n end\n source\n end", "def my_array_modification_method(source, thing_to_modify)\n new_array = []\n source.each do |num|\n if num.is_a? Integer\n num += thing_to_modify\n new_array.push num\n else\n new_array.push num \n end\n end\n return new_array\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! do |e|\n if e.class == Fixnum\n e = e + thing_to_modify\n elsif e.class == String\n e = e\n end\n end\n return source\nend", "def union(*arrys)\n\n united = []\n \n # For each argument passed, push it into a new flattened array\n # that is one dimensional. Making use of implied returns.\n arrys.each {|arg| united.push(arg) }.flatten\n\nend", "def union(*array)\n array.inject { |acc, arr| acc + arr } #accumulator + array\nend", "def add_element_to_end_of_array(array, element)\n array << element \nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! {|var|\n if var.is_a?(Integer)\n var + thing_to_modify\n else\n next var\n end\n }\n p source\nend", "def my_array_modification_method!(arry, num)\n p arry.map! {|x|\n if x.is_a?(Integer)\n x + num\n else\n x\n end\n }\nend", "def custom_union(arr1, arr2)\n final = []\n arr1.each { |item| final << item unless final.include?(item) }\n arr2.each { |item| final << item unless final.include?(item) }\n final\nend", "def custom_union(arr1, arr2)\n arr1.concat(arr2).uniq\nend", "def union (*data) \n\tunion_ = [] \n\tdata.each{\n\t\t|elm| \n\t\telm.each{\n\t\t\t|elme| \n\t\t\tunion_.push(elme)\n\t\t}\n\t} \n\treturn union_\nend", "def ordenEach ()\n ordenado = []\n each do\n |nodo|\n if ordenado.empty?\n ordenado.push(nodo)\n else\n indice = 0\n while indice < ordenado.length\n if nodo <= ordenado[indice]\n ordenado.insert(indice, nodo)\n break\n elsif indice == ordenado.length-1\n ordenado.insert(indice+1, nodo)\n break\n end\n indice+=1\n end\n end\n end\n return ordenado\n end", "def my_array_modification_method!(array, numadd)\n array.map!{|element| element.is_a?(Integer) ? element + numadd : element}\nend", "def <<(arr)\n order_check(arr)\n super\n end", "def each a\n\ti = 0\n\tuntil i == a.size\n\t\tyield a[i]\n\t\ti += 1\n\tend\n\ta\nend", "def my_array_modification_method!(sentence_array, increment)\n sentence_array.map! do |word|\n if word.is_a?(Integer)\n word += increment\n else\n word # no change, but needs to be specified or word goes to nil\n end\n end\n return sentence_array\nend", "def my_array_splitting_method(source)\n \n ints = []\n other = []\n out = []\n \n source.each {|idx| if idx.is_a?(Integer) then ints.push(idx) else other.push(idx) end}\n out.push(ints, other)\n \n p out\nend", "def my_array_modification_method!(source, thing_to_modify)\n source.map! { |x|\n if x.is_a?(Integer)\n x + thing_to_modify\n else\n x\n end\n }\nend", "def update_arr2(var)\n\tvar.uniq!\nend", "def add_data_array(data_old, data_new)\n return data_old.sort if data_new.nil?\n data_old = Array.new if data_old.nil?\n data_new.each do |dat|\n data_old << dat if not data_old.any?(dat)\n end\n return data_old.sort\nend", "def union(*arrays)\n arrays # () => []\nend", "def my_each(array)\n\t\t#array = []\n\t\tindex = 0\n\t\twhile index < array.length\n\t\t\tyield(array[index])\n\t\t\tindex += 1\n\t\tend\n\t\treturn array\n\tend", "def union(*arrays)\n arrays.inject { |all_elements, arr| all_elements + arr }\nend", "def append(target_array, value_to_append)\n target_array << value_to_append\nend", "def add_ly(array)\n array.collect! do |element|\n if element.is_a?(Array)\n add_ly(element)\n else\n element += \"ly\"\n end\n end\n return array\nend", "def my_array_modification_method!(source, num_of_pets_wanted)\n source.map! do |x|\n if x.is_a?(Integer)\n x + num_of_pets_wanted\n else\n x\n end\n end\n return source\nend", "def rmerge!(other)\n if other.is_a?(Array)\n other.each { |v| self << v.rdup unless include?(v) }\n elsif other\n self << other.rdup unless include?(other)\n end\n self\n end", "def replace_array(match_array, replace_arry)\n array = []\n match_array\n self.each_index{|i|\n if self[i].eql?(match_array.first) and self.slice(i, match_array.count).eql?(match_array)\n array.concat self.first(i)\n array.concat replace_arry\n array.concat self.drop(i + match_array.count)\n break\n end\n }\n array = self if array.empty?\n array\n end", "def q7_other_arr(arry)\n arry_out = []\n arry.each_index { |i| arry_out << arry[i] if i.even? }\n arry_out\nend", "def my_each_with_index\n i = 0\n while i < self.to_a.length\n yield self.to_a[i], i\n i += 1\n end\n end", "def translate_array(array)\n array.each_with_object([]) do |input_element, output_array|\n output_element = self.map(input_element)\n if output_element.kind_of? Array\n output_array.concat output_element\n elsif ! output_element.nil?\n output_array << output_element\n end\n end\n end", "def my_array_modification_method!(array, increase)\r\n array.map! do |x| \r\n if x.is_a? Integer\r\n x += increase\r\n else \r\n x\r\n end\r\n end\r\nend", "def map(arr)\n new_arr = []\n for el in arr\n new_arr << yield(el)\n end\n new_arr\nend", "def custom_each(array)\n i = 0\n while i < array.length\n #yield will pass this element to the block\n yield array[i] #each and single element of array iterate\n i += 1 #to stop infinite loop\n end\nend", "def union(*array)\n array.flatten\nend", "def copy_and_return(result_or_array)\r\n if result_or_array.nil?\r\n nil\r\n elsif result_or_array.is_a?(Array)\r\n result_or_array.map {|r| copy_and_return(r) }\r\n else\r\n result_or_array.clone\r\n end\r\n end", "def alternate!\n return self if size.zero?\n first = self[0]\n return self.clear << [first] if size == 1\n ary1, ary2 = populate_alternate_arrays\n self.clear << ary1 << ary2\n end", "def array_concat(array_1, array_2)\n # Your code here\n array_2.each do |element|\n array_1 << element\n end\n array_1\nend", "def add_element_to_end_of_array(array, element)\n array << element\nend", "def reduce_to_all_true(source_array)\nend", "def mutate(arr)\n arr.uniq!\nend", "def array_concat(array_1, array_2)\n # Your code here\n array_2.each do |val|\n \tarray_1 << val\n end\n array_1\nend", "def my_each(arr)\n array = []\n n = 0\n while n < arr.length\n yield(arr[n])\n array << arr[n]\n n += 1\n end\n array\nend", "def index_arr_multiple_add(arr, index)\n # add any two elements to the arr at the index\n return arr.push(index,arr)\n return arr.push(index,arr)\nend", "def map &block\n new_array = [] # create a new array where elements will go into\n self.each {|el| new_array << (yield el)} # for each true element in the block, shovel that element into new array\n new_array # return the new array\n end", "def ordenar_for\n\t @lista = self.map{ |a| a }\n\t \tfor i in ([email protected])\n\t\t\tfor j in ([email protected])\n\t\t\t\tif j+1 != @lista.count\n if @lista[j+1] < @lista[j]\n\t\t\t\t\t\t@lista[j],@lista[j+1] = @lista[j+1],@lista[j]\n \t\t\t\tend\n\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@lista\n end", "def double_array(array)\n # your code here\nend", "def array_concat(array_1, array_2)\n\tarray_1 += array_2\nend" ]
[ "0.6314202", "0.6136714", "0.59359163", "0.59351826", "0.593229", "0.59248644", "0.59098417", "0.58888525", "0.5882097", "0.58776957", "0.58757776", "0.58682984", "0.58642006", "0.5852364", "0.5833233", "0.5822562", "0.58202344", "0.58093995", "0.5798673", "0.5758143", "0.5750572", "0.5747903", "0.5745842", "0.5739693", "0.5729747", "0.5729496", "0.57235867", "0.57235867", "0.5721689", "0.5719539", "0.5719264", "0.5718428", "0.5714502", "0.57008797", "0.57008797", "0.57008797", "0.5693807", "0.5687613", "0.56833744", "0.56785935", "0.56785935", "0.5669489", "0.5668311", "0.5660868", "0.5637786", "0.56335586", "0.5631921", "0.56269866", "0.5617346", "0.56076634", "0.5596924", "0.55947506", "0.559273", "0.5582792", "0.5567424", "0.5565164", "0.5564769", "0.55623585", "0.55568695", "0.5553861", "0.555369", "0.5549673", "0.554369", "0.5543272", "0.5541809", "0.55328417", "0.55250376", "0.55220145", "0.5518456", "0.55181193", "0.5515736", "0.551538", "0.55071294", "0.5503084", "0.5502273", "0.5499871", "0.54964745", "0.549428", "0.54923415", "0.54878765", "0.5482023", "0.5475858", "0.54752743", "0.5466391", "0.54601395", "0.54524416", "0.5447189", "0.54457015", "0.54454684", "0.5436394", "0.54343426", "0.54298735", "0.5426464", "0.5425572", "0.542375", "0.5421805", "0.54089016", "0.54065007", "0.54000235", "0.5399316" ]
0.5698999
36
Never trust parameters from the scary internet, only allow the white list through.
def grumble_params params.require(:grumble).permit(:authorName, :content, :title, :photoUrl) 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
def self.new_with_session(params, session) super.tap do |user| if data = session["devise.facebook_data"] && session["devise.facebook_data"]["extra"]["raw_info"] user.email = data["email"] if user.email.blank? end end end
def give_goals_to_user self.goals.create(category: "Use my own bags at the store", point_value: 12, frequency: 0, weekly_points_goal: 0, weekly_results: 0) self.goals.create(category: "Carpool instead of use my car", point_value: 100, frequency: 0, weekly_points_goal: 0, weekly_results: 0) self.goals.create(category: "Air dry a load of laundry", point_value: 70, frequency: 0, weekly_points_goal: 0, weekly_results: 0) self.goals.create(category: "Adjust the thermostat up 1 degree in summer", point_value: 40, frequency: 0, weekly_points_goal: 0, weekly_results: 0) self.goals.create(category: "Install a compact fluorescent light bulb", point_value: 60, frequency: 0, weekly_points_goal: 0, weekly_results: 0) self.goals.create(category: "Ride a bike instead of car 1 mile", point_value: 20, frequency: 0, weekly_points_goal: 0, weekly_results: 0) self.goals.create(category: "Take a shorter shower (5 min or less)", point_value: 4, frequency: 0, weekly_points_goal: 0, weekly_results: 0) self.goals.create(category: "Turn off my engine instead of idleing", point_value: 15, frequency: 0, weekly_points_goal: 0, weekly_results: 0) self.goals.create(category: "Buy or eat local", point_value: 15, frequency: 0, weekly_points_goal: 0, weekly_results: 0) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_with_session(params, session)\n super.tap do |user|\n if data = session[\"devise.facebook_data\"] && session[\"devise.facebook_data\"][\"extra\"][\"raw_info\"]\n user.email = data[\"email\"] if user.email.blank?\n end\n end\n end", "def new_with_session(params, session)\n super.tap do |user|\n if (data = session['devise.facebook_data']) && session['devise.facebook_data']['extra']['raw_info']\n user.email = params[:email]\n user.alias = params[:alias]\n user.fb_userid = data['id']\n generated_password = Devise.friendly_token.first(10)\n user.password = generated_password\n user.password_confirmation = generated_password\n user.skip_confirmation!\n end\n end\n end", "def new_with_session(params, session)\n super.tap do |user|\n if data = session[\"devise.twitter_data\"] && session[\"devise.twitter_data\"][\"extra\"][\"raw_info\"]\n user.email = data[\"email\"] if user.email.blank?\n elsif data = session[\"devise.google_data\"] && session[\"devise.google_data\"][\"extra\"][\"raw_info\"]\n user.email = data[\"email\"] if user.email.blank?\n end\n end\n end", "def new_with_session(params, session)\n if session['devise.google_oauth2_data']\n super.tap do |user|\n if data = session[\"devise.google_oauth2_data\"] && session[\"devise.google_oauth2_data\"][\"info\"]\n user.email = data[\"email\"] if user.email.blank?\n user.first_name = data['first_name']\n user.last_name = data['last_name']\n user.identity.first_or_initialize(\n provider: session[\"devise.google_oauth2_data\"]['provider'],\n uid: session[\"devise.google_oauth2_data\"]['uid']\n )\n end\n end\n\n elsif session['devise.facebook_data']\n super.tap do |user|\n if data = session[\"devise.facebook_data\"] && session[\"devise.facebook_data\"][\"extra\"][\"raw_info\"]\n user.email = data[\"email\"] if user.email.blank?\n user.first_name = data['first_name']\n user.last_name = data['last_name']\n user.identity.first_or_initialize(\n provider: session[\"devise.facebook_data\"]['provider'],\n uid: session[\"devise.facebook_data\"]['uid']\n )\n end\n end\n else\n new(params)\n end\n end", "def set_facebook_user_session\n session[:facebook_auth] = {}.tap do |fa|\n fa[:first_name] = auth_info.first_name\n fa[:last_name] = auth_info.last_name\n fa[:email] = auth_info.email\n fa[:picture] = auth_info.image\n fa[:birth_date] = auth_hash.extra.raw_info.birthday\n end\n set_facebook_user_authentication_session()\n end", "def apply_facebook(omniauth)\n if (extra = omniauth['extra']['user_hash'] rescue false)\n self.email = (extra['email'] rescue '')\n end\nend", "def before_connect(fb_session)\n begin\n # Get user info and store in session.\n fb_session.user.populate\n logger.debug \"FACEBOOK SESSION: #{pp fb_session.user}\"\n \n # == Account details.\n self.facebook_proxy_email = fb_session.user.try(:proxied_email)\n self.login = fb_session.user.try(:username) # not supported by Facebooker right now\n self.locale = fb_session.user.try(:locale) # or nil\n self.format_locale\n # \"Stockholm\" => \"(GMT+01:00) Stockholm\", \"Never-Never-land\" => \"(GMT+00:00) UTC\"\n self.time_zone = fb_session.user.try(:current_location).try(:city)\n self.country = fb_session.user.try(:current_location).try(:country) # or nil\n \n # == Account profile details.\n profile_hash = {}\n profile_hash[:real_name] = fb_session.user.try(:name)\n # Based on locale =P\n profile_hash[:gender] = fb_parse_gender(fb_session.user.try(:sex))\n \n # == Examples:\n # profile_hash[:about_me] = facebook_session.user.try(:profile_blurb)\n # profile_hash[:birthdate] = facebook_session.user.try(:birthday_date).try(:to_date)\n # profile_hash[:birthdate] ||= facebook_session.user.try(:birthday).try(:to_date)\n \n self.profile ||= Profile.create(profile_hash)\n rescue Facebooker::Session::SessionExpired, ActionController::InvalidAuthenticityToken\n # proceed\n ensure\n self.confirmed_at = Time.now # Activate account - no e-mail confirmation for FBC-accounts.\n self.format_locale\n end\n end", "def apply_facebook(omniauth)\n if (info = omniauth['info'] rescue false)\n self.email = (info['email'] rescue '')\n end\n end", "def new\n session.delete('devise.omniauth_data')\n super\n end", "def before_connect(facebook_session)\n self.login = facebook_session.user.name\n self.facebook_name = facebook_session.user.name\n self.password = \"5uttr33_#{self.login}\"\n self.signup_source = 'facebook'\n end", "def facebook\n user = User.from_facebook_omniauth(request.env[\"omniauth.auth\"])\n if user.persisted?\n sign_in_and_redirect user, notice: \"#{user.name}, you are signed in!\"\n else\n session[\"devise.user_attributes\"] = user.attributes\n redirect_to new_user_registration_url\n end\n end", "def facebook_create\n @new_user = User.find_or_create_by(uid: auth['uid']) do |u|\n u.name = auth['info']['name']\n u.email = auth['info']['email']\n u.image = auth['info']['image']\n u.password = User.generic_password\n end\n @new_user.save\n session[:user_id] = @new_user.id \n redirect_to home_path(@new_user)\n end", "def new_facebook_signup\n \n @fb_data = fetch_facebook_params\n\n @user = Spree::User.where(email: @fb_data[:email]).first\n\n if @user.blank?\n @user = Spree::User.new(email: @fb_data[:email], facebook_token: @fb_data[:fb_token])\n \n @user.addresses.build\n @user.addresses.first.firstname = @fb_data[:firstname]\n @user.addresses.first.lastname = @fb_data[:lastname]\n\n\n else\n @user.update_attributes(facebook_token: @fb_data[:fb_token]) if @user.facebook_token != @fb_data[:fb_token] #update the token if @user_founds token is not same as the @fb_token\n sign_in(:spree_user, @user)\n redirect_to main_app.profile_users_path\n end\n\n end", "def before_connect(facebook_session)\n self.login = 'facebook_' + facebook_session.user.name\n self.facebook_name = facebook_session.user.name\n self.password = \"5uttr33_#{self.login}\"\n self.signup_source = 'facebook'\n end", "def fetch_facebook_params\n\n @fb_details = request.env['omniauth.auth']\n redirect_to main_app.root_path if @fb_details.nil?\n\n session[:email] = @fb_details[:info][:email]\n session[:firstname] = @fb_details[:info][:first_name]\n session[:lastname] = @fb_details[:info][:last_name]\n session[:fb_token] = @fb_details[:credentials][:token]\n\n end", "def new\n @user_session = UserSession.new(:email => session[:user_real_account_email])\n end", "def new_with_session(params, session)\n if session[\"devise.user_attributes\"]\n # we already trust this isn't mass assignment attack, so use without protection\n new(session[\"devise.user_attributes\"], without_protection: true) do |user|\n user.attributes = params\n user.identities.build(session[\"identity_attributes\"]) if session[\"identity_attributes\"]\n # sets user.errors, which will be present when we return the user to the form with validation errors\n user.valid?\n end\n else\n # create and return new User instance\n super\n end \n end", "def new\n \n if request.env['omniauth.auth'].present?\n params = request.env[\"omniauth.params\"]\n\n @fb_data = fetch_facebook_params\n @user = Spree::User.where(email: @fb_data[:email]).first\n\n\n if (@user.blank? && params[\"login\"].present?) || (@user.present? && is_ordinary_user?(@user.facebook_token) && params[\"login\"].present?)\n\n #here need to check if it's a fb registered user + in params we must receive login\n #if !is_ordinary_user?(@user.facebook_token) && params[\"login\"].present?\n #use the @not_yet_fb_signed_up to notify the message at the top.\n\n @not_yet_fb_signed_up = true\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n\n #user does not registered yet & coming for signup(or login params is blank.)\n elsif @user.blank? && params[\"login\"].blank?\n @user = Spree::User.new(email: @fb_data[:email], facebook_token: @fb_data[:fb_token], image: @fb_data[:image])\n @user.addresses.build\n @user.creditcards.build\n @user.addresses.first.firstname = @fb_data[:firstname]\n @user.addresses.first.lastname = @fb_data[:lastname]\n\n #user is registered & still trying for signup via facebook\n elsif @user.present? && params[\"login\"].blank?\n @registered_email = @user.email\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n else\n #update the token if @user_founds token is not same as the @fb_token\n @user.update_attributes(facebook_token: @fb_data[:fb_token], image: @fb_data[:image]) if @user.facebook_token != @fb_data[:fb_token]\n sign_in(:spree_user, @user)\n redirect_to spree.snack_queue_orders_path\n end\n\n else\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n\n end\n @subscriptions = Subscription.select('id, subscription_type', 'plan_price')\n @snacks = Spree::Product.limit(6)\n @snacks.sort_by! { |x| x[:name].downcase }\n\n end", "def apply_omniauth(omniauth)\n #add some info about the user\n self.login ||= omniauth['user_info']['nickname']\n self.picture_url = omniauth['user_info']['image']\n self.email ||= omniauth['user_info']['email']\n #self.nickname = omniauth['user_info']['nickname'] if nickname.blank?\n \n # unless omniauth['credentials'].blank?\n # user_tokens.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n # else\n user_tokens.build(:provider => omniauth['provider'], :uid => omniauth['uid'], \n :token => omniauth['credentials']['token'], :token_secret => omniauth['credentials']['secret'])\n # end\n #self.confirm!# unless user.email.blank?\n end", "def set_facebook_user_authentication_session\n session[:facebook_auth][:user_authentication] = {}.tap do |ua|\n expires_at = !auth_hash().credentials.expires_at.blank? ? Time.at(auth_hash().credentials.expires_at) : nil\n ua[:token] = auth_hash().credentials.token\n ua[:refresh_token] = auth_hash().credentials.refresh_token\n ua[:secret] = auth_hash().credentials.secret\n ua[:uid] = auth_uid\n ua[:provider_id] = provider.id\n ua[:expires_at] = expires_at\n end\n end", "def create\n #Create user instance\n @user = User.new(params[:user])\n @user.fb_uid = facebook_user.uid if facebook_user \n if @user.save\n \n #flash[:notice] = sprintf(t(:user_created_confirmation_sent), @user.name,@user.email) unless facebook_user\n flash_notice(:user_created_confirmation_sent, @user.full_name,@user.email) unless facebook_user\n \n create_session(@user) if facebook_user\n redirect_to_last_page\n else\n render :action => \"new\"\n end\n end", "def new\n raise Webapp::UserSessionExistsError if session[:user_session]\n @user = User.new\n if facebook_user\n @user.first_name = facebook_user.first_name\n @user.last_name = facebook_user.last_name\n end\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n \n rescue Webapp::UserSessionExistsError\n flash_error(:user_session_exists)\n redirect_to root_url\n end", "def create\n auth = request.env[\"omniauth.auth\"]\n user = User.find_by_provider_and_uid(auth[\"provider\"], auth[\"uid\"]) || User.create_with_omniauth(auth)\n User.update(user.id, :fb_nickname => auth[\"info\"][\"nickname\"])\n session[:user_id] = user.id\n redirect_to root_url\n end", "def facebook\n @user = User.find_for_facebook_oauth(request.env[\"omniauth.auth\"], current_user)\n\n if @user.persisted?\n @user\n sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated\n set_flash_message(:notice, :success, :kind => \"Facebook\") if is_navigational_format?\n else\n request.env[\"omniauth.auth\"]\n session[\"devise.facebook_data\"] = request.env[\"omniauth.auth\"]\n redirect_to new_user_registration_url\n end\n end", "def find_for_facebook_oauth(access_token, signed_in_resource=nil)\n data = access_token.extra.raw_info\n user = where(facebook_id: data.id).first\n user ||= where(email: data.email).first\n unless user\n # Create a user with a stub password.\n user = new(:email => data.email, :password => Devise.friendly_token[0,20])\n end\n user.email = data.email\n user.facebook_id = data.id\n user.facebook_access_token = access_token.credentials.token\n user.facebook_username = data.username\n user.name ||= data.name\n user.locale ||= data.locale || I18n.default_locale\n user.timezone ||= data.timezone\n user.gender ||= data.gender\n user.save\n user\n end", "def facebook_user_data(data)\n raise \"SHOULD BE IMPLEMENT NEW USER DATA\"\n end", "def create\n\t\tauth = request.env[\"omniauth.auth\"] #when press the link fb_login, response that is received from callback is stored in auth var\n\t\tsession[:omniauth] = auth.except('extra') #session var with info from response, except extra- info that we dont need\n\t\tcurrent_user = User.sign_in_from_omniauth(auth)\n\t\tsession[:user_id] = current_user.id\n\t\tredirect_to root_url, flash: { notice: \"#{current_user.name}, welcome to Like Machine.\"}\n\tend", "def new\n auth_hash = request.env['omniauth.auth']\n session[:auth_provider] = auth_hash[:provider]\n\n # look up auth_field, auth_value of User by provider, from config/initializers/omniauth.rb\n # Currently CAS is our only provider\n auth_config = ResearchMatch::Application.config.auth_providers[session[:auth_provider].to_sym]\n if auth_config\n auth_field = auth_config[:auth_field].to_s\n auth_value = auth_hash[auth_config[:auth_value]].to_s\n session[:auth_field] = auth_field\n session[:auth_value] = auth_value\n else\n flash[:error] = \"There were problems identifying your auth provider. Please try again or contact support.\"\n redirect_to home_path\n return\n end\n\n\n user = User.where(auth_field => auth_value).first\n if user.present?\n UserSession.new(user).save\n session[:user_id] = user.id # TODO remove (use only @user_session)\n redirect_to dashboard_path\n else\n if session[:auth_provider].to_sym == :google_oauth2\n session[:info_hash] = auth_hash[:info]\n end\n puts 'redirect_to new_user_path'\n redirect_to new_user_path\n end\n end", "def register_by_facebook_account(fb_session, fb_uid)\n api = FacebookGraphApi.new(fb_session.auth_token, fb_uid)\n user_attributes = api.find_user(fb_uid)\n email = user_attributes['email'] || 'FAKE'\n name = user_attributes['name'] || ''\n\n if !email.blank? && !name.blank?\n existing_user = User.find_by_email(email)\n existing_user = User.find_by_facebook_uid(fb_uid) if existing_user.nil?\n\n if existing_user\n existing_user.facebook_uid = fb_uid\n existing_user.facebook_sid = fb_session.auth_token\n existing_user.facebook_connect_enabled = true\n existing_user.save(false)\n\n existing_user.update_attribute(:state, 'active')\n existing_user\n else\n attributes = {\n :login => find_or_build_unique_user_name(name),\n :name => name,\n :email => find_or_build_unique_fake_email(email),\n :facebook_uid => fb_uid,\n :facebook_sid => fb_session.session_key,\n :activated_at => Time.now,\n :state => 'active',\n :facebook_connect_enabled => true\n }\n\n user = User.new(attributes)\n user.save(false)\n\n user.update_attribute(:state, 'activate')\n user\n end\n else\n # Do something else let's log him out from facebook\n raise 'Durrr! you are one of those unlucky person for whom we haven\\'t fixed this bug!\n please let me know that i told you this crap!' + \" data - #{user_attributes.inspect}\"\n end\n end", "def facebook_callback\n user_data = parse_facebook_user_data\n token = sign_user_token(user_data[\"email\"],\"facebook\")\n\n user = User.find_by_token(token)\n if user\n set_current_user(user)\n else\n user = User.new(:email => user_data[\"email\"],\n :nick => user_data[\"first_name\"],\n :token => token)\n user.save!\n\n set_current_user(user)\n end\n redirect_to :controller => \"sales_management\",\n :action => \"index\",\n :user_id => user.id\n end", "def apply_omniauth(omniauth)\r\n self.email = omniauth['user_info']['email'] if email.blank?\r\n authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\r\n end", "def signup_facebook_user\n @user = Spree::User.new(user_params_list)\n @user.facebook_token = session[:fb_token]\n\n @user.addresses.first.country_id = 503\n\n if @user.save\n session\n signin_vegan_user(@user.id)\n else\n render 'complete_signup'\n end\n end", "def create\n\n params[:user].reject! {|k,v| !['name','email','password','facebook_uid'].include?k }\n @user = User.new(params[:user])\n if @user.facebook_uid and current_facebook_user and current_facebook_client\n if current_facebook_user.id == @user.facebook_uid\n @user.facebook_session_key = current_facebook_client.access_token\n @user.password = \"fb-#{@user.facebook_uid}-\"+Time.now().to_s if @user.password.empty?\n end\n else\n if @user.password != params[:password_verify] then\n @user.errors.add(:password, \"Password fields don't match\")\n respond_to do |format|\n format.html { render :action => \"new\" }\n format.json { render json: @user }\n end\n return\n end\n end\n \n respond_to do |format|\n if @user.save\n UserSession.create(@user, true)\n format.html { redirect_to(@user, :notice => 'User was successfully created.') }\n format.json { render json: @user }\n else\n format.html { render :action => \"new\" }\n format.json { render json: @user }\n end\n end\n end", "def new_with_redirect;\n\t\t@user=User.new;\n\t\treturn redirect_to auth_path(:facebook) if params[:with]==\"facebook\"\n\t\treturn redirect_to auth_path(:linkedin) if params[:with]==\"linkedin\"\n\t\tif !auth_hash.blank?\n\t\t\tif @user.facebook_info(auth_hash)=='mail missing'\n\t\t\t\tflash[:error]='Sign up failed, we need your email to sign you up'\n\t\t\t\tredirect_to root_path\n\t\t\tend\n\t\tend\n\tend", "def create_fb\n if current_facebook_user\n current_facebook_user.fetch\n if logged_in_member\n logged_in_member.update_attribute(:fb_user_id, current_facebook_user.id)\n redirect_to logged_in_member\n else\n @member = Member.find_or_initialize_with_facebook(current_facebook_user)\n conference_delegate = ConferenceDelegate.find_by_signature(params[:signature]) if !params[:signature].blank?\n if @member.new_record?\n @member.conference_delegate = conference_delegate\n @member.auth_service = 'Facebook'\n render :template => \"sessions/register_email\"\n else\n if conference_delegate && conference_delegate.member.nil? && @member.conference_delegate.nil?\n conference_delegate.update_attribute(:member, @member)\n end\n login_member!(@member)\n end\n end\n else\n redirect_to new_session_path\n end\n end", "def register_user_to_fb\n\t #users = {:email => email, :account_id => id}\n\t #Facebooker::User.register([users])\n\t #self.email_hash = Facebooker::User.hash_email(email)\n\t #save(false)\n\tend", "def set_facebook_info omni\n info = omni['info']\n self.email = info['email']\n self.first_name = info['first_name']\n self.last_name = info['last_name']\n\n # Get the large size image. Omniauth returns 'square' by default and thats\n # too small to use.\n if info['image'].present?\n self.remote_profile_image_url = info['image'].gsub(\"square\", \"large\")\n end\n end", "def fill_fb_credentials\n\n fill_in FB_EMAIL_OR_ID_FIELD,with:FB_USER_ID\n fill_in FB_PASSWORD_FIELD,with:FB_USER_PASSWORD\n\nend", "def create\n # super\n self.resource = warden.authenticate!(auth_options)\n set_flash_message!(:notice, :signed_in)\n \n if resource\n user = resource\n sign_in(resource_name, resource)\n else\n user = User.find_by_email(params[:user][:email])\n sign_in(user, scope: :user) \n end\n \n profile = Profile.new\n profile.app_name = ''\n profile.desc = ''\n profile.tel = ''\n profile.app_email = ''\n user.profile = profile\n profile.save\n\n yield resource if block_given?\n render status: :ok, json: {\"user\": user, \"token\": user.token(user.id)}\n # respond_with resource, location: after_sign_in_path_for(resource)\n end", "def apply_omniauth(auth)\n # In previous omniauth, 'user_info' was used in place of 'raw_info'\n self.email = auth['extra']['raw_info']['email']\n # Again, saving token is optional. If you haven't created the column in authentications table, this will fail\n authentications.build(:provider => auth['provider'], :uid => auth['uid'], :token => auth['credentials']['token'])\n end", "def createF\r\n user = User.omniauth(env['omniauth.auth'])\r\n session[:user_id] = user.id\r\n Action.create(info: current_user.username + ' has logged in using facebook.', user_email: current_user.email)\r\n redirect_to user\r\n end", "def handle_omniauth_callback(auth)\n # Try to find authentication first\n authentication = Authentication.find_by_provider_and_uid(auth['provider'], auth['uid'])\n provider = auth['provider'] || 'Unknown'\n\n ## data of facebook\n # info=#<OmniAuth::AuthHash::InfoHash email=\"[email protected]\"\n # first_name=\"Long\" image=\"http://graph.facebook.com/100000709457324/picture?type=square\"\n # last_name=\"Phan-Hoàng\" location=\"Ho Chi Minh City, Vietnam\" name=\"Long Phan-Hoàng\"\n # nickname=\"phanhoanglong2610\"\n # urls=#<Hashie::Mash Facebook=\"http://www.facebook.com/phanhoanglong2610\">\n # verified=true> provider=\"facebook\" uid=\"100000709457324\"\n\n if authentication\n\n # sign in and direct to previous page\n sign_in_and_redirect authentication.user, :event => :authentication\n set_flash_message(:notice, :success, :kind => auth[\"facebook\"]) if is_navigational_format?\n\n else\n # Authentication not found, thus a new user.\n @user = User.new\n\n # temp for username social accounts such as Twitter\n\n #prefill with info from provider website\n @user.apply_omniauth(auth)\n\n @info = {\n \t:first_name => @user.first_name,\n \t:last_name => @user.last_name,\n \t:email => @user.email\n }\n\n session[\"devise.#{auth[\"provider\"]}_data\"] = auth.except(\"extra\")\n\n render :template => \"devise/registrations/new\"\n end\n\tend", "def social_login_fill_new_user(user, jwt)\n # no-op\n end", "def create_from_fb\n fb_user = FbGraph::User.fetch(\n \"me?fields=first_name,last_name,\"\\\n \"gender,email,birthday\",\n :access_token => params[:access_token])\n\n @user = User.add_from_fb(fb_user,@source)\n end", "def apply_omniauth(auth)\n self.email = auth['extra']['raw_info']['email'] if auth['extra']['raw_info']['email']\n self.password = Devise.friendly_token[0,20]\n authentications.build(:provider=>auth['provider'], :uid=>auth['uid'], :token=>auth['credentials']['token'], :secret=>auth['credentials']['secret'])\n end", "def omniauth \n\n @user = User.create_by_google_omniauth(auth)\n # @user = User.find_or_create_by(username: auth[:info][:email]) do |u| #moved this method to user model\n # u.password = SecureRandom.hex \n # end\n\n session[:user_id] = @user.id\n #if you havent set the password, it wont assign a userid, which means we won't have a user here to deal with\n redirect_to user_path(@user)\n\n #User.where(email: auth[:info][:email]).first_or_initialize\n #both .where method and .find_or_create_by method accomplish same thing\n \n end", "def apply_omniauth(omniauth)\n self.email = omniauth['user_info']['email'] if email.blank?\n\n if nick.blank?\n self.nick = (omniauth['user_info']['first_name'] || omniauth['user_info']['nickname'] ||\n omniauth['user_info']['name'] ||omniauth['user_info']['email'])\n end\n\n self.email_alert = false\n self.sms_alert = false\n self.weekend = false\n\n authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n end", "def map_user_attributes(omniauth)\n info = omniauth.info\n raw_info = omniauth.extra.raw_info\n\n self.login = info.nickname\n self.name = info.name || ''\n self.email = info.email || ''\n self.avatar_url = info.image || ''\n\n self.company = raw_info.company\n self.location = raw_info.location\n self.followers = raw_info.followers\n self # return self\n end", "def new\n @user = env['omniauth.identity'] ||= User.new\n\n #if signed_in?\n #@user = User.new\n #else\n #auth = session['auth']\n #@user = User.create_with_omniauth(auth)\n #end\n end", "def fb_auth\n session[:sign_up_reason] = nil\n\n if params[:return_to]\n set_after_sign_in_location(params[:return_to])\n elsif params[:spree_user_return_to]\n set_after_sign_in_location(params[:spree_user_return_to])\n elsif is_user_came_from_current_app\n set_after_sign_in_location(request.referrer)\n end\n\n if params[:redeem_via_fb_state]\n session[:redeem_via_fb_state] = params[:redeem_via_fb_state]\n end\n\n if params[:new_modal_fb_state]\n session[:new_modal_fb_state] = params[:new_modal_fb_state]\n end\n\n if params[:show_promocode_modal]\n session[:show_promocode_modal] = params[:show_promocode_modal]\n # reset current modal popup\n set_after_sign_in_location(root_path)\n end\n\n session[:auto_apply] = params[:auto_apply] if params.key?(:auto_apply)\n session[:auto_apply_promo] = params[:auto_apply_promo] if params.key?(:auto_apply_promo)\n\n # Capture PLEASE REMIND ME ABOUT MY SALE events to push onto customer.io later.\n session[:email_reminder_promo] = params[:email_reminder_promo] if params.key?(:email_reminder_promo)\n\n\n redirect_to spree.spree_user_omniauth_authorize_url(provider: :facebook, scope: 'email,public_profile,user_friends')\n end", "def create\n @user = User.find_by(email: session_params[\"email\"])\n if @user\n login!\n render json: {\n status: :created, \n logged_in: true, \n user: @user,\n profile: @user.profile\n \n }\n # render json: @session, status: :created, location: @session\n else\n render json: { status: 401 }\n # render json: @session.errors, status: :unprocessable_entity\n end\n end", "def create\n auth = request.env[\"omniauth.auth\"] \n user = User.find_by_fb_id(auth[\"uid\"]) || User.create_with_omniauth(auth) \n #for those update from feeds\n if user.access_token.empty?\n user.access_token = auth[\"credentials\"][\"token\"]\n user.save\n end\n redirect_to FB_APP_URL \n end", "def create\n omniauth = env['omniauth.auth']\n\n user = User.find_by(uid: omniauth['uid'])\n unless user\n # New user registration\n user = User.new(uid: omniauth['uid'])\n end\n user.email = omniauth['info']['email']\n user.save\n\n # p omniauth\n\n # Currently storing all the info\n session[:user_id] = omniauth\n\n flash[:notice] = t(:successfully_logged_in)\n redirect_to root_path\n end", "def apply_omniauth(omniauth)\n self.email = omniauth['info']['email'] if email.blank?\n self.username = omniauth['info']['name'] if username.blank?\n puts \"******************************\"\n puts omniauth\n puts \"******************************\"\n authentications.build(provider:omniauth['provider'], uid:omniauth['uid'])\n end", "def user_from_session\n user = user_from_claims\n return user unless session[:auth0_json]\n raw = JSON.parse(session[:auth0_json] || '{}').with_indifferent_access.fetch(:extra, {}).fetch(:raw_info, {})\n user.email = raw.fetch(:email, user.email)\n user.picture = raw.fetch(:picture, user.picture)\n user.user_metadata = raw.fetch(:user_metadata, user.user_metadata)\n user\n end", "def signup!(params)\n self.login = params[:user][:login]\n self.email = params[:user][:email]\n save_without_session_maintenance\n end", "def new_user user_or_page_data\n Services::Facebook::User.new do |user|\n # Facebook casts some IDs as strings and others as integers, but in the interest of being consistent and\n # future-proof we'll cast them all to strings.\n user.id = (user_or_page_data[:uid] || user_or_page_data[:page_id]).to_s\n user.name = user_or_page_data[:name]\n end\n end", "def create\n user = User.from_omniauth(env[\"omniauth.auth\"])\n session[:user_id] = user.id\n me=User.find(user.id)\n me.loggedin=true\n me.tutoring=false\n me.request=Request.new(class_name:\"3365f80a5cccb3e76443df3b736b26e8\")\n me.save\n render erb: :'sessions#create'\nend", "def facebook_user\n (session[:facebook_session] && session[:facebook_session].session_key) ? session[:facebook_session].user : nil\n end", "def create_from_oauth\n if stored_anonymous_user?\n user, from_registration = update_from_omniauth(env[\"omniauth.auth\"], params[:provider])\n else\n user, from_registration = create_from_omniauth(env[\"omniauth.auth\"], params[:provider])\n end\n\n if user.errors.any?\n redirect_to_registration_page(user)\n else\n change_global_user_id(user.id)\n sign_in(user)\n fandom_play_login(user)\n \n if from_registration\n log_data = { 'form_data' => env[\"omniauth.auth\"], 'user_id' => current_user.id }\n log_synced(\"registration from oauth\", adjust_user_and_log_data_with_utm(user, log_data))\n\n set_account_up()\n cookies[:from_registration] = true \n end\n\n if $site.force_facebook_tab && !request_is_from_mobile_device?(request)\n redirect_to request.site.force_facebook_tab\n else\n redirect_after_oauth_successful_login()\n end\n end\n end", "def create_with_facebook\n auth_hash = request.env['omniauth.auth']\n authorization = Authorization.find_by_provider_and_uid(auth_hash['provider'], auth_hash['uid'])\n name = auth_hash['info']['name'].split\n email = auth_hash['info']['email']\n first, last = name[0], name[1..-1].join(' ')\n user = User.find_by_first_name_and_last_name_and_email(first, last, email)\n\n # when both a user and an authorization have been found\n if authorization && user\n user.oauth_token = auth_hash['credentials']['token']\n user.save\n authorization.update_attribute 'user', user\n sessionize authorization.user\n\n # if only a user exists, build an authorization\n elsif user\n user.authorizations.build :provider => auth_hash['provider'], :uid => auth_hash['uid']\n sessionize user\n\n # No user or authorization; build them\n else\n user = User.new(:first_name => first, :last_name => last, :email => email)\n user.authorizations.build :provider => auth_hash['provider'], :uid => auth_hash['uid']\n user.save\n sessionize user\n end\n\n redirect_to root_path\n end", "def prepare_info_for_facebook(oauth_info)\n { uid: oauth_info.uid.to_s,\n token: oauth_info.credentials.token,\n nickname: oauth_info.info.nickname || \"fbuser_#{uid}\",\n name: oauth_info.info.name,\n email: oauth_info.info.email }\n end", "def signup!(params)\n self.email = params[:user][:email]\n self.name = params[:user][:name]\n self.password = params[:user][:password]\n #save_without_session_maintenance\n end", "def new\n if(params[\"session\"] == 'nil')\n session[:mailid] = nil\n end\n @loginuser = Loginuser.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @loginuser }\n end\n \n end", "def create\n omniauth = request.env['omniauth.auth']\n\n user = User.find_by_uid(omniauth['uid'])\n if not user\n # registruje novog usera\n user = User.new(:uid => omniauth['uid'])\n end\n user.email = omniauth['info']['email']\n user.save\n\n # sve info o useru u sesiji\n session[:user_id] = omniauth\n\n flash[:notice] = \"Successfully logged in\"\n redirect_to root_path\n end", "def create_from_omniauth(omniauth_hash)\n info_hash = omniauth_hash['info']\n return nil unless email = info_hash && info_hash['email']\n user = User.new\n user.credentials << Credentials::Email.new(email: email, verified: true)\n user.save!\n user\n end", "def update_devise_user\n inject_into_file 'app/models/user.rb', after: \":validatable\" do <<-'RUBY'\n, :omniauthable\n validates_presence_of :email\n has_many :authorizations\n\n def self.new_with_session(params,session)\n if session[\"devise.user_attributes\"]\n new(session[\"devise.user_attributes\"],without_protection: true) do |user|\n user.attributes = params\n user.valid?\n end\n else\n super\n end\n end\n\n def self.from_omniauth(auth, current_user)\n authorization = Authorization.where(:provider => auth.provider, :uid => auth.uid.to_s, :token => auth.credentials.token, :secret => auth.credentials.secret).first_or_initialize\n if authorization.user.blank?\n user = current_user.nil? ? User.where('email = ?', auth[\"info\"][\"email\"]).first : current_user\n if user.blank?\n user = User.new\n user.password = Devise.friendly_token[0,10]\n user.name = auth.info.name\n user.email = auth.info.email\n auth.provider == \"twitter\" ? user.save(:validate => false) : user.save\n end\n authorization.username = auth.info.nickname\n authorization.user_id = user.id\n authorization.save\n end\n authorization.user\n end\n RUBY\n end\n end", "def update_facebook_session(fb_uid, fb_session)\n existing_user = User.find_by_facebook_uid(fb_uid)\n existing_user.facebook_sid = fb_session.auth_token\n existing_user.save(false)\n existing_user\n end", "def new_profile?\n @profile = Profile.new(params[:profile])\n @profile.user = current_user\n @profile.email = current_user.email\n end", "def set_session\n\t #no idea why I need this, but login form seems to break otherwise\n\t session[:email] = session[:email]\n\t session[:password] = session[:password]\n\t end", "def register_user_to_fb\n users = {:email => email, :account_id => id}\n Facebooker::User.register([users])\n self.email_hash = Facebooker::User.hash_email(email)\n end", "def make_user\n @user = User.new(session_token: params[:session_token])\n graph = Koala::Facebook::API.new(@user.session_token)\n id = graph.get_object(\"me\")[\"id\"]\n if id != params[:facebook_id]\n render json: [\"Invalid session token\"], status: 401\n return\n end\n @user.fill_user_data(graph)\n if @user.save\n # @user.add_friends(graph)\n render \"api/users/show\"\n else\n render json: @user.errors.full_messages, status: 422\n end\n end", "def create\n omniauth = request.env['omniauth.auth']\n authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])\n if authentication\n flash[:notice] = \"Signed in successfully\"\n sign_in_and_redirect(:user, authentication.user)\n else\n user = User.new\n user.apply_omniauth(omniauth)\n user.email = omniauth['extra'] && omniauth['extra']['user_hash'] && omniauth['extra']['user_hash']['email']\n if user.save\n flash[:notice] = \"Successfully registered\"\n sign_in_and_redirect(:user, user)\n else\n session[:omniauth] = omniauth.except('extra')\n session[:omniauth_email] = omniauth['extra'] && omniauth['extra']['user_hash'] && omniauth['extra']['user_hash']['email']\n\n # Check if email already taken. If so, ask user to link_accounts\n if user.errors[:email][0] =~ /has already been taken/ # omniauth? TBD\n # fetch the user with this email id!\n user = User.find_by_email(user.email)\n return redirect_to link_accounts_url(user.id)\n end\n redirect_to new_user_registration_url\n end\n end\n end", "def new\n @email_field = email_field\n @session = Session.new\n end", "def apply_omniauth(omniauth)\n # self.email = omniauth['info']['email'] if email.blank? # Twitter does not return an email\n authentications.build(provider: omniauth[\"provider\"], uid: omniauth[\"uid\"])\n end", "def parse_user_new_session(user_params)\n user = User.where(email: user_params[:email]).first\n if user && user.valid_password?(user_params[:password])\n user\n else\n user = User.new\n user.errors.add :email, 'incorrect email address or password'\n user\n end\n end", "def login_from_facebook\n fb_cookie = get_facebook_cookie\n return unless fb_cookie and fb_cookie[\"uid\"]\n\n #uid : 507527287\n #sig : ddf9dffcd85fcc41dbe4257b5eee922b\n #base_domain : gear.com\n #secret : fSoxbS_tGGF0oP2c9_SUbw__\n #access_token : 225955489319|2.KBSGTAnBP5tSEIxJBXcWfA__.3600.1278799200-507527287|d5zULU1zLZFguUUcsqVU0-C-tOM.\n #session_key : 2.KBSGTAnBP5tSEIxJBXcWfA__.3600.1278799200-507527287\n #expires : 1278799200\n\n user = User.find_by_fb_user_id(fb_cookie[\"uid\"])\n\n # cant find the user in the db but they have a fb session..\n return unless user\n \n # Add fb user to the user object and set the current user\n self.current_user = user \n end", "def ensure_facebook_connect\n set_facebook_session()\n if facebook_session && facebook_session.user.id\n @user = User.find_or_create_by_facebook_id(facebook_session.user.id)\n else\n redirect_to :controller=>:account, :action=>:login, :next_url=>request.request_uri\n end\n end", "def new\n session[:user_return_to] ||= params[:user_return_to]\n @already_hoc_registered = params[:already_hoc_registered]\n @hide_sign_in_option = true\n if params[:providerNotLinked]\n if params[:useClever]\n # The provider was not linked, and we need to tell the user to sign in specifically through Clever\n flash.now[:alert] = I18n.t 'auth.use_clever', provider: I18n.t(\"auth.#{params[:providerNotLinked]}\")\n else\n # This code is only reached through the oauth flow when the user already has an email account.\n # Usually email would not be available for students, this is a special case where oauth fills it in.\n flash.now[:alert] = I18n.t 'auth.not_linked', provider: I18n.t(\"auth.#{params[:providerNotLinked]}\")\n @email = params[:email]\n end\n end\n super\n end", "def register_user_to_fb\n users = {:email => email, :account_id => id}\n Facebooker::User.register([users])\n self.email_hash = Facebooker::User.hash_email(email)\n save(false)\n end", "def register_user_to_fb\n users = {:email => email, :account_id => id}\n Facebooker::User.register([users])\n self.email_hash = Facebooker::User.hash_email(email)\n save(false)\n end", "def create\n\t# user = User.find_by_email(params[:session][:email])\n\t# if user.authenticate(params[:session][:password])\n\t# \tsign_in user\n\t# \tflash[:message] = \"Successfully logged in!\"\n\t# \tredirect_to feed_path(user.id)\n\t# else\n\t# \tflash[:error] = \"Your email or password is invalid\"\n\t# \tredirect_to signin_path\n\t# end\n\tUser.find(auth).nil? ? @user = User.find(auth) : @user = User.create(auth) \n\tsign_in @user\n\tredirect_to \"/\"\n\n end", "def facebook\n @fb_user ||= FbGraph::User.me( self.authentications.find_by_provider('facebook').token)\n end", "def set_user\n \t#to do\n \t#if cookie authentication_token type facebook\n\n \t#elsif cookie authentication_token type email\n\n \t#end\n \t\t\n \t@user = User.find_by(authentication_token: request.headers['Authorization'])\n end", "def apply_omniauth(omniauth)\n info = omniauth[\"info\"]\n\n user_name = %Q(#{info[\"first_name\"]} #{info[\"last_name\"]})\n user_name.gsub!(/\\s+/, \" \").strip!\n\n self.provider = omniauth[\"provider\"]\n self.uid = omniauth[\"uid\"]\n self.name = user_name if self.name.blank?\n self.email = info[\"email\"] if info[\"email\"] && self.email.blank?\n self\n end", "def facebook\n @user = User.find_or_create_for_facebook(request.env[\"omniauth.auth\"], current_user)\n flash[:alert] = \"Signed in with Facebook successfully.\"\n # use devise-provided method to redirect the user\n if @user.sign_in_count == 0\n sign_in @user, :event => :authentication\n redirect_to users_get_path\n else\n sign_in_and_redirect @user, :event => :authentication\n end\n end", "def set_attributes(email,password,first_name,last_name)#called by sign_in api in apis controller\n self.email = email\n self.password = password\n self.first_name = first_name\n self.last_name = last_name\n self.save\n end", "def temp_user_login(info)\n\t\t\tunless TmpUser.find_by_email(info[\"email\"]).nil?\n\t\t\t\t@user = TmpUser.find_by_email(info[\"email\"])\n\t\t\t\treturn @user\n\t\t\telse\n\t\t\t\t@user = TmpUser.create(:email => info[\"email\"],:coupon_id => info[\"coupon\"], :game_id => info[\"game\"] )\n\t\t\t\treturn @user\n\t\t\tend\n\t\tend", "def new\n @student = Student.new_from_oauth session['devise.oauth_data']\n end", "def set_user\n @user = User.find_by(email: params[:session][:email])\n end", "def before_create_user\n logger.debug(\"on before creare user\")\n #Generate a unique key\n if facebook_user?\n self.active = 1 \n else\n activation_key_string = self.salt+self.email+self.hashed_password\n self.activation_key =Digest::SHA1.hexdigest(activation_key_string)\n self.active = 0\n end\n self.admin = 0 \n self.handle=generate_unique_handle\n \n end", "def facebook_callback\n hash = request.env[\"omniauth.auth\"]\n if hash\n email = hash[\"info\"][\"email\"]\n username = hash[\"info\"][\"nickname\"]\n gender = hash[\"extra\"][\"raw_info\"][\"gender\"]\n provider = hash[\"provider\"]\n gid = hash[\"uid\"]\n token = hash[\"credentials\"][\"token\"]\n auth = Authentication.find_by_provider_and_gid(provider, gid)\n if !gamer_signed_in?\n if auth\n if auth.gamer\n flash[:success] = t(:signed_in_fb)\n sign_in_and_redirect(:gamer, auth.gamer)\n else\n flash[:error] = t(:no_account)\n redirect_to \"/gamers/sign_up\"\n end\n else\n gamer = Gamer.find_by_email(email)\n if gamer\n Authentication.create_with_omniauth(provider, gid,\n token, nil, email, gamer.id)\n flash[:success] = t(:signed_in_fb)\n sign_in_and_redirect(:gamer, gamer)\n else\n session[\"devise.token\"] = token\n session[\"devise.gid\"] = gid\n session[\"devise.token_secret\"] = nil\n flash[:info] = t(:continue_reg_fb)\n redirect_to controller: \"social_registrations\",\n action: \"new_social\", email: email, username: username,\n gender: gender, provider: provider\n end\n end\n else\n if !auth\n Authentication.create_with_omniauth(provider,gid,\n token, nil, email, current_gamer.id)\n flash[:success] = t(:logged_in_to_fb)\n redirect_to \"/gamers/edit\"\n else\n Authentication.update_token(current_gamer.id, provider, token)\n redirect_to \"/games/post_facebook\"\n end\n end\n else\n flash[:error] = t(:oops_error_fb)\n redirect_to root_url\n end\n end", "def create\n auth = request.env[\"omniauth.auth\"]\n user_info = auth[\"info\"] ? auth[\"info\"] : auth[\"user_info\"]\n authentication = Authorization.where(:provider => auth['provider'], :uid => auth['uid']).first\n authentication = Authorization.new(:provider => auth['provider'], :uid => auth['uid']) if !authentication\n session[:fb_token] = auth['credentials']['token'] if auth['credentials']['token'] != nil\n # if the user exists, but does not have a link with the social service\n if !authentication.user && current_user\n authentication.user = current_user\n authentication.save\n end\n # twitter only (gets no email)\n if !authentication.user && !user_info[\"email\"]\n flash[:notice] = \"No user linked to this account. Please sign in or create a new account\"\n redirect_to '/users/sign_up/'\n # if user doesnt exists, register user\n elsif !authentication.user\n user = User.where(email: user_info['email']).first\n if user\n authentication.user = user\n else\n new_user = User.new(email: user_info['email'], username: user_info['name'], first_name: user_info['first_name'], last_name: user_info['last_name'], role: \"registered\")\n new_user.save\n authentication.user = new_user\n end\n authentication.save\n end\n # if user exists, sign in. Gives a Mongoid glitch of not signing in after registration. So double sign in\n if authentication.user\n if !current_user\n sign_in authentication.user\n sign_out authentication.user\n sign_in authentication.user\n # raise \"user signed in? #{user_signed_in?.to_s}\".inspect\n flash[:notice] = \"Authorization successful.\"\n redirect_to root_path\n else\n flash[:notice] = \"Linked successfully.\"\n redirect_to '/users/'+current_user.id\n end\n end\n end", "def create\n\t\t#get the user info\n\t\t\n\t\tauth = request.env[\"omniauth.auth\"]\n\t\tif auth == nil and \n\t\t\tif session[:temp] == true\n\t\t\t auth = {:info => {:email => \"[email protected]\"} }\n\t\t\telse\n\t\t\t auth = {:info => {:email => \"[email protected]\"} }\t\n\t\t\tend\n\t\tend\n\t\t#whitelist \n\t\tif auth[:info][:email].to_s =~ /[email protected]/\n\t\t\tuser = User.find_by_uid(auth[\"uid\"]) || User.createUser(auth)\n\t\t\tsession[:user_id] = user.id \n\t\t\tsession[:admin] = user.admin\n\t\t\tsession[:authenticated] = true\n\t\t\tredirect_to links_path\n\t\telse\n\t\t\tsession[:authenticated] = false\n\t\t\tsession[:error] = \"Must have a wesleyan email address\"\n\t\t\tredirect_to root_path\n\t\tend\t\n\tend", "def create\n email = params[:email]\n password = params[:password]\n fb_token = params[:fbtoken]\n if request.format != :json\n render :status => 406, :json => {:message => 'The request must be json'}\n return\n end\n\n if (email.nil? or password.nil?) && fb_token.nil?\n render :status => 400,\n :json => {:message => 'The request must contain the user email and password or FB token.'}\n return\n end\n\n if fb_token\n #check token\n begin\n facebook_graph = ::Koala::Facebook::API.new('595428443887130|BMCDixQJlECImLZsnnxGBO2jtoI')\n @token_info = facebook_graph.debug_token(fb_token)\n logger.info @token_info.inspect\n @user = User.find_by(fb_id: @token_info['data']['user_id'])\n rescue => e\n logger.error e.message\n @user = nil\n end\n else\n @user = User.find_by(email: email.downcase)\n end\n\n if @user.nil?\n logger.info(\"User #{email || fb_token} failed signin, user cannot be found.\")\n render :status => 401, :json => {:message => 'Invalid email or password or FB token.'}\n return\n end\n\n # http://rdoc.info/github/plataformatec/devise/master/Devise/Models/TokenAuthenticatable\n #@user.generate_authentication_token\n\n valid = (!fb_token && @user.valid_password?(password)) || (fb_token && @token_info['data']['app_id'] == '595428443887130')\n\n if valid\n @user.ensure_authentication_token\n logger.info 'Token: ' + @user.authentication_token.to_s\n @user.save_device_token(params[:device_token])\n render :status => 200, :json => {:token => @user.authentication_token, :email => @user.email, :premium => [email protected]?(:free)}\n else\n logger.info(\"User #{email} failed signin, password \\\"#{password}\\\" is invalid\")\n render :status => 401, :json => {:message => 'Invalid email or password or FB token.'}\n end\n end", "def constructed_user\n OpenStruct.new(email: current_user.email)\n end", "def callback\n @request_token = session[:request_token]\n @access_token = @request_token.get_access_token\n\n session[:oauth_token] = @access_token.token\n session[:oauth_token_secret] = @access_token.secret\n\n current_user = twitter_api.account_verify_credentials\n \n session[:user_attributes] = {\n id: current_user.id,\n screen_name: current_user.screen_name,\n profile_image_url: current_user.profile_image_url,\n profile_image_url_https: current_user.profile_image_url_https\n }\n\n redirect_to :root\n end", "def fetch_details_from_facebook\n\t\t# graph = Koala::Facebook::API.new(self.token)\n\t\t# facebook_data = graph.get_object(\"me\")\n\t\t# self.username = facebook_data['username']\n\t\t# self.save\n\t\t# self.user.username = facebook_data['username'] if self.user.username.blank?\n\t\t# self.user.image = \"http://graph.facebook.com/\" + self.username + \"/picture?type=large\" if self.user.image.blank?\n\t\t# self.user.location = facebook_data['location'] if self.user.location.blank?\n\t\t# self.user.save\n\t\tself.user.has_facebook = true\n\t\tself.user.save\n\tend", "def register_user_to_fb\n users = {:email => email, :account_id => id}\n r = Facebooker::User.register([users])\n self.email_hash = Facebooker::User.hash_email(email)\n save(false)\n end", "def facebook\n social_login(request.env['omniauth.auth'], current_user,\"Facebook\")\n end", "def signup_with_facebook\n @status, @msg, @data = UserValidator.signup_with_facebook(params)\n @status, @msg, @data = UserManager.signup_with_facebook(params) if @status\n end" ]
[ "0.97167295", "0.9157083", "0.90557295", "0.8633759", "0.7233643", "0.71774304", "0.7118631", "0.7025944", "0.6996177", "0.68110645", "0.6803577", "0.6784633", "0.6756826", "0.6713332", "0.6676178", "0.66739297", "0.66244805", "0.6558739", "0.6528538", "0.6500806", "0.64794993", "0.6418411", "0.6413528", "0.6399034", "0.6371984", "0.63679606", "0.6338964", "0.63309574", "0.6324664", "0.6312983", "0.6312809", "0.6297166", "0.62953043", "0.6278606", "0.62682265", "0.62641054", "0.62575334", "0.6253114", "0.62480325", "0.62356603", "0.62344855", "0.62323356", "0.62232137", "0.62208986", "0.6219521", "0.62100506", "0.62089527", "0.6206036", "0.6202445", "0.618642", "0.61798984", "0.6147163", "0.61397946", "0.6133725", "0.61097056", "0.6100642", "0.6096069", "0.60900474", "0.6088578", "0.6075958", "0.607277", "0.60467535", "0.6042782", "0.60409516", "0.60348606", "0.60295284", "0.60290706", "0.6025287", "0.6025077", "0.6024119", "0.6019776", "0.6008633", "0.59971833", "0.59941626", "0.59939003", "0.59778327", "0.59763575", "0.5973105", "0.5964896", "0.59522897", "0.59522897", "0.59505606", "0.59356976", "0.5925928", "0.59233713", "0.5915692", "0.5912896", "0.590535", "0.59048223", "0.5899742", "0.5890258", "0.588544", "0.58747137", "0.5872269", "0.5858807", "0.5849199", "0.58485806", "0.58428377", "0.5842683", "0.583856", "0.5836555" ]
0.0
-1
Cat.all collections of all the cat objects get those cats that belong to owner
def cats Cat.all.select do |cat| cat.owner == self end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cats\n Cat.all.select { |cats| cats.owner == self }\n end", "def cats \n Cat.all.select do |cat_instance|\n cat_instance.owner == self \n end\n end", "def cats\n Cat.all.select do |cat|\n cat.owner == self\n end\n end", "def cats \n Cat.all.select {|one_cat| one_cat.owner == self} \n end", "def cats\n Cat.all.select {|cat| cat.owner == self}\n end", "def cats\n\t\t# Note that you call upon the other class within this class.\n\t\tCat.all.select do |cat|\n\t\t\tcat.owner == self\n\t\tend\n\tend", "def cats\n #loop through .all class method for the class Cat\n #select the value for variable cat and return it to a new array\n #every time cat.owner == self is true\n Cat.all.select do |cat|\n #block determines true value\n cat.owner == self #returns if true\n end\n end", "def find_owner_cat\n @cat = @owner.cats.find_by!(id: params[:id]) if @owner\n end", "def dogs\n collection_of_dogs = []\n Dog.all.each do |dog|\n if dog.owner == self\n collection_of_dogs << dog\n end \n end \n return collection_of_dogs\n end", "def list_owners\n Owner.all.each_with_index do |owner, i|\n puts \"\\n#{i + 1}. #{owner.name} \\nAddress: #{owner.address}\"\n puts \"Food provided: #{owner.food_provided.capitalize}\"\n puts \"Has a cat? #{owner.cat_already.to_s.capitalize} | Has a dog? #{owner.dog.to_s.capitalize}\"\n puts \"Lives in #{owner.neighborhood.name}\"\n all_cats = Cat.all.select { |x| x.owner_id == owner.id}\n cats_list = all_cats.map{ |x| x.name }.join(\", \")\n puts \"#{owner.name}'s cat(s): #{cats_list}\"\n puts \"\\n----------------------------------------------------------------------------\"\n end\n end", "def all_cars\n Car.all.select do |car|\n car.owner == self\n end\n end", "def dogs\n Dog.all.select do |dog|\n dog.owner == self\n end\n end", "def dogs\n Dog.all.select do |dog_instance|\n dog_instance.owner == self \n end\n end", "def cars\n Car.all.select {|c| c.owner == self}\n end", "def dogs\n Dog.all.select {|d| d.owner == self}\n end", "def dogs\nDog.all.find_all do |dog|\n dog.owner == self\nend\n\nend", "def owners\n self.cars.map{|car_instance| car_instance.owner}.uniq\n end", "def show_all\n @owners = Owner.all\n end", "def dogs\n\t\t# Note that you call upon the other class within this class.\n\t\tDog.all.select do |dog|\n\t\t\tdog.owner == self\n\t\tend\n\tend", "def cats_at_this_cafe\n Cat.all.select do |cat| \n cat.cafe == self \n end\n end", "def cars\n Car.all.select { |car| car.car_owner == self }\n end", "def index\n render json: @owner.cats\n end", "def dogs\n Dog.doggies.select { |dogs| dogs.owner == self }\n end", "def cars\n Car.all.select do |car|\n car.car_owner == self\n end\n end", "def toys_that_jet_owns\n # Find all of the toys that Jet owns. Then list the the names of all \n # the other cats that own those toys as well as the toys names.\n # Exclude Jet from the results.\n # Order alphabetically by cat name. \n\n # DO NOT USE A SUBQUERY\n execute(<<-SQL)\n SELECT DISTINCT\n notjetcats.name, toys.name \n FROM \n toys \n JOIN \n cattoys as notjetjoins ON toys.id = notjetjoins.toy_id \n JOIN \n cats as notjetcats ON notjetcats.id = notjetjoins.cat_id \n JOIN \n cattoys as jetcatjoins ON toys.id = jetcatjoins.toy_id \n JOIN \n cats as jetcats ON jetcats.id= jetcatjoins.cat_id \n WHERE \n jetcats.name = 'Jet' AND notjetcats.name != 'Jet'\n ORDER BY\n notjetcats.name ASC;\n SQL\n end", "def list_cats\n Cat.all.each_with_index do |kitty, i| \n puts \"\\n#{i + 1}. #{kitty.name} 🐈\"\n ##### if no owner\n if kitty.owner.nil?\n puts \"Breed: #{kitty.breed} | Color: #{kitty.color.capitalize}\"\n puts \"Food preference: #{kitty.favorite_food.capitalize} | Gets along with other cats? #{kitty.temperament.to_s.capitalize}\"\n puts \"\\n----------------------------------------------------------------------------\"\n ##############\n else\n puts \"Owner: #{kitty.owner.name}\"\n puts \"Breed: #{kitty.breed} | Color: #{kitty.color.capitalize}\"\n puts \"Food preference: #{kitty.favorite_food.capitalize} | Gets along with other cats? #{kitty.temperament.to_s.capitalize}\"\n puts \"\\n----------------------------------------------------------------------------\"\n end\n end\n end", "def owners\n return @owners\n end", "def owner_names\n self.pets.map {|p| p.owner}.pluck(:name).uniq\n end", "def owners\n self.car.map do |car| car.owner.uniq\nend\n\n\n\nend", "def get_pool\n return Pool.where({\"category_id\" => self.id})\n end", "def owners\n @obj['owners']\n end", "def owner_rent_out\n cuties = []\n Rental.all.each do |r|\n temp_arr = []\n if r.cutie.user == self\n temp_arr[0] = r.cutie\n temp_arr[1] = r\n cuties << temp_arr\n end\n end\n return cuties\n end", "def index\n @all_collections = Collection.all\n @current_user = User.find_by username: session[:user]\n @collections = []\n @all_collections.each do |collection|\n if collection.owner.id == @current_user.id or collection.user_ids.include? @current_user.id\n @collections.push(collection)\n end\n end\n end", "def collection\n conditions = conditions_from_params\n @collection ||= end_of_association_chain.find(:all, :conditions => conditions)\n end", "def owners\n self.authors.collect(&:user)\n end", "def people\n Person.find(dogs.map(&:owner_id))\n end", "def find\n @owner = Owner.find(params[:id])\n @dogs = Owner.find(params[:id]).dogs\n end", "def all_oaths\n Bloodoath.all.select {|oath| oath.cult == self}\n #can call .cult because of attr reader in bloodoath\n end", "def index\n @author_widget_categories = WidgetCategory.fetch_data(current_user).includes(:author_widgets)\n end", "def toys_that_jet_owns_sub\n # Find all of the toys that Jet owns. Then list the the names of all \n # the other cats that own those toys as well as the toys names.\n # Exclude Jet from the results.\n # Order alphabetically by cat name. \n\n # USE A SUBQUERY\n execute(<<-SQL)\n SELECT\n cats.name, toys.name\n FROM cattoys\n JOIN cats ON cat_id = cats.id\n JOIN toys ON toy_id = toys.id\n WHERE\n toys.id IN (\n SELECT toys.id\n FROM cattoys\n JOIN cats ON cat_id = cats.id\n JOIN toys ON toy_id = toys.id\n WHERE cats.name = 'Jet'\n ) AND cats.name != 'Jet'\n ORDER BY cats.name;\n SQL\nend", "def get_lookups\n\t @categories = Category.ordered \n\t\t@ownerships = Ownership.ordered\n end", "def index\n @categories = Category.includes(:user).all\n end", "def car_owners\n car_owners_arr = Car.all.select do |car_ob|\n #binding.pry\n car_ob.mechanic == self\n end\n car_owners_arr.map do |car_ob|\n car_ob.owner\n end\nend", "def get_childs\n childs = Category.any_in(parent_ids: [parent.id])\n\n results = Array.new\n childs.each do |child|\n results << child\n end\n\n results\n end", "def index\n @cats = Cat.all\n end", "def all\n post_owners = [current_user.id] + Friendship.where(:user2_id => current_user, :approved => true).pluck(:user1_id)\n @posts = Post.where('owner_id' => post_owners).order(created_at: :desc).page(params[:page]).per_page(POSTS_PER_PAGE)\n end", "def blood_oaths\n # First, get all of the blood oaths and then from them, select only the ones that belong to this cult\n BloodOath.all.select { |blood_oath| blood_oath.cult == self }\n end", "def show\n @p_cats = PCat.all\n end", "def getOwners\r\n\t\t\t\t\treturn @owners\r\n\t\t\t\tend", "def my_clients\n self.client_cars.map do |car|\n car.owner\n end\n end", "def owner_and_coowners\n vals = Role.access_values_for(:creator).concat(Role.access_values_for(:administrator))\n User.joins(:roles).where(\"roles.plan_id = ? AND roles.access IN (?)\", self.id, vals)\n end", "def filter_by_owner(array_to_filter)\n filtered_array = []\n if session[:owner]\n array_to_filter.each do |object|\n if object.owner == session[:owner]\n filtered_array << object\n end\n end\n else\n filtered_array = array_to_filter\n end\n filtered_array\n end", "def filter_by_owner(array_to_filter)\n filtered_array = []\n if session[:owner]\n array_to_filter.each do |object|\n if object.owner == session[:owner]\n filtered_array << object\n end\n end\n else\n filtered_array = array_to_filter\n end\n filtered_array\n end", "def find_owner_appointments\n owner_appointments = Appointment.all.select { |appointment| appointment.owners.include?(self) || appointment.owner_id == id } \n if !owner_appointments.empty?\n owner_appointments\n else\n nil\n end\n end", "def car_owner_names\n car_owners_arr = Car.all.select do |car_ob|\n #binding.pry\n car_ob.mechanic == self\n end\n car_owners_arr.map do |car_ob|\n car_ob.owner.name\n end\nend", "def find_associated_records\n if category and (category.new_record? or category.dirty?)\n if category.name.blank?\n self.category = nil\n else\n existing_category = Category.find_by_name(category.name)\n self.category = existing_category if existing_category\n end\n end\n end", "def on(owner = nil)\n if owner.present?\n where :owner_id => owner.id, :owner_type => owner.class.name\n else\n where :owner_id => nil, :owner_type => nil\n end\n end", "def index\n @vendor_cats = VendorCat.all\n end", "def all_categories\n\t\t@categories = Category.all\n\tend", "def owners\n # set @owners instance variable by\n # 1) grabbing all Ownerships containing this panlist\n # 2) converting each Ownership into an Owner\n @owners ||= Ownership.where(list_id: self.id).map do |ownership|\n Owner.find_by_netid(ownership.owner_id)\n end\n end", "def getCategoryAll()\n params = Hash.new\n return doCurl(\"get\",\"/category/all\",params)\n end", "def potential_categories\n if categories.length > 0\n Category.all(:conditions => \"id NOT IN (#{category_ids})\")\n else\n Category.all\n end\n end", "def all\n @customer_objects\n end", "def ownedCards\n \tcus_owned_by_user = cards_users.where(is_shared: false)\n\n \t# Have a list of CardsUsers, but want a list of Owned Cards\n \towned_cards = []\n \tcus_owned_by_user.each do | cu |\n \t\tcard = Card.find(cu.card_id)\n \t\towned_cards.push(card)\n \tend\n \towned_cards\n end", "def show\n @categories = Category.all\n @users = User.all\n end", "def cur_oaths\n BloodOath.all.select {|bloodoath| bloodoath.cult == self}\n end", "def all\n where\n end", "def comics_owned\n comics_array = self.comics.map do |comic|\n comic\n end\n comics_array.uniq\n end", "def collections\n Collection.find(:all, :find_through => [N::DCT.hasPart, self])\n end", "def carowner_names\n CarOwner.all.select do |c|\n if c.mechanic == self\n c.name\n end\n end\nend", "def get_owners\n return make_request(\"#{self.endpoint}/list/owners\")\n end", "def categories\n add_to_query restrict_kind: 'category'\n end", "def crazy_cat_lady\n cat_lady = Owner.all.inject do |memo, owner|\n memo.cats.count > owner.cats.count ? memo : owner\n end\n puts \"\\nThe person with the most cats is #{cat_lady.name} with #{cat_lady.cats.count} cats! 🙀\\n\"\n end", "def member_collections\n Collection.where(community_id: id)\n end", "def get_related_to(category)\n raise \"Cannot do a look-up with a blank category!\" if category.blank?\n collection = self.class.new\n collection.kinds = @kinds.get_related_to(category)\n collection.mixins = @mixins.get_related_to(category)\n collection\n end", "def users\n category_users.uniq\n end", "def index\n @categories = Category.where(user_id: current_user.id)\n end", "def owners\n get_user_with_role(:owner)\n end", "def index\n @p_cats = PCat.all\n end", "def all\n render json: Cat.all\n end", "def index\n @maincats = Maincat.all\n end", "def list_pets\n @owner.dogs.count\n @owner.cats.count\n end", "def blood_oaths #<-- blood oath selects all cult members in bloodOath Class file\n BloodOath.all.select { |blood_oath| blood_oath.cult == self}\n end", "def list\n @categories = current_user.categories.where locked: false\n end", "def get_categories\n @categories = Category.all\n end", "def find_all_tagged_objs\n Tagging.where(tagger: self).map{|tagging| tagging.tagged_obj}.uniq\n end", "def index\n @owners = Owner.all\n end", "def index\n @owners = Owner.all\n end", "def all_bookings\n Booking.includes(:user, :court).ordered.load\n end", "def all(coll)\n @db[coll].find\n end", "def collected_entities entity_type, viewer=nil\n entity_type = entity_type.to_s\n if viewer == self\n assoc = entity_type.to_s\n scope = self.method(assoc).call\n scope = scope.where.not(owner_id: id) if entity_type == \"List\"\n scope\n else\n arr = collection_pointers.where(entity_type: entity_type, private: false).map(&:entity)\n arr = arr.keep_if { |l| l.owner != self } if entity_type == \"List\"\n arr\n end\n end", "def eligible_owners\n User.where('users.id != ?', @cookbook.user_id)\n end", "def get_categories\n @cards.each do |card|\n if [email protected]?(card.category)\n @categories << card.category\n end\n end\n @categories\n end", "def get_all_category_select_options()\n o = []\n Category.where(:category_id => nil).each do |c|\n get_category_select_options(c).each do |c_option|\n o << c_option\n end\n end\n return o\n end", "def carowners\n CarOwner.all.each do |c|\n c.mechanic == self\n end\nend", "def index\n @categories = Category.roots\n end", "def category_users\n images.collect{|e| e.user}\n end", "def allclient\n @clients = Client.where(is_client:true)\n end", "def activities_by_owner(owner)\n acts = @activities.select { |act| act.owner == owner}\n unless acts.nil?\n self.sort_activities acts\n end\n end", "def index\n @cooks = Cook.includes(:user)\n end" ]
[ "0.81496465", "0.80740863", "0.80354977", "0.80171543", "0.8001798", "0.7867059", "0.7041076", "0.69846386", "0.6716329", "0.6443365", "0.64384097", "0.6388401", "0.6378328", "0.62944335", "0.62826616", "0.62637126", "0.61636835", "0.6154231", "0.6140937", "0.6069419", "0.6011114", "0.5994755", "0.59785575", "0.5973829", "0.5946014", "0.5907432", "0.58651024", "0.5820023", "0.5807316", "0.5806962", "0.57857984", "0.5783104", "0.5762586", "0.57414407", "0.573836", "0.5728816", "0.5727286", "0.5704121", "0.56610894", "0.56564546", "0.56053627", "0.56039125", "0.5601567", "0.5589585", "0.5577432", "0.5570474", "0.55577236", "0.55482024", "0.55281675", "0.5527415", "0.55214477", "0.55200076", "0.5518218", "0.5517164", "0.5513867", "0.5508307", "0.5507351", "0.54900974", "0.54801035", "0.54520273", "0.5435565", "0.54197574", "0.5419301", "0.5415167", "0.5411238", "0.54099554", "0.5406949", "0.5401456", "0.53896415", "0.5379949", "0.53797287", "0.5374039", "0.5369712", "0.5369064", "0.5359669", "0.53517616", "0.5346295", "0.53430414", "0.5337565", "0.5337385", "0.5327834", "0.5314347", "0.53134996", "0.5306294", "0.5295154", "0.5292423", "0.52924114", "0.52924114", "0.5284337", "0.52823424", "0.5277894", "0.527712", "0.5273857", "0.5270585", "0.5244642", "0.52402383", "0.52313673", "0.5224299", "0.52222043", "0.5220696" ]
0.7905704
5
Nikki.sell_pets get list of NIKKIS dogs and cats only (not all dod ) change dog mood to nervous, change cat mood to nervous remove their owner
def sell_pets all_owner_pets = self.dogs + self.cats all_owner_pets.each do |pet| pet.mood = "nervous" pet.owner = nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sell_pets\n Cat.all.collect do |cats|\n cats.mood=\"nervous\"\n cats.owner=nil\n end\n Dog.all.collect do |dogs|\n dogs.mood=\"nervous\"\n dogs.owner=nil\n end\n end", "def sell_pets\n all_pets = []\n all_pets << self.cats \n all_pets << self.dogs \n all_pets.flatten.map do |each_pet|\n each_pet.mood = \"nervous\"\n each_pet.owner = nil\n end\n end", "def sell_pets\n pets.each {|kind, moods|\n moods.each {|pets| pets.mood=(\"nervous\")}\n moods.clear\n }\n end", "def sell_pets\n pets = dogs + cats\n\n pets.each do |pet|\n pet.mood = \"nervous\"\n pet.owner = nil\n end\n end", "def sell_pets\n cats.each do |pet|\n pet.mood = \"nervous\"\n pet.owner = nil\n end\n dogs.each do |pet|\n pet.mood = \"nervous\"\n pet.owner = nil\n end\n \n\n end", "def sell_pets\n self.cats.each{ |each_cat|\n each_cat.mood = \"nervous\"\n each_cat.owner = nil\n }\n \n self.dogs.each{ |each_dog|\n each_dog.mood = \"nervous\"\n each_dog.owner = nil\n }\n\n self.cats.clear\n self.dogs.clear\n end", "def sell_pets\n self.pets[:dogs].each do |dog|\n dog.mood = \"nervous\"\n end\n self.pets[:cats].each do |cat|\n cat.mood = \"nervous\"\n end\n self.pets[:fishes].each do |fish|\n fish.mood = \"nervous\"\n end\n self.pets[:fishes] = []\n self.pets[:dogs] = []\n self.pets[:cats] = []\n end", "def sell_pets\n all_animals = self.pets.values\n\n all_animals.each do |species|\n species.each {|pet| pet.mood = \"nervous\"}\n species.clear\n end\n end", "def sell_pets\n @pets.each do |type, pet| \n pet.each { |animal| animal.mood = \"nervous\"}\n end\n @pets.clear\n end", "def sell_pets\n pets.each do |type, all_type|\n all_type.each do |pet|\n pet.mood = \"nervous\"\n end\n end\n pets.clear\n end", "def sell_pets\n#this makes them all nervous\n pets.each do |species, animals|\n animals.each do |animal|\n animal.mood = \"nervous\"\n end\n animals.clear\n end\n end", "def sell_pets\n pets.each do |species, pet_array| #enumerate through pets hash...\n pet_array.each do |pet_object| #then enumerate through pet_array within pets hash...\n #binding.pry\n pet_object.mood = \"nervous\" #set each pet_object's mood to \"nervous\"\n end\n end #end loop\n self.pets.clear #and reset Owner instance .pets to an empty array, that is returned\n end", "def sell_pets \n self.dogs.each do |dog|\n dog.owner = nil\n dog.mood = \"nervous\"\n self.dogs.delete(dog)\n end \n self.cats.each do |cat|\n cat.owner = nil\n cat.mood = \"nervous\"\n self.cats.delete(cat)\n end\n end", "def sell_pets #Owner can sell all its pets, which make them nervous\n # fido = Dog.new(\"Fido\")\n # tabby = Cat.new(\"Tabby\")\n # nemo = Fish.new(\"Nemo\")\n # [fido, tabby, nemo].each {|o| o.mood = \"happy\" }\n # owner.pets = {\n # :dogs => [fido, Dog.new(\"Daisy\")],\n # :fishes => [nemo],\n # :cats => [Cat.new(\"Mittens\"), tabby]\n # }\n # owner.sell_pets\n # owner.pets.each {|type, pets| expect(pets.empty?).to eq(true) }\n # [fido, tabby, nemo].each { |o| expect(o.mood).to eq(\"nervous\") }\n pets.each do |type, animals|\n animals.each do |animal|\n animal.mood = \"nervous\"\n end\n animals.clear\n end\n end", "def pets\n\t\t@pets_list\n\tend", "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 pets\n @pets\n end", "def pets_by_breed(petshop,breed)\n pets=[]\n petshop[:pets].each do\n |pet| \n if pet[:breed] == breed\n pets.push(breed) \n end\n end\n return pets\n end", "def pets_by_breed(petshop,breed)\n pets=[]\n for pet in petshop[:pets] do\n if pet[:breed] == breed\n pets.push(breed) \n end\n end\n return pets\n end", "def pets_by_breed(pet_shop, breed)\n pets_of_type_breed = []\n for pet in pet_shop[:pets]\n pets_of_type_breed << pet[:name] if pet[:breed] == breed\n end\n return pets_of_type_breed\nend", "def pets #stores all of the owners pets\n @pets #expect(owner.pets).to eq({:fishes => [], :dogs => [], :cats => []})\n end", "def pets\n pet_owners.map do |pet_owner|\n pet_owner.pet\n end\n end", "def pets_by_breed(pet_shop, breed)\n all_breed = []\n for l_breed in pet_shop[:pets]\n if l_breed[:breed] == breed\n all_breed.push(l_breed[:name])\n end\n end\n return all_breed\nend", "def turnover_pet\n selected_pet = choose_pet()\n @pets.delete(selected_pet.name.to_sym) # remove the pet from clients pet list\n\n return selected_pet\n end", "def pets_by_breed(shop, type)\n pets = []\n for pet in shop[:pets]\n if pet[:breed] == type\n pets.push(pet)\n end\n end\n return pets\nend", "def pets_by_breed(pets, pet_breed)\n result = []\n for breed in pets[:pets]\n if breed[:breed] == pet_breed\n result.push(breed)\n end\n end\n return result\nend", "def list_pets\n \"I have #{pets[:fishes].count} fish, #{pets[:dogs].count} dog(s), and #{pets[:cats].count} cat(s).\"\n end", "def list_pets\n \"I have #{pets[:fishes].count} fish, #{pets[:dogs].count} dog(s), and #{pets[:cats].count} cat(s).\"\n end", "def pets_by_breed(pet_shop, supplied_breed)\n saved_breeds = []\n for pet in pet_shop[:pets]\n saved_breeds.push(pet) if pet[:breed] == supplied_breed\n end\n return saved_breeds\nend", "def list_pets\n return \"I have #{@pets[:fishes].count} fish, #{@pets[:dogs].count} dog(s), and #{@pets[:cats].count} cat(s).\"\n end", "def pets_by_breed(pet_shop, pet_type)\n pet_type_array = []\n for pet in pet_shop[:pets]\n if pet_type == pet[:breed]\n pet_type_array.push(pet)\n end\n end\n return pet_type_array\nend", "def pets_by_breed(pet_shop,pet_breed)\n breeds = []\n for pet in pet_shop[:pets]\n if pet[:breed].include?(pet_breed)\n breeds.push(pet[:breed])\n end\n end\n return breeds\nend", "def list_pets\n dog_n = self.pets[:dogs].size\n cat_n = self.pets[:cats].size\n fish_n = self.pets[:fishes].size\n\n \"I have #{fish_n} fish, #{dog_n} dog(s), and #{cat_n} cat(s).\"\n #self.pets.each do |key,value|\n \n end", "def list_pets\n # if @pets[:cats].size == 1\n # @catplural = \"\"\n # else\n # @catplural = \"'s\"\n # end\n # if @pets[:dogs].size == 1\n # @dogplural = \"\"\n # else\n # @dogplural = \"'s\"\n # end\n # \"I have #{pets[:fishes].size} fish, #{pets[:dogs].size} dog#{@dogplural}, and #{pets[:cats].size} cat#{@catplural}.\"\n \"I have #{pets[:fishes].size} fish, #{pets[:dogs].size} dog(s), and #{pets[:cats].size} cat(s).\"\n end", "def pets_by_breed(shop, breed)\n pet_breed = []\n pets = shop[:pets]\n for pet in pets\n if pet[:breed] == breed\n pet_breed.push(pet)\n end\n end\n return pet_breed\nend", "def sell_pet_to_customer(shop, pet, customer)\n for animal in shop[:pets]\n if animal == pet && customer_can_afford_pet(customer, pet) == true\n remove_customer_cash(customer, pet[:price])\n add_or_remove_cash(shop, pet[:price])\n increase_pets_sold(shop,1)\n add_pet_to_customer(customer, pet)\n remove_pet_by_name(shop, pet)\n end\n end\nend", "def pets_by_breed(pet_shop, type)\n\n counter = []\n\n for pet in pet_shop[:pets]\n if pet[:breed] == type\n counter.push(pet)\n end\n end\n return counter\nend", "def list_pets\n \"I have #{@pets[:fishes].count} fish, #{@pets[:dogs].count} dog(s), and #{@pets[:cats].count} cat(s).\"\n end", "def pets_by_breed(shop, breed_to_count)\n selected_breed = []\n for pet in shop[:pets]\n if pet[:breed] == breed_to_count\n selected_breed << pet[:breed]\n end\n end\n return selected_breed\nend", "def buy_dog(name)\n#know sabout its dogs\n pets[:dogs] << Dog.new(name)\n end", "def pets_by_breed(pet_shop, breed_type)\n breed = []\n for pet in pet_shop[:pets]\n if pet[:breed] == breed_type\n breed.push(pet) #add pet to breed array\n end\n end\n return breed #do not return count as this called in the test\nend", "def sell_pet_to_customer(shop,pet,customer)\n if pet != nil && customer_can_afford_pet(customer,pet) == true\n for animal in shop[:pets]\n if animal[:name] == pet[:name]\n amount = pet[:price]\n add_pet_to_customer(customer,pet)\n customer_pet_count(customer)\n increase_pets_sold(shop,1)\n remove_customer_cash(customer,amount)\n add_or_remove_cash(shop,amount)\n end\n end\n end\nend", "def pets_by_breed(pet_shop, breed)\n pets = [] # reminding myself again that the empty array will include the amount it has counted when searched\n for pet in pet_shop[:pets]\n if pet[:breed] == breed \n pets << pet\n end \n end\n #two ends because you are closing out the for and if\n return pets\nend", "def pets_by_breed(pet_shop, breed)\n # breeds = []\n # for pet in @pet_shop[:pets]\n # if breed == pet[:breed]\n # breeds.push(pet)\n # end\n # end\n # return breeds\n #need to refactor this tonight\nend", "def remove_pet_by_name(animal, past_animal)\n for pet in animal[:pets]\n if pet[:name] == past_animal\n return animal[:pets].delete(pet)\n end\n end\nend", "def mediterranean_ingredients\n\n mediterranean_list = shopping_list.select {|key, value| [:protein, :dairy, :fruits, :vegetables, :grains].include? key}\n mediterranean_list[:protein][:meat].pop\n mediterranean_list[:protein][:other] = [\"nuts\"]\n mediterranean_list[:dairy].delete(\"milk\")\n mediterranean_list\nend", "def play_with_cats\n pets[:cats].each do |cat|\n cat.mood = \"happy\"\n end\n end", "def pets_by_breed(shop, breed)\n pets_array = []\n for pet in shop[:pets]\n pets_array.push(pet) if pet[:breed] == breed\n end\n return pets_array\nend", "def play_with_cats\n @pets[:cats].each { |cat| cat.mood = \"happy\"}\n end", "def remove_pet_by_name(pet_shop, name)\n for pet in pet_shop[:pets]\n if pet[:name] == name\n p pet_shop[:pets].delete(pet)\n end\n end\nend", "def get_pet_list_by_client_id(client_id)\n pet_list = []\n for pet in get_data(\"pets\")\n if client_id == pet[\"client_id\"]\n pet_list.push(pet)\n end\n end\n\n return pet_list\n end", "def adopt_pet_from_shelter(animal_name, animal_instance_name, shelter_instance_name)\n @number_of_pets = @number_of_pets + 1\n @pets[animal_name] = animal_instance_name\n shelter_instance_name.animals.delete(animal_name)\n end", "def find_pet_by_name(pet_shop, name)\n pets = pets\n for pet in pet_shop[:pets]\n if pet[:name] == name\n pets = pet\n nil\n end\n end\n return pets\nend", "def for_adoption(animal)\n @pets_list.pop(animal)\n end", "def play_with_cats\n self.pets[:cats].each do |cat|\n cat.mood = \"happy\"\n end\n end", "def walk_dogs\n self.pets[:dogs].map do |dogs|\n dogs.mood = \"happy\"\n end\n end", "def list_pets\n \"I have #{self.dogs.count} dog(s), and #{self.cats.count} cat(s).\"\n end", "def list_pets\n \"I have #{self.dogs.count} dog(s), and #{self.cats.count} cat(s).\"\n end", "def shelter_pets(options = {})\n defaults = {'id' => 1}\n options = defaults.merge(options)\n \n @petfinder.shelter_pets(options['id'], options)\n end", "def list_pets\n \"I have #{self.pets[:fishes].length} fish, #{self.pets[:dogs].length} dog(s), and #{self.pets[:cats].length} cat(s).\"\n end", "def remove_pet_by_name(shops, animal)\n for pet in shops[:pets]\n if pet[:name] == animal\n shops[:pets].delete(pet)\n end\n end\nend", "def remove_pet_by_name(pet_shop, pet_name)\n for pet in pet_shop[:pets]\n pet_shop[:pets].delete(pet) if pet[:name] == pet_name\n end\nend", "def list_pets \n \"I have #{self.dogs.count} dog(s), and #{self.cats.count} cat(s).\"\n end", "def play_with_cats\n#makes each of the cat's moods happy when played with\n pets[:cats].each do |cat|\n cat.mood = \"happy\"\n end\n end", "def pets_by_breed(pet_shop,breed)\n breed_array = Array.new\n for pet in pet_shop[:pets]\n pet[:breed] == breed ? breed_array << pet[:breed] : false\n end\n return breed_array\nend", "def pets_by_breed(shop, breed_name)\n breed_name_array = []\n for pet in shop[:pets]\n if pet[:breed] == breed_name\n breed_name_array.push(pet)\n end\n end\n return breed_name_array\nend", "def remove_pet_by_name(pet_shop, pet_name)\n for pet in pet_shop[:pets]\n if pet[:name] == pet_name\n pet_shop[:pets].delete(pet)\n end\n end\nend", "def remove_pet_by_name(pet_shop, pet_name)\n for pet in pet_shop[:pets]\n if pet[:name] == pet_name\n pet_shop[:pets].delete(pet)\n end\n end\nend", "def remove_pet_by_name(pet_shop, name)\n for pet in pet_shop[:pets]\n if pet[:name] == name\n pet_shop[:pets].delete(pet)\n end\n end\nend", "def remove_pet_by_name (pet_shop, pet_name)\n for pet in pet_shop[:pets]\n if pet_name == pet[:name]\n pet[:name].delete!(pet_name)\n end\n end\nend", "def sell_pet_to_customer(pet_shop, pet, customer)\n for l_pet_shop in pet_shop[:pets]\n if l_pet_shop == pet\n if customer_can_afford_pet(customer, pet) == true\n remove_customer_cash(customer, pet[:price])\n add_or_remove_cash(pet_shop, pet[:price])\n add_pet_to_customer(customer, pet)\n increase_pets_sold(pet_shop, 1)\n end\n end\n end\nend", "def list_pets\n @owner.dogs.count\n @owner.cats.count\n end", "def good_pokemon # :not_very_effective AND :no_effect_on\n good_pokemon = []\n @type.not_very_effective.each {|pokemon| good_pokemon << pokemon}\n @type.no_effect_on.each {|pokemon| good_pokemon << pokemon if !good_pokemon.include?(pokemon)}\n \n if good_pokemon.count > 0\n puts \"\"\n puts \"USE POKEMON OF THESE TYPE(S)\"\n good_pokemon.each_with_index {|pokemon, index| puts \"#{index +1}. #{pokemon.name}\"}\n end\n end", "def remove_pet_by_name(pet_shop, pet_name)\n for item in pet_shop[:pets]\n if item[:name] == pet_name\n pet_shop[:pets].delete(item)\n end\n end\nend", "def remove_pet_by_name(shop, name)\n for pet in shop[:pets]\n return pet.delete(:name) if name == pet[:name]\n end\nend", "def adopt_pet(animal)\n @pets_list.push(animal)\n end", "def list_cats\n Cat.all.each_with_index do |kitty, i| \n puts \"\\n#{i + 1}. #{kitty.name} 🐈\"\n ##### if no owner\n if kitty.owner.nil?\n puts \"Breed: #{kitty.breed} | Color: #{kitty.color.capitalize}\"\n puts \"Food preference: #{kitty.favorite_food.capitalize} | Gets along with other cats? #{kitty.temperament.to_s.capitalize}\"\n puts \"\\n----------------------------------------------------------------------------\"\n ##############\n else\n puts \"Owner: #{kitty.owner.name}\"\n puts \"Breed: #{kitty.breed} | Color: #{kitty.color.capitalize}\"\n puts \"Food preference: #{kitty.favorite_food.capitalize} | Gets along with other cats? #{kitty.temperament.to_s.capitalize}\"\n puts \"\\n----------------------------------------------------------------------------\"\n end\n end\n end", "def sell_pet_to_customer(pet_shop, pet_to_sell, customer)\n for pet_for_sale in pet_shop[:pets]\n if pet_for_sale[:name] == pet_to_sell\n customer[:pets].push(pet_to_sell)\n pet_shop[:admin][:pets_sold] += 1\n customer[:cash] -= pet_to_sell[:price]\n pet_shop[:admin][:total_cash] += pet_to_sell[:price]\n end\n end\nend", "def dogs\n collection_of_dogs = []\n Dog.all.each do |dog|\n if dog.owner == self\n collection_of_dogs << dog\n end \n end \n return collection_of_dogs\n end", "def remove_pet_by_name(pet_shop, supplied_name)\n for pet in pet_shop[:pets]\n pet_shop[:pets].delete(pet) if supplied_name == pet[:name]\n end\nend", "def remove_pet_by_name(pet_shop, pet_name)\n\n for remove_pet in pet_shop[:pets]\n if remove_pet[:name] == pet_name\n pet_shop[:pets].delete(remove_pet)\n # Needs to look at :pets within pet_shop to delete.\n end\n end\nend", "def find_pet_by_name(pet_shop, pet_name)\n\n for pets in pet_shop[:pets]\n\n if pets[:name] == pet_name\n\n\n return pets\n\n end\n end\n\n return\n end", "def sell_pet_to_customer(petshop,name,customer)\n for pet in petshop[:pets]\n if pet[:name] == name\n customers[:pets].push(pet)\n petshop[:admin][:pets_sold].push(pet)\n sold[:admin][:total_cash] += amount\n end\n end\n return nil\nend", "def customers_affordable_pets(pet_shop_details,customer)\n affordable_pets = []\n for pet in pet_shop_details[:pets]\n if can_customer_afford_pet?(customer,pet)\n affordable_pets.push(pet)\n end\n end\n return affordable_pets\nend", "def pets_by_breed(shop, breed)\n count = []\n for pet in shop[:pets]\n if pet[:breed] == breed\n then count << pet\n end\n end\n return count\nend", "def buy_dog(name)\n pets[:dogs] << Dog.new(name)\n end", "def remove_pet_by_name(pets, name)\n return pets[:pets].delete_if {|pets| name == name }\nend", "def play_with_cats\n @pets[:cats].each {|cat| cat.mood = \"happy\"} \n end", "def pets_by_breed(shop, breed)\n matched_breeds = {}\n matched_breeds = shop[:pets].keep_if{|shop_pets| shop_pets[:breed] == breed}\n return matched_breeds\nend", "def pets_by_breed(pet_shop, breed)\n breed_total = []\n for item in pet_shop[:pets]\n if item[:breed] == breed # was returning an array of 6 of the same breed in an array because I accidentally used a single = operator\n breed_total.push(item[:breed])\n end\n end\n return breed_total\nend", "def get_pets\n if @pet_arr == []\n pet_info = \"No pets in system.\"\n else\n pet_info = @pet_arr.inject(\"\") do |pet_info_str, animal|\n pet_info_str << \"#{animal.name_str.capitalize} (#{animal.species_str}) \"\n end\n end\n return pet_info\n end", "def pets_owned (x)\n @pets.push (x)\n end", "def buy_cat(cat_name)\n cat = Cat.new(cat_name)\n self.pets[:cats] << cat\n\n end", "def buy_dog(dog_name)\n dog = Dog.new(dog_name)\n self.pets[:dogs] << dog\n end", "def sell_pet_to_customer(shop, pet, customer)\n if find_pet_by_name(shop, pet) != nil\n then\n if customer_can_afford_pet(customer, pet)\n then\n add_pet_to_customer(customer, pet)\n # remove_pet_by_name(shop, pet)\n increase_pets_sold(shop, 1)\n remove_customer_cash(customer, pet[:price])\n add_or_remove_cash(shop, pet[:price])\nend\nend\nend", "def walk_dogs\n self.pets[:dogs].each do |dog|\n dog.mood = \"happy\"\n end\n end", "def buy_cat(name)\n #knows about its cats\n pets[:cats] << Cat.new(name)\n end", "def unadopted_pet_urls_from_doc(doc)\n pet_names = pet_names_from_doc(doc)\n pet_urls = pet_urls_from_doc(doc)\n pets_hash = Hash[pet_names.zip (pet_urls)]\n pets_hash.map do |name, url|\n pets_hash.delete_if {|name, url| name =~/Adopted/i}\n end\n pets_hash.values\n end", "def walk_dogs\n self.pets.each do |family, type|\n if family.to_s == \"dogs\"\n type.each do |individual|\n individual.mood = \"happy\"\n end\n end\n end\nend", "def remove_pet_by_name(pet_shop, name)\n pet_shop[:pets].each do |pet|\n pet_shop[:pets].delete(pet) if pet[:name] == name\n end\n end" ]
[ "0.7942787", "0.77901405", "0.77847093", "0.75183535", "0.74559134", "0.7317256", "0.7304654", "0.72911704", "0.72751087", "0.7241007", "0.71527725", "0.71185917", "0.69585556", "0.6837484", "0.65689373", "0.6440744", "0.64276016", "0.64176714", "0.63490415", "0.6338492", "0.6279028", "0.6185308", "0.6152123", "0.61348915", "0.61142445", "0.6107789", "0.609027", "0.609027", "0.6043351", "0.60367984", "0.60304856", "0.6022347", "0.60194296", "0.59783", "0.59669566", "0.5946089", "0.5942821", "0.5921106", "0.58994246", "0.5887891", "0.58679837", "0.5830615", "0.5815788", "0.5807664", "0.57815236", "0.5768356", "0.5763386", "0.57600474", "0.57396966", "0.57388747", "0.5733999", "0.57336634", "0.5727728", "0.57136095", "0.5712423", "0.5706137", "0.57011425", "0.57011425", "0.56809145", "0.5679823", "0.56775886", "0.56753856", "0.5656917", "0.5654499", "0.5631924", "0.56289387", "0.56207603", "0.56207603", "0.56117815", "0.56102896", "0.56089014", "0.55986905", "0.5588459", "0.5574783", "0.55739176", "0.55644053", "0.55531627", "0.5542526", "0.5530496", "0.552374", "0.55174905", "0.5511196", "0.551084", "0.55056626", "0.54998475", "0.5492522", "0.54682755", "0.54672045", "0.5466109", "0.5453414", "0.5450223", "0.54367244", "0.5432247", "0.5431122", "0.5428631", "0.5424826", "0.54197985", "0.5406026", "0.5404622", "0.5401576" ]
0.77688175
3
Laina.walk_dogs, then all dogs' moods == "happy"
def walk_dogs Dog.all.each do |dog| if dog.owner == self dog.mood = "happy" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def walk_dogs\n Dog.all.collect do |dogs|\n dogs.mood=\"happy\"\n end\n end", "def walk_dogs\n self.dogs.each {|dog| dog.mood = \"happy\"}\n end", "def walk_dogs\n\n self.dogs.each do |dog|\n dog.mood = \"happy\"\n end\n end", "def walk_dogs \n self.dogs.each do |dog|\n dog.mood = \"happy\"\n end \n end", "def walk_dogs\n self.dogs.each{|dog|\n dog.mood = \"happy\"\n }\n end", "def walk_dogs\n self.pets.each do |family, type|\n if family.to_s == \"dogs\"\n type.each do |individual|\n individual.mood = \"happy\"\n end\n end\n end\nend", "def walk_dogs\n @pets[:dogs].each { |dog| dog.mood = \"happy\"}\n end", "def walk_dogs\n dogs.map {|dog| dog.mood = \"happy\"}\n end", "def walk_dogs\n self.pets[:dogs].each do |dog|\n dog.mood = \"happy\"\n end\n end", "def walk_dogs\n pets[:dogs].each do |dog|\n dog.mood = \"happy\"\n end\n end", "def walk_dogs\n @pets[:dogs].each {|dog| dog.mood = \"happy\"}\n end", "def walk_dogs\n @pets[:dogs][0].mood=(\"happy\")\n end", "def walk_dogs\n self.pets[:dogs].map do |dogs|\n dogs.mood = \"happy\"\n end\n end", "def walk_dogs\n dogs.each do |dog|\n dog.mood = \"happy\"\n end\nend", "def walk_dogs #walks the dogs which makes the dogs' moods happy\n # dog = Dog.new(\"Daisy\")\n # owner.pets[:dogs] << dog\n # owner.walk_dogs\n # expect(dog.mood).to eq(\"happy\")\n pets[:dogs].each do |dog|\n dog.mood = \"happy\"\n end\n end", "def walks\n Walk.all.select { |walk_instance| walk_instance.dog == self }\n end", "def walks\n Walk.all.select {|walk_instance| walk_instance.dog_walker == self}\n end", "def happy_walker?\n @dog_walker.favorite_breed == @dog.breed \n end", "def mood\n \tself.happiness > self.nausea ? \"happy\" : \"sad\" if self.happiness && self.nausea\n end", "def mood\n\t\tself.nausea < self.happiness ? mood = \"happy\" : mood = \"sad\"\n\tend", "def mood\n if self.nausea && self.happiness\n self.nausea > self.happiness ? (return \"sad\") : (return \"happy\")\n end\n end", "def mood\n if self.happiness && self.nausea\n self.happiness > self.nausea ? \"happy\" : \"sad\"\n end\n end", "def play_with_cats\n#makes each of the cat's moods happy when played with\n pets[:cats].each do |cat|\n cat.mood = \"happy\"\n end\n end", "def mood\n if nausea && happiness\n self.nausea > self.happiness ? \"sad\" : \"happy\" \n end\n end", "def mood\n self.happiness > self.nausea ? \"happy\" : \"sad\"\n end", "def dogs \n dogs = self.walks.map {|walk| walk.dog}\n dogs.uniq\n end", "def mood\n if self.nausea > self.happiness\n \"sad\"\n else\n \"happy\"\n end\n end", "def mood\n if self.happiness < self.nausea\n \"sad\"\n else\n \"happy\"\n end\n end", "def walk \n puts \"Hmm.. not in a mood to walk...\"\n super # parent 'walk' method\n end", "def mood\n #it \"has a method 'mood' that returns 'happy' when the user is more happy than nauseous\" do\n if self.happiness && self.nausea\n if self.happiness > self.nausea\n \"happy\"\n #it \"has a method 'mood' that returns 'sad' when the user is more nauseous than happy\" do\n elsif self.happiness < self.nausea\n \"sad\"\n end\n end\n end", "def play_with_cats\n self.pets[:cats].each do |cat|\n cat.mood = \"happy\"\n end\n end", "def walks_for_game(game)\n atbats = game.atbats.select {|atbat| atbat.pitcher_id == gameday_id.to_i}\n w_atbats = atbats.select {|atbat| atbat.ball == 4} \n w_atbats.size\n end", "def play_with_cats\n @pets[:cats].each { |cat| cat.mood = \"happy\"}\n end", "def play_with_cats\n pets[:cats].each do |cat|\n cat.mood = \"happy\"\n end\n end", "def mood \n if self.happiness && self.nausea\n mood = self.happiness - self.nausea\n mood > 0 ? \"happy\" : \"sad\"\n end\n end", "def play_with_cats\n @pets[:cats].each {|cat| cat.mood = \"happy\"} \n end", "def mood\n if self.happiness && self.nausea\n mood = self.happiness - self.nausea\n mood > 0 ? \"happy\" : \"sad\"\n end\nend", "def mood room = nil, mood = nil, debug = false\n success = false\n debug and ( p 'Executing mood: ' + mood + ' in room: ' + room )\n rooms = self.class.get_rooms self.get_config\n # support for setting a mood in all rooms (recursive)\n if room == 'all'\n debug and ( p 'Processing all rooms...' )\n rooms.each do | config, each_room |\n room = each_room['name']\n debug and ( p 'Room is: ' + room )\n success = self.mood room, mood, debug\n sleep 1\n end\n success = true\n # process single mood\n else\n if rooms[room] and mood\n if rooms[room]['mood'][mood]\n command = self.command rooms[room], nil, rooms[room]['mood'][mood]\n debug and ( p 'command is ' + command )\n self.raw command\n success = true\n # support for special \"moods\" via device looping\n elsif mood[0,3] == 'all'\n state = mood[3..-1]\n debug and (p 'Selected state is: ' + state)\n rooms[room]['device'].each do | device |\n p 'Processing device: ' + device[0].to_s\n self.send room, device[0]['name'], state, debug\n sleep 1\n end\n success = true\n end\n else\n STDERR.puts self.usage( room );\n end\n end\n success\n end", "def walk\n return false if (@captives > 0 and captives_close and warrior.feel(get_bomb_direction).captive?) or # Captives needs to be rescued, dont walk away\n count_unit_type(:Sludge) > 5\n message = nil\n walk_to = nil\n if check_for_a_bomb and @bomb_optimal_direction != false\n message = \"Walking to captive with the bomb optimal direction to direction #{@bomb_optimal_direction}\"\n walk_to = @bomb_optimal_direction\n elsif @captives > 0 and check_for_a_bomb and !warrior.feel(:forward).enemy?\n message = \"Walking to get the captive with a bomb to direction #{get_bomb_direction}\"\n walk_to = get_bomb_direction\n elsif @captives > 0 and warrior.look(:forward)[1].to_s.to_sym == :\"Thick Sludge\" and count_unit_type(:\"Thick Sludge\") > 1\n message = \"Walking to avoid sludges to direction #{@captives_direction[0]}\"\n walk_to = :right\n elsif @enemies_binded < 3 and @captives > 0 and !enemies_close\n message = \"Walking to rescue captives to direction #{@captives_direction[0]}\"\n walk_to = @captives_direction[0]\n elsif !under_attack and warrior.listen.empty?\n message = \"Walking to the stairs to direction #{warrior.direction_of_stairs}\"\n walk_to = warrior.direction_of_stairs\n elsif !under_attack and !enemies_close\n message = \"Walking to closest unit to direction #{warrior.direction_of(warrior.listen.first)}\"\n walk_to = warrior.direction_of(warrior.listen.first)\n end\n if walk_to != nil\n if message != nil\n puts message\n end\n return warrior.walk! walk_to\n end\n return false\n end", "def feed_fish\n self.pets[:fishes].each do |fish|\n fish.mood = \"happy\"\n end\n end", "def dog_walkers # ex: dog_instance.dog_walkers\n dog_walkers_array = self.walks.map { |walk_instance| walk_instance.dog_walker }\n dog_walkers_array.uniq\n end", "def list_all_animals(shelter)\n\n if shelter.animals.any?\n puts \"*** List of all animals ***\"\n shelter.animals.each do |key, x|\n puts \"Name: #{x.name}, Breed: #{x.breed}, Gender: #{x.gender}, Age: #{x.age}, Toys: #{x.toys.join(', ')}, Adoption: #{x.adoption}\"\n end\n else\n puts \"We have no animals left!\"\n end\n\nend", "def mood\n if !nausea || !happiness\n return \"\"\n elsif nausea >= happiness\n return \"sad\"\n elsif happiness > nausea\n return \"happy\"\n end\n end", "def poisonAllPokemon(event=nil)\n for pkmn in $Trainer.ablePokemonParty\n next if pkmn.hasType?(:POISON) || pkmn.hasType?(:STEEL) ||\n pkmn.hasAbility?(:COMATOSE) || pkmn.hasAbility?(:SHIELDSDOWN) || pkmn.hasAbility?(:IMMUNITY)\n pkmn.status!=0\n pkmn.status = 2\n pkmn.statusCount = 1\n end\nend", "def explore\n while (target = search_unknown)\n # puts \"PATH: #{target.inspect}\"\n target.each do |dir|\n output = @vm.run(input: [dir]).first\n case output\n when 0 # droid hits wall\n @map.set(@droid.move(dir), Map::WALL)\n when 1 # droid moved into an empty space\n @droid = @droid.move(dir)\n @map.set(@droid, Map::NOTHING)\n when 2 # droid moved into a space containing oxygen\n @droid = @droid.move(dir)\n @map.set(@droid, Map::OXYGEN)\n end\n end\n end\n end", "def learnmood room = nil, mood = nil, debug = false\n debug and ( p 'Learning mood: ' + mood )\n rooms = self.class.get_rooms self.get_config\n if rooms[room] and mood and rooms[room]['learnmood'][mood]\n command = self.command rooms[room], nil, rooms[room]['learnmood'][mood]\n debug and ( p 'command is ' + command )\n self.raw command\n else\n STDERR.puts self.usage( room )\n end\n end", "def check_for_long_walks itineraries\n\n filtered = []\n replaced = false\n itineraries.each do |itinerary|\n\n ### Check to see where the long walks are\n legs = itinerary.get_legs\n\n first_leg = legs.first\n last_leg = legs.last\n\n multiple_long_walks = false\n long_first_leg = false\n long_last_leg = false\n\n if first_leg.mode == 'WALK' and first_leg.duration > Oneclick::Application.config.max_walk_seconds\n long_first_leg = true\n end\n\n if last_leg.mode == 'WALK' and last_leg.duration > Oneclick::Application.config.max_walk_seconds\n long_last_leg = true\n end\n\n if long_last_leg and long_first_leg\n multiple_long_walks = true\n end\n\n unless multiple_long_walks\n legs[1...-1].each do |leg|\n if leg.mode == 'WALK' and leg.duration > Oneclick::Application.config.max_walk_seconds and (long_first_leg or long_last_leg)\n multiple_long_walks = true\n break\n end\n end\n end\n\n filtered << itinerary\n\n end\n\n filtered\n end", "def feed_fish\n pets[:fishes].each do |fish|\n fish.mood = \"happy\"\n end\n end", "def walk\n if @legs > 0\n @speed = @speed + (0.2 * @legs)\n else\n raise TypeError, \"This dog don't exist.\"\n end\n end", "def mood\n unless admin\n happiness > nausea ? 'happy' : 'sad'\n end\n end", "def feed_cats\n self.cats.each {|c| c.mood = \"happy\"}\n end", "def feed_cats\n self.cats.each do |cat|\n cat.mood = \"happy\"\n end \n end", "def test_mood6\n assert_equal @p.mood?([100, 0]), 'victorious!'\n end", "def feed_fish\n @pets[:fishes].each {|fish| fish.mood = \"happy\"}\n end", "def underdog\n\t if home_team != favorite\n\t home_team\n\t else\n\t visitor_team\n\t end\n\tend", "def my_followers_mottos\n Bloodoath.all.each do |bloodoath|\n if bloodoath.cult == self\n puts bloodoath.follower.life_motto\n end\n end\n end", "def all_judge\n #defensive check for rappers in the stage\n unless self.stage.is_full\n raise \"stage must be full to make everyone a judge\"\n end\n # makes the booth seats point to the audience\n @audience.all_judge # method in the audience class that makes everyone a judge\n @booth.booth_seats = @audience.seating #might need to add them all to queue foirst, hopefuly this way of skipping that doesnt cause issues\n end", "def check_the_check\n self.find_attacks(\"white\")\n self.find_attacks(\"black\")\n self.find_king_in_check\n end", "def map(olympians)\n only_athletes=[]\n for x in olympians\n if x[:event] == \"Swimming\"\n only_athletes.push(x)\n end\nend\nreturn only_athletes\nend", "def feed_fish\n @pets[:fishes].each { |fish| fish.mood = \"happy\"}\n end", "def walk()\r\n @warrior.walk!\r\n end", "def walk()\r\n @warrior.walk!\r\n end", "def walk\n if @awake != true\n puts \"Wake up, #{@name}. It's time for a walk.\"\n @awake = true\n end #end of conditional to wake up and go out\n\n if @food_in_intestine > 50\n @food_in_intestine = 0\n puts \"#{@name} pooped.\"\n else\n puts \"#{@name} sniffs around, but doesn't do business.\"\n end #end of conditional for pooping on walk\n time_passed\nend", "def test_mood2\n assert_equal @p.mood?([1, 0]), 'sad.'\n end", "def feed_cats\n Cat.all.collect do |cats|\n cats.mood=\"happy\"\n end\n end", "def likes_to_eat(person, food)\n\n for x in person[:favourites][:snacks]\n if x == food\n return true\n end\n end\n return false\nend", "def walk; end", "def eat\n @hungry = false\n end", "def eat\n @hungry = false\n end", "def eat\n @hungry = false\n end", "def dog_eat(items)\n \t items.each do |item|\n \t\t puts \"My puppy likes #{item}\"\n \t end\n end", "def all_gyms\n Membership.all.map do |membership| \n if membership.lifter == self\n membership.gym\n end\n end\n end", "def adoption_list(shelter)\n\n if shelter.animals.any?\n puts \"*** List of animals available for adoption ***\"\n shelter.animals.each do |key, x|\n if x.adoption == \"y\"\n puts \"Name: #{key}, Breed: #{x.breed}, Gender: #{x.gender}, Age: #{x.age}, Toys: #{x.toys.join(', ')}, Adoption: #{x.adoption}\"\n end\n end\n else\n puts \"We have no animals left!\"\n end\n\nend", "def all_gyms\n lifter_membership.map {|lifter| lifter.gym}\n end", "def include_dog?\n animals = [\"cat\", \"elephant\", \"lion\", \"dog\", \"jaguar\", \"snake\"]\nend", "def feed_cats\n self.cats.each do |cat|\n cat.mood = \"happy\"\n end\n end", "def walk\n\t\tputs \"walking around\"\t\n\tend", "def test_mood4\n assert_equal @p.mood?([9, 0]), 'sad.'\n end", "def food_tastes(person, food)\n return person[:favourites][:things_to_eat].include?(food)\nend", "def they_here\n included = true\n new_animals = [\"Andean Cat\", \"Dodo\", \"Saiga Antelope\"]\n new_animals.each do |animal|\n @animal_array.each do |animal2|\n if animal == animal2\n included\n puts \"#{animal} is extinct\"\n else\n !included\n end\n end\n end\nend", "def test_mood5\n assert_equal @p.mood?([10, 0]), 'victorious!'\n end", "def all_howl\n @wolves.each { |wolf| wolf.howl }\n end", "def likes_to_eat(person, food)\nreturn person[:favourites][:snacks].include?(food)\nend", "def what_is thing\n $things[thing] && $things[thing].map{|t| what_is(t)}.flatten || [thing]\nend", "def like_food?(food, person)\n person[:favourites][:things_to_eat].include?(food)\nend", "def behavior_hungry\n @world.food.each do |food|\n if distance_from_point(food.position) < (food.quantity + ROID_SIZE*5)\n @delta -= self.position - food.position\n end \n if distance_from_point(food.position) <= food.quantity + 5\n eat food\n end \n end \n end", "def all_animals\n Animal.all.select do |animal| \n # binding.pry\n animal.zoo == self\n end\n end", "def test_mood1\n assert_equal @p.mood?([0, 0]), 'empty-handed.'\n end", "def bloodoaths\n BloodOath.all.select do |blood| \n blood.follower == self\n end\n end", "def find_people_around_football_pitch_around_jindigeling\n find_shops\nend", "def dogs\n Dog.doggies.select { |dogs| dogs.owner == self }\n end", "def dogs\nDog.all.find_all do |dog|\n dog.owner == self\nend\n\nend", "def all_gold_medal_winners(olympic_data)\n return gold_athletes = olympic_data.select {|athletes| athletes[\"Medal\"] == \"Gold\"}\nend", "def feed_cats\n cats.each do |cat|\n cat.mood = \"happy\"\n end\n end", "def feed_cats \n self.cats.each do |cat|\n cat.mood = \"happy\"\n end \n end", "def bloodoats \n BloodOath.all.select do |oat|\n oat.cult == self\n end\n end", "def happy?\n @happiness > 7 \n end", "def happy_unhappy_unhappiness\n # The distance between 'i' and 'y' is 0.5. The distance between and two\n # other non-equal phone pairs is 1. This ensures that 'i' and 'y' will tend\n # align with each other.\n happy_unhappy_phones =<<-EOTEXT\n FORM, LETTER, CLASS\n i, i, iy\n y, y, iy\n a, a, a\n e, e, e\n h, h, h\n n, n, n\n p, p, p\n s, s, s\n u, u, u\n EOTEXT\n phone_table = PhoneticAlign::PhoneTable.new(happy_unhappy_phones)\n # Phonetic sequences\n # Meanings\n un_meaning = PhoneticAlign::FeatureValueMatrix[:POL => :neg]\n happy_meaning = PhoneticAlign::FeatureValueMatrix[:LEMMA => :happy]\n ness_meaning = PhoneticAlign::FeatureValueMatrix[:POS => :noun]\n # Morphemes\n un_morph = PhoneticAlign::SurfaceMorpheme.new(un_meaning, phone_table.phone_sequence(\"un\"))\n happy_morph = PhoneticAlign::SurfaceMorpheme.new(happy_meaning, phone_table.phone_sequence(\"happy\"))\n happy_happi_morph = PhoneticAlign::SurfaceMorpheme.new(happy_meaning, phone_table.phone_sequence(\"happi\"), \n [phone_table.phone_sequence(\"happy\"),\n phone_table.phone_sequence(\"happi\")])\n ness_morph = PhoneticAlign::SurfaceMorpheme.new(ness_meaning, phone_table.phone_sequence(\"ness\"))\n # Words consisting of all phones.\n happy_p = PhoneticAlign::Word.new(phone_table.phone_sequence(\"happy\"), happy_meaning)\n unhappy_p = PhoneticAlign::Word.new(phone_table.phone_sequence(\"unhappy\"), un_meaning + happy_meaning)\n unhappiness_p = PhoneticAlign::Word.new(phone_table.phone_sequence(\"unhappiness\"), un_meaning + happy_meaning + ness_meaning)\n # Words consisting of phones and morphemes.\n unhappy_pm = PhoneticAlign::Word.new([un_morph] + phone_table.phone_sequence(\"happy\"), un_meaning + happy_meaning)\n # Words consisting of all morphemes\n happy_m = PhoneticAlign::Word.new([happy_morph], happy_meaning)\n unhappy_m = PhoneticAlign::Word.new([un_morph, happy_morph], un_meaning + happy_meaning)\n happy_happi_ness_m = PhoneticAlign::Word.new([happy_happi_morph, ness_morph], happy_meaning)\n unhappy_happi_ness_m = PhoneticAlign::Word.new([un_morph, happy_happi_morph, ness_morph], un_meaning + happy_meaning + ness_meaning)\n return Struct.new(:phone_table,\n :happy_p, :unhappy_p, :unhappiness_p,\n :unhappy_pm,\n :happy_m, :unhappy_m, :happy_happi_ness_m, :unhappy_happi_ness_m,\n :un_meaning, :happy_meaning, :ness_meaning).new(\n phone_table,\n happy_p, unhappy_p, unhappiness_p,\n unhappy_pm,\n happy_m, unhappy_m, happy_happi_ness_m, unhappy_happi_ness_m,\n un_meaning, happy_meaning, ness_meaning)\nend", "def fight_scene\n\tjason = PowerRanger.new(\"Jason\", \"Red\")\n\ttommy = PowerRanger.new(\"tommy\", \"Green\")\n\tjon = Person.new(\"Jon\")\n\thoward = Person.new(\"Howard\")\n\tevilGuy_a = EvilNinja.new(\"Evil Guy 1\")\n\tevilGuy_b = EvilNinja.new(\"Evil Guy 2\")\n\n\tputs \"Two innocent bystanders are attacked by evil ninjas.\"\n\tjon.scream\n\thoward.scream\n\tjon.run\n\thoward.drink_coffee\n\thoward.run\n\n\tputs \"The Power Rangers arrive!\"\n\tjason.punch(evilGuy_a)\n\ttommy.punch(evilGuy_b)\n\tjason.rest(2)\n\ttommy.drink_coffee\n\n\tputs \"The Evil Ninjas fight back.\"\n\tevilGuy_a.punch(tommy)\n\tevilGuy_b.punch(tommy)\n\tevilGuy_a.cause_mayhem(jason)\n\n\tputs \"The Power Rangers try Megazord\"\n\tjason.use_megazord(evilGuy_a)\n\tevilGuy_a.punch(jason)\n\n\tputs \"Cmon Tommy!\"\n\ttommy.use_megazord(evilGuy_a)\n\ttommy.drink_coffee(10)\n\ttommy.use_megazord(evilGuy_b)\n\n\tputs \"Did the Power Rangers save the day?\"\n\n\tninja_array = [evilGuy_a, evilGuy_b]\n\twin = \"yes\"\n\n\tninja_array.each do |ninja|\n\t\t# p ninja.show_caffeine_level\n\t\tif ninja.caffeine_level > 0\n\t\t\twin = \"no\"\n\t\tend\n\tend\n\n\tif win == \"yes\"\n\t\tputs \"Yes!\"\n\telse\n\t\tputs \"No :(.\"\n\tend\n\nend", "def find_alive(players)\n alive = []\n players.each do |player|\n alive << player if player[:is_shot] == false\n end\n alive.length\nend" ]
[ "0.7936932", "0.77647716", "0.7691516", "0.7673095", "0.76453155", "0.76043767", "0.7595616", "0.75860643", "0.75721794", "0.75654536", "0.75635475", "0.7462288", "0.737697", "0.70792484", "0.68411916", "0.6817402", "0.6563621", "0.642962", "0.617243", "0.61546737", "0.6144587", "0.6128202", "0.605799", "0.6056743", "0.59845245", "0.59807366", "0.59262884", "0.59198153", "0.59181875", "0.5835486", "0.5822835", "0.5792576", "0.57865834", "0.5781935", "0.5751759", "0.56655556", "0.56602615", "0.56133777", "0.5607809", "0.5457999", "0.53866315", "0.5385411", "0.53773344", "0.5366311", "0.53658557", "0.5364424", "0.53643763", "0.5359123", "0.5350841", "0.53506947", "0.5335448", "0.5331558", "0.53291893", "0.53244114", "0.53086025", "0.5307045", "0.5300467", "0.52844405", "0.52821445", "0.52686715", "0.52633864", "0.52633864", "0.5261731", "0.52511823", "0.52499545", "0.5242989", "0.5236249", "0.522487", "0.522487", "0.522487", "0.5216058", "0.5211425", "0.5204383", "0.52030635", "0.5202479", "0.51940376", "0.51936406", "0.5185753", "0.5171406", "0.51643074", "0.5163183", "0.51610976", "0.5140348", "0.5132994", "0.51305497", "0.51295376", "0.5113222", "0.51109064", "0.5102073", "0.50935006", "0.508449", "0.50816375", "0.5067484", "0.50625837", "0.50615484", "0.50601995", "0.5059171", "0.50517", "0.5040737", "0.50395674" ]
0.761721
5
ideal code: Dad.buy_cat("Captain") get Cat class makes new instance of that cat
def buy_cat(name) Cat.new(name, self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def buy_cat(name)\n new_cat = Cat.new(name, self)\nend", "def buy_cat(name)\n Cat.new(name, self)\nend", "def buy_cat(name)\n Cat.new(name,self)\n end", "def buy_cat(cat)\n new_cat = Cat.all.find do |cat_instance|\n cat_instance.name == cat \n end\n if new_cat \n Cat.new(new_cat.name, self)\n else \n brand_new_cat = Cat.new(cat, self)\n end \n end", "def buy_cat(name)\n Cat.new(name, self)\n end", "def buy_cat(name)\n Cat.new(name, self)\n end", "def buy_cat(name)\n Cat.new(name, self)\n end", "def buy_cat(name)\n Cat.new(name, self)\n end", "def buy_cat(cat_name)\n new_cat = Cat.new(cat_name, self)\n # self.cats << new_cat\n # binding.pry\n end", "def buy_cat(name)\n #passing a name and this owner object into the cat object\n cat = Cat.new(name, self) \n @cats << cat\n \n end", "def buy_cat(cat_name)\n self.cats << Cat.new(cat_name,self)\n end", "def buy_cat(cat_name)\n Cat.new(cat_name, self)\n end", "def buy_dog(dog_name)\n new_dog = Dog.new(dog_name, self)\nend", "def buy_cat(cat_name)\n cat = Cat.new(cat_name)\n self.pets[:cats] << cat\n\n end", "def buy_dog(dog_name)\n new_dog = Dog.new(dog_name, self)\n # tommy.buy_cat(\"Garfield\")\n end", "def buy_cat(name) # expect(owner.pets[:cats].count).to eq(0)\n new_cat = Cat.new(name) # owner.buy_cat(\"Crookshanks\")\n self.pets[:cats] << new_cat # owner.pets[:cats].each { |cat| expect(cat).to be_a(Cat) }\n new_cat # expect(owner.pets[:cats].count).to eq(1)\n # = knows about its cats; Owner knows all about its pets - Owner sets name of pet, the pet can\\'t change its name\n # owner.buy_cat(\"Crookshanks\")\n # expect(owner.pets[:cats][0].name).to eq(\"Crookshanks\")\n end", "def buy_dog(name)\n new_dog = Dog.new(name,self)\n end", "def buy_dog(name)\n Dog.new(name,self)\n end", "def buy_cat(name)\n cat = Cat.new(name)\n @pets[:cats] << cat\n end", "def buy_cat(name)\n #knows about its cats\n pets[:cats] << Cat.new(name)\n end", "def buy_cat(name)\n pets[:cats] << Cat.new(name)\n end", "def buy_dog(name)\n dog = Dog.new(name, self)\n end", "def buy_dog(name)\n Dog.new(name, self)\n end", "def buy_dog(name)\n Dog.new(name, self)\n end", "def buy_dog(dog)\n new_dog = Dog.all.find do |dog_instance|\n dog_instance.name == dog \n end\n if new_dog \n Dog.new(new_dog.name, self)\n else \n brand_new_dog = Dog.new(dog, self)\n end \n end", "def buy_dog(new_name)\n # @dogs << Dog.new(name, self)\n Dog.new(new_name, self)\n end", "def buy_dog(dog_name)\n self.dogs << Dog.new(dog_name,self)\n end", "def buy_dog(name)\n dog = Dog.new(name, self)\n @dogs << dog\n end", "def buy_dog(dog_name)\n dog = Dog.new(dog_name)\n self.pets[:dogs] << dog\n end", "def buy_dog(name)\n dog = Dog.new(name)\n @pets[:dogs] << dog\n end", "def buy_dog(name)\n#know sabout its dogs\n pets[:dogs] << Dog.new(name)\n end", "def buy_dog(name)\n pets[:dogs] << Dog.new(name)\n end", "def new\n @cat = Cat.new\n end", "def new\n @cat = Cat.new\n end", "def buy_fish(name)\n new_fish = Fish.new(name)\n if new_fish.class == Fish\n @pets[:fishes] << new_fish\n end \n end", "def make_bike\n new_bike = Bike.new\n new_bike.brand = self\n end", "def buy_fish(name)\n new_fish = Fish.new(name)\n self.pets[:fishes] << new_fish \n end", "def meow # Define a method that allows any instance of Cat to meow\n puts \"meow!\"\n end", "def new\n # category instance\n @category = Category.new\n end", "def buy_fish(name) # expect(owner.pets[:fishes].count).to eq(0)\n new_fish = Fish.new(name) # owner.buy_fish(\"Bubbles\")\n self.pets[:fishes] << new_fish # owner.pets[:fishes].each { |fish| expect(fish).to be_a(Fish)}\n new_fish # expect(owner.pets[:fishes].count).to eq(1)\n # = knows about its fishes; Owner knows all about its pets - Owner sets name of pet, the pet can\\'t change its name\n # owner.buy_fish(\"Bubbles\")\n # expect(owner.pets[:fishes][0].name).to eq(\"Bubbles\")\n end", "def category_new\n @finance_transaction_category = FinanceTransactionCategory.new\n end", "def new\n @cat = Category.new\n end", "def buy_fish(fish_name)\n fish = Fish.new(fish_name)\n self.pets[:fishes] << fish\n end", "def new\n @catogory = Catogory.new\n end", "def release_bike\n Bike.new\n end", "def buy_pet(pet)\n self.pets.push(pet)\n pet.owner = self\n end", "def set_cat\n @cat = Cat.find(params[:id])\n end", "def make_object klass\n obj = $manager.make_object klass\n inventory << obj if self.respond_to? :inventory\n obj\n end", "def buy_fish(name)\n pets[:fishes] << Fish.new(name)\nend", "def buy_fish(name)\n @pets[:fishes] << Fish.new(name)\n end", "def buy_fish(name)\n fish = Fish.new(name)\n @pets[:fishes] << fish\n end", "def buy_fish(name)\n fish = Fish.new(name)\n @pets[:fishes] << fish\n end", "def buy_fish(name)\n#knows about its fishes\n pets[:fishes] << Fish.new(name)\n end", "def new_objects\n @gadget = Gadget.new\n \n @allCategories = Category.order(\"id asc\").all.map{|u| [u.name, u.id]}\n end", "def set_cat\n @cat = Cat.find(params[:id])\n end", "def set_cat\n @cat = Cat.find(params[:id])\n end", "def add_cat(name_en, name_nl)\n c = Category.new(name_en: name_en, name_nl: name_nl)\n c.save!\nend", "def test_multiples_non_objectable_types_with_default_new_method\n cat1 = 'Amelia'\n cat2 = 'Gorbypuff'\n cats = [cat1, cat2]\n test_object = ObjTestClasses::TestObject.new(menagerie: cats)\n\n test_object.menagerie.each do |animal|\n assert_instance_of(ObjTestClasses::Cat, animal)\n end\n\n cats.each do |cat|\n assert_includes(test_object.menagerie, ObjTestClasses::Cat.new(cat))\n end\n end", "def new\n \t@category =Category.new\n end", "def new\n \t@category = Category.new\n end", "def new_changed_food(name)\n food = Food.new 'apple'\n food.name = 'potato'\n food\nend", "def create\n @cat = Cat.new(catparams)\n if @cat.save\n redirect_to @cat\n else\n render 'new'\n end\n end", "def create\n\t\t@cat = Cat.new(cat_params)\n\n\t\tif @cat.save\n\t\t\t# cat_url(@cat) == /cat/{@cat.id}\n\t\t\tredirect_to cat_url(@cat)\n\t\telse\n\t\t\trender :new\n\t\t\t# render json: @cat.errors.full_messages, status: :unprocessable_entity\n\t\tend \n\tend", "def new\n @category = Category.new(position: Category.current.count + 1)\n end", "def buy_fish(name)\n pets[:fishes] << Fish.new(name)\n end", "def new\n @o_single = Category.new\n end", "def find_cat\n @cat = Cat.find(params[:cat_id])\n end", "def new\n @game = Game.new\n @merchant = Merchant.new \n @character = Character.new\n end", "def new\n @drink = Drink.new\n end", "def new\n\t\t@category = Category.new\n\tend", "def new\n\t\t@category = Category.new\n\tend", "def set_category\n @category = GoodCategory.find(params[:id])\n end", "def set_cat_item\n @cat_item = CatItem.find(params[:id])\n end", "def new\n # brand instance\n @brand = Brand.new\n end", "def sell_pets\n pets = dogs + cats\n\n pets.each do |pet|\n pet.mood = \"nervous\"\n pet.owner = nil\n end\n end", "def add(beer)\n \t$catalogue << beer\n end", "def initialize(name, breed, owner_name)\n @name = name # this returns name of the dog\n @breed = breed # returns the breed classification\n @owner = Owner.new(owner_name, self) # returns Owner when #class is called on #owner \n end", "def generate_category\n category = Category.new\n category[:name] = Faker::Commerce.department\n category[:description] = Faker::Lorem.sentence\n category.save\nend", "def initialize(species, weight, nickname, zoo)\n @species = species\n @weight = weight\n @nickname = nickname\n @zoo = zoo\n @@all << self\n\n #everytime a new animal object is created, its shoveled into the Animal class\n\nend", "def create_drink(category, table_name, name, price, max_price, min_price, current_price, price_difference, bio)\n @bar.drinks.create(name: name, price: price, max_price: max_price, min_price: min_price, current_price: current_price, price_difference: price_difference, bio: bio, category: category,\n table_name: table_name)\n end", "def new\n @advert = @advert_class.new\n end", "def new\n @dish_in_basket = DishInBasket.new\n end", "def initialize(name)\n @name = name\n @@all << self # adds the new dog instance to the @@all array\n end", "def printCat(cat)\n puts cat.name \n puts cat.breed \n puts cat.poopSize \nend", "def category(id=nil)\n @category = Plaid::Category.new\n res = self.get('categories',id)\n id.nil? ? @category.instantiate_all_categories(res) : @category.instantiate_one_category(res)\n end", "def brand(klass)\n\t\tklass = klass.dup\n\t\tklass.client = self.client\n\t\treturn klass\n\tend", "def brand(klass)\n\t\tklass = klass.dup\n\t\tklass.client = self.client\n\t\treturn klass\n\tend", "def feed_cats \n self.cats.each do |cat|\n cat.mood = \"happy\"\n end \n end", "def get_animal(name)\n animal = nil\n\n if @type == \"cow\"\n animal = Cow.new name\n elsif @type == \"pig\"\n animal = Pig.new name\n end\n\n return animal\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def create_price \n Price.create_from_item(self)\n end", "def create(tag)\n klass = Class.new self\n klass.tag tag\n klass\n end", "def make_corpse\n if @@corpse_proto == nil\n @@corpse_proto = Tag.find_any_obj(\"do.not.change::corpse.prototype\")[0] # corpse prototype\n end\n # generate a new item based off of the corpse prototype.\n\n o = @@corpse_proto.instance # new corpse\n if ('A'..'Z') === short_desc[0]\n o.name = o.name % self.short_desc\n else\n o.name = o.name % self.short_desc.en.a\n end\n\n in_room.accept(o) # put the object in the same room.\n end" ]
[ "0.8603804", "0.844882", "0.8163699", "0.8059277", "0.7922411", "0.7922411", "0.7922411", "0.7922411", "0.7794786", "0.77737945", "0.7721542", "0.76968056", "0.7684081", "0.76199883", "0.7491412", "0.74529356", "0.7445323", "0.7405874", "0.73743445", "0.7327647", "0.72289234", "0.7211459", "0.72076833", "0.72076833", "0.71108407", "0.7052926", "0.6937382", "0.69348794", "0.6722296", "0.65464205", "0.6491091", "0.6410495", "0.6374722", "0.6374722", "0.62778634", "0.61080307", "0.6102755", "0.5932144", "0.5910713", "0.58619076", "0.58049464", "0.5802929", "0.58026135", "0.5783297", "0.57155097", "0.57039034", "0.5699254", "0.5689311", "0.56247306", "0.5607707", "0.55958813", "0.55958813", "0.5586529", "0.5568246", "0.5553768", "0.5553768", "0.55516124", "0.55475646", "0.5514596", "0.55060655", "0.5452473", "0.54445475", "0.5421941", "0.5416219", "0.5388028", "0.53868484", "0.5379709", "0.53487307", "0.53462976", "0.53445727", "0.53445727", "0.53238416", "0.53195035", "0.53154415", "0.5303612", "0.53034335", "0.5274023", "0.52699834", "0.5264315", "0.52530915", "0.5243467", "0.52314043", "0.5228266", "0.5222795", "0.52151513", "0.5214655", "0.5214655", "0.52123094", "0.5208965", "0.52013385", "0.52013385", "0.52013385", "0.52013385", "0.52013385", "0.52013385", "0.52013385", "0.52013385", "0.5201035", "0.51999986", "0.5198443" ]
0.7572495
14
Formulario General Para Cajones de Busquedad
def buscar(url,columnas) form_tag url, class: 'navbar-form navbar-right',method: 'get',role: "search" do content_tag :div , class: "form-group form-group-sm" do |div| array = [] array << text_field_tag(:search, params[:search], class:"form-control", style:"width:inherid",placeholder: "Buscar") array << select_tag(:sort ,options_for_select(columnas,params[:sort]), class: "form-control",style: "width:100px;") array << submit_tag("Buscar",class: 'btn btn-default btn-sm', :name => nil) array.join.html_safe end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multiples_facturas_confirmar_parciales\n @width_layout=1180\n @form_title = I18n.t('Sistema.Body.Modelos.OrdenDespachoDetalle.Mensajes.orden_despacho_insumos') \n @form_title_record = I18n.t('Sistema.Body.Modelos.OrdenDespachoDetalle.Mensajes.orden_despacho_insumo') \n end", "def comida_params\n params.require(:comida).permit(:dia, :fecha, :codigo, :menu, :tipo, :ciudad, :local, :cantidad, :precio)\n end", "def mi_carrera\n\n\tend", "def new\n @cegonha = Cegonha.new\n @editar_localizacao = params[:editar_localizacao]\n @cegonha.build_motorista\n\n\n\n if params[:cegonha_contratada]\n @cegonha.build_empresa\n @cegonha.build_pagamento\n\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cegonha }\n end\n end", "def camposDescarga(tipo_descarga=nil)\n checkbox = ''\n campos = { x_tipo_distribucion: 'Tipo de distribución', x_cat_riesgo: 'Categorías de riesgo y comercio internacional', x_ambiente: 'Ambiente', x_nombres_comunes: 'Nombres comunes', x_bibliografia: 'Bibliografía' }\n \n case tipo_descarga\n when 'basica'\n when 'avanzada'\n campos.merge!({ x_col_basicas: 'Columnas basicas', x_taxa_sup: 'Taxonomía superior', x_url_ev: 'URL de la especie en enciclovida' })\n when 'region'\n campos = { x_num_reg: 'Número de registros' }.merge(campos.merge!({ x_col_basicas: 'Columnas basicas', x_taxa_sup: 'Taxonomía superior', x_url_ev: 'URL de la especie en enciclovida' }))\n when 'checklist'\n campos.merge!({ x_estatus: 'Solo válidos/aceptados', x_distribucion: 'Distribución (reportada en literatura)', x_residencia: 'Categoría de residencia (aves)', x_formas: 'Formas de crecimiento (plantas)', x_interaccion: 'Interacciones biológicas' }) \n end\n \n campos.each do |valor, label|\n if valor.to_s == 'x_col_basicas'\n checkbox << check_box_tag('f_desc[]', valor, true, style: 'display: none;', id: \"f_#{tipo_descarga}_#{valor}\")\n else\n checkbox << \"<div class='custom-control custom-switch'>\"\n checkbox << check_box_tag('f_desc[]', valor, false, class: \"custom-control-input\", id: \"f_#{tipo_descarga}_#{valor}\")\n checkbox << \"<label class='custom-control-label' for='f_#{tipo_descarga}_#{valor}'>#{label}</label>\"\n checkbox << \"</div>\"\n end\n\n \n end\n\n checkbox.html_safe\n end", "def info_conta\n # CAMPO TAMANHO\n # agencia 3\n # conta corrente 7\n \"#{agencia}#{conta_corrente}\"\n end", "def view\n\t\n @width_layout=1180\n @form_title = I18n.t('Sistema.Body.Modelos.OrdenDespachoDetalle.Mensajes.orden_despacho_insumos') \n @form_title_record = I18n.t('Sistema.Body.Modelos.OrdenDespachoDetalle.Mensajes.orden_despacho_insumo') \n \t@orden_despacho = OrdenDespacho.find(params[:id])\n \t\n \t@sucursal_casa_proveedora = []\n \t@usuario = Usuario.find(session[:id])\n\n #nuevo codigo\n @solicitud1=Solicitud.find(@orden_despacho.solicitud_id)\n @usuario_auc = Usuario.find(:first, :conditions=>['nombre_usuario = ?',@solicitud1.usuario_pre_evaluacion])\n @usuario_select1 = Usuario.find(:first, :conditions=>['cedula in (select cedula from tecnico_campo ) and nombre_usuario = ? ', @solicitud1.usuario_pre_evaluacion], :order=>'primer_nombre, primer_apellido')\n #fin nuevo codigo\n \t@solicitudes = Solicitud.find(:all, :conditions => ['id = ? ', @orden_despacho.solicitud_id])\n\n\n \tunless @solicitudes[0].nil?\n \t if !@solicitudes[0].cliente.persona_id.nil? \n \t\t@es_no=1\n \t\t@datos_cliente=Persona.find(@solicitudes[0].cliente.persona_id) unless @solicitudes[0].nil?\n \telse\n \t\t@es_no=2\n \t\t@datos_cliente=Empresa.find(@solicitudes[0].cliente.empresa_id) unless @solicitudes[0].nil?\n \t end\n \tend\n\n @orden_despacho_detalle =OrdenDespachoDetalle.find(:all, :conditions=> ['orden_despacho_id = ?',@orden_despacho.id])\n\n \tlist(@orden_despacho.id)\n\n end", "def becario_params\n params.require(:becario).permit(:condonacion_beneficiarios,\n :cumple_requisitos, :numero_DI,\n :nombre, :apellido1, :apellido2,\n :fecha_nacimiento, :departamento_nacimiento,\n :genero, :email, :telefono,\n :direccion_residencial, :ciudad,\n :direccion_profesional, :info_beneficiario,\n :info_programa_doctoral, :info_tesis,\n :registro_pasantia)\n end", "def anulacion \n @solicitud=Solicitud.find(params[:id])\n @causal_select=CausalesAnulacionRevocatoria.find(:all,:conditions=>\"anulacion=true\",:order=>\"causa asc\")\n @width_layout = '660'\n end", "def info_conta\n # CAMPO TAMANHO\n # agencia 4\n # complemento 2\n # conta corrente 5\n # digito da conta 1\n # complemento 8\n \"#{agencia}#{codigo_beneficiario}#{''.rjust(uso_exclusivo_header, ' ')}\"\n end", "def nombr_comune_params\n params[:nombr_comune]\n end", "def comentarios_params\n params.require(:comentario).permit(:accion_id, :texto)\n end", "def detalle_reserva_params\n params.require(:about).permit(:cboOrigen, :cboDestino, :txtFechaSalida, :txtFechaRegreso, :cboAdultos, :cboMenores, :cboInfantes, :pers_nombreCompleto, :pers_correoElectronico, :pers_telefono, :tipo_mensaje, :msj_asunto, :msj_contenido)\n end", "def info_conta\n # CAMPO TAMANHO\n # agencia 4\n # digito agencia 1\n # conta corrente 8\n # digito da conta 1\n # numero convenio 6\n cc = conta_corrente.to_s.rjust(8, '0')\n \"#{agencia}#{agencia_dv}#{cc}#{conta_corrente_dv}#{''.rjust(6, '0')}\"\n end", "def busqueda\n \t@pagadero = Payment.find_by_id(params[:id])\n \t# @imp = @pagadero.to_s\n end", "def titulo_guia\n titulo = []\n\n t = Especie.find(params[:especie_id])\n a = t.adicional\n\n tipo_region = params[:tipo_region] == \"anp\" ? \"ANP \" : \"Municipio de \"\n \n if a.nombre_comun_principal.present?\n titulo[0] = \"Guía de #{a.nombre_comun_principal}\"\n else\n titulo[0] = \"Guía de #{t.nombre_cientifico}\"\n end\n\n titulo[1] = tipo_region + params[:nombre_region]\n titulo\n end", "def create\n @caso.current_usuario = current_usuario\n @caso.memo = ''\n @caso.titulo = ''\n\n notificacion = 'Caso creado.'\n if @conscasocount > MAX_CASOS_REFRESCA_AUTOMATICO\n notificacion += \" Por la cantidad de casos (#{@conscasocount})\"+\n \" debe Refrescar para actualizar \" +\n \" el cambio en el listado de casos\"\n end\n respond_to do |format|\n if @caso.save\n if registrar_en_bitacora\n Msip::Bitacora.a(request.remote_ip, current_usuario.id,\n request.url, params, 'Sivel2Gen::Caso',\n @caso.id, 'crear', '')\n end\n\n format.html {\n redirect_to @caso,\n notice: notificacion\n }\n format.json {\n render action: 'show', status: :created, location: @caso,\n layout: 'application'\n }\n else\n format.html {\n render action: 'new', layout: 'application'\n }\n format.json {\n render json: @caso.errors, status: :unprocessable_entity\n }\n end\n end\n begin\n @conscasocount = Conscaso.count\n if @conscasocount <= MAX_CASOS_REFRESCA_AUTOMATICO\n puts Conscaso.refresca_conscaso\n end\n rescue\n puts Conscaso.refresca_conscaso\n end\n end", "def asignaturas\n @seccion = \"Asignaturas\"\n @titulo = \"Asignaturas\"\n if params[:orden]\n case params[:orden]\n when \"Código\"\n @orden = \"codigo\"\n when \"Nombre\"\n @orden = \"nombre\"\n when \"Créditos\"\n @orden = \"unidades_credito\"\n when \"Tipo\"\n @orden = \"tipo\"\n else\n @orden = \"codigo\"\n end\n else\n @orden = \"codigo\"\n end\n \n @carreras = [\"Biología\", \"Computación\", \"Geoquímica\", \"Física\", \"Matemática\", \"Química\", \"Complementaria\"]\n @categorias = ['Código', 'Nombre', 'Créditos','Tipo'] #Este es el orden que se mostrará en el select de la vista\n @categoria_seleccionada = params[:orden]\n\n @asignatura_datos = [] #En este arreglo se guardan los pares \"Codigo - Nombre\" de cada asignatura para mostrar en el campo de busqueda\n Asignatura.order('nombre').all.each do |asignatura|\n #En este foro se agregan uno a uno los valores de cada asignatura al arreglo de la manera indicada arriba\n @asignatura_datos << asignatura.codigo.to_s + \" - \" + asignatura.nombre.to_s\n end\n end", "def new\n\t\t# Aqui criamos o Carrinho de Compras se ele não existir...\n\t\tif !defined?($CarrinhoCompras)\n\t\t\t$CarrinhoCompras = Array.new()\n\t\tend\n\t\tif !defined?($CarrinhoComprasQuant)\n\t\t\t$CarrinhoComprasQuant = Array.new()\n\t\tend\t\n\t\tcreate()\n\t\tredirect_to \"/compras?pd=\" + Admloja.first.mcab.to_s\n\tend", "def bairro_params\n params.require(:bairro).permit(:cidade_id, :nome)\n end", "def comprobante_params\n params.require(:comprobante).permit(:IdComprobante, :Nombre_Duenio, :Paciente, :Ruc, :Direccion, :Fecha_Registro, :Detalle_Producto, :Precio_Unitario, :Precio_Total, :Cantidad)\n end", "def new\n @pagetitle = \"Nueva Guia\"\n @action_txt = \"Create\"\n \n @delivery = Delivery.new\n @delivery[:code] = \"#{generate_guid2()}\"\n @delivery[:processed] = false\n @remision = Remision.all \n \n @company = Company.find(params[:company_id])\n @delivery.company_id = @company.id\n @delivery[:fecha1]=Date.today\n @delivery[:fecha2]=Date.today\n \n @locations = @company.get_locations()\n @divisions = @company.get_divisions()\n\n @trucks1 = @company.get_trucks()\n @trucks2 = @company.get_trucks()\n \n @employees = @company.get_employees()\n @customers = @company.get_customers()\n @remites = @company.get_customers()\n @empsubs = @company.get_empsubs()\n @unidads = @company.get_unidads()\n @addresses = @company.get_addresses()\n @addresses2 = @company.get_addresses()\n\n @services = @company.get_services()\n @servicebuys = @company.get_servicebuys()\n\n @transports = @company.get_transports()\n\n @ac_user = getUsername()\n @delivery[:user_id] = getUserId()\n end", "def contador_params\n params.require(:contador).permit(:contC, :contPg)\n end", "def new\n @cabcompra = Cabcompra.new\n @rencompra = Rencompra.new\n @cabplaegreso = Cabplaegreso.find([params[:idpe], session[:sucursal]])\n @tipocomprobantes = Tipocomprobante.find(:all, :order =>\"tcom_nombre\")\n # @proveedores = Proveedor.find(:all, :conditions => ['sucursal_id = ?', session[:sucursal]], :order =>\"prov_nombre\")\n @jurisdiccions = Jurisdiccion.find(:all, :order =>\"juri_nombre\")\n @conceptoegresos = Conceptoegreso.find(:all, :order =>\"cegr_detalle\")\n @alicuotaivas = Alicuotaiva.find(:all) \n if params[:cabcompra].nil? \n @iva = Tipocomprobante.find(1)\n else\n @iva = Tipocomprobante.find(params[:cabcompra][:tipocomprobante_id]) \n end\n end", "def caso_params\n params.require(:caso).permit(:radicado, :nombreimplicado, :tribunal, :estado, :estado, :tribunalquecomunica, :sala, :tipodecision, :segundainstancia, :magistradoponente, :radicado, :nombreyaliaspost, :bloque, :lugardeinfluencia, :lugarexpedicion, :fechaexpedicion, :estadoprovidencia, :secomunico, :fechacomunicacion, :delimitaciondeapartados, :ordenexhorto, :recomendaciones, :direcciongrupo, :tiempodeterminado)\n end", "def compra_params\n params.require(:compra).permit(:producto, :p_compra, :p_venta, :cantidad)\n end", "def contas_receber_params\n params.require(:contas_receber).permit(:dataEmissao, :valor, :vencimento, :juros, :multa, :Cliente_id)\n end", "def comentario_params\n params.require(:comentario).permit(:autor, :conteudo)\n end", "def cassete_params\n params.require(:cassete).permit(:formato, :pelicula_id)\n end", "def compte_params\n params.require(:compte).permit(:codeguichet, :numerocompte, :rib, :ibanbic, :banque_id)\n end", "def cachorro_params\n params.require(:cachorro).permit(:nome, :data_de_nascimento, :data_aproximada, :porte, :sexo, :saude, :temperamento, :foto, :equipamento, :dupla_para_passeio_id, :frequencia_de_passeio, :tempo_de_passeio, :habilitado_para_passeio)\n end", "def create\n # valor = params[:pedido][:valor]\n # params[:pedido][:valor] = valor.split( ',').join('.')\n conta = Conta.find_by_cliente_id(params[:pedido][:cliente_id])\n @proteinas_disponiveis = Proteina.where(:disponibilidade => true)\n @acompanhamentos_disponiveis = Acompanhamento.where(:disponibilidade => true)\n @guarnicoes_disponiveis = Guarnicao.where(:disponibilidade => true)\n @saladas_disponiveis = Salada.where(:disponibilidade => true)\n @bebidas_disponiveis = Bebida.where(:disponibilidade => true)\n @sobremesas_disponiveis = Sobremesa.where(:disponibilidade => true)\n #descricao = \"\"\n @pedido = Pedido.new(pedido_params)\n @pedido.conta_id = conta.id.to_i\n # if @pedido.cliente.nil?\n # @pedido.cliente = Cliente.find(current_usuario.cliente.id)\n # @pedido.conta = Conta.find_by_cliente_id(current_usuario.id)\n # end\n # ENTRADAS #\n # acompanhamentos = params[:pedido][:acompanhamento_ids]\n # acompanhamentos.each do |id|\n # if !id.blank?\n # acompanhamento = Acompanhamento.find(id.to_i)\n # @pedido.pedidos_acompanhamentos.new(:acompanhamento_id => id)\n # #@pedido.acompanhamentos << acompanhamento\n # end\n # end\n ###### FINAL ENTRADAS ########\n acompanhamentos = Acompanhamento.where(:disponibilidade => true).count\n for i in 0...acompanhamentos do\n if !params[\"acompanhamento_#{i}\"].blank?\n @pedido.pedidos_acompanhamentos.new(:acompanhamento_id => params[\"acompanhamento_#{i}\"], :quantidade => params[\"quantidade_acompanhamento_#{i}\"])\n end\n end\n\n proteinas = Proteina.where(:disponibilidade => true).count\n for i in 0...proteinas do\n if !params[\"proteina_#{i}\"].blank?\n @pedido.pedidos_proteinas.new(:proteina_id => params[\"proteina_#{i}\"], :quantidade => params[\"quantidade_proteina_#{i}\"])\n end\n end\n\n guarnicoes = Guarnicao.where(:disponibilidade => true).count\n for i in 0...guarnicoes do\n if !params[\"guarnicao_#{i}\"].blank?\n @pedido.pedidos_guarnicoes.new(:guarnicao_id => params[\"guarnicao_#{i}\"], :quantidade => params[\"quantidade_guarnicao_#{i}\"])\n end\n end\n\n saladas = Salada.where(:disponibilidade => true).count\n for i in 0...saladas do\n if !params[\"salada_#{i}\"].blank?\n @pedido.pedidos_saladas.new(:salada_id => params[\"salada_#{i}\"], :quantidade => params[\"quantidade_salada_#{i}\"])\n end\n end\n\n bebidas = Bebida.where(:disponibilidade => true).count\n for i in 0...bebidas do\n if !params[\"bebida_#{i}\"].blank?\n @pedido.pedidos_bebidas.new(:bebida_id => params[\"bebida_#{i}\"], :quantidade => params[\"quantidade_bebida_#{i}\"])\n end\n end\n\n sobremesas = Sobremesa.where(:disponibilidade => true).count\n for i in 0...sobremesas do\n if !params[\"sobremesa_#{i}\"].blank?\n @pedido.pedidos_sobremesas.new(:sobremesa_id => params[\"sobremesa_#{i}\"], :quantidade => params[\"quantidade_sobremesa_#{i}\"])\n end\n end\n\n\n #@pedido.proteinas << Proteina.where(:nome => params[:proteina]).first\n\n # debugger\n # if !params[:arroz].nil?\n # descricao = \"Arroz \"+ params[:arroz] + \",\"\n # end\n # if params[:feijao] = \"Sim\"\n # descricao = descricao + \" Feijao, \"\n # end\n\n # if params[:farofa] == \"Sim\"\n # descricao = descricao + \" Farofa,\"\n # end\n\n # descricao = descricao + params[:proteina] + \", \" + params[:acompanhamento] + \" Salada: \"+ params[:salada]\n # @pedido.descricao = descricao\n # itens = params[:pedido][:item_de_pedidos_attributes]\n\n # if !itens.nil?\n # for i in 0..params[:pedido][:item_de_pedidos_attributes].count do\n # if itens[\"#{i}\"] != nil\n # if itens[\"#{i}\"][:produto_id].blank?\n # itens.delete(\"#{i}\")\n # end\n # else\n # itens.delete(\"#{i}\")\n # end\n # end\n # end\n # if !itens.blank?\n # @pedido.calcular_valor\n # else\n # @pedido.item_de_pedidos.destroy_all\n # @pedido.valor = 0\n # end\n # if !itens.nil?\n # params[:pedido][:item_de_pedidos_attributes].replace(itens)\n # end\n\n @pedido.situacao = \"Em processamento\"\n #parametros[:valor] = @pedido.valor\n\n respond_to do |format|\n if @pedido.save\n @pedido.calcular_valor\n @pedido.conta.calcular_saldo\n #@pedido.adicionar_conta\n #proteina = @pedido.proteina\n #proteina.decrescer\n format.html { redirect_to @pedido }\n format.json { render action: 'show', status: :created, location: @pedido }\n else\n format.html { render action: 'new' }\n format.json { render json: @pedido.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @correo = Correo.new(correo_params)\n deptoClasificado = clasifica(@correo.mensaje)\n @correo.departamento = clasifica(@correo.mensaje)\n if deptoClasificado == 'Sells'\n @correo.departamento = 'Ventas'\n elsif deptoClasificado == 'Client'\n @correo.departamento = 'Atencion a cliente'\n elsif deptoClasificado == 'Human'\n @correo.departamento = 'Recursos humanos'\n end\n\n respond_to do |format|\n if @correo.save\n format.html { redirect_to @correo, notice: 'Correo was successfully created.' }\n format.json { render :show, status: :created, location: @correo }\n else\n format.html { render :new }\n format.json { render json: @correo.errors, status: :unprocessable_entity }\n end\n end\n end", "def cobrador_params\n params.require(:cobrador).permit(:clave, :nombre, :zona, :ruta)\n end", "def ajoutCss()\n #css label\n @titreLabel.override_color(:normal, Fenetre::COULEUR_BLANC)\n @titreLabel.set_margin_top(30)\n @tmp.set_margin_top(10)\n @labelCouleurCaseBase.override_color(:normal, Fenetre::COULEUR_BLANC)\n @labelCouleurCaseBase.set_margin(10)\n @labelCouleurCaseBase.set_margin_bottom(0)\n @labelCouleurCaseSelectionne.override_color(:normal, Fenetre::COULEUR_BLANC)\n @labelCouleurCaseSelectionne.set_margin(10)\n @labelCouleurCaseSelectionne.set_margin_bottom(0)\n @labelCouleurTexte.override_color(:normal, Fenetre::COULEUR_BLANC)\n @labelCouleurTexte.set_margin(10)\n @labelCouleurTexte.set_margin_bottom(0)\n @labelCouleurIndices.override_color(:normal, Fenetre::COULEUR_BLANC)\n @labelCouleurIndices.set_margin(10)\n @labelCouleurIndices.set_margin_bottom(0)\n @labelPolice.override_color(:normal, Fenetre::COULEUR_BLANC)\n @labelPolice.set_margin(10)\n @labelPolice.set_margin_bottom(0)\n #css bouton\n @boutonCouleurCaseBase.set_margin(10)\n @boutonCouleurCaseBase.set_margin_bottom(0)\n @boutonCouleurCaseSelectionne.set_margin(10)\n @boutonCouleurCaseSelectionne.set_margin_bottom(0)\n @boutonCouleurTexte.set_margin(10)\n @boutonCouleurTexte.set_margin_bottom(0)\n @boutonCouleurIndices.set_margin(10)\n @boutonCouleurIndices.set_margin_bottom(0)\n @boutonPolice.set_margin(10)\n @boutonPolice.set_margin_bottom(0)\n @boutonReset.set_margin(30)\n @boutonReset.set_margin_bottom(0)\n end", "def conta_params\n params.require(:conta).permit(:banco_id, :conta_numero, :conta_digito, :agencia_numero, :agencia_digito, :descricao)\n end", "def celulare_params\n params.require(:celulare).permit(:precio, :modelo, :memoriain, :memoriaex)\n end", "def create\n @quinto = Quinto.new(quinto_params)\n \n @quinto.anio = params[:anio]\n @quinto.mes = params[:mes]\n \n \n respond_to do |format|\n if @quinto.save\n format.html { redirect_to @quinto, notice: 'Quinto was successfully created.' }\n format.json { render :show, status: :created, location: @quinto }\n else\n format.html { render :new }\n format.json { render json: @quinto.errors, status: :unprocessable_entity }\n end\n end\n end", "def comanda_params\n params.require(:comanda).permit(:idcomanda, :idFuncionario, :mesa, :dataAbertura, :dataEncerramento, :valorFinal)\n end", "def comentar_params\n params.require(:comentar).permit(:user_id, :disciplinacurso_id, :professor_id, :semestre_id,:comentario, :data_comentario,:denuncia,:bloqueio, :data_bloqueio)\n end", "def cabecera\n puts \"\"\n puts \"\"\n puts \"El examen va a comenzar.\"\n puts \" Debe responder poniendo solo el caracter de la respuesta elegida.\"\n print \" El examen consta de \"\n print @numeroPreguntas\n puts \" preguntas.\"\n end", "def cpf_cnpj_ecm_new_cadastro_item(form_item, params)\n view = \"\"\n unless params\n if form_item.opcoes[:tipo] == \"1\"\n view.concat(masked_text_field :cadastro, \"item_#{form_item.id}\", options={:mask=>\"999.999.999-99\"})\n elsif form_item.opcoes[:tipo] == \"2\"\n view.concat(masked_text_field :cadastro, \"item_#{form_item.id}\", options={:mask=>\"99.999.999/0009-99\"})\n else\n view.concat(masked_text_field :cadastro, \"item_#{form_item.id}\")\n end\n else\n if form_item.opcoes[:tipo] == \"1\"\n view.concat(masked_text_field :cadastro, \"item_#{form_item.id}\", options={:mask=>\"999.999.999-99\", :value=>params[\"item_#{form_item.id}\"]})\n elsif form_item.opcoes[:tipo] == \"2\"\n view.concat(masked_text_field :cadastro, \"item_#{form_item.id}\", options={:mask=>\"99.999.999/0009-99\", :value=>params[\"item_#{form_item.id}\"]})\n else\n view.concat(masked_text_field :cadastro, \"item_#{form_item.id}\", :value=>params[\"item_#{form_item.id}\"])\n end\n end\n return view\n end", "def bloqueo_params\n params.require(:bloqueo).permit(:nombres, :apellidos, :dni, :proyecto, :departamento, :voucher, :tipo, :monto)\n end", "def info_conta\n # CAMPO TAMANHO\n # agencia 4\n # complemento 1\n # conta corrente 8\n # digito da conta 1\n # complemento 6\n \"#{agencia} #{conta_corrente}#{digito_conta}#{''.rjust(6, ' ')}\"\n end", "def contrato_abono_params\n params.require(:contrato_abono).permit(:fecha, :customer_id, :medio_id, :secu_cont, :observa, :importe, :moneda_id)\n end", "def index\n @historia_clinicas = buscar(params[:palabra])\n end", "def espacio_comun_params\n params.require(:espacio_comun).permit(:espacio_comun, :descripcion, :reglamento, :precio, :foto, :comunidad_id)\n end", "def index\n if !Rails.configuration.x.sivel2_consulta_web_publica\n authorize! :index, Sivel2Gen::Caso\n end\n begin\n @conscasocount = Conscaso.count\n rescue\n Conscaso.refresca_conscaso\n @conscasocount = Conscaso.count\n end\n #byebug\n #if !ActiveRecord::Base.connection.data_source_exists?(\n # 'sivel2_gen_consexpcaso')\n # Consexpcaso.crea_consexpcaso\n #end\n @cortamemo = cortamemo\n\n @incluir = incluir_inicial\n @campoord = campoord_inicial\n @conscaso = Sivel2Gen::Conscaso.all\n\n # Las 2 siguientes se agregaron para evaluar OBSERVADOR_PARTE\n # pero hacen demasiado ineficiente la consulta del listado\n # de casos --Una consulta de 35.000 casos pasa de 3s a 28s.\n #casos = Sivel2Gen::Caso.accessible_by(current_ability)\n #@conscaso = @conscaso.where(caso_id: casos.map(&:id))\n #@conscaso = @conscaso.accessible_by(current_ability)\n\n @conscaso = filtrar_ca(@conscaso)\n @conscasocount = @conscaso.count\n inicializa_index\n\n # Filtro\n if params && params[:filtro]\n # if params[:filtro][:q] && params[:filtro][:q].length>0\n # Simple\n # q = params[:filtro][:q].gsub(\"-\", \" \")\n # @conscaso = @conscaso.where(\n # \"q @@ plainto_tsquery('spanish', unaccent(?))\", q\n # )\n # else\n # Avanzado\n @conscaso = filtro_avanzado @conscaso, params[:filtro]\n #puts @conscaso.to_sql; byebug\n # Columnas por incluir\n nincluir = []\n for i in @incluir do\n s = 'inc_' + i\n if params[:filtro][s.to_sym] && params[:filtro][s.to_sym] == '1'\n nincluir.push(i)\n end\n end\n @incluir = nincluir\n # Cambiar Ordenamiento\n if params[:filtro][:orden]\n @campoord = params[:filtro][:orden]\n end\n # Otros (puede cambiar consulta, @incluir o @campoord)\n @conscaso = filtro_particular @conscaso, params[:filtro]\n #puts @conscaso.to_sql; byebug\n end\n\n # Ordenamiento y control de acceso\n if defined? @conscaso.ordenar_por\n @conscaso = @conscaso.ordenar_por @campoord\n end\n\n # Cuenta y Paginación\n #Rails.logger.info @conscaso.to_sql\n @numconscaso = @conscaso.size\n @paginar = !params || !params[:filtro] ||\n !params[:filtro][:paginar] ||\n params[:filtro][:paginar] != '0'\n if @paginar && params[:idplantilla].nil? && defined?(@conscaso.paginate)\n @conscaso = @conscaso.paginate(\n page: params[:pagina], per_page: 20)\n else\n @paginar = false\n end\n #if @usa_consexpcaso\n # if @paginar && params[:idplantilla].nil? && defined?(@consexpcaso.paginate)\n # @consexpcaso = @consexpcaso.paginate(\n # page: params[:pagina], per_page: 20)\n # else\n # @paginar = false\n # end\n #end\n if registrar_en_bitacora\n Msip::Bitacora.a(request.remote_ip, current_usuario ?\n current_usuario.id : nil,\n request.url, params, 'Sivel2Gen::Caso',\n 0, 'listar', '')\n end\n presenta_index\n end", "def coleccionable_params\n params.require(:coleccionable).permit(:nombre, :marca, :precio)\n end", "def comentario_params\n params.require(:comentario).permit(:comentario, :usuario_id, :correo, :nombre, :estatus, :ancestry, :institucion,\n :con_verificacion, :es_admin, :es_respuesta, :especie_id, :categorias_contenido_id,\n :ajax, :nombre_cientifico, :created_at)\n end", "def giro_comercial_params\n params.require(:giro_comercial).permit(:nombre)\n end", "def comentario_params\n params.require(:comentario).permit(:mensagem)\n end", "def companium_params\n params.require(:companium).permit(:nombre_c, :cuenta, :twi)\n end", "def new # modificacion para transacciones\n @solicitudrecurso = Solicitudrecurso.new \n \n #identifico los tipos distintos de recurso\n @tipos = Recurso.find(:all).map{ |i| i.descripcion }.uniq\n \n # cargo los dias y horas posibles para los select\n @dias=Dia.find(:all,:conditions=>['en_uso = ?',\"t\"])\n @horas=Horario.find(:all,:conditions=>['en_uso = ?',\"t\"])\n\n #obtengo y formateo la fecha actual\n @[email protected]=formato_europeo(Date.today)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @solicitudrecurso }\n end\n end", "def diario\n fechas()\n @ejercicios = Ejercicio.find(:all)\n @asientos = Contabilidad.librodiario(params[:fechadesde], params[:fechahasta])\n\n \n end", "def nombre_completo\n\tprimer_nombre+\" \"+primer_apellido\n#fin del metodo\nend", "def info_conta\n # CAMPO TAMANHO\n # agencia 4\n # complemento 1\n # conta corrente 8\n # digito da conta 1\n # complemento 6\n \"#{agencia} #{conta_corrente}#{digito_conta}#{''.rjust(6, ' ')}\"\n end", "def conciliabank_detail_params\n params.require(:conciliabank_detail).permit(:fecha, :tipomov_id, :cargo, :abono, :concepto, :nrocheque)\n end", "def create\n @contrato_abono = ContratoAbono.new(contrato_abono_params)\n\n @customers = Customer.all.order(:name) \n @monedas = Moneda.all\n @medios =Medio.all.order(:descrip)\n @customercontrato = CustomerContrato.all.order(:secu_cont)\n \n\n respond_to do |format|\n if @contrato_abono.save\n format.html { redirect_to @contrato_abono, notice: 'Contrato abono was successfully created.' }\n format.json { render :show, status: :created, location: @contrato_abono }\n else\n format.html { render :new }\n format.json { render json: @contrato_abono.errors, status: :unprocessable_entity }\n end\n end\n end", "def cabine_params\n params.require(:cabine).permit(:cod, :empresa_id)\n end", "def prepara_form\n @enderecos = Endereco.order :rua\n end", "def create\n @busca = Busca.new(busca_params)\n\n respond_to do |format|\n if @busca.save\n format.html { redirect_to @busca, notice: 'Busca was successfully created.' }\n format.json { render :show, status: :created, location: @busca }\n else\n format.html { render :new }\n format.json { render json: @busca.errors, status: :unprocessable_entity }\n end\n end\n end", "def cofre_params\n params.require(:cofre).permit(:data, :dineiro, :moeda, :chqvista, :dolares, :euros)\n end", "def cancha_params\n params.require(:cancha).permit(:nombre, :precio, :comercio_id, :descripcion, :ciudad_id, :foto )\n end", "def index\n @formularios = Formulario.all\n $statusA = \"Pendente\"\n end", "def calculo_params\n params.require(:calculo).permit(:perdida_persion, :diametro_cilindro, :velocidad_cilindro, :presion_trabajo, :diametro_tubo)\n end", "def seguimiento_params\n params.require(:seguimiento).permit(:fecha, :caso_id, :numero, :glosa)\n end", "def full_descripcion \n \"#{asunto.nombre} - \"+\"#{nombre}\" \n end", "def solicitacao_bloq_params\n params.require(:solicitacao_bloq).permit(:cadastro_id, :informacoes, :usuario, :visualizado)\n end", "def anschreiben_params\n params.require(:anschreiben).permit(:name, :adess, :plz, :plzz, :city, :company_name, :comapay_adress, :company_city, :bewerbung, :stelle, :datum)\n end", "def create\n @interno = Interno.new(interno_params)\n @interno.state = 'Activo'\n @interno.lugarNacimiento=(params[:palabra])\n \n if @interno.save\n flash[:success] = 'Interno fue creado exitosamente'\n redirect_to @interno\n else\n render action: \"new\"\n end\n \n end", "def conta_params\n params.require(:conta).permit(:correntista_id, :flag_ativo, :created_at, :updated_at, :saldo, :saldoProvisorio)\n end", "def datos_default\n if new_record?\n lastRecord = MovMovimiento.last\n if lastRecord\n self.hoja = lastRecord.hoja\n end\n\n num_abonos = ComPago.where(com_compra: com_compra).count + 1\n self.concepto = \"Abono #{num_abonos} a compra \\\"#{com_compra.title}\\\"\"\n end\n end", "def ofrece_params\n params.require(:ofrece).permit(:dia, :nombre, :tipo, :descripcion, :precio, :calificasion)\n end", "def new\n @cabo_eleitoral = CaboEleitoral.new\n @pessoa = Pessoa.new\n @pessoas = Pessoa.find(:all).map { |u| [u.nome + ' - ' + u.cpf + ';'] }.uniq\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cabo_eleitoral }\n end\n end", "def comppra_params\n params.require(:comppra).permit(:fecha_compra, :monto, :cliente)\n end", "def contacto_params\n params.require(:contacto).permit(:Nombre, :Email, :Asunto, :Body)\n end", "def forma_contacto_params\n params.require(:forma_contacto).permit(:clave_forma_contacto, :forma_contacto, caracteristica_forma_contactos_attributes: [:id, :caracteristica, :requerido, :tipo_dato_id, :forma_contacto_id, :orden, :_destroy] )\n end", "def cancha_params\n params.require(:cancha).permit(:nombre, :descripcion, :capacidad, :operativa, :mmpp_id)\n end", "def compra_params\n params.require(:compra).permit(:numero, :docvalor, :fecha, :existencia, :poa, :presupuestaria, :cotizacion, :especificaciones, :autorizaciones, :fecha)\n end", "def cuenta_params\n params.require(:cuenta).permit(:chofer_id, :movil_id, :saldo_anterior, :agencia_id, :descripcion)\n end", "def cuartel_params\n params.require(:cuartel).permit(:nombre, :distrito_id, :localizacion, :descripcion, :himno, :lema)\n end", "def cuenca_params\n params.require(:cuenca).permit(:id_vertiente, :nombre, :id_status)\n end", "def comentario_params\n params.require(:comentario).permit(:titulo, :texto)\n end", "def cegreso_params\n params.require(:cegreso).permit(:employee_id, :transportorder_id, :fecha1, :fecha2, :observa, :descrip, :importe, :moneda_id)\n end", "def sivic_contabanco_params\r\n params.require(:sivic_contabanco).permit(:nome_conta, :numr_agencia, :numr_conta, :numr_dvconta, :sivic_banco_id, :sivic_igreja_id, :User, :User_id, :data_exclusao)\r\n end", "def create\n @clientes = Cliente.all\n @contactos = Cliente.all.order(:nombre).first.contactos\n @horarios = Horario.where(\"cliente_id = ?\", Cliente.all.order(:nombre).first.id)\n #@datosgenerale = Datosgenerale.new(datosgenerale_params)\n @datosgenerale.cliente_id = params[:datosgenerale][:cliente_id]\n\n @datosgenerale.contacto1_id = nil\n @datosgenerale.contacto2_id = nil\n @datosgenerale.contacto3_id = nil\n @datosgenerale.contacto4_id = nil\n @datosgenerale.contacto5_id = nil\n\n\n params[:datosgenerale][:contacto1_id].each_index { |i|\n case i\n when 1\n @datosgenerale.contacto1_id = params[:datosgenerale][:contacto1_id][i]\n when 2\n @datosgenerale.contacto2_id = params[:datosgenerale][:contacto1_id][i]\n when 3\n @datosgenerale.contacto3_id = params[:datosgenerale][:contacto1_id][i]\n when 4\n @datosgenerale.contacto4_id = params[:datosgenerale][:contacto1_id][i]\n when 5\n @datosgenerale.contacto5_id = params[:datosgenerale][:contacto1_id][i]\n else\n #do default case\n end\n\n }\n\n\n @datosgenerale.horario_id = params[:post][:horario_id]\n #@datosgenerale.alta = Date.strptime(params[:datosgenerale][:alta], '%m/%d/%Y')\n if(params[:datosgenerale][:tipocambio]=='1')\n @datosgenerale.tipocambio=true\n else\n @datosgenerale.tipocambio=false\n end\n\n respond_to do |format|\n if @datosgenerale.save\n format.html { redirect_to @datosgenerale, notice: 'Datosgenerale was successfully created.' }\n format.json { render action: 'show', status: :created, location: @datosgenerale }\n else\n format.html { render action: 'new', :layout => \"layout_2\"}\n format.json { render json: @datosgenerale.errors, status: :unprocessable_entity }\n end\n end\n end", "def contactus\r\n end", "def form_chaga_params\n params.require(:form_chaga).permit(:paciente_id, :hospital_id, :muestra, :diag_serologico, :conclucion_diag, :diag_confir, :conclu_pueb_confir, :observaciones, :firma)\n end", "def motorista_params\n params.require(:motorista).permit(:nome, :cnh, :telefone, :email, :cpf, :empresa_id)\n end", "def informacioncomercial_params\n params.require(:informacioncomercial).permit(:idtipomoneda, :correlativoinformacion, :fechainforcomercial, :montoinforcomercial, :fechahoraingreso)\n end", "def create\n @comissao = Comissao.new(params[:comissao])\n\n respond_to do |format|\n if @comissao.save\n flash[:notice] = 'Comissão cadastrado com sucesso.'\n format.html { redirect_to(@comissao) }\n format.xml { render :xml => @comissao, :status => :created, :location => @comissao }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @comissao.errors, :status => :unprocessable_entity }\n end\n end\n end", "def contato_params\n params.require(:contato).permit(:nome, :cargo, :telefone, :celular, :email, :facebook, :linkedin, :googleplus, :cliente_potencial_id)\n end", "def index\n @cuarteles = Cuartel.select(:id, :nombre).order(:nombre)\n\n # Control de los botones activos\n @gu_active = ''\n @rm_active = ''\n @cuarteles_active = 'active'\n end", "def daw_comunicado_params\n params.require(:daw_comunicado).permit(:com_nombre, :com_texto, :com_tipocomunicado, :com_estado, :com_fechaenvio)\n end", "def to_s\n return \"Casilla Juez -> Nombre: #{nombre}, Tipo: #{@tipo}, Número Cárcel: #{@@carcel}\"\n end", "def show\n #@comentario = Comentario.new\n @comentario = @noticium.comentarios.build\n end", "def cupo_params\n params.require(:cupo).permit(:parqueadero_id, :tipo_de_cupo_id, :cantidad)\n end", "def create\n @tipomaquinat = Tipomaquinat.new(tipomaquinat_params)\n #@tipomaquinat = Tipomaquinat.new\n #@tipomaquinat.id=401\n #@tipomaquinat.tipomaquina = \"KLK\" #params.require(:tipomaquinat).permit(:tipomaquina)\n #@tipomaquinat.descripcion = \"YOOOO\" #params.require(:tipomaquinat).permit(:descripcion)\n #descripcion\n\n # params.require(:tipomaquinat).permit(:tipomaquina, :descripcion,\n\n respond_to do |format|\n if @tipomaquinat.save\n format.html { redirect_to @tipomaquinat, notice: 'Tipomaquinat was successfully created.' }\n format.json { render :show, status: :created, location: @tipomaquinat }\n else\n format.html { render :new }\n format.json { render json: @tipomaquinat.errors, status: :unprocessable_entity }\n end\n end\n end", "def soatseguro_params\n params.require(:soatseguro).permit(:Placa, :del, :vehiculo, :Fecha, :inicio, :vigencia, :Fecha, :fin, :vigencia, :Numero, :pasajeros, :Cilindraje, :Clase, :Toneladas, :Edad, :Precio)\n end", "def conta_params\n params.require(:conta).permit(:duracao, :numeroMesa, :qtdClientes)\n end" ]
[ "0.65286636", "0.62023795", "0.6152687", "0.61135095", "0.60902584", "0.6061958", "0.60468096", "0.6042072", "0.6020243", "0.600849", "0.59937924", "0.5984717", "0.5981439", "0.59610784", "0.59361017", "0.59222907", "0.5916482", "0.59100455", "0.58903545", "0.58865637", "0.5863883", "0.5858396", "0.5854238", "0.5845365", "0.5844838", "0.58438486", "0.5841779", "0.58391505", "0.5823436", "0.5817027", "0.58169115", "0.58011913", "0.5798807", "0.5798507", "0.5794129", "0.5789543", "0.5786955", "0.57823753", "0.57821745", "0.57734466", "0.5767297", "0.57646847", "0.5749088", "0.57471496", "0.5742925", "0.573978", "0.5731372", "0.57274747", "0.5727138", "0.57264966", "0.57238275", "0.57226276", "0.5722227", "0.57204473", "0.57153976", "0.57142186", "0.5712524", "0.5709039", "0.5705438", "0.5704481", "0.5697146", "0.5693257", "0.56923705", "0.56911975", "0.56871784", "0.56865126", "0.5686445", "0.5683713", "0.5683265", "0.568264", "0.5682081", "0.5681716", "0.56735134", "0.56680864", "0.5666966", "0.5666813", "0.5666181", "0.5665361", "0.56646353", "0.56644446", "0.56628627", "0.5658499", "0.565722", "0.56538886", "0.56524134", "0.5651759", "0.56500155", "0.5649772", "0.56457126", "0.56441283", "0.56436384", "0.5639709", "0.5636752", "0.5635589", "0.5634805", "0.5633491", "0.56320256", "0.5627542", "0.5626399", "0.5625294", "0.562399" ]
0.0
-1
Update parameters of a TIFF image. The image is saved in the cloud
def modify_tiff_from_storage puts('Update parameters of a TIFF image from cloud storage') upload_sample_image_to_cloud compression = 'adobedeflate' resolution_unit = 'inch' bit_depth = 1 horizontal_resolution = 150.0 vertical_resolution = 150.0 from_scratch = nil folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage storage = nil # We are using default Cloud Storage request = AsposeImagingCloud::ModifyTiffRequest.new( get_sample_image_file_name, bit_depth, compression, resolution_unit, horizontal_resolution, vertical_resolution, from_scratch, folder, storage) puts("Call ModifyTiff with params: compression: #{compression}, resolution unit: #{resolution_unit}, bit depth:" + " #{bit_depth}, horizontal resolution: #{horizontal_resolution}, vertical resolution: " + "#{vertical_resolution}") updated_image = imaging_api.modify_tiff(request) save_updated_sample_image_to_output(updated_image, false) puts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modify_tiff_and_upload_to_storage\n puts('Update parameters of a TIFF image and upload to cloud storage')\n\n upload_sample_image_to_cloud\n\n compression = 'adobedeflate'\n resolution_unit = 'inch'\n bit_depth = 1\n horizontal_resolution = 150.0\n vertical_resolution = 150.0\n from_scratch = nil\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ModifyTiffRequest.new(\n get_sample_image_file_name, bit_depth, compression, resolution_unit, horizontal_resolution,\n vertical_resolution, from_scratch, folder, storage)\n\n puts(\"Call ModifyTiff with params: compression: #{compression}, resolution unit: #{resolution_unit}, \" +\n \"bit depth: #{bit_depth}, horizontal resolution: #{horizontal_resolution}, vertical resolution: \" +\n \"#{vertical_resolution}\")\n\n updated_image = @imaging_api.modify_tiff(request)\n upload_image_to_cloud(get_modified_sample_image_file_name, updated_image)\n puts\n end", "def update_tiff_to_fax_from_storage\n puts('Update parameters of TIFF image according to fax parameters')\n\n upload_sample_image_to_cloud\n\n # Update TIFF Image parameters according to fax parameters\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ConvertTiffToFaxRequest.new(get_sample_image_file_name, storage, folder)\n\n puts('Call ConvertTiffToFax')\n\n updated_image = imaging_api.convert_tiff_to_fax(request)\n save_updated_image_to_output('ConvertTiffToFax.tiff', updated_image)\n puts\n end", "def create_modified_tiff_from_request_body\n puts('Update parameters of a TIFF image from request body')\n\n compression = 'adobedeflate'\n resolution_unit = 'inch'\n bit_depth = 1\n horizontal_resolution = 150.0\n vertical_resolution = 150.0\n from_scratch = nil\n storage = nil # We are using default Cloud Storage\n out_path = nil # Path to updated file (if this is empty, response contains streamed image)\n\n input_stream = File.open(File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, get_sample_image_file_name), 'r')\n request = AsposeImagingCloud::CreateModifiedTiffRequest.new(\n input_stream, bit_depth, compression, resolution_unit, horizontal_resolution, vertical_resolution,\n from_scratch, out_path, storage)\n\n puts(\"Call CreateModifiedTiff with params: compression: #{compression}, resolution unit: #{resolution_unit}, \" +\n \"bit depth: #{bit_depth}, horizontal resolution: #{horizontal_resolution}, vertical resolution: \" +\n \"#{vertical_resolution}\")\n\n updated_image = imaging_api.create_modified_tiff(request)\n save_updated_sample_image_to_output(updated_image, true)\n puts\n end", "def modify_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def create_modified_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def update!(**args)\n @far = args[:far] if args.key?(:far)\n @format = args[:format] if args.key?(:format)\n @image_height = args[:image_height] if args.key?(:image_height)\n @image_width = args[:image_width] if args.key?(:image_width)\n @mime = args[:mime] if args.key?(:mime)\n @near = args[:near] if args.key?(:near)\n @units = args[:units] if args.key?(:units)\n end", "def update!(**args)\n @bytes_value = args[:bytes_value] if args.key?(:bytes_value)\n @float_value = args[:float_value] if args.key?(:float_value)\n @image_template = args[:image_template] if args.key?(:image_template)\n @int32_value = args[:int32_value] if args.key?(:int32_value)\n @version = args[:version] if args.key?(:version)\n end", "def image=(image)\n self.image.assign image.tempfile\n end", "def update!(**args)\n @image = args[:image] if args.key?(:image)\n @tag = args[:tag] if args.key?(:tag)\n end", "def update!(**args)\n @deprecated_entropy_color = args[:deprecated_entropy_color] if args.key?(:deprecated_entropy_color)\n @filename = args[:filename] if args.key?(:filename)\n @flags = args[:flags] if args.key?(:flags)\n @height = args[:height] if args.key?(:height)\n @width = args[:width] if args.key?(:width)\n end", "def update_template_with_image_id(template)\n params = template.parameters\n params.each do |key, value|\n update_params_with_image_id(params, key, value)\n end\n end", "def update!(**args)\n @enhanced_image = args[:enhanced_image] if args.key?(:enhanced_image)\n @feature_graphic = args[:feature_graphic] if args.key?(:feature_graphic)\n @screenshot = args[:screenshot] if args.key?(:screenshot)\n end", "def update_properties\r\n if @picture.origin == 0\r\n set_origin(0, 0)\r\n else\r\n set_origin(bitmap.width / 2, bitmap.height / 2)\r\n end\r\n set_position(@picture.x, @picture.y)\r\n self.z = @picture.number\r\n self.zoom_x = @picture.zoom_x / 100.0\r\n self.zoom_y = @picture.zoom_y / 100.0\r\n self.opacity = @picture.opacity\r\n shader.blend_type = @picture.blend_type\r\n self.angle = @picture.angle\r\n tone = @picture.tone\r\n unless tone.eql?(@current_tone)\r\n shader.set_float_uniform('tone', tone)\r\n @current_tone = tone.clone\r\n end\r\n end", "def update_image image\n temp_path = @image_folder.detect{|image_string| image_string.downcase == \"#{@image_path}/#{image.image_file_name}\".downcase}\n filename = File.basename(temp_path)\n image.image_number = @img_count\n\n @img_count += 1\n if temp_path.blank?\n InputBatch::Log.status_log.error \">>>>>>>>Image #{filename} not found<<<<<<<<<\"\n puts \">>>>>>>>>>>>Image #{filename} not found\"\n InputBatch::Log.error_log.error \"Error on line #{@row_index} : Image #{filename} not found\"\n else\n InputBatch::Log.status_log.info \"Image #{filename} found\"\n image.page_count = %x[identify #{temp_path}].split(filename).length-1 rescue nil\n end\n\n rename_image image if facility.index_file_parser_type == \"WellsFargo_bank\"\n return image\n end", "def update!(**args)\n @image = args[:image] if args.key?(:image)\n end", "def update!(**args)\n @image_bytes = args[:image_bytes] if args.key?(:image_bytes)\n end", "def update!(**args)\n @checksum = args[:checksum] if args.key?(:checksum)\n @color_sampling = args[:color_sampling] if args.key?(:color_sampling)\n @dense_features = args[:dense_features] if args.key?(:dense_features)\n @dense_general_extra_features = args[:dense_general_extra_features] if args.key?(:dense_general_extra_features)\n @external_image_id = args[:external_image_id] if args.key?(:external_image_id)\n @is_assigned = args[:is_assigned] if args.key?(:is_assigned)\n @is_instant = args[:is_instant] if args.key?(:is_instant)\n @model_version = args[:model_version] if args.key?(:model_version)\n @overwrite_reason = args[:overwrite_reason] if args.key?(:overwrite_reason)\n @quantized_features = args[:quantized_features] if args.key?(:quantized_features)\n @score = args[:score] if args.key?(:score)\n @sparse_features = args[:sparse_features] if args.key?(:sparse_features)\n @thumbnail_set = args[:thumbnail_set] if args.key?(:thumbnail_set)\n @thumbnail_version = args[:thumbnail_version] if args.key?(:thumbnail_version)\n @type = args[:type] if args.key?(:type)\n end", "def update!(**args)\n @color_entropy = args[:color_entropy] if args.key?(:color_entropy)\n @image_data = args[:image_data] if args.key?(:image_data)\n @is_unsafe = args[:is_unsafe] if args.key?(:is_unsafe)\n @starburst_v4_embedding = args[:starburst_v4_embedding] if args.key?(:starburst_v4_embedding)\n @thumbnail_bytes = args[:thumbnail_bytes] if args.key?(:thumbnail_bytes)\n end", "def update!(**args)\n @author_name = args[:author_name] if args.key?(:author_name)\n @corpus = args[:corpus] if args.key?(:corpus)\n @geo_location = args[:geo_location] if args.key?(:geo_location)\n @global_feature = args[:global_feature] if args.key?(:global_feature)\n @image_height = args[:image_height] if args.key?(:image_height)\n @image_id = args[:image_id] if args.key?(:image_id)\n @image_url = args[:image_url] if args.key?(:image_url)\n @image_width = args[:image_width] if args.key?(:image_width)\n @info = args[:info] if args.key?(:info)\n @object_info = args[:object_info] if args.key?(:object_info)\n @object_name = args[:object_name] if args.key?(:object_name)\n @opaque_data = args[:opaque_data] if args.key?(:opaque_data)\n @roi = args[:roi] if args.key?(:roi)\n @subset = args[:subset] if args.key?(:subset)\n @version = args[:version] if args.key?(:version)\n end", "def update!(**args)\n @dense_features = args[:dense_features] if args.key?(:dense_features)\n @encoded_image_string = args[:encoded_image_string] if args.key?(:encoded_image_string)\n @encoded_image_string_small = args[:encoded_image_string_small] if args.key?(:encoded_image_string_small)\n @encoded_thumbnails = args[:encoded_thumbnails] if args.key?(:encoded_thumbnails)\n @id = args[:id] if args.key?(:id)\n @ocr_text = args[:ocr_text] if args.key?(:ocr_text)\n @quality_scores = args[:quality_scores] if args.key?(:quality_scores)\n @should_update_default_thumbnail = args[:should_update_default_thumbnail] if args.key?(:should_update_default_thumbnail)\n @thumbnailer_model_version = args[:thumbnailer_model_version] if args.key?(:thumbnailer_model_version)\n @timestamp_ms = args[:timestamp_ms] if args.key?(:timestamp_ms)\n @type = args[:type] if args.key?(:type)\n @user_reported_thumbnail = args[:user_reported_thumbnail] if args.key?(:user_reported_thumbnail)\n @user_reported_thumbnails = args[:user_reported_thumbnails] if args.key?(:user_reported_thumbnails)\n @version = args[:version] if args.key?(:version)\n end", "def update!(**args)\n @filename = args[:filename] if args.key?(:filename)\n @height = args[:height] if args.key?(:height)\n @ms_offset = args[:ms_offset] if args.key?(:ms_offset)\n @width = args[:width] if args.key?(:width)\n end", "def update!(**args)\n @byte_size = args[:byte_size] if args.key?(:byte_size)\n @encoding_quality = args[:encoding_quality] if args.key?(:encoding_quality)\n @encoding_type = args[:encoding_type] if args.key?(:encoding_type)\n @height = args[:height] if args.key?(:height)\n @image_blob_id = args[:image_blob_id] if args.key?(:image_blob_id)\n @image_bytes = args[:image_bytes] if args.key?(:image_bytes)\n @image_string = args[:image_string] if args.key?(:image_string)\n @width = args[:width] if args.key?(:width)\n end", "def update!(**args)\n @image_height = args[:image_height] if args.key?(:image_height)\n @image_id = args[:image_id] if args.key?(:image_id)\n @image_url = args[:image_url] if args.key?(:image_url)\n @image_width = args[:image_width] if args.key?(:image_width)\n @is_animated = args[:is_animated] if args.key?(:is_animated)\n @is_default = args[:is_default] if args.key?(:is_default)\n @metadata = args[:metadata] if args.key?(:metadata)\n end", "def put_images_extract_as_tiff_with_http_info(name, page_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_images_extract_as_tiff ...\"\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_images_extract_as_tiff\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.put_images_extract_as_tiff\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/images/extract/tiff\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'destFolder'] = opts[:'dest_folder'] if !opts[:'dest_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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_images_extract_as_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def set_img\n\n end", "def update!(**args)\n @stable_image = args[:stable_image] if args.key?(:stable_image)\n @target_image = args[:target_image] if args.key?(:target_image)\n end", "def update!(**args)\n @animations = args[:animations] if args.key?(:animations)\n @image = args[:image] if args.key?(:image)\n end", "def set_trfileimage\n @trfileimage = Trfileimage.find(params[:id])\n end", "def update!(**args)\n @inferred_image_source = args[:inferred_image_source] if args.key?(:inferred_image_source)\n @inferred_image_type = args[:inferred_image_type] if args.key?(:inferred_image_type)\n end", "def update_file(params)\n self.processed = false\n self.attributes = params\n set_upload_attributes\n save!\n Avatar.delay.finalize_and_cleanup(id)\n end", "def append_tiff_from_storage\n puts('Appends existing TIFF image to another existing TIFF image')\n\n append_file_name = 'Append.tiff' # Image file name to be appended to original one\n\n upload_sample_image_to_cloud\n upload_image_to_cloud(append_file_name, File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, append_file_name))\n\n # Update TIFF Image parameters according to fax parameters\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n update_request = AsposeImagingCloud::AppendTiffRequest.new(\n get_sample_image_file_name, append_file_name, storage, folder)\n\n puts('Call AppendTiff')\n\n imaging_api.append_tiff(update_request)\n\n # Download updated file to local storage\n download_request = AsposeImagingCloud::DownloadFileRequest.new(\n File.join(ImagingBase::CLOUD_PATH, get_sample_image_file_name), storage)\n updated_image = imaging_api.download_file(download_request)\n save_updated_image_to_output('AppendToTiff.tiff', updated_image)\n puts\n end", "def update!(**args)\n @image_docid = args[:image_docid] if args.key?(:image_docid)\n @thumb_height = args[:thumb_height] if args.key?(:thumb_height)\n @thumb_type = args[:thumb_type] if args.key?(:thumb_type)\n @thumb_width = args[:thumb_width] if args.key?(:thumb_width)\n end", "def update!(**args)\n @blobs = args[:blobs] if args.key?(:blobs)\n @scalar = args[:scalar] if args.key?(:scalar)\n @step = args[:step] if args.key?(:step)\n @tensor = args[:tensor] if args.key?(:tensor)\n @wall_time = args[:wall_time] if args.key?(:wall_time)\n end", "def update!(**args)\n @multi_thumbnail_variant = args[:multi_thumbnail_variant] if args.key?(:multi_thumbnail_variant)\n @preview_frame_zero_variant = args[:preview_frame_zero_variant] if args.key?(:preview_frame_zero_variant)\n @thumbnail_variant = args[:thumbnail_variant] if args.key?(:thumbnail_variant)\n @timestamp_ms = args[:timestamp_ms] if args.key?(:timestamp_ms)\n end", "def update!(**args)\n @style_image_type_predictions = args[:style_image_type_predictions] if args.key?(:style_image_type_predictions)\n @version = args[:version] if args.key?(:version)\n end", "def save\n return false if @changed_values.empty?\n @errors.clear\n temp_file = Tempfile.new('mini_exiftool')\n temp_file.close\n temp_filename = temp_file.path\n FileUtils.cp filename, temp_filename\n all_ok = true\n @changed_values.each do |tag, val|\n original_tag = MiniExiftool.original_tag(tag)\n arr_val = val.kind_of?(Array) ? val : [val]\n arr_val.map! {|e| convert e}\n tag_params = ''\n arr_val.each do |v|\n tag_params << %Q(-#{original_tag}=\"#{v}\" )\n end\n opt_params = ''\n opt_params << (arr_val.detect {|x| x.kind_of?(Numeric)} ? '-n ' : '')\n opt_params << (@convert_encoding ? '-L ' : '')\n cmd = %Q(#@@cmd -q -P -overwrite_original #{opt_params} #{tag_params} \"#{temp_filename}\")\n result = run(cmd)\n unless result\n all_ok = false\n @errors[tag] = @error_text.gsub(/Nothing to do.\\n\\z/, '').chomp\n end\n end\n if all_ok\n FileUtils.cp temp_filename, filename\n reload\n end\n temp_file.delete\n all_ok\n end", "def update!(**args)\n @image_alt_text = args[:image_alt_text] if args.key?(:image_alt_text)\n @image_type = args[:image_type] if args.key?(:image_type)\n @image_url = args[:image_url] if args.key?(:image_url)\n @subtitle = args[:subtitle] if args.key?(:subtitle)\n @title = args[:title] if args.key?(:title)\n end", "def update!(**args)\n @image_alt_text = args[:image_alt_text] if args.key?(:image_alt_text)\n @image_type = args[:image_type] if args.key?(:image_type)\n @image_url = args[:image_url] if args.key?(:image_url)\n @subtitle = args[:subtitle] if args.key?(:subtitle)\n @title = args[:title] if args.key?(:title)\n end", "def update!(**args)\n @image_alt_text = args[:image_alt_text] if args.key?(:image_alt_text)\n @image_type = args[:image_type] if args.key?(:image_type)\n @image_url = args[:image_url] if args.key?(:image_url)\n @subtitle = args[:subtitle] if args.key?(:subtitle)\n @title = args[:title] if args.key?(:title)\n end", "def convert_tiff_to_fax_from_request\n puts('Update parameters of TIFF image from request body according to fax parameters.')\n\n upload_sample_image_to_cloud\n\n # Update TIFF Image parameters according to fax parameters\n out_path = nil\n storage = nil # We are using default Cloud Storage\n\n input_stream = File.open(File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, get_sample_image_file_name), 'r')\n request = AsposeImagingCloud::CreateFaxTiffRequest.new(input_stream, out_path, storage)\n\n puts('Call CreateFaxTiff')\n\n updated_image = imaging_api.create_fax_tiff(request)\n save_updated_sample_image_to_output(updated_image, updated_image)\n puts\n end", "def operation(*args)\n src_file, out_file = args\n image = Vips::Image.new_from_file src_file\n image.tiffsave(out_file, **options)\n # Return lof if any\n end", "def update!(**args)\n @disk_interface = args[:disk_interface] if args.key?(:disk_interface)\n @image = args[:image] if args.key?(:image)\n @size_gb = args[:size_gb] if args.key?(:size_gb)\n @snapshot = args[:snapshot] if args.key?(:snapshot)\n @type = args[:type] if args.key?(:type)\n end", "def update!(**args)\n @image = args[:image] if args.key?(:image)\n @java_jars = args[:java_jars] if args.key?(:java_jars)\n @properties = args[:properties] if args.key?(:properties)\n @python_packages = args[:python_packages] if args.key?(:python_packages)\n end", "def write_info_tags(filename, info, map)\n photo = MiniExiftool.new(filename)\n tags = MiniExiftool.writable_tags\n\n info.to_h.each do |key, val|\n tag = map[key]\n if tags.find {|x| x == tag} and tag != nil\n photo[tag] = val\n end\n end\n\n state = photo.save\nend", "def set_image_attrib\n @image_attrib = ImageAttrib.find(params[:id])\n end", "def update!(**args)\n @docid = args[:docid] if args.key?(:docid)\n @frame_identifier = args[:frame_identifier] if args.key?(:frame_identifier)\n @regions = args[:regions] if args.key?(:regions)\n @starburst_features_v4 = args[:starburst_features_v4] if args.key?(:starburst_features_v4)\n @starburst_tokens_v4 = args[:starburst_tokens_v4] if args.key?(:starburst_tokens_v4)\n @thumbnail_type = args[:thumbnail_type] if args.key?(:thumbnail_type)\n end", "def update!(**args)\n @image_alt_text = args[:image_alt_text] if args.key?(:image_alt_text)\n @image_style = args[:image_style] if args.key?(:image_style)\n @image_url = args[:image_url] if args.key?(:image_url)\n @subtitle = args[:subtitle] if args.key?(:subtitle)\n @title = args[:title] if args.key?(:title)\n end", "def update!(**args)\n @bbox = args[:bbox] if args.key?(:bbox)\n @creation_time = args[:creation_time] if args.key?(:creation_time)\n @description = args[:description] if args.key?(:description)\n @id = args[:id] if args.key?(:id)\n @last_modified_time = args[:last_modified_time] if args.key?(:last_modified_time)\n @name = args[:name] if args.key?(:name)\n @project_id = args[:project_id] if args.key?(:project_id)\n @raster_type = args[:raster_type] if args.key?(:raster_type)\n @tags = args[:tags] if args.key?(:tags)\n end", "def update!(**args)\n @classification = args[:classification] if args.key?(:classification)\n @image_based_detection_done = args[:image_based_detection_done] if args.key?(:image_based_detection_done)\n @timestamp = args[:timestamp] if args.key?(:timestamp)\n end", "def update!(**args)\n @image_style = args[:image_style] if args.key?(:image_style)\n @image_url = args[:image_url] if args.key?(:image_url)\n @subtitle = args[:subtitle] if args.key?(:subtitle)\n @title = args[:title] if args.key?(:title)\n end", "def update!(**args)\n @image_style = args[:image_style] if args.key?(:image_style)\n @image_url = args[:image_url] if args.key?(:image_url)\n @subtitle = args[:subtitle] if args.key?(:subtitle)\n @title = args[:title] if args.key?(:title)\n end", "def update!(**args)\n @image_style = args[:image_style] if args.key?(:image_style)\n @image_url = args[:image_url] if args.key?(:image_url)\n @subtitle = args[:subtitle] if args.key?(:subtitle)\n @title = args[:title] if args.key?(:title)\n end", "def update_image_features(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :PUT, nil)\n nil\n end", "def append_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, nil)\n nil\n end", "def update!(**args)\n @image_url = args[:image_url] if args.key?(:image_url)\n @status = args[:status] if args.key?(:status)\n @type = args[:type] if args.key?(:type)\n end", "def update!(**args)\n @background_type = args[:background_type] if args.key?(:background_type)\n @collage = args[:collage] if args.key?(:collage)\n @cropping = args[:cropping] if args.key?(:cropping)\n @model_type = args[:model_type] if args.key?(:model_type)\n @nfs = args[:nfs] if args.key?(:nfs)\n @object_count = args[:object_count] if args.key?(:object_count)\n @overlay = args[:overlay] if args.key?(:overlay)\n @selfie = args[:selfie] if args.key?(:selfie)\n @text_overlay = args[:text_overlay] if args.key?(:text_overlay)\n @version = args[:version] if args.key?(:version)\n end", "def modify_jpeg2000(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def update\n respond_to do |format|\n if @taxi_image.update(taxi_image_params)\n format.html { redirect_to @taxi_image, notice: 'Taxi image was successfully updated.' }\n format.json { render :show, status: :ok, location: @taxi_image }\n else\n format.html { render :edit }\n format.json { render json: @taxi_image.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @alt_text = args[:alt_text] if args.key?(:alt_text)\n @border_style = args[:border_style] if args.key?(:border_style)\n @crop_style = args[:crop_style] if args.key?(:crop_style)\n @image_uri = args[:image_uri] if args.key?(:image_uri)\n end", "def update!(**args)\n @alt_text = args[:alt_text] if args.key?(:alt_text)\n @border_style = args[:border_style] if args.key?(:border_style)\n @crop_style = args[:crop_style] if args.key?(:crop_style)\n @image_uri = args[:image_uri] if args.key?(:image_uri)\n end", "def update!(**args)\n @alt_text = args[:alt_text] if args.key?(:alt_text)\n @border_style = args[:border_style] if args.key?(:border_style)\n @crop_style = args[:crop_style] if args.key?(:crop_style)\n @image_uri = args[:image_uri] if args.key?(:image_uri)\n end", "def update!(**args)\n @image = args[:image] unless args[:image].nil?\n end", "def update\n par = img_properties\n logger.info(\"parameters: #{par.inspect}\")\n valid = true\n\n # find by user associated to app key, not by user from request parameter!\n @image = Image.editable_by(@user).find_by_guid(params[:id])\n\n return not_found if !@image\n\n # set these variables back to nil if they were in the request but blank\n if par[:ref]\n @image.ref = par[:ref].blank? ? nil : par[:ref]\n end\n if par[:name]\n @image.name = par[:name].blank? ? nil : par[:name]\n end\n if par[:page_url]\n @image.page_url = par[:page_url].blank? ? nil : par[:page_url]\n end\n @image.private = par[:private] if par[:private]\n\n # update calibration data if specified\n if !par[:calibrate_length].blank?\n @image.calibrate_length = par[:calibrate_length].to_f\n @image.calibrate_unit = par[:calibrate_unit].to_i if !par[:calibrate_unit].blank?\n @image.calibrate_coords = par[:calibrate_coords] if !par[:calibrate_coords].blank?\n @image.ppi = calculate_ppi(@image)\n end\n\n orig_url = par[:original_url] || par[:url]\n begin\n # this may fail\n if !orig_url.blank? && orig_url != @image.original_url\n # url was updated\n @image.remote_upload_url = orig_url\n @image.original_url = orig_url\n end\n rescue CarrierWave::DownloadError\n @image.errors.add(:remote_upload_url, \"^This url doesn't appear to be valid\")\n valid = false\n rescue CarrierWave::IntegrityError\n @image.errors.add(:remote_upload_url, \"^This url does not appear to point to a valid image\")\n valid = false\n rescue StandardError\n @image.errors.add(:remote_upload_url, \"There does not appear to be an image at this url\")\n valid = false\n end\n\n if valid && @image.save\n # update product if set\n @image.user_product = par[:product] if par[:product]\n\n image_data = @image.js_serialize\n # if the user hit the 'save and next' button, include the guid of the next image in the response.\n # The client side will redirect to the edit page for that image. \n if params[:commit] == 'save and next'\n image = Image.find_most_recent_uncalibrated(current_user.id)\n image_data['nextImage'] = image.guid if image\n end\n render :json => image_data, :callback => params[:callback]\n else\n render :json => { :error => 403, :messages => prepare_errors(@image), :callback => params[:callback] }, :status => 200\n end\n end", "def update!(**args)\n @inferred_image_id = args[:inferred_image_id] if args.key?(:inferred_image_id)\n @inferred_image_source = args[:inferred_image_source] if args.key?(:inferred_image_source)\n @inferred_image_type = args[:inferred_image_type] if args.key?(:inferred_image_type)\n @neardup_info = args[:neardup_info] if args.key?(:neardup_info)\n end", "def update!(**args)\n @dpi = args[:dpi] if args.key?(:dpi)\n @height_px = args[:height_px] if args.key?(:height_px)\n @m_size = args[:m_size] if args.key?(:m_size)\n @neng_size = args[:neng_size] if args.key?(:neng_size)\n @width_px = args[:width_px] if args.key?(:width_px)\n end", "def put_image_extract_as_tiff_with_http_info(name, image_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_image_extract_as_tiff ...\"\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_image_extract_as_tiff\"\n end\n # verify the required parameter 'image_id' is set\n if @api_client.config.client_side_validation && image_id.nil?\n fail ArgumentError, \"Missing the required parameter 'image_id' when calling PdfApi.put_image_extract_as_tiff\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/images/{imageId}/extract/tiff\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'imageId' + '}', image_id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'destFolder'] = opts[:'dest_folder'] if !opts[:'dest_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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_image_extract_as_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update!(**args)\n @alt_text = args[:alt_text] if args.key?(:alt_text)\n @aspect_ratio = args[:aspect_ratio] if args.key?(:aspect_ratio)\n @image_url = args[:image_url] if args.key?(:image_url)\n @on_click = args[:on_click] if args.key?(:on_click)\n end", "def update_db_record\n img_file = file.to_file\n img = ::Magick::Image::read(img_file).first\n model.height = img.rows\n model.width = img.columns\n \n new_filename = model.imageable.filename( file.extension )\n new_file = file.copy_to(type_dir + new_filename)\n model.url = access_dir + new_filename\n model.save\n end", "def put_images_extract_as_tiff(name, page_number, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = put_images_extract_as_tiff_with_http_info(name, page_number, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = put_images_extract_as_tiff_with_http_info(name, page_number, opts)\n else\n raise\n end\n return data\n end", "def update!(**args)\n @aspect_ratio = args[:aspect_ratio] if args.key?(:aspect_ratio)\n @image_url = args[:image_url] if args.key?(:image_url)\n @on_click = args[:on_click] if args.key?(:on_click)\n end", "def update!(**args)\n @aspect_ratio = args[:aspect_ratio] if args.key?(:aspect_ratio)\n @image_url = args[:image_url] if args.key?(:image_url)\n @on_click = args[:on_click] if args.key?(:on_click)\n end", "def update!(**args)\n @aspect_ratio = args[:aspect_ratio] if args.key?(:aspect_ratio)\n @image_url = args[:image_url] if args.key?(:image_url)\n @on_click = args[:on_click] if args.key?(:on_click)\n end", "def put_document_save_as_tiff(request)\n data, _status_code, _headers = put_document_save_as_tiff_with_http_info(request)\n request_token if _status_code == 401\n data\n end", "def update\n \tif params[:instrument][:picture] != nil\n \t @instrument.image_url = upload \n \tend\n \t\n set_available_time\n \t\n respond_to do |format|\n if @instrument.update(instrument_params)\n format.html { redirect_to @instrument, notice: 'Instrument was successfully updated.' }\n format.json { render :show, status: :ok, location: @instrument }\n else\n format.html { render :edit }\n format.json { render json: @instrument.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @image = ImagePost.find(params[:id])\n\n respond_to do |format|\n if @image.update_attributes(params[:imagest_po])\n track_activity @image\n format.html { redirect_to @image, notice: 'Image post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end", "def save\n\n properties = {}\n # exif = {}\n # KCGImagePropertyExifDictionary\n # exif[KCGImagePropertyExifUserComment] = 'Image downloaded from www.sheetmusicplus.com'\n # exif[KCGImagePropertyExifAuxOwnerName] = 'www.sheetmusicplus.com'\n if @filetype == :pdf\n CGPDFContextEndPage(@ctx)\n CGContextFlush(@ctx)\n return\n elsif @filetype == :png\n format = NSPNGFileType\n elsif @filetype == :tif\n format = NSTIFFFileType\n properties[NSImageCompressionMethod] = NSTIFFCompressionLZW\n #properties[NSImageCompressionMethod] = NSTIFFCompressionNone\n elsif @filetype == :gif\n format = NSGIFFileType\n #properties[NSImageDitherTransparency] = 0 # 1 = dithered, 0 = not dithered\n #properties[NSImageRGBColorTable] = nil # For GIF input and output. It consists of a 768 byte NSData object that contains a packed RGB table with each component being 8 bits.\n elsif @filetype == :jpg\n format = NSJPEGFileType\n properties[NSImageCompressionFactor] = @quality # (jpeg compression, 0.0 = max, 1.0 = none)\n #properties[NSImageEXIFData] = exif\n end\n cgimageref = CGBitmapContextCreateImage(@ctx) # => CGImageRef\n bitmaprep = NSBitmapImageRep.alloc.initWithCGImage(cgimageref) # => NSBitmapImageRep\n blob = bitmaprep.representationUsingType(format, properties:properties) # => NSConcreteData\n blob.writeToFile(@output, atomically:true)\n true\n end", "def bike_image=(file_data)\n @file_data = file_data\n end", "def update!(**args)\n @alt_text = args[:alt_text] if args.key?(:alt_text)\n @border_style = args[:border_style] if args.key?(:border_style)\n @crop_style = args[:crop_style] if args.key?(:crop_style)\n @image_url = args[:image_url] if args.key?(:image_url)\n end", "def update!(**args)\n @discretized_style_image_type_confidence = args[:discretized_style_image_type_confidence] if args.key?(:discretized_style_image_type_confidence)\n @style_image_type = args[:style_image_type] if args.key?(:style_image_type)\n end", "def modify_jpeg(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def update!(**args)\n @imagesearch_docid = args[:imagesearch_docid] if args.key?(:imagesearch_docid)\n @is_thumbnail_missing = args[:is_thumbnail_missing] if args.key?(:is_thumbnail_missing)\n @serving_metadata = args[:serving_metadata] if args.key?(:serving_metadata)\n @thumbnail_info = args[:thumbnail_info] if args.key?(:thumbnail_info)\n @timestamp_ms = args[:timestamp_ms] if args.key?(:timestamp_ms)\n end", "def update!(**args)\n @boot_disk_size_gb = args[:boot_disk_size_gb] if args.key?(:boot_disk_size_gb)\n @cpus = args[:cpus] if args.key?(:cpus)\n @enable_load_balancer = args[:enable_load_balancer] if args.key?(:enable_load_balancer)\n @image = args[:image] if args.key?(:image)\n @image_type = args[:image_type] if args.key?(:image_type)\n @labels = args[:labels] if args.key?(:labels)\n @memory_mb = args[:memory_mb] if args.key?(:memory_mb)\n @replicas = args[:replicas] if args.key?(:replicas)\n @taints = args[:taints] if args.key?(:taints)\n @vsphere_config = args[:vsphere_config] if args.key?(:vsphere_config)\n end", "def update!(**args)\n @image_config = args[:image_config] if args.key?(:image_config)\n @instance_config = args[:instance_config] if args.key?(:instance_config)\n @notification_config = args[:notification_config] if args.key?(:notification_config)\n @sequence_number = args[:sequence_number] if args.key?(:sequence_number)\n end", "def update_image_attributes\n if imageable.present?\n self.width, self.height = `identify -format \"%wx%h\" #{url.file.path}`.split(/x/)\n end\n end", "def processImage(params, metadata)\n url = params['metadataServerURL']\n \n # This is used to determine if we should actually process this image or\n # not, based on some criteria (e.g. modification date and whether or not\n # the tile set exists.\n process = false\n \n # See if there is an existing checkpoint and date for this map.\n checkpointDate = nil\n @checkpoints.each do |checkpoint|\n if (checkpoint['id'].to_s == metadata['id'].to_s)\n checkpointDate = DateTime.parse(checkpoint['updated_at'])\n break\n end\n end\n \n # If there is no date, then we haven't seen this map before, so we want\n # to process it. Otherwise, we only process the map if the new date is\n # more recent than the old checkpoint date.\n currentDate = DateTime.parse(metadata['updated_at'])\n if (checkpointDate == nil || checkpointDate < currentDate) then process = true end\n \n # We don't want to process an image if there aren't enough control points,\n # regardless of if the times check out...\n if (metadata['no_control_points'].to_i < 3) then process = false end\n controlPoints = fetchControlPoints(url, metadata['id'])\n\n if (process)\n puts 'Processing map '+metadata['id'].to_s+'...'\n \n # Reset the metadata to include all the in-depth metadata for this map.\n metadata = getMapMetadata(url, metadata['id'])\n fileName = metadata['identifier']\n \n # The y values in the database is \"wrong\": the conversion commands\n # start from the top left corner but MapHub starts from the bottom\n # left. Therefore, we need to \"flip\" the y values around the median\n # line of the map.\n mapHeight = Float(metadata['height'])\n median = mapHeight / 2\n controlPoints.map! do |cp|\n y = Float(cp['y'])\n if (y > median)\n difference = y - median\n y = median - difference\n elsif (y < median)\n difference = median - y\n y = median + difference\n else\n # This point is exactly on the median. Don't anger it.\n end\n cp['y'] = y\n cp\n end\n \n ENV['GDAL_DATA'] = $GDALRoot\n dir = Dir.mktmpdir()\n \n # Translate the image.\n translateCommand = 'gdal_translate -of VRT -a_srs EPSG:4326'\n controlPoints.each do |cp|\n translateCommand = translateCommand+' -gcp '+cp['x'].to_s+' '+cp['y'].to_s+' '+cp['lng']+' '+cp['lat']\n end\n translateCommand = translateCommand+' '+params['imageDirectory']+'/raw/'+fileName+'.jp2 '+dir.to_s+'/'+fileName+'-original.vrt'\n puts \"Translating: #{translateCommand}\"\n system(translateCommand)\n \n # Warp the image.\n warpCommand='gdalwarp -of VRT -s_srs EPSG:4326 -t_srs EPSG:4326 '+dir.to_s+'/'+fileName+'-original.vrt '+dir.to_s+'/'+fileName+'-warped.vrt'\n puts \"Warping: #{warpCommand}\"\n system(warpCommand)\n\n # Generate the tile set, placing the generated images in the temporary\n # directory.\n #tileCommand='gdal2tiles.py -n '+dir.to_s+'/'+fileName+'-warped.vrt '+dir.to_s+'/'+$tilesetName\n publishURL = params['publishServerURL'] + $tilesetName\n tileCommand='gdal2tiles.py -u '+publishURL+' -k '+dir.to_s+'/'+fileName+'-warped.vrt '+dir.to_s+'/'+fileName\n puts \"Tiling: #{tileCommand}\"\n system(tileCommand)\n \n # Next we need to tell the server what the new map boundaries are. Get\n # the XML data so we can parse out the boundaries.\n # xmlFile = File.new(dir.to_s+'/'+$tilesetName+'/tilemapresource.xml')\n # xmlDoc = REXML::Document.new(xmlFile)\n # bounds = xmlDoc.root.elements['BoundingBox'].attributes\n # \n # Make a PUT request to update the map with the new boundaries.\n # This is disabled for the time being.\n # uri = URI(params['metadataServerURL'].to_s+'maps/'+metadata['id'].to_s)\n # request = Net::HTTP::Put.new(uri.path)\n # request.set_form_data(\n # 'ne_lat' => bounds['maxx'],\n # 'ne_lng' => bounds['maxy'],\n # 'sw_lat' => bounds['minx'],\n # 'sw_lng' => bounds['miny']\n # )\n # http = Net::HTTP.new(uri.host, uri.port)\n # response = http.request(request)\n \n # Clean up the generated files to leave only the images and the XML\n # file which contains the map bounds and other GIS information.\n FileUtils.rm(Dir.glob(dir.to_s+'/'+$tilesetName+'/*.html'))\n \n # Remove the current tile set and move the new tile set into its\n # place.\n FileUtils.mkdir_p(params['imageDirectory']+'/'+$tilesetName)\n FileUtils.rm_rf(params['imageDirectory']+'/'+$tilesetName+'/'+fileName)\n \n # Move /tmp/.../IDENTIFIER to target/ts_google/IDENTIFIER\n FileUtils.mv(dir.to_s+'/'+fileName, params['imageDirectory']+'/'+$tilesetName+'/'+fileName)\n \n return true\n end\n \n return false\n end", "def update\n respond_to do |format|\n if @trfileimage.update(trfileimage_params)\n format.html { redirect_to @trfileimage, notice: 'Trfileimage was successfully updated.' }\n format.json { render :show, status: :ok, location: @trfileimage }\n else\n format.html { render :edit }\n format.json { render json: @trfileimage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_image(branch, old_path, new_file, author, message)\n repo = satelliterepo\n repo.checkout(branch)\n file = File.join satellitedir, old_path\n FileUtils.cp new_file.tempfile.path, file\n repo.index.add old_path\n commit_id = satellite_commit(\n repo,\n message,\n author,\n branch\n )\n generate_thumbnail old_path, commit_id\n repo.checkout('master')\n end", "def update\n respond_to do |format|\n if @image.update(image_params)\n @image.text = RTesseract.new(Rails.root.join('public', 'assets', @image.id.to_s, @image.url.file.filename).to_s, :processor => \"none\")\n @image.update(image_params)\n format.html { redirect_to @image, notice: 'Image was successfully updated.' }\n format.json { render :show, status: :ok, location: @image }\n else\n format.html { render :edit }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @raw_image.update(raw_image_params)\n redirect_to admin_raw_images_path\n\n end", "def template_image=(filepath)\n @template_image = read_image(filepath)\n end", "def update_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def modify_file\n file_path = \"./app/views/hocr_files/_p#{self.filename}_hocr.html\"\n file = File.open(file_path, \"r\")\n data = file.read\n data = self.replace_bbox(data)\n data = self.add_image(data)\n File.open(file_path, 'w') {|f| f.write(data) }\n end", "def resize_image(params)\n # The path of the image\n path = \"public/images/#{params[1]}/#{@tempo.id}_#{params[1]}.#{params[0]}\"\n # Read the image\n img = Magick::Image.read(\"public/images/original/#{@original_image_name}\").first\n # Resize and Crop the image\n target = Magick::Image.new(params[2], params[3])\n thumb = img.resize_to_fill!(params[2], params[3])\n target.composite(thumb, Magick::CenterGravity, Magick::CopyCompositeOp).write(path)\n # Insert the width and height into an object\n @tempo.width, @tempo.height = \"#{params[2]}\", \"#{params[3]}\"\n # Add the link and tags to its DB\n add_linkID_tagsID(path,params[1])\n # Delete the image after uploading it to the storage\n File.delete(path)\n end", "def update!(**args)\n @preview_length = args[:preview_length] if args.key?(:preview_length)\n @xtag_list = args[:xtag_list] if args.key?(:xtag_list)\n end", "def update!(**args)\n @preview_length = args[:preview_length] if args.key?(:preview_length)\n @xtag_list = args[:xtag_list] if args.key?(:xtag_list)\n end", "def image=(img)\n @image__ = img\n end", "def update_image(branch, old_path, new_file, author, message)\n repo = satelliterepo\n repo.checkout(branch)\n # to test if first image is updated\n file = File.join satellitedir, old_path\n FileUtils.cp new_file.tempfile.path, file\n repo.index.add old_path\n commit_id = satellite_commit(\n repo,\n message,\n author,\n branch\n )\n generate_thumbnail old_path, commit_id\n generate_inspire_image old_path if branch == 'master'\n repo.checkout('master')\n end", "def create_modified_jpeg(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def update\n\n params = image_params\n params[\"tags\"] = params[\"tags\"].delete_suffix(',')\n\n respond_to do |format|\n if @image.update(params)\n format.html { redirect_to @image, notice: \"Image was successfully updated.\" }\n format.json { render :show, status: :ok, location: @image }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_modified_jpeg2000(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end" ]
[ "0.75248754", "0.64094824", "0.63928926", "0.6162859", "0.59199685", "0.58921754", "0.5878425", "0.5715703", "0.5683739", "0.56832814", "0.5631916", "0.5582434", "0.5565626", "0.55581564", "0.555063", "0.5541528", "0.55397534", "0.5526326", "0.55211145", "0.5505909", "0.549765", "0.54818475", "0.5470881", "0.5468889", "0.5460563", "0.54339063", "0.54263586", "0.542172", "0.54216754", "0.54013205", "0.5388659", "0.53849304", "0.53737366", "0.53680265", "0.53644073", "0.53551936", "0.5343569", "0.5343569", "0.5343569", "0.5340962", "0.5334923", "0.5332994", "0.53251797", "0.5294606", "0.52911055", "0.5285512", "0.5283089", "0.5273275", "0.527121", "0.5261615", "0.5261615", "0.5261615", "0.5258036", "0.5255019", "0.5254413", "0.5251668", "0.525132", "0.52483183", "0.52425534", "0.52425534", "0.52425534", "0.5240259", "0.52276325", "0.52229273", "0.5216779", "0.5209627", "0.5200927", "0.5200085", "0.519967", "0.51981723", "0.51981723", "0.51981723", "0.5193219", "0.5192545", "0.51700795", "0.5169341", "0.51666355", "0.51644", "0.51628506", "0.5162782", "0.5161314", "0.51572174", "0.5156592", "0.5155072", "0.51544964", "0.51535666", "0.51476735", "0.5141456", "0.513815", "0.51362544", "0.51170874", "0.5113745", "0.510802", "0.5091394", "0.5091394", "0.5085904", "0.5075568", "0.5073577", "0.5072193", "0.5066439" ]
0.7163092
1
Update parameters of a TIFF image, and upload updated image to Cloud Storage
def modify_tiff_and_upload_to_storage puts('Update parameters of a TIFF image and upload to cloud storage') upload_sample_image_to_cloud compression = 'adobedeflate' resolution_unit = 'inch' bit_depth = 1 horizontal_resolution = 150.0 vertical_resolution = 150.0 from_scratch = nil folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage storage = nil # We are using default Cloud Storage request = AsposeImagingCloud::ModifyTiffRequest.new( get_sample_image_file_name, bit_depth, compression, resolution_unit, horizontal_resolution, vertical_resolution, from_scratch, folder, storage) puts("Call ModifyTiff with params: compression: #{compression}, resolution unit: #{resolution_unit}, " + "bit depth: #{bit_depth}, horizontal resolution: #{horizontal_resolution}, vertical resolution: " + "#{vertical_resolution}") updated_image = @imaging_api.modify_tiff(request) upload_image_to_cloud(get_modified_sample_image_file_name, updated_image) puts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modify_tiff_from_storage\n puts('Update parameters of a TIFF image from cloud storage')\n\n upload_sample_image_to_cloud\n\n compression = 'adobedeflate'\n resolution_unit = 'inch'\n bit_depth = 1\n horizontal_resolution = 150.0\n vertical_resolution = 150.0\n from_scratch = nil\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ModifyTiffRequest.new(\n get_sample_image_file_name, bit_depth, compression, resolution_unit, horizontal_resolution,\n vertical_resolution, from_scratch, folder, storage)\n\n puts(\"Call ModifyTiff with params: compression: #{compression}, resolution unit: #{resolution_unit}, bit depth:\" +\n \" #{bit_depth}, horizontal resolution: #{horizontal_resolution}, vertical resolution: \" +\n \"#{vertical_resolution}\")\n\n updated_image = imaging_api.modify_tiff(request)\n save_updated_sample_image_to_output(updated_image, false)\n puts\n end", "def update_tiff_to_fax_from_storage\n puts('Update parameters of TIFF image according to fax parameters')\n\n upload_sample_image_to_cloud\n\n # Update TIFF Image parameters according to fax parameters\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ConvertTiffToFaxRequest.new(get_sample_image_file_name, storage, folder)\n\n puts('Call ConvertTiffToFax')\n\n updated_image = imaging_api.convert_tiff_to_fax(request)\n save_updated_image_to_output('ConvertTiffToFax.tiff', updated_image)\n puts\n end", "def append_tiff_from_storage\n puts('Appends existing TIFF image to another existing TIFF image')\n\n append_file_name = 'Append.tiff' # Image file name to be appended to original one\n\n upload_sample_image_to_cloud\n upload_image_to_cloud(append_file_name, File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, append_file_name))\n\n # Update TIFF Image parameters according to fax parameters\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n update_request = AsposeImagingCloud::AppendTiffRequest.new(\n get_sample_image_file_name, append_file_name, storage, folder)\n\n puts('Call AppendTiff')\n\n imaging_api.append_tiff(update_request)\n\n # Download updated file to local storage\n download_request = AsposeImagingCloud::DownloadFileRequest.new(\n File.join(ImagingBase::CLOUD_PATH, get_sample_image_file_name), storage)\n updated_image = imaging_api.download_file(download_request)\n save_updated_image_to_output('AppendToTiff.tiff', updated_image)\n puts\n end", "def create_modified_tiff_from_request_body\n puts('Update parameters of a TIFF image from request body')\n\n compression = 'adobedeflate'\n resolution_unit = 'inch'\n bit_depth = 1\n horizontal_resolution = 150.0\n vertical_resolution = 150.0\n from_scratch = nil\n storage = nil # We are using default Cloud Storage\n out_path = nil # Path to updated file (if this is empty, response contains streamed image)\n\n input_stream = File.open(File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, get_sample_image_file_name), 'r')\n request = AsposeImagingCloud::CreateModifiedTiffRequest.new(\n input_stream, bit_depth, compression, resolution_unit, horizontal_resolution, vertical_resolution,\n from_scratch, out_path, storage)\n\n puts(\"Call CreateModifiedTiff with params: compression: #{compression}, resolution unit: #{resolution_unit}, \" +\n \"bit depth: #{bit_depth}, horizontal resolution: #{horizontal_resolution}, vertical resolution: \" +\n \"#{vertical_resolution}\")\n\n updated_image = imaging_api.create_modified_tiff(request)\n save_updated_sample_image_to_output(updated_image, true)\n puts\n end", "def image_upload\n measurement = Measurement.find_by_id(params[:measurement_id])\n\n if measurement\n measurement.image = params[:image]\n measurement.save!\n end\n end", "def put_images_extract_as_tiff_with_http_info(name, page_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_images_extract_as_tiff ...\"\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_images_extract_as_tiff\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.put_images_extract_as_tiff\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/images/extract/tiff\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'destFolder'] = opts[:'dest_folder'] if !opts[:'dest_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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_images_extract_as_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def modify_gif_and_upload_to_storage\n puts('Update parameters of a GIF image and upload to cloud storage')\n\n upload_sample_image_to_cloud\n\n background_color_index = 5\n color_resolution = 4\n has_trailer = true\n interlaced = false\n is_palette_sorted = true\n pixel_aspect_ratio = 4\n from_scratch = nil\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ModifyGifRequest.new(\n get_sample_image_file_name, background_color_index, color_resolution, has_trailer, interlaced,\n is_palette_sorted, pixel_aspect_ratio, from_scratch, folder, storage)\n\n puts(\"Call ModifyGif with params: background color index: #{background_color_index}, color resolution: \" +\n \"#{color_resolution}, has trailer: #{has_trailer}, interlaced: #{interlaced}}, is palette sorted: \" +\n \"#{is_palette_sorted}, pixel aspect ratio: #{pixel_aspect_ratio}\")\n\n updated_image = @imaging_api.modify_gif(request)\n upload_image_to_cloud(get_modified_sample_image_file_name, updated_image)\n puts\n end", "def upload_derivs(img, filename)\n\n\n ret = {}\n\n # Full:\n full_path = \"#{BUCKET_FOLDER}/full/#{filename}\" # data['capture_uuid']}.#{suffix}.jpg\"\n upload_image img, full_path\n ret['file_path'] = \"https://s3.amazonaws.com/#{BUCKET_NAME}/#{full_path}\"\n\n # Thumb (exactly 150px wide by however tall):\n img.change_geometry(\"150\") { |cols, rows, img| img.resize!(cols, rows) }\n thumb_path = \"#{BUCKET_FOLDER}/thumb/#{filename}\"\n upload_image img, thumb_path\n ret['thumbnail'] = \"https://s3.amazonaws.com/#{BUCKET_NAME}/#{thumb_path}\"\n\n ret\nend", "def update_template_with_image_id(template)\n params = template.parameters\n params.each do |key, value|\n update_params_with_image_id(params, key, value)\n end\n end", "def update_file(params)\n self.processed = false\n self.attributes = params\n set_upload_attributes\n save!\n Avatar.delay.finalize_and_cleanup(id)\n end", "def upload_weathermap_image(upload, current_user_guid, org_token, options={})\n return if upload.length==0\n self.init_uploaded_file(upload, 'WeatherMap Image', current_user_guid,\n options)\n\n oi = XmlSaving.store_original_file(@file_path, self.guid, @input_category, @mime_type) if is_file_upload\n oi = XmlSaving.store_original_input(upload, self.guid, @input_category, @mime_type) if !is_file_upload\n\n # Store the WeatherMap Images record\n WeatherMapImage.create(organization_token: org_token, image_id: oi.id)\n\n self.status = ActionStatus::SUCCEEDED\n self.save\n IngestUtilities.cleanup(self, @file_path)\n rescue Exception => e\n IngestUtilities.add_error(self, \"#{e.backtrace.first}: #{e.message} (#{e.class})\")\n ExceptionLogger.debug(\"exception: #{e}, message: #{e.message}, backtrace: #{e.backtrace}\")\n self.save\n IngestUtilities.cleanup(self, @file_path)\n end", "def update_image(branch, old_path, new_file, author, message)\n repo = satelliterepo\n repo.checkout(branch)\n file = File.join satellitedir, old_path\n FileUtils.cp new_file.tempfile.path, file\n repo.index.add old_path\n commit_id = satellite_commit(\n repo,\n message,\n author,\n branch\n )\n generate_thumbnail old_path, commit_id\n repo.checkout('master')\n end", "def create_updated_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def update!(**args)\n @image_bytes = args[:image_bytes] if args.key?(:image_bytes)\n end", "def update!(**args)\n @byte_size = args[:byte_size] if args.key?(:byte_size)\n @encoding_quality = args[:encoding_quality] if args.key?(:encoding_quality)\n @encoding_type = args[:encoding_type] if args.key?(:encoding_type)\n @height = args[:height] if args.key?(:height)\n @image_blob_id = args[:image_blob_id] if args.key?(:image_blob_id)\n @image_bytes = args[:image_bytes] if args.key?(:image_bytes)\n @image_string = args[:image_string] if args.key?(:image_string)\n @width = args[:width] if args.key?(:width)\n end", "def img\n source = Tinify.from_file(params[:file].tempfile.path)\n if source.store(\n service: 's3',\n aws_access_key_id: ENV['AWS_Access_Key_ID'],\n aws_secret_access_key: ENV['AWS_Secret_Access_Key'],\n region: 'us-west-1',\n path: 'gkbimages//client/'+params[:file].original_filename\n )\n render :json => {status: 0, data: 'https://s3-us-west-1.amazonaws.com/gkbimages//client/'+params[:file].original_filename}\n else \n render :json => {status: 404, data: \"Something went wrong with image upload\"}\n end\n end", "def update_image(branch, old_path, new_file, author, message)\n repo = satelliterepo\n repo.checkout(branch)\n # to test if first image is updated\n file = File.join satellitedir, old_path\n FileUtils.cp new_file.tempfile.path, file\n repo.index.add old_path\n commit_id = satellite_commit(\n repo,\n message,\n author,\n branch\n )\n generate_thumbnail old_path, commit_id\n generate_inspire_image old_path if branch == 'master'\n repo.checkout('master')\n end", "def update!(**args)\n @bytes_value = args[:bytes_value] if args.key?(:bytes_value)\n @float_value = args[:float_value] if args.key?(:float_value)\n @image_template = args[:image_template] if args.key?(:image_template)\n @int32_value = args[:int32_value] if args.key?(:int32_value)\n @version = args[:version] if args.key?(:version)\n end", "def create_modified_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def update_image image\n temp_path = @image_folder.detect{|image_string| image_string.downcase == \"#{@image_path}/#{image.image_file_name}\".downcase}\n filename = File.basename(temp_path)\n image.image_number = @img_count\n\n @img_count += 1\n if temp_path.blank?\n InputBatch::Log.status_log.error \">>>>>>>>Image #{filename} not found<<<<<<<<<\"\n puts \">>>>>>>>>>>>Image #{filename} not found\"\n InputBatch::Log.error_log.error \"Error on line #{@row_index} : Image #{filename} not found\"\n else\n InputBatch::Log.status_log.info \"Image #{filename} found\"\n image.page_count = %x[identify #{temp_path}].split(filename).length-1 rescue nil\n end\n\n rename_image image if facility.index_file_parser_type == \"WellsFargo_bank\"\n return image\n end", "def update!(**args)\n @gcs_uri = args[:gcs_uri] if args.key?(:gcs_uri)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n end", "def update!(**args)\n @gcs_uri = args[:gcs_uri] if args.key?(:gcs_uri)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n end", "def modify_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def put_image_extract_as_tiff_with_http_info(name, image_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_image_extract_as_tiff ...\"\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_image_extract_as_tiff\"\n end\n # verify the required parameter 'image_id' is set\n if @api_client.config.client_side_validation && image_id.nil?\n fail ArgumentError, \"Missing the required parameter 'image_id' when calling PdfApi.put_image_extract_as_tiff\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/images/{imageId}/extract/tiff\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'imageId' + '}', image_id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'destFolder'] = opts[:'dest_folder'] if !opts[:'dest_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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_image_extract_as_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update!(**args)\n @far = args[:far] if args.key?(:far)\n @format = args[:format] if args.key?(:format)\n @image_height = args[:image_height] if args.key?(:image_height)\n @image_width = args[:image_width] if args.key?(:image_width)\n @mime = args[:mime] if args.key?(:mime)\n @near = args[:near] if args.key?(:near)\n @units = args[:units] if args.key?(:units)\n end", "def update_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def resize_image(params)\n # The path of the image\n path = \"public/images/#{params[1]}/#{@tempo.id}_#{params[1]}.#{params[0]}\"\n # Read the image\n img = Magick::Image.read(\"public/images/original/#{@original_image_name}\").first\n # Resize and Crop the image\n target = Magick::Image.new(params[2], params[3])\n thumb = img.resize_to_fill!(params[2], params[3])\n target.composite(thumb, Magick::CenterGravity, Magick::CopyCompositeOp).write(path)\n # Insert the width and height into an object\n @tempo.width, @tempo.height = \"#{params[2]}\", \"#{params[3]}\"\n # Add the link and tags to its DB\n add_linkID_tagsID(path,params[1])\n # Delete the image after uploading it to the storage\n File.delete(path)\n end", "def upload_new_image_file(detection_flags, image = {})\n @client.post \"/service_json_ssl.svc/UploadNewImage_File\", {detection_flags:detection_flags,imagefile_data:image[:data],original_filename:image[:original_filename]}\n end", "def create_modified_jpeg(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def file_update(project, old_file, new_fie)\n file = ActionDispatch::Http::UploadedFile.new(\n tempfile: upload(new_fie),\n filename: new_fie,\n original_filename: old_file\n )\n post :file_update, user_id: project.user.username,\n id: project.name,\n branch: 'master',\n destination: new_fie,\n message: 'update image',\n file: file\n end", "def set_upload\n @contest.upload.update_column(:image, nil) if params[:image_url].eql?(\"true\")\n @contest.upload.update_column(:file, nil) if params[:file_url].eql?(\"true\")\n end", "def update_db_record\n img_file = file.to_file\n img = ::Magick::Image::read(img_file).first\n model.height = img.rows\n model.width = img.columns\n \n new_filename = model.imageable.filename( file.extension )\n new_file = file.copy_to(type_dir + new_filename)\n model.url = access_dir + new_filename\n model.save\n end", "def put_storage(request, params)\n xmldoc = XMLElement.build_xml(request.body, 'STORAGE')\n image_info = XMLElement.new(xmldoc) if xmldoc != nil\n\n image = ImageOCCI.new(\n Image.build_xml(params[:id]),\n @client)\n\n rc = nil\n if image_info['PERSISTENT'] && image_info['PUBLIC']\n error_msg = \"It is not allowed more than one change per request\"\n return OpenNebula::Error.new(error_msg), 400\n elsif image_info['PERSISTENT'] == 'YES'\n rc = image.persistent\n elsif image_info['PERSISTENT'] == 'NO'\n rc = image.nonpersistent\n elsif image_info['PUBLIC'] == 'YES'\n rc = image.publish\n elsif image_info['PUBLIC'] == 'NO'\n rc = image.unpublish\n end\n\n if OpenNebula.is_error?(rc)\n return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]\n end\n\n # --- Prepare XML Response ---\n image.info\n return to_occi_xml(image, :code=>202)\n end", "def modify_jpeg(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def update\n par = img_properties\n logger.info(\"parameters: #{par.inspect}\")\n valid = true\n\n # find by user associated to app key, not by user from request parameter!\n @image = Image.editable_by(@user).find_by_guid(params[:id])\n\n return not_found if !@image\n\n # set these variables back to nil if they were in the request but blank\n if par[:ref]\n @image.ref = par[:ref].blank? ? nil : par[:ref]\n end\n if par[:name]\n @image.name = par[:name].blank? ? nil : par[:name]\n end\n if par[:page_url]\n @image.page_url = par[:page_url].blank? ? nil : par[:page_url]\n end\n @image.private = par[:private] if par[:private]\n\n # update calibration data if specified\n if !par[:calibrate_length].blank?\n @image.calibrate_length = par[:calibrate_length].to_f\n @image.calibrate_unit = par[:calibrate_unit].to_i if !par[:calibrate_unit].blank?\n @image.calibrate_coords = par[:calibrate_coords] if !par[:calibrate_coords].blank?\n @image.ppi = calculate_ppi(@image)\n end\n\n orig_url = par[:original_url] || par[:url]\n begin\n # this may fail\n if !orig_url.blank? && orig_url != @image.original_url\n # url was updated\n @image.remote_upload_url = orig_url\n @image.original_url = orig_url\n end\n rescue CarrierWave::DownloadError\n @image.errors.add(:remote_upload_url, \"^This url doesn't appear to be valid\")\n valid = false\n rescue CarrierWave::IntegrityError\n @image.errors.add(:remote_upload_url, \"^This url does not appear to point to a valid image\")\n valid = false\n rescue StandardError\n @image.errors.add(:remote_upload_url, \"There does not appear to be an image at this url\")\n valid = false\n end\n\n if valid && @image.save\n # update product if set\n @image.user_product = par[:product] if par[:product]\n\n image_data = @image.js_serialize\n # if the user hit the 'save and next' button, include the guid of the next image in the response.\n # The client side will redirect to the edit page for that image. \n if params[:commit] == 'save and next'\n image = Image.find_most_recent_uncalibrated(current_user.id)\n image_data['nextImage'] = image.guid if image\n end\n render :json => image_data, :callback => params[:callback]\n else\n render :json => { :error => 403, :messages => prepare_errors(@image), :callback => params[:callback] }, :status => 200\n end\n end", "def process_photo(db, filename, data)\n\n # PG update-related methods\n update_pg(db, filename) if photo_exists?(db, filename) == false\n\n # S3 update-related methods\n decoded_image = decode_image(filename, data)\n write_swap_file(filename, decoded_image)\n save_file_to_s3_bucket(filename)\n\n end", "def update!(**args)\n @image = args[:image] if args.key?(:image)\n @tag = args[:tag] if args.key?(:tag)\n end", "def update!(**args)\n @file_path = args[:file_path] if args.key?(:file_path)\n @gcs_timestamps = args[:gcs_timestamps] if args.key?(:gcs_timestamps)\n @size_bytes = args[:size_bytes] if args.key?(:size_bytes)\n end", "def update!(**args)\n @file_path = args[:file_path] if args.key?(:file_path)\n @gcs_timestamps = args[:gcs_timestamps] if args.key?(:gcs_timestamps)\n @size_bytes = args[:size_bytes] if args.key?(:size_bytes)\n end", "def write_webcam_image_to_s3(bucket)\n # Create random name for image\n image_name = SecureRandom.hex(32) + \".jpg\";\n\n # Take picture and store it as image_name\n cli_cmd = $camera_command + \" \" + image_name\n `#{cli_cmd}`\n\n # Open Image file & upload it to StorageGRID\n image_file = File.open(image_name, \"r+\")\n $client.put_object(bucket: bucket, key: image_name,\n metadata: { 'foo' => 'bar' },\n body: image_file.read,\n server_side_encryption: 'AES256'\n )\n image_file.close\n\n # Delete temporary image file from disk\n File.delete(image_file)\n\n # return full URL of image\n $endpoint + \"/\" + bucket + \"/\" + image_name\nend", "def update_image_features(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :PUT, nil)\n nil\n end", "def convert_tiff_to_fax_from_request\n puts('Update parameters of TIFF image from request body according to fax parameters.')\n\n upload_sample_image_to_cloud\n\n # Update TIFF Image parameters according to fax parameters\n out_path = nil\n storage = nil # We are using default Cloud Storage\n\n input_stream = File.open(File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, get_sample_image_file_name), 'r')\n request = AsposeImagingCloud::CreateFaxTiffRequest.new(input_stream, out_path, storage)\n\n puts('Call CreateFaxTiff')\n\n updated_image = imaging_api.create_fax_tiff(request)\n save_updated_sample_image_to_output(updated_image, updated_image)\n puts\n end", "def upload_file(file_upload, owner)\n image = MiniMagick::Image.open(file_upload.tempfile.path)\n image.resize \"500x500>\"\n image.format \"jpeg\"\n\n tempfile = Tempfile.new \"item_picture\"\n image.write(tempfile)\n\n owner = \"#{current_user.id}/#{owner}\"\n\n upload = Upload.find_by(owner: owner) || Upload.new(owner: owner)\n\n upload.mime_type = \"image/jpeg\"\n upload.extension = \".jpeg\"\n upload.body = tempfile.read\n\n if upload.save\n StoreUploadToCloudJob.perform_later upload\n\n upload\n end\n end", "def update!(**args)\n @dense_features = args[:dense_features] if args.key?(:dense_features)\n @encoded_image_string = args[:encoded_image_string] if args.key?(:encoded_image_string)\n @encoded_image_string_small = args[:encoded_image_string_small] if args.key?(:encoded_image_string_small)\n @encoded_thumbnails = args[:encoded_thumbnails] if args.key?(:encoded_thumbnails)\n @id = args[:id] if args.key?(:id)\n @ocr_text = args[:ocr_text] if args.key?(:ocr_text)\n @quality_scores = args[:quality_scores] if args.key?(:quality_scores)\n @should_update_default_thumbnail = args[:should_update_default_thumbnail] if args.key?(:should_update_default_thumbnail)\n @thumbnailer_model_version = args[:thumbnailer_model_version] if args.key?(:thumbnailer_model_version)\n @timestamp_ms = args[:timestamp_ms] if args.key?(:timestamp_ms)\n @type = args[:type] if args.key?(:type)\n @user_reported_thumbnail = args[:user_reported_thumbnail] if args.key?(:user_reported_thumbnail)\n @user_reported_thumbnails = args[:user_reported_thumbnails] if args.key?(:user_reported_thumbnails)\n @version = args[:version] if args.key?(:version)\n end", "def update!(**args)\n @gcs_source = args[:gcs_source] if args.key?(:gcs_source)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n end", "def image=(image)\n self.image.assign image.tempfile\n end", "def create_storage_request(post)\n request = Typhoeus::Request.new post.img_url\n request.on_complete do |response|\n if response.code == 200\n\n dest_file = File.join(STORED_IMAGES_DIR, \"#{post.id}#{File.extname(post.img_url)}\")\n File.open(dest_file, 'w') do |file|\n file.write response.body\n end\n\n if File.exist? dest_file\n post_fingerprint = Phashion::Image.new(dest_file).fingerprint\n sql_fingerprint = Sequel.lit(\"B'#{post_fingerprint.to_s(2).rjust(64, '0')}'\")\n\n DATABASE.transaction do\n DATABASE[\n 'UPDATE posts SET img_saved = TRUE, fingerprint = ?, skip = exists(select * from posts p2 where p2.fingerprint is not null and p2.id != ? and hamming(p2.fingerprint, ?) >= ?) WHERE id = ?',\n sql_fingerprint,\n post.id,\n sql_fingerprint,\n DUPLICATE_LEVEL,\n post.id].update\n end\n else\n DATABASE.transaction do\n post.update({:img_saved => true})\n end\n end\n end\n end\n request\n end", "def update!(**args)\n @disk_interface = args[:disk_interface] if args.key?(:disk_interface)\n @image = args[:image] if args.key?(:image)\n @size_gb = args[:size_gb] if args.key?(:size_gb)\n @snapshot = args[:snapshot] if args.key?(:snapshot)\n @type = args[:type] if args.key?(:type)\n end", "def upload\r\n \r\n end", "def update\n @image = Image.find(params[:id])\n type = @image.url_type\n if @image.update_attributes!(params[:image])\n if request.xhr?\n render :text => [ @image.to_jq_upload(type, \"image\") ].to_json.to_s\n else\n redirect_to console_images_path\n end\n else \n if request.xhr?\n render :text => [ @image.to_jq_upload(type, \"image\").merge({ :error => \"custom_failure\" }) ].to_json.to_s\n else\n redirect_to edit_console_image_path(@image)\n end\n end\n end", "def update\n\n params = image_params\n params[\"tags\"] = params[\"tags\"].delete_suffix(',')\n\n respond_to do |format|\n if @image.update(params)\n format.html { redirect_to @image, notice: \"Image was successfully updated.\" }\n format.json { render :show, status: :ok, location: @image }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end", "def upload(bucket, file); end", "def update\n \tif params[:instrument][:picture] != nil\n \t @instrument.image_url = upload \n \tend\n \t\n set_available_time\n \t\n respond_to do |format|\n if @instrument.update(instrument_params)\n format.html { redirect_to @instrument, notice: 'Instrument was successfully updated.' }\n format.json { render :show, status: :ok, location: @instrument }\n else\n format.html { render :edit }\n format.json { render json: @instrument.errors, status: :unprocessable_entity }\n end\n end\n end", "def put_images_extract_as_gif_with_http_info(name, page_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_images_extract_as_gif ...\"\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_images_extract_as_gif\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.put_images_extract_as_gif\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/images/extract/gif\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'destFolder'] = opts[:'dest_folder'] if !opts[:'dest_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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_images_extract_as_gif\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def image_url_upload\n ar_object = Kernel.const_get(params[:ar_object_class]).find(params[:ar_object_id])\n ar_object.image_file_url = params[:image_file_url]\n if ar_object.save\n @messages = 'fleximage updated'\n else\n @messages = 'Oups updating fleximage'\n ar_object.errors.each { |field, msg| puts \"********* field:#{field} --> #{msg}\" }\n end\n render :update do |page| \n page.replace(MainController.image_domid(ar_object),\n render(:partial => \"/main/image_editor\", :locals => {:title => params[:title], :ar_object => ar_object }))\n\t\tend\n end", "def call\n @upload.image_file_name = direct_upload_url_data[:filename]\n @upload.image_file_size = direct_upload_attributes.content_length\n @upload.image_content_type = direct_upload_attributes.content_type\n @upload.image_updated_at = direct_upload_attributes.last_modified\n end", "def update!(**args)\n @image_height = args[:image_height] if args.key?(:image_height)\n @image_id = args[:image_id] if args.key?(:image_id)\n @image_url = args[:image_url] if args.key?(:image_url)\n @image_width = args[:image_width] if args.key?(:image_width)\n @is_animated = args[:is_animated] if args.key?(:is_animated)\n @is_default = args[:is_default] if args.key?(:is_default)\n @metadata = args[:metadata] if args.key?(:metadata)\n end", "def upload_image(row, h2i, product_id, row_index)\n url = get_val row, 'images', h2i\n return nil unless url\n res = sphere.post_image product_images_url(@sphere_project_key, product_id), url\n raise \"[row #{row_index}] Problems on image upload: '#{url}' - server returned with code '#{res.code}':\\n #{res.body}\" if res == nil or res.code != \"200\"\n j = parse_JSON res.body\n j['version'] # The method returns the latest version of the product.\n end", "def put_images_extract_as_jpeg_with_http_info(name, page_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_images_extract_as_jpeg ...\"\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_images_extract_as_jpeg\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.put_images_extract_as_jpeg\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/images/extract/jpeg\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'destFolder'] = opts[:'dest_folder'] if !opts[:'dest_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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_images_extract_as_jpeg\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def uploadoriginal(file,path)\n\text = File.extname(file)\n \tif ext.upcase == \".JPG\"\n \t\textfinal = \".jpg\"\n \telsif ext.upcase == \".JPEG\"\n \t\textfinal = \".jpg\"\n \telsif ext.upcase == \".GIF\"\n \t\textfinal = \".gif\"\n \telsif ext.upcase == \".PNG\"\n \t\textfinal = \".png\"\n \tend\t\n\t\t\n\t\t\n \t#nombre original de la imagen\n \tfilename_orig = File.basename(file, '.*')\n\n \t#remove white space in image name\n \tfilename_orig = filename_orig.gsub(\" \",\"-\")\n\n \twidth = 800\n\n \timage = Magick::Image.read(file).first\n\n \twidthimage = image.columns\n \theightimage = image.rows\n \theight = (width * heightimage) / widthimage\n \tthumbnail = image.thumbnail(width, height)\n\n\n \tfinalname = path + \"800-\" + filename_orig + extfinal\n \tq=99\n \tthumbnail.write(finalname){ self.quality = q }\n return filename_orig + extfinal\n \nend", "def upload\n to_png_file do |png_path|\n File.open(png_path, 'rb') do |file|\n S3.put_object bucket: Giffy::Configuration.aws.bucket, key: key, body: file\n end\n S3.put_object_acl acl: 'public-read', bucket: Giffy::Configuration.aws.bucket, key: key\n end\n end", "def upload\n to_png_file do |png_path|\n File.open(png_path, 'rb') do |file|\n S3.put_object bucket: Giffy::Configuration.aws.bucket, key: key, body: file\n end\n S3.put_object_acl acl: 'public-read', bucket: Giffy::Configuration.aws.bucket, key: key\n end\n end", "def update_attributes(attributes = {},user,images_directory)\n Rails.logger.debug \"Call to photo.update_attributes\"\n if self.valid? #Validate if the Photo object is valid\n Rails.logger.debug \"The photo is valid!\"\n file = attributes[:file]#Set the photo file object\n if !file.blank? #Validate if a file was supplied by the user\n images_directory =images_directory.blank? ? @@images_directory : images_directory #Validate if an image_directory was supplied, otherwise we use the default one\n file_s3_path = Util.upload_image(images_directory,file) #Upload the new image\n if !attributes[:previous_picture].blank? #Validate if there was a previous image file tied to the photo node\n Util.delete_image(attributes[:previous_picture]) #Delete the previous image file\n end\n else\n file_s3_path = self.file #If none was provided, keep the original file\n end\n #Create a raw photo object\n photo_req = { 'title'=>attributes[:title],\n 'description'=>attributes[:description],\n 'url'=>file_s3_path,\n 'date'=> Util.date_to_epoch(attributes[:date]), #Turn the date to epoch\n 'ownerId'=> self.owner_id \n } \n reqUrl = \"/api/photo/#{self.id}\" #Set the request url\n\n rest_response = MwHttpRequest.http_put_request(reqUrl,photo_req,user['email'],user['password']) #Make the PUT call to the server with the required parameters\n Rails.logger.debug \"Response from server: #{rest_response.code} #{rest_response.message}: #{rest_response.body}\"\n if rest_response.code == \"200\" #Validate if the response from the server is 200, which means OK\n photo = Photo.rest_to_photo(rest_response.body)\n return true, photo #Return success\n else\n return false, \"#{rest_response.code}\", \"#{rest_response.message}\" #Return error\n end\n else\n Rails.logger.debug self.errors.full_messages\n return false, self.errors.full_messages #Return invalid object error\n end\n end", "def update!(**args)\n @image = args[:image] if args.key?(:image)\n end", "def processImage(params, metadata)\n url = params['metadataServerURL']\n \n # This is used to determine if we should actually process this image or\n # not, based on some criteria (e.g. modification date and whether or not\n # the tile set exists.\n process = false\n \n # See if there is an existing checkpoint and date for this map.\n checkpointDate = nil\n @checkpoints.each do |checkpoint|\n if (checkpoint['id'].to_s == metadata['id'].to_s)\n checkpointDate = DateTime.parse(checkpoint['updated_at'])\n break\n end\n end\n \n # If there is no date, then we haven't seen this map before, so we want\n # to process it. Otherwise, we only process the map if the new date is\n # more recent than the old checkpoint date.\n currentDate = DateTime.parse(metadata['updated_at'])\n if (checkpointDate == nil || checkpointDate < currentDate) then process = true end\n \n # We don't want to process an image if there aren't enough control points,\n # regardless of if the times check out...\n if (metadata['no_control_points'].to_i < 3) then process = false end\n controlPoints = fetchControlPoints(url, metadata['id'])\n\n if (process)\n puts 'Processing map '+metadata['id'].to_s+'...'\n \n # Reset the metadata to include all the in-depth metadata for this map.\n metadata = getMapMetadata(url, metadata['id'])\n fileName = metadata['identifier']\n \n # The y values in the database is \"wrong\": the conversion commands\n # start from the top left corner but MapHub starts from the bottom\n # left. Therefore, we need to \"flip\" the y values around the median\n # line of the map.\n mapHeight = Float(metadata['height'])\n median = mapHeight / 2\n controlPoints.map! do |cp|\n y = Float(cp['y'])\n if (y > median)\n difference = y - median\n y = median - difference\n elsif (y < median)\n difference = median - y\n y = median + difference\n else\n # This point is exactly on the median. Don't anger it.\n end\n cp['y'] = y\n cp\n end\n \n ENV['GDAL_DATA'] = $GDALRoot\n dir = Dir.mktmpdir()\n \n # Translate the image.\n translateCommand = 'gdal_translate -of VRT -a_srs EPSG:4326'\n controlPoints.each do |cp|\n translateCommand = translateCommand+' -gcp '+cp['x'].to_s+' '+cp['y'].to_s+' '+cp['lng']+' '+cp['lat']\n end\n translateCommand = translateCommand+' '+params['imageDirectory']+'/raw/'+fileName+'.jp2 '+dir.to_s+'/'+fileName+'-original.vrt'\n puts \"Translating: #{translateCommand}\"\n system(translateCommand)\n \n # Warp the image.\n warpCommand='gdalwarp -of VRT -s_srs EPSG:4326 -t_srs EPSG:4326 '+dir.to_s+'/'+fileName+'-original.vrt '+dir.to_s+'/'+fileName+'-warped.vrt'\n puts \"Warping: #{warpCommand}\"\n system(warpCommand)\n\n # Generate the tile set, placing the generated images in the temporary\n # directory.\n #tileCommand='gdal2tiles.py -n '+dir.to_s+'/'+fileName+'-warped.vrt '+dir.to_s+'/'+$tilesetName\n publishURL = params['publishServerURL'] + $tilesetName\n tileCommand='gdal2tiles.py -u '+publishURL+' -k '+dir.to_s+'/'+fileName+'-warped.vrt '+dir.to_s+'/'+fileName\n puts \"Tiling: #{tileCommand}\"\n system(tileCommand)\n \n # Next we need to tell the server what the new map boundaries are. Get\n # the XML data so we can parse out the boundaries.\n # xmlFile = File.new(dir.to_s+'/'+$tilesetName+'/tilemapresource.xml')\n # xmlDoc = REXML::Document.new(xmlFile)\n # bounds = xmlDoc.root.elements['BoundingBox'].attributes\n # \n # Make a PUT request to update the map with the new boundaries.\n # This is disabled for the time being.\n # uri = URI(params['metadataServerURL'].to_s+'maps/'+metadata['id'].to_s)\n # request = Net::HTTP::Put.new(uri.path)\n # request.set_form_data(\n # 'ne_lat' => bounds['maxx'],\n # 'ne_lng' => bounds['maxy'],\n # 'sw_lat' => bounds['minx'],\n # 'sw_lng' => bounds['miny']\n # )\n # http = Net::HTTP.new(uri.host, uri.port)\n # response = http.request(request)\n \n # Clean up the generated files to leave only the images and the XML\n # file which contains the map bounds and other GIS information.\n FileUtils.rm(Dir.glob(dir.to_s+'/'+$tilesetName+'/*.html'))\n \n # Remove the current tile set and move the new tile set into its\n # place.\n FileUtils.mkdir_p(params['imageDirectory']+'/'+$tilesetName)\n FileUtils.rm_rf(params['imageDirectory']+'/'+$tilesetName+'/'+fileName)\n \n # Move /tmp/.../IDENTIFIER to target/ts_google/IDENTIFIER\n FileUtils.mv(dir.to_s+'/'+fileName, params['imageDirectory']+'/'+$tilesetName+'/'+fileName)\n \n return true\n end\n \n return false\n end", "def upload_image\r\n load_projects if params[:is_from_setting_center]\r\n @content = Image.new\r\n @content.user_id = @user.id\r\n @content.cat_id = (params[:cat_id].blank? ? Content::CATEGORIES[:image][:id] : params[:cat_id])\r\n end", "def update!(**args)\n @inferred_image_source = args[:inferred_image_source] if args.key?(:inferred_image_source)\n @inferred_image_type = args[:inferred_image_type] if args.key?(:inferred_image_type)\n end", "def update\n @raw_image.update(raw_image_params)\n redirect_to admin_raw_images_path\n\n end", "def update!(**args)\n @checksum = args[:checksum] if args.key?(:checksum)\n @color_sampling = args[:color_sampling] if args.key?(:color_sampling)\n @dense_features = args[:dense_features] if args.key?(:dense_features)\n @dense_general_extra_features = args[:dense_general_extra_features] if args.key?(:dense_general_extra_features)\n @external_image_id = args[:external_image_id] if args.key?(:external_image_id)\n @is_assigned = args[:is_assigned] if args.key?(:is_assigned)\n @is_instant = args[:is_instant] if args.key?(:is_instant)\n @model_version = args[:model_version] if args.key?(:model_version)\n @overwrite_reason = args[:overwrite_reason] if args.key?(:overwrite_reason)\n @quantized_features = args[:quantized_features] if args.key?(:quantized_features)\n @score = args[:score] if args.key?(:score)\n @sparse_features = args[:sparse_features] if args.key?(:sparse_features)\n @thumbnail_set = args[:thumbnail_set] if args.key?(:thumbnail_set)\n @thumbnail_version = args[:thumbnail_version] if args.key?(:thumbnail_version)\n @type = args[:type] if args.key?(:type)\n end", "def create\n @image = Image.new(image_params)\n\n # fetch tags from google vision API\n helpers.fetch_tags(image_params)\n\n @image.image_file.attach(image_params[:image_file])\n\n respond_to do |format|\n if @image.save()\n format.html { redirect_to @image, notice: \"Image was successfully created.\" }\n format.json { render :show, status: :created, location: @image }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end", "def append_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, nil)\n nil\n end", "def update\n respond_to do |format|\n if @picture.update(picture_params)\n create_image_tumb(@picture)\n format.html { redirect_to @picture, notice: 'Picture was successfully updated.' }\n format.json { render :show, status: :ok, location: @picture }\n else\n format.html { render :edit }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end", "def upload\n end", "def upload\n end", "def update\n @image = Image.find(params[:id])\n\n #we can allow updating an image name and description and unit, but not the image data. for that we need to create a new image\n update_params = image_params\n update_params.delete(\"image\")\n\n if @image.update(update_params)\n head :no_content\n else\n render json: @image.errors, status: :unprocessable_entity\n end\n end", "def upload\n if File.exists?(file_path = \"/home/redroid/motion_detection_images/#{params[:img]}.jpg\")\n send_403_forbidden\n else\n File.open(file_path, 'wb') { |file| file.write(request.raw_post)}\n send_200_ok\n end\nend", "def save\n if !persisted?\n gps=EXIFR::JPEG.new(@contents).gps\n @location=Point.new(:lng=>gps.longitude,:lat=>gps.latitude)\n @contents.rewind\n\n description = {}\n description[:content_type]='image/jpeg' \n description[:metadata]={:location=>@location.to_hash} \n\n grid_file = Mongo::Grid::File.new(@contents.read,description)\n @id=Photo.mongo_client.database.fs.insert_one(grid_file).to_s\n end \n\tend", "def update!(**args)\n @inferred_image_id = args[:inferred_image_id] if args.key?(:inferred_image_id)\n @inferred_image_source = args[:inferred_image_source] if args.key?(:inferred_image_source)\n @inferred_image_type = args[:inferred_image_type] if args.key?(:inferred_image_type)\n @neardup_info = args[:neardup_info] if args.key?(:neardup_info)\n end", "def upload\n self._create params[:upfile], params[:pictitle]\n end", "def update!(**args)\n @color_entropy = args[:color_entropy] if args.key?(:color_entropy)\n @image_data = args[:image_data] if args.key?(:image_data)\n @is_unsafe = args[:is_unsafe] if args.key?(:is_unsafe)\n @starburst_v4_embedding = args[:starburst_v4_embedding] if args.key?(:starburst_v4_embedding)\n @thumbnail_bytes = args[:thumbnail_bytes] if args.key?(:thumbnail_bytes)\n end", "def update!(**args)\n @image_url = args[:image_url] if args.key?(:image_url)\n @status = args[:status] if args.key?(:status)\n @type = args[:type] if args.key?(:type)\n end", "def save\n if self.persisted?\n # Just update the metadata\n ph = self.class.mongo_client.database.fs.find({:_id=>BSON::ObjectId.from_string(@id)})\n ph.update_one(\n {:metadata=>\n {:location=>@location.to_hash, :place=>@place}\n }) if ph.count == 1\n return\n end\n\n # Get the GPS info from the photo metadata\n gps = EXIFR::JPEG.new(@contents).gps\n @contents.rewind # Reset the read cursor\n\n # Store the latitude/longitude information in a Point object\n @location = Point.new(:lng=>gps.longitude, :lat=>gps.latitude)\n\n # Store meta data about the file\n description = {}\n description[:content_type] = \"image/jpeg\"\n description[:metadata] = {}\n description[:metadata][:location] = @location.to_hash\n description[:metadata][:place] = @place\n\n # Save the file\n grid_file = Mongo::Grid::File.new(@contents.read, description)\n id = self.class.mongo_client.database.fs.insert_one(grid_file)\n @id = id.to_s\n @id\n end", "def put_image_in_storage_to_pdf_with_http_info(name, image_templates, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_image_in_storage_to_pdf ...\"\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_image_in_storage_to_pdf\"\n end\n # verify the required parameter 'image_templates' is set\n if @api_client.config.client_side_validation && image_templates.nil?\n fail ArgumentError, \"Missing the required parameter 'image_templates' when calling PdfApi.put_image_in_storage_to_pdf\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/create/images\".sub('{' + 'name' + '}', name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'dstFolder'] = opts[:'dst_folder'] if !opts[:'dst_folder'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].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(image_templates)\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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_image_in_storage_to_pdf\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def put_images_extract_as_tiff(name, page_number, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = put_images_extract_as_tiff_with_http_info(name, page_number, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = put_images_extract_as_tiff_with_http_info(name, page_number, opts)\n else\n raise\n end\n return data\n end", "def update\n @sys_image = resource_find(params[:id])\n uploaded_io = params[:file]\n if (params[:sys_image_id] != -1)\n @sys_image.sys_image_id = params[:sys_image_id]\n end\n\n unless uploaded_io.nil?\n _size = File.size(uploaded_io) \n params[:sys_image].merge!({:size => _size}) \n end\n\n if @sys_image.update_attributes(params[:sys_image])\n unless uploaded_io.nil?\n write_resource(@sys_image, uploaded_io.read, \"ndz\")\n end \n\n #flash[\"success\"] = 'Sys image was successfully updated.'\n flash[\"success\"] = t(\"amazing.sys_image.updated\")\n redirect_to(@sys_image) \n else\n render :action => \"edit\"\n end\n end", "def post_storage(request)\n # --- Check OCCI XML from POST ---\n if request.params['occixml'] == nil\n error_msg = \"OCCI XML representation of Image\" +\n \" not present in the request\"\n error = OpenNebula::Error.new(error_msg)\n return error, 400\n end\n\n # --- Create and Add the new Image ---\n occixml = request.params['occixml']\n occixml = occixml[:tempfile].read if occixml.class == Hash\n\n image = ImageOCCI.new(\n Image.build_xml,\n @client,\n occixml,\n request.params['file'])\n\n # --- Generate the template and Allocate the new Instance ---\n template = image.to_one_template\n return template, 500 if OpenNebula.is_error?(template)\n\n rc = image.allocate(template, @config[:datastore_id]||1)\n if OpenNebula.is_error?(rc)\n return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]\n end\n\n image.info\n #wait until image is ready to return\n while (image.state_str == 'LOCKED') && (image['RUNNING_VMS'] == '0') do\n sleep IMAGE_POLL_SLEEP_TIME\n image.info\n end\n\n # --- Prepare XML Response ---\n return to_occi_xml(image, :code=>201)\n end", "def perform_study_file_upload(filename, study_file_params, study_id)\n file_upload = Rack::Test::UploadedFile.new(Rails.root.join('test', 'test_data', filename))\n study_file_params[:study_file].merge!(upload: file_upload)\n patch \"/single_cell/studies/#{study_id}/upload\", params: study_file_params, headers: {'Content-Type' => 'multipart/form-data'}\nend", "def uploadimage \n img = Cloudinary::Uploader.upload(params[:image])\n company = Company.find(params[:id])\n if company.update(\n \n image: img[\"url\"]\n )\n render json:{\n status: :updated,\n company: :company\n }\n else\n render json: {status: 550}\n end \n end", "def update \n if @adm_galerias_imagem.update(adm_galerias_imagem_params)\n\t\thead :created \n else\n\t\thead :bad_request\n end \n end", "def add_image\n pass_query_params\n @observation = find_or_goto_index(Observation, params[:id].to_s)\n return unless @observation\n\n if !check_permission!(@observation)\n redirect_with_query(controller: \"observer\",\n action: \"show_observation\", id: @observation.id)\n elsif request.method != \"POST\"\n @image = Image.new\n @image.license = @user.license\n @image.copyright_holder = @user.legal_name\n @image.user = @user\n # Set the default date to the date of the observation\n # Don't know how to correctly test this.\n @image.when = @observation.when\n @licenses = License.current_names_and_ids(@image.license)\n init_project_vars_for_add_or_edit(@observation)\n elsif params[:upload].blank?\n flash_warning(:runtime_no_changes.t)\n redirect_with_query(controller: \"observer\",\n action: \"show_observation\", id: @observation.id)\n else\n args = params[:image]\n i = 1\n while i < 5 || params[:upload][\"image#{i}\"].present?\n process_image(args, params[:upload][\"image#{i}\"])\n i += 1\n end\n redirect_with_query(controller: \"observer\",\n action: \"show_observation\", id: @observation.id)\n end\n end", "def update!(**args)\n @imagesearch_docid = args[:imagesearch_docid] if args.key?(:imagesearch_docid)\n @is_thumbnail_missing = args[:is_thumbnail_missing] if args.key?(:is_thumbnail_missing)\n @serving_metadata = args[:serving_metadata] if args.key?(:serving_metadata)\n @thumbnail_info = args[:thumbnail_info] if args.key?(:thumbnail_info)\n @timestamp_ms = args[:timestamp_ms] if args.key?(:timestamp_ms)\n end", "def image_commit(project, imagefile)\n if logged_in?\n commit project.path, imagefile.original_filename, imagefile.read, \"Add new file #{imagefile.original_filename}.\" \n end\n end", "def image_params\n params.require(:image).permit(:month, :hour, :small_square, :square, :weather, :image_id, :size, :category, :thumb, :exif, :title, :tags, :location, :type, :medium, :description, :normal, :link, :user, :bigger, :hits, :uploaded_at, :url, :original, :large, :taken_at, :dimension, :focal_length, :date_taken, :aperture, :camera, :metering_mode, :iso_speed_ratings, :city)\n end", "def post_file_to_server id, content, size, page_count, extension = \".jpg\"\n\n @s.execute_file_post @s.url_for(\"system/pool/createfile.#{id}.page#{page_count}-#{size}\"), \"thumbnail\", \"thumbnail\", content, related_mimetype(extension)\n alt_url = @s.url_for(\"p/#{id}/page#{page_count}.#{size}\" + extension)\n @s.execute_post alt_url, {\"sakai:excludeSearch\" => true}\n log \"Uploaded image to curl #{alt_url}\"\nend", "def update!(**args)\n @filename = args[:filename] if args.key?(:filename)\n @size = args[:size] if args.key?(:size)\n @upload_status = args[:upload_status] if args.key?(:upload_status)\n end", "def update\n respond_to do |format|\n if @taxi_image.update(taxi_image_params)\n format.html { redirect_to @taxi_image, notice: 'Taxi image was successfully updated.' }\n format.json { render :show, status: :ok, location: @taxi_image }\n else\n format.html { render :edit }\n format.json { render json: @taxi_image.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @gcs_output_directory = args[:gcs_output_directory] if args.key?(:gcs_output_directory)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end", "def update!(**args)\n @image_docid = args[:image_docid] if args.key?(:image_docid)\n @thumb_height = args[:thumb_height] if args.key?(:thumb_height)\n @thumb_type = args[:thumb_type] if args.key?(:thumb_type)\n @thumb_width = args[:thumb_width] if args.key?(:thumb_width)\n end", "def update_profile_image(file)\n perform_post(\"account/update_profile_image.#{Twitter.format}\", build_multipart_bodies(:image => file))\n end", "def save\n if @place.is_a? Place\n @place = BSON::ObjectId.from_string(@place.id)\n end\n\n if !persisted?\n gps = EXIFR::JPEG.new(@contents).gps\n location=Point.new(:lng=>gps.longitude, :lat=>gps.latitude)\n @contents.rewind\n\n description={}\n description[:metadata] = {\n :location => location.to_hash,\n :place => @place\n }\n #description[:contentType] = \"image/jpeg\" #don't know why not work\n description[:content_type] = \"image/jpeg\"\n @location = Point.new(location.to_hash)\n grid_file = Mongo::Grid::File.new(@contents.read, description)\n @id = self.class.mongo_client.database.fs.insert_one(grid_file).to_s\n else\n doc = self.class.mongo_client.database.fs.find(\n '_id': BSON::ObjectId.from_string(@id)\n ).first\n doc[:metadata][:place] = @place\n doc[:metadata][:location] = @location.to_hash\n self.class.mongo_client.database.fs.find(\n '_id': BSON::ObjectId.from_string(@id)\n ).update_one(doc)\n end\n end" ]
[ "0.7289607", "0.6953938", "0.6241735", "0.6236834", "0.6219689", "0.6117133", "0.6110932", "0.6075472", "0.60708135", "0.6052028", "0.6024746", "0.5989361", "0.59705985", "0.5968926", "0.59594244", "0.5911838", "0.59079736", "0.59057546", "0.5890637", "0.58853126", "0.5879327", "0.5879327", "0.58792424", "0.58553123", "0.5847526", "0.58458143", "0.58373", "0.58334804", "0.5822738", "0.58022183", "0.57972765", "0.5791561", "0.5755419", "0.573187", "0.57268906", "0.570841", "0.5704374", "0.5695328", "0.5694144", "0.569358", "0.5688187", "0.56775206", "0.5662568", "0.564454", "0.5641503", "0.5635483", "0.5630818", "0.56271", "0.56165034", "0.5604877", "0.5599044", "0.558987", "0.5571453", "0.55651635", "0.5561021", "0.555263", "0.5545461", "0.55432445", "0.5539347", "0.55377924", "0.5536084", "0.5536084", "0.5533941", "0.5529766", "0.5527442", "0.552286", "0.5497372", "0.5488227", "0.54864395", "0.54861975", "0.5481062", "0.5479609", "0.5464412", "0.5464412", "0.5463568", "0.5453855", "0.5447078", "0.5446483", "0.5445489", "0.5443546", "0.5442977", "0.54351526", "0.54348284", "0.5427712", "0.54249173", "0.54152775", "0.5406323", "0.5402005", "0.5392273", "0.53912175", "0.5388931", "0.53877676", "0.5385981", "0.5379177", "0.5369513", "0.5363792", "0.5360812", "0.53544986", "0.53521407", "0.5352001" ]
0.804041
0
Update parameters of a TIFF image. Image data is passed in a request stream
def create_modified_tiff_from_request_body puts('Update parameters of a TIFF image from request body') compression = 'adobedeflate' resolution_unit = 'inch' bit_depth = 1 horizontal_resolution = 150.0 vertical_resolution = 150.0 from_scratch = nil storage = nil # We are using default Cloud Storage out_path = nil # Path to updated file (if this is empty, response contains streamed image) input_stream = File.open(File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, get_sample_image_file_name), 'r') request = AsposeImagingCloud::CreateModifiedTiffRequest.new( input_stream, bit_depth, compression, resolution_unit, horizontal_resolution, vertical_resolution, from_scratch, out_path, storage) puts("Call CreateModifiedTiff with params: compression: #{compression}, resolution unit: #{resolution_unit}, " + "bit depth: #{bit_depth}, horizontal resolution: #{horizontal_resolution}, vertical resolution: " + "#{vertical_resolution}") updated_image = imaging_api.create_modified_tiff(request) save_updated_sample_image_to_output(updated_image, true) puts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modify_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def modify_tiff_and_upload_to_storage\n puts('Update parameters of a TIFF image and upload to cloud storage')\n\n upload_sample_image_to_cloud\n\n compression = 'adobedeflate'\n resolution_unit = 'inch'\n bit_depth = 1\n horizontal_resolution = 150.0\n vertical_resolution = 150.0\n from_scratch = nil\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ModifyTiffRequest.new(\n get_sample_image_file_name, bit_depth, compression, resolution_unit, horizontal_resolution,\n vertical_resolution, from_scratch, folder, storage)\n\n puts(\"Call ModifyTiff with params: compression: #{compression}, resolution unit: #{resolution_unit}, \" +\n \"bit depth: #{bit_depth}, horizontal resolution: #{horizontal_resolution}, vertical resolution: \" +\n \"#{vertical_resolution}\")\n\n updated_image = @imaging_api.modify_tiff(request)\n upload_image_to_cloud(get_modified_sample_image_file_name, updated_image)\n puts\n end", "def create_modified_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def append_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, nil)\n nil\n end", "def update_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def modify_tiff_from_storage\n puts('Update parameters of a TIFF image from cloud storage')\n\n upload_sample_image_to_cloud\n\n compression = 'adobedeflate'\n resolution_unit = 'inch'\n bit_depth = 1\n horizontal_resolution = 150.0\n vertical_resolution = 150.0\n from_scratch = nil\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ModifyTiffRequest.new(\n get_sample_image_file_name, bit_depth, compression, resolution_unit, horizontal_resolution,\n vertical_resolution, from_scratch, folder, storage)\n\n puts(\"Call ModifyTiff with params: compression: #{compression}, resolution unit: #{resolution_unit}, bit depth:\" +\n \" #{bit_depth}, horizontal resolution: #{horizontal_resolution}, vertical resolution: \" +\n \"#{vertical_resolution}\")\n\n updated_image = imaging_api.modify_tiff(request)\n save_updated_sample_image_to_output(updated_image, false)\n puts\n end", "def modify_jpeg(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def update!(**args)\n @bytes_value = args[:bytes_value] if args.key?(:bytes_value)\n @float_value = args[:float_value] if args.key?(:float_value)\n @image_template = args[:image_template] if args.key?(:image_template)\n @int32_value = args[:int32_value] if args.key?(:int32_value)\n @version = args[:version] if args.key?(:version)\n end", "def update!(**args)\n @far = args[:far] if args.key?(:far)\n @format = args[:format] if args.key?(:format)\n @image_height = args[:image_height] if args.key?(:image_height)\n @image_width = args[:image_width] if args.key?(:image_width)\n @mime = args[:mime] if args.key?(:mime)\n @near = args[:near] if args.key?(:near)\n @units = args[:units] if args.key?(:units)\n end", "def update!(**args)\n @data = args[:data] if args.key?(:data)\n @height = args[:height] if args.key?(:height)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n @width = args[:width] if args.key?(:width)\n end", "def update!(**args)\n @image_bytes = args[:image_bytes] if args.key?(:image_bytes)\n end", "def set_params\r\n @listing.pictures.build.photo = File.new params[:file].tempfile if params[:file]\r\n respond_to do |format|\r\n format.html { params[:temp_listing] = ResetDate::reset_dates(params[:temp_listing]) }\r\n format.json { params[:temp_listing] = JSON.parse(params[:temp_listing]) }\r\n end\r\n end", "def update!(**args)\n @byte_size = args[:byte_size] if args.key?(:byte_size)\n @encoding_quality = args[:encoding_quality] if args.key?(:encoding_quality)\n @encoding_type = args[:encoding_type] if args.key?(:encoding_type)\n @height = args[:height] if args.key?(:height)\n @image_blob_id = args[:image_blob_id] if args.key?(:image_blob_id)\n @image_bytes = args[:image_bytes] if args.key?(:image_bytes)\n @image_string = args[:image_string] if args.key?(:image_string)\n @width = args[:width] if args.key?(:width)\n end", "def img_params\n\n end", "def modify_bmp(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def put_images_extract_as_tiff_with_http_info(name, page_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_images_extract_as_tiff ...\"\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_images_extract_as_tiff\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.put_images_extract_as_tiff\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/images/extract/tiff\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'destFolder'] = opts[:'dest_folder'] if !opts[:'dest_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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_images_extract_as_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def modify_jpeg2000(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def create_modified_jpeg(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def create_updated_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def convert_tiff_to_fax_from_request\n puts('Update parameters of TIFF image from request body according to fax parameters.')\n\n upload_sample_image_to_cloud\n\n # Update TIFF Image parameters according to fax parameters\n out_path = nil\n storage = nil # We are using default Cloud Storage\n\n input_stream = File.open(File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, get_sample_image_file_name), 'r')\n request = AsposeImagingCloud::CreateFaxTiffRequest.new(input_stream, out_path, storage)\n\n puts('Call CreateFaxTiff')\n\n updated_image = imaging_api.create_fax_tiff(request)\n save_updated_sample_image_to_output(updated_image, updated_image)\n puts\n end", "def update_template_with_image_id(template)\n params = template.parameters\n params.each do |key, value|\n update_params_with_image_id(params, key, value)\n end\n end", "def update!(**args)\n @image = args[:image] if args.key?(:image)\n @tag = args[:tag] if args.key?(:tag)\n end", "def put_image_extract_as_tiff_with_http_info(name, image_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_image_extract_as_tiff ...\"\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_image_extract_as_tiff\"\n end\n # verify the required parameter 'image_id' is set\n if @api_client.config.client_side_validation && image_id.nil?\n fail ArgumentError, \"Missing the required parameter 'image_id' when calling PdfApi.put_image_extract_as_tiff\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/images/{imageId}/extract/tiff\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'imageId' + '}', image_id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'destFolder'] = opts[:'dest_folder'] if !opts[:'dest_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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_image_extract_as_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update_image_features(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :PUT, nil)\n nil\n end", "def update!(**args)\n @color_entropy = args[:color_entropy] if args.key?(:color_entropy)\n @image_data = args[:image_data] if args.key?(:image_data)\n @is_unsafe = args[:is_unsafe] if args.key?(:is_unsafe)\n @starburst_v4_embedding = args[:starburst_v4_embedding] if args.key?(:starburst_v4_embedding)\n @thumbnail_bytes = args[:thumbnail_bytes] if args.key?(:thumbnail_bytes)\n end", "def update!(**args)\n @image_height = args[:image_height] if args.key?(:image_height)\n @image_id = args[:image_id] if args.key?(:image_id)\n @image_url = args[:image_url] if args.key?(:image_url)\n @image_width = args[:image_width] if args.key?(:image_width)\n @is_animated = args[:is_animated] if args.key?(:is_animated)\n @is_default = args[:is_default] if args.key?(:is_default)\n @metadata = args[:metadata] if args.key?(:metadata)\n end", "def put_pdf_in_request_to_tiff_with_http_info(out_path, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_pdf_in_request_to_tiff ...\"\n end\n # verify the required parameter 'out_path' is set\n if @api_client.config.client_side_validation && out_path.nil?\n fail ArgumentError, \"Missing the required parameter 'out_path' when calling PdfApi.put_pdf_in_request_to_tiff\"\n end\n if @api_client.config.client_side_validation && opts[:'compression'] && !['LZW', 'CCITT4', 'CCITT3', 'RLE', 'None'].include?(opts[:'compression'])\n fail ArgumentError, 'invalid value for \"compression\", must be one of LZW, CCITT4, CCITT3, RLE, None'\n end\n if @api_client.config.client_side_validation && opts[:'color_depth'] && !['Default', 'Format8bpp', 'Format4bpp', 'Format1bpp'].include?(opts[:'color_depth'])\n fail ArgumentError, 'invalid value for \"color_depth\", must be one of Default, Format8bpp, Format4bpp, Format1bpp'\n end\n if @api_client.config.client_side_validation && opts[:'orientation'] && !['None', 'Landscape', 'Portrait'].include?(opts[:'orientation'])\n fail ArgumentError, 'invalid value for \"orientation\", must be one of None, Landscape, Portrait'\n end\n # resource path\n local_var_path = \"/pdf/convert/tiff\"\n\n # query parameters\n query_params = {}\n query_params[:'outPath'] = out_path\n query_params[:'brightness'] = opts[:'brightness'] if !opts[:'brightness'].nil?\n query_params[:'compression'] = opts[:'compression'] if !opts[:'compression'].nil?\n query_params[:'colorDepth'] = opts[:'color_depth'] if !opts[:'color_depth'].nil?\n query_params[:'leftMargin'] = opts[:'left_margin'] if !opts[:'left_margin'].nil?\n query_params[:'rightMargin'] = opts[:'right_margin'] if !opts[:'right_margin'].nil?\n query_params[:'topMargin'] = opts[:'top_margin'] if !opts[:'top_margin'].nil?\n query_params[:'bottomMargin'] = opts[:'bottom_margin'] if !opts[:'bottom_margin'].nil?\n query_params[:'orientation'] = opts[:'orientation'] if !opts[:'orientation'].nil?\n query_params[:'skipBlankPages'] = opts[:'skip_blank_pages'] if !opts[:'skip_blank_pages'].nil?\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'xResolution'] = opts[:'x_resolution'] if !opts[:'x_resolution'].nil?\n query_params[:'yResolution'] = opts[:'y_resolution'] if !opts[:'y_resolution'].nil?\n query_params[:'pageIndex'] = opts[:'page_index'] if !opts[:'page_index'].nil?\n query_params[:'pageCount'] = opts[:'page_count'] if !opts[:'page_count'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].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(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n # Fix header in file\n post_body = nil\n post_body = opts[:'file'] if !opts[:'file'].nil?\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/octet-stream'])\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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_pdf_in_request_to_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def swfupload_file=(data)\r\n data.content_type = MIME::Types.type_for(data.original_filename).to_s if data\r\n self.image = data\r\n end", "def update_tiff_to_fax_from_storage\n puts('Update parameters of TIFF image according to fax parameters')\n\n upload_sample_image_to_cloud\n\n # Update TIFF Image parameters according to fax parameters\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ConvertTiffToFaxRequest.new(get_sample_image_file_name, storage, folder)\n\n puts('Call ConvertTiffToFax')\n\n updated_image = imaging_api.convert_tiff_to_fax(request)\n save_updated_image_to_output('ConvertTiffToFax.tiff', updated_image)\n puts\n end", "def update!(**args)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n @raw_bytes = args[:raw_bytes] if args.key?(:raw_bytes)\n @uri = args[:uri] if args.key?(:uri)\n end", "def postToolsImage( filedata, type)\n params = Hash.new\n params['filedata'] = filedata\n params['type'] = type\n return doCurl(\"post\",\"/tools/image\",params)\n end", "def update!(**args)\n @imagesearch_docid = args[:imagesearch_docid] if args.key?(:imagesearch_docid)\n @is_thumbnail_missing = args[:is_thumbnail_missing] if args.key?(:is_thumbnail_missing)\n @serving_metadata = args[:serving_metadata] if args.key?(:serving_metadata)\n @thumbnail_info = args[:thumbnail_info] if args.key?(:thumbnail_info)\n @timestamp_ms = args[:timestamp_ms] if args.key?(:timestamp_ms)\n end", "def update!(**args)\n @docid = args[:docid] if args.key?(:docid)\n @frame_identifier = args[:frame_identifier] if args.key?(:frame_identifier)\n @regions = args[:regions] if args.key?(:regions)\n @starburst_features_v4 = args[:starburst_features_v4] if args.key?(:starburst_features_v4)\n @starburst_tokens_v4 = args[:starburst_tokens_v4] if args.key?(:starburst_tokens_v4)\n @thumbnail_type = args[:thumbnail_type] if args.key?(:thumbnail_type)\n end", "def update!(**args)\n @data = args[:data] if args.key?(:data)\n @height = args[:height] if args.key?(:height)\n @page_number = args[:page_number] if args.key?(:page_number)\n @viewport = args[:viewport] if args.key?(:viewport)\n @width = args[:width] if args.key?(:width)\n end", "def update!(**args)\n @image_docid = args[:image_docid] if args.key?(:image_docid)\n @thumb_height = args[:thumb_height] if args.key?(:thumb_height)\n @thumb_type = args[:thumb_type] if args.key?(:thumb_type)\n @thumb_width = args[:thumb_width] if args.key?(:thumb_width)\n end", "def init_image_from_stream(file)\n @file = nil\n self.upload_temp_file = nil\n if file.respond_to?(:content_length)\n self.upload_length = file.content_length.chomp\n end\n self.upload_length = file.size if file.respond_to?(:size)\n add_extra_attributes_from_file(file)\n end", "def update!(**args)\n @image = args[:image] if args.key?(:image)\n end", "def update!(**args)\n @filename = args[:filename] if args.key?(:filename)\n @height = args[:height] if args.key?(:height)\n @ms_offset = args[:ms_offset] if args.key?(:ms_offset)\n @width = args[:width] if args.key?(:width)\n end", "def update!(**args)\n @image_url = args[:image_url] if args.key?(:image_url)\n @status = args[:status] if args.key?(:status)\n @type = args[:type] if args.key?(:type)\n end", "def create_modified_jpeg2000(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def call\n @upload.image_file_name = direct_upload_url_data[:filename]\n @upload.image_file_size = direct_upload_attributes.content_length\n @upload.image_content_type = direct_upload_attributes.content_type\n @upload.image_updated_at = direct_upload_attributes.last_modified\n end", "def set_trfileimage\n @trfileimage = Trfileimage.find(params[:id])\n end", "def update!(**args)\n @expiration_timestamp_micros = args[:expiration_timestamp_micros] if args.key?(:expiration_timestamp_micros)\n @height = args[:height] if args.key?(:height)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n @size = args[:size] if args.key?(:size)\n @type = args[:type] if args.key?(:type)\n @width = args[:width] if args.key?(:width)\n end", "def set_image_attrib\n @image_attrib = ImageAttrib.find(params[:id])\n end", "def put_document_save_as_tiff(request)\n data, _status_code, _headers = put_document_save_as_tiff_with_http_info(request)\n request_token if _status_code == 401\n data\n end", "def update!(**args)\n @num_images = args[:num_images] if args.key?(:num_images)\n @num_images_with_content = args[:num_images_with_content] if args.key?(:num_images_with_content)\n @num_resources = args[:num_resources] if args.key?(:num_resources)\n @num_resources_with_content = args[:num_resources_with_content] if args.key?(:num_resources_with_content)\n @sum_http_response_length = args[:sum_http_response_length] if args.key?(:sum_http_response_length)\n end", "def update!(**args)\n @deprecated_entropy_color = args[:deprecated_entropy_color] if args.key?(:deprecated_entropy_color)\n @filename = args[:filename] if args.key?(:filename)\n @flags = args[:flags] if args.key?(:flags)\n @height = args[:height] if args.key?(:height)\n @width = args[:width] if args.key?(:width)\n end", "def update\n @sys_image = resource_find(params[:id])\n uploaded_io = params[:file]\n if (params[:sys_image_id] != -1)\n @sys_image.sys_image_id = params[:sys_image_id]\n end\n\n unless uploaded_io.nil?\n _size = File.size(uploaded_io) \n params[:sys_image].merge!({:size => _size}) \n end\n\n if @sys_image.update_attributes(params[:sys_image])\n unless uploaded_io.nil?\n write_resource(@sys_image, uploaded_io.read, \"ndz\")\n end \n\n #flash[\"success\"] = 'Sys image was successfully updated.'\n flash[\"success\"] = t(\"amazing.sys_image.updated\")\n redirect_to(@sys_image) \n else\n render :action => \"edit\"\n end\n end", "def image_params\n params[:image]\n \n end", "def update!(**args)\n @data = args[:data] if args.key?(:data)\n @file_name = args[:file_name] if args.key?(:file_name)\n @size = args[:size] if args.key?(:size)\n end", "def profile_image=(file_data)\n @file_data = file_data\n end", "def create_modified_bmp(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def add_some_extra_params\n @params['size'] = @file.size\n @params['md5sum'] = @file.md5sum\n end", "def update\n @image = ImagePost.find(params[:id])\n\n respond_to do |format|\n if @image.update_attributes(params[:imagest_po])\n track_activity @image\n format.html { redirect_to @image, notice: 'Image post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @inferred_image_source = args[:inferred_image_source] if args.key?(:inferred_image_source)\n @inferred_image_type = args[:inferred_image_type] if args.key?(:inferred_image_type)\n end", "def update_search_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :PUT, nil)\n nil\n end", "def update\n\n params = image_params\n params[\"tags\"] = params[\"tags\"].delete_suffix(',')\n\n respond_to do |format|\n if @image.update(params)\n format.html { redirect_to @image, notice: \"Image was successfully updated.\" }\n format.json { render :show, status: :ok, location: @image }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end", "def image_params\n params.require(:image).permit(:file_path, :dataset_id, :user_id)\n end", "def riffblob_params\n params.require(:riffblob).permit(:user_id, :file, :shoutout, :url, :pointer)\n end", "def filter_effect_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :PUT, 'File')\n end", "def image_params\n params.require(:image).permit(:month, :hour, :small_square, :square, :weather, :image_id, :size, :category, :thumb, :exif, :title, :tags, :location, :type, :medium, :description, :normal, :link, :user, :bigger, :hits, :uploaded_at, :url, :original, :large, :taken_at, :dimension, :focal_length, :date_taken, :aperture, :camera, :metering_mode, :iso_speed_ratings, :city)\n end", "def image_params\n params.require(:data).require(:attributes).permit(:title, :data_uri, :user_id)\n end", "def update!(**args)\n @binary_data = args[:binary_data] if args.key?(:binary_data)\n @update_time = args[:update_time] if args.key?(:update_time)\n end", "def update!(**args)\n @binary_data = args[:binary_data] if args.key?(:binary_data)\n @update_time = args[:update_time] if args.key?(:update_time)\n end", "def taxi_image_params\n params.fetch(:taxi_image, {})\n end", "def image_params\n params.require(:image).permit(:data, :analyzed_data, :description)\n end", "def update!(**args)\n @info = args[:info] if args.key?(:info)\n @input_read_time = args[:input_read_time] if args.key?(:input_read_time)\n @partial_file = args[:partial_file] if args.key?(:partial_file)\n @total_vsi_time = args[:total_vsi_time] if args.key?(:total_vsi_time)\n @vsi_stats = args[:vsi_stats] if args.key?(:vsi_stats)\n end", "def update_file(params)\n self.processed = false\n self.attributes = params\n set_upload_attributes\n save!\n Avatar.delay.finalize_and_cleanup(id)\n end", "def set_raw_image\n @raw_image = RawImage.find(params[:id])\n end", "def put_page_convert_to_tiff_with_http_info(name, page_number, out_path, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_page_convert_to_tiff ...\"\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_page_convert_to_tiff\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.put_page_convert_to_tiff\"\n end\n # verify the required parameter 'out_path' is set\n if @api_client.config.client_side_validation && out_path.nil?\n fail ArgumentError, \"Missing the required parameter 'out_path' when calling PdfApi.put_page_convert_to_tiff\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/convert/tiff\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'outPath'] = out_path\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'password'] = opts[:'password'] if !opts[:'password'].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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_page_convert_to_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update!(**args)\n @content = args[:content] if args.key?(:content)\n @height = args[:height] if args.key?(:height)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n @width = args[:width] if args.key?(:width)\n end", "def set_input_stream\n @input_stream = InputStream.find(params[:id])\n end", "def update\n scan_procedure_array = (current_user.edit_low_scan_procedure_array).split(' ').map(&:to_i)\n @image_dataset = ImageDataset.where(\"image_datasets.visit_id in (select visit_id from scan_procedures_visits where scan_procedure_id in (?))\", scan_procedure_array).find(params[:id])\n\n respond_to do |format|\n if @image_dataset.update_attributes(params[:image_dataset])\n flash[:notice] = 'ImageDataset was successfully updated.'\n format.html { redirect_to(@image_dataset) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @image_dataset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def image=(image)\n self.image.assign image.tempfile\n end", "def set_image_file\n @image_file = ImageFile.find(params[:id])\n end", "def set_image_file\n @image_file = ImageFile.find(params[:id])\n end", "def update!(**args)\n @image_docid = args[:image_docid] if args.key?(:image_docid)\n @product_image_type = args[:product_image_type] if args.key?(:product_image_type)\n end", "def bike_image=(file_data)\n @file_data = file_data\n end", "def update!(**args)\n @auth_method = args[:auth_method] if args.key?(:auth_method)\n @content_length = args[:content_length] if args.key?(:content_length)\n @content_type = args[:content_type] if args.key?(:content_type)\n @crawl_time = args[:crawl_time] if args.key?(:crawl_time)\n @encoding = args[:encoding] if args.key?(:encoding)\n @has_http_header = args[:has_http_header] if args.key?(:has_http_header)\n @language = args[:language] if args.key?(:language)\n @original_encoding = args[:original_encoding] if args.key?(:original_encoding)\n @representation = args[:representation] if args.key?(:representation)\n @uncompressed_length = args[:uncompressed_length] if args.key?(:uncompressed_length)\n @visual_type = args[:visual_type] if args.key?(:visual_type)\n @crawled_file_size = args[:crawled_file_size] if args.key?(:crawled_file_size)\n @encoded_geometry_annotations = args[:encoded_geometry_annotations] if args.key?(:encoded_geometry_annotations)\n end", "def update!(**args)\n @author_name = args[:author_name] if args.key?(:author_name)\n @corpus = args[:corpus] if args.key?(:corpus)\n @geo_location = args[:geo_location] if args.key?(:geo_location)\n @global_feature = args[:global_feature] if args.key?(:global_feature)\n @image_height = args[:image_height] if args.key?(:image_height)\n @image_id = args[:image_id] if args.key?(:image_id)\n @image_url = args[:image_url] if args.key?(:image_url)\n @image_width = args[:image_width] if args.key?(:image_width)\n @info = args[:info] if args.key?(:info)\n @object_info = args[:object_info] if args.key?(:object_info)\n @object_name = args[:object_name] if args.key?(:object_name)\n @opaque_data = args[:opaque_data] if args.key?(:opaque_data)\n @roi = args[:roi] if args.key?(:roi)\n @subset = args[:subset] if args.key?(:subset)\n @version = args[:version] if args.key?(:version)\n end", "def set_input_stream\n @input_stream = InputStream.find(params[:id])\n end", "def update!(**args)\n @filename = args[:filename] if args.key?(:filename)\n @size = args[:size] if args.key?(:size)\n @upload_status = args[:upload_status] if args.key?(:upload_status)\n end", "def tour_image_params\n params.fetch(:tour_image, {})\n end", "def edit_image # :prefetch: :norobots:\n pass_query_params\n if @image = find_or_goto_index(Image, params[:id].to_s)\n @licenses = License.current_names_and_ids(@image.license)\n if !check_permission!(@image)\n redirect_to(:action => 'show_image', :id => @image,\n :params => query_params)\n elsif request.method != :post\n init_project_vars_for_add_or_edit(@image)\n else\n @image.attributes = params[:image]\n xargs = {}\n xargs[:set_date] = @image.when if @image.when_changed?\n xargs[:set_notes] = @image.notes if @image.notes_changed?\n xargs[:set_copyright_holder] = @image.copyright_holder if @image.copyright_holder_changed?\n xargs[:set_original_name] = @image.original_name if @image.original_name_changed?\n xargs[:set_license] = @image.license if @image.license_id_changed?\n done = false\n if xargs.empty?\n if update_projects(@image, params[:project])\n flash_notice :runtime_image_edit_success.t(:id => @image.id)\n else\n flash_notice(:runtime_no_changes.t)\n end\n done = true\n elsif [email protected]\n flash_object_errors(@image)\n else\n xargs[:id] = @image\n Transaction.put_image(xargs)\n @image.log_update\n flash_notice :runtime_image_edit_success.t(:id => @image.id)\n update_projects(@image, params[:project])\n done = true\n end\n if done\n redirect_to(:action => 'show_image', :id => @image.id, :params => query_params)\n else\n init_project_vars_for_reload(@image)\n end\n end\n end\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @raster_collections = args[:raster_collections] if args.key?(:raster_collections)\n end", "def convert_to_tiff_with_http_info(image_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertApi.convert_to_tiff ...'\n end\n # verify the required parameter 'image_file' is set\n if @api_client.config.client_side_validation && image_file.nil?\n fail ArgumentError, \"Missing the required parameter 'image_file' when calling ConvertApi.convert_to_tiff\"\n end\n # resource path\n local_var_path = '/image/convert/to/tiff'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['imageFile'] = image_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\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 => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertApi#convert_to_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def set_img\n\n end", "def image\n @sys_image = resource_find(params[:id])\n uploaded_io = params[:file]\n _size = File.size(uploaded_io)\n write_resource(@sys_image, uploaded_io.read, \"ndz\")\n redirect_to(@sys_image) \n end", "def update!(**args)\n @image = args[:image] unless args[:image].nil?\n end", "def update!(**args)\n @inferred_image_id = args[:inferred_image_id] if args.key?(:inferred_image_id)\n @inferred_image_source = args[:inferred_image_source] if args.key?(:inferred_image_source)\n @inferred_image_type = args[:inferred_image_type] if args.key?(:inferred_image_type)\n @neardup_info = args[:neardup_info] if args.key?(:neardup_info)\n end", "def create_fax_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def processImage(params, metadata)\n url = params['metadataServerURL']\n \n # This is used to determine if we should actually process this image or\n # not, based on some criteria (e.g. modification date and whether or not\n # the tile set exists.\n process = false\n \n # See if there is an existing checkpoint and date for this map.\n checkpointDate = nil\n @checkpoints.each do |checkpoint|\n if (checkpoint['id'].to_s == metadata['id'].to_s)\n checkpointDate = DateTime.parse(checkpoint['updated_at'])\n break\n end\n end\n \n # If there is no date, then we haven't seen this map before, so we want\n # to process it. Otherwise, we only process the map if the new date is\n # more recent than the old checkpoint date.\n currentDate = DateTime.parse(metadata['updated_at'])\n if (checkpointDate == nil || checkpointDate < currentDate) then process = true end\n \n # We don't want to process an image if there aren't enough control points,\n # regardless of if the times check out...\n if (metadata['no_control_points'].to_i < 3) then process = false end\n controlPoints = fetchControlPoints(url, metadata['id'])\n\n if (process)\n puts 'Processing map '+metadata['id'].to_s+'...'\n \n # Reset the metadata to include all the in-depth metadata for this map.\n metadata = getMapMetadata(url, metadata['id'])\n fileName = metadata['identifier']\n \n # The y values in the database is \"wrong\": the conversion commands\n # start from the top left corner but MapHub starts from the bottom\n # left. Therefore, we need to \"flip\" the y values around the median\n # line of the map.\n mapHeight = Float(metadata['height'])\n median = mapHeight / 2\n controlPoints.map! do |cp|\n y = Float(cp['y'])\n if (y > median)\n difference = y - median\n y = median - difference\n elsif (y < median)\n difference = median - y\n y = median + difference\n else\n # This point is exactly on the median. Don't anger it.\n end\n cp['y'] = y\n cp\n end\n \n ENV['GDAL_DATA'] = $GDALRoot\n dir = Dir.mktmpdir()\n \n # Translate the image.\n translateCommand = 'gdal_translate -of VRT -a_srs EPSG:4326'\n controlPoints.each do |cp|\n translateCommand = translateCommand+' -gcp '+cp['x'].to_s+' '+cp['y'].to_s+' '+cp['lng']+' '+cp['lat']\n end\n translateCommand = translateCommand+' '+params['imageDirectory']+'/raw/'+fileName+'.jp2 '+dir.to_s+'/'+fileName+'-original.vrt'\n puts \"Translating: #{translateCommand}\"\n system(translateCommand)\n \n # Warp the image.\n warpCommand='gdalwarp -of VRT -s_srs EPSG:4326 -t_srs EPSG:4326 '+dir.to_s+'/'+fileName+'-original.vrt '+dir.to_s+'/'+fileName+'-warped.vrt'\n puts \"Warping: #{warpCommand}\"\n system(warpCommand)\n\n # Generate the tile set, placing the generated images in the temporary\n # directory.\n #tileCommand='gdal2tiles.py -n '+dir.to_s+'/'+fileName+'-warped.vrt '+dir.to_s+'/'+$tilesetName\n publishURL = params['publishServerURL'] + $tilesetName\n tileCommand='gdal2tiles.py -u '+publishURL+' -k '+dir.to_s+'/'+fileName+'-warped.vrt '+dir.to_s+'/'+fileName\n puts \"Tiling: #{tileCommand}\"\n system(tileCommand)\n \n # Next we need to tell the server what the new map boundaries are. Get\n # the XML data so we can parse out the boundaries.\n # xmlFile = File.new(dir.to_s+'/'+$tilesetName+'/tilemapresource.xml')\n # xmlDoc = REXML::Document.new(xmlFile)\n # bounds = xmlDoc.root.elements['BoundingBox'].attributes\n # \n # Make a PUT request to update the map with the new boundaries.\n # This is disabled for the time being.\n # uri = URI(params['metadataServerURL'].to_s+'maps/'+metadata['id'].to_s)\n # request = Net::HTTP::Put.new(uri.path)\n # request.set_form_data(\n # 'ne_lat' => bounds['maxx'],\n # 'ne_lng' => bounds['maxy'],\n # 'sw_lat' => bounds['minx'],\n # 'sw_lng' => bounds['miny']\n # )\n # http = Net::HTTP.new(uri.host, uri.port)\n # response = http.request(request)\n \n # Clean up the generated files to leave only the images and the XML\n # file which contains the map bounds and other GIS information.\n FileUtils.rm(Dir.glob(dir.to_s+'/'+$tilesetName+'/*.html'))\n \n # Remove the current tile set and move the new tile set into its\n # place.\n FileUtils.mkdir_p(params['imageDirectory']+'/'+$tilesetName)\n FileUtils.rm_rf(params['imageDirectory']+'/'+$tilesetName+'/'+fileName)\n \n # Move /tmp/.../IDENTIFIER to target/ts_google/IDENTIFIER\n FileUtils.mv(dir.to_s+'/'+fileName, params['imageDirectory']+'/'+$tilesetName+'/'+fileName)\n \n return true\n end\n \n return false\n end", "def update\n par = img_properties\n logger.info(\"parameters: #{par.inspect}\")\n valid = true\n\n # find by user associated to app key, not by user from request parameter!\n @image = Image.editable_by(@user).find_by_guid(params[:id])\n\n return not_found if !@image\n\n # set these variables back to nil if they were in the request but blank\n if par[:ref]\n @image.ref = par[:ref].blank? ? nil : par[:ref]\n end\n if par[:name]\n @image.name = par[:name].blank? ? nil : par[:name]\n end\n if par[:page_url]\n @image.page_url = par[:page_url].blank? ? nil : par[:page_url]\n end\n @image.private = par[:private] if par[:private]\n\n # update calibration data if specified\n if !par[:calibrate_length].blank?\n @image.calibrate_length = par[:calibrate_length].to_f\n @image.calibrate_unit = par[:calibrate_unit].to_i if !par[:calibrate_unit].blank?\n @image.calibrate_coords = par[:calibrate_coords] if !par[:calibrate_coords].blank?\n @image.ppi = calculate_ppi(@image)\n end\n\n orig_url = par[:original_url] || par[:url]\n begin\n # this may fail\n if !orig_url.blank? && orig_url != @image.original_url\n # url was updated\n @image.remote_upload_url = orig_url\n @image.original_url = orig_url\n end\n rescue CarrierWave::DownloadError\n @image.errors.add(:remote_upload_url, \"^This url doesn't appear to be valid\")\n valid = false\n rescue CarrierWave::IntegrityError\n @image.errors.add(:remote_upload_url, \"^This url does not appear to point to a valid image\")\n valid = false\n rescue StandardError\n @image.errors.add(:remote_upload_url, \"There does not appear to be an image at this url\")\n valid = false\n end\n\n if valid && @image.save\n # update product if set\n @image.user_product = par[:product] if par[:product]\n\n image_data = @image.js_serialize\n # if the user hit the 'save and next' button, include the guid of the next image in the response.\n # The client side will redirect to the edit page for that image. \n if params[:commit] == 'save and next'\n image = Image.find_most_recent_uncalibrated(current_user.id)\n image_data['nextImage'] = image.guid if image\n end\n render :json => image_data, :callback => params[:callback]\n else\n render :json => { :error => 403, :messages => prepare_errors(@image), :callback => params[:callback] }, :status => 200\n end\n end", "def update!(**args)\n @dense_features = args[:dense_features] if args.key?(:dense_features)\n @encoded_image_string = args[:encoded_image_string] if args.key?(:encoded_image_string)\n @encoded_image_string_small = args[:encoded_image_string_small] if args.key?(:encoded_image_string_small)\n @encoded_thumbnails = args[:encoded_thumbnails] if args.key?(:encoded_thumbnails)\n @id = args[:id] if args.key?(:id)\n @ocr_text = args[:ocr_text] if args.key?(:ocr_text)\n @quality_scores = args[:quality_scores] if args.key?(:quality_scores)\n @should_update_default_thumbnail = args[:should_update_default_thumbnail] if args.key?(:should_update_default_thumbnail)\n @thumbnailer_model_version = args[:thumbnailer_model_version] if args.key?(:thumbnailer_model_version)\n @timestamp_ms = args[:timestamp_ms] if args.key?(:timestamp_ms)\n @type = args[:type] if args.key?(:type)\n @user_reported_thumbnail = args[:user_reported_thumbnail] if args.key?(:user_reported_thumbnail)\n @user_reported_thumbnails = args[:user_reported_thumbnails] if args.key?(:user_reported_thumbnails)\n @version = args[:version] if args.key?(:version)\n end", "def stream_image(headers, index, is_retina)\n image_option = selected_image_at_index index.to_i\n return nil if image_option.nil?\n\n image_file_name = \"#{image_option['path']}\"\n image_file_name.gsub! /\\.png/i, '@2x.png' if (is_retina.to_i >= 1)\n image_file_path = \"#{@assets_path}/images/#{image_file_name}\"\n\n read_file headers, image_file_path, 'image/png'\n end", "def create_image_frame(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def update!(**args)\n @data = args[:data] if args.key?(:data)\n @mimetype = args[:mimetype] if args.key?(:mimetype)\n end", "def set_image\n @image = Image.find(params[:id]).decorate\n end", "def update!(**args)\n @encoded_data = args[:encoded_data] if args.key?(:encoded_data)\n @first_value = args[:first_value] if args.key?(:first_value)\n @num_entries = args[:num_entries] if args.key?(:num_entries)\n @rice_parameter = args[:rice_parameter] if args.key?(:rice_parameter)\n end", "def set_image_file\n @image_file = ImageFile.find_by_id(params[:id])\n end" ]
[ "0.65617687", "0.6207883", "0.61605865", "0.597902", "0.5892953", "0.58489525", "0.57709026", "0.575025", "0.5632139", "0.56035566", "0.55919546", "0.55775326", "0.5544361", "0.5537182", "0.55243593", "0.5522123", "0.549101", "0.5489181", "0.54658824", "0.54581183", "0.54499614", "0.54481894", "0.54100615", "0.5399037", "0.53928876", "0.5369561", "0.5364221", "0.5352007", "0.5344774", "0.53175247", "0.5301772", "0.52901626", "0.5278691", "0.5266849", "0.5254869", "0.5252867", "0.5250245", "0.52322775", "0.5227395", "0.5224646", "0.52122223", "0.5196667", "0.5195182", "0.5187308", "0.51834357", "0.5178304", "0.5173805", "0.5170303", "0.51677215", "0.5162969", "0.51602644", "0.51596206", "0.51539826", "0.5125561", "0.5124705", "0.5115914", "0.5098173", "0.5089186", "0.5081202", "0.50787365", "0.5077686", "0.5071802", "0.50686723", "0.50686723", "0.5063868", "0.5063678", "0.5062307", "0.5061786", "0.50577563", "0.50439215", "0.50399345", "0.50349057", "0.5034826", "0.5030804", "0.502834", "0.502834", "0.5026494", "0.5026139", "0.50215423", "0.5021395", "0.50184405", "0.5016789", "0.49967605", "0.4980215", "0.49799687", "0.49718645", "0.49701387", "0.49683037", "0.49668673", "0.49634323", "0.4956227", "0.49510264", "0.49507207", "0.49488795", "0.49446687", "0.49426052", "0.49413365", "0.49358785", "0.49337074", "0.4933278" ]
0.6608118
0
Update parameters of TIFF image according to fax parameters
def update_tiff_to_fax_from_storage puts('Update parameters of TIFF image according to fax parameters') upload_sample_image_to_cloud # Update TIFF Image parameters according to fax parameters folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage storage = nil # We are using default Cloud Storage request = AsposeImagingCloud::ConvertTiffToFaxRequest.new(get_sample_image_file_name, storage, folder) puts('Call ConvertTiffToFax') updated_image = imaging_api.convert_tiff_to_fax(request) save_updated_image_to_output('ConvertTiffToFax.tiff', updated_image) puts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_tiff_to_fax_from_request\n puts('Update parameters of TIFF image from request body according to fax parameters.')\n\n upload_sample_image_to_cloud\n\n # Update TIFF Image parameters according to fax parameters\n out_path = nil\n storage = nil # We are using default Cloud Storage\n\n input_stream = File.open(File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, get_sample_image_file_name), 'r')\n request = AsposeImagingCloud::CreateFaxTiffRequest.new(input_stream, out_path, storage)\n\n puts('Call CreateFaxTiff')\n\n updated_image = imaging_api.create_fax_tiff(request)\n save_updated_sample_image_to_output(updated_image, updated_image)\n puts\n end", "def modify_tiff_and_upload_to_storage\n puts('Update parameters of a TIFF image and upload to cloud storage')\n\n upload_sample_image_to_cloud\n\n compression = 'adobedeflate'\n resolution_unit = 'inch'\n bit_depth = 1\n horizontal_resolution = 150.0\n vertical_resolution = 150.0\n from_scratch = nil\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ModifyTiffRequest.new(\n get_sample_image_file_name, bit_depth, compression, resolution_unit, horizontal_resolution,\n vertical_resolution, from_scratch, folder, storage)\n\n puts(\"Call ModifyTiff with params: compression: #{compression}, resolution unit: #{resolution_unit}, \" +\n \"bit depth: #{bit_depth}, horizontal resolution: #{horizontal_resolution}, vertical resolution: \" +\n \"#{vertical_resolution}\")\n\n updated_image = @imaging_api.modify_tiff(request)\n upload_image_to_cloud(get_modified_sample_image_file_name, updated_image)\n puts\n end", "def update_properties\r\n if @picture.origin == 0\r\n set_origin(0, 0)\r\n else\r\n set_origin(bitmap.width / 2, bitmap.height / 2)\r\n end\r\n set_position(@picture.x, @picture.y)\r\n self.z = @picture.number\r\n self.zoom_x = @picture.zoom_x / 100.0\r\n self.zoom_y = @picture.zoom_y / 100.0\r\n self.opacity = @picture.opacity\r\n shader.blend_type = @picture.blend_type\r\n self.angle = @picture.angle\r\n tone = @picture.tone\r\n unless tone.eql?(@current_tone)\r\n shader.set_float_uniform('tone', tone)\r\n @current_tone = tone.clone\r\n end\r\n end", "def modify_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def update!(**args)\n @far = args[:far] if args.key?(:far)\n @format = args[:format] if args.key?(:format)\n @image_height = args[:image_height] if args.key?(:image_height)\n @image_width = args[:image_width] if args.key?(:image_width)\n @mime = args[:mime] if args.key?(:mime)\n @near = args[:near] if args.key?(:near)\n @units = args[:units] if args.key?(:units)\n end", "def modify_tiff_from_storage\n puts('Update parameters of a TIFF image from cloud storage')\n\n upload_sample_image_to_cloud\n\n compression = 'adobedeflate'\n resolution_unit = 'inch'\n bit_depth = 1\n horizontal_resolution = 150.0\n vertical_resolution = 150.0\n from_scratch = nil\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ModifyTiffRequest.new(\n get_sample_image_file_name, bit_depth, compression, resolution_unit, horizontal_resolution,\n vertical_resolution, from_scratch, folder, storage)\n\n puts(\"Call ModifyTiff with params: compression: #{compression}, resolution unit: #{resolution_unit}, bit depth:\" +\n \" #{bit_depth}, horizontal resolution: #{horizontal_resolution}, vertical resolution: \" +\n \"#{vertical_resolution}\")\n\n updated_image = imaging_api.modify_tiff(request)\n save_updated_sample_image_to_output(updated_image, false)\n puts\n end", "def update!(**args)\n @dpi = args[:dpi] if args.key?(:dpi)\n @height_px = args[:height_px] if args.key?(:height_px)\n @m_size = args[:m_size] if args.key?(:m_size)\n @neng_size = args[:neng_size] if args.key?(:neng_size)\n @width_px = args[:width_px] if args.key?(:width_px)\n end", "def update!(**args)\n @filename = args[:filename] if args.key?(:filename)\n @height = args[:height] if args.key?(:height)\n @ms_offset = args[:ms_offset] if args.key?(:ms_offset)\n @width = args[:width] if args.key?(:width)\n end", "def create_modified_tiff_from_request_body\n puts('Update parameters of a TIFF image from request body')\n\n compression = 'adobedeflate'\n resolution_unit = 'inch'\n bit_depth = 1\n horizontal_resolution = 150.0\n vertical_resolution = 150.0\n from_scratch = nil\n storage = nil # We are using default Cloud Storage\n out_path = nil # Path to updated file (if this is empty, response contains streamed image)\n\n input_stream = File.open(File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, get_sample_image_file_name), 'r')\n request = AsposeImagingCloud::CreateModifiedTiffRequest.new(\n input_stream, bit_depth, compression, resolution_unit, horizontal_resolution, vertical_resolution,\n from_scratch, out_path, storage)\n\n puts(\"Call CreateModifiedTiff with params: compression: #{compression}, resolution unit: #{resolution_unit}, \" +\n \"bit depth: #{bit_depth}, horizontal resolution: #{horizontal_resolution}, vertical resolution: \" +\n \"#{vertical_resolution}\")\n\n updated_image = imaging_api.create_modified_tiff(request)\n save_updated_sample_image_to_output(updated_image, true)\n puts\n end", "def reset_aftinfo\n @afopac = AFTIMG_OPACITY_EASE\n @afrate = AFTIMG_IMAGE_RATE\n end", "def reset_aftinfo\n @afopac = AFTIMG_OPACITY_EASE\n @afrate = AFTIMG_IMAGE_RATE\n end", "def set_image_attrib\n @image_attrib = ImageAttrib.find(params[:id])\n end", "def create_modified_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def reformat(tifs, cfg)\n # do vis\n vis = File.basename(tifs['vis'], '.tif')\n command = \" #{cfg['awips_conversion']['vis_stretch']} #{vis}.tif #{vis}.stretched.tif\"\n puts(\"INFO: stretching #{command}\")\n shell_out!(command,clean_environment: true)\n command = \"gdalwarp #{cfg['awips_conversion']['warp_opts']} -te #{cfg['awips_conversion']['extents']} #{cfg['gdal']['co_opts']} -t_srs #{cfg['awips_conversion']['proj']} #{vis}.stretched.tif #{vis}.302.tif\"\n puts(\"INFO: warping to 302.. #{command}\")\n shell_out!(command,clean_environment: true)\n end", "def setImage\n str = @pixbuf.pixels\n str.length.times do |i| str[i] = @image_test[@current][i/3] end\n @pixbuf.pixels = str\n @image.pixbuf = @pixbuf.scale(280,280,Gdk::Pixbuf::INTERP_NEAREST)\n set_title(\"MSI, img ##{@current} => #{@label_test[@current]}\")\n if @edge\n edgifyImage\n end\n end", "def create_fax_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def set_prawn(prawn)\n\t\t@prawn = prawn\n\t\[email protected] = @x + SUB_TILE_WIDTH/2.0 - Prawn::TILE_WIDTH/2 \n\t\[email protected] = @y + SUB_TILE_HEIGHT/2.0 \n\t\[email protected] = @angle\n\tend", "def update!(**args)\n @deprecated_entropy_color = args[:deprecated_entropy_color] if args.key?(:deprecated_entropy_color)\n @filename = args[:filename] if args.key?(:filename)\n @flags = args[:flags] if args.key?(:flags)\n @height = args[:height] if args.key?(:height)\n @width = args[:width] if args.key?(:width)\n end", "def change_info(n,h,w)\n @name = n\n @height = h\n @weight = w\nend", "def update!(**args)\n @blur_baseline_config = args[:blur_baseline_config] if args.key?(:blur_baseline_config)\n @smooth_grad_config = args[:smooth_grad_config] if args.key?(:smooth_grad_config)\n @step_count = args[:step_count] if args.key?(:step_count)\n end", "def update!(**args)\n @blur_baseline_config = args[:blur_baseline_config] if args.key?(:blur_baseline_config)\n @smooth_grad_config = args[:smooth_grad_config] if args.key?(:smooth_grad_config)\n @step_count = args[:step_count] if args.key?(:step_count)\n end", "def update!(**args)\n @inferred_image_source = args[:inferred_image_source] if args.key?(:inferred_image_source)\n @inferred_image_type = args[:inferred_image_type] if args.key?(:inferred_image_type)\n end", "def change_info(n, h, w)\n self.name = n\n self.height = h\n self.weight = w\n end", "def change_info(n, h, w)\n self.name = n\n self.height = h\n self.weight = w\n end", "def change_info(n, h, w)\n self.name = n\n self.height = h\n self.weight = w\n end", "def update!(**args)\n @bytes_value = args[:bytes_value] if args.key?(:bytes_value)\n @float_value = args[:float_value] if args.key?(:float_value)\n @image_template = args[:image_template] if args.key?(:image_template)\n @int32_value = args[:int32_value] if args.key?(:int32_value)\n @version = args[:version] if args.key?(:version)\n end", "def update_zoom\n @effectus_old_zoom_x = @picture.zoom_x\n @effectus_old_zoom_y = @picture.zoom_y\n self.zoom_x = @effectus_old_zoom_x / 100.0\n self.zoom_y = @effectus_old_zoom_y / 100.0\n end", "def update_afterimage_info\n if @battler\n @afterimage_opac = @battler.afopac\n @afterimage_rate = @battler.afrate\n return\n end\n @afterimage_opac = 20\n @afterimage_rate = 3\n end", "def change_info(n, h, w)\n self.name = n\n self.height = h\n self.weight = w\nend", "def change_info(n, h, w)\n name = n\n height = h\n weight = w\nend", "def change_info(n, h, w)\n name = n\n height = h\n weight = w\nend", "def modify_image\n if @vertical\n @main_image = @main_image.zooming_v\n else\n @main_image = @main_image.zooming_h\n end\n end", "def update\n respond_to do |format|\n if @taxi_image.update(taxi_image_params)\n format.html { redirect_to @taxi_image, notice: 'Taxi image was successfully updated.' }\n format.json { render :show, status: :ok, location: @taxi_image }\n else\n format.html { render :edit }\n format.json { render json: @taxi_image.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_image_attributes\n if imageable.present?\n self.width, self.height = `identify -format \"%wx%h\" #{url.file.path}`.split(/x/)\n end\n end", "def analyze_tiff(file,debug)\n result = {:mime=>'image/tiff'}\n littleEndian = [0x49,0x49].eql?(file.read(2))\n file.seek(2,IO::SEEK_CUR)\n nextIFD = littleEndian ? file.read(4).unpack('V')[0] : file.read(4).unpack('N')[0]\n result.merge!(analyze_exif(file,nextIFD,littleEndian,debug))\n result\n end", "def start_export( img_width, img_height)\n @width ||= img_width # If they be nil\n @height ||= img_height\n \n x_factor, y_factor = (@width / img_width.to_f), (@height / img_height.to_f) \n \n @stash = @exporter\n @exporter = Tracksperanto::Tool::Scaler.new(@exporter, :x_factor => x_factor, :y_factor => y_factor)\n super\n end", "def imperialize(params)\n self.weight = (params[:weight].to_f * 0.00220462).round(2)\n self.height = (params[:height].to_f / 2.54).round(2)\n self.depth = (params[:depth].to_f / 2.54).round(2)\n self.width = (params[:width].to_f / 2.54).round(2)\n end", "def update_image image\n temp_path = @image_folder.detect{|image_string| image_string.downcase == \"#{@image_path}/#{image.image_file_name}\".downcase}\n filename = File.basename(temp_path)\n image.image_number = @img_count\n\n @img_count += 1\n if temp_path.blank?\n InputBatch::Log.status_log.error \">>>>>>>>Image #{filename} not found<<<<<<<<<\"\n puts \">>>>>>>>>>>>Image #{filename} not found\"\n InputBatch::Log.error_log.error \"Error on line #{@row_index} : Image #{filename} not found\"\n else\n InputBatch::Log.status_log.info \"Image #{filename} found\"\n image.page_count = %x[identify #{temp_path}].split(filename).length-1 rescue nil\n end\n\n rename_image image if facility.index_file_parser_type == \"WellsFargo_bank\"\n return image\n end", "def update_file(params)\n self.processed = false\n self.attributes = params\n set_upload_attributes\n save!\n Avatar.delay.finalize_and_cleanup(id)\n end", "def main\n ImageManip::inspect_image(@image_path)\n dimensions = ImageManip::get_dimensions(@image_path)\n sharp_pixels = get_accidental_pixels(@sharp_path)\n flat_pixels = get_accidental_pixels(@flat_path)\n edits = Hash.new\n edits[:lower_left] = [dimensions[0] / 2, dimensions[1] / 2]\n edits[:rgb_array] = sharp_pixels\n ImageManip::draw_2D_object(@image_path, './new_staff.gif', edits)\n edits[:lower_left] = [dimensions[0] / 3, dimensions[1] / 3]\n edits[:rgb_array] = flat_pixels\n ImageManip::draw_2D_object('./new_staff.gif', './new_staff.gif', edits)\n end", "def put_images_extract_as_tiff_with_http_info(name, page_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_images_extract_as_tiff ...\"\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_images_extract_as_tiff\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.put_images_extract_as_tiff\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/images/extract/tiff\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'destFolder'] = opts[:'dest_folder'] if !opts[:'dest_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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_images_extract_as_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def set_img\n\n end", "def convert_tiff_to_fax(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def update!(**args)\n @enhanced_image = args[:enhanced_image] if args.key?(:enhanced_image)\n @feature_graphic = args[:feature_graphic] if args.key?(:feature_graphic)\n @screenshot = args[:screenshot] if args.key?(:screenshot)\n end", "def update!(**args)\n @preview_length = args[:preview_length] if args.key?(:preview_length)\n @xtag_list = args[:xtag_list] if args.key?(:xtag_list)\n end", "def update!(**args)\n @preview_length = args[:preview_length] if args.key?(:preview_length)\n @xtag_list = args[:xtag_list] if args.key?(:xtag_list)\n end", "def set_taxi_image\n @taxi_image = TaxiImage.find(params[:id])\n end", "def update!(**args)\n @multi_thumbnail_variant = args[:multi_thumbnail_variant] if args.key?(:multi_thumbnail_variant)\n @preview_frame_zero_variant = args[:preview_frame_zero_variant] if args.key?(:preview_frame_zero_variant)\n @thumbnail_variant = args[:thumbnail_variant] if args.key?(:thumbnail_variant)\n @timestamp_ms = args[:timestamp_ms] if args.key?(:timestamp_ms)\n end", "def set_trfileimage\n @trfileimage = Trfileimage.find(params[:id])\n end", "def update!(**args)\n @dimensions = args[:dimensions] if args.key?(:dimensions)\n @font_scale_factor = args[:font_scale_factor] if args.key?(:font_scale_factor)\n end", "def set_size(params = {})\n @width = params[:width] if params[:width]\n @height = params[:height] if params[:height]\n @x_scale = params[:x_scale] if params[:x_scale]\n @y_scale = params[:y_scale] if params[:y_scale]\n @x_offset = params[:x_offset] if params[:x_offset]\n @y_offset = params[:y_offset] if params[:y_offset]\n end", "def update!(**args)\n @docid = args[:docid] if args.key?(:docid)\n @frame_identifier = args[:frame_identifier] if args.key?(:frame_identifier)\n @regions = args[:regions] if args.key?(:regions)\n @starburst_features_v4 = args[:starburst_features_v4] if args.key?(:starburst_features_v4)\n @starburst_tokens_v4 = args[:starburst_tokens_v4] if args.key?(:starburst_tokens_v4)\n @thumbnail_type = args[:thumbnail_type] if args.key?(:thumbnail_type)\n end", "def update!(**args)\n @animations = args[:animations] if args.key?(:animations)\n @image = args[:image] if args.key?(:image)\n end", "def bmp=(arg1)\n bmp(arg1)\n end", "def append_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, nil)\n nil\n end", "def update!(**args)\n @style_image_type_predictions = args[:style_image_type_predictions] if args.key?(:style_image_type_predictions)\n @version = args[:version] if args.key?(:version)\n end", "def set_fog_data(fog, fog_data)\n fog.bitmap = Cache.parallax(fog_data[0])\n fog.opacity = fog_data[1] || 255\n fog.blend_type = fog_data[2] || 0\n fog.zoom_x = fog_data[3] || 1\n fog.zoom_y = fog_data[3] || 1\n fog.x_speed = fog_data[4] || 0\n fog.y_speed = fog_data[5] || 0\n end", "def update!(**args)\n @feature = args[:feature] if args.key?(:feature)\n @label_group = args[:label_group] if args.key?(:label_group)\n @roi = args[:roi] if args.key?(:roi)\n end", "def set name, value, match_image, flags, gtype, destructive\n if gtype == IMAGE_TYPE\n value = Operation.imageize match_image, value\n\n # in non-destructive mode, make sure we have a unique copy\n if (flags & ARGUMENT_MODIFY) != 0 &&\n !destructive\n value = value.copy.copy_memory\n end\n elsif gtype == ARRAY_IMAGE_TYPE\n value = value.map { |x| Operation.imageize match_image, x }\n end\n\n super name, value\n end", "def modify_jpeg2000(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def update_metadata\n file_attributes = ::FileSetEditForm.model_attributes(attributes)\n actor.update_metadata(file_attributes)\n end", "def setup\n size 200, 200\n @a = load_image 'construct.jpg'\n @b = load_image 'wash.jpg'\n @offset = 0.0\nend", "def update!(**args)\n @column_count = args[:column_count] if args.key?(:column_count)\n @end_time_offset = args[:end_time_offset] if args.key?(:end_time_offset)\n @file_prefix = args[:file_prefix] if args.key?(:file_prefix)\n @format = args[:format] if args.key?(:format)\n @interval = args[:interval] if args.key?(:interval)\n @quality = args[:quality] if args.key?(:quality)\n @row_count = args[:row_count] if args.key?(:row_count)\n @sprite_height_pixels = args[:sprite_height_pixels] if args.key?(:sprite_height_pixels)\n @sprite_width_pixels = args[:sprite_width_pixels] if args.key?(:sprite_width_pixels)\n @start_time_offset = args[:start_time_offset] if args.key?(:start_time_offset)\n @total_count = args[:total_count] if args.key?(:total_count)\n end", "def update!(**args)\n @affine_matrix = args[:affine_matrix] if args.key?(:affine_matrix)\n @data = args[:data] if args.key?(:data)\n @data_factor = args[:data_factor] if args.key?(:data_factor)\n @feature_vector = args[:feature_vector] if args.key?(:feature_vector)\n @opaque_data = args[:opaque_data] if args.key?(:opaque_data)\n @orientation = args[:orientation] if args.key?(:orientation)\n @scale = args[:scale] if args.key?(:scale)\n @strength = args[:strength] if args.key?(:strength)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n end", "def add_fuzz_to_images\n if fuzz\n # We must set fuzz on images using the format \"40%\"\n # where fcmp uses the format \"0.4\"\n fuzz_as_percent = \"#{fuzz.round(2)*100}%\"\n puts \"Setting fuzz at #{fuzz_as_percent}\" if @verbose\n search_image.fuzz = fuzz_as_percent\n template_image.fuzz = fuzz_as_percent\n end\n end", "def set_featuring\n @featuring = Featuring.find(params[:id])\n end", "def set_featureimg\n @featureimg = Featureimg.find(params[:id])\n end", "def update_image_features(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :PUT, nil)\n nil\n end", "def update!(**args)\n @categorical_threshold_config = args[:categorical_threshold_config] if args.key?(:categorical_threshold_config)\n @import_features_analysis = args[:import_features_analysis] if args.key?(:import_features_analysis)\n @numerical_threshold_config = args[:numerical_threshold_config] if args.key?(:numerical_threshold_config)\n @snapshot_analysis = args[:snapshot_analysis] if args.key?(:snapshot_analysis)\n end", "def operation(*args)\n src_file, out_file = args\n image = Vips::Image.new_from_file src_file\n image.tiffsave(out_file, **options)\n # Return lof if any\n end", "def update!(**args)\n @base = args[:base] if args.key?(:base)\n @connector = args[:connector] if args.key?(:connector)\n @extent = args[:extent] if args.key?(:extent)\n end", "def update!(**args)\n @aspect_ratio = args[:aspect_ratio] if args.key?(:aspect_ratio)\n @image_url = args[:image_url] if args.key?(:image_url)\n @on_click = args[:on_click] if args.key?(:on_click)\n end", "def update!(**args)\n @aspect_ratio = args[:aspect_ratio] if args.key?(:aspect_ratio)\n @image_url = args[:image_url] if args.key?(:image_url)\n @on_click = args[:on_click] if args.key?(:on_click)\n end", "def update!(**args)\n @aspect_ratio = args[:aspect_ratio] if args.key?(:aspect_ratio)\n @image_url = args[:image_url] if args.key?(:image_url)\n @on_click = args[:on_click] if args.key?(:on_click)\n end", "def upRes(file_path)\t\n\t\toriginal_image = Magick::Image.read(file_path) { self.density = \"300.0x300.0\" }\n\t\toriginal_image.each do |image|\n\t\t\t image = image.resample(300.0, 300.0)\n\t\t\t image.write(file_path) { self.quality = 100 }\n\t\tend\n\tend", "def change_info(n, h, w)\n #using self. tells ruby we are calling the set method we created earlier, not a local variable\n self.name = n\n self.height = h\n self.weight = w\n end", "def update!(**args)\n @approximation_error = args[:approximation_error] if args.key?(:approximation_error)\n @baseline_output_value = args[:baseline_output_value] if args.key?(:baseline_output_value)\n @feature_attributions = args[:feature_attributions] if args.key?(:feature_attributions)\n @instance_output_value = args[:instance_output_value] if args.key?(:instance_output_value)\n @output_display_name = args[:output_display_name] if args.key?(:output_display_name)\n @output_index = args[:output_index] if args.key?(:output_index)\n @output_name = args[:output_name] if args.key?(:output_name)\n end", "def update_asset_attributes\n if !self.external_service? and self.present? and self.changed?\n self.content_type = self.filename.file.content_type\n self.file_size = self.filename.file.size\n self.width, self.height = `identify -format \"%wx%h\" #{self.filename.file.path}`.split(/x/) unless self.document? or self.width? or self.height?\n self.ratio = self.width.to_f / self.height.to_f if self.width.present? and self.height.present?\n end\n end", "def update!(**args)\n @inferred_image_id = args[:inferred_image_id] if args.key?(:inferred_image_id)\n @inferred_image_source = args[:inferred_image_source] if args.key?(:inferred_image_source)\n @inferred_image_type = args[:inferred_image_type] if args.key?(:inferred_image_type)\n @neardup_info = args[:neardup_info] if args.key?(:neardup_info)\n end", "def setAperture _args\n \"setAperture _args;\" \n end", "def update!(**args)\n @checksum = args[:checksum] if args.key?(:checksum)\n @color_sampling = args[:color_sampling] if args.key?(:color_sampling)\n @dense_features = args[:dense_features] if args.key?(:dense_features)\n @dense_general_extra_features = args[:dense_general_extra_features] if args.key?(:dense_general_extra_features)\n @external_image_id = args[:external_image_id] if args.key?(:external_image_id)\n @is_assigned = args[:is_assigned] if args.key?(:is_assigned)\n @is_instant = args[:is_instant] if args.key?(:is_instant)\n @model_version = args[:model_version] if args.key?(:model_version)\n @overwrite_reason = args[:overwrite_reason] if args.key?(:overwrite_reason)\n @quantized_features = args[:quantized_features] if args.key?(:quantized_features)\n @score = args[:score] if args.key?(:score)\n @sparse_features = args[:sparse_features] if args.key?(:sparse_features)\n @thumbnail_set = args[:thumbnail_set] if args.key?(:thumbnail_set)\n @thumbnail_version = args[:thumbnail_version] if args.key?(:thumbnail_version)\n @type = args[:type] if args.key?(:type)\n end", "def update!(**args)\n @image_docid = args[:image_docid] if args.key?(:image_docid)\n @thumb_height = args[:thumb_height] if args.key?(:thumb_height)\n @thumb_type = args[:thumb_type] if args.key?(:thumb_type)\n @thumb_width = args[:thumb_width] if args.key?(:thumb_width)\n end", "def update!(**args)\n @x_offsets = args[:x_offsets] if args.key?(:x_offsets)\n @y_offsets = args[:y_offsets] if args.key?(:y_offsets)\n @z_offsets = args[:z_offsets] if args.key?(:z_offsets)\n end", "def update!(**args)\n @x_offsets = args[:x_offsets] if args.key?(:x_offsets)\n @y_offsets = args[:y_offsets] if args.key?(:y_offsets)\n @z_offsets = args[:z_offsets] if args.key?(:z_offsets)\n end", "def set_compass_correction_parameters(new_mag_field, new_offset0, new_offset1, new_offset2, new_gain0, new_gain1, new_gain2, new_t0, new_t1, new_t2, new_t3, new_t4, new_t5)\n Klass.setCompassCorrectionParameters(@handle, new_mag_field, new_offset0, new_offset1, new_offset2, new_gain0, new_gain1, new_gain2, new_t0, new_t1, new_t2, new_t3, new_t4, new_t5)\n\t true\n end", "def update!(**args)\n @fife_url = args[:fife_url] if args.key?(:fife_url)\n @height = args[:height] if args.key?(:height)\n @width = args[:width] if args.key?(:width)\n end", "def prepare_format_properties # :nodoc:\n # Separate format objects into XF and DXF formats.\n prepare_formats\n\n # Set the font index for the format objects.\n prepare_fonts\n\n # Set the number format index for the format objects.\n prepare_num_formats\n\n # Set the border index for the format objects.\n prepare_borders\n\n # Set the fill index for the format objects.\n prepare_fills\n end", "def update!(**args)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n @zoom = args[:zoom] if args.key?(:zoom)\n end", "def update!(**args)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n @zoom = args[:zoom] if args.key?(:zoom)\n end", "def set_pix\n @pix = Pix.find(params[:id])\n end", "def update!(**args)\n @discretized_style_image_type_confidence = args[:discretized_style_image_type_confidence] if args.key?(:discretized_style_image_type_confidence)\n @style_image_type = args[:style_image_type] if args.key?(:style_image_type)\n end", "def update!(**args)\n @deprecated_src_fp = args[:deprecated_src_fp] if args.key?(:deprecated_src_fp)\n @count = args[:count] if args.key?(:count)\n @face = args[:face] if args.key?(:face)\n @size = args[:size] if args.key?(:size)\n @text = args[:text] if args.key?(:text)\n @type = args[:type] if args.key?(:type)\n @weight = args[:weight] if args.key?(:weight)\n end", "def internal_file_attributes=(_arg0); end", "def initialize(p, opts, x, y, width, height, padLeft, padRight, padTop, padBottom, app)\n \n @parentApp = app #Stores the parent app for the initialization of image data later in the code.\n \n @drawColor = FXRGB(255, 0, 0) #variable that stores the active draw color\n @mouseDown = false #checks if mouse is depressed\n #@dirty = false #Checks if canvas has data in it\n @brushSize = 1 #stores the active brush size\n @parent = p #stores the parent app for object initialization\n @canvasWidth = width #stores the current canvas width\n @canvasHeight = height #stores the current canvas height\n \n @layerArray = Array.new #stores hide/show state of each layer.\n @imageArray = Array.new #stores the image data of each layer.\n @dirtyArray = Array.new #stores the dirty status of each layer.\n @activeIndex = 0\n \n @saved = false #Checks if the image has been saved.\n @savePath = \"\" #Stores the image save path\n\n #The horitzontal frame that stores the verticle frame. \n @parentFrame = FXHorizontalFrame.new(p, opts, x, y, width, height, \n padLeft, padRight, padTop, padBottom)\n \n #Canvas Frame is the vertical frame that stores the canvas.\n @canvas_frame = FXVerticalFrame.new(@parentFrame,FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT, \n 0, 0, 0, 0, 0, 0, 0, 0) \n \n #exportImage stores the image data that is saved.\n @exportImage = FXPNGImage.new(app, nil, @canvasWidth, @canvasHeight)\n \n @exportImage.create #initializes the image object.\n @exportImage.resize(@canvasWidth, @canvasHeight) #Sizes the image to match canvas width and height\n \n #Stores the image that is in the active layer.\n createImage() #Calls the createImage method. \n @activeImage = @imageArray[@activeIndex] #Sets the active image to the image stored in the first index of the imageArray\n \n \n #canvas stores the canvas object that is draw on.\n @canvas = FXCanvas.new(@canvas_frame, nil, 0, LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT|LAYOUT_TOP|LAYOUT_LEFT, 0, 0, width, height) \n \n #On creation, connect to the SEL_Paint handler. Every time the canvas changes, the canvas is repainted.\n @canvas.connect(SEL_PAINT, method(:onCanvasRepaint))\n \n @canvas.resize(@canvasWidth, @canvasHeight) #Sets the canvas to the default width and height.\n \n #Event handler that checks for left mouse button depression. \n @canvas.connect(SEL_LEFTBUTTONPRESS) do |sender, sel, event|\n \n @canvas.grab #grabs the canvas. Windows stores mouse data when mouse is inside canvas.\n @mouseDown = true #The mouse is depressed. Set mouseDown to true.\n \n #Get device context for the canvas\n dc = FXDCWindow.new(@activeImage)\n\n # Set the foreground color for drawing\n dc.foreground = @drawColor\n #dc.fillRectangle(event.win_x, event.win_y, 2, 2)\n \n #Defines draw alogrithms for a single click or \"Point edit\" on the canvas. \n if @mouseDown #make sure mouse is down.\n if @brushSize == 1 || @brushSize == 2 || @brushSize == 3 #If any of the square draw brushes \n dc.drawLine(event.last_x, event.last_y, event.win_x, event.win_y) #draw a line from the x,y coordinate of mouse depression to latest x,y coordinate.\n end\n if @brushSize == 2 #If brush two...\n \n i=0\n while i < 10 #Draw a series of lines within a 10X10 pixel square onto canvas.\n dc.drawLine(event.last_x+i, event.last_y, event.win_x+i, event.win_y)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x, event.win_y)\n dc.drawLine(event.last_x, event.last_y, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y, event.win_x, event.win_y+i)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x+i, event.win_y)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y)\n i += 1\n end\n end\n \n if @brushSize == 3 || @brushSize == 5 #Draw a series of lines within a 30X30 pixel square onto canvas.\n i=0\n while i < 30\n dc.drawLine(event.last_x+i, event.last_y, event.win_x+i, event.win_y)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x, event.win_y)\n dc.drawLine(event.last_x, event.last_y, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y, event.win_x, event.win_y+i)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x+i, event.win_y)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y)\n i += 1\n end\n end\n if @brushSize == 4 #Paint bucket fills the entire canvas with current draw color.\n dc.foreground = @drawColor\n dc.fillRectangle(event.rect.x, event.rect.y, event.rect.w + @canvas.width, event.rect.h + @canvas.height)\n end\n if @brushSize == 6 #Draws a white line of size 10X10 over any draw data.(Eraser handler)\n i=0\n while i < 10\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y+i)\n i += 1\n end\n end\n\n \n @dirtyArray[@activeIndex] = true # Since there is draw data in the active image, set the image's dirty value to true.\n @canvas.update #Redraw the canvas to display the image data changes onto the canvas.\n # Release the DC immediately\n dc.end\n end\n end\n \n @canvas.connect(SEL_MOTION) do |sender, sel, event| #On mouse motion.\n if @mouseDown\n # Get device context for the canvas\n dc = FXDCWindow.new(@activeImage)\n\n # Set the foreground color for drawing\n dc.foreground = @drawColor\n \n \n #While there is mouse motion, continue to repeat the same draw algorithms as for single points\n if @brushSize == 1 || @brushSize == 2 || @brushSize == 3\n dc.drawLine(event.last_x, event.last_y, event.win_x, event.win_y)\n end\n if @brushSize == 2\n \n i=0\n while i < 10\n dc.drawLine(event.last_x+i, event.last_y, event.win_x+i, event.win_y)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x, event.win_y)\n dc.drawLine(event.last_x, event.last_y, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y, event.win_x, event.win_y+i)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x+i, event.win_y)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y)\n i += 1\n end\n end\n if @brushSize == 3 || @brushSize == 5\n i=0\n while i < 30\n dc.drawLine(event.last_x+i, event.last_y, event.win_x+i, event.win_y)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x, event.win_y)\n dc.drawLine(event.last_x, event.last_y, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y, event.win_x, event.win_y+i)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x+i, event.win_y)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y)\n i += 1\n end\n end\n if @brushSize == 4\n dc.foreground = @drawColor\n dc.fillRectangle(event.rect.x, event.rect.y, event.rect.w + @canvas.width, event.rect.h + @canvas.height)\n end\n if @brushSize == 6\n i=0\n while i < 10\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y+i)\n i += 1\n end\n end\n\n # We have drawn something, so now the canvas is dirty\n @dirtyArray[@activeIndex] = true\n @canvas.update\n # Release the DC immediately\n dc.end\n end\n end\n \n @canvas.connect(SEL_LEFTBUTTONRELEASE) do |sender, sel, event| #On left mouse release\n @canvas.ungrab #Remove canvas device draw context\n @mouseDown = false #Set mouse down to false\n @canvas.update #Redraw the canvas to reflect changes in image data\n end\n end", "def convert_adjust_params(params)\n params['on'] = params['on'] == 'true' if params['on']\n params['bri'] = params['bri'].to_i if params['bri']\n params['ct'] = params['ct'].to_i if params['ct']\n params['sat'] = params['sat'].to_i if params['sat']\n params['hue'] = params['hue'].to_i if params['hue']\n end", "def update!(**args)\n @blue = args[:blue] if args.key?(:blue)\n @green = args[:green] if args.key?(:green)\n @max_luminance = args[:max_luminance] if args.key?(:max_luminance)\n @min_luminance = args[:min_luminance] if args.key?(:min_luminance)\n @red = args[:red] if args.key?(:red)\n @white_point = args[:white_point] if args.key?(:white_point)\n end", "def set_params\r\n @listing.pictures.build.photo = File.new params[:file].tempfile if params[:file]\r\n respond_to do |format|\r\n format.html { params[:temp_listing] = ResetDate::reset_dates(params[:temp_listing]) }\r\n format.json { params[:temp_listing] = JSON.parse(params[:temp_listing]) }\r\n end\r\n end", "def reset_analyzer filename, dpi, result, upstream\n @raw_barcode = []\n @raw_marked_votes = []\n @filename = filename\n @upstream = upstream\n @upstream.info \"Premier Ballot2: Processing #{filename}, Target DPI=#{dpi}\"\n self.target_dpi = dpi \n end", "def put_page_convert_to_tiff_with_http_info(name, page_number, out_path, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_page_convert_to_tiff ...\"\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_page_convert_to_tiff\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.put_page_convert_to_tiff\"\n end\n # verify the required parameter 'out_path' is set\n if @api_client.config.client_side_validation && out_path.nil?\n fail ArgumentError, \"Missing the required parameter 'out_path' when calling PdfApi.put_page_convert_to_tiff\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/convert/tiff\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'outPath'] = out_path\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'password'] = opts[:'password'] if !opts[:'password'].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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_page_convert_to_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update!(**args)\n @filters = args[:filters] if args.key?(:filters)\n @line_options = args[:line_options] if args.key?(:line_options)\n @name = args[:name] if args.key?(:name)\n @point_options = args[:point_options] if args.key?(:point_options)\n @polygon_options = args[:polygon_options] if args.key?(:polygon_options)\n @zoom_levels = args[:zoom_levels] if args.key?(:zoom_levels)\n end" ]
[ "0.58253926", "0.57195073", "0.5651652", "0.54872596", "0.5463444", "0.52969515", "0.5196241", "0.5158733", "0.51491296", "0.5118988", "0.5118988", "0.50878406", "0.50488585", "0.5047299", "0.5042461", "0.5034973", "0.50137544", "0.49913076", "0.4975679", "0.49155724", "0.49155724", "0.4910158", "0.4895818", "0.4894793", "0.4894793", "0.4875114", "0.48628056", "0.48504367", "0.4843969", "0.48309377", "0.48309377", "0.4792847", "0.4785954", "0.47822362", "0.47524405", "0.47455695", "0.47412264", "0.473691", "0.47303212", "0.47211877", "0.4718085", "0.47057623", "0.4703238", "0.46861178", "0.46819565", "0.46819565", "0.4666611", "0.4659377", "0.46581987", "0.46577013", "0.464704", "0.46448326", "0.46299404", "0.46123552", "0.46079063", "0.4603705", "0.4603673", "0.46006206", "0.45947644", "0.45938328", "0.4590392", "0.45897704", "0.4583707", "0.45808026", "0.45721906", "0.45672882", "0.45655438", "0.45560607", "0.45514625", "0.4545035", "0.45441064", "0.45359507", "0.45359507", "0.45359507", "0.453578", "0.45357162", "0.4532654", "0.4521161", "0.45194042", "0.45161512", "0.45123804", "0.45112655", "0.4509089", "0.4509089", "0.45090455", "0.45065555", "0.45047846", "0.4503332", "0.4503332", "0.45027414", "0.45021722", "0.4498501", "0.44888875", "0.44849652", "0.44839576", "0.4479362", "0.44778305", "0.44772825", "0.4476987", "0.4476228" ]
0.63675535
0
Update parameters of TIFF image from request body according to fax parameters
def convert_tiff_to_fax_from_request puts('Update parameters of TIFF image from request body according to fax parameters.') upload_sample_image_to_cloud # Update TIFF Image parameters according to fax parameters out_path = nil storage = nil # We are using default Cloud Storage input_stream = File.open(File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, get_sample_image_file_name), 'r') request = AsposeImagingCloud::CreateFaxTiffRequest.new(input_stream, out_path, storage) puts('Call CreateFaxTiff') updated_image = imaging_api.create_fax_tiff(request) save_updated_sample_image_to_output(updated_image, updated_image) puts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_modified_tiff_from_request_body\n puts('Update parameters of a TIFF image from request body')\n\n compression = 'adobedeflate'\n resolution_unit = 'inch'\n bit_depth = 1\n horizontal_resolution = 150.0\n vertical_resolution = 150.0\n from_scratch = nil\n storage = nil # We are using default Cloud Storage\n out_path = nil # Path to updated file (if this is empty, response contains streamed image)\n\n input_stream = File.open(File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, get_sample_image_file_name), 'r')\n request = AsposeImagingCloud::CreateModifiedTiffRequest.new(\n input_stream, bit_depth, compression, resolution_unit, horizontal_resolution, vertical_resolution,\n from_scratch, out_path, storage)\n\n puts(\"Call CreateModifiedTiff with params: compression: #{compression}, resolution unit: #{resolution_unit}, \" +\n \"bit depth: #{bit_depth}, horizontal resolution: #{horizontal_resolution}, vertical resolution: \" +\n \"#{vertical_resolution}\")\n\n updated_image = imaging_api.create_modified_tiff(request)\n save_updated_sample_image_to_output(updated_image, true)\n puts\n end", "def modify_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def update_tiff_to_fax_from_storage\n puts('Update parameters of TIFF image according to fax parameters')\n\n upload_sample_image_to_cloud\n\n # Update TIFF Image parameters according to fax parameters\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ConvertTiffToFaxRequest.new(get_sample_image_file_name, storage, folder)\n\n puts('Call ConvertTiffToFax')\n\n updated_image = imaging_api.convert_tiff_to_fax(request)\n save_updated_image_to_output('ConvertTiffToFax.tiff', updated_image)\n puts\n end", "def create_modified_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def append_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, nil)\n nil\n end", "def modify_tiff_and_upload_to_storage\n puts('Update parameters of a TIFF image and upload to cloud storage')\n\n upload_sample_image_to_cloud\n\n compression = 'adobedeflate'\n resolution_unit = 'inch'\n bit_depth = 1\n horizontal_resolution = 150.0\n vertical_resolution = 150.0\n from_scratch = nil\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ModifyTiffRequest.new(\n get_sample_image_file_name, bit_depth, compression, resolution_unit, horizontal_resolution,\n vertical_resolution, from_scratch, folder, storage)\n\n puts(\"Call ModifyTiff with params: compression: #{compression}, resolution unit: #{resolution_unit}, \" +\n \"bit depth: #{bit_depth}, horizontal resolution: #{horizontal_resolution}, vertical resolution: \" +\n \"#{vertical_resolution}\")\n\n updated_image = @imaging_api.modify_tiff(request)\n upload_image_to_cloud(get_modified_sample_image_file_name, updated_image)\n puts\n end", "def create_fax_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def taxi_image_params\n params.fetch(:taxi_image, {})\n end", "def put_images_extract_as_tiff_with_http_info(name, page_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_images_extract_as_tiff ...\"\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_images_extract_as_tiff\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.put_images_extract_as_tiff\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/images/extract/tiff\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'destFolder'] = opts[:'dest_folder'] if !opts[:'dest_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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_images_extract_as_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def img_params\n\n end", "def update!(**args)\n @far = args[:far] if args.key?(:far)\n @format = args[:format] if args.key?(:format)\n @image_height = args[:image_height] if args.key?(:image_height)\n @image_width = args[:image_width] if args.key?(:image_width)\n @mime = args[:mime] if args.key?(:mime)\n @near = args[:near] if args.key?(:near)\n @units = args[:units] if args.key?(:units)\n end", "def set_params\r\n @listing.pictures.build.photo = File.new params[:file].tempfile if params[:file]\r\n respond_to do |format|\r\n format.html { params[:temp_listing] = ResetDate::reset_dates(params[:temp_listing]) }\r\n format.json { params[:temp_listing] = JSON.parse(params[:temp_listing]) }\r\n end\r\n end", "def put_image_extract_as_tiff_with_http_info(name, image_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_image_extract_as_tiff ...\"\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_image_extract_as_tiff\"\n end\n # verify the required parameter 'image_id' is set\n if @api_client.config.client_side_validation && image_id.nil?\n fail ArgumentError, \"Missing the required parameter 'image_id' when calling PdfApi.put_image_extract_as_tiff\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/images/{imageId}/extract/tiff\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'imageId' + '}', image_id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'destFolder'] = opts[:'dest_folder'] if !opts[:'dest_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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_image_extract_as_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def modify_jpeg(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def update_image_features(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :PUT, nil)\n nil\n end", "def modify_bmp(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def modify_tiff_from_storage\n puts('Update parameters of a TIFF image from cloud storage')\n\n upload_sample_image_to_cloud\n\n compression = 'adobedeflate'\n resolution_unit = 'inch'\n bit_depth = 1\n horizontal_resolution = 150.0\n vertical_resolution = 150.0\n from_scratch = nil\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ModifyTiffRequest.new(\n get_sample_image_file_name, bit_depth, compression, resolution_unit, horizontal_resolution,\n vertical_resolution, from_scratch, folder, storage)\n\n puts(\"Call ModifyTiff with params: compression: #{compression}, resolution unit: #{resolution_unit}, bit depth:\" +\n \" #{bit_depth}, horizontal resolution: #{horizontal_resolution}, vertical resolution: \" +\n \"#{vertical_resolution}\")\n\n updated_image = imaging_api.modify_tiff(request)\n save_updated_sample_image_to_output(updated_image, false)\n puts\n end", "def create_updated_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def convert_tiff_to_fax(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def filter_effect_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :PUT, 'File')\n end", "def modify_jpeg2000(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def create_modified_jpeg(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def put_pdf_in_request_to_tiff_with_http_info(out_path, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_pdf_in_request_to_tiff ...\"\n end\n # verify the required parameter 'out_path' is set\n if @api_client.config.client_side_validation && out_path.nil?\n fail ArgumentError, \"Missing the required parameter 'out_path' when calling PdfApi.put_pdf_in_request_to_tiff\"\n end\n if @api_client.config.client_side_validation && opts[:'compression'] && !['LZW', 'CCITT4', 'CCITT3', 'RLE', 'None'].include?(opts[:'compression'])\n fail ArgumentError, 'invalid value for \"compression\", must be one of LZW, CCITT4, CCITT3, RLE, None'\n end\n if @api_client.config.client_side_validation && opts[:'color_depth'] && !['Default', 'Format8bpp', 'Format4bpp', 'Format1bpp'].include?(opts[:'color_depth'])\n fail ArgumentError, 'invalid value for \"color_depth\", must be one of Default, Format8bpp, Format4bpp, Format1bpp'\n end\n if @api_client.config.client_side_validation && opts[:'orientation'] && !['None', 'Landscape', 'Portrait'].include?(opts[:'orientation'])\n fail ArgumentError, 'invalid value for \"orientation\", must be one of None, Landscape, Portrait'\n end\n # resource path\n local_var_path = \"/pdf/convert/tiff\"\n\n # query parameters\n query_params = {}\n query_params[:'outPath'] = out_path\n query_params[:'brightness'] = opts[:'brightness'] if !opts[:'brightness'].nil?\n query_params[:'compression'] = opts[:'compression'] if !opts[:'compression'].nil?\n query_params[:'colorDepth'] = opts[:'color_depth'] if !opts[:'color_depth'].nil?\n query_params[:'leftMargin'] = opts[:'left_margin'] if !opts[:'left_margin'].nil?\n query_params[:'rightMargin'] = opts[:'right_margin'] if !opts[:'right_margin'].nil?\n query_params[:'topMargin'] = opts[:'top_margin'] if !opts[:'top_margin'].nil?\n query_params[:'bottomMargin'] = opts[:'bottom_margin'] if !opts[:'bottom_margin'].nil?\n query_params[:'orientation'] = opts[:'orientation'] if !opts[:'orientation'].nil?\n query_params[:'skipBlankPages'] = opts[:'skip_blank_pages'] if !opts[:'skip_blank_pages'].nil?\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'xResolution'] = opts[:'x_resolution'] if !opts[:'x_resolution'].nil?\n query_params[:'yResolution'] = opts[:'y_resolution'] if !opts[:'y_resolution'].nil?\n query_params[:'pageIndex'] = opts[:'page_index'] if !opts[:'page_index'].nil?\n query_params[:'pageCount'] = opts[:'page_count'] if !opts[:'page_count'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].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(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n # Fix header in file\n post_body = nil\n post_body = opts[:'file'] if !opts[:'file'].nil?\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/octet-stream'])\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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_pdf_in_request_to_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_page_convert_to_tiff_with_http_info(name, page_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_page_convert_to_tiff ...\"\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_page_convert_to_tiff\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.get_page_convert_to_tiff\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/convert/tiff\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'password'] = opts[:'password'] if !opts[:'password'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['multipart/form-data'])\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 => 'File')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_page_convert_to_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update!(**args)\n @bytes_value = args[:bytes_value] if args.key?(:bytes_value)\n @float_value = args[:float_value] if args.key?(:float_value)\n @image_template = args[:image_template] if args.key?(:image_template)\n @int32_value = args[:int32_value] if args.key?(:int32_value)\n @version = args[:version] if args.key?(:version)\n end", "def get_image_extract_as_tiff_with_http_info(name, image_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_image_extract_as_tiff ...\"\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_image_extract_as_tiff\"\n end\n # verify the required parameter 'image_id' is set\n if @api_client.config.client_side_validation && image_id.nil?\n fail ArgumentError, \"Missing the required parameter 'image_id' when calling PdfApi.get_image_extract_as_tiff\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/images/{imageId}/extract/tiff\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'imageId' + '}', image_id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\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(['multipart/form-data'])\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 => 'File')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_image_extract_as_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create_image_features(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, nil)\n nil\n end", "def image_params\n params[:image]\n \n end", "def rent_image_params\n params.fetch(:rent_image, {})\n end", "def update!(**args)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n @raw_bytes = args[:raw_bytes] if args.key?(:raw_bytes)\n @uri = args[:uri] if args.key?(:uri)\n end", "def extract_image_frame_properties(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'ImagingResponse')\n end", "def request_params_to_query\n layers = \"7,6,8,9\"\n bboxSR = 4326\n # imageSR corresponds to GoogleMaps spatial reference\n imageSR = 3857\n dpi = 96\n {\n \"dpi\"=> dpi,\n \"transparent\"=>\"true\",\n \"format\"=>\"png8\",\n \"layers\"=>\"show:#{layers}\",\n \"bbox\"=> format_bounds(self.bounds),\n \"bboxSR\"=> bboxSR,\n \"imageSR\"=> imageSR,\n \"size\"=> self.size,\n \"f\"=>\"image\"\n }.to_query\n end", "def extract_image_properties(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'ImagingResponse')\n end", "def create_modified_bmp(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def create_image_frame(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def img_properties\n par = params[:image]\n if !par\n # json webservice call, not coming from rails form. Change all keys from camelcased to underscores\n par = params\n %w(pageUrl originalUrl calibrateLength calibrateUnit calibrateCoords).each do |p|\n par[p.underscore] = par[p]\n par.delete(p)\n end\n end\n par\n end", "def put_page_convert_to_tiff_with_http_info(name, page_number, out_path, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_page_convert_to_tiff ...\"\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_page_convert_to_tiff\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.put_page_convert_to_tiff\"\n end\n # verify the required parameter 'out_path' is set\n if @api_client.config.client_side_validation && out_path.nil?\n fail ArgumentError, \"Missing the required parameter 'out_path' when calling PdfApi.put_page_convert_to_tiff\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/convert/tiff\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'outPath'] = out_path\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'password'] = opts[:'password'] if !opts[:'password'].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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_page_convert_to_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n respond_to do |format|\n if @taxi_image.update(taxi_image_params)\n format.html { redirect_to @taxi_image, notice: 'Taxi image was successfully updated.' }\n format.json { render :show, status: :ok, location: @taxi_image }\n else\n format.html { render :edit }\n format.json { render json: @taxi_image.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_grayscaled_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def add_some_extra_params\n @params['size'] = @file.size\n @params['md5sum'] = @file.md5sum\n end", "def get_image_for_expression(retina_name, body, image_scalar=2, plot_shape='circle', image_encoding='base64/png', sparsity=1.0)\n resource_path = '/image'\n verb = 'POST'\n query_params = { 'retina_name' => retina_name, 'image_scalar' => image_scalar, 'plot_shape' => plot_shape,\n 'image_encoding' => image_encoding, 'sparsity' => sparsity }\n post_data = body\n headers = {'Accept' => 'image/png', 'Content-Type' => 'application/json'}\n\n response = @api_client.call_api(resource_path, verb, query_params,post_data, headers)\n response.body\n end", "def update!(**args)\n @docid = args[:docid] if args.key?(:docid)\n @frame_identifier = args[:frame_identifier] if args.key?(:frame_identifier)\n @regions = args[:regions] if args.key?(:regions)\n @starburst_features_v4 = args[:starburst_features_v4] if args.key?(:starburst_features_v4)\n @starburst_tokens_v4 = args[:starburst_tokens_v4] if args.key?(:starburst_tokens_v4)\n @thumbnail_type = args[:thumbnail_type] if args.key?(:thumbnail_type)\n end", "def create_modified_jpeg2000(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def tour_image_params\n params.fetch(:tour_image, {})\n end", "def edit_pdf_rasterize_with_http_info(input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: EditPdfApi.edit_pdf_rasterize ...'\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling EditPdfApi.edit_pdf_rasterize\"\n end\n # resource path\n local_var_path = '/convert/edit/pdf/rasterize'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\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 => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: EditPdfApi#edit_pdf_rasterize\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def grayscale_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def convert_to_tiff_with_http_info(image_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertApi.convert_to_tiff ...'\n end\n # verify the required parameter 'image_file' is set\n if @api_client.config.client_side_validation && image_file.nil?\n fail ArgumentError, \"Missing the required parameter 'image_file' when calling ConvertApi.convert_to_tiff\"\n end\n # resource path\n local_var_path = '/image/convert/to/tiff'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['imageFile'] = image_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\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 => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertApi#convert_to_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def image_params\n params.require(:image).permit(:month, :hour, :small_square, :square, :weather, :image_id, :size, :category, :thumb, :exif, :title, :tags, :location, :type, :medium, :description, :normal, :link, :user, :bigger, :hits, :uploaded_at, :url, :original, :large, :taken_at, :dimension, :focal_length, :date_taken, :aperture, :camera, :metering_mode, :iso_speed_ratings, :city)\n end", "def riffblob_params\n params.require(:riffblob).permit(:user_id, :file, :shoutout, :url, :pointer)\n end", "def update!(**args)\n @inferred_image_source = args[:inferred_image_source] if args.key?(:inferred_image_source)\n @inferred_image_type = args[:inferred_image_type] if args.key?(:inferred_image_type)\n end", "def update_template_with_image_id(template)\n params = template.parameters\n params.each do |key, value|\n update_params_with_image_id(params, key, value)\n end\n end", "def image_attrib_params\n params.require(:image_attrib).permit(:description, :file)\n end", "def configure_image(payload)\n debug self.uid\n binary = Base64.decode64(payload.value)\n info \"configure_image: value = #{binary}\"\n id = payload.requestId\n fir = FlashImagesRequest.new\n fir.nodeUrns = self.nodeUrns\n fir.image = binary\n req = Request.new\n req.requestId = id\n req.type = Request::Type::FLASH_IMAGES\n req.flashImagesRequest = fir\n self.store(id, req)\n EventBus.publish(Events::DOWN_FLASH_IMAGE, request: req)\n return nil\n end", "def dimage_params\n params.require(:dimage).permit(:fotka, :flag, :descr)\n end", "def update\n @request = Request.find(params[:id])\n\n if params[:images_attributes]\n if @request.update(request_params)\n if params[:images_attributes]\n params[:images_attributes]['image'].each do |a|\n @image_attachment = @request.images.create!(:picture => a, :name => 'RequestApp')\n end\n end\n\n redirect_to action: 'show'\n flash[:success] = \"Su solicitud ha sido editada con exito\"\n else\n render 'edit'\n flash.now[:danger] = \"Revise los siguentes errores\"\n end\n else\n flash.now[:danger] = \"La solicitud requiere de una imagen\"\n render 'edit'\n end\n end", "def get_a_heat_image_given_its_floorplan_id_and_filter_parameters(args = {}) \n get(\"/resource.json/heat/#{args[:floorplanId]}/#{args[:filename]}\", args)\nend", "def request_params\n params.require(:request).\n permit(\n :background_color, :terms, :city_or_state, :physical_address, :company_overview, :product_feature,\n :card_type, :balance_enquire_method, :offer_id,\n *Request::IMAGE_NAMES\n )\n end", "def put_images_extract_as_png_with_http_info(name, page_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_images_extract_as_png ...\"\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_images_extract_as_png\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.put_images_extract_as_png\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/images/extract/png\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'destFolder'] = opts[:'dest_folder'] if !opts[:'dest_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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_images_extract_as_png\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def put_images_extract_as_gif_with_http_info(name, page_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.put_images_extract_as_gif ...\"\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_images_extract_as_gif\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.put_images_extract_as_gif\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/images/extract/gif\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'destFolder'] = opts[:'dest_folder'] if !opts[:'dest_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(: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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#put_images_extract_as_gif\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update!(**args)\n @byte_size = args[:byte_size] if args.key?(:byte_size)\n @encoding_quality = args[:encoding_quality] if args.key?(:encoding_quality)\n @encoding_type = args[:encoding_type] if args.key?(:encoding_type)\n @height = args[:height] if args.key?(:height)\n @image_blob_id = args[:image_blob_id] if args.key?(:image_blob_id)\n @image_bytes = args[:image_bytes] if args.key?(:image_bytes)\n @image_string = args[:image_string] if args.key?(:image_string)\n @width = args[:width] if args.key?(:width)\n end", "def featureimg_params\n params.fetch(:featureimg, {}).permit!\n# params.require(:featureimg).permit(:name, :user_id, :feature_img)\n end", "def create_converted_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def get_image_for_bulk_expressions(retina_name, body, get_fingerprint=nil, image_scalar=2, plot_shape='circle', sparsity=1.0)\n resource_path = '/image/bulk'\n verb = 'POST'\n query_params = { 'retina_name' => retina_name, 'plot_shape' => plot_shape, 'image_scalar' => image_scalar,\n 'sparsity' => sparsity, 'get_fingerprint' => get_fingerprint }\n post_data = body\n headers = {'Accept' => 'Application/json', 'Content-Type' => 'application/json'}\n\n response = @api_client.call_api(resource_path, verb, query_params,post_data, headers)\n JSON.parse(response.body, symbolize_names: true).map { |r| RetinaSDK::Model::Image.new(r) }\n end", "def image_query_params\n params.require(:image_query).permit(:name, :person_id, :is_match, :percentage_match, :image, :meta)\n end", "def update!(**args)\n @image_bytes = args[:image_bytes] if args.key?(:image_bytes)\n end", "def stampimage_params\n params.require(:stampimage).permit(:name, :rate, :image, :image_cache, :remove_image)\n end", "def create_modified_gif_from_request_body\n puts('Update parameters of a GIF image from request body')\n\n background_color_index = 5\n color_resolution = 4\n has_trailer = true\n interlaced = false\n is_palette_sorted = true\n pixel_aspect_ratio = 4\n from_scratch = nil\n storage = nil # We are using default Cloud Storage\n out_path = nil # Path to updated file (if this is empty, response contains streamed image)\n\n input_stream = File.open(File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, get_sample_image_file_name), 'r')\n request = AsposeImagingCloud::CreateModifiedGifRequest.new(\n input_stream, background_color_index, color_resolution, has_trailer, interlaced, is_palette_sorted,\n pixel_aspect_ratio, from_scratch, out_path, storage)\n\n puts(\"Call CreateModifiedGif with params: background color index: #{background_color_index}, color resolution: \" +\n \"#{color_resolution}, has trailer: #{has_trailer}, interlaced: #{interlaced}}, is palette sorted: \" +\n \"#{is_palette_sorted}, pixel aspect ratio: #{pixel_aspect_ratio}\")\n\n updated_image = imaging_api.create_modified_gif(request)\n save_updated_sample_image_to_output(updated_image, true)\n puts\n end", "def set_taxi_image\n @taxi_image = TaxiImage.find(params[:id])\n end", "def set_image_attrib\n @image_attrib = ImageAttrib.find(params[:id])\n end", "def filter_motion_blur_with_http_info(radius, sigma, angle, image_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: FilterApi.filter_motion_blur ...'\n end\n # verify the required parameter 'radius' is set\n if @api_client.config.client_side_validation && radius.nil?\n fail ArgumentError, \"Missing the required parameter 'radius' when calling FilterApi.filter_motion_blur\"\n end\n # verify the required parameter 'sigma' is set\n if @api_client.config.client_side_validation && sigma.nil?\n fail ArgumentError, \"Missing the required parameter 'sigma' when calling FilterApi.filter_motion_blur\"\n end\n # verify the required parameter 'angle' is set\n if @api_client.config.client_side_validation && angle.nil?\n fail ArgumentError, \"Missing the required parameter 'angle' when calling FilterApi.filter_motion_blur\"\n end\n # verify the required parameter 'image_file' is set\n if @api_client.config.client_side_validation && image_file.nil?\n fail ArgumentError, \"Missing the required parameter 'image_file' when calling FilterApi.filter_motion_blur\"\n end\n # resource path\n local_var_path = '/image/filter/blur/motion/{radius}/{sigma}/{angle}'.sub('{' + 'radius' + '}', radius.to_s).sub('{' + 'sigma' + '}', sigma.to_s).sub('{' + 'angle' + '}', angle.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['imageFile'] = image_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\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 => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FilterApi#filter_motion_blur\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def image_params\n transform_params if params[:image]\n params.permit(:reference, :registration)\n end", "def raw_image_params\n params.require(:raw_image).permit(:identifier, :title, :image)\n end", "def set_request_body!(request); end", "def update!(**args)\n @image = args[:image] if args.key?(:image)\n @tag = args[:tag] if args.key?(:tag)\n end", "def modify_svg(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def put_images_extract_as_tiff(name, page_number, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = put_images_extract_as_tiff_with_http_info(name, page_number, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = put_images_extract_as_tiff_with_http_info(name, page_number, opts)\n else\n raise\n end\n return data\n end", "def swfupload_file=(data)\r\n data.content_type = MIME::Types.type_for(data.original_filename).to_s if data\r\n self.image = data\r\n end", "def update!(**args)\n @inferred_image_id = args[:inferred_image_id] if args.key?(:inferred_image_id)\n @inferred_image_source = args[:inferred_image_source] if args.key?(:inferred_image_source)\n @inferred_image_type = args[:inferred_image_type] if args.key?(:inferred_image_type)\n @neardup_info = args[:neardup_info] if args.key?(:neardup_info)\n end", "def pxe_image_type_get_form_vars\n @pxe_image_type = @edit[:pxe_id] ? PxeImageType.find_by_id(@edit[:pxe_id]) : PxeImageType.new\n @edit[:new][:name] = params[:name] if params[:name]\n @edit[:new][:provision_type] = params[:provision_type] if params[:provision_type]\n end", "def modify_emf(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def tatoo_params\n params.require(:tatoo).permit(:premium, :image)\n end", "def modify_wmf(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def set_trfileimage\n @trfileimage = Trfileimage.find(params[:id])\n end", "def update\n @image = Image.find(params[:id])\n type = @image.url_type\n if @image.update_attributes!(params[:image])\n if request.xhr?\n render :text => [ @image.to_jq_upload(type, \"image\") ].to_json.to_s\n else\n redirect_to console_images_path\n end\n else \n if request.xhr?\n render :text => [ @image.to_jq_upload(type, \"image\").merge({ :error => \"custom_failure\" }) ].to_json.to_s\n else\n redirect_to edit_console_image_path(@image)\n end\n end\n end", "def update!(**args)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n @uri_prefix = args[:uri_prefix] if args.key?(:uri_prefix)\n end", "def update_search_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :PUT, nil)\n nil\n end", "def update!(**args)\n @expiration_timestamp_micros = args[:expiration_timestamp_micros] if args.key?(:expiration_timestamp_micros)\n @height = args[:height] if args.key?(:height)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n @size = args[:size] if args.key?(:size)\n @type = args[:type] if args.key?(:type)\n @width = args[:width] if args.key?(:width)\n end", "def update!(**args)\n @data = args[:data] if args.key?(:data)\n @height = args[:height] if args.key?(:height)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n @width = args[:width] if args.key?(:width)\n end", "def update\n @food.build_image(params['image']) do |t|\n if params['food']['image']['data']\n t.data = Base64.encode64(params['food']['image']['data'].read)\n t.filename = params['food']['image']['data'].original_filename\n t.mime_type = params['food']['image']['data'].content_type\n end\n end \n @food.name = @food.name.capitalize\n respond_to do |format|\n if @food.update(food_params)\n format.html { redirect_to @food, notice: 'Food was successfully updated.' }\n format.json { render :show, status: :ok, location: @food }\n else\n format.html { render :edit }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end", "def file_update(project, old_file, new_fie)\n file = ActionDispatch::Http::UploadedFile.new(\n tempfile: upload(new_fie),\n filename: new_fie,\n original_filename: old_file\n )\n post :file_update, user_id: project.user.username,\n id: project.name,\n branch: 'master',\n destination: new_fie,\n message: 'update image',\n file: file\n end", "def photo_params\n params.require(:photo).permit(:image, :camara_id, :description, :aperture, :exposure,\n :iso, :shutter_speed, :color_space, :focal_length, :took_at, :settings, tag_list: [])\n end", "def create_image_frame_range(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def sensor_params\n params.require(:sensor).permit(:mac, :url, :tipo, :latitudine, :longitudine, :unit_misura, :public, :downtime_to_alarm, :last_firmware_update, :image)\n end", "def image_params\n params.require(:image).permit(:name, :width, :height, :x_position, :y_position, :original_image, :face_image)\n end", "def convert_image_image_set_dpi_with_http_info(dpi, input_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConvertImageApi.convert_image_image_set_dpi ...'\n end\n # verify the required parameter 'dpi' is set\n if @api_client.config.client_side_validation && dpi.nil?\n fail ArgumentError, \"Missing the required parameter 'dpi' when calling ConvertImageApi.convert_image_image_set_dpi\"\n end\n # verify the required parameter 'input_file' is set\n if @api_client.config.client_side_validation && input_file.nil?\n fail ArgumentError, \"Missing the required parameter 'input_file' when calling ConvertImageApi.convert_image_image_set_dpi\"\n end\n # resource path\n local_var_path = '/convert/image/set-dpi/{dpi}'.sub('{' + 'dpi' + '}', dpi.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = input_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\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 => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConvertImageApi#convert_image_image_set_dpi\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def call\n @upload.image_file_name = direct_upload_url_data[:filename]\n @upload.image_file_size = direct_upload_attributes.content_length\n @upload.image_content_type = direct_upload_attributes.content_type\n @upload.image_updated_at = direct_upload_attributes.last_modified\n end", "def get_pdf_in_storage_to_tiff_with_http_info(name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_pdf_in_storage_to_tiff ...\"\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_pdf_in_storage_to_tiff\"\n end\n if @api_client.config.client_side_validation && opts[:'compression'] && !['LZW', 'CCITT4', 'CCITT3', 'RLE', 'None'].include?(opts[:'compression'])\n fail ArgumentError, 'invalid value for \"compression\", must be one of LZW, CCITT4, CCITT3, RLE, None'\n end\n if @api_client.config.client_side_validation && opts[:'color_depth'] && !['Default', 'Format8bpp', 'Format4bpp', 'Format1bpp'].include?(opts[:'color_depth'])\n fail ArgumentError, 'invalid value for \"color_depth\", must be one of Default, Format8bpp, Format4bpp, Format1bpp'\n end\n if @api_client.config.client_side_validation && opts[:'orientation'] && !['None', 'Landscape', 'Portrait'].include?(opts[:'orientation'])\n fail ArgumentError, 'invalid value for \"orientation\", must be one of None, Landscape, Portrait'\n end\n # resource path\n local_var_path = \"/pdf/{name}/convert/tiff\".sub('{' + 'name' + '}', name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'brightness'] = opts[:'brightness'] if !opts[:'brightness'].nil?\n query_params[:'compression'] = opts[:'compression'] if !opts[:'compression'].nil?\n query_params[:'colorDepth'] = opts[:'color_depth'] if !opts[:'color_depth'].nil?\n query_params[:'leftMargin'] = opts[:'left_margin'] if !opts[:'left_margin'].nil?\n query_params[:'rightMargin'] = opts[:'right_margin'] if !opts[:'right_margin'].nil?\n query_params[:'topMargin'] = opts[:'top_margin'] if !opts[:'top_margin'].nil?\n query_params[:'bottomMargin'] = opts[:'bottom_margin'] if !opts[:'bottom_margin'].nil?\n query_params[:'orientation'] = opts[:'orientation'] if !opts[:'orientation'].nil?\n query_params[:'skipBlankPages'] = opts[:'skip_blank_pages'] if !opts[:'skip_blank_pages'].nil?\n query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?\n query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?\n query_params[:'xResolution'] = opts[:'x_resolution'] if !opts[:'x_resolution'].nil?\n query_params[:'yResolution'] = opts[:'y_resolution'] if !opts[:'y_resolution'].nil?\n query_params[:'pageIndex'] = opts[:'page_index'] if !opts[:'page_index'].nil?\n query_params[:'pageCount'] = opts[:'page_count'] if !opts[:'page_count'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['multipart/form-data'])\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 => 'File')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_pdf_in_storage_to_tiff\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def pixel_params\n params.require(:pixel).permit(:text)\n end", "def update\n respond_to do |format|\n if @vendor.update(vendor_params)\n unless params[:draft_img].blank?\n attachment = Attachment.create(attachment_entity_type: \"Vendor\",attachment_entity_id: @vendor.id , path: params[:draft_img], created_by: 1 ) \n @vendor.cover_img = attachment.id\n path = \"#{Rails.root}/public#{attachment.path.to_s}\"\n exif = EXIFR::JPEG.new(path)\n @latitude = exif.gps&.latitude||39.9717219722\n @longitude = exif.gps&.longitude||116.4911780001\n @vendor.latitude = @latitude\n @vendor.longitude = @longitude\n @vendor.save\n end\n format.html { redirect_to @vendor, notice: 'vendor was successfully updated.' }\n format.json { render :show, status: :ok, location: @vendor }\n else\n format.html { render :edit }\n format.json { render json: @vendor.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.69623035", "0.6587275", "0.63759434", "0.62554896", "0.6193293", "0.603095", "0.60180163", "0.5945903", "0.590611", "0.57979476", "0.57667667", "0.56971025", "0.5669187", "0.56582874", "0.5656709", "0.5604555", "0.55913335", "0.557831", "0.5572861", "0.55206877", "0.54937106", "0.54378843", "0.54020476", "0.53831923", "0.5374794", "0.5370245", "0.53691506", "0.5358842", "0.53231", "0.53112394", "0.52770865", "0.52764255", "0.52506006", "0.5248251", "0.5241361", "0.5237583", "0.5233242", "0.52300346", "0.522439", "0.52232534", "0.52196735", "0.5203513", "0.51964045", "0.51957184", "0.5192126", "0.5185705", "0.5181945", "0.51784414", "0.5172621", "0.5137541", "0.5132599", "0.5131723", "0.5126771", "0.51233673", "0.5115578", "0.5108112", "0.5107868", "0.5104894", "0.5085164", "0.50768036", "0.50760216", "0.5067575", "0.5065212", "0.50631917", "0.50630724", "0.5056067", "0.505035", "0.50381243", "0.5036628", "0.50265545", "0.5019495", "0.5015047", "0.5010489", "0.500183", "0.49988177", "0.4997579", "0.49970853", "0.49939772", "0.4988492", "0.4977548", "0.4969285", "0.49651062", "0.49591365", "0.49584833", "0.49507287", "0.495027", "0.49439132", "0.49415258", "0.49371558", "0.4935673", "0.49259207", "0.4922498", "0.49220183", "0.49216515", "0.4920174", "0.4919711", "0.49145603", "0.49110305", "0.4910832", "0.48989803" ]
0.67815745
1