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
image methods for easy api calls
def mobile_poster_image_url self.show_images.poster.any? ? self.show_images.poster.first.avatar.url(:mobile_poster) : nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def image\n\n end", "def image; end", "def image\n end", "def image\n end", "def images; end", "def image\n end", "def image\n end", "def images\n end", "def image\n #__log_activity\n # __debug_route\n response = Faraday.get(params[:url]) # TODO: caching\n image_data = Base64.encode64(response.body)\n mime_type = response.headers['content-type']\n render plain: image_data, format: mime_type, layout: false\n end", "def marketplace_image_my_images_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VnfsApi.marketplace_image_my_images ...'\n end\n # resource path\n local_var_path = '/1.0.0/marketplace/image/my_images/'\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 = nil\n auth_names = ['oAuth2']\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 => 'InlineResponse2009')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VnfsApi#marketplace_image_my_images\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def thumbnail_image\n end", "def get_image\n if getters.include? params[:type]\n self.method(\"get_#{params[:type]}\").call\n elsif params[:type] == \"random\"\n self.method(\"get_#{getters[rand(getters.length)]}\").call\n else\n raise ActiveRecord::RecordNotFound\n end\n end", "def image options = {}\n Diffbot::APIClient::Image.new self, options\n end", "def images\n Vultr::Resource::OS.new(@faraday)\n end", "def image(id, nsfw = false)\n img = get url: \"images/#{id}\", nsfw: nsfw\n img['image'] if img\n end", "def image hash = {}\n hash = { :id => hash} if hash.is_a? String\n home hash.update :action => 'image', :trailing_slash => false\n end", "def image\n image = Weatherman::Image.new(attribute('image'))\n do_convertions(image, [:width, :to_i], [:height, :to_i], :title, :link, :url)\n end", "def pull_image(value)\n user_hash = pull_records(value)\n id = user_hash[0][\"id\"]\n image_name = user_hash[0][\"image\"]\n image = \"images/uploads/#{id}/#{image_name}\"\nend", "def to_api\n\n results = {\n 'client_id' => id,\n 'name' => name,\n 'nation_builder' => nation_builder_crm_authentication ? nation_builder_crm_authentication.to_api : nil\n }\n\n Client::IMAGE_SIZES.each do |label, size|\n results[\"image_#{label}\"] = avatar(label)\n end\n\n return results;\n end", "def get_image\n source_file = Item.new(Path.new(params[:source]+\".\"+params[:type]))\n begin\n send_file source_file.path, :filename => source_file.path.basename.to_s, :type => \"image/#{params[:type]}\"\n rescue \n not_found\n end\n end", "def get_an_image_thumbnail_given_its_floorplan_id(args = {}) \n get(\"/resource.json/floorplan/#{args[:floorplanId]}/thumb\", args)\nend", "def img_params\n\n end", "def render_image\n render_image_iterm2\n end", "def wiki_image_data(image)\n RestClient.get(image['image_url'], :accept => image['image_content_type'])\n end", "def image\r\n\t\tbegin\r\n\t\t\t@image = Image.find(params[:id])\r\n\t\trescue ActiveRecord::RecordNotFound\r\n\t\t\trender :text => \"Image ##{params[:id].to_s} not found\"\r\n\t\telse\r\n\t\t\tsend_data(@image.data,\r\n\t\t\t\t:filename => @image.filename,\r\n\t\t\t\t:type => @image.content_type,\r\n\t\t\t\t:disposition => 'inline')\r\n\t\tend\r\n\tend", "def show\n respond_to do |format|\n format.png { send_image @user.raw_image_data, :png }\n format.jpg { send_image @user.raw_image_data, :jpeg }\n format.html { }\n end\n end", "def image\n @path\n end", "def cover_image\n end", "def image()\n @image__\n end", "def img(*) # :nodoc:\n raise \"no!\"\n end", "def images\n IbmCloudRest.get \"#{@uri}/images\"\n end", "def image\n return unless object.image.attached?\n\n # object.image.blob.attributes\n # .slice('filename', 'byte_size')\n # .merge(url: image_url)\n # .tap { |attrs| attrs['name'] = attrs.delete('filename') }\n object.image.service_url\n \n end", "def marketplace_image_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VnfsApi.marketplace_image ...'\n end\n # resource path\n local_var_path = '/1.0.0/marketplace/image'\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 = nil\n auth_names = ['oAuth2']\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 => 'InlineResponse2009')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VnfsApi#marketplace_image\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def images() \n uri = URI.parse(\"http://\" + @location.host + \":9292/v2/images\")\n return get_request(uri, @token)\n end", "def getImg(width=64, height=64)\n if self.image\n self.image+\"?width=#{width}&height=#{height}\"\n else\n \"no_image.png\"\n end\n end", "def images\n @picturesandmeta = Pictureandmeta.all\n @kind = Kind.find(params[:kind_id])\n Rails.logger.info(\"Kind: #{@kind.inspect}\")\n end", "def show\n user_id, id, ref = params[:user_id], params[:id], params[:ref]\n img = nil\n if id == '0' && ref\n # do lookup by reference\n img = Image.find_user_image_by_ref(user_id, params[:ref])\n elsif id != '0'\n # do lookup by guid\n img = Image.find_user_image_by_guid(user_id, id)\n end\n return not_found if !img\n\n respond_to do |format|\n format.json { render :json => img.js_serialize, :callback => params[:callback] }\n end\n end", "def image_hash; end", "def image\n TmdbImage.new(@imdb_id.gsub(/^tt/, ''), @api_key, @logger, @filespec) rescue nil\n end", "def image_url\n image_uri\n end", "def set_img\n\n end", "def image\n response[\"image\"]\n end", "def show\n @image = Image.find(params[:id])\n\n respond_to do |format|\n format.jpg # show.jpg.flexi\n format.html # show.html.erb\n format.png # show.png.flexi\n format.xml { render :xml => @image }\n end\n end", "def show\n @image = Image.find(params[:id])\n\n respond_to do |format|\n format.jpg # show.jpg.flexi\n format.html # show.html.erb\n format.png # show.png.flexi\n format.xml { render :xml => @image }\n end\n end", "def images\n @images ||= ApiFactory.new 'Projects::Images'\n end", "def getImage\n image=AWS::S3::S3Object.url_for('testing.png','tradeDev')\n render :json => {:image=>image}\n end", "def info( options =nil )\n json = request 'images.getInfo', options, :ImageID => image_id, :ImageKey => key\n \n image = upper_hash_to_lower_hash( json['Image'] )\n image.merge!( :image_id => image[\"id\"] )\n \n OpenStruct.new( image ) \n end", "def serve_image\n\n # http://stackoverflow.com/questions/9462785/referencing-model-with-string-input\n # https://github.com/carrierwaveuploader/carrierwave/issues/614\n # model.avatar.file.filename\n # model[:avatar]\n # model.avatar_identifier\n # File.basename(model.file.path)\n\n\n if params[:id] && params[:model] && params[:type] && params[:id_image] && params[:uploader]\n\n model = params[:model].singularize.classify.constantize.find(params[:id_image])\n name = model.read_attribute(params[:uploader].to_s)\n image_name = \"#{params[:type]}_#{name}\"\n\n image_path = File.join(Rails.root,\"images\",Rails.env, params[:model], params[:uploader], params[:id_image],image_name)\n\n unless send_file( image_path,disposition: 'inline', type: 'image/jpeg', x_sendfile: true )\n return \"some default image\" # ensure views have css defining the size of thumbnail, that way default image is the proper size\n end\n end\n\n end", "def getimage\n @trek = Trek.find params[:id]\n if @trek == nil\n redirect_to treks_path, :alert => \"Trek not found.\"\n end\n filename = params[:name] + \".\" + params[:format]\n send_file @trek.get_img_path(filename),\n :type => \"image/jpeg\",\n :disposition => \"inline\"\n end", "def photo_format; end", "def show\n @picture = Picture.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.png { render :inline => \"@picture.operate{}\", :type => :flexi}\n format.gif { render :inline => \"@picture.operate{}\", :type => :flexi}\n format.jpg { render :inline => \"@picture.operate{}\", :type => :flexi}\n format.xml { render :xml => @picture }\n end end", "def get_image_with_http_info(name, image_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_image ...\"\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\"\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\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/images/{imageId}\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'imageId' + '}', image_id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n # Fix header in file\n post_body = nil\n\n # http body (model)\n # Fix header in file\n # post_body = nil\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ImageResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_image\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def images\n response = JSON.parse( self.class.get(\"#{BASE_URL}/contest/#{@api_key}/images\") )\n end", "def run\n ::SimpleHttp.get(@url).tap do |response|\n status, headers, blob = *response\n response[2] = Magick::Image.from_blob(blob).first if status == 200\n end\n end", "def goods_image\n return params[:image_url] if params[:image_url].present?\n return params[:based64_image] if params[:based64_image].present?\n @image.present? ? @image : 'no_pic.png'\n end", "def default_image\n end", "def image\n @image = Image.find_user_image_by_ref(params[:user], params[:ref])\n end", "def image(id, options={})\n params = options\n get(surl('image') + id, params).body\n end", "def configureImages()\n #Fetch the server configuration\n config = fetchServerConfig()\n #Used the gathered configuration information to build a URL for accessing images\n $imageBase = config['images']['base_url']+config['images']['poster_sizes'][5]\nend", "def images()\n @photos = all_photos() \n @headers['Content-Type'] = CONTENT_TYPE\n end", "def robot_image_generator\n img_base_url = 'https://robohash.org/'\n @robot.img_sm = img_base_url + @robot.robot_name + '?size=80x80'\n @robot.img_lg = img_base_url + @robot.robot_name + '?size=300x300'\n end", "def base_image\n self\n end", "def imgify(tweet)\n return tweet\nend", "def get_image\n\n begin\n office_map = OfficeMap.find(params[:id])\n rescue\n office_map = nil\n end\n\n if office_map.nil?\n render(:text => '')\n return\n end\n\n=begin\n# Too much restriction\n if !office_map.group_id.nil? and (office_map.group_id != 0)\n unless User.belongs_to_group?(@login_user, office_map.group_id, true)\n render(:text => 'ERROR:' + t('msg.need_auth_to_access'))\n return\n end\n end\n=end\n response.headers[\"Content-Type\"] = office_map.img_content_type\n response.headers[\"Content-Disposition\"] = \"inline\"\n render(:text => office_map.img_content)\n end", "def thumb\n @agency_logo = AgencyLogo.find(params[:id])\n respond_to do |format|\n format.jpg # thumb.jpg.flexi\n end\n end", "def image_url\n image.url\n end", "def thumb\n @agency_image = AgencyImage.find(params[:id])\n respond_to do |format|\n format.jpg # thumb.jpg.flexi\n end\n end", "def to_api\n\n results = {\n 'user_id' => id,\n 'first_name' => first_name,\n 'last_name' => last_name[0,1],\n 'organization_name' => organization_name,\n 'zip_code' => zip_code,\n 'avatar_url' => avatar_url\n }\n\n User::IMAGE_SIZES.each do |label, size|\n results[\"image_#{label}\"] = organization_avatar(label)\n end\n\n return results;\n end", "def download_image(src_url,dest_path)\n content_type = http_content_type(src_url)\n content_type = content_type.gsub(\"image/\", \"\")\n content_type = content_type.gsub(\"pjpeg\",\"jpg\")\n content_type = content_type.gsub(\"jpeg\",\"jpg\")\n vortex_url = download_resource(src_url,dest_path,content_type)\n return vortex_url\nend", "def images\n []\n end", "def get_image_by_uuid\n @command = :get_image_by_uuid\n # the UUID was the last \"previous argument\"\n image_uuid = @prev_args.peek(0)\n # setup the proper URI depending on the options passed in\n uri = URI.parse(@uri_string + '/' + image_uuid)\n # and get the results of the appropriate RESTful request using that URI\n result = hnl_http_get(uri)\n # finally, based on the options selected, print the results\n print_object_array(hash_array_to_obj_array([result]), \"Image:\")\n end", "def find_image\n\t id = params[:id]\n\t return render_message ({status:ERR_STATUS, responseMessage: \"Invalid request\", responseCode: ERROR}) unless id\n\t @image = Image.find_by(id: id)\n\t unless @image\n\t return render_message({status:ERR_STATUS,responseMessage: \"No record found\", responseCode: ERROR})\n\t end\n\tend", "def image\n\t\t@image ||= Image.joins(:album)\n .where(id: params[:id], :albums => {:user_id => user_id})\n .take || halt(404)\n\tend", "def get_images\n {}\n end", "def show\n @image = Image.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.jpg # show.jpg.erb\n format.png # show.png.erb\n format.xml { render :xml => @image }\n end\n end", "def image _args\n \"image _args;\" \n end", "def images()\n\t\treturn Images.new(@credentials.client_key, @credentials.get_access_token)\n\tend", "def image\n lambda do |text|\n begin \n hash = parse_text(text)\n image = find_image(hash)\n src = get_image_src(hash, image)\n\n unless image.nil?\n engine = gen_haml('image.haml')\n engine.render(nil, {:src => src, :id => hash['id'], :class_name => hash['class'], :alt => hash['alt'], :title => hash['title'], :itemprop => hash['itemprop'], :height => hash['height'], :width => hash['width']})\n end\n rescue NoMethodError => e\n Rails.logger.error \"#{e} could not find image with the params: #{text}\"\n end\n end\n end", "def create image_url, page_url, x, y, h, w\n #@img = Img.create(image_url: image_url, page_url: page_url, x: x, y: y, h: h, w: w)\n end", "def image\n 0\n end", "def make_calls_from_image(image_upload)\n response = post_file(OLA_IP_API_URL, 'file', image_upload)\n results = JSON.parse(response.body)['results']\n if results.blank?\n raise 'Automatic Visual Call failed. Missing or unprocessible image.'\n else\n return results\n end\n end", "def show\n render_general(@image)\n end", "def create_basic\n ImageGeneratingService.new(self, 'Basic.jpg', 'image/jpeg', 100).generate_resized(600)\n end", "def cloudinary_imgs_cara(key,instance)\n cl_image_tag(key, :quality=>\"auto\", :fetch_format=>:auto, :crop=>\"fit\", :class=>\"d-block mx-auto img-fluid rounded\", :alt=>\"#{instance.name}\")\n end", "def load_image(path)\n end", "def render_info\n account, ref, app_key = params[:user], params[:ref], params[:a]\n if (account.nil? || ref.nil?)\n json_error(\"missing parameters\")\n return\n elsif (@screen_res.nil?)\n json_error(\"unable to find current screen resolution\");\n return\n end\n\n # look up the image\n begin\n @image = Image.find_user_image_by_ref(account, ref)\n #@image = Image.find_lifesize_image(account, ref)\n rescue ActiveRecord::RecordNotFound\n json_error(\"image not found: \" + ref)\n return\n else\n if @image.nil?\n json_error(\"image not found: \" + ref)\n return\n end\n\n # calculate how big the image should be rendered now, and return that to the server\n lifesize = LifeSize.new(@screen_config)\n sz = lifesize.image_size(@image)\n response = { :width => sz[:width], :height => sz[:height], :confidence => @screen_config[:confidence]}\n puts \"image response will be #{response.to_json}\"\n respond_to do |format|\n format.json { render :json => response }\n end\n end\n end", "def pic_url\n {\n picture: self.object.pic.service_url\n }\n end", "def get_image_details(token, assetIds)\r\n\r\n request = {\r\n :RequestHeader => {\r\n :Token => token,\r\n :CoordinationId => \"MyUniqueId\"\r\n },\r\n :GetImageDetailsRequestBody => {\r\n :CountryCode => \"USA\",\r\n :ImageIds => assetIds,\r\n :Language => \"en-us\"\r\n }\r\n }\r\n\r\n response = post_json(request, \"https://connect.gettyimages.com/v1/search/GetImageDetails\")\r\n\r\n # status = response[\"ResponseHeader\"][\"Status\"]\r\n # images = response[\"GetImageDetailsResult\"][\"Images\"]\r\n end", "def get_images_data\t\t\t\t\t\t\n\t\t{ payload: { 'makes' => makes_dropdown, 'images' => images_array('none').compact}, success: true}\n\tend", "def getimagesinfo\n trek = Trek.find_by_id(params[:id])\n send_data(trek.get_images_info.to_json,\n {:type => \"application/json\", :disposition => \"inline\"})\n end", "def edit_particular_image\n \n end", "def images\n {\n thumbnail: object.thumbnail.url(:large),\n logo: object.logo.url(:medium),\n white_logo: object.white_logo.url(:medium)\n }\n end", "def show\n\n # Get random gif from Giphy (http://giphy.com)\n response = HTTParty.get('http://api.giphy.com/v1/gifs/search?' +\n 'q=' + @boolio.val.to_s +\n '&api_key=dc6zaTOxFJmzC' + # provided for public beta testing via (https://github.com/Giphy/GiphyAPI#public-beta-key)\n '&limit=1' + # only want 1\n '&offset=' + rand(30).to_s + # pull from the top 10 most relevant images\n '&rating=pg' + # afraid if this is any higher\n '&fmt=json' # seems to return JSON anyway, but just in case\n )\n\n if response.code == 200\n\n # conver to JSON\n json = JSON.parse response.body, object_class: OpenStruct\n\n # set image from returned results\n @image = json.data[0].images if json.data.count > 0\n end\n\n end", "def show\n @photos = Photo.all\n @post = Post.find(params[:id])\n x = @post.image.url\n\n #private_key = Google::Auth::ServiceAccountCredentials.make_creds(\n #scope: 'https://www.googleapis.com/auth/cloud-platform',\n #json_key_io: StringIO.new(ENV['VISION_KEYFILE_JSON'])\n #)\n\n\n vision = Google::Cloud::Vision.new(\n project: \"redoproject-163021\",\n keyfile: \"config/redoproject-e87605fb29d9.json\",\n )\n @image = vision.image(x)\n @labels = @image.labels\n #logs\n @logs = @image.logos\n #web\n p @web = @image.web.entities\n\nend", "def download_image_online_with_http_info(document, index, format, password = nil)\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SlidesApi.download_image_online ...'\n end\n\n # verify the required parameter 'document' is set\n if @api_client.config.client_side_validation && document.nil?\n fail ArgumentError, \"Missing the required parameter 'document' when calling SlidesApi.download_image_online\"\n end\n # verify the required parameter 'index' is set\n if @api_client.config.client_side_validation && index.nil?\n fail ArgumentError, \"Missing the required parameter 'index' when calling SlidesApi.download_image_online\"\n end\n # verify the required parameter 'format' is set\n if @api_client.config.client_side_validation && format.nil?\n fail ArgumentError, \"Missing the required parameter 'format' when calling SlidesApi.download_image_online\"\n end\n # verify enum value\n if @api_client.config.client_side_validation && !['Jpeg', 'Png', 'Gif', 'Bmp', 'Tiff'].any?{ |s| s.casecmp(format)==0 }\n fail ArgumentError, \"Invalid value for parameter format: \" + format + \". Must be one of Jpeg, Png, Gif, Bmp, Tiff\"\n end\n # resource path\n local_var_path = '/slides/images/{index}/{format}'\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'index', index)\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'format', format)\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(['multipart/form-data'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n header_params[:'password'] = password unless password.nil?\n\n # http body (model)\n post_body = nil\n\n # form parameters\n post_files = []\n if document\n post_files = post_files.push(document)\n end\n\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :body => post_body,\n :files => post_files,\n :auth_names => auth_names,\n :return_type => 'File')\n return data, status_code, headers\n end", "def change_image\n\n response_str = \"NG\"\n url = root_url + \"admin_data/klass/image/\"\n\n news_id = Integer(params[:news_id])\n news = News.find(news_id)\n\n if(news != nil)\n images = Image.find_by_news_id(news_id)\n url += (images.id).to_s\n url += \"/edit\"\n\n response_str = url\n end\n\n respond_to do |format|\n format.html { render :inline => response_str }\n end\n\n\n end", "def proxy_image\n multiresimage = Multiresimage.find(params[:id])\n img_length = params[:image_length]\n\n begin\n if multiresimage.DELIV_OPS.svg_image.svg_width[0].to_i <= params[:image_length].to_i\n img_length = multiresimage.DELIV_OPS.svg_image.svg_width[0].to_i-1\n end\n rescue Exception\n #this is a fix so that smaller images get shown. Currently, they break since larger versions do not exist.\n end\n\n default_image = File.open(\"app/assets/images/site/missing2.png\", 'rb') do |f|\n f.read\n end\n filename = \"missing2.png\"\n resp = ''\n\n if can?(:read, multiresimage)\n\n Net::HTTP.start(DIL_CONFIG['dil_fedora_base_ip'], DIL_CONFIG['dil_fedora_port']) { |http|\n resp = http.get(\"#{DIL_CONFIG['dil_fedora_url']}#{params[:id]}#{DIL_CONFIG['dil_fedora_disseminator']}#{img_length}\")\n #open(\"/usr/local/proxy_images/#{params[:id]}.jpg\" ,\"wb\") { |new_file|\n #new_file.write(resp.body)\n #send_file(new_file, :type => \"image/jpeg\", :disposition=>\"inline\")\n #send data uses server memory instead of storage.\n if(resp.body.include? \"error\")\n image = default_image\n else\n image = resp.body\n filename = \"#{params[:id]}.jpg\"\n end\n send_data(image, :disposition=>'inline', :type=>'image/jpeg', :filename=>filename)\n }\n #}\n else\n send_data(default_image, :disposition=>'inline', :type=>'image/jpeg', :filename=>filename)\n end\n end", "def image_data\n response = nil\n\n Net::HTTP.start(SERVICE_HOST) do |http|\n response = http.get(URI.parse(@url).path + ':medium')\n\n if response.code.to_s =~ /\\A3\\d\\d/\n new_location = URI.parse(response['Location'])\n Net::HTTP.start(new_location.host) do |http|\n response = http.get(new_location.path + '?' + new_location.query)\n end\n end\n end\n\n response.body\n end", "def download_image_with_http_info(name, index, format, password = nil, folder = nil, storage = nil)\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SlidesApi.download_image ...'\n end\n\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 SlidesApi.download_image\"\n end\n # verify the required parameter 'index' is set\n if @api_client.config.client_side_validation && index.nil?\n fail ArgumentError, \"Missing the required parameter 'index' when calling SlidesApi.download_image\"\n end\n # verify the required parameter 'format' is set\n if @api_client.config.client_side_validation && format.nil?\n fail ArgumentError, \"Missing the required parameter 'format' when calling SlidesApi.download_image\"\n end\n # verify enum value\n if @api_client.config.client_side_validation && !['Jpeg', 'Png', 'Gif', 'Bmp', 'Tiff'].any?{ |s| s.casecmp(format)==0 }\n fail ArgumentError, \"Invalid value for parameter format: \" + format + \". Must be one of Jpeg, Png, Gif, Bmp, Tiff\"\n end\n # resource path\n local_var_path = '/slides/{name}/images/{index}/{format}'\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'name', name)\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'index', index)\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'format', format)\n\n # query parameters\n query_params = {}\n query_params[:'folder'] = @api_client.prepare_for_query(folder) unless folder.nil?\n query_params[:'storage'] = @api_client.prepare_for_query(storage) unless 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 header_params[:'password'] = password unless password.nil?\n\n # http body (model)\n post_body = nil\n\n # form parameters\n post_files = []\n\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 :body => post_body,\n :files => post_files,\n :auth_names => auth_names,\n :return_type => 'File')\n return data, status_code, headers\n end", "def to_jpg\n load_image\n end", "def show\n\n #render plain: @myimage\n end" ]
[ "0.7716205", "0.7702462", "0.7645807", "0.7645807", "0.7557929", "0.7446073", "0.7446073", "0.74273276", "0.70037615", "0.6795638", "0.672484", "0.66604847", "0.6659207", "0.66583914", "0.6654267", "0.66532654", "0.6641657", "0.66397923", "0.6634986", "0.6625283", "0.6625004", "0.6618982", "0.66106874", "0.66009074", "0.6588037", "0.6585445", "0.6581024", "0.65786034", "0.65674573", "0.6544587", "0.65319157", "0.65286803", "0.6515776", "0.6507255", "0.65038276", "0.647084", "0.6458788", "0.64506465", "0.64487815", "0.6440684", "0.64332676", "0.6423965", "0.6413472", "0.6407154", "0.6402054", "0.6400206", "0.63991296", "0.6394301", "0.6392671", "0.63905805", "0.63847476", "0.6381343", "0.6366221", "0.63651043", "0.6363911", "0.63544965", "0.6351803", "0.63456124", "0.63409114", "0.63323385", "0.63317", "0.6330145", "0.6329762", "0.63193613", "0.6315063", "0.6309761", "0.6305478", "0.6301708", "0.6299704", "0.628541", "0.62846565", "0.62792516", "0.6277271", "0.6272003", "0.62680924", "0.6261028", "0.62539566", "0.6253347", "0.62465054", "0.62449354", "0.62438935", "0.62333775", "0.62315226", "0.6226988", "0.62265295", "0.62212473", "0.6215814", "0.62154675", "0.62123597", "0.62090737", "0.6208189", "0.6205892", "0.6204423", "0.61781234", "0.61706156", "0.61699456", "0.61675376", "0.61521184", "0.61515343", "0.6146956", "0.61439055" ]
0.0
-1
rocks and gold, something like this: [ ['R', 'R', 'G'], ['R', 'G', 'R'], ['R', 'G', 'G'] ]
def pick_up_the_gold(grid) gold_sachel = [] x, y = 0, 0 while y < grid.length current_sq = grid[y][x] if current_sq == 'G' gold_sachel.push 'G' grid[y][x] = 'R' end if x == (grid[y].length - 1) x = 0 y += 1 else x += 1 end end raise "Oops, looks like we missed one" if grid.include? 'G' puts "You picked up #{gold_sachel.count} pieces of gold!" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def second_challenge\n groceries = {\n dairy: [\"milk\", \"yogurt\", \"cheese\"],\n vegetable: [\"carrots\", \"broccoli\", \"cucumbers\"],\n meat: [\"chicken\", \"steak\", \"salmon\"],\n grains: [\"rice\", \"pasta\"]\n }\n\n groceries.values.flatten\n\n\nend", "def skittle_combos(skittles)\n array = []\n skittles.each do |color1|\n skittles.each do |color2|\n if color1 == color2 \n next \n end \n result = [color1,color2].sort()\n array.append(result)\n end\n end\n return array \nend", "def mix_names(girls, boys)\n\tnew_array = girls \n\tindex = 0 \n\n\tboys.length.times do\n\t\tnew_array << boys[index]\n\t\tindex = index + 1 \n\tend \n\n\toutput = new_array\n\treturn output\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 skittle_combos(skittles)\n two_flavor_array = Array.new\n skittles.each do |el1|\n skittles.each do |el2|\n if el1 != el2\n two_flavor_array.push([el1, el2].sort)\n end\n end\n end\n two_flavor_array.uniq.sort\nend", "def genres\n songs.map{|song|song.genre}.uniq\n end", "def buy_fruit(grocery_list)\n array_of_fruits = []\n\n grocery_list.each do |fruit|\n fruit[1].times { array_of_fruits << fruit[0]}\n end\n array_of_fruits\nend", "def buy_fruit(groceries)\n things_to_buy = []\n groceries.each do |items|\n items[1].times { things_to_buy << items[0] }\n end\n things_to_buy \nend", "def skittle_combos(skittles)\n skittles.combination(2).map(&:sort).uniq\nend", "def grocery_list(groceries)\n\tneeded_groceries = {}\n\tgroceries = groceries.split(' ')\n\tgroceries.each do |item|\n\t\tneeded_groceries[item] = 1\n\tend\n\t#p needed_groceries\n\tpretty_list(needed_groceries)\nend", "def buy_fruit(grocery_list)\n result = []\n grocery_list.each do |fruit|\n fruit[1].times do\n result << fruit[0]\n end\n end\n result\nend", "def genres\n songs.collect{|song| song.genre}.uniq\n end", "def genres \n songs.collect {|song| song.genre}.uniq \n\n end", "def cows_and_bulls\n [@cows, @bulls]\n end", "def allergens\n self.allergy.map do |allergen|\n allergen.ingredient\n end.uniq\n end", "def genres\n songs.map{|song| song.genre} # giving back all the genres under that particular artist. artists can have nmany genres and calling of theirmany genres.\n # Song.all.map{|ind_song| ind_song.genre} #giving back all the different genres from the collection of song array. giving back all the genres of the songs\n # binding.pry\n end", "def genres\n @songs.collect{|song| song.genre }.uniq\n end", "def plays_genres\n genres = Array.new\n self.genres.each do |genre|\n genres << genre.printable\n end\n genres.uniq\n end", "def rockmelons\n [Pack.new(3, Money.new(595, 'NZD')),\n Pack.new(5, Money.new(995, 'NZD')),\n Pack.new(9, Money.new(1699, 'NZD'))]\n end", "def genres\n @songs.collect { |song| song.genre }.uniq\n end", "def girls_with_green_eyes(students, eye_colors)\n\tgirls = []\n\tgirls_with_green_eyes = []\n\tstudents.each_with_index do |student, i|\n\t\tif i%2 == 0\n\t\t\tgirls.push(eye_colors[i])\n\t\t\tgirls.push(students[i])\n\t\tend\n\tend\n\n\tgirls.each_with_index do |eye_color, i|\n\t\tif eye_color == \"Green\"\n\t\t\tgirls_with_green_eyes.push(students[i])\n\t\tend\n\tend\n\n\treturn girls_with_green_eyes\nend", "def treasure\n [\"ring\", \"necklace\", \"dagger\", \"amulet\", \"ruby\", \"sapphire\", \"piece of jade\", \"human skull\", \"tarask skull\"].sample\nend", "def genres\n @songs.collect do |song|\n song.genre\n end.uniq\n end", "def genres\n\t\[email protected] {|g| g.genre}\n\tend", "def buy_fruit(grocery_list)\n grocery_list.each_with_object([]) do |sub_arr, arr|\n sub_arr[1].times { arr << sub_arr[0] }\n end\nend", "def genres \n songs.collect{ |s| s.genre }.uniq #returns collection of genres for all of the artist's songs/ does not return duplicate genres/ collects genres\n end", "def genres\n self.songs.collect {|song| (song.genre) }.uniq\n end", "def genres\n songs.map {|song| song.genre}\n end", "def allergens\n self.ingredients.map do |ingredient|\n Allergen.all.map do |allergen|\n ingredient if allergen.ingredient_O == ingredient\n end.compact\n end.flatten.uniq\n end", "def genres\n songs.map do |song| song.genre end\n end", "def genres\n self.songs.map { |song| song.genre }.uniq\n end", "def genres\n songs.map {|song| song.genre }\n end", "def gracify(data)\n data.map{|i| Belt.new(i[0], i[1])}\n end", "def genres\n self.songs.map do |song|\n song.genre\n end.uniq\n #unduped.uniq #uniq only works on an array\n end", "def genres #How to shorten? \n array = []\n songs.each do |song_instance|\n array << song_instance.genre \n end\n array.uniq\n end", "def squares\r\n [@a1, @a2, @a3, @b1, @b2, @b3, @c1, @c2, @c3]\r\n \r\nend", "def build_shoe(num_of_decks)\n shoe = []\n num_of_decks.times do |_|\n DECK_OF_CARDS.map do |card|\n shoe << card\n end\n end\n shoe\nend", "def 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 genres\n @new_array_of_genres = []\n @songs.each do |song| #iterate through each song to find the genre\n if @new_array_of_genres.include?(song.genre) #does not return duplicate genres\n nil\n else\n @new_array_of_genres << song.genre #collects genres through its songs\n end\n end\n @new_array_of_genres #returns a collection of genres for all of the artists songs\n end", "def genres\n @songs.collect {|s| s.genre}\n end", "def gallaries\n paintings.map{|paint| paint.gallery}\n\n end", "def goose_filter(birds)\n geese = [\"African\", \"Roman Tufted\", \"Toulouse\", \"Pilgrim\", \"Steinbacher\"]\n birds - geese\nend", "def garments\n garments = []\n self.closets.map do |closet|\n closet.garments.map do |garment|\n garments.push({id: garment.id, name: garment.name, garment_style: garment.garment_style, garment_type: garment.garment_type, is_favorite: garment.is_favorite, is_clean: garment.is_clean, closet_id: garment.closet_id, image: garment.image, temperatures: garment.temperatures, user: garment.user, lowest_temp: garment.lowest_temp, highest_temp: garment.highest_temp, garment_weight: garment.garment_weight, temperatures: garment.temperatures, temperature_ranges: garment.temperature_ranges})\n end\n end\n garments\n end", "def genres\n search_by_text('жанры').split(', ')\n end", "def rocks\r\n rockdata = sampledata.find_all_by_property('rock type')\r\n {\r\n :qual_values => rockdata.map{|r| r.qual_value }.join('; ')\r\n }\r\n end", "def allergens\n ingredients_array=[]\n ingredients.each do |ingredient|\n # binding.pry\n if ingredient.allergens\n # binding.pry\n ingredients_array << ingredient.allergens\n end\n end\n arr= ingredients_array.flatten.map do |allergen|\n allergen.ingredient\n end\n arr.uniq\n end", "def genres\n songs.collect do |song|\n song.genre\n end\n .uniq #does not return duplicate genres if the artist has more than one song of a particular genre (artist has many genres through songs)\n end", "def squares\n [@a1, @a2, @a3, @b1, @b2, @b3, @c1, @c2, @c3]\n\nend", "def buy_fruit(fruit_array)\n fruit_array.map { |fruit, how_many| [fruit] * how_many }.flatten\nend", "def squares\n [@a1, @a2, @a3, @b1, @b2, @b3, @c1, @c2, @c3]\n \nend", "def build_shoe(num_of_decks)\n shoe = []\n num_of_decks.times do |_|\n DECK_OF_CARDS.select do |card|\n shoe << card\n end\n end\n shoe\nend", "def genres\n self.songs.collect {|song| song.genre}.uniq\n end", "def genre_array\n Genre.list.each { |genre| @available_genres << genre.kind }\n end", "def genres\n to_array search_by_itemprop 'genre'\n end", "def galleries\n paintings.map{|painting| painting.gallery}.uniq\n end", "def genre_list\n {\"1\" => 'シーバス', \"2\" => 'バス', \"3\" => \"青物\",\n \"4\" => \"フラットフィッシュ\", \"6\" => \"アジ\"}\n end", "def remix(ingredients)\n alcohol = ingredients.map {|el| el[0]}\n mixers = ingredients.map {|el| el[1] }\n alcohol.shuffle!\n mixers.shuffle!\n result = []\n alcohol.each_with_index do |al, i| \n result << [al, mixers[i]]\n end\n result\nend", "def combine\n other_survivor_supplies = [ \"warm clothes\", \"rations\", \"compass\", \"camp stove\",\n \"solar battery\", \"flashlight\"]\n other_survivor_supplies.each do |others|\n @zombie_apocalypse_supplies.push(others)\n end\n @zombie_apocalypse_supplies = @zombie_apocalypse_supplies.uniq\n\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 eshop_games \n arr = [] \n listings.each do |g| \n if g&.sale_price\n arr << g \n end \n end \n arr \n end", "def add_asterik(grocery_list)\n\n\tgrocery_string = grocery_list.join(\"|*\")\n\n\tcomplete_grocery_string = \"*\" << grocery_string\n\n\toutput_grocery_list = complete_grocery_string.split(\"|\")\n\n\tputs output_grocery_list\n\n\tputs \"You have a total of #{output_grocery_list.length} items in your list.\"\n\n\tputs grocery_list.include?(\"*banana*\") ? \"You don't need to pick up banana\" : \"You need to pick up bananas\"\n\n\tputs \"The second item on your list is #{grocery_list[1]}\"\n\n\tputs output_grocery_list.sort\n\nend", "def wells\n plates.collect(&:wells).flatten\n end", "def join_ingredients(src)\n \n new_array = []\n \n new_array.push(\"I love #{src[0][0]} and #{src[0][1]} on my pizza\")\n new_array.push(\"I love #{src[1][0]} and #{src[1][1]} on my pizza\")\n new_array.push(\"I love #{src[2][0]} and #{src[2][1]} on my pizza\")\n \n\n new_array\nend", "def genres\r\n self.songs.collect do |song|\r\n song.genre\r\n end\r\n end", "def genres\n self.songs.map {|x| x.genre}\n end", "def grapher(array)\n hash = Hash.new { |hash, key| hash[key] = [] }\n array.each do |pair|\n hash[pair[0]] ||= []\n hash[pair[0]] << pair[1]\n end\n hash\nend", "def married_men_and_unmarried_woman\n result = []\n add_married_men_to(result)\n add_unmarried_woman_to(result)\n result\nend", "def galleries\n self.paintings.map{|painitng| painitng.gallery}.uniq\n end", "def genres\n songs.map do |song|\n song.genre\n end\nend", "def populate\n black = [\n Rook.new(:black, self, [0,0], \" ♜ \"),\n Knight.new(:black, self, [0,1], \" ♞ \"),\n Bishop.new(:black, self, [0,2], \" ♝ \"),\n Queen.new(:black, self, [0,3], \" ♛ \"),\n King.new(:black, self, [0,4], \" ♚ \"),\n Bishop.new(:black, self, [0,5], \" ♝ \"),\n Knight.new(:black, self, [0,6],\" ♞ \"),\n Rook.new(:black, self, [0,7], \" ♜ \")\n ]\n white = [\n Rook.new(:white, self, [7,0], \" ♖ \"),\n Knight.new(:white, self, [7,1], \" ♘ \"),\n Bishop.new(:white, self, [7,2], \" ♗ \"),\n Queen.new(:white, self, [7,3], \" ♕ \"),\n King.new(:white, self, [7,4], \" ♔ \"),\n Bishop.new(:white, self, [7,5], \" ♗ \"),\n Knight.new(:white, self, [7,6], \" ♘ \"),\n Rook.new(:white, self, [7,7], \" ♖ \")\n ]\n\n @grid.each_with_index do |row, i|\n row.each_with_index do |column, j|\n pos = [i, j]\n if i == 0\n self[pos]= black[j]\n @black_pieces << black[j]\n elsif i == 7\n self[pos]= white[j]\n @white_pieces << white[j]\n elsif i == 1\n black_pawn = Pawn.new(:black, self, pos, \" ♟ \")\n self[pos]= black_pawn\n @black_pieces << black_pawn\n elsif i == 6\n white_pawn = Pawn.new(:white, self, pos, \" ♙ \")\n self[pos] = white_pawn\n @white_pieces << white_pawn\n end\n end\n end\n\n @grid\n end", "def find_gold_bags!\n # Find the set of bags that can directly contain a SHINY_GOLD bag.\n gold_bags = Set.new @rules.values.filter { |e| e.contents.include?(SHINY_GOLD) }.map(&:color)\n\n # Do a transitive closure, finding all bags that can contain a bag which\n # contains a bag which ...\n stabilized = false\n until stabilized\n initial_size = gold_bags.length\n\n @rules.each do |color, contents|\n color_contents = contents.contained_colors\n\n # If any of the contained colors are in the set of bags we know can\n # contain a gold bag\n if color_contents.intersect? gold_bags\n # add in the new parent color\n gold_bags << color\n end\n end\n\n stabilized = gold_bags.length == initial_size\n end\n\n gold_bags\n end", "def grocery(grocery_list)\n \thash = {}\n \t list_item = grocery_list.split(\" \")\n \t list_item.each {|x| hash[x] = 2}\n return hash \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 allergens\n array = []\n Allergen.all.each do |allergen_instance|\n ingredients.each do |ingredient|\n if allergen_instance.ing == ingredient\n array << allergen_instance.ing\n end\n end\n end\n array\nend", "def one_week_wonders(songs)\n array = []\n songs.each do |song|\n array << song if no_repeats?(song, songs) && array.include?(song) == false\n end\n array\nend", "def pets_by_breed(shop, breed) # def the function with two arguements of shop and breed which are passed in through test as @pet_shop and \"B/s\"\n pets_array = [] #creates a new array\n for pet in shop[:pets] #for loop says for a pet in @pet_shop pets\n pets_array.push(pet) if pet[:breed] == breed #push the pet breed of B/s into the pets array\n end\n return pets_array #return the pets array (2)\nend", "def victoire\n \n [[@a1, @a2, @a3],\n [@a1, @b2, @c3],\n [@a1, @b1, @c1],\n [@b1, @b2, @b3],\n [@c1, @c2, @c3],\n [@c1, @b2, @a3],\n [@a2, @b2, @c2],\n [@a3, @b3, @c3]]\n end", "def squares\n [@a1, @a2, @a3, @b1, @b2, @b3, @c1, @c2, @c3]\n\n end", "def allergens\n unique_allergen_ingredients = Allergen.all.map do |allergen|\n allergen.ingredient\n end.uniq\n\n (self.ingredients & unique_allergen_ingredients)\n end", "def neat_genres\n genres.split(',').delete_if { |word| word.eql?(\"\") || word.eql?(\" \") }.join(', ')\n end", "def blend()\n grabs_items = @smoothie_ingredients.keys.join.split(\"\").shuffle\n # Return takes new variable, joins all array characters into one line\n # and removes any spaces\n return grabs_items.join.delete(\" \")\n end", "def scrobbles\n tracks_url_for(@user) { |url| tracks_for_url(url) }.flatten\n end", "def baseball_team_lists\n [\"A's\", \"Tigers\", \"Stars\"] #Simple ruby array\nend", "def list\n current_list = []\n\n allergens.each_with_index do |allergen, index|\n if score & (2 ** index) > 0\n current_list << allergen\n end\n end\n\n # if score & (2**0) > 0\n # current_list << allergens[0]\n # end\n\n # if score & (2**1) > 0\n # current_list << allergens[1]\n # end\n\n current_list\n end", "def g5_games(teams)\n games = Array.new\n teams.each do |team|\n 2.times do\n games << [team, G5_RATINGS.sample]\n end\n end\n\n games\nend", "def genres(string)\n return [] if string.blank?\n\n genres = []\n\n # Split fields\n string.split(/[,;]/).each do |genre|\n ##\n # Start with a single empty genre string. Split the genre by spaces\n # and process each component. If a component does not have a slash,\n # concatenate it to all genre strings present in +temp+. If it does\n # have a slash present, duplicate all genre strings, and concatenate\n # the first component (before the slash) to the first half, and the\n # last component to the last half. +temp+ now has an array of genre\n # combinations.\n #\n # 'Traditional Heavy/Power Metal' => ['Traditional Heavy', 'Traditional Power']\n # 'Traditional/Classical Heavy/Power Metal' => [\n # 'Traditional Heavy', 'Traditional Power',\n # 'Classical Heavy', 'Classical Power']\n #\n temp = [\"\"]\n\n genre.downcase.split.reject { |g| GENRE_SUFFIXES.include? g }.each do |g|\n if g.include? \"/\"\n # Duplicate all WIP genres\n temp2 = temp.dup\n\n # Assign first and last components to temp and temp2 respectively\n split = g.split \"/\"\n temp.map! { |t| t.empty? ? split.first.capitalize : \"#{t.capitalize} #{split.first.capitalize}\" }\n temp2.map! { |t| t.empty? ? split.last.capitalize : \"#{t.capitalize} #{split.last.capitalize}\" }\n\n # Add both genre trees\n temp += temp2\n else\n temp.map! { |t| t.empty? ? g.capitalize : \"#{t.capitalize} #{g.capitalize}\" }\n end\n end\n genres += temp\n end\n genres.uniq\n end", "def create_grocery_list(items)\r\n\tgrocery_list = {}\r\n\tgrocery_array = items.split(\" \")\r\n\tgrocery_array.each do |item|\r\n\t\tgrocery_list[item] = 1\r\n\tend\r\n\tgrocery_list\r\nend", "def GearInfo\n @gearArray = []\n @gearArray[ 0 ] = \"a helmet\"\n @gearArray[ 1 ] = \"knee pads\"\n @gearArray[ 2 ] = \"elbow pads\"\n @gearArray[ 3 ] = \"wrist wraps\"\n \n gearString = \"I wear:\" \n \n i = 0\n gearAlreadyUsed = Array.new\n numGear = rand( 1 .. @gearArray.size )\n \n numGear.times do\n if (i == numGear - 1 && i != 0) \n gearString << \" and\" \n elsif i != 0\n gearString << \", \" \n end\n \n #save what gear has already been used, we don't want the same piece to appear more than once\n foundGear = false\n while foundGear == false\n tempGear = rand( @gearArray.size - 1 )\n if !gearAlreadyUsed.include?( tempGear ) \n foundGear = true \n else\n foundGear = false\n end\n end\n \n gearString << \" #{@gearArray[ tempGear ]}\"\n gearAlreadyUsed.push( tempGear )\n i = i + 1\n end #gear loop\n puts gearString << \".\"\n end", "def groceryList(*list)\n \ti=0\n \twhile i<list.length\n \t\tputs list[i]\n \t\ti+=1\n \tend\n end", "def breed_group\n return data.breed_groupes\n end", "def group_braille_arrays\n get_braille_arrays.each_slice(3).to_a\n end", "def genres\n self.songs.collect do |song|\n song.genre\n end\n end", "def genres\n self.songs.collect do |song|\n song.genre\n end\n end", "def genres\n self.songs.collect do |song|\n song.genre\n end\n end", "def genres\n self.songs.collect do |song|\n song.genre\n end\n end", "def genres\n self.songs.collect do |song|\n song.genre\n end\n end", "def bakeries\n dessert.map do |dessert|\n dessert.bakery\n end\n \n end", "def subgenres; end", "def genders\n ['male','female','A being beyong comprehension']\n end", "def galleries\n galleries_array = paintings.map {|painting| painting.gallery}\n galleries_array.uniq\n end" ]
[ "0.629131", "0.6111802", "0.60970443", "0.60818183", "0.6028822", "0.5893935", "0.58764905", "0.58362335", "0.5831098", "0.5789968", "0.57704693", "0.5763978", "0.5763026", "0.5753572", "0.5745396", "0.57448995", "0.57391024", "0.5734377", "0.5733186", "0.5729222", "0.5716541", "0.5711234", "0.5710792", "0.57096344", "0.57059914", "0.56700873", "0.56556183", "0.5647166", "0.5631711", "0.5627358", "0.5617188", "0.5611079", "0.5609888", "0.56059813", "0.55956674", "0.5592102", "0.5587768", "0.55714196", "0.5570027", "0.55675584", "0.55528307", "0.5542595", "0.55392116", "0.5533992", "0.5531232", "0.55289143", "0.552539", "0.552019", "0.55136436", "0.550811", "0.55043614", "0.55013275", "0.54993284", "0.5493402", "0.54910684", "0.5469866", "0.54491633", "0.54338306", "0.54316735", "0.5425981", "0.54173565", "0.54160225", "0.54157066", "0.5414831", "0.54141307", "0.54138637", "0.54124564", "0.54095846", "0.54010314", "0.5396628", "0.5394262", "0.5391878", "0.5388084", "0.53847164", "0.5383359", "0.53829163", "0.53823906", "0.53791696", "0.5375773", "0.53754324", "0.5364532", "0.53596133", "0.535937", "0.53571904", "0.53453714", "0.53449804", "0.5344919", "0.5344661", "0.534376", "0.53414357", "0.5340576", "0.53372234", "0.53372234", "0.53372234", "0.53372234", "0.53372234", "0.53294516", "0.53290755", "0.53281164", "0.532729" ]
0.5610471
32
Push a record onto the records
def << (record) raise "Obj should be a Record" unless record.class == Record @entries << record end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def <<(record)\n @records << record\n end", "def <<(record)\n @records << record\n end", "def addRecord(rec); @records[rec.key] = rec end", "def push_record(record)\n params = TogglRecord.new(record, config).push\n record[:id]\n end", "def addRecords(recs); recs.each { |r| addRecord r } end", "def add_record(record)\n condensed_record = condense_record(record)\n load_atoms(condensed_record)\n add_occurences(condensed_record,record.id)\n @records_size += 1\n end", "def add_to_buffer(records)\n @records_buffer.push(*records)\n end", "def add_record(record)\n return unless @if_proc.call(record)\n\n condensed_record = condense_record(record)\n atoms = add_occurences(condensed_record, record.id)\n\n @storage.add(atoms)\n end", "def push_new_record(record)\n handle_couch_response do\n RestClient.post(local_couch_database_url, record, content_type: :json)\n end\n end", "def add_record(record)\n return unless allow_indexing?(record)\n\n condensed_record = condense_record(record)\n atoms = add_occurences(condensed_record, record.id)\n\n @storage.add(atoms)\n end", "def enqueue(record)\n @queue << record.representation\n end", "def add_record(record_id)\n @records[record_id] = [] unless include_record?(record_id)\n end", "def add_transaction_record(record)\n current_transaction.add_record(record)\n end", "def add_record record\n # Record all leases, since the definition of a duplicate depends on whether we\n # are searching by ip or mac. Arrays have fixed sort order so we can rely on this\n # being the order they were read from the file\n @records.push record\n logger.debug \"Added #{record} to #{to_s}\"\n return true\n end", "def extend(records)\n @records += records\n end", "def <<(*records)\n flatten_deeper(records).each do |record|\n raise_on_type_mismatch(record)\n insert_record(record)\n @collection << record if loaded?\n end\n self\n end", "def add(record, zone)\n new_answers = [{ answer: build_api_answer_from_record(record) }]\n\n record_fqdn = record.fqdn.sub(/\\.$/, '')\n\n existing_record = client.record(\n zone: zone,\n fqdn: record_fqdn,\n type: record.type\n )\n\n if existing_record.nil?\n client.create_record(\n zone: zone,\n fqdn: record_fqdn,\n type: record.type,\n params: {\n answers: new_answers,\n ttl: record.ttl,\n use_client_subnet: false, # only required for filter chains that are not supported by record_store\n }\n )\n return\n end\n\n existing_answers = existing_record['answers'].map { |answer| symbolize_keys(answer) }\n client.modify_record(\n zone: zone,\n fqdn: record_fqdn,\n type: record.type,\n params: { answers: existing_answers + new_answers, ttl: record.ttl }\n )\n end", "def add_records(records)\n records.each do |r|\n condensed_record = condense_record(r)\n load_atoms(condensed_record)\n add_occurences(condensed_record,r.id)\n @records_size += 1\n end\n end", "def append(model, data)\n data.group_by { |row| row[:record_id] }.each do |record_id, changes|\n @records << Record.new(model, record_id, changes.map { |c| c.slice(:column_name, :value, :changed_at)})\n end\n @length = nil\n self\n end", "def add(record)\n unless exist?(record[0])\n domain = new_domain(record[0])\n zone = new_zone(domain.id)\n for t in @templates\n new_record(t, domain, record)\n end\n\n if(record[4] == \"yes\")\n @mxgoogle.each do |content, ttl_prio|\n new_mx_record(domain, content, ttl_prio[\"ttl\"], ttl_prio[\"prio\"])\n end\n\n new_txt_record(domain, record[5]) unless record[5].empty?\n end\n\n return record\n else\n update(record)\n end\n\n return nil\n end", "def add_records(records)\n atoms = {}\n\n records.each do |record|\n next unless @if_proc.call(record)\n\n condensed_record = condense_record(record)\n atoms = add_occurences(condensed_record, record.id, atoms)\n end\n\n @storage.add(atoms)\n end", "def add_records(records)\n atoms = ActiveSupport::OrderedHash.new\n records_count = 0\n\n records.each do |record|\n next unless allow_indexing?(record)\n records_count += 1\n\n condensed_record = condense_record(record)\n atoms = add_occurences(condensed_record, record.id, atoms)\n end\n\n @storage.add(atoms, records_count)\n end", "def add_record(value)\n @children['record'][:value] << value\n end", "def add_record(value)\n @children['record'][:value] << value\n end", "def add_to_purchases(purchase_record)\n @purchases << purchase_record\n end", "def push(parsed_response)\n TimeEntry.transaction do\n parsed_response[:data].map { |x| push_record x }\n end\n end", "def add(record)\n @server.add record.class.name, record.to_doc\n end", "def record(record)\n @db.save_doc(record)\n end", "def append_records\n # counter is a array type container hold numbers of AxOrder instance.\n # current AxOrder instance by manipulate is last member of container.\n counter = []\n begin\n if counter.empty?\n counter << new(:ax_order_number => next_ax_order_number)\n else\n counter << new(:ax_order_number => next_ax_order_number(counter.last.ax_order_number))\n end\n\n order, items = counter.last.fetch_data\n counter.last.attributes = order\n items.each do |item|\n counter.last.ax_order_line_items << AxOrderLineItem.new(item)\n end\n counter.each {|o| o.save }\n append_records # recursive invoke method self\n rescue => ex\n puts ex.message if AppConfig.DEBUG_MODE\n retry unless counter.size == MAX_COUNTER\n end\n end", "def write(record)\n @worker.enqueue record\n end", "def record(data)\n results << data\n Spidey.logger.info \"Recording #{data.inspect}\"\n end", "def push(element)\n # add element to the head of @store\n @store.add_first(element)\n end", "def insert(record, sync: true)\n record = klass.new(**record) if record.is_a?(Hash)\n row = record.to_row(header)\n ws.update_cells(*next_row_col, [row])\n ws.synchronize if sync\n record\n end", "def set_new_record(record)\n replace(record)\n end", "def push(item); end", "def add_a_record(user, book)\n\t\tnow = DateTime.now.to_date\n\t\tborrow_days = 60\n\t\tdue = now + borrow_days\n\t\t@records << Record.new(user.id, book.isbn, now, due)\n\t\tputs \"Successfully lend <#{book.title}> to #{user.name}. Due:#{due}\"\n\tend", "def add_transaction_detail_record(record)\n raise InvalidTypeError, \"Expected record of type TransactionDetailRecord\" unless record.is_a?(TransactionDetailRecord) \n @transaction_detail_records << record\n end", "def push\n end", "def add_position(record_id, pos)\n add_record(record_id)\n @records[record_id] << pos\n end", "def add_record type, data, ttl = 0, flags = 0\n @records << _add_record(flags.to_i, type, data, ttl)\n end", "def add(record)\n handle_drb_error { @server.add index_name, record.to_doc }\n end", "def accumulate record\n end", "def process(record)\n @output << record\n end", "def push(element)\n @store.push(element)\n self\n end", "def <<(record)\n @cache[record.class] << record\n end", "def push(x)\n @store << x\n \n end", "def add_to_transaction(*)\n @connection.add_transaction_record(self)\n end", "def add(row)\n @data << row\n end", "def add_record(name, record)\n klass_map = self.object_map[self.models[record.class]]\n\n # Panic if attempted to insert duplicate fixture record.\n if klass_map.include?(name.to_sym)\n raise \"Duplicate fixture for #{record.class} - #{name}\"\n end\n\n self.fixture_name_map[record] = name.to_s\n klass_map[name.to_sym] = record\n dot\n\n return record\n end", "def append(log_record)\r\n self.log_records << log_record\r\n log_record.identifiers.each do |id|\r\n self.identifiers << id if not self.identifiers.include? id\r\n end\r\n end", "def push(element)\n @data.push(element)\n end", "def add_entry entry\n @data << entry\n end", "def add_record param, strength\n\trecord = check_repeat(param)\n\trecord.add_record(strength)\nend", "def push(document)\n name = document._name\n initialize_array(name)\n self.delta_pack[name].push document.to_h\n update_ust(document)\n end", "def record(*args)\n raise 'Not enough arguments' if args.empty?\n raise 'Too many arguments' if args.size > 2\n\n queue << ['record', *args]\n end", "def add_to_index(records, **opt)\n fields = records.map(&:emma_metadata)\n $stderr.puts \"=== STEP #{__method__} | #{Emma::ThreadMethods.thread_name} | #{records.size} recs = #{records.map { |r| manifest_item_id(r) }} | #{fields.size} fields = #{fields.inspect.truncate(1024)}\" # TODO: testing - remove\n result = ingest_api.put_records(*fields)\n remaining, failure = process_ingest_errors(result, *records)\n\n opt[:success] = 'indexed' # TODO: I18n\n opt[:meth] = __method__\n opt[:initial] = { failure: failure }\n\n now = DateTime.now\n run_step(remaining, **opt) do |_id, rec|\n rec.update_columns(last_indexed: now)\n end\n end", "def push(x)\n @store << x\n end", "def schedule_new_record(row)\n ETL::Engine.logger.debug \"writing new record\"\n if scd_type == 2\n row[scd_effective_date_field] = @timestamp\n row[scd_end_date_field] = '9999-12-31 00:00:00'\n row[scd_latest_version_field] = true\n end\n buffer << row\n end", "def create(contents)\n store.write do |data| \n id = (data[:identifiers][column] += 1)\n \n data[:columns][column][id] = contents \n\n Record.new(column, id, contents)\n end\n end", "def push(e)\n idx = @data.size\n @data.push e\n percolate_up\n end", "def add(rf, start_time, uploader)\n hash = HistoryEntry.new.from_recording_format(rf)\n hash.add_time(start_time)\n hash.add_status(uploader.status)\n\n @history << hash\n hash[:id] = @_hdb.add(hash)\n end", "def insert_record(name, type, ttl, content)\n records_table.insert(\n :domain_id => domain.id,\n :name => name,\n :type => type, \n :ttl => ttl, \n :content => content,\n :change_date => Time.now.to_i\n )\n end", "def create(record)\n now = Time.now\n record['created_at'] ||= now\n record['updated_at'] ||= now\n collection.insert(record)\n end", "def records=(records)\n clear\n concat(records)\n end", "def <<(*records)\n result = true\n load_target if @owner.new_record?\n\n transaction do\n flatten_deeper(records).each do |record|\n raise_on_type_mismatch(record)\n add_record_to_target_with_callbacks(record) do |r|\n result &&= insert_record(record) unless @owner.new_record?\n end\n end\n end\n\n @owner.send(:cache_write, @reflection, self) if @reflection.options[:cached]\n\n result && self\n end", "def save!(additions = [])\n additions.each do |contact|\n @ab.addRecord(contact.person)\n end\n\n @ab.save\n end", "def push(x)\n @store.unshift(x)\n end", "def push(element)\n @store.push(element)\n @top += 1\n end", "def push(info)\n\t\tadd(info)\n\tend", "def <<(*records)\n load_target\n flatten_deeper(records).compact.each do |record|\n raise_on_type_mismatch(record)\n add_record_to_target_with_callbacks(record)\n end\n self\n end", "def save_record(record)\n record.save\n end", "def save_record(record)\n record.save\n end", "def push(element)\n @store << element #putting the element into the array, thereby putting it into the stack\n end", "def push(value); end", "def push(*args)\n @tables.push *args\n return self\n end", "def create(key, contents)\n store.write do |data| \n \n data[:columns][column][key] = contents \n\n Record.new(column, key, contents)\n end\n end", "def add_to_list\n\n # Keep a copy of position to set after the change detail is saved, \n # because the entry will be put at the end of the list.\n position = self.position\n self.save\n\n if self.errors.empty?\n change_details = self.change_item.change_details.find(:all)\n position = 1 if !position\n change_details.last.insert_at(position)\n end\n end", "def new_student(name, email)\n #code here\n @students.push({name: name, email: email})\nend", "def push\n end", "def add_pet_to_customer(customer, new_pet)\ncustomer[:pets].push(new_pet)\nend", "def record; end", "def record; end", "def record; end", "def upsert_record\n connection.change_resource_record_sets(\n hosted_zone_id: @zone,\n change_batch: {\n changes: [\n {\n action: 'UPSERT',\n resource_record_set: {\n name: @resource[:record],\n type: @resource[:type],\n ttl: @resource[:ttl],\n resource_records: @resource[:value].map { |value| { value: value } }\n }\n }\n ]\n }\n )\n end", "def add_new_record(h, ws)\n row_array = []\n @excel_row.each do |a|\n row_array.push(h[a])\n end\n ws.add_row row_array\nend", "def push(datum)\r\n @data_stack << datum\r\n end", "def store_record rec\n return if rec.comment # skip GFF comments\n id = Helpers::Record::formatID(rec)\n @count_ids.add(id)\n @count_seqnames.add(rec.seqname)\n\n is_component = COMPONENT_TYPES.include?(rec.feature_type.upcase)\n if is_component\n # check for container ID\n warn(\"Container <#{rec.feature_type}> has no ID, so using sequence name instead\",id) if rec.id == nil\n @componentlist[id] = rec\n info \"Added feature <#{rec.feature_type}> with component ID\",id\n # $stderr.print rec\n end \n case rec.feature_type\n when 'gene' || 'SO:0000704'\n @orflist.add(id,rec)\n when 'mRNA' || 'SO:0000234'\n @mrnalist.add(id,rec)\n when 'CDS' || 'SO:0000316'\n @cdslist.add(id,rec)\n when 'exon' || 'SO:0000147'\n @exonlist.add(id,rec)\n else\n if !is_component and !IGNORE_FEATURES.include?(rec.feature_type)\n @unrecognized_features[rec.feature_type] = true\n end\n end\n end", "def save_records\n unless @records.empty?\n @model_class.connection.populate(@model_class.quoted_table_name, columns_sql, rows_sql_arr, \"#{@model_class.name} Populate\")\n @last_id_in_database = @records.last.id\n @records.clear\n end\n end", "def enroll(new_student) \n @students.push(new_student) \n end", "def push(*rows)\n rows.each { |row| self << row }\n self\n end", "def save\n @@all.push(self)\n end", "def <<(*records)\n save_records = proxy_owner.persisted?\n\n if records.flatten.all? &:valid?\n records.flatten.each do |record|\n unless include? record\n raise_if_type_mismatch(record)\n add_foreign_key_in_proxy_owner(record.id)\n proxy_target << record\n record.save if save_records\n end\n end\n\n proxy_owner.save if save_records\n\n self\n end\n end", "def push(element); end", "def add(element)\n # set element id\n element.id = @next_id\n # push element into elements\n @elements << element\n # save changes\n save_csv\n # increment next_id\n @next_id += 1\n end", "def push(x)\n @data.push(x) \n end", "def push(value)\r\n @data << value\r\n end", "def set_or_replace_record(obj)\r\n @records.delete_if {|record| record.id == obj.id }\r\n obj.id ||= (@id_counter += 1)\r\n\r\n # Dup to clean up any extra added pieces, like Errors\r\n @records << obj.dup\r\n\r\n obj\r\n end", "def create\n push_to_db\n end", "def create\n push_to_db\n end", "def batch_new\n @records = Array.new(BATCH_SIZE) { record_class.new }\n end" ]
[ "0.7778802", "0.7778802", "0.7679838", "0.74537224", "0.7308447", "0.723168", "0.71305203", "0.71200836", "0.7061831", "0.69934124", "0.6942726", "0.6927854", "0.6855094", "0.66557133", "0.66419643", "0.656446", "0.64771014", "0.6455133", "0.64538145", "0.63954437", "0.63898945", "0.63799804", "0.6379949", "0.6379949", "0.6364114", "0.63597786", "0.62765956", "0.62674874", "0.6243298", "0.6191429", "0.61512834", "0.6109908", "0.609395", "0.6083169", "0.60745484", "0.6069581", "0.60695195", "0.6066892", "0.60651493", "0.6052025", "0.60231894", "0.60133815", "0.596363", "0.5961611", "0.5956017", "0.5955173", "0.5910352", "0.59074867", "0.58987606", "0.5890396", "0.5889111", "0.5878156", "0.58746314", "0.5866804", "0.5866589", "0.58579195", "0.5839347", "0.58384854", "0.58297247", "0.5808676", "0.58029854", "0.57764494", "0.5770189", "0.57496625", "0.5743575", "0.5737578", "0.57255226", "0.5724961", "0.57245886", "0.5724155", "0.5713658", "0.5713658", "0.5712665", "0.57044494", "0.5691942", "0.569015", "0.5686469", "0.5648258", "0.5646919", "0.5645715", "0.56436497", "0.56436497", "0.56436497", "0.5640447", "0.5634534", "0.5633203", "0.5628257", "0.56280786", "0.56247216", "0.5623418", "0.56045306", "0.55964464", "0.55919576", "0.55834806", "0.5580363", "0.5578944", "0.5574256", "0.5568665", "0.5568665", "0.5552959" ]
0.7076533
8
Sorts the records by DOB, ASC
def sort_by_dob! @entries.sort! { |a,b| a.dob <=> b.dob } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n # @birthdays = Birthday.order(month: :asc)\n # ここでまた @birthdays を order するけど、普通のルビーコードで\n # @birthdays.each do 〜 みたいな文\n # @birthdays = Birthday.order(day: :asc).reorder(month: :asc)\n # @birthdays = Birthday.order(month: :asc)\n @birthdays = Birthday.order(month: :asc, day: :asc)\n\n\n\n end", "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 sorted_by_age(people)\nend", "def sort_by_model_then_year\n @garage.sort_by{\n |car1, car2| (car1.class.to_s, car1.model_year) <=> (car2.class.to_s, car2.model_year)\n }\n end", "def alphabetailc_order\n @sorting_order = @data[\"prizes\"].sort_by{|a| a[\"year\"]}.group_by{|a| puts a[\"laureates\"].sort_by{|k| k[\"firstname\"]}}\n #@sorting_order = @data[\"prizes\"].sort_by { |a | [a[\"year\"],a[\"category\"]] }.sort_by{|a|}\n render :json => @sorting_order\n end", "def sort_accounts\n if params[:sort_by].present?\n criteria = params[:sort_by]\n @accounts = if criteria == 'last_created_at'\n @accounts.order('created_at desc')\n elsif criteria == 'first_created_at'\n @accounts.order('created_at asc')\n else\n @accounts.order('updated_at desc')\n end\n else # default sorting\n @accounts = @accounts.order('updated_at desc')\n end\n end", "def ja_sort\n [{ :created_at => :desc }]\n end", "def sorted\n @@all = @@all.sort_by(&:year)\n end", "def sort_email_address\n \"-#{self.email_address}\"\n end", "def index\n @people = Person.order(\"#{sort_column} #{sort_direction}\")\n end", "def sort_tenants_by_age tenants\n return tenants.sort_by { |tenant| tenant.age }\n end", "def sort_by_date(items)\n in_progress = items.select { |item| item[:date].nil? }\n .sort_by { |item| item[:name].downcase }\n done = items - in_progress\n done = done.sort do |item_a, item_b|\n case item_a[:date] <=> item_b[:date]\n when -1 then 1\n when 1 then -1\n else\n item_a[:name].downcase <=> item_b[:name].downcase\n end\n end\n in_progress + done\n end", "def sorted\n all.order(Arel.sql(%[ #{quoted_table_name}.\"recorded_at\" ASC, #{quoted_table_name}.\"hid\" ASC ]))\n end", "def sort_by_birthday_then_last_name\n sorted = final_array.sort_by {|k,v| [k[:birth_date][-2..-1], k[:last_name]] }\n hash_values = sorted.map {|element| element.values}\n with_line_breaks = add_line_breaks(hash_values)\n with_line_breaks.unshift(\"Output 2:\\n\")\n with_line_breaks.join(\", \").gsub(/,/, '').gsub( /\\n\\s+/, \"\\n\" )\nend", "def sort_entries; end", "def postdocs\n @postdocs = Person.find(:all, :conditions => {:position => 'Postdoctoral Fellow'})\n @postdocs.sort! {|a, b| a.last_name.upcase <=> b.last_name.upcase}\n \n respond_to do |format|\n format.html # postdocs.html.erb\n format.xml { render :xml => nil }\n end\n end", "def sort_by_sex_then_ln!\n @entries.sort! { |a,b| [a.sex, a.ln] <=> [b.sex, b.ln] }\n end", "def sort_items\n @items = @items.sort_by(&:created_at) if params[:order] == 'date'\n @items = @items.sort_by(&:created_at).reverse if params[:order] == 'date desc'\n @items = @items.sort_by(&:payee) if params[:order] == 'payee'\n @items = @items.sort_by(&:payee).reverse if params[:order] == 'payee desc'\n @items = @items.sort_by(&:description) if params[:order] == 'descr'\n @items = @items.sort_by(&:description).reverse if params[:order] == 'descr desc'\n @items = @items.sort_by(&:amount) if params[:order] == 'saldo'\n @items = @items.sort_by(&:amount).reverse if params[:order] == 'saldo desc'\n @items = @items.sort_by(&:category_id) if params[:order] == 'cat'\n @items = @items.sort_by(&:category_id).reverse if params[:order] == 'cat desc'\n end", "def sort(table_name, list, sort_by, order, per_page, default)\r\n\r\n if table_name.has_attribute?(sort_by) && (order == \"asc\" || order == \"desc\")\r\n list = list.sort_by{|item| item[sort_by].to_s.downcase}\r\n if order == \"desc\"\r\n list = list.reverse\r\n end\r\n list \r\n else\r\n # default case\r\n list.sort_by{|item| item[default].downcase}\r\n end\r\n\r\n end", "def ordered(data)\n field, ordering = sanitize_ordering(data, field_suffix: :AT)\n\n dtf = params.dig(:query, :filter, :date_time_filter) || {}\n if (dtf.keys - [field]).any?\n raise SquareLite::MismatchedParams.new(sort_field: data, date_time_filter: dtf)\n end\n\n params.bury(:query, :sort, sort_field: field, sort_order: ordering)\n self\n end", "def blogs\n\t\t @blogs.sort! { |blog1, blog2| blog2.date <=> blog1.date }\n\tend", "def sorted\n all.order(%[ #{quoted_table_name}.\"recorded_at\", #{quoted_table_name}.\"hid\" ])\n end", "def sort_name\n @ole.SortName\n end", "def user_records\n @user_records = (view_context.filter_params[:sort].present?) ? user.records.reorder(\"#{view_context.parsed_current_sort.first} #{view_context.parsed_current_sort.last}\", view_context.secondary_sort) : user.records.reorder(created_at: :desc) \n end", "def sorted_info\t\n\t\t$employee_info.values.sort_by { |hash| hash[:last_name]}\n\tend", "def sorted_for_field(field)\n for_field(field).sort\n end", "def sorted_posts_by_date\n @items.select do |i|\n ! ( REGEXP_DATE_ISO.match(i.identifier).nil? )\n end.sort do |a,b|\n a.identifier <=> b.identifier\n end.reverse\nend", "def final_name_info\n sort_by_gender_then_last_name + \"\\n\" + sort_by_birthday_then_last_name+ \"\\n\" + sort_by_last_name\nend", "def index\n @doctors = Doctor.where(status_id: 1).order(:surname)\n end", "def sort_tweets_by_date\n\t\ttweets = @tweets.sort_by{|tweet| tweet.created_at}\n\tend", "def sort sortfield = :id, descending = false\n @sortfield = sortfield.to_sym\n reverse = descending ? -1 : 1\n @data = @data.compact.sort { |us1, us2|\n comp =\n if us1[@sortfield] && us2[@sortfield]\n us1[@sortfield] <=> us2[@sortfield]\n elsif us1[@sortfield]\n 1\n elsif us2[@sortfield]\n -1\n else\n 0\n end\n comp * reverse\n }\n end", "def sort_employees(employees, argument)\n employees.sort_by do |employee|\n case argument\n when 'f' then employee.first_name\n when 'l' then employee.last_name\n end\n end\nend", "def order(field='id',order='desc')\n case order.downcase.to_s\n when 'asc'\n self.sort { |a,b| b.send(field.to_s) <=> a.send(field.to_s) }\n when 'desc' \n self.sort { |a,b| a.send(field.to_s) <=> b.send(field.to_s) }\n end\n end", "def sort_column\n super \"User\", \"lastname\"\n end", "def sort_column\n super \"User\", \"lastname\"\n end", "def sort_column\n super \"User\", \"lastname\"\n end", "def default_sort\n 'name asc'\n end", "def sort_fields(fields)\n fields.sort {|a,b| (COLUMN_SORTING_MAP[a] || a).to_s <=> (COLUMN_SORTING_MAP[b] || b).to_s }\n end", "def ordered_by(field_name)\n \n # if no field is set for sorting, request to sort by date is assumed\n if params[:sort_by].blank?\n return( field_name == \"date\" )\n else\n return( field_name == params[:sort_by] )\n end\n \n end", "def sort_by_surname(input, fullname_field)\n input.sort_by { |i| i[fullname_field].downcase.split(/ /)[1] }\n end", "def sort_by_surname(input, fullname_field)\n input.sort_by { |i| i[fullname_field].downcase.split(/ /)[1] }\n end", "def sort_users\n if params[:sort_by].present?\n criteria = params[:sort_by]\n @users = if criteria == 'last_sign_in_at'\n @users.order('last_sign_in_at desc')\n elsif criteria == 'last_created_at'\n @users.order('created_at desc')\n else\n @users.order('created_at asc')\n end\n else # default sorting\n @users = @users.order('last_sign_in_at desc')\n end\n end", "def index\n @people = Person.all.order(\"cognome asc\")\n end", "def preptime_order_by(model_tag)\n return model_tag + \".name ASC\" \n end", "def sort_params; end", "def sort_params; end", "def index\n @people = Person.all.ordered_by_last_name\n end", "def sort_due_date_incomplete\n @due_date_task_list.sort! { |duedatetask1, duedatetask2| duedatetask1.due_date <=> duedatetask2.due_date }\n @due_date_task_list.select { |duedatetask| (duedatetask.status == \"incomplete\") }\n end", "def sort_column\n %w[fullname school].include?(params[:sort]) ? params[:sort]: \"created_at\"\n end", "def sort\n\t\t#User.order(sort_column + \" \" + sort_direction).page(params[:page])\n\t\tUser.paginate(\t:page => params[:page], per_page: 10, \n\t\t\t\t\t \torder: (sort_column + \" \" + sort_direction))\n\tend", "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 order_by(field)\n ensure_valid_parameter('sorting order', field, %w(price age))\n @request[:order_by] = field.to_s \n self\n end", "def incomplete_list(sort_order: { created_at: :desc })\n incomplete.order(sort_order)\n end", "def sort_by_year(array)\n array.sort! { |a, b| a.year <=> b.year }\n end", "def sortingTheClasses (upcomingClasses)\n #i need to take the values out of the database and \n #make a hash then return the hash so that it can \n #access the data members better by date. \n upcomingClasses.sort_by{ |k, v| v[:date]}.reverse\nend", "def index\n\n @customers = Customer.order(:firstname)\n\n end", "def alphabetical_list(students)\n sorted_array = students.sort_by {|person| person[:last_name].downcase}\n sorted_array.each do |student|\n # puts \"#{student[:first_name]} #{student[:last_name]} -- #{student[:cohort]}\"\n end\nend", "def index\n @auto_bill_payments = @origin_acct.auto_bill_payments.sort {|a,b| a.dateToPay <=> b.dateToPay}\n end", "def index\n @students = Student.order(:family_name).order(:preferred_name).order(:given_name)\n end", "def sort(individual_audits, order_by, sort_direction)\n return individual_audits if order_by.blank? || sort_direction.blank?\n\n # Satisfy brakeman with additional sanitation logic\n dir = sort_direction == 'asc' ? 'asc' : 'desc'\n\n case order_by\n when 'user'\n individual_audits = if dir == 'asc'\n individual_audits.sort_by { |a| a[:user] }\n else\n individual_audits.sort_by { |a| a[:user] }.reverse\n end\n when 'timestamp'\n individual_audits = if dir == 'asc'\n individual_audits.sort_by { |a| a[:timestamp] }\n else\n individual_audits.sort_by { |a| a[:timestamp] }.reverse\n end\n end\n\n individual_audits\n end", "def sort\n @books.sort.each {|item| puts \"#{item[0]} (#{item[1]})\" }\n end", "def index\n @employees = Employee.operarixs.sort_by_calificacion\n end", "def sort_records(records)\n sort_order = order.map { |direction| [ direction.target, direction.operator == :asc ] }\n\n records.sort_by do |record|\n sort_order.map do |(property, ascending)|\n Sort.new(record_value(record, property), ascending)\n end\n end\n end", "def sort_name\n if start_date.present?\n 10_000_000_000 - start_date.to_time.to_i # because always sorted ASC and we want sooner first\n elsif end_date.present?\n 10_000_000_000 - end_date.to_time.to_i # because always sorted ASC and we want sooner first\n else\n 10_000_000_000\n end\n end", "def sort_data\n store.sort_data!\n end", "def default_sort\n 'created_at desc'\n end", "def alumni\n @alumni = Person.find(:all, :conditions => {:position => 'Alumnus'})\n \n @alumni.sort! {|a, b| a.last_name.upcase <=> b.last_name.upcase}\n\n respond_to do |format|\n format.html # alumni.html.erb\n format.xml { render :xml => nil }\n end\n end", "def filter_and_sort(sort_by = nil)\n filter_customers\n sort_customers(sort_by)\n\n self\n end", "def index\n @pacients = Pacient.order(sort_column + \" \" + sort_direction) \n end", "def sort_docs_by_key!; end", "def index\n @patients = Patient.all.sort_by { |name | name[:patient_first_name] }\n @appointments = Appointment.all\n end", "def diet_order_by(model_tag)\n return model_tag + \".name ASC\" \n end", "def sorted_fields\n @sorted_fields ||= fields.sort_by {|tag, _| tag}\n end", "def sort\n sorter = to_hash\n sorter['fields'] =\n sorter['fields'].sort_by.with_index { |f, idx| [f.keys, idx] }\n MARC::Record.new_from_hash(sorter)\n end", "def index\n @attendance_records = AttendanceRecord\n .includes(:student).order('students.family_name')\n end", "def articles_asc\n articles.sort_by(&:published)\n end", "def sort\n (@params[:sort] || :created_at).to_sym\n end", "def sort_tweets\n tweets.sort { |a, b| b.created_at <=> a.created_at }\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 getSortingOrder #:doc:\n sorting = @default_sorting.dup\n ordering = [\"DESC\", \"ASC\", \"ASC\", \"ASC\"] # default ordering\n \n if @queryparams[:sort_by]\n # get given sort_by-values\n sorts = @queryparams[:sort_by].split(\" \")\n # get given order-values and make sure sorts.size == orders.size\n orders = Array.new(sorts.size, \"DESC\")\n if @queryparams[:order]\n orders = @queryparams[:order].split(\" \")\n if orders.size < sorts.size\n orders += Array.new(sorts.size - orders.size, \"DESC\")\n elsif orders.size > sorts.size\n orders = orders.slice(0, sorts.size)\n end\n orders.each do |o|\n if not (o.upcase == \"ASC\" or o.upcase == \"DESC\") then o = \"ASC\" end\n end \n end\n \n # first sort_by-value has to be processed last (so it gets first on the list)\n sorts = sorts.reverse\n orders = orders.reverse\n \n # check sort_by-values\n sorts.each_index do |i|\n if @sort_by.has_key?(sorts[i])\n # move the sort-attribute to first\n sort_value = @sort_by[sorts[i]]\n ind = sorting.index(\"LOWER(\" + @sort_by[sorts[i]] + \")\")\n if ind != nil\n sorting.delete_at(ind)\n ordering.delete_at(ind)\n sort_value = \"LOWER(\" + sort_value + \")\"\n end\n sorting.unshift(sort_value)\n ordering.unshift(orders[i].upcase)\n end\n end\n end\n \n #combine everything together\n returnable = sorting[0] + \" \" + ordering[0]\n sorting.each_index do |i|\n next if i == 0\n returnable += \", \" + sorting[i] + \" \" + ordering[i]\n end\n return returnable\n end", "def add_sort_field(*) super end", "def earliest_order!\n # order(created_at: :asc)\n all.to_a.sort_by {|n| n.created_at }\n end", "def students\n @students = Person.find(:all, :conditions => {:position => 'Graduate Student'})\n @students.sort! {|a, b| a.last_name.upcase <=> b.last_name.upcase}\n \n respond_to do |format|\n format.html # students.html.erb\n format.xml { render :xml => nil }\n end\n end", "def sort()\n\t\t@events = @events.sort do |a,b| a[0] <=> b[0] end\n\tend", "def order_by\n if params[:order_by]\n if params[:order_by] == 'created_at'\n # If created at, get newest first\n params[:order_by] + ' DESC'\n else\n # Otherwise, get closest to now\n params[:order_by] + ' ASC'\n end\n else\n # Default to start date, ascending\n 'starts_at ASC'\n end\n end", "def facet_sort_field_for_solr\n date_to_order_by = event_start\n # puts \"T1: date_to_order_by = #{date_to_order_by}\"\n date_to_order_by = entry_deadline if is_opportunity?\n # puts \"T2: date_to_order_by = #{date_to_order_by}\"\n date_to_order_by = Time.parse(\"12/31/2037\") if date_to_order_by.blank?\n # puts \"T3: date_to_order_by = #{date_to_order_by}\"\n return FinderHelper.date_for_solr_ymd(date_to_order_by)\n end", "def sort_name\n sort_constituent\n end", "def order\n order = sortable_column_order do |column, direction|\n case column\n when \"name\", \"username\", \"email\"\n \"LOWER(#{column}) #{direction}\"\n when \"admin\"\n \"#{column} #{direction}\"\n else\n 'LOWER(username) ASC'\n end\n end\n end", "def index\n unless [\"asc\", \"desc\"].one? params[:order]\n params[:order] = \"asc\"\n end\n @personels = Personel.all.order(name: params[:order])\n @personel = Personel.new\n end", "def donations_sorted_for_display\n storg_id = Organization.find_savetogether_org.id\n donations.sort {|this, that|\n if this.to_user_id == storg_id\n 1\n elsif that.to_user_id == storg_id\n -1\n elsif this.id && that.id\n this.id <=> that.id\n else\n 0\n end\n }\n end", "def default_sort\n { order: :created_at, direction: :desc }\n end", "def ordering_by\n order && order.to_s.gsub(/^(ascend|descend)_by_/, '')\n end", "def sort!\n sort_if_needed\n self\n end", "def sort_params params\n if @sortable\n pairs = sort_pairs(params)\n found_pair = false\n pairs.each_with_index{|pair,index|\n if pair[0] == self.name.to_s\n pairs[index][1] = pair[1] == \"asc\" ? \"desc\" : \"asc\"\n found_pair = true\n end\n }\n unless found_pair\n pairs << [self.name.to_s,\"asc\"]\n end\n (pairs.map{|pair| pair.join(\",\")}).join(\"|\")\n else\n \"\"\n end\n end", "def addresses(tenantArr)\n newArray = tenantArr.sort_by {|tenant| tenant[:age]}\n newArray.each do |tenant|\n #puts tenant[:age]\n end\n end", "def sort_asc(column_name)\n results = CONNECTION.execute(\"SELECT * FROM #{table_name} ORDER BY #{column_name} ASC;\")\n results_as_objects(results)\n end", "def customers_ordered\n customers.all(:order => 'name_normalized ASC')\n end", "def sort_name\n n = \"#{self.last_name}, #{self.first_name}\"\n if self.middle_name.present?\n n += \" #{self.middle_name}\"\n end\n n\n end", "def sort_all_incomplete\n @due_date_task_list.sort! { |duedatetask1, duedatetask2| duedatetask1.due_date <=> duedatetask2.due_date }\n @combined_list = @due_date_task_list + @task_list\n @combined_list.select { |duedatetask| (duedatetask.status == \"incomplete\") }\n end", "def tie_breaking_sort\n { \"content_id\" => { order: \"asc\" } }\n end" ]
[ "0.63921434", "0.61869264", "0.61537546", "0.6141651", "0.6085773", "0.60281", "0.600521", "0.60012716", "0.59593576", "0.59437484", "0.59166485", "0.5883935", "0.58783615", "0.5875312", "0.58738977", "0.58227134", "0.57979995", "0.5793642", "0.5790312", "0.57856715", "0.57832575", "0.5778534", "0.5765655", "0.5756358", "0.5727341", "0.57167023", "0.5712613", "0.57114005", "0.5685306", "0.56733304", "0.5658494", "0.5657554", "0.56537014", "0.56536865", "0.56536865", "0.56536865", "0.56458235", "0.56414014", "0.56339186", "0.5633329", "0.5633329", "0.560081", "0.559706", "0.5578556", "0.5564955", "0.5564955", "0.55612826", "0.55559397", "0.55523396", "0.55348444", "0.5533294", "0.5527761", "0.55254537", "0.5514455", "0.55144066", "0.54863536", "0.5486342", "0.54841", "0.5483526", "0.54795694", "0.5475218", "0.547296", "0.54722536", "0.5445936", "0.5443197", "0.5427834", "0.5426517", "0.54221267", "0.5412382", "0.5407699", "0.54021186", "0.5401413", "0.5389286", "0.538197", "0.53753436", "0.5370941", "0.53669673", "0.5366597", "0.53602463", "0.5360045", "0.5347059", "0.533397", "0.5331824", "0.5330142", "0.5328361", "0.53233355", "0.53189397", "0.53130007", "0.5312177", "0.53120077", "0.5309904", "0.5309106", "0.5306928", "0.52999675", "0.5299539", "0.52966094", "0.52957934", "0.5295289", "0.5293668", "0.52931017" ]
0.83023405
0
Sorts the records by LN, DESC
def sort_by_ln! @entries.sort! { |a,b| a.ln <=> b.ln } @entries.reverse! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort_entries; end", "def ja_sort\n [{ :created_at => :desc }]\n end", "def sort_by_sex_then_ln!\n @entries.sort! { |a,b| [a.sex, a.ln] <=> [b.sex, b.ln] }\n end", "def sort sortfield = :id, descending = false\n @sortfield = sortfield.to_sym\n reverse = descending ? -1 : 1\n @data = @data.compact.sort { |us1, us2|\n comp =\n if us1[@sortfield] && us2[@sortfield]\n us1[@sortfield] <=> us2[@sortfield]\n elsif us1[@sortfield]\n 1\n elsif us2[@sortfield]\n -1\n else\n 0\n end\n comp * reverse\n }\n end", "def sort_norm_data\n store.sort_norm_data!\n end", "def sort\n @pokers.sort.reverse\n end", "def descending\n swap(:startkey, :endkey) if query[:startkey] || query[:endkey]\n swap(:startkey_docid, :endkey_docid) if query[:startkey_docid] || query[:endkey_docid]\n\n update_query(:descending => true)\n end", "def sort_data_descending!(*sort_keys)\n self.sort_data!(false, sort_keys)\n end", "def sort_data\n store.sort_data!\n end", "def sort_by_most_recently_popular(sources)\n\t\tsorted = sources.sort_by do |source|\n\t\t\t(ONE_VOTE * source.rating) + source.created_at.to_i\n\t\tend.reverse\n\tend", "def sort_popular_jobs\n Application.group(:job).count.sort_by do |job|\n job[1]\n end.reverse\n end", "def sort_records(raw_records)\n records = raw_records.clone\n return records if records.size < 2\n (records.size - 2).downto(0) do |i|\n (0 .. i).each do |j|\n records[j], records[j + 1] = records[j + 1], records[j] if records[j].id.to_i < records[j + 1].id.to_i\n end\n end\n records\n end", "def sort_ranking\n @sorted_hash = @hash_ranking.sort_by { |_name, points| -points }\n @sorted_hash = @sorted_hash.first(10)\n @sorted_hash.map { |k, v| \"#{k}\\t#{v}\" }.join(\"\\n\")\n end", "def sort_snps\n @snps.sort!{|x,y| x.location <=> y.location}\n end", "def sort\n conditions = scope_condition\n list_items = order_by_position(conditions, :created_at.desc).to_a\n\n list_items.each_with_index do |list_item, index|\n list_item.set_my_position index + 1\n end\n end", "def sort\n conditions = scope_condition\n list_items = order_by_position(conditions, :created_at.desc).to_a\n\n list_items.each_with_index do |list_item, index|\n list_item.set_my_position index + 1\n end\n end", "def top_sort\n top_sort_visit([]).reverse\n end", "def get_top_news(start=0,count=TopNewsPerPage)\n numitems = $r.zcard(\"news.top\")\n news_ids = $r.zrevrange(\"news.top\",start,start+(count-1))\n result = get_news_by_id(news_ids,:update_rank => true)\n # Sort by rank before returning, since we adjusted ranks during iteration.\n return result.sort_by(&:rank), numitems\nend", "def sortByCountDecreasing\r\n @counts.sort_by { |k,v| v }.reverse\r\n end", "def s_idsort; det.link(:text, 'ID'); end", "def sort_descending(sort)\n self.query.sort = sort\n self.query.sort_descending = true\n self\n end", "def descending(*fields)\n clone.tap do |crit|\n setup_sort_options(crit.options) unless fields.first.nil?\n fields.flatten.each { |field| merge_options(crit.options[:sort], [ localize(field), :desc ]) }\n end\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 sort_results(results)\n case @metadata[:sort]\n when \"new\"\n results.sort_by do |c|\n [c.set.regular? ? 0 : 1, -c.release_date_i, c.default_sort_index]\n end\n when \"old\"\n results.sort_by do |c|\n [c.set.regular? ? 0 : 1, c.release_date_i, c.default_sort_index]\n end\n when \"newall\"\n results.sort_by do |c|\n [-c.release_date_i, c.default_sort_index]\n end\n when \"oldall\"\n results.sort_by do |c|\n [c.release_date_i, c.default_sort_index]\n end\n when \"cmc\"\n results.sort_by do |c|\n [c.cmc ? 0 : 1, -c.cmc.to_i, c.default_sort_index]\n end\n when \"pow\"\n results.sort_by do |c|\n [c.power ? 0 : 1, -c.power.to_i, c.default_sort_index]\n end\n when \"tou\"\n results.sort_by do |c|\n [c.toughness ? 0 : 1, -c.toughness.to_i, c.default_sort_index]\n end\n when \"rand\"\n results.sort_by do |c|\n [Digest::MD5.hexdigest(@query_string + c.name), c.default_sort_index]\n end\n when \"number\"\n results.sort_by do |c|\n [c.set.name, c.number.to_i, c.number, c.default_sort_index]\n end\n when \"color\"\n results.sort_by do |c|\n [COLOR_ORDER.fetch(c.colors), c.default_sort_index]\n end\n when \"ci\"\n results.sort_by do |c|\n [COLOR_ORDER.fetch(c.color_identity), c.default_sort_index]\n end\n when \"rarity\"\n results.sort_by do |c|\n [-c.rarity_code, c.default_sort_index]\n end\n else # \"name\" or unknown key\n results.sort_by(&:default_sort_index)\n end\n end", "def topn_by_downloads (keyinfo, n)\n topn_by_downloads = keyinfo.sort_by{ |x| x[:total_downloads] }.reverse.slice(0 .. n-1)\n top_table topn_by_downloads\nend", "def user_records\n @user_records = (view_context.filter_params[:sort].present?) ? user.records.reorder(\"#{view_context.parsed_current_sort.first} #{view_context.parsed_current_sort.last}\", view_context.secondary_sort) : user.records.reorder(created_at: :desc) \n end", "def __sort_pair__\n { first => Mongoid::Criteria::Translator.to_direction(last) }\n end", "def order_by_descending_change_count(lines)\n lines.sort do | one, another |\n one_count = churn_line_to_int(one)\n another_count = churn_line_to_int(another)\n - (one_count <=> another_count)\n end\nend", "def recent(n)\n\t \tin_order.endmost(n)\n\t end", "def sort_entries=(_arg0); end", "def sort_by_dob!\n @entries.sort! { |a,b| a.dob <=> b.dob }\n end", "def descending_order(n)\n n.to_s.chars.sort.reverse.join.to_i\nend", "def descending_order(n)\n sort_arr = n.to_s.split(\"\")\n sort_arr.sort.join.reverse.to_i\nend", "def sort_params; end", "def sort_params; end", "def by_relevance\n self.order(\"search_ranking DESC\")\n end", "def sort_desc(scoped, sort)\n sort ? Hash[scoped.sort_by { |_name, values| values.count }.reverse] : scoped\n end", "def descending_order(n)\n n.to_s.split('').sort.reverse.join.to_i\nend", "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 top_10_sorted\n\t\t\t\t\traw = notable_order_by_cvss_raw\n\t\t\t\t\tdata = Array.new\n\n\t\t\t\t\traw.each do |vuln|\n\t\t\t\t\t\trow = Array.new\n\t\t\t\t\t\tplugin_id = vuln[0]\n\t\t\t\t\t\tcount = vuln[1]\n\n\t\t\t\t\t\tname = scrub_plugin_name(Plugin.find_by_id(plugin_id).plugin_name)\n\n\t\t\t\t\t\trow.push(name)\n\t\t\t\t\t\trow.push(count)\n\t\t\t\t\t\tdata.push(row)\n\t\t\t\t\tend\n\n\t\t\t\t\tdata = data.sort do |a, b|\n\t\t\t\t\t\tb[1] <=> a[1]\n\t\t\t\t\tend\n\n\t\t\t\t\treturn data\n\t\t\t\tend", "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 to_rss(records)\n super(flatten_and_sort(records).last(records.size).reverse)\n end", "def sort_name\n sort_constituent\n end", "def sort_records(records)\n sort_order = order.map { |direction| [ direction.target, direction.operator == :asc ] }\n\n records.sort_by do |record|\n sort_order.map do |(property, ascending)|\n Sort.new(record_value(record, property), ascending)\n end\n end\n end", "def order_by_descending_change_count(changes)\n changes.sort do |a, b|\n - (a[1] <=> b[1])\n end\n end", "def search_queries_with_frequencies_sorted_descending\n @searches_grouped_by_frequency.to_a.sort{|a,b| b[1] <=> a[1]}\n end", "def index\n @rbs = Rb.all.order(l1: :asc, l2: :asc, l3: :asc)\n end", "def descending_order(n)\n n.to_s.split(\"\").sort.reverse.join.to_i\nend", "def index\n @rallies = Rally.includes(:rank_score).order('rank_scores.value desc').all.paginate(page: params[:page])\n end", "def descending_order(n)\n # n.to_s.chars.sort { |a, b| b <=> a }.join.to_i\n n.to_s\n .chars\n .sort { |a, b| b <=> a }\n .join\n .to_i\nend", "def index\n @news = News.all.order(priority: :desc, id: :desc)\n end", "def descending_order(n)\n\tsplit_up = n.to_s.chars.map(&:to_i)\n\tsorted = split_up.sort\n\tputs sorted.reverse.join.to_i\nend", "def sort_sql_helper(param)\n return param.gsub('_reverse',\" DESC\")\n end", "def descending_order(n)\n n.to_s.split('').sort.reverse.join('').to_i\nend", "def sort_using(xs, sidebar)\n # caching is possible but doesn't improve significantly the build times\n\n rank_lookup = rank_lookup_from_sidebar(sidebar)\n\n xs.sort {|x, y|\n # The default rank is very high so that pages that don't appear in the sidebar are put at the end\n rx = rank_lookup[x.url] || 10000\n ry = rank_lookup[y.url] || 10000\n\n rx <=> ry\n }\n\n end", "def sorted\n all.order(Arel.sql(%[ #{quoted_table_name}.\"recorded_at\" ASC, #{quoted_table_name}.\"hid\" ASC ]))\n end", "def lbSort _args\n \"lbSort _args;\" \n end", "def add_hierarchy_sort(solr_params)\n solr_params[:sort] = 'sort_ii asc' if %w[online_contents collection_context].include? blacklight_params[:view]\n solr_params\n end", "def sort_order\n 0\n end", "def sortby_callnum solr_parameters, user_parameters\n if user_parameters[:search_field] == 'call number'\n callnum_sortby = blacklight_config.sort_fields.values.select { |field| field.callnum_default == true }.first\n solr_parameters[:sort] = callnum_sortby.field\n end\n end", "def sort_param(log_param_name: 'time', mode: :desc)\n \"sort:!(#{escape(log_param_name)},#{mode})\"\n end", "def descending_order(n)\n n.to_s.split('').sort().reverse().join('').to_i\nend", "def tie_breaking_sort\n { \"content_id\" => { order: \"asc\" } }\n end", "def sort_times\n @links.each_value { |l| l.sort_times }\n end", "def sort(key, by: T.unsafe(nil), limit: T.unsafe(nil), get: T.unsafe(nil), order: T.unsafe(nil), store: T.unsafe(nil)); end", "def sorting\n @records = Record.all #Get existing records\n @sortType = params[:sortType] #Get parameters from the form on index\n @sortField = params[:sortField]\n\n @limit = params[:sortNum].to_i # params must be converted from string\n\n if @sortType == \"Decending\" # check if sort direction is decending\n case @sortField #check what header to sort by\n when \"id\" # when table header is ID sort by ID descending\n @sortedSet = Record.order(id: :desc).limit(@limit)\n when \"REF_DATE\"\n @sortedSet = Record.order(REF_DATE: :desc).limit(@limit)\n when \"GEO\"\n @sortedSet = Record.order(GEO: :desc).limit(@limit)\n when \"DGUID\"\n @sortedSet = Record.order(DGUID: :desc).limit(@limit)\n when \"Sex\"\n @sortedSet = Record.order(Sex: :desc).limit(@limit)\n when \"Age_group\"\n @sortedSet = Record.order(Age_group: :desc).limit(@limit)\n when \"Student_response\"\n @sortedSet = Record.order(Student_response: :desc).limit(@limit)\n when \"UOM\"\n @sortedSet = Record.order(UOM: :desc).limit(@limit)\n when \"UOM_ID\"\n @sortedSet = Record.order(UOM_ID: :desc).limit(@limit)\n when \"SCALAR_FACTOR\"\n @sortedSet = Record.order(SCALAR_FACTOR: :desc).limit(@limit)\n when \"SCALAR_ID\"\n @sortedSet = Record.order(SCALAR_ID: :desc).limit(@limit)\n when \"VECTOR\"\n @sortedSet = Record.order(VECTOR: :desc).limit(@limit)\n when \"COORDINATE\"\n @sortedSet = Record.order(COORDINATE: :desc).limit(@limit)\n when \"VALUE\"\n @sortedSet = Record.order(VALUE: :desc).limit(@limit)\n when \"STATUS\"\n @sortedSet = Record.order(STATUS: :desc).limit(@limit)\n when \"SYMBOL\"\n @sortedSet = Record.order(SYMBOL: :desc).limit(@limit)\n when \"TERMINATED\"\n @sortedSet = Record.order(TERMINATED: :desc).limit(@limit)\n when \"DECIMALS\"\n @sortedSet = Record.order(DECIMALS: :desc).limit(@limit)\n \n end # end case/when\n else # if not decending its ascending\n case @sortField # check header to sort by\n when \"id\" # when table header is ID sort by ID ascending\n @sortedSet = Record.order(id: :asc).limit(@limit)\n when \"REF_DATE\"\n @sortedSet = Record.order(REF_DATE: :asc).limit(@limit)\n when \"GEO\"\n @sortedSet = Record.order(GEO: :asc).limit(@limit)\n when \"DGUID\"\n @sortedSet = Record.order(DGUID: :asc).limit(@limit)\n when \"Sex\"\n @sortedSet = Record.order(Sex: :asc).limit(@limit)\n when \"Age_group\"\n @sortedSet = Record.order(Age_group: :asc).limit(@limit)\n when \"Student_response\"\n @sortedSet = Record.order(Student_response: :asc).limit(@limit)\n when \"UOM\"\n @sortedSet = Record.order(UOM: :asc).limit(@limit)\n when \"UOM_ID\"\n @sortedSet = Record.order(UOM_ID: :asc).limit(@limit)\n when \"SCALAR_FACTOR\"\n @sortedSet = Record.order(SCALAR_FACTOR: :asc).limit(@limit)\n when \"SCALAR_ID\"\n @sortedSet = Record.order(SCALAR_ID: :asc).limit(@limit)\n when \"VECTOR\"\n @sortedSet = Record.order(VECTOR: :asc).limit(@limit)\n when \"COORDINATE\"\n @sortedSet = Record.order(COORDINATE: :asc).limit(@limit)\n when \"VALUE\"\n @sortedSet = Record.order(VALUE: :asc).limit(@limit)\n when \"STATUS\"\n @sortedSet = Record.order(STATUS: :asc).limit(@limit)\n when \"SYMBOL\"\n @sortedSet = Record.order(SYMBOL: :asc).limit(@limit)\n when \"TERMINATED\"\n @sortedSet = Record.order(TERMINATED: :asc).limit(@limit)\n when \"DECIMALS\"\n @sortedSet = Record.order(DECIMALS: :asc).limit(@limit) \n end\n end\n \n end", "def descending_order(n)\n n.to_s.chars.map(&:to_i).sort.reverse.join.to_i\nend", "def sort_with!(field, direction)\n return self if 'usefulness' == field && 'desc' == direction\n return self.reverse! if 'usefulness' == field && 'asc' == direction\n if 'asc' == direction\n self.sort! { |review1, review2| review1[field] <=> review2[field]}\n elsif 'desc' == direction\n self.sort! { |review1, review2| review2[field] <=> review1[field]}\n end\n end", "def descending_order(n)\n n.digits.sort.reverse.join.to_i\nend", "def sort(table_name, list, sort_by, order, per_page, default)\r\n\r\n if table_name.has_attribute?(sort_by) && (order == \"asc\" || order == \"desc\")\r\n list = list.sort_by{|item| item[sort_by].to_s.downcase}\r\n if order == \"desc\"\r\n list = list.reverse\r\n end\r\n list \r\n else\r\n # default case\r\n list.sort_by{|item| item[default].downcase}\r\n end\r\n\r\n end", "def bigSorting(unsorted)\n\nend", "def sort_by_last_name\n sorted = final_array.sort_by {|k,v| k[:last_name] }\n hash_values = sorted.map {|element| element.values}.reverse\n with_line_breaks = add_line_breaks(hash_values)\n with_line_breaks.unshift(\"Output 3:\\n\")\n with_line_breaks.join(\", \").gsub(/,/, '').gsub( /\\n\\s+/, \"\\n\" )\nend", "def sort_by_tag_count\n end", "def bubble_sort_rec(&prc)\n end", "def sort_by_price_usd\n coins.sort_by { |coin| coin.price_usd }.reverse\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 descending_order(n)\n n.to_s.split(\"\").sort.reverse.join(\"\").to_i\nend", "def descending_order(n)\n n.to_s.split(\"\").sort do |a, b|\n if n.positive?\n b <=> a\n else\n # Sorts for the negative number closest to 0.\n a <=> b\n end\n end.join(\"\").to_i\nend", "def sort_by_popularity(dir='DESC')\n query = self.scoped.joins(\"LEFT OUTER JOIN punches ON punches.punchable_id = #{self.to_s.tableize}.id AND punches.punchable_type = '#{self.to_s}'\")\n query = query.group(:id)\n query.reorder(\"SUM(punches.hits) #{dir}\")\n end", "def rev_order\n\t \torder(created_at: :desc)\n\t end", "def sort_using_rank\n score[1]\n end", "def natural_sort(list)\n natural_sort_by(list, &:to_s)\n end", "def sort_leafs!\n leafs.sort! { |a, b| a.position.to_i <=> b.position.to_i }\n end", "def index_sort_order\n @query = {}\n @query['sort_key'] = params['sort_key'] unless params['sort_key'].blank?\n\n if @query['sort_key']&.starts_with?('-')\n \"#{@query['sort_key'].delete_prefix('-')} DESC\"\n elsif @query['sort_key'].present?\n \"#{@query['sort_key']} ASC\"\n else\n 'updated_at DESC'\n end\n end", "def all_sorted\n @data[:pages].sort_by{|k, v| -v}\n end", "def stable_sort_by(list); end", "def sort_floor_plans\n if presentable.available_floor_plans.in_group(group).map(&:position).any?{ |e| e.nil? }\n @plans = presentable.available_floor_plans.in_group(group).\n sort{|a,b| NaturalSort.comparator(a.name, b.name)}\n else\n @plans = presentable.available_floor_plans.in_group(group).order(:position)\n end\n end", "def sort_it(list_, n)\n # Your code goes here\nend", "def descending_order(n)\n n.digits.sort().reverse.join.to_i\nend", "def index\n @npcs = Npc.order(sort_column + ' ' + sort_direction).all\n end", "def sort_docs_by_key!; end", "def sort\n @sort ||= Vidibus::Words.sort_by_occurrence(list)\n end", "def inverse\n OrderBy.new(@field, @dir == :asc ? :desc : :asc)\n end", "def sort_abschnitte_and_umschlaege\n abschnitt_umschlag_list = []\n # Hilfsmethode, baut einen nach Orten sortierten Hash auf.\n ort_to_detail = sort_abschnitte_and_umschlaege_by_ort\n File.open(\"log/transport.log\",\"w\"){|f| f.puts \"Ort to detail #{ort_to_detail}\" }\n unless self.start_anlage.nil?\n if self.start_anlage.ort\n ort_aktuell = self.start_anlage.ort\n if ort_aktuell.nil? || ort_to_detail[ort_aktuell.id].nil?\n ort_aktuell = abschnitt_only_start_ort(ort_to_detail.keys) \n end \n counter = 0\n while not (ort_aktuell.nil? || ort_to_detail.empty? || counter > 100)\n counter += 1\n next_ort = nil\n ort_aktuell_id = ort_aktuell.nil? ? 0 : ort_aktuell.id \n unless ort_to_detail[ort_aktuell_id].nil?\n ort_to_detail[ort_aktuell_id].each do |abschnitt_umschlag|\n File.open(\"log/transport.log\",\"a\"){|f| f.puts abschnitt_umschlag.attributes }\n abschnitt_umschlag_list << abschnitt_umschlag\n next_ort = abschnitt_umschlag.end_ort if abschnitt_umschlag.kind_of? Transportabschnitt \n end\n ort_to_detail.delete(ort_aktuell_id) \n ort_aktuell = next_ort\n end\n end \n # Rest nach Datum sortieren\n unless ort_to_detail.empty?\n File.open(\"log/transport.log\",\"a\"){|f| f.puts \"Rest nach Datum\" }\n abschnitt_umschlag_list = abschnitt_umschlag_list.concat(sort_abschnitte_and_umschlaege_by_date(ort_to_detail.values.flatten))\n end\n else \n #File.open(\"log/transport.log\",\"a\"){|f| f.puts \"Alles nach Datum\" }\n abschnitt_umschlag_list = abschnitt_umschlag_list.concat(sort_abschnitte_and_umschlaege_by_date(ort_to_detail.values.flatten))\n end \n end\n #File.open(\"log/transport.log\",\"a\"){|f| f.puts \"Transport #{id}: #{abschnitt_umschlag_list.to_s}\" }\n abschnitt_umschlag_list\n end", "def check_sort_options #:nodoc:\r\n table_name = @tables.first[1]\r\n return if session[table_name][:sort].nil? || @records.class != Mongoid::Criteria\r\n\r\n sort, direction = session[table_name][:sort].split(' ')\r\n @records = @records.order_by( sort => direction.to_i )\r\nend", "def sort_by_high\n data_sort_by_high = load_data.sort{ |x,y| y[2] <=> x[2] }\n data_sort_by_high.insert(0, data[0])\n end", "def articles_asc\n articles.sort_by(&:published)\n end", "def sort_fields\n Blacklight.config[:sort_fields]\n end", "def sort_by_popularity\n @song_data = @song_data.sort_by {|x| [-x[:plays], x[:index]] }\n end", "def sort\n @items.sort { |x,y| x.rank <=> y.rank }\n end" ]
[ "0.62844336", "0.6161671", "0.61378556", "0.61363196", "0.5888436", "0.5872766", "0.584869", "0.579978", "0.5787683", "0.5783197", "0.5757387", "0.5727465", "0.5717788", "0.5716454", "0.57148445", "0.57148445", "0.5711713", "0.57022476", "0.56722003", "0.5665171", "0.56640685", "0.5650016", "0.56446964", "0.5640906", "0.56033105", "0.5596751", "0.55891377", "0.5588184", "0.5574521", "0.55724406", "0.55645436", "0.5557551", "0.5548592", "0.5546108", "0.5546108", "0.5540212", "0.5527175", "0.5526448", "0.5522756", "0.5522589", "0.5517479", "0.55170405", "0.5505961", "0.55019945", "0.54844564", "0.547791", "0.54736596", "0.5468962", "0.54656535", "0.54650617", "0.546096", "0.5442492", "0.5432293", "0.5430221", "0.5428323", "0.5424084", "0.54236203", "0.5415078", "0.5414777", "0.54027396", "0.5401006", "0.54001546", "0.53989345", "0.5397214", "0.5395713", "0.53914124", "0.53912103", "0.53893006", "0.5377148", "0.53762776", "0.5375116", "0.5372209", "0.5372085", "0.53707814", "0.5367795", "0.5367773", "0.53646487", "0.5362151", "0.5360612", "0.53523576", "0.5351981", "0.53493184", "0.5337225", "0.53312004", "0.53286403", "0.5328555", "0.5324396", "0.53222513", "0.5316484", "0.5316138", "0.5315289", "0.5312048", "0.5296137", "0.5283115", "0.52809805", "0.5280113", "0.5268296", "0.5264901", "0.52620625", "0.5261833" ]
0.7389627
0
Sorts the records by sex (female > male), then by ln, ASC
def sort_by_sex_then_ln! @entries.sort! { |a,b| [a.sex, a.ln] <=> [b.sex, b.ln] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort_by_ln!\n @entries.sort! { |a,b| a.ln <=> b.ln }\n @entries.reverse!\n end", "def sort_by_gender_then_last_name \n sorted = final_array.sort_by {|k,v| [k[:gender], k[:last_name]] }\n hash_values = sorted.map {|element| element.values}\n with_line_breaks = add_line_breaks(hash_values)\n with_line_breaks.unshift(\"Output 1:\\n\")\n with_line_breaks.join(\", \").gsub(/,/, '').gsub( /\\n\\s+/, \"\\n\" )\nend", "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 final_name_info\n sort_by_gender_then_last_name + \"\\n\" + sort_by_birthday_then_last_name+ \"\\n\" + sort_by_last_name\nend", "def sorted_by_age(people)\nend", "def sort\n @roster.each do |grade, studen_name|\n studen_name.sort!\n end\n end", "def sort_by_dob!\n @entries.sort! { |a,b| a.dob <=> b.dob }\n end", "def sort\n sorted = roster.sort_by { |k| k[:grade]}\n sorted.each do |x|\n x[:students].sort_by! { |v| v }\n end\n puts sorted\n end", "def students\n @students = Person.find(:all, :conditions => {:position => 'Graduate Student'})\n @students.sort! {|a, b| a.last_name.upcase <=> b.last_name.upcase}\n \n respond_to do |format|\n format.html # students.html.erb\n format.xml { render :xml => nil }\n end\n end", "def sort_members(members)\n members.sort do |a,b|\n avis = VISIBILITY_VALUE[a.visibility]\n bvis = VISIBILITY_VALUE[b.visibility]\n (avis == bvis) ? a.name <=> b.name : avis <=> bvis\n end\n end", "def sort_grosstotal\n BoxOffice::Movie.all.map( &:to_s ).sort {|a,b| b.grosstotal <=> a.grosstotal}.each.with_index(1) do |movie, index|\n puts \"#{movie.title}\"\n end\n end", "def sort_employees(employees, argument)\n employees.sort_by do |employee|\n case argument\n when 'f' then employee.first_name\n when 'l' then employee.last_name\n end\n end\nend", "def alphabetailc_order\n @sorting_order = @data[\"prizes\"].sort_by{|a| a[\"year\"]}.group_by{|a| puts a[\"laureates\"].sort_by{|k| k[\"firstname\"]}}\n #@sorting_order = @data[\"prizes\"].sort_by { |a | [a[\"year\"],a[\"category\"]] }.sort_by{|a|}\n render :json => @sorting_order\n end", "def sorted_info\t\n\t\t$employee_info.values.sort_by { |hash| hash[:last_name]}\n\tend", "def alphabetical_list(students)\n sorted_array = students.sort_by {|person| person[:last_name].downcase}\n sorted_array.each do |student|\n # puts \"#{student[:first_name]} #{student[:last_name]} -- #{student[:cohort]}\"\n end\nend", "def sort_name\n sort_constituent\n end", "def names_by_cohort\n @students.sort_by { |student| student[:cohort] }\nend", "def sort_records(records)\n sort_order = order.map { |direction| [ direction.target, direction.operator == :asc ] }\n\n records.sort_by do |record|\n sort_order.map do |(property, ascending)|\n Sort.new(record_value(record, property), ascending)\n end\n end\n end", "def sort_entries; end", "def sort\n self.roster.each do |grade, students|\n students.sort!\n end\n self.roster\n end", "def index\n @students = Student.order(:family_name).order(:preferred_name).order(:given_name)\n end", "def sort_by_birthday_then_last_name\n sorted = final_array.sort_by {|k,v| [k[:birth_date][-2..-1], k[:last_name]] }\n hash_values = sorted.map {|element| element.values}\n with_line_breaks = add_line_breaks(hash_values)\n with_line_breaks.unshift(\"Output 2:\\n\")\n with_line_breaks.join(\", \").gsub(/,/, '').gsub( /\\n\\s+/, \"\\n\" )\nend", "def ordered_by_qualifications (collection)\n collection.sort_by {|x| [x[:years_of_experience], x[:github_points]]}.reverse!\nend", "def sort_children\n @children.sort_by!(&:name)\n @children.map(&:sort_children)\n end", "def ordered_by_qualifications(candidates)\n candidates.sort {|candidate1, candidate2| candidate1[:years_of_experience] == candidate2[:years_of_experience]? candidate2[:github_points] <=> candidate1[:github_points] : candidate2[:years_of_experience] <=> candidate1[:years_of_experience]}\nend", "def sort_fields(fields)\n fields.sort {|a,b| (COLUMN_SORTING_MAP[a] || a).to_s <=> (COLUMN_SORTING_MAP[b] || b).to_s }\n end", "def sort_tenants_by_age tenants\n return tenants.sort_by { |tenant| tenant.age }\n end", "def ordered_by_qualifications(candidates)\n if [:years_of_experience] == [:years_of_experience]\n @candidates.sort_by { |experience| experience[:years_of_experience] }.reverse\n else\n @candidates.sort_by { |github| github[:github_points]}.reverse\n end\nend", "def tree_sort_order\n if !tree_use_rational_numbers\n \"#{tree_order} #{tree_depth_field}\"\n else\n tree_nv_div_dv_field.asc\n end\n end", "def sort_by_fitness\n sort_by { |individual| individual.fitness }\n end", "def sort!\r\n @tabs.sort! { |x,y| x.name <=> y.name }\r\n end", "def sort_column\n super \"User\", \"lastname\"\n end", "def sort_column\n super \"User\", \"lastname\"\n end", "def sort_column\n super \"User\", \"lastname\"\n end", "def proefssorted\n \tproefs.order(:position)\n end", "def sort_name\n n = \"#{self.last_name}, #{self.first_name}\"\n if self.middle_name.present?\n n += \" #{self.middle_name}\"\n end\n n\n end", "def ordered_by_qualifications(candidates)\n\n candidates.sort_by{ |candidate| [-candidate[:years_of_experience], -candidate[:github_points]] }\n\nend", "def sort_methods\n [\n 'score desc',\n 'authors_sort asc',\n 'authors_sort desc',\n 'title_sort asc',\n 'title_sort desc',\n 'journal_sort asc',\n 'journal_sort desc',\n 'year_sort asc',\n 'year_sort desc'\n ]\n end", "def apply_sorting(relation)\n relation.order(@q.sorting.to_sql)\n end", "def ordered_by_qualifications(candidates)\n candidates.sort_by{ |candidate| [candidate[:years_of_experience], candidate[:github_points]] }\n .reverse\n\nend", "def ordered_by_qualifications(candidates)\n sortedCandidates = candidates.sort_by! { |candidate| [candidate[:years_of_experience], candidate[:github_points]] }\n return sortedCandidates.reverse! \nend", "def sort_by_model_then_year\n @garage.sort_by{\n |car1, car2| (car1.class.to_s, car1.model_year) <=> (car2.class.to_s, car2.model_year)\n }\n end", "def sort_by_most_recently_popular(experiences)\n\t\tsorted = experiences.sort_by do |experience|\n\t\t\t(ONE_VOTE * experience.rating) + experience.created_at.to_i\n\t\tend.reverse\n\tend", "def alumni\n @alumni = Person.find(:all, :conditions => {:position => 'Alumnus'})\n \n @alumni.sort! {|a, b| a.last_name.upcase <=> b.last_name.upcase}\n\n respond_to do |format|\n format.html # alumni.html.erb\n format.xml { render :xml => nil }\n end\n end", "def sort\n super { |x, y| x.file_name <=> y.file_name }\n end", "def sort_children\n @children.sort! do |a, b|\n if (a.leaf? && b.leaf?) || (!a.leaf? && !b.leaf?)\n a.name <=> b.name\n elsif a.leaf? && !b.leaf?\n -1\n else\n 1\n end\n end\n @children.each(&:sort_children)\n end", "def ordered_by_qualifications(candidates)\n candidates.sort_by {|candidate| [-candidate[:years_of_experience], -candidate[:github_points]]}\nend", "def show\n @blessing = Blessing.find(params[:id])\n\n @sort = params[:sort]\n @sort=\"id\" if @sort==nil\n @order = params[:order]\n @order=\"normal\" if @order==nil\n #cookies.permanent[:gender] = @gender\n \n @[email protected]\n if @sort=='no'\n @participants.sort! { |a,b| a.no <=> b.no }\n elsif @sort=='fname'\n @participants.sort! { |a,b| a.fname <=> b.fname }\n elsif @sort=='mname'\n @participants.sort! { |a,b| a.mname <=> b.mname }\n elsif @sort=='lname'\n @participants.sort! { |a,b| a.lname <=> b.lname }\n elsif @sort=='sex'\n @[email protected]_by{|x| [x.sex, x.donation, x.age ]}.reverse\n elsif @sort=='age'\n @[email protected]_by{|x| [x.age, x.donation ]}.reverse\n elsif @sort=='donation'\n # @[email protected]_by{|x| [x.donation, x.age ]}.reverse\n @participants.sort! { |a,b| b.donation <=> a.donation }\n \n else \n @[email protected]_by{|x| [x.sex, x.donation, x.age ]}.reverse\n end\n \n if @order=='reverse'\n @[email protected]\n end \n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blessing }\n# format.csv\n #format.xls\n format.xlsx \n end\n end", "def sort_by_accession_number(model)\n return unless model.column_names.include?(\"accession_number\")\n\n \"#{model.table_name}.accession_number ASC\"\n end", "def sort_by_surname(input, fullname_field)\n input.sort_by { |i| i[fullname_field].downcase.split(/ /)[1] }\n end", "def sort_by_surname(input, fullname_field)\n input.sort_by { |i| i[fullname_field].downcase.split(/ /)[1] }\n end", "def test_sort_attr\n ou = []\n @@conn.search( @@naming_context, LDAP::LDAP_SCOPE_ONELEVEL,\n '(ou=*)' ) do |x|\n ou << x['ou']\n end\n ou.flatten!\n\n sorted_ou = []\n @@conn.search( @@naming_context, LDAP::LDAP_SCOPE_ONELEVEL,\n '(ou=*)', nil, nil, 0, 0, 'ou' ) do |x|\n sorted_ou << x['ou']\n end\n sorted_ou.flatten!\n\n assert_not_equal( ou, sorted_ou )\n assert_equal( ou.sort, sorted_ou )\n end", "def stories_sorted_by_growth_rate\n stories = @stories.values.sort_by do |story|\n story.growth_rate\n end\n stories.reverse\n end", "def elements_sorted_by_experience\n collection.sort_by{|person| person[:years_experience]}\n end", "def sort sortfield = :id, descending = false\n @sortfield = sortfield.to_sym\n reverse = descending ? -1 : 1\n @data = @data.compact.sort { |us1, us2|\n comp =\n if us1[@sortfield] && us2[@sortfield]\n us1[@sortfield] <=> us2[@sortfield]\n elsif us1[@sortfield]\n 1\n elsif us2[@sortfield]\n -1\n else\n 0\n end\n comp * reverse\n }\n end", "def ordered_by_qualifications(candidates)\n myArray = candidates\n #first sort by github points\n myArray.sort! { |a, b| a[:github_points] <=> b[:github_points] }\n #sort by experience\n myArray.sort! { |a, b| a[:years_of_experience] <=> b[:years_of_experience] }\n\n return myArray\nend", "def sort(table_name, list, sort_by, order, per_page, default)\r\n\r\n if table_name.has_attribute?(sort_by) && (order == \"asc\" || order == \"desc\")\r\n list = list.sort_by{|item| item[sort_by].to_s.downcase}\r\n if order == \"desc\"\r\n list = list.reverse\r\n end\r\n list \r\n else\r\n # default case\r\n list.sort_by{|item| item[default].downcase}\r\n end\r\n\r\n end", "def sort_students(students, comparator)\n students.sort do |x,y|\n comparator.call(x) <=> comparator.call(y)\n end\nend", "def sort_input(input, property, order); end", "def sort_order # rubocop:disable Metrics/AbcSize, Metrics/MethodLength\n col = sort_column\n # do a case-insensitive sort if we are sort on last name\n col = \"lower(#{col})\" if col.include?('last_name')\n return Arel.sql(\"#{col} #{sort_direction}\") unless col.include?('enumerations')\n\n klass, method = col.split('.')\n values = klass.singularize.capitalize.constantize.send(method.intern)\n .order(Arel.sql(\"value #{sort_direction} \")).pluck('value')\n order_query = values.each_with_index.inject(+'CASE ') do |memo, (val, i)| # rubocop:disable Style/EachWithObject\n memo << \"WHEN( enumerations.value = '#{val}') THEN #{i} \"\n memo\n end\n Arel.sql(\"#{order_query} ELSE #{values.length} END\")\n end", "def print_student_list\n @students.sort_by! { |hash| hash[:cohort] }\n @students.each.with_index(1) do |student, index|\n puts \"#{index}. #{student[:name]} (#{student[:cohort]} cohort)\".center(100)\n end\nend", "def default_sort\n 'name asc'\n end", "def sort_ranking\n @sorted_hash = @hash_ranking.sort_by { |_name, points| -points }\n @sorted_hash = @sorted_hash.first(10)\n @sorted_hash.map { |k, v| \"#{k}\\t#{v}\" }.join(\"\\n\")\n end", "def ordered_by_qualifications(candidates)\n ordered_by_qualification = [] #creates an empty array for the candidates\n years_of_experience = candidates.sort { |a, b| [a[:years_of_experience], a[:github_points]] <=> [b[:years_of_experience], b[:github_points]] }\n ordered_by_qualification << years_of_experience.reverse\n return ordered_by_qualification\nend", "def sort\n # pp @paren_array.map{|paren| paren.offset}\n @paren_array.sort{|x, y| x.offset <=> y.offset}.each_with_index do | paren, i |\n # puts \"$$_#{i+1} offset:#{paren.offset}\"\n refer_name = \"$$_#{i+1}\"\n @paren_hash[refer_name] = paren # parenthesis number from 1\n paren.set_refer_name(refer_name)\n end\n end", "def sort!\n @tabs.sort! { |x,y| x.text <=> y.text }\n end", "def sort\n sorted_list = {}\n @roster.each do |grade, student|\n sorted_list[grade] = student.sort\n end\n return sorted_list\n end", "def sort\r\n @roster.each do |key, value|\r\n value.sort!\r\n end\r\n end", "def sort_leafs!\n leafs.sort! { |a, b| a.position.to_i <=> b.position.to_i }\n end", "def ordered_by_qualifications(candiates)\n # Candidates with the most experience are at the top\n return candiates.sort_by { | obj | [obj[:years_of_experience], obj[:github_points]] }\n # return candiates.sort! { |a, b| b[:years_of_experience] <=> a[:years_of_experience] }\n\n # return candiates.sort_by {|:years_of_experience, :github_points|[ :github_points, :years_of_experience]}\n\n # return candiates.sort { | a, b | }\n # array.sort { |a,b| [ a[1], a[0] ] <=> [ b[1], b[0] ] }\n\n\n # For Candidates that have the same years of experience, \n #they are further sorted by their number of Github points (highest first)\nend", "def sortme( names )\n names.sort\nend", "def sort_teams_and_adjs\n @teams.sort! { |a,b| b.calc_rank <=> a.calc_rank }\n @adjs.sort! { |a,b| b.score <=> a.score }\n\n #@teams.sort! { |a,b| b.score <=> a.score } #allows sorting by score only\n #expression is flipped in terms of a and b\n #therefore we have decending in teams by score\n end", "def sort\n sorted = {}\n roster.each do |grade, students|\n sorted[grade] = students.sort\n end\n sorted\n end", "def sort\n sorted = {}\n roster.each do |grade, students|\n sorted[grade] = students.sort\n end\n sorted\n end", "def sort\n sorted = {}\n roster.each do |grade, students|\n sorted[grade] = students.sort\n end\n sorted\n end", "def sort_percentages\n @_sort_percentages ||= percentages.sort { |a, b| b.last <=> a.last }\n end", "def sort_by_balance!\n self.sort! do |a, b|\n a.balance <=> b.balance\n end\n end", "def sort_by_display_name(object_array)\n object_array.sort { |x,y| \n xdn = x[\"display_name_display\"]\n ydn = y[\"display_name_display\"]\n if (xdn && ydn)\n if (xdn.is_a?(Array))\n xdn = xdn.first\n end\n if (ydn.is_a?(Array))\n ydn = ydn.first\n end\n xdn <=> ydn\n elsif xdn\n -1\n elsif ydn\n 1\n else # both nil\n 0\n end\n }\n end", "def sort_files!; end", "def sort\n @items.sort { |x,y| x.rank <=> y.rank }\n end", "def sort_group_scores(groups, attr)\n groups\n .map(&:group_scores).flatten # collect all group scores\n .sort_by(&attr).reverse\n end", "def get_data2\n\tdata2 = File.read(\"mockchallenge2.txt\")\n\tarr = []\n\tsplit = data2.each_line { |line| arr << line.split(\", \") }\n\tgender = arr.sort_by { |x| x[2] }\n\tmarr = []\n\tfarr = []\n\tgender.each { |x| if x[2] == \"Male\" then marr << x else farr << x end }\n\tsortedmarr = marr.sort_by { |x| x[0] }\n\tsortedfarr = farr.sort_by { |x| x[0] }\n\tanswer = sortedfarr << sortedmarr\n\tprint answer\n\t\nend", "def sort_data\n store.sort_data!\n end", "def ordered_by_qualifications(candidates)\n\n return @candidates.sort_by{ |candidate| [candidate[:years_of_experience], candidate[:github_points]] }\n\nend", "def sort\n sorted = {}\n \n roster.each do |grades, students|\n sorted[grades] = students.sort\n end\n sorted\n # binding.pr\n end", "def ja_sort\n [{ :created_at => :desc }]\n end", "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\nstudent_hash = {}\n @roster.each do |grade, students|\nstudent_hash[grade] = students.sort\n end\n student_hash\nend", "def sort_name\n @ole.SortName\n end", "def sort_by_last_name\n sorted = final_array.sort_by {|k,v| k[:last_name] }\n hash_values = sorted.map {|element| element.values}.reverse\n with_line_breaks = add_line_breaks(hash_values)\n with_line_breaks.unshift(\"Output 3:\\n\")\n with_line_breaks.join(\", \").gsub(/,/, '').gsub( /\\n\\s+/, \"\\n\" )\nend", "def sorting_file\n a = File.readlines(file_name)\n a.sort do |x,y|\n x.downcase <=> y.downcase\n end\n end", "def ordered_by_qualifications(candidates)\n begin\n sorted = candidates.sort_by { |candidate| [candidate[:years_of_experience], candidate[:github_points]] }\n sorted.reverse!\n rescue\n puts \"There must be a years of experience and github points key.\"\n end\nend", "def sortme(names)\n names.sort\nend", "def display_stories stories\n #Double the score for each title with \"cat\" or \"dog\" in the title.\n cat_dog(stories)\n\n stories.sort_by! { |story| story[:score] }\n\n stories.reverse!\n\n stories.each do |story|\n # \"Title: title, Category: category, Upvotes: score\"\n puts \"Title: #{story[:title]}, Category: #{story[:category]}, Upvotes: (#{story[:score]})\"\n end\nend", "def studies_order\n order = sortable_column_order do |column, direction|\n case column\n when \"name\"\n \"LOWER(studies.name) #{direction}\"\n when \"active\", \"public\", \"promoted\"\n \"studies.#{column} #{direction}\"\n else\n 'LOWER(studies.name) ASC'\n end\n end\n end", "def sort_my_list\n @tracks.clear\n @artists.clear\n @genres.clear\n @user_list.each do |item|\n @tracks << item['id'] if item['type'] == 'track'\n @artists << item['id'] if item['type'] == 'artist'\n @genres << item['name'].downcase if item['type'] == 'genre'\n end\n end", "def sortme( names )\n names.sort\nend", "def sortme( names )\n names.sort\nend", "def sort_by_alg_header(algs); end" ]
[ "0.6245048", "0.61611944", "0.6150194", "0.6099462", "0.6033164", "0.5955961", "0.5931184", "0.5784812", "0.57658637", "0.5750996", "0.57198244", "0.5713558", "0.57113975", "0.571085", "0.56654686", "0.56370765", "0.5619122", "0.56006646", "0.5599366", "0.5567647", "0.5562838", "0.5557747", "0.55304635", "0.5501383", "0.54933214", "0.5490142", "0.5474076", "0.54528", "0.54430723", "0.5420248", "0.5419439", "0.541471", "0.5406351", "0.5406351", "0.5406351", "0.5406118", "0.5399485", "0.5369478", "0.5353505", "0.5349719", "0.53437656", "0.5329285", "0.53230816", "0.53197485", "0.5314118", "0.53108484", "0.530089", "0.52909034", "0.5280383", "0.5270572", "0.5269765", "0.5269765", "0.52523494", "0.52512676", "0.5246511", "0.5238075", "0.52279943", "0.5225495", "0.5224078", "0.5220861", "0.5219681", "0.52039874", "0.5201744", "0.51907593", "0.5180533", "0.5174986", "0.51577693", "0.51570946", "0.5144652", "0.5144239", "0.5143016", "0.5134196", "0.5130103", "0.5128206", "0.51273316", "0.51273316", "0.51260966", "0.5120667", "0.5120063", "0.5118633", "0.51071906", "0.51033694", "0.50971293", "0.5096868", "0.50932026", "0.5090819", "0.50860137", "0.50825846", "0.50806296", "0.5073868", "0.5070837", "0.5069817", "0.5062599", "0.50602764", "0.5059318", "0.5047022", "0.5043486", "0.5042554", "0.5042554", "0.50378674" ]
0.8604584
0
Formats the contents of the data structure to be output to the screen.
def to_s lines = [] @entries.each do |e| # I would prefer to use e.dob.strftime("%m/%d/%Y") here, but can't find an # easy way to ditch the leading zeros for months/days < 10...so we have this ugliness lines << %{#{e.ln} #{e.fn} #{e.sex} #{e.dob.month}/#{e.dob.day}/#{e.dob.year} #{e.fav_color}\n} end lines.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format\n output = @sum.to_s\n\n if @verbose\n @raw.each do |h|\n @display << \"#{h.keys[0]}:#{h.values[0]} \"\n end\n\n output << \" -- #{@display.strip}\"\n end\n\n output\n end", "def format data\n data\n end", "def format\n text = \"[#{name}]\\n\"\n @entries.each do |entry|\n if entry.is_a?(Array)\n key, value = entry\n text << \"#{key}=#{value}\\n\" unless value.nil?\n else\n text << entry\n end\n end\n text\n end", "def format; end", "def format; end", "def format; end", "def format; end", "def format; end", "def format; end", "def format; end", "def format; end", "def print_contents\n\t\tputs \"Artist: %s\" % [@artist]\n\t\tputs \"Album: %s\" % [@title]\n\t\tputs \"Released: %s\" % [@year]\n\n\t\tif @cd_count > 0\n\t\tputs \"CD(%d): %s\" % [@cd_count, @cd_id]\n\t\tend\n\n\t\tif @tape_count > 0\n\t\tputs \"Tape(%d): %s\" % [@tape_count, @tape_id]\n\t\tend\n\n\t\tif @vinyl_count > 0\n\t\tputs \"Vinyl(%d): %s\" % [@vinyl_count, @vinyl_id]\n\t\tend\n\n\tend", "def format!; end", "def formatter; end", "def formatter; end", "def formatter; end", "def output(data = {}, indent = 0)\n case @options['format']\n when 'json'\n puts JSON.pretty_generate(data)\n when 'yaml'\n puts data.to_yaml\n else\n # rubocop:disable Metrics/BlockNesting\n if data.class == Hash\n data.each do |k, v|\n if v.class == Hash || v.class == Array\n puts \"#{' ' * indent}#{k.nil? ? 'nil' : k}:\"\n output(v, indent + 2)\n else\n puts \"#{' ' * indent}#{k.nil? ? 'nil' : k}: #{v.nil? ? 'nil' : v}\"\n end\n end\n elsif data.class == Array\n data.each do |d|\n if d.class == Hash || d.class == Array\n output(d, indent + 2)\n else\n puts \"#{' ' * indent}#{d.nil? ? 'nil' : d}\"\n end\n end\n puts \"\\nTotal: #{data.size}\" if indent < 1\n else\n puts \"#{' ' * indent}#{data.nil? ? 'nil' : data}\"\n end\n # rubocop:enable Metrics/BlockNesting\n end\n end", "def display!\n escaped = self.map(&:to_json)\n puts(\"[\" + escaped.join(\",\") + \"],\\n\\n\") || $stdout.flush\n self.clear\n end", "def _deep_output(io, obj, depth: 0)\n if obj.is_a? Hash\n obj.each do |k, v|\n io.print ' ' * depth\n io.puts k.to_s\n _deep_output(io, v, depth: depth+1)\n end\n else\n obj.each do |array|\n key = array[0]\n title = _adjust(array[1])\n text = array[2]\n io.print ' ' * depth\n io.print ColorUtils.color(key, title)\n io.print ' '\n io.puts text\n end\n end\n end", "def formatStruct(theLines)\n\t# TODO\nend", "def print\n\t\t\tself.each do |item|\n\t\t\t\titem.p( @colsizes, @align, @padding )\n\t\t\tend\n\t\tend", "def display_data\n\t\t\t\"#{@model} #{@color} #{@horsepower} #{@year} #{@brand} #{@mpg}\"\n\t\tend", "def render\n buffer = []\n _guess_col_widths\n rows = @list.size.to_s.length\n @rows = rows\n _prepare_format\n \n str = \"\"\n if @numbering\n str = \" \"*(rows+1)+@y\n end\n str << @fmstr % @columns\n buffer << str\n #puts \"-\" * str.length\n buffer << separator\n if @list\n if @numbering\n @fmstr = \"%#{rows}d \"+ @y + @fmstr\n end\n #@list.each { |e| puts e.join(@y) }\n count = 0\n @list.each_with_index { |r,i| \n value = convert_value_to_text r, count\n buffer << value\n count += 1\n }\n end\n buffer\n end", "def display\n puts \" 0 1 2 3 4 5 6 7 \"\n puts \"#{format}\"\n end", "def inspect\n out = \"\"\n self.each_pair do |k ,v|\n out << \"%-40s\" % k.to_s.yellow unless [:header, :item, :magic].include? k\n case k\n when :image_format then out << \"0x%03x\\n\" % v\n when :header\n v.each_pair do |i, j|\n out << \"%-40s%s\\n\" % [i.to_s.yellow, j] if i == :item_count\n out << \"%-40s%d MB\\n\" % [i.to_s.yellow, j>> 20] if i == :len_low\n # out \"res:\" << reserved.inspect if i == :reserved\n end\n when :item\n out << \"Items\\n\".light_blue\n v.each { |it| out << it.inspect << \"\\n\" }\n end\n end\n out\n end", "def output(data)\n msg @presenter.format(data)\n end", "def to_s\n return '' if @printed\n @printed = true\n struct = required_structs\n members = @values.map do |key, value|\n type = RustStruct.type_name(value[0])\n subtype = RustStruct.type_name(value[1])\n # TODO: add option for pub / private\n # Will this be a per field thing that is configurable from\n # within the JSON or will it be configured on the parse command?\n member = \" pub #{key}: #{type}\"\n member << \"<#{subtype}>\" unless value[1].nil?\n member\n end\n struct << \"pub struct #{@name} {\\n\" + members.join(\",\\n\") + \",\\n}\\n\\n\"\n struct = struct.gsub(\"\\n\\n\\n\", \"\\n\\n\")\n reset if @root\n struct\n end", "def text(obj, width=nil)\n @output << obj\n end", "def dump\n super\n\n puts \"page header:\"\n pp page_header\n puts\n\n puts \"fseg header:\"\n pp fseg_header\n puts\n\n puts \"sizes:\"\n puts \" %-15s%5i\" % [\"header\", header_space]\n puts \" %-15s%5i\" % [\"trailer\", trailer_space]\n puts \" %-15s%5i\" % [\"directory\", directory_space]\n puts \" %-15s%5i\" % [\"free\", free_space]\n puts \" %-15s%5i\" % [\"used\", used_space]\n puts \" %-15s%5i\" % [\"record\", record_space]\n puts \" %-15s%5.2f\" % [\"per record\", space_per_record]\n puts\n\n puts \"page directory:\"\n pp directory\n puts\n\n puts \"system records:\"\n pp infimum.record\n pp supremum.record\n puts\n\n puts \"garbage records:\"\n each_garbage_record do |rec|\n pp rec.record\n puts\n end\n puts\n\n puts \"records:\"\n each_record do |rec|\n pp rec.record\n puts\n end\n puts\n end", "def format_data(data)\n case format\n when :json\n JSON.pretty_generate(data)\n else # default to YAML\n data.to_yaml.sub(/\\A\\-\\-\\-\\n/, '')\n end\n end", "def print output_formatter\n output_formatter.print({ \"Commits:\" => @commits, \"Standard churn:\" => @result, \"Deletions:\" => @deletions, \"Insertions:\" => @insertions })\n end", "def pretty_format\n pretty = \"\"\n sorted = @hash.sort_by { |name, arrays| name }\n\n sorted.each { |name, array|\n pretty.concat(name)\n pretty.concat(\": \")\n pretty.concat(\"#{@hash[name].join(\",\")}\\n\")\n\n }\n pretty\n\n ### FILL IN YOUR CODE HERE\n end", "def pretty_output #two columns\n alphabetical_keys = @concordance_hash.keys.sort\n half = (alphabetical_keys.length - 1) / 2\n alphabetical_keys[0..half].each_with_index do |key, idx|\n value = \"{\" + @concordance_hash[key][0].to_s + \":\" +\n @concordance_hash[key][1..-1].to_s.delete(\"[] \") + \"}\"\n\n key2 = alphabetical_keys[1 + idx + half]\n value2 = \"{\" + @concordance_hash[key2][0].to_s + \":\" +\n @concordance_hash[key2][1..-1].to_s.delete(\"[] \") + \"} \\n\"\n if 1 + idx + half >= alphabetical_keys.length\n value2 = \"\\n\"\n end\n\n printf \"%-15s %-20s %-15s %s\", key, value, key2, value2\n end\n end", "def show\n data, format = [], []\n \n update(:elapsed, (Time.now - @start_time).to_i)\n \n sorted = @data.sort { |a,b| a[1][:order]<=>b[1][:order] }\n sorted.each do |item|\n format << \"#{item[0].to_s.capitalize}: #{item[1][:format]}\"\n data << item[1][:value] \n end\n \n $stdout.printf(format.join(' | ') + \"\\r\", *data)\n $stdout.flush\n end", "def formatted_client_display_info\n output_info = []\n output_info << \"Name: #{@name}\"\n output_info << \"Age: #{@age}\"\n output_info << \"Children: #{@number_of_children}\"\n output_info << \"Pets: #{self.number_of_pets}\"\n @pets.each { |k, pet| output_info << \" #{pet.name} is #{pet.age}, and likes to play with... #{pet.toys}\" }\n # add a blank line\n output_info << \" \"\n return output_info\n end", "def output(data)\n msg @presenter.format(data)\n end", "def display\n to_s.split(\"\\n\")\n .map { |line| line.split('').join(' ') }\n .join(\"\\n\")\n end", "def print_employee_data\n\n # Define positions.\n box_offsets = [[0, 0], [4.25, 0], [0, -5.5], [4.25, -5.5]]\n starting_x = 0.25\n starting_y = 10.75\n\n # Draw text for each position.\n box_offsets.each do |o|\n box_x = starting_x + o[0]\n box_y = starting_y + o[1]\n print_employee_data_box(box_x, box_y)\n end\n\n end", "def formats; end", "def formats; end", "def pretty_print(depth = 0)\n depth.times { STDERR.print ' *' }\n STDERR.print ' '\n STDERR.puts \"#{@name} (#{@id})\"\n @contents.each { |obj| obj.pretty_print(depth + 1) }\n end", "def display_object\n\tputs \"Name: #{name}\"\n\tpretty_price = format(\"%0.2f\", price)\n\tputs \"Price: $#{pretty_price}\"\n\tputs \"Size: #{size}\"\n end", "def print_data(layout = :print_layout)\n PrintData.new(sections(layout)).to_json\n end", "def printable\n\t\[email protected] do |key, value|\n\t\t\t\"[#{key}] \\\"#{value}\\\"\"\n\t\tend.join(\"\\n\")\n\tend", "def formatJSON\n # @formattedContents = .... whatever puts it into JSON\n end", "def to_s\n header_output = build_header_output\n data_output = build_data_output\n\n string = ''\n string << Yummi.colorize(@title, @style[:title]) << $/ if @title\n string << Yummi.colorize(@description, @style[:description]) << $/ if @description\n table_data = header_output + data_output\n if @layout == :vertical\n # don't use array transpose because the data may differ in each line size\n table_data = rotate table_data\n end\n string << content(table_data)\n end", "def formatted!\n self[:formatted] = true\n node[:volumes][name][:formatted] = true\n end", "def output(data); end", "def dumpAsString\n\t\tmarkup = \"\"\n\t\[email protected] do |line|\n\t\t\tmarkup += \"#{line}<br />\\n\"\n\t\tend\n\t\treturn markup\n\tend", "def display_data_universe\n\n end", "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 formatters; end", "def educate stream=$stdout\n width # just calculate it now; otherwise we have to be careful not to\n # call this unless the cursor's at the beginning of a line.\n\n left = {}\n @specs.each do |name, spec| \n left[name] = \"--#{spec[:long]}\" +\n (spec[:short] ? \", -#{spec[:short]}\" : \"\") +\n case spec[:type]\n when :flag; \"\"\n when :int; \" <i>\"\n when :string; \" <s>\"\n when :float; \" <f>\"\n end\n end\n\n leftcol_width = left.values.map { |s| s.length }.max || 0\n rightcol_start = leftcol_width + 6 # spaces\n\n unless @order.size > 0 && @order.first.first == :text\n stream.puts \"#@version\\n\" if @version\n stream.puts \"Options:\"\n end\n\n @order.each do |what, opt|\n if what == :text\n stream.puts wrap(opt)\n next\n end\n\n spec = @specs[opt]\n stream.printf \" %#{leftcol_width}s: \", left[opt]\n desc = spec[:desc] + \n if spec[:default]\n if spec[:desc] =~ /\\.$/\n \" (Default: #{spec[:default]})\"\n else\n \" (default: #{spec[:default]})\"\n end\n else\n \"\"\n end\n stream.puts wrap(desc, :width => width - rightcol_start - 1, :prefix => rightcol_start)\n end\n end", "def printable\n \tprint_this = []\n \[email protected]{ |k,v| print_this << \"[#{k}] \\\"#{v}\\\"\\n\" }\n \tprint_this.sort.join.chomp.chomp\n end", "def pretty_generate\n JSON.pretty_generate( self.to_h )\n end", "def output\n # If there are neither headers nor any rows in the table, return an\n # empty string.\n return '' if table.empty? && table.headers.empty?\n\n # This results in a hash of two-element arrays. The key\n # is the header and the value is an array of the header and formatted\n # header. We do the latter so the structure parallels the structure for\n # rows explained next.\n formatted_headers = build_formatted_headers\n\n # These produce an array with each element representing a row of the\n # table. Each element of the array is a two-element array. The location of\n # the row in the table (:bfirst, :body, :gfooter, etc.) is the first\n # element and a hash of the row is the second element. The keys for the\n # hash are the row headers as in the Table, but the values are two element\n # arrays as well. First is the raw, unformatted value of the cell, the\n # second is a string of the first value formatted according to the\n # instructions for the column and location in which it appears. The\n # formatting done on this pass is only formatting that affects the\n # contents of the cells, such as inserting commas, that would affect the\n # width of the columns as displayed. We keep both the raw value and\n # unformatted value around because we have to make two passes over the\n # table if there is any alignment, and we want to know the type of the raw\n # element for the second pass of formatting for type-specific formatting\n # (e.g., true_color, false_color, etc.).\n new_rows = build_formatted_body\n new_rows += build_formatted_footers\n\n # Having formatted the cells, we can now compute column widths so we can\n # do any alignment called for if this is a Formatter that performs its own\n # alignment. On this pass, we also decorate the cells with colors, bold,\n # etc.\n if aligned?\n widths = width_map(formatted_headers, new_rows)\n table.headers.each do |h|\n fmt_h = formatted_headers[h].last\n istruct = format_at[:header][h]\n formatted_headers[h] =\n [h, format_cell(fmt_h, istruct, width: widths[h], decorate: true)]\n end\n aligned_rows = []\n new_rows.each do |loc_row|\n if loc_row.nil?\n aligned_rows << nil\n next\n end\n loc, row = *loc_row\n aligned_row = {}\n row.each_pair do |h, (val, _fmt_v)|\n istruct = format_at[loc][h]\n aligned_row[h] =\n [val, format_cell(val, istruct, width: widths[h], decorate: true)]\n end\n aligned_rows << [loc, aligned_row]\n end\n new_rows = aligned_rows\n end\n\n # Now that the contents of the output table cells have been computed and\n # alignment applied, we can actually construct the table using the methods\n # for constructing table parts, pre_table, etc. We expect that these will\n # be overridden by subclasses of Formatter for specific output targets. In\n # any event, the result is a single string (or ruby object if eval is true\n # for the Formatter) representing the table in the syntax of the output\n # target.\n result = ''\n result += pre_table\n if include_header_row?\n result += pre_header(widths)\n result += pre_row\n cells = []\n formatted_headers.each_pair do |h, (_v, fmt_v)|\n cells << pre_cell(h) + quote_cell(fmt_v) + post_cell\n end\n result += cells.join(inter_cell)\n result += post_row\n result += post_header(widths)\n end\n new_rows.each do |loc_row|\n if loc_row.nil?\n result += hline(widths)\n next\n end\n\n _loc, row = *loc_row\n result += pre_row\n cells = []\n row.each_pair do |h, (_v, fmt_v)|\n cells << pre_cell(h) + quote_cell(fmt_v) + post_cell\n end\n result += cells.join(inter_cell)\n result += post_row\n end\n result += post_footers(widths)\n result += post_table\n\n # If this Formatter targets a ruby data structure (e.g., AoaFormatter), we\n # eval the string to get the object.\n evaluate? ? eval(result) : result\n end", "def dump\n @@fields.each { |field| @contents[field] = send(field) } \n @contents\n end", "def format(content)\n content\n end", "def to_s\r\n pretty_output\r\n end", "def formatData(data)\n data.keys.each{|key| data}\n end", "def format_print(print_values)\n widths = Array.new(print_values[0].size, 0)\n print_values.each do |print_value|\n widths = widths.zip(print_value).map! {|width, value| value.length > width ? value.length : width }\n end\n\n print_values.each do |print_value|\n widths.zip(print_value) do |width, value|\n printf(\"%-#{width + 5}s\", value)\n end\n puts \"\"\n end\n end", "def format\n @_format\n end", "def flush\n @output.puts @widgets.values.join\n end", "def display_pretty_json(data)\n puts JSON.pretty_generate(data)\nend", "def d(data)\n data.send :display \n \"\\n\".send :display\nend", "def format(printer, object)\n buffer = new_buffer\n printer.run(Output.new(tty, buffer), object)\n buffer.rewind\n buffer.read\n end", "def format(text); end", "def render\n puts \"-------------------------------------\"\n @grid.each do |row| \n puts \"| \" + row.map(&:to_s).join(\" | \") + \" |\"\n puts \"-------------------------------------\"\n end\n end", "def print_layout # rubocop:disable Metrics/MethodLength\n [{ code: :property_details, # section code\n divider: true, # should we have a section divider\n key: :title, # key for the title translation\n key_scope: %i[returns lbtt_properties about_the_property], # scope for the title translation\n display_title: true, # Is the title to be displayed\n type: :list, # type list = the list of attributes to follow\n list_items: [{ code: :lau_code, lookup: true },\n { code: :full_title_number, action_name: :print },\n { code: :full_parent_title_number },\n { code: :ads_due_ind, lookup: true, when: :flbt_type, is: ['CONVEY'] }] },\n { code: :address,\n key: :title, # key for the title translation\n key_scope: %i[returns lbtt_properties property_address], # scope for the title translation\n type: :object }]\n end", "def print(data, level = 0)\n case data\n when Hash\n data.each do |key, value|\n if value.is_a? Enumerable\n string = \"#{indent_string(level)}#{format_key(key)}:\"\n\n if value.empty?\n puts string + ' ' + empty_value(value)\n else\n puts string\n print(value, level + 1)\n end\n else\n puts \"#{indent_string(level)}#{format_key(key)}: #{format_value(value)}\"\n end\n end\n when Array\n data.each do |value|\n if value.is_a? Enumerable\n string = format_key \"#{indent_string(level)}-\"\n if value.empty?\n puts string + ' ' + empty_value(value)\n else\n puts string\n print(value, level + 1)\n end\n else\n puts \"#{indent_string(level)}#{format_key('-')} #{format_value(value)}\"\n end\n end\n else\n puts \"#{indent_string(level)}#{format_value(data)}\"\n end\n end", "def pretty\n \" Size: #{size} Blocks: #{blocks} IO Block: #{blksize} Type: #{rdev}\\n\"\\\n \"Device: #{dev} Inode: #{ino} Links: #{nlink}\\n\"\\\n \" Mode: #{prettymode}\\n\"\\\n \" Uid: #{uid} Gid: #{gid}\\n\"\\\n \"Access: #{atime}\\n\"\\\n \"Modify: #{mtime}\\n\"\\\n \"Change: #{ctime}\\n\"\n end", "def structure_dump() end", "def formatForSTDOUT()\n output = \"Total Reads Produced = \" + @totalReadsProduced.to_s + \"\\r\\n\" +\n \"Duplicate Reads = \" + @numDuplicateReads.to_s + \" (\" + @perDuplicateReads.to_s + \")%\\r\\n\" +\n \"Total Reads Aligned = \" + @numAlignedReads.to_s + \" (\" + @perAlignedReads.to_s + \")%\\r\\n\" +\n \"Paired Reads = \" + @numReadsPaired.to_s + \"\\r\\n\" +\n \"Reads Paired with Mapped Mates = \" + @numReadAndMatePaired.to_s + \"\\r\\n\" +\n \"Buffer Aligned Reads = \" + @numBufferAlignedReads.to_s + \" (\" + @perBufferAlignedReads.to_s + \")%\\r\\n\" + \n \"Target Aligned Reads = \" + @numTargetAlignedReads.to_s + \" (\" + @perTargetAlignedReads.to_s + \")%\\r\\n\" +\n \"Average Coverage = \" + @avgCoverage.to_s + \"\\r\\n\" +\n \"Reads on Target or Buffer = \" + @numReadsTargetBuffer.to_s + \" (\" + @perReadsTargetBuffer.to_s + \")%\\r\\n\" +\n \"Total Aligned Reads (Expected) = \" + @totalExpAlignedReads.to_s + \"\\r\\n\" +\n \"Total Aligned Reads (Calculated) = \" + @totalCalcAlignedReads.to_s + \"\\r\\n\" +\n \"Targets Hit = \" + @numTargetsHit.to_s + \" (\" + @perTargetsHit.to_s + \")%\\r\\n\" +\n \"Target Buffers Hit = \" + @numTargetBuffersHit.to_s + \" (\" + @perTargetBuffersHit.to_s + \")%\\r\\n\" +\n \"Total Targets = \" + @numTotalTargets.to_s + \"\\r\\n\" +\n \"Non Target Hits = \" + @numNonTarget.to_s + \"\\r\\n\" +\n \"Bases on Target = \" + @numTargetedBases.to_s + \"\\r\\n\" +\n \"Buffer Bases = \" + @numBufferBases.to_s + \"\\r\\n\" + \n \"Bases with 1+ Coverage = \" + @numBases1Coverage.to_s + \" (\" + @perBases1Coverage.to_s + \")%\\r\\n\" +\n \"Bases with 4+ Coverage = \" + @numBases4Coverage.to_s + \" (\" + @perBases4Coverage.to_s + \")%\\r\\n\" +\n \"Bases with 10+ Coverage = \" + @numBases10Coverage.to_s + \" (\" + @perBases10Coverage.to_s + \")%\\r\\n\" +\n \"Bases with 20+ Coverage = \" + @numBases20Coverage.to_s + \" (\" + @perBases20Coverage.to_s + \")%\\r\\n\" +\n \"Bases with 40+ Coverage = \" + @numBases40Coverage.to_s + \" (\" + @perBases40Coverage.to_s + \")%\\r\\n\"\n return output\n end", "def render data, path=[], &block\n indent = (path.length + 1) * @indentation\n pad = \" \" * indent\n\n case data\n\n when Hash\n append(\"{}\", path) and return if data.empty?\n append \"{\\n\", path\n\n sort_any(data.keys).each_with_index do |key, i|\n append \"#{pad}#{ yield(:key, key) }#{ yield(:key_assign) }\", path\n\n value = data[key]\n new_path = path.dup << key\n render value, new_path, &block\n\n append(\",\", path) unless i == data.length - 1\n append(\"\\n\", path)\n end\n\n append((\"#{\" \" * (indent - @indentation)}}\"), path)\n\n when Array\n append(\"[]\", path) and return if data.empty?\n append \"[\\n\", path\n\n (0...data.length).each do |key|\n append pad, path\n\n value = data[key]\n new_path = path.dup << key\n render value, new_path, &block\n\n append(\",\", path) unless key == data.length - 1\n append(\"\\n\", path)\n end\n\n append((\"#{\" \" * (indent - @indentation)}]\"), path)\n\n else\n output = @struct_only ? yield(:struct, data) : yield(:value, data)\n output = colorize output, data if @color\n append output.to_s, path\n end\n end", "def createTextOutput(tree, width, height, divisions)\n\tareaMap = [ ]\n\ttextOutput = [ ]\n\tfor x in 0..width \n\t\tareaMap[x] = [ ]\n\t\tfor y in 0..height \n\t\t\tareaMap[x][y] = '#'\n\t\tend\n\tend\n\tareaMap = tree.displayTree(areaMap)\n\tsaveTextOutput(1, areaMap, width, height, divisions)\nend", "def dump\n puts \"Memory dump:\"\n @content.each_index do |index|\n puts \"%0.5d: %0.4o\" % [index, @content[index]] unless @content[index].nil?\n end\n end", "def format_output(result, format)\n case format\n when :json\n JSON.pretty_generate(result)\n when :yaml\n YAML.dump(result)\n when :text\n result = result.keys if result.respond_to?(:keys)\n result.join(\" \")\n else\n raise ArgumentError, \"Unknown output format #{format}\"\n end\n end", "def inspect\n Thread.current[:formatador] ||= Formatador.new\n data = \"#{Thread.current[:formatador].indentation}<#{self.class.name}\"\n Thread.current[:formatador].indent do\n unless self.instance_variables.empty?\n vars = self.instance_variables.clone\n vars.delete(:@client)\n vars.delete(:@page)\n data << \" \"\n data << vars.map { |v| \"#{v}=#{instance_variable_get(v.to_s).inspect}\" }.join(\", \")\n end\n end\n data << \" >\"\n data\n end", "def output\n # This results in a hash of two-element arrays. The key is the header and\n # the value is an array of the header and formatted header. We do the\n # latter so the structure parallels the structure for rows explained next.\n formatted_headers = build_formatted_headers\n\n # These produce an array with each element representing a row of the\n # table. Each element of the array is a two-element array. The location of\n # the row in the table (:bfirst, :body, :gfooter, etc.) is the first\n # element and a hash of the row is the second element. The keys for the\n # hash are the row headers as in the Table, but the values are two element\n # arrays as well. First is the raw, unformatted value of the cell, the\n # second is a string of the first value formatted according to the\n # instructions for the column and location in which it appears. The\n # formatting done on this pass is only formatting that affects the\n # contents of the cells, such as inserting commas, that would affect the\n # width of the columns as displayed. We keep both the raw value and\n # unformatted value around because we have to make two passes over the\n # table if there is any alignment, and we want to know the type of the raw\n # element for the second pass of formatting for type-specific formatting\n # (e.g., true_color, false_color, etc.).\n new_rows = build_formatted_body\n new_rows += build_formatted_footers\n\n # Having formatted the cells, we can now compute column widths so we can\n # do any alignment called for if this is a Formatter that performs its own\n # alignment. On this pass, we also decorate the cells with colors, bold,\n # etc.\n if aligned?\n widths = width_map(formatted_headers, new_rows)\n table.headers.each do |h|\n fmt_h = formatted_headers[h].last\n istruct = format_at[:header][h]\n formatted_headers[h] =\n [h, format_cell(fmt_h, istruct, width: widths[h], decorate: true)]\n end\n aligned_rows = []\n new_rows.each do |loc_row|\n if loc_row.nil?\n aligned_rows << nil\n next\n end\n loc, row = *loc_row\n aligned_row = {}\n row.each_pair do |h, (val, _fmt_v)|\n istruct = format_at[loc][h]\n aligned_row[h] =\n [val, format_cell(val, istruct, width: widths[h], decorate: true)]\n end\n aligned_rows << [loc, aligned_row]\n end\n new_rows = aligned_rows\n end\n\n # Now that the contents of the output table cells have been computed and\n # alignment applied, we can actually construct the table using the methods\n # for constructing table parts, pre_table, etc. We expect that these will\n # be overridden by subclasses of Formatter for specific output targets. In\n # any event, the result is a single string (or ruby object if eval is true\n # for the Formatter) representing the table in the syntax of the output\n # target.\n result = ''\n result += pre_table\n if include_header_row?\n result += pre_header(widths)\n result += pre_row\n cells = []\n formatted_headers.each_pair do |h, (_v, fmt_v)|\n cells << pre_cell(h) + quote_cell(fmt_v) + post_cell\n end\n result += cells.join(inter_cell)\n result += post_row\n result += post_header(widths)\n end\n new_rows.each do |loc_row|\n result += hline(widths) if loc_row.nil?\n next if loc_row.nil?\n\n _loc, row = *loc_row\n result += pre_row\n cells = []\n row.each_pair do |h, (_v, fmt_v)|\n cells << pre_cell(h) + quote_cell(fmt_v) + post_cell\n end\n result += cells.join(inter_cell)\n result += post_row\n end\n result += post_footers(widths)\n result += post_table\n\n # If this Formatter targets a ruby data structure (e.g., AoaFormatter), we\n # eval the string to get the object.\n evaluate? ? eval(result) : result\n end", "def to_s\n stringio = StringIO.new\n\n # Set the column widths\n if @data\n @data.each do |row|\n next if row.length != @columns.length\n\n @columns.each_with_index do |column, i|\n data_string = column.data_to_s.call(row[i])\n column.width = data_string.length if data_string.length > column.width\n end\n end\n else\n @columns.each { |column| column.width = column.label.length }\n end\n\n # Print the column headers\n stringio.puts(@columns.collect do |column|\n padding = column.padding || \" \"\n padding + column.label.center(column.width) + padding\n end.join(\"|\"))\n\n total_width = stringio.string.length - 1\n\n # Print the bar below the column header\n stringio.puts(@columns.collect do |column|\n padding = column.padding || \" \"\n \"-\" * (column.width + 2 * padding.length)\n end.join(\"+\"))\n\n # If we have rows, print each one, otherwise print \"No rows\"\n if @data\n @data.each do |row|\n # Skip rows that have the wrong number of columns\n next if row.length != @columns.length\n\n # Generate the row of data. These machinations with the index variable are because collect_with_index doesn't exist\n # and Ruby 1.8.x doesn't support each_with_index.collect.\n i = 0\n stringio.puts(row.collect do |data|\n padded_aligned_data = @columns[i].padded_aligned_data(data)\n i += 1\n padded_aligned_data\n end.join(\"|\"))\n end\n else\n stringio.puts(\"No rows\".center(total_width))\n end\n\n stringio.string\n end", "def printable\n asPrintable = \"\"\n doCount = 0 # way to keep track of the entries loop so a new line can be added to the end of the concat string\n @entries.sort.each do |keyWord, value|\n asPrintable += \"[#{keyWord}] \\\"#{value}\\\"\"\n if doCount < @entries.length - 1 # in order for test to pass, it cant have a extra line at the end\n asPrintable += \"\\n\" # only add one if not the last element of the hash\n end\n doCount += 1 # each loop adds one\n end\n asPrintable # return concat string\n end", "def render\n puts \" #{(0..8).to_a.join(\" \")}\"\n grid.each_with_index do |row, i|\n arr = []\n row.each do |tile|\n if tile.revealed == true\n arr << tile.display_value\n elsif tile.flagged == true\n arr << \"F\"\n else\n arr << \"*\"\n end\n end\n\n puts \"#{i} #{arr.join(\" \")}\"\n end\n end", "def preformatting\n\n end", "def print\n unless success?\n return nil\n end\n nlen = \"Name\".length\n clen = \"Craft\".length\n @data['people'].each do |p|\n nlen = p['name'].length > nlen ? p['name'].length : nlen\n clen = p['craft'].length > clen ? p['craft'].length : clen\n end\n\n print_header(nlen, clen)\n @data['people'].each do |p|\n print_line(nlen, p['name'], clen, p['craft'])\n end\n end", "def dump\n result = ''\n result << \"#{lanes}\\n\"\n result << \"#{cars}\\n\"\n result << \"#{rounds}\\n\"\n chart.each do |heat|\n result << heat.join(' ') << \"\\n\"\n end\n result\n end", "def dump\n dump_text = ''\n regions.each do |child|\n dump_text << ' '*child.level << \"[Level: #{child.level}] \" << child.content.to_s << \"\\n\"\n end\n dump_text\n end", "def format\n collect { |a| a.format }\n end", "def rendered_format; end", "def rendered_format; end", "def format_content(content)\n return \"\" if content.nil? || content.empty?\n\n JSON.pretty_generate(content)\n end", "def print_all\n @data.each do |row|\n row.each do |item|\n print \" \", item.area\n end\n print \"\\n\"\n end\n end", "def print_data(data, padding)\n p = \"\"\n (0..padding.length - data.to_s.length).map {p += \" \"}\n print data.to_s + p\n end", "def print\n\t\tif self.length == 0\n\t\t\tputs \"empty\"\n\t\telse\n\t\t\tself.each { |item| puts item.data }\n\t\tend\n\tend", "def inspect\n s = ''\n @props.each do |key,val|\n s << sprintf(\"%-20.20s : %-40.40s\\n\", key.to_s, val.inspect)\n end\n s\n end", "def printData()\n puts @data\n end", "def format\n @ole.Format\n end", "def format\n @ole.Format\n end", "def display_order_contents\n\t\[email protected] {|item| print item, \" -- \"}\n\tend", "def output data\n @out << data.to_s\n data\n end", "def pretty_print(result)\n result.each_with_index do |line, index|\n puts \"#{index+1}:\\t #{type_to_sym(line[:type])}\\t#{line[:value]}\"\n end\n end", "def render\n Tilt.new(@file)\n .render(OpenStruct.new(@binds))\n .delete!(\"\\n\")\n end" ]
[ "0.65562123", "0.65229595", "0.6448225", "0.6366006", "0.6366006", "0.6366006", "0.6366006", "0.6366006", "0.6366006", "0.6366006", "0.6366006", "0.63358295", "0.6300172", "0.6289767", "0.6289767", "0.6289767", "0.6286952", "0.6276543", "0.62709177", "0.62561464", "0.62172157", "0.61738026", "0.6164843", "0.6156098", "0.6092583", "0.6076389", "0.6045016", "0.6041005", "0.6040858", "0.6037355", "0.6032444", "0.60127413", "0.5997264", "0.5980663", "0.5979663", "0.5959848", "0.5943707", "0.5933887", "0.59229565", "0.59229565", "0.5910675", "0.590437", "0.59013945", "0.59004647", "0.58985466", "0.5876518", "0.5870303", "0.5848076", "0.5847685", "0.5828896", "0.58282864", "0.5812054", "0.5809459", "0.58021295", "0.57733655", "0.5752949", "0.5736575", "0.57312214", "0.57269806", "0.57032055", "0.5702563", "0.5694799", "0.5692341", "0.5683457", "0.5682454", "0.56818813", "0.5672436", "0.56698537", "0.56658125", "0.5663597", "0.56624424", "0.56609184", "0.56567466", "0.56540203", "0.5642676", "0.5641997", "0.56386876", "0.56369114", "0.5636245", "0.5630579", "0.56278527", "0.56262255", "0.56246775", "0.5623577", "0.5620022", "0.5616963", "0.56106126", "0.56079924", "0.56079924", "0.56024194", "0.56013775", "0.5591401", "0.55849445", "0.55787927", "0.5576367", "0.5575525", "0.5575525", "0.5573513", "0.5567067", "0.55619544", "0.556139" ]
0.0
-1
Returns a symbol got from final section (after the last ::) of the given class name. If no :: found the full name is returned
def class_moniker self.class.moniker end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def class_name\n self.fullname[/\\A(.*)([\\.\\#])([^\\.\\#]+)\\z/, 1]\n end", "def name_from_object(class_name)\n class_name.split('::').last\n end", "def name\n klass.name.split('::').last\n end", "def class_unqualified_name(clazz)\n name = clazz.name\n if name =~ /::([^:]+)$/\n $1\n else\n name\n end\n end", "def name\n has_module?(klass) ? klass[(klass.index(\"::\")+2)..-1] : klass\n end", "def name\n return self.class.name.split('::').last\n end", "def full_class_name\n @class_names.join(\"::\")\n end", "def name\n self.class.to_s.split('::').last\n end", "def name\n self.class.name.split('::').last\n end", "def class_name\r\n r = \"\"\r\n up = true\r\n each_byte do |c|\r\n if c == 95\r\n if up\r\n r << \"::\"\r\n else\r\n up = true\r\n end\r\n else\r\n m = up ? :upcase : :to_s\r\n r << (c.chr.send(m))\r\n up = false\r\n end\r\n end\r\n r\r\n end", "def class_name\n self.class.name.split(\"::\").last\n end", "def name\n self.class.name.split('::').last\n end", "def name\n self.class.name.split(\"::\").last\n end", "def parse_classname(full_cname)\n names=full_cname.split(\"::\")\n return names[0..-2].join('::'), names[-1], names.join(\"/\") \n end", "def name\n self.class.name.split('::').last\n end", "def inicial\n self.class.name.gsub(/#{Module.nesting.last}::/, '').chr\n end", "def full_name\n decorated_class_name = case self.klass_flags\n when 0x2\n \"<Class::#{klass_name}>\"\n when 0x4\n \"<Module::#{klass_name}>\"\n when 0x8\n \"<Object::#{klass_name}>\"\n else\n klass_name\n end\n\n \"#{decorated_class_name}##{method_name}\"\n end", "def base_class_name\n split('::').last\n end", "def class_name\n self.class.to_s.split('::').last\n end", "def class_name\n self.class.name.split(\"::\").last.downcase\n end", "def name\n self.class.name.split(\"::\").last.downcase\n end", "def class_name method_name\n segments = method_name.split('::')\n return segments[0..-2].join('::') if segments.count > 1\n \"Object\"\nend", "def extract_class(string)\n uncapitalize(string.split('::').last)\n end", "def class_name\n %x{\n var first = self[0];\n return (first && first.className) || \"\";\n }\n end", "def last_constant(constant)\n constant.to_s.split(\"::\").last\n end", "def classname\n @classname ||= self.class.name.split(\"::\")[1..-1].join(\"::\")\n end", "def simple_name\n name.split('::').last\n end", "def simple_name\n name.split('::').last\n end", "def name\n @label || self.class.to_s.rpartition('::').last\n end", "def class_to_filename (c)\n c.split(/::/).map {|i| i.gsub(/([A-Z])/, '_\\1').sub(/_/, '').downcase}.\n join('/')\nend", "def full_name\n \"#{namespace.name || namespace.inspect}::#{namespace.instances[ self ]}\"\n end", "def name_and_class\n [name, self['class']].compact.join('.')\n end", "def classname(name)\n [@lexer.namespace, name].join(\"::\").sub(/^::/, '')\n end", "def underscorized_classname\n self.class.name.split(\"::\").last.\n gsub( /([A-Z]+)([A-Z][a-z])/, '\\1_\\2' ).\n gsub( /([a-z\\d])([A-Z])/, '\\1_\\2' ).downcase\n end", "def ns (klass) #name symbol.\n\tklass.name.to_sym\nend", "def fully_qualified_ruby_name\n return \"::#{self.package.gsub('.', '::')}\"\n end", "def class_name\n if @class_stack.any?\n @class_stack.reverse\n else\n :main\n end\n end", "def full_name\n klass.name\n end", "def stripped_class_name\n name.demodulize\n end", "def get_as_class_name ruby_class_name\n mapping = @ruby_mappings[ruby_class_name]\n return mapping.nil? ? nil : mapping.as\n end", "def name\n n = self.class.name\n n.gsub!( /::/, '.' )\n n.gsub( /(\\w)\\w+\\./ ) { |m| $1.downcase + '.' }\n end", "def get_previous_class cursor\n # The class (or module) is followed by a '('\n ret = @info.rsearch_with_length(/\\s\\S+\\(/, cursor)\n return ret[0].empty? ? nil : ret[2][1..-2] # skip the first char (a space) and the last (a parentheses)\n end", "def combined_class_name\n @combined_class_name ||= \"Combined::\" + my_class_name.to_s.sub(/.*::/, \"\")\n end", "def last_tab_class(klass, tab_classes)\n tab_classes.last == klass ? 'last' : ''\n end", "def extract_class_name(filename)\n filename.split('/')[2..-1].collect { |i| i.camelize }.join('::').chomp(\".rb\")\n end", "def method_name\n self.fullname[/\\A(.*)([\\.\\#])([^\\.\\#]+)\\z/, 3]\n end", "def find_class_or_module name\n name = $' if name =~ /^::/\n @classes_hash[name] || @modules_hash[name]\n end", "def to_s\n self.name.split('::').last\n end", "def parse_name(name)\n parts = name.split(/(::|\\#|\\.)/)\n\n if parts[-2] != '::' or parts.last !~ /^[A-Z]/ then\n meth = parts.pop\n parts.pop\n end\n\n klass = parts.join\n\n [klass, meth]\n end", "def objective_class_name namespace_name\t\n\tif namespace_name.scan(/::/).count > 0\n\t\tnamespace_name.split(\"::\").map { |word|\n\t\t\tif word.scan(/[A-Z]/).count > 0\n\t\t\t\tword\n\t\t\telse\n\t\t\t\tword.capitalize\n\t\t\tend\n\t\t}.join\n\telsif namespace_name.scan(/_/).count > 0\n\t\tnamespace_name.split(\"_\").map { |w|\n\t\t\tw.capitalize\n\t\t}.join\n\telsif namespace_name[0].scan(/[A-Z]/).count > 0\n\t\tnamespace_name\n\telse\n\t\tnamespace_name.capitalize\n\tend\nend", "def find_class_or_module_named(symbol)\n RDoc::TopLevel.classes_hash.each_value do |c|\n return c if c.full_name == symbol\n end\n\n RDoc::TopLevel.modules_hash.each_value do |m|\n return m if m.full_name == symbol\n end\n\n nil\n end", "def module_name\n (i = name.index(\"::\")) ? name[0..i-1] : name\n end", "def klass\n name.gsub(module_name+\"::\",\"\")\n end", "def only_last_part_plural cls_name \n parts = cls_name.split('_')\n name = parts.inject([]) do |res, part|\n res << (part != parts.last ? part.singularize : part)\n res\n end.join('_') \n end", "def class_name_node(node)\n node.descendants.detect do |e|\n e.is_a?(Parser::AST::Node) &&\n e.pair_type? &&\n e.children[0].children[0] == :class_name\n end\n end", "def get_class_name(formula_file)\n string = formula_file.match(/(#{@formulas_dir.split('/').last}.*#{@formula})\\.rb$/)[1]\n string = string.sub(/^[a-z\\d]*/) { $&.capitalize }\n string.gsub(/(?:_|(\\/))([a-z\\d]*)/) { \"#{$1}#{$2.capitalize}\" }.gsub('/', '::') # rubocop:disable PerlBackrefs\n end", "def class_name(name)\n name, anchor = name.to_s.split(\"#\", 2)\n name = File.basename(name, \".json\")\n name = name + \"_\" + anchor if anchor.present?\n name.gsub(/[^\\w]/, \"_\").camelcase\n end", "def get_class_ref(class_name)\n klass = Kernel\n class_name.split(\"::\").each do |name|\n if klass.const_defined? name\n klass = klass.const_get(name)\n else\n return nil\n end\n end\n klass\n end", "def method\n self.class.name.split('::').last || ''\n end", "def namesplit(fullname)\n ary = fullname.split(\"::\")\n n = ary.pop || \"\"\n ns = ary.join(\"::\")\n return ns, n\n end", "def format\n self.class.name.split('::').last.downcase.to_sym\n end", "def full_name\n m = self.module\n RDoc::ClassModule === m ? m.full_name : @name\n end", "def _namespace_class(ns)\n return unless ns\n Ing::Util.decode_class(ns.gsub(/:$/,\": \"))\n end", "def class_name\n name = @klass.name\n name.name\n end", "def self_name\n #cm[1] == true for module/class definitions\n node=@cur_method.select {|cm| cm[1] == true}.last\n node.first unless node.nil?\n end", "def get_path(klass)\n result = klass.to_s.split('::').inject([Object]) do |acc,el|\n parent = acc[-1]\n raise NameError unless Module === parent\n acc << parent.const_get(el.to_sym) unless el.empty?\n acc\n end\n result.shift if result[0] == result[1] # If klass is 'Object' or '::Object'\n result\n end", "def deconstantize\n self[0...(rindex('::') || 0)] # implementation based on the one in facets' Module#spacename\n end", "def formatted_class_name(class_name)\n class_name = class_name.split(':')[-1]\n (class_name.gsub!(/(.)([A-Z])/, '\\1_\\2') || class_name).upcase\n end", "def type; self.class.name.split('::').last.to_sym; end", "def class_name_for_class_file(subtree, class_file)\n the_classes_directory = classes_directory(subtree)\n subpath_string = FilePath.new(class_file).relative_path_from(the_classes_directory).to_s\n subpath_string = $1 if subpath_string =~ /^(.*)\\.class\\s*$/\n subpath_string.gsub!(\"/\", \".\")\n subpath_string.gsub!(\"\\\\\", \".\")\n subpath_string\n end", "def variable_name_to_class_name(name)\n name.to_s.\n gsub(/\\/(.?)/) { \"::#{$1.upcase}\" }.\n gsub(/(?:^|_)(.)/) { $1.upcase }\n end", "def variable_name_to_class_name(name)\n name.to_s.\n gsub(/\\/(.?)/) { \"::#{$1.upcase}\" }.\n gsub(/(?:^|_)(.)/) { $1.upcase }\n end", "def type\n klass = self.class.name\n if sep = klass.rindex('::')\n klass[(sep+2)..-1]\n else\n klass\n end.underscore.to_sym\n end", "def full_name\n @full_name ||= if RDoc::ClassModule === parent then\n \"#{parent.full_name}::#{@name}\"\n else\n @name\n end\n end", "def fully_qualified_name\n return \".#{self.package}\"\n end", "def qualified_name\n if @demangled\n # The 'demangled' attribute of the node for methods / functions is the \n # full signature, so cut that part out.\n @demangled.split(/\\(/)[0]\n else\n @parent ? \"#{@parent.qualified_name}::#{@name}\" : @name\n end\n end", "def full_name\n @full_name ||= \"#{@klass}##{@method_name}\"\n end", "def get_constant(basis, class_string)\n begin\n class_string.split('::').reduce(basis) do |basis, const|\n basis.const_get(const, false)\n end\n rescue NameError\n nil\n end\n\n end", "def instance_variable_name_for(klass)\n klass.to_s.split('::').last.underscore\n end", "def pretty_class_name\n return self.class.to_s.split(/(?=[A-Z])/).join(' ')\n end", "def class_name()\n return self.id.downcase.gsub(/\\Ah?l_/i, \"\")\n end", "def base_filename; class_to_filename(name.gsub(/.*:/, '')); end", "def class_path klass_name\n File.join @path, *klass_name.split('::')\n end", "def object_symbol\n class_name = self.class.name\n index = class_name.rindex(/::/)\n class_name[index+2..-1].underscore.to_sym\n end", "def class_name\n @class_name ||= derive_class_name\n end", "def retain_class_name\n @retain_class_name ||= \"Retain::\" + my_class_name.to_s.sub(/.*::/, \"\")\n end", "def qualified_name_for(mod, name)\n mod_name = to_constant_name mod\n mod_name == \"Object\" ? name.to_s : \"#{mod_name}::#{name}\"\n end", "def class_name_for(module_name, name)\n \"#{module_name}::#{class_name(name)}\"\n end", "def to_class_name\n parts = downcase.split('/')\n parts.each(&:capitalize!)\n parts.join('').gsub(%r{-}, '')\n end", "def class_name\n Jaspion::Kilza::Class.normalize(@original_name)\n end", "def get_class(cname, mdl = Processor)\n mdl.const_get(cname.split(/[\\,\\_]/).map { |p| p.capitalize }.join)\n rescue NameError\n return nil\n end", "def extract_class_name(filename)\n File.basename(filename).chomp(\".rb\").camelize\n end", "def get_ruby_class_name as_class_name\n mapping = @as_mappings[as_class_name]\n return mapping.nil? ? nil : mapping.ruby\n end", "def class_from_string(class_name)\n parts = class_name.split('::')\n constant = Object\n parts.each do |part|\n constant = constant.const_get(part)\n end\n constant\nend", "def my_name \n @my_name ||= self.class.name.split(\"::\").last\n end", "def class_name\n klass = single_class\n while klass.name == ''\n klass = klass.superclass\n end\n if list_context?\n \"[#{klass}]\"\n else\n klass.name\n end\n end", "def get_penultimate_superclass_name_from_string(param_name)\n superclass_constant = Module.const_get(param_name)\n while superclass_constant.name != \"Object\"\n penultiamte_class = superclass_constant\n superclass_constant = superclass_constant.superclass\n end\n return penultiamte_class.name\n end", "def self_class_symbol\n self.class.to_s.underscore.to_sym\n end", "def lookup_name(namecase = nil)\n if namecase == :underscore\n name(namecase)\n else\n @lookup_name ||= class_name.tr('::', '')\n end\n end", "def demodulize(class_name_in_module)\n class_name_in_module.to_s.gsub(/^.*::/, '')\n end", "def to_const_string\n gsub(/\\/(.?)/) { \"::#{$1.upcase}\" }.gsub(/(?:^|_)(.)/) { $1.upcase }\n end" ]
[ "0.7341725", "0.7125613", "0.6937897", "0.69312894", "0.6731252", "0.6708073", "0.66831684", "0.66581696", "0.6657768", "0.6636355", "0.6629037", "0.6621426", "0.6604565", "0.6596603", "0.658169", "0.6558837", "0.6526801", "0.642873", "0.6418992", "0.63701445", "0.6333579", "0.62427837", "0.62390286", "0.6203222", "0.6149564", "0.6148795", "0.6140131", "0.6140131", "0.6109515", "0.6071152", "0.6067226", "0.60577124", "0.60387486", "0.60369027", "0.6030602", "0.60226274", "0.59970003", "0.59955424", "0.5991896", "0.5973656", "0.5970696", "0.59687155", "0.5963136", "0.5961152", "0.5956507", "0.59555846", "0.593474", "0.5916879", "0.59105706", "0.5893936", "0.5888738", "0.5885859", "0.5878889", "0.5869805", "0.58686", "0.58650136", "0.58645093", "0.585439", "0.58455884", "0.58439493", "0.5837915", "0.58372325", "0.58354515", "0.5832508", "0.5827659", "0.58271325", "0.5800393", "0.57788426", "0.576695", "0.57623476", "0.5750617", "0.5750617", "0.5739397", "0.573515", "0.5732305", "0.5726628", "0.57237315", "0.5711203", "0.5709941", "0.57083005", "0.57047695", "0.56967545", "0.5690626", "0.5689053", "0.5663168", "0.56588244", "0.5644865", "0.5644715", "0.56280017", "0.5624617", "0.561684", "0.5614339", "0.56121504", "0.56103206", "0.5608238", "0.55981314", "0.5592768", "0.55906993", "0.5565947", "0.55626625", "0.5560618" ]
0.0
-1
Name of the ISO file by the given staging project tracked on openqa
def openqa_iso(project) ending = project_iso(project) return if ending.nil? ending.gsub!(/.*-Build/, '') "SLE-15-Staging:#{project.letter}-Installer-DVD-#{arch}-Build#{project.letter}.#{ending}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def openqa_iso(project)\n ending = project_iso(project)\n \"SLE12-SP1-Staging:#{project.letter}-#{ending}\"\n end", "def openqa_iso(project)\n ending = project_iso(project)\n \"SLE12-#{sp_version}-Staging:#{project.letter}-#{ending}\"\n end", "def iso_file\n resource[:iso_file].first[\"name\"] if resource[:iso_file]\n end", "def project_filename; end", "def project_filename\n @filename.sub(Regexp.new(\"^#{Regexp.escape(SimpleCov.root)}\"), \"\")\n end", "def filename\n File.join(GalleryConfig.directories.staging, \"#{uuid}.ipynb\")\n end", "def devops_stage(file_path)\n file_path.match(%r{\\d{1,2}_(\\w+)/})&.captures&.first\n end", "def local_artifact_name\n @resource[:path]\n end", "def local_artifact_name\n if File.directory?(@resource[:path])\n b, f = bucket_and_file(@resource[:source])\n artifact = File.join(@resource[:path], f)\n else\n artifact = @resource[:path]\n end\n end", "def file_name\n\t\treturn 'st' + student_id.to_s + 'pr' + problem_id.to_s + 'so' + id.to_s\n\tend", "def determine_file_name (workitem)\n\n fei = workitem.fei\n\n OpenWFE::ensure_for_filename(\n \"#{fei.wfid}_#{fei.expression_id}__\" +\n \"#{fei.workflow_definition_name}__\" +\n \"#{fei.workflow_definition_revision}__\" +\n \"#{workitem.participant_name}.yaml\")\n end", "def file_name\n \"images/#{@name}.msf\"\n end", "def archive_file_name\n raise \"Not implemented yet!\"\n end", "def object_name\n @name ||= File.split(@source_path).last.gsub('.txt', '')\n end", "def get_config_file_project_name\n @metadata[\"short_dest_repo_name\"]\n end", "def projectizeName(filename)\n return ApplicationController.projectizeName(filename)\n end", "def filename\n filename = (model.name + '_' + model.artist.name + '_' + model.release.name).downcase.gsub(/\\s/, '-')\n \"#{filename}\" if original_filename \n end", "def name\n read_property('Name') || asmname || proj_filename_noext\n end", "def access_file_name\n end", "def image_name\n path = \"sets/#{set}/#{dimension}_#{polarity}_#{verbal}\"\n # Rails.application.assets.find_asset(path).nil? ? 'placeholder' : path\n path\n end", "def file_name\n object_file_name\n end", "def name\n filename\n end", "def name\n filename\n end", "def project_file(fname)\n \"#{@project_path}/#{fname}\"\nend", "def repository_name\n @repository_name ||= \"#{project_name}-boshrelease\"\n end", "def gen_filename\n name = @issue[\"created\"].strftime(\"%Y-%m-%d-\") + \n @issue[\"title\"].gsub(/\\W+/, \"_\") +\n \".yaml\"\n n = 1\n while File.exist?(File.join(@dir, name))\n name = File.basename(name, \".yaml\") + \"-\" + n.to_s + \".yaml\"\n n += 1\n end\n\n name\n end", "def name() @filename end", "def iso_source(version, edition)\n src = node['visualstudio'][version][edition]['default_source']\n src = node['visualstudio']['source'] if node['visualstudio']['source']\n src = node['visualstudio'][version][edition]['source'] if node['visualstudio'][version][edition]['source']\n src\n end", "def filename(version=nil)\n if version.blank?\n return \"#{unique_name}.#{file_ext}\"\n else\n return nil unless (workflow_version = self.find_version(version))\n return \"#{workflow_version.unique_name}.#{workflow_version.file_ext}\"\n end\n end", "def filename\n @filename ||= \"#{ @component.name }-#{(t=Time.now).to_i}-#{t.usec}.yaml\"\n end", "def experiment_filename\n date = DateTime.now.strftime('%Y-%m-%d')\n \"#{date}_Job_#{job.id}\"\n end", "def open_software_image\n image_path(image_name: params[:open_software_image])\n end", "def file_name\n return unless @file\n\n @file.absolute_name\n end", "def image_name\n ovf.xpath(\"//*[local-name()='References']/*[local-name()='File']\")[0].attribute(\"href\").value\n end", "def format_file_system_item_short(fsi)\n return \"\" unless fsi\n \"#{fsi.name}\" \n end", "def name\n @name ||= @project.dir.path.match(/.*\\/(.*)$/).nil? ? \"unknown\" : $1\n end", "def name\n @svn_name\n end", "def old_filename() \n\t\t \t\treturn @podspec + \"_old\"\n\t\t \tend", "def full_filename(for_file)\n #[remote_process!, for_file].join(\".\")\n for_file\n end", "def path\n @svn_name\n end", "def project_name\n # using Dir.pwd will return something like: \n # /var/www/apps/staging.sweetspot.dm/releases/20061006155448\n # instead of\n # /var/www/apps/staging.sweetspot.dm/current\n pwd = ENV['PWD'] || Dir.pwd\n #another hack..ugh. If using standard capistrano setup, pwd will be the 'current' symlink.\n pwd = File.dirname(pwd) if File.symlink?(pwd)\n File.basename(pwd)\n end", "def filename\n if original_filename.present?\n \"#{model.story.slug}-#{secure_token}.#{file.extension}\"\n end\n end", "def get_config_file_name(config, stage)\n path = File.dirname(config)\n extension = File.extname(config)\n filename = File.basename(config, extension)\n extension.sub!(/^\\./, '')\n local_file = [filename, stage].join('.')\n local_file = [local_file, extension].join('.') unless extension.empty?\n local_path = File.join(path, local_file)\n end", "def public_filename(record, file)\n filename = [application_for_offering.id.to_s] \n filename << application_for_offering.person.fullname\n filename << title\n ext = file.suffix.nil? || file.suffix == :original ? file.extension : file.suffix\n filename.join(' ').gsub(/[^a-z0-9 \\(\\)]+/i,'') + \".#{ext}\"\n end", "def filepath\n groupId = @groupId.gsub('.', '/')\n artifactId = @artifactId.gsub('.', '/')\n return \"#{groupId}/#{artifactId}/#{@version}/#{artifactId}-#{@version}\"\n end", "def filename\n return Pathname.new(@file_object.io.path) if @file_object.io.respond_to?(:path) && File.exist?(@file_object.io.path)\n end", "def filename\n return Pathname.new(@file_object.io.path) if @file_object.io.respond_to?(:path) && File.exist?(@file_object.io.path)\n end", "def create_full_filename(tv, q, f)\n ext = helper_make_ext(q,f)\n title = tv['track']['title'].dup\n title.gsub!(/'|\"/, ' ')\n title.gsub!(/[^A-Za-z0-9_ \\-]/, '_')\n title.gsub!(/ /, '')\n prefix = \"#{tv['track_key']} #{title}\"\n # We cut this off at 27 characters, basically trying to keep aif name\n # under 32 characters long.\n prefix.slice!(27..10000) if prefix.length > 27\n \"#{prefix}.#{ext}\"\n end", "def download_or_use_iso(iso_name)\n # TODO\n end", "def basename\n without_extension.delete_suffix(WIP_IDENTIFIER)\n .delete_suffix(DEV_IDENTIFIER)\n end", "def create_short_filename(tv, q, f)\n ext = helper_make_ext(q,f)\n \"#{tv['track_key']}.#{ext}\"\n end", "def filename(record, file)\n original = \"#{file.basename}.#{file.extension}\"\n write_attribute(:original_filename, original)\n ext = file.suffix.nil? || file.suffix == :original ? file.extension : file.suffix\n \"#{application_for_offering.id.to_s}-#{title.gsub(/[\\s,\\.\\\\\\/\\*\\?\\%\\:\\|\\\"\\'\\<\\>]?/,'')}.#{ext}\"\n end", "def filename()\n #This is a stub, used for indexing\n end", "def project_name\n DeliveryGolang::Helpers.project_name(node)\n end", "def temp_file\n File.join($config[\"processed_loc\"], File.basename(@origional_file).sub('.'+process_tag, '').sub(File.extname(@origional_file), '.mkv'))\n end", "def file_name\n @_file_name ||= [@file_name, 'checkout_step'].join('_')\n end", "def make_paltrack_file_name( proposal )\n if EdiHelper.current_out_is_cumulative\n @filename = \"#{@flow_type.upcase}#{EdiHelper.network_address}#{Time.now.strftime('%Y%m%d-%H%M%S')}.#{proposal.hub_address}\"\n else\n @filename = \"#{@flow_type.upcase}#{EdiHelper.network_address}#{@formatted_seq}.#{proposal.hub_address}\"\n end\n end", "def file_name\n case variant\n when :sample\n \"sample-#{md5}.#{file_ext}\"\n else\n \"#{md5}.#{file_ext}\"\n end\n end", "def file_name\n @file_name\n end", "def project_name\n \"$PROJECT_NAME v.$PROJECT_VERSION\"\n end", "def suggested_filename\n (oas_filename_pattern.presence || DEFAULT_FILENAME_PATTERN)\n .gsub('{{version}}', formatted_version)\n .gsub('{{extension}}', extension)\n end", "def gitolite_repository_name\n if (parent_path = get_full_parent_path).empty?\n project.identifier\n else\n File.join(parent_path, project.identifier)\n end\n end", "def file_name\n if source\n source.is_a?(File) ? File.basename(source.path) : File.basename(source)\n else\n object.original_name.nil? ? \"original_file\" : object.original_name\n end\n end", "def filename\n original_filename\n end", "def file_name\n File.basename @path\n end", "def file_name\n name.underscore\n end", "def pending_file_name(item = nil)\n get_file_data(item)[:name].presence\n end", "def file_path\n \"studio/#{type}/#{id}.xml\"\n end", "def filename\n return Pathname.new(file_object.io.path) if file_object.io.respond_to?(:path) && File.exist?(file_object.io.path)\n end", "def filename\n return Pathname.new(file_object.io.path) if file_object.io.respond_to?(:path) && File.exist?(file_object.io.path)\n end", "def filename\n return Pathname.new(file_object.io.path) if file_object.io.respond_to?(:path) && File.exist?(file_object.io.path)\n end", "def file_name\n file_name = (\"./tmp/database_doings/doing_uniques/uniques_done.txt\")\n end", "def file_name\n uploaded_file_file_name\n end", "def file_name\n ts = @entries.first.time_stamp\n File.join(@coord.options.output_dir,\n ts.strftime('%Y-%m-%d'),\n ts.strftime('%H-%M'),\n ts.strftime('%S.%3N-') + id)\n end", "def image_name\n ovf.elements['//References/File'].attributes['ovf:href']\n end", "def full_filename (for_file = model.document.file)\n for_file\n end", "def name\n file.partition(base).last.gsub(/[_\\/]/, \" \").strip\n end", "def archive_file_name\n @archive_file_name ||= stored_file.file_name\n end", "def filename\n return @file_object.io.path if @file_object.io.respond_to?(:path) && File.exist?(@file_object.io.path)\n end", "def filename\n local?? swf_url : tmp_file.path\n end", "def file_file_name\n f = nil\n if self.asset_clone_id.present?\n x = self.asset_clone\n f = x.asset_file_name if x.present?\n else\n f = self.asset_file_name\n end\n return f\n end", "def splunk_file(uri)\n require 'pathname'\n require 'uri'\n if URI.parse(uri).query.to_s.match(/filename=/)\n Pathname.new(URI.parse(uri).query).to_s.gsub(/^.*?filename=(.*?)\\&.*/, '\\1')\n else\n Pathname.new(URI.parse(uri).path).basename.to_s\n end\nend", "def project_name\n \"GS::Basic\"\n end", "def full_filename\n File.join(path, self.disk_filename)\n end", "def filename\n @file.basename.to_s\n end", "def original_filename\n @file_representation[:filename]\n end", "def name\n @name ||= filename.split(\".\").first.sub(/^_/, \"\")\n end", "def filename\n @name ||= \"#{timestamp}-#{secure_token(8)}.#{file.extension}\" if original_filename.present?\n end", "def file_name\n @file_name ||= File.basename tree\n end", "def filename_for_export\n return \"No file attached to this asset\" if target_item.files.empty?\n target_item.original_file.file_name.first\n end", "def file_name\n \"#{Time.current.to_i}-#{@file.original_filename}\"\n end", "def show\n @title = @stocked_file.original_name\n end", "def project_name\n return config['project_name'] if config['project_name']\n # using Dir.pwd will return something like: \n # /var/www/apps/staging.sweetspot.dm/releases/20061006155448\n # instead of\n # /var/www/apps/staging.sweetspot.dm/current\n pwd = ENV['PWD'] || Dir.pwd\n #another hack..ugh. If using standard capistrano setup, pwd will be the 'current' symlink.\n pwd = File.dirname(pwd) if File.symlink?(pwd)\n File.basename(pwd)\n end", "def filename(version)\n @file_id.sub(/\\.#{file_type}\\Z/, \".#{version}.#{file_type}\")\n end", "def filename\n case File.extname original_filename\n when /.zip/\n \"oag_airlines.xls.zip\"\n when /.xls/\n \"oag_airlines.xls\"\n end\n end", "def file_name\n return @file_name\n end", "def file_name\n return @file_name\n end", "def filename\n \"application_#{model.hash}.#{file.extension}\" if original_filename.present?\n end", "def filename\n @io.original_filename\n end", "def original_filename\n metadata[\"filename\"]\n end" ]
[ "0.7687124", "0.7661618", "0.6555441", "0.6227549", "0.61912704", "0.6129656", "0.6069429", "0.60249615", "0.600626", "0.6004811", "0.5976688", "0.58867466", "0.5886088", "0.58679813", "0.5866906", "0.58123213", "0.5811506", "0.5798067", "0.57360667", "0.5723885", "0.57183987", "0.56954837", "0.56954837", "0.56954277", "0.56775606", "0.56473875", "0.5639655", "0.5638511", "0.56301963", "0.5619482", "0.5617286", "0.56146437", "0.5613547", "0.56078607", "0.5602689", "0.56002206", "0.55917186", "0.5586749", "0.5576621", "0.55712533", "0.55680716", "0.5562377", "0.556048", "0.55581295", "0.55437106", "0.55384773", "0.55384773", "0.5537607", "0.5536418", "0.5529682", "0.55289143", "0.5526945", "0.5525118", "0.5524604", "0.55226076", "0.5517998", "0.5517594", "0.55092466", "0.5507447", "0.55050063", "0.54866236", "0.5486617", "0.54830736", "0.54813504", "0.5479289", "0.5477919", "0.5469637", "0.546687", "0.5466253", "0.5466253", "0.5466253", "0.546607", "0.5464654", "0.54610556", "0.54555434", "0.54527795", "0.54493695", "0.54448336", "0.5441931", "0.5440127", "0.5437477", "0.543517", "0.5434575", "0.5433273", "0.543134", "0.5413803", "0.5410963", "0.54090047", "0.5408202", "0.54077727", "0.540535", "0.54050016", "0.5401559", "0.53974", "0.53967774", "0.53885263", "0.53885263", "0.5386695", "0.53788763", "0.53771883" ]
0.74954957
2
Lazy loads and yields the data when evaluating
def load(serializer_instance, load_for, &block) record = if load_for.present? serializer_instance.object.public_send(load_for) else serializer_instance.object end BatchLoader.for(record).batch(key: cache_key(record)) do |records, loader| data = [] records.each do |r| value = calculate_value(r) data << value loader.call(r, value) end data = data.flatten.compact.uniq block&.call(data) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def result\n if not_already_loaded? && any_to_load?\n lazy_results.merge!(block_results)\n lazy_values.clear\n end\n lazy_results[value]\n end", "def eval\n yield self\n end", "def lazy\n yield\n yield\nend", "def evaluate(&block)\n instance_eval(&block)\n end", "def lazy(&block)\n DelayedEvaluator.new(&block)\n end", "def __yield\n return if @_undies_source_stack.nil? || (source = @_undies_source_stack.pop).nil?\n if source.file?\n instance_eval(source.data, source.source, 1)\n else\n instance_eval(&source.data)\n end\n end", "def data\n # If @data is defined, then we know we've been loaded in some\n # non-standard way, so we attempt to repair the data.\n repair! @data if defined? @data\n @raw_data ||= @@generator.next\n end", "def evaluate(&block)\n if block.arity > 0\n yield self\n else\n instance_exec(&block)\n end\n end", "def each\n load_all\n @facts.each do |name, fact|\n value = fact.value\n yield name.to_s, value unless value.nil?\n end\n end", "def __yield\n return if (source = @_undies_source_stack.pop).nil?\n if source.file?\n instance_eval(source.data, source.source, 1)\n else\n instance_eval(&source.data)\n end\n end", "def evaluate(&block)\n if block.arity.zero?\n instance_eval(&block)\n else\n yield(self)\n end\n end", "def lazy\n return each.lazy if key_value.collection.app.inside_parallel?\n super\n end", "def lazy?; @lazy; end", "def each\n loop do\n data = fetch\n\n if data\n yield data\n else\n break\n end\n end\n end", "def eager_load=(_arg0); end", "def eager_load=(_arg0); end", "def eager_load=(_arg0); end", "def evaluate(scope, locals, &block)\n File.read(eval(data))\n end", "def load(data)\n clear_transformed_data!\n data = [data] unless data[0].kind_of? Array\n data.each do |data| \n templated_data = apply_template(data)\n sets = result_sets(templated_data)\n sets.map! do |set|\n transform(set)\n end\n @transformed_values.push sets\n end\n self\n end", "def eval\n @block.eval\n end", "def data; @data ||= fetch; end", "def each(&block)\n get unless loaded\n self.objects.first[1].each(&block) rescue nil\n end", "def each\n yield :code, code\n yield :data, data\n end", "def eager_load_results(opts, eo, &block)\n opts.eager_load_results(eo, &block)\n end", "def render(scope=Object.new, locals={}, &block)\n if @data.nil?\n @data = @reader.call(self)\n compile!\n end\n evaluate scope, locals || {}, &block\n end", "def evaluated?; @__evaluated end", "def lazy\n Fetcher.new(self).lazy\n end", "def evaluate(scope, locals, &block); end", "def evaluate\n super\n content\n end", "def data(&block)\n if block_given?\n project_graph(nil) do |statement|\n block.call(statement) unless statement.variable? ||\n has_graph?(statement.subject) ||\n has_graph?(statement.object)\n end\n end\n enum_data\n end", "def evaluate scope, locals, &block\n Wisp.compile data\n end", "def evaluate\n context = Context.new(self, node)\n context.instance_exec(&block)\n node\n end", "def lazy(&block)\n callable = nil\n Pipeline.new(@pipes + [lambda do |e|\n callable ||= block.call\n callable.call(e)\n end])\n end", "def data\n # This is a common memoization technique used in Ruby\n @data ||= normalize_data\nend", "def get(data, ctx, lazy=false) # IDENTITY TRACKING AND LAZY LOADING\n entity_key = extract_key(data)\n key = [self, entity_key]\n # extract_key is generated ad-hoc by model compiler!\n if cached = ctx.entity_cache[key]\n cached\n else\n ctx.entity_cache[key] = get(*entity_key)\n # get is generated ad-hoc by model compiler\n end\n end", "def eager_load!; end", "def eager_load!; end", "def eager_load!; end", "def eager_load!; end", "def next() end", "def next() end", "def evaluate(*args, &block)\n self.class.evaluate(self, *args, &block)\n self\n end", "def evaluate\n\n end", "def pipelined\n yield\n end", "def values(&block)\n return super(&block) unless @lazy_loading && @processors.any?\n self.keys.map { |k| self[k] }\n end", "def try_with_cache(obj, source, consume_all); end", "def data\n @data ||= @_data.respond_to?(:call) ? @_data.call() : @_data\n end", "def context_for_eval; end", "def fetch(key)\n send(:[], key){return(yield if defined?(yield))}\n end", "def each(&block)\n return super(&block) unless @lazy_loading && @processors.any?\n self.keys.each { |k| block.(k, self[k]) }\n end", "def lazy_read(file)\n Enumerator.new do |yielder|\n CSV.foreach(file, DEFAULT_CSV_OPTIONS) do |row|\n yielder.yield(row)\n end\n end\n end", "def evaluate(scope, locals, &block)\n Tilt.new(eval(data)).render(scope, locals, &block)\n end", "def call\n if hash?\n return iterate_hash { |*args, **opts| yield(*args, **opts) }\n end\n\n iterate { |*args, **opts| yield(*args, **opts) }\n end", "def eager_load; end", "def eager_load; end", "def eager_load; end", "def with_sql_each(sql)\n if row_proc\n super(sql) do |obj|\n obj.forbid_lazy_load if obj.is_a?(InstanceMethods)\n yield obj\n end\n else\n super\n end\n end", "def result\n @result = yield\n end", "def fetch(*key)\n @cache[key] ||= yield\n end", "def rows\n @rows.lazy\n end", "def next!() end", "def each\n i = limit if limit\n loop do\n if data.length > 0 or refresh > 0\n if limit\n raise StopIteration if i == 0\n i = i - 1\n end\n if lazymap\n yield lazymap.call(data.shift)\n else\n yield data.shift\n end\n else\n raise StopIteration\n end\n end\n end", "def each\n response = run\n\n entities = @collection.deserialize(response.entities)\n entities.each { |x| yield(x) }\n\n while continue?(response)\n response.entities = []\n\n @options[:exclusive_start_key] = response.last_evaluated_key\n response = run(response)\n\n entities = @collection.deserialize(response.entities)\n entities.each { |x| yield(x) }\n end\n\n response.count\n end", "def value_cached_based_on(*whatever)\n segmented_path = lazy_cache_key_for(whatever)\n fragment = (@controller || self).read_fragment(segmented_path)\n fragment ? Marshal.load(fragment) : returning(yield) {|f| (@controller || self).write_fragment(segmented_path, Marshal.dump(f)) }\n end", "def each(node)\n load_all\n\n RFacter::DSL::COLLECTION.bind(self) do\n RFacter::DSL::NODE.bind(node) do\n @facts.each do |name, fact|\n value = fact.value\n unless value.nil?\n yield name.to_s, value\n end\n end\n end\n end\n end", "def cache\n yield\n end", "def lazy_map\n lazify.call(S.map)\n end", "def after_any_lazies(maybe_lazies)\n if maybe_lazies.any? { |l| lazy?(l) }\n GraphQL::Execution::Lazy.all(maybe_lazies).then do |result|\n yield result\n end\n else\n yield maybe_lazies\n end\n end", "def lazy_read(file)\n Enumerator.new do |yielder|\n CSV.foreach(file, DEFAULT_CSV_OPTIONS) do |row|\n yielder.yield(row)\n end\n end\n end", "def data\n self.load if @data.nil?\n @data\n end", "def process_iter(exp)\n call = exp.shift # the method call to which the iterator is passed\n params = exp.shift # arguments of the block\n code = exp.shift # the code block\n\n old_iter_dvars = @current_iter_dvars\n @current_iter_dvars = Set.new \n @block_whileloop_stack.push(:iter)\n \n # Get an argument name for the iterator function signature.\n arg_name = @model.encode_fresh_local_variable()\n\n fun_str = \"\"\n asgn_str = \"\"\n \n if params.nil? \n # Case 1: {}: Any number of arguments may be passed\n arity = -1\n fun_str << \"function(){\"\n elsif params == 0\n # Case 2: {||}: Zero arguments\n arity = 0\n fun_str << \"function(){\"\n elsif params.first == :masgn\n # Case 3: {|i,j|}: Multiple arguments (multiple assignment)\n arity = nil # |arity| >= 2 \n fun_str << \"function(#{arg_name}){\"\n\n # TODO: remove masgn_iter and instead put the corresponding logic\n # into yield!\n masgn_iter = @model.encode_globalattr(\"masgn_iter\")\n params << [:to_ary, [:special_to_ary, \"#{masgn_iter}(#{arg_name})\"]]\n want_expression(false) do\n without_result do\n asgn_str << process(params) \n end\n end\n else\n # Case 4: {|i|}: Single argument\n # TODO: warning if not exactly one argument is passed \n arity = 1\n fun_str << \"function(#{arg_name}){\"\n\n # we convert a single argument into a multiple assignment clause\n # with one argument.\n\n sasgn_iter = @model.encode_globalattr(\"sasgn_iter\")\n params << [:special_inline_js_value, \"#{arg_name}==null?#{@model.encode_nil}:#{arg_name}\"]\n\n want_expression(false) do\n without_result do\n asgn_str << process(params) \n end\n end\n end\n\n old_result_name = @result_name\n @result_name = nil\n\n block_str = \"\"\n want_expression(false) do\n want_result do\n block_str << process(code) if code\n end\n end\n\n # generate code for the variable declarations\n var_str = \"\"\n unless @current_iter_dvars.empty?\n var_str << \"var \"\n var_str << @current_iter_dvars.to_a.join(\",\")\n var_str << sep()\n end\n\n # declare and initialize the return value\n if @result_name\n var_str << \"var #{@result_name}=#{@model.encode_nil}#{sep()}\"\n end\n\n # NOTE: we don't need to initialize any dvar to nil, as \n # they can't be used before being assigned to (because\n # otherwise they are vcall's and not dynamic variables). \n\n str = fun_str + var_str + asgn_str + sep() + block_str\n str << \"#{sep()}return #{@result_name}\" if @result_name\n str << \"}\"\n\n put_iter(str)\n\n @result_name = old_result_name\n @current_iter_dvars = old_iter_dvars\n @block_whileloop_stack.pop || raise\n\n return process(call)\n end", "def yields\n parsed {\n @yields\n }\n end", "def include_gathered_data\n compile_user_data if @@aggregate.length == 6\n end", "def each\n yield(@value)\n end", "def scope() yield end", "def placeholder_eager_loader\n cached_fetch(:placeholder_eager_loader) do\n Sequel::Dataset::PlaceholderLiteralizer.loader(associated_dataset) do |pl, ds|\n apply_eager_limit_strategy(eager_loading_dataset.where(predicate_key=>pl.arg), eager_limit_strategy)\n end\n end\n end", "def call(*args)\n\t\tif @block\n\t\t\t# run sub-transform as defined by this closure\n\t\t\treturn @block.call @vars, *args\n\t\telse\n\t\t\t# return unmodified data\n\t\t\treturn *args\n\t\tend\n\tend", "def force\n case content.type\n when :eager\n content.value\n when :lazy\n promise = content.value.call\n if content.type != :eager\n content.type = promise.content.type\n content.value = promise.content.value\n promise.content = content\n end\n force\n else\n raise ScriptError, \"should not reach here\"\n end\n end", "def populate &block\n instance_eval(&block)\n self\n end", "def fetch; @data = pager.fetcher[self.begin, pager.per_page]; end", "def get_data\n\t\texecute unless @result\n\t\treturn get_data_from_result(@result)\n\tend", "def process_yield(exp)\n value = exp.shift\n\n str = without_result do\n want_expression do\n block_name() + \"(\" + (value ? process(value) : '') + \")\"\n end\n end\n resultify(str)\n end", "def get(data, &succ)\n if succ\n (data || []).filter(&@pred).map(&succ)\n else\n data\n end\n end", "def nextValue\n while setDataSource do\n result = @valueCreator.nextValue\n if (@valueCreator.hasValue) then\n if ([email protected](result.value)) then\n result.setValue(@transformer.transform(result.value))\n return result\n end\n else\n @valueCreator.resetSequenceSource\n end\n end\n return nil\n end", "def next()\n \n end", "def next()\n \n end", "def run_eager\n root_operation = query.selected_operation\n root_op_type = root_operation.operation_type || \"query\"\n root_type = schema.root_type_for_operation(root_op_type)\n st = get_current_runtime_state\n st.current_object = query.root_value\n st.current_result = @response\n runtime_object = root_type.wrap(query.root_value, context)\n runtime_object = schema.sync_lazy(runtime_object)\n\n if runtime_object.nil?\n # Root .authorized? returned false.\n @response = nil\n else\n call_method_on_directives(:resolve, runtime_object, root_operation.directives) do # execute query level directives\n gathered_selections = gather_selections(runtime_object, root_type, root_operation.selections)\n # This is kind of a hack -- `gathered_selections` is an Array if any of the selections\n # require isolation during execution (because of runtime directives). In that case,\n # make a new, isolated result hash for writing the result into. (That isolated response\n # is eventually merged back into the main response)\n #\n # Otherwise, `gathered_selections` is a hash of selections which can be\n # directly evaluated and the results can be written right into the main response hash.\n tap_or_each(gathered_selections) do |selections, is_selection_array|\n if is_selection_array\n selection_response = GraphQLResultHash.new(nil, nil, false)\n final_response = @response\n else\n selection_response = @response\n final_response = nil\n end\n\n @dataloader.append_job {\n st = get_current_runtime_state\n st.current_object = query.root_value\n st.current_result = selection_response\n # This is a less-frequent case; use a fast check since it's often not there.\n if (directives = selections[:graphql_directives])\n selections.delete(:graphql_directives)\n end\n call_method_on_directives(:resolve, runtime_object, directives) do\n evaluate_selections(\n runtime_object,\n root_type,\n root_op_type == \"mutation\",\n selections,\n selection_response,\n final_response,\n nil,\n )\n end\n }\n end\n end\n end\n delete_all_interpreter_context\n nil\n end", "def load\n eval(@data, TOPLEVEL_BINDING, @filename)\n end", "def result(data)\n walk(template, data)\n end", "def each\n request unless initialized?\n @data.each do |hash|\n yield entry(hash)\n end\n end", "def load_static_cache_rows\n if rows = Sequel.synchronize{@static_cache_cache[name]}\n rows.map{|row| call(row)}.freeze\n else\n rows = dataset.all.freeze\n raw_rows = rows.map(&:values)\n Sequel.synchronize{@static_cache_cache[name] = raw_rows}\n rows\n end\n end", "def each(&block)\n return enum_for :each unless block\n\n @data.each(&block)\n\n self\n end", "def load_data\n return if [:loading, :ready ].include? state\n self.state = :loading\n data_loader.async.load_data\n end", "def evaluate(scope, locals, &block)\n @data = build_mixin_body(scope) + data\n super\n end", "def run\n yield\n end", "def each\n return enum_for unless block_given?\n\n loop do\n data = EXIF.exif_loader_get_data(self)\n\n if data.null?\n break\n end\n\n yield Data.new(data)\n end\n end", "def lazy_select(&block)\n Enumerator.new do |y|\n self.each do |x|\n y.yield(x) if block.call(x)\n end\n end\n end", "def evaluate(scope)\n end", "def each\n return enum_for(:each) unless block_given?\n\n @data.collection.each { |item| yield item }\n end", "def after_lazy(value)\n if lazy?(value)\n GraphQL::Execution::Lazy.new do\n result = sync_lazy(value)\n # The returned result might also be lazy, so check it, too\n after_lazy(result) do |final_result|\n yield(final_result) if block_given?\n end\n end\n else\n yield(value) if block_given?\n end\n end", "def perform\n @resolved_name = yield name ? [name] : []\n @resolved_value = yield value ? [value] : []\n end" ]
[ "0.6682949", "0.65320414", "0.61216915", "0.6116302", "0.60013926", "0.59971803", "0.59923756", "0.5962693", "0.5895884", "0.5894882", "0.5885427", "0.5861535", "0.5797292", "0.57912785", "0.57319814", "0.57319814", "0.57319814", "0.56762177", "0.5659655", "0.56537145", "0.5650501", "0.5633741", "0.56067973", "0.56040925", "0.5581455", "0.5572499", "0.55422986", "0.55329365", "0.55236584", "0.5505464", "0.5497589", "0.5490304", "0.54895514", "0.54651237", "0.54466015", "0.54366034", "0.54366034", "0.54366034", "0.54366034", "0.54357606", "0.54357606", "0.5430098", "0.54128474", "0.54123944", "0.5400292", "0.5392517", "0.5392332", "0.5380264", "0.53690237", "0.53631", "0.5360077", "0.5359744", "0.5358376", "0.5354147", "0.5354147", "0.5354147", "0.5339397", "0.5328534", "0.5325169", "0.53134656", "0.5309986", "0.5309699", "0.5296422", "0.5296287", "0.5292563", "0.5272687", "0.52595544", "0.52256703", "0.52241087", "0.5223425", "0.5206465", "0.5206265", "0.5203707", "0.5190463", "0.51848847", "0.5182871", "0.51797426", "0.5173995", "0.5167572", "0.51593584", "0.5154895", "0.5154693", "0.5153929", "0.51505893", "0.51441216", "0.51441216", "0.5138684", "0.5129077", "0.5125621", "0.5121503", "0.511963", "0.5116786", "0.5107972", "0.5104515", "0.5098537", "0.5090317", "0.5087269", "0.50867784", "0.5077928", "0.50705916", "0.5062765" ]
0.0
-1
Public: Returns if the high score podium, and high score list, should be displayed to the user.
def scores_enabled? session[:show_scores] != false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def judge_scores?\n standard_skill_score_entries.any?\n end", "def pl_high?\n session[:player].hand_total > session[:dealer].hand_total\n end", "def enough_scores?\n self.scores.count > 2 \n end", "def has_scores?\n @user.personal_scores.published.any?\n end", "def overall_draw?(score)\n\tputs \"\\n-------------------------------------------------------\"\n\tputs \"Player 1 score is \" + \"#{score[$player1]}\" \n\tputs \"Player 2 score is \" + \"#{score[$player2]}\" \n\tscore[$player1] == score[$player2]\nend", "def full_display?(flat_answer_data)\n true\n end", "def advantage?\n (score1 - score2).abs == 1 &&\n score1 >= deuce_minimum &&\n score2 >= deuce_minimum\n end", "def score\n handscore = possible_scores.sort.reverse\n handscore.detect { |value| value <= 21 } or handscore.last\n end", "def full_hp?\n return @hp == MAX_HITPOINT\n end", "def display?(flat_answer_data)\n true\n end", "def won?\n total_score\n #check to see total_score_instance > 100 - if it is, return true, else return false\n if @total_score_instance > 100\n return true\n else\n return false\n end\n end", "def important?\n !@story_points.nil? && @story_points > 2\n end", "def score_frame\n strike_frame?\n spare_or_open_frame?\n end", "def should_show_height?(question)\n answer_for(question, is_first_pv1?)\n end", "def best_out_of_five?\n if @user_score == 3 && (@user_score + @comp_score) == 5\n puts \"You win the game!!!\"\n return true\n elsif @comp_score == 3 && (@user_score + @comp_score) == 5\n puts \"You lost the game, better luck next time!\"\n return true\n else\n return false\n end\n end", "def show_perc?\n @perc\n end", "def scored?\n metric_type_codename == :score ||\n metric_type_codename == :wiki_rating\nend", "def check_if_all_pop_ups_are_displayed\n\n your_league_pop_up_should_not_be_displayed\n make_your_predictions_pop_up_should_not_be_displayed\n join_private_league_pop_up_should_not_be_displayed\n join_public_league_pop_up_should_not_be_displayed\n create_your_own_league_pop_up_should_not_be_displayed\n\n end", "def show_winner_and_scores\n display_winner_and_secret_code(@winner, @secret_code)\n display_player_score(@human)\n display_player_score(@machine)\n end", "def game_ending?\n @first_score > 3000 || @second_score > 3000\n end", "def high?\n severity == 3\n end", "def print_score\n puts 'Game Over'\n if @p1_score > @p2_score\n puts \"Congrats #{@player1} wins with #{@p1_score} correct sets\"\n else if @p2_score > @p1_score\n puts \"Congrats #{@player2} wins with #{@p2_score} correct sets\"\n else\n puts 'It a tie'\n\n end \n end \nend", "def accepted?\n score == max_score\n end", "def visibility_allowed?\n value=(self.num_answered_questions().to_f/self.num_questions()*100).round(2)\n !self.is_test? && value >= Rails.application.config.default_plan_percentage_answered\n end", "def opinion_show_poll?\n\t\t\tbegin\n\t\t\t\t!opinion_user.nil?\n\t\t\trescue NoMethodError\n\t\t\t\tfalse\n\t\t\tend\n\t\tend", "def advantage?\n @points > @opponent.points && @points > 3\n end", "def double_faced?\n two_up? && mana_costs_shown.select(&:present?).count < 2\n end", "def displayed?; end", "def top_numbers?\n true\n end", "def smartRankingEnabled?\n smart_ranking_element.count > 0 \n end", "def critical?\n hp_rate <= Critical_Rate\n end", "def critical?\n hp_rate <= Critical_Rate\n end", "def enable_or_disable_scores\n if params[:scores].present?\n session[:show_scores] = ! SCORE_OFF_VALUES.include?(params[:scores])\n end\n end", "def score_last_frame\n spare_or_open_frame_in_last_frame?\n bonus_round?\n bonus_round_valid?\n end", "def good?\n @summary[:total_score] <= Constants::THRESHOLDS[\"Project\"]\n end", "def game_score\n \n if (@player1.points > 3 || @player2.points > 3) && (@player2.points - @player1.points > 1 || @player1.points - @player2.points > 1)\n return \"#{@player1.score}\"\n elsif (@player1.points >= 3 && @player2.points >= 3) && (@player2.points - @player1.points == 1 || @player1.points - @player2.points == 1)\n return \"#{@player1.score}\"\n elsif @player1.points >= 3 && @player2.points - @player1.points == 0\n return \"#{@player1.score}\"\n elsif @player1.points == @player2.points && @player1.points < 3 \n return \"#{@player1.score} all\"\n elsif @player1.points != @player2.points && @player1.points <= 3 && @player2.points <= 3 \n return \"#{@player1.score}: #{@player2.score}\"\n else\n return \"this is an unfamiliar scoring situation\"\n end\n end", "def won?\n total_score > 100 ? true : false\n end", "def win_game?\n if @user_score == 2 && (@user_score + @comp_score) == 3\n puts \"You win!!!\"\n return true\n elsif @comp_score == 2 && (@user_score + @comp_score) == 3\n puts \"You lost, better luck next time!\"\n return true\n else\n return false\n end\n end", "def won?\n return total_score > 100 ? true : false\n end", "def competitor_has_result?(competitor)\n competitor.scores.any?\n end", "def display_score score, rank\r\n if score == nil\r\n puts \"There is no #{rank} score\"\r\n else\r\n puts \"The #{rank} score is #{score}\"\r\n end\r\n end", "def print_scores_and_determine_winner\n tie = false\n puts \"\\nScores:\"\n winner = @players[0]\n (0..num_players - 1).each do |i|\n puts \"\\n#{@players[i].name} : #{@players[i].score}\"\n tie = @players[i].score == winner.score\n winner = @players[i] if @players[i].score > winner.score\n end\n\n puts \"\\nIt was a tie!\" if tie == true\n puts 'Congratulations ' + winner.name + \"!! You win!!\\n\" if tie == false\n end", "def display_score(player_wins, computer_wins) # keeps track of number of wins for each side\n puts \"================================================\"\n if player_wins == MAXIMUM_WINS\n prompt(\"Congratulations, Player collected #{MAXIMUM_WINS} wins. Player won the entire game!\")\n elsif computer_wins == MAXIMUM_WINS\n prompt(\"Sorry, Computer has won #{MAXIMUM_WINS} times before you #sad_day\")\n else\n prompt(\"Current Score is #{player_wins}(User):#{computer_wins}(Computer)\")\n end\n puts \"================================================\"\nend", "def show?\n user.rank > SCHOOL_RANK || user.college == @college.id\n end", "def entertained?\n return maximus?\n end", "def question_max_score\n question = Question.find(self.question_id)\n if question.type == \"Checkbox\"\n return 1\n elsif question.is_a? ScoredQuestion\n @question_max_score\n else\n \"N/A\"\n end\n end", "def question_max_score\n question = Question.find(self.question_id)\n if question.type == \"Checkbox\"\n return 1\n elsif question.is_a? ScoredQuestion\n @question_max_score\n else\n \"N/A\"\n end\n end", "def system_fault_level_score_message\n score = [system_fault_level_lv_score, system_fault_level_hv_score].max\n score_message = \"Very Low\" if score == 1\n score_message = \"Low\" if score == 2\n score_message = \"Moderate\" if score == 3\n score_message = \"High\" if score == 4\n score_message = \"Very High\" if score == 5 \n return score_message\n end", "def winning_scores\n high_score = scores.max{|score| score.total}.total\n scores.select {|score| score.total == high_score}\n end", "def hungry?\n return (@hunger > @max_health/2)\n end", "def competitor_has_result?(competitor)\n competitor.scores.count > 0\n end", "def is_freelancer_skills_displayed\n @driver.find_element(:xpath, FREELANCER_SKILLS).displayed?\n end", "def display_score\n puts \"-----#{@name}-----\"\n puts \"Score: #{@score} \"\n puts \"Lives left: #{@lives}\"\n puts \"---------------\"\n end", "def all_secondary_picks_are_wins?\n user_picks = secondary_pool_picks\n return false if user_picks.count < Week.closed_second_chance_pick_week_ids.count\n return user_picks.select{|x| x.is_game_over? }.select{|y| !y.is_a_winner? }.count == 0\n end", "def display_score score, rank\n\tif score == nil\n\t return\n\tend\n\t\n\tif rank > 3\n\t puts \"The total of remaining scores is #{score}\"\n\telsif rank == 0\n\t puts \"The first score is #{score}\"\n\telsif rank == 1\n\t puts \"The second score is #{score}\"\n\telsif rank == 2\n\t puts \"The third score is #{score}\"\n\tend\n end", "def third_screen_visible?\n @third_screen_title.visible?\n end", "def show_game_over_message\n if @score > @@max_score\n @@max_score = @score\n end\n Text.new(\"Game over\", color: \"red\", x: 200, y: 150, size: 50)\n Text.new(\"Score: #{@score}, max score: #{@@max_score}\",\n color: \"blue\", x: 120, y: 300, size: 25)\n end", "def high_bid_is_kiosk?\n return false if self.bid_histories.blank? || !self.member_id.present?\n last_bid = self.bid_histories.first\n last_bid.bid_amount == self.high_bid_amount &&\n last_bid.member_id == self.member_id &&\n ( last_bid.bid_source_code == BidHistory::BID_SOURCE_BID_BUTLER_KIOSK_DIFFERENT_YARD ||\n last_bid.bid_source_code == BidHistory::BID_SOURCE_BID_BUTLER_KIOSK_SAME_YARD ||\n last_bid.bid_source_code == BidHistory::BID_SOURCE_KIOSK_DIFFERENT_YARD ||\n last_bid.bid_source_code == BidHistory::BID_SOURCE_KIOSK_SAME_YARD )\n end", "def pro_rating?\n safe_rating >= Elo.config.pro_rating_boundry\n end", "def hungry?\n\n\t\t @stuff_in_belly <= 2\n\t\tend", "def confidence_high?\n @json[:confidence] == 'High'\n end", "def display_message?\n if play? || seconds - @last_time_value < 6 && @last_time_value >= @level_num\n true\n else\n false\n end\n end", "def display_score score, rank\r\n\r\n end", "def display_scores\n puts \"P1: #{@player1.lives}/3 vs P2: #{@player2.lives}/3\"\n end", "def score\n p1_score = players.first.score \n p2_score = players[1].score\n\n if p1_score == p2_score\n score_word = SCORE_NUMBER_TO_WORD_MAP[0..-2][p1_score]\n return score_word ? score_word + \"-All\" : \"Deuce\"\n elsif p1_score <= 3 && p2_score <= 3\n return players.map{|player| SCORE_NUMBER_TO_WORD_MAP[player.score] }.join(\"-\")\n else\n winning_player = players.sort{|a, b| a.score <=> b.score}.last\n return (p1_score - p2_score).abs == 1 ? \"Advantage #{winning_player.name}\" : \"Win for #{winning_player.name}\"\n end\n end", "def display_final_scores(players)\n\t\tall_scores = []\n\t\tputs \"\\n\\n\"\n\t\tputs \"*\"*20\n\t\tputs \"FINAL SCORES\"\n\t\tplayers.each do |player|\n\t\t\tplayer_score = player.score[:grand_total][:score]\n\t\t\tputs \"\\tPlayer#{player.id}: #{player_score}\"\n\t\t\tall_scores << player_score\n\t\tend\n\t\tmax_score = all_scores.max\n\t\tif all_scores.count(max_score) > 1\n\t\t\tputs \"Its a tie!! Play again to find out clear winner!!\"\n\t\telse\n\t\t\tputs \"Player #{all_scores.index(max_score) + 1} wins!!!! Yay!! Congratulations!!\"\n\t\tend\n\t\t\n\t\tputs \"*\"*20\n\n\tend", "def latest_is_personal_best?\n latest == personal_best\n end", "def high_score(current_score,finished_game_counter)\n if finished_game_counter == 0\n puts \"No games played yet\"\n elsif\n puts \"Best game: #{current_score} turns\"\n end\nend", "def list_top_players\n if @highscore_list.empty?\n puts \"No available data.\"\n else\n table = TTY::Table.new header: ['Name', 'Score']\n @highscore_list.each do |player|\n table << [player.name, player.score]\n end\n\n finalTable = table.render :unicode do |renderer|\n renderer.alignments = [:left, :center]\n renderer.border.separator = :each_row\n end\n\n puts \"Sets Current Highscore\"\n puts finalTable\n end\n \n end", "def is_company_skills_displayed\n @driver.find_element(:xpath, COMPANY_SKILLS).displayed?\n end", "def render_score; end", "def hungry?\n\t\t@stuff_in_belly <= 2\n\tend", "def hungry?\n\t\t@stuff_in_belly <= 2\n\tend", "def advantage\n (score1 > score2 ? 1 : 2) if advantage?\n end", "def score_for( kinployee )\n @kinployment.preferred_availability <= kinployee.availability ?\n 1.0 :\n 0.0\n end", "def show_prf?\n bathing_water['latestProfile.pollutionRiskForecasting'].val == 'true'\n end", "def hand?\n @cards_by_score.length == 5\n end", "def show?\n answers.any?\n end", "def score\n return 'love' if @points == 0\n return 'fifteen' if @points == 1\n return 'thirty' if @points == 2\n return 'duece' if @points == 3 && @opponent.points == 3\n return 'forty' if @points == 3\n game_won?\n end", "def is_game_over?; won_by?(:hunter) || won_by?(:prey) end", "def busted?(total)\n total > GAME_HIGH\nend", "def umpire_call\n if deuce? \n \"The score is deuce\"\n elsif @player1.points >= 4 || @player2.points >= 4\n if @player1.points >= 4 && @player1.points >= @player2.points + 2\n \"Player 1 has won\"\n elsif @player2.points >= 4 && @player2.points >= @player1.points + 2\n \"Player 2 has won\"\n elsif advantage?\n \"The score is advantage\"\n end\n else\n \"The score is \" + \"#{player1.score}\" + \"-\" + \"#{player2.score}\"\n end\n end", "def base_is_most_popular?\n most_popular.nil? ? nil : most_popular[0] == base_answer.food_groups\n end", "def game_over?\n @game_over\n end", "def display_all_scores\n show_wait_cursor(3)\n all_scores = @score_table.score_table\n say '----------------------'.yellow\n all_scores.each { |s| say 'player:' + all_scores.index(s).to_s.blue + ' score: ' + s.to_s.red }\n say '----------------------'.yellow\n end", "def prime?\n @badges.key? 'premium'\n end", "def default_level?\n experience_points_threshold == 0\n end", "def score\n if (@deuce == false && @advantage == false)\n @score[@points]\n elsif @deuce\n 'deuce'\n elsif @advantage\n 'advantage'\n end\n \n end", "def has_honors\n if @gpa >= 3.5\n return true\n end\n return false\n end", "def display_highscores(highscores_array)\n highscores_window = content_windows[:highscores_window]\n # Set the color of the text to be white\n highscores_window.attron(Curses.color_pair(8))\n # Set headings for scores\n highscores_window.setpos(1, 1)\n highscores_window.addstr('# NAME SCORE')\n\n # Loop through each hash in the highscores array\n highscores_array.each_with_index do |hash, i|\n highscores_window.setpos(4 + i * 2, 1)\n # For the tenth ranking, move the curser one to the left so that the numbers line up on screen\n highscores_window.setpos(4 + i * 2, 0) if i > 8\n # Add name and score for each hash to the window\n highscores_window.addstr(\"#{i + 1} #{hash['name']} #{hash['score'].rjust(6, ' ')}\")\n end\n highscores_window.noutrefresh\nend", "def check_score\n if @player_1.lose\n winner(@player_2)\n elsif @player_2.lose\n winner(@player_1)\n end\n end", "def failed?\n if score.present? and min_score.present?\n score < min_score\n end\n end", "def show?\n user.rank > SCHOOL_RANK || user.unit == @unit\n end", "def show_section_appraisal_moderated?\n subject.lead?(record) ||\n (\n record.assessor_assignments.moderated.submitted? &&\n (\n subject.primary?(record) ||\n (assessor? && record.from_previous_years?)\n )\n )\n end", "def only_show_summary?\n\t\tcount = 0\t\n\t\t[\"payable_from_organization_id\",\"payable_to_organization_id\",\"payable_from_patient_id\"].each do |k|\n\t\t\tcount+=1 unless self.send(k.to_sym).blank?\n\t\tend\n\t\tcount <= 1\n\tend", "def hungry?\n\t @stuff_in_belly <= 2\n\tend", "def rank_officer?\n !rank_id.nil? && rank.rate > 2\n end", "def won?\n [score1, score2].max >= win_minimum && (score1 - score2).abs >= win_margin\n end", "def index\n @scores = Score.all\n @high_scores = Score.order(correct: :desc).where.not(:correct => nil)\n @score = session[:score]\n end", "def pro_rating?\n rating >= Player::PRO_RATING_BOUNDARY\n end" ]
[ "0.66911125", "0.6429269", "0.6407012", "0.6293705", "0.6146136", "0.60757124", "0.6049819", "0.59835166", "0.59547895", "0.59404993", "0.5918795", "0.59092087", "0.5896555", "0.587732", "0.5867047", "0.5859357", "0.58472526", "0.5832752", "0.5822404", "0.5817523", "0.5796817", "0.57935596", "0.5778079", "0.5777265", "0.5774548", "0.5764716", "0.5763659", "0.5736489", "0.5735351", "0.5730781", "0.5724168", "0.5724168", "0.57048774", "0.569637", "0.56923395", "0.5682684", "0.5676683", "0.5673905", "0.5671377", "0.5663345", "0.564069", "0.5635643", "0.563443", "0.56302726", "0.5626432", "0.5621218", "0.5621218", "0.56141686", "0.5613473", "0.5598817", "0.5592256", "0.55913794", "0.5584257", "0.55833006", "0.5582076", "0.5578501", "0.5575871", "0.5575397", "0.5558624", "0.55563796", "0.55500436", "0.5547124", "0.55455166", "0.55412537", "0.5539586", "0.5535186", "0.55305284", "0.55197805", "0.551721", "0.5510801", "0.55080235", "0.55015326", "0.55015326", "0.5496334", "0.54956406", "0.5490814", "0.5487558", "0.548347", "0.547404", "0.5467122", "0.5466588", "0.5461513", "0.5460317", "0.5451478", "0.54508734", "0.5450459", "0.5450237", "0.54494417", "0.5447827", "0.5443588", "0.5439975", "0.54392296", "0.54284185", "0.54236907", "0.5420845", "0.5418277", "0.54176193", "0.54123116", "0.5404383", "0.5396844" ]
0.6657101
1
Shows or hides scores depending on the +score+ query param.
def enable_or_disable_scores if params[:scores].present? session[:show_scores] = ! SCORE_OFF_VALUES.include?(params[:scores]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_score score, rank\r\n\r\n end", "def display_score score, rank\r\n if score == nil\r\n puts \"There is no #{rank} score\"\r\n else\r\n puts \"The #{rank} score is #{score}\"\r\n end\r\n end", "def display_score score, rank\n\tif score == nil\n\t return\n\tend\n\t\n\tif rank > 3\n\t puts \"The total of remaining scores is #{score}\"\n\telsif rank == 0\n\t puts \"The first score is #{score}\"\n\telsif rank == 1\n\t puts \"The second score is #{score}\"\n\telsif rank == 2\n\t puts \"The third score is #{score}\"\n\tend\n end", "def set_score\n @score = ScoreService.detail(current_user.id, params[:view_number])\n routing_error if @score.blank?\n end", "def index\n if show_score?\n flash[:positiv] = \"You got it. Your score is \" + current_score.to_s + \".\"\n delete_score\n end\n\n @scores = Score.all.order(score: :desc)\n end", "def display_score\n puts \"-----#{@name}-----\"\n puts \"Score: #{@score} \"\n puts \"Lives left: #{@lives}\"\n puts \"---------------\"\n end", "def show\n authorize @score\n end", "def set_score\n @score = Score.find(params[:id])\n end", "def set_score\n @score = Score.find(params[:id])\n end", "def set_score\n @score = Score.find(params[:id])\n end", "def set_score\n @score = Score.find(params[:id])\n end", "def set_score\n @score = Score.find(params[:id])\n end", "def set_score\n @score = Score.find(params[:id])\n end", "def set_score\n @score = Score.find(params[:id])\n end", "def set_score\n @score = Score.find(params[:id])\n end", "def set_score\n @score = Score.find(params[:id])\n end", "def set_score\n @score = Score.find(params[:id])\n end", "def set_score\n @score = Score.find(params[:id])\n end", "def show_score\n puts \"\"\n puts \"Your total is: #{@score}/25\"\n puts \"\"\n case @score\n when 0..5\n puts \"Shameful\"\n when 6..10\n puts \"I wouldn't go bragging about this\"\n when 11..12\n puts \"Might need some more help next time!\"\n when 13..14\n puts \"Not too bad!\"\n when 15..17\n puts \"Nice work!\"\n when 18..19\n puts \"Great score!\"\n when 20..21\n puts \"You cracked 20, excellent effort\"\n when 22..24\n puts \"That was out of this world!\"\n when 25\n puts \"Me oh my, perfect score!\"\n end\n end", "def set_score\n @score = Score.find(params[:id])\n end", "def show\n @score = Score.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @score }\n end\n end", "def show\n @score = Score.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @score }\n end\n end", "def show\n @score = Score.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @score }\n end\n end", "def show_score\n puts\n @@score.each do |player, score|\n print \"- #{player.capitalize}: #{score} -\"\n end\n puts\n end", "def show\n @score = Score.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @score }\n end\n end", "def score=(value)\n @score = value\n end", "def key_for(score)\n if score.nil?\n return :not_participated\n end\n\n # if you change the scoring, remember to change the 'about method' page as well.\n case score\n when 0...33\n :against\n when 33...66\n :for_and_against\n when 66..100\n :for\n end\n end", "def scores\n @title_page = 'Scores'\n $game.player.score = params['grade'].to_i\n\n @username = $game.player.username\n @score = $game.player.score\n\n response = Request.post_request(URL_SCORES, {\n username: $game.player.username,\n score: $game.player.score\n })\n\n @scores = Request.manage_response(response)\n\n erb :scores, layout: :template\nend", "def render_score; end", "def display_all_scores\n show_wait_cursor(3)\n all_scores = @score_table.score_table\n say '----------------------'.yellow\n all_scores.each { |s| say 'player:' + all_scores.index(s).to_s.blue + ' score: ' + s.to_s.red }\n say '----------------------'.yellow\n end", "def game_score(score)\n end", "def scores_enabled?\n session[:show_scores] != false\n end", "def index\n @scores = Score.all\n @high_scores = Score.order(correct: :desc).where.not(:correct => nil)\n @score = session[:score]\n end", "def show\n @score = Score.find(params[:id])\n\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @score }\n end\n end", "def score_params\n params.fetch(:score, {})\n end", "def show\n @score = Score.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @score }\n end\n end", "def show\n @score_board = ScoreBoard.find(params[:id])\n end", "def score_params\n\t\t\tparams.require(:score).permit(:a1, :a2, :a3, :a4, :a5, :a6, :a7, :a8, :a9, :a10, :a11, :a12, \n\t\t\t:b1, :b2, :b3, :b4, :b5, :b6, :b7, :b8, :c1, :c2, :c3, :c4, :c5, :c6, :c7, :c8, :c9, :c10, \n\t\t\t:d1, :d2, :d3, :d4, :d5, :d6, :d7, :d8, :e1, :e2, :e3, :e4, :comment) unless !params.has_key?(\"score\")\n\t\tend", "def set_user_score\n @user_score = UserScore.find(params[:id])\n end", "def add_score()\n\t\tscore = params[:score]\n\t\treader_id = session[:user_id]\n\t\tapp = App.find(params[:id])\n\t\tif reader_id.to_s == app.reader_1.to_s\n\t\t\tapp.score_1 = score\n\t\telsif reader_id.to_s == app.reader_2.to_s\n\t\t\tapp.score_2 = score\n\t\tend\n\t\tif app.save\n\t\t\tredirect_to :back\n\t\telse\n\t\t\tflash[:error] = app.errors.full_messages.last\n\t\t\tredirect_to :back\n\t\tend\n\tend", "def show_scores\n puts \"Showing scores: \"\n @state_scores.each_pair do |state, score|\n position = state[:position]\n player = state[:player]\n puts\n p position\n puts \"Player to move: #{player}\"\n puts \"Score: #{score}\"\n end\n end", "def score\n respond_to do |format|\n if @survey.score\n format.html { redirect_to edit_admins_thriver_path(@user), notice: 'Survey was successfully scored.' }\n format.json { render :show, status: :ok, location: @survey }\n else\n format.html { render :edit }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def score_display(score, difficulty)\n \"Current Score: #{score} | Difficulty: #{difficulty[7]}\".colorize(@@colours[0])\n end", "def call_score\n if @player1.points == @player2.points\n tie_score\n elsif advantage?\n advantage \n else \n \"#{current_server.score} #{current_server.opponent.score}\"\n end\n end", "def score_player(player,score)\n\t\tputs \"|#{player[0]}: #{score[0]} |_SCORE_| #{player[1]}: #{score[1]}|\\n\\n\".colorize(:red) \n\tend", "def set_score_query\n @score_query = ScoreHistory.find(params[:id])\n end", "def set_score_query\n @score_query = ScoreHistory.find(params[:id])\n end", "def show\n @game = Game.find(params[:id])\n @score = Score.new\n end", "def show\n @enrolled_score = EnrolledScore.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @enrolled_score }\n end\n end", "def do_something_with(score)\n puts \"doing something with score: #{score}\"\n end", "def score_query_params\n params[:score_query]\n end", "def score_query_params\n params[:score_query]\n end", "def set_gamescore\n @gamescore = Gamescore.find(params[:id])\n end", "def score_params\n params.require(:score).permit(:score, :user_id)\n end", "def show\n @score = Evaluation.eval_user(@user)\n end", "def update\n\t\t@score_board = ScoreBoard.find(params[:id])\n\t\tif @score_board\n\t\t\t@score_board.update_attributes(score: params[:score].to_i)\n\t\t\tapi_response(@score_board, 'Score Board updated', :ok)\n\t\telse\n\t\t\tapi_response(nil, 'Cannot find score', :bad_request)\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @score.update(score_params)\n format.html { redirect_to @score, notice: 'Score was successfully updated.' }\n format.json { render :show, status: :ok, location: @score }\n else\n format.html { render :edit }\n format.json { render json: @score.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @score.update(score_params)\n format.html { redirect_to @score, notice: 'Score was successfully updated.' }\n format.json { render :show, status: :ok, location: @score }\n else\n format.html { render :edit }\n format.json { render json: @score.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @score.update(score_params)\n format.html { redirect_to @score, notice: 'Score was successfully updated.' }\n format.json { render :show, status: :ok, location: @score }\n else\n format.html { render :edit }\n format.json { render json: @score.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @score.update(score_params)\n format.html { redirect_to @score, notice: 'Score was successfully updated.' }\n format.json { render :show, status: :ok, location: @score }\n else\n format.html { render :edit }\n format.json { render json: @score.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @user = User.find(session[:user_id])\n @quiz=Quiz.find(params[:id])\n @article=Article.find(params[:id])\n\n if(Score.where([\"user_id = ? and article_id = ? and score > ?\", @user.id, @quiz.id, 49]).blank?)\n if(Score.find_by(user_id: @user.id, article_id: @quiz.id, score: -1).blank?)\n @score = Score.new({user_id: @user.id, article_id: @quiz.id, score: -1})\n @score.save\n else\n @score=Score.find_by(user_id: @user.id, article_id: @quiz.id, score: -1)\n end\n else\n flash[:danger] = \"Quiz already passed\"\n redirect_to(@article)\n end\n\n end", "def test_scores(score)\n puts \"Student scored an #{score}\"\n end", "def score(player)\n\t$running = false\n\tplayer.score += 1\n\t$gui.show_scored(player.name)\n\t$gui.show_info()\n\t$gui.update_score($p1.score, $p2.score)\nend", "def set_question_score\n @question_score = QuestionScore.find(params[:id])\n end", "def score_params\n if params.has_key?(:score)\n params.require(:score).permit(:name, :score, :game_id)\n end\n end", "def set_student_score\n @student_score = StudentScore.find(params[:id])\n end", "def display_scoreboard\n puts \"The score is\"\n puts \"#{@player_1_name}\"+\" #{@player_1_score}\" \n puts \"#{@player_2_name}\"+\" #{@player_2_score}\"\n puts\n end", "def addScore _score=0\n SQF.addScore @this, _score\n end", "def show\n @game_score = GameScore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @game_score }\n end\n end", "def show\n @username_score = UsernameScore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @username_score }\n end\n end", "def update\n respond_to do |format|\n if @score.update(score_params)\n format.html { redirect_to @score, notice: 'Score was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @score.errors, status: :unprocessable_entity }\n end\n end\n end", "def scoring \n\t\tscore = rand(10)\n\t\tputs \"And the score is #{score}.\"\n\tend", "def set_score_summary\n @score_summary = ScoreSummary.find(params[:id])\n end", "def index\n authorize Score\n @scores = Score.all\n end", "def show\n @rec2 = Leaderboard.find_by_user_email_and_quiz_id(current_user.email, 3)\n @current_url2 = request.env['PATH_INFO']\n if (@rec2.state>=1 && @rec2.state < Bollywood.count() && @current_url2 == \"/bollywoods/1\")\n @rec2.score = 0\n @rec2.state = 0\n @rec2.save\n end\n if (@bollywood.ques_type.include? \"Single\")\n if @rec2.state >= Bollywood.count()\n @rec2.state = 0\n @rec2.score = 0\n @rec2.save\n end\n if (@bollywood.answer == params[:option])\n @rec2.state += 1\n @rec2.score = @rec2.score + 100\n @rec2.save\n elsif (params[:option].present? && @bollywood.answer != params[:option])\n @rec2.state += 1\n @rec2.save\n end\n else\n if @rec2.state >= Bollywood.count()\n @rec2.state = 0\n @rec2.score = 0\n @rec2.save\n end\n if (@bollywood.answer == params[:option1].to_s+params[:option2].to_s+params[:option3].to_s+params[:option4].to_s)\n @rec2.score = @rec2.score + 100\n @rec2.state += 1\n @rec2.save\n elsif ((params[:option1].present? || params[:option2].present? || params[:option3].present? || params[:option4].present?) && (@bollywood.answer != params[:option1].to_s+params[:option2].to_s+params[:option3].to_s+params[:option4].to_s))\n @rec2.state += 1\n @rec2.save\n end\n end\n end", "def input_score(score)\n @userscore = score\n raise 'Please input a valid score' if score > 10 || score.negative?\n\n update = @scorecard[frame?]\n if update.framescore[:roll_1].nil?\n if score == 10\n update.framescore[:roll_2] = '-'\n update.framescore[:roll_1] = 'X'\n else\n update.framescore[:roll_1] = score\n end\n elsif (update.framescore[:roll_1] + score) > 10\n raise 'Please input a valid score'\n elsif (update.framescore[:roll_1] + score) == 10\n update.framescore[:roll_2] = '/'\n else\n update.framescore[:roll_2] = score\n end\n spare_bonus(score)\n end", "def display_score\n current_score_table = TTY::Table.new([\"Name\", \"Total Steps Taken\",\"Current Score\"], [[@name, \"#{@position}/33\", @score]]) \n puts current_score_table.render(:unicode, resize: true, width: 50)\n end", "def set_score\n if $Iterator >= 0 && $Iterator < $Length\n @questions = @subgenre.questions.all\n @question = @questions[$Iterator]\n @options = @question.options.all\n @useranswers = params[:answer_ids]\n flag = 0\n if !@useranswers\n flag = 1\n else\n for option in @options\n if @useranswers.include? (option.id).to_s && option.isanswer == 0\n flag = 1\n break\n elsif option.isanswer == 1 && !(@useranswers.include? (option.id).to_s)\n flag = 1\n break\n end\n end\n end\n if flag == 0\n @stat = Stat.find_by(subgenre_id: @subgenre.id, user_id: session['user_id'])\n x = @stat.score\n y = @question.score\n @stat.update_attributes(score: x+y)\n end\n end\n end", "def score\n @score || calculate_score\n end", "def comments_by_score(options={})\n parse_comments(request(singular(id) + \"comments/score\", options))\n end", "def index\n @scores = Score.all\n end", "def index\n @scores = Score.all\n end", "def index\n @scores = Score.all \n end", "def set_record_score\n @record_score = RecordScore.find(params[:id])\n end", "def set_home_score\n @home_score = HomeScore.find(params[:id])\n end", "def update!(**args)\n @score = args[:score] if args.key?(:score)\n end", "def update!(**args)\n @score = args[:score] if args.key?(:score)\n end", "def update\n @score = Score.find(params[:id])\n\n respond_to do |format|\n if @score.update_attributes(params[:score])\n format.html { redirect_to @score, notice: 'Score was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @score.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @score = Score.find(params[:id])\n\n respond_to do |format|\n if @score.update_attributes(params[:score])\n format.html { redirect_to @score, notice: 'Score was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @score.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @score = Score.find(params[:id])\n\n respond_to do |format|\n if @score.update_attributes(params[:score])\n format.html { redirect_to @score, notice: 'Score was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @score.errors, status: :unprocessable_entity }\n end\n end\n end", "def formulate_score()\n @player_score = @player_score.sort!().reverse!().join().to_i()\n p \"#{@players[0].get_name}'s score is #{@player_score}\"\n check_score()\n end", "def score_params\n params.require(:regularscorer).permit(:homescore, :awayscore)\n end", "def set_five_score\n @five_score = FiveScore.find(params[:id])\n end", "def show\n @score_card.mark_as_read! for: current_user\n end", "def update_scoreboard(scores = {})\n end", "def continue_game\n redirect_to scores_url unless show_score?\n end", "def show\n @aja_score = AjaScore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @aja_score }\n end\n end", "def display_scores\n puts \"P1: #{@player1.lives}/3 vs P2: #{@player2.lives}/3\"\n end", "def show\n @score = Evaluation.eval_post(@post)\n end", "def show\n @game = Game.find(params[:id])\n @score_class = @game.scores\n @score_scope = get_scoped_scores\n \n respond_to do |format|\n format.html # show.html.erb\n format.js # show.js.erb\n format.bbcode { scores_with_position = @score_scope.ordered.each_with_index {|sc,idx| sc[:score_position] = idx+1}\n template_map = @game.attributes.merge({:scores => scores_with_position, :raw_scores => @score_class.current_scores})\n template_string = @game.scoreboard_template\n render :text => Mustache.render(template_string, template_map) \n }\n format.xml { render :xml => @game }\n end\n end" ]
[ "0.6743665", "0.650048", "0.648773", "0.6368426", "0.6328055", "0.6276015", "0.6263041", "0.62412524", "0.62412524", "0.62412524", "0.62412524", "0.62412524", "0.62412524", "0.62412524", "0.62412524", "0.62412524", "0.62412524", "0.62412524", "0.60781765", "0.6073044", "0.60676926", "0.60676926", "0.60676926", "0.6066934", "0.60434365", "0.6033905", "0.6020413", "0.5922858", "0.59013474", "0.58930457", "0.5874634", "0.586382", "0.58329296", "0.58234507", "0.5782346", "0.5775386", "0.57595396", "0.5752317", "0.57466316", "0.57435644", "0.57106394", "0.5709226", "0.57053536", "0.57024443", "0.5696399", "0.56887496", "0.56887496", "0.5671789", "0.5670164", "0.5665331", "0.56613475", "0.56613475", "0.56603724", "0.5657636", "0.56449157", "0.5643314", "0.563868", "0.563868", "0.563868", "0.563868", "0.56226844", "0.56140256", "0.56072134", "0.56063324", "0.560605", "0.5551034", "0.55487454", "0.55428284", "0.55289793", "0.5515941", "0.55031216", "0.5488923", "0.5482074", "0.54816836", "0.54811513", "0.5462177", "0.54617393", "0.5458851", "0.5456279", "0.5455369", "0.5455279", "0.5455279", "0.5450501", "0.5439734", "0.54331696", "0.5430867", "0.5430867", "0.54305655", "0.54305655", "0.54305655", "0.54287076", "0.54251665", "0.5422004", "0.54130304", "0.54042494", "0.54002255", "0.53903985", "0.53878576", "0.5378431", "0.5371567" ]
0.66982275
1
TODO: deserves to be moved elswhere
def format_lines(lines) prev = lines[0] slices = lines.slice_before do |e| (prev + 1 != e).tap { prev = e } end slices.map { |slice_first, *, slice_last| slice_last ? (slice_first..slice_last) : slice_first } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def schubert; end", "def implementation; end", "def implementation; end", "def weber; end", "def refutal()\n end", "def wrapper; end", "def suivre; end", "def isolated; end", "def isolated; end", "def internal; end", "def terpene; end", "def custom; end", "def custom; end", "def from; end", "def from; end", "def from; end", "def from; end", "def berlioz; end", "def operations; end", "def operations; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def offences_by; end", "def stderrs; end", "def sitemaps; end", "def identify; end", "def verdi; end", "def eplore\n end", "def formation; end", "def intensifier; end", "def trd; end", "def villian; end", "def original_result; end", "def r; end", "def r; end", "def processor; end", "def strategy; end", "def handle; end", "def etfs\n\n end", "def who_we_are\r\n end", "def extra; end", "def init; end", "def init; end", "def init; end", "def init; end", "def parslet; end", "def parslet; end", "def parslet; end", "def parslet; end", "def executor; end", "def executor; end", "def executor; end", "def anchored; end", "def upc_e; end", "def feruchemist; end", "def dh; end", "def spec; end", "def spec; end", "def zuruecksetzen()\n end", "def escaper; end", "def external; end", "def internship_passed; end", "def celebration; end", "def reflector; end", "def reflector; end", "def apply\n\t\t\n\tend", "def apply\n\t\t\n\tend", "def context; end", "def context; end", "def context; end", "def context; end", "def context; end", "def context; end", "def context; end", "def context; end", "def context; end", "def context; end", "def context; end", "def context; end", "def context; end", "def context; end", "def context; end", "def context; end", "def context; end", "def context; end", "def context; end", "def context; end", "def context; end" ]
[ "0.77427375", "0.6600724", "0.65973717", "0.65973717", "0.65973717", "0.65973717", "0.6567165", "0.6323523", "0.6323523", "0.63145137", "0.631329", "0.6142819", "0.6112921", "0.60382855", "0.60382855", "0.6016837", "0.5996183", "0.5947805", "0.5947805", "0.59409153", "0.59409153", "0.59409153", "0.59409153", "0.5935361", "0.58923274", "0.58923274", "0.58664405", "0.58664405", "0.58664405", "0.58664405", "0.58664405", "0.58664405", "0.58664405", "0.58664405", "0.58664405", "0.58661556", "0.58607244", "0.58606654", "0.5848735", "0.58429337", "0.5842867", "0.58409595", "0.5812822", "0.5803713", "0.57870567", "0.5776292", "0.57691586", "0.57691586", "0.57554024", "0.57530427", "0.57396096", "0.5736214", "0.57336086", "0.5720601", "0.57175076", "0.57175076", "0.57175076", "0.57175076", "0.5694266", "0.5694266", "0.5694266", "0.5694266", "0.56933904", "0.56933904", "0.56933904", "0.5689282", "0.5685811", "0.5674941", "0.5674009", "0.56735575", "0.56735575", "0.5668124", "0.56655216", "0.56447875", "0.5643041", "0.56426054", "0.56205916", "0.56205916", "0.56150854", "0.56150854", "0.5602137", "0.5602137", "0.5602137", "0.5602137", "0.5602137", "0.5602137", "0.5602137", "0.5602137", "0.5602137", "0.5602137", "0.5602137", "0.5602137", "0.5602137", "0.5602137", "0.5602137", "0.5602137", "0.5602137", "0.5602137", "0.5602137", "0.5602137", "0.5602137" ]
0.0
-1
TODO: can be updated to read directly from `run.nodes` instead of passing `undercover_report`
def warnings_to_annotations results = @undercover_report.flagged_results log "posting warnings: #{results}" results.map do |result| # TODO: duplicates pronto-undercover logic, move to Undercover::Result lines = result.coverage.map { |ln, *| ln if result.uncovered?(ln) }.compact.uniq message = "#{result.node.human_name.capitalize} `#{result.node.name}` is missing" \ " coverage for line#{'s' if lines.size > 1} #{format_lines(lines).join(',')}" \ " (node coverage: #{result.coverage_f})." lines_missing_branch_cov = result.coverage.map do |ln, _block, _branch, cov| ln if cov&.zero? end.compact.uniq if lines_missing_branch_cov.any? message += "\nMissing branch coverage found in line#{'s' if lines_missing_branch_cov.size > 1} " \ "#{format_lines(lines_missing_branch_cov).join(',')}." end { path: result.file_path, start_line: result.first_line, end_line: result.last_line, annotation_level: "warning", title: "Untested #{result.node.human_name}", message:, raw_details: result.pretty_print } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def report_moab_nodes\n self.report('moab_nodes_report')\n end", "def parse_output(_report, _result, _targets); end", "def get_test_run_summary_report(test_report, test_summary)\n file_data = test_report\n file_lines = file_data.split(\"\\n\")\n\n=begin\n #Remove the duplicate headings\n title = 0\n i = 0\n file_lines.each do |line|\n i += 1\n if line.match(/<h1 align='center'><u>(\\w|\\s)+<\\/u><\\/h1><br\\/>/)\n title += 1\n if title > 1\n file_lines.delete_at(i-1)\n end\n end\n end\n=end\n\n test_run_summary = <<-EOS\n <h1 align='center'><u>#{test_summary[:title]}<\\/u><\\/h1><br\\/>\n EOS\n\n #Get the test run details from the report\n file_data.match(/<td>Kadu server:(.+)<\\/td>/)\n kadu_server = $1\n test_suites = file_data.scan(/<th align=\"center\">(.+)<\\/th>/)\n test_suite_status = file_data.scan(/Test suite status: <font id=(statuspass|statusfail)>(.*)<\\/font>/)\n\n i = 0\n test_status = {}\n test_suites.each do |test_suite|\n test_status[test_suite] = test_suite_status[i]\n i +=1\n end\n\n test_status = test_status.sort_by{|name,status| status}\n\n test_run_time_in_secs = Time.parse(test_summary[:test_run_end_time].to_s) - Time.parse(test_summary[:test_run_start_time].to_s)\n\n # Get the test case numbers\n passed_tcs = 0\n failed_tcs = 0\n blocked_tcs = 0\n\n file_lines.each do |line|\n passed_tcs +=1 if line.match(\"Test result status: <font id=statuspass>PASS</font>\")\n failed_tcs +=1 if line.match(\"Test result status: <font id=statusfail>FAIL</font>\")\n blocked_tcs +=1 if line.match(\"Test result status: <font id=statusfail>BLOCK</font>\")\n end\n total_tcs_count = passed_tcs + failed_tcs + blocked_tcs\n\n #Create the test run summary section\n test_run_summary += <<-EOS\n <a name=summary></a>\n <table id=\"specifications\" width=\"500px\">\n <tr><td><strong>Kadu Server:</strong></td><td>#{kadu_server}</td></tr>\n <tr><td><strong>Country:</strong></td><td>#{test_summary[:country]}</td></tr>\n <tr><td><strong>Test Run Started On:</strong></td><td>#{test_summary[:test_run_start_time]}</td></tr>\n <tr><td><strong>Duration:</strong></td><td>#{test_run_time_in_secs} secs</td></tr>\n <tr><td><strong>Number of test cases executed:</strong></td><td>#{total_tcs_count}</td></tr>\n <tr><td><strong>Number of test cases passed:</strong></td><td>#{passed_tcs}</td></tr>\n <tr><td><strong>Number of test cases failed:</strong></td><td>#{failed_tcs}</td></tr>\n <tr><td><strong>Number of test cases blocked:</strong></td><td>#{blocked_tcs}</td></tr>\n </table>\n <br>\n EOS\n if !test_summary[:known_issues].nil?\n test_run_summary += <<-EOS\n #{get_fail_test_details(test_summary[:known_issues])}\n <br>\n EOS\n end\n\n test_run_summary += <<-EOS\n <table id=\"specifications\" width=\"900px\">\n <tr>\n <th >Test Suite</th>\n <th >Test Suite Status</th>\n </tr>\n EOS\n i = 0\n test_status.each do |suite_name,suite_status|\n test_run_summary += <<-EOS\n <tr>\n <td><a href=\"##{replace_space_by_dash(suite_name.to_s.gsub(/\"|\\[|\\]/,''))}\">#{suite_name.to_s.gsub(/\"|\\[|\\]/,'')}</a></td>\n <td><font id=#{suite_status[0]}>#{suite_status[1]}</font></td>\n </tr>\n EOS\n i +=1\n end\n test_run_summary += <<-EOS\n </table>\n <br>\n <hr size=2 color=\"#000080\">\n <br/>\n EOS\n\n # Convert the section into array and add it to the file at the start.\n test_run_summary = test_run_summary.split(\"\\n\")\n i = 0\n file_lines.each do |line|\n i += 1\n if line.match(/<center>/)\n j = i\n test_run_summary.each do |row|\n file_lines.insert(j,row)\n j +=1\n end\n break\n end\n end\n\n report = \"\"\n file_lines.each do |line|\n report += <<-EOS\n #{line}\n EOS\n end\n report\n end", "def report_network\n self.report('network_report')\n end", "def find_probes(velvet_underground_graph, probe_read_ids)\n # First use the C method to extract the set of interesting nodes\n log.debug \"Extracting target nodes using the C method..\" if log.debug?\n target_node_ids = find_probe_nodes(velvet_underground_graph, probe_read_ids)\n\n # Then iterate over just those nodes we know are interesting\n log.debug \"Extracting from only those #{target_node_ids.length} nodes that are interesting..\" if log.debug?\n target_node_ids_set = Set.new target_node_ids\n return Bio::AssemblyGraphAlgorithms::NodeFinder.new.find_unique_nodes_with_sequence_ids(\n velvet_underground_graph, probe_read_ids, :target_node_ids => target_node_ids_set\n )\n end", "def run\n print_banner\n @test_plan.each do |plan|\n found_nodes = nodes(plan)\n if found_nodes\n found_nodes.each { |node| execute_plan_tests(node, plan) }\n end\n end\n exit @ret_code\n end", "def find_nodes\n puts '1st pass: find nodes'\n find :nodes\n self\n end", "def report_from(tests)\n tests.map do |test|\n report = [test.name, test.executed?]\n report << test.platform.name unless test.platform.nil?\n report << test.node unless test.node.nil?\n # Only report the first line of the error messages, as some contain callstacks\n report << test.errors.map { |error| error.split(\"\\n\").first } unless test.errors.empty?\n report\n end\n end", "def run\n reset!\n\n pages.each do |page|\n log.puts\n\n if page.respond_to?(:read)\n html = page.read\n elsif page.respond_to?(:call)\n result = instance_eval(&page)\n\n html = case result\n when String\n result\n else\n @agent.page.body\n end\n else\n begin\n html = fetch(page)\n rescue FetchError => e\n log.puts(e.message.red)\n next\n end\n end\n\n process!(html)\n end\n\n report\n\n selectors_to_review\n end", "def nodes; end", "def nodes; end", "def nodes; end", "def examine_uncovered_file(filename)\n # run it through the Loader\n # it will fill out the coverage data for this file\n @loader.load filename\n\n # re-get the lines\n coverage_data[filename]\n end", "def summary\n \" Discovered #{@discovered_nodes.count} live node(s)\"\n end", "def report(result_set)\n print '.' and return if result_set.success?\n\n puts\n files = Hash.new { |h, k| h[k] = File.readlines(k) }\n result_set.each do |result|\n file = files[result.filename]\n node = result.node\n puts \"#{result.filename}:#{node.line}\"\n puts \"#{node.line-1}: #{file[node.line - 2]}\" if file[node.line - 2] && !(node.line - 2).negative?\n puts \"#{node.line}: #{file[node.line - 1]}\"\n puts \"#{node.line+1}: #{file[node.line]}\" if file[node.line]\n puts '-' * 16\n end\n puts\n end", "def collectives_report\n collectives = get_collectives\n\n puts \" %-30s %s\" % [ \"Collective\", \"Nodes\" ]\n puts \" %-30s %s\" % [ \"==========\", \"=====\" ]\n\n collectives[:collectives].sort_by {|key,count| count.size}.each do |collective|\n puts \" %-30s %d\" % [ collective[0], collective[1].size ]\n end\n\n puts\n puts \" %30s %d\" % [ \"Total nodes:\", collectives[:nodes] ]\n puts\n end", "def count_nodes_rec_unr\n File.open(@c.reciprocated_node_count, \"w\") do |r|\n File.open(@c.unreciprocated_node_count, \"w\") do |u|\n @c.reciprocated do |i,rec_filename|\n unr_filename = @c.unreciprocated(i)\n r.puts \"#{i} #{Counter.unique_nodes(rec_filename, 0, 1)}\"\n u.puts \"#{i} #{Counter.unique_nodes(unr_filename, 0, 1)}\"\n end\n end\n end\n end", "def report_run(command)\n result = nil\n @run_report = Report.new(name: nil, target: command)\n begin\n result = yield @run_report\n ensure\n @run_report = nil\n end\n\n result\n end", "def report!\n # Borrowed from simplecov#41\n #\n # If an exception is thrown that isn't a \"SystemExit\", we need to capture\n # that error and re-raise.\n if $!\n exit_status = $!.is_a?(SystemExit) ? $!.status : EXIT_FAILURE\n else\n exit_status = EXIT_SUCCESS\n end\n\n report = {}.tap do |h|\n h[:total] = @collection.size\n h[:touched] = @collection.count { |_, resource| resource.touched? }\n h[:coverage] = ((h[:touched] / h[:total].to_f) * 100).round(2)\n end\n\n report[:untouched_resources] = @collection.collect do |_, resource|\n resource unless resource.touched?\n end.compact\n report[:all_resources] = @collection.values\n\n @outputs.each do |block|\n instance_exec(report, &block)\n end\n\n # Ensure we exit correctly (#351)\n Kernel.exit(exit_status) if exit_status && exit_status > 0\n end", "def root_nodes\n @nodes ||= discovered_files.collect do |file|\n raising_with_file file[0] do\n Dock::Node.new context.call('Dock.generate', *file, language)\n end\n end\n end", "def main ()\n runlist = YAML.load_file(ARGV[0])\n all = runlist.values.flatten.uniq.sort \n stop_agent(all)\n run_puppet(all)\n #backup_classification(all)\n runlist.each do |role, nodes| #arity?\n classify(nodes, role)\n run_puppet(nodes)\n end\n #restore_classification(all)\n run_puppet(all, true)\n start_agent(all)\nend", "def report_for(nodes, locale_code)\n # This method simply provides a report for a given list of nodes in the desired locale.\n # The locale will be one of the supported ones.\n # Generate the report in a file to be uploaded on web10.\n File.write(\n '/tmp/web_report.txt',\n @platforms_handler.known_platforms.map do |platform|\n \"= Inventory for platform #{platform.repository_path} of type #{platform.platform_type}:\\n\" +\n platform.known_nodes.map do |node|\n \"* Node #{node} (IP: #{@nodes_handler.get_host_ip_of(node)}, Hostname: #{@nodes_handler.get_hostname_of(node)}).\"\n end.join(\"\\n\")\n end.join(\"\\n\")\n )\n # Upload the file on our web10 instance\n system 'scp -o StrictHostKeyChecking=no /tmp/web_report.txt [email protected]_tutorial.org:/root/hello_world.txt'\n out 'Upload successful'\n end", "def script\n sh.raw \"echo -en 'coverity_scan:start\\\\r'\"\n sh.if \"${COVERITY_VERBOSE} = 1\", echo: true do\n sh.raw \"set -x\"\n end\n sh.set 'PROJECT_NAME', @config[:project][:name], echo: true\n set_coverity_scan_branch\n sh.if \"${COVERITY_SCAN_BRANCH} = 1\", echo: true do\n sh.raw \"echo -e \\\"\\033[33;1mCoverity Scan analysis selected for branch \\\"$TRAVIS_BRANCH\\\".\\033[0m\\\"\"\n authorize_quota\n build_command\n end\n sh.raw \"echo -en 'coverity_scan:end\\\\r'\"\n end", "def run\n\t\t\tsummary\n\t\tend", "def report!\n simplecov\n Coveralls.push!\n\n nil\n end", "def post_analyze!\n contents = File.open(self.name, 'r').readlines\n exelines = 0\n contents.each_with_index do |line, num|\n sline = line.strip\n \n case sline\n when '', /^#/\n lines << num + 1\n when /^\\s*(?:end|\\})\\s*(?:#.*)?$/, /^(public|private|protected)/,\n /^(?:begin\\s*(?:#.*)?|ensure\\s*(?:#.*)?|else\\s*(?:#.*)?)$/,\n /^(?:rescue)/, /^case\\s*(?:#.*)?$/, /^(\\)|\\]|\\})(?:#.*)?$/\n lines << num + 1\n exelines += 1\n else\n exelines += 1\n end\n \n end\n \n @coverage_percent = (exelines.to_f / contents.size) * 100.0\n end", "def report\n [coverage, badge]\n end", "def target_num_nodes() ; info[:target_num_nodes] ; end", "def run\n super\n\n entity_name = _get_entity_name\n entity_type = _get_entity_type_string\n\n # Make sure the key is set\n api_key = _get_task_config(\"binary_edge_api_key\")\n\n if entity_type == \"IpAddress\"\n response = search_binaryedge_by_ip entity_name, api_key\n\n if response[\"events\"]\n response[\"events\"].each do |e|\n e[\"results\"].each do |r|\n\n # create a network service for every result\n # saving the details off as extended details\n port = r[\"target\"][\"port\"]\n proto = r[\"target\"][\"protocol\"]\n be_details = {\"extended_binaryedge\" => e }\n _create_network_service_entity(@entity,port,proto, be_details)\n\n # this should be optional...\n #if port != \"443\"\n # _create_issue({\n # name: \"#{entity_name}:#{port} [Binary Edge]\",\n # type: \"Malicious IP\",\n # severity: 3 ,\n # status: \"confirmed\",\n # description: \"Port: #{e[\"port\"]} || State:#{r[\"result\"][\"data\"][\"state\"]} || Security issue:#{r[\"result\"][\"data\"][\"security\"]}\n # || Reason:#{r[\"result\"][\"data\"][\"reason\"]} || \", #Running Service:#{r[\"result\"][\"data\"][\"service\"]}\"s\n # details: json\n # })\n #end\n\n end\n end\n end\n\n elsif entity_type == \"Domain\"\n # look for related eentities?\n dns_records = search_binaryedge_by_subdomain entity_name, api_key\n\n dns_records.each do |d|\n _create_entity \"DnsRecord\" , \"name\" => d\n end\n\n # also check for data leaks\n response = search_binaryedge_leaks_by_domain entity_name, api_key\n response[\"groups\"].each do |t|\n # create issues if we found any\n _create_linked_issue(\"leaked_data\",{\n proof: \"#{t[\"count\"]} accounts found related to #{entity_name} in #{t[\"leak\"]}\",\n detailed_description: \"#{t[\"count\"]} accounts found related to #{entity_name} in #{t[\"leak\"]}\",\n references:[\"https://binaryedge.com/\",\n \"https://askleo.com/account-involved-breach/\"] ,\n details: t\n })\n end\n\n elsif entity_type == \"EmailAddress\"\n\n # checks for data leaks\n response = search_binaryedge_leaks_by_email_address entity_name, api_key\n\n if response[\"total\"] == 0\n _log \"No results found!\"\n return\n end\n\n # create issues if we found any\n response[\"events\"].each do |u|\n ############################################\n ### Old Issue ###\n ###########################################\n # _create_issue({\n # name: \"Email Found in Data Leak #{u}\",\n # type: \"leaked_account\",\n # severity: 3,\n # status: \"confirmed\",\n # detailed_description: \"This Email has been found in this breach: #{u}, via BinaryEdge\",\n # references:\"https://binaryedge.com/\",\n # details: u\n # })\n ############################################\n ### New Issue ###\n ###########################################\n _create_linked_issue(\"leaked_data\",{\n proof: \"This Email has been found in this breach: #{u}\",\n name: \"Email Found in Data Leak #{u}\",\n type: \"leaked_email\",\n detailed_description: \"This Email has been found in this breach: #{u}, via BinaryEdge\",\n references:\"https://binaryedge.com/\",\n details: u\n })\n end\n\n elsif entity_type == \"NetBlock\"\n #do the right thing\n events = search_binaryedge_netblock(_get_entity_name, api_key, 0)\n events.each do |e|\n begin \n port = e[\"target\"][\"port\"]\n target = e[\"target\"][\"ip\"]\n protocol = e[\"target\"][\"protocol\"]\n _create_entity \"NetworkService\", {\"name\" => \"#{target}:#{port}/#{protocol}\"}\n \n rescue NoMethodError, KeyError\n # pass it on\n next\n end\n end\n \n else\n _log_error \"Unsupported entity type\"\n end\n\n end", "def test_for_node\n raise \"Failing test #{@name} for #{@node}\" if Node.fail_for.key?(@name) && Node.fail_for[@name].include?(@node)\n\n sleep_time = Node.sleeps.dig(@name, @node)\n sleep sleep_time unless sleep_time.nil?\n Node.runs << [@name, @node]\n end", "def report_for(nodes, locale_code)\n output = ''\n locale = TRANSLATIONS[locale_code]\n\n output << <<~EO_MEDIAWIKI\n Back to the [[Hadoop]] / [[Impala]] / [[XAE_Network_Topology]] portal pages\n\n This page has been generated using <code>./bin/report --format mediawiki</code> on #{Time.now.utc.strftime('%F %T')} UTC.\n\n EO_MEDIAWIKI\n\n # Get all confs\n # Use the translations' keys to know all properties we want to display\n all_properties = (%i[physical_node cluster private_ips description] + locale.keys).uniq\n @nodes_handler.prefetch_metadata_of nodes, locale.keys\n nodes.\n map do |node|\n { node: node }.merge(all_properties.map { |property| [property, @nodes_handler.metadata_of(node, property)] }.to_h)\n end.\n # Group them by physical / VMs\n group_by do |node_info|\n # Consume the info to not display it again later\n physical_node = node_info.delete(:physical_node)\n !physical_node.nil? && physical_node\n end.\n each do |physical, nodes_for_physical|\n output << \"= #{physical ? 'Physical' : 'Virtual'} nodes =\\n\\n\"\n # Group them by location\n nodes_for_physical.\n group_by do |node_info|\n # Consume the info to not display it again later\n cluster = node_info.delete(:cluster)\n cluster.nil? ? '' : cluster\n end.\n sort.\n each do |cluster, nodes_for_cluster|\n output << \"== #{cluster.empty? ? 'Independent nodes' : \"Belonging to cluster #{cluster}\"} ==\\n\\n\"\n # Group them by IP range (24 bits)\n nodes_for_cluster.\n group_by { |node_info| node_info[:private_ips].nil? || node_info[:private_ips].empty? ? [] : node_info[:private_ips].first.split('.')[0..2].map(&:to_i) }.\n sort.\n each do |ip_range, nodes_for_ip_range|\n output << \"=== #{ip_range.empty? ? 'No IP' : \"#{ip_range.join('.')}/24\"} ===\\n\\n\"\n nodes_for_ip_range.\n sort_by { |node_info| node_info[:node] }.\n each do |node_info|\n output << \"* '''#{node_info.delete(:node)}'''#{node_info[:private_ips].nil? || node_info[:private_ips].empty? ? '' : \" - #{node_info[:private_ips].first}\"} - #{node_info.delete(:description)}\\n\"\n node_info.delete(:private_ips) if !node_info[:private_ips].nil? && node_info[:private_ips].size == 1\n node_info.sort.each do |property, value|\n next if value.nil?\n\n raise \"Missing translation of key: #{property}. Please edit TRANSLATIONS[:#{locale_code}].\" unless locale.key?(property)\n\n output << \": #{locale[property]}: #{\n case value\n when Array\n \"\\n#{value.map { |item| \"::* #{item}\" }.join(\"\\n\")}\"\n when Hash\n \"\\n#{value.map { |item, item_value| \"::* #{item}: #{item_value}\" }.join(\"\\n\")}\"\n when TrueClass\n locale[:true]\n when FalseClass\n locale[:false]\n else\n value.to_str\n end\n }\\n\"\n end\n output << \"\\n\\n\"\n end\n end\n end\n end\n\n output << <<~EO_MEDIAWIKI\n Back to the [[Hadoop]] / [[Impala]] / [[XAE_Network_Topology]] portal pages\n\n [[Category:My Project]]\n [[Category:Hadoop]]\n [[Category:NoSQL]]\n [[Category:Hosting]]\n [[Category:XAE]]\n [[Category:Server]]\n [[Category:Configuration]]\n [[Category:Chef]]\n EO_MEDIAWIKI\n\n out output\n end", "def num_source_nodes(total_nodes,sources_per,detectors_per)\n total_nodes.to_f / (sources_per.to_f/detectors_per.to_f + 1.0)\nend", "def run_analysis(ast, vm, report)\n configuration.analysis_classes.each do |const|\n instance = const.new(:vm => vm, :report => report)\n instance.iterate(ast)\n end\n end", "def report_metrics\n metadata = {\n 'sourcetype' => 'json',\n 'source' => 'chef-handler',\n 'host' => node.hostname,\n 'index' => @index,\n 'check-index' => false\n }\n\n # We're creating a new Hash b/c 'node' and 'all_resources' in run_status\n # are just TOO large.\n event = {\n :failed => run_status.failed?,\n :start_time => run_status.start_time,\n :end_time => run_status.end_time,\n :elapsed_time => run_status.elapsed_time,\n :exception => run_status.formatted_exception\n }.to_json\n\n splunk_post(event, metadata)\n end", "def build_report\n # build cases\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.testsuites {\n testsuite = xml.testsuite {\n @cases.each do |tc|\n testcase = xml.testcase {\n if tc.result_has_message?\n result_type = xml.send(tc.result)\n result_type[:message] = tc.message if tc.message.present?\n end\n\n if tc.system_out.size > 0\n xml.send('system-out') { xml.text tc.system_out.to_s }\n end\n\n if tc.system_err.size > 0\n xml.send('system-err') { xml.text tc.system_err.to_s }\n end\n }\n\n testcase[:name] = tc.name if tc.name.present?\n testcase[:time] = tc.time if tc.time.present?\n\n testcase[:classname] = package if package.present?\n if tc.classname.present?\n if testcase[:classname].present?\n testcase[:classname] = \"#{testcase[:classname]}.#{tc.classname}\"\n else\n testcase[:classname] = tc.classname\n end\n end\n\n end\n }\n\n testsuite[:name] = name if name.present?\n testsuite[:package] = package if package.present?\n }\n end\n\n builder.parent.root.to_xml\n end", "def run(reporter=nil)\n reporter ||= Reporters::DotProgress.new\n #parse\n evaluator = Runner.new(self)\n evaluator.run(reporter)\n end", "def print_summary\r\n traverse do |node|\r\n print node.effectively_skipped? ? '-' : '+'\r\n case\r\n when node.test? then print 'T'\r\n when node.suite? then print 'S'\r\n when node.static? then print 'X'\r\n else print '?'\r\n end\r\n print node.indented_name(' ')\r\n tags = node.effective_tags.to_a\r\n unless tags.empty?\r\n # highlight the tags that are explicit on this node\r\n tags = tags.map {|tag| node.explicit_tags.include?(tag) ? \"*#{tag}\" : tag }\r\n print \" [#{tags.join(',')}]\"\r\n end\r\n print \"\\n\"\r\n end\r\n end", "def load_report(report)\n report.configuration_source(config_source_1)\n report.configuration_source(config_source_2)\n report.configuration_directive(config_directive, config_directive_value)\n report.scan_passed(scanner_1, scanner_1_passed)\n report.scan_info(scanner_1, scanner_1_info_type_1, scanner_1_info_type_1_message_1)\n report.scan_info(scanner_1, scanner_1_info_type_1, scanner_1_info_type_1_message_2)\n report.scan_info(scanner_1, scanner_1_info_type_2, scanner_1_info_type_2_message_1)\n report.scan_stdout(scanner_1, scanner_1_stdout)\n report.scan_info(scanner_2, scanner_1_info_type_1, scanner_1_info_type_1_message_1)\n report.scan_stderr(scanner_2, scanner_2_stderr)\n report.salus_info(salus_info_type_1, salus_info_type_1_message_1)\n report.salus_info(salus_info_type_1, salus_info_type_1_message_2)\n report.salus_info(salus_info_type_2, salus_info_type_2_message_1)\n report.salus_error(salus_error_1_class, salus_error_1_data)\n report.salus_error(salus_error_2_class, salus_error_2_data)\n report.salus_runtime_error(salus_runtime_error_data)\n report\n end", "def exec_search_nCOP_heruistic\n # select a starting node\n s_gene = get_start_gene\n \n # initialize cover and other variables\n cover, cov_pat, $explored = [], Set.new, Set.new\n cover << s_gene and cov_pat.merge $genes[s_gene]\n start_cost = cost_func cover, cov_pat.size\n \n # run nCOP greedy heuristic\n nCOP_heuristic(cover, cov_pat, start_cost)\n \n # learn which genes are bad starting nodes\n if cover.size < 3\n $bad_starting_genes << s_gene\n end\n \n # return the cover found\n cover\nend", "def nodes\n TestLab::Node.all\n end", "def read_wcet_analysis_results(wcet_elem, analysis_entry)\n read_contexts(wcet_elem.get_elements(\"contexts\").first)\n\n @function_count, @function_cost = {} , Hash.new(0)\n\n # frequency of an edge on worst-case path\n edge_freq = {}\n\n # maximum number of cycles it takes to execute edge\n edge_cycles = {}\n\n # WCET contribution of an edge\n edge_contrib = {}\n\n ait_ins_cost, ait_ins_contrib = Hash.new(0), Hash.new(0)\n\n wcet_elem.each_element(\"wcet_path\") { |e|\n # only read results for analysis entry\n rentry = e.get_elements(\"wcet_entry\").first.attributes[\"routine\"]\n entry = @routines[rentry]\n next unless entry.function == analysis_entry\n\n # read results for each routine\n e.each_element(\"wcet_routine\") { |re|\n # extract function cost\n routine = @routines[re.attributes['routine']]\n if routine.function\n @function_count[routine.function] = re.attributes['count'].to_i\n @function_cost[routine.function] += re.attributes['cumulative_cycles'].to_i\n else\n # loop cost\n end\n\n # extract edge cost (relative to LLVM terminology)\n re.each_element(\"wcet_context\") { |ctx_elem|\n\n context = @contexts[ctx_elem.attributes['context']]\n\n # deal with aiT's special nodes\n start_nodes, loop_nodes, call_nodes, return_nodes = {}, {}, {}, {}\n\n # Special Case #1: (StartNode -> Node) is ignored\n # => If the target block is a start block, ignore the edge\n ctx_elem.each_element(\"wcet_start\") { |elem|\n start_nodes[elem.attributes['block']] = true\n }\n\n # Special Case #2: (Node -> CallNode[Loop]) => (Node -> LoopHeaderNode)\n # => If we have an edge from a node to a 'loop call node', we need to replace\n # it by an edge to the loop header node\n ctx_elem.each_element(\"wcet_edge_call\") { |call_edge|\n if loopblock = @routines[call_edge.attributes['target_routine']].loop\n loop_nodes[call_edge.attributes['source_block']] = loopblock\n else\n call_nodes[call_edge.attributes['source_block']] = true\n end\n }\n\n # Special case #3: The unsolveable one?\n # In aiT we have edges from nodes within a loop to loop end nodes,\n # and edges from return nodes to nodes just after loop, but end nodes\n # and return nodes are not connected.\n # So in theory we could have the following situation in LLVM:\n # a[L1] -> c v d v h[L1]\n # b[L1] -> c v d v h[L1]\n # and in aiT:\n # a[L1] -> end ; return[L1] -> c\n # b[L1] -> end ; return[L1] -> d\n # and no sane way to determine the execution frequencies of a->c, a->d, b->c, b->d\n # If, however, all loop exit nodes x have a unique successor E(x) outside of the loop,\n # we simply increment the frequency of x->E(x) if we see x->EndOfLoop.\n # As I do not know of a better way to do it, we stuck with this strategy for now.\n ctx_elem.each_element(\"wcet_edge_return\") { |return_edge|\n return_nodes[return_edge.attributes['target_block']] = true\n }\n\n # Now read in the cost for WCET edges\n ctx_elem.each_element(\"wcet_edge\") { |edge|\n\n # skip if no cost associated with edge\n next unless edge.attributes['cycles'] || edge.attributes['path_cycles'] || edge.attributes['count']\n\n source_block_id = edge.attributes['source_block']\n\n # skip start nodes and return nodes\n next if start_nodes[source_block_id]\n next if return_nodes[source_block_id]\n\n source = @blocks[edge.attributes['source_block']]\n unless source\n warn(\"Could not find block corresponding to #{edge.attributes['source_block']}\")\n next\n end\n\n target_block_id = edge.attributes['target_block']\n target = @blocks[edge.attributes['target_block']]\n\n # check if the target of this edge is in the same block as the source of the edge\n is_intrablock_target = ! target.nil? && target.index > 0 && ! loop_nodes[target_block_id]\n is_intrablock_target = true if call_nodes[target_block_id]\n\n # get the target block (if any), handling the case of a loop entry\n target_block = if loop_nodes[target_block_id]\n loop_nodes[target_block_id]\n else\n b = @blocks[target_block_id]\n b ? b.block : nil\n end\n\n attr_count = edge.attributes['count'].to_i # frequency on WCET path\n attr_cycles = edge.attributes['cycles'].to_i # WCET contribution\n attr_edge_cycles = edge.attributes['edge_cycles'].to_i # edge WCET\n\n # if there is no WCET for the edge, estimate it (WCET_contribution/WCET_frequency)\n if attr_count > 0\n computed_edge_cycles = (attr_cycles.to_f / attr_count).to_i\n if attr_edge_cycles.to_i == 0\n warn(\"No edge_cycles attribute for edge on WCET path (#{edge})\")\n attr_edge_cycles = computed_edge_cycles\n end\n elsif attr_cycles > 0\n die(\"Bad aiT profile entry (contribution of edge not on WC path): #{edge}\")\n end\n next unless attr_edge_cycles\n\n # We need to map the aiT edge to an LLVM edge\n #\n # In addition to the special cases discussed above,\n # there is the problem of duplicated blocks, as we want to compute cycles per execution,\n # not just cummulative cycles.\n #\n # One case is that we are given cycles for an intraprocedural edge b/i -> b/j (j>0), in different\n # contexts. As there might be several aiT nodes for b/i, we need store the maximum cost for\n # the slice (b/i..b/j) in this case. The frequency is ignored here, it is determined by\n # the frequency of the block anyway.\n # The other case is that we have cycles for an edge b/i -> b'/0; again there might be\n # several aiT nodes for b/i. In this case, we accumulate the frequency of (b -> b'),\n # and store the maximum cost for (b-> b').\n #\n # Later on, we add the maximum cost for every slice (b/i..b/j) to all edges\n # b->b' where b' is a live successor at instruction b/i.\n # Moreover, we add the maximum cost for (b/i -> b') to the edge b->b'.\n\n if source.block == target_block && is_intrablock_target\n ref = ContextRef.new(source, context)\n ait_ins_cost[ref] = [ait_ins_cost[ref], attr_edge_cycles].max\n ait_ins_contrib[ref] += attr_cycles\n debug(options, :ait) { \"Adding #{attr_cycles} cummulative cycles to #{ref} (intrablock)\" }\n else\n pml_edge = source.block.edge_to(target_block ? target_block : nil)\n\n # handle the case where the target is an end-of-loop node, and we need to add the frequency\n # to the unique out-of-loop successor of the source. If it does not exist, we give up\n if ! target_block && @is_loopblock[target_block_id]\n exit_successor = nil\n\n\t\tloop do\n source.block.successors.each { |s|\n if source.block.exitedge_source?(s)\n die(\"More than one exit edge from a block within a loop. This makes it\" +\n \"impossible (for us) to determine correct edge frequencies\") if exit_successor\n exit_successor = s\n end\n }\n\t\t break if exit_successor\n\n\t\t # If we did not simplify the CFG, the exit edge might leave from a successor of the block. \n # Hence check if there is a single successor block with a single predecessor, continue the exit search\n # from there.\n\t\t if source.block.successors.length == 1 && source.block.successors.first.predecessors.length == 1\n\t\t source = source.block.successors.first\n\t\t else\n die(\"no loop exit successor for #{source}, although there is an edge to end-of-loop node\")\n\t\t end\n\t\tend\n\n pml_edge = source.block.edge_to(exit_successor)\n end\n\n # store maximum cost for edge in context, and add to cummulative cost\n ref = ContextRef.new(pml_edge, context)\n ait_ins_cost[ref] = [ait_ins_cost[ref], attr_edge_cycles].max\n ait_ins_contrib[ref] += attr_cycles\n debug(options, :ait) { \"Adding #{attr_cycles} cummulative cycles to #{ref} (interblock)\" }\n\n # if the edge is on the worst-case path, increase WCET frequency\n if attr_count > 0\n debug(options, :ait) { \"Adding frequency to intraprocedural edge #{pml_edge}: #{attr_count} (#{edge})\" }\n (edge_freq[pml_edge]||=Hash.new(0))[context] += attr_count\n end\n end\n }\n }\n }\n }\n\n # Now extract profile entries from the cost read from the aiT profile\n ait_ins_cost.each { |cref, path_cycles|\n contrib_cycles = ait_ins_contrib[cref]\n context = cref.context\n\n # if the edge cost is attributed to an instruction (intrablock cost),\n # add it to all edges that are live at this instruction\n # FIXME: WCET contribution is more difficult - we have to split it amongst\n # the outgoing edges..\n if cref.programpoint.kind_of?(Instruction)\n ins = cref.programpoint\n ins.block.outgoing_edges.each { |pml_edge|\n if ins.live_successor?(pml_edge.target)\n (edge_cycles[pml_edge]||=Hash.new(0))[context] += path_cycles\n (edge_contrib[pml_edge]||=Hash.new(0))[context] += contrib_cycles\n end\n }\n else\n pml_edge = cref.programpoint\n assert(\"read_wcet_analysis_result: expecting Edge type\") { pml_edge.kind_of?(Edge) }\n\n (edge_cycles[pml_edge]||=Hash.new(0))[context] += path_cycles\n (edge_contrib[pml_edge]||=Hash.new(0))[context] += contrib_cycles\n end\n }\n\n debug(options,:ait) { |&msgs|\n @function_count.each { |f,c|\n msgs.call \"- function #{f}: #{@function_cost[f].to_f / c.to_f} * #{c}\"\n }\n }\n\n # create profile entries\n profile_list = []\n edge_cycles.each { |e,ctxs|\n debug(options,:ait) { \"- edge #{e}\" }\n ctxs.each { |ctx,cycles|\n ref = ContextRef.new(e, ctx)\n freq = edge_freq[e] ? edge_freq[e][ctx] : 0\n contrib = freq * cycles # edge_contrib[e][ctx]\n debug(options,:ait) {\n sprintf(\" -- %s: %d * %d (%d)\\n\",ctx.to_s, cycles, freq, contrib)\n }\n profile_list.push(ProfileEntry.new(ref, cycles, freq, contrib))\n }\n }\n profile_list\n end", "def node\n run_context.node\n end", "def node\n run_context.node\n end", "def find_probe_nodes(velvet_underground_graph, probe_read_ids)\n @bindings ||= Bio::FinishM::VelvetCBinding.new\n\n c_probe_read_ids = FFI::MemoryPointer.new(:int32, probe_read_ids.length)\n c_probe_read_ids.write_array_of_int32(probe_read_ids)\n\n probe_nodes = @bindings.extract_best_probe_reads(\n velvet_underground_graph.internal_graph_struct,\n c_probe_read_ids,\n probe_read_ids.length)\n probe_nodes2 = probe_nodes.read_array_of_int32(probe_read_ids.length).collect{|n| n.abs}.uniq\n\n #clean up\n c_probe_read_ids.free\n\n return probe_nodes2\n end", "def run\n connection = VMConnection.new(report)\n last_percent = connection.get_simplecov_last_percent\n\n if last_percent && last_percent.is_a?(Float)\n self.percent = last_percent.to_f\n save\n return true\n end\n\n false\n end", "def test_get_node_range_no_features\n nodes = @container.get_nodes('1',12,27,0)\n assert_equal(4, nodes.length)\n assert_equal([11,15,0], [nodes[0].start, nodes[0].stop, nodes[0].count])\n assert_equal([16,20,0], [nodes[1].start, nodes[1].stop, nodes[1].count])\n assert_equal([21,25,1], [nodes[2].start, nodes[2].stop, nodes[2].count])\n assert_equal([26,28,0], [nodes[3].start, nodes[3].stop, nodes[3].count])\n end", "def run(model, runner, user_arguments)\r\n super(model, runner, user_arguments)\r\n \r\n #use the built-in error checking \r\n if not runner.validateUserArguments(arguments(model), user_arguments)\r\n return false\r\n end\r\n \r\n # Define the reporting frequency\r\n reporting_frequency = \"hourly\"\r\n \r\n # Define the variables to report\r\n variable_names = []\r\n variable_names << \"District Heating Rate\"\r\n variable_names << \"District Cooling Rate\"\r\n \r\n # Request each output variable\r\n variable_names.each do |variable_name|\r\n output_variable = OpenStudio::Model::OutputVariable.new(variable_name,model)\r\n output_variable.setReportingFrequency(reporting_frequency)\r\n runner.registerInfo(\"Requested output for '#{output_variable.variableName}' at the #{output_variable.reportingFrequency} timestep.\")\r\n end\r\n \r\n # Report the outlet node conditions for each plant loop in the model\r\n # Rename the outlet node so that it makes sense in the report\r\n outlet_node_variable_names = []\r\n outlet_node_variable_names << \"System Node Temperature\"\r\n outlet_node_variable_names << \"System Node Setpoint Temperature\"\r\n outlet_node_variable_names << \"System Node Mass Flow Rate\"\r\n model.getPlantLoops.each do |plant_loop|\r\n outlet_node = plant_loop.supplyOutletNode\r\n outlet_node_name = \"#{plant_loop.name} Supply Outlet Node\"\r\n outlet_node.setName(outlet_node_name)\r\n outlet_node_variable_names.each do |outlet_node_variable_name|\r\n output_variable = OpenStudio::Model::OutputVariable.new(outlet_node_variable_name,model)\r\n output_variable.setKeyValue(outlet_node_name) \r\n output_variable.setReportingFrequency(reporting_frequency) \r\n end\r\n end\r\n \r\n \r\n return true\r\n \r\n end", "def coverage; end", "def coverage; end", "def get_anodes()\n nodes = [] ; 1.upto(32){|i|nodes << \"compute-0-#{i}\"}\n run_cluster(nodes, \"uptime\").map{|e|[e[0], e[1].scan(/\\d\\.\\d\\d/)[0].to_f, e[2]]}.sort_by{|e|e[1]} \nend", "def buildXmlReport(test_run)\n\n\t\t#First we need to create metadata about the test results so we can generate the junit format\n\t\t#We are creatimng a map of test classes to test_results so we can create a heirarchy of them in the returned xml\n\t\tpackages = {}\n\t\tpass,fail,error = 0,0,0\n\t\ttest_run.test_results.each do |test_result|\n\t\t\ttest = test_result.test\n\t\t\tkey = \"#{test.package}.#{test.class_name}\"\n\t\t\tpackages[key] = [] if packages[key].nil?\n \t\t\n \t\tpackages[key].append test_result\n\n\t\t\tcase test_result.result\n\t\t\twhen \"pass\"\n\t\t\t\tpass+=1\n\t\t\twhen \"fail\"\n\t\t\t\tfail+=1\n\t\t\twhen \"error\"\n\t\t\t\terror+=1\n\t\t\tend\n\n\t\tend\n\t\t#end metadata\n\n\t\tdoc = \"\"\n\t\txml = Builder::XmlMarkup.new(:target => doc, :ident => 1)\n\t\txml.instruct! :xml, :encoding => \"ASCII\"\n\t\t#<testrun name=\"Test (2)\" project=\"Test\" tests=\"3\" started=\"3\" failures=\"1\" errors=\"1\" ignored=\"0\">\n\t\txml.testrun(:name => test_run.build_id, :tests => \"#{pass+fail+error}\", :failures => fail, :errors => error) {\n\t\t\tpackages.each do |key,package|\n\t\t\t\txml.testsuite(:name => key) {\n\t\t\t\t\tpackage.each do |test_result|\n\t\t\t\t\t\ttest = test_result.test\n\t\t\t\t\t\t# <testcase name=\"testError\" classname=\"com.ibm.Test\" time=\"0.001\">\n\t\t\t\t\t\txml.testcase(:name => test.name, :classname => \"#{test.package}.#{test.class_name}\", :time => test_result.time) {\n\t\t\t\t\t\t\tif test_result.result == \"error\"\n\t\t\t\t\t\t\t\txml.error test_result.log\n\t\t\t\t\t\t\telsif test_result.result == \"fail\"\n\t\t\t\t\t\t\t\txml.failure test_result.log\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\tend\n\t\t}\n\n\t\treturn doc\n\tend", "def coverage(project_name)\n section \"coverage\", \"rm -rf hpc_report\", :condition => $tests_compiled_coverage, :noexception => true do\n hpc_excluded_modules = ((Dir.glob(\"test/**/*Spec.hs\") # skip all test-spec files\n .map { |k| k.gsub(/^test\\//, \"\") # ...converting path to namespace for HPC\n .gsub(/\\.hs$/,\"\")\n .gsub(\"/\",\".\")\n }\n ) << \"Main\" # and skip \"Main\", the entrypoint for tests\n ).map{|k| \"--exclude=#{k}\" }.join(\" \")\n command_interactive \"hpc report #{project_name}.tix #{hpc_excluded_modules}\"\n command_interactive \"hpc markup #{project_name}.tix --destdir=hpc_report #{hpc_excluded_modules}\"\n end\nend", "def reachable_nodes\n recursive_set(@start) { |n| n.out }\n end", "def get_issue_from_cover_page(cover_page)\r\n unless @login_success\r\n login\r\n end\r\n cover_image = cover_page.at(\".issue-image > img\")\r\n issue_id = id_from_href(cover_page.uri.path)\r\n issue = Issue.new(issue_id, \"The Economist\" ,cover_image['title'])\r\n issue.publisher = \"The Economist Newspaper Ltd.\"\r\n issue.cover_image = Image.new(cover_image['src'], \"cover.jpg\")\r\n\r\n puts \"Creating Kindle version of Issue \" + issue.to_s\r\n puts \"\"\r\n article_ids = []\r\n cover_page.search(\".section\").each do |s_element|\r\n section = Section.new(s_element.at(\"h4\").inner_html)\r\n s_element.search(\".article\").each do |a_element|\r\n link = a_element.at(\".node-link\")\r\n href = link[\"href\"]\r\n title = link.text\r\n article = Article.new(id_from_href(href), title, href)\r\n article_ids << id_from_href(href)\r\n section << article\r\n end\r\n issue << section\r\n end\r\n\r\n puts \"Downloading and processing articles:\"\r\n STDOUT.flush\r\n all_articles = issue.articles\r\n progress = ProgressBar.new(\"Downloading\", all_articles.length)\r\n all_articles.each_with_index do |article, done|\r\n\r\n article_page = @agent.get article.uri.to_s\r\n\r\n # get topic of article (its hard easier to extract than from the cover page)\r\n topic = article_page.at(\".fly-title\").text\r\n\r\n # the article abstract (curiously marked up as h1)\r\n if article_page.at(\"h1.rubric\")\r\n article.abstract = article_page.at(\".rubric\").text\r\n end\r\n\r\n # now the article content\r\n c_element = article_page.at(\".ec-article-content\")\r\n\r\n # lets get rid of the related items box\r\n c_element.search(\".related-items\").remove\r\n\r\n # lets get rid of the related items box\r\n c_element.search(\".related-expanded\").remove\r\n\r\n # replace links with local references\r\n c_element.search(\"a\").each do |a|\r\n if a['href'] && a['href'].start_with?(\"http://www.economist.com/node/\") &&\r\n article_ids.include?(id_from_href(a['href']))\r\n a[\"href\"] = a[\"href\"].gsub(\"http://www.economist.com/node/\", \"\") + \".html\"\r\n end\r\n end\r\n\r\n c_element.search(\"p\").each do |p|\r\n if p.children.first && p.children.first.name == \"strong\"\r\n p.swap(\"<h4>\"+p.children.first.text+\"</h4>\")\r\n end\r\n end\r\n\r\n # download the article images\r\n images = c_element.search(\"img\")\r\n images.each do |img|\r\n image = Image.new(img[\"src\"])\r\n img[\"src\"] = image.rel_path\r\n article.images << image\r\n end\r\n\r\n article.content = c_element.inner_html\r\n article.topic = topic if topic.strip != \"\"\r\n progress.inc\r\n end\r\n progress.finish\r\n puts ''\r\n issue\r\n end", "def index\n\t\t@node = current_user.nodes.find(params[:node_id])\n\t\t@reports = @node.reports\n\t\t@title = \"Todos los reportes de #{current_user.nodes.find(params[:node_id]).fqdn}\"\n\tend", "def inspect\n test_cases.each do |tc|\n puts tc.print\n end\n end", "def run\n super\n \n nmap_options = @options['nmap_options']\n \n if @object.kind_of? Host\n to_scan = @object.ip_address\n elsif @object.kind_of? NetBlock\n to_scan = @object.range\n elsif @object.kind_of? Domain\n to_scan = @object.name\n else\n raise ArgumentError, \"Unknown object type\"\n end\n \n rand_file_path = \"#{Dir::tmpdir}/nmap_scan_#{to_scan}_#{rand(100000000)}.xml\"\n \n # shell out to nmap and run the scan\n @task_logger.log \"scanning #{to_scan} and storing in #{rand_file_path}\"\n @task_logger.log \"nmap options: #{nmap_options}\"\n \n safe_system(\"nmap #{to_scan} #{nmap_options} -oX #{rand_file_path}\")\n \n # Gather the XML and parse\n @task_logger.log \"Parsing #{rand_file_path}\"\n parser = Nmap::Parser.parsefile(rand_file_path)\n\n # Create objects for each discovered service\n parser.hosts(\"up\") do |host|\n\n @task_logger.log \"Handling nmap data for #{host.addr}\"\n\n # Handle the case of a netblock or domain - where we will need to create host object(s)\n master_object = @object\n if @object.kind_of? NetBlock or @object.kind_of? Domain\n @object = create_object(Host, {:ip_address => host.addr })\n end\n\n [:tcp, :udp].each do |proto_type|\n host.getports(proto_type, \"open\") do |port|\n @task_logger.log \"Creating Service: #{port}\"\n create_object(NetSvc, {\n :host_id => @object.id,\n :port_num => port.num,\n :proto => port.proto,\n :fingerprint => \"#{port.service.name} #{port.service.product} #{port.service.version}\"})\n end\n # reset this back to the main task object & loop\n @object = master_object\n end\n \n end\nend", "def report_load\n self.report('load_report')\n end", "def run\n # Clear out previous run\n @result = nil\n\n field_stream = FieldStream.new\n @xtrace = Xtrace.new(field_stream)\n\n fd = @xtrace.file_descriptor\n env = { \"PS4\" => Xtrace.ps4 }\n options = { in: :in }\n\n if Bashcov.options.mute\n options[:out] = \"/dev/null\"\n options[:err] = \"/dev/null\"\n end\n\n run_xtrace(fd, env, options) do\n command_pid = Process.spawn env, *@command, options # spawn the command\n\n begin\n # start processing the xtrace output\n xtrace_thread = Thread.new { @xtrace.read }\n\n Process.wait command_pid\n\n @xtrace.close\n\n @coverage = xtrace_thread.value # wait for the thread to return\n rescue XtraceError => e\n write_warning <<-WARNING\n encountered an error parsing Bash's output (error was:\n #{e.message}). This can occur if your script or its path contains\n the sequence #{Xtrace.delimiter.inspect}, or if your script unsets\n LINENO. Aborting early; coverage report will be incomplete.\n WARNING\n\n @coverage = e.files\n end\n end\n\n $?\n end", "def report; end", "def report; end", "def report; end", "def report; end", "def report; end", "def get_cluster_debug_report\n report = \"\\n\"\n primitives_status_by_node.each do |primitive, data|\n primitive_name = primitive\n primitive_name = primitives[primitive]['name'] if primitives[primitive]['name']\n primitive_type = 'Simple'\n primitive_type = 'Cloned' if primitive_is_clone? primitive\n primitive_type = 'Multistate' if primitive_is_multistate? primitive\n primitive_status = primitive_status primitive\n\n report += \"-> #{primitive_type} primitive '#{primitive_name}' global status: #{primitive_status}\"\n report += ' (UNMANAGE)' unless primitive_is_managed? primitive\n report += \"\\n\"\n report += ' ' if data.any?\n nodes = []\n data.keys.sort.each do |node_name|\n node_status = data.fetch node_name\n node_block = \"#{node_name}: #{node_status}\"\n node_block += ' (FAIL)' if primitive_has_failures? primitive, node_name\n nodes << node_block\n end\n report += nodes.join ' | '\n report += \"\\n\"\n end\n report\n end", "def report\n if @coverage_level > 0 then\n extend RDoc::Text\n end\n\n if @coverage_level.zero? then\n calculate\n\n return great_job if @num_items == @doc_items\n end\n\n ucm = @store.unique_classes_and_modules\n\n report = RDoc::Markup::Document.new\n report << RDoc::Markup::Paragraph.new('The following items are not documented:')\n report << RDoc::Markup::BlankLine.new\n\n ucm.sort.each do |cm|\n body = report_class_module(cm) {\n [\n report_constants(cm),\n report_attributes(cm),\n report_methods(cm),\n ].compact\n }\n\n report << body if body\n end\n\n if @coverage_level > 0 then\n calculate\n\n return great_job if @num_items == @doc_items\n end\n\n report\n end", "def nodetool_netstats\n @nodetool_netstats ||= DaemonRunner::ShellOut.new(command: 'nodetool netstats', timeout: 300)\n @nodetool_netstats.run!\n @nodetool_netstats.stdout\n end", "def print_all_node_stats\n print_stats(stats: get_stats)\n end", "def node\n run_context.node\n end", "def rspec_parser(nokigiri_doc)\n result_arr = []\n testsuites = nokigiri_doc.xpath(\"//testsuites\")\n testsuites.each do |suites|\n testsuite = suites.xpath(\"./testsuite\")\n testsuite.each do |suite|\n debug_msg \"\\nSUITE: #{suite[\"name\"]} \"\n testsuite_name = suite[\"name\"]\n testcases = suite.xpath(\"./testcase\")\n testcases.each do |tcase|\n debug_msg \"TESTCASE: #{tcase}\"\n is_passed = false\n failure = tcase.xpath(\"./failure\")\n if ! failure.nil?\n is_passed = true\n if failure.size > 0\n is_passed = false\n end\n end\n debug_msg \" TC: #{tcase[\"name\"]}\"\n testcase_name = tcase[\"name\"]\n trail_cases = parse_trail_tag(testcase_name)\n trail_cases.each do |trail_case|\n result_arr.push({:trail_case => trail_case, :passed => is_passed})\n end\n end\n end\n debug_msg \"FINAL: #{result_arr}\"\n return result_arr\n end\n end", "def print_discovered_urls_by_crawler\t\t\n\t\tputs \"Print discovered url by the crawler. \" if @verbose\n\t\tbegin\n\t\t\tputs \"\\nSummary Report of Discovered URLs from the Crawler:\"\n\t\t\t@discovered_urls_by_crawler.keys.each do |url|\n\t\t\t\tputs url\n\t\t\tend\n\t\t\tputs \"Total: #{@discovered_urls_by_crawler.keys.size}\"\n\t\t\tputs \"End of the summary\"\n rescue => ee\n puts \"Exception on method #{__method__}: #{ee}\" if @verbose\n return nil\n end\n\tend", "def auto_analyze; end", "def process\n ReportAdapter.new(report: runner.run(run_options), root: root).each do |issue|\n io.print issue.to_json\n io.print \"\\0\"\n end\n end", "def thread_graph(out, t_id, info)\n total_calls = 0\n run_total = 0.0\n\n data = info[:nodes]\n\n methods = info[:methods]\n\n run_total = info[:runtime].to_f\n\n all_callers = Hash.new { |h,k| h[k] = [] }\n\n data.each do |n_id, n_data|\n n_data[4].each do |sub|\n all_callers[sub] << n_id\n end\n end\n\n indexes = data.keys.sort do |a, b|\n data[b][1] <=> data[a][1]\n end\n\n indexes = indexes.first(SHORT_LINES) unless options[:full_report]\n\n shown_indexes = {}\n\n indexes.each_with_index do |id, index|\n shown_indexes[id] = index + 1\n end\n\n out.puts \"===== Thread #{t_id} =====\"\n out.puts \"Total running time: #{sec(info[:runtime])}s\"\n out.puts \"index % time self children called name\"\n out.puts \"----------------------------------------------------------\"\n\n primary = \"%-7s%6s %8.2f %9.2f %8d %s [%d]\\n\"\n secondary = \" %8.2f %9.2f %8d %s%s\\n\"\n\n indexes.each do |id|\n m_id, total, called, tn, sub_nodes = data[id]\n\n # The idea is to report information about caller as a ratio of the\n # time it called method.\n #\n\n callers = all_callers[id].sort_by do |c_id|\n clr = data[c_id]\n\n clr[total]\n end\n\n callers = callers.first(10) unless options[:full_report]\n\n callers.each do |c_id|\n clr_m_id, clr_total, clr_called, clr_tn, clr_sub = data[c_id]\n\n sub_total = clr_sub.inject(0) { |a,s| a + data[s][1] }\n\n self_total = clr_total - sub_total\n out.printf(secondary, sec(self_total),\n sec(sub_total),\n clr_called,\n methods[clr_m_id][:name],\n graph_method_index(shown_indexes[c_id]))\n end\n\n # Now the primary line.\n\n children = sub_nodes.inject(0) { |a,s| a + data[s][1] }\n # children = method[:cumulative] * (method[:edges_total].to_f / method[:total])\n\n self_total = total - children\n out.printf primary, (\"[%d]\" % shown_indexes[id]),\n percentage(total, run_total, 1, nil),\n sec(self_total),\n sec(children),\n called,\n methods[m_id][:name],\n shown_indexes[id]\n\n # Same as caller, the idea is to report information about callee methods\n # as a ratio of the time it was called from method.\n #\n\n edges = sub_nodes.sort_by do |e_id|\n if edge = data[e_id]\n edge[1]\n else\n 0.0\n end\n end\n\n edges = edges.last(10) unless options[:full_report]\n # method[:edges] = method[:edges].first(10) unless options[:full_report]\n\n edges.reverse_each do |e_id|\n c_m_id, c_total, c_called, c_tn, c_sub_nodes = data[e_id]\n\n grandchildren = c_sub_nodes.inject(0) { |a,s| a + data[s][1] }\n grandchildren = 0 if grandchildren < 0\n\n self_total = c_total - grandchildren\n out.printf secondary, sec(self_total),\n sec(grandchildren),\n c_called,\n methods[c_m_id][:name],\n graph_method_index(shown_indexes[e_id])\n end\n\n out.puts \"-------------------------------------------------------\"\n end\n\n epilogue out, data.size, total_calls\n end", "def calc_full_nodes_avail\n @full_nodes_available = 0\n #if @cluster_title.eql?(\"Ruby\")\n # # See line 62\n #@full_nodes_available = nodes_info.lines(\"\\n\\n\").select { |node| node.include?(\"dedicated_threads = 0\") && node.include?(\"np = 20\") && node.include?(\"gpu_state=Unallocated\")}.size\n #else\n #@full_nodes_available = nodes_info.lines(\"\\n\\n\").select { |node| node.include?(\"dedicated_threads = 0\") && node.include?(\"gpu_state=Unallocated\") }.size\n #end\n end", "def report\n STATE_DATA.each do |state, population_stats|\n state = VirusPredictor.new(state, population_stats[:population_density], population_stats[:population])\n state.virus_effects\n end\nend", "def gen_node_infos(cluster_yml)\n\n master_n = 1\n master_mem = cluster_yml['master_mem']\n master_cpus = cluster_yml['master_cpus']\n\n slave_n = cluster_yml['slave_n']\n slave_mem = cluster_yml['slave_mem']\n slave_cpus = cluster_yml['slave_cpus']\n\n master_ipbase = cluster_yml['master_ipbase']\n slave_ipbase = cluster_yml['slave_ipbase']\n\n master_infos = (1..master_n).map do |i|\n { :hostname => \"master#{i}\",\n :ip => master_ipbase + \"#{10+i}\",\n :mem => master_mem,\n :cpus => master_cpus\n }\n end\n\n slave_infos = (1..slave_n).map do |i|\n { :hostname => \"slave#{i}\",\n :ip => slave_ipbase + \"#{10+i}\",\n :mem => slave_mem,\n :cpus => slave_cpus\n }\n end\n\n analytics_node = cluster_yml['analytics_node']\n analytics_mem = cluster_yml['analytics_mem']\n analytics_cpus = cluster_yml['analytics_cpus']\n\n analytics_info = {\n :node => analytics_node,\n :mem => analytics_mem,\n :cpus => analytics_cpus\n }\n\n\n return { :master => master_infos, :slave=>slave_infos, :analytics=>analytics_info }\nend", "def report_cpu\n self.report('cpu_report')\n end", "def output_success\n puts \"status Cman node status for #{@hostname}\"\n @metrics.each do |name,v|\n puts \"metric #{name} #{v[:type]} #{v[:value]}\"\n end\nend", "def get_nodes\n @known_nodes\n end", "def report\n message = [identification]\n\n message.concat(make_report('Original-Source', :original_source))\n message.concat(make_report('Generated-Source', :generated_source))\n message.concat(make_report('Original-Node', :original_node))\n message.concat(make_report('Generated-Node', :generated_node))\n message.concat(node_diff_report)\n\n message.join(\"\\n\")\n end", "def collect_node_properties(certname, profile, resources, settings, totals)\n properties = {\n 'profile' => profile,\n 'resources' => resources,\n 'settings' => settings,\n 'totals' => totals,\n }\n @collected_nodes[certname] = properties\n end", "def nodes(plan)\n if plan['nodes'].is_a?(Regexp)\n @m_finder.match_nodes(plan['nodes'])\n elsif plan['nodes'].is_a?(Array)\n plan['nodes'].collect { |n| @m_finder.machine(n.to_sym) }\n end\n end", "def call_tree\n `cube_info #{@fname}`\n end", "def process_report(report)\n file_names = @dangerfile.git.modified_files.map { |file| File.expand_path(file) }\n file_names += @dangerfile.git.added_files.map { |file| File.expand_path(file) }\n report.targets.each do |target|\n target.files = target.files.select { |file| file_names.include?(file.location) }\n end\n\n report\n end", "def report\n report_metrics\n report_resources\n if run_status.failed?\n report_backtrace\n end\n end", "def results\n bc = buffer.source_lines.map { |line| '-' * line.size }\n each_node do |node|\n runs = node_runs(node)\n next if runs == nil\n node.proper_range.each do |pos|\n bc[buffer.line_for_position(pos) - buffer.first_line][buffer.column_for_position(pos)] = runs > 0 ? ' ' : 'x'\n end\n end\n bc.zip(buffer.source_lines) { |cov, line| cov[line.size..-1] = '' } # remove extraneous character for end lines, in any\n bc\n end", "def initialize\n @collection = {}\n @filters = {}\n @outputs = []\n add_output do |report|\n\n erb = Erubis::Eruby.new(File.read(@template))\n puts erb.evaluate(report)\n rescue NameError => e\n raise Error::ErbTemplateParseError.new(original_error: e.message)\n\n end\n @template = ChefSpec.root.join(\"templates\", \"coverage\", \"human.erb\")\n end", "def run_and_check_status (node, expected_exit_status)\n `./bin/aeolus-node-check ./spec/fixtures/nodes/#{node}`\n $?.exitstatus.should be(expected_exit_status), \"#{node}\"\nend", "def process_child_nodes(node); end", "def fetch_page_nodes\n (1..12).each do |file_name|\n body = File.open(\"#{Rails.root}/lib/wayfair_batch/#{file_name}.html\")\n @page_nodes.push(Nokogiri::HTML(body))\n end\n end", "def do_report file, args=nil\n require 'rexml/document'\n begin\n dom = REXML::Document.new( IO.read( file ) )\n if args.empty?\n puts basic_xhtml_report( dom )\n else\n puts report_on( dom, args.first )\n end\n rescue Exception\n warn \"There was a problem reading '#{file}': \\n#{$!}\"\n end\n end", "def discover_nodes(type, properties)\n uses_properties = properties.delete(\"uses\") || {}\n playbook.uses.from_hash(uses_properties)\n\n nodes.from_hash(\"task_nodes\" => properties.merge(\n \"type\" => type,\n \"uses\" => uses_properties.keys\n ))\n\n nodes.prepare\n nodes[\"task_nodes\"]\n end", "def analyze_samples\n run_data = show do \n title \"Run analysis\"\n note \"If you can't click \\\"run\\\", and there is an error that reads, \\\"The pressure is too low. Replace the nitrogen cylinder or check the external nitrogen source,\\\" \n close the software, and reopen it. Then repeat steps 9-13.\"\n check \"Otherwise, click run\"\n note \"Estimated time is given at the bottom of the screen\"\n get \"number\", var: \"runs_left\", label: \"Enter the number of \\\"Remaining Runs\\\" left in this cartridge.\", default: 0\n image \"Actions/Fragment Analyzer/frag_an_run.jpg\"\n end\n\n while run_data[:runs_left].nil? && !debug\n run_data = show do \n title \"Enter remaining runs\"\n warning \"Please enter the number of remaining runs left in this cartridge.\"\n get \"number\", var: \"runs_left\", label: \"Enter the number of \\\"Remaining Runs\\\" left in this cartridge.\", default: 0\n end\n end\n run_data\n end", "def find_applying_nodes(hosts, statuses = [])\n Log.debug(\"checking applying status of #{hosts.inspect}\")\n @client.filter[\"identity\"].clear\n hosts.each do |host|\n @client.identity_filter(host)\n end\n\n results = @client.status\n\n hosts.each do |host|\n result = results.select { |r| r[:sender] == host }.first\n status = statuses.select { |s| s[:name] == host }.first\n\n unless status\n status = make_status(host)\n statuses << status\n end\n\n if result\n # check the value of applying as defined in the agent ddl\n if result[:data][:applying] == true\n # we're applying\n if result[:data][:initiated_at]\n # it's a new agent, we can record when it started\n Log.debug(\"#{host} run was started at #{result[:data][:initiated_at]}\")\n status[:initiated_at] = result[:data][:initiated_at]\n else\n Log.debug(\"#{host} run started\")\n end\n else\n # Here we check the \"asked to run but not yet started\" state.\n if result[:data][:lastrun].to_i >= status[:initiated_at]\n Log.debug(\"#{host} run completed\")\n # The node has finished applying, remove from the running set\n statuses.reject! { |s| s[:name] == host }\n next\n else\n # We haven't started yet that we can see, increment the check counter\n status[:checks] += 1\n Log.debug(\"#{host} starting, checks #{status[:checks]}\")\n end\n end\n else\n # We didn't get a result from this host, log and record a check happened\n log(\"Host #{host} did not respond to the status action.\")\n status[:no_response] += 1\n end\n\n if status[:no_response] >= 5\n # If we missed many responses to status, assume it's a dead node\n log(\"Host #{host} failed to respond multiple times. Skipping.\")\n statuses.reject! { |s| s[:name] == host }\n end\n\n if status[:checks] >= 5\n # If we hit more than 5 checks, assume it couldn't start\n log(\"Host #{host} did not move into an applying state. Skipping.\")\n statuses.reject! { |s| s[:name] == host }\n end\n end\n\n return statuses\n end", "def run\n blocks if config[:blocks]\n inodes if config[:inodes]\n check_blocks_and_inodes\n end", "def execute\n puts @robot.report\n end", "def test_more\n xmlsource = fixture_path(\"testsrc.xml\")\n xpathtests = fixture_path(\"xp.tst\")\n\n doc = File.open(xmlsource) {|f| REXML::Document.new(f) }\n #results = \"\"\n results = REXML::Document.new\n results.add_element \"test-results\"\n File.foreach(xpathtests) do |line|\n line.strip!\n begin\n doc.root\n #puts \"#\"*80\n #print \"\\nDoing #{line} \" ; $stdout.flush\n doc.elements.each(line) do |el|\n #print \".\" ; $stdout.flush\n results.root << el.clone\n #results << el.to_s\n end\n #ObjectSpace.garbage_collect\n GC::start\n rescue Exception => z\n #puts \"\\n'#{line}' failed\"\n fail(\"Error on line #{line}:\\n#{z.message}\\n\"+z.backtrace[0,10].join(\"\\n\"))\n #results.root.add_element( \"error\", {\"path\"=>line}).text = z.message+\"\\n\"+z.backtrace[0,10].join(\"\\n\")\n #results << \"<error path='\"+line+\"'>\"+z.message+\"</error>\"\n end\n end\n end", "def failed_critical_nodes\n critical_nodes.select do |node|\n node.failed? && !node.skipped?\n end\n end", "def coverage\n bl_range = (0..article&.body&.length.to_i)\n endpoints.grep bl_range\n end" ]
[ "0.5779997", "0.5373228", "0.52066165", "0.5200856", "0.514599", "0.5082208", "0.50282973", "0.49819762", "0.4909435", "0.49082386", "0.49082386", "0.49082386", "0.49019468", "0.49018583", "0.48720074", "0.48349997", "0.48325175", "0.48231134", "0.4823081", "0.47887096", "0.47840196", "0.47742465", "0.47663325", "0.47635272", "0.4755329", "0.4750188", "0.47458348", "0.47454056", "0.47427705", "0.47410595", "0.47375387", "0.47289118", "0.47224963", "0.47098014", "0.47054416", "0.46863392", "0.46796432", "0.46786037", "0.4652324", "0.46499407", "0.46201763", "0.46115783", "0.46115783", "0.46098587", "0.46026152", "0.45971984", "0.45909932", "0.458806", "0.458806", "0.45823026", "0.4580377", "0.45774505", "0.4576432", "0.45746228", "0.4570293", "0.4565407", "0.4555075", "0.45457476", "0.45391208", "0.4531035", "0.4531035", "0.4531035", "0.4531035", "0.4531035", "0.45285505", "0.4525628", "0.4518367", "0.45174208", "0.45144123", "0.45139873", "0.45095524", "0.45065308", "0.45055342", "0.4498252", "0.44967142", "0.44962117", "0.44945255", "0.44935936", "0.4492803", "0.4491196", "0.44859347", "0.44791234", "0.44731963", "0.44638875", "0.44637945", "0.44612405", "0.44589123", "0.44453377", "0.44404447", "0.44379285", "0.44367868", "0.44367248", "0.4434579", "0.4433261", "0.4433185", "0.44277346", "0.4412002", "0.44085884", "0.44073164", "0.4404295" ]
0.50412476
6
=begin Here is another solution I developed, it is almost identical to my original solution just that we rearrange the string by splitting it into an array of characters, then we use the rotate method to shift every element 1 index position to the left. Rotate with no number passed in is the same as rotate(1) so the element in position 1 becomes the first element, and the first element becomes the last element, we join this back then add "ay" to the end. =end
def pig_it_ms_two(str) pig = [] str.split.each do |w| pig << w.chars.rotate.join + "ay" if w =~ /\w/ pig << w if w =~ /\W/ end pig.join(" ") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotate_string(string)\n return nil if string.empty?\n array = string.split('')\n result = array[1..-1] + [array[0]]\n result.join # to convert array back to 'string'\nend", "def rotate_string(string)\n array = string.split('')\n rotate_array(array).join\nend", "def rotate_string(string)\n string[1..-1] + string[0]\nend", "def rotate_string(string)\n string[1..-1] + string[0]\nend", "def rotate_str(str)\n str[1..-1] << str[0]\nend", "def rotate_string(string)\n arr = string.chars\n str = rotate_array(arr).join\nend", "def rotate_string(word)\n new_word = ''\n new_word << word[1..-1] << word[0]\n new_word\nend", "def rotate_string(str)\n arr = str.chars\n rotate_array(arr).join\nend", "def rotate_string(string)\n rotate_array(string.chars).join\nend", "def rotate_string(string)\n rotate_array(string.chars).join\nend", "def rotate_string(string)\n rotate_array(string.chars).join\nend", "def rotate_string(string)\n rotate_array(string.chars).join\nend", "def rotate_string(string)\n rotate_array(string.chars).join\nend", "def rotate_string(string)\n arr = string.split(\"\")\n rotate_array(arr).join(\"\")\nend", "def rotateChar(s)\n #convert string to array\n arr = []\n s.each_char do |char|\n arr.push(char)\n end\n #Rotate\n result = Array.new(arr.length)\n arr.each_with_index do |element,index|\n result[index-1] = element\n end\n return result.join\nend", "def rotate_string(string)\n if string.size > 1\n rotate_array(string.chars).join\n else\n string\n end\nend", "def rotate_string(str)\n rotate_array(str.chars).join\nend", "def rotate_string(str)\n rotate_array(str.chars).join\nend", "def rotate_string(str)\n rotate_array(str.chars).join\nend", "def rotate_string(string)\n return \"\" if string.empty?\n string.chars.rotate # using chars instead of split.\nend", "def rotate(unrotated)\n return '' if unrotated.empty?\n unrotated[1..-1] + unrotated[0]\nend", "def rotate(input)\n input[1..-1] << input[0]\nend", "def rotations(string)\n #array = string.split(//)\n #array2 = array.map {|element| }\n\n return (0...string.length).map { |i| (string * 2)[i, string.length] }\n\nend", "def vowel_rotate(str)\n vowels = \"aeiou\"\n arr = []\n copy_str = str.dup \n copy_arr = copy_str.split(\"\")\n str.each_char.with_index do |char, i|\n if vowels.include?(char)\n arr << i\n end\n end\n p arr\n last = arr.last\n first = arr.first\n copy_str[first]= str[last]\n\n (1...arr.length).each do |j|\n copy_str[arr[j]] = str[arr[j - 1]]\n end\n copy_str\n \nend", "def vowel_rotate(string)\n vowels = \"aeiou\"\n rotated = string.dup\n \n last_vow = string.chars.reverse_each { |char| break char if vowels.include?(char) }\n prev_vow = nil\n\n string.each_char.with_index do |char, i|\n # if vowel - replace with previous vowel\n if vowels.include?(char)\n # if it's the first vowel - replace with last vowel\n if prev_vow.nil?\n prev_vow = char\n rotated[i] = last_vow\n next\n end\n\n rotated[i] = prev_vow\n prev_vow = char\n end\n end\n\n rotated\nend", "def vowel_rotate(str)\n vowels = \"aeiou\"\n orig_vowels = []\n rotated = str\n\n str.chars.each {|c| orig_vowels << c if vowels.include?(c)}\n\n rotated.chars.each_with_index do |c, i|\n if vowels.include?(c)\n rotated[i] = orig_vowels[-1]\n orig_vowels << orig_vowels.shift\n end\n end\n rotated\nend", "def rotate(word, rotations)\n word.split('').rotate(rotations).join\n end", "def caesar_cipher(string, shift = DateTime.now.day) # I set shift to be the current day if I do not include a parameter for it\n string.tr Alphabet.join, Alphabet.map{ |array| array.rotate shift }.join # This looks at every single character in the string and uses .map to rotate the array to bascially let it shift how ever many times within the array to assign the new character to the string variable\nend", "def alphabeticShift(inputString)\n alpha = (\"a\"..\"z\").to_a + [\"a\"]\n array = inputString.split(\"\")\n \n for i in 0..(array.count-1)\n array[i] = alpha[alpha.index(array[i])+1]\n end\n array.join(\"\")\nend", "def vowel_rotate(str)\n vowels = \"aeiou\"\n new_str = \"\"\n indices = []\n\n str.each_char { |char| indices << char if vowels.include?(char) }\n rotated = indices.rotate(-1)\n str.each_char.with_index do |c,i|\n if !vowels.include?(c)\n new_str += c\n else\n new_str += rotated.shift\n end\n end\n\n new_str\n # indices = []\n # vowels = \"aeiou\"\n # (0...str.length).each { |i| indices << i if vowels.include?(str[i]) }\n # debugger\n # indices.each_with_index do |vowel_idx, idx|\n # prev = indices[-1 - idx] \n # str[vowel_idx] = str[prev]\n # end\n # str\nend", "def vowel_rotate(str)\n vowels = ['a','e','i','o','u']\n array = []\n str.each_char do |char|\n array << char if vowels.include?(char)\n end\n array = [array[-1]] + array.slice(0,array.length-1)\n str.each_char.with_index do |char, idx|\n str[idx] = array.shift if vowels.include?(char)\n end\n str\nend", "def revrot(str, sz)\n return \"\" if sz == 0 || sz > str.length\n out = \"\"\n str.split(\"\").each_slice(sz).to_a.each do |i|\n return out if i.length < sz\n if i.reduce(0){ |sum,e| sum + (e.to_i)**3 } % 2 == 0 \n out += i.reverse!.join\n else\n out += i.rotate!.join\n end\n end\n out\nend", "def vowel_rotate(str)\n vowels = \"aeiou\"\n new_str = str[0..-1] \n \n vowel_idx = (0...str.length).select { |i| vowels.include?(str[i]) }\n new_vowels = vowel_idx.rotate(-1)\n vowel_idx.each_with_index do |vowel, i|\n new_vowel = str[new_vowels[i]]\n new_str[vowel] = new_vowel\n end\n new_str\nend", "def vowel_rotate(str)\n vowels = \"aeiou\"\n str_vowels = (0...str.length).select { |i| vowels.include?(str[i]) }\n new_string = str[0..-1]\n new_str_vowels = str_vowels.rotate(-1)\n\n str_vowels.each_with_index do |vowel_idx, i|\n new_vowel = str[new_str_vowels[i]]\n new_string[vowel_idx] = new_vowel\n end\n\n new_string\nend", "def rotate(array, number)\n\t#put the strings we want to move into a new string\n\tnewArray = array.shift\n\t#subtract the number\n\tnumber-=1\n\t#push the strings to the back of the array\n\tarray.push(newArray)\n\t#keep doing this until our number is 0\n\trotate(array, number) unless number ==0\nend", "def vowel_rotate(str)\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n\n vows = []\n ids = []\n str.chars.each_with_index do |char, idx| \n if vowels.include?(char)\n vows << char\n ids << idx\n end\n end\n\n vows.unshift(vows.pop())\n (0...vows.length).each { |i| str[ids[i]] = vows[i]}\n\n str\nend", "def vowel_rotate(str)\n vowels = \"AEIOUaeiou\"\n vowel_arr = []\n str.each_char do |char|\n if vowels.include?(char)\n vowel_arr << char\n end\n end\n vowel_arr.rotate!(-1)\n idx2 = 0\n str.each_char.with_index do |char,idx|\n if vowels.include?(char)\n str[idx] = vowel_arr[idx2]\n idx2 += 1\n end\n end\n str\nend", "def rotLeft(a, d)\n str = ''\n\n a.count.times do |i|\n new_index = (i + d) % a.count\n str += \"#{a[new_index]} \"\n end\n\n str.split(' ')\nend", "def vowel_rotate(str)\n# make a copy of a original string\n new_str = str[0..-1]\n vowels = \"aeiou\"\n\n# obtain the indices of vowels\n vowel_indices = (0...str.length).select { |i| vowels.include?(str[i]) }\n # [1, 4, 6]\n\n# rotate the positions\n new_vowel_indices = vowel_indices.rotate(-1) # [6, 1, 4]\n\n# iterate through the ORIGINAL vowel indices\n vowel_indices.each_with_index do |vowel_idx, i| \n # vowels_idx = 1, 4, 6; i = 0, 1, 2\n new_vowel = str[new_vowel_indices[i]] # str[6]\n new_str[vowel_idx] = new_vowel\n end\n\n new_str\nend", "def vowel_rotate(string)\n vowels = \"aeiou\"\n new_str = string\n vowel_indices = []\n letters = string.split(\"\")\n \n string.each_char.with_index do |char, i|\n vowel_indices << i if vowels.include?(char)\n end\n rotated = vowel_indices.rotate(-1)\n #debugger\n vowel_indices.each_with_index do |v_idx, i|\n new_idx = rotated[i]\n new_str[v_idx] = letters[new_idx]\n end\n new_str\n\nend", "def vowel_rotate(str)\n vowels = \"aeiou\"\n arr = []\n original_vowels = \"\"\n\n str.each_char.with_index do |char, i|\n if vowels.include?(char)\n original_vowels += char \n arr << i\n end\n end\n\n str[arr.shift] = original_vowels[-1]\n arr.each_with_index do |str_index, index|\n str[str_index] = original_vowels[index]\n end\n\n str\nend", "def vowel_rotate(str)\n vowels = \"aeiou\"\n str_vowels = []\n str.each_char { |char| str_vowels << char if vowels.include?(char) }\n str_vowels.unshift(str_vowels.pop)\n \n str.each_char.with_index do |char, idx|\n str[idx] = str_vowels.shift if vowels.include?(char)\n end\n\n str\nend", "def vowel_rotate(str)\n vowel_indices = (0...str.length).select { |i| 'aeiou'.include?(str[i]) }\n rotated_indices = vowel_indices.rotate(-1)\n rotated_chars = str.split('').map.with_index do |char, i|\n vowel_indices.include?(i) ? str[rotated_indices.shift] : char\n end\n rotated_chars.join\nend", "def vowel_rotate(str)\n vowels = 'aeiou'\n array = []\n i = 0\n\n str.each_char {|char| array << char if vowels.include?(char)}\n str.each_char.with_index do |char, idx|\n if vowels.include?(char)\n str[idx] = array[i - 1]\n i += 1\n end\n end\n str\nend", "def vowel_rotate(str)\n vowels = 'aeiou'\n my_vowels = []\n\n str.each_char { |char| my_vowels << char if vowels.include?(char) }\n my_vowels.unshift(my_vowels.pop)\n str.each_char.with_index { |char, i| str[i] = my_vowels.shift if vowels.include?(char) }\n str\nend", "def vowel_rotate(str)\n new_str = str[0..-1]\n vowels = 'aeiou'\n vowel_indices = (0...str.length).select { |i| vowels.include?(str[i]) }\n new_vowel_indices = vowel_indices.rotate(-1)\n\n vowel_indices.each_with_index do |vowel_idx, i|\n new_vowel = str[new_vowel_indices[i]]\n new_str[vowel_idx] = new_vowel\n end\n\n new_str\nend", "def vowel_rotate(str)\n arr_of_vowels = vowels(str)\n idx = 0\n new_str = \"\"\n vowels = \"aeiou\"\n str.each_char do |char|\n if vowels.include?(char)\n new_str += arr_of_vowels[(idx - 1) % arr_of_vowels.length]\n idx +=1\n else\n new_str += char\n end\n end\n new_str\nend", "def vowel_rotate(str)\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n vowels_from_str = []\n\n str.each_char do |char|\n if vowels.include?(char)\n vowels_from_str << char\n end\n end\n\n vowels_2 = vowels_from_str.rotate(vowels_from_str.length - 1)\n\n i = 0\n while i < vowels_2.length - 1\n str.each_char.with_index do |char, idx|\n if vowels.include?(char)\n str[idx] = vowels_2[i]\n i += 1\n end\n end\n end\n str\nend", "def vowel_rotate(str)\n new_str = str[0..-1]\n vowels = 'aeiou'\n\n vowel_idxs = (0...str.length).select { |i| vowels.include?(str[i]) }\n rotated_vowel_idxs = vowel_idxs.rotate(-1)\n\n vowel_idxs.each_with_index do |vowel_idx, i|\n new_vowel = str[rotated_vowel_idxs[i]]\n new_str[vowel_idx] = new_vowel\n end\n\n new_str\nend", "def rotate_47(input=\"hello world\")\n decode= ''\n ascii=[]\n #converts to ascii\n input.each_byte do |c|\n ascii << c\n end\n\n for i in 0..ascii.length-1\n if ascii[i]>=33 and ascii[i] <=126\n ascii[i]+=47\n if ascii[i]>126\n ascii[i] += -94\n end\n end\n decode << ascii[i].chr\n end\n decode\nend", "def vowel_rotate(str)\n rotated_word = \"\"\n vowels = \"aeiou\"\n \n last_vowel = \"\"\n i = str.length - 1\n while i >= 0\n if vowels.include?(str[i])\n last_vowel = str[i] \n break\n end\n i -= 1\n end\n \n str.each_char do |char|\n if vowels.include?(char)\n rotated_word += last_vowel\n last_vowel = char\n else\n rotated_word += char\n end\n end\n\n rotated_word\nend", "def vowel_rotate(str)\n vowels = \"aeiou\"\n last_vowel = \"\"\n\n result = \"\"\n str.each_char.with_index do |char, idx|\n if vowels.include?(char)\n if last_vowel == \"\"\n last_vowel = get_last_vowel(str)\n end\n result << last_vowel\n last_vowel = str[idx]\n else\n result << char\n end\n end\n return result\nend", "def shifting_letters(s, shifts)\n letters = ('a'..'z').to_a\n \n shifts = shifts.reverse\n \n shifts.each_with_index do |shift, index|\n next if index == 0\n \n shifts[index] = shifts[index] + shifts[index - 1]\n end\n \n shifts = shifts.reverse\n s = s.split('')\n \n s.each_with_index do |char, index|\n total_rotation_in_num = shifts[index] + letters.index(char)\n \n s[index] = letters[total_rotation_in_num % 26]\n end\n \n s.join('')\nend", "def vowel_rotate(str)\n vowel_arr= []\n \n vowels = \"aeiou\"\n #can use select to select vowels\n # vowel_arr = (0...str.length).select {|i| vowels.include?(str[i])}\n str.each_char.with_index do |char, i|\n if vowels.include?(char)\n vowel_arr << char\n end\n end\n #rather than pop and unshift, we can use rotate method\n last = vowel_arr.pop\n vowel_arr.unshift(last)\n count = 0\n #our new_vowel array and our rotated_vowel array will now look like this\n # [1, 3, 7] => [7, 1, 3]\n #what we can do is change the values according to the idx\n # str[old[0]], which is str[1] should now be str[new[0]]\n str.each_char.with_index do |char, i|\n if vowels.include?(char)\n str[i] = vowel_arr[count]\n count += 1\n end\n end\n str\n\nend", "def swap(string)\n array = string.scan(/\\w+/)\n array.map! { |word| word.scan(/(.)/) }\n array.map! do |word|\n letter_last = word.pop\n word.rotate.unshift(letter_last).join\n end\n array.join(' ')\nend", "def reverse(string)\n# string.chars.reverse.join\t\t\t\t\t \t# Option 1 - Break string in array of chars, reverse array, and join them back together\n \n=begin \t\t\t\t\t\t\t\t\t\t\t # Option 2 - Break string into chars and prepend them so that the letter \n str = ''\t\t\t\t\t\t\t\t\t\t # after is now before it\n string.chars.each{|x| str.prepend(x)}\n str\n=end\n \n arr = string.chars\t\t\t\t\t\t\t # Option 3 - Iterating through each index of array of characters in string from last \n string = ''\t\t\t\t\t\t\t\t\t # to first, push character into string \n (arr.length-1).downto(0) do |x|\t\t\t\t\n string << arr[x]\n end\n string\nend", "def RotateNumber (input)\n\tfirst = input[0]\n\tinput[0] = ''\n\tinput += first\nend", "def rot(x, string, encrypt = true)\n\tletters = ('A'..'Z').to_a\n\tletters_length = letters.length \n\toutput_text = ''\n\tstring.each_char{ |chr|\t\n\t\toutput_text << chr && next if chr.match(/^[a-zA-Z]+$/).nil? \n\t\trot_idx = encrypt ? (letters.index(chr.upcase) + x) : (letters.index(chr.upcase) - x)\n\t\toutput_idx = (rot_idx <= (letters_length - 1)) ? rot_idx : (rot_idx % letters_length)\n\t\toutput_text << ((chr.match(/[[:upper:]]/).nil?) ? letters[output_idx].downcase : letters[output_idx])\n\t}\n\treturn output_text\nend", "def transform(string)\n arr = string.split\n\n transformed = arr.map.with_index do |word, idx|\n idx.even? ? word : word.reverse\n end\n\n if transformed.last == '.'\n transformed[-2] << transformed.pop\n elsif transformed.size.even?\n transformed[-1] = transformed.last[1..-1] + '.'\n end\n\n transformed.join(' ')\nend", "def swap(string)\n arr = []\n string.split(\" \").each do |element|\n arr << element.split(\"\")\n end\n \n swap_arr = []\n arr.each do |e|\n first_char = e.shift\n last_char = e.pop\n swap_arr << e.unshift(last_char).push(first_char)\n end\n \n swap_arr.map! do |el|\n el.join(\"\")\n end\n \n swap_str = swap_arr.join(\" \")\n \n swap_str\nend", "def translate_word(word)\n split_array = split_into_array(word)\n rotated_array = rotate_at_vindex(split_array)\n ay_array = add_ay(rotated_array)\n final_array = back_to_s(ay_array)\nend", "def vowel_shift(text,n)\n\n # Check for empty and nil\n if text.to_s == ''\n return text\n end\n\n # letrs_arr = [\"t\", \"h\", \"i\", \"s\" ...]\n letrs_arr = text.split(\"\")\n # letrs_arr_len = letrs_arr.length\n letr_arr_ind = 0\n # big_array [[\"i\", 2, var], [\"i\", 5, var], [\"a\", 8, var], [\"e\", 11, var]]\n # var will depend on the given n\n big_array = []\n # define array for where letters should go back to\n vowels_position_index = []\n vowels = [\"a\",\"e\",\"i\",\"o\",\"u\",\"A\",\"E\",\"I\",\"O\",\"U\"]\n\n # this is to construct V1 of big_array [[\"i\", 2, 0], [\"i\", 5, 1], [\"a\", 8, 2], [\"e\", 11, 3]]\n while letr_arr_ind < letrs_arr.length\n if vowels.include? letrs_arr[letr_arr_ind]\n big_array << [letrs_arr[letr_arr_ind]]\n vowels_position_index << letr_arr_ind\n end\n letr_arr_ind += 1\n end\n\n roted_big_array = big_array.rotate(-n)\n\n for i in 0..vowels_position_index.length-1\n letrs_arr[vowels_position_index[i]] = roted_big_array[i]\n end\n\n string = letrs_arr.join(\"\")\n return string\n\nend", "def unrotate(string, positions = 12)\r\n alphabet = Array('A'..'Z')\r\n decrypted = ''\r\n string.split('').each do |char|\r\n i = alphabet.find_index(char)\r\n decrypted += alphabet[(i-positions)%alphabet.size]\r\n end\r\n return decrypted\r\nend", "def reverse_string_3(string)\n string = string.to_s\n result = ''\n string.length.times { |i| result << string[(i + 1) * -1] }\n result\nend", "def rotx2(x, string, encrypt=true)\n offset = encrypt ? x % 26 : -x % 26\n string.tr('A-Za-z', rotated_alph(offset))\nend", "def vowel_rotate(str)\n new_word = \"\"\n next_vowel = \"\"\n first_vowel_ind = \"\"\n\n str.each_char.with_index do |char, ind|\n if is_vowel?(char) && next_vowel.empty?\n first_vowel_ind = ind\n next_vowel = char\n new_word += char\n elsif is_vowel?(char)\n new_word += next_vowel\n next_vowel = char\n else\n new_word += char\n end\n end\n new_word[first_vowel_ind] = next_vowel\n new_word\nend", "def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend", "def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend", "def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend", "def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend", "def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend", "def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend", "def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend", "def swap(string)\n if string.split.size > 1\n array = string.split.each do |word|\n word[0], word[-1] = word[-1], word[0]\n end\n array.join(' ')\n elsif string.length <= 1\n string\n else\n first = string[0]\n last = string[-1]\n string[0] = last\n string[-1] = first\n string\n end\nend", "def rotx1(x, string, encrypt=true)\n\n return string if x % 26 == 0\n offset = encrypt ? x % 26 : -x % 26\n\n return string.tr('A-Za-z', 'B-ZAb-za') if offset == 1\n return string.tr('A-Za-z', \"ZA-Yza-y\") if offset == 25\n rot_a = (offset + 'a'.ord).chr\n rot_z = (rot_a.ord - 1).chr\n \n string.tr('A-Za-z', rot_a.upcase + \"-ZA-\" + rot_z.upcase + rot_a + \"-za-\" + rot_z)\nend", "def rotate_rightmost_digits(number, times)\n rotated_number = number.to_s.split('')\n rotated_number[(times * -1)..-1] = rotate_array(rotated_number[times*-1..-1])\n\n rotated_number.join('').to_i\nend", "def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(' ')\nend", "def rotate_integer(integer)\n integer.to_s.chars.rotate.join.to_i\nend", "def reverse_inplace(s)\n return s if s.length <= 1\n\n s = s.split('')\n first = s[0]\n last = s[s.length-1]\n s.shift\n s.pop\n\n s = reverse_inplace(s.join(''))\n s = s.split('')\n s.unshift(last)\n s.push(first)\n return s.join('')\nend", "def string_rotation(str1, str2)\n arr1 = str1.split('')\n str1.length.times do |i|\n return true if arr1.unshift(arr1.pop).join == str2\n end\n return false\nend", "def rot13(string) #puts (ascii % 90)+64+13 #T-G 84-71\n # binding.pry\n rot = \"\"\n string.length.times do |i|\n ascii = string[i].ord\n if ascii >= 65 && ascii <= 90 then\n if (ascii + 13) > 90\n rot.concat((((ascii+13) % 90)+64).chr)\n else\n rot.concat((ascii+13).chr)\n end\n elsif ascii >= 97 && ascii <= 122\n if (ascii + 13) > 122\n rot.concat((((ascii+13) % 122)+96).chr)\n else\n rot.concat((ascii+13).chr)\n end\n else\n rot << \" \"\n end\n end\n return rot\nend", "def spin_me(str)\n str.split.map do |word|\n word.reverse\n end.join(\" \")\nend", "def movingShift(s, shift)\nres = ''\n s.chars.each do |x|\n ord = x.ord\n if x.ord > 64 && x.ord < 91\n ord = ((ord - 65 + shift) % 26) + 65\n else\n if x.ord > 96 && x.ord < 123\n ord = ((ord - 97 + shift) % 26) + 97\n end\n end\n shift+=1\n res += ord.chr\n end\n l = (res.length/5.0).ceil\nputs l\nputs res\n [res[0..l-1], res[l..2*len-1],res[2*l..3*l-1],res[3*l..4*len-1],res[4*l..-1]]\nend", "def reverse_string_5(string)\n string = string.to_s\n result = ''\n string.split('').each_index do |i|\n result += if i != 0\n string[-1 * (i + 1)]\n else\n string[i - 1]\n end\n end\n result\nend", "def 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 rotLeft(a, d)\n d.times do\n ele = a.shift\n a << ele\n end\n return a\nend", "def reverse(string)\n i = 0\n abc = [] # creating empty array\n while i < string.length\n abc.unshift(string[i]) #populating empty array in reverse\n i = i + 1\nend\nreturn abc.join \nend", "def reverse(str)\n str.chars.inject([], &:unshift).join\nend", "def vigenere_cipher(str, arr)\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n results = \"\"\n str.each_char.with_index do |char, i|\n ind = (alphabet.index(char) + arr[0]) % 26\n results += alphabet[ind]\n arr.rotate!\n end\n results\nend", "def reverse(string)\n\n # Empty array\n result = []\n\n # Iterate through each character in the input string\n string.each_char do |char|\n result.unshift(char) # To reverse, force each char to the front\n end\n\n # Return the array compressed back into a string\n return result.join(\"\")\nend", "def reverse(txt)\n output = []\n txt.each_char do |char|\n output.unshift(char) #unshift is like prepend\n end\n\n output.join\nend", "def rot13(string)\n # Put your code here!\n ans = \"\"\n alph = \"abcdefghijklmnopqrstuvwxyz\"\n calph = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n string.each_char do |x|\n if alph.include?(x)\n ind = alph.index(x)\n newi = ind + 13\n pos = newi % 26\n ans << alph[pos]\n elsif calph.include?(x)\n ind = calph.index(x)\n newi = ind + 13\n pos = newi % 26\n ans << calph[pos]\n else\n ans << x\n end\n end\n return ans\n\nend", "def reverse_string_4(string)\n string = string.to_s\n result = ''\n index = 0\n while index < string.length\n result = string[index] + result\n index += 1\n end\n result\nend", "def shift(str)\n cap_vowels = \"AEIOUA\"\n lower_vowels = \"aeioua\"\n cap_consonants = \"BCDFGHJKLMNPQRSTVWXYZB\"\n lower_consonants = \"bcdfghjklmnpqrstvwxyzb\"\n letter_array = []\n shifted_string = \"\"\n\n str = str.split\n letter_array += str[0].split(\"\")\n letter_array += [\" \"]\n letter_array += str[1].split(\"\")\n letter_array.each do |letter|\n if cap_vowels.include? letter\n shifted_string += cap_vowels[cap_vowels.index(letter) + 1]\n elsif lower_vowels.include? letter\n shifted_string += lower_vowels[lower_vowels.index(letter) + 1]\n elsif cap_consonants.include? letter\n shifted_string += cap_consonants[cap_consonants.index(letter) + 1]\n elsif lower_consonants.include? letter\n shifted_string += lower_consonants[lower_consonants.index(letter) + 1]\n elsif letter == \" \"\n shifted_string += \" \"\n end\n end\n shifted_string\n end", "def compress(string)\n compressed_string = []\n count_consecutive = 0\n\n ##\n # Here is a simple counter: count_consecutiv will add 1 each time\n # next string letter is the same. If next array element is not the the same\n # will write letter and counter after the letter. Once it happened will set\n # counter back to 0.\n #\n for i in 0..string.length - 1\n count_consecutive +=1\n\n if string.chars[i] != string.chars[i+1]\n if count_consecutive == 1\n compressed_string << string.chars[i].to_s\n count_consecutive = 0\n else\n compressed_string << string.chars[i].to_s + count_consecutive.to_s\n count_consecutive = 0\n end\n end\n end\n compressed_string.join\nend", "def shiftl(word)\n word[1..-1] << word[0]\nend", "def reverse_a_string(string)\n letter = string.split(\"\")\n reversed_string =[]\n reversed_string.each do |letter|\n reversed_string.unshift(letter)\n end\nend", "def transform(str)\n str = \"^#{str}$\"\n table = [str.dup]\n len = str.length\n (1...len).each do\n c = str.slice!(len - 1)\n str = c + str\n\n table << str.dup\n end\n\n table.sort!\n newstr = \"\"\n (0...len).each do |i|\n s = table[i]\n newstr << \"#{s[len -1]}\"\n end\n return newstr\nend", "def swap(string)\n string = string.split\n new_string = []\n\n\n string.map do |word|\n word = word.chars\n c1 = word[0]\n c2 = word[-1]\n\n word[0] = c2\n word[-1] = c1\n\n new_string << word.join\n\n end\n\n new_string.join(' ')\nend", "def rotate_array_fe(input)\n if input.is_a?(String)\n rotate_array(input.chars).join\n elsif input.is_a?(Integer)\n rotate_array(input.to_s.chars).join.to_i\n else \n rotate_array(input)\n end\nend" ]
[ "0.8420863", "0.83757365", "0.8354062", "0.8354062", "0.8325349", "0.82930464", "0.82857203", "0.8282977", "0.8261854", "0.8261854", "0.8261854", "0.8261854", "0.8261854", "0.8257434", "0.82502234", "0.82138014", "0.8213407", "0.8213407", "0.8213407", "0.7922199", "0.77572376", "0.75273615", "0.72676605", "0.7166924", "0.71245545", "0.7114418", "0.70978886", "0.7092906", "0.70885885", "0.7085822", "0.70697784", "0.70570457", "0.70240116", "0.70217913", "0.6994923", "0.6993736", "0.69725513", "0.69631904", "0.69453037", "0.6938303", "0.69330764", "0.6929588", "0.6927648", "0.6923301", "0.690992", "0.6906935", "0.6900901", "0.68815726", "0.6872997", "0.68443364", "0.6838225", "0.6832332", "0.6825846", "0.6820563", "0.68069315", "0.6767024", "0.67581534", "0.6753503", "0.67444354", "0.6695679", "0.6656565", "0.6654892", "0.66539526", "0.6644034", "0.6643073", "0.66347396", "0.66290873", "0.66290873", "0.66290873", "0.66290873", "0.66290873", "0.66290873", "0.66290873", "0.66255885", "0.6619357", "0.6617661", "0.66153693", "0.6607238", "0.6584102", "0.65815645", "0.65672535", "0.65648323", "0.6562101", "0.6546172", "0.6533096", "0.65315235", "0.65200585", "0.6519603", "0.6510055", "0.6508623", "0.6492892", "0.6488241", "0.6485514", "0.64850646", "0.6482287", "0.6479819", "0.6465605", "0.6464583", "0.6453209", "0.6443461" ]
0.6484085
94
=begin Here is a better solution, taken from a Codewars user. It is the highest clever rated solution on Codewars. 1) gsub returns a copy of the given string with all (global) occurrences of the pattern substituted for the second argument. 2) (\w) captures the first letter of every word, this is the first capture group. 3) (\w+) captures the rest of the letters of every word, this is the second capture group. 4) '\2\1ay' essentially says put the capture group 1 (first letter) after capture group 2 (the rest of letters) and after capture group 1 (first letter), put ay. This rearranges the string. Single quotation marks '' must be used instead of "" to make this substitution work. =end
def pig_it(str) str.gsub(/(\w)(\w+)*/, '\2\1ay') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pig_it text\n text.gsub(/(\\w)(\\w+)*/, '\\2\\1ay')\nend", "def pig_it text\n text.gsub(/(\\w)(\\w+)*/, '\\2\\1ay')\nend", "def kacokadekame(word)\n 'ka' + word.gsub(/([aeiouy])(?=[^aeiouy])/i, '\\1ka')\nend", "def swap(string)\n array = string.scan(/\\w+/)\n array.map! { |word| word.scan(/(.)/) }\n array.map! do |word|\n letter_last = word.pop\n word.rotate.unshift(letter_last).join\n end\n array.join(' ')\nend", "def pig_it(text)\n text.gsub(/\\b([a-z0-9]?)([a-z0-9]+)\\b/i, '\\2\\1ay')\n # text.gsub(/\\b([a-z0-9])([a-z0-9]+)*\\b/i, '\\2\\1ay')\n # text.gsub(/([a-z0-9])([a-z0-9]+)*/i, '\\2\\1ay')\nend", "def pig_it(string)\n words = string.split\n\n words.map do |word|\n if word.match(/[a-z]/i)\n word[1..word.size] << word[0] << 'ay'\n else\n word\n end\n end.join(' ')\nend", "def weirdcase1(string)\n string.gsub(/(\\w{1,2})/) { |s| $1.capitalize }\nend", "def alternate_words(string)\n arr = string.gsub(/[!@$#%^&*()-=_+\\[\\]:;,.\\/<>?\\|]/, ' ').split(' ')\n newarr = arr.each_index.select{|i| i.even?}\n fnlarr = []\n newarr.each do |i|\n fnlarr.push(arr[i].gsub(/^(\\W+)?(\\w+)(\\W+)?$/, '\\2'))\n end\n fnlarr.reject! {|word| word !~ /\\w+/}\n fnlarr\nend", "def swap(string)\n string_arr = string.split.map do |word|\n first_letter = word[0]\n word = word.gsub(word[0], word[-1])\n word[-1] = first_letter\n word\n end\n string_arr.join(' ')\nend", "def capitalize_letter_of_each_word(str)\n return_string = \"\"\n words = str.split()\n\n index = 0\n words.each do |word|\n word[0] = word[0].upcase\n index += 1\n if index >= 2\n return_string = return_string + \" #{word}\"\n elsif index < 2\n return_string = word\n end\n end\n\n return return_string\nend", "def titleize(text)\n little_word = [\"and\", \"the\"]\n text.gsub(/[[:alpha]]+/) { |x| little_word.include?(x) & (Regexp.last_match.begin(0)> 0)? x : x.capitalize\n }\n\nend", "def pig_it(str)\r\n str.split.map { |w| w =~ /[a-z]/i ? w[1..-1] + w[0] + 'ay' : w }.join(' ')\r\nend", "def reverberate(str)\n \n new_str = str.split(\" \").map do |wrd|\n new_wrd = wrd.length > 3 ? reverberate_word(wrd) : wrd\n wrd.capitalize == wrd ? new_wrd.capitalize : new_wrd\n end\n\n new_str.join(\" \")\nend", "def pig_it_ms_two(str)\n pig = []\n str.split.each do |w|\n pig << w.chars.rotate.join + \"ay\" if w =~ /\\w/\n pig << w if w =~ /\\W/\n end\n pig.join(\" \")\nend", "def regexize_words(words)\n words.each {|word|word.gsub!(/(\\?|\\*)/, '\\w\\1')}\n end", "def reverse_words(string)\n string.gsub(/\\w+/) { |match| match.reverse }\nend", "def pig_it(str)\n \twords_from_sentence = str.split\n \twords_from_sentence.map! do |word|\n \t\tif word.length == 1\n \t\t\tif word.match? (/[^\\w]/)\n \t\t\t\tword\n \t\t\telse\n \t\t\t\tword << 'ay'\n \t\t\tend\n \t\telsif word[-1].match? (/[^\\w]/)\n \t\t\tlast_letter = word.slice!(-1)\n \t\t\tword << word.slice!(0) << 'ay' << last_letter\n \t\telse\n \t\t\tword << word.slice!(0) << 'ay'\n \t\tend\n \tend\n \twords_from_sentence.join(' ')\nend", "def translate s\n \n words = s.split.map{|word|\n if %w(a e i o u).include?(word[0])\n word << \"ay\"\n elsif %w(thr sch squ).include?(word[0..2])\n word[3..-1] << (word[0..2] << \"ay\")\n elsif %w(ch qu br th).include?(word[0..1])\n word[2..-1] << word[0..1] << \"ay\" \n else\n word[1..-1] << (word[0] << \"ay\") \n end\n }\n words.join(\" \")\n\nend", "def aliass(full_name)\n alphabet = \"bcdfghjklmnpqrstvwxyz\"\n vowels = \"aeiou\"\n new_string = \"\"\n \n #break input word into array and iterate through each letter\n #if the letter is a vowel, take it and change it to next_vowel\n #if the letter is a consonant, take it and change it to consonant\n #else just add with no modification\n full_name.split('').each do |letter|\n if vowels.include?(letter)\n new_string += vowel(letter)\n elsif alphabet.include?(letter)\n new_string += consonant(letter)\n else\n new_string += letter\n end\n end\n #transform this new string into an array\n new_word = new_string.split(' ')\n #swap first and second word in array\n new_word.reverse!\n #turn new word into string\n new_word.map {|names| names.capitalize!}\n new_string = new_word.join(\" \")\n end", "def danish(text)\n p text.sub(/\\b(apple|cherry|blueberry)\\b/, 'danish')\nend", "def aliass(full_name)\n\talphabet = \"bcdfghjklmnpqrstvwxyz\"\n\tvowels = \"aeiou\"\n\tnew_string = \"\"\n\n full_name.split('').each do |letter|\n \t\tif vowels.include?(letter)\n \t\t\tnew_string += vowel(letter)\n \t\telsif alphabet.include?(letter)\n \t\t\tnew_string += consonant(letter)\n \t\telse\n \t\t\tnew_string += letter\n \t\tend\nend\n#Transform this new string into an array\n#Swap first and second word in array\n#Turn new word into string\n#Create empty array outside of loop\nnew_word = new_string.split(' ')\n new_word.reverse!\n\nnew_word.map {|names| names.capitalize!}\nnew_string = new_word.join(\" \")\nend", "def weirdcase str\n str.split.map(&:chars).map do |word|\n word.map.with_index { |letter, index| index.even? ? letter.capitalize : letter }.join\n end.join(' ')\nend", "def wave(str)\n words = str.split(\"\")\n result = []\n words.each_with_index do |letter, index|\n if letter != \" \"\n words[index].replace(letter.upcase)\n result << words.join(\"\")\n words[index].replace(letter.downcase)\n end\n end\n result\nend", "def alternating_case(string)\n if !(string.instance_of?(String))\n raise \"The argument should be a String\"\n end\n\n words = string.split(\" \")\n\n words.each_with_index do |word, index| \n index % 2 == 0 ? word.upcase! : word.downcase!\n end\n\n words.join(\" \")\nend", "def alternate_words(s)\nwords = s.gsub(/[!@$%^&*()-=_+:;,.<>?\\|]/ , ' ').split\n#removing all symbols and spliting the words. Setting variable to words\nfirst = words.sort\n#sorting the words\nprint first[0..2]\n#print the first 0 to 2 indexes\n\n\nend", "def reverberate(sent)\n new_arr = []\n words_arr = sent.split(\" \")\n vowels = \"aeiouAEIOU\"\n words_arr.each do |word|\n capt = false\n if word.capitalize == word\n capt = true\n end\n if word.length < 3\n new_arr << capt ? word.capitalize : word #new_arr << capt ? word.capitalize : word\n elsif vowels.include?(word[-1])\n new_arr << (capt ? (word * 2).capitalize : word * 2)\n elsif !vowels.include?(word[-1])\n rev_index = word.chars.reverse.index { |char| vowels.include?(char) }\n i = word.length - 1 - rev_index\n new_arr << (capt ? (word + word[i..-1]).capitalize : word + word[i..-1])\n end\n end\n new_arr.join(\" \")\nend", "def danish(string)\n string.sub(/\\b(apple|blueberry|cherry)\\b/, 'danish')\nend", "def danish(string)\n string.sub(/\\b(apple|blueberry|cherry)\\b/, 'danish')\nend", "def danish(string)\n string.sub(/\\b(apple|blueberry|cherry)\\b/, 'danish')\nend", "def danish(str)\n str.sub(/\\b(apple|blueberry|cherry)\\b/, 'danish')\nend", "def swap_name(str)\n str.gsub(/(.+)\\s(.+)/, '\\2, \\1')\nend", "def word_cap3(str)\n str.split.map { |word| word.sub(word[0], word[0].upcase) }.join(\" \")\nend", "def word_cap2(str)\n str.split(' ').map { |wrd| wrd[0].upcase + wrd[1..-1].downcase }.join(' ')\nend", "def aliass(full_name)\n\talphabet = \"bcdfghjklmnpqrstvwxyz\"\n\tvowels = \"aeiou\"\n\tnew_string = \"\"\n\n\t#break input word into array and iterate through each letter\n\t#if the letter is a vowel, take it and change it to next_vowel\n\t#if the letter is a consonant, take it and change it to consonant\n\t#else just add with no modification\n\tfull_name.split('').each do |letter|\n\t\tif vowels.include?(letter)\n\t\t\tnew_string += vowel(letter)\n\t\telsif alphabet.include?(letter)\n\t\t\tnew_string += consonant(letter)\n\t\telse\n\t\t\tnew_string += letter\n\t\tend\n\tend\n\t#transform this new string into an array\n\tnew_word = new_string.split(' ')\n\t#swap first and second word in array\n\tnew_word.reverse!\n\t#turn new word into string\n\tnew_word.map {|names| names.capitalize!}\n\tnew_string = new_word.join(\" \")\nend", "def pig_it(str)\n words = str.split\n pigified = []\n words.each do |word|\n if word =~ /\\w/\n word += \"#{word.chr}ay\"\n word[0] = ''\n pigified << word\n else pigified << word\n end\n end\n pigified.join(' ')\nend", "def swapcase(multi_word_string)\n word_arr = multi_word_string.split\"\" \n modified_arr = word_arr.map do |char|\n if char.match(/[a-z]/)\n char.upcase\n elsif char.match(/[A-Z]/)\n char.downcase\n else\n char\n end\n end\n modified_arr.join\"\"\nend", "def sub_word(string)\n array = string.split\n array.each do |word|\n word.gsub!(/\\bt[oo]\\b/, \"2\")\n #word.gsub!(\"too\", \"2\")\n word.gsub!(\"for\", \"4\")\n word.gsub!(\"four\", \"4\")\n word.gsub!(\"you\", \"u\")\n word.gsub!(\"at\", \"/@\")\n word.gsub!(\"and\", \"&\")\n end\nend", "def titleize\n arr = %w(a an the by to)\n upcase_arr = %w(DX EDA AEDG LPD COP)\n r = gsub('_', ' ').gsub(/\\w+/) do |match|\n match_result = match\n if upcase_arr.include?(match.upcase)\n match_result = upcase_arr[upcase_arr.index(match.upcase)]\n elsif arr.include?(match)\n match_result = match\n else\n match_result = match.capitalize\n end\n match_result\n end\n\n r\n end", "def weirdcase(string)\n string.split(' ').map do |word|\n word.split('').map.with_index do |letter, index|\n if index % 2 == 0\n letter.capitalize\n else\n letter\n end\n end.join('')\n end.join(' ')\nend", "def acronymize(string)\n array = string.split\n acronym = \"\"\n array.each { |first_letter| acronym << first_letter[0] }\n acronym.upcase\nend", "def replacements word\n n = word.length\n new_words = []\n n.times {|i| ('a'..'z').each {|l| new_words << word[0...i]+l.chr+word[i+1..-1] } }\n new_words\n end", "def reverse_words_refactor(string)\n jumbled_letters = string.split(\" \").each {|word| word.reverse!}.join(\" \")\nend", "def amendTheSentence(s)\n s.gsub(/([A-Z])/, ' \\1').strip.downcase\nend", "def reverse_words(string)\n string.gsub(/\\w+/) { |word| word.reverse! } \n end", "def pig_it(sentence)\n sentence.split.map do |word|\n if ('a'..'z').cover?(word.downcase)\n word[1..-1] + word[0] + 'ay'\n else\n word\n end\n end.join(' ')\nend", "def acronymize(sentence)\n sentence.split.map { |word| word[0].upcase }.join\n # split the sentence into an array\n # need to iterate over the words\n # take the first letter from each word and place into array\n # array into string, then .upcase(should be gud. its ok)\nend", "def staggered_case(str)\narray = str.split(\"\")\nresult = array.each_with_index do |char, index|\n if index % 2 == 0 && char.match(/[a-zA-Z]/)\n char.upcase!\n elsif index % 2 == 1 && char.match(/[a-zA-Z]/)\n char.downcase!\n end\nend\nresult.join(\"\")\nend", "def word_cap2(str) # Without Using .capitalize method\n str.split.each { |word| word[0] = word[0].upcase }.join(\" \")\nend", "def change_me(string)\n result = []\n words = string.split\n iterator = 0\n loop do\n break if iterator == words.size\n word = words[iterator]\n if word.reverse == word\n result << word.upcase\n else\n result << word\n end\n iterator += 1\n end\n result.join(' ')\nend", "def staggered_case(str)\n spongebob_case = str.split('').map.with_index do |char, index|\n if index.odd?\n char.upcase\n elsif index.even?\n char.downcase\n else\n char\n end\n end.join\n\n spongebob_case\nend", "def danish(str)\n str.sub(/\\b*apple|cherry|blueberry\\b*/, 'danish')\nend", "def swap_letters(sentence, letters)\n # your code goes here\n result = []\n\n l1, l2= letters[0], letters[1]\n sentence.split.each do |word|\n temp = \"\"\n word.chars.each do |ch|\n if ch == l1 || ch == l1.downcase\n ch = l2\n elsif ch == l2 || ch.downcase == l2\n ch = l1.downcase\n end\n temp << ch\n end\n result << temp\n end\n\n result.join(\" \")\nend", "def pig_it(string)\n arr = string.split(\" \")\n result = \"\"\n arr.each do |word|\n # Check if word is containing only letters and not special characters\n if word.match? /\\A[a-zA-Z']*\\z/\n result += (word[1..-1] + word[0] + \"ay \")\n else\n result += (word + \" \")\n end\n end\n result[0...-1]\nend", "def format_name(str)\n norm_arr = []\n str_arr = str.split(\" \")\n\n str_arr.each do |word|\n word = word.downcase\n word[0] = word[0].upcase\n norm_arr << word\n end\n\n return norm_arr.join(\" \")\nend", "def swap(str)\n array_of_words = str.split\n\n array_of_words.each do |word|\n first_char = word[0]\n last_char = word[-1]\n\n word[0] = last_char\n word[-1] = first_char\n end\n\n array_of_words.join(' ')\n\nend", "def weirdcase(string)\n string = string.split(' ').each.map do |word|\n word = word.split('').each_with_index.map do |letter, index|\n if index.even?\n letter.capitalize\n else\n letter.downcase\n end\n end\n word.join('')\n end\n return string.join(' ')\nend", "def capitalize_letter_of_each_word(str)\n str.split.map(&:capitalize).join(' ')\nend", "def staggered_case(string)\n string = string.split(' ')\n current_idx = -1\n\n new_string = string.map do |word|\n current_idx += 1\n word.chars.map do |letter|\n current_idx.even? ? letter.upcase! : letter.downcase!\n current_idx += 1\n letter\n end.join('')\n end\n new_string.join(' ')\nend", "def word_replace word, first_word\n if word =~ /^[A-Z]*$/ then\n \"_PROPER_\"#proper names\n elsif word =~ /^[A-Z|\\.]*$/ then\n if first_word then\n \"_FIRST_\"\n else\n \"_FNOCO_\" #first name or companies\n end\n elsif word =~ /^[A-Z].+$/ then\n if first_word then\n \"_FIRST_NAME_\"\n else\n \"_NAME_\"\n end\n elsif word =~ /^[0-9|\\-]*$/ then\n \"_NUM_\" #number\n else\n \"_RARE_\"\n end\nend", "def letter_reverse(sentence)\n # sentence.split(\" \").map(&:reverse).join(\" \")\n # sentence.gsub(/\\w+/) { |word| word.reverse }\n sentence.gsub(/\\w+/, &:reverse)\nend", "def LetterChanges(str)\n\n str=str.tr('a-y','b-z')\n str=str.tr('aeiou','AEIOU')\n return str \n \nend", "def word_cap3(string)\n string.split.each { |word| word[0] = word[0].capitalize }.join(\" \")\nend", "def titleize (string)\n little_words = [ \"and\", \"the\", \"over\", \"in\", \"by\" ]\n phrase = []\n string.split.each_with_index do |word, i|\n phrase << ((i==0 || !little_words.include?(word)) ? word.capitalize : word)\n end\nphrase.join(' ')\nend", "def titleize_a_string(string)\n result = string.split.each do |x|\n if (x != 'a' && x != 'and' && x != 'the')\n x.capitalize!\n end\n end\n result[0].capitalize!\n result.join(' ')\nend", "def swap(words_string)\n words_array = words_string.split\n words_array.each { |word| word[0], word[-1] = word[-1], word[0] }\n words_array.join(' ')\nend", "def titleize(str)\n little_words = %w{a an and the for or nor of but over on from by under at yet to too}\n str.split.each_with_index.map{|i, index| little_words.include?(i) && index > 0 ? i : i.capitalize}.join(' ')\nend", "def crazy_strings(first_word, second_word)\nputs \"#{first_word} #{second_word.gsub(\"s\",\"z\").swapcase}!\"\nend", "def titleize_wow(name)\n lowercase_words = %w{a an the and but or for nor of}\n name.split.each_with_index.map{|x, index| lowercase_words.include?(x) && index > 0 ? x : x.capitalize }.join(\" \")\nend", "def reverberate(str)\n reverberated = []\n vowels = \"aeiou\"\n\n str = str.split(\" \")\n str.each_with_index do |word, idx|\n if word.length < 3\n reverberated << word\n elsif vowels.include?(word[-1])\n reverberated << word + word.downcase\n else \n i = word.length - 1\n suffix = \"\"\n while i >= 0 \n if !vowels.include?(word[i])\n suffix += word[i]\n else\n suffix += word[i]\n suffix = suffix.reverse\n reverberated << (word + suffix)\n break\n end\n i -= 1\n end\n end\n end\n reverberated.join(\" \")\nend", "def swap_words(string)\n swapped = string.split(' ').map { |word| swap_characters(word) }.join(' ')\nend", "def titleize string\n words = string.split(' ')\n words[0] = words[0].capitalize\n words.map! { |word|\n ignore = %w{and over the}\n if ignore.include? word\n word \n else\n word.capitalize\n end\n }\n words.join(' ')\nend", "def swap(sentence)\n sentence = sentence.split\n # split on \" \"\n # grab first letter, move last to first, move grabbed to last\n sentence.each do |word|\n first_char = word[0]\n word[0] = word[-1]\n word[-1] = first_char\n end\n\n sentence.join(\" \")\nend", "def wordprep(word)\n return word.gsub(/\\W/,'').downcase.chars.sort.join\nend", "def weirdcase(string)\n words = string.split(' ')\n\n words.map do |word|\n word.chars.map.with_index do |letter, index|\n index.even? ? letter.upcase : letter.downcase\n # if index.even?\n # letter.upcase\n # else\n # letter.downcase\n # end\n end.join\n end.join(' ')\n\nend", "def word_substituter(tweet)\n newtweet = tweet.split \n dictionary.each do |phrase, subs|\n newtweet.map! do |word|\n if word == phrase\n word = subs\n elsif \n word == phrase.capitalize\n word = subs\n else \n word = word\n end\n end\n end \n newtweet.join(\" \")\nend", "def weirdcase(string)\n final_string = []\n string.split(' ').map do |word|\n capitalized_words = []\n word.split('').map.with_index do |letter, index|\n if index % 2 == 0\n letter = letter.capitalize\n else\n letter\n end\n capitalized_words << letter\n end\n final_string << capitalized_words.join('')\n end\n return final_string.join(' ')\nend", "def translate word\n alpha = ('a'..'z').to_a\n vowels = %w[a e i o u]\n consonants = alpha - vowels\n\n if vowels.include?(word[0])\n word + 'ay'\n elsif consonants.include?(word[0]) && consonants.include?(word[1])\n word[2..-1] + word[0..1] + 'ay'\n elsif consonants.include?(word[0])\n word[1..-1] + word[0] + 'ay'\n else\n word # return unchanged\n end\nend", "def weirdcase(string)\n string.split(\" \").map do |word|\n word.split(\"\").each_with_index.map do |char, i|\n i.even? ? char.upcase : char.downcase\n end.join(\"\")\n end.join(\" \")\nend", "def pig_it text\n answer = text.split(' ')\n answer.each_with_index do |str, index|\n if (!str.match(/[-!$%^&*()_+|~=`{}\\[\\]:\";'<>?,.\\/]/))\n firstLetter = str[0]\n str[0] = str[0].delete(str[0])\n answer[index] = str.concat(firstLetter) + \"ay\"\n end\n end \n answer.join(' ')\nend", "def solution(string)\n string.gsub(/([A-Z])/, ' \\1')\nend", "def solution(string)\n string.gsub(/([A-Z])/, ' \\1')\nend", "def staggered_case(words)\n mixed_chars = words.chars.each_with_index.map do |char, index|\n if index.even? && char =~ /[a-zA-Z]/\n char.upcase\n elsif index.odd? && char =~ /[a-zA-Z]/\n char.downcase\n else\n char\n end\n end\n mixed_chars.join\nend", "def alternate_words(wrd)\n result = []\n counter = 0\n wrd_2 = wrd.gsub(/[!@$#%^&*()-=_+\\[\\]:;,.\\/<>?\\|]/, \" \")\n words = wrd_2.split(/\\s+/)\n words.each do |word|\n result << word if counter % 2 == 0\n counter += 1\n end\n return result\nend", "def titleize!(title)\n title.split.map { |word| word.gsub(word[0],word[0].upcase) }.join(' ')\nend", "def titleize(string)\r\n words = string.split(\" \")\r\n array = []\r\n words.each_with_index do |word, index|\r\n if index == 0\r\n array << word.upcase[0] + word[1..-1]\r\n else\r\n if word.length > 3\r\n array << word.upcase[0] + word[1..-1]\r\n else\r\n array << word\r\n end\r\n end\r\n end\r\n return array.join(\" \")\r\nend", "def format_name(str)\n\twords = str.split(\" \")\n \tnewWord = \"\"\n \n \twords.each do |word|\n newWord += word[0].upcase + word[1..-1].downcase + \" \"\n end\n return newWord\nend", "def acronymize(sentence)\n letters = []\n sentence.split.each { |word| letters << word[0].upcase }\n letters.join(\"\")\nend", "def swap(string)\n # swapped_words = []\n string.split.each do |word|\n word[0], word[-1] = word[-1], word[0]\n # swapped_words << word\n end.join(' ')\n\n # swapped_words\nend", "def pig_latin_word(word)\r\n\tif word[0].downcase =~ /[aeiou]/\r\n\t\tword << \"way\" \r\n\telse\r\n\t\tn = /[aeiou]/.match word.downcase\r\n\t\tn.to_s + n.post_match + n.pre_match + \"ay\"\r\n\tend\r\nend", "def capitalize_words(string)\n new = string.split\n i = 0\n first = \"\"\n str = \"\"\n \n while i < new.length\n str = new[i]\n first = str[0]\n first = first.upcase\n str[0] = first\n i = i + 1\n end\n \n final = new.join(\" \")\n return final\n \nend", "def solution(str)\n str.gsub(/([A-Z])/, ' \\1')\nend", "def translate (sentence)\n\ttranslated = ''\n\twords = sentence.split(' ')\n\twords.each { |word|\n\t\tfound_vowels = word.scan(/^[aeiou]*/)\n\t\tfound_consonants = word.scan(/^[bcdfghjklmnpqrstvxzwy]*/)\n\t\tif !found_vowels[0].empty?\n\t\t\ttranslated << word << 'ay'\n\t\telsif !found_consonants[0].empty?\n\t\t\tword = word.tr(found_consonants[0], '')\n\t\t\ttranslated << word << found_consonants[0] << 'ay'\n\t\tend\n\t\tif words.length > 1\n\t\t\ttranslated << ' '\n\t\tend\n\t}\n\treturn translated.rstrip\nend", "def pig_it text\n arr = []\n text.split.map do |x|\n split_word = x.split('')\n unless /[[:punct:]]/.match(x)\n first_letter = split_word.first\n split_word.shift\n split_word << \"#{first_letter + 'ay'}\"\n end\n arr << split_word.join\n end\n arr.join(' ')\nend", "def weirdcase(string)\n result = []\n string.split(' ').each do |word|\n i = 0\n while i < word.length\n word[i] = if i.odd?\n word[i].upcase\n else\n word[i].downcase\n end\n i += 1\n end\n result << word\n end\n result.join\nend", "def titlify(s)\n s.split(/[ _]/).map(&:capitalize).join(' ')\nend", "def weirdcase(str)\n str.split.map do |word|\n word.chars.map.with_index { |char,i| i.even? ? char.upcase : char.downcase}.join\n end.join(' ')\nend", "def word_cap(str)\n words = str.split\n words.each do |word|\n word[0] = word[0].upcase\n word[1..-1] = word[1..-1].downcase\n end\n words.join(' ')\nend", "def swap(input)\n array = input.split(' ')\n array.map! { |word| word.chars }\n array.map! do |word|\n word[0], word[-1] = word[-1], word[0]\n word.join('')\n end\n array.join(' ')\nend", "def transform_word(str)\n ary = str.split(\"\")\n ary_nums = convert_to_ascii(ary)\n new_nums = add_i(ary_nums)\n new_ary = convert_to_letters(new_nums)\nend", "def staggered_case(string)\n array = string.split('')\n\n upper = 0\n lower = 1\n\n loop do\n array[upper] = array[upper].upcase\n upper += 2\n\n array[lower] = array[lower].downcase\n lower += 2\n break if lower >= array.size\n end\n \n if array.size.odd?\n array.last.gsub!(array.last, array.last.upcase)\n end\n array.join('')\nend" ]
[ "0.7943445", "0.7943445", "0.72666585", "0.7099973", "0.70572203", "0.6905169", "0.6904118", "0.6852544", "0.6840252", "0.6836425", "0.681228", "0.67991066", "0.6756529", "0.67484653", "0.6705733", "0.66861564", "0.6662058", "0.6649415", "0.6639252", "0.6636886", "0.6636351", "0.66330165", "0.660599", "0.6602148", "0.66016084", "0.6593546", "0.658019", "0.658019", "0.658019", "0.6568235", "0.6566919", "0.6563809", "0.65565574", "0.6544326", "0.65418214", "0.6536932", "0.65258414", "0.6521754", "0.6518705", "0.65066665", "0.64973056", "0.64941573", "0.64866954", "0.64859664", "0.6475668", "0.64704823", "0.6466309", "0.6451059", "0.6441958", "0.64351153", "0.6424955", "0.6416331", "0.64060885", "0.6397043", "0.63947123", "0.63931704", "0.63721114", "0.6371787", "0.63711756", "0.6368076", "0.6365945", "0.6357092", "0.63498396", "0.6343788", "0.63367146", "0.63354254", "0.6330294", "0.6325707", "0.6316924", "0.6313612", "0.63122565", "0.63083786", "0.6300645", "0.6300576", "0.63003075", "0.62974524", "0.6291448", "0.62901187", "0.6289224", "0.6286477", "0.6286477", "0.62804574", "0.6276063", "0.62644637", "0.62625426", "0.6258474", "0.62555575", "0.62517124", "0.62466216", "0.62441695", "0.624293", "0.6236897", "0.62342674", "0.6230383", "0.62252104", "0.6222656", "0.6208419", "0.6208147", "0.6206861", "0.62013495" ]
0.8108457
0
FIXME! how to get access to the controller?
def controller end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def controller\n @controller\n end", "def controller(controller); end", "def controller; end", "def controller; end", "def controller; end", "def controller; end", "def controller; end", "def controller; end", "def controller; end", "def controller; end", "def controller; end", "def controller; end", "def controller\n self\n end", "def controller\n return @controller\n end", "def controller; nil; end", "def controller\n self::Controller\n end", "def controller\n nil\n end", "def controller\n platform_service(:controller)\n end", "def controller\n @controller ||= MainController.new\n end", "def controller\n self\n end", "def controller_class; end", "def controller_class; end", "def controller\n @controller ||= ApplicationController.new\n end", "def controller\n ApplicationController\n end", "def controller\n nil\n end", "def controller\n nil\n end", "def controller_name; end", "def controller_name; end", "def controller\n Thread.current[:authlogic_controller]\n end", "def controller=(_arg0); end", "def controller=(_arg0); end", "def controller=(_arg0); end", "def entry\n @controller.send(:entry)\n end", "def controller client\n client.env[CONTROLLER_NAME]\n end", "def controller_path; end", "def controller_path; end", "def request\n @controller.request\n end", "def request\n @controller.request\n end", "def request\n @controller.request\n end", "def content_controller\n main_controller.content_controller\n end", "def controller\n @controller ||= controller_name.constantize\n end", "def initialize(controller)\n @controller = controller\n end", "def initialize(controller)\n @controller = controller\n end", "def controller\n @params['controller'] || @params[:controller]\n end", "def cnam\r\n CNAMController.instance\r\n end", "def content_controller\n self\n end", "def is_controller?; false; end", "def controller\n MSPhysics::Newton::Hinge.get_controller(@address)\n end", "def clients\r\n ClientsController.instance\r\n end", "def controller_resource\n Iteration\n end", "def controller\n Notifierrails.controller\n end", "def controller_name\n self.class.controller_name\n end", "def controllers\n raise NotImplementedError\n end", "def set_controller\n @controller = Controller.find(params[:id])\n end", "def index\n @controllers = Controller.all\n end", "def controller_path\n self.class.controller_path\n end", "def setup_controller_for_warden; end", "def compete_controller\n @kernel.resources.controllers.compete\n end", "def sm\r\n SMController.instance\r\n end", "def people_controller\n @kernel.resources.controllers.people\n end", "def current\n Thread.current[:CURRENT_CONTROLLER]\n end", "def get_controller\n @controller_name = params[:controller]\n end", "def controller_name\n self.request.route_obj.instance_variable_get('@controller')\n end", "def instance\n @controller.instance_variable_get(:\"@#{instance_name}\")\n end", "def config; Rails.application.config.action_controller; end", "def controller\n @controller ||= Authlogic::TestCase::MockController.new\n end", "def controller(&block)\n @config.controller.class_exec(&block) if block_given?\n @config.controller\n end", "def index\n\t\tctrl_index\n\tend", "def index\n\t\tctrl_index\n\tend", "def index\n\t\tctrl_index\n\tend", "def default_controller; end", "def load\n @load_controller = @controller\n end", "def main_controller\n window.rootViewController\n end", "def controller\n MSPhysics::Newton::BallAndSocket.get_controller(@address)\n end", "def authentication\r\n AuthenticationController.instance\r\n end", "def devices\r\n DevicesController.instance\r\n end", "def industrial\r\n IndustrialController.instance\r\n end", "def controller_name\n self.class.to_s\n end", "def params\n @controller.params\n end", "def params\n @controller.params\n end", "def controller\n MSPhysics::Newton::CurvySlider.get_controller(@address)\n end", "def controller\n MSPhysics::Newton::CurvySlider.get_controller(@address)\n end", "def controller_name\n @controller_name ||= controller.class.to_s.sub('Controller', '').underscore\nend", "def mreturn\r\n ReturnController.instance\r\n end", "def pii\r\n PIIController.instance\r\n end", "def controller_name\n \"#{self.class.app_namespace}::#{@controller_name}\"\n end", "def method_missing *args\n @controller_instance.send *args\n end", "def controller_params\n @controller.params\n end", "def use_relative_controller!; end", "def initialize(controller)\n @controller = controller\n end", "def entries\n @controller.send(:entries)\n end", "def initialize(controller)\n end", "def routes\r\n RoutesController.instance\r\n end", "def method_missing(method_name, *arguments, &block)\n if controller.respond_to?(method_name)\n controller.public_send(method_name, *arguments, &block)\n else\n super\n end\n end", "def method_missing(method, *args, &block)\n if controller.respond_to?(method)\n define_singleton_method(method) do |*args, &block|\n controller.send(method, *args, &block)\n end\n send(method, *args, &block)\n else\n super\n end\n end", "def current_request\n controller.request if has_request?\n end", "def getcontrollers\n @controllers = Eb::Permission.getcontrollers\n end", "def sensors\r\n SensorsController.instance\r\n end", "def controller=(value)\n @controller = value\n end" ]
[ "0.79640883", "0.7880399", "0.77943367", "0.77943367", "0.77943367", "0.77943367", "0.77943367", "0.77943367", "0.77943367", "0.77943367", "0.77943367", "0.77943367", "0.7691605", "0.7683049", "0.7621862", "0.75697213", "0.7569223", "0.7551087", "0.75317776", "0.7479696", "0.74131393", "0.74131393", "0.7296672", "0.7291093", "0.7263045", "0.7263045", "0.71231997", "0.71231997", "0.71226615", "0.7105991", "0.7105991", "0.7105991", "0.70842105", "0.7007852", "0.6979846", "0.6979846", "0.69451404", "0.69451404", "0.69451404", "0.6879495", "0.68759024", "0.68119293", "0.68119293", "0.68066263", "0.67702276", "0.67656416", "0.6734901", "0.66981393", "0.6696976", "0.6675226", "0.66224253", "0.66222054", "0.66198725", "0.66185856", "0.66158575", "0.66153866", "0.6615047", "0.660343", "0.6594714", "0.6582135", "0.6582009", "0.6574729", "0.6564645", "0.65581805", "0.65445423", "0.6534501", "0.6520629", "0.6514999", "0.6514999", "0.6514999", "0.6501388", "0.6479848", "0.64314353", "0.64272", "0.6393904", "0.638279", "0.6374175", "0.633545", "0.6328765", "0.6328765", "0.6322952", "0.6322952", "0.632244", "0.6308737", "0.63017863", "0.6293544", "0.6291746", "0.6290943", "0.6289662", "0.6268344", "0.62580365", "0.62424487", "0.62293935", "0.6227744", "0.62217236", "0.62134373", "0.62122095", "0.6196431", "0.61922175" ]
0.778965
13
FIXME remove ActionController::Request dependency
def generic_url_rewriter env = Request.env_for('http://localhost') UrlRewriter.new(ActionController::Request.new(env), {}) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def set_request; end", "def request; return @request end", "def call(request); end", "def request\n @controller.request\n end", "def request\n @controller.request\n end", "def request\n @controller.request\n end", "def process(request); end", "def request_params; end", "def request\n @_request\n end", "def fixup_request( request )\n\t\treturn request\n\tend", "def request_method; end", "def request\n raise 'need to be implemented'\n end", "def before_request\n end", "def request_object\n $REQUEST\n end", "def request\n @request.full\n end", "def request=(request); @request = request end", "def request\n nil\n end", "def on_pre_request( request ); end", "def on_pre_request( request )\n end", "def request_parameters; end", "def request\n @request\n end", "def apply_request(request_env); end", "def set_request\n $request = request\n end", "def perform(request, response); end", "def request=(_arg0); end", "def request=(_arg0); end", "def request=(_arg0); end", "def request\n @_context[:request]\n end", "def request\n @@request\n end", "def perform(request, options); end", "def initialize(request)\n @request = request\n end", "def request\n @@request\n end", "def request_data; end", "def request\n response.request\n end", "def request_log(request); end", "def receive(request); end", "def valid_params_request?; end", "def call(request)\r\n self\r\n end", "def parse(request)\n raise NotImplementedError\n end", "def build_request(method); end", "def request\n view_context.request\n end", "def request_path; end", "def current_request\n controller.request if has_request?\n end", "def request\n @req\n end", "def request_headers; end", "def request_headers; end", "def generate_request\r\n end", "def request_method_symbol; end", "def request(*args); end", "def request\n @source.request\n end", "def params() request.params end", "def zz_request(*_)\n # Do nothing\n end", "def fixup_request( request )\n\t\trequest.session_namespace = self.class.session_namespace\n\t\treturn super\n\tend", "def POST\r\n@env[\"action_dispatch.request.request_parameters\"] ||= (normalize_encode_params(super) || {})\r\nrescue TypeError => e\r\nraise ActionController::BadRequest.new(:request, e)\r\nend", "def http_method(request)\n raise NotImplementedError\n end", "def http_method(request)\n raise NotImplementedError\n end", "def request_uri; end", "def request(*args, &block); end", "def req\n \n end", "def request\n @rest_response.request\n end", "def request_dependencies\n end", "def request(action, params = T.unsafe(nil), header = T.unsafe(nil), query = T.unsafe(nil)); end", "def test_request\n if defined?(ActionDispatch) # Rails 3.x\n ActionDispatch::TestRequest.new\n else # Rails 2.x\n ActionController::TestRequest.new\n end\n end", "def request_phase\n super\n end", "def request_phase\n super\n end", "def request\n @request ||= ::Lotus::Action::Request.new(@_env)\n end", "def request(*args)\n end", "def post_request(object)\n end", "def method\n controller.request.request_method\n end", "def new\n #@request = Request.new\n end", "def http_method(request)\n request.request_method\n end", "def request_context\n @requester ? @requester.request : \"(unknown)\"\n end", "def after_request\n end", "def validate_request(request, request_resource_prefix)\n method = (request_resource_prefix + '_request').to_sym\n return send(method, request[0])\nend", "def initialize(request)\n @params = {}\n @params.merge! request.class.query_parse(request.params[\"QUERY_STRING\"])\n \n # Check to see if a form was submitted and fill in the form values\n if request.is_multipart?\n @params.merge! request.split_multipart\n end #if\n end", "def request\n SharedStorage.get(:request)\n end", "def params\n @request.params\n end", "def send_request; end", "def request\n @request ||= Request.find request_id\n end", "def before_dispatch(env); end", "def before_dispatch(_env)\n end", "def headers(request)\n raise NotImplementedError\n end", "def set_request_body!(request); end", "def params\n @_params ||= ActionController::ManagebleParameters.new(request.parameters)\n end", "def request_method\r\n@request_method ||= check_method(env[\"REQUEST_METHOD\"])\r\nend", "def pre_connect(request); end", "def after_request\n end", "def xml_http_request?; end", "def log_request(request)\n access = Access.new\n access.host = request.ip\n access.referrer = request.referer\n access.timestamp = DateTime.now\n\n access.method = request.request_method\n \n (request.get? ? request.GET : request.POST).each_pair do |key, value|\n pair = FormDataPair.new\n pair.name = key\n pair.value = value\n access.form_data_pairs << pair\n end\n\n access.save\n\n status 404\n 'No one here but us chickens.'\nend", "def find(request)\n nil\n end" ]
[ "0.7229971", "0.7229971", "0.7229971", "0.7229971", "0.7229971", "0.7229971", "0.7229971", "0.7229971", "0.7229971", "0.7229971", "0.7229971", "0.71342325", "0.70124894", "0.699485", "0.69773716", "0.69773716", "0.69773716", "0.6955372", "0.69097394", "0.69030946", "0.6860935", "0.6819735", "0.6819325", "0.67905486", "0.67120254", "0.67041", "0.6684975", "0.6665252", "0.6651986", "0.6634012", "0.6630986", "0.66080546", "0.6584961", "0.655206", "0.6550499", "0.6540788", "0.6540788", "0.6540788", "0.6513699", "0.6491308", "0.64575034", "0.6410148", "0.6401242", "0.63751566", "0.626402", "0.62491053", "0.6237739", "0.6233786", "0.62332594", "0.6232943", "0.62252426", "0.62105674", "0.61874956", "0.61773723", "0.616423", "0.6162112", "0.6162112", "0.61329216", "0.6119225", "0.60933954", "0.60687715", "0.6060133", "0.60599655", "0.60596985", "0.60151", "0.6014718", "0.6014718", "0.6011815", "0.60032976", "0.59895664", "0.597384", "0.5969221", "0.5968981", "0.59507096", "0.59417826", "0.59417826", "0.5906289", "0.5904771", "0.59007126", "0.5896318", "0.58901966", "0.58874816", "0.58811074", "0.588066", "0.5880571", "0.5856466", "0.5851358", "0.58436465", "0.58406043", "0.5822051", "0.5818905", "0.5806089", "0.5799652", "0.579881", "0.57960516", "0.577942", "0.5763924", "0.5737591", "0.5732151", "0.57299626", "0.5718704" ]
0.0
-1
send message about record change to all subscribers of this record
def publish_record(record) subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record.class}__#{record.id}") time_now = Time.now.to_f scrub_time = time_now - 24.hours.to_f message = { record_type: record.class.to_s, id: record.id, updated_at: record.updated_at } message[:destroyed] = true if record.destroyed? Rails.logger.debug "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" Rails.logger.debug "========================================== SUBSCRIBERS ================ #{subscribers}" Rails.logger.debug "=========================================== SUBSCRIBERS SIZE =============== #{subscribers.size}" # can only trigger to max 10 channels at once on pusher subscribers.each_slice(10) do |slice| Rails.logger.debug "========================================================== EACH SLICE !" Rails.logger.debug "=============================================SLICE============= #{slice}" Rails.logger.debug "=============================================SLICE SIZE============= #{slice.size}" channel_array = [] slice.each do |session_id, last_requested| if last_requested.to_f < scrub_time Hyperloop.redis_instance.hdel("HRPS__#{record.class}__#{record.id}", session_id) next end Rails.logger.debug "========================================================== SESSION ID : #{session_id} !" Rails.logger.debug "========================================================== RECORD CLASS : #{record.class} !" Rails.logger.debug "========================================================== RECORD ID : #{record.id} !" channel_array << "hyper-record-update-channel-#{session_id}" end Rails.logger.debug "========================================================== CHANNEL ARRAY #{channel_array} !" if channel_array.size > 0 if Hyperloop.resource_transport == :pusher _pusher_client.trigger_async(channel_array, 'update', message) Rails.logger.debug "========================================================== PUSHER #{channel_array} !" elsif Hyperloop.resource_transport == :action_cable channel_array.each do |channel| Rails.logger.debug "========================================================== BROADCAST #{channel} !" ActionCable.server.broadcast(channel, message) end end end end Hyperloop.redis_instance.del("HRPS__#{record.class}__#{record.id}") if record.destroyed? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def notify_subscribers\n AdminMailer.notify_of_standard_change(self)\n end", "def send_update\n changed\n notify_observers(self)\n end", "def notify\n @subscribers.each { |ident, (block,obj)| block.call(obj) }\n end", "def pub_sub_record(record)\n subscribe_record(record)\n publish_record(record)\n end", "def notify_subscribers\n NotificationSubscription.notify(self)\n end", "def subscribed; end", "def notify_will_change!\n collection_will_change!\n forward \"#{@key}_will_change!\"\n end", "def notfiy_subscribers(params)\n subject = params[:subscribable]\n\n subject.subscribers.each do |subscriber|\n subscriber.notify(subject, params[:message])\n end\n\n continue(params)\n end", "def notify_subscribers(resource)\n resource.subscriptions.each do |subscription|\n http = EM::HttpRequest.new(subscription.url).post(:body => {:data => resource.body})\n http.callback{ |response|\n puts \"POSTed updated data for #{resource.url}, #{resource.body.length} characters\"\n }\n http.errback {|response|\n # Do something here, maybe setting the resource\n # to be not checked anymore.\n }\n end\n end", "def send_email_changed_notification; end", "def notify_change\n SpecificNodeMailer.notify_change\n end", "def notify_subscribers\n AdminMailer.notify_of_comment(self)\n end", "def subscribed\n super\n increase_current_users\n stream_from channel\n end", "def subscribe\n \nend", "def email_changed(record, opts = {})\n @resource = record\n view_mail('cd9fbf07-4960-4cb7-903c-068b76d2ca32',\n reply_to_id: @reply_to_id,\n to: @resource.email,\n subject: 'Email changed'\n )\n end", "def subscribe\n self.subscribed = true\n end", "def rt_update\n Realtime::Publisher.instance.batch_update all_members\n end", "def broadcast_users_changed\n data = {\n action: 'players_changed'\n }\n ActionCable.server.broadcast \"game:#{@room.id}\", data\n end", "def handle_update\n navdata = connection.receive_data\n publish(event_topic_name(\"update\"), navdata)\n end", "def broadcast_change\n # don't broadcast submits from /admin when nothing changed\n BroadcastChangeJob.perform_now(self) unless previous_changes.empty?\n end", "def notify_concierge(record)\n if record.user.concierge && record.user.concierge_id != record.author_id\n create_notification(record, record.user.concierge)\n end\n end", "def subscribers\n AdminNotifier.subscribers(Subscriber.first)\n end", "def notify\n changed(true)\n notify_observers(self)\n end", "def subscriptions; end", "def subscriptions; end", "def subscriptions; end", "def subscribe!\n # TODO: Implement\n end", "def show_subscriptions\n puts \"\\nYour current subscriptions are:\"\n @user.subscriptions.reload.each do |sub|\n puts sub.name\n end\n end", "def notify\n puts 'Subject: Notifying observers...'\n @observers.each { |observer| observer.update(self) }\n end", "def subscribe\n @board.subscribers << current_user\n redirect_to board_path(@board), notice: \"Boarda abone oldunuz.\"\n end", "def changed_and_notify(*args)\n changed\n notify_observers(*args)\n end", "def subscribed # :doc:\n # Override in subclasses\n end", "def new_record_notification(record)\n @record = record\n @phase = Phase.find(record.phase_id)\n @goal = Goal.find(@phase.goal_id)\n @user = User.find(@goal.user_id)\n\n mail to: @user.email, subject: \"Don't Break The Streak!\"\n end", "def notify_observers(*args)\n return unless changed?\n\n unwrap(connection).exec \"NOTIFY #{channel}, #{args}\"\n\n changed false\n end", "def notify_users_after_change\n if !id ||\n saved_change_to_when? ||\n saved_change_to_where? ||\n saved_change_to_location_id? ||\n saved_change_to_notes? ||\n saved_change_to_specimen? ||\n saved_change_to_is_collection_location? ||\n saved_change_to_thumb_image_id?\n notify_users(:change)\n end\n end", "def subscribers\r\n @subscribers.clone\r\n end", "def notify\n @observers.each { |observer| observer.update }\nend", "def update_subscriptions_from_account \n contacts = params[:contacts]\n contacts_subscribing = params[:subscribers].is_a?(Hash) ? params[:subscribers].keys : []\n contacts_unsubscribing = params[:contacts] - contacts_subscribing\n \n # subscribe these contacts\n contacts_subscribing.each do |c_id|\n begin\n Case_Watcher.create_subscription!(Contact.find(c_id), \n :account => Sfaccount.find(params[:id]).synced_record )\n rescue ActiveRecord::RecordNotFound\n logger.info(\"Couldn't create subscription for contact w/id: #{c_id}. Contact doesn't exist.\")\n end\n end\n\n # unsubscribe these contacts\n contacts_unsubscribing.each do |c_id|\n begin\n Case_Watcher.remove_subscription!(Contact.find(c_id), \n :account => Sfaccount.find(params[:id]).synced_record )\n rescue ActiveRecord::RecordNotFound\n logger.info(\"Couldn't remove subscription for contact w/id: #{c_id}. Contact doesn't exist.\")\n end\n end\n \n redirect_to :action => 'account', :id => @account, :notice => \"Account subscriptions updated.\"\n end", "def send_kafka_event_on_update\n return unless self.class.kafka_config[:update]\n\n producers = self.class.kafka_producers\n fields = producers.flat_map(&:watched_attributes).uniq\n fields -= ['updated_at']\n # Only send an event if a field we care about was changed.\n any_changes = fields.any? do |field|\n field_change = self.previous_changes[field]\n field_change.present? && field_change[0] != field_change[1]\n end\n return unless any_changes\n\n producers.each { |p| p.send_event(self) }\n end", "def notify_user(record)\n unless record.user_id == record.author_id\n create_notification(record, record.user)\n end\n end", "def websocket_update\n json = self.to_jsonapi\n watching_users.each do |user|\n UpdatesChannel.broadcast_to(user, {loadModels: [json]})\n end\n end", "def inform_obeservers\n\t\[email protected] { |observer| observer.update(self) }\n\tend", "def subscribers\n store[name].map { |r| r.contents } \n end", "def send_email_changed_notification?; end", "def update_subscriber_list\n @mandrill = Mandrill::API.new 'nDSi_tYPhOy6QpG8Kn_lqg'\n @subscriber_list = User.where(isSubscribed: true)\n end", "def update_subscriptions_from_case\n contacts = params[:contacts]\n contacts_subscribing = params[:subscribers].is_a?(Hash) ? params[:subscribers].keys : []\n contacts_unsubscribing = params[:contacts] - contacts_subscribing\n \n logger.info \"Found #{contacts_subscribing.size} subscribing\"\n logger.info \"Found #{contacts_unsubscribing.size} unsubscribing\"\n \n # subscribe these contacts\n contacts_subscribing.each do |c_id|\n begin\n Case_Watcher.create_subscription!(Contact.find(c_id), \n :support_case => Sfcase.find(params[:id]).synced_record )\n rescue ActiveRecord::RecordNotFound\n logger.info(\"Couldn't remove subscription for contact w/id: #{c_id}. Contact doesn't exist.\")\n end\n end\n if contacts_unsubscribing.any?\n logger.info(\"[CASE WATCHER] Removing subscription for: #{contacts_unsubscribing.join(',')}\")\n end\n # unsubscribe these contacts\n contacts_unsubscribing.each do |c_id|\n begin\n Case_Watcher.remove_subscription!(Contact.find(c_id), \n :support_case => Sfcase.find(params[:id]).synced_record )\n rescue ActiveRecord::RecordNotFound\n logger.info(\"Couldn't remove subscription for contact w/id: #{c_id}. Contact doesn't exist.\")\n end\n end\n redirect_to :action => 'case', :id => @case, :notice => \"CR subscriptions updated.\"\n end", "def subscription_updated(customer_param, atts = {})\n around_mail_action(:subscription_updated, customer_param, atts) do\n return true unless EffectiveOrders.mailer[:send_subscription_updated]\n\n @customer = (customer_param.kind_of?(Effective::Customer) ? customer_param : Effective::Customer.find(customer_param))\n @subscriptions = @customer.subscriptions\n @user = @customer.user\n\n @subject = subject_for(@customer, :subscription_updated, 'Subscription Changed')\n\n mail(to: @customer.user.email, subject: @subject)\n end\n end", "def subscribe_record(record)\n return unless session.id\n Hyperloop.redis_instance.hset \"HRPS__#{record.class}__#{record.id}\", session.id.to_s, Time.now.to_f.to_s\n end", "def update_subscription\n # Only change the subscription if the models email\n # address has been changed.\n self.class.list_manager.update_subscription(self.email_was, self.email, campaignable_additional_fields) if self.email_changed?\n end", "def track_external_change(app_id, action, document)\n return unless Conf.redis\n Conf.redis.rpush(\"#{KEYS[:changes]}-#{app_id}\", MultiJson.encode([action, document]))\n end", "def changed_details\n mail_deliver(:notify_staff_details, :subject => \"Your details have changed for \" + self.school.school_name)\n end", "def notify_attribute_changes\n ignore = [\"updated_at\", \"user_id\"]\n changed.each do |property|\n delta = changes[property]\n event_name = \"user_update_item_#{property}\" \n ActivityLogger.send(event_name, :from => self.user, :for => [self], :changes => delta) unless ignore.include? property\n end \n end", "def notify_attribute_changes\n ignore = [\"updated_at\", \"user_id\"]\n changed.each do |property|\n delta = changes[property]\n event_name = \"user_update_item_#{property}\" \n ActivityLogger.send(event_name, :from => self.user, :for => [self], :changes => delta) unless ignore.include? property\n end \n end", "def after_update(profile)\n \n puts(\"observer called----------------<><><><><>?<<><><><><><><>--------------\") \n @user=User.find(profile.user_id)\n if(profile.changes.any?)\n ApplicationMailer.send_observer_mail(@user).deliver\n \n end\n end", "def track_record_update\n true\n end", "def notify(method, record, *args)\n # This technique of notifying observers is much less than ideal.\n # Unfortunately, ActiveRecord only allows the record to be passed into\n # Observer methods. As a result, it's not possible to pass in the\n # from state, to state, and other contextual information for the\n # transition.\n record.class.class_eval do\n @observer_peers.dup.each do |observer|\n observer.send(method, record, *args) if observer.respond_to?(method)\n end if defined?(@observer_peers)\n end\n end", "def changes_notification\n NotifierMailer.changes_notification(User.limit(2), {\n title: 'Email test title',\n content: 'Email test content',\n body: 'Email test body'\n })\n end", "def engine_notify_datas_updated(datas_updated)\n end", "def notify_change(method, *args)\n changed\n notify_observers(method, self, *args)\n end", "def message_posted_with_change(message)\n redmine_headers 'Project' => message.project.identifier,\n 'Topic-Id' => (message.parent_id || message.id)\n @author = message.author\n message_id message\n references message.root\n recipients = message.recipients\n cc = ((message.root.watcher_recipients + message.board.watcher_recipients).uniq - recipients)\n @message = message\n @message_url = url_for(message.event_url)\n mail :to => recipients,\n :cc => cc,\n :subject => \"[#{message.board.project.to_s} - #{message.board.name} - msg#{message.root.id}] #{message.subject}\"\n end", "def announce_consensus_change(old_name, new_name)\n log_consensus_change(old_name, new_name)\n\n # Change can trigger emails.\n owner = user\n sender = User.current\n recipients = []\n\n # Tell owner of observation if they want.\n recipients.push(owner) if owner&.email_observations_consensus\n\n # Send to people who have registered interest.\n # Also remove everyone who has explicitly said they are NOT interested.\n interests.each do |interest|\n if interest.state\n recipients.push(interest.user)\n else\n recipients.delete(interest.user)\n end\n end\n\n # Remove users who have opted out of all emails.\n recipients.reject!(&:no_emails)\n\n # Send notification to all except the person who triggered the change.\n (recipients.uniq - [sender]).each do |recipient|\n QueuedEmail::ConsensusChange.create_email(sender, recipient, self,\n old_name, new_name)\n end\n end", "def pubsub; end", "def changed(key, value, revision)\n logger.debug \"Updated: #{key}\", value\n\n return unless @update_subscribers\n\n # Subscribers to specific paths\n if subscribers = @update_subscribers[key]\n subscribers.each{|subscriber| subscriber.call(key, value, revision)}\n end\n\n # Any subscribers for all events?\n if all_subscribers = @update_subscribers['*']\n all_subscribers.each{|subscriber| subscriber.call(key, value, revision)}\n end\n end", "def subscribed\n id = params.fetch(:id)\n return unless execution = JobQueue.find_by_id(id)\n\n execution.viewers.push current_user\n\n Thread.new do\n ActiveRecord::Base.connection_pool.with_connection do\n builder = EventBuilder.new(execution.job)\n execution.output.each do |event, data|\n transmit event: event, data: builder.payload(event, data)\n end\n # TODO: disconnect all listeners so they close their sockets ?\n # then replace the reloaded/finished/waitUntilEnabled stuff with that\n end\n end\n end", "def notify_game_change\n connection.execute \"NOTIFY #{channel}, #{connection.quote self.to_s}\"\n end", "def notify\n end", "def notify_subscribers\n NewAnswerNotificationMailer.notify_subscribers\n end", "def modify_subscriptions(subs)\n iq = connection.iq_stanza({'to'=>jid.bare,'type'=>'set'},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSubOwner},\n x('subscriptions',{:node => node_id},\n subs.map do |s|\n x('subscription',:jid => s.jid, :subscription => s.subscription, :subid => s.sub_id)\n end\n )\n )\n )\n send_iq_stanza_fibered iq\n end", "def unsubscribed; end", "def update_contact_case_subscriptions\n cases = params[:cases]\n cases_subscribing = params[:case_subscriptions].is_a?(Hash) ? params[:case_subscriptions].keys : []\n cases_unsubscribing = cases - cases_subscribing\n\n cases_unsubscribing.each do |c_id|\n Case_Watcher.remove_subscription!(current_contact.synced_record, \n :support_case => Sfcase.find(c_id).synced_record )\n end\n redirect_to :controller => 'contact', :action => 'settings', \n :notice => \"Cases subscriptions updated.\"\n end", "def notify_changes(repo,revision)\n \n @logger.debug(\"ChangeNotifier Entering with repo=\"<< repo)\n @logger.debug(\"ChangeNotifier Entering with revision=\"<< revision)\n begin\n author = author_check(revision,repo)\n @logger.debug(\"Author is #{author}\")\n\n paths = changed_paths_check(revision, repo)\n @logger.debug(\"svnlook changed returned \" << paths.join(\" \"))\n \n check_changes(paths, author) do |watched_paths,paths_by_users|\n\n date_committed = `svnlook date -r #{revision} #{repo}`\n log_message=`svnlook log -r #{revision} #{repo}`\n hash={:author => author, :date => date_committed, :log=>log_message, :rev=>revision}\n # send email only to interested parties\n threads=[]\n send_mail watched_paths, hash, paths_by_users do |user_email, subject,body|\n t1 = Thread.new do\n @logger.debug(\"ChangeNotifier about to send mail for \" << body)\n Util::MailSender.instance.send_mail(user_email, subject, body)\n end\n threads << t1\n end\n threads.each do |thread|\n thread.join\n @logger.debug(\"ChangeNotifier joined \" << thread.to_s)\n end\n end\n rescue Exception => e\n # log the error at least\n @logger.error(e)\n raise\n end\n end", "def notify_users(action)\n sender = user\n recipients = []\n\n # Send to people who have registered interest.\n interests.each do |interest|\n recipients.push(interest.user) if interest.state\n end\n\n # Tell masochists who want to know about all observation changes.\n User.where(email_observations_all: true).find_each do |user|\n recipients.push(user)\n end\n\n # Send notification to all except the person who triggered the change.\n recipients.uniq.each do |recipient|\n next if !recipient || recipient == sender || recipient.no_emails\n\n case action\n when :destroy\n QueuedEmail::ObservationChange.destroy_observation(sender, recipient,\n self)\n when :change\n QueuedEmail::ObservationChange.change_observation(sender, recipient,\n self)\n else\n QueuedEmail::ObservationChange.change_images(sender, recipient, self,\n action)\n end\n end\n end", "def upemail(params)\n old_email = params[\"old_email\"]\n new_email = params[\"new_email\"]\n\n subscriber = nil\n enabled_models.each { |model| subscriber ||= model.constantize.find_by_email(old_email) }\n\n unless over_the_limit(subscriber.updated_at)\n subscriber.email = new_email\n subscriber.save_without_update_list_member(:validate => false)\n end\n end", "def object_updated(object)\n notify\n end", "def broadcast message\n @clients.keys.each do |key|\n notify key, message\n end\n end", "def notify( event, *args )\n @subscribers.values.each { |b| b.call(event, *args) }\n end", "def subscribe(params)\n web_id = params[\"web_id\"]\n email = params[\"merges\"][\"EMAIL\"]\n\n subscriber = nil\n enabled_models.each { |model| subscriber ||= model.constantize.find_by_email(email) }\n\n subscriber.subscribed_to_list = true\n subscriber.mail_chimp_id = web_id.to_i\n subscriber.save_without_update_list_member(:validate => false)\n end", "def news_comment_added_with_change(comment)\n news = comment.commented\n redmine_headers 'Project' => news.project.identifier\n @author = comment.author\n message_id comment\n references news\n @news = news\n @comment = comment\n @news_url = url_for(:controller => 'news', :action => 'show', :id => news)\n mail :to => news.recipients,\n :cc => news.watcher_recipients,\n :subject => \"Re: [#{news.project.to_s}] #{l(:label_news)}: #{news.title}\"\n end", "def after_commit(model)\n # get the customer\n customer = model.customer\n\n # do a UI update push for this customer\n PUBNUB.publish({\n # NJS - use more secure channel name\n :channel => \"customer_ui_update_available_#{customer.id}\",\n # the actual message is ignored\n :message => \"UI update available\",\n :callback => lambda { |message| puts(message) }\n })\n end", "def changed_and_notify_observers(data)\n unless @generating_resume_template\n changed\n notify_observers([data, session, current_user])\n end\n end", "def subscribers\n @subscribers ||= ActsAsIcontact::Subscription.contacts(:listId => id)\n end", "def new_record_notification(message_info, contacts, sender)\n @message_info = message_info\n @sender = sender.email\n contacts.each do |contact|\n @reciever = contact.email\n mail(to: @reciever, subject: @message_info.subject) unless @reciever == @sender\n end\n end", "def updated(message)\n end", "def get_subscribers\n @subscriptions = subscribers(@nodename)\n end", "def subscribe\n @entry.subscribers << current_user\n\n rescue ActiveRecord::StatementInvalid\n # ignore ... and just render nothing (this happens when user clicks too fast before getting previous update)\n render :nothing => true\n end", "def subscribed\n \t#stream_from 'demo_chan'\n end", "def subscriber_names\n @client.smembers @name\n end", "def notify\n {\n }\n end", "def notify\n {\n }\n end", "def index\n @subscribers = [] # Subscriber.all\n end", "def record_change_notification=(value)\n @children['record-change-notification'][:value] = value\n end", "def notify_observers\n\t\[email protected] do |observer|\n\t\t\tobserver.update(self)\n\t\tend\n\tend", "def update_message(data); end", "def update_message(data); end", "def subscribe_to_updates\n if @subscription = @requestor.find_or_create_subscriptions(@target.id)\n @subscription.update_attributes(blocked: false) if @subscription.blocked?\n render json: { success: true }\n else\n render json: {message: @subscription.errors&.full_messages || 'Unable to subscriber updates, please try again'}, status: 202\n end\n end", "def updating( msg )\n @log.info \"updating #{msg}\"\n end", "def broadcast_update\n broadcast broadcast_event_name(:updated), self, previous_changes\n end", "def notify(*args)\n subscribers.values.each { |subscriber| subscriber.call(*args) }\n end", "def publish_change event\n send :invalidate_rolegroups_cache! if event == :role_groups\n event_manager.publish_change event, :from => self\n end", "def chore_collect chore_info\n @@data_collector.notify chore_info\n end" ]
[ "0.70791966", "0.666697", "0.6509179", "0.62848705", "0.62453055", "0.6182195", "0.61139494", "0.60994095", "0.60753155", "0.6047617", "0.603326", "0.59629095", "0.59436476", "0.5918301", "0.5908037", "0.5871527", "0.58531755", "0.58511245", "0.5805142", "0.5795377", "0.57846427", "0.5776818", "0.57755464", "0.5767127", "0.5767127", "0.5767127", "0.5733037", "0.57298166", "0.5701257", "0.5677638", "0.56737506", "0.5625952", "0.5607458", "0.56045043", "0.5587149", "0.5585585", "0.5583693", "0.5568912", "0.55584514", "0.5546441", "0.55422515", "0.55406713", "0.5539329", "0.55303663", "0.55203176", "0.551086", "0.5508517", "0.5504527", "0.5491658", "0.5484535", "0.54769343", "0.5466261", "0.5466261", "0.5462449", "0.5456009", "0.5451521", "0.5450566", "0.54470885", "0.54394734", "0.54380804", "0.5435762", "0.5424945", "0.54234356", "0.5422937", "0.5419968", "0.5412882", "0.5404556", "0.5401757", "0.53861004", "0.53789824", "0.5368979", "0.53652835", "0.5349609", "0.53469574", "0.53398097", "0.5327556", "0.53230476", "0.53223014", "0.5320038", "0.53143924", "0.5312514", "0.5307958", "0.53077704", "0.53072894", "0.5295315", "0.5289646", "0.52847975", "0.5284581", "0.5284581", "0.5271226", "0.5271198", "0.5270176", "0.5269434", "0.5269434", "0.5254884", "0.5251697", "0.52506703", "0.52449346", "0.5241521", "0.5230786" ]
0.62218195
5
send message about relation change to all subscribers of this record
def publish_relation(base_record, relation_name, record = nil) subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}") time_now = Time.now.to_f scrub_time = time_now - 24.hours.to_f message = { record_type: base_record.class.to_s, id: base_record.id, updated_at: base_record.updated_at, relation: relation_name } if record message[:cause] = {} message[:cause][:record_type] = record.class.to_s message[:cause][:id] = record.id message[:cause][:updated_at] = record.updated_at message[:cause][:destroyed] = true if record.destroyed? end subscribers.each_slice(10) do |slice| channel_array = [] slice.each do |session_id, last_requested| if last_requested.to_f < scrub_time Hyperloop.redis_instance.hdel("HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}", session_id) next end channel_array << "hyper-record-update-channel-#{session_id}" end if Hyperloop.resource_transport == :pusher _pusher_client.trigger_async(channel_array, 'update', message) elsif Hyperloop.resource_transport == :action_cable channel_array.each do |channel| ActionCable.server.broadcast(channel, message) end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def notify_subscribers\n AdminMailer.notify_of_standard_change(self)\n end", "def subscribers\n AdminNotifier.subscribers(Subscriber.first)\n end", "def notify_subscribers\n NotificationSubscription.notify(self)\n end", "def pub_sub_relation(relation, base_record, relation_name, causing_record = nil)\n subscribe_relation(relation, base_record, relation_name)\n publish_relation(base_record, relation_name, causing_record)\n end", "def notify_will_change!\n collection_will_change!\n forward \"#{@key}_will_change!\"\n end", "def show_subscriptions\n puts \"\\nYour current subscriptions are:\"\n @user.subscriptions.reload.each do |sub|\n puts sub.name\n end\n end", "def notify\n @subscribers.each { |ident, (block,obj)| block.call(obj) }\n end", "def send_update\n changed\n notify_observers(self)\n end", "def subscribers\r\n @subscribers.clone\r\n end", "def subscribed; end", "def notify_subscribers\n AdminMailer.notify_of_comment(self)\n end", "def notify_subscribers(resource)\n resource.subscriptions.each do |subscription|\n http = EM::HttpRequest.new(subscription.url).post(:body => {:data => resource.body})\n http.callback{ |response|\n puts \"POSTed updated data for #{resource.url}, #{resource.body.length} characters\"\n }\n http.errback {|response|\n # Do something here, maybe setting the resource\n # to be not checked anymore.\n }\n end\n end", "def subscriptions; end", "def subscriptions; end", "def subscriptions; end", "def notify_concierge(record)\n if record.user.concierge && record.user.concierge_id != record.author_id\n create_notification(record, record.user.concierge)\n end\n end", "def subscribed\n super\n increase_current_users\n stream_from channel\n end", "def subscribe\n self.subscribed = true\n end", "def subscribed # :doc:\n # Override in subclasses\n end", "def notfiy_subscribers(params)\n subject = params[:subscribable]\n\n subject.subscribers.each do |subscriber|\n subscriber.notify(subject, params[:message])\n end\n\n continue(params)\n end", "def update_subscription\n # Only change the subscription if the models email\n # address has been changed.\n self.class.list_manager.update_subscription(self.email_was, self.email, campaignable_additional_fields) if self.email_changed?\n end", "def rt_update\n Realtime::Publisher.instance.batch_update all_members\n end", "def subscribe\n @board.subscribers << current_user\n redirect_to board_path(@board), notice: \"Boarda abone oldunuz.\"\n end", "def modify_subscriptions(subs)\n iq = connection.iq_stanza({'to'=>jid.bare,'type'=>'set'},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSubOwner},\n x('subscriptions',{:node => node_id},\n subs.map do |s|\n x('subscription',:jid => s.jid, :subscription => s.subscription, :subid => s.sub_id)\n end\n )\n )\n )\n send_iq_stanza_fibered iq\n end", "def after_save\n unless destroyed_by_association\n touch_subscriptions if saved_change_to_unread_entries?\n end\n end", "def subscribers\n @subscribers ||= ActsAsIcontact::Subscription.contacts(:listId => id)\n end", "def broadcast_users_changed\n data = {\n action: 'players_changed'\n }\n ActionCable.server.broadcast \"game:#{@room.id}\", data\n end", "def notify_collections *updates\n @collections.each {|coll| instance_variable_get(\"@#{coll}\").notify_members *updates }\n end", "def subscribers\n store[name].map { |r| r.contents } \n end", "def notify\n changed(true)\n notify_observers(self)\n end", "def relation_members\n old_members\n end", "def subscribe_relation(relation, base_record = nil, relation_name = nil)\n return unless session.id\n time_now = Time.now.to_f.to_s\n session_id = session.id.to_s\n Hyperloop.redis_instance.pipelined do\n if relation.is_a?(Enumerable)\n # has_many\n relation.each do |record|\n Hyperloop.redis_instance.hset(\"HRPS__#{record.class}__#{record.id}\", session_id, time_now)\n end\n elsif !relation.nil?\n # has_one, belongs_to\n Hyperloop.redis_instance.hset(\"HRPS__#{relation.class}__#{relation.id}\", session_id, time_now)\n end\n Hyperloop.redis_instance.hset(\"HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}\", session_id, time_now) if base_record && relation_name\n end\n end", "def subscribers(log)\n Person.notifiable.joins(:subscriptions).where(subscriptions: {\n subscribable_type: log.activity_loggable_type,\n subscribable_id: log.activity_loggable_id })\n end", "def get_subscribers\n @subscriptions = subscribers(@nodename)\n end", "def related_to(*args)\n@relations = args.map(&:to_s)\nend", "def unsubscribed; end", "def update_subscriptions_from_account \n contacts = params[:contacts]\n contacts_subscribing = params[:subscribers].is_a?(Hash) ? params[:subscribers].keys : []\n contacts_unsubscribing = params[:contacts] - contacts_subscribing\n \n # subscribe these contacts\n contacts_subscribing.each do |c_id|\n begin\n Case_Watcher.create_subscription!(Contact.find(c_id), \n :account => Sfaccount.find(params[:id]).synced_record )\n rescue ActiveRecord::RecordNotFound\n logger.info(\"Couldn't create subscription for contact w/id: #{c_id}. Contact doesn't exist.\")\n end\n end\n\n # unsubscribe these contacts\n contacts_unsubscribing.each do |c_id|\n begin\n Case_Watcher.remove_subscription!(Contact.find(c_id), \n :account => Sfaccount.find(params[:id]).synced_record )\n rescue ActiveRecord::RecordNotFound\n logger.info(\"Couldn't remove subscription for contact w/id: #{c_id}. Contact doesn't exist.\")\n end\n end\n \n redirect_to :action => 'account', :id => @account, :notice => \"Account subscriptions updated.\"\n end", "def update_subscriber_list\n @mandrill = Mandrill::API.new 'nDSi_tYPhOy6QpG8Kn_lqg'\n @subscriber_list = User.where(isSubscribed: true)\n end", "def notify\n puts 'Subject: Notifying observers...'\n @observers.each { |observer| observer.update(self) }\n end", "def websocket_update\n json = self.to_jsonapi\n watching_users.each do |user|\n UpdatesChannel.broadcast_to(user, {loadModels: [json]})\n end\n end", "def notify_change\n SpecificNodeMailer.notify_change\n end", "def subscribe\n \nend", "def unsubscribe!\n self.unsubscribed = true\n save\n end", "def subscribe_teachers\n self.indicated_teachers.each do |teacher|\n self.subscriptions.create user_id: teacher.id\n end\n end", "def collection_updated(object, result)\n key = object.key\n if result\n parent_add(key, object)\n object.subscribe(self)\n else\n object.unsubscribe(self)\n parent_delete(object)\n end\n end", "def subscriber_names\n @client.smembers @name\n end", "def inform_obeservers\n\t\[email protected] { |observer| observer.update(self) }\n\tend", "def notify_subscribers\n NewAnswerNotificationMailer.notify_subscribers\n end", "def association_changed(record)\n\t\ttouch if persisted?\n\tend", "def index\n @subscribers = [] # Subscriber.all\n end", "def notify activity\n\n # people who are subscribed directly to the question\n q_subscribers = self.subscribers.all\n\n # people who are subscribed to the tags of the question\n t_subscribers = self.tag_subscribers.all\n\n (q_subscribers + t_subscribers).each do |subscriber|\n Notification.create :user => subscriber, :activity => activity\n end\n end", "def update_recipients\n if @receivers\n @receivers.each do |kind, receivers|\n kind_recipients = recipients.select {|recipient| recipient.kind == kind}\n new_receivers = receivers - kind_recipients.map(&:receiver)\n removed_recipients = kind_recipients.reject {|recipient| receivers.include?(recipient.receiver)}\n \n recipients.delete(*removed_recipients) if removed_recipients.any?\n new_receivers.each {|receiver| self.recipients.create!(:receiver => receiver, :kind => kind)}\n end\n \n @receivers = nil\n end\n end", "def notify\n @observers.each { |observer| observer.update }\nend", "def mark_old_broadcasts\n BroadcastMessage.all.each do |broadcast|\n broadcast.users_viewed << self.id\n broadcast.save\n end\n end", "def notify_attribute_changes\n ignore = [\"updated_at\", \"user_id\"]\n changed.each do |property|\n delta = changes[property]\n event_name = \"user_update_item_#{property}\" \n ActivityLogger.send(event_name, :from => self.user, :for => [self], :changes => delta) unless ignore.include? property\n end \n end", "def notify_attribute_changes\n ignore = [\"updated_at\", \"user_id\"]\n changed.each do |property|\n delta = changes[property]\n event_name = \"user_update_item_#{property}\" \n ActivityLogger.send(event_name, :from => self.user, :for => [self], :changes => delta) unless ignore.include? property\n end \n end", "def update_subscriptions_from_case\n contacts = params[:contacts]\n contacts_subscribing = params[:subscribers].is_a?(Hash) ? params[:subscribers].keys : []\n contacts_unsubscribing = params[:contacts] - contacts_subscribing\n \n logger.info \"Found #{contacts_subscribing.size} subscribing\"\n logger.info \"Found #{contacts_unsubscribing.size} unsubscribing\"\n \n # subscribe these contacts\n contacts_subscribing.each do |c_id|\n begin\n Case_Watcher.create_subscription!(Contact.find(c_id), \n :support_case => Sfcase.find(params[:id]).synced_record )\n rescue ActiveRecord::RecordNotFound\n logger.info(\"Couldn't remove subscription for contact w/id: #{c_id}. Contact doesn't exist.\")\n end\n end\n if contacts_unsubscribing.any?\n logger.info(\"[CASE WATCHER] Removing subscription for: #{contacts_unsubscribing.join(',')}\")\n end\n # unsubscribe these contacts\n contacts_unsubscribing.each do |c_id|\n begin\n Case_Watcher.remove_subscription!(Contact.find(c_id), \n :support_case => Sfcase.find(params[:id]).synced_record )\n rescue ActiveRecord::RecordNotFound\n logger.info(\"Couldn't remove subscription for contact w/id: #{c_id}. Contact doesn't exist.\")\n end\n end\n redirect_to :action => 'case', :id => @case, :notice => \"CR subscriptions updated.\"\n end", "def subscribe\n @entry.subscribers << current_user\n\n rescue ActiveRecord::StatementInvalid\n # ignore ... and just render nothing (this happens when user clicks too fast before getting previous update)\n render :nothing => true\n end", "def subscribe_author\n self.subscriptions.create user_id: self.user.id\n end", "def notify(*args)\n subscribers.values.each { |subscriber| subscriber.call(*args) }\n end", "def relation_added(issue)\n journalize_action(\n :property => 'relation',\n :prop_key => 'relates',\n :value => issue.try(:id)\n )\n end", "def index\n @subscribers = Subscriber.all\n end", "def destroy\n @subscriber.update(active: :false)\n respond_to do |format|\n format.html { redirect_to session[:request_page], notice: 'Subscriber is now inactive.' }\n format.json { head :no_content }\n end\n @subscriber.subscribers_books.each do |subscription|\n subscription.quantity = 0\n subscription.save\n end\n relations = Relationship.where(\"name_index = ?\", @subscriber.index)\n relations.each do |relation|\n relation.quantity = 0\n relation.save\n end\n end", "def change_subscription\n @user = User.find(params[:id])\n @user.notify = [email protected]\n @user.save\n respond_with(@user) do\n redirect_to \"/users/successful_unsubscribe\"\n end\n end", "def changed_and_notify(*args)\n changed\n notify_observers(*args)\n end", "def recipients(subscriber)\n subscribers\n end", "def update\n friend = current_user.friends.find params[:id]\n return render json: { error: \"This doesn't seem to be your friend\" } if friend.nil?\n subscribed = !friend.subscribed\n change = subscribed ? 1 : -1\n friend.update subscribed: subscribed\n notify friend, change, 'subscribe'\n render json: {success: subscribed == friend.subscribed}\n end", "def affect_relation_values!\n Relations.new(@klass).affect_relation_values!\n end", "def websocket_update\n UpdatesChannel.broadcast_to(user, {loadModels: [self.to_jsonapi]})\n end", "def subscribe(params)\n web_id = params[\"web_id\"]\n email = params[\"merges\"][\"EMAIL\"]\n\n subscriber = nil\n enabled_models.each { |model| subscriber ||= model.constantize.find_by_email(email) }\n\n subscriber.subscribed_to_list = true\n subscriber.mail_chimp_id = web_id.to_i\n subscriber.save_without_update_list_member(:validate => false)\n end", "def chore_collect chore_info\n @@data_collector.notify chore_info\n end", "def in_relation_refused\n @headhunter = Headhunter.first.id\n @talent = Talent.first.id\n @status = \"refusé\"\n HeadhunterMailer.in_relation(@headhunter, @talent, @status)\n end", "def notify_users_after_change\n if !id ||\n saved_change_to_when? ||\n saved_change_to_where? ||\n saved_change_to_location_id? ||\n saved_change_to_notes? ||\n saved_change_to_specimen? ||\n saved_change_to_is_collection_location? ||\n saved_change_to_thumb_image_id?\n notify_users(:change)\n end\n end", "def update_recipients\n\t\t#puts \"starting now ------------------>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\"\n\t\tunless recipients_include_patient?\t\n\t\t\t#puts \"recipients dont include the patient, so added it, size now is: #{self.recipients.size}\"\n\t\t\tself.recipients << Notification::Recipient.new(patient_id: self.patient.id.to_s) \n\t\tend\n\t\t\t\n\t\t## this should be integrated into the gather_recipients call.\n\n\t\tk = organization_defined_recipients\t\n\t\t\n\t\t#puts \"organization defined recipients are:\"\n\t\t\n\t\t#puts k\n\n\t\tk.each do |r|\n\t\t\tself.recipients << r\n\t\tend\n\n\t\t#puts \"size at close is: \"\n\t\t#puts self.recipients.size\n\t\t#puts \"-----------------------------------------------------------------------((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((\"\n\n\tend", "def subscriptions\n iq = connection.iq_stanza({'to'=>jid.bare},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSubOwner},\n x('subscriptions',:node => node_id)\n )\n )\n send_iq_stanza_fibered iq\n end", "def subscribers(domain, node)\n @cluster.query(:smembers, \"pubsub:#{domain}:subscribers_#{node}\")\n end", "def publish_to(*user_ids)\n @users_to_notify += user_ids\n end", "def subscriptions\n\t\t@subscriptions = current_user.customer.subjects\n\tend", "def toggle_subscription!\n self.unsubscribed = !unsubscribed\n save\n end", "def publish_record(record)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record.class}__#{record.id}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n\n message = {\n record_type: record.class.to_s,\n id: record.id,\n updated_at: record.updated_at\n }\n message[:destroyed] = true if record.destroyed?\n\n Rails.logger.debug \"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\"\n\n Rails.logger.debug \"========================================== SUBSCRIBERS ================ #{subscribers}\"\n Rails.logger.debug \"=========================================== SUBSCRIBERS SIZE =============== #{subscribers.size}\"\n\n\n # can only trigger to max 10 channels at once on pusher\n subscribers.each_slice(10) do |slice|\n Rails.logger.debug \"========================================================== EACH SLICE !\"\n Rails.logger.debug \"=============================================SLICE============= #{slice}\"\n Rails.logger.debug \"=============================================SLICE SIZE============= #{slice.size}\"\n channel_array = []\n slice.each do |session_id, last_requested|\n\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{record.class}__#{record.id}\", session_id)\n next\n end\n Rails.logger.debug \"========================================================== SESSION ID : #{session_id} !\"\n Rails.logger.debug \"========================================================== RECORD CLASS : #{record.class} !\"\n Rails.logger.debug \"========================================================== RECORD ID : #{record.id} !\"\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n Rails.logger.debug \"========================================================== CHANNEL ARRAY #{channel_array} !\"\n\n if channel_array.size > 0\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n Rails.logger.debug \"========================================================== PUSHER #{channel_array} !\"\n\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n Rails.logger.debug \"========================================================== BROADCAST #{channel} !\"\n\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n\n end\n Hyperloop.redis_instance.del(\"HRPS__#{record.class}__#{record.id}\") if record.destroyed?\n end", "def notify_subscribers_about_new_response(reply)\n subscribers.each do |user|\n user.with_user_locale do\n UserMailer.reply_notification(user.id, reply.id).deliver!\n end unless user == reply.user\n end\n end", "def create / update_subscriptions\n end", "def show\n @messages = @message_room.messages.order(:created_at)\n @subscribers = @message_room.users\n end", "def index\n @subscribers = Subscriber.all\n end", "def send_mail_to_associates\n user = self.matter_people.assignee\n if(@is_changed && user && User.current_user!=user)\n send_notification_to_responsible(user,self,User.current_user)\n @is_changed = false\n\n true\n end\n end", "def subscribe!\n # TODO: Implement\n end", "def notify_observers(*args)\n return unless changed?\n\n unwrap(connection).exec \"NOTIFY #{channel}, #{args}\"\n\n changed false\n end", "def notify_users(action)\n sender = user\n recipients = []\n\n # Send to people who have registered interest.\n interests.each do |interest|\n recipients.push(interest.user) if interest.state\n end\n\n # Tell masochists who want to know about all observation changes.\n User.where(email_observations_all: true).find_each do |user|\n recipients.push(user)\n end\n\n # Send notification to all except the person who triggered the change.\n recipients.uniq.each do |recipient|\n next if !recipient || recipient == sender || recipient.no_emails\n\n case action\n when :destroy\n QueuedEmail::ObservationChange.destroy_observation(sender, recipient,\n self)\n when :change\n QueuedEmail::ObservationChange.change_observation(sender, recipient,\n self)\n else\n QueuedEmail::ObservationChange.change_images(sender, recipient, self,\n action)\n end\n end\n end", "def update_invoice_status\n invoices = self.invoices\n invoices.each do |invoice|\n invoice.received = true\n invoice.save\n end\n end", "def subscribe\n\t if !self_owned? && !subscribed?\n\t\towners.each do |peer|\n\t\t peer.subscribe(self) unless peer.subcribed?(self)\n\t\tend\n\t end\n\tend", "def notify activity\n\n # people who are subscribed to the tags of the question\n t_subscribers = target.subscribers.all\n\n (t_subscribers).each do |subscriber|\n Notification.create :user => subscriber, :activity => activity\n end\n end", "def update_contact_case_subscriptions\n cases = params[:cases]\n cases_subscribing = params[:case_subscriptions].is_a?(Hash) ? params[:case_subscriptions].keys : []\n cases_unsubscribing = cases - cases_subscribing\n\n cases_unsubscribing.each do |c_id|\n Case_Watcher.remove_subscription!(current_contact.synced_record, \n :support_case => Sfcase.find(c_id).synced_record )\n end\n redirect_to :controller => 'contact', :action => 'settings', \n :notice => \"Cases subscriptions updated.\"\n end", "def notify_parties\n buyer.add_transaction self\n seller.add_transaction self if seller\n end", "def update_from_relation(field_name, related = Ladder::Config.settings[:with_relations])\n objects = send(field_name).to_a\n\n if related || embedded_relations[field_name]\n # Force autosave of related documents to ensure correct serialization\n methods.select { |i| i[/autosave_documents/] }.each { |m| send m }\n\n # update inverse relation properties\n relation = relations[field_name]\n objects.each { |object| object.resource.set_value(relation.inverse, rdf_subject) } if relation.inverse\n objects.map(&:update_resource)\n else\n # remove inverse relation properties\n objects.each { |object| resource.delete [object.rdf_subject] }\n objects.map(&:rdf_subject)\n end\n end", "def update_contact_account_subscriptions\n accounts = params[:accounts]\n accounts_subscribing = params[:account_subscriptions].is_a?(Hash) ? params[:account_subscriptions].keys : []\n accounts_unsubscribing = accounts - accounts_subscribing\n accounts_unsubscribing.each do |a_id|\n Case_Watcher.remove_subscription!(current_contact.synced_record, \n :account => Sfaccount.find(a_id).synced_record )\n end\n redirect_to :controller => 'contact', :action => 'settings', \n :notice => \"Account subscriptions updated.\"\n end", "def notification\n user = User.first\n comic = Comic.first\n SubscriptionMailer.notification(work: comic, user: user)\n end", "def subscribe_all\n # Get an array of all the email addresses accociated with this devise class.\n emails = all.map(&:email).select {|e| Devise::Models::Campaignable.valid_campaign_email? e}\n\n # Ask the list managed to subscibe all of these emails.\n list_manager.batch_subscribe(emails)\n end", "def people(convo)\n @recipients = convo.conversation.users.where('user_id <> ?', current_user)\n end", "def subscribe_to_updates\n if @subscription = @requestor.find_or_create_subscriptions(@target.id)\n @subscription.update_attributes(blocked: false) if @subscription.blocked?\n render json: { success: true }\n else\n render json: {message: @subscription.errors&.full_messages || 'Unable to subscriber updates, please try again'}, status: 202\n end\n end", "def notify(new_user)\n self.users.each do |user|\n if user.id != new_user.id\n SocketController.user_joined(user, new_user)\n end\n end\n end" ]
[ "0.66124755", "0.61680496", "0.61637944", "0.61364126", "0.61346143", "0.60502297", "0.6005926", "0.5998482", "0.5987814", "0.5902612", "0.58898187", "0.5778486", "0.57216686", "0.57216686", "0.57216686", "0.5693455", "0.56650513", "0.56645656", "0.566012", "0.5646806", "0.56462353", "0.5633638", "0.5547374", "0.5544603", "0.5519074", "0.55101204", "0.5477541", "0.5448598", "0.5436834", "0.5431521", "0.54288226", "0.54143184", "0.5401589", "0.53959525", "0.538694", "0.538394", "0.53678185", "0.5367261", "0.5361072", "0.5361046", "0.53578734", "0.53434825", "0.5333166", "0.5327891", "0.5320582", "0.53189105", "0.5307593", "0.526784", "0.52618754", "0.52466685", "0.52347255", "0.52325124", "0.52172774", "0.5216337", "0.52127415", "0.52127415", "0.52121824", "0.5199851", "0.5193786", "0.51904047", "0.518923", "0.51813745", "0.51694214", "0.5158836", "0.51432353", "0.5142435", "0.5141832", "0.51296604", "0.51287395", "0.5127362", "0.51270115", "0.5118204", "0.51151484", "0.5112936", "0.5111906", "0.5111767", "0.5106841", "0.51049185", "0.51030177", "0.50969964", "0.5096184", "0.5095277", "0.50900745", "0.50881845", "0.5086633", "0.50836897", "0.5083017", "0.508121", "0.5080196", "0.5074575", "0.50744367", "0.50713915", "0.50615454", "0.50613105", "0.5056395", "0.5052349", "0.5050962", "0.5043587", "0.504298", "0.50373894" ]
0.57590413
12
send message to notify clients that they should call the rest_class_method again
def publish_rest_class_method(record_class, rest_class_method_name) subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}") time_now = Time.now.to_f scrub_time = time_now - 24.hours.to_f message = { record_type: record_class.to_s, rest_class_method: rest_class_method_name } subscribers.each_slice(10) do |slice| channel_array = [] slice.each do |session_id, last_requested| if last_requested.to_f < scrub_time Hyperloop.redis_instance.hdel("HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}", session_id) next end channel_array << "hyper-record-update-channel-#{session_id}" end if Hyperloop.resource_transport == :pusher _pusher_client.trigger_async(channel_array, 'update', message) elsif Hyperloop.resource_transport == :action_cable channel_array.each do |channel| ActionCable.server.broadcast(channel, message) end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pub_sub_rest_class_method(record_class, rest_class_method_name)\n subscribe_rest_class_method(record_class, rest_class_method_name)\n publish_rest_class_method(record_class, rest_class_method_name)\n end", "def subscribe_rest_class_method(record_class, rest_class_method_name)\n return unless session.id\n time_now = Time.now.to_f.to_s\n session_id = session.id.to_s\n Hyperloop.redis_instance.pipelined do\n Hyperloop.redis_instance.hset(\"HRPS__#{record_class}__rest_class_method_name__#{rest_class_method_name}\", session_id, time_now)\n end\n end", "def publish_rest_method(record, rest_method_name)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: record.class.to_s,\n id: record.id,\n rest_method: rest_method_name\n }\n subscribers.each_slice(10) do |slice|\n channel_array = []\n slice.each do |session_id, last_requested|\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\", session_id)\n next\n end\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n end", "def __send__(*rest) end", "def refresh\n raise Occi::Api::Client::Errors::NotImplementedError, \"#{__method__} is just a stub!\"\n end", "def pub_sub_rest_method(record, rest_method_name)\n subscribe_rest_method(record, rest_method_name)\n publish_rest_method(record, rest_method_name)\n end", "def call\n context.response ||= notify\n end", "def rest_class_method(name, options = { default_result: '...' })\n rest_class_methods[name] = options\n # @!method promise_[name]\n # @return [Promise] on success the .then block will receive the result of the RPC call as arg\n # on failure the .fail block will receive the HTTP response object as arg\n define_singleton_method(\"promise_#{name}\") do |*args|\n name_args = _name_args(name, *args)\n _class_fetch_states[name_args] = 'i'\n rest_class_methods[name_args] = { result: options[:default_result] } unless rest_class_methods.has_key?(name_args)\n _promise_get_or_patch(\"#{resource_base_uri}/methods/#{name}.json?timestamp=#{`Date.now() + Math.random()`}\", *args).then do |response_json|\n rest_class_methods[name_args][:result] = response_json[:result] # result is parsed json\n _class_fetch_states[name_args] = 'f'\n _notify_class_observers\n rest_class_methods[name_args][:result]\n end.fail do |response|\n error_message = \"#{self.to_s}.#{name}, a rest_method, failed to execute!\"\n `console.error(error_message)`\n response\n end\n end\n # @!method [name]\n # @return result either the default_result ass specified in the options or the real result if the RPC call already finished\n define_singleton_method(name) do |*args|\n name_args = _name_args(name, *args)\n _register_class_observer\n rest_class_methods[name_args] = { result: options[:default_result] } unless rest_class_methods.has_key?(name_args)\n unless _class_fetch_states.has_key?(name_args) && 'fi'.include?(_class_fetch_states[name_args])\n self.send(\"promise_#{name}\", *args)\n end\n rest_class_methods[name_args][:result]\n end\n # @!method update_[name] mark internal structures so that the method is called again once it is requested again\n # @return nil\n define_singleton_method(\"update_#{name}\") do |*args|\n _class_fetch_states[_name_args(name, *args)] = 'u'\n nil\n end\n end", "def subscribe_rest_method(record, rest_method_name)\n return unless session.id\n time_now = Time.now.to_f.to_s\n session_id = session.id.to_s\n Hyperloop.redis_instance.hset(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\", session_id, time_now)\n end", "def retry_change_requests; end", "def retry_change_requests; end", "def rest_class_methods\n @rest_class_methods ||= {}\n end", "def restart!\n CouchRest.post \"#{@uri}/_restart\"\n end", "def notify(method, *args)\n @serializer.write([2, method, args])\n self\n end", "def notify\n end", "def rest_end_point; end", "def send_request; end", "def send_pending; end", "def method_missing(method, *args, &block)\n if actions(current_api).include? method\n self.class.send(:define_method, method) do |params|\n perform_soap_call(method, params) || perform_rest_call(params)\n end\n send method, *args, &block\n else\n super\n end\n end", "def pend_rest_if(message)\n attribute(:fast_pending, [caller, message], {:keep => true})\n end", "def method_missing(meth, *args)\n if client.respond_to?(meth)\n client.send(meth, *args)\n else\n super(meth, *args)\n end\n end", "def method_missing(meth, *args, &blk)\n if client.respond_to?(meth)\n client.send(meth, *args, &blk)\n else\n super\n end\n end", "def retry\n super\n end", "def rest_endpoint; end", "def method_missing(meth, *args, &block)\n super unless client.respond_to?(meth)\n\n define_singleton_method meth do |*meth_args, &meth_block|\n client.send(meth, *meth_args, &meth_block)\n end\n\n send(meth, *args, &block)\n end", "def notify\n # render :nothing => true\n end", "def restart\n client.restart\n end", "def call\r\n # TODO: rename to more appropriate one 2007/05/10 by shino\r\n self.modify_message\r\n logger.debug{\"Ap4r::Dispatcher after modification\\n#{@message.to_yaml}\"}\r\n self.invoke\r\n self.validate_response\r\n self.response\r\n end", "def notify_post\n raise \"not yet implemented\"\n end", "def fire_async_response(class_method)\n response_id = AsyncResponse.new_response_id\n ZZ::Async::ConnectorWorker.enqueue(response_id, service_identity.id, self.class.name, class_method, params)\n response.headers[\"x-poll-for-response\"] = async_response_url(response_id)\n render :json => {:message => \"poll-for-response\"}\n end", "def _run\n super.tap { reenqueue }\n end", "def on_success(_klass, _method); end", "def reset()\n super\n=begin\n url = \"#{self.api_protocol}://#{self.api_domain}:#{self.api_port.to_s}/api1.3/threads/reset.json\"\n res = BlackStack::Netting::api_call(url, {\n 'api_key' => self.api_key,\n 'filename' => self.filename,\n 'id_client' => self.id_client,\n })\n=end\n end", "def notify\n {\n }\n end", "def notify\n {\n }\n end", "def refresh\n respond_to do |format|\n @endpoint.last_refresh_request_at = Time.now\n\n if @endpoint.save\n RefreshEndpointWorker.perform_async RefreshSubmission.new(@endpoint.id)\n\n format.html { redirect_to root_url, notice: 'Endpoint refreshing.' }\n format.json { head :ok }\n else\n format.html { head :unprocessable_entity }\n format.json { render json: @endpoint.errors, status: :unprocessable_entity }\n end\n end\n end", "def consume_rest; end", "def send(*rest) end", "def send(*rest) end", "def send(*rest) end", "def rest_method(name, options = { default_result: '...' })\n # @!method promise_[name]\n # @return [Promise] on success the .then block will receive the result of the RPC call as arg\n # on failure the .fail block will receive the HTTP response object as arg\n define_method(\"promise_#{name}\") do |*args|\n name_args = self.class._name_args(name, *args)\n @fetch_states[name_args] = 'i'\n @rest_methods[name] = {}.merge!(options) unless @rest_methods.has_key?(name)\n @rest_methods[name_args] = { result: options[:default_result] } unless @rest_methods.has_key?(name_args) && @rest_methods[name_args].has_key?(:result)\n raise \"#{self.class.to_s}[_no_id_].#{name}, can't execute instance rest_method without id!\" unless self.id\n self.class._promise_get_or_patch(\"#{resource_base_uri}/#{self.id}/methods/#{name}.json?timestamp=#{`Date.now() + Math.random()`}\", *args).then do |response_json|\n @rest_methods[name_args][:result] = response_json[:result] # result is parsed json\n @fetch_states[name_args] = 'f'\n _notify_observers\n @rest_methods[name_args][:result]\n end.fail do |response|\n error_message = \"#{self.class.to_s}[#{self.id}].#{name}, a rest_method, failed to execute!\"\n `console.error(error_message)`\n response\n end\n end\n # @!method [name]\n # @return result either the default_result ass specified in the options or the real result if the RPC call already finished\n define_method(name) do |*args|\n _register_observer\n name_args = self.class._name_args(name, *args)\n @rest_methods[name] = {}.merge!(options) unless @rest_methods.has_key?(name)\n @rest_methods[name_args] = { result: options[:default_result] } unless @rest_methods.has_key?(name_args) && @rest_methods[name_args].has_key?(:result)\n unless @fetch_states.has_key?(name_args) && 'fi'.include?(@fetch_states[name_args])\n self.send(\"promise_#{name}\", *args)\n end\n @rest_methods[name_args][:result]\n end\n # @!method update_[name] mark internal structures so that the method is called again once it is requested again\n # @return nil\n define_method(\"update_#{name}\") do |*args|\n @fetch_states[self.class._name_args(name, *args)] = 'u'\n nil\n end\n end", "def notify\n {}\n end", "def notify\n {}\n end", "def notify\n {}\n end", "def http_method\n raise \"Implement in child class\"\n end", "def redo!\n send_request\n end", "def recall; end", "def requeue\n @action = :requeue\n end", "def refuse_method(request)\n maybe_log(\"Refusing method call (transaction=#{message.transaction})\")\n error = ::Ractor::ClosedError.new\n request.sender.send(Message.new(:error, data: error, transaction: message.transaction))\n end", "def notify(data={})\n RestClient::Request.execute(:method => :post, :url => notify_path, :payload => data, :timeout => TIMEOUT, :open_timeout => TIMEOUT)\n rescue\n nil\n end", "def do_refresh_confirmed!\n end", "def define_verb(verb)\n define_method verb do |*args, &block|\n retries = options[:authentication_retries]\n begin\n connection.send(verb, *args, &block)\n rescue Restforce::UnauthorizedError\n if retries.positive?\n retries -= 1\n connection.url_prefix = options[:instance_url]\n retry\n end\n raise\n end\n end\n end", "def rest_endpoint=(_arg0); end", "def reconected(server)\n\t\t@reconect = false\n\t\t@server = server\n\tend", "def json_reload(notice: nil)\n self.notice(notice) if notice\n json_response 'reload'\n end", "def send(*args)\n args = args.insert(1, @id) # Add the id in the arguments\n meth = args[0] # Method is the 1st argument\n begin\n if affordable?(meth)\n deduct(meth)\n self.call(*args)\n else \n raise Wordtracker::InsufficientFundsException.new\n end\n rescue XMLRPC::FaultException => e\n raise Wordtracker::FaultException.new(0, \"RPC error calling #{meth}\")\n end\n end", "def notify_reverting\n @msg = \"Deployment Reverting\"\n post\n end", "def handle_reboot_request(obj, message)\n if obj.first == :guest\n guest_id = nil\n obj.each do |param|\n if param.is_a?(Array) && param.first == :id\n guest_id = param.second\n end\n end\n\n if XenNode.is_guest_running?(guest_id)\n if XenNode.reboot_guest(guest_id)\n msg = Cirrocumulus::Message.new(nil, 'inform', [message.content, [:finished]])\n msg.ontology = self.name\n msg.receiver = message.sender\n msg.in_reply_to = message.reply_with\n self.agent.send_message(msg)\n else\n msg = Cirrocumulus::Message.new(nil, 'failure', [message.content, [:unknown_reason]])\n msg.ontology = self.name\n msg.receiver = message.sender\n msg.in_reply_to = message.reply_with\n self.agent.send_message(msg)\n end\n else\n msg = Cirrocumulus::Message.new(nil, 'refuse', [message.content, [:guest_not_found]])\n msg.ontology = self.name\n msg.receiver = message.sender\n msg.in_reply_to = message.reply_with\n self.agent.send_message(msg)\n end\n end\n end", "def handle_request( * ) # :nodoc:\n\t\tself.log.debug \"[:restresources] handling request for REST resource.\"\n\t\tsuper\n\tend", "def method_missing(method_name, *args, &block)\n return super unless client.respond_to?(method_name)\n client.send(method_name, *args, &block)\n end", "def method_missing(method_name, *args, &block)\n return super unless client.respond_to?(method_name)\n client.send(method_name, *args, &block)\n end", "def method_missing(method_name, *args, &block)\n return super unless client.respond_to?(method_name)\n client.send(method_name, *args, &block)\n end", "def receive_request(request)\n request.reply(\"You should override #{self.class.to_s}#receive_request.\")\n end", "def dispatched!\n update dispatched: true\n end", "def restart!\n IbmCloudRest.post \"#{@uri}/_restart\"\n end", "def notify_reloading\n notify(\"RELOADING=1\")\n end", "def deliver\n raise Pomodori::Notifier::Error, \"This method needs to be overwritten\"\n end", "def synch_products_now\n result = Product.synch_products_now\n status = eval_status_res(result)\n send_email_which_service_api_is_not_connected(status)\n respond_to do |f|\n @back_to_index = \"#{products_path}\"\n f.js {render :layout => false, :status => status}\n end\n end", "def retry_change_requests=(retri); end", "def notifier; end", "def notifier; end", "def method_missing(name, *args, &block) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing\n client.public_send(name, *args, &block)\n end", "def dispatch message, client\n host, the_class, query = discover_resource message[\"resource\"].clone\n if @config.gateway.forward && host != @config.hostname && host != 'localhost'\n # May be we should gateway this message, if this wasn't aimed at us\n message.to.send @config.strategy.outbound\n else\n # Is there a reverse gateway token there?\n if @config.gateway.reverse && message.gateway == 'reverse'\n if clients.has_key? message.token.first\n begin \n clients[message.token.first].send message.to.json\n @config.logger.debug message.to.string\n rescue Exception => exception\n @config.logger.error exception.message\n @config.logger.debug exception.backtrace.to_s\n end\n else\n if respond_to? :client_not_found\n client_not_found message.token.first, message\n else\n raise ClientNotFoundError, \"Client #{message.token.first} is not registered in this server\"\n end\n end\n else\n if the_class.ancestors.include? JSTP::Controller\n resource = the_class.new message, query, self, client\n resource.send message[\"method\"].downcase.to_sym\n else\n if @config.environment == :development\n raise NotAControllerError, \"The resource class #{the_class} for #{message[\"resource\"].join(\"/\")} was found, but is not a JSTP::Controller\"\n else\n raise NotPermittedError, \"The selected resource is forbidden for this type of request\"\n end\n end\n end\n end\n end", "def reload_data\n self.class.new reinit_endpoint.do_get\n end", "def notify(optional_destination, rpc_method, *args)\n # TODO\n end", "def notify\n raise NotImplementedError\n end", "def method_missing(method_name, *arguments, &block)\n client.send(method_name, *arguments, &block)\n end", "def refuse\n @api_v1_reservation.update(status: :refused)\n Api::V1::ReservationMailer.refused_reservation(@api_v1_reservation).deliver_now\n render json: { success: true }, status: 200\n rescue Exception => errors\n render json: errors, status: :unprocessable_entity\n end", "def notifications\n end", "def refresh!\n # if self.payment_preauthorized? || self.confirmed? || self.started? || self.archived?\n # LOG.info \"Not possible to refresh.\"\n # end\n\n if self.created?\n do_refresh_created!\n elsif self.confirmed?\n #do_refresh_confirmed!\n else\n LOG.info \"Not possible to refresh.\"\n LOG.info message: \"Nothing to do for this booking.\", booking_id: self.id, booking_status: self.status\n end\n end", "def retire\n\n end", "def blocklisted_responder=(_arg0); end", "def send_notification(method, params); end", "def refresh(resource)\n resource.client = self\n resource.refresh\n end", "def method_missing(*args)\n result = nil\n orig = args.shift\n class_sym = self.class.name.to_sym\n m = orig.to_s[0,5] == '_DAV_' ? orig : \"_DAV_#{orig}\" # If hell is doing the same thing over and over and expecting a different result this is a hell preventer\n raise NoMethodError.new(\"Undefined method: #{orig} for class #{self}.\") unless respond_to?(m)\n @runner.call(class_sym, :before, orig)\n result = send m, *args\n @runner.call(class_sym, :after, orig)\n result\n end", "def acknowledge()\n\t\tend", "def method_missing(method, *args, &block)\n if @client.respond_to?(method)\n define_singleton_method(method) do |*args, &block|\n @client.send(method, *args, &block)\n end\n return send(method, *args, &block)\n end\n super\n end", "def acknowledge\n # do nothing\n end", "def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend", "def phone_reboot\nself.phone.reboot if self.phone\nend", "def restart\n\t\tself.stop_heartbeat\n\t\tsuper\n\t\tself.start_heartbeat\n\tend", "def update_status_to_processed\n fail 'child class to implement'\n end", "def resend(reason = nil)\n copy self.class.resend(@id, { metadata: @metadata, reason: reason })\n true\n end", "def notify\n begin\n request(@config.method, @config.url, payload_data, @config.format)\n true\n rescue Exception => ex\n log_error(ex) if @config.has_logger?\n false\n end\n end", "def refresh!\n raise NotImplementedError, \"#refresh! is not implemented on #{@provider}:#{@type}\"\n end", "def create\n @friend = User.find(params[:friend_id])\n if @friend.super_user?\n redirect_to(root_url)\n return\n end\n current_user.require_friend(@friend)\n msg = { resource: current_user.name+\" has just sent you a request friend\" ,\n friend_id: params[:friend_id],\n user_id: current_user.id\n } \n $redis.publish 'rt-change', msg.to_json\n redirect_to request.referrer\n \n end", "def snooze!\n log \"Sending #{@method} to Snooze.io\"\n handle_post_response { Snooze::Post.send(@method, @clock_id) }\n end", "def forget\n Forgotten.new(@object, @remote_key)\n end", "def test_reset\n response = @request.get('/reseted')\n assert !response.ok?\n assert_equal 404, response.status, 'Base class routing should be reset'\n\n base_class_response = @base_class_request.get('/reseted')\n assert base_class_response.ok?\n assert_equal 'only_in_base_class', base_class_response.body\n end", "def resting(args = {})\n args[:work_type] = REST_TYPE\n workpattern(args)\n end" ]
[ "0.6370434", "0.61913794", "0.61048335", "0.5896762", "0.58278847", "0.5817641", "0.5775535", "0.5696426", "0.5692046", "0.55505234", "0.55505234", "0.5517397", "0.55170935", "0.55004454", "0.54606736", "0.54507464", "0.5434953", "0.5429647", "0.54267377", "0.5408788", "0.5384758", "0.5359285", "0.5354058", "0.5339444", "0.53352773", "0.5329549", "0.5325921", "0.5317795", "0.5316944", "0.53060603", "0.5300159", "0.52739096", "0.52535796", "0.5241143", "0.5241143", "0.5235454", "0.52340704", "0.52150553", "0.52150553", "0.52150553", "0.5206998", "0.51997805", "0.51997805", "0.51997805", "0.519351", "0.5187796", "0.51840216", "0.5177272", "0.5162591", "0.51544607", "0.5136524", "0.5133827", "0.5123949", "0.5120138", "0.51166475", "0.5115649", "0.5110798", "0.51030505", "0.5102374", "0.5098022", "0.5098022", "0.5098022", "0.5092731", "0.50779086", "0.507231", "0.5070219", "0.5065276", "0.5064476", "0.5060956", "0.50529623", "0.50529623", "0.5051431", "0.5050109", "0.50397056", "0.5028591", "0.5027538", "0.5023642", "0.50185114", "0.50151503", "0.5014157", "0.5003797", "0.5000953", "0.499854", "0.4995868", "0.49933633", "0.49863774", "0.49834433", "0.49746946", "0.4973053", "0.4970066", "0.49648276", "0.49644893", "0.49575835", "0.4948934", "0.49470687", "0.49458045", "0.4945271", "0.49384212", "0.49228105", "0.4919905" ]
0.6812041
0
send message to notify clients that they should call the rest_method again
def publish_rest_method(record, rest_method_name) subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}") time_now = Time.now.to_f scrub_time = time_now - 24.hours.to_f message = { record_type: record.class.to_s, id: record.id, rest_method: rest_method_name } subscribers.each_slice(10) do |slice| channel_array = [] slice.each do |session_id, last_requested| if last_requested.to_f < scrub_time Hyperloop.redis_instance.hdel("HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}", session_id) next end channel_array << "hyper-record-update-channel-#{session_id}" end if Hyperloop.resource_transport == :pusher _pusher_client.trigger_async(channel_array, 'update', message) elsif Hyperloop.resource_transport == :action_cable channel_array.each do |channel| ActionCable.server.broadcast(channel, message) end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call\n context.response ||= notify\n end", "def pub_sub_rest_method(record, rest_method_name)\n subscribe_rest_method(record, rest_method_name)\n publish_rest_method(record, rest_method_name)\n end", "def restart!\n CouchRest.post \"#{@uri}/_restart\"\n end", "def publish_rest_class_method(record_class, rest_class_method_name)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: record_class.to_s,\n rest_class_method: rest_class_method_name\n }\n subscribers.each_slice(10) do |slice|\n channel_array = []\n slice.each do |session_id, last_requested|\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}\", session_id)\n next\n end\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n end", "def redo!\n send_request\n end", "def subscribe_rest_method(record, rest_method_name)\n return unless session.id\n time_now = Time.now.to_f.to_s\n session_id = session.id.to_s\n Hyperloop.redis_instance.hset(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\", session_id, time_now)\n end", "def notify(data={})\n RestClient::Request.execute(:method => :post, :url => notify_path, :payload => data, :timeout => TIMEOUT, :open_timeout => TIMEOUT)\n rescue\n nil\n end", "def refresh\n raise Occi::Api::Client::Errors::NotImplementedError, \"#{__method__} is just a stub!\"\n end", "def retry_change_requests; end", "def retry_change_requests; end", "def notify\n # render :nothing => true\n end", "def send_request; end", "def restart\n client.restart\n end", "def refuse\n @api_v1_reservation.update(status: :refused)\n Api::V1::ReservationMailer.refused_reservation(@api_v1_reservation).deliver_now\n render json: { success: true }, status: 200\n rescue Exception => errors\n render json: errors, status: :unprocessable_entity\n end", "def notify\n end", "def notify(method, *args)\n @serializer.write([2, method, args])\n self\n end", "def synch_products_now\n result = Product.synch_products_now\n status = eval_status_res(result)\n send_email_which_service_api_is_not_connected(status)\n respond_to do |f|\n @back_to_index = \"#{products_path}\"\n f.js {render :layout => false, :status => status}\n end\n end", "def reset_whats_new_for_all_users \n get(\"/users.json/news/reset\")\nend", "def reset_whats_new_for_all_users \n get(\"/users.json/news/reset\")\nend", "def pend_rest_if(message)\n attribute(:fast_pending, [caller, message], {:keep => true})\n end", "def send_pending; end", "def notify_reverting\n @msg = \"Deployment Reverting\"\n post\n end", "def httpAndNotify(path, params, msg_from, method)\n message = \"\"\n begin\n \n m = \"\"\n if method == :get\n m = \"GET\"\n elsif method == :post\n m = \"POST\"\n elsif method == :put\n m = \"PUT\"\n elsif method == :delete\n m = \"DELETE\"\n else\n raise Exception.new(\"Wrong method! use: :get, :post, :put or :delete!\")\n end\n \n puts \"HTTP #{m} to: #{@@http_host + path}\"\n res = HttpRequest.new(method, path, params).send(@@http_host)\n message = \"#{res.code.to_s}; #{res.body}; #{path}\"\n \n rescue Exception => e\n puts \"Error: \" + e.to_s\n puts \" -- line #{e.backtrace[0].to_s}\"\n message = \"#{e.to_s}; #{path}\"\n end\n \n # Notifies the xmpp-client about the http-rest result \n puts \"xmpp-response\"\n notification = {:receiver => msg_from, :message => message}\n sendMessage(notification, @receive_client)\n \n end", "def rest_endpoint; end", "def rest_end_point; end", "def do_refresh_confirmed!\n end", "def refuse_method(request)\n maybe_log(\"Refusing method call (transaction=#{message.transaction})\")\n error = ::Ractor::ClosedError.new\n request.sender.send(Message.new(:error, data: error, transaction: message.transaction))\n end", "def __send__(*rest) end", "def refresh\n respond_to do |format|\n @endpoint.last_refresh_request_at = Time.now\n\n if @endpoint.save\n RefreshEndpointWorker.perform_async RefreshSubmission.new(@endpoint.id)\n\n format.html { redirect_to root_url, notice: 'Endpoint refreshing.' }\n format.json { head :ok }\n else\n format.html { head :unprocessable_entity }\n format.json { render json: @endpoint.errors, status: :unprocessable_entity }\n end\n end\n end", "def reset()\n super\n=begin\n url = \"#{self.api_protocol}://#{self.api_domain}:#{self.api_port.to_s}/api1.3/threads/reset.json\"\n res = BlackStack::Netting::api_call(url, {\n 'api_key' => self.api_key,\n 'filename' => self.filename,\n 'id_client' => self.id_client,\n })\n=end\n end", "def subscribe_rest_class_method(record_class, rest_class_method_name)\n return unless session.id\n time_now = Time.now.to_f.to_s\n session_id = session.id.to_s\n Hyperloop.redis_instance.pipelined do\n Hyperloop.redis_instance.hset(\"HRPS__#{record_class}__rest_class_method_name__#{rest_class_method_name}\", session_id, time_now)\n end\n end", "def synch\n @results = PurchaseOrder.synch_retur_now\n status = eval_status_res(@results)\n send_email_which_service_api_is_not_connected(status)\n respond_to do |f|\n @back_to_index = \"#{returned_processes_path}\"\n f.js {render :layout => false, :status=>status}\n end\n end", "def json_reload(notice: nil)\n self.notice(notice) if notice\n json_response 'reload'\n end", "def notify(optional_destination, rpc_method, *args)\n # TODO\n end", "def notify_post\n raise \"not yet implemented\"\n end", "def pub_sub_rest_class_method(record_class, rest_class_method_name)\n subscribe_rest_class_method(record_class, rest_class_method_name)\n publish_rest_class_method(record_class, rest_class_method_name)\n end", "def create\n @friend = User.find(params[:friend_id])\n if @friend.super_user?\n redirect_to(root_url)\n return\n end\n current_user.require_friend(@friend)\n msg = { resource: current_user.name+\" has just sent you a request friend\" ,\n friend_id: params[:friend_id],\n user_id: current_user.id\n } \n $redis.publish 'rt-change', msg.to_json\n redirect_to request.referrer\n \n end", "def notify\n {\n }\n end", "def notify\n {\n }\n end", "def reset_and_resend\n @download_registration.update(download_count: 0)\n @download_registration.deliver_download_code\n @msg = \"Message to #{@download_registration.first_name} is on its way.\"\n respond_to do |format|\n format.html { redirect_to [:admin, @download_registration.registered_download], notice: @msg}\n format.js\n end\n end", "def notify\n {}\n end", "def notify\n {}\n end", "def notify\n {}\n end", "def retry_change_requests=(retri); end", "def reconected(server)\n\t\t@reconect = false\n\t\t@server = server\n\tend", "def restart!\n IbmCloudRest.post \"#{@uri}/_restart\"\n end", "def snooze!\n log \"Sending #{@method} to Snooze.io\"\n handle_post_response { Snooze::Post.send(@method, @clock_id) }\n end", "def resend_invite\n service_response = AdminManagement::AdminUser::Invite::Resend.new(params).perform\n render_api_response(service_response)\n end", "def rest_endpoint=(_arg0); end", "def requeue\n @action = :requeue\n end", "def notify\n begin\n request(@config.method, @config.url, payload_data, @config.format)\n true\n rescue Exception => ex\n log_error(ex) if @config.has_logger?\n false\n end\n end", "def test_start_auction_to_one_server_should_replicate\n reset(REP_SERVERS)\n server1, server2, server3 = REP_SERVERS\n name = \"gau2\"\n \n do_rest(server1, :start_auction, {name: name, end_time: Time.now.to_i + 3})\n do_rest(server1, :bid, {name: name, client:1, bid:100})\n res = do_rest(server1, :status, {name: name})\n assert_equal(\"1\", res.strip)\n\n res = do_rest(server2, :status, {name: name})\n assert_equal(\"1\", res.strip)\n res = do_rest(server3, :status, {name: name})\n assert_equal(\"1\", res.strip)\n end", "def send_notification method, params\n response = {\n jsonrpc: \"2.0\",\n method: method,\n params: params\n }\n json = response.to_json\n envelope = \"Content-Length: #{json.bytesize}\\r\\n\\r\\n#{json}\"\n queue envelope\n end", "def save\n @client.patch(@endpoint, :content=>@changed)\n return nil\n end", "def send_notification(method, params); end", "def send(*rest) end", "def send(*rest) end", "def send(*rest) end", "def remote_call(remote_method, params)\n correlation_id = SecureRandom.uuid\n message = { id: correlation_id, jsonrpc: '2.0', method: remote_method, params: params}\n # Reply To => make sure the service knows where to send it's response.\n # Correlation ID => identify the results that belong to the unique call made\n @exchange.publish(message.to_json, routing_key: @server_queue.name, correlation_id: correlation_id,\n reply_to: @reply_queue.name)\n result = @results[correlation_id].pop\n @results.delete correlation_id # remove item from hash. prevents memory leak.\n result\n end", "def method_missing(method, *args, &block)\n if actions(current_api).include? method\n self.class.send(:define_method, method) do |params|\n perform_soap_call(method, params) || perform_rest_call(params)\n end\n send method, *args, &block\n else\n super\n end\n end", "def synch_product_based_on_code\n product_db = Product.find(params[:id]).callback_api_product_based_on_code\n status = eval_status_res(product_db)\n send_email_which_service_api_is_not_connected(status)\n respond_to do |f|\n f.js {render :layout => false, :status => status}\n end\n end", "def request module_id, msg, &block\n req_id = @req_id\n @req_id += 1\n @callbacks[req_id] = block\n msg[:client_id] = @client_id\n msg[:username] = @username\n @ws.send ['client', compose_request(req_id, module_id, msg)].to_json\n end", "def call\r\n # TODO: rename to more appropriate one 2007/05/10 by shino\r\n self.modify_message\r\n logger.debug{\"Ap4r::Dispatcher after modification\\n#{@message.to_yaml}\"}\r\n self.invoke\r\n self.validate_response\r\n self.response\r\n end", "def notify module_id, msg\n msg[:client_id] = @client_id\n msg[:username] = @username\n @ws.send ['client', compose_request(nil, module_id, msg)].to_json\n end", "def update_client!(success)\n 5.times do\n push_count = ActionCable.server.broadcast(\"auth_#{@code}\", { success: success })\n return true if push_count.positive?\n\n sleep 0.5\n end\n\n false\n end", "def subscribe\n \nend", "def request(method, message = nil)\n @client.call(method, message:)\n end", "def sub_reactivate\n begin\n ChargeBee::Subscription.reactivate(@subscription_id)\n render json: {\n :forward => \"/ssp/subscription\"\n }\n rescue ChargeBee::PaymentError =>e\n ErrorHandler.handle_charge_attempt_failure_errors(e, self)\n rescue ChargeBee::InvalidRequestError => e\n ErrorHandler.handle_invalid_errors(e, self)\n rescue Exception => e\n ErrorHandler.handle_general_errors(e, self)\n end\n end", "def handle_reboot_request(obj, message)\n if obj.first == :guest\n guest_id = nil\n obj.each do |param|\n if param.is_a?(Array) && param.first == :id\n guest_id = param.second\n end\n end\n\n if XenNode.is_guest_running?(guest_id)\n if XenNode.reboot_guest(guest_id)\n msg = Cirrocumulus::Message.new(nil, 'inform', [message.content, [:finished]])\n msg.ontology = self.name\n msg.receiver = message.sender\n msg.in_reply_to = message.reply_with\n self.agent.send_message(msg)\n else\n msg = Cirrocumulus::Message.new(nil, 'failure', [message.content, [:unknown_reason]])\n msg.ontology = self.name\n msg.receiver = message.sender\n msg.in_reply_to = message.reply_with\n self.agent.send_message(msg)\n end\n else\n msg = Cirrocumulus::Message.new(nil, 'refuse', [message.content, [:guest_not_found]])\n msg.ontology = self.name\n msg.receiver = message.sender\n msg.in_reply_to = message.reply_with\n self.agent.send_message(msg)\n end\n end\n end", "def notify(uri, rpc_method, *args)\n # will block until message is published\n published_l = Mutex.new\n published_c = ConditionVariable.new\n\n uri = URI.parse(uri)\n host,port = uri.host, uri.port\n\n invoked = false\n conn = nil\n message = Messages::Notification.new :method => rpc_method,\n :args => args,\n :headers => @message_headers\n @@em.schedule {\n init_client(:host => host, :port => port,\n :rjr_node => self) { |c|\n conn = c\n c.send_msg message.to_s\n # XXX, this should be invoked only when we are sure event\n # machine sent message. Shouldn't pose a problem unless event\n # machine is killed immediately after\n published_l.synchronize { invoked = true ; published_c.signal }\n }\n }\n published_l.synchronize { published_c.wait published_l unless invoked }\n #sleep 0.01 until conn.get_outbound_data_size == 0\n nil\n end", "def notifications\n end", "def process\n client.unreliable_activity_without_retry_options\n end", "def request!\n self.type = :subscribe\n reply_if_needed!\n end", "def notification(function_name, *para)\n para = {'method' => function_name, 'params' => para, 'id' => nil}\n .to_json\n send_request para\n nil\n end", "def reply\n end", "def nack\n @action = :nack\n end", "def cancelled_requests; end", "def perform_op(method, req_hash, options={}, &blk)\n set_defaults(options)\n max_retries = options[:max_retries] || 5\n max_follows = options[:max_follows] || 10\n if options[:follow_count] && options[:follow_count] >= max_follows\n raise Rest::RestError, \"Too many follows. #{options[:follow_count]}\"\n end\n current_retry = 0\n current_follow = 0\n success = false\n tries = 0\n res = nil\n # todo: typhoeus does retries in the library so it shouldn't do retries here. And we should use the max_retries here as a parameter to typhoeus\n while current_retry < max_retries && current_follow < max_follows do\n tries += 1\n begin\n res = yield blk\n res.tries = tries\n if res.code >= 300 && res.code < 400\n # try new location\n #p res.headers\n loc = res.headers[\"location\"]\n @logger.debug \"#{res.code} Received. Trying new location: #{loc}\"\n if loc.nil?\n raise InvalidResponseError.new(\"No location header received with #{res.code} status code!\")\n end\n # options.merge({:max_follows=>options[:max_follows-1]}\n options[:follow_count] ||= 0\n options[:follow_count] += 1\n res = perform_op(method, req_hash, options) do\n res = @wrapper.send(method, loc, req_hash)\n end\n #puts 'X: ' + res.inspect\n return res\n end\n # If it's here, then it's all good\n break\n rescue Rest::HttpError => ex\n if ex.code == 503\n raise ex if current_retry == max_retries - 1\n\n pow = (4 ** (current_retry)) * 100 # milliseconds\n #puts 'pow=' + pow.to_s\n s = rand * pow\n #puts 's=' + s.to_s\n sleep_secs = 1.0 * s / 1000.0\n #puts 'sleep for ' + sleep_secs.to_s\n current_retry += 1\n @logger.debug \"#{ex.code} Received. Retrying #{current_retry} out of #{max_retries} max in #{sleep_secs} seconds.\"\n sleep sleep_secs\n else\n raise ex\n end\n end\n end\n res\n end", "def update_scrap_topic\n # Not allowed for now\n render_401 and return\n end", "def response_from_service\n\n end", "def rest_method(name, options = { default_result: '...' })\n # @!method promise_[name]\n # @return [Promise] on success the .then block will receive the result of the RPC call as arg\n # on failure the .fail block will receive the HTTP response object as arg\n define_method(\"promise_#{name}\") do |*args|\n name_args = self.class._name_args(name, *args)\n @fetch_states[name_args] = 'i'\n @rest_methods[name] = {}.merge!(options) unless @rest_methods.has_key?(name)\n @rest_methods[name_args] = { result: options[:default_result] } unless @rest_methods.has_key?(name_args) && @rest_methods[name_args].has_key?(:result)\n raise \"#{self.class.to_s}[_no_id_].#{name}, can't execute instance rest_method without id!\" unless self.id\n self.class._promise_get_or_patch(\"#{resource_base_uri}/#{self.id}/methods/#{name}.json?timestamp=#{`Date.now() + Math.random()`}\", *args).then do |response_json|\n @rest_methods[name_args][:result] = response_json[:result] # result is parsed json\n @fetch_states[name_args] = 'f'\n _notify_observers\n @rest_methods[name_args][:result]\n end.fail do |response|\n error_message = \"#{self.class.to_s}[#{self.id}].#{name}, a rest_method, failed to execute!\"\n `console.error(error_message)`\n response\n end\n end\n # @!method [name]\n # @return result either the default_result ass specified in the options or the real result if the RPC call already finished\n define_method(name) do |*args|\n _register_observer\n name_args = self.class._name_args(name, *args)\n @rest_methods[name] = {}.merge!(options) unless @rest_methods.has_key?(name)\n @rest_methods[name_args] = { result: options[:default_result] } unless @rest_methods.has_key?(name_args) && @rest_methods[name_args].has_key?(:result)\n unless @fetch_states.has_key?(name_args) && 'fi'.include?(@fetch_states[name_args])\n self.send(\"promise_#{name}\", *args)\n end\n @rest_methods[name_args][:result]\n end\n # @!method update_[name] mark internal structures so that the method is called again once it is requested again\n # @return nil\n define_method(\"update_#{name}\") do |*args|\n @fetch_states[self.class._name_args(name, *args)] = 'u'\n nil\n end\n end", "def acknowledge()\n\t\tend", "def acknowledge\n # do nothing\n end", "def retire!\n update!(retired: true)\n end", "def consume_rest; end", "def refuse_request\n request = Request.first\n RequestMailer.refuse_request(request)\n end", "def call(method_name, *params)\n request = nil\n response = nil\n\n @call_mutex.synchronize do\n request = [0, @msgid, method_name, params]\n @msgid = (@msgid % MAX_MSGID) + 1\n response = make_request_with_retries(request)\n end\n\n if response[0] != 1\n raise MsgpackRpcClient::Error, 'Response does not bear the proper type flag - something is very wrong'\n end\n if response[1] != request[1]\n raise MsgpackRpcClient::Error, 'Response message id does not match request message id - something is very wrong'\n end\n if response[2] != nil\n raise MsgpackRpcClient::Error, \"Server responded with error: #{response[2]}\"\n end\n\n response[3]\n end", "def retry_change_requests\n @agent.retry_change_requests\n end", "def reset!\n client.reset!\n end", "def call_rest(verb, url, xml=nil, content_type='text/xml')\n begin\n case verb.to_sym\n when :get\n RestClient.get(url)\n when :post\n RestClient.post(url, xml, :content_type => content_type)\n when :put\n RestClient.put(url, xml, :content_type => content_type)\n when :delete\n RestClient.delete(url)\n end\n rescue => e\n puts \"Exception at: #{url}\"\n puts e.response ? e.response : e\n end\n end", "def reminder_sent\n end", "def send(*args)\n args = args.insert(1, @id) # Add the id in the arguments\n meth = args[0] # Method is the 1st argument\n begin\n if affordable?(meth)\n deduct(meth)\n self.call(*args)\n else \n raise Wordtracker::InsufficientFundsException.new\n end\n rescue XMLRPC::FaultException => e\n raise Wordtracker::FaultException.new(0, \"RPC error calling #{meth}\")\n end\n end", "def notify_user\n current_user.notify!(twilio_client)\n redirect_to current_user\n end", "def refresh_part\n\n if params[:restream].nil?\n @msg = current_user.check_message\n render layout: false\n else\n @msg = current_user.check_message\n\n respond_to do |format|\n format.js\n end\n end\n\n end", "def refreshnotify\n @title = \"\"\n\n puts '====================== refreshnotify'\n\n current_user.update_attributes!(:notify => \"NO\")\n @user = current_user\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json=> { \n :user=>@user.as_json(:only => [:id, :name, :email, :invitation_token, :notify, :buddy, :gender, :displayname], :methods => [:photo_url]) \n } }\n end\n end", "def send_request method, params, &block\n message = {\n jsonrpc: \"2.0\",\n method: method,\n params: params,\n id: @next_request_id\n }\n json = message.to_json\n requests[@next_request_id] = Request.new(@next_request_id, &block)\n envelope = \"Content-Length: #{json.bytesize}\\r\\n\\r\\n#{json}\"\n queue envelope\n @next_request_id += 1\n end", "def restart\n r = REXML::Element.new 'body'\n r.attributes['rid'] = @http_rid += 1\n r.attributes['sid'] = @http_sid\n r.attributes['to'] = @jid.domain\n r.attributes['xmlns'] = 'http://jabber.org/protocol/httpbind'\n r.attributes['xmlns:xmpp'] = 'urn:xmpp:xbosh'\n r.attributes['xmpp:restart'] = 'true'\n s = post(r)\n unless s.name == 'body'\n raise 'Response body is no <body/> element'\n end\n receive_elements_with_rid(@http_rid, s.children)\n end", "def blocklisted_responder=(_arg0); end", "def send_notification\n\n\n end", "def push_subscription\n\t\trender :nothing => true\n\tend" ]
[ "0.61973923", "0.6140131", "0.5967415", "0.5911174", "0.5888645", "0.5872892", "0.5854032", "0.5854032", "0.581641", "0.581641", "0.5782182", "0.57259923", "0.5702955", "0.5629774", "0.55910534", "0.5578763", "0.55683357", "0.5568055", "0.5568055", "0.5555822", "0.5528968", "0.5515175", "0.5501116", "0.5497136", "0.5476091", "0.5470616", "0.5462756", "0.54370105", "0.5425722", "0.54140157", "0.5412931", "0.54119813", "0.5395236", "0.53896266", "0.53855616", "0.5385407", "0.5377747", "0.53754896", "0.53754896", "0.53745955", "0.53733194", "0.53733194", "0.53733194", "0.53644913", "0.53640455", "0.5348988", "0.53355074", "0.5331324", "0.53256184", "0.5320088", "0.5317951", "0.53088444", "0.530619", "0.53021646", "0.52929837", "0.5279969", "0.5279969", "0.5279969", "0.52661175", "0.52495867", "0.524664", "0.52337927", "0.5227947", "0.52236295", "0.52234274", "0.5220621", "0.52136946", "0.52110624", "0.5205608", "0.5188223", "0.5187328", "0.5185185", "0.5181402", "0.51766384", "0.51744914", "0.51728976", "0.51723504", "0.51599044", "0.51584816", "0.51561344", "0.5148423", "0.51460886", "0.514573", "0.5134657", "0.51274735", "0.5126198", "0.5123549", "0.5123333", "0.51212126", "0.5116241", "0.5114757", "0.5113444", "0.5104397", "0.5088418", "0.5085126", "0.50849056", "0.5072224", "0.5060195", "0.5058125", "0.5053165" ]
0.6347894
0
send message about scope change to all subscribers
def publish_scope(record_class, scope_name) subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record_class}__scope__#{scope_name}") time_now = Time.now.to_f scrub_time = time_now - 24.hours.to_f message = { record_type: record_class.to_s, scope: scope_name } subscribers.each_slice(10) do |slice| channel_array = [] slice.each do |session_id, last_requested| if last_requested.to_f < scrub_time Hyperloop.redis_instance.hdel("HRPS__#{record_class}__scope__#{scope_name}", session_id) next end channel_array << "hyper-record-update-channel-#{session_id}" end if Hyperloop.resource_transport == :pusher _pusher_client.trigger_async(channel_array, 'update', message) elsif Hyperloop.resource_transport == :action_cable channel_array.each do |channel| ActionCable.server.broadcast(channel, message) end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def notify_subscribers\n AdminMailer.notify_of_standard_change(self)\n end", "def notification_recipient_scope=(value)\n @notification_recipient_scope = value\n end", "def subscribed; end", "def send_update\n changed\n notify_observers(self)\n end", "def subscribed\n super\n increase_current_users\n stream_from channel\n end", "def subscriptions; end", "def subscriptions; end", "def subscriptions; end", "def broadcast_users_changed\n data = {\n action: 'players_changed'\n }\n ActionCable.server.broadcast \"game:#{@room.id}\", data\n end", "def scopeChanged\n pp [:got_scopeChanged] if $DEBUG\n end", "def notify_subscribers\n NotificationSubscription.notify(self)\n end", "def notfiy_subscribers(params)\n subject = params[:subscribable]\n\n subject.subscribers.each do |subscriber|\n subscriber.notify(subject, params[:message])\n end\n\n continue(params)\n end", "def modify_subscriptions(subs)\n iq = connection.iq_stanza({'to'=>jid.bare,'type'=>'set'},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSubOwner},\n x('subscriptions',{:node => node_id},\n subs.map do |s|\n x('subscription',:jid => s.jid, :subscription => s.subscription, :subid => s.sub_id)\n end\n )\n )\n )\n send_iq_stanza_fibered iq\n end", "def send_email_changed_notification; end", "def notify\n @subscribers.each { |ident, (block,obj)| block.call(obj) }\n end", "def unsubscribed; end", "def pub_sub_scope(collection, record_class, scope_name)\n subscribe_scope(collection, record_class, scope_name)\n publish_scope(record_class, scope_name)\n end", "def notify_subscribers(resource)\n resource.subscriptions.each do |subscription|\n http = EM::HttpRequest.new(subscription.url).post(:body => {:data => resource.body})\n http.callback{ |response|\n puts \"POSTed updated data for #{resource.url}, #{resource.body.length} characters\"\n }\n http.errback {|response|\n # Do something here, maybe setting the resource\n # to be not checked anymore.\n }\n end\n end", "def subscribe\n self.subscribed = true\n end", "def subscribe\n \nend", "def subscribed # :doc:\n # Override in subclasses\n end", "def show_subscriptions\n puts \"\\nYour current subscriptions are:\"\n @user.subscriptions.reload.each do |sub|\n puts sub.name\n end\n end", "def send_permissions_changed_email\n UserMailer.permissions_changed(self).deliver_now\n end", "def tell_all(m, message)\r\n if_admin(m) do\r\n @bot.channels.each {|c| c.send(message) }\r\n end\r\n end", "def subscribe!\n # TODO: Implement\n end", "def publish_change event\n send :invalidate_rolegroups_cache! if event == :role_groups\n event_manager.publish_change event, :from => self\n end", "def update_scope\n @scope = params[:scope] || params[:q] || {}\n end", "def websocket_update\n json = self.to_jsonapi\n watching_users.each do |user|\n UpdatesChannel.broadcast_to(user, {loadModels: [json]})\n end\n end", "def update\n Channel.channels_to_update\n end", "def broadcast_change\n # don't broadcast submits from /admin when nothing changed\n BroadcastChangeJob.perform_now(self) unless previous_changes.empty?\n end", "def subscribe_to_channel; end", "def notify_key\n self.key.update_status(self.lang)\n self.audits.destroy\n end", "def notify_change\n SpecificNodeMailer.notify_change\n end", "def subscribe(data)\n # @channels (local tracker)\n # push channel name into subscribe list, if and only if not already in subscribe list\n end", "def status_changed(participation)\n @cbo = participation.cbo\n @user = participation.user\n @participation = participation\n @url = \"http://#{request.host_with_port}\" + participation_path(participation)\n \n mail(:to => @user.email, :subject => \"Your application to #{@cbo.cboprofile.name} has been updated!\")\n end", "def send_notifications\n end", "def update_scopes\n if changes = friendly_id_changes\n friendly_id_config.child_scopes.each do |klass|\n Slug.update_all \"scope = '#{changes[1]}'\", [\"sluggable_type = ? AND scope = ?\", klass.to_s, changes[0]]\n end\n end\n end", "def update_scopes\n if changes = friendly_id_changes\n friendly_id_config.child_scopes.each do |klass|\n Slug.update_all \"scope = '#{changes[1]}'\", [\"sluggable_type = ? AND scope = ?\", klass.to_s, changes[0]]\n end\n end\n end", "def notify_will_change!\n collection_will_change!\n forward \"#{@key}_will_change!\"\n end", "def push_updates(data)\n PushService.new.send_update_store(Channel::STAFF_CHANNEL, data)\n PushService.new.send_update_store(Channel.private_channels_for(donor, DONOR_APP), data)\n end", "def update\n friend = current_user.friends.find params[:id]\n return render json: { error: \"This doesn't seem to be your friend\" } if friend.nil?\n subscribed = !friend.subscribed\n change = subscribed ? 1 : -1\n friend.update subscribed: subscribed\n notify friend, change, 'subscribe'\n render json: {success: subscribed == friend.subscribed}\n end", "def notify_game_change\n connection.execute \"NOTIFY #{channel}, #{connection.quote self.to_s}\"\n end", "def subscribed\n \t#stream_from 'demo_chan'\n end", "def scopes; end", "def scoped_members=(value)\n @scoped_members = value\n end", "def refreshRoomViews\n @windowController.sites.each_value do |site|\n site.rooms.each_value do |room| \n room.controller.view.updateVisibleMessages if room.controller\n end\n end\n end", "def broadcast_feeling_change(org, adjustment)\n orgs = @rl.repository.everything_of_type(KuiOrg)\n orgs.each { |recipient| \n recipient.receive_feeling_change(self,org, adjustment) }\n end", "def rt_update\n Realtime::Publisher.instance.batch_update all_members\n end", "def subscribers\r\n @subscribers.clone\r\n end", "def someone_did_change_topic(stem, person, channel, topic)\n end", "def notify\n {\n }\n end", "def notify\n {\n }\n end", "def check_updated_permissions\n\t\tif self.permission_changed?\n\t\t\tSingleCellMailer.share_notification(self.study.user, self).deliver_now\n\t\tend\n\tend", "def after_create\n oscopes = OscopeMsg.find_all_by_timestamp_and_user_id(timestamp, user_id)\n # instantiation of oscopes already caused oscope_start_msg to link to them\n # :update_without_callbacks is a provate method. direct call will not work. need to 'send' it\n oscopes.each {|p| p.send(:update_without_callbacks) } # this will save all instantiated oscopes\n end", "def notify\n notify_unmentioned_reviewers\n notify_mentioned_event_staff if mention_names.any?\n end", "def subscriber_names\n @client.smembers @name\n end", "def subscribed_people(logs)\n people = people_subscribed_to_logged_items logs\n people.select(&:receive_notifications?)\n end", "def IsSubscribed=(arg0)", "def IsSubscribed=(arg0)", "def set_members\n members_ids = params[:message][:recipient_ids].reject(&:empty?)\n members_ids.each do |members_id|\n @message = current_user.messages.create(:conversation_id => members_id , :body => params[:message][:body])\n\n #send notification\n reciver = User.find(members_id)\n if reciver.notification_setting.try(:new_update)\n Notification.create(recepient_id: members_id, user: current_user, body: \"#{current_user.screen_name } has send a message #{@message.topic} \", notificable: @message, :accept => false)\n end\n end\n end", "def notify_user(copies, scope)\n return if copies.all?(&:copied)\n\n WorkerMailer.node_copy_email(\n @context.user.email,\n copies,\n scope,\n ).deliver_now\n end", "def unsubscribed\n\tend", "def notification_recipient_scope\n return @notification_recipient_scope\n end", "def announce_consensus_change(old_name, new_name)\n log_consensus_change(old_name, new_name)\n\n # Change can trigger emails.\n owner = user\n sender = User.current\n recipients = []\n\n # Tell owner of observation if they want.\n recipients.push(owner) if owner&.email_observations_consensus\n\n # Send to people who have registered interest.\n # Also remove everyone who has explicitly said they are NOT interested.\n interests.each do |interest|\n if interest.state\n recipients.push(interest.user)\n else\n recipients.delete(interest.user)\n end\n end\n\n # Remove users who have opted out of all emails.\n recipients.reject!(&:no_emails)\n\n # Send notification to all except the person who triggered the change.\n (recipients.uniq - [sender]).each do |recipient|\n QueuedEmail::ConsensusChange.create_email(sender, recipient, self,\n old_name, new_name)\n end\n end", "def unsubscribed\n end", "def unsubscribed\n end", "def notify_changed_request_status(request)\n @request=request\n mail(to: request.user.email,\n subject: \"#{request.user.name} your request has been #{I18n.t \"request_status.#{request.status}\"}\")\n end", "def subscribed\n id = params.fetch(:id)\n return unless execution = JobQueue.find_by_id(id)\n\n execution.viewers.push current_user\n\n Thread.new do\n ActiveRecord::Base.connection_pool.with_connection do\n builder = EventBuilder.new(execution.job)\n execution.output.each do |event, data|\n transmit event: event, data: builder.payload(event, data)\n end\n # TODO: disconnect all listeners so they close their sockets ?\n # then replace the reloaded/finished/waitUntilEnabled stuff with that\n end\n end\n end", "def get_subscribers\n @subscriptions = subscribers(@nodename)\n end", "def refresh\n puts \" -- refresh subscriptions(#{@subscriptions.size}):\"\n\n run_callback_server # call it once to make sure it runs\n \n @subscriptions.each do |sub| \n puts \" - #{sub.name}\"\n params = { \"attributes[accept]\" => 'application/json' }\n\n query = \"/gnp;#{sub.name};#{sub.entry_uri}\"\n params[\"attributes[callback_url]\"] = \"#{callback_server.base_url}#{query}\"\n\n [:operations, :uri_regexp, :condition_script].each do |key|\n (v = sub.send key) and params[\"attributes[#{key}]\"] = v\n end\n\n url = \"#{@target_url}#{sub.uri}.xml\"\n http_put(url, params) # {|req| req.content_type = 'application/xml'}\n end\n end", "def publish_change event\n send :invalidate_role_cache! if event == :roles\n event_manager.publish_change event, :from => self\n end", "def notifications\n end", "def broadcast message\n @clients.keys.each do |key|\n notify key, message\n end\n end", "def broadcast_messages\n @info = ['Gol', 'Zmiana','Żółta Kartka','Druga Żółta Kartka','Czerwona Kartka',]\n end", "def notify_collections *updates\n @collections.each {|coll| instance_variable_get(\"@#{coll}\").notify_members *updates }\n end", "def sync_scopes(related_records, record, filtering = true)\n #related_records = related_records.intersection([*@collection])\n related_records = in_this_collection(related_records) if filtering\n live_scopes.each { |scope| scope.sync_scopes(related_records, record, filtering) }\n notify_of_change unless related_records.empty?\n ensure\n @pre_sync_related_records = nil\n end", "def subscribers\n AdminNotifier.subscribers(Subscriber.first)\n end", "def pubsub; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def relatedrequests \n @requests = User.get_myblood_requests(current_user.blood_type) \n current_user.update_attribute(:notifications , 0) \n end", "def configure_membership(*args)\n new_membership = [args[0]].flatten\n\n new_membership.each do |new_m|\n unless @membership.include?(new_m)\n OmfCommon.comm.subscribe(new_m) do |t|\n if t.error?\n warn \"Group #{new_m} disappeared\"\n #EM.next_tick do\n # @membership.delete(m)\n #end\n else\n self.synchronize do\n @membership << new_m\n @membership_topics[new_m] = t\n self.inform(:status, { membership: @membership }, t)\n end\n\n t.on_message(nil, @uid) do |imsg|\n process_omf_message(imsg, t)\n end\n end\n end\n end\n end\n @membership\n end", "def update_scopes\n if @old_friendly_id != friendly_id\n friendly_id_config.child_scopes.each do |klass|\n Slug.all(:sluggable_type => klass, :scope => @old_friendly_id).update(:scope => friendly_id)\n end\n end\n end", "def send_email_changed_notification?; end", "def notify\n puts 'Subject: Notifying observers...'\n @observers.each { |observer| observer.update(self) }\n end", "def subscribe_to_updates\n if @subscription = @requestor.find_or_create_subscriptions(@target.id)\n @subscription.update_attributes(blocked: false) if @subscription.blocked?\n render json: { success: true }\n else\n render json: {message: @subscription.errors&.full_messages || 'Unable to subscriber updates, please try again'}, status: 202\n end\n end", "def send_mail_to_associates\n user = self.matter_people.assignee\n if(@is_changed && user && User.current_user!=user)\n send_notification_to_responsible(user,self,User.current_user)\n @is_changed = false\n\n true\n end\n end", "def broadcast_update\n broadcast broadcast_event_name(:updated), self, previous_changes\n end", "def subscribed\n stream_from channel_name\n end", "def update_global_common_events\n end", "def subscriptions\n iq = connection.iq_stanza({'to'=>jid.bare},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSubOwner},\n x('subscriptions',:node => node_id)\n )\n )\n send_iq_stanza_fibered iq\n end", "def messaging\n end" ]
[ "0.6172533", "0.6017756", "0.58801055", "0.57497996", "0.56288785", "0.56122017", "0.56122017", "0.56122017", "0.5602712", "0.560242", "0.5525237", "0.55160236", "0.5479672", "0.54576564", "0.54550016", "0.54522467", "0.5431061", "0.54008865", "0.5395308", "0.5381413", "0.53808695", "0.5357198", "0.53538936", "0.53432184", "0.53202987", "0.5274109", "0.5260559", "0.5256963", "0.5254742", "0.5234188", "0.52208835", "0.52060246", "0.52044326", "0.51886886", "0.5170026", "0.51692456", "0.5164912", "0.5164912", "0.5162454", "0.5139676", "0.513032", "0.51174337", "0.51137877", "0.510113", "0.5097179", "0.5095142", "0.5089381", "0.50890744", "0.5082646", "0.5082346", "0.5077572", "0.5077572", "0.50743604", "0.5074318", "0.50740325", "0.50720805", "0.5069366", "0.5066623", "0.5066623", "0.5064312", "0.50606805", "0.50493723", "0.50328124", "0.5032804", "0.50274223", "0.50274223", "0.5021902", "0.5017403", "0.50001895", "0.49967", "0.49959493", "0.49886224", "0.49878523", "0.49799392", "0.4958711", "0.4954472", "0.4952888", "0.49520713", "0.49510473", "0.49510473", "0.49510473", "0.49510473", "0.49510473", "0.49510473", "0.49510473", "0.49510473", "0.49510473", "0.49510473", "0.4950656", "0.49403802", "0.49355137", "0.49328253", "0.492986", "0.49288708", "0.49168682", "0.4916052", "0.49140844", "0.49094594", "0.49078566", "0.49051586" ]
0.6065538
1
subscribe to record changes
def subscribe_record(record) return unless session.id Hyperloop.redis_instance.hset "HRPS__#{record.class}__#{record.id}", session.id.to_s, Time.now.to_f.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pub_sub_record(record)\n subscribe_record(record)\n publish_record(record)\n end", "def set_record_updates_event(record)\n # Decide if this is a new or updated record. Check both id_changed? and save_change_to_id? since we can't be sure\n # if we'll be in an after_save or after_commit callback\n new_rec = record.id_changed? || record.saved_change_to_id?\n rec_type = \"#{new_rec ? 'created' : 'updated'} #{ModelReference.record_type_to_ns_table_name(record.class).humanize.downcase}\"\n\n self.protocol_event = Rails.cache.fetch \"record_updates_protocol_events_#{sub_process.id}_#{rec_type}\" do\n sub_process.protocol_events.where(name: rec_type).first\n end\n\n return if protocol_event\n\n raise \"Bad protocol_event (#{rec_type}) for tracker #{record}. If you believe it should exist, \"\\\n 'check double spacing is correct in the definition for namespaced classes.'\n end", "def subscribed; end", "def recordOn()\n @record = true ;\n end", "def track_record_update\n true\n end", "def subscribe!\n # TODO: Implement\n end", "def on_data_changed; end", "def subscribe\n self.subscribed = true\n end", "def subscribe_sql_active_record=(_arg0); end", "def notify_will_change!\n collection_will_change!\n forward \"#{@key}_will_change!\"\n end", "def recording_changes(attributes={}, &block)\n self.cache_recordable_attributes!\n yield\n self.write_changes!(attributes)\n end", "def track_external_change(app_id, action, document)\n return unless Conf.redis\n Conf.redis.rpush(\"#{KEYS[:changes]}-#{app_id}\", MultiJson.encode([action, document]))\n end", "def publish_record(record)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record.class}__#{record.id}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n\n message = {\n record_type: record.class.to_s,\n id: record.id,\n updated_at: record.updated_at\n }\n message[:destroyed] = true if record.destroyed?\n\n Rails.logger.debug \"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\"\n\n Rails.logger.debug \"========================================== SUBSCRIBERS ================ #{subscribers}\"\n Rails.logger.debug \"=========================================== SUBSCRIBERS SIZE =============== #{subscribers.size}\"\n\n\n # can only trigger to max 10 channels at once on pusher\n subscribers.each_slice(10) do |slice|\n Rails.logger.debug \"========================================================== EACH SLICE !\"\n Rails.logger.debug \"=============================================SLICE============= #{slice}\"\n Rails.logger.debug \"=============================================SLICE SIZE============= #{slice.size}\"\n channel_array = []\n slice.each do |session_id, last_requested|\n\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{record.class}__#{record.id}\", session_id)\n next\n end\n Rails.logger.debug \"========================================================== SESSION ID : #{session_id} !\"\n Rails.logger.debug \"========================================================== RECORD CLASS : #{record.class} !\"\n Rails.logger.debug \"========================================================== RECORD ID : #{record.id} !\"\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n Rails.logger.debug \"========================================================== CHANNEL ARRAY #{channel_array} !\"\n\n if channel_array.size > 0\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n Rails.logger.debug \"========================================================== PUSHER #{channel_array} !\"\n\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n Rails.logger.debug \"========================================================== BROADCAST #{channel} !\"\n\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n\n end\n Hyperloop.redis_instance.del(\"HRPS__#{record.class}__#{record.id}\") if record.destroyed?\n end", "def changes\n poll(\"Changes\")\n end", "def save_changes_from(record)\n self.save_base_attributes(record)\n if record.new_record?\n self.log_type = \"created\"\n end\n self.extract_changes_from(record)\n end", "def after_update_save(record); end", "def subscribe\n \nend", "def send_update\n changed\n notify_observers(self)\n end", "def process\n changed\n notify_observers(@pointer)\n @pointer\n end", "def notify\n changed(true)\n notify_observers(self)\n end", "def subscribe_sql_active_record; end", "def did_update\n trigger_events(:update)\n end", "def observer\n Observer.for_db(self)\n end", "def track_change(record, column_name, count)\n @changes_holder << {\n :entity => relation_class.name,\n relation_class.primary_key.to_sym => record.send(relation_class.primary_key),\n :what => column_name,\n :wrong => record.send(column_name),\n :right => count\n }\n end", "def subscribed # :doc:\n # Override in subclasses\n end", "def on_change(&block)\n self.tracked = true\n notify do\n block.call(read)\n end\n end", "def changes\n SQLite::API.changes( @handle )\n end", "def channel\r\n @record\r\n end", "def on_change (&block)\n debug \"Somebody bound to me\"\n @change_observers << block\n end", "def on_update(req)\n res = @data_sources.collect do |name, table|\n {:stream => name, :events => table.rows}\n end\n [res.to_json, \"text/json\"]\n end", "def subscriptions; end", "def subscriptions; end", "def subscriptions; end", "def after_update(record)\n contents = to_sql_update(record)\n to_logfile(contents)\n end", "def association_changed(record)\n\t\ttouch if persisted?\n\tend", "def changed_and_notify(*args)\n changed\n notify_observers(*args)\n end", "def handle_update\n navdata = connection.receive_data\n publish(event_topic_name(\"update\"), navdata)\n end", "def on_update; end", "def refresh!\n records true\n self\n end", "def engine_notify_datas_updated(datas_updated)\n end", "def record_updated(record)\n return unless geo_file?(record)\n publish_message(\n message(\"UPDATED\", record)\n )\n end", "def subscribes?(record, **args)\n subscriber(record, **args).present?\n end", "def on_change(&block)\n @change_listener = block\n end", "def before_update_save(record); end", "def record; end", "def record; end", "def record; end", "def extract_changes_from(record)\n self.changed_keys ||= record.changed\n self.filter_attributes(record)\n self.old_values ||= Hash.new\n self.new_values ||= Hash.new\n record.changed.each do |key|\n self.old_values[key] = record.changes[key.to_s].try(:first)\n self.new_values[key] = record.changes[key.to_s].try(:last)\n end\n self.changed_keys\n end", "def after_save\n unless destroyed_by_association\n touch_subscriptions if saved_change_to_unread_entries?\n end\n end", "def recording_on()\n update({:recording_enabled => true})\n reload()\n end", "def notify(method, record, *args)\n # This technique of notifying observers is much less than ideal.\n # Unfortunately, ActiveRecord only allows the record to be passed into\n # Observer methods. As a result, it's not possible to pass in the\n # from state, to state, and other contextual information for the\n # transition.\n record.class.class_eval do\n @observer_peers.dup.each do |observer|\n observer.send(method, record, *args) if observer.respond_to?(method)\n end if defined?(@observer_peers)\n end\n end", "def autolog_updated\n autolog_event(:updated)\n end", "def record\n\n end", "def event_change\n\t\n\tend", "def after_subscribe(subscribed)\n # not required\n end", "def notify_change(method, *args)\n changed\n notify_observers(method, self, *args)\n end", "def on_track_change\n # XXXMLG implement\n end", "def changed_and_notify_observers(data)\n unless @generating_resume_template\n changed\n notify_observers([data, session, current_user])\n end\n end", "def send_kafka_event_on_update\n return unless self.class.kafka_config[:update]\n\n producers = self.class.kafka_producers\n fields = producers.flat_map(&:watched_attributes).uniq\n fields -= ['updated_at']\n # Only send an event if a field we care about was changed.\n any_changes = fields.any? do |field|\n field_change = self.previous_changes[field]\n field_change.present? && field_change[0] != field_change[1]\n end\n return unless any_changes\n\n producers.each { |p| p.send_event(self) }\n end", "def stripe_customer_subscription_updated(event, req)\n subscription = event['data']['object']\n subs = Lynr::Model::Subscription.new({\n canceled_at: subscription['canceled_at'],\n plan: subscription['plan']['id'],\n status: subscription['status'],\n })\n dealership = dealer_dao.get_by_customer_id(subscription['customer']).set('subscription' => subs)\n dealer_dao.save(dealership)\n end", "def StreamDataUpdated(stream, table_name, id, rec)\n @ole._invoke(3, [stream, table_name, id, rec], [VT_BYREF|VT_DISPATCH, VT_BSTR, VT_I8, VT_BYREF|VT_DISPATCH])\n end", "def record_change_notification=(value)\n @children['record-change-notification'][:value] = value\n end", "def record(record)\n @db.save_doc(record)\n end", "def subscribe\n debug [self.name, \"incoming\"]\n subscribe_request\n end", "def push_new_record(record)\n handle_couch_response do\n RestClient.post(local_couch_database_url, record, content_type: :json)\n end\n end", "def <<(record)\n @records << record\n end", "def <<(record)\n @records << record\n end", "def watch\n\nend", "def save_changed\n save changed: true\n end", "def subscribed\n super\n increase_current_users\n stream_from channel\n end", "def observe\n Observable.new(super)\n end", "def run_on_changes(_)\n restart\n end", "def save!\n if new_record?\n self.class.create(@conn_id, @id, :subscription => subscribed?)\n @changed = []\n @new_record = false\n elsif changed?\n new_path = (location_changed?) ? @location.path : nil\n new_subscription = (subscription_changed?) ? subscribed? : nil\n \n self.class.update(@conn_id, @id, :path => new_path, :subscription => new_subscription)\n @id = @location.path\n @changed = []\n @new_record = false\n end\n \n self\n end", "def on_inc\n end", "def subscribe\n @player.subscribe(self)\n end", "def after_save(record)\n \n end", "def watch_for_set; end", "def register_events\n EventReactor.sub(:trade_cleared, &method(:log_trade_cleared))\n EventReactor.sub(:round_change, &method(:log_round_change))\n end", "def notify\n @observers.each { |observer| observer.update }\nend", "def object_updated(object)\n notify\n end", "def collection_updated(object, result)\n key = object.key\n if result\n parent_add(key, object)\n object.subscribe(self)\n else\n object.unsubscribe(self)\n parent_delete(object)\n end\n end", "def call_change_listeners\n change_listeners.each do |listener|\n listener.call(self)\n end\n end", "def emit record\n $stdout.puts(record.to_s)\n end", "def remote_update(*)\n super(changed)\n end", "def link!(record)\n event = event_store.read.stream(record.stream_name).forward.first\n\n event_store.link(\n event.event_id,\n stream_name: stream_name\n )\n end", "def capture_serialisation_changes\n serialiser = ActiveModel::Serializer.serializer_for(self)\n if self.id\n before = serialiser.new(self.clone.reload).attributes\n action = :updated\n else\n before = {}\n action = :created\n end\n\n GorgRabbitmqNotifier.batch do\n yield\n\n after = serialiser.new(self).attributes\n changes = deep_hash_diff(before, after)\n send_rabbitmq_notification(action, changes)\n end\n end", "def notify\n @subscribers.each { |ident, (block,obj)| block.call(obj) }\n end", "def record_update(force = nil)\n paper_trail.record_update(force)\n end", "def on_change(value)\n \n end", "def updated_data; end", "def history_added; end", "def run_subscribe(conn, dest)\n return if not @need_subscribe\n @log.debug \"run_subscribe starts\"\n conn.subscribe(dest) # call hook\n @log.debug \"run_subscribe done\"\n @need_subscribe = false\n @need_gets = true\nend", "def inform_obeservers\n\t\[email protected] { |observer| observer.update(self) }\n\tend", "def chore_collect chore_info\n @@data_collector.notify chore_info\n end", "def unsubscribed; end", "def subscribe\n @conn.send_data :opcode => SUBSCRIBE, :channel => @name\n @subscribe_sent = true\n end", "def listen \n response.headers[\"Content-Type\"] = \"text/event-stream\"\n redis = Redis.new\n\n key = \"/node/#{params[:event_id]}:change\"\n logger.info \"listen #{key}\"\n redis.subscribe(key) do |on|\n on.message do |event, data|\n response.stream.write \"event: update\\n\"\n response.stream.write \"data: \"+data+\"\\n\\n\"\n end\n end\n\n rescue IOError \n # Client disconnected\n ensure \n response.stream.close\n end", "def atomic_updates(*args)\n r = super(*args)\n if @records\n (r['$set'] ||= {})['records'] = serialize_records\n end\n r\n end", "def on_change(name = nil, recursive = false, &block)\n attach\n name = name.to_s if name\n @observers[name] << Observer.new(recursive, block)\n self\n end", "def notify_subscribers(resource)\n resource.subscriptions.each do |subscription|\n http = EM::HttpRequest.new(subscription.url).post(:body => {:data => resource.body})\n http.callback{ |response|\n puts \"POSTed updated data for #{resource.url}, #{resource.body.length} characters\"\n }\n http.errback {|response|\n # Do something here, maybe setting the resource\n # to be not checked anymore.\n }\n end\n end" ]
[ "0.66672933", "0.64204484", "0.63560516", "0.63188434", "0.63057363", "0.60260856", "0.6025094", "0.60176605", "0.59979624", "0.59496295", "0.59261155", "0.5910179", "0.5892779", "0.5877025", "0.58698833", "0.5866101", "0.58280426", "0.58155584", "0.578312", "0.5760717", "0.5747287", "0.5722755", "0.5701171", "0.56849134", "0.5680784", "0.5674229", "0.56409574", "0.563471", "0.5622605", "0.5619976", "0.56109315", "0.56109315", "0.56109315", "0.55865204", "0.55320394", "0.55268824", "0.5522982", "0.54822385", "0.54802203", "0.5474291", "0.547401", "0.5459498", "0.5444925", "0.54404336", "0.542986", "0.542986", "0.542986", "0.5423522", "0.54100055", "0.54068595", "0.54006535", "0.5395908", "0.5394375", "0.53920746", "0.5363651", "0.53630453", "0.53470016", "0.53397244", "0.5332773", "0.53286684", "0.5316101", "0.52994287", "0.52901214", "0.5270404", "0.52687186", "0.52530134", "0.52530134", "0.5251535", "0.5248766", "0.5241259", "0.52410764", "0.5240894", "0.52363133", "0.52345675", "0.5222824", "0.5221515", "0.5213993", "0.520077", "0.5194742", "0.5185883", "0.51806253", "0.5179911", "0.5170793", "0.5170257", "0.5164373", "0.5157686", "0.5141444", "0.51288044", "0.51203686", "0.5112175", "0.5110172", "0.5106741", "0.5099539", "0.50954247", "0.50890064", "0.50834924", "0.5077416", "0.5062586", "0.5061292", "0.50593567" ]
0.67444456
0
subscribe to relation changes
def subscribe_relation(relation, base_record = nil, relation_name = nil) return unless session.id time_now = Time.now.to_f.to_s session_id = session.id.to_s Hyperloop.redis_instance.pipelined do if relation.is_a?(Enumerable) # has_many relation.each do |record| Hyperloop.redis_instance.hset("HRPS__#{record.class}__#{record.id}", session_id, time_now) end elsif !relation.nil? # has_one, belongs_to Hyperloop.redis_instance.hset("HRPS__#{relation.class}__#{relation.id}", session_id, time_now) end Hyperloop.redis_instance.hset("HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}", session_id, time_now) if base_record && relation_name end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subscribed; end", "def subscribed # :doc:\n # Override in subclasses\n end", "def pub_sub_relation(relation, base_record, relation_name, causing_record = nil)\n subscribe_relation(relation, base_record, relation_name)\n publish_relation(base_record, relation_name, causing_record)\n end", "def subscribe\n self.subscribed = true\n end", "def subscriptions; end", "def subscriptions; end", "def subscriptions; end", "def notify_will_change!\n collection_will_change!\n forward \"#{@key}_will_change!\"\n end", "def notify\n changed(true)\n notify_observers(self)\n end", "def subscribe!\n # TODO: Implement\n end", "def after_subscribe(subscribed)\n # not required\n end", "def after_save\n unless destroyed_by_association\n touch_subscriptions if saved_change_to_unread_entries?\n end\n end", "def relation_added(issue)\n journalize_action(\n :property => 'relation',\n :prop_key => 'relates',\n :value => issue.try(:id)\n )\n end", "def notify_subscribers\n NotificationSubscription.notify(self)\n end", "def association_changed(record)\n\t\ttouch if persisted?\n\tend", "def collection_updated(object, result)\n key = object.key\n if result\n parent_add(key, object)\n object.subscribe(self)\n else\n object.unsubscribe(self)\n parent_delete(object)\n end\n end", "def subscribe\n \nend", "def unsubscribed; end", "def subscribed\n super\n increase_current_users\n stream_from channel\n end", "def changed_and_notify(*args)\n changed\n notify_observers(*args)\n end", "def send_update\n changed\n notify_observers(self)\n end", "def before_query(query)\n if query.subscription? && !query.subscription_update?\n query.context.namespace(:subscriptions)[:events] = []\n end\n end", "def do_subscribe\n subscribe_to(@nodename)\n get_subscriptions\n end", "def subscribers\r\n @subscribers.clone\r\n end", "def update_from_relation(field_name, related = Ladder::Config.settings[:with_relations])\n objects = send(field_name).to_a\n\n if related || embedded_relations[field_name]\n # Force autosave of related documents to ensure correct serialization\n methods.select { |i| i[/autosave_documents/] }.each { |m| send m }\n\n # update inverse relation properties\n relation = relations[field_name]\n objects.each { |object| object.resource.set_value(relation.inverse, rdf_subject) } if relation.inverse\n objects.map(&:update_resource)\n else\n # remove inverse relation properties\n objects.each { |object| resource.delete [object.rdf_subject] }\n objects.map(&:rdf_subject)\n end\n end", "def subscribe\n\t if !self_owned? && !subscribed?\n\t\towners.each do |peer|\n\t\t peer.subscribe(self) unless peer.subcribed?(self)\n\t\tend\n\t end\n\tend", "def update_relation(plan, m_from, op, m_to, m_rel, m_info = nil)\n\t\tif plan\n\t\t Roby::Distributed.update(peer.local_object(plan)) { update_relation(nil, m_from, op, m_to, m_rel, m_info) }\n\t\telse\n\t\t from, to = \n\t\t\tpeer.local_object(m_from, false), \n\t\t\tpeer.local_object(m_to, false)\n\n\t\t if !from\n\t\t\treturn unless to && (to.self_owned? || to.subscribed?)\n\t\t\tfrom = peer.local_object(m_from)\n\t\t elsif !to\n\t\t\treturn unless from && (from.self_owned? || from.subscribed?)\n\t\t\tto = peer.local_object(m_to)\n\t\t end\n\n\t\t rel = peer.local_object(m_rel)\n\t\t Roby::Distributed.update_all([from.root_object, to.root_object]) do\n\t\t\tif op == :add_child_object\n\t\t\t from.add_child_object(to, rel, peer.local_object(m_info))\n\t\t\telsif op == :remove_child_object\n\t\t\t from.remove_child_object(to, rel)\n\t\t\tend\n\t\t end\n\t\tend\n\t\tnil\n\t end", "def subscribers\n AdminNotifier.subscribers(Subscriber.first)\n end", "def observer\n Observer.for_db(self)\n end", "def publish_relation(base_record, relation_name, record = nil)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: base_record.class.to_s,\n id: base_record.id,\n updated_at: base_record.updated_at,\n relation: relation_name\n }\n if record\n message[:cause] = {}\n message[:cause][:record_type] = record.class.to_s\n message[:cause][:id] = record.id\n message[:cause][:updated_at] = record.updated_at\n message[:cause][:destroyed] = true if record.destroyed?\n end\n subscribers.each_slice(10) do |slice|\n channel_array = []\n slice.each do |session_id, last_requested|\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}\", session_id)\n next\n end\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n end", "def relation\n Proxy\n end", "def relation\n Proxy\n end", "def relation\n Proxy\n end", "def show_subscriptions\n puts \"\\nYour current subscriptions are:\"\n @user.subscriptions.reload.each do |sub|\n puts sub.name\n end\n end", "def subscribe(object)\n while object.respond_to?(:__getobj__)\n object = object.__getobj__\n end\n\n if remote_object = (remote_object(object) rescue nil)\n if !subscriptions.include?(remote_object)\n remote_object = nil\n end\n end\n\n unless remote_object\n remote_sibling = object.sibling_on(self)\n remote_object = call(:subscribe, remote_sibling)\n synchro_point\n end\n local_object = local_object(remote_object)\n end", "def subscribe_owner\n\t subscription = owner.subscribe_to(activity_feed)\n\t subscription.save\n\t end", "def changes\n poll(\"Changes\")\n end", "def clear_relations\n each_event { |ev| ev.clear_relations }\n\t super()\n self\n\tend", "def relations\n _relations\n end", "def relations\n _relations\n end", "def affect_relation_values!\n Relations.new(@klass).affect_relation_values!\n end", "def notify_subscribers(resource)\n resource.subscriptions.each do |subscription|\n http = EM::HttpRequest.new(subscription.url).post(:body => {:data => resource.body})\n http.callback{ |response|\n puts \"POSTed updated data for #{resource.url}, #{resource.body.length} characters\"\n }\n http.errback {|response|\n # Do something here, maybe setting the resource\n # to be not checked anymore.\n }\n end\n end", "def object_updated(object)\n notify\n end", "def notify_change(method, *args)\n changed\n notify_observers(method, self, *args)\n end", "def subscribe_sql_active_record; end", "def subscribe\n @player.subscribe(self)\n end", "def notify_subscribers\n AdminMailer.notify_of_standard_change(self)\n end", "def update_subscription\n # Only change the subscription if the models email\n # address has been changed.\n self.class.list_manager.update_subscription(self.email_was, self.email, campaignable_additional_fields) if self.email_changed?\n end", "def related_to(*args)\n@relations = args.map(&:to_s)\nend", "def after_update\n super\n touch_associations\n end", "def subscribe_author\n self.subscriptions.create user_id: self.user.id\n end", "def update!(**args)\n @relation = args[:relation] if args.key?(:relation)\n end", "def observe\n Observable.new(super)\n end", "def relations\n self.class.relations\n end", "def unsubscribed # :doc:\n # Override in subclasses\n end", "def notify\n @subscribers.each { |ident, (block,obj)| block.call(obj) }\n end", "def inform_obeservers\n\t\[email protected] { |observer| observer.update(self) }\n\tend", "def notify\n puts 'Subject: Notifying observers...'\n @observers.each { |observer| observer.update(self) }\n end", "def changes_applied!\n # find all fields that are of type :array\n fields(:array) do |key, v|\n proxy = send(key)\n # clear changes\n proxy.changes_applied! if proxy.respond_to?(:changes_applied!)\n end\n\n # for all relational fields,\n relations.each do |key, v|\n proxy = send(key)\n # clear changes if they support the method.\n proxy.changes_applied! if proxy.respond_to?(:changes_applied!)\n end\n changes_applied\n end", "def notify\n @observers.each { |observer| observer.update }\nend", "def prepare_to_change_association(object)\n name = association_name(object)\n send(\"#{name}_will_change!\")\n end", "def websocket_update\n UpdatesChannel.broadcast_to(user, {loadModels: [self.to_jsonapi]})\n end", "def on_data_changed; end", "def unsubscribe!\n self.unsubscribed = true\n save\n end", "def child_relation; end", "def toggle_subscription!\n self.unsubscribed = !unsubscribed\n save\n end", "def subscriptions\n @subscriptions ||= {}\n end", "def push_subscription(object)\n local_server.subscribe(object)\n synchro_point\n end", "def notify_observers(*args)\n return unless changed?\n\n unwrap(connection).exec \"NOTIFY #{channel}, #{args}\"\n\n changed false\n end", "def remote_update(*)\n super(changed)\n end", "def relation\n raise NotImplementedError\n end", "def get_subscribers\n @subscriptions = subscribers(@nodename)\n end", "def relations\n @relations ||= process_rels\n end", "def unsubscribed\n end", "def unsubscribed\n end", "def subscribe_sql_active_record=(_arg0); end", "def apply_event_subscription\n @dispatcher.subscribe_event(event_subscription)\n end", "def changed\n _find_changed_twins!(@_changes)\n\n @_changes\n end", "def update!(**args)\n @relation_descriptor = args[:relation_descriptor] if args.key?(:relation_descriptor)\n end", "def relations\n @relations ||= {}\n end", "def association_changeset(name)\n association = self.item.send(name)\n # association = association.source if association.decorated?\n\n self.changeset_class(association).new(association, self.data['associations'].fetch(name.to_s).try(:fetch, 'changes'))\n end", "def unsubscribed\n super\n # TODO: abort any pending lookup requests\n end", "def chore_collect chore_info\n @@data_collector.notify chore_info\n end", "def run_subscribe(conn, dest)\n return if not @need_subscribe\n @log.debug \"run_subscribe starts\"\n conn.subscribe(dest) # call hook\n @log.debug \"run_subscribe done\"\n @need_subscribe = false\n @need_gets = true\nend", "def publish_change event\n send :invalidate_role_cache! if event == :roles\n event_manager.publish_change event, :from => self\n end", "def create / update_subscriptions\n end", "def subscribe(&callback)\n @parent_callback = callback\n end", "def handle_update\n navdata = connection.receive_data\n publish(event_topic_name(\"update\"), navdata)\n end", "def history_relation_object(attribute)\n @history_relation_object = attribute\n end", "def association_changed?(associtaion_name) # :nodoc:\n raise 'Not implemented!'\n end", "def notify_observers\n\t\[email protected] do |observer|\n\t\t\tobserver.update(self)\n\t\tend\n\tend", "def subscribe\n # PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", \"http://li182-172.members.linode.com/feeds/#{self.id}\", \"async\")\n PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", self.url, \"async\")\n end", "def unsubscribed\n\tend", "def subscribeTo (event)\r\n @subscribedEvents.add(event)\r\n end", "def notify activity\n\n # people who are subscribed directly to the question\n q_subscribers = self.subscribers.all\n\n # people who are subscribed to the tags of the question\n t_subscribers = self.tag_subscribers.all\n\n (q_subscribers + t_subscribers).each do |subscriber|\n Notification.create :user => subscriber, :activity => activity\n end\n end", "def process\n changed\n notify_observers(@pointer)\n @pointer\n end", "def relation_removed(issue)\n journalize_action(\n :property => 'relation',\n :prop_key => 'relates',\n :old_value => issue.try(:id)\n )\n end", "def call_change_listeners\n change_listeners.each do |listener|\n listener.call(self)\n end\n end", "def websocket_update\n json = self.to_jsonapi\n watching_users.each do |user|\n UpdatesChannel.broadcast_to(user, {loadModels: [json]})\n end\n end", "def add_subscription(entity)\r\n subscriptions << entity\r\n end" ]
[ "0.6452602", "0.63099724", "0.6271999", "0.62322664", "0.60561633", "0.60561633", "0.60561633", "0.59896386", "0.5831739", "0.57834697", "0.57805717", "0.57313323", "0.5665741", "0.5652396", "0.562503", "0.5591842", "0.55822545", "0.5582072", "0.55687624", "0.5521885", "0.549266", "0.5486207", "0.5424925", "0.54213524", "0.53851223", "0.5378994", "0.53601646", "0.5337833", "0.5322967", "0.5318858", "0.5301849", "0.5301849", "0.5301849", "0.5276203", "0.5273069", "0.5262096", "0.5259764", "0.5246065", "0.52403104", "0.52403104", "0.523102", "0.52275646", "0.5216836", "0.5199175", "0.51967597", "0.51935333", "0.51894987", "0.5178686", "0.5173733", "0.5131673", "0.51311195", "0.51288724", "0.51214117", "0.5109931", "0.51096004", "0.5107622", "0.51068926", "0.51037264", "0.50952315", "0.5091506", "0.5078042", "0.50670546", "0.5059595", "0.5044714", "0.50441486", "0.5038622", "0.50369954", "0.5031271", "0.503121", "0.50287855", "0.50216603", "0.50207233", "0.50193775", "0.501913", "0.501913", "0.50070417", "0.5002222", "0.49984133", "0.49928942", "0.49886224", "0.49839675", "0.49814183", "0.49809682", "0.4976463", "0.49737626", "0.4972405", "0.49721688", "0.49680376", "0.49678177", "0.49664944", "0.49609938", "0.4952394", "0.4928234", "0.49252492", "0.4923216", "0.4923154", "0.49158603", "0.49122298", "0.49106404", "0.49097466" ]
0.60393786
7
subscribe to rest_class_method updates
def subscribe_rest_class_method(record_class, rest_class_method_name) return unless session.id time_now = Time.now.to_f.to_s session_id = session.id.to_s Hyperloop.redis_instance.pipelined do Hyperloop.redis_instance.hset("HRPS__#{record_class}__rest_class_method_name__#{rest_class_method_name}", session_id, time_now) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pub_sub_rest_class_method(record_class, rest_class_method_name)\n subscribe_rest_class_method(record_class, rest_class_method_name)\n publish_rest_class_method(record_class, rest_class_method_name)\n end", "def publish_rest_class_method(record_class, rest_class_method_name)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: record_class.to_s,\n rest_class_method: rest_class_method_name\n }\n subscribers.each_slice(10) do |slice|\n channel_array = []\n slice.each do |session_id, last_requested|\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}\", session_id)\n next\n end\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n end", "def pub_sub_rest_method(record, rest_method_name)\n subscribe_rest_method(record, rest_method_name)\n publish_rest_method(record, rest_method_name)\n end", "def subscribe_rest_method(record, rest_method_name)\n return unless session.id\n time_now = Time.now.to_f.to_s\n session_id = session.id.to_s\n Hyperloop.redis_instance.hset(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\", session_id, time_now)\n end", "def publish_rest_method(record, rest_method_name)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: record.class.to_s,\n id: record.id,\n rest_method: rest_method_name\n }\n subscribers.each_slice(10) do |slice|\n channel_array = []\n slice.each do |session_id, last_requested|\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\", session_id)\n next\n end\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n end", "def rest_class_methods\n @rest_class_methods ||= {}\n end", "def subscribed; end", "def subscribe\n \nend", "def subscribe!\n # TODO: Implement\n end", "def subscribe\n self.subscribed = true\n end", "def method_added(*) end", "def rest_endpoint; end", "def notify_subscribers(resource)\n resource.subscriptions.each do |subscription|\n http = EM::HttpRequest.new(subscription.url).post(:body => {:data => resource.body})\n http.callback{ |response|\n puts \"POSTed updated data for #{resource.url}, #{resource.body.length} characters\"\n }\n http.errback {|response|\n # Do something here, maybe setting the resource\n # to be not checked anymore.\n }\n end\n end", "def subscriptions; end", "def subscriptions; end", "def subscriptions; end", "def method_missing(meth, *args, &block)\n @_resource.send(:method_missing, meth, *args, &block)\n end", "def subscribed # :doc:\n # Override in subclasses\n end", "def handle_request( * ) # :nodoc:\n\t\tself.log.debug \"[:restresources] handling request for REST resource.\"\n\t\tsuper\n\tend", "def notify(method, *args)\n @serializer.write([2, method, args])\n self\n end", "def on_success(_klass, _method); end", "def refresh\n puts \" -- refresh subscriptions(#{@subscriptions.size}):\"\n\n run_callback_server # call it once to make sure it runs\n \n @subscriptions.each do |sub| \n puts \" - #{sub.name}\"\n params = { \"attributes[accept]\" => 'application/json' }\n\n query = \"/gnp;#{sub.name};#{sub.entry_uri}\"\n params[\"attributes[callback_url]\"] = \"#{callback_server.base_url}#{query}\"\n\n [:operations, :uri_regexp, :condition_script].each do |key|\n (v = sub.send key) and params[\"attributes[#{key}]\"] = v\n end\n\n url = \"#{@target_url}#{sub.uri}.xml\"\n http_put(url, params) # {|req| req.content_type = 'application/xml'}\n end\n end", "def register_subresource(resource)\n super.tap do |added|\n if added && action_on_update\n Chef::Log.debug(\"[#{self}] Registering #{action_on_update_immediately ? 'immediate ' : ''}#{action_on_update} notification from #{resource}\")\n resource.notifies action_on_update.to_sym, self, (action_on_update_immediately ? :immediately : :delayed)\n end\n end\n end", "def rest_endpoint=(_arg0); end", "def on_refresh(&block)\n @connection.on_refresh_cb = block\n end", "def broadcast_sync(meth, *args)\n @listeners.select { |listener| listener.class.ann(meth, :stem_sync) }.each { |listener| listener.respond meth, *args }\n end", "def on_update; end", "def remote_update(*)\n super(changed)\n end", "def watch_method; end", "def update\n super\n refresh if controller_changed?\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def method_missing(method, *args, &block)\n if _resource.respond_to?(method.to_s)\n result = _resource.send(method, *args, &block)\n result.nil? ? delegate_method(method, *args, &block) : result\n else\n super\n end\n end", "def methods(*args)\n super | rpc_methods\n end", "def subscribe(cls, &block)\n @subscribers[cls.name] = block\n end", "def consume_rest; end", "def booking_callback_refresh\n @booking.refresh!\n end", "def method_missing(method, *args, &block)\n if actions(current_api).include? method\n self.class.send(:define_method, method) do |params|\n perform_soap_call(method, params) || perform_rest_call(params)\n end\n send method, *args, &block\n else\n super\n end\n end", "def method_added(id)\n\t\t\t\t\treset_routing_cache\n\t\t\t\tend", "def after_update(resource)\n add_activity(:update, resource)\n end", "def update_consumer(klass)\n Thread.current[:\"[mongoid][#{klass}]:update-consumer\"]\n end", "def method_added(id)\n\t\t\t\treset_routing_cache\n\t\t\tend", "def reroute_callbacks\n @reroute_callbacks\n end", "def update\n self.publish_json\n end", "def update!(**args)\n @method_match = args[:method_match] if args.key?(:method_match)\n @polling_options = args[:polling_options] if args.key?(:polling_options)\n end", "def method_missing(meth, *args)\n return true if meth.to_s =~ /^observe_/\n super(meth, *args)\n end", "def subscribe\n # PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", \"http://li182-172.members.linode.com/feeds/#{self.id}\", \"async\")\n PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", self.url, \"async\")\n end", "def method_missing(method, *params, &block)\n @endpoint_parts << method.to_s\n\n @endpoint_parts << params\n @endpoint_parts = @endpoint_parts.flatten!\n\n block&.call\n\n self || super\n end", "def resource_updated(resource, action)\n updates << [ resource, action ]\n end", "def update\n super\n @observing_procs.values.each { |block| block.call(item) }\n end", "def method_added(name)\n super(name) if defined?(super)\n published(name) if @publishing\n end", "def method_missing(method, *args, &block) #:doc:\n super unless @wsdl.respond_to? method\n\n setup method, &block\n dispatch method\n end", "def public_class_method(*rest) end", "def subscribe\n debug [self.name, \"incoming\"]\n subscribe_request\n end", "def refresh\n raise Occi::Api::Client::Errors::NotImplementedError, \"#{__method__} is just a stub!\"\n end", "def register_rest(handler, &block)\n @register_rest ||= (handler || block)\n end", "def listen(klass, *args)\n supervise klass, name, handlers, *args\n end", "def rest_end_point; end", "def after_subscribe(subscribed)\n # not required\n end", "def poll_req\n super # placeholder so that I can add some doc\n end", "def update\n # actions\n path = URI(@endpoint).path\n action = URI(@req.request_uri).path.sub(path, '').split('/')\n action -= ['']\n if action.include?('_history')\n @actions = [action[0], '_history']\n else\n @actions = [action[0]]\n end\n\n # search param\n req_query = URI(@req.request_uri).query\n unless req_query.nil?\n @req_params = URI::decode_www_form(req_query).to_h\n end\n\n # requst method\n if @req.request_method == \"GET\" and @actions.include? '_history'\n @req_method = 'vread'\n elsif @req.request_method == \"GET\" and @req_params != nil\n @req_method = 'search-type'\n elsif @req.request_method == \"PUT\"\n @req_method = 'update'\n elsif @req.request_method == \"POST\"\n @req_method = 'create'\n else\n @req_method = 'read'\n end\n\n # interaction\n int1 = Interaction.last type: @actions[0], code: @req_method\n if int1.nil?\n @present = 0\n else\n @present = int1.id\n @intCode = int1.valueCode\n end\n end", "def send_update\n changed\n notify_observers(self)\n end", "def on_subscription_success\n end", "def method_added(method)\n return unless @current_doc_link\n\n @doc_urls ||= {}\n @doc_urls[method] = @current_doc_link\n\n # Prevent infinite recursion on define_method below\n @current_doc_link = nil\n\n alias_method \"old_#{method}\".to_sym, method\n\n define_method(method) do |*args|\n begin\n send(\"old_#{method}\", *args)\n rescue Exception => e\n msg = e.message + \"\\n\\nPlease refer to this URL for additional information on this API call:\\n#{self.class.api_docs(method)}\\n\" \n raise e, msg, e.backtrace\n end\n end\n end", "def object_updated(object)\n notify\n end", "def methods\n main_service.methods.select(&:can_generate_rest?)\n end", "def method_missing(method, *args)\n api_obj.send(method, *args)\n end", "def rest_class_method(name, options = { default_result: '...' })\n rest_class_methods[name] = options\n # @!method promise_[name]\n # @return [Promise] on success the .then block will receive the result of the RPC call as arg\n # on failure the .fail block will receive the HTTP response object as arg\n define_singleton_method(\"promise_#{name}\") do |*args|\n name_args = _name_args(name, *args)\n _class_fetch_states[name_args] = 'i'\n rest_class_methods[name_args] = { result: options[:default_result] } unless rest_class_methods.has_key?(name_args)\n _promise_get_or_patch(\"#{resource_base_uri}/methods/#{name}.json?timestamp=#{`Date.now() + Math.random()`}\", *args).then do |response_json|\n rest_class_methods[name_args][:result] = response_json[:result] # result is parsed json\n _class_fetch_states[name_args] = 'f'\n _notify_class_observers\n rest_class_methods[name_args][:result]\n end.fail do |response|\n error_message = \"#{self.to_s}.#{name}, a rest_method, failed to execute!\"\n `console.error(error_message)`\n response\n end\n end\n # @!method [name]\n # @return result either the default_result ass specified in the options or the real result if the RPC call already finished\n define_singleton_method(name) do |*args|\n name_args = _name_args(name, *args)\n _register_class_observer\n rest_class_methods[name_args] = { result: options[:default_result] } unless rest_class_methods.has_key?(name_args)\n unless _class_fetch_states.has_key?(name_args) && 'fi'.include?(_class_fetch_states[name_args])\n self.send(\"promise_#{name}\", *args)\n end\n rest_class_methods[name_args][:result]\n end\n # @!method update_[name] mark internal structures so that the method is called again once it is requested again\n # @return nil\n define_singleton_method(\"update_#{name}\") do |*args|\n _class_fetch_states[_name_args(name, *args)] = 'u'\n nil\n end\n end", "def method_added(name); end", "def method_added(name); end", "def on_update(&update_callback)\n @update_callbacks << update_callback\n end", "def notify_change(method, *args)\n changed\n notify_observers(method, self, *args)\n end", "def listeners; end", "def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend", "def handler_method; end", "def update &block\n receive_update_callbacks << block\n end", "def notifications\n end", "def callbacks; end", "def callbacks; end", "def update(*)\n unavailable_method\n end", "def update(*)\n unavailable_method\n end", "def update(*)\n unavailable_method\n end", "def update(*)\n unavailable_method\n end", "def create / update_subscriptions\n end", "def singleton_method_added(*) end", "def listen\n raise NotImplementedError.new(\"Implement listen() in your Invoker. \")\n end", "def delegate_method(method, *args, &block)\n return unless @key && _resource.respond_to?(@key)\n\n @delegate ||= _resource.send(@key)\n return unless @delegate&.respond_to?(method.to_s)\n\n @delegate.send(method, *args, &block)\n end", "def rest_routes\n\t\t\t\t\t[\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :index },\n\t\t\t\t\t\t{ method: :POST, path: '/', action: :create },\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :show },\n\t\t\t\t\t\t{ method: :PUT, path: '/', action: :update },\n\t\t\t\t\t\t{ method: :DELETE, path: '/', action: :delete }\n\t\t\t\t\t]\n\t\t\t\tend", "def method_missing(method_name, *args)\n # TODO: Add permission checking for all updates to the model\n # TODO: Add permission checking for read access?\n\n update = method_name.to_s[-1..-1] == '='\n\n shortcut = if update \n method_name.to_s[0..-2]\n else\n method_name.to_s\n end\n\n # Otherwise, check for the RDF predicate\n registered = N::URI[shortcut.to_s]\n\n return super(method_name, *args) unless(registered) # normal handler if not a registered uri\n raise(ArgumentError, \"Must give a namspace as argument\") unless(registered.is_a?(N::Namespace))\n\n DummyHandler.new(registered, self)\n end", "def when_class_receives(method_name, &block)\n self.class.when_receiving method_name, &block\n end", "def fire_async_response(class_method)\n response_id = AsyncResponse.new_response_id\n ZZ::Async::ConnectorWorker.enqueue(response_id, service_identity.id, self.class.name, class_method, params)\n response.headers[\"x-poll-for-response\"] = async_response_url(response_id)\n render :json => {:message => \"poll-for-response\"}\n end", "def callback\n\n end", "def notify_subscribers\n NotificationSubscription.notify(self)\n end", "def method_missing(*args)\n result = nil\n orig = args.shift\n class_sym = self.class.name.to_sym\n m = orig.to_s[0,5] == '_DAV_' ? orig : \"_DAV_#{orig}\" # If hell is doing the same thing over and over and expecting a different result this is a hell preventer\n raise NoMethodError.new(\"Undefined method: #{orig} for class #{self}.\") unless respond_to?(m)\n @runner.call(class_sym, :before, orig)\n result = send m, *args\n @runner.call(class_sym, :after, orig)\n result\n end", "def method_missing(method_id, *args)\n return super unless @resource.respond_to? method_id\n @resource.public_send method_id, *args\n end", "def method_missing(method_name, *args)\n # TODO: Add permission checking for all updates to the model\n # TODO: Add permission checking for read access?\n \n update = method_name.to_s[-1..-1] == '='\n \n shortcut = if update \n method_name.to_s[0..-2]\n else\n method_name.to_s\n end\n\n # Otherwise, check for the RDF predicate\n registered = N::URI[shortcut.to_s]\n \n return super(method_name, *args) unless(registered) # normal handler if not a registered uri\n raise(ArgumentError, \"Must give a namspace as argument\") unless(registered.is_a?(N::Namespace))\n \n DummyHandler.new(registered, self)\n end", "def rpc(method, arguments)\n\t\t\t# This update might not be sent right away. Therefore, mutable arguments may be serialized to JSON at a later time (or never). This could be a race condition:\n\t\t\[email protected]([method, arguments])\n\t\tend", "def get_changes\n CouchRest.get(SERVER.uri << DB.uri << \"/_changes\")\nend", "def update(resource_type_identifier, mixins)\n raise Occi::Api::Client::Errors::NotImplementedError, \"#{__method__} is just a stub!\"\n end", "def subscribe_to_updates\n if @subscription = @requestor.find_or_create_subscriptions(@target.id)\n @subscription.update_attributes(blocked: false) if @subscription.blocked?\n render json: { success: true }\n else\n render json: {message: @subscription.errors&.full_messages || 'Unable to subscriber updates, please try again'}, status: 202\n end\n end" ]
[ "0.72033644", "0.69221956", "0.67598283", "0.6544552", "0.64317316", "0.62116086", "0.6026355", "0.5926975", "0.5906476", "0.5815818", "0.579933", "0.5780975", "0.5679477", "0.5677518", "0.5677518", "0.5677518", "0.5666928", "0.56605464", "0.5579463", "0.5573429", "0.5549983", "0.55467093", "0.55219364", "0.5521336", "0.5508614", "0.55060524", "0.55041635", "0.5490481", "0.54688865", "0.54534435", "0.54503405", "0.54503405", "0.54320145", "0.542814", "0.5413176", "0.54082274", "0.5407138", "0.5397648", "0.5392516", "0.53901505", "0.53657484", "0.53553545", "0.5344258", "0.533963", "0.533232", "0.5329236", "0.5328813", "0.5327763", "0.532742", "0.53267735", "0.5320779", "0.53091305", "0.5297721", "0.5278622", "0.5268301", "0.5243195", "0.5240042", "0.5237679", "0.52340823", "0.5227055", "0.52264166", "0.52222085", "0.5217663", "0.51998156", "0.51951915", "0.5180773", "0.5180494", "0.51731575", "0.51710165", "0.51710165", "0.5168183", "0.5166234", "0.5166013", "0.5159294", "0.5155404", "0.51509637", "0.51508147", "0.51475716", "0.51475716", "0.514731", "0.5137586", "0.5137586", "0.5137586", "0.51236546", "0.5104018", "0.509509", "0.50911516", "0.507992", "0.50759023", "0.5073413", "0.5060669", "0.5055683", "0.50511706", "0.5050983", "0.5050219", "0.5042753", "0.50415415", "0.5041324", "0.5031228", "0.50312054" ]
0.68422437
2
subscribe to rest_method updates
def subscribe_rest_method(record, rest_method_name) return unless session.id time_now = Time.now.to_f.to_s session_id = session.id.to_s Hyperloop.redis_instance.hset("HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}", session_id, time_now) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pub_sub_rest_method(record, rest_method_name)\n subscribe_rest_method(record, rest_method_name)\n publish_rest_method(record, rest_method_name)\n end", "def publish_rest_method(record, rest_method_name)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: record.class.to_s,\n id: record.id,\n rest_method: rest_method_name\n }\n subscribers.each_slice(10) do |slice|\n channel_array = []\n slice.each do |session_id, last_requested|\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\", session_id)\n next\n end\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n end", "def pub_sub_rest_class_method(record_class, rest_class_method_name)\n subscribe_rest_class_method(record_class, rest_class_method_name)\n publish_rest_class_method(record_class, rest_class_method_name)\n end", "def subscribe\n \nend", "def subscribe!\n # TODO: Implement\n end", "def subscribe_rest_class_method(record_class, rest_class_method_name)\n return unless session.id\n time_now = Time.now.to_f.to_s\n session_id = session.id.to_s\n Hyperloop.redis_instance.pipelined do\n Hyperloop.redis_instance.hset(\"HRPS__#{record_class}__rest_class_method_name__#{rest_class_method_name}\", session_id, time_now)\n end\n end", "def rest_endpoint; end", "def publish_rest_class_method(record_class, rest_class_method_name)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: record_class.to_s,\n rest_class_method: rest_class_method_name\n }\n subscribers.each_slice(10) do |slice|\n channel_array = []\n slice.each do |session_id, last_requested|\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}\", session_id)\n next\n end\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n end", "def subscribed; end", "def notify_subscribers(resource)\n resource.subscriptions.each do |subscription|\n http = EM::HttpRequest.new(subscription.url).post(:body => {:data => resource.body})\n http.callback{ |response|\n puts \"POSTed updated data for #{resource.url}, #{resource.body.length} characters\"\n }\n http.errback {|response|\n # Do something here, maybe setting the resource\n # to be not checked anymore.\n }\n end\n end", "def subscriptions; end", "def subscriptions; end", "def subscriptions; end", "def subscribe\n self.subscribed = true\n end", "def refresh\n puts \" -- refresh subscriptions(#{@subscriptions.size}):\"\n\n run_callback_server # call it once to make sure it runs\n \n @subscriptions.each do |sub| \n puts \" - #{sub.name}\"\n params = { \"attributes[accept]\" => 'application/json' }\n\n query = \"/gnp;#{sub.name};#{sub.entry_uri}\"\n params[\"attributes[callback_url]\"] = \"#{callback_server.base_url}#{query}\"\n\n [:operations, :uri_regexp, :condition_script].each do |key|\n (v = sub.send key) and params[\"attributes[#{key}]\"] = v\n end\n\n url = \"#{@target_url}#{sub.uri}.xml\"\n http_put(url, params) # {|req| req.content_type = 'application/xml'}\n end\n end", "def rest_endpoint=(_arg0); end", "def update\n # actions\n path = URI(@endpoint).path\n action = URI(@req.request_uri).path.sub(path, '').split('/')\n action -= ['']\n if action.include?('_history')\n @actions = [action[0], '_history']\n else\n @actions = [action[0]]\n end\n\n # search param\n req_query = URI(@req.request_uri).query\n unless req_query.nil?\n @req_params = URI::decode_www_form(req_query).to_h\n end\n\n # requst method\n if @req.request_method == \"GET\" and @actions.include? '_history'\n @req_method = 'vread'\n elsif @req.request_method == \"GET\" and @req_params != nil\n @req_method = 'search-type'\n elsif @req.request_method == \"PUT\"\n @req_method = 'update'\n elsif @req.request_method == \"POST\"\n @req_method = 'create'\n else\n @req_method = 'read'\n end\n\n # interaction\n int1 = Interaction.last type: @actions[0], code: @req_method\n if int1.nil?\n @present = 0\n else\n @present = int1.id\n @intCode = int1.valueCode\n end\n end", "def resource_updated(resource, action)\n updates << [ resource, action ]\n end", "def register_subresource(resource)\n super.tap do |added|\n if added && action_on_update\n Chef::Log.debug(\"[#{self}] Registering #{action_on_update_immediately ? 'immediate ' : ''}#{action_on_update} notification from #{resource}\")\n resource.notifies action_on_update.to_sym, self, (action_on_update_immediately ? :immediately : :delayed)\n end\n end\n end", "def subscribe\n debug [self.name, \"incoming\"]\n subscribe_request\n end", "def subscribe\n # PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", \"http://li182-172.members.linode.com/feeds/#{self.id}\", \"async\")\n PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", self.url, \"async\")\n end", "def get_changes\n CouchRest.get(SERVER.uri << DB.uri << \"/_changes\")\nend", "def handle_request( * ) # :nodoc:\n\t\tself.log.debug \"[:restresources] handling request for REST resource.\"\n\t\tsuper\n\tend", "def methods(*args)\n super | rpc_methods\n end", "def subscribed # :doc:\n # Override in subclasses\n end", "def update!(**args)\n @method_match = args[:method_match] if args.key?(:method_match)\n @polling_options = args[:polling_options] if args.key?(:polling_options)\n end", "def on_refresh(&block)\n @connection.on_refresh_cb = block\n end", "def request!\n self.type = :subscribe\n reply_if_needed!\n end", "def consume_rest; end", "def notify(method, *args)\n @serializer.write([2, method, args])\n self\n end", "def rest_end_point; end", "def subscribe_request_hook(name = SecureRandom.hex.to_sym, &block)\n EasyPost::Hooks.subscribe(:request, name, block)\n end", "def broadcast_sync(meth, *args)\n @listeners.select { |listener| listener.class.ann(meth, :stem_sync) }.each { |listener| listener.respond meth, *args }\n end", "def subscribe_to_updates\n if @subscription = @requestor.find_or_create_subscriptions(@target.id)\n @subscription.update_attributes(blocked: false) if @subscription.blocked?\n render json: { success: true }\n else\n render json: {message: @subscription.errors&.full_messages || 'Unable to subscriber updates, please try again'}, status: 202\n end\n end", "def method_added(*) end", "def watch_method; end", "def remote_update(*)\n super(changed)\n end", "def on_subscription_success\n end", "def create / update_subscriptions\n end", "def rpc(method, arguments)\n\t\t\t# This update might not be sent right away. Therefore, mutable arguments may be serialized to JSON at a later time (or never). This could be a race condition:\n\t\t\[email protected]([method, arguments])\n\t\tend", "def method_missing(method, *args, &block)\n if actions(current_api).include? method\n self.class.send(:define_method, method) do |params|\n perform_soap_call(method, params) || perform_rest_call(params)\n end\n send method, *args, &block\n else\n super\n end\n end", "def poll_req\n super # placeholder so that I can add some doc\n end", "def rest_routes\n\t\t\t\t\t[\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :index },\n\t\t\t\t\t\t{ method: :POST, path: '/', action: :create },\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :show },\n\t\t\t\t\t\t{ method: :PUT, path: '/', action: :update },\n\t\t\t\t\t\t{ method: :DELETE, path: '/', action: :delete }\n\t\t\t\t\t]\n\t\t\t\tend", "def after_update(resource)\n add_activity(:update, resource)\n end", "def methods\n main_service.methods.select(&:can_generate_rest?)\n end", "def update\n self.publish_json\n end", "def method_missing(meth, *args, &block)\n @_resource.send(:method_missing, meth, *args, &block)\n end", "def rest_class_methods\n @rest_class_methods ||= {}\n end", "def after_subscribe(subscribed)\n # not required\n end", "def method_missing(method, *params, &block)\n @endpoint_parts << method.to_s\n\n @endpoint_parts << params\n @endpoint_parts = @endpoint_parts.flatten!\n\n block&.call\n\n self || super\n end", "def on_update; end", "def method_added(method)\n return unless @current_doc_link\n\n @doc_urls ||= {}\n @doc_urls[method] = @current_doc_link\n\n # Prevent infinite recursion on define_method below\n @current_doc_link = nil\n\n alias_method \"old_#{method}\".to_sym, method\n\n define_method(method) do |*args|\n begin\n send(\"old_#{method}\", *args)\n rescue Exception => e\n msg = e.message + \"\\n\\nPlease refer to this URL for additional information on this API call:\\n#{self.class.api_docs(method)}\\n\" \n raise e, msg, e.backtrace\n end\n end\n end", "def refresh\n raise Occi::Api::Client::Errors::NotImplementedError, \"#{__method__} is just a stub!\"\n end", "def http_method(v)\n endpoint_info[:http_method] = v\n end", "def rest_interface(*operations)\n const_get(:REST_INTERFACE).push(*operations)\n end", "def reroute_callbacks\n @reroute_callbacks\n end", "def update\n super\n refresh if controller_changed?\n end", "def endpoint; end", "def endpoint; end", "def endpoint; end", "def endpoint; end", "def register_rest(handler, &block)\n @register_rest ||= (handler || block)\n end", "def method_added(name)\n super(name) if defined?(super)\n published(name) if @publishing\n end", "def subscribe_to_channel; end", "def on_request_uri(cli, request)\r\n print_status(\"Request: #{request.uri}\")\r\n if request.uri =~ /#{Regexp.escape(get_resource)}/\r\n print_status('Sending payload...')\r\n send_response(cli, @pl)\r\n end\r\n end", "def method_missing(method_name, *args)\n payload = Kauplus::Client.authenticate_payload(args.first)\n if method_name.match(/(get|post|multipart_post|put|delete|head)_(.*)/)\n Kauplus::Client.send($1, \"#{@resource}/#{$2}\", payload)\n else\n Kauplus::Client.get(\"#{@resource}/#{method_name}\", payload)\n end\n end", "def subscribe(args = {})\n :no_response\n end", "def method_added(id)\n\t\t\t\t\treset_routing_cache\n\t\t\t\tend", "def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend", "def method_missing(method_name, *args, &block)\n # Quick check to see if changes or was are being called, this check\n # keeps us from needing to parse out the parts if we're not going\n # to use them.\n if method_name =~ /[_](changes|was)$/\n # Break apart the method call\n # TODO: no destructuring because of https://github.com/opal/opal/issues/663\n *parts = method_name.to_s.split('_')\n action = parts.pop\n key = parts.join('_').to_sym\n\n # Handle changes or was calls.\n case action\n when 'changes'\n return changes(key)\n when 'was'\n return was(key)\n end\n end\n\n # Otherwise, run super\n super\n end", "def method_added(id)\n\t\t\t\treset_routing_cache\n\t\t\tend", "def update &block\n receive_update_callbacks << block\n end", "def booking_callback_refresh\n @booking.refresh!\n end", "def add_rest_method(name, uri, verb, parameters, output)\n @lines ||= []\n _add_cell(name)\n _add_cell(uri)\n _add_cell(verb)\n _add_cell(_format_rest_value(parameters))\n _add_cell(_format_rest_value(output))\n @lines.push \"|-\"\n end", "def notifications\n end", "def method_missing(method, *args, &block)\n if _resource.respond_to?(method.to_s)\n result = _resource.send(method, *args, &block)\n result.nil? ? delegate_method(method, *args, &block) : result\n else\n super\n end\n end", "def send_update\n changed\n notify_observers(self)\n end", "def method_translator\n operations.each do | op |\n if op['method'].blank? && op['httpMethod']\n op['method']= op.delete('httpMethod')\n swagger[\"__notifications\"] << \"001: replace `httpMethod' with `method'\"\n end\n end\n end", "def endpoints; end", "def save\n @client.patch(@endpoint, :content=>@changed)\n return nil\n end", "def notify(optional_destination, rpc_method, *args)\n # TODO\n end", "def old_rest path, query={}, opts={}, &cb\n uri = url(\"method/#{path}\", {:format => 'json'}.merge(query),\n old_server, opts)\n if opts[:post]\n request(\n opts.merge(:uri => uri),\n [:post,\n url(\"method/#{path}\", {:format => 'json'}, old_server, opts),\n query],\n &cb)\n else\n request(opts, [:get, uri], &cb)\n end\n end", "def subscription_update\n data = request.body.read\n @verified = verify_webhook(data, request)\n if @verified\n ReserveInventory.delay(:retry => false).update_reserve_inventory\n head :ok\n else\n head :error\n end\n end", "def notify_change(method, *args)\n changed\n notify_observers(method, self, *args)\n end", "def update\n super\n @observing_procs.values.each { |block| block.call(item) }\n end", "def query_api_pattern(method_name, verb, path='', opts={}, &block)\n self.class.query_api_pattern(method_name, verb, path, opts, @query_api_patterns, &block)\n end", "def listen\n raise NotImplementedError.new(\"Implement listen() in your Invoker. \")\n end", "def rest_token_endpoint; end", "def subscribe_response_hook(name = SecureRandom.hex.to_sym, &block)\n EasyPost::Hooks.subscribe(:response, name, block)\n end", "def listen\r\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def rest_token_endpoint=(_arg0); end", "def non_get_methods\n [:post, :put, :delete]\n end", "def watch\n\nend", "def unsubscribed; end", "def on_update(&update_callback)\n @update_callbacks << update_callback\n end", "def method_missing(api_method, *args) # :nodoc:\n @client.wsdl.soap_actions.include?(api_method.to_sym) ? call(api_method, *args) : super\n end", "def subscribed\n super\n increase_current_users\n stream_from channel\n end", "def request_method\n {:filter => :post,\n :sample => :get,\n :firehose => :get,\n :retweet => :get\n }.fetch(@path, :get)\n end" ]
[ "0.7105133", "0.6579582", "0.63768786", "0.6216438", "0.61687917", "0.6116977", "0.6067221", "0.60581565", "0.59867567", "0.593846", "0.59278405", "0.59278405", "0.59278405", "0.5892552", "0.5880831", "0.5803589", "0.5726174", "0.56889856", "0.5674444", "0.56697875", "0.5641334", "0.5585611", "0.5558812", "0.55394155", "0.5511624", "0.55026305", "0.54838604", "0.5479366", "0.54727066", "0.54409224", "0.53936803", "0.5375943", "0.5370835", "0.53685004", "0.5367314", "0.53650653", "0.5361689", "0.5360939", "0.5356056", "0.53553075", "0.5353676", "0.53534687", "0.5340144", "0.5315628", "0.5295391", "0.5283476", "0.52775645", "0.5264489", "0.52640444", "0.5262667", "0.52519816", "0.5248359", "0.5225424", "0.5213285", "0.52020407", "0.51969266", "0.51837176", "0.5174393", "0.5174393", "0.5174393", "0.5174393", "0.5169976", "0.51651", "0.5162299", "0.5161453", "0.51555127", "0.51552117", "0.51459473", "0.5122043", "0.5119302", "0.5118939", "0.5111441", "0.51104504", "0.51101357", "0.509363", "0.507781", "0.5070179", "0.5056899", "0.5049542", "0.50483656", "0.5044115", "0.50339645", "0.50257784", "0.50243956", "0.5018743", "0.5016902", "0.50074714", "0.49976456", "0.4996058", "0.49884042", "0.49856296", "0.49856296", "0.49835983", "0.49730712", "0.49669495", "0.49623433", "0.49583343", "0.49515635", "0.49510628", "0.49480787" ]
0.66870373
1
subscribe to scope updates
def subscribe_scope(collection, record_class = nil, scope_name = nil) return unless session.id time_now = Time.now.to_f.to_s session_id = session.id.to_s Hyperloop.redis_instance.pipelined do if collection.is_a?(Enumerable) collection.each do |record| Hyperloop.redis_instance.hset("HRPS__#{record.class}__#{record.id}", session_id, time_now) end end Hyperloop.redis_instance.hset("HRPS__#{record_class}__scope__#{scope_name}", session_id, time_now) if record_class && scope_name end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subscribed; end", "def send_update\n changed\n notify_observers(self)\n end", "def subscribe\n self.subscribed = true\n end", "def scopeChanged\n pp [:got_scopeChanged] if $DEBUG\n end", "def subscribe!\n # TODO: Implement\n end", "def subscribed # :doc:\n # Override in subclasses\n end", "def notify\n @observers.each { |observer| observer.update }\nend", "def subscriptions; end", "def subscriptions; end", "def subscriptions; end", "def changes\n poll(\"Changes\")\n end", "def notify_observers\n\t\[email protected] do |observer|\n\t\t\tobserver.update(self)\n\t\tend\n\tend", "def subscribe interval=1\n\t\t\treturn if @update_timer\n\n\t\t\tupdate_proc = proc {\n\t\t\t\tupdate do |status, result|\n\t\t\t\t\t@update_timer = EM::Timer.new(interval, update_proc) if @update_timer\n\t\t\t\tend\n\t\t\t}\n\n\t\t\t@update_timer = EM::Timer.new(interval, update_proc)\n\t\tend", "def update\n super\n @observing_procs.values.each { |block| block.call(item) }\n end", "def subscribe\n \nend", "def notify\n changed(true)\n notify_observers(self)\n end", "def scope() binding end", "def changed_and_notify(*args)\n changed\n notify_observers(*args)\n end", "def notify\n puts 'Subject: Notifying observers...'\n @observers.each { |observer| observer.update(self) }\n end", "def did_update\n trigger_events(:update)\n end", "def subscribed\n super\n increase_current_users\n stream_from channel\n end", "def notify_will_change!\n collection_will_change!\n forward \"#{@key}_will_change!\"\n end", "def on_update; end", "def notify_subscribers\n NotificationSubscription.notify(self)\n end", "def inform_obeservers\n\t\[email protected] { |observer| observer.update(self) }\n\tend", "def pub_sub_scope(collection, record_class, scope_name)\n subscribe_scope(collection, record_class, scope_name)\n publish_scope(record_class, scope_name)\n end", "def after_subscribe(subscribed)\n # not required\n end", "def unsubscribed; end", "def watch\n\nend", "def publish_scope(record_class, scope_name)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record_class}__scope__#{scope_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: record_class.to_s,\n scope: scope_name\n }\n subscribers.each_slice(10) do |slice|\n channel_array = []\n slice.each do |session_id, last_requested|\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{record_class}__scope__#{scope_name}\", session_id)\n next\n end\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n end", "def update\n Thread.current[:\"[mongoid]:update-consumer\"]\n end", "def update\n Thread.current[:\"[mongoid]:update-consumer\"]\n end", "def object_updated(object)\n notify\n end", "def update_scope\n @scope = params[:scope] || params[:q] || {}\n end", "def update\n Channel.channels_to_update\n end", "def refresh\n puts \" -- refresh subscriptions(#{@subscriptions.size}):\"\n\n run_callback_server # call it once to make sure it runs\n \n @subscriptions.each do |sub| \n puts \" - #{sub.name}\"\n params = { \"attributes[accept]\" => 'application/json' }\n\n query = \"/gnp;#{sub.name};#{sub.entry_uri}\"\n params[\"attributes[callback_url]\"] = \"#{callback_server.base_url}#{query}\"\n\n [:operations, :uri_regexp, :condition_script].each do |key|\n (v = sub.send key) and params[\"attributes[#{key}]\"] = v\n end\n\n url = \"#{@target_url}#{sub.uri}.xml\"\n http_put(url, params) # {|req| req.content_type = 'application/xml'}\n end\n end", "def websocket_update\n json = self.to_jsonapi\n watching_users.each do |user|\n UpdatesChannel.broadcast_to(user, {loadModels: [json]})\n end\n end", "def subscribe\n @player.subscribe(self)\n end", "def process\n changed\n notify_observers(@pointer)\n @pointer\n end", "def subscribe_to_channel; end", "def broadcast_update\n broadcast broadcast_event_name(:updated), self, previous_changes\n end", "def notify_subscribers(resource)\n resource.subscriptions.each do |subscription|\n http = EM::HttpRequest.new(subscription.url).post(:body => {:data => resource.body})\n http.callback{ |response|\n puts \"POSTed updated data for #{resource.url}, #{resource.body.length} characters\"\n }\n http.errback {|response|\n # Do something here, maybe setting the resource\n # to be not checked anymore.\n }\n end\n end", "def do_subscribe\n subscribe_to(@nodename)\n get_subscriptions\n end", "def observe\n Observable.new(super)\n end", "def update\n run_callbacks :update do\n true\n end\n end", "def watch_method; end", "def after_save\n unless destroyed_by_association\n touch_subscriptions if saved_change_to_unread_entries?\n end\n end", "def sync_scopes(related_records, record, filtering = true)\n #related_records = related_records.intersection([*@collection])\n related_records = in_this_collection(related_records) if filtering\n live_scopes.each { |scope| scope.sync_scopes(related_records, record, filtering) }\n notify_of_change unless related_records.empty?\n ensure\n @pre_sync_related_records = nil\n end", "def websocket_update\n UpdatesChannel.broadcast_to(user, {loadModels: [self.to_jsonapi]})\n end", "def notify\n @subscribers.each { |ident, (block,obj)| block.call(obj) }\n end", "def subscribe\n debug [self.name, \"incoming\"]\n subscribe_request\n end", "def set_observation\n @observation = scope.find(params[:id])\n end", "def subscribe(qualifications = {})\n if data.is_a?(MutableData)\n MutationStore.instance.register(self, data, qualifications, view.context.request.session)\n end\n\n channel = ChannelBuilder.build(\n scope: view.scoped_as,\n mutation: mutation[:name],\n qualifiers: mutation[:qualifiers],\n data: data,\n qualifications: qualifications\n )\n\n # subscribe to the channel\n view.context.socket.subscribe(channel)\n\n # handle setting the channel on the view\n if view.is_a?(Presenter::ViewContext)\n working_view = view.instance_variable_get(:@view)\n else\n working_view = view\n end\n\n if working_view.is_a?(Presenter::ViewCollection)\n # NOTE there's a special case here where if the collection is\n # empty we insert an empty element in its place; this makes\n # it possible to know what the data should be applied to when\n # a mutation occurs in the future\n\n unless working_view.exists?\n # TODO: would rather this be an html comment, but they aren't\n # supported by query selectors; need to finalize how we will\n # handle this particular edge case\n working_view.first.doc.append('<span data-channel=\"' + channel + '\" data-version=\"empty\"></span>')\n return\n end\n end\n\n working_view.attrs.send(:'data-channel=', channel)\n end", "def notify_change(method, *args)\n changed\n notify_observers(method, self, *args)\n end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def update &block\n receive_update_callbacks << block\n end", "def watch_for_set; end", "def before_query(query)\n if query.subscription? && !query.subscription_update?\n query.context.namespace(:subscriptions)[:events] = []\n end\n end", "def scope(*args); end", "def changes\n poll = @watch.objects.find { |obj| obj.name == \"pollChanges\" }\n\n poll.invoke.objects.find do |object|\n object.name == \"values\"\n end.objects\n end", "def engine_notify_datas_updated(datas_updated)\n end", "def after_update(resource)\n add_activity(:update, resource)\n end", "def on_update(&update_callback)\n @update_callbacks << update_callback\n end", "def show_subscriptions\n puts \"\\nYour current subscriptions are:\"\n @user.subscriptions.reload.each do |sub|\n puts sub.name\n end\n end", "def notify_observers(*args)\n return unless changed?\n\n unwrap(connection).exec \"NOTIFY #{channel}, #{args}\"\n\n changed false\n end", "def update\n super\n refresh if controller_changed?\n end", "def updated\n watchers.find_all(&:updated?)\n end", "def subscriptions\n @subscriptions ||= {}\n end", "def changed(key, value, revision)\n logger.debug \"Updated: #{key}\", value\n\n return unless @update_subscribers\n\n # Subscribers to specific paths\n if subscribers = @update_subscribers[key]\n subscribers.each{|subscriber| subscriber.call(key, value, revision)}\n end\n\n # Any subscribers for all events?\n if all_subscribers = @update_subscribers['*']\n all_subscribers.each{|subscriber| subscriber.call(key, value, revision)}\n end\n end", "def subscribe_to_channel(*)\n synchronize_entrypoint! { super }\n end", "def observing(scope, action, traversal, values)\n @observations ||= []\n @observations << {\n scope: scope,\n action: action,\n traversal: traversal,\n values: values\n }\n end", "def subscribe_channels\n @channels.each { |channel| subscribe(channel) }\n end", "def apply_event_subscription\n @dispatcher.subscribe_event(event_subscription)\n end", "def subscribed\n location_id = params[:location_id].to_i\n location = Location.find(location_id)\n stream_for location\n \n @@locations_with_subscribers << location_id\n\n WeatherUpdateJob.schedule(location)\n end", "def update_scopes\n if changes = friendly_id_changes\n friendly_id_config.child_scopes.each do |klass|\n Slug.update_all \"scope = '#{changes[1]}'\", [\"sluggable_type = ? AND scope = ?\", klass.to_s, changes[0]]\n end\n end\n end", "def update_scopes\n if changes = friendly_id_changes\n friendly_id_config.child_scopes.each do |klass|\n Slug.update_all \"scope = '#{changes[1]}'\", [\"sluggable_type = ? AND scope = ?\", klass.to_s, changes[0]]\n end\n end\n end", "def observer\n Observer.for_db(self)\n end", "def update!(**args)\n @pubsub_subscription = args[:pubsub_subscription] if args.key?(:pubsub_subscription)\n end", "def track_in_session_revision_list\n RevisionList.track_changes_in(lambda { | | create_session_revision_list! }) do \n yield\n end\n self\n end", "def changes_pending!\n self.lifecycle.changes_pending! nil\n end", "def refresh_observers\n logger.debug(\"refresh_observers: enter\")\n observers.each do |_, observer|\n observer.rerun unless observer.status\n end\n end", "def apply_on_subscribing\n @apply_on_subscribing = true\n return self\n end", "def listen_for_changes\n Listen.to(input_dir.to_s) do\n sync\n end.start\n end", "def handle_update\n navdata = connection.receive_data\n publish(event_topic_name(\"update\"), navdata)\n end", "def on_data_changed; end", "def subscribe(data)\n # @channels (local tracker)\n # push channel name into subscribe list, if and only if not already in subscribe list\n end", "def subscribe\n @bot.get_updates(fail_silently: true) do |message|\n parser = InputParser.new(message.text)\n subject = parser.parse_subject\n if subject != nil\n response = \"Hello #{subject}, I'm dad.\"\n message.reply do |reply|\n reply.text = response\n reply.send_with(@bot)\n end\n end\n end\n end", "def scopes; end", "def on_track_change\n # XXXMLG implement\n end", "def watcher=(_arg0); end", "def notify_collections *updates\n @collections.each {|coll| instance_variable_get(\"@#{coll}\").notify_members *updates }\n end" ]
[ "0.63665754", "0.6141811", "0.60926044", "0.60675323", "0.60510194", "0.59879136", "0.59664476", "0.59514904", "0.59514904", "0.59514904", "0.5779719", "0.5707332", "0.56540954", "0.5653643", "0.56420255", "0.5630628", "0.5593789", "0.55473745", "0.55442375", "0.5535873", "0.5530182", "0.5508852", "0.5502019", "0.5485942", "0.54826766", "0.54752886", "0.54467195", "0.5444739", "0.5444686", "0.5427931", "0.54271907", "0.54271907", "0.5403531", "0.53987235", "0.5368524", "0.53674227", "0.53541666", "0.5343109", "0.5335804", "0.533456", "0.53234", "0.5312559", "0.5283926", "0.52649474", "0.5243707", "0.5238152", "0.5234514", "0.5221173", "0.5218684", "0.52099466", "0.5201292", "0.5185123", "0.5183351", "0.51819515", "0.5179776", "0.5179776", "0.5179776", "0.5179776", "0.5179776", "0.5179776", "0.5179776", "0.5179776", "0.5179776", "0.5179776", "0.51756907", "0.51628286", "0.5151941", "0.514837", "0.5120031", "0.51007193", "0.5094758", "0.50927484", "0.50900054", "0.5087354", "0.5075418", "0.507384", "0.5063306", "0.50537306", "0.50501347", "0.50497305", "0.50435597", "0.5040911", "0.5036021", "0.50285167", "0.50285167", "0.5014468", "0.5001593", "0.49993593", "0.4991416", "0.49910322", "0.4978438", "0.4977315", "0.49765024", "0.49754685", "0.49735716", "0.49723628", "0.4972128", "0.49719167", "0.49697644", "0.49523768" ]
0.52470285
44
subscribe to record and then publish
def pub_sub_record(record) subscribe_record(record) publish_record(record) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subscribe!\n # TODO: Implement\n end", "def subscribe_record(record)\n return unless session.id\n Hyperloop.redis_instance.hset \"HRPS__#{record.class}__#{record.id}\", session.id.to_s, Time.now.to_f.to_s\n end", "def subscribe\n \nend", "def publish_record(record)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record.class}__#{record.id}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n\n message = {\n record_type: record.class.to_s,\n id: record.id,\n updated_at: record.updated_at\n }\n message[:destroyed] = true if record.destroyed?\n\n Rails.logger.debug \"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\"\n\n Rails.logger.debug \"========================================== SUBSCRIBERS ================ #{subscribers}\"\n Rails.logger.debug \"=========================================== SUBSCRIBERS SIZE =============== #{subscribers.size}\"\n\n\n # can only trigger to max 10 channels at once on pusher\n subscribers.each_slice(10) do |slice|\n Rails.logger.debug \"========================================================== EACH SLICE !\"\n Rails.logger.debug \"=============================================SLICE============= #{slice}\"\n Rails.logger.debug \"=============================================SLICE SIZE============= #{slice.size}\"\n channel_array = []\n slice.each do |session_id, last_requested|\n\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{record.class}__#{record.id}\", session_id)\n next\n end\n Rails.logger.debug \"========================================================== SESSION ID : #{session_id} !\"\n Rails.logger.debug \"========================================================== RECORD CLASS : #{record.class} !\"\n Rails.logger.debug \"========================================================== RECORD ID : #{record.id} !\"\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n Rails.logger.debug \"========================================================== CHANNEL ARRAY #{channel_array} !\"\n\n if channel_array.size > 0\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n Rails.logger.debug \"========================================================== PUSHER #{channel_array} !\"\n\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n Rails.logger.debug \"========================================================== BROADCAST #{channel} !\"\n\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n\n end\n Hyperloop.redis_instance.del(\"HRPS__#{record.class}__#{record.id}\") if record.destroyed?\n end", "def subscribed; end", "def subscribe(&b)\n @publisher.subscribe(&b)\n end", "def subscribe\n self.subscribed = true\n end", "def subscribes?(record, **args)\n subscriber(record, **args).present?\n end", "def subscribe(_topic, **)\n raise 'not implemented'\n end", "def subscribe(&blk)\n pres = connection.presence_stanza('to'=>jid.bare, 'type' => 'subscribe')\n connection.send_stanza pres, &blk\n end", "def pubsub; end", "def subscribe\n debug [self.name, \"incoming\"]\n subscribe_request\n end", "def run_subscribe(conn, dest)\n return if not @need_subscribe\n @log.debug \"run_subscribe starts\"\n conn.subscribe(dest) # call hook\n @log.debug \"run_subscribe done\"\n @need_subscribe = false\n @need_gets = true\nend", "def subscribe\n @conn.send_data :opcode => SUBSCRIBE, :channel => @name\n @subscribe_sent = true\n end", "def pubsub_adapter; end", "def subscribe\n @player.subscribe(self)\n end", "def subscribe\n @broker.subscribe(*self.class.subscriptions) do |channel, data|\n begin\n perform(channel, data)\n rescue => e\n puts \"Exception #{e}\"\n end\n end\n end", "def subscribed # :doc:\n # Override in subclasses\n end", "def pub_sub_relation(relation, base_record, relation_name, causing_record = nil)\n subscribe_relation(relation, base_record, relation_name)\n publish_relation(base_record, relation_name, causing_record)\n end", "def subscribe(*args, &blk)\n (@client ||= connect).subscribe(*args, &blk)\n end", "def subscribe_to_channel; end", "def pub_sub_rest_method(record, rest_method_name)\n subscribe_rest_method(record, rest_method_name)\n publish_rest_method(record, rest_method_name)\n end", "def subscribe\n @conn.subscribe(@queue_name, @headers)\n @@log.debug(\"subscribe to: #{@queue_name}\")\n @@log.debug(\"headers: #{@headers.inspect}\")\n end", "def subscribe(subscribable, subscription_level = Subscription::Levels[:reader])\n subscribable.subscribe(self, subscription_level)\n end", "def do_subscribe\n subscribe_to(@nodename)\n get_subscriptions\n end", "def after_subscribe(subscribed)\n # not required\n end", "def subscribed\n super\n increase_current_users\n stream_from channel\n end", "def subscribe( publication )\n subscriptions.create(publication: publication) unless has_subscribed?(publication)\n rescue ActiveRecord::RecordNotUnique\n end", "def subscribed\n \t#stream_from 'demo_chan'\n end", "def push_subscription(object)\n local_server.subscribe(object)\n synchro_point\n end", "def pub_sub_rest_class_method(record_class, rest_class_method_name)\n subscribe_rest_class_method(record_class, rest_class_method_name)\n publish_rest_class_method(record_class, rest_class_method_name)\n end", "def publish\n set_publish_state(Event::PUBLISHED_STATE)\n end", "def publish!\r\n publish\r\n save!\r\n end", "def on_publish(ptr, _, packet_id)\n @events << {\n type: :publish,\n packet_id: packet_id,\n }\n end", "def publish!\n publish\n save\n end", "def subscribed\n @course_queue = CourseQueue.find(params[:id])\n stream_for @course_queue\n end", "def subscribe!\n @repository.callback_url = pubsubhubbub_callback_url\n\n if @repository.valid?\n begin\n client.subscribe(\n topic,\n @repository.callback_url,\n ENV['PUBSUBHUBBUB_SECRET']\n )\n\n @repository.save\n rescue Octokit::Error => e\n @repository.errors.add(:base, e.message)\n\n false\n end\n end\n end", "def subscribed\n id = params.fetch(:id)\n return unless execution = JobQueue.find_by_id(id)\n\n execution.viewers.push current_user\n\n Thread.new do\n ActiveRecord::Base.connection_pool.with_connection do\n builder = EventBuilder.new(execution.job)\n execution.output.each do |event, data|\n transmit event: event, data: builder.payload(event, data)\n end\n # TODO: disconnect all listeners so they close their sockets ?\n # then replace the reloaded/finished/waitUntilEnabled stuff with that\n end\n end\n end", "def publisher; end", "def publisher; end", "def subscribe \n @subscription = MQ.new\n @subscription.queue(@uuid).bind(@subscription.fanout('global_history')).subscribe do |result|\n x = Mash.new(JSON::parse(result))\n puts \"received: #{x[:uuid]} #{x[:user]}@#{x[:host]}$ #{x[:message]}\"\n if x[:uuid] != @uuid\n @pause = true\n File.open(path, \"a\") {|f| f.puts(x[:message])}\n skip_ahead\n @pause = false\n schedule_next_read\n end\n end\n end", "def publish_relation(base_record, relation_name, record = nil)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: base_record.class.to_s,\n id: base_record.id,\n updated_at: base_record.updated_at,\n relation: relation_name\n }\n if record\n message[:cause] = {}\n message[:cause][:record_type] = record.class.to_s\n message[:cause][:id] = record.id\n message[:cause][:updated_at] = record.updated_at\n message[:cause][:destroyed] = true if record.destroyed?\n end\n subscribers.each_slice(10) do |slice|\n channel_array = []\n slice.each do |session_id, last_requested|\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}\", session_id)\n next\n end\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n end", "def subscribe(subscriber)\n handler.subscribe(self, subscriber)\n end", "def subscribe(response)\n response.headers['Content-Type'] = 'text/event-stream'\n @subscriber = response\n end", "def subscribe(&onMessage) # block\n end", "def subscribe(aSubscriber)\n subscribers << aSubscriber\n end", "def subscribe(name, params, &blk)\n id = self.next_id()\n self.send({msg: 'sub', id: id, name: name, params: params})\n\n @subs[name] = id\n @callbacks[id] = blk\n end", "def subscribe\n subscribee = connection.jid.bare\n\n iq = connection.iq_stanza({'to'=>jid.bare,'type'=>'set'},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSub},\n x('subscribe','node' => node_id, 'jid'=>subscribee)\n )\n )\n\n send_iq_stanza_fibered iq\n end", "def subscribe(*a, &b)\n name = gen_id\n EM.schedule { @subs[name] = EM::Callback(*a, &b) }\n\n name\n end", "def subscribe(domain, node, jid)\n jid = JID.new(jid)\n redis.multi\n redis.sadd(\"pubsub:#{domain}:subscribers_#{node}\", jid.to_s)\n redis.sadd(\"pubsub:#{domain}:subscriptions_#{jid}\", node)\n redis.exec\n end", "def publish\n self.push_message_to_client\n update_attribute(:number, self.number+1)\n end", "def perform\n @logger.info({context: :monitor, action: :perfomed})\n @client.psubscribe(\"#{service}:*\") do |callback|\n callback.psubscribe(self.on_subscribed)\n callback.pmessage(self.on_message)\n callback.punsubscribe(self.on_unsubscribed)\n end\n end", "def publish( message )\n subscribers.each do |name, subscriber|\n subscriber.produce( message )\n end\n end", "def publish!(entry)\n # no-op (for now)\n end", "def subscribe(subscriber, subscription_level = Subscription::Levels[:reader])\n\n if sub = subscription_to(subscriber)\n # no need for equine abuse post-mortem\n return if sub.level == subscription_level\n else\n # Build a subscription\n sub = self.subscriptions_to.build(Sable.subscriber_relation_name.to_sym => subscriber)\n\n # Manually assigning +subscribable+ ensures the current instance will\n # carry forward (useful in combination with +suppress_notifiables+)\n sub.subscribable = self\n end\n\n sub.level = subscription_level\n sub.save! unless new_record?\n end", "def subscribe(subscription)\n @pipe.send_strings [\"subscribe\", subscription]\n end", "def subscribe(cls, &block)\n @subscribers[cls.name] = block\n end", "def subscribed\n stream_from channel_name\n end", "def subscribe(&callback)\n redis.subscribe(channel) do |on|\n on.message do |channel, payload|\n data = JSON.parse(payload) rescue payload\n callback.call channel, data, self\n end\n end\n end", "def subscriptions; end", "def subscriptions; end", "def subscriptions; end", "def subscribe!(topic)\n subscriptions.create!( :topic_id => topic.id )\n end", "def publisher\n end", "def publish\n end", "def publish\n end", "def publish\n end", "def on_subscription_success\n end", "def write(record)\n @worker.enqueue record\n end", "def subscribe(magazine, price)\n Subscription.create(price: price, magazine_id: magazine.id, reader_id: self.id)\n end", "def subscribe\n # PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", \"http://li182-172.members.linode.com/feeds/#{self.id}\", \"async\")\n PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", self.url, \"async\")\n end", "def subscribe\n CampaignMonitorWrapper.subscribe(id: user.id, email: user.email, name: user.name, beta: user.beta?.to_s, billable: user.billable?.to_s)\n end", "def handle_subscribe(client, data)\n topic = @engine.subscribe_client_to_topic client, data[0]\n\n trigger(:subscribe, client, topic.uri)\n end", "def subscribe\n conn = @cluster.connect\n conn.subscribe(ALL)\n conn.subscribe(SHARE)\n conn.subscribe(@channel)\n conn.on(:message) do |channel, message|\n @messages.push([channel, message])\n end\n end", "def subscribe(params = T.unsafe(nil)); end", "def subscribed\n location_id = params[:location_id].to_i\n location = Location.find(location_id)\n stream_for location\n \n @@locations_with_subscribers << location_id\n\n WeatherUpdateJob.schedule(location)\n end", "def subscribe(worker)\n subscriber = listen(worker)\n subscriber.on_error { |e| on_error(e) }\n subscriber.start\n end", "def publish_rest_method(record, rest_method_name)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: record.class.to_s,\n id: record.id,\n rest_method: rest_method_name\n }\n subscribers.each_slice(10) do |slice|\n channel_array = []\n slice.each do |session_id, last_requested|\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\", session_id)\n next\n end\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n end", "def subscribe(repo)\n subscriptions.create(repository: repo)\n end", "def publish(*args, &blk)\n (@client ||= connect).publish(*args, &blk)\n end", "def publish(*args, &blk)\n (@client ||= connect).publish(*args, &blk)\n end", "def publish(event, payload)\n end", "def subscribe(node, host, &block)\n pubsub.subscribe(node, nil, host, &callback_logging(__method__, node, &block))\n end", "def subscribe\n\t if !self_owned? && !subscribed?\n\t\towners.each do |peer|\n\t\t peer.subscribe(self) unless peer.subcribed?(self)\n\t\tend\n\t end\n\tend", "def polling\n while true do\n publish\n end\n end", "def channel\r\n @record\r\n end", "def subscribe(key)\n @amq.queue(key).subscribe do |value|\n yield value\n end\n end", "def subscribe(url)\n subscribed_feed = UrlSubscriber.subscribe url, self\n end", "def subscribe_to(topic)\n StreamUser.create(:user => self, :stream_message => topic.stream_messages.last, :source => 'followed') if topic.stream_messages.last\n subscriptions << Subscription.new(:topic => topic)\n end", "def link!(record)\n event = event_store.read.stream(record.stream_name).forward.first\n\n event_store.link(\n event.event_id,\n stream_name: stream_name\n )\n end", "def subscribe!\n raise StandardError, \"Consumer already exists\" unless @consumer.nil?\n @consumer ||= @main_exchange.subscribe(@consumer_tag) do |delivery_info, metadata, payload|\n process(delivery_info, metadata, payload)\n end\n end", "def subscribe(*addresses, &block)\n reactive.subscribe(*addresses, &block)\n end", "def before_publish(message)\n # do any business logic\n # this calls the adapter.publish(message) afterware\n message\n end", "def publish(*args, &block)\n Register.publish(*args, &block)\n end", "def publish(event, *arguments)\n subscribers.each do |subscriber|\n if subscriber.respond_to?(:notify)\n subscriber.notify(event, *arguments)\n end\n end\n end", "def subscribe_pubsub(domain, node, jid)\n @pubsub.subscribe(domain, node, jid)\n end", "def subscribe_plan\n call(:subscribe_plan, connection_space.plan.remote_id)\n synchro_point\n end", "def publish(event)\n exchange.publish(event)\n nil\n end", "def publish(object)\n @channel << object\n end", "def subscribe_to_channel(*)\n synchronize_entrypoint! { super }\n end" ]
[ "0.7155365", "0.7118702", "0.6906086", "0.68943745", "0.6888428", "0.6870245", "0.67870426", "0.66193604", "0.65513426", "0.6480246", "0.64794236", "0.6462708", "0.645849", "0.6396674", "0.627759", "0.6269025", "0.6254639", "0.62454885", "0.6225504", "0.6210253", "0.6206394", "0.6165668", "0.61587036", "0.6155814", "0.61512715", "0.6144035", "0.6138161", "0.6122797", "0.61100054", "0.60898906", "0.6032575", "0.6029245", "0.60245556", "0.60200024", "0.5961541", "0.59571403", "0.59465027", "0.59391254", "0.5931934", "0.5931934", "0.593005", "0.59223694", "0.59220415", "0.59135556", "0.5908964", "0.588908", "0.58771175", "0.586774", "0.5860572", "0.5849712", "0.58430827", "0.58302873", "0.5828151", "0.5817547", "0.58060706", "0.5806006", "0.5800723", "0.57992816", "0.57949203", "0.57894254", "0.57894254", "0.57894254", "0.5782851", "0.57778186", "0.5772515", "0.5772515", "0.5772515", "0.57649267", "0.57577544", "0.5743372", "0.5734423", "0.57189834", "0.5698932", "0.5695364", "0.5692105", "0.56893355", "0.5689024", "0.5683971", "0.56831384", "0.5680518", "0.5680518", "0.567304", "0.5669896", "0.5666301", "0.56618273", "0.56587684", "0.56583536", "0.564766", "0.5640981", "0.56387097", "0.56385076", "0.5635059", "0.561796", "0.5617664", "0.56027", "0.56009954", "0.5592007", "0.55912066", "0.55669796", "0.55609983" ]
0.84695905
0
subscribe to relation changes and then publish them
def pub_sub_relation(relation, base_record, relation_name, causing_record = nil) subscribe_relation(relation, base_record, relation_name) publish_relation(base_record, relation_name, causing_record) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subscribed; end", "def subscribe\n self.subscribed = true\n end", "def subscribed # :doc:\n # Override in subclasses\n end", "def subscribe!\n # TODO: Implement\n end", "def subscriptions; end", "def subscriptions; end", "def subscriptions; end", "def subscribed\n super\n increase_current_users\n stream_from channel\n end", "def after_subscribe(subscribed)\n # not required\n end", "def subscribe\n \nend", "def notify_subscribers\n NotificationSubscription.notify(self)\n end", "def notify_will_change!\n collection_will_change!\n forward \"#{@key}_will_change!\"\n end", "def publish_relation(base_record, relation_name, record = nil)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: base_record.class.to_s,\n id: base_record.id,\n updated_at: base_record.updated_at,\n relation: relation_name\n }\n if record\n message[:cause] = {}\n message[:cause][:record_type] = record.class.to_s\n message[:cause][:id] = record.id\n message[:cause][:updated_at] = record.updated_at\n message[:cause][:destroyed] = true if record.destroyed?\n end\n subscribers.each_slice(10) do |slice|\n channel_array = []\n slice.each do |session_id, last_requested|\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}\", session_id)\n next\n end\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n end", "def subscribe\n\t if !self_owned? && !subscribed?\n\t\towners.each do |peer|\n\t\t peer.subscribe(self) unless peer.subcribed?(self)\n\t\tend\n\t end\n\tend", "def pub_sub_record(record)\n subscribe_record(record)\n publish_record(record)\n end", "def subscribe_relation(relation, base_record = nil, relation_name = nil)\n return unless session.id\n time_now = Time.now.to_f.to_s\n session_id = session.id.to_s\n Hyperloop.redis_instance.pipelined do\n if relation.is_a?(Enumerable)\n # has_many\n relation.each do |record|\n Hyperloop.redis_instance.hset(\"HRPS__#{record.class}__#{record.id}\", session_id, time_now)\n end\n elsif !relation.nil?\n # has_one, belongs_to\n Hyperloop.redis_instance.hset(\"HRPS__#{relation.class}__#{relation.id}\", session_id, time_now)\n end\n Hyperloop.redis_instance.hset(\"HRPS__#{base_record.class}__#{base_record.id}__#{relation_name}\", session_id, time_now) if base_record && relation_name\n end\n end", "def do_subscribe\n subscribe_to(@nodename)\n get_subscriptions\n end", "def after_save\n unless destroyed_by_association\n touch_subscriptions if saved_change_to_unread_entries?\n end\n end", "def publish\n set_publish_state(Event::PUBLISHED_STATE)\n end", "def push_subscription(object)\n local_server.subscribe(object)\n synchro_point\n end", "def subscribe(&b)\n @publisher.subscribe(&b)\n end", "def subscribe_owner\n\t subscription = owner.subscribe_to(activity_feed)\n\t subscription.save\n\t end", "def collection_updated(object, result)\n key = object.key\n if result\n parent_add(key, object)\n object.subscribe(self)\n else\n object.unsubscribe(self)\n parent_delete(object)\n end\n end", "def notify_subscribers(resource)\n resource.subscriptions.each do |subscription|\n http = EM::HttpRequest.new(subscription.url).post(:body => {:data => resource.body})\n http.callback{ |response|\n puts \"POSTed updated data for #{resource.url}, #{resource.body.length} characters\"\n }\n http.errback {|response|\n # Do something here, maybe setting the resource\n # to be not checked anymore.\n }\n end\n end", "def pubsub; end", "def unsubscribed; end", "def publish\n self.published = true\n end", "def notify\n changed(true)\n notify_observers(self)\n end", "def publish_changes\n return unless resource.valid?\n private_publish resource\n end", "def publish!\n publish\n save\n end", "def handle_update\n navdata = connection.receive_data\n publish(event_topic_name(\"update\"), navdata)\n end", "def subscribe(object)\n while object.respond_to?(:__getobj__)\n object = object.__getobj__\n end\n\n if remote_object = (remote_object(object) rescue nil)\n if !subscriptions.include?(remote_object)\n remote_object = nil\n end\n end\n\n unless remote_object\n remote_sibling = object.sibling_on(self)\n remote_object = call(:subscribe, remote_sibling)\n synchro_point\n end\n local_object = local_object(remote_object)\n end", "def subscribers\n AdminNotifier.subscribers(Subscriber.first)\n end", "def publish!\n self.update_attribute(:status, PUBLISHED)\n end", "def publish!\n self.update_attribute(:status, PUBLISHED)\n end", "def publish!\n self.update_attribute(:status, PUBLISHED)\n end", "def publish!\n self.update_attribute(:status, PUBLISHED)\n end", "def apply_on_publishing_and_subscribing\n apply_on_subscribing\n apply_on_publishing\n return self\n end", "def subscribe\n @player.subscribe(self)\n end", "def before_query(query)\n if query.subscription? && !query.subscription_update?\n query.context.namespace(:subscriptions)[:events] = []\n end\n end", "def publish!\r\n publish\r\n save!\r\n end", "def pubsub_adapter; end", "def notify\n @subscribers.each { |ident, (block,obj)| block.call(obj) }\n end", "def publish\n self.update_attributes(status: STATUS_PUBLISHED)\n end", "def run_subscribe(conn, dest)\n return if not @need_subscribe\n @log.debug \"run_subscribe starts\"\n conn.subscribe(dest) # call hook\n @log.debug \"run_subscribe done\"\n @need_subscribe = false\n @need_gets = true\nend", "def subscribers\r\n @subscribers.clone\r\n end", "def publish!\n self.update_attribute(:published, true)\n end", "def subscribe_author\n self.subscriptions.create user_id: self.user.id\n end", "def subscribe\n # PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", \"http://li182-172.members.linode.com/feeds/#{self.id}\", \"async\")\n PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", self.url, \"async\")\n end", "def send_update\n changed\n notify_observers(self)\n end", "def subscribe( publication )\n subscriptions.create(publication: publication) unless has_subscribed?(publication)\n rescue ActiveRecord::RecordNotUnique\n end", "def subscribe( key, node )\n\t\tkey = key.to_sym\n\t\tself.log.debug \"Adding subscription to %p nodes for %p\" % [ key, node ]\n\t\tself.subscriptions[ key ] << node\n\t\t# self.log.debug \" now have subscriptions for: %p\" % [ self.subscriptions.keys ]\n\t\tif self.published_nodes.key?( key )\n\t\t\tself.log.debug \" re-publishing %d %p nodes to late subscriber\" %\n\t\t\t\t[ self.published_nodes[key].length, key ]\n\t\t\tnode.publish( *self.published_nodes[key] )\n\t\tend\n\tend", "def subscribed\n id = params.fetch(:id)\n return unless execution = JobQueue.find_by_id(id)\n\n execution.viewers.push current_user\n\n Thread.new do\n ActiveRecord::Base.connection_pool.with_connection do\n builder = EventBuilder.new(execution.job)\n execution.output.each do |event, data|\n transmit event: event, data: builder.payload(event, data)\n end\n # TODO: disconnect all listeners so they close their sockets ?\n # then replace the reloaded/finished/waitUntilEnabled stuff with that\n end\n end\n end", "def notify\n puts 'Subject: Notifying observers...'\n @observers.each { |observer| observer.update(self) }\n end", "def apply_event_subscription\n @dispatcher.subscribe_event(event_subscription)\n end", "def apply_on_subscribing\n @apply_on_subscribing = true\n return self\n end", "def subscribe\n debug [self.name, \"incoming\"]\n subscribe_request\n end", "def publish!\n self.published = true\n save\n end", "def subscribe(repo)\n subscriptions.create(repository: repo)\n end", "def publish\n\t\tchanged = !published?\n\t\tself.status = 'published'\n\t\tchanged\n\tend", "def changed_and_notify(*args)\n changed\n notify_observers(*args)\n end", "def subscribe\n @conn.send_data :opcode => SUBSCRIBE, :channel => @name\n @subscribe_sent = true\n end", "def published!\n self.update_attribute(:status, PUBLISHED)\n end", "def create / update_subscriptions\n end", "def pubsub_subscribers(domain, node)\n @pubsub.subscribers(domain, node)\n end", "def subscribe_to_channel; end", "def publish\n end", "def publish\n end", "def publish\n end", "def subscribe_notifications\n @subscribe_notifications ||= true\n end", "def publish\n set_publish(true)\n end", "def notify_subscribers\n AdminMailer.notify_of_standard_change(self)\n end", "def get_subscribers\n @subscriptions = subscribers(@nodename)\n end", "def subscriptions\n @subscriptions ||= {}\n end", "def publisher; end", "def publisher; end", "def publish\n self.push_message_to_client\n update_attribute(:number, self.number+1)\n end", "def subscribe\n @broker.subscribe(*self.class.subscriptions) do |channel, data|\n begin\n perform(channel, data)\n rescue => e\n puts \"Exception #{e}\"\n end\n end\n end", "def notify activity\n\n # people who are subscribed directly to the question\n q_subscribers = self.subscribers.all\n\n # people who are subscribed to the tags of the question\n t_subscribers = self.tag_subscribers.all\n\n (q_subscribers + t_subscribers).each do |subscriber|\n Notification.create :user => subscriber, :activity => activity\n end\n end", "def published?; end", "def published?; end", "def publish_change event\n send :invalidate_role_cache! if event == :roles\n event_manager.publish_change event, :from => self\n end", "def subscribed\n stream_from channel_name\n end", "def pub_sub_rest_method(record, rest_method_name)\n subscribe_rest_method(record, rest_method_name)\n publish_rest_method(record, rest_method_name)\n end", "def relation_added(issue)\n journalize_action(\n :property => 'relation',\n :prop_key => 'relates',\n :value => issue.try(:id)\n )\n end", "def notify\n @observers.each { |observer| observer.update }\nend", "def object_updated(object)\n notify\n end", "def publish\r\n if update_attribute('published', true)\r\n log_activity\r\n true\r\n else\r\n false\r\n end\r\n end", "def subscriptions\n iq = connection.iq_stanza({'to'=>jid.bare},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSubOwner},\n x('subscriptions',:node => node_id)\n )\n )\n send_iq_stanza_fibered iq\n end", "def subscribe_channels\n @channels.each { |channel| subscribe(channel) }\n end", "def pub_sub_rest_class_method(record_class, rest_class_method_name)\n subscribe_rest_class_method(record_class, rest_class_method_name)\n publish_rest_class_method(record_class, rest_class_method_name)\n end", "def toggle_subscription!\n self.unsubscribed = !unsubscribed\n save\n end", "def subscribe(*topics)\n # FIXME: make sure @connection isn't nil\n @connection.subscribe(*topics)\n end", "def publish( message )\n subscribers.each do |name, subscriber|\n subscriber.produce( message )\n end\n end", "def subscribers\n store[name].map { |r| r.contents } \n end", "def chore_collect chore_info\n @@data_collector.notify chore_info\n end", "def observe\n Observable.new(super)\n end", "def subscribed(subscribable, subscription_level = nil)\n subscribable.subscription_to(self, subscription_level)\n end", "def show_subscriptions\n puts \"\\nYour current subscriptions are:\"\n @user.subscriptions.reload.each do |sub|\n puts sub.name\n end\n end", "def update_relation(plan, m_from, op, m_to, m_rel, m_info = nil)\n\t\tif plan\n\t\t Roby::Distributed.update(peer.local_object(plan)) { update_relation(nil, m_from, op, m_to, m_rel, m_info) }\n\t\telse\n\t\t from, to = \n\t\t\tpeer.local_object(m_from, false), \n\t\t\tpeer.local_object(m_to, false)\n\n\t\t if !from\n\t\t\treturn unless to && (to.self_owned? || to.subscribed?)\n\t\t\tfrom = peer.local_object(m_from)\n\t\t elsif !to\n\t\t\treturn unless from && (from.self_owned? || from.subscribed?)\n\t\t\tto = peer.local_object(m_to)\n\t\t end\n\n\t\t rel = peer.local_object(m_rel)\n\t\t Roby::Distributed.update_all([from.root_object, to.root_object]) do\n\t\t\tif op == :add_child_object\n\t\t\t from.add_child_object(to, rel, peer.local_object(m_info))\n\t\t\telsif op == :remove_child_object\n\t\t\t from.remove_child_object(to, rel)\n\t\t\tend\n\t\t end\n\t\tend\n\t\tnil\n\t end" ]
[ "0.6788774", "0.6597455", "0.6526561", "0.62998605", "0.62750715", "0.62750715", "0.62750715", "0.61798525", "0.6133517", "0.6056338", "0.5970647", "0.590864", "0.5888758", "0.5885154", "0.58544546", "0.58249015", "0.58121973", "0.5762711", "0.572511", "0.57030565", "0.5697442", "0.56958646", "0.5694959", "0.5692773", "0.5678758", "0.5652628", "0.5642442", "0.56275356", "0.56243414", "0.56203777", "0.56119984", "0.56028533", "0.55967516", "0.55814236", "0.55814236", "0.55814236", "0.55814236", "0.5572118", "0.5562257", "0.55505246", "0.5534345", "0.55251175", "0.5521561", "0.55205137", "0.5519942", "0.54899305", "0.5487456", "0.5480611", "0.54694223", "0.54613197", "0.54328704", "0.5424747", "0.54137886", "0.5404554", "0.53931457", "0.53833926", "0.5378277", "0.5375683", "0.53668123", "0.533963", "0.5339022", "0.53371274", "0.53325194", "0.53290546", "0.53237534", "0.5289526", "0.52812403", "0.52812403", "0.52812403", "0.5279426", "0.5265408", "0.5249661", "0.5248674", "0.5240819", "0.52288646", "0.52288646", "0.5214221", "0.52107257", "0.52104366", "0.5204444", "0.5204444", "0.5201825", "0.52014476", "0.5178496", "0.51765674", "0.5173994", "0.5173281", "0.517203", "0.51678", "0.516725", "0.5166339", "0.5164211", "0.5159305", "0.5153738", "0.5150932", "0.51490426", "0.5144788", "0.51356566", "0.51329315", "0.5124631" ]
0.69037145
0
subscribe to rest_class_method and then send message to notify clients that they should call the rest_class_method again
def pub_sub_rest_class_method(record_class, rest_class_method_name) subscribe_rest_class_method(record_class, rest_class_method_name) publish_rest_class_method(record_class, rest_class_method_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def publish_rest_class_method(record_class, rest_class_method_name)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: record_class.to_s,\n rest_class_method: rest_class_method_name\n }\n subscribers.each_slice(10) do |slice|\n channel_array = []\n slice.each do |session_id, last_requested|\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}\", session_id)\n next\n end\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n end", "def subscribe_rest_class_method(record_class, rest_class_method_name)\n return unless session.id\n time_now = Time.now.to_f.to_s\n session_id = session.id.to_s\n Hyperloop.redis_instance.pipelined do\n Hyperloop.redis_instance.hset(\"HRPS__#{record_class}__rest_class_method_name__#{rest_class_method_name}\", session_id, time_now)\n end\n end", "def pub_sub_rest_method(record, rest_method_name)\n subscribe_rest_method(record, rest_method_name)\n publish_rest_method(record, rest_method_name)\n end", "def publish_rest_method(record, rest_method_name)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: record.class.to_s,\n id: record.id,\n rest_method: rest_method_name\n }\n subscribers.each_slice(10) do |slice|\n channel_array = []\n slice.each do |session_id, last_requested|\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\", session_id)\n next\n end\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n end", "def subscribe_rest_method(record, rest_method_name)\n return unless session.id\n time_now = Time.now.to_f.to_s\n session_id = session.id.to_s\n Hyperloop.redis_instance.hset(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\", session_id, time_now)\n end", "def subscribe\n \nend", "def subscribe!\n # TODO: Implement\n end", "def subscribe\n self.subscribed = true\n end", "def subscribed; end", "def subscribe(message_class, process_method)\n debug_me{[ :message_class ]}\n raise ::SmartMessage::Errors::NotImplemented\n end", "def notify(method, *args)\n @serializer.write([2, method, args])\n self\n end", "def request!\n self.type = :subscribe\n reply_if_needed!\n end", "def subscribe\n # PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", \"http://li182-172.members.linode.com/feeds/#{self.id}\", \"async\")\n PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", self.url, \"async\")\n end", "def call\n context.response ||= notify\n end", "def method_missing(meth, *args, &block)\n super unless client.respond_to?(meth)\n\n define_singleton_method meth do |*meth_args, &meth_block|\n client.send(meth, *meth_args, &meth_block)\n end\n\n send(meth, *args, &block)\n end", "def notify_subscribers(resource)\n resource.subscriptions.each do |subscription|\n http = EM::HttpRequest.new(subscription.url).post(:body => {:data => resource.body})\n http.callback{ |response|\n puts \"POSTed updated data for #{resource.url}, #{resource.body.length} characters\"\n }\n http.errback {|response|\n # Do something here, maybe setting the resource\n # to be not checked anymore.\n }\n end\n end", "def fire_async_response(class_method)\n response_id = AsyncResponse.new_response_id\n ZZ::Async::ConnectorWorker.enqueue(response_id, service_identity.id, self.class.name, class_method, params)\n response.headers[\"x-poll-for-response\"] = async_response_url(response_id)\n render :json => {:message => \"poll-for-response\"}\n end", "def rest_class_methods\n @rest_class_methods ||= {}\n end", "def notify(optional_destination, rpc_method, *args)\n # TODO\n end", "def subscribe(args = {})\n :no_response\n end", "def when_class_receives(method_name, &block)\n self.class.when_receiving method_name, &block\n end", "def broadcast_sync(meth, *args)\n @listeners.select { |listener| listener.class.ann(meth, :stem_sync) }.each { |listener| listener.respond meth, *args }\n end", "def subscribed # :doc:\n # Override in subclasses\n end", "def subscribe(cls, &block)\n @subscribers[cls.name] = block\n end", "def subscribe\n debug [self.name, \"incoming\"]\n subscribe_request\n end", "def subscribe_to_newsletter\n SubscribeToNewsletterService.new(self).call\n end", "def rest_endpoint; end", "def method_missing(method, *args, &block)\n if actions(current_api).include? method\n self.class.send(:define_method, method) do |params|\n perform_soap_call(method, params) || perform_rest_call(params)\n end\n send method, *args, &block\n else\n super\n end\n end", "def rest_class_method(name, options = { default_result: '...' })\n rest_class_methods[name] = options\n # @!method promise_[name]\n # @return [Promise] on success the .then block will receive the result of the RPC call as arg\n # on failure the .fail block will receive the HTTP response object as arg\n define_singleton_method(\"promise_#{name}\") do |*args|\n name_args = _name_args(name, *args)\n _class_fetch_states[name_args] = 'i'\n rest_class_methods[name_args] = { result: options[:default_result] } unless rest_class_methods.has_key?(name_args)\n _promise_get_or_patch(\"#{resource_base_uri}/methods/#{name}.json?timestamp=#{`Date.now() + Math.random()`}\", *args).then do |response_json|\n rest_class_methods[name_args][:result] = response_json[:result] # result is parsed json\n _class_fetch_states[name_args] = 'f'\n _notify_class_observers\n rest_class_methods[name_args][:result]\n end.fail do |response|\n error_message = \"#{self.to_s}.#{name}, a rest_method, failed to execute!\"\n `console.error(error_message)`\n response\n end\n end\n # @!method [name]\n # @return result either the default_result ass specified in the options or the real result if the RPC call already finished\n define_singleton_method(name) do |*args|\n name_args = _name_args(name, *args)\n _register_class_observer\n rest_class_methods[name_args] = { result: options[:default_result] } unless rest_class_methods.has_key?(name_args)\n unless _class_fetch_states.has_key?(name_args) && 'fi'.include?(_class_fetch_states[name_args])\n self.send(\"promise_#{name}\", *args)\n end\n rest_class_methods[name_args][:result]\n end\n # @!method update_[name] mark internal structures so that the method is called again once it is requested again\n # @return nil\n define_singleton_method(\"update_#{name}\") do |*args|\n _class_fetch_states[_name_args(name, *args)] = 'u'\n nil\n end\n end", "def method_missing(meth, *args)\n if client.respond_to?(meth)\n client.send(meth, *args)\n else\n super(meth, *args)\n end\n end", "def method_missing(meth, *args, &blk)\n if client.respond_to?(meth)\n client.send(meth, *args, &blk)\n else\n super\n end\n end", "def broadcast(meth, *args)\n @listeners.select { |listener| not listener.class.ann(meth, :stem_sync) }.each do |listener|\n Thread.new do\n begin\n listener.respond meth, *args\n rescue Exception\n options[:logger].error $!\n message(\"Listener #{listener.class.to_s} raised an exception responding to #{meth}: \" + $!.to_s) rescue nil # Try to report the error if possible\n end\n end\n end\n end", "def listen\n raise NotImplementedError.new(\"Implement listen() in your Invoker. \")\n end", "def notify\n end", "def listen(klass, *args)\n supervise klass, name, handlers, *args\n end", "def notify(uri, rpc_method, *args)\n # will block until message is published\n published_l = Mutex.new\n published_c = ConditionVariable.new\n\n uri = URI.parse(uri)\n host,port = uri.host, uri.port\n\n invoked = false\n conn = nil\n message = Messages::Notification.new :method => rpc_method,\n :args => args,\n :headers => @message_headers\n @@em.schedule {\n init_client(:host => host, :port => port,\n :rjr_node => self) { |c|\n conn = c\n c.send_msg message.to_s\n # XXX, this should be invoked only when we are sure event\n # machine sent message. Shouldn't pose a problem unless event\n # machine is killed immediately after\n published_l.synchronize { invoked = true ; published_c.signal }\n }\n }\n published_l.synchronize { published_c.wait published_l unless invoked }\n #sleep 0.01 until conn.get_outbound_data_size == 0\n nil\n end", "def __send__(*rest) end", "def subscriptions; end", "def subscriptions; end", "def subscriptions; end", "def consume_rest; end", "def on_success(_klass, _method); end", "def perform\n @logger.info({context: :monitor, action: :perfomed})\n @client.psubscribe(\"#{service}:*\") do |callback|\n callback.psubscribe(self.on_subscribed)\n callback.pmessage(self.on_message)\n callback.punsubscribe(self.on_unsubscribed)\n end\n end", "def refresh\n raise Occi::Api::Client::Errors::NotImplementedError, \"#{__method__} is just a stub!\"\n end", "def rest_end_point; end", "def subscribe_to_channel; end", "def run_subscribe(conn, dest)\n return if not @need_subscribe\n @log.debug \"run_subscribe starts\"\n conn.subscribe(dest) # call hook\n @log.debug \"run_subscribe done\"\n @need_subscribe = false\n @need_gets = true\nend", "def after_subscribe(subscribed)\n # not required\n end", "def unsubscribed; end", "def subscribe\n @broker.subscribe(*self.class.subscriptions) do |channel, data|\n begin\n perform(channel, data)\n rescue => e\n puts \"Exception #{e}\"\n end\n end\n end", "def notify\n @subscribers.each { |ident, (block,obj)| block.call(obj) }\n end", "def subscribe_to_channel(*)\n synchronize_entrypoint! { super }\n end", "def reroute_callbacks\n @reroute_callbacks\n end", "def on_subscription_success\n end", "def handle_request( * ) # :nodoc:\n\t\tself.log.debug \"[:restresources] handling request for REST resource.\"\n\t\tsuper\n\tend", "def auto_subscribe_topic\n fail NotImplementedError, 'To be implemented by the concrete topic posts controller.'\n end", "def method_missing(method_name, *args, &block)\n return super unless client.respond_to?(method_name)\n client.send(method_name, *args, &block)\n end", "def method_missing(method_name, *args, &block)\n return super unless client.respond_to?(method_name)\n client.send(method_name, *args, &block)\n end", "def method_missing(method_name, *args, &block)\n return super unless client.respond_to?(method_name)\n client.send(method_name, *args, &block)\n end", "def method_missing(method, *args, &block) #:doc:\n super unless @wsdl.respond_to? method\n\n setup method, &block\n dispatch method\n end", "def rest_endpoint=(_arg0); end", "def refresh\n puts \" -- refresh subscriptions(#{@subscriptions.size}):\"\n\n run_callback_server # call it once to make sure it runs\n \n @subscriptions.each do |sub| \n puts \" - #{sub.name}\"\n params = { \"attributes[accept]\" => 'application/json' }\n\n query = \"/gnp;#{sub.name};#{sub.entry_uri}\"\n params[\"attributes[callback_url]\"] = \"#{callback_server.base_url}#{query}\"\n\n [:operations, :uri_regexp, :condition_script].each do |key|\n (v = sub.send key) and params[\"attributes[#{key}]\"] = v\n end\n\n url = \"#{@target_url}#{sub.uri}.xml\"\n http_put(url, params) # {|req| req.content_type = 'application/xml'}\n end\n end", "def register_subresource(resource)\n super.tap do |added|\n if added && action_on_update\n Chef::Log.debug(\"[#{self}] Registering #{action_on_update_immediately ? 'immediate ' : ''}#{action_on_update} notification from #{resource}\")\n resource.notifies action_on_update.to_sym, self, (action_on_update_immediately ? :immediately : :delayed)\n end\n end\n end", "def method_missing(method_name, *arguments, &block)\n client.send(method_name, *arguments, &block)\n end", "def method_missing(method, *args, &block)\n if @client.respond_to?(method)\n define_singleton_method(method) do |*args, &block|\n @client.send(method, *args, &block)\n end\n return send(method, *args, &block)\n end\n super\n end", "def notify\n raise NotImplementedError\n end", "def call\r\n # TODO: rename to more appropriate one 2007/05/10 by shino\r\n self.modify_message\r\n logger.debug{\"Ap4r::Dispatcher after modification\\n#{@message.to_yaml}\"}\r\n self.invoke\r\n self.validate_response\r\n self.response\r\n end", "def subscribe(*args, &blk)\n (@client ||= connect).subscribe(*args, &blk)\n end", "def method_missing(meth, *args, &block)\n @_resource.send(:method_missing, meth, *args, &block)\n end", "def pubsub; end", "def send_notification(method, params); end", "def notify_subscribers\n NotificationSubscription.notify(self)\n end", "def bind_method(service_ref, controller, method_name, desc)\n method_key = method_name.to_s.underscore.to_sym\n controller_name = controller.name\n service_ref.class_eval do\n if desc.request_response?\n define_method(method_key) do |message, active_call|\n Gruf::Autoloaders.controllers.with_fresh_controller(controller_name) do |fresh_controller|\n c = fresh_controller.new(\n method_key: method_key,\n service: service_ref,\n message: message,\n active_call: active_call,\n rpc_desc: desc\n )\n c.call(method_key)\n end\n end\n elsif desc.client_streamer?\n define_method(method_key) do |active_call|\n Gruf::Autoloaders.controllers.with_fresh_controller(controller_name) do |fresh_controller|\n c = fresh_controller.new(\n method_key: method_key,\n service: service_ref,\n message: proc { |&block| active_call.each_remote_read(&block) },\n active_call: active_call,\n rpc_desc: desc\n )\n c.call(method_key)\n end\n end\n elsif desc.server_streamer?\n define_method(method_key) do |message, active_call, &block|\n Gruf::Autoloaders.controllers.with_fresh_controller(controller_name) do |fresh_controller|\n c = fresh_controller.new(\n method_key: method_key,\n service: service_ref,\n message: message,\n active_call: active_call,\n rpc_desc: desc\n )\n c.call(method_key, &block)\n end\n end\n else # bidi\n define_method(method_key) do |messages, active_call, &block|\n Gruf::Autoloaders.controllers.with_fresh_controller(controller_name) do |fresh_controller|\n c = fresh_controller.new(\n method_key: method_key,\n service: service_ref,\n message: messages,\n active_call: active_call,\n rpc_desc: desc\n )\n c.call(method_key, &block)\n end\n end\n end\n end\n end", "def method_missing(method, *args, &block)\n method_name = method.to_s\n sync = method_name.end_with?(\"_sync\")\n async = method_name.end_with?(\"_async\")\n if sync || async\n method_name.gsub!(/_sync$/, '') if sync\n method_name.gsub!(/_async$/, '') if async\n future = send_request(method_name, args, !!sync)\n future.attach_callback(block) if block\n if sync\n @transport.listen_for_return_sync\n future.get\n if future.error\n raise error\n else\n return future.result\n end\n elsif async\n @transport.listen_for_return_async\n return future\n end\n else\n super\n end\n end", "def unsubscribed\n super\n # TODO: abort any pending lookup requests\n end", "def method_missing(method_name, *arguments, **kw_arguments, &block)\n instance_eval <<-End\n def #{method_name} *arguments, **kw_arguments\n @endpoint.sync_call '#{method_name}', *arguments, **kw_arguments\n end\n End\n @endpoint.sync_call method_name, *arguments, **kw_arguments\n end", "def register_rest(handler, &block)\n @register_rest ||= (handler || block)\n end", "def subscribe(&onMessage) # block\n end", "def notifications\n end", "def notify(uri, rpc_method, *args)\n # will block until message is published\n published_l = Mutex.new\n published_c = ConditionVariable.new\n\n invoked = false\n message = Messages::Notification.new :method => rpc_method,\n :args => args,\n :headers => @message_headers\n @@em.schedule {\n init_client(uri) do |c|\n c.stream { |msg| handle_message(msg.data, c) }\n\n c.send_msg message.to_s\n\n # XXX same issue w/ tcp node, due to nature of event machine\n # we aren't guaranteed that message is actually written to socket\n # here, process must be kept alive until data is sent or will be lost\n published_l.synchronize { invoked = true ; published_c.signal }\n end\n }\n published_l.synchronize { published_c.wait published_l unless invoked }\n nil\n end", "def curl_subscribe!\n Helpers.thread { curl_subscribe }\n rescue => e\n Helpers.before_retry(e)\n retry\n end", "def methods(*args)\n super | rpc_methods\n end", "def initialize(routing, client_class)\n super\n WorklingRabbitMQSubscriber.sleep_time = Workling.config[:sleep_time] || 0.2\n end", "def rest_method(name, options = { default_result: '...' })\n # @!method promise_[name]\n # @return [Promise] on success the .then block will receive the result of the RPC call as arg\n # on failure the .fail block will receive the HTTP response object as arg\n define_method(\"promise_#{name}\") do |*args|\n name_args = self.class._name_args(name, *args)\n @fetch_states[name_args] = 'i'\n @rest_methods[name] = {}.merge!(options) unless @rest_methods.has_key?(name)\n @rest_methods[name_args] = { result: options[:default_result] } unless @rest_methods.has_key?(name_args) && @rest_methods[name_args].has_key?(:result)\n raise \"#{self.class.to_s}[_no_id_].#{name}, can't execute instance rest_method without id!\" unless self.id\n self.class._promise_get_or_patch(\"#{resource_base_uri}/#{self.id}/methods/#{name}.json?timestamp=#{`Date.now() + Math.random()`}\", *args).then do |response_json|\n @rest_methods[name_args][:result] = response_json[:result] # result is parsed json\n @fetch_states[name_args] = 'f'\n _notify_observers\n @rest_methods[name_args][:result]\n end.fail do |response|\n error_message = \"#{self.class.to_s}[#{self.id}].#{name}, a rest_method, failed to execute!\"\n `console.error(error_message)`\n response\n end\n end\n # @!method [name]\n # @return result either the default_result ass specified in the options or the real result if the RPC call already finished\n define_method(name) do |*args|\n _register_observer\n name_args = self.class._name_args(name, *args)\n @rest_methods[name] = {}.merge!(options) unless @rest_methods.has_key?(name)\n @rest_methods[name_args] = { result: options[:default_result] } unless @rest_methods.has_key?(name_args) && @rest_methods[name_args].has_key?(:result)\n unless @fetch_states.has_key?(name_args) && 'fi'.include?(@fetch_states[name_args])\n self.send(\"promise_#{name}\", *args)\n end\n @rest_methods[name_args][:result]\n end\n # @!method update_[name] mark internal structures so that the method is called again once it is requested again\n # @return nil\n define_method(\"update_#{name}\") do |*args|\n @fetch_states[self.class._name_args(name, *args)] = 'u'\n nil\n end\n end", "def method_missing(method, *params, &block)\n @endpoint_parts << method.to_s\n\n @endpoint_parts << params\n @endpoint_parts = @endpoint_parts.flatten!\n\n block&.call\n\n self || super\n end", "def listen\r\n end", "def notify_post\n raise \"not yet implemented\"\n end", "def notify\n {\n }\n end", "def notify\n {\n }\n end", "def listen\n # TODO\n self\n end", "def notify\n begin\n request(@config.method, @config.url, payload_data, @config.format)\n true\n rescue Exception => ex\n log_error(ex) if @config.has_logger?\n false\n end\n end", "def notifier; end", "def notifier; end", "def public_class_method(*rest) end", "def on_refresh(&block)\n @connection.on_refresh_cb = block\n end", "def subscribe(process_method=nil)\n message_class = whoami\n process_method = message_class + '.process' if process_method.nil?\n\n debug_me{[ :message_class, :process_method ]}\n\n raise Errors::BrokerNotConfigured if broker_missing?\n broker.subscribe(message_class, process_method)\n end", "def method_missing(method_name, *args)\n payload = Kauplus::Client.authenticate_payload(args.first)\n if method_name.match(/(get|post|multipart_post|put|delete|head)_(.*)/)\n Kauplus::Client.send($1, \"#{@resource}/#{$2}\", payload)\n else\n Kauplus::Client.get(\"#{@resource}/#{method_name}\", payload)\n end\n end", "def register!\n return if @registered\n @registered = true\n\n self.behavior = :notify\n @subscriber = ActiveSupport::Notifications.subscribe(%r{^deprecation}) do |*args|\n queue.enqueue args\n end\n end", "def method_missing(method, *args)\n single_request(method, args)\n end", "def notify(data={})\n RestClient::Request.execute(:method => :post, :url => notify_path, :payload => data, :timeout => TIMEOUT, :open_timeout => TIMEOUT)\n rescue\n nil\n end" ]
[ "0.7280258", "0.701402", "0.69165057", "0.66378623", "0.65532345", "0.6181606", "0.61627847", "0.6101013", "0.5899211", "0.5891438", "0.5869018", "0.57853174", "0.5780493", "0.57291096", "0.5660718", "0.5625182", "0.56130886", "0.5559812", "0.5550139", "0.55158293", "0.55142236", "0.55037975", "0.550338", "0.5492885", "0.54877734", "0.54747206", "0.547251", "0.546541", "0.5453151", "0.54326046", "0.54229605", "0.5407943", "0.5396046", "0.53871995", "0.53757674", "0.53523165", "0.5346423", "0.534555", "0.534555", "0.534555", "0.53278536", "0.53129685", "0.5299333", "0.5294398", "0.5291164", "0.5284004", "0.52610034", "0.5244658", "0.5243812", "0.5229485", "0.5221319", "0.5221086", "0.5212649", "0.52110344", "0.5210182", "0.52083194", "0.52081156", "0.52081156", "0.52081156", "0.5208113", "0.5195195", "0.5193885", "0.5188865", "0.5185703", "0.51791716", "0.51765287", "0.51657706", "0.516408", "0.51560503", "0.5154451", "0.5142248", "0.51401126", "0.5120751", "0.5109764", "0.5108148", "0.5100502", "0.50884855", "0.5086237", "0.5083963", "0.5080137", "0.5075806", "0.50729924", "0.5068762", "0.5064692", "0.5055892", "0.5036202", "0.50326514", "0.5020913", "0.5020913", "0.50055087", "0.49961668", "0.49917495", "0.49917495", "0.49914944", "0.49878824", "0.497879", "0.49754333", "0.4963288", "0.4959076", "0.49581793" ]
0.74487114
0
subscribe to rest_method and then send message to notify clients that they should call the rest_method again
def pub_sub_rest_method(record, rest_method_name) subscribe_rest_method(record, rest_method_name) publish_rest_method(record, rest_method_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def publish_rest_method(record, rest_method_name)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: record.class.to_s,\n id: record.id,\n rest_method: rest_method_name\n }\n subscribers.each_slice(10) do |slice|\n channel_array = []\n slice.each do |session_id, last_requested|\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\", session_id)\n next\n end\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n end", "def subscribe_rest_method(record, rest_method_name)\n return unless session.id\n time_now = Time.now.to_f.to_s\n session_id = session.id.to_s\n Hyperloop.redis_instance.hset(\"HRPS__#{record.class}__#{record.id}__rest_method__#{rest_method_name}\", session_id, time_now)\n end", "def pub_sub_rest_class_method(record_class, rest_class_method_name)\n subscribe_rest_class_method(record_class, rest_class_method_name)\n publish_rest_class_method(record_class, rest_class_method_name)\n end", "def subscribe\n \nend", "def publish_rest_class_method(record_class, rest_class_method_name)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: record_class.to_s,\n rest_class_method: rest_class_method_name\n }\n subscribers.each_slice(10) do |slice|\n channel_array = []\n slice.each do |session_id, last_requested|\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{record_class}__rest_class_method__#{rest_class_method_name}\", session_id)\n next\n end\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n end", "def subscribe!\n # TODO: Implement\n end", "def request!\n self.type = :subscribe\n reply_if_needed!\n end", "def subscribe_rest_class_method(record_class, rest_class_method_name)\n return unless session.id\n time_now = Time.now.to_f.to_s\n session_id = session.id.to_s\n Hyperloop.redis_instance.pipelined do\n Hyperloop.redis_instance.hset(\"HRPS__#{record_class}__rest_class_method_name__#{rest_class_method_name}\", session_id, time_now)\n end\n end", "def subscribe\n self.subscribed = true\n end", "def subscribe(args = {})\n :no_response\n end", "def subscribe\n # PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", \"http://li182-172.members.linode.com/feeds/#{self.id}\", \"async\")\n PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", self.url, \"async\")\n end", "def call\n context.response ||= notify\n end", "def notify_subscribers(resource)\n resource.subscriptions.each do |subscription|\n http = EM::HttpRequest.new(subscription.url).post(:body => {:data => resource.body})\n http.callback{ |response|\n puts \"POSTed updated data for #{resource.url}, #{resource.body.length} characters\"\n }\n http.errback {|response|\n # Do something here, maybe setting the resource\n # to be not checked anymore.\n }\n end\n end", "def subscribed; end", "def notify(method, *args)\n @serializer.write([2, method, args])\n self\n end", "def subscribe\n debug [self.name, \"incoming\"]\n subscribe_request\n end", "def rest_endpoint; end", "def notify(optional_destination, rpc_method, *args)\n # TODO\n end", "def notify(uri, rpc_method, *args)\n # will block until message is published\n published_l = Mutex.new\n published_c = ConditionVariable.new\n\n uri = URI.parse(uri)\n host,port = uri.host, uri.port\n\n invoked = false\n conn = nil\n message = Messages::Notification.new :method => rpc_method,\n :args => args,\n :headers => @message_headers\n @@em.schedule {\n init_client(:host => host, :port => port,\n :rjr_node => self) { |c|\n conn = c\n c.send_msg message.to_s\n # XXX, this should be invoked only when we are sure event\n # machine sent message. Shouldn't pose a problem unless event\n # machine is killed immediately after\n published_l.synchronize { invoked = true ; published_c.signal }\n }\n }\n published_l.synchronize { published_c.wait published_l unless invoked }\n #sleep 0.01 until conn.get_outbound_data_size == 0\n nil\n end", "def subscribe(*args, &blk)\n (@client ||= connect).subscribe(*args, &blk)\n end", "def subscriptions; end", "def subscriptions; end", "def subscriptions; end", "def rest_endpoint=(_arg0); end", "def refresh\n puts \" -- refresh subscriptions(#{@subscriptions.size}):\"\n\n run_callback_server # call it once to make sure it runs\n \n @subscriptions.each do |sub| \n puts \" - #{sub.name}\"\n params = { \"attributes[accept]\" => 'application/json' }\n\n query = \"/gnp;#{sub.name};#{sub.entry_uri}\"\n params[\"attributes[callback_url]\"] = \"#{callback_server.base_url}#{query}\"\n\n [:operations, :uri_regexp, :condition_script].each do |key|\n (v = sub.send key) and params[\"attributes[#{key}]\"] = v\n end\n\n url = \"#{@target_url}#{sub.uri}.xml\"\n http_put(url, params) # {|req| req.content_type = 'application/xml'}\n end\n end", "def curl_subscribe!\n Helpers.thread { curl_subscribe }\n rescue => e\n Helpers.before_retry(e)\n retry\n end", "def subscribe\n Socky.send( {:action => \"subscribe\",\n :channel => params[:channel],\n :client => (params[:client_id] || '')}.to_json)\n render :text => \"ok\"\n end", "def rest_end_point; end", "def on_subscription_success\n end", "def subscribe_to_channel; end", "def perform\n @logger.info({context: :monitor, action: :perfomed})\n @client.psubscribe(\"#{service}:*\") do |callback|\n callback.psubscribe(self.on_subscribed)\n callback.pmessage(self.on_message)\n callback.punsubscribe(self.on_unsubscribed)\n end\n end", "def httpAndNotify(path, params, msg_from, method)\n message = \"\"\n begin\n \n m = \"\"\n if method == :get\n m = \"GET\"\n elsif method == :post\n m = \"POST\"\n elsif method == :put\n m = \"PUT\"\n elsif method == :delete\n m = \"DELETE\"\n else\n raise Exception.new(\"Wrong method! use: :get, :post, :put or :delete!\")\n end\n \n puts \"HTTP #{m} to: #{@@http_host + path}\"\n res = HttpRequest.new(method, path, params).send(@@http_host)\n message = \"#{res.code.to_s}; #{res.body}; #{path}\"\n \n rescue Exception => e\n puts \"Error: \" + e.to_s\n puts \" -- line #{e.backtrace[0].to_s}\"\n message = \"#{e.to_s}; #{path}\"\n end\n \n # Notifies the xmpp-client about the http-rest result \n puts \"xmpp-response\"\n notification = {:receiver => msg_from, :message => message}\n sendMessage(notification, @receive_client)\n \n end", "def notify(data={})\n RestClient::Request.execute(:method => :post, :url => notify_path, :payload => data, :timeout => TIMEOUT, :open_timeout => TIMEOUT)\n rescue\n nil\n end", "def subscribe_to_newsletter\n SubscribeToNewsletterService.new(self).call\n end", "def consume_rest; end", "def run_subscribe(conn, dest)\n return if not @need_subscribe\n @log.debug \"run_subscribe starts\"\n conn.subscribe(dest) # call hook\n @log.debug \"run_subscribe done\"\n @need_subscribe = false\n @need_gets = true\nend", "def register_subresource(resource)\n super.tap do |added|\n if added && action_on_update\n Chef::Log.debug(\"[#{self}] Registering #{action_on_update_immediately ? 'immediate ' : ''}#{action_on_update} notification from #{resource}\")\n resource.notifies action_on_update.to_sym, self, (action_on_update_immediately ? :immediately : :delayed)\n end\n end\n end", "def method_missing(method, *args, &block)\n if actions(current_api).include? method\n self.class.send(:define_method, method) do |params|\n perform_soap_call(method, params) || perform_rest_call(params)\n end\n send method, *args, &block\n else\n super\n end\n end", "def unsubscribed; end", "def subscribed # :doc:\n # Override in subclasses\n end", "def after_subscribe(subscribed)\n # not required\n end", "def do_subscribe(params)\n mode = params['hub.mode']\n callback = params['hub.callback']\n topic = params['hub.topic']\n verify = params['hub.verify']\n vtoken = params['hub.verify_token']\n \n content_type 'text/plain', :charset => 'utf-8'\n unless callback and topic and verify\n throw :halt, [400, \"Bad request: Expected 'hub.callback', 'hub.topic', and 'hub.verify'\"]\n end\n throw :halt, [400, \"Bad request: Empty 'hub.callback' or 'hub.topic'\"] if (callback.empty? or topic.empty?)\n # anchor part in the url not allowed by the spec\n throw :halt, [400, \"Bad request: Invalid URL\"] if (callback.include?('#') or topic.include?('#'))\n \n throw :halt, [400, \"Bad request: Unrecognized mode\"] unless ['subscribe', 'unsubscribe'].include?(mode)\n\n # Processing optional secret\n secret = params['hub.secret'] ? params['hub.secret'] : ''\n \n # remove invalid verify modes \n verify = Array(verify.split(',')).delete_if { |x| not ['sync','async'].include?(x) }\n throw :halt, [400, \"Bad request: Unrecognized verification mode\"] if verify.empty?\n # For now, only using the first preference of verify mode\n verify = verify[0]\n #throw :halt, [400, \"Bad request: Unrecognized verification mode\"] unless ['sync', 'async'].include?(verify)\n begin\n hash = Topic.to_hash(topic)\n tp = DB[:topics].filter(:url => hash).first\n throw :halt, [404, \"Not Found\"] unless tp[:id]\n \n state = (verify == 'async') ? 1 : 0\n query = { 'hub.mode' => mode,\n 'hub.topic' => topic,\n 'hub.lease_seconds' => 0, # still no subscription refreshing support\n 'hub.challenge' => gen_id}\n query['hub.verify_token'] = vtoken if vtoken\n if verify == 'sync'\n MyTimer.timeout(Config::GIVEUP) do\n res = HTTPClient.get_content(callback, query)\n opts = \"m=#{mode} c=#{callback} t=#{topic} v=#{verify} -> res=#{res.inspect}\"\n raise \"do_verify(#{opts})\" unless res and res == query['hub.challenge']\n end\n state = 0\n end\n \n # Add subscription\n # subscribe/unsubscribe to/from ALL channels with that topic\n cb = DB[:subscriptions].filter(:topic_id => tp[:id], :callback => Topic.to_hash(callback))\n cb.delete if (mode == 'unsubscribe' or cb.first)\n if mode == 'subscribe'\n raise \"DB insert failed\" unless DB[:subscriptions] << {\n :topic_id => tp[:id], :callback => Topic.to_hash(callback), \n :vtoken => vtoken, :vmode => verify, :secret => secret, :state => state }\n end\n throw :halt, verify == 'async' ? [202, \"202 Scheduled for verification\"] : \n [204, \"204 No Content\"]\n rescue Exception => e\n throw :halt, [409, \"Subscription verification failed: #{e.to_s}\"]\n end\n end", "def notify(uri, rpc_method, *args)\n # will block until message is published\n published_l = Mutex.new\n published_c = ConditionVariable.new\n\n invoked = false\n message = Messages::Notification.new :method => rpc_method,\n :args => args,\n :headers => @message_headers\n @@em.schedule {\n init_client(uri) do |c|\n c.stream { |msg| handle_message(msg.data, c) }\n\n c.send_msg message.to_s\n\n # XXX same issue w/ tcp node, due to nature of event machine\n # we aren't guaranteed that message is actually written to socket\n # here, process must be kept alive until data is sent or will be lost\n published_l.synchronize { invoked = true ; published_c.signal }\n end\n }\n published_l.synchronize { published_c.wait published_l unless invoked }\n nil\n end", "def do_subscribe\n subscribe_to(@nodename)\n get_subscriptions\n end", "def broadcast_sync(meth, *args)\n @listeners.select { |listener| listener.class.ann(meth, :stem_sync) }.each { |listener| listener.respond meth, *args }\n end", "def method_missing(meth, *args, &block)\n super unless client.respond_to?(meth)\n\n define_singleton_method meth do |*meth_args, &meth_block|\n client.send(meth, *meth_args, &meth_block)\n end\n\n send(meth, *args, &block)\n end", "def notify\n end", "def refresh\n raise Occi::Api::Client::Errors::NotImplementedError, \"#{__method__} is just a stub!\"\n end", "def pubsub; end", "def unsubscribed\n super\n # TODO: abort any pending lookup requests\n end", "def subscribe_to_updates\n if @subscription = @requestor.find_or_create_subscriptions(@target.id)\n @subscription.update_attributes(blocked: false) if @subscription.blocked?\n render json: { success: true }\n else\n render json: {message: @subscription.errors&.full_messages || 'Unable to subscriber updates, please try again'}, status: 202\n end\n end", "def send_notification(method, params); end", "def subscribe\n @broker.subscribe(*self.class.subscriptions) do |channel, data|\n begin\n perform(channel, data)\n rescue => e\n puts \"Exception #{e}\"\n end\n end\n end", "def restart!\n CouchRest.post \"#{@uri}/_restart\"\n end", "def auto_subscribe_topic\n fail NotImplementedError, 'To be implemented by the concrete topic posts controller.'\n end", "def subscribe_to_channel(*)\n synchronize_entrypoint! { super }\n end", "def broadcast(meth, *args)\n @listeners.select { |listener| not listener.class.ann(meth, :stem_sync) }.each do |listener|\n Thread.new do\n begin\n listener.respond meth, *args\n rescue Exception\n options[:logger].error $!\n message(\"Listener #{listener.class.to_s} raised an exception responding to #{meth}: \" + $!.to_s) rescue nil # Try to report the error if possible\n end\n end\n end\n end", "def notify\n begin\n request(@config.method, @config.url, payload_data, @config.format)\n true\n rescue Exception => ex\n log_error(ex) if @config.has_logger?\n false\n end\n end", "def call_rest(verb, url, xml=nil, content_type='text/xml')\n begin\n case verb.to_sym\n when :get\n RestClient.get(url)\n when :post\n RestClient.post(url, xml, :content_type => content_type)\n when :put\n RestClient.put(url, xml, :content_type => content_type)\n when :delete\n RestClient.delete(url)\n end\n rescue => e\n puts \"Exception at: #{url}\"\n puts e.response ? e.response : e\n end\n end", "def handle_request( * ) # :nodoc:\n\t\tself.log.debug \"[:restresources] handling request for REST resource.\"\n\t\tsuper\n\tend", "def remote_call(remote_method, params)\n correlation_id = SecureRandom.uuid\n message = { id: correlation_id, jsonrpc: '2.0', method: remote_method, params: params}\n # Reply To => make sure the service knows where to send it's response.\n # Correlation ID => identify the results that belong to the unique call made\n @exchange.publish(message.to_json, routing_key: @server_queue.name, correlation_id: correlation_id,\n reply_to: @reply_queue.name)\n result = @results[correlation_id].pop\n @results.delete correlation_id # remove item from hash. prevents memory leak.\n result\n end", "def subscribe(&onMessage) # block\n end", "def method_missing(meth, *args)\n if client.respond_to?(meth)\n client.send(meth, *args)\n else\n super(meth, *args)\n end\n end", "def subscribe(message_class, process_method)\n debug_me{[ :message_class ]}\n raise ::SmartMessage::Errors::NotImplemented\n end", "def method_missing(meth, *args, &blk)\n if client.respond_to?(meth)\n client.send(meth, *args, &blk)\n else\n super\n end\n end", "def method_missing(method, *args, &block)\n method_name = method.to_s\n sync = method_name.end_with?(\"_sync\")\n async = method_name.end_with?(\"_async\")\n if sync || async\n method_name.gsub!(/_sync$/, '') if sync\n method_name.gsub!(/_async$/, '') if async\n future = send_request(method_name, args, !!sync)\n future.attach_callback(block) if block\n if sync\n @transport.listen_for_return_sync\n future.get\n if future.error\n raise error\n else\n return future.result\n end\n elsif async\n @transport.listen_for_return_async\n return future\n end\n else\n super\n end\n end", "def fire_async_response(class_method)\n response_id = AsyncResponse.new_response_id\n ZZ::Async::ConnectorWorker.enqueue(response_id, service_identity.id, self.class.name, class_method, params)\n response.headers[\"x-poll-for-response\"] = async_response_url(response_id)\n render :json => {:message => \"poll-for-response\"}\n end", "def request module_id, msg, &block\n req_id = @req_id\n @req_id += 1\n @callbacks[req_id] = block\n msg[:client_id] = @client_id\n msg[:username] = @username\n @ws.send ['client', compose_request(req_id, module_id, msg)].to_json\n end", "def notifications\n end", "def subscribe\n @conn.send_data :opcode => SUBSCRIBE, :channel => @name\n @subscribe_sent = true\n end", "def request(method, message = nil)\n @client.call(method, message:)\n end", "def listen\n raise NotImplementedError.new(\"Implement listen() in your Invoker. \")\n end", "def successful_unsubscribe\n end", "def push_subscription\n\t\trender :nothing => true\n\tend", "def unsubscribed\n end", "def unsubscribed\n end", "def reroute_callbacks\n @reroute_callbacks\n end", "def subscribed\n super\n increase_current_users\n stream_from channel\n end", "def methods(*args)\n super | rpc_methods\n end", "def unsubscribed\n\tend", "def send_request; end", "def rest_method(name, options = { default_result: '...' })\n # @!method promise_[name]\n # @return [Promise] on success the .then block will receive the result of the RPC call as arg\n # on failure the .fail block will receive the HTTP response object as arg\n define_method(\"promise_#{name}\") do |*args|\n name_args = self.class._name_args(name, *args)\n @fetch_states[name_args] = 'i'\n @rest_methods[name] = {}.merge!(options) unless @rest_methods.has_key?(name)\n @rest_methods[name_args] = { result: options[:default_result] } unless @rest_methods.has_key?(name_args) && @rest_methods[name_args].has_key?(:result)\n raise \"#{self.class.to_s}[_no_id_].#{name}, can't execute instance rest_method without id!\" unless self.id\n self.class._promise_get_or_patch(\"#{resource_base_uri}/#{self.id}/methods/#{name}.json?timestamp=#{`Date.now() + Math.random()`}\", *args).then do |response_json|\n @rest_methods[name_args][:result] = response_json[:result] # result is parsed json\n @fetch_states[name_args] = 'f'\n _notify_observers\n @rest_methods[name_args][:result]\n end.fail do |response|\n error_message = \"#{self.class.to_s}[#{self.id}].#{name}, a rest_method, failed to execute!\"\n `console.error(error_message)`\n response\n end\n end\n # @!method [name]\n # @return result either the default_result ass specified in the options or the real result if the RPC call already finished\n define_method(name) do |*args|\n _register_observer\n name_args = self.class._name_args(name, *args)\n @rest_methods[name] = {}.merge!(options) unless @rest_methods.has_key?(name)\n @rest_methods[name_args] = { result: options[:default_result] } unless @rest_methods.has_key?(name_args) && @rest_methods[name_args].has_key?(:result)\n unless @fetch_states.has_key?(name_args) && 'fi'.include?(@fetch_states[name_args])\n self.send(\"promise_#{name}\", *args)\n end\n @rest_methods[name_args][:result]\n end\n # @!method update_[name] mark internal structures so that the method is called again once it is requested again\n # @return nil\n define_method(\"update_#{name}\") do |*args|\n @fetch_states[self.class._name_args(name, *args)] = 'u'\n nil\n end\n end", "def method_missing(method_name, *args)\n payload = Kauplus::Client.authenticate_payload(args.first)\n if method_name.match(/(get|post|multipart_post|put|delete|head)_(.*)/)\n Kauplus::Client.send($1, \"#{@resource}/#{$2}\", payload)\n else\n Kauplus::Client.get(\"#{@resource}/#{method_name}\", payload)\n end\n end", "def notify module_id, msg\n msg[:client_id] = @client_id\n msg[:username] = @username\n @ws.send ['client', compose_request(nil, module_id, msg)].to_json\n end", "def method_missing(method_name, *args, &block)\n return super unless client.respond_to?(method_name)\n client.send(method_name, *args, &block)\n end", "def method_missing(method_name, *args, &block)\n return super unless client.respond_to?(method_name)\n client.send(method_name, *args, &block)\n end", "def method_missing(method_name, *args, &block)\n return super unless client.respond_to?(method_name)\n client.send(method_name, *args, &block)\n end", "def subscribe(url, id = nil, opts = {}, &block)\n feed_id = \"#{id ? id : Base64.urlsafe_encode64(url)}\"\n if block\n @verifications[feed_id] ||= {}\n @verifications[feed_id]['subscribe'] = block\n end\n endpoint = opts[:hub] || SUPERFEEDR_ENDPOINT\n opts.delete(:hub)\n\n retrieve = opts[:retrieve] || false\n opts.delete(:retrieve)\n\n\n if endpoint == SUPERFEEDR_ENDPOINT\n opts[:userpwd] = \"#{@params[:login]}:#{@params[:password]}\"\n end\n\n\n opts = opts.merge({\n :params => {\n 'hub.mode' => 'subscribe',\n 'hub.topic' => url,\n 'hub.callback' => generate_callback(url, feed_id)\n },\n :headers => {\n :accept => @params[:format] == \"json\" ? \"application/json\" : \"application/atom+xml\"\n }\n })\n\n if retrieve\n opts[:params][:retrieve] = true\n end\n\n opts[:params][:'hub.verify'] = @params[:async] ? 'async' : 'sync'\n\n response = http_post(endpoint, opts)\n\n #@error = response.body\n\n # TODO Log error (response.body)\n if !retrieve\n @params[:async] && response.code == '202' || response.code == '204' # We return true to indicate the status.\n else\n\n if response.code == 200\n\n if @params[:format] != \"json\"\n content = Nokogiri.XML(response.body)\n else\n content = JSON.parse(response.body)\n end\n # Let's now send that data back to the user.\n if defined? Hashie::Mash\n info = Hashie::Mash.new(req: req, body: body)\n end\n if [email protected](content, feed_id, info)\n # We need to unsubscribe the user\n end\n true\n else\n puts \"Error #{response.code}. #{@error}\"\n false\n end\n end\n end", "def send_notification method, params\n response = {\n jsonrpc: \"2.0\",\n method: method,\n params: params\n }\n json = response.to_json\n envelope = \"Content-Length: #{json.bytesize}\\r\\n\\r\\n#{json}\"\n queue envelope\n end", "def reset_whats_new_for_all_users \n get(\"/users.json/news/reset\")\nend", "def reset_whats_new_for_all_users \n get(\"/users.json/news/reset\")\nend", "def notify\n @subscribers.each { |ident, (block,obj)| block.call(obj) }\n end", "def test_start_auction_to_one_server_should_replicate\n reset(REP_SERVERS)\n server1, server2, server3 = REP_SERVERS\n name = \"gau2\"\n \n do_rest(server1, :start_auction, {name: name, end_time: Time.now.to_i + 3})\n do_rest(server1, :bid, {name: name, client:1, bid:100})\n res = do_rest(server1, :status, {name: name})\n assert_equal(\"1\", res.strip)\n\n res = do_rest(server2, :status, {name: name})\n assert_equal(\"1\", res.strip)\n res = do_rest(server3, :status, {name: name})\n assert_equal(\"1\", res.strip)\n end", "def notification(method, *args)\n data = Request.new(method, args, nil).data\n RPC.log \"CLIENT ENCODE NOTIFICATION #{data.inspect}\"\n data.to_json\n end", "def subscribe_notifications\n @subscribe_notifications ||= true\n end", "def subscribe(_topic, **)\n raise 'not implemented'\n end", "def subscribe_request_hook(name = SecureRandom.hex.to_sym, &block)\n EasyPost::Hooks.subscribe(:request, name, block)\n end", "def on_refresh(&block)\n @connection.on_refresh_cb = block\n end", "def resting(args = {})\n args[:work_type] = REST_TYPE\n workpattern(args)\n end", "def method_missing(method, *params, &block)\n @endpoint_parts << method.to_s\n\n @endpoint_parts << params\n @endpoint_parts = @endpoint_parts.flatten!\n\n block&.call\n\n self || super\n end" ]
[ "0.6859852", "0.67546505", "0.6643123", "0.65063757", "0.6396501", "0.6371607", "0.62836903", "0.626599", "0.6175847", "0.60430044", "0.6018183", "0.5981468", "0.5972004", "0.5847349", "0.58340645", "0.5801273", "0.578398", "0.57807577", "0.56387025", "0.5578157", "0.5568382", "0.5568382", "0.5568382", "0.552441", "0.54868627", "0.5485129", "0.54730195", "0.5458905", "0.5453071", "0.54514045", "0.5424929", "0.54234934", "0.54196227", "0.54055935", "0.54050386", "0.54013115", "0.53687906", "0.5366781", "0.5362699", "0.5359545", "0.53582793", "0.53533596", "0.53271943", "0.53271025", "0.5322697", "0.5288512", "0.528828", "0.5284798", "0.52618176", "0.5254028", "0.5251054", "0.5239146", "0.52372193", "0.5231576", "0.5216818", "0.5215205", "0.5199983", "0.51972187", "0.51966065", "0.51672083", "0.5160568", "0.5160558", "0.51604176", "0.5150158", "0.51443243", "0.5142119", "0.5139954", "0.51385975", "0.51321125", "0.5128203", "0.51220036", "0.5121953", "0.5118241", "0.5112884", "0.5112441", "0.5112441", "0.5102051", "0.5100513", "0.50978494", "0.5096831", "0.5091518", "0.5069072", "0.50616646", "0.5061596", "0.5061484", "0.5061484", "0.5061484", "0.50554514", "0.50546014", "0.50539875", "0.50539875", "0.5049094", "0.50405294", "0.503929", "0.50371623", "0.50356275", "0.5032476", "0.5031271", "0.50286305", "0.5025022" ]
0.7372814
0
subscribe to scope changes and send message about scope change to all subscribers
def pub_sub_scope(collection, record_class, scope_name) subscribe_scope(collection, record_class, scope_name) publish_scope(record_class, scope_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def publish_scope(record_class, scope_name)\n subscribers = Hyperloop.redis_instance.hgetall(\"HRPS__#{record_class}__scope__#{scope_name}\")\n time_now = Time.now.to_f\n scrub_time = time_now - 24.hours.to_f\n message = {\n record_type: record_class.to_s,\n scope: scope_name\n }\n subscribers.each_slice(10) do |slice|\n channel_array = []\n slice.each do |session_id, last_requested|\n if last_requested.to_f < scrub_time\n Hyperloop.redis_instance.hdel(\"HRPS__#{record_class}__scope__#{scope_name}\", session_id)\n next\n end\n channel_array << \"hyper-record-update-channel-#{session_id}\"\n end\n if Hyperloop.resource_transport == :pusher\n _pusher_client.trigger_async(channel_array, 'update', message)\n elsif Hyperloop.resource_transport == :action_cable\n channel_array.each do |channel|\n ActionCable.server.broadcast(channel, message)\n end\n end\n end\n end", "def subscribed; end", "def scopeChanged\n pp [:got_scopeChanged] if $DEBUG\n end", "def subscribe!\n # TODO: Implement\n end", "def subscribe\n self.subscribed = true\n end", "def subscriptions; end", "def subscriptions; end", "def subscriptions; end", "def subscribed # :doc:\n # Override in subclasses\n end", "def subscribed\n super\n increase_current_users\n stream_from channel\n end", "def subscribe_to_channel; end", "def subscribe\n \nend", "def notify_subscribers\n NotificationSubscription.notify(self)\n end", "def send_update\n changed\n notify_observers(self)\n end", "def notify_subscribers\n AdminMailer.notify_of_standard_change(self)\n end", "def subscribe(data)\n # @channels (local tracker)\n # push channel name into subscribe list, if and only if not already in subscribe list\n end", "def do_subscribe\n subscribe_to(@nodename)\n get_subscriptions\n end", "def subscribe_channels\n @channels.each { |channel| subscribe(channel) }\n end", "def sync_scopes(related_records, record, filtering = true)\n #related_records = related_records.intersection([*@collection])\n related_records = in_this_collection(related_records) if filtering\n live_scopes.each { |scope| scope.sync_scopes(related_records, record, filtering) }\n notify_of_change unless related_records.empty?\n ensure\n @pre_sync_related_records = nil\n end", "def notify_subscribers(resource)\n resource.subscriptions.each do |subscription|\n http = EM::HttpRequest.new(subscription.url).post(:body => {:data => resource.body})\n http.callback{ |response|\n puts \"POSTed updated data for #{resource.url}, #{resource.body.length} characters\"\n }\n http.errback {|response|\n # Do something here, maybe setting the resource\n # to be not checked anymore.\n }\n end\n end", "def notification_recipient_scope=(value)\n @notification_recipient_scope = value\n end", "def update_scope\n @scope = params[:scope] || params[:q] || {}\n end", "def notify\n @subscribers.each { |ident, (block,obj)| block.call(obj) }\n end", "def subscribe_scope(collection, record_class = nil, scope_name = nil)\n return unless session.id\n time_now = Time.now.to_f.to_s\n session_id = session.id.to_s\n Hyperloop.redis_instance.pipelined do\n if collection.is_a?(Enumerable)\n collection.each do |record|\n Hyperloop.redis_instance.hset(\"HRPS__#{record.class}__#{record.id}\", session_id, time_now)\n end\n end\n Hyperloop.redis_instance.hset(\"HRPS__#{record_class}__scope__#{scope_name}\", session_id, time_now) if record_class && scope_name\n end\n end", "def update_scopes\n if changes = friendly_id_changes\n friendly_id_config.child_scopes.each do |klass|\n Slug.update_all \"scope = '#{changes[1]}'\", [\"sluggable_type = ? AND scope = ?\", klass.to_s, changes[0]]\n end\n end\n end", "def update_scopes\n if changes = friendly_id_changes\n friendly_id_config.child_scopes.each do |klass|\n Slug.update_all \"scope = '#{changes[1]}'\", [\"sluggable_type = ? AND scope = ?\", klass.to_s, changes[0]]\n end\n end\n end", "def unsubscribed; end", "def subscribed\n \t#stream_from 'demo_chan'\n end", "def scopes; end", "def subscribe\n debug [self.name, \"incoming\"]\n subscribe_request\n end", "def notfiy_subscribers(params)\n subject = params[:subscribable]\n\n subject.subscribers.each do |subscriber|\n subscriber.notify(subject, params[:message])\n end\n\n continue(params)\n end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def scope; end", "def refresh\n puts \" -- refresh subscriptions(#{@subscriptions.size}):\"\n\n run_callback_server # call it once to make sure it runs\n \n @subscriptions.each do |sub| \n puts \" - #{sub.name}\"\n params = { \"attributes[accept]\" => 'application/json' }\n\n query = \"/gnp;#{sub.name};#{sub.entry_uri}\"\n params[\"attributes[callback_url]\"] = \"#{callback_server.base_url}#{query}\"\n\n [:operations, :uri_regexp, :condition_script].each do |key|\n (v = sub.send key) and params[\"attributes[#{key}]\"] = v\n end\n\n url = \"#{@target_url}#{sub.uri}.xml\"\n http_put(url, params) # {|req| req.content_type = 'application/xml'}\n end\n end", "def subscribe(*channels, &block); end", "def subscribe\n\t if !self_owned? && !subscribed?\n\t\towners.each do |peer|\n\t\t peer.subscribe(self) unless peer.subcribed?(self)\n\t\tend\n\t end\n\tend", "def after_subscribe(subscribed)\n # not required\n end", "def subscribe_all\n @config.subscriptions.size.times do\n current\n select_next_consumer\n end\n end", "def scope() binding end", "def on_open(env)\n @subscription = @config.consumer(env).subscription(@config.channel(env))\n @subscription.on_message {|message, consumer| send_data message }\n @subscription.subscribe\n end", "def register_global_listeners\n Wisper.clear\n Wisper.subscribe(AdminNotifier.new)\n Wisper.subscribe(SlackNotifications.new)\n Wisper.subscribe(UserEmails.new)\n end", "def modify_subscriptions(subs)\n iq = connection.iq_stanza({'to'=>jid.bare,'type'=>'set'},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSubOwner},\n x('subscriptions',{:node => node_id},\n subs.map do |s|\n x('subscription',:jid => s.jid, :subscription => s.subscription, :subid => s.sub_id)\n end\n )\n )\n )\n send_iq_stanza_fibered iq\n end", "def subscribed\n stream_from channel_name\n end", "def changes\n poll(\"Changes\")\n end", "def subscribed\n id = params.fetch(:id)\n return unless execution = JobQueue.find_by_id(id)\n\n execution.viewers.push current_user\n\n Thread.new do\n ActiveRecord::Base.connection_pool.with_connection do\n builder = EventBuilder.new(execution.job)\n execution.output.each do |event, data|\n transmit event: event, data: builder.payload(event, data)\n end\n # TODO: disconnect all listeners so they close their sockets ?\n # then replace the reloaded/finished/waitUntilEnabled stuff with that\n end\n end\n end", "def notify_will_change!\n collection_will_change!\n forward \"#{@key}_will_change!\"\n end", "def notify\n puts 'Subject: Notifying observers...'\n @observers.each { |observer| observer.update(self) }\n end", "def subscribe_to_channel(*)\n synchronize_entrypoint! { super }\n end", "def changed_and_notify(*args)\n changed\n notify_observers(*args)\n end", "def websocket_update\n json = self.to_jsonapi\n watching_users.each do |user|\n UpdatesChannel.broadcast_to(user, {loadModels: [json]})\n end\n end", "def scope(*args); end", "def apply_to_scope(scope)\n scope\n end", "def subscribe(qualifications = {})\n if data.is_a?(MutableData)\n MutationStore.instance.register(self, data, qualifications, view.context.request.session)\n end\n\n channel = ChannelBuilder.build(\n scope: view.scoped_as,\n mutation: mutation[:name],\n qualifiers: mutation[:qualifiers],\n data: data,\n qualifications: qualifications\n )\n\n # subscribe to the channel\n view.context.socket.subscribe(channel)\n\n # handle setting the channel on the view\n if view.is_a?(Presenter::ViewContext)\n working_view = view.instance_variable_get(:@view)\n else\n working_view = view\n end\n\n if working_view.is_a?(Presenter::ViewCollection)\n # NOTE there's a special case here where if the collection is\n # empty we insert an empty element in its place; this makes\n # it possible to know what the data should be applied to when\n # a mutation occurs in the future\n\n unless working_view.exists?\n # TODO: would rather this be an html comment, but they aren't\n # supported by query selectors; need to finalize how we will\n # handle this particular edge case\n working_view.first.doc.append('<span data-channel=\"' + channel + '\" data-version=\"empty\"></span>')\n return\n end\n end\n\n working_view.attrs.send(:'data-channel=', channel)\n end", "def subscribe\n @conn.send_data :opcode => SUBSCRIBE, :channel => @name\n @subscribe_sent = true\n end", "def subscribe(name, params, &blk)\n id = self.next_id()\n self.send({msg: 'sub', id: id, name: name, params: params})\n\n @subs[name] = id\n @callbacks[id] = blk\n end", "def notify\n @observers.each { |observer| observer.update }\nend", "def subscriptions\n @subscriptions ||= {}\n end", "def update\n Channel.channels_to_update\n end", "def get_subscribers\n @subscriptions = subscribers(@nodename)\n end", "def subscribe_notifications\n @subscribe_notifications ||= true\n end", "def relevant_events_scope\n events\n end", "def after_create\n oscopes = OscopeMsg.find_all_by_timestamp_and_user_id(timestamp, user_id)\n # instantiation of oscopes already caused oscope_start_msg to link to them\n # :update_without_callbacks is a provate method. direct call will not work. need to 'send' it\n oscopes.each {|p| p.send(:update_without_callbacks) } # this will save all instantiated oscopes\n end", "def notify\n changed(true)\n notify_observers(self)\n end", "def subscribe(*a, &b)\n name = gen_id\n EM.schedule { @subs[name] = EM::Callback(*a, &b) }\n\n name\n end", "def relevant_events_scope\n raise NotImplementedError\n end", "def notify_observers(*args)\n return unless changed?\n\n unwrap(connection).exec \"NOTIFY #{channel}, #{args}\"\n\n changed false\n end", "def subscribe(*addresses, &block)\n reactive.subscribe(*addresses, &block)\n end", "def update_scopes\n if @old_friendly_id != friendly_id\n friendly_id_config.child_scopes.each do |klass|\n Slug.all(:sluggable_type => klass, :scope => @old_friendly_id).update(:scope => friendly_id)\n end\n end\n end", "def broadcast_users_changed\n data = {\n action: 'players_changed'\n }\n ActionCable.server.broadcast \"game:#{@room.id}\", data\n end", "def scope_to(*args, &block)\n config.scope_to(*args, &block)\n end", "def show_subscriptions\n puts \"\\nYour current subscriptions are:\"\n @user.subscriptions.reload.each do |sub|\n puts sub.name\n end\n end", "def update_global_common_events\n end", "def subscribe(subscribable, subscription_level = Subscription::Levels[:reader])\n subscribable.subscribe(self, subscription_level)\n end", "def subscribers\r\n @subscribers.clone\r\n end", "def on_membership_change(opts={}, &blk)\n MembershipSubscription.new(self, opts, blk).tap do |ms|\n # the watch is registered in create!\n synchronize { @membership_subscriptions << ms }\n end\n end", "def subscribed\n location_id = params[:location_id].to_i\n location = Location.find(location_id)\n stream_for location\n \n @@locations_with_subscribers << location_id\n\n WeatherUpdateJob.schedule(location)\n end", "def pubsub; end", "def notify_key\n self.key.update_status(self.lang)\n self.audits.destroy\n end", "def scope=(value)\n @scope = value\n end", "def scope=(value)\n @scope = value\n end", "def scope=(value)\n @scope = value\n end", "def scope=(value)\n @scope = value\n end", "def scope=(value)\n @scope = value\n end", "def scope=(value)\n @scope = value\n end", "def subscribe\n @bot.get_updates(fail_silently: true) do |message|\n parser = InputParser.new(message.text)\n subject = parser.parse_subject\n if subject != nil\n response = \"Hello #{subject}, I'm dad.\"\n message.reply do |reply|\n reply.text = response\n reply.send_with(@bot)\n end\n end\n end\n end", "def push_subscription(object)\n local_server.subscribe(object)\n synchro_point\n end", "def service_subscriptions\n iq = connection.iq_stanza({'to'=>jid.bare},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSub},\n x('subscriptions')\n )\n )\n send_iq_stanza_fibered iq\n end", "def subscribed(subscribable, subscription_level = nil)\n subscribable.subscription_to(self, subscription_level)\n end", "def scope\n @scope ||= {}\n end", "def scope\n @scope ||= {}\n end", "def subscribe\n conn = @cluster.connect\n conn.subscribe(ALL)\n conn.subscribe(SHARE)\n conn.subscribe(@channel)\n conn.on(:message) do |channel, message|\n @messages.push([channel, message])\n end\n end", "def apply_on_subscribing\n @apply_on_subscribing = true\n return self\n end" ]
[ "0.6338729", "0.61815774", "0.5970382", "0.5954858", "0.58622986", "0.58119786", "0.58119786", "0.58119786", "0.57888234", "0.57743937", "0.5731783", "0.5716293", "0.56978613", "0.56176114", "0.56116176", "0.5606647", "0.5595493", "0.5589765", "0.5569349", "0.5501265", "0.5468543", "0.5450759", "0.5449164", "0.5414545", "0.53913635", "0.53913635", "0.5383098", "0.53719926", "0.5324334", "0.5314129", "0.5313153", "0.5266103", "0.5266103", "0.5266103", "0.5266103", "0.5266103", "0.5266103", "0.5266103", "0.5266103", "0.5266103", "0.5266103", "0.52470773", "0.5237781", "0.5219669", "0.5215091", "0.5205927", "0.51972854", "0.51952314", "0.5194621", "0.51917183", "0.51894206", "0.51794857", "0.5175629", "0.5173632", "0.5158549", "0.51569164", "0.51560664", "0.5153865", "0.51520026", "0.5142911", "0.5132387", "0.5116384", "0.5113972", "0.5110037", "0.510499", "0.5103709", "0.5077021", "0.5059616", "0.5057771", "0.50491154", "0.5047274", "0.5046638", "0.5042961", "0.50307447", "0.502737", "0.502616", "0.5023913", "0.50147086", "0.4995055", "0.4994228", "0.49936226", "0.49926347", "0.49922425", "0.49881187", "0.49877617", "0.49714464", "0.49664834", "0.49664834", "0.49664834", "0.49664834", "0.49664834", "0.49664834", "0.49644276", "0.49642172", "0.49582037", "0.49570173", "0.4942067", "0.4942067", "0.4938445", "0.49338746" ]
0.59766364
2
Use ODBC format, not Microsoft format, as the ODBC layer does some translation, but allow for millisecond precision.
def default_timestamp_format "{ts '%Y-%m-%d %H:%M:%S%N'}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quoted_date(value)\n @logger.unknown(\"ODBCAdapter#quoted_date (MS SQL)>\") if @trace\n @logger.unknown(\"args=[#{value}]\") if @trace\n # MS SQL DBTIME and DBDATE environment variables should be set to:\n # DBTIME=%d.%m.%Y %H:%M:%S\n # DBDATE=%d.%m.%Y\n if value.acts_like?(:time) # Time, DateTime\n %Q!'#{value.strftime(\"%Y%m%d %H:%M:%S\")}'!\n else # Date\n %Q!'#{value.strftime(\"%Y%m%d\")}'!\n end\n end", "def configure_connection\n # For sql server 2008+ we want it to send an actual time otherwise comparisons with time columns don't work\n @connection.connection.setSendTimeAsDatetime(false)\n end", "def to_sql\n self.strftime(\"%Y-%m-%d %H:%M:%S\")\n \tend", "def dbms_type_cast(columns, rows)\n # Cast the values to the correct type\n columns.each_with_index do |column, col_index|\n #puts \" #{column.name} type #{column.type} length #{column.length} nullable #{column.nullable} scale #{column.scale} precision #{column.precision} searchable #{column.searchable} unsigned #{column.unsigned}\"\n rows.each do |row|\n value = row[col_index]\n\n new_value = case\n when value.nil?\n nil\n when [ODBC::SQL_CHAR, ODBC::SQL_VARCHAR, ODBC::SQL_LONGVARCHAR].include?(column.type)\n # Do nothing, because the data defaults to strings\n # This also covers null values, as they are VARCHARs of length 0\n value.is_a?(String) ? value.force_encoding(\"UTF-8\") : value\n when [ODBC::SQL_DECIMAL, ODBC::SQL_NUMERIC].include?(column.type)\n column.scale == 0 ? value.to_i : value.to_f\n when [ODBC::SQL_REAL, ODBC::SQL_FLOAT, ODBC::SQL_DOUBLE].include?(column.type)\n value.to_f\n when [ODBC::SQL_INTEGER, ODBC::SQL_SMALLINT, ODBC::SQL_TINYINT, ODBC::SQL_BIGINT].include?(column.type)\n value.to_i\n when [ODBC::SQL_BIT].include?(column.type)\n value == 1\n when [ODBC::SQL_DATE, ODBC::SQL_TYPE_DATE].include?(column.type)\n value.to_date\n when [ODBC::SQL_TIME, ODBC::SQL_TYPE_TIME].include?(column.type)\n value.to_time\n when [ODBC::SQL_DATETIME, ODBC::SQL_TIMESTAMP, ODBC::SQL_TYPE_TIMESTAMP].include?(column.type)\n value.to_datetime\n # when [\"ARRAY\"?, \"OBJECT\"?, \"VARIANT\"?].include?(column.type)\n # TODO: \"ARRAY\", \"OBJECT\", \"VARIANT\" all return as VARCHAR\n # so we'd need to parse them to make them the correct type\n\n # As of now, we are just going to return the value as a string\n # and let the consumer handle it. In the future, we could handle\n # if here, but there's not a good way to tell what the type is\n # without trying to parse the value as JSON as see if it works\n # JSON.parse(value)\n when [ODBC::SQL_BINARY].include?(column.type)\n # These don't actually ever seem to return, even though they are\n # defined in the ODBC driver, but I left them in here just in case\n # so that future us can see what they should be\n value\n else\n # the use of @connection.types() results in a \"was not dropped before garbage collection\" warning.\n raise \"Unknown column type: #{column.type} #{@connection.types(column.type).first[0]}\"\n end\n\n row[col_index] = new_value\n end\n end\n rows\n end", "def to_sql\n self.to_datetime.to_sql\n \tend", "def odb_format(frmt)\n \"#{to_s}.format(#{quote(frmt)})\"\n end", "def to_sql\n \"timestamp '#{to_s}'\"\n end", "def stringify_datetime(datetime_name, params)\n DateTime.civil(params[datetime_name + \"(1i)\"].to_i,\n params[datetime_name + \"(2i)\"].to_i,\n params[datetime_name + \"(3i)\"].to_i,\n params[datetime_name + \"(4i)\"].to_i,\n params[datetime_name + \"(5i)\"].to_i,\n params[datetime_name + \"(6i)\"].to_i,\n 0).to_formatted_s(:db)\n end", "def test_datetime2_truncate_usec_on_assigment_default_precision\n time = Time.parse('2018-12-31T23:59:21.341867923')\n record = DateTime2Types.new(my_datetime: time)\n\n assert_equal 23, record.my_datetime.hour\n assert_equal 59, record.my_datetime.min\n assert_equal 21, record.my_datetime.sec\n assert_equal 341_867, record.my_datetime.usec\n assert_equal 341_867_000, record.my_datetime.nsec\n end", "def default_timestamp_format\n \"TIMESTAMP '%Y-%m-%d %H:%M:%S%N %z'\".freeze\n end", "def convert(value) \n return value.to_formatted_s(:db) if value.respond_to?(:to_formatted_s)\n value.to_s\n end", "def test_datetime2_truncate_usec_on_assigment_precision_0\n time = Time.parse('2018-12-31T23:59:21.341867')\n record = DateTime2Types.new(my_datetime_alt: time)\n\n assert_equal 23, record.my_datetime_alt.hour\n assert_equal 59, record.my_datetime_alt.min\n assert_equal 21, record.my_datetime_alt.sec\n assert_equal 0, record.my_datetime_alt.usec\n assert_equal 0, record.my_datetime_alt.nsec\n end", "def sql_datetime_second_mask\n case session[:database][:locale]\n when \"de\" then \"DD.MM.YYYY HH24:MI:SS\"\n when \"en\" then \"YYYY-MM-DD HH24:MI:SS\"\n else \"DD.MM.YYYY HH24:MI:SS\" # Deutsche Variante als default\n end\n end", "def connection_configuration_sqls\n sqls = super\n sqls << \"SET DateStyle = 'ISO'\" if @use_iso_date_format\n sqls\n end", "def typecast_value_datetime(value)\n Sequel.typecast_to_application_timestamp(value)\n end", "def quoted_date(value)\n if value.acts_like?(:time)\n if value.respond_to?(:getutc)\n value = value.getutc\n end\n end\n\n result = value.to_s(:db)\n end", "def format(precise: false)\n return '-' if @ms.nil?\n\n return Kernel.format('%02d:%02d:%02d.%03d', hours, minutes, seconds, milliseconds) if precise\n Kernel.format('%02d:%02d:%02d', hours, minutes, seconds)\n end", "def dbf\n strftime(DB_TIME_FORMAT)\n end", "def dbf\n strftime(DB_TIME_FORMAT)\n end", "def value_for(value)\n return value.to_s(:db) if value.kind_of?(Time) \n return value.to_s(:db) if value.kind_of?(Date)\n return value.to_s\n end", "def convert_db_time(date)\n \treturn date.strftime(\"%m/%d/%Y | %I:%M %P\")\n end", "def cdr_to_fmt\n '%s'\n end", "def type_to_sql(type, limit = nil, precision = nil, scale = nil)\n if type == :decimal\n # Force an explicit scale if none supplied to specify the fixed\n # point form of Virtuoso's DECIMAL type. If no scale is specified,\n # the Virtuoso DECIMAL type stores floating point values.\n precision ||= 32\n scale ||= 0\n end\n super(type, limit, precision, scale)\n end", "def dbf\n strftime(DB_TIME_FORMAT)\n end", "def convert_row(row)\n return nil if row.nil?\n row.collect do |col|\n if col.is_a? ::ODBC::Date\n DBI::Date.new(col.year, col.month, col.day)\n elsif col.is_a? ::ODBC::Time\n DBI::Time.new(col.hour, col.minute, col.second)\n elsif col.is_a? ::ODBC::TimeStamp\n DBI::Timestamp.new(col.year, col.month, col.day,\n col.hour, col.minute, col.second, col.fraction)\n else\n col\n end\n end\n end", "def quoted_date(value) #:nodoc:\n if value.acts_like?(:time) && value.respond_to?(:usec)\n \"#{super}.#{sprintf(\"%06d\", value.usec)}\"\n else\n super\n end\n end", "def to_bson\n [ increment, seconds ].pack(TIMESTAMP_PACK)\n end", "def type_to_sql(*args); connection.type_to_sql(*args); end", "def to_db(value)\n value = value.new_offset(0) if value.respond_to?(:new_offset)\n\n args = [value.year, value.month, value.day]\n args += (value.class == Date ? [0, 0, 0] : [value.hour, value.min, value.sec])\n\n Time.utc(*args).to_i\n end", "def to_postgres_string\n min_string = minutes.to_s\n sec_string = seconds.to_s\n \n min_string = \"0\" + min_string if minutes.to_s.length < 2\n sec_string = \"0\" + sec_string if seconds.to_s.length < 2\n \n return hours.to_s+\":\"+min_string+\":\"+sec_string\n end", "def datetime_format\n end", "def dbms_type_cast(columns, values)\n int_column = {}\n columns.each_with_index do |c, i|\n int_column[i] = c.type == 3 && c.scale == 0\n end\n\n float_column = {}\n columns.each_with_index do |c, i|\n float_column[i] = c.type == 3 && c.scale != 0\n end\n\n values.each do |row|\n row.each_index do |idx|\n val = row[idx]\n if val\n if int_column[idx]\n row[idx] = val.to_i\n elsif float_column[idx]\n row[idx] = val.to_f\n elsif val.is_a?(String)\n row[idx] = val.force_encoding('UTF-8')\n end\n end\n end\n end\n end", "def quote_date_with_to_date(value)\n value = value.to_s(:db) if value.acts_like?(:date) || value.acts_like?(:time)\n \"TO_DATE('#{value}','YYYY-MM-DD HH24:MI:SS')\"\n end", "def db_formatted_d( d )\n# d.try( :to_formatted_s, :db_date )\n d&.to_formatted_s( :db_date )\n end", "def quote_value(col)\n case column_detail(col).data_type\n when 'CHAR', 'VARCHAR2', 'CLOB', 'RAW'\n \"'#{@column_values[col]}'\"\n when 'DATE', 'DATETIME'\n \"to_date('#{@column_values[col].strftime('%Y%m%d %H:%M:%S')}', 'YYYYMMDD HH24:MI:SS')\"\n else\n @column_values[col].to_s\n end\n end", "def date_time_to_db_format(date, time)\n finish_date_time = date + \" \" + time\n # format datetime for the database\n postgrestimestamp = DateTime::strptime(finish_date_time, '%d %b %Y %H:%M').to_time\n return postgrestimestamp\n end", "def to_s_mysql\n a = self.to_a.collect {|x| x.to_s.rjust(2).gsub(/ /, \"0\")}\n return \"#{a[0]}-#{a[1]}-#{a[2]} #{a[3]}:#{a[4]}:#{a[5]}\"\n end", "def type_to_sql(type, limit: nil, precision: nil, scale: nil, **) # :nodoc:\n # MSSQL's NVARCHAR(n | max) column supports either a number between 1 and\n # 4000, or the word \"MAX\", which corresponds to 2**30-1 UCS-2 characters.\n #\n # It does not accept NVARCHAR(1073741823) here, so we have to change it\n # to NVARCHAR(MAX), even though they are logically equivalent.\n #\n # See: http://msdn.microsoft.com/en-us/library/ms186939.aspx\n #\n type = type.to_sym if type\n native = native_database_types[type]\n\n if type == :string && limit == 1_073_741_823\n 'nvarchar(max)'\n elsif NO_LIMIT_TYPES.include?(type)\n super(type)\n elsif %i[int integer].include?(type)\n if limit.nil? || limit == 4\n 'int'\n elsif limit == 2\n 'smallint'\n elsif limit == 1\n 'tinyint'\n else\n 'bigint'\n end\n elsif type == :uniqueidentifier\n 'uniqueidentifier'\n elsif %i[datetime time].include?(type)\n precision ||= 7\n column_type_sql = (native.is_a?(Hash) ? native[:name] : native).dup\n if (0..7).include?(precision)\n column_type_sql << \"(#{precision})\"\n else\n raise(\n ArgumentError,\n \"No #{native[:name]} type has precision of #{precision}. The \" \\\n 'allowed range of precision is from 0 to 7, even though the ' \\\n 'sql type precision is 7 this adapter will persist up to 6 ' \\\n 'precision only.'\n )\n end\n else\n super\n end\n end", "def timestamp_with_usec\n time = Time.now\n time.strftime('%Y-%m-%dT%H:%M:%S.') + format('%06d ', time.usec)\n end", "def test_formatting_time_according_to_precision_coerced\n skip unless @connection # Avoids arunit2 suite run errors.\n @connection.create_table(:foos, force: true) do |t|\n t.time :start, precision: 0\n t.time :finish, precision: 4\n end\n time = ::Time.utc(2000, 1, 1, 12, 30, 0, 999999)\n Foo.create!(start: time, finish: time)\n assert foo = Foo.find_by(start: time)\n assert_equal 1, Foo.where(finish: time).count\n assert_equal time.to_s, foo.start.to_s\n assert_equal time.to_s, foo.finish.to_s\n assert_equal 000000, foo.start.usec\n assert_equal 999000, foo.finish.usec\n end", "def to_sql\n sql = [\"select\"]\n select_values << \"*\" if select_values.empty?\n\n sql << select_values.uniq.join(\", \")\n\n sql << \"from #{build_series_name}\"\n\n sql << \"where #{where_values.join(\" and \")}\" unless where_values.empty?\n\n unless group_values.empty? && time_value.nil?\n group_fields = (time_value.nil? ? [] : [\"time(\" + @values[:time] + \")\"]) + group_values\n group_fields.uniq!\n sql << \"group by #{group_fields.join(\", \")}\"\n end\n\n sql << \"fill(#{fill_value})\" unless fill_value.nil?\n\n sql << \"order by #{order_values.uniq.join(\",\")}\" unless order_values.empty?\n\n sql << \"limit #{limit_value}\" unless limit_value.nil?\n sql << \"offset #{offset_value}\" unless offset_value.nil?\n sql << \"slimit #{slimit_value}\" unless slimit_value.nil?\n sql << \"soffset #{soffset_value}\" unless soffset_value.nil?\n sql << \"TZ('#{timezone_value}')\" unless timezone_value.blank?\n sql.join \" \"\n end", "def adapter_initialize\n @use_iso_date_format = typecast_value_boolean(@opts.fetch(:use_iso_date_format, Postgres.instance_variable_get(:@use_iso_date_format))) # , true)) # SEQUEL5\n initialize_postgres_adapter\n add_conversion_proc(17, method(:unescape_bytea)) if USES_PG\n add_conversion_proc(1082, TYPE_TRANSLATOR.method(:date)) if @use_iso_date_format\n self.convert_infinite_timestamps = @opts[:convert_infinite_timestamps]\n end", "def data_type_pretty\n type_string =\n case(@band.DataType)\n when Gdal::Gdalconst::GDT_UNKNOWN; 'GDT_UNKNOWN'\n when Gdal::Gdalconst::GDT_BYTE; 'GDT_BYTE'\n when Gdal::Gdalconst::GDT_UINT16;'GDT_UINT16'\n when Gdal::Gdalconst::GDT_INT16;'GDT_INT16'\n when Gdal::Gdalconst::GDT_UINT32; 'GDT_UINT32'\n when Gdal::Gdalconst::GDT_INT32; 'GDT_INT32'\n when Gdal::Gdalconst::GDT_FLOAT32; 'IDT_FLOAT32'\n when Gdal::Gdalconst::GDT_FLOAT64; 'GDT_FLOAT64'\n when Gdal::Gdalconst::GDT_CINT16; 'GDT_CINT16' \n when Gdal::Gdalconst::GDT_CINT32; 'GDT_CINT32' \n when Gdal::Gdalconst::GDT_CFLOAT32; 'GDT_CFLOAT32' \n when Gdal::Gdalconst::GDT_CFLOAT64; 'GDT_CFLOAT64'\n else raise ArgumentError(\"Unknown data type.. not sure what to do here folks\", caller)\n end\n type_string\n end", "def test_format_strftime_record\n d = create_driver %[\n tag #{@tag}\n key #{@key}\n format %d/%b/%Y:%H:%M:%S %z\n source record\n standard localtime\n ]\n\n d.run do\n d.emit({\"a\"=>1}, Time.parse(\"1990-04-14 09:45:15 UTC\").to_i)\n end\n\n record = d.emits.first.last\n assert_equal \"14/Apr/1990:11:45:15 +0200\", record[@key]\n end", "def must_convert?\n big_query_conversion_column.present? && unit != 'seconds'\n end", "def precision_timestamp\n Time.now.strftime(\"%Y%m%d%H%M%S%L\")\n end", "def requires_sql_standard_datetimes?\n true\n end", "def to_s()\n @sql ||= print_to(Printer.new()).to_s()\n end", "def set_date_format(format) \n unless format.nil?\n return format\n else\n return @@db_format\n end\n end", "def date_out(date_obj = Knj::Datet.new, args = {})\r\n conn_exec do |driver|\r\n if driver.respond_to?(:date_out)\r\n return driver.date_out(date_obj, args)\r\n end\r\n end\r\n \r\n return Knj::Datet.in(date_obj).dbstr(args)\r\n end", "def dbstr(args = nil)\n str = \"#{\"%04d\" % @t_year}-#{\"%02d\" % @t_month}-#{\"%02d\" % @t_day}\"\n \n if !args or (!args.key?(:time) or args[:time])\n str << \" #{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}:#{\"%02d\" % @t_sec}\"\n end\n \n return str\n end", "def timestamp(row)\n row[0].to_f\nend", "def to_datetime string_or_datetime\n if string_or_datetime.is_a?(String)\n Sequel.string_to_datetime(string_or_datetime)\n else\n string_or_datetime\n end\n end", "def supports_datetime_with_precision?\n false\n end", "def supports_datetime_with_precision?\n false\n end", "def to_s\n if @orig.is_a?(Time)\n \"Time: #{@orig.to_s}\"\n elsif @orig.is_a?(DateTime)\n \"DateTime: #{@orig.to_s}\"\n elsif @orig.is_a?(TimestampWithOffset)\n \"TimestampWithOffset: #{@orig.to_s}\"\n else\n \"Timestamp: #{@orig.to_s}\"\n end\n end", "def to_fs(format = :default)\n if format == :db\n utc.to_fs(format)\n elsif formatter = ::Time::DATE_FORMATS[format]\n formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter)\n else\n # Change to to_s when deprecation is gone.\n \"#{time.strftime(\"%Y-%m-%d %H:%M:%S\")} #{formatted_offset(false, 'UTC')}\"\n end\n end", "def configure_connection\n super\n execute(\"SET SESSION IntervalStyle TO 'iso_8601'\", 'SCHEMA')\n end", "def type_to_sql(type, limit = nil, precision = nil, scale = nil)\n return super unless NO_LIMIT_TYPES.include?(t = type.to_s.downcase.to_sym)\n\n native_type = NATIVE_DATABASE_TYPES[t]\n native_type.is_a?(Hash) ? native_type[:name] : native_type\n end", "def to_binary_dos_time; end", "def to_s_for_cap\n to_datetime.to_s_for_cap\n end", "def must_convert?\n self.big_query_conversion_column.present? && self.unit != 'seconds'\n end", "def to_s\n if @orig.is_a?(Time)\n \"Time: #{@orig.to_s}\"\n elsif @orig.is_a?(DateTime)\n \"DateTime: #{@orig.to_s}\"\n else\n \"Timestamp: #{@orig.to_s}\"\n end\n end", "def to_s\n if @orig.is_a?(Time)\n \"Time: #{@orig.to_s}\"\n elsif @orig.is_a?(DateTime)\n \"DateTime: #{@orig.to_s}\"\n else\n \"Timestamp: #{@orig.to_s}\"\n end\n end", "def datetime_to_iso8601_date(gm_time = nil)\n gm_time ||= Time.now.gmtime\n\n gm_time.strftime('%Y-%m-%dT%H:%M:%SZ')\n end", "def as_json(options = nil)\n if ActiveSupport::JSON::Encoding.use_standard_json_time_format\n xmlschema(ActiveSupport::JSON::Encoding.time_precision)\n else\n %(#{time.strftime(\"%Y/%m/%d %H:%M:%S\")} #{formatted_offset(false)})\n end\n end", "def serialize(row)\n row\n .map { |c| db_format(c) }\n .join(\",\")\nend", "def type_cast_for_schema(value) # :nodoc:\n case value\n when 'toDate(now()', 'CAST(now() AS Date)'\n 'now()'.inspect\n else\n value.inspect\n end\n end", "def date_string_to_readable(db_date)\n\n # Parse string (db date) to DateTime\n date = date_string_to_object(db_date)\n\n # Format it to a more readable string\n string = \"#{date.day}/#{date.month}/#{date.year}\"\n string << \" #{date.hour}:#{date.minute}\"\n\n return string\nend", "def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc:\r\n if native = native_database_types[type]\r\n if type == :integer\r\n column_type_sql = 'integer'\r\n elsif type == :string and !limit.nil?\r\n \"varchar (#{limit})\"\r\n else\r\n super(type, limit, precision, scale)\r\n end\r\n else\r\n super(type, limit, precision, scale)\r\n end\r\n end", "def firebird_cast_default\n sql = \"SELECT CAST(#{@default} AS #{column_def}) FROM RDB$DATABASE\"\n if connection = Base.active_connections.values.detect { |conn| conn && conn.adapter_name == 'Firebird' }\n connection.execute(sql).to_a.first['CAST']\n else\n raise ConnectionNotEstablished, \"No Firebird connections established.\"\n end\n end", "def database_type\n :mssql\n end", "def type_literal_generic_datetime(column)\n :timestamp\n end", "def to_s(mode = :normal)\n case mode\n when :db, :rfc822 then utc.to_s(mode)\n else time.to_s(mode)\n end\n end", "def cdr_from_fmt\n '%s'\n end", "def to_s\n format = \n if @_utc then\n \"%a %b %d %H:%M:%S UTC %Y\"\n else\n \"%a %b %d %H:%M:%S %Z %Y\"\n end\n return LIBC.new.c_strftime(format, @vals)\n end", "def cast_default(value)\n @format_string = iso8601\n cast_fmt(value)\n end", "def to_bson(buffer = ByteBuffer.new)\n value = _bson_to_i * 1000 + usec.divmod(1000).first\n buffer.put_int64(value)\n end", "def format_datetime(date, format = :long)\n date.to_formatted_s(format)\n end", "def to_datetime()\n #This is a stub, used for indexing\n end", "def type_to_sql(type, limit = nil, precision = nil, scale = nil)\n return super if defined?(::Jdbc::H2) || type.to_s != 'integer' || limit == nil\n\n type\n end", "def test_time_truncate_usec_on_assigment_default_precision\n time = Time.parse('2018-12-31T23:59:21.341867923')\n record = DateAndTimeTypes.new(my_time: time)\n\n assert_equal 23, record.my_time.hour\n assert_equal 59, record.my_time.min\n assert_equal 21, record.my_time.sec\n assert_equal 341_867, record.my_time.usec\n assert_equal 341_867_000, record.my_time.nsec\n end", "def strptime_format\n #'%Y-%m-%dT%H:%M:%S.%L'\n \"%Y-%m-%dT%H:%M:%SZ\"\n end", "def mssql_query(sqla, doprint=false, opts={})\n\t\tinfo = { :sql => sqla }\n\n\t\topts[:timeout] ||= 15\n\n\t\tpkts = []\n\t\tidx = 0\n\n\t\tbsize = 4096 - 8\n\t\tchan = 0\n\n\t\t@cnt ||= 0\n\t\t@cnt += 1\n\n\t\tsql = Rex::Text.to_unicode(sqla)\n\t\twhile(idx < sql.length)\n\t\t\tbuf = sql[idx, bsize]\n\t\t\tflg = buf.length < bsize ? \"\\x01\" : \"\\x00\"\n\t\t\tpkts << \"\\x01\" + flg + [buf.length + 8].pack('n') + [chan].pack('n') + [@cnt].pack('C') + \"\\x00\" + buf\n\t\t\tidx += bsize\n\n\t\tend\n\n\t\tresp = mssql_send_recv(pkts.join, opts[:timeout])\n\t\tmssql_parse_reply(resp, info)\n\t\tmssql_print_reply(info) if doprint\n\t\tinfo\n\tend", "def native_format\n @data_chunk_reader.raw_native_format\n end", "def native_format\n @data_chunk_reader.raw_native_format\n end", "def iso8601\n utc.strftime DATE_FORMATS[:iso8601]\n end", "def date_formats_by_unit\n #mysql format is always at first position, only one value if mysql and strftime are equivalent\n return ['%Y-%m-%d %H%i%s', '%Y-%m-%d %H%M%S'] if measured_in?(\"seconds\")\n return ['%Y-%m-%d %H%i', '%Y-%m-%d %H%M'] if measured_in?(\"minutes\")\n return ['%Y-%m-%d %H'] if measured_in?(\"hours\")\n return ['%Y-%m-%d']\n end", "def type_to_sql_with_notext(*args)\n type = type_to_sql_without_notext(*args)\n if type =~ /(text|blob)/\n 'varchar(2500)' # If this is bigger than about 21000 it always fails, and sometimes hits a row limit anyway if too large\n else\n type\n end\n end", "def default\n if @default\n sql = \"SELECT CAST(#{@default} AS #{column_def}) FROM RDB$DATABASE\"\n connection = ActiveRecord::Base.connection\n if connection\n value = connection.select_one(sql)['cast']\n if value.acts_like?(:date) or value.acts_like?(:time)\n nil\n else\n type_cast(value)\n end\n else\n raise ConnectionNotEstablished, \"No Firebird connections established.\"\n end\n end\n end", "def from_database_type(obj)\n case obj\n when String, Float, Integer, NilClass, TrueClass, FalseClass\n obj\n when java.sql.Date, java.sql.Time, java.sql.Timestamp\n Time.at(obj.time/1000)\n when java.sql.Blob\n String.from_java_bytes(obj.get_bytes(1,obj.length))\n when java.sql.Clob\n obj.get_sub_string(1, obj.length)\n when java.math.BigDecimal\n BigDecimal.new(obj.to_s)\n else\n raise \"Can't find correct type to convert #{obj.inspect} into\"\n end\n end", "def format_parameter(parameter)\n parameter.instance_of?(Time) ? iso_format(parameter) : parameter.to_s\n end", "def datetime(s)\n @db.to_application_timestamp(s)\n end", "def format_datetime\n if @opts[:as] == :select\n values = {}\n if v = @attr[:value]\n v = DateTime.parse(v) unless v.is_a?(Time) || v.is_a?(DateTime)\n values[:year], values[:month], values[:day], values[:hour], values[:minute], values[:second] = v.year, v.month, v.day, v.hour, v.min, v.sec\n end\n _format_date_select(values, @opts[:order] || DEFAULT_DATETIME_ORDER)\n else\n _format_input('datetime-local')\n end\n end", "def to_sql_hash\n { \n 'iso_time' => iso_time,\n 'date' => date,\n 'hostname' => hostname,\n 'process' => process,\n 'pid' => pid,\n 'raw_message' => raw_message\n }\n end", "def dt_format\n \"%Y-%m-%d %H:%M\"\n end", "def datetime_format\n @default_formatter.datetime_format\n end", "def literal_datetime(v)\n v.strftime(\"TIMESTAMP '%Y-%m-%d %H:%M:%S'\")\n end", "def sqlify_date(raw_date)\n m, d, y = raw_date.split('/')\n \"%04d-%02d-%02d\" % [y, m, d]\nend", "def datetime_format\n @default_formatter.datetime_format\n end" ]
[ "0.6193917", "0.6027293", "0.60185945", "0.5974096", "0.58190393", "0.5744007", "0.5625299", "0.5606582", "0.55727845", "0.54956925", "0.54899985", "0.5469331", "0.54488885", "0.5445127", "0.53989637", "0.5317874", "0.5275467", "0.5264983", "0.5264983", "0.5245957", "0.52243274", "0.52185774", "0.52027225", "0.5178733", "0.51485157", "0.5132297", "0.51262134", "0.51232076", "0.51071346", "0.5104535", "0.5079043", "0.50380594", "0.5033091", "0.50325364", "0.50231975", "0.50108546", "0.5003599", "0.49576205", "0.49312955", "0.49189073", "0.4914777", "0.49109054", "0.49061298", "0.48935622", "0.4887256", "0.488462", "0.48746142", "0.4863857", "0.48625827", "0.48591298", "0.48539186", "0.4842287", "0.48041075", "0.47910815", "0.47910815", "0.47826257", "0.47818825", "0.47808522", "0.47753775", "0.47752517", "0.47626802", "0.47554317", "0.47551304", "0.47551304", "0.4741641", "0.47382358", "0.47354528", "0.47351217", "0.47318915", "0.4721538", "0.4720603", "0.47176597", "0.47139308", "0.4713202", "0.4711653", "0.4702706", "0.46988544", "0.46979657", "0.46947536", "0.46911225", "0.46883854", "0.4687917", "0.4679531", "0.46750775", "0.46668246", "0.46668246", "0.46610034", "0.4660533", "0.4659833", "0.4652134", "0.4650154", "0.46444672", "0.4642905", "0.46427232", "0.46335092", "0.46209726", "0.4619206", "0.46114188", "0.46113008", "0.4608397" ]
0.5402206
14
Use ODBC format, not Microsoft format, as the ODBC layer does some translation.
def literal_date(v) v.strftime("{d '%Y-%m-%d'}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dbms_type_cast(columns, rows)\n # Cast the values to the correct type\n columns.each_with_index do |column, col_index|\n #puts \" #{column.name} type #{column.type} length #{column.length} nullable #{column.nullable} scale #{column.scale} precision #{column.precision} searchable #{column.searchable} unsigned #{column.unsigned}\"\n rows.each do |row|\n value = row[col_index]\n\n new_value = case\n when value.nil?\n nil\n when [ODBC::SQL_CHAR, ODBC::SQL_VARCHAR, ODBC::SQL_LONGVARCHAR].include?(column.type)\n # Do nothing, because the data defaults to strings\n # This also covers null values, as they are VARCHARs of length 0\n value.is_a?(String) ? value.force_encoding(\"UTF-8\") : value\n when [ODBC::SQL_DECIMAL, ODBC::SQL_NUMERIC].include?(column.type)\n column.scale == 0 ? value.to_i : value.to_f\n when [ODBC::SQL_REAL, ODBC::SQL_FLOAT, ODBC::SQL_DOUBLE].include?(column.type)\n value.to_f\n when [ODBC::SQL_INTEGER, ODBC::SQL_SMALLINT, ODBC::SQL_TINYINT, ODBC::SQL_BIGINT].include?(column.type)\n value.to_i\n when [ODBC::SQL_BIT].include?(column.type)\n value == 1\n when [ODBC::SQL_DATE, ODBC::SQL_TYPE_DATE].include?(column.type)\n value.to_date\n when [ODBC::SQL_TIME, ODBC::SQL_TYPE_TIME].include?(column.type)\n value.to_time\n when [ODBC::SQL_DATETIME, ODBC::SQL_TIMESTAMP, ODBC::SQL_TYPE_TIMESTAMP].include?(column.type)\n value.to_datetime\n # when [\"ARRAY\"?, \"OBJECT\"?, \"VARIANT\"?].include?(column.type)\n # TODO: \"ARRAY\", \"OBJECT\", \"VARIANT\" all return as VARCHAR\n # so we'd need to parse them to make them the correct type\n\n # As of now, we are just going to return the value as a string\n # and let the consumer handle it. In the future, we could handle\n # if here, but there's not a good way to tell what the type is\n # without trying to parse the value as JSON as see if it works\n # JSON.parse(value)\n when [ODBC::SQL_BINARY].include?(column.type)\n # These don't actually ever seem to return, even though they are\n # defined in the ODBC driver, but I left them in here just in case\n # so that future us can see what they should be\n value\n else\n # the use of @connection.types() results in a \"was not dropped before garbage collection\" warning.\n raise \"Unknown column type: #{column.type} #{@connection.types(column.type).first[0]}\"\n end\n\n row[col_index] = new_value\n end\n end\n rows\n end", "def connection_configuration_sqls\n sqls = super\n sqls << \"SET DateStyle = 'ISO'\" if @use_iso_date_format\n sqls\n end", "def odb_format(frmt)\n \"#{to_s}.format(#{quote(frmt)})\"\n end", "def quoted_date(value)\n @logger.unknown(\"ODBCAdapter#quoted_date (MS SQL)>\") if @trace\n @logger.unknown(\"args=[#{value}]\") if @trace\n # MS SQL DBTIME and DBDATE environment variables should be set to:\n # DBTIME=%d.%m.%Y %H:%M:%S\n # DBDATE=%d.%m.%Y\n if value.acts_like?(:time) # Time, DateTime\n %Q!'#{value.strftime(\"%Y%m%d %H:%M:%S\")}'!\n else # Date\n %Q!'#{value.strftime(\"%Y%m%d\")}'!\n end\n end", "def type_to_sql(*args); connection.type_to_sql(*args); end", "def database_type\n :fdbsql\n end", "def convert(value) \n return value.to_formatted_s(:db) if value.respond_to?(:to_formatted_s)\n value.to_s\n end", "def database_type\n :mssql\n end", "def cdr_to_fmt\n '%s'\n end", "def configure_connection\n # For sql server 2008+ we want it to send an actual time otherwise comparisons with time columns don't work\n @connection.connection.setSendTimeAsDatetime(false)\n end", "def sql_modes; end", "def to_sql\n self.to_datetime.to_sql\n \tend", "def target_sql_mode; end", "def database_type\n :as400\n end", "def _format_sql(sql)\n sql = sql.delete '\"'\n sql.downcase\n end", "def to_s()\n @sql ||= print_to(Printer.new()).to_s()\n end", "def cdr_from_fmt\n '%s'\n end", "def database_type\n :oracle\n end", "def ascii_query(sql,*values)\n sth = self.query(sql,*values)\n rows = sth.fetch_all\n col_names = sth.column_names\n sth.finish\n DBI::Utils::TableFormatter.ascii(col_names, rows)\n end", "def to_sql\n self.strftime(\"%Y-%m-%d %H:%M:%S\")\n \tend", "def target_sql_mode=(_arg0); end", "def firebird_cast_default\n sql = \"SELECT CAST(#{@default} AS #{column_def}) FROM RDB$DATABASE\"\n if connection = Base.active_connections.values.detect { |conn| conn && conn.adapter_name == 'Firebird' }\n connection.execute(sql).to_a.first['CAST']\n else\n raise ConnectionNotEstablished, \"No Firebird connections established.\"\n end\n end", "def type_to_sql_with_notext(*args)\n type = type_to_sql_without_notext(*args)\n if type =~ /(text|blob)/\n 'varchar(2500)' # If this is bigger than about 21000 it always fails, and sometimes hits a row limit anyway if too large\n else\n type\n end\n end", "def adapter_initialize\n @use_iso_date_format = typecast_value_boolean(@opts.fetch(:use_iso_date_format, Postgres.instance_variable_get(:@use_iso_date_format))) # , true)) # SEQUEL5\n initialize_postgres_adapter\n add_conversion_proc(17, method(:unescape_bytea)) if USES_PG\n add_conversion_proc(1082, TYPE_TRANSLATOR.method(:date)) if @use_iso_date_format\n self.convert_infinite_timestamps = @opts[:convert_infinite_timestamps]\n end", "def dialect\n connection.adapter_name.downcase.to_s\n end", "def cast_string(sql_type = nil)\n cast(sql_type || :text).sql_string\n end", "def convert_sql(sql, definition)\n sql.gsub(/\\b\\d+\\b/, ':int').gsub(/`([^`]+)`/, '\\1').gsub(/'[^']*'/, ':string').rstrip\n end", "def convert_row(row)\n return nil if row.nil?\n row.collect do |col|\n if col.is_a? ::ODBC::Date\n DBI::Date.new(col.year, col.month, col.day)\n elsif col.is_a? ::ODBC::Time\n DBI::Time.new(col.hour, col.minute, col.second)\n elsif col.is_a? ::ODBC::TimeStamp\n DBI::Timestamp.new(col.year, col.month, col.day,\n col.hour, col.minute, col.second, col.fraction)\n else\n col\n end\n end\n end", "def cast_string(arg, sql_type = nil)\n cast(arg, sql_type || String).sql_string\n end", "def odb_format_str(*args)\n \"format('#{to_s}', #{args.map{|x| quote(x)}.join(', ')})\"\n end", "def dbms_type_cast(columns, values)\n int_column = {}\n columns.each_with_index do |c, i|\n int_column[i] = c.type == 3 && c.scale == 0\n end\n\n float_column = {}\n columns.each_with_index do |c, i|\n float_column[i] = c.type == 3 && c.scale != 0\n end\n\n values.each do |row|\n row.each_index do |idx|\n val = row[idx]\n if val\n if int_column[idx]\n row[idx] = val.to_i\n elsif float_column[idx]\n row[idx] = val.to_f\n elsif val.is_a?(String)\n row[idx] = val.force_encoding('UTF-8')\n end\n end\n end\n end\n end", "def sql_to_soql(frozen_sql)\n sql = frozen_sql.dup\n # Unescape column and table names\n sql.gsub!('`', '')\n\n # Remove table namespace from fields\n sql.gsub!(\"#{QueryBuilder::DUMMY_TABLE_NAME}.\", '')\n\n # Add table name\n sql.gsub!(QueryBuilder::DUMMY_TABLE_NAME, klass.object_name)\n\n # Convert 1=0 to id IS NULL (id never be NULL, so it a false case)\n sql.gsub!(/\\s+1=0(\\s*)/i, ' id IS NULL\\1')\n\n # Convert IS NOT to !=\n sql.gsub!(/\\s+IS\\s+NOT\\s+/i, ' != ')\n\n # Convert IS to =\n sql.gsub!(/\\s+IS\\s+/i, ' = ')\n\n # Convert datatime to salesforce format\n sql.gsub!(/'(\\d{4}-\\d{2}-\\d{2}) (\\d{2}:\\d{2}:\\d{2})(\\.\\d+)?'/, '\\1T\\2Z')\n\n # Convert date to salesforce format\n sql.gsub!(/'(\\d{4}-\\d{2}-\\d{2})'/, '\\1')\n\n # Convert boolean_field = (1|0) to boolean_field = (true|false)\n sql = boolean_data_type_conversion(sql)\n\n # Convert aliased fields\n convert_aliased_fields(sql).strip\n end", "def to_s\n regex = REPLACEMENT\n\n if Gitlab::Database.mysql?\n regex = Regexp.union(regex, MYSQL_REPLACEMENTS)\n end\n\n sql = @sql.gsub(regex, '?').gsub(CONSECUTIVE) do |match|\n \"#{match.count(',') + 1} values\"\n end\n\n # InfluxDB escapes double quotes upon output, so lets get rid of them\n # whenever we can.\n if Gitlab::Database.postgresql?\n sql = sql.delete('\"')\n end\n\n sql.tr(\"\\n\", ' ')\n end", "def type_to_sql(type, limit: nil, precision: nil, scale: nil, **) # :nodoc:\n # MSSQL's NVARCHAR(n | max) column supports either a number between 1 and\n # 4000, or the word \"MAX\", which corresponds to 2**30-1 UCS-2 characters.\n #\n # It does not accept NVARCHAR(1073741823) here, so we have to change it\n # to NVARCHAR(MAX), even though they are logically equivalent.\n #\n # See: http://msdn.microsoft.com/en-us/library/ms186939.aspx\n #\n type = type.to_sym if type\n native = native_database_types[type]\n\n if type == :string && limit == 1_073_741_823\n 'nvarchar(max)'\n elsif NO_LIMIT_TYPES.include?(type)\n super(type)\n elsif %i[int integer].include?(type)\n if limit.nil? || limit == 4\n 'int'\n elsif limit == 2\n 'smallint'\n elsif limit == 1\n 'tinyint'\n else\n 'bigint'\n end\n elsif type == :uniqueidentifier\n 'uniqueidentifier'\n elsif %i[datetime time].include?(type)\n precision ||= 7\n column_type_sql = (native.is_a?(Hash) ? native[:name] : native).dup\n if (0..7).include?(precision)\n column_type_sql << \"(#{precision})\"\n else\n raise(\n ArgumentError,\n \"No #{native[:name]} type has precision of #{precision}. The \" \\\n 'allowed range of precision is from 0 to 7, even though the ' \\\n 'sql type precision is 7 this adapter will persist up to 6 ' \\\n 'precision only.'\n )\n end\n else\n super\n end\n end", "def stringify_datetime(datetime_name, params)\n DateTime.civil(params[datetime_name + \"(1i)\"].to_i,\n params[datetime_name + \"(2i)\"].to_i,\n params[datetime_name + \"(3i)\"].to_i,\n params[datetime_name + \"(4i)\"].to_i,\n params[datetime_name + \"(5i)\"].to_i,\n params[datetime_name + \"(6i)\"].to_i,\n 0).to_formatted_s(:db)\n end", "def to_sql\n sql = [\"select\"]\n select_values << \"*\" if select_values.empty?\n\n sql << select_values.uniq.join(\", \")\n\n sql << \"from #{build_series_name}\"\n\n sql << \"where #{where_values.join(\" and \")}\" unless where_values.empty?\n\n unless group_values.empty? && time_value.nil?\n group_fields = (time_value.nil? ? [] : [\"time(\" + @values[:time] + \")\"]) + group_values\n group_fields.uniq!\n sql << \"group by #{group_fields.join(\", \")}\"\n end\n\n sql << \"fill(#{fill_value})\" unless fill_value.nil?\n\n sql << \"order by #{order_values.uniq.join(\",\")}\" unless order_values.empty?\n\n sql << \"limit #{limit_value}\" unless limit_value.nil?\n sql << \"offset #{offset_value}\" unless offset_value.nil?\n sql << \"slimit #{slimit_value}\" unless slimit_value.nil?\n sql << \"soffset #{soffset_value}\" unless soffset_value.nil?\n sql << \"TZ('#{timezone_value}')\" unless timezone_value.blank?\n sql.join \" \"\n end", "def data_type_pretty\n type_string =\n case(@band.DataType)\n when Gdal::Gdalconst::GDT_UNKNOWN; 'GDT_UNKNOWN'\n when Gdal::Gdalconst::GDT_BYTE; 'GDT_BYTE'\n when Gdal::Gdalconst::GDT_UINT16;'GDT_UINT16'\n when Gdal::Gdalconst::GDT_INT16;'GDT_INT16'\n when Gdal::Gdalconst::GDT_UINT32; 'GDT_UINT32'\n when Gdal::Gdalconst::GDT_INT32; 'GDT_INT32'\n when Gdal::Gdalconst::GDT_FLOAT32; 'IDT_FLOAT32'\n when Gdal::Gdalconst::GDT_FLOAT64; 'GDT_FLOAT64'\n when Gdal::Gdalconst::GDT_CINT16; 'GDT_CINT16' \n when Gdal::Gdalconst::GDT_CINT32; 'GDT_CINT32' \n when Gdal::Gdalconst::GDT_CFLOAT32; 'GDT_CFLOAT32' \n when Gdal::Gdalconst::GDT_CFLOAT64; 'GDT_CFLOAT64'\n else raise ArgumentError(\"Unknown data type.. not sure what to do here folks\", caller)\n end\n type_string\n end", "def to_sql\n \"timestamp '#{to_s}'\"\n end", "def sqlify_date(raw_date)\n m, d, y = raw_date.split('/')\n \"%04d-%02d-%02d\" % [y, m, d]\nend", "def generate_sql\n sql = 'guid, obj_id'\n @fields.each do |field|\n sql << ',v'\n sql << field.num.to_s\n sql << ' as '\n sql << field.name\n end\n return sql\n end", "def native_format\n @data_chunk_reader.raw_native_format\n end", "def native_format\n @data_chunk_reader.raw_native_format\n end", "def prepare_column_options(column)\n super.tap do |spec|\n spec[:encoding] = \"'#{column.sql_type_metadata.encoding}'\" if column.sql_type_metadata.encoding.present?\n end\n end", "def create_dsn_string\n @dsn = \"dbi:#{@driver}:#{@database}\" if @driver\n end", "def database_type(database)\n Contrib::Utils::Database.normalize_vendor(database.database_type.to_s)\n end", "def to_s\n \"Default DataSource\"\n end", "def db_formatted_d( d )\n# d.try( :to_formatted_s, :db_date )\n d&.to_formatted_s( :db_date )\n end", "def quote_value(col)\n case column_detail(col).data_type\n when 'CHAR', 'VARCHAR2', 'CLOB', 'RAW'\n \"'#{@column_values[col]}'\"\n when 'DATE', 'DATETIME'\n \"to_date('#{@column_values[col].strftime('%Y%m%d %H:%M:%S')}', 'YYYYMMDD HH24:MI:SS')\"\n else\n @column_values[col].to_s\n end\n end", "def serialize(row)\n row\n .map { |c| db_format(c) }\n .join(\",\")\nend", "def to_sql\n source.select(bin_sql).to_sql\n end", "def standard_sql?\n !legacy_sql?\n end", "def sql! sql=nil\n require 'niceql'\n puts Niceql::Prettifier.prettify_sql sql || $last_sql_command\n end", "def encoding\n select_value(\"SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE datname LIKE '#{current_database}'\", 'SCHEMA')\n end", "def type_to_sql(type, limit = nil, precision = nil, scale = nil)\n return super unless NO_LIMIT_TYPES.include?(t = type.to_s.downcase.to_sym)\n\n native_type = NATIVE_DATABASE_TYPES[t]\n native_type.is_a?(Hash) ? native_type[:name] : native_type\n end", "def to_s_mysql\n a = self.to_a.collect {|x| x.to_s.rjust(2).gsub(/ /, \"0\")}\n return \"#{a[0]}-#{a[1]}-#{a[2]} #{a[3]}:#{a[4]}:#{a[5]}\"\n end", "def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc:\n if type == :enum\n native = native_database_types[type]\n column_type_sql = native[:name] || 'enum'\n \n column_type_sql << \"(#{limit.map { |v| quote(v) }.join(',')})\"\n column_type_sql \n else\n # Edge rails fallback for Rails 1.1.6. We can remove the\n # rescue once everyone has upgraded to 1.2.\n begin\n __type_to_sql_enum(type, limit, precision, scale)\n rescue ArgumentError\n __type_to_sql_enum(type, limit)\n end\n end\n end", "def quote_date_with_to_date(value)\n value = value.to_s(:db) if value.acts_like?(:date) || value.acts_like?(:time)\n \"TO_DATE('#{value}','YYYY-MM-DD HH24:MI:SS')\"\n end", "def set_date_format(format) \n unless format.nil?\n return format\n else\n return @@db_format\n end\n end", "def sql_type\n self['sql_type']\n end", "def native_database_types\n {\n :primary_key => \"integer not null primary key\",\n :string => { :name => \"varchar\", :limit => 255 },\n :text => { :name => \"blob sub_type text\" },\n :integer => { :name => \"integer\" },\n :float => { :name => \"float\" },\n :decimal => { :name => \"decimal\" },\n :datetime => { :name => \"timestamp\" },\n :timestamp => { :name => \"timestamp\" },\n :time => { :name => \"time\" },\n :date => { :name => \"date\" },\n :binary => { :name => \"blob\" },\n :boolean => { :name => boolean_domain[:name] }\n }\n end", "def type_to_sql(type, limit = nil, precision = nil, scale = nil)\n if type == :decimal\n # Force an explicit scale if none supplied to specify the fixed\n # point form of Virtuoso's DECIMAL type. If no scale is specified,\n # the Virtuoso DECIMAL type stores floating point values.\n precision ||= 32\n scale ||= 0\n end\n super(type, limit, precision, scale)\n end", "def date_out(date_obj = Knj::Datet.new, args = {})\r\n conn_exec do |driver|\r\n if driver.respond_to?(:date_out)\r\n return driver.date_out(date_obj, args)\r\n end\r\n end\r\n \r\n return Knj::Datet.in(date_obj).dbstr(args)\r\n end", "def set_native_database_types\n @native_types = {}\n end", "def quote(value, column = nil) #:nodoc:\n return super unless column\n\n case value\n when Float\n return super unless value.infinite? && column.type == :datetime\n \"'#{value.to_s.downcase}'\"\n when Numeric\n return super unless column.sql_type == 'money'\n # Not truly string input, so doesn't require (or allow) escape string syntax.\n \"'#{value}'\"\n when String\n case column.sql_type\n when 'bytea' then \"E'#{escape_bytea(value)}'::bytea\"\n when 'xml' then \"xml '#{quote_string(value)}'\"\n when /^bit/\n case value\n when /^[01]*$/ then \"B'#{value}'\" # Bit-string notation\n when /^[0-9A-F]*$/i then \"X'#{value}'\" # Hexadecimal notation\n end\n else\n super\n end\n else\n super\n end\n end", "def default\n if @default\n sql = \"SELECT CAST(#{@default} AS #{column_def}) FROM RDB$DATABASE\"\n connection = ActiveRecord::Base.connection\n if connection\n value = connection.select_one(sql)['cast']\n if value.acts_like?(:date) or value.acts_like?(:time)\n nil\n else\n type_cast(value)\n end\n else\n raise ConnectionNotEstablished, \"No Firebird connections established.\"\n end\n end\n end", "def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc:\r\n if native = native_database_types[type]\r\n if type == :integer\r\n column_type_sql = 'integer'\r\n elsif type == :string and !limit.nil?\r\n \"varchar (#{limit})\"\r\n else\r\n super(type, limit, precision, scale)\r\n end\r\n else\r\n super(type, limit, precision, scale)\r\n end\r\n end", "def formatted_for_db?(found_converter, value)\n return false unless found_converter.respond_to?(:db_type)\n found_converter.respond_to?(:converted?) ? found_converter.converted?(value) : value.is_a?(found_converter.db_type)\n end", "def mssql_query(sqla, doprint=false, opts={})\n\t\tinfo = { :sql => sqla }\n\n\t\topts[:timeout] ||= 15\n\n\t\tpkts = []\n\t\tidx = 0\n\n\t\tbsize = 4096 - 8\n\t\tchan = 0\n\n\t\t@cnt ||= 0\n\t\t@cnt += 1\n\n\t\tsql = Rex::Text.to_unicode(sqla)\n\t\twhile(idx < sql.length)\n\t\t\tbuf = sql[idx, bsize]\n\t\t\tflg = buf.length < bsize ? \"\\x01\" : \"\\x00\"\n\t\t\tpkts << \"\\x01\" + flg + [buf.length + 8].pack('n') + [chan].pack('n') + [@cnt].pack('C') + \"\\x00\" + buf\n\t\t\tidx += bsize\n\n\t\tend\n\n\t\tresp = mssql_send_recv(pkts.join, opts[:timeout])\n\t\tmssql_parse_reply(resp, info)\n\t\tmssql_print_reply(info) if doprint\n\t\tinfo\n\tend", "def typus_date_format(attribute = :default)\n Typus::Configuration.config[name]['fields']['options']['date_formats'][attribute.to_s].to_sym\n rescue\n :db\n end", "def to_cql\n fail NotImplementedError\n end", "def quote(value, column = nil) #:nodoc:\n if value.kind_of?(String) && column && column.sql_type =~ /^xml$/\n \"xml '#{quote_string(value)}'\"\n elsif value.kind_of?(Numeric) && column && column.sql_type =~ /^money$/\n # Not truly string input, so doesn't require (or allow) escape string syntax.\n \"'#{value.to_s}'\"\n elsif value.kind_of?(String) && column && column.sql_type =~ /^bit/\n case value\n when /^[01]*$/\n \"B'#{value}'\" # Bit-string notation\n when /^[0-9A-F]*$/i\n \"X'#{value}'\" # Hexadecimal notation\n end\n elsif column && column.sql_type =~ /^datetime$/\n if (not value.nil?) && (value.acts_like?(:date) || value.acts_like?(:time))\n \"CONVERT(datetime,'#{quoted_date(value)}',120)\"\n else\n # Fixtures#insert_fixtures sets fields like +updated_now+ to a String instance (\"Time.now.to_s(:db)\")\n super\n end\n elsif column && column.sql_type =~ /^boolean$/\n \"'#{value ? 1 : 0}'\"\n elsif value.class.to_s == 'System::Byte[]' && column && column.sql_type =~ /^binary$/\n \"CONVERT(varbinary(max),'0x#{bytes_to_string(value)}',1)\" \n else\n super\n end\n end", "def cast_string(sql_type = nil)\n Cast.new(self, sql_type || String).sql_string\n end", "def connect\n config = @connection_options\n @connection = case config[:mode]\n when :dblib\n appname = config[:appname] || configure_application_name || Rails.application.class.name.split('::').first rescue nil\n login_timeout = config[:login_timeout].present? ? config[:login_timeout].to_i : nil\n timeout = config[:timeout].present? ? config[:timeout].to_i/1000 : nil\n encoding = config[:encoding].present? ? config[:encoding] : nil\n TinyTds::Client.new({\n :dataserver => config[:dataserver],\n :host => config[:host],\n :port => config[:port],\n :username => config[:username],\n :password => config[:password],\n :database => config[:database],\n :appname => appname,\n :login_timeout => login_timeout,\n :timeout => timeout,\n :encoding => encoding,\n :azure => config[:azure]\n }).tap do |client|\n if config[:azure]\n client.execute(\"SET ANSI_NULLS ON\").do\n client.execute(\"SET CURSOR_CLOSE_ON_COMMIT OFF\").do\n client.execute(\"SET ANSI_NULL_DFLT_ON ON\").do\n client.execute(\"SET IMPLICIT_TRANSACTIONS OFF\").do\n client.execute(\"SET ANSI_PADDING ON\").do\n client.execute(\"SET QUOTED_IDENTIFIER ON\")\n client.execute(\"SET ANSI_WARNINGS ON\").do\n else\n client.execute(\"SET ANSI_DEFAULTS ON\").do\n client.execute(\"SET CURSOR_CLOSE_ON_COMMIT OFF\").do\n client.execute(\"SET IMPLICIT_TRANSACTIONS OFF\").do\n end\n client.execute(\"SET TEXTSIZE 2147483647\").do\n end\n when :odbc\n if config[:dsn].include?(';')\n driver = ODBC::Driver.new.tap do |d|\n d.name = config[:dsn_name] || 'Driver1'\n d.attrs = config[:dsn].split(';').map{ |atr| atr.split('=') }.reject{ |kv| kv.size != 2 }.inject({}){ |h,kv| k,v = kv ; h[k] = v ; h }\n end\n ODBC::Database.new.drvconnect(driver)\n else\n ODBC.connect config[:dsn], config[:username], config[:password]\n end.tap do |c|\n begin\n c.use_time = true\n c.use_utc = ActiveRecord::Base.default_timezone == :utc\n rescue Exception => e\n warn \"Ruby ODBC v0.99992 or higher is required.\"\n end\n end\n end\n @spid = _raw_select('SELECT @@SPID', fetch: :rows).first.first\n configure_connection\n rescue\n raise unless @auto_connecting\n end", "def quoted_date(value)\n if value.acts_like?(:time)\n if value.respond_to?(:getutc)\n value = value.getutc\n end\n end\n\n result = value.to_s(:db)\n end", "def to_sof\n \"'\" + to_s + \"'\"\n end", "def legacy_sql?\n val = @gapi.configuration.query.use_legacy_sql\n return true if val.nil?\n val\n end", "def formata_data_desconto(formato = '%d%m%y')\n data_desconto.strftime(formato)\n rescue StandardError\n if formato == '%d%m%y'\n '000000'\n else\n '00000000'\n end\n end", "def encoding\n select_value(\n \"SELECT pg_encoding_to_char(pg_database.encoding)\" <<\n \" FROM pg_database\" <<\n \" WHERE pg_database.datname LIKE '#{current_database}'\",\n 'SCHEMA')\n end", "def value_for(value)\n return value.to_s(:db) if value.kind_of?(Time) \n return value.to_s(:db) if value.kind_of?(Date)\n return value.to_s\n end", "def export_data_using_sql(table_or_report_uri, format, sql, config={})\n body = {'ZOHO_SQLQUERY' => sql}\n body = body.merge!(config) if config.present?\n\n options = {\n :query => {\n 'ZOHO_ACTION' => 'EXPORT',\n 'ZOHO_OUTPUT_FORMAT' => format,\n },\n :body => body\n }\n\n result = send_request get_uri(table_or_report_name), 'post', options\n result\n # TODO: Figure out to what to do with File objectsw response\n end", "def info_sql\n INFO_SQL\n end", "def convert_type(v)\n case v\n when Java::NetSourceforgeJtdsJdbc::ClobImpl\n convert_type(v.getSubString(1, v.length))\n else\n super\n end\n end", "def writeTable(outf, db)\n fieldNames = db.fields\n rows = db.data\n \n #outf.puts(\"*** Field Names (#{fieldNames.length}) *** \\n\", fieldNames, \"\\n\") # debug\n #outf.puts(\"*** Records *** \\n\", rows) # debug\n outf.puts(rows)\nend", "def sql\n s = \"\"\n options = @options.dup\n\n if update = options.delete(:update)\n s = \"UPDATE \"\n s << Mao.quote_ident(@table)\n s << \" SET \"\n\n if update.length == 0\n raise ArgumentError, \"invalid update: nothing to set\"\n end\n\n s << update.map do |column, value|\n check_column(column, @table, @col_types)\n\n \"#{Mao.quote_ident(column)} = #{Mao.escape_literal(value)}\"\n end.join(\", \")\n\n if where = options.delete(:where)\n s << \" WHERE \"\n s << Mao::Filter.sql(where)\n end\n elsif insert = options.delete(:insert)\n s = \"INSERT INTO \"\n s << Mao.quote_ident(@table)\n s << \" (\"\n\n keys = insert.map(&:keys).flatten.uniq.sort\n s << keys.map do |column|\n check_column(column, @table, @col_types)\n Mao.quote_ident(column)\n end.join(\", \")\n s << \") VALUES \"\n\n first = true\n insert.each do |row|\n if first\n first = false\n else\n s << \", \"\n end\n\n s << \"(\"\n s << keys.map {|k|\n if row.include?(k)\n Mao.escape_literal(row[k])\n else\n \"DEFAULT\"\n end\n }.join(\", \")\n s << \")\"\n end\n\n if returning = options.delete(:returning)\n s << \" RETURNING \"\n s << returning.map {|c| Mao.quote_ident(c)}.join(\", \")\n end\n else\n s = \"SELECT \"\n\n join = options.delete(:join)\n only = options.delete(:only)\n\n if join\n n = 0\n s << (@col_types.keys.sort.map {|c|\n n += 1\n if !only or (only[@table] and only[@table].include?(c))\n \"#{Mao.quote_ident(@table)}.#{Mao.quote_ident(c)} \" +\n \"#{Mao.quote_ident(\"c#{n}\")}\"\n end\n } + Mao.query(join[0]).col_types.keys.sort.map {|c|\n n += 1\n if !only or (only[join[0]] and only[join[0]].include?(c))\n \"#{Mao.quote_ident(join[0])}.#{Mao.quote_ident(c)} \" +\n \"#{Mao.quote_ident(\"c#{n}\")}\"\n end\n }).reject(&:nil?).join(\", \")\n elsif only\n s << only.map {|c| Mao.quote_ident(c)}.join(\", \")\n else\n s << \"*\"\n end\n\n s << \" FROM #{Mao.quote_ident(@table)}\"\n\n if join\n s << \" INNER JOIN #{Mao.quote_ident(join[0])} ON \"\n s << Mao::Filter.sql(join[1])\n end\n\n if where = options.delete(:where)\n s << \" WHERE \"\n s << Mao::Filter.sql(where)\n end\n\n if order = options.delete(:order)\n s << \" ORDER BY \"\n s << Mao.quote_ident(order[0])\n s << \" \"\n s << order[1]\n end\n\n if limit = options.delete(:limit)\n s << \" LIMIT #{limit}\"\n end\n end\n\n if options.length > 0\n raise ArgumentError,\n \"invalid options in #sql: #{options.inspect}. \" \\\n \"SQL constructed: #{s}\"\n end\n\n s\n end", "def to_oai_dc\n WorkOaiDcSerialization.new(self).to_oai_dc\n end", "def emit(str=\"\", col_format_code=nil)\n str = str.to_s\n if col_format_code\n str = Col(str).fmt(col_format_code)\n end\n @out.puts str\n end", "def printGetDbFormats(dbName)\n printDebugMessage('printGetDbFormats', 'Begin', 1)\n paramsList = soapGetDbFormats({'db' => dbName})\n paramsList.each { |param|\n puts param\n }\n printDebugMessage('printGetDbFormats', 'End', 1)\n end", "def requires_sql_standard_datetimes?\n true\n end", "def configure_connection\n if @config[:encoding]\n if @connection.respond_to?(:set_client_encoding)\n @connection.set_client_encoding(@config[:encoding])\n else\n execute(\"SET client_encoding TO '#{@config[:encoding]}'\")\n end\n end\n self.schema_search_path = @config[:schema_search_path] || @config[:schema_order]\n\n # Use standard-conforming strings if available so we don't have to do the E'...' dance.\n set_standard_conforming_strings\n\n # If using Active Record's time zone support configure the connection to return\n # TIMESTAMP WITH ZONE types in UTC.\n if ActiveRecord::Base.default_timezone == :utc\n execute(\"SET time zone 'UTC'\")\n elsif @local_tz\n execute(\"SET time zone '#{@local_tz}'\")\n end\n end", "def mssql_parse_tds_row(data, info)\n\t\tinfo[:rows] ||= []\n\t\trow = []\n\n\t\tinfo[:colinfos].each do |col|\n\n\t\t\tif(data.length == 0)\n\t\t\t\trow << \"<EMPTY>\"\n\t\t\t\tnext\n\t\t\tend\n\n\t\t\tcase col[:id]\n\t\t\twhen :hex\n\t\t\t\tstr = \"\"\n\t\t\t\tlen = data.slice!(0,2).unpack('v')[0]\n\t\t\t\tif(len > 0 and len < 65535)\n\t\t\t\t\tstr << data.slice!(0,len)\n\t\t\t\tend\n\t\t\t\trow << str.unpack(\"H*\")[0]\n\n\t\t\twhen :string\n\t\t\t\tstr = \"\"\n\t\t\t\tlen = data.slice!(0,2).unpack('v')[0]\n\t\t\t\tif(len > 0 and len < 65535)\n\t\t\t\t\tstr << data.slice!(0,len)\n\t\t\t\tend\n\t\t\t\trow << str.gsub(\"\\x00\", '')\n\n\t\t\twhen :datetime\n\t\t\t\trow << data.slice!(0,8).unpack(\"H*\")[0]\n\n\t\t\twhen :rawint\n\t\t\t\trow << data.slice!(0,4).unpack('V')[0]\n\n\t\t\twhen :bigint\n\t\t\t\trow << data.slice!(0,8).unpack(\"H*\")[0]\n\n\t\t\twhen :smallint\n\t\t\t\trow << data.slice!(0, 2).unpack(\"v\")[0]\n\n\t\t\twhen :smallint3\n\t\t\t\trow << [data.slice!(0, 3)].pack(\"Z4\").unpack(\"V\")[0]\n\n\t\t\twhen :tinyint\n\t\t\t\trow << data.slice!(0, 1).unpack(\"C\")[0]\n\n\t\t\twhen :image\n\t\t\t\tstr = ''\n\t\t\t\tlen = data.slice!(0,1).unpack('C')[0]\n\t\t\t\tstr = data.slice!(0,len) if (len and len > 0)\n\t\t\t\trow << str.unpack(\"H*\")[0]\n\n\t\t\twhen :int\n\t\t\t\tlen = data.slice!(0, 1).unpack(\"C\")[0]\n\t\t\t\traw = data.slice!(0, len) if (len and len > 0)\n\n\t\t\t\tcase len\n\t\t\t\twhen 0,255\n\t\t\t\t\trow << ''\n\t\t\t\twhen 1\n\t\t\t\t\trow << raw.unpack(\"C\")[0]\n\t\t\t\twhen 2\n\t\t\t\t\trow << raw.unpack('v')[0]\n\t\t\t\twhen 4\n\t\t\t\t\trow << raw.unpack('V')[0]\n\t\t\t\twhen 5\n\t\t\t\t\trow << raw.unpack('V')[0] # XXX: missing high byte\n\t\t\t\twhen 8\n\t\t\t\t\trow << raw.unpack('VV')[0] # XXX: missing high dword\n\t\t\t\telse\n\t\t\t\t\tinfo[:errors] << \"invalid integer size: #{len} #{data[0,16].unpack(\"H*\")[0]}\"\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tinfo[:errors] << \"unknown column type: #{col.inspect}\"\n\t\t\tend\n\t\tend\n\n\t\tinfo[:rows] << row\n\t\tinfo\n\tend", "def sql_strings(value)\n case value\n when String\n \"'#{value}'\"\n when Numeric\n value.to_s\n else\n \"null\"\n end\n end", "def escaped_sql\n sql % binds.reduce({}) { |a, (col, val)|\n a[col.to_sym] = if val.is_a? Array\n val.map { |x| @conn.quote x }.join(', ')\n else\n @conn.quote val\n end\n a\n }\n end", "def configure_connection\n super\n execute(\"SET SESSION IntervalStyle TO 'iso_8601'\", 'SCHEMA')\n end", "def quote_string(string)\n @logger.unknown(\"ODBCAdapter#quote_string>\") if @trace\n\n # MySQL requires backslashes to be escaped\t\t\t\t\n string.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\")\n end", "def prefix\n if @config.db_general_authmode == :winauth\n \"%s.dbo.\" % [@dbprops.name]\n else\n \"\"\n end\n end", "def database_column_type\n :string\n end", "def to_sql\n @line.gsub(OUTPUT_REGEX, '')\n end", "def sql sql\n @master.puts \"#{sql};\"\n end", "def sql_datetime_second_mask\n case session[:database][:locale]\n when \"de\" then \"DD.MM.YYYY HH24:MI:SS\"\n when \"en\" then \"YYYY-MM-DD HH24:MI:SS\"\n else \"DD.MM.YYYY HH24:MI:SS\" # Deutsche Variante als default\n end\n end", "def execute( sql, backwards_compat=false )\r\n result = @conn.query( sql )\r\n if backwards_compat\r\n return PGresult.new( result )\r\n else\r\n ResultSet.new result\r\n end\r\n rescue Exception => e\r\n raise DataAccessException.new( e.message, e ), $!, caller\r\n end", "def mssqlchar\n foo=[]\n self.asciime.split(',').each {|chr| foo << \"CHAR(#{chr})\" }\n foo.join('+')\n end" ]
[ "0.6067609", "0.5955339", "0.5916529", "0.59145594", "0.5631123", "0.5609314", "0.55505466", "0.54980963", "0.5419187", "0.54061157", "0.5389631", "0.5345905", "0.52913034", "0.5215306", "0.5214778", "0.52143836", "0.5112817", "0.50917166", "0.5089373", "0.50670135", "0.5047186", "0.4992715", "0.49772838", "0.494416", "0.49418685", "0.4938983", "0.49218887", "0.49136272", "0.48784712", "0.48670006", "0.48227993", "0.47922087", "0.4789843", "0.4781098", "0.47787505", "0.47662857", "0.47632688", "0.47612095", "0.47606462", "0.47544825", "0.4754294", "0.4754294", "0.47504824", "0.47434703", "0.4719729", "0.47147804", "0.47083497", "0.47059843", "0.46887085", "0.4682607", "0.4677717", "0.46745244", "0.46722665", "0.466993", "0.46697062", "0.4665093", "0.46528125", "0.4648099", "0.4647768", "0.4637463", "0.46369228", "0.46336806", "0.46234256", "0.46194467", "0.4616151", "0.46101278", "0.460608", "0.4589359", "0.45837015", "0.4583361", "0.458299", "0.45723665", "0.45712626", "0.45702484", "0.45702398", "0.45669904", "0.4565862", "0.45561078", "0.4552805", "0.45520532", "0.45513728", "0.45400384", "0.45318973", "0.4529927", "0.45227835", "0.4519507", "0.45031422", "0.4488405", "0.44866067", "0.4485435", "0.4485077", "0.44789633", "0.44742233", "0.44637647", "0.44474545", "0.4445482", "0.44448638", "0.44377807", "0.44325635", "0.44312817", "0.44300464" ]
0.0
-1
tests whethere an integer is even or odd
def is_even?(n) true if n%2==0 else false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_odd2?(int) \n if int < 0\n int = int * -1\n end\n int % 2 == 1\nend", "def is_odd?(integer)\n integer % 2 != 0\nend", "def is_odd?(int)\n (int % 2).abs != 0\nend", "def is_odd?(int)\n int % 2 == 1\nend", "def is_it_odd?(int)\n int.abs % 2 != 0\nend", "def is_odd?(integer)\n\tinteger.abs % 2 == 1\n\t\nend", "def is_also_odd?(param_integer)\n param_integer % 2 > 0\nend", "def is_odd?(int) \n if int % 2 == 0\n return false\n else return true\n end\nend", "def is_odd?(integer)\n integer % 2 == 1\nend", "def is_odd?(integer)\n integer % 2 == 1\nend", "def is_odd?(integer)\n integer % 2 == 1\nend", "def is_odd?(int)\n int.abs % 2 == 1\nend", "def is_odd?(integer)\n integer % 2 == 0 ? false : true\nend", "def even? num\n num.to_i % 2 == 0\n end", "def is_odd?(int)\n int.odd?\nend", "def is_odd?(int)\n int.abs.remainder(2) == 1\nend", "def odd(int)\n int % 2 == 1\nend", "def this_is_also_odd?(param_integer)\n param_integer.remainder(2) != 0\nend", "def is_odd?(integer)\r\n !(integer.abs.remainder(2) == 0)\r\nend", "def is_odd?(number)\n number % 2 != 0\nend", "def is_odd?(num)\n num.abs.to_i % 2 != 0 && num.to_i == num\nend", "def is_odd?(num)\n num % 2 != 0\nend", "def is_odd?(num)\n num % 2 != 0\nend", "def odd_number_check_two(number)\r\n number % 2 == 1 || number % 2 == -1 \r\nend", "def is_odd2?(num)\n num.abs % 2 == 1\nend", "def is_odd(num)\n return ((num % 2) != 0)\nend", "def is_odd?(input)\n input % 2 != 0 # => true\nend", "def is_odd1?(integer)\n integer.remainder(2) != 0\nend", "def is_odd?(number)\n number.to_i.odd?\nend", "def is_odd?(num)\r\n num % 2 == 1\r\nend", "def is_odd2?(num)\n num.remainder(2) != 0\nend", "def is_odd?(n)\n n % 2 == 1\nend", "def is_odd? number\n number % 2 == 1\nend", "def is_odd(num)\n return num % 2 == 1\nend", "def is_odd?(number)\n number % 2 == 1\nend", "def is_odd(number)\n if number%2 > 0\n return true\n end\n return false\nend", "def is_odd(n)\n n % 1 == 0 && n.to_i.odd?\nend", "def is_odd?(num)\n # could use the built-in Integer#odd? method but building my own for practice\n num.abs % 2 == 1\nend", "def is_odd?(n)\n n.abs % 2 != 0\nend", "def is_odd?(num)\n num.abs % 2 != 0\nend", "def is_odd?(num)\n num % 2 == 1\nend", "def is_odd?(num)\n num % 2 == 1\nend", "def is_odd?(num)\n num % 2 == 1\nend", "def is_odd?(num)\n num % 2 == 1\nend", "def is_odd?(num)\n num % 2 == 1\nend", "def is_odd?(number)\n number.abs % 2 != 0\nend", "def is_odd?(number)\n number.abs % 2 != 0\nend", "def is_even(num)\n return(num % 2) == 0\nend", "def is_odd?(num)\n num.remainder(2) == 1 || num.remainder(2) == -1\nend", "def is_even(number)\n number.to_i\n if number%2 == 1\n return true\n else\n return false\n end\nend", "def is_even(n)\n !n.odd?\nend", "def is_even(num)\n return num % 2 == 0\nend", "def is_odd?(number)\n number.abs % 2 != 0 && number != 0\nend", "def is_even(n)\n return n % 2 === 0\nend", "def is_odd?(num)\n num.remainder(2) != 0\nend", "def is_odd?(num)\n num.remainder(2) != 0\nend", "def is_odd?(num)\n num.remainder(2) != 0\nend", "def is_odd?(num)\n return num.abs % 2 == 1 ? true : false\nend", "def odd_integer(n)\n if n % 2 == 0 || n == 0\n return false\n else \n return true\n end\nend", "def is_odd?(integer)\n# integer.abs % 2 == 1 the #abs method is unnecessary here, because of how modulus works :)\n integer % 2 == 1\nend", "def is_odd?(number)\n number.remainder(2) != 0\nend", "def is_odd?(num)\n # num.abs % 2 != 0 \n num % 2 == 1\n # ruby modulus operator always return non-negative result if num on right is positive\n # ie, % is a modulus operator and \"not a remainder operator as in some languages\"\n # my first line was correct, but more properly per the proposed problem\n # check if odd, do not check if not even\nend", "def odd_number?(number)\n number % 2 == 1\nend", "def is_even int\n if int.class != Integer\n p 'Please enter a whole number'\n elsif int % 2 == 0\n p \"#{int} is even.\"\n else\n p \"#{int} is odd.\"\n end\nend", "def is_even(n)\n n % 2 == 0\nend", "def is_even(n)\n n % 2 == 0\nend", "def is_odd(number)\n if number % 2== 1\n return true\n else \n return false\n end \nend", "def is_odd(number)\n return true if number % 2 != 0\n return false if number % 2 == 0\nend", "def is_odd?(num)\n # return false if num.zero?\n # num *= -1 if num < 0\n !(num % 2).zero?\n # !(num.remainder(2).zero?)\nend", "def is_odd?(int)\n \n # int.abs.odd? # #abs, #remainder\n\n # int.abs.remainder(2) == 1 # #abs and #remainder \n \n # int.remainder(2) == 1 || int.remainder(2) == -1 # remainder only\n \n int % 2 == 1 # #modulo % always has the sign of the divisor (positive 2)\n\nend", "def ood_or_even(number)\n if number.odd?\n 'the number is odd'\n else\n 'the number is even'\n end\nend", "def is_odd?(number)\n number.remainder(2).abs > 0\nend", "def is_odd?(num)\n num.remainder(2).abs == 1\nend", "def is_odd(tal)\n if tal % 2 != 0\n return true\n else\n return false\n end\nend", "def is_odd?(input)\n\n if input % 2 == 1\n true\n else\n false\n end\n\nend", "def is_even(num)\n if num%2 ==0\n puts true\n else\n puts false\n end\nend", "def is_odd(x)\n # Use the logical results provided to you by Ruby already..\n x % 2 != 0\nend", "def is_odd?(value)\n return false unless value == value.to_i # check float = integer\n value.abs % 2 == 1 ? true : false # check if odd\nend", "def is_odd(num)\n return true if num % 2 != 0\n return false\nend", "def is_odd?(num)\n num.odd?\nend", "def is_odd?(num)\n num.odd?\nend", "def is_odd(number)\n if number % 2 == 0\n return false\n end\n return true\nend", "def is_odd?(integer)\n integer.abs.remainder\nend", "def is_odd?(number)\n number.abs.remainder(2) == 1\nend", "def is_odd(x)\n x % 2 == 0 ? false : true\nend", "def is_odd?(num)\n if num == 0 ||num.remainder(2) == 0\n false\n else\n true\n end\nend", "def is_odd(num)\n if num % 2 == 0\n return false\n else\n return true\n end\nend", "def is_even(number)\n if number % 2 == 0\n return true\n else\n return false\n end\nend", "def isEven(i)\n\t(i & 1) == 0\nend", "def is_even(number)\n if number % 2== 0\n return true\n else \n return false\n end \n \nend", "def is_even(num)\n if num % 2 == 0\n return true\n else\n return false\n end\nend", "def test_odd?\n assert_equal(false, @main.odd?(0))\n assert_equal(true, @main.odd?(1))\n assert_equal(false, @main.odd?(2))\n assert_equal(true, @main.odd?(-1)) \n assert_equal(false, @main.odd?(-2))\n end", "def is_even(num)\n if num % 2 == 0\n return num\n else\n return 0\n end\nend", "def is_odd(number)\n\tif(number%2 != 0)\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def is_odd_using_remainder(int)\n int.remainder(2).abs == 1\nend", "def is_odd(num)\n output = false\n if num % 2 != 0\n output = true\n end\n return output\nend", "def odd?(number)\n if number % 2 == 0\n false\n else \n true\n end\nend", "def is_odd(number)\n output = false\n if (number % 2) != 0\n output = true\n end\n return output\nend", "def odd_or_even(number)\n if number.odd?\n \"That number is odd\"\n else\n \"That number is even\"\n end\nend", "def is_odd?(num)\n num = num * -1 if num < 0 # get absolute value\n num.remainder(2) == 1 ? true: false\nend" ]
[ "0.84689146", "0.8466157", "0.846187", "0.84572583", "0.84379417", "0.84278005", "0.8426993", "0.8409027", "0.83983904", "0.83983904", "0.83983904", "0.8381239", "0.8378729", "0.82809865", "0.82592034", "0.825356", "0.8228626", "0.8228557", "0.81828874", "0.8126947", "0.81248325", "0.81241703", "0.81241703", "0.81157005", "0.8108418", "0.8088651", "0.80809164", "0.80796015", "0.80782807", "0.8054489", "0.8044494", "0.80402374", "0.8036724", "0.8030109", "0.8029497", "0.80275553", "0.8022303", "0.8020952", "0.8019613", "0.801224", "0.80101824", "0.80101824", "0.80101824", "0.80101824", "0.80101824", "0.8003165", "0.8003165", "0.8001602", "0.79896194", "0.7989082", "0.798751", "0.7986658", "0.79770625", "0.79745775", "0.7958559", "0.7958559", "0.7958559", "0.79544336", "0.7953174", "0.79526544", "0.79413396", "0.79396415", "0.7938059", "0.7937621", "0.7926477", "0.7926477", "0.79217607", "0.7920719", "0.79179996", "0.791457", "0.79144526", "0.7904671", "0.7904549", "0.7897164", "0.78813976", "0.78786707", "0.78741866", "0.78731006", "0.7869185", "0.7853129", "0.7853129", "0.7845437", "0.78445256", "0.7838607", "0.7838576", "0.7837296", "0.78342074", "0.7830589", "0.7826101", "0.78245693", "0.78206086", "0.7813001", "0.7811679", "0.78046584", "0.7797808", "0.77957183", "0.77880937", "0.7786559", "0.777277", "0.7765031" ]
0.78785306
76
In the previous exercise, we wrote a method that emulates Enumerableeach_cons, but limited our method to handling 2 elements at a time. Enumerableeach_cons can actually handle any number of elements at a time: 1, 2, 3, or more. Update your each_cons method so it takes an argument that specifies how many elements should be processed at a time. Your method may use each, each_index, each_with_object, inject, loop, for, while, or until to iterate through the Array passed in as an argument, but must not use any other methods that iterate through an Array or any other collection.
def each_cons(arr, num_cons_elems) num_yields = arr.size - num_cons_elems + 1 puts "arr.size = #{arr.size} num_cons_elems = #{num_cons_elems} num_yields = #{num_yields}" num_yields.times do |index| p *arr[index..(index + num_cons_elems - 1)] yield(*arr[index..(index + num_cons_elems - 1)]) index += 1 end nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each_cons(array, cons_elements)\n array.each_with_index do |value, index|\n if index <= array.size - cons_elements\n yield(value, *array[(index + 1)...(index + cons_elements)])\n end\n end\n nil\nend", "def each_cons(array)\n array.each_with_index do |item, index|\n break if index + 1 >= array.size\n yield(item, array[index + 1])\n end\n nil\nend", "def each_cons(arr)\n first = 0\n second = 1\n loop do\n break if second >= arr.size\n yield(arr[first], arr[second])\n first += 1\n second += 1\n end\n nil\nend", "def each_cons(arr, &block)\n arr.size < 2 ? return : block.call(arr[0, 2])\n each_cons(arr.drop(1), &block)\nend", "def each_cons(array)\n index1 = 0\n index2 = 1\n while index1 < array.size\n yield(index1, index2)\n index1 += 2\n index2 += 2\n end\n return nil\nend", "def each_cons(array)\n iterations = array.size - 1\n iterations.times do |index| \n yield(array[index], array[index + 1])\n end\n nil\nend", "def each_cons(arr)\n ndx = 0\n while ndx < arr.size - 1\n yield(arr[ndx], arr[ndx + 1])\n ndx += 1\n end\n nil\nend", "def each_cons(n)\n # Your code goes here.\n end", "def each_cons(arr, n)\n arr.each_with_index do |el, idx|\n break if idx + n > arr.size\n if n < 3\n yield(el, arr[idx + 1])\n else\n yield([el, arr.slice((idx + 1), (n - 1))].flatten)\n end\n end\nend", "def each_cons list, n\n list.each_cons(n).to_a\nend", "def each_cons(list)\n index = 0\n while index + 1 < list.length\n yield(list[index], list[index + 1])\n index += 1\n end\nend", "def each_cons(array, n)\n array.each_index do |index|\n break if index + n - 1 >= array.size\n yield(*array[index..(index + n - 1)])\n end\nend", "def each_cons(array, n)\r\n array.each_index do |index|\r\n break if index + n -1 >= array.size\r\n yield(*array[index..(index + n - 1)])\r\n end\r\n nil\r\nend", "def each_cons(array, consecutive_num=2)\n return nil if array.empty? || !block_given?\n\n array.each_index do |index|\n return nil if index + consecutive_num - 1 >= array.size\n yield(*array[index..(index + consecutive_num - 1)])\n end\nend", "def each_cons(array, step)\n count = 0\n blocks = []\n while count < array.size\n block = []\n count.upto(count + step) do |num|\n block << array[num]\n end\n blocks << block\n count += 1\n end\n\n array.each_with_index do |element, idx|\n yield(element, blocks[idx])\n end\nend", "def test_0640_each_cons\n @@log.debug \"test_0640_each_cons starts\" if @@log.debug?\n assert_respond_to(@list, :each_cons, \"test_0640_each_cons_respond\")\n # Type check\n enum = @list.each_cons(2)\n result = enum.is_a? Enumerator\n assert(result,\"test_0640_each_cons_class\") \n # Ckeck each consecutive array\n pass = 0\n @list.each_cons(2) {|suba|\n pass += 1\n case pass\n when 1\n assert_equal([@aen, @bsb], suba, \"test_0640_each_cons_p1\")\n when 2\n assert_equal([@bsb, @cab], suba, \"test_0640_each_cons_p2\")\n when 3\n assert_equal([@cab, @dad], suba, \"test_0640_each_cons_p3\")\n else\n fail(\"test_0640_each_cons_invalid\")\n end\n }\n @@log.debug \"test_0640_each_cons ends\" if @@log.debug?\n end", "def got_three?(array) # def got_three?(elements)\n array.each_cons 3 do |a, b, c| # elements.each_cons 3 do |a, b, c|\n if a == b && b == c # return true if a == b && b == c\n return true # end\n else # false\n false # end\n end\n end\nend", "def each(arr)\n counter = 0\n \n while counter < arr.length\n yield(arr[counter])\n counter += 1\n end\n \n arr\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 odd_elements(array)\n counter = 0\n newarray = []\n array.each do |x|\n if counter.odd?\n if block_given?\n newarray.push(yield x)\n else\n newarray.push(x)\n end\n end\n counter += 1\n end\n newarray\nend", "def my_each(array) \n n = 0\n while n < array.length \n yield(array[n])\n n = n + 1 \n end\n array\nend", "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 got_three?(elements)\n elements.each_cons 3 do |a, b, c| # iterates the given block for each array of consecutive <n> elements.\n return true if a == b && b == c # return true when the condition is true (note this happens is inside the iterator)\n end\n false # else return false\nend", "def odd_elements(array)\n res = []\n (1...array.length).step(2).each do |idx|\n elem = array[idx]\n elem = yield elem if block_given?\n res.push(elem)\n end\n\n res\nend", "def each(arr)\n ndx = 0\n while ndx < arr.size do\n yield(arr[ndx])\n ndx += 1\n end\n arr\nend", "def each(array)\n counter = 0\n while counter < array.size do\n yield(array[counter])\n counter += 1\n end\n array\nend", "def each(array)\n index = 0\n\n while index < array.size\n element = array[index]\n yield element\n index += 1\n end\n \n array\nend", "def for_each_element(arr)\n index = 0\n total = arr.size\n\n while index < total\n yield(arr[index])\n index += 1\n end\nend", "def each(arr)\n # set index value, beginning with the first element at 0\n i = 0\n # while the current index value still exists in the array, run the block of code, stored in yield, on each index, then increase the index value by 1 until the end of the array\n while i < arr.length\n yield(arr[i])\n i += 1\n end\nend", "def my_each(array)\n i = 0\n while i < array.length\n yield array[i]\n i += 1\n end\n array\nend", "def my_collect(array)\n i = 0\n collect = []\n while i < array.length\n collect << yield(array[i])\n i += 1\n end\n collect\nend", "def my_collect(array)\ni = 0\n\nnewArray = []\nwhile i < array.length\n\n newArray.push(yield array[i])\n i = i + 1\nend\nnewArray\nend", "def my_each(array)\n if block_given?\n counter = 0\n while counter < array.length\n yield (array[counter])\n counter += 1\n end\n array\n else\n puts \"No block given\"\n end\nend", "def my_collect(array)\n i = 0\n collection = []\n while i < array.size\n collection << yield(array[i])\n i += 1\n end\n collection\nend", "def my_each(array)\n if block_given?\n i = 0\n while i < array.length\n yield array[i]\n i = i + 1\n end\n array\n end\nend", "def each(array)\n idx = 0\n while idx < array.size\n yield(array[idx]) if block_given?\n idx += 1\n end\n\n array\nend", "def hello(array)\n i = 0\n collection = []\n while i < array.length\n collection << yield(array[i])\n i += 1\n end\n collection\nend", "def hello(array)\n i = 0\n collection = []\n while i < array.length\n collection << yield(array[i])\n i += 1\n end\n collection\nend", "def hello(array)\n i = 0\n collection = []\n while i < array.length\n collection << yield(array[i])\n i += 1\n end\n collection\nend", "def my_collect(array)\n i = 0\n collect = []\n while i < array.length\n collect << yield(array[i])\n i+=1\n end\n collect\nend", "def my_collect(array)\n collection = []\n index = 0\n while index < array.size\n collection << yield(array[index])\n index += 1\n end\n collection\nend", "def got_three? array\n three = false\n array.each_cons(3) do |a, b, c|\n three = true if (a == b && a == c)\n end\n three\nend", "def cycle arr\n while true\n arr.each do |elem|\n yield elem\n end\n end\nend", "def each(array)\n for elem in array do\n yield(elem)\n end\n\n array\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 consecutive(arr)\r\n\r\nend", "def my_collect(array)\n \n i = 0 \n collect = []\n \n while i < array.length \n collect << yield(array[i])\n i += 1\n end\n \n collect \nend", "def my_collect(array) # put argument(s) here\n # code here\n i = 0\n result = []\n\n while i < array.size\n\n result << yield(array[i])\n i += 1\n end\nresult\nend", "def my_each(array) # put argument(s) here\n i = 0\n\n while i < array.length\n yield array[i]\n i += 1\n end\n array\nend", "def my_each(array)\n i = 0\n while i < array.length\n yield(array[i])\n array[i]\n i += 1\n end\n array\nend", "def custom_each(array)\n i = 0\n while i < array.length\n yield array[i]\n i += 1\n end\nend", "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 cada2(array, &myproc)\n i = 0\n while i < array.size\n myproc.call(array[i])\n i += 1\n end\n array\nend", "def oddities(arr)\n counter = 0\n return_array = []\n loop do\n return_array << arr[counter]\n counter += 2\n break if counter >= arr.size\n end\n return_array.compact\nend", "def double_eles(arr)\n arr.map do |ele|\n ele * 2\n end\nend", "def reduce(arr, accum=0)\n counter = 0\n\n while counter < arr.size\n accum = yield(accum, arr[counter])\n counter += 1\n end\n\n accum\nend", "def my_collect(input_array)\n if block_given?\n counter = 0\n output = []\n while counter < input_array.size\n output << yield(input_array[counter])\n counter +=1\n end\n output\n end\n\n\n\n\nend", "def each\n i = 0\n while i < 2\n yield self[i]\n i += 1\n end\n end", "def test_each\n # codecite examples\n evens = Sequence.new(5, 2) {|a| a.last + 2} \n odds = Sequence.new(5, 1) {|a| a.last + 2}\n fibs = Sequence.new(5, 1, 1) {|a| a[-2] + a[-1]}\n # codecite examples\n \n assert_equal [2,4,6,8,10], evens.to_a\n assert_equal [1,3,5,7,9], odds.to_a\n assert_equal [1,1,2,3,5], fibs.to_a\n end", "def pbEachCombination(array,num)\n return if array.length<num || num<=0\n if array.length==num\n yield array\n return\n elsif num==1\n for x in array\n yield [x]\n end\n return\n end\n currentComb = []\n arr = []\n for i in 0...num\n currentComb[i] = i\n end\n begin\n for i in 0...num\n arr[i] = array[currentComb[i]]\n end\n yield arr\n end while _pbNextComb(currentComb,array.length)\nend", "def my_collect(array)\n new_array = []\n # if array.size == 0\n # return 0\n # else\n counter = 0\n while counter < array.length\n new_array << yield(array[counter])\n counter += 1\n end\n \n new_array\nend", "def got_three?(array)\n r = []\n r_2 = []\n array.each_cons(2) { |a, b| r << [a, b] }\n r.each_cons (2) {|e1, e2| r_2 << (e1 == e2)}\n r_2.include? true\nend", "def consecutives(size)\n Enumerator.new do |enum|\n ps = Prime.lazy\n a = Prime.take(size)\n size.times{ps.next}\n loop do \n enum << a.dup\n ( a << ps.next ).shift\n end\n end\nend", "def doubler(arr)\n new = []\n arr.each do |i|\n new << i*2\n end\n return new\nend", "def pbEachCombination(array,num)\n return if array.length<num || num<=0\n if array.length==num\n yield array\n return\n elsif num==1\n for x in array\n yield [x]\n end\n return\n end\n currentComb=[]\n arr=[]\n for i in 0...num\n currentComb[i]=i\n end\n begin\n for i in 0...num\n arr[i]=array[currentComb[i]]\n end\n yield arr\n end while _pbNextComb(currentComb,array.length)\nend", "def do_it_twice(array)\n yield(array[0])\n yield(array[1])\nend", "def got_three?(numbers)\n numbers.each_cons(3) do |a, b, c|\n if a == b && b == c\n return true\n end\n return false\n end\nend", "def reverse_each_cons(size, items)\n slots = Array.new(size)\n enum = items.reverse_each\n stops = nil\n\n loop do\n item = begin\n stops += 1 if stops\n stops ? nil : enum.next\n rescue StopIteration\n stops = 1\n nil\n end\n\n slots.unshift(item)\n slots.pop\n\n yield slots\n\n # It's not useful to anybody to yield an array of all nils.\n break if stops == size - 1\n end\n end", "def reduce(array, default = nil)\n unless default\n accumulator = 0 # Setting the starting accumulator value.\n else\n accumulator = default\n end\n index = 0\n\n# Yielding to the block for each element\n while index < array.size\n element = array[index]\n accumulator = yield accumulator, element\n index += 1\n end\n \n accumulator # Returning the accumulator at the end of iteration.\nend", "def oddities2(arr)\n index = 0\n result = []\n loop do\n break if index >= arr.size\n result << arr[index]\n index += 2\n end\n result\nend", "def yield_with_each(array, &block)\n array.each do |x|\n yield x\n end\n\nend", "def reduce(arr, acc = 0)\n count = 0\n\n while count < arr.size\n acc = yield(acc, arr[count])\n count += 1\n end\n\n acc\nend", "def yield_with_each(array, &block)\n array.each { |i| yield i }\nend", "def doubler(array)\r\n res = []\r\n array.each do |ele|\r\n res << ele * 2\r\n end\r\n res\r\nend", "def my_each(array)\n if block_given?\n i = 0\n \n while i < array.length \n yield array[i] \n i = i + 1 \n end\n \n array\n else\n return \"Hey! No block was given!\"\n end\nend", "def yield_with_while_loop(array, &block)\n i = 0\n while i < array.length\n yield array[i]\n i += 1\n end\nend", "def consecutive(arr)\n\n (0...arr.length - 1).each do |i|\n if arr[i] + 1 == arr[i + 1] || arr[i] == arr[i + 1] + 1\n return arr[0...i] + arr[i + 2..-1]\n end\n end\n arr\nend", "def my_collect(array)\n if block_given?\n i = 0\n collection = []\n while i < array.length\n collection << yield(array[i])\n i+=1\n end\n else\n puts \"Hey! No block given!\"\n end #block_given?\n collection\nend", "def consecutive_collapse(arr)\nend", "def combinations(arr)\n\n arr.each_with_index do |ele1, idx|\n arr.each_with_index do |ele2, idx2|\n puts ele1 + ele2\n end\n end\n\nend", "def nc_my_each(array, &block)\n array.length.times do |i|\n block.call(array[i])\n end\n array\nend", "def reduce(array, acc = 0)\n index = 0\n\n while index < array.size\n acc = yield(acc, array[index])\n index += 1\n end\n\n acc\nend", "def hello_t(array)\n i = 0\n\n while i < array.length\n yield(array[i])\n i = i + 1\n end\n\n array\nend", "def yield_with_while_loop(array, &block)\n return [] if array.length == 0\n i = 0\n while i < array.length\n block.call(array[i])\n i += 1\n end\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 consecutive_collapse(nums)\n found_pairs = true\n collapsed = nums\n\n while(found_pairs)\n found_pairs = false\n new_iterration = []\n\n (0...collapsed.count-1).each do |i|\n if consecutive?(collapsed[i], collapsed[i+1])\n new_iterration.concat(collapsed[i+2..-1])\n found_pairs = true\n break\n else\n new_iterration << collapsed[i]\n end\n end\n collapsed = new_iterration if found_pairs\n end\n collapsed\nend", "def oddities(array)\n result = []\n index = 0\n\n loop do\n result << array[index]\n index += 2\n break if index >= array.size\n end\n\n result\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 each_pair(*) end", "def reduce(arr, acc=0)\n sum = acc\n counter = 0\n\n while counter < arr.size\n element = arr[counter]\n sum = yield(sum, element)\n counter += 1\n end\n\n sum\nend", "def consume_arr(y)\n y.each { |elem| puts (elem*2) }\nend", "def consume_arr(y)\n y.each { |elem| puts (elem*2) }\nend", "def consume_arr(y)\n y.each { |elem| puts (elem*2) }\nend", "def sequence2(n, m, c)\ni = 0\nwhile(i < n)\n# loop n times\nyield i*m + c\n# pass next element of the sequence to the block\ni += 1\nend\nend", "def multi_map(arr, n=1, &prc)\n new_arr = []\n\n arr.each do |ele|\n new_ele = ele\n n.times do\n new_ele = prc.call(new_ele)\n end\n\n new_arr << new_ele\n end\n new_arr\n\nend", "def each_word_pair\n words.each_cons(2) { |array| yield(array[0],array[1]) }\n end", "def oddities(array)\n odd_elements = []\n index = 0\n while index < array.size\n odd_elements << array[index]\n index += 2\n end\n odd_elements\nend", "def oddities(array)\n odd_elements = []\n index = 0\n while index < array.size\n odd_elements << array[index]\n index += 2\n end\n odd_elements\nend", "def caterpillar_method\n result=[]\n i=0\n while(i<self.size/2)\n j=i+1\n while (self[j] && (yield self[i],self[j]))\n result<<[self[i],self[j]]\n j+=1\n end\n i+=1\n end\n return result\n end", "def using_each(arr)\n result = []\n acc = []\n arr.each { |e| \n acc << e\n if (acc.length === 4 or e === arr.last)\n result << acc\n acc = []\n end\n }\n result\nend" ]
[ "0.8156945", "0.8142903", "0.8129785", "0.81081074", "0.8091964", "0.80225486", "0.80110407", "0.7953092", "0.78244764", "0.77529466", "0.7731859", "0.7730933", "0.7721244", "0.7707085", "0.7532563", "0.7391682", "0.6293397", "0.62558365", "0.6183258", "0.618119", "0.6128222", "0.61256236", "0.60768664", "0.6058411", "0.604511", "0.60444576", "0.603275", "0.6023102", "0.6016462", "0.5995515", "0.59603024", "0.59522283", "0.5951992", "0.5951935", "0.5947136", "0.5944406", "0.5942358", "0.5942358", "0.5942358", "0.59256786", "0.59213424", "0.5918133", "0.59027535", "0.5898862", "0.5889755", "0.58874214", "0.5876248", "0.5875806", "0.5835471", "0.5833511", "0.5818026", "0.5796877", "0.5764006", "0.5756262", "0.5747668", "0.5720881", "0.5720672", "0.570816", "0.5705382", "0.57041657", "0.5696775", "0.5690997", "0.56813955", "0.56755006", "0.5674616", "0.56683254", "0.5642494", "0.563264", "0.5625458", "0.56207883", "0.5611215", "0.56080544", "0.5606993", "0.5606084", "0.56028324", "0.56020206", "0.55636644", "0.55546296", "0.5551946", "0.5532888", "0.5532533", "0.5532069", "0.5527076", "0.5526403", "0.5500569", "0.54994535", "0.5494895", "0.5487404", "0.54865056", "0.5482691", "0.548243", "0.548243", "0.548243", "0.5478028", "0.5475096", "0.5467508", "0.54622555", "0.5461476", "0.54583883", "0.5454798" ]
0.7987888
7
assert_equal( expected, actual, failure_message = nil ) String > Integer produce integer of roman String I = 1 V = 5 X = 10 L = 50 C = 100 D = 500 M = 1000 IV = 4 IX = 9 XL = 40 XC = 90 CD = 400 CM = 900
def roman_to_integer str result = 0 idx = 0 # thousands while true if str[idx, 1].downcase != 'm' break end result += 1000 idx += 1 end # 900 or 400 or 500 if str[idx, 2].downcase == 'cm' result += 900 idx += 2 elsif str[idx, 2].downcase == 'cd' result += 400 idx += 2 elsif str[idx, 1].downcase == 'd' result += 500 idx += 1 end # hundreds while true if str[idx, 1].downcase != 'c' break end result += 100 idx += 1 end # 90 or 50 or 40 if str[idx, 2].downcase == 'xc' result += 90 idx += 2 elsif str[idx, 2].downcase == 'xl' result += 40 idx += 2 elsif str[idx, 1].downcase == 'l' result += 50 idx += 1 end # tens while true if str[idx, 1].downcase != 'x' break end result += 10 idx += 1 end # 9 or 4 or 5 if str[idx, 2].downcase == 'ix' result += 9 idx += 2 elsif str[idx, 2].downcase == 'iv' result += 4 idx += 2 elsif str[idx, 1].downcase == 'v' result += 5 idx += 1 end # ones while true if str[idx, 1].downcase != 'i' break end result += 1 idx += 1 end if idx == str.length return result else puts "#{str} is not a valid roman number" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_is_number_true\n #Arrange\n input = '2'\n #Act\n result = @roman.is_number?(input)\n #Assert\n assert_equal(true, result)\n end", "def test_for_bigger_numbers\n\t\tassert_equal(\"MCXCI\", roman_converter(1191))\n\t\tassert_equal(\"MLXVI\", roman_converter(1066))\n\t\tassert_equal(\"XLIX\", roman_converter(49))\n\t\tassert_equal(\"CMXCIX\", roman_converter(999))\n\t\tassert_equal(\"DCLXVI\", roman_converter(666))\n\tend", "def test_is_roman\n assert_equal(true, RomanMathmaticalOperation.is_roman(\"V\"))\n exception = assert_raise(\"RomanMathmaticalOperationError\") {RomanMathmaticalOperation.is_roman(1)}\n assert_equal(\"Not valid input\", exception.message)\n exception = assert_raise(\"RomanMathmaticalOperationError\") {RomanMathmaticalOperation.is_roman(\"WRONG\")}\n assert_equal(\"Not valid input\", exception.message)\n end", "def test_to_roman\n assert_equal(\"X\", RomanMathmaticalOperation.new.send(:to_roman,10))\n assert_not_equal(\"X\", RomanMathmaticalOperation.new.send(:to_roman,11))\n assert_equal(\"\", RomanMathmaticalOperation.new.send(:to_roman,0))\n end", "def generic_fn_roman_numerals(input, expected)\n #Arrange\n #This step is not longer used because the input comes as parameter\n #Act\n result = @roman.convert( input )\n #Assert\n assert_equal(expected, result)\n end", "def test_simple \n R.each do |k, v|\n assert_equal(v, RomanNumerals.new(k).xp_converter)\n end\n end", "def test_can_convert_numbers\n\t\tassert_equal(11, arabic_converter(\"XI\"))\n\t\tassert_equal(14, arabic_converter(\"XIV\"))\n\t\tassert_equal(19, arabic_converter(\"XIX\"))\n\t\tassert_equal(16, arabic_converter(\"XVI\"))\n\t\tassert_equal(18, arabic_converter(\"XVIII\"))\n\tend", "def assert_value(actual,expected,message)\n puts message\n puts actual == expected\nend", "def test_convert_roman_one_to_arabic_one\n generic_fn_roman_numerals( 'I', '1' )\n end", "def test_to_num\n assert_equal(11, RomanMathmaticalOperation.new.send(:to_num,\"XI\"))\n assert_equal(0, RomanMathmaticalOperation.new.send(:to_num,\"wrong\"))\n assert_not_equal(11, RomanMathmaticalOperation.new.send(:to_num,\"X\"))\n end", "def test_covert_one_to_roman\n generic_fn_roman_numerals( '1', 'I' )\n end", "def test_message_sent_to_invalid_ID\nresult = add_characters_if_valid(\"\")\nassert_equal(\"Inavalid ID. Please enter new ID with only lower case letters.\", result)\nend", "def assert_equals(expected, actual, failure_message)\n if expected == actual\n \"Ok!\"\n else\n \"Expected '\" + expected.to_s + \"', but found '\" + actual.to_s + \"': \" + failure_message\n end\nend", "def assert actual, expected, message\n display message\n puts actual == expected || display_error(actual, expected)\nend", "def test_06\n -999.upto(999){ |i| assert_equal(\"~d\".format(i), \"~:d\".format(i)) }\n end", "def assertEqualTest expected, value\n assertEqual expected, value\n end", "def test_001_to_i()\n TestVals.each do |sVal|\n iVal = sVal.to_i(2)\n bs = BitString.new(sVal)\n assert_equal(iVal,\n bs.to_i,\n \"Test BitString.to_i(#{sVal}) => #{iVal}\")\n end\n end", "def test_19\n expected = [\"12345\", \"12345\", \"12345\", \"12345\", \"12345\", \" 12345\",\n \" 12345\", \" 12345\", \" 12345\", \" 12345\", \" 12345\"]\n 0.upto(10) do |i|\n assert_equal(expected[i], '~#d'.format(12345, *Array.new(i)))\n end\n end", "def assert_equal(actual, expected)\n if actual == expected\n puts \"pass\"\n else\n puts \"fail\"\n end\nend", "def assert_equal_enumerables(expected, actual, message)\n diff = expected - actual\n unless diff.empty?\n fail(\"#{message}. Expected to find #{diff.join(', ')} in #{actual.join(', ')}\")\n end\n \n diff = actual - expected\n unless diff.empty?\n fail(\"#{message}. Did not expect #{diff.join(', ')} in #{actual.join(', ')}\")\n end\n \n expected.each_with_index do |expected_member, index|\n actual_member = actual[index]\n assert_equal(expected_member, actual_member, \"Expected #{expected_member} at index #{index}, but was #{actual_member}\")\n end\n end", "def assert_equal(expected, actual)\n\tif expected == actual\n\t\tputs \":)\"\n\telse\n\t\tputs \"This should have been #{expected} not #{actual}\"\n\tend\nend", "def test(message, expected, actual)\n if expected == actual\n puts \"Pass - #{message}\"\n else\n puts \"Fail - #{message}\"\n end\nend", "def assertEqualWithMessageTest expected, value, message\n assertEqual expected, value, message\n end", "def assert_equal(actual, expected)\n\tif (actual == expected)\n\t\tputs \"pass\"\n\telse\n\t\tputs \"fail\"\n\tend\nend", "def test_palindrome_parameter_0\n err = assert_raises InvalidIntegerError do\n Palindrome.new(0)\n end\n assert_match 'The argument is not an integer greater than 1', err.message\n end", "def test_palindrome_parameter_string_number\n palindrome = Palindrome.new('2')\n assert_equal 9009, palindrome.digit_product\n end", "def test_number_15\n\t\t\t\t\n\t\t\tassert_equal(\"Mined Minds\",mineminds_array[14])\n\t\t\t\n\t\tend", "def roman_to_integer roman\r\n digit_vals = {'i' => 1,\r\n 'v' => 5,\r\n 'x' => 10,\r\n 'l' => 50,\r\n 'c' => 100,\r\n 'd' => 500,\r\n 'm' => 1000}\r\n total = 0\r\n prev = 0\r\n roman.reverse.each_char do |c_or_C|\r\n c = c_or_C.downcase\r\n val = digit_vals[c]\r\n if !val\r\n puts 'this is not a valid roman numeral!'\r\n return\r\n end\r\n if val < prev\r\n val *= -1\r\n else\r\n prev = val\r\n end\r\n\r\n total += val\r\n end\r\n\r\n total\r\nend", "def test_less_than_3_equal_chars\n\t\tassert_equal(false,compare('1234','1325'))\n\tend", "def verifyEqual(exp_val,act_val)\n assert_equal(exp_val, act_val,\"Wrong value Expected #{exp_val} Actual #{act_val}\")\n end", "def assert_equal(type,expected, actual)\n text1=get_text(type,expected)\n text2=$array1[\"#{actual}\"] \n puts text1\n puts text2\n if text1 == text2\n puts \"given text is available\"\n elsif \n $log.error \"given #{expected} text is not displayed\"\n raise(\"given #{expected} text is not displayed\")\n end\nend", "def assert_equal expected, got\n puts expected == got ?\n \"passed: #{expected}\" :\n \"Assertion failed\\nExpected: #{expected}\\nGot: #{got}\"\nend", "def test(msg, expected, actual)\n if expected == actual\n puts \"pass!! #{msg}\"\n else\n puts \"fail!! #{msg}\"\n end\nend", "def roman_numeral num\n \n if num >= 1000\n thousands = 'M' * (num / 1000)\n end\n\n # We now account for cases of 400 and 900 (CD, CM, respectively)\n # CCC=300, CD=400, D=500, DCCC=800, CM=900\n if num >= 100\n temp_hundreds = (num % 1000) / 100\n if temp_hundreds == 9\n hundreds = 'CM'\n elsif (temp_hundreds < 9 && temp_hundreds > 5)\n hundreds = 'D' + 'C' * (temp_hundreds - 5)\n elsif temp_hundreds == 5\n hundreds = 'D'\n elsif temp_hundreds == 4\n hundreds = 'CD'\n else\n hundreds = 'C' * temp_hundreds\n end\n end\n \n # We now account for cases of 40 and 90 (XL, XC, respectively)\n # XXX=30, XL=40, L=50, LXXX=80, XC=90\n if num >= 10\n temp_tens = (num % 100) / 10\n if temp_tens == 9\n tens = 'XC'\n elsif (temp_tens < 9 && temp_tens > 5)\n tens = 'L' + 'X' * (temp_tens - 5)\n elsif temp_tens == 5\n tens = 'L'\n elsif temp_tens == 4\n tens = 'XL'\n else\n tens = 'X' * temp_tens\n end\n end\n \n # We now account for cases of 4 and 9 (IV, IX, respectively)\n # III=3, IV=4, V=5, XIII=8, IX=9\n if num > 0\n temp_ones = num % 10\n if temp_ones == 9\n ones = 'IX'\n elsif (temp_ones < 9 && temp_ones > 5)\n ones = 'V' + 'I' * (temp_ones - 5)\n elsif temp_ones == 5\n ones = 'V'\n elsif temp_ones == 4\n ones = 'IV'\n else\n ones = 'I' * temp_ones\n end\n end\n \n puts \"#{num} in \\\"Modern\\\" Roman numerals is \"+\"#{thousands}\"+\"#{hundreds}\"+\"#{tens}\"+\"#{ones}\"\nend", "def test_print\n var = 30\n assert_kind_of Integer, var\n assert_output(var)\n end", "def assert(statement,val)\n ret = eval(statement)\n print \"Checking '#{statement.ljust(35)}': \"\n print \"Expecting #{val}, got #{ret}. \".ljust(29)\n if ret == val\n puts \"(PASS)\" \n else\n puts \"(FAIL)\" \n end\nend", "def roman_to_integer(roman)\n values = {i: 1, v: 5, x: 10, l: 50, c: 100, d: 500, m: 1000}\n total = 0\n prev = 0\n index = roman.length - 1\n while index >= 0\n c = roman[index].downcase\n c = c.to_sym\n index = index - 1\n value = values[c]\n if !value\n return \"Not a valid roman numeral\"\n end\n if value < prev\n value = value * -1\n else\n prev = value\n end\n total = total + value\n end\n total\nend", "def test_romana?\n assert_equal(true, 'MCCXXXIV'.romana?)\n assert_equal(false, 'lixo'.romana?)\n end", "def new_roman_numeral num\n number = \"\"\n if (num / 1000) > 0\n number = \"M\" * (num / 1000)\n end\n if (num % 1000) >= 900 \n number += \"CM\"\n end\n if (num % 1000) >= 500 && (num % 1000) < 900\n number += \"D\"\n end\n if (num % 1000) >= 400 && (num % 1000) < 500\n number += \"CD\"\n end\n if ((num % 1000) % 500) >= 100 && ((num % 1000) % 500) < 400\n number += \"C\" * (((num % 1000) % 500) / 100)\n end\n if (((num % 1000) % 500) % 100) >= 90\n number += \"XC\"\n end\n if (((num % 1000) % 500) % 100) >= 50 && (((num % 1000) % 500) % 100) < 90\n number += \"L\"\n end\n if (((num % 1000) % 500) % 100) >= 40 && (((num % 1000) % 500) % 100) < 50\n number += \"XL\"\n end\n if (((num % 1000) % 500) % 50) >= 10 && (((num % 1000) % 500) % 50) < 40\n number += \"X\" * ((((num % 1000) % 500) % 50) / 10)\n end\n if ((((num % 1000) % 500) % 50) % 10) == 9\n number += \"IX\"\n end\n if ((((num % 1000) % 500) % 50) % 10) >= 5 && ((((num % 1000) % 500) % 50) % 10) < 9\n number += \"V\" + \"I\" * (((((num % 1000) % 500) % 50) % 10) % 5)\n end\n if ((((num % 1000) % 500) % 50) % 10) == 4\n number += \"IV\"\n end\n if ((((num % 1000) % 500) % 50) % 10) < 4\n number += \"I\" * (((((num % 1000) % 500) % 50) % 10) % 5)\n end\n puts number\nend", "def assert_equal( expected, obtained, msg = nil )\n unless expected == obtained\n fail \"*** assert_equal( #{expected.inspect}, #{obtained.inspect}, #{msg} )\"\n end\nend", "def assert_equal(actual, expected)\n\tif actual == expected\n\t\tputs \"pass\"\n\telse\n\t\tputs \"fail\"\nend\n \nassert_equal(1,1) #=> pass\nassert_equal(2,1) #=> fail\n \n# Use assert to test the following:\n \n# define a method to sum the values of an array. Make this method defend against nils and\n# other errors\n \ndef sum(numbers)\n\tresult = 0\n\tnumbers.collect do |i|\n\tresult += i if i.is_a? Integer\n\tend\n\tresult\nend\n \nassert_equal sum([]), 0\nassert_equal sum([1,2]), 3\nassert_equal sum([1,nil,2]), 3\nassert_equal sum([1, \"2\", 2]), 3\n \n# define a method that returns comfortable for temps between 60-80, cold for below and hot\n# for above.\n \ndef temperature_bot(temp)\n\tif temp >=60 && temp <=80\n\t\tputs \"comfortable\"\n\telsif temp < 60\n\t\tputs \"cold\"\n\telse\n\t\tputs \"hot\"\n\tend\nend\n \nassert_equal temperature_bot(65), \"comfortable\"\nassert_equal temperature_bot(70), \"comfortable\"\nassert_equal temperature_bot(85), \"hot\"\nassert_equal temperature_bot(30), \"cold\"\n \n# define an object, Person, that has a birthdate and a name. Define a method for a person\n# that returns their age.\n\nclass Person\n\tattr_accessor :birthday, :name\n\n\tdef age\n\t\tbirth_year = @birthday.split(\"/\").last.to_i\n\t\tTime.now.year - birth_year\n\tend\nend\n\n\nbegin\n person = Person.new\n person.name = \"Alan Turing\"\n person.birthday = \"06/23/1912\"\n \n assert_equal person.name, \"Alan Turing\"\n assert_equal person.birthday, \"06/23/1912\"\n assert_equal person.age, 101\n \nrescue => e\n puts \"Fail: #{e}\"\nend", "def roman_to_integer roman \n digit_vals = {'i' => 1,\n 'v' => 5,\n 'x' => 10,\n 'l' => 50,\n 'c' => 100,\n 'd' => 500,\n 'm' => 1000}\n total = 0 \n prev = 0 \n index = roman.length - 1 \n while index >= 0 \n c = roman[index].downcase \n index = index - 1 \n val = digit_vals[c]\n if !val \n puts \"This is not a valud roman numeral\"\n return \n end \n if val < prev\n val = val * -1\n else \n prev = val \n end \n total = total + val \n end \n total \nend", "def test_plural_int\n assert_equal @p.plural?(1), 'ruby'\n end", "def roman_numbers num\n case num\n when 'CM'\n return 900\n when 'CD'\n return 400\n when 'XC'\n return 90\n when 'XL'\n return 40\n when 'IX'\n return 9\n when 'IV'\n return 4\n else\n return false\n end\nend", "def assert_equal expected, got\n puts expected == got ?\n \"passed: #{expected.inspect}\" :\n \"Assertion failed\\nExpected: #{expected.inspect}\\nGot: #{got}\"\nend", "def roman_to_integer passcode\n\n\tdigit_vals = { 'i' => 1,\n\t\t\t\t 'v' => 5,\n\t\t\t\t 'x' => 10,\n\t\t\t\t 'l' => 50,\n\t\t\t\t 'c' => 100,\n\t\t\t\t 'd' => 500,\n\t\t\t\t 'm' => 1000}\n\n\ttotal = 0\n\tprev = 0\n\tindex = passcode.length-1\n\t\n\twhile index >=0\n\t\tc = passcode[index].downcase\n\t\tindex = index - 1\n\t\tval = digit_vals[c]\n\t\tif !val\n\t\t\tputs 'This is not a valid roman numeral!'\t\n\t\t\treturn\n\t\tend\n\n\t\tif val < prev\n\t\t\tval = val * -1\n\t\telse\n\t\t\tprev = val\n\t\tend\n\t\ttotal = total + val\n\tend\n\ttotal\n\nend", "def test_16\n MiniUniverse.each do |e|\n assert_equal(\"~d\".format(e), \"~A\".format(e)) unless e.respond_to? :to_int\n end\n end", "def assert_equal expected, got\n puts expected == got ?\n \"passed: #{expected.inspect}\" :\n \"Assertion failed\\nExpected: #{expected.inspect}\\nGot: #{got.inspect}\"\nend", "def assert_equal expected, got\n puts expected == got ?\n \"passed: #{expected.inspect}\" :\n \"Assertion failed\\nExpected: #{expected.inspect}\\nGot: #{got.inspect}\"\nend", "def roman_to_integer(roman_value)\n digital_vals = {'i'=> 1, 'v'=> 5, 'x'=> 10, 'l'=> 50, \n 'c'=> 100, 'd'=> 500, 'm'=> 1000,}\n\n roman_value.each_char do |char|\n if digital_vals.has_key?(char) == false\n return \"Invalid Entry!\"\n end \n end\n\n \n\n reversed_roman_value = roman_value.reverse\n total_value = 0\n prev_val = 0\n prev_char = ''\n reversed_roman_value.each_char do |char|\n val = digital_vals[char]\n\n val < prev_val ? val *= -1 : prev_val = val\n total_value += val\n\n\n\n=begin \nNote: The commented method below isn't concise and simple as the current implementation\nabove.\nInstead of comparing the alphabets, it's simpler to compare the values\n case \n when ((char == 'i') && (prev_char == 'x')) then total_value -= 1\n when ((char == 'i') && (prev_char == 'v')) then total_value -= 1\n when ((char == 'x') && (prev_char == 'l')) then total_value -= 10\n when ((char == 'x') && (prev_char == 'c')) then total_value -= 10\n when ((char == 'c') && (prev_char == 'd')) then total_value -= 100\n when ((char == 'c') && (prev_char == 'm')) then total_value -= 100\n else \n total_value += digital_vals[char]\n end\n prev_char = char\n\n=end \n\n end\n\n \n\n \n total_value\nend", "def assertEqualWithMessageFailTest expected, value, message\n rescue_assertion ASSERT_EQUAL_ERROR, message do\n assertEqual expected, value, message\n end\n end", "def test_exercise_119\n verify_method :exercise_119,\n :with => [{param: 1, expect: '1'},\n {param: 2, expect: '10'},\n {param: 3, expect: '11'},\n {param: 8, expect: '1000'},\n {param: 11, expect: '1011'}]\n end", "def test_valid_10_digit_isbn767\n assert_equal(true, valid_isbn?(\"0-321 14 6530\")) \n end", "def test_int_check_fail\n assert_equal int_check(['k', 'k', 'k']), false # pass\n assert_equal int_check(['a', 's', 'd', 'f']), false # pass\n end", "def test_prompt\n actual_input = prompt (\"please input the number 4 for testing \\n\")\n expected_input = \"4\"\n assert_equal expected_input, actual_input\n end", "def assertWithMessageTest value, message\n assert value, message\n end", "def test_fizzbuzz__4_returns_4_as_string\n #Arrange\n number = 4\n #Act\n result = fizzbuzz(number)\n #Assert\n assert_equal(\"4\", result)\n end", "def assertEqualFailTest expected, value\n rescue_assertion ASSERT_EQUAL_ERROR do\n assertEqual expected, value\n end\n end", "def old_roman_string num\n raise \"Use positive integer\" if num <= 0\n roman_str = ''\nroman_str << 'M' * (num /1000)\nroman_str << 'D' * (num % 1000 / 500)\nroman_str << 'C' * (num % 500 / 100)\nroman_str << 'L' * (num % 100 / 50)\nroman_str << 'X' * (num % 50 / 10)\nroman_str << 'V' * (num % 10 / 5)\nroman_str << 'I' * (num % 5 / 1)\n\n#build up the strings by * H,T,U\nend", "def assert(expected, actual, message)\n if (expected != actual)\n puts \"Error: \" + message\n puts \"*\"*50\n else\n puts message + \" true\"\n puts \"*\"*50\n end\nend", "def test_equality(expected, actual)\n \tif expected == actual\n \t\tputs \"pass :):):)\"\n \telse\n \t\tputs \"fail :(:(:(\"\n\tend\nend", "def test_values\n assert_equal(9, @symbols.select{ |key, value| value < 10}.length, \"Low Value Cards\")\n assert_equal(4, @symbols.select{ |key, value| value == 10}.length, \"Face Cards\")\n assert_equal(1, @symbols.select{|key, value| value == 1}.length, \"Ace as 11\")\n end", "def test_rec_number_positive\n @numbers.each do |value, expected|\n assert_equal expected, @TS_Rec.format(value)\n end\n end", "def test_a_pavlicek_number(i)\n board = HandRecordUtility.pavlicek_number_to_board(i)\n \n if (board.nil?) then\n puts \"Could not create a board for number #{i}.\"\n return\n end\n\n j = HandRecordUtility.to_pavlicek_number(board)\n if (i == j)\n puts \"Testing with Pavlicek number #{i} passed.\"\n else\n puts \"Testing with Pavlicek number #{i} failed.\"\n end\nend", "def test_generate_message_not_a_number_with_default_message\n assert_equal \"is not a number\", @person.errors.generate_message(:title, :not_a_number, value: \"title\")\n end", "def new_roman_numeral number\n digits = []\n i = 4\n while i>0\n digits.push (number%10)\n number = (number/10).to_i\n i -= 1\n end\n thousandth = 'M'*digits[3]\n hundredth = 'D'*(digits[2]/5).to_i+'C'*(digits[2]%5)\n tenth = 'L'*(digits[1]/5).to_i+'X'*(digits[1]%5)\n unit = 'V'*(digits[0]/5).to_i+'I'*(digits[0]%5)\n hundredth = 'CD' if hundredth == 'C'*4\n hundredth = 'CM' if hundredth == 'D'+'C'*4\n tenth = 'XL' if tenth == 'X'*4\n tenth = 'XC' if tenth == 'L'+'X'*4\n unit = 'IV' if unit == 'I'*4\n unit = 'IX' if unit == 'V'+'I'*4\n puts thousandth+hundredth+tenth+unit\nend", "def to_roman(integer)\n integer = integer.to_i\n if integer < 1 or integer > 3999\n raise RangeError, \"Integer must be between 1 and 3999\"\n end\n\n roman = \"\"\n integer, roman = prepare_group(integer, roman, 1000, \"M\", 900, \"CM\")\n integer, roman = prepare_group(integer, roman, 500, \"D\", 400, \"CD\")\n integer, roman = prepare_group(integer, roman, 100, \"C\", 90, \"XC\")\n integer, roman = prepare_group(integer, roman, 50, \"L\", 40, \"XL\")\n integer, roman = prepare_group(integer, roman, 10, \"X\", 9, \"IX\")\n integer, roman = prepare_group(integer, roman, 5, \"V\", 4, \"IV\")\n integer, roman = prepare_group(integer, roman, 1, \"I\", nil, nil)\n\n roman\nend", "def roman_numeral num\n\n number1000s = (num / 1000)\n number100s = (num % 1000) / 100\n number10s = (num % 100) / 10\n number1s = (num % 10) / 1\n\n numberDs = (num % 1000) / 500\n numberCs = (num % 500) / 100\n numberLs = (num % 100) / 50\n numberXs = (num % 50) / 10\n numberVs = (num % 10) / 5\n numberIs = (num % 5) / 1\n\n result = \"M\" * number1000s\n\n if number100s == 9\n result = result + \"CM\"\n elsif number100s == 4\n result = result + \"CD\"\n else\n result = result + \"D\" * numberDs\n result = result + \"C\" * numberCs\n end\n\n if number10s == 9\n result = result + \"XC\"\n elsif number10s == 4\n result = result + \"XL\"\n else\n result = result + \"L\" * numberLs\n result = result + \"X\" * numberXs\n end\n\n if number1s == 9\n result = result + \"IX\"\n elsif number1s == 4\n result = result + \"IV\"\n else\n result = result + \"V\" * numberVs\n result = result + \"I\" * numberIs\n end\n\n result\n\nend", "def assertTest value\n assert value\n end", "def test_code = assert_equal('MX', @territory.code)", "def old_roman_numeral num\n\t\n\tif num >= 1000\n\t\tthousands = 'M' * (num / 1000)\n\tend\n\n\tif num >= 100\n\t\ttemp_hundreds = (num % 1000) / 100\n\t\tif temp_hundreds > 5\n\t\t\thundreds = 'D' + 'C' * (temp_hundreds - 5)\n\t\telsif temp_hundreds == 5\n\t\t\thundreds = 'D'\n\t\telse\n\t\t\thundreds = 'C' * temp_hundreds\n\t\tend\n\tend\n\t\n\tif num >= 10\n\t\ttemp_tens = (num % 100) / 10\n\t\tif temp_tens > 5\n\t\t\ttens = 'L' + 'X' * (temp_tens - 5)\n\t\telsif temp_tens == 5\n\t\t\ttens = 'L'\n\t\telse\n\t\t\ttens = 'X' * temp_tens\n\t\tend\n\tend\n\t\n\tif num > 0\n\t\ttemp_ones = num % 10\n\t\tif temp_ones > 5\n\t\t\tones = 'V' + 'I' * (temp_ones - 5)\n\t\telsif temp_ones == 5\n\t\t\tones = 'V'\n\t\telse\n\t\t\tones = 'I' * temp_ones\n\t\tend\n\tend\n\t\n\tputs \"#{num} in Roman numerals is \"+\"#{thousands}\"+\"#{hundreds}\"+\"#{tens}\"+\"#{ones}\"\nend", "def test_numeric_and_string_comparison\n value1_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)\n value2_ = ::Versionomy.create([1, 9, 2, 1], :rubygems)\n assert(value2_ > value1_)\n end", "def test_number_3\n\t\t\tassert_equal(\"Mined\", mineminds_array[2])\n\t\tend", "def roman_numerals(number)\n\n puts (\"M\" * (number/1000)).to_s\n if ((number%1000)%500) == 0\n puts (\"D\" * (number%1000/500)).to_s\n if ((number%500)%100) == 0\n puts (\"C\" * (number%500/100)).to_s\n if ((number%100)%50) == 0\n puts (\"L\" * (number%100/50)).to_s\n if ((number%50)%10) == 0\n puts (\"X\" * (number%50/10)).to_s\n if ((number%10)%5) == 0\n puts (\"V\" * (number%10/5)).to_s\n if ((number%5)%1)) == 0\n puts (\"I\" * (number%5/1)).to_s\n end\n end\n end\n end\n end\n end\n\n\nend", "def assert_equal_cases(expected_db_val, enum_map, *different_keys)\n different_keys.each do |this_case|\n assert_equal expected_db_val, enum_map[this_case], \"param string: '#{this_case}' did not associate as expected\"\n end\n end", "def roman\n return \"-#{(-self).roman}\" if self < 0\n return \"\" if self == 0\n @@roman_values_assoc.each do | (i, v) | return(i+(self-v).roman) if v <= self end\n end", "def report expected, actual\n if expected == actual\n puts \"Yes, found '#{actual}'\"\n else\n puts \"Failed, found '#{actual}' but was expecting '#{expected}'\"\n end\nend", "def roman_numeral(num)\n thousands = (num / 1000)\n hundreds = (num % 1000 / 100)\n tens = (num % 100 / 10)\n ones = (num % 10)\n\n roman = 'M' * thousands\n\n if hundreds == 9\n roman = roman + 'CM'\n elsif hundreds == 4\n roman = roman + 'CD'\n else\n roman = roman + 'D' * (num % 1000 / 500)\n roman = roman + 'C' * (num % 500 / 100)\n end\n\n if tens == 9\n roman = roman + 'XC'\n elsif tens == 4\n roman = romann + 'XL'\n else\n roman = roman + 'L' * (num % 100 / 50)\n roman = roman + 'X' * (num % 50 / 10)\n end\n\n if ones == 9\n roman = roman + 'IX'\n elsif ones == 4\n roman = roman + 'IV'\n else\n roman = roman + 'V' * (num % 10 / 5)\n roman = roman + 'I' * (num % 5 / 1)\n end\n roman\nend", "def test_code_1\n string = \"Line 321: Variable x is not initialized\\n\"\n assert_output(string) { Errorcode.error(1, 321, 'x') }\n end", "def old_roman_numeral(num)\n return \"Please use a positive integer.\" if num <= 0\n \n roman = \"\"\n \n roman << \"M\" * (num / 1000)\n roman << \"D\" * (num % 1000 / 500)\n roman << \"C\" * (num % 500 / 100)\n roman << \"L\" * (num % 100 / 50)\n roman << \"X\" * (num % 50 / 10)\n roman << \"V\" * (num % 10 / 5)\n roman << \"I\" * (num % 5 / 1)\n \n roman\nend", "def assert_equal(expected, actual, message=nil)\n assert expected == actual, message || \"#{expected.inspect} expected but was #{actual.inspect}\"\n end", "def roman_numeral num\n roman_to_arabic = {\n M: 1_000, CM: 900, D: 500, CD: 400,\n C: 100, XC: 90, L: 50, XL: 40,\n X: 10, IX: 9, V: 5, IV: 4,\n I: 1\n }\n\n return '' if num <= 0\n roman_to_arabic.each { |key, val| return key.to_s + roman_numeral(num - val) if num >= val }\nend", "def assert_equal(*args, &block)\n adapter = AssertionAdapter::Minitest.new\n adapter.assert_equal(*args, &block) # FIXME: this sucks: Minitest catches the Assertion exception here, instead of properly passing it up the chain.\n\n pp adapter\n # instead, there should be an API in Minitest so we can pass it results (failures and passes?) and it \"does the rest\" .\n @assertions ||=[]\n @assertions << @description\n end", "def test_06\n -7.upto(7){ |i| assert_equal(\"~b\".format(i), \"~:b\".format(i)) }\n end", "def test_display_invalid_ruby\r\n assert_raises('rubyist_num must be an integer!') { @g.display_rubies(1, 1, 'a', 2) }\r\n end", "def test_number_49\n\t\t\tassert_equal(49, mineminds_array[48])\n\t\tend", "def test_equal\r\n a, b = 1, 1\r\n assert_equal a, b\r\n end", "def to_roman(num)\n \n output = ''\n\n if num\n how_many_thousand = (num - num % 1000) / 1000\n num = num - (num - num % 1000)\n\n how_many_hundred = (num - num % 100) / 100\n num = num - (num - num % 100)\n\n how_many_tens = (num - num % 10) / 10\n num = num - (num - num % 10)\n\n how_many_ones = num - (num - num % 10)\n else\n \treturn nil\n end\n\n #adding thousands\n output << 'M' * how_many_thousand\n #adding hundreds\n if how_many_hundred == 9\n \t output << 'CM'\n \telsif how_many_hundred >= 5\n \t output << 'D' + 'C' * (how_many_hundred - 5)\n elsif how_many_hundred == 4\n output << 'CD'\n else\n output << \"C\" * how_many_hundred\n end\n #adding tens\n if how_many_tens == 9\n \t output << 'XC'\n \telsif how_many_tens >= 5 \n \t output << 'L' + 'X' * (how_many_tens - 5)\n elsif how_many_tens == 4\n output << 'XL'\n else\n output << \"X\" * how_many_tens\n end\n #adding ones\n if how_many_ones == 9\n \t output << 'IX'\n \telsif how_many_ones >= 5 \n \t output << 'V' + 'I' * (how_many_ones - 5)\n elsif how_many_ones == 4\n output << 'IV'\n else\n output << \"I\" * how_many_ones\n end\n\n output\n\nend", "def test_plural_int2\n assert_equal @p.plural?(2), 'rubies'\n end", "def assert_equal(expected, actual)\n unless expected == actual\n puts \"Assertion failed!\"\n puts \"Expected: #{expected.inspect}\"\n puts \"Actual: #{actual.inspect}\"\n end\nend", "def assert_equal(expected, actual)\n unless expected == actual\n puts \"Assertion failed!\"\n puts \"Expected: #{expected.inspect}\"\n puts \"Actual: #{actual.inspect}\"\n end\nend", "def assert_equal(expected, actual)\n unless expected == actual\n puts \"Assertion failed!\"\n puts \"Expected: #{expected.inspect}\"\n puts \"Actual: #{actual.inspect}\"\n end\nend", "def assert_equal(expected, actual)\n unless expected == actual\n puts \"Assertion failed!\"\n puts \"Expected: #{expected.inspect}\"\n puts \"Actual: #{actual.inspect}\"\n end\nend", "def assert_equal(expected, actual)\n unless expected == actual\n puts \"Assertion failed!\"\n puts \"Expected: #{expected.inspect}\"\n puts \"Actual: #{actual.inspect}\"\n end\nend", "def test_new_code_1\n string = Errorcode.new_error 1, 'R'\n assert_equal \"Variable R is not initialized\", string\n end", "def old_roman_numeral number\n\n if number >= 1000\n thousands = 'M' * (number / 1000)\n end\n\n if number >= 100\n hundreds = (number % 1000) / 100\n if hundreds >= 5\n hundreds = 'D' + 'C' * (hundreds - 5)\n else\n hundreds = 'C' * ((number % 1000) / 100)\n end\n end\n\n if number >= 10\n tens = (number % 100) / 10\n if tens >= 5\n tens = 'L' + 'X' * (tens - 5)\n else\n tens = 'X' * ((number % 100) / 10)\n end\n end\n\n if number >= 1\n ones = (number % 10) / 1\n if ones >= 5\n ones = 'V' + 'I' * (ones - 5)\n else\n ones = 'I' * ((number % 10) / 1)\n end\n end\n\n puts \"#{number} in old-school Roman numerals is \"+\"#{thousands}\"+\"#{hundreds}\"+\"#{tens}\"+\"#{ones}\"\nend", "def assert(actual, expected)\n\traise \"actual: #{actual}, expected: #{expected}\" unless expected == actual\nend", "def test_first_example\n assert_equal(0, purple([\"+1\", \"-1\"]))\n end", "def roman_numeral num\n thous = (num / 1000)\n hunds = (num % 1000 / 100)\n tens = (num % 100 / 10)\n ones = (num % 10 )\n\n roman = \"M\" * thous\n if hunds == 9\n roman = roman + \"CM\" \n elsif hunds == 4\n roman = roman + \"CD\"\n else\n roman = roman + \"D\" * (num % 1000 / 500)\n roman = roman + \"C\" * (num % 500 / 100)\n end\n\n if tens == 9 \n roman = roman + \"XC\"\n elsif tens == 4\n roman = roman + \"XL\"\n else\n roman = roman + \"L\" * (num % 100 / 50) \n roman = roman + \"X\" * (num % 50 / 10)\n end\n\n if ones == 9 \n roman = roman + \"IX\"\n elsif ones == 4\n roman = roman + \"IV\"\n else\n roman = roman + \"V\" * (num % 10/ 5)\n roman = roman + \"I\" * (num % 5 / 1)\n end\n roman\n end", "def to_i\n value = 0\n @roman.split(//).each.with_index do |char, i|\n char_val = INT_VAL[char]\n next_char = (i + 1 < @roman.length) ? @roman[i + 1] : false\n if next_char && INT_VAL[next_char] > char_val\n value -= char_val\n else\n value += char_val\n end\n end\n value\n end" ]
[ "0.7028638", "0.6797572", "0.6614056", "0.6476273", "0.6420921", "0.63896435", "0.6305983", "0.623505", "0.62034744", "0.6154641", "0.612793", "0.612069", "0.61133176", "0.60989296", "0.6058061", "0.6017317", "0.6004574", "0.59982455", "0.5955311", "0.5943512", "0.59403926", "0.59072524", "0.59052354", "0.58693147", "0.585997", "0.5854777", "0.5852408", "0.5841185", "0.5812766", "0.5808104", "0.5781354", "0.5777134", "0.57684326", "0.57578194", "0.5757563", "0.5743614", "0.57370836", "0.57316756", "0.57168186", "0.57123435", "0.5708748", "0.5691419", "0.5685002", "0.56848365", "0.56845105", "0.56828994", "0.5675383", "0.5665543", "0.5665543", "0.56630456", "0.5655821", "0.5648543", "0.56460434", "0.5645911", "0.5635054", "0.5629928", "0.5626302", "0.5624692", "0.5619429", "0.5612452", "0.5603923", "0.5603222", "0.5602726", "0.55965453", "0.55912524", "0.5587221", "0.55868274", "0.55787885", "0.5576007", "0.5566968", "0.55659145", "0.5563307", "0.55543554", "0.5553764", "0.5553466", "0.55408865", "0.55389106", "0.55353296", "0.5534695", "0.5533206", "0.5530619", "0.55298173", "0.552832", "0.55245686", "0.5523367", "0.5520184", "0.5519159", "0.55186296", "0.5501304", "0.550125", "0.550125", "0.550125", "0.550125", "0.550125", "0.5500613", "0.55001646", "0.54972965", "0.5491102", "0.5485629", "0.5482003" ]
0.6210751
8
Copy a ActiveModel::Model errors
def copy_errors(model) model.errors.each do |key, value| self.errors[key] = value end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy_errors(source)\n source.errors.each do |key, error|\n self.errors.add(key, error)\n end\n end", "def errors\n @errors ||= ActiveModel::Errors.new(self)\n end", "def result_errors_to_active_model(key, result)\n unless result.success?\n if result.errors.is_a? Array\n result.errors.each do |error|\n errors.add key, error\n end\n else\n result.errors.each do |hash_key, error_hash|\n error_hash.each do |attr, message|\n errors.add key, message[0]\n end\n end\n end\n end\n end", "def errors\n @errors.clone\n end", "def errors\n @errors.dup\n end", "def form_errors_from_model(obj)\n if obj.respond_to?(:errors)\n obj.errors.each do |key, value|\n if value.respond_to?(:first)\n value = value.first\n end\n \n form_error(key.to_s, value % key)\n end\n end\n end", "def to_a\n errors.dup\n end", "def errors\n @errors.dup\n end", "def errors_to_builder(model)\n {\n errors: {\n message: model.errors.full_messages.to_sentence,\n fields: model.errors\n }\n }\n end", "def errors_to_json(model)\n\t\treturn ModelError.new({\n\t\t\t:model => model,\n\t\t\t:error => model.errors.collect{ |attr,msg| attr.humanize+' - '+msg }.join('\\n'),\n\t\t})\n\tend", "def warnings\n @warnings ||= ActiveModel::Errors.new(self)\n end", "def error_message_from_model(model, attribute, message, extra = {})\n ::ActiveModel::Errors.new(model).generate_message(attribute, message, extra)\n end", "def render_error_model(model)\n render_error_messages(model.errors.full_messages)\n end", "def collect_errors\n self.errors.full_messages.join(\"\\n\")\n end", "def errors\n @errors ||= ActiveRecord::Errors.new(self)\n end", "def errors\n @errors ||= ActiveRecord::Errors.new(self)\n end", "def derive_errors_from_error(error)\n @errors = self.errors.merge(error.details)\n end", "def copy_errors(source, target, name, key, value, **opts)\n nested = opts[:nested_keys]\n original = opts[:original_keys]\n\n if !nested && !original\n target.errors.add(name, key, record: target, value: value)\n else\n source.errors.messages.each do |k, texts|\n target_key = nested ? nested_key(name, k) : k\n texts.each { |text| target.errors.add(target_key, text) }\n end\n end\n end", "def build_model_errors(model, errors)\n return if errors.blank?\n\n model.errors.clear\n errors.each do |err_attr|\n next if err_attr.blank?\n\n # Note lowercase the first letter as some section names have upper case first which does not\n # work with the current message\n err_attr[0] = err_attr[0].downcase\n model.errors.add(:base, :section_not_complete, attr: err_attr)\n end\n end", "def errors_for(_object); end", "def errors\n self.__source.errors.messages.to_hash.stringify_keys\n end", "def errors=(_); end", "def errors_on_object(record)\n record.errors.full_messages\n end", "def clear_errors!\n update_attributes last_error: nil\n end", "def errors\n @errors ||= Errors.new(self)\n end", "def format_dv_errors(model)\n errors = []\n model.errors.each_pair do |key, value|\n errors.push({ key => value })\n end\n return errors\n end", "def flash_errors_model(model)\n flash[:error] = model.errors.full_messages.join(', ')\n end", "def remove_duplicate_errors\n self.errors.flatten!\n self.errors.uniq!\n end", "def original_error; end", "def original_error; end", "def initialize\n @errors = ActiveRecord::Errors.new(self)\n def @errors.[](key) # Return errors in same format as Rails 3.\n Array(on(key))\n end\n end", "def list_errors\n error_messages = []\n @models.each do |m|\n if !m[:model].valid?\n m[:model].errors.each do |e|\n error_messages << \"#{e.to_s.titlecase} #{m[:model].errors[e][0]} - #{m[:meta][:sheet]}, row #{m[:meta][:row] or 'N/A'}\"\n end\n end\n end\n error_messages\n end", "def errors\n @errors ||= Errors.new(self)\n end", "def errors\n @errors ||= Errors.new(self)\n end", "def load_errors(obj)\n obj.errors.full_messages.each { |m|\n @msg.add(:error, m);\n }\n end", "def errors\n @errors ||= ActiveModel::Errors.new(self)\n if respond_to?(:main_instance) && main_instance && main_instance.errors.any?\n main_instance.errors\n else\n @errors\n end\n end", "def error_messages\n self.errors.full_messages\n end", "def write_errors(obj, scope: false)\n obj.errors.map { |e| \"#{t_field(e.attribute, scope || obj.class.table_name.singularize)} #{e.message}\" }.join(', ')\n end", "def errors\n object.errors.messages.flat_map do |field, messages|\n messages.map.with_index do |message, index|\n build_error(field, message, index)\n end\n end\n end", "def model_errors(model)\n result = \"\"\n if model.errors.any?\n result = \"<div class='alert alert-danger'>#{model.errors.full_messages.join('<br>')}</div>\".html_safe\n end\n result\n end", "def loose_errors\n err = []\n err << title\n err << authors\n err << s3_error_uploads\n err << url_error_validating\n\n err.flatten\n end", "def save_model_error object\n error_str = I18n.t 'term.error'\n error_str += ' : '\n # Grab the error message from the student\n object.errors.each do |attr,msg|\n error_str += \"#{attr} - #{msg},\"\n end\n render :json => { error: error_str }, :status => :unprocessable_entity\n end", "def errors\n @updater.errors.messages.values.flatten + @errors\n end", "def promote_errors(child_object)\r\n child_object.errors.map{ |error, msg| self.errors.add(error, msg) }\r\n end", "def errors\n run_validation\n @errors\n end", "def reset_errors!\n @errors = []\n end", "def reset_errors!\n @errors = []\n end", "def reset_errors!\n @errors = []\n self\n end", "def errors\n @_errors ||= {}\n @_errors\n end", "def errors\n @model_decorator.form_active_errors(@resource)\n end", "def errors(*args)\n Result::Errors.new(@result, self)\n end", "def errors_as_sentence(obj)\n obj.errors.full_messages.to_sentence\n end", "def errors_as_sentence(obj)\n obj.errors.full_messages.to_sentence\n end", "def errors\n\t\treturn @errors ||= Treequel::Model::Errors.new\n\tend", "def errors\n @errors\n end", "def errors\n @errors\n end", "def errors\n @errors\n end", "def error_list_for(object)\n return errors_to_list(object.errors.full_messages)\n end", "def errors_h\n\t\t{errors: self.errors.messages}\n\tend", "def errors\n @errors ||= EntityTypePropertyErrors.new(self)\n end", "def errors\n @attributes[:errors]\n end", "def errors\n return super unless ldp_object.present?\n ldp_object.errors\n end", "def assign_errors_from_response( response )\n response.errors.each do |key, value|\n value.each do |message|\n errors[key.to_sym] = message \n end\n end \n end", "def initialize(errors)\n @errors_object = errors\n super(errors_object)\n end", "def clean_error\n @error = nil\n @error_description = nil\n @error_attribute = nil\n end", "def errors\n @errors ||= {}\n end", "def original_exceptions\n errors.flat_map { |e, _| e.exception.original_exceptions }.to_set.to_a\n end", "def move_errors_to_warnings\n self.class.warnr_warning_fields.each do |field|\n if errors[field]\n errors[field].each { |error| warnings.add(field, error) }\n errors.delete(field)\n end\n end\n end", "def errors\n @errors ||= []\n end", "def errors_for(o);\n mab do\n ul.errors { o.errors.each_full { |er| li er } }\n end if o.errors.any?\n end", "def errors\n @errors.values.flatten\n end", "def apply_errors\n apply_errors_get(data)\n end", "def errors\n bindings[:object].errors[name]\n end", "def errors\n bindings[:object].errors[name]\n end", "def errors\n bindings[:object].errors[name]\n end", "def error_messages_as_json\n { errors: object.errors.messages }\n end", "def errors\n validate_or_get_results :errors\n end", "def error_message(obj)\n obj.errors.full_messages.join(',')\n end", "def errors\n @errors ||= []\n end", "def errors\n @errors ||= []\n end", "def errors\n @errors ||= []\n end", "def errors\n @errors\n end", "def errors\n @errors\n end", "def errors\n @errors\n end", "def errors\n @errors ||= []\n end", "def errors\n @errors ||= []\n end", "def errors\n @errors.values\n end", "def to_h\n Utils::Hash.new(@errors).deep_dup\n end", "def add_errors_to_model(errors_hash)\n association_trees = errors_hash.map { |error_key, errors| error_key.to_s.split(\".\") }.uniq\n\n association_trees.each do |association_tree|\n association_errors = errors_hash[association_tree.join('.')]\n association_or_attribute_name = association_tree.last\n association_target = association_tree[0..-2].inject(self, :send)\n\n # Ingore errors for non existant attributes\n next unless association_target.respond_to?(association_or_attribute_name)\n\n if association_target.send(association_or_attribute_name).respond_to? :each\n # It's a has_many association\n if association_errors == [{\"error\"=>\"blank\"}]\n # Special case when the association is completely blank\n self.add_to_errors(association_tree.first, [{error: :blank}])\n else\n # We need to add one error to our \"base\" object so that it's not valid\n self.add_to_errors(association_tree.first, [{error: :invalid}])\n association_errors.each do |new_error_hash_with_index|\n\n new_error_hash_with_index.each do |index, inner_errors_hash|\n inner_errors_hash.each do |inner_field_name, inner_field_errors|\n error_attribute = inner_field_name.split('.').last.to_sym\n association_target.send(association_or_attribute_name)[index.to_i].add_to_errors(error_attribute, inner_field_errors)\n end\n end\n end\n end\n else\n # It's an attribute\n association_target.add_to_errors(association_or_attribute_name.to_sym, association_errors)\n association_target.errors.each do |attribute, message|\n self.errors[association_tree.join('.')] << message\n self.errors[association_tree.join('.')].uniq!\n end\n end\n end\n end", "def errors\n model_inst.marked_errors[@field_name]\n end", "def errors\n @error.fetch('errors', [])\n end", "def keep_errors(prefix = \"\")\n original_errors = errors.respond_to?(:messages) ? errors.messages.dup : errors.dup\n result = yield\n merge_errors(original_errors, prefix)\n result\n end", "def nice_errors(object, errors)\n object.errors.each do |key|\n error_obj = object.send(key)\n if error_obj.kind_of?(Array)\n errors[key] = {}\n error_obj.each {|item| nice_errors(item, errors[key])}\n elsif error_obj.kind_of?(ActiveRecord::Base)\n errors[error_obj.id] = {}\n nice_errors(error_obj, errors[error_obj.id])\n else\n errors[key] = object.errors[key]\n end\n end\n return errors\n end", "def error_messages\n errors.messages\n end", "def add_validation_errors(value); end", "def massage\n begin\n @massage ||= lookup.first % to_var( '_copy' )\n rescue => exception \n raise( exception, self.inspect )\n end \n end", "def initialize\n @errors = nil\n end", "def log_error_messages(model, grep_string = '')\n prefix = grep_string.empty? ? \"\" : \"[#{grep_string}] \"\n self.error \"#{prefix} Unable to save the #{model.class}\"\n model.errors.each do |name, msg|\n self.error \"#{prefix} #{model.class}[#{name}] = [#{msg}]\"\n end\n end", "def invalid_attributes(model) #:nodoc:\n model.valid? ? [] : model.errors.instance_variable_get(\"@errors\").keys.map(&:to_sym)\n end", "def load_errors_from(errors)\n errors.each do |key, value|\n [*value].each do |_value|\n self.errors.add(key, _value) unless self.errors.added?(key, _value)\n end\n end\n end" ]
[ "0.68175197", "0.68134886", "0.6707112", "0.6671951", "0.65738714", "0.6559467", "0.65437853", "0.65335274", "0.64072406", "0.6406935", "0.6382663", "0.62255937", "0.6166828", "0.61540055", "0.614228", "0.614228", "0.6132323", "0.61243135", "0.6114986", "0.6104908", "0.6098827", "0.5979179", "0.59498006", "0.5915731", "0.589861", "0.589349", "0.5892", "0.58893216", "0.5840412", "0.5840412", "0.5837974", "0.5830997", "0.58292246", "0.58292246", "0.5828934", "0.57919604", "0.57717323", "0.57668597", "0.57126766", "0.5705679", "0.5701465", "0.56687844", "0.5639763", "0.5634056", "0.56157905", "0.5591385", "0.5591385", "0.5583991", "0.5569142", "0.55645114", "0.55637664", "0.554765", "0.554765", "0.5538239", "0.5521785", "0.5521785", "0.5521785", "0.54935366", "0.5490811", "0.5477126", "0.5466429", "0.5457881", "0.54563564", "0.54563135", "0.5454482", "0.54496735", "0.5449081", "0.540911", "0.5404827", "0.5401254", "0.5399698", "0.5396821", "0.5396539", "0.5396539", "0.5396539", "0.53907937", "0.53852916", "0.5380148", "0.53780866", "0.53780866", "0.53766495", "0.5374733", "0.5374733", "0.5374733", "0.5370487", "0.5370487", "0.536187", "0.5359003", "0.5352526", "0.5339042", "0.5338742", "0.5334731", "0.53272915", "0.53157526", "0.5314072", "0.5311967", "0.5305137", "0.5303796", "0.52976596", "0.5286001" ]
0.8457919
0
Generalizes the constructor of ActiveModel::Model to make it work with an array argument. When an array argument is passed, it calls formatted_hash method to generate a Hash and then pass it to the ActiveModel::Model constructor == Parameters: arr_or_hash:: Array or Hash of values which represents an excel column.
def initialize(arr_or_hash = {}) if arr_or_hash.is_a?(Array) super(self.class.formatted_hash(arr_or_hash)) else super(arr_or_hash) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(arr_or_hash = {})\n self.copied_errors = ActiveModel::Errors.new(self)\n if arr_or_hash.is_a?(Array)\n super(self.class.formatted_hash(arr_or_hash))\n else\n super(arr_or_hash)\n end\n end", "def initialize(columns, size_or_array=nil)\n size_or_array ||= columns.size \n\n case size_or_array\n when Integer\n @arr = Array.new(size_or_array)\n when Array\n @arr = size_or_array\n else\n raise TypeError, \"parameter must be either Integer or Array\"\n end\n\n # The '@column_map' is used to map column names to integer values so\n # that users can reference row values by name or number.\n\n @column_map = {}\n @column_names = columns\n columns.each_with_index { |c,i| @column_map[c] = i }\n super(@arr)\n end", "def convert_format(arr)\n if cs = @columns\n h = {}\n arr.zip(cs).each{|v, c| h[c] = v}\n h\n else\n arr\n end\n end", "def to_xls_from_activerecord(base_instance, *args, &block)\r\n options = args.extract_options!\r\n \r\n return nil if empty?(base_instance) && options[:prepend].blank?\r\n\r\n #Rails::logger.info(\"Array#to_xls_from_activerecord(1) dopo primo return\")\r\n\r\n columns = []\r\n options.reverse_merge!(:header => true)\r\n options[:human] ||= true\r\n options[:worksheet] ||= \"Foglio1\"\r\n xls_report = StringIO.new\r\n book = Spreadsheet::Workbook.new\r\n sheet = book.create_worksheet\r\n sheet.name = options[:worksheet]\r\n \r\n sheet_index = 0\r\n \r\n unless options[:prepend].blank?\r\n options[:prepend].each do |array|\r\n sheet.row(sheet_index).concat(array)\r\n sheet_index += 1\r\n end\r\n end\r\n \r\n unless empty?(base_instance)\r\n \r\n base_instance = base_instance.to_a\r\n \r\n \r\n #Must check culumns name agains methids and removing the non working\r\n if options[:only]\r\n #columns = Array(options[:only]).map(&:to_sym)\r\n columns = Array(options[:only]).map { |column| validate(column,base_instance)}\r\n columns.compact!\r\n else\r\n columns = base_instance.first.class.column_names.map(&:to_sym) - Array(options[:except]).map(&:to_sym)\r\n end\r\n \r\n #Humanize columns name\r\n options[:header_columns] ||= columns.map do |column|\r\n #Se :human => false non umanizzo i nomi\r\n #Iconve risolve i problemi di codifica su caratteri strani tipo à che diventa \\340....\r\n options[:human] == false ? column.to_s : Iconv.conv(\"UTF-8\", \"LATIN1\", base_instance.first.class.human_attribute_name(column.to_s.gsub(/\\./,\"_\")))\r\n end\r\n \r\n return nil if columns.empty? && options[:prepend].blank?\r\n \r\n #Add headers to excel\r\n if options[:header]\r\n sheet.row(sheet_index).concat(options[:header_columns])\r\n sheet_index += 1\r\n end\r\n \r\n base_instance.each_with_index do |obj, index|\r\n if block\r\n sheet.row(sheet_index).replace(columns.map { |column| block.call(column, get_column_value(obj, column), index) })\r\n else\r\n sheet.row(sheet_index).replace(columns.map { |column| get_column_value(obj, column) })\r\n end\r\n \r\n sheet_index += 1\r\n end\r\n end\r\n \r\n #Rails::logger.info(\"Spreadsheet::Workbook sheet.rows=#{sheet.rows.inspect}\")\r\n #Rails::logger.info(\"Spreadsheet::Workbook book=#{book.inspect}\")\r\n if options[:file] == true\r\n Rails::logger.info(\"Spreadsheet::Workbook file\")\r\n tmp = Tempfile.new('tmp_xls')\r\n book.write(tmp.path)\r\n tmp\r\n else\r\n Rails::logger.info(\"Spreadsheet::Workbook stringIO\")\r\n book.write(xls_report)\r\n xls_report.string\r\n end\r\n end", "def thrift_cell_from_native_array(array)\n cell = Hypertable::ThriftGen::Cell.new\n cell.row_key = array[0]\n cell.column_family = array[1]\n cell.column_qualifier = array[2] if !array[2].blank?\n cell.value = array[3] if array[3]\n cell.timestamp = array[4] if array[4]\n cell\n end", "def initialize(arr)\n # tokenize headers \n @headers = arr[0].map { |h| h.strip.downcase.sub(' ', '_').to_sym }\n\n # turn all rows into processing friendly format\n @data = arr[1..arr.count].map do |d|\n Hash[@headers.collect.with_index { |header, idx| [header, d[idx]] }]\n end\n end", "def format=(arr)\n if arr.is_a?(Array)\n arr = arr.reject {|v| v.blank? }\n end\n super(arr)\n end", "def build_model(row)\n row[:id] = row[:id].to_i # Convert column to Integer\n new_instance = Employee.new(row)\n return new_instance\n end", "def cell(*args)\n if args.empty?\n raise ArgumentError, 'no args passed to #cell, you must pass at least a column name'\n end\n \n column = args.first.to_sym\n \n if args.size == 2\n @cells[column] = args.last\n elsif args.size == 1\n if @model && @model.respond_to?(column)\n @cells[column] = @model.send(column)\n else\n raise ArgumentError, \"##{column} is not a method on #{@model.class.to_s}, call `csv.cell #{column}, value` instead\"\n end\n else\n raise ArgumentError, 'you can pass a column or a column with a value to #cell'\n end\n \n @cells\n end", "def initialize(params = {})\n unless params.empty?\n params.each do |attr_name, value|\n\n if class_obj.columns.include?(attr_name.to_sym)\n self.send(\"#{attr_name.to_s}=\", params[attr_name])\n else\n raise \"unknown attribute '#{attr_name}'\"\n end\n\n end\n end\n end", "def array_to_cells(values, options = {})\n DataTypeValidator.validate :array_to_cells, Array, values\n types, style, formula_values, escape_formulas, offset = options.delete(:types), options.delete(:style), options.delete(:formula_values), options.delete(:escape_formulas), options.delete(:offset)\n offset.to_i.times { |index| self[index] = Cell.new(self) } if offset\n values.each_with_index do |value, index|\n options[:style] = style.is_a?(Array) ? style[index] : style if style\n options[:type] = types.is_a?(Array) ? types[index] : types if types\n options[:escape_formulas] = escape_formulas.is_a?(Array) ? escape_formulas[index] : escape_formulas unless escape_formulas.nil?\n options[:formula_value] = formula_values[index] if formula_values.is_a?(Array)\n\n self[index + offset.to_i] = Cell.new(self, value, options)\n end\n end", "def array_to_cells(values, options={})\n values = values\n DataTypeValidator.validate 'Row.array_to_cells', Array, values\n types, style = options.delete(:types), options.delete(:style)\n values.each_with_index do |value, index|\n cell_style = style.is_a?(Array) ? style[index] : style\n options[:style] = cell_style if cell_style\n cell_type = types.is_a?(Array)? types[index] : types\n options[:type] = cell_type if cell_type\n Cell.new(self, value, options)\n end\n end", "def initialize(worksheet, values=[], options={})\n @height = nil\n self.worksheet = worksheet\n @cells = SimpleTypedList.new Cell\n @worksheet.rows << self\n self.height = options.delete(:height) if options[:height]\n array_to_cells(values, options)\n end", "def initialize(params = {}) # <- ?is params a hash representing a new row object?\n params.each do |key, value|\n attr_name = key.to_sym\n class_name = self.class\n raise \"unknown attribute '#{attr_name}'\" if !class_name.columns.include?(attr_name)\n \n # set the attr_name by calling #send \n # ? what method are we sending? \n # ? we are sending the column name to ?\n self.send(\"#{attr_name}=\", value) \n # self.send \"#{attr_name}=\", value # also works\n end\n end", "def CSVHash arg, columns=nil\n if arg.is_a?(File)\n CSVHash.from_file(arg.path)\n elsif arg.is_a?(String)\n CSVHash.from_file(arg)\n elsif arg.is_a?(Array) && columns.is_a?(Array)\n CSVHash.to_string(arg,columns)\n end\nend", "def initialize(array, options={})\n @rows = array\n @options = {\n :table_class => \"tidy_table\",\n :first_row_class => \"first_row\",\n :first_column_class => \"first_column\",\n :last_column_class => \"last_column\",\n :title_class => \"title\"\n }.merge(options)\n end", "def initialize(params = {})\n params.each do |k,v|\n k = k.to_sym\n if self.class.columns.include?(k)\n self.send(k.to_s+'=', v)\n else\n raise \"unknown attribute '#{k}'\"\n end\n end\n end", "def make_cell\n # Some::ArrayCell.new\n end", "def initialize table, array = []\n @cell_index = 0\n @table = table\n @cells = []\n array.each { |item| self << item }\n end", "def initialize(worksheet, values = [], options = {})\n self.worksheet = worksheet\n super(Cell, nil, values.size + options[:offset].to_i)\n self.height = options.delete(:height)\n worksheet.rows << self\n array_to_cells(values, options)\n end", "def createField(rows,columns)\n\t\t@rows = rows\n\t\t@columns = columns\n\t\t@field = Array.new(rows) {Array.new(columns,Cell.new)}\n\t\tself\n\tend", "def from_activerecord(relation, *fields)\n if fields.empty?\n records = relation.map do |record|\n record.attributes.symbolize_keys\n end\n return Daru::DataFrame.new(records)\n else\n fields = fields.map(&:to_sym)\n end\n\n vectors = fields.map { |name| [name, Daru::Vector.new([], name: name)] }.to_h\n\n Daru::DataFrame.new(vectors, order: fields).tap do |df|\n relation.pluck(*fields).each do |record|\n df.add_row(Array(record))\n end\n df.update\n end\n end", "def from_array_of_hashes(hashes, hlines: false, **types)\n heads = hashes.first.keys\n result = new(*heads, **types)\n hashes.each do |hsh|\n if hsh.nil?\n unless hlines\n msg = 'found an hline in input: try setting hlines true'\n raise UserError, msg\n end\n result.mark_boundary\n next\n end\n result << hsh.to_h\n end\n result.normalize_boundaries\n result\n end", "def initialize(arr = 0)\n if ::Array === arr\n super(arr.map{|v| ::Array === v ? self.class.new(v) : v})\n else\n super\n end\n end", "def create\n data.is_a?(Array) ? create_by_array : create_by_hash(data)\n end", "def initialize(model, *args)\n # Ensure they're passing the correct type\n if !model.is_a? ActiveRecord::Base and !model.is_a? ActiveRecord::Relation\n raise TypeError.new \"Model passed to Flexigrid must be an ActiveRecord Base or Relation object\"\n end\n \n # Some default options\n @editable_columns = true\n \n @model = model\n @original_model = model\n @columns = Array.new\n @reload = false\n @ajax = false\n @paginate = true\n @columns_hash = Hash.new\n \n \n # Handle the two AR types that is accepted by Flexigrid\n @model_class = (model.is_a? ActiveRecord::Relation) ? model.klass : model.class\n \n # Is this actually unique? Grr rails...\n @unique_count = @unique_count ||= 0\n @unique_count += 1\n @id = @model_class.name + \"_#{@unique_count}\"\n \n \n # Automatically handle options\n args.each do |arg|\n if arg.is_a? Symbol\n m = arg.to_s + '='\n self.send(m, true) if self.respond_to? m\n elsif arg.is_a? Hash\n arg.each do |k,v|\n m = k.to_s + '='\n self.send m, v if self.respond_to? m\n end\n end\n end\n end", "def initialize(params = {})\n params.each do |attr_name, value|\n attr_name_sym = attr_name.to_sym\n if self.class.columns.include?(attr_name_sym)\n self.send(\"#{attr_name_sym}=\", value)\n else\n raise \"unknown attribute '#{attr_name_sym}'\"\n end\n end\n end", "def initialize(column, operator, value, options = {})\n return super(column) if column.instance_of?(Hash)\n throw \"No column given.\" unless column\n throw \"No operator given.\" unless operator\n\n @column = column\n @operator = operator\n @value = value \n if @value == nil\n\t@operator = \"IS NULL\" if @operator == \"=\"\n\t@operator = \"IS NOT NULL\" if @operator == \"!=\"\n end\n @value = nil if @operator == \"IS NULL\" || @operator == \"IS NOT NULL\"\n @options = options\n # value = @conditions[i][2]\n # value = [value] if value.class.name == \"String\"\n # value = [] if value == nil\n # ret = \"\"\n # for val in value \n # ret += \" OR \" if ret != \"\"\n # ret += \"#{@conditions[i][0]} #{@conditions[i][1]} #{val}\"\n # end\n # return \"(#{ret})\"\n end", "def initialize arr = []\n super arr\n end", "def initialize(model, column, value)\n @model, @column, @value = model, column, value\n\n case @value\n when String\n @filename_without_extension = File.basename @value\n when File\n @original_file = @value\n @original_filename = File.basename @value.path\n model.converted = false\n when ActionDispatch::Http::UploadedFile\n @original_file = @value.tempfile\n @original_filename = @value.original_filename\n model.converted = false\n when Hash\n @converted_files = @value.select{ |k| formats.include? k }\n @original_filename_without_extension = @value[:filename]\n formats.each { |f| instance_variable_set :\"@#{duration_keys[f]}\", @value[ duration_keys[f] ] }\n version_formats.each{ |v, _| instance_variable_set :\"@#{version_input_path_keys[v]}\", @value[ version_input_path_keys[v] ] }\n else\n @filename_without_extension ||= ''\n end\n end", "def initialize(params = {})\n params.each do |attr_name, value|\n attr_name_sym = attr_name.to_sym\n\n unless self.class.columns.include?(attr_name_sym)\n raise \"unknown attribute \\'#{attr_name_sym}\\'\"\n end\n attr_setter = (attr_name.to_s + \"=\").to_sym\n send(attr_setter, value)\n end\n end", "def init_object_from_row(row)\n if row\n data = Hash[columns.zip(row)]\n new(data)\n end\n end", "def normalize_array_of_columns(arry)\n arry.map do |f| \n if f.is_a?(Hash)\n f.symbolize_keys\n else\n f.to_sym\n end\n end\n end", "def from_array_of_arrays(rows, hlines: false, **types)\n headers = []\n if !hlines\n # Take the first row as headers\n # Second row et seq as data\n headers = rows[0].map(&:to_s).map(&:as_sym)\n first_data_row = 1\n elsif rows[1].nil?\n # Use first row 0 as headers\n # Row 1 is an hline\n # Row 2 et seq are data\n headers = rows[0].map(&:to_s).map(&:as_sym)\n first_data_row = 2\n else\n # Synthesize headers\n # Row 0 et seq are data\n headers = (1..rows[0].size).to_a.map { |k| \"col_#{k}\".as_sym }\n first_data_row = 0\n end\n result = new(*headers, **types)\n rows[first_data_row..-1].each do |row|\n if row.nil?\n unless hlines\n msg = 'found an hline in input: try setting hlines true'\n raise UserError, msg\n end\n result.mark_boundary\n next\n end\n row = row.map { |s| s.to_s.strip }\n hash_row = Hash[headers.zip(row)]\n result << hash_row\n end\n result.normalize_boundaries\n result\n end", "def from_hash(hash:, klass:, use_alias: false)\n validate_class_kit(klass)\n\n return hash.map { |i| from_hash(hash: i, klass: klass, use_alias: use_alias) } if hash.is_a?(Array)\n\n @hash_helper.indifferent!(hash)\n entity = klass.new\n attributes = @attribute_helper.get_attributes(klass)\n attributes.each do |attribute|\n key = use_alias ? (attribute[:alias] || attribute[:name]) : attribute[:name]\n type = attribute[:type]\n\n # if the hash value is nil skip it\n next if hash[key].nil?\n\n value = if is_class_kit?(type)\n from_hash(hash: hash[key], klass: type, use_alias: use_alias)\n elsif is_class_kit_custom_type?(type)\n type.parse_from_hash(hash[key])\n elsif type == Array\n hash[key].map do |array_element|\n if attribute[:collection_type].nil?\n array_element\n else\n if is_class_kit?(attribute[:collection_type])\n from_hash(hash: array_element, klass: attribute[:collection_type], use_alias: use_alias)\n elsif is_class_kit_custom_type?(attribute[:collection_type])\n attribute[:collection_type].parse_from_hash(array_element)\n else\n @value_helper.parse(type: attribute[:collection_type], value: array_element)\n end\n end\n end\n else\n hash[key]\n end\n\n entity.public_send(:\"#{attribute[:name]}=\", value)\n end\n\n entity\n end", "def from_a(ary)\n ary.each { |e|\n self[e[0]] = e[1]\n }\n end", "def initialize(params = {})\n # Your #initialize method should iterate through each of the\n # attr_name, value pairs.\n params.each do | attr_name, value |\n # For each attr_name,\n # it should first convert the name to a symbol\n attr_name = attr_name.to_sym\n # check whether the attr_name is among the columns\n # Hint: we need to call ::columns on a class object\n # not the instance.\n # For example, we can call Dog::columns but not dog.columns.\n if self.class.columns.include?(attr_name)\n # calls appropriate setter method for each item in params\n # Use #send; avoid using @attributes or\n # attributes inside #initialize.\n self.send(\"#{attr_name}=\", value)\n else\n # If it is not, raise an error\n raise \"unknown attribute '#{attr_name}'\"\n end\n end\n end", "def initialize(header:, items: [])\n @raw_header = header\n @header =\n if @raw_header.is_a?(Symbol)\n @raw_header\n else\n @raw_header.to_s.as_sym\n end\n @type = 'NilClass'\n msg = \"unknown column type '#{type}\"\n raise UserError, msg unless TYPES.include?(@type.to_s)\n\n @items = []\n items.each { |i| self << i }\n end", "def from_activerecord(relation, *fields)\n fields = relation.klass.column_names if fields.empty?\n fields = fields.map(&:to_sym)\n\n result = relation.pluck(*fields).transpose\n Daru::DataFrame.new(result, order: fields).tap(&:update)\n end", "def build_from_hash(attributes)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n elsif attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]])\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n self\n end", "def <<( array)\n unless @list\n # columns were not added, this most likely is the title\n @list ||= []\n _init_model array\n end\n @list << array\n @native_text = @list # 2014-05-27 - 16:34 \n fire_dimension_changed\n self\n end", "def build_model(row)\n row[:id] = row[:id].to_i # Convert column to Integer\n new_instance = Customer.new(row)\n return new_instance\n end", "def build_element(row)\n # Price MUST be an integer\n # binding.pry\n row[:price] = row[:price].to_i\n # binding.pry\n Meal.new(row) # returns a Meal instance\n end", "def initialize(*args)\n if args.size == 2 # no array initializer\n rows = args[0]\n cols = args[1]\n elsif args.size == 3 # flat array initializer\n rows = args[0]\n cols = args[1]\n ary = args[2]\n elsif args.size == 1 # nested list (by rows) initializer\n rows = args[0].size\n cols = args[0][0].size\n ary = args[0]\n else\n raise ArgumentError.new(\"wrong args: #{args.size} for 1, 2, or 3\")\n end\n\n @gsl = MatrixStruct.new(alloc(rows, cols))\n\n @size = [@gsl[:rows], @gsl[:cols]]\n\n if (args.size == 3) # flat array of value\n row = 0\n col = 0\n ary.each do |v|\n self[row, col] = v\n col += 1\n if (col == cols)\n col = 0\n row += 1\n end\n end\n elsif (args.size == 1) # nested array of rows of values\n row = 0\n ary.each do |rowdata|\n col = 0\n rowdata.each do |v|\n self[row, col] = v\n col += 1\n end\n row += 1\n end\n end\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end", "def build_from_hash(attributes)\n return nil unless attributes.is_a?(Hash)\n self.class.swagger_types.each_pair do |key, type|\n if type =~ /\\AArray<(.*)>/i\n # check to ensure the input is an array given that the the attribute\n # is documented as an array but the input is not\n if attributes[self.class.attribute_map[key]].is_a?(Array)\n self.send(\"#{key}=\", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )\n end\n elsif !attributes[self.class.attribute_map[key]].nil?\n self.send(\"#{key}=\", _deserialize(type, attributes[self.class.attribute_map[key]]))\n end # or else data not found in attributes(hash), not an issue as the data can be optional\n end\n\n self\n end" ]
[ "0.7286811", "0.56759477", "0.5553372", "0.55328107", "0.54705304", "0.5394304", "0.531762", "0.5198018", "0.5183628", "0.5109349", "0.50992733", "0.5073423", "0.5071204", "0.50398135", "0.5032002", "0.5027121", "0.50114876", "0.50032616", "0.4999988", "0.49855044", "0.49728188", "0.49650434", "0.49553052", "0.49226695", "0.48927733", "0.48700565", "0.4858738", "0.485599", "0.48553756", "0.47993663", "0.47863597", "0.47749", "0.47534153", "0.4744884", "0.47446173", "0.47352743", "0.47297335", "0.4719744", "0.47113606", "0.46964386", "0.46579745", "0.465481", "0.46328413", "0.46259022", "0.46135408", "0.46135408", "0.46135408", "0.46135408", "0.46135408", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542", "0.46122542" ]
0.67429686
1
Action to take on every line of csv file with header row
def process(report) puts "Code to process csv goes here for #{report}" CSV.foreach(report, headers: true) do |row| # **** actions here are operated on every row in the csv **** puts row['Site Name'] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def header\n @header ||= csv_rows.first\n end", "def header\n @header ||= csv_rows.first\n end", "def collect_row_headers\n @row_headers = []\n CSV.foreach('testdata.csv') {|row| @row_headers << row[1].to_i}\n @row_headers = @row_headers.uniq.sort[0..-1] # ==> [0, 734638, 734639, 734640, 734641, 734642, 734643, 734644, 734645, 734646]\nend", "def parse_headers!(csv_file)\n csv = CSV.open(csv_file, :headers => true)\n csv.gets\n csv.headers\n end", "def each\n\t\t\tfilename = self.class.to_s.downcase + '.txt'\n\t\t\tfile = File.new(filename)\n\t\t\t@headers = file.gets.chomp.split(', ')\n\n\t\t\tfile.each { |row| yield CsvRow.new(row.chomp.split(', ')) }\n\t\tend", "def csv_file_headers\n # Open file\n CSV.foreach(self.file.path, headers: true) do |row|\n # Transform row to hash\n row = row.to_hash\n # Normalize it\n row = normalize_row(row)\n errors.add(:file, \"Invalid CSV headers, please check if #{required_csv_headers.join(', ')} are present.\") unless valid_headers?(row)\n break\n end\n end", "def process\n lines = clean_lines\n\n # Peek ahead to get the headers\n unless @file_content.blank?\n CSV.parse(@file_content, {:headers => true, :skip_blanks => true}) do |row|\n @rows_exist = true\n @headers = row.headers\n break\n end\n end\n\n @rows_exist = @rows_exist and [email protected]?\n end", "def csv_header\n #empty by default\n []\n end", "def csv_header\n #empty by default\n []\n end", "def csv_header(*columns)\n csv.start(columns.flatten)\n end", "def each(&block)\n file_handle.each do |line|\n yield headers.zip(line.chomp!.split(col_sep, -1)).to_h\n end\n end", "def each\n @csv_contents.each do |line|\n yield CsvRow.new(@headers, line)\n end\n end", "def csv_headers\n raise NotImplementedError\n end", "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 process_csv\n @file = @file.tempfile\n CSV.foreach(@file, headers: false) { |row| process_item(row[0].to_i) }\n end", "def scanFirstRowOfIndividualLogFile(row)\n @csvColumnLabelList = [] ;\n @csvColumnIndex = {} ;\n row.each{|val|\n index = @csvColumnLabelList.length ;\n @csvColumnIndex[val] = index ;\n self.instance_variable_set(\"@index_\" + val.to_s, index) ;\n @csvColumnLabelList.push(val) ;\n }\n RequiredColumnName.each{|colName|\n if([email protected]_key?(colName)) then\n p [:missingColumn, colName] ;\n raise(\"log CSV file should have the column: \" + colName) ;\n end\n }\n end", "def each\n CSV.foreach(@file, :encoding => 'iso-8859-1:utf-8') do |row|\n # File has a footer - truncate at the last valid line\n break if row.empty?\n \n yield row\n end\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 each\n\t\t\t@csv_contents.each { |csv_row| yield CsvRow.new(csv_row, @headers) } \n\t\t\tnil\n\t\tend", "def header_fields\n @csv.headers\n end", "def fix_csv(csv_filenames)\n # Read line from file, modify, and write back out\n first_line = true\n new_file_name = \"#{@file_name[0...-3]}csv\"\n # Open final csv for output\n File.open(new_file_name, 'w') do |fo|\n # Iterate over tmp csv files\n csv_filenames.each do |csv|\n # Go through each line of tmp csv\n CSV.foreach(csv, headers: true) do |row|\n if first_line\n headers = @col_num_hash.keys\n fo.puts headers.join(',')\n first_line = false\n else\n fo.puts fix_data(row)\n end\n end\n end\n end\nend", "def csv_header(header_prefix)\n @csv_header << header_prefix\n end", "def double_header(iterator)\n #p \"double_header iterator\", iterator\n head1 = cut_line(iterator) \n #p \"head1\", head1\n head1_csv = CSV.parse(head1).flatten \n #p \"head1_csv\", head1_csv\n head1_csv = nil_blank(head1_csv) \n #p \"head1_csv\", head1_csv\n head1_csv.collect!{|str| str.strip} #leading and trailing whitespace removed\n #p \"head1_csv\", head1_csv \n #puts \"\"\n \n head2 = cut_line(iterator) \n #p \"head2\", head2\n head2_csv = CSV.parse(head2).flatten \n #p \"head2_csv\", head2_csv\n head2_csv = nil_blank(head2_csv) \n #p \"head2_csv\", head2_csv\n head2_csv.collect!{|str| str.strip} #leading and trailing whitespace removed\n #p \"head2_csv\", head2_csv\n \n merged_arr = merge_headers(head1_csv, head2_csv, \" \", \"[\", \"]\")\n \n #Adds quotes around fields (helps avoid CSV parse bugs)\n if ($add_quotes == true)\n merged_arr.map! {|s| \"\\\"#{s}\\\"\" }\n end\n \n new_head = merged_arr.join(',') #creats string with \",\" as sperator\n new_head << \"\\r\\n\" #So CSV can parse headers\n new_iterator = new_head << iterator #combines new header with data\n return new_iterator\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 validate_header(header)\n import_failed(0, t(:header_invalid)) if self.class.csv_header != header\n end", "def write_header csv = nil\n csv << indices\n end", "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 skip_headers\n start_of_file? ? (@headers = read_row) : false\n end", "def generate_header_row\n (@header.map {|x| generate_header_item(x)}).join\n end", "def collect_column_headers\n @column_headers = []\n CSV.foreach('testdata.csv') {|row| @column_headers << row[0].to_i}\n @column_headers = @column_headers.uniq.sort[1..-1] # ==> [102231711, 103244134, 103285344, 103293593]\nend", "def main \n skip_first = true\n headers = []\n CSV.foreach('to_email.csv', :encoding => \"UTF-8\") do |row|\n if skip_first\n headers = row\n skip_first = false\n next\n else\n cur = File.open(\"#{row[5].to_s}.txt\", 'a')\n cur << \"Hi,\n\nBelow is the feedback you received from your customer:\" << \"\\n\\n\"\n headers.zip(row).each do |header, val|\n if header == \"emails\"\n tmp = val.split\n val = tmp.join(\",\")\n cur << \"Customer Feedback, Iteration 2\\n\"\n cur << val << \"\\n\\n\"\n next\n end\n if header == \"Which project is this feedback for?\"\n next\n end\n cur << header << \"\\n\"\n cur << val << \"\\n\\n\"\n end\n cur.close\n end\n end\n\nend", "def parse_headers(row = nil)\n if @headers.nil? # header row\n @headers = case @use_headers # save headers\n # Array of headers\n when Array then @use_headers\n # HBCSV header String\n when String\n self.class.parse_line( @use_headers,\n col_sep: @col_sep,\n row_sep: @row_sep,\n quote_char: @quote_char )\n # first row is headers\n else row\n end\n\n # prepare converted and unconverted copies\n row = @headers if row.nil?\n @headers = convert_fields(@headers, true)\n @headers.each { |h| h.freeze if h.is_a? String }\n\n if @return_headers # return headers\n return self.class::Row.new(@headers, row, true)\n elsif not [Array, String].include? @use_headers.class # skip to field row\n return shift\n end\n end\n\n self.class::Row.new(@headers, convert_fields(row)) # field row\n end", "def import_csv_full\n \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 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 parse(line)\n @io.rewind\n @io.truncate(0)\n @io << line\n @io.rewind\n @csv.shift\n end", "def show_csv(csv)\n csv.each do |row|\n p row\n end\n puts\n end", "def parse_header(row)\r\n @first_month = 0 # January.\r\n row.each do |col|\r\n next unless col.nil?\r\n index = Date::MONTHNAMES.index(col.strip)\r\n unless index.nil?\r\n @first_month = index\r\n break\r\n end\r\n end\r\n @header_parsed = true\r\n end", "def generate_header_row\n generate_row(@header)\n end", "def generate_header_row\n generate_row(@header)\n end", "def each_row(input)\n csv = ::CSV.new(input, csv_options)\n # Skip skipRows and headerRows\n rownum = dialect.skipRows.to_i + dialect.headerRowCount\n (1..rownum).each {csv.shift}\n csv.each do |row|\n rownum += 1\n yield(Row.new(row, self, rownum))\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 csv_file_header_array\n\t\tScreeningDatumUpdate.expected_column_names\n\tend", "def import!\n log \"Importing #{csv_file.split('/').last.sub('.csv', '')}\"\n\n @errors_count = 0\n\n before_import()\n with_each_row { process_row }\n after_import()\n\n log \"Import complete (#{@errors_count} errors in #{@has_header_row ? @current_row_number-1 : @current_row_number} rows)\"\n end", "def read_csv(file, header)\n FasterCSV.read(file, {:header_converters => :symbol, :headers => header } )\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 csv_headers\n return @@csv_headers\n end", "def empty(headers, path)\n path = Pathname(path) unless path.nil?\n\n raise(ExistingCSVHeaderError, path) if path&.file?\n\n headers = headers.map { |header| normalize_key(header) }\n new(CSV::Table.new([CSV::Row.new(headers, headers, true)]), path)\n end", "def start\n file_name = ARGV[0]\n puts \"file_name: #{file_name}\"\n \n input = CSV.read(file_name)\n\n header = input.first\n #puts header\n rows = []\n (1...input.size).each { |i| rows << CSV::Row.new(header, input[i]) }\n \n @FeatureCount = 0 #@iCount = 0 or rows.length-1\n while @FeatureCount<rows.length #@iCount<rows.length or @iCount> 0\n if(input[@FeatureCount]!= nil)\n puts rows[@FeatureCount]\n manage_userStory(rows[@FeatureCount])\n end\n @FeatureCount += 1\n end\nend", "def header(*args, &block)\n if block_given?\n block = capture(&block)\n @header_line.add_cell(@collection.first, args, nil, block)\n else\n @header_line.add_cell(@collection.first, args)\n end\n nil\n end", "def start()\n header = true # skip the header\n File.open(\"pricefile.txt\", 'w') do |file|\n CSV.foreach(\"../../produce.csv\") do |row| \n row[5].to_i.times do\n selling_price = adjusted_price(row[0], get_markup(row[1]), row[4])\n sell_by = adjusted_sell_by(row[0], row[1], row[3])\n short_description = row[2][0..30]\n\n file.puts \"R#{'% 8.2f' % (selling_price)}#{sell_by.strftime('%Y/%m/%d')}#{short_description}\"\n end unless header\n header = false\n end\n end\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 csv_header\n [\n 'project key',\n 'key',\n 'summary',\n 'description',\n 'issue type',\n 'epic name'\n ]\n end", "def header_rows\n []\n end", "def filter(*columns)\n # columns = [*columns].flatten #columns should accept either an array of strings or a variable number of strings\n raise ArgumentError unless (columns.respond_to?(:size) and columns.size < @num_columns)\n output = []\n @file.each_with_index do |line, i|\n #TODO: Decide wther to allow user to specify if header row exists. If so, this step will be conditional. Else, add proviso to the README that csv file must include a header line.\n next if i == 0 # skip header row\n row = {}\n line.chomp.split(@separator).each_with_index do |value, j|\n if filtered_column_positions(columns).include? j\n row[@header[j]] = value\n end\n end\n output << row\n end\n output\n end", "def headers\n @headers ||= next_row\n end", "def header\n @header ||= Header.new(\n column_definitions: config.column_definitions,\n column_names: csv.header\n )\n end", "def valid_headers?(row)\n (required_csv_headers - row.keys).empty?\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 header=(_arg0); end", "def consume_header_line(line, column_mappings)\n columns = column_names(column_mappings)\n\n header_guess = line.map { |column| column.to_s.downcase }\n\n # The \"best guess\" is only if/when the header eventually deemed to be\n # invalid - in which case, it builds the informative error message.\n @header_best_guess = header_guess if header_guess.any?(&:present?)\n @header_valid = true if header_guess == columns\n end", "def csv_emit(row)\n row = row.to_h\n mutex.synchronize do\n # header if necessary\n csv_header(row.keys) if !csv.started?\n\n # emit\n print = csv.emit(row)\n puts print.ai if options[:verbose]\n\n # this is caught by Sinew::Main\n if csv.count == options[:limit]\n raise LimitError\n end\n end\n end", "def process_data(data, header)\n i = 2\n if data.present?\n data.each do |row|\n obj = Transport.new(:academic_year_id => academic_year_id)\n header.each do |name|\n method_n = header_to_method(name)\n send(method_n, obj, row[name].try(:strip)) if row[name].present? or method_n == \"fare\"\n end\n val = obj.save\n log_error(i, obj.errors.full_messages) unless val\n i += 1\n end\n else\n import_failed(1, t(:no_data_present_in_csv))\n end\n end", "def each_row(batch = ETL::Batch.new)\n log.debug(\"Reading from CSV input file #{file_name}\")\n @rows_processed = 0\n ::CSV.foreach(file_name, csv_options) do |row_in|\n # Row that maps name => value\n row = {}\n\n # If we weren't given headers then we use what's in the file\n if headers.nil?\n # We have a hash - OK we'll use it\n if row_in.respond_to?(:to_hash)\n row = row_in.to_hash\n # We have an array - use numbers as the keys\n elsif row_in.respond_to?(:to_a)\n ary = row_in.to_a\n ary.each_index do |i|\n row[i] = ary[i]\n end\n # Error out since we don't know how to process this\n else\n raise ETL::InputError, \"Input row class #{row_in.class} needs to be a hash or array\"\n end\n # if we were given the headers to use then we just need to grab the\n # values out of whatever we have\n else\n values = row_in.kind_of?(::CSV::Row) ? row_in.fields : row_in.to_a\n\n if headers.length != values.length\n raise ETL::InputError, \"Must have the same number of headers #{headers.length} \" + \n \"and values #{values.length}\"\n end\n\n # match up headers and values\n (0...headers.length).each do |i|\n row[headers[i]] = values[i]\n end\n end\n\n # now we apply our header map if we have one\n @headers_map.each do |name, new_name|\n if row.has_key?(name)\n # remap old name to new name\n row[new_name] = row[name]\n row.delete(name)\n else\n raise ETL::InputError, \"Input row does not have expected column '#{name}'\"\n end\n end\n\n transform_row!(row)\n yield row\n @rows_processed += 1\n end\n end", "def read_continuous_trait_headers\n # Try to find all the names listed in the template\n # Note that headers appearing in the template but not the CSV will not be in the output data\n found_headers = @config.continuous_trait_column_names & @csvfile.headers\n @trait_headers[:continuous] += found_headers.map{|x|\n {:name => x,\n :groups => @config.groups_for_continuous_trait(x),\n :format => @config.continuous_trait_format(x),\n :summarization_method => @config.continuous_trait_summarization_method(x)\n }\n }\n @validation_results[:info] << {:info => \"Found #{found_headers.count} continuous trait headers\"}\n end", "def genCsvRowSummary()\n row = configIndex() ;\n\n row.push(getAveSpeed()) ;\n row.push(getShareRatio()) ;\n row.push(getCumulativeShare()) ;\n return row ;\n end", "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 csvread (filename)\n File.readlines(filename).each do |line|\n if line && !empty?(line)\n num, code, kind, desc, contenten, contentme = line.split(\"\\t\")\n\n num = num\n code = clean(code)\n kind = clean(kind)\n contenten = clean(contenten)\n contentme = clean(contentme)\n\n yield num, code, kind, desc, contenten, contentme\n end\n end\nend", "def transform_csv_file(csv_file)\n @logger.info(\"Transforming CSV file\")\n transformed = []\n headers = csv_file.shift\n headers.map!(&method(:prepare_custom_headers))\n\n csv_file.each do |row|\n transformed << Hash[headers.zip row]\n end\n prefix_sf_attribute_names transformed\n end", "def parse_header(filename, header)\n result = Hash.new(0)\n CSV.foreach(filename, headers: true, converters: %i[numeric date]) do |row|\n result[row[header]] += 1\n end \n result \nend", "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 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 add_row(row)\n\n # Delete row if it already exists\n $rows.delete_if { |r| r['file_path'] == row['file_path'] }\n $rows << row\n\n # rewrite csv:\n update_csv($rows)\nend", "def header_row(collection)\n sheet.add_row header_data_for(collection), { :style => header_style_id }\n end", "def headers\n rows.first\n end", "def generate(with_headers: true)\n @file = Tempfile.new([row_model_class.name, \".csv\"])\n CSV.open(file.path, \"wb\") do |csv|\n @csv = csv\n row_model_class.setup(csv, context, with_headers: with_headers)\n yield Proxy.new(self)\n end\n ensure\n @csv = nil\n end", "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 proccess_lines(input)\n CSV.foreach(input, headers: true, header_converters: :symbol) do |row|\n line_parser = LineParser.new(row)\n\n if line_parser.valid?\n output_file << line_parser.to_csv\n elsif !line_parser.empty?\n error_file << line_parser.to_csv\n end\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 write_csv\n # header = \"name, description\"\n CSV.open(@csv_file, 'wb') do |csv|\n # csv << header\n @recipes.each do |row|\n csv << [row.name, row.description, row.cooking_time, row.difficulty, row.tested]\n end\n end\n end", "def scanCsv(csvFile)\n CSV.foreach(csvFile){|row|\n if(@colList.nil?) then\n scanCsvHeader(row) ;\n else\n scanCsvEntry(row) ;\n end\n }\n end", "def analyze_headers\n# @chron_list = nil\n chrons = []\n extractor.headers.each_with_index do |v, colnum|\n pv = ParsedValue.new(v)\n if !pv.chron.empty? then\n chrons << pv.chron.first\n if colnum < @ncolumns\n# puts \"Setting the column role to #{pv.chron.first}\"\n @columns[colnum].role = pv.chron.first\n end\n end\n end\n # p chrons\n# @chron_list = chrons unless chrons.empty?\n end", "def parse_csv(path)\n require 'csv'\n\n str = Nitro::Template.new.render(File.read(path))\n\n reader = CSV::Reader.create(str)\n header = reader.shift\n\n reader.each_with_index do |row, i|\n data = {}\n row.each_with_index do |cell, j|\n data[header[j].to_s.strip] = cell.to_s.strip\n end\n self[\"#{@name}_#{i+1}\"] = obj = instantiate(data)\n @objects << obj\n end\n end", "def csv_writer(rows)\n headers = [\"name\", \"capacity\", \"storage\"]\n CSV.open(\"reservoir_data.csv\", 'w') do |csv|\n csv << headers\n rows.each do |row|\n csv << row\n end\n end\nend", "def insert_headers headers = []\n @headers = Hash[headers.map.with_index { |e, i| [e, i] }]\n define_row(@headers)\n\n @has_headers = false\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_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 scanIndivLogFile(file)\n @csvColumnLabelList = nil ;\n CSV.foreach(file) {|row|\n if(@csvColumnLabelList.nil?) then\n scanFirstRowOfIndividualLogFile(row)\n else\n scanCsvRow(row) ;\n end\n }\n end", "def load_headers\n @headers = @rows[COLUMNS_ROW].xpath('td').map(&:text).pop\n end", "def append_csv(rainfall) # append rainfall details into CSV file\r\n filename = \"rainfall_collection.csv\"\r\n if !File.file?(filename) # places header information\r\n header = [\"Place\",\"year\",\"Month\",\r\n \"day1\",\"day2\",\"day3\",\"day4\",\"day5\",\"day6\",\"day7\",\"day8\",\"day9\",\"day10\",\r\n \"day11\",\"day12\",\"day13\",\"day14\",\"day15\",\"day16\",\"day17\",\"day18\",\"day19\",\"day20\",\r\n \"day21\",\"day22\",\"day23\",\"day24\",\"day25\",\"day26\",\"day27\",\"day28\",\"day29\",\"day30\",\r\n \"day31\"]\r\n CSV.open(filename, \"w+\") do |hdr|\r\n hdr << header\r\n hdr << rainfall\r\n end\r\n else\r\n CSV.open(filename, \"a+\") do |mth|\r\n mth << rainfall\r\n end\r\n end # end for File.file? if file exists\r\n\r\nend", "def _each\n delete_harmful!\n convert_eol_to_unix!\n transliterate_whole_file_to_utf8!\n skip_rows!\n\n Engine.new(local_copy.encoded_io, csv_options).each do |row|\n\n some_value_present = false\n\n if not headers\n\n # represent the row as an array\n array = row.map do |v|\n v = v.to_s\n if not some_value_present and not keep_blank_rows and v.present?\n some_value_present = true\n end\n v\n end\n if some_value_present or keep_blank_rows\n yield array\n end\n\n else\n\n # represent the row as a hash\n hash = ::ActiveSupport::OrderedHash.new\n row.each do |k, v|\n next unless k.present?\n v = v.to_s\n if not some_value_present and not keep_blank_rows and v.present?\n some_value_present = true\n end\n hash[k] = v\n end\n if some_value_present or keep_blank_rows\n yield hash\n end\n\n end\n end\n ensure\n local_copy.cleanup\n end", "def started\n\t\t@csv[3]\n\tend", "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 non_standardized_header(row)\n @header=row.split(/\\s{2}+/).reject{|a|a.empty?} \n @header[1].insert(8,'--')\n @header[1]=@header[1].split(/--/)\n @header.insert(1,'Incep Date')\n @[email protected]\n end", "def process_silently(csv_file)\n assert_output { process(csv_file) }\n end", "def each\n rewind\n return self.enum_for(:each) unless block_given?\n csv.each do |row|\n next unless out = convert_row(row)\n yield(out)\n end\n end", "def strip_csv_quotes(src_path, dest_path)\n\n require 'csv'\n open('LoginHistory-comma-delim.csv', 'w') do |f|\n first_line = true\n CSV.foreach('LoginHistory.csv') do |row|\n if first_line\n first_line = false\n else\n f.puts( row.join(',') )\n end\n \n end\n end\n\nend", "def scanCsvHeader(row)\n @colList = row ;\n @colIndex = {} ;\n ([email protected]).each{|index|\n _label = @colList[index] ;\n if(!_label.nil? && _label.length > 0) then\n @colIndex[_label] = index ;\n end\n }\n return @colIndex ;\n end", "def seed_from_csv_file(path, label, has_headers = true)\n CSV.read(Rails.root.join(path), headers: has_headers).tap do |csv|\n print \"Seeding #{label}: \\n\"\n\n csv.each_with_index do |row, i|\n yield row if block_given?\n\n ratio = (i + 1).to_f / csv.size\n per10 = (ratio * 10).round\n\n filled = per10 < 2 ? 0 : (per10 - 1)\n unfilled = 10 - per10\n pad_percentage = (\"%.2f\" % (ratio * 100)).rjust(6)\n progress = \"%s%% [%s>%s]\" % [ pad_percentage, (\"=\" * filled), (\" \" * unfilled) ]\n\n print \"\\r#{progress}\"\n end\n print \"\\n\"\n end\nend" ]
[ "0.68843275", "0.68843275", "0.67756444", "0.67494935", "0.67436343", "0.67245203", "0.67109495", "0.66968113", "0.66968113", "0.6678946", "0.6670517", "0.65253526", "0.65163213", "0.64949095", "0.64844567", "0.6441023", "0.6405447", "0.6278036", "0.62325144", "0.62098587", "0.6201635", "0.61985767", "0.6194326", "0.6141437", "0.6133073", "0.6129173", "0.6102711", "0.6101351", "0.6090237", "0.608563", "0.6049479", "0.6046508", "0.6045987", "0.6045384", "0.60286254", "0.6025643", "0.6018557", "0.5987744", "0.59793544", "0.59793544", "0.5906017", "0.58967274", "0.58904076", "0.5884355", "0.5882067", "0.58767605", "0.5869691", "0.5867526", "0.5864638", "0.5847289", "0.5846379", "0.5844549", "0.5828748", "0.5819874", "0.5819715", "0.5799767", "0.57892174", "0.5762952", "0.5748315", "0.5741931", "0.5732472", "0.5724678", "0.57171255", "0.57114404", "0.57062507", "0.570427", "0.57039404", "0.57016426", "0.5699304", "0.5697992", "0.56912756", "0.5690036", "0.5686331", "0.5684874", "0.5684692", "0.5683518", "0.5680266", "0.5677697", "0.56647104", "0.56647104", "0.5652554", "0.5651856", "0.56491286", "0.5628188", "0.56177336", "0.5617463", "0.561286", "0.5609039", "0.56086797", "0.5607427", "0.56012005", "0.5599782", "0.5596135", "0.5589045", "0.55789626", "0.5572117", "0.5566108", "0.5563685", "0.55630463", "0.55624825" ]
0.6164836
23
Where the magic is. You've got report naming, sql query, & time monitoring.
def adhoc_report(site) start_time = Time.now report_name = "reports/#{site.name}.csv" puts "Generating #{report_name}. Be patient. Get some coffee." query = %q{WITH vuln_urls AS ( SELECT vulnerability_id, array_to_string(array_agg(reference), ' , ') AS references FROM dim_vulnerability_reference GROUP BY vulnerability_id ) select da.ip_address, da.host_name, dos.description as operating_system, dv.title as vuln_title, round(dv.riskscore::numeric,0) as vuln_riskscore, CASE WHEN (dv.riskscore >= 800) then 'Very High' WHEN (dv.riskscore >= 600 AND dv.riskscore <= 799) then 'High' WHEN (dv.riskscore >= 400 AND dv.riskscore <= 599) then 'Medium' WHEN (dv.riskscore >= 200 AND dv.riskscore <= 399) then 'Low' WHEN (dv.riskscore <= 199) then 'Very Low' END AS vuln_severity, proofastext(dv.description) as vuln_description, proofastext(favi.proof) as vuln_proof, vu.references, favi.port as "port", dv.date_added as vuln_date_into_nexpose, to_char(favi.date, 'YYYY-mm-dd') as asset_last_scan FROM fact_asset_vulnerability_instance favi JOIN dim_vulnerability dv USING (vulnerability_id) JOIN dim_asset da USING (asset_id) JOIN dim_operating_system dos USING (operating_system_id) JOIN dim_vulnerability_reference dvr USING (vulnerability_id) JOIN vuln_urls vu USING (vulnerability_id) WHERE dv.riskscore >= 600 ORDER BY dv.riskscore DESC} report_config = Nexpose::AdhocReportConfig.new(nil, 'sql', site.id) report_config.add_filter('version', '2.3.0') report_config.add_filter('query', query) report_output = report_config.generate(@nsc) end_time = Time.now File.open(report_name, "w+") do |file| file.write report_output end csv_output = CSV.parse(report_output.chomp, { :headers => :first_row }) file_length = csv_output.entries.count #calculates duration for file creation ttg = ( (end_time - start_time) / 60).round(1) puts "\t. . . Complete after #{ttg} minutes and is #{file_length} lines long!" report_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def report_lister\n \"Name: #{@name}\\nType: #{@type}\\nRate: #{@rate}\\nCategory: #{@category}\"\n # \"Report run on: \" + Time.now.to_s\n end", "def report; end", "def report; end", "def report; end", "def report; end", "def report; end", "def reporting\n # STUB\n end", "def report_title; end", "def report_title; end", "def set_report\n end", "def report\n \n end", "def report\n\t\tend", "def reporters; end", "def reporters; end", "def reporters; end", "def reporters; end", "def reporters; end", "def report_startup\n @time = Time.now\n #dir = File.basename(source) #File.basename(File.dirname(source))\n report \"Generating #{job} in #{File.basename(output)}:\\n\\n\"\n end", "def write_report\n\n end", "def create_report\n print_sales_report_ASCII\n print_date\n print_products_ASCII\n print_brands_ASCII\n end", "def report_load\n self.report('load_report')\n end", "def mreport\r\n\t\tsystem (\"clear\")\r\n\t\tputs \"#@name\" + \" the \" + \"#@type \" + \"approaches!!\"\r\n\t\tputs \" \"\r\n\t\tputs \"#@name\" + \" has \" + \"#@health \" + \"health\"\r\n\t\tputs \" \"\r\n\t\tsleep 2\r\n\tend", "def logReport\n @log.write( \"\\n\\n\\nFilter\\t\\t\\t\\t\\t\\t\\t\\t #{FILTER_NAME}\" + \"\\n________________________________________________________\\n\")\n @log.write( \"File name:\\t\\t\\t\\t\\t\\t\\t\" + QRY_FILE + \"\\n\")\n @log.write( \"Size: \\t\\t\\t\\t\\t\\t\\t\\t\" + File.stat(QRY_FILE).size.to_s + \" bytes\\n\")\n @log.write( \"Started:\\t\\t\\t\\t\\t\\t\\t\" + started_at.to_s + \"\\n\")\n @log.write( \"Completed:\\t\\t\\t\\t\\t\\t\\t\" + @completed_at.to_s + \"\\n\") \n @log.write( \"Input file count: \\t\\t\\t\\t\\t\" + \"%d\" % lines + \"\\n\")\n @log.write( \"Total seconds\\t\\t\\t\\t\\t\\t\" + \"%.3f\" % (completed_at - @started_at).to_f + \"\\n\" )\n @log.write( \"Average records per second:\\t\\t\\t\" + \"%.3f\" % (lines/(completed_at - started_at)).to_f + \"\\n\" )\n @log.write( \"__END__\\n\")\n @log.write( \"(c) Copyright 2009 VenueSoftware Corp. All Rights Reserved. \\n\")\n @log.close\n\n #\n # Report the results recorded in log.txt\n # \n puts \"\\n\"\n File.open(\"log.txt\", \"r\") do |f|\n while line = f.gets\n puts line\n end\n end\n Kernel.exit\nend", "def data_report(options={})\n puts \"\\n\\n\"\n puts \"**********************************\\n\"\n puts \"**********************************\"\n puts @last_log\nend", "def process\n profile(\"report#process\", [:puppetdb, :report, :process]) do\n current_time = Time.now\n submit_command(self.host, CommandStoreReport, 8, current_time.utc) do\n report_to_hash(current_time)\n end\n end\n\n nil\n end", "def report\n # Iterate over each qotd record and check if it is present verbatim\n # in the corresponding content AT file.\n discrepancies = []\n @qotd_records.each { |qotd_record|\n date_code = qotd_record[:title].downcase\n puts \" - processing #{ date_code }\"\n sanitized_qotd_content = sanitize_qotd_content(qotd_record[:contents])\n corresponding_content_at_file = RFile::ContentAt.find_by_date_code(\n date_code,\n \"at\",\n @content_type\n )\n\n if corresponding_content_at_file.nil?\n raise ArgumentError.new(\"Could not find content AT file for #{ date_code }\")\n end\n\n sanitized_content_at_plain_text = sanitize_content_at_plain_text(\n corresponding_content_at_file.plain_text_with_subtitles_contents({})\n )\n\n find_diffs_between_qotd_and_content_at(\n date_code,\n qotd_record[:publishdate],\n sanitized_qotd_content,\n sanitized_content_at_plain_text,\n discrepancies\n )\n }\n assign_discrepancy_types(discrepancies)\n discrepancies\n end", "def create_global_report\n super\n end", "def mreport\r\n\t\tsystem (\"clear\")\r\n\t\tputs \"#@name\" + \" the \" + \"#@type \" + \"approaches!!\"\r\n\t\tputs \" \"\r\n\t\tputs \"#@name\" + \" has \" + \"#@health \" + \"health\"\r\n\t\tputs \" \"\r\n\t\tsleep 1\r\n\t\treturn\r\n\tend", "def print_final_report\n puts; puts; puts \"=== FINAL DATABASE COUNTS ===\"\n puts; puts end_of_task_report\n puts; puts; puts \"=== BY SCHOOL ===\"\n puts by_school_report\n puts; AssessmentsReport.new.print_report\n end", "def emp_report\n \n end", "def show_using_sqls_historic\n save_session_time_selection # Werte puffern fuer spaetere Wiederverwendung\n @instance = prepare_param_instance\n @dbid = prepare_param_dbid\n @object_owner = params[:ObjectOwner]\n @object_owner = nil if @object_owner == \"\"\n @object_name = params[:ObjectName]\n update_area = params[:update_area]\n\n where_filter = \"\"\n where_values = []\n if @instance\n where_filter << \" AND s.Instance_Number = ?\"\n where_values << @instance\n end\n if @object_owner\n where_filter << \" AND p.Object_Owner=UPPER(?)\"\n where_values << @object_owner\n end\n\n @sqls = sql_select_all [\"\nSELECT /* Panorama-Tool Ramm */\n (SELECT TO_CHAR(SUBSTR(SQL_Text,1,100)) FROM DBA_Hist_SQLText t WHERE t.DBID=sql.DBID AND t.SQL_ID=sql.SQL_ID) SQL_Text,\n sql.*\nFROM (\n SELECT p.DBID, p.SQL_ID, s.Instance_Number, Parsing_Schema_Name, p.Operation, p.Options, p.Other_Tag,\n MIN(snap.Begin_Interval_Time) First_Occurrence,\n MAX(snap.End_Interval_Time) Last_Occurrence,\n SUM(Executions_Delta) Executions,\n SUM(Fetches_Delta) Fetches,\n SUM(Elapsed_Time_Delta)/1000000 Elapsed_Time_Secs,\n (SUM(ELAPSED_TIME_Delta)/1000000) / DECODE(SUM(EXECUTIONS_Delta), 0, 1, SUM(EXECUTIONS_Delta)) ELAPSED_TIME_SECS_PER_EXECUTE,\n SUM(CPU_Time_Delta)/1000000 CPU_Time_Secs,\n SUM(Disk_Reads_Delta) Disk_Reads,\n SUM(DISK_READS_delta) / DECODE(SUM(EXECUTIONS_Delta), 0, 1, SUM(EXECUTIONS_Delta)) DISK_READS_PER_EXECUTE,\n SUM(Buffer_Gets_Delta) Buffer_Gets,\n SUM(BUFFER_GETS_delta) / DECODE(SUM(EXECUTIONS_Delta), 0, 1, SUM(EXECUTIONS_delta)) BUFFER_GETS_PER_EXEC,\n SUM(Rows_Processed_Delta) Rows_Processed,\n SUM(Rows_Processed_Delta) / DECODE(SUM(EXECUTIONS_Delta), 0, 1, SUM(EXECUTIONS_Delta)) Rows_Processed_PER_EXECUTE,\n SUM(Parse_Calls_Delta) Parse_Calls,\n MIN(s.Snap_ID) Min_Snap_ID,\n MAX(s.Snap_ID) Max_Snap_ID\n FROM DBA_Hist_SQL_Plan p\n JOIN DBA_Hist_SQLStat s ON s.DBID = p.DBID AND s.SQL_ID = p.SQL_ID AND s.Plan_Hash_Value = p.Plan_Hash_Value\n JOIN DBA_Hist_Snapshot snap ON snap.DBID = s.DBID AND snap.Instance_Number = s.Instance_Number AND snap.Snap_ID = s.Snap_ID\n JOIN (\n SELECT /*+ NO_MERGE*/ DBID, Instance_Number,\n MAX(CASE WHEN Begin_Interval_time <= TO_TIMESTAMP(?, '#{sql_datetime_minute_mask}') THEN Snap_ID ELSE NULL END) StartMin, -- Normaler Start-Schnappschuss\n MIN(CASE WHEN Begin_Interval_time >= TO_TIMESTAMP(?, '#{sql_datetime_minute_mask}') THEN Snap_ID ELSE NULL END) StartMax, -- alternativer Start-Schnappschuss wenn StartMin=NULL\n MAX(CASE WHEN End_Interval_time <= TO_TIMESTAMP(?, '#{sql_datetime_minute_mask}') THEN Snap_ID ELSE NULL END) EndMin, -- alternativer End-Schnappschuss, wenn EndMin=NULL\n MIN(CASE WHEN End_Interval_time >= TO_TIMESTAMP(?, '#{sql_datetime_minute_mask}') THEN Snap_ID ELSE NULL END) EndMax -- Normaler End-Schnappschuss\n FROM DBA_Hist_Snapshot\n WHERE DBID = ?\n GROUP BY Instance_Number, DBID\n ) snap_limit ON snap_limit.DBID = s.DBID AND snap_limit.Instance_Number = s.Instance_Number\n WHERE p.Object_Name LIKE UPPER(?) #{where_filter}\n AND s.Snap_ID >= NVL(snap_limit.StartMin, snap_limit.StartMax)\n AND s.Snap_ID <= NVL(snap_limit.EndMax, snap_limit.EndMin)\n GROUP BY p.DBID, p.SQL_ID, s.Instance_Number, s.Parsing_Schema_Name, p.Operation, p.Options, p.Other_Tag\n ) sql\n ORDER BY sql.Elapsed_Time_Secs DESC\",\n @time_selection_start, @time_selection_start, @time_selection_end, @time_selection_end, @dbid, @object_name].concat(where_values)\n\n respond_to do |format|\n format.js {render :js => \"$('##{update_area}').html('#{j render_to_string :partial=>\"list_sql_area_historic\" }');\"}\n end\n end", "def action_daily\n # ToDo: Change the hard coded report to a Report setting, or client base\n raise 'Hard coded report implementation' unless RAILS_ENV =~ /susbkk/\n end", "def report_lister\n \"Name: #{@name}\\nGuest type: #{@type}\\nLinks: #{@link}\\nRooms booked: #{@rooms.size}\"\n # \"Report run on: \" + Time.now.to_s\n end", "def generate_report\n self.consume_stdin\n self.data_sorter\n\n @drivers.each do |driver|\n driver.total_duration\n driver.distance_calculator\n driver.average_speed\n end\n\n self.compile_report\n end", "def reports(wspace=framework.db.workspace)\n ::ApplicationRecord.connection_pool.with_connection {\n wspace.reports\n }\n end", "def generate_query(*args) #generate_query starts here\n begin\n @tablename=args[0].split('-')[0]\n @duration=args[0].split('-')[1]\n @report_type=args[1] \n @column1=args[2]\n @column2=args[3]\n @startdate=args[4]\n @enddate=args[5]\n @order=args[6]\n @limit=args[7]\n @column3=args[8]\n @page=(args[9]!=nil) ? args[9] : 0\n #~ @start_year= Time.parse(@startdate).strftime(\"%Y-%m-%d\").split('-')[0] if @startdate!=nil #selects only year\n #~ @start_day=Time.parse(@startdate).strftime(\"%Y-%m-%d\").split('-')[2] if @startdate!=nil#selects only day\n #~ @start_month=Time.parse(@startdate).strftime(\"%Y-%m-%d\").split('-')[1] if @startdate!=nil\n #~ @end_year=Time.parse(@enddate).strftime(\"%Y-%m-%d\").split('-')[0] if @enddate!=nil\n #~ @end_month=Time.parse(@enddate).strftime(\"%Y-%m-%d\").split('-')[1] if @enddate!=nil\n #~ @end_day=Time.parse(@enddate).strftime(\"%Y-%m-%d\").split('-')[2] if @enddate!=nil\n #~ @ctr=\"((sum(clicks)/sum(impressions))*100)\"#if @report_type!=\"Overall_Performance\"\n #~ @ecpm='((sum(revenue)/sum(impressions))*1000)'\n #~ customize_column= @column3=='campaign_name' ? 'c.campaign_name' : @column3=='pub_name' ? 'p.publisher_name' : @column3=='advertiser_name' ? 'a.name' : ''\n #~ customize_table=@column3=='campaign_name' ? 'campaigns_summaries cs, campaigns c' : @column3=='pub_name' ? 'adclients_summaries ad,publishers p' : @column3=='advertiser_name' ? 'campaigns_summaries cs,advertisers a' : ''\n #~ customize_condition=@column3=='campaign_name' ? 'c.id=cs.campaign_id' : @column3=='pub_name' ? 'p.id=ad.pub_id' : @column3=='advertiser_name' ? 'a.id=cs.advertiser_id' : ''\n #~ customize_filter=@column3=='campaign_name' ? 'and (cs.impressions>0 or cs.clicks>0)' : @column3=='pub_name' ? 'and (ad.impressions>0 or ad.clicks>0)' : @column3=='advertiser_name' ? 'and (cs.impressions>0 or cs.clicks>0)' : ''\n #~ begin\n #~ # ---- Query Builder ----\n #~ sub_query=\"select count(*) as count from #{@tablename}\"\n #~ sub_query+=\" where delivery_date>='#{(Time.parse(@startdate)).strftime(\"%Y-%m-%d\")} 00:00:00' and delivery_date<='#{(Time.parse(@enddate)).strftime(\"%Y-%m-%d\")} 23:59:59'\" \n #~ #sub_query+=\"and #{@column1}!='ip' and #{@column1}!=''\"\n #~ obj=@column3=='pub_name' ? 'ad.' :'cs.' \n #~ sql_query =\"select #{customize_column} as #{@column3} , (#{(@column2=='ctr') ? @ctr : @column2=='ecpm' ? @ecpm : \"sum(#{obj}#{@column2})\"}) as #{@column2=='amount_spent' ? 'amt_spent' :@column2} from #{customize_table}\" \n #~ sql_query+=\" where delivery_date>='#{(Time.parse(@startdate)).strftime(\"%Y-%m-%d\")} 00:00:00' and delivery_date<='#{(Time.parse(@enddate)).strftime(\"%Y-%m-%d\")} 23:59:59' and #{customize_condition} #{customize_filter}\" \n #~ sql_query+=\" group by #{@column1} order by #{@column2=='amount_spent' ? 'amt_spent' :@column2} #{@order} limit #{@limit} offset #{@page}\" if @report_type!=\"Overall_Performance\"\n #~ sql_query+=\" group by #{@column1} order by #{@column2=='amount_spent' ? 'amt_spent' :@column2} #{@order} \" if @report_type==\"Overall_Performance\"\n #~ #following code is used to calculate modulas value if applicable\n #~ @add_month=0\n #~ @no_day=(@end_day.to_i-@start_day.to_i)+1\n #~ if @end_year.to_i!=@start_year.to_i\n #~ @add_month=@end_month.to_i+12\n #~ @add_month=@add_month.to_i-@start_month.to_i\n #~ @no_day+=(@add_month*30)\n #~ elsif @end_month.to_i>@start_month.to_i\n #~ @add_month=@end_month.to_i-@start_month.to_i\n #~ @no_day+=(@add_month*30)\n #~ end\n #~ @modulas=@no_day/30\n #~ @XML_xaxis='days'\n #~ @@date_count=Time.parse(@startdate)\n #~ rescue Exception=>e\n #~ puts \"DEBUGGER :: Error:: in admin_xml_builder.rb - generate_query ::#{e.to_s}\"\n #~ end\n @XML_xaxis='days'\n begin\n #~ @tablename=AdminCampaignWiseReport.show_data() #convert the string into model name\n #~ @[email protected] #convert the string into model name\n #~ @[email protected]_by_sql(sql_query) # fetch the recordset from table\n @recordset=AdminCampaignWiseReport.top_campaigns_performance(@order,@startdate,@enddate) # fetch the recordset from table\n rescue Exception=>e\n puts \"DEBUGGER :: ERROR :: in admin_xml_builder.rb - generate_query :: #{e.to_s}\"\n end\n @anchor_color=\"anchorBgColor='FF0000'\"\n count=0\n othersValue=0.00\n if @recordset.size !=0 #main If conditons starts here\n for recordset in @recordset \n #Check whether publisher request click or impression or revenuereport\n i=1\n if args[3]!='imp vs clicks'\n #~ puts \"-------------check 1---------\"\n #~ generate_mutil_linechartXML(recordset.impressions,recordset.clicks,recordset.delivery_date,@startdate,@enddate,'Impression Vs Clicks',@no_day,@duration) \n #~ else\n count+=1\n if (count.to_i<[email protected]_i)\n #~ puts \"-------------check 2----#{@report_type}-----\"\n generate_piechartXML(recordset[@column3],recordset[@column2]) \n else\n othersValue+=recordset[@column2].to_f\n if (@recordset.size.to_i==count.to_i)\n generate_piechartXML('Others',othersValue)\n end\n end\n i+=1\n end\n end #for loop ends here\n\n #to insert xml datas for which recordset are not available\n #~ if @report_type=='admin_campaign_wise_reports' and args[3].to_s!='imp vs clicks'\n #~ puts \"-------------check 3---------\"\n #~ if Time.parse(@enddate)>@@date_count\n #~ while Time.parse(@enddate)>=@@date_count\n #~ delivery_day=@@date_count.strftime(\"%Y-%m-%d\").split('-')[2] #will return day\n #~ if Time.parse(@enddate)==@@date_count\n #~ @@strXML+= \"<set name='#{@@date_count.strftime(\"%d-%b-%Y\")}' value='0' #{@anchor_color if @duration.to_i==1}/>\" \n #~ elsif delivery_day.to_i%@modulas==0 \n #~ @@strXML+= \"<set name='#{@@date_count.strftime(\"%d-%b-%Y\")}' value='0'/>\"\n #~ end\n #~ @@date_count+=86400\n #~ end\n #~ elsif Time.parse(@enddate)==@@date_count\n #~ @@strXML+= \"<set name='#{@@date_count.strftime(\"%d-%b-%Y\")}' value='0' #{@anchor_color if @duration.to_i==1}/>\" \n #~ end\n #~ @@strXML+=\"<styles><definition><style name='myLabelsFont' type='font' font='Arial' size='12' color='000000' bold='1'/></definition><application><apply toObject='DataLabels' styles='myLabelsFont' /></application></styles>\"\n #~ #to insert xml datas for impression vs click if recordsets are not available for specified date\n #~ elsif @report_type=='admin_campaign_wise_reports' && args[3].to_s=='imp vs clicks'\n #~ puts \"-------------check 1-1--------\"\n #~ if Time.parse(@enddate)>@@date_count\n #~ while Time.parse(@enddate)>=@@date_count\n #~ delivery_day=@@date_count.strftime(\"%Y-%m-%d\").split('-')[2] #will return day\n #~ if Time.parse(@enddate)==@@date_count \n #~ @@strXML+= \"<set value='0' #{@anchor_color if @duration.to_i==1}/>\"\n #~ @@cat_strXML+=\"<category label='#{@@date_count.strftime(\"%d-%b-%Y\")}'/>\"\n #~ @@multi_strXML+=\"<set value='0' #{@anchor_color if @duration.to_i==1}/>\"\n #~ elsif delivery_day.to_i%@modulas==0\n #~ @@strXML+= \"<set value='0'/>\"\n #~ @@cat_strXML+=\"<category label='#{@@date_count.strftime(\"%d-%b-%Y\")}'/>\"\n #~ @@multi_strXML+=\"<set value='0'/>\"\n #~ end\n #~ @@date_count+=86400\n #~ end\n #~ elsif Time.parse(@enddate)==@@date_count\n #~ puts \"-------------check 1--2-------\"\n #~ @@strXML+= \"<set value='0'/ #{@anchor_color if @duration.to_i==1}>\"\n #~ @@cat_strXML+=\"<category label='#{@@date_count.strftime(\"%d-%b-%Y\")}'/>\"\n #~ @@multi_strXML+=\"<set value='0'/ #{@anchor_color if @duration.to_i==1}>\"\n #~ end\n #~ @@multi_strXML+=\"</dataset>\"\n #~ @@cat_strXML+=\"</categories>\"\n #~ @@strXML+=\"</dataset>\"\n #~ @@strXML+=@@cat_strXML\n #~ @@strXML+=@@multi_strXML\n #~ p @@strXML+=\"<styles><definition><style name='myLabelsFont' type='font' font='Arial' size='12' color='000000' bold='1'/></definition><application><apply toObject='DataLabels' styles='myLabelsFont' /></application></styles>\"\n #~ end\n #~ if @report_type=='Traffic'\n #~ @@strXML+=\"</data>\"\n #~ @@strXML+=\"<colorRange><color minValue='0' maxValue='#{(@@date_count-1).to_s}' displayValue='Low' color='F0FFE8' /><color minValue='#{(@@date_count.to_i-1).to_s}' maxValue='#{(@@date_count.to_i+1).to_s}' displayValue='High' color='009900' /></colorRange></map>\"\n #~ end\n #~ if @report_type=='Ad_Wise' and args[5]=='imp vs clicks'\n #~ puts \"-------------check 12---------\"\n #~ @@multi_strXML+=\"</dataset>\"\n #~ @@cat_strXML+=\"</categories>\"\n #~ @@strXML+=\"</dataset>\"\n #~ @@strXML+=@@cat_strXML\n #~ @@strXML+=@@multi_strXML\n #~ @@strXML+=\"<styles><definition><style name='myLabelsFont' type='font' font='Arial' size='12' color='000000' bold='1'/></definition><application><apply toObject='DataLabels' styles='myLabelsFont' /></application></styles>\"\n #~ end\n #~ if @report_type=='Traffic_Continent'\n #~ puts \"-------------check 14---------\"\n #~ @@strXML+='</data>'\n #~ @@strXML+=\"<colorRange><color minValue='0' maxValue='#{(@@date_count-1).to_s}' displayValue='Low' color='F0FFE8' /><color minValue='#{(@@date_count.to_i-1).to_s}' maxValue='#{(@@date_count.to_i+1).to_s}' displayValue='High' color='009900' /></colorRange></map>\"\n #~ end\n #~ if @report_type=='Keyword'\n #~ puts \"-------------check 1-6--------\"\n #~ @@strXML+=\"<styles><definition><style name='myValuesFont' type='font' size='16' color='000000' bold='1' font='Arial, Helvetica, sans-serif' /></definition><application><apply toObject='DataLabels' styles='myValuesFont' /></application></styles>\"\n #~ end\n @@strXML = @@strXML + \"</chart>\" \n end #main If ends here\n #reinitialize flag, str variable and counters to construct next chart\n @@flag=true \n #~ @@xml_count=0\n #~ @@date_count=0\n @@color_count=0 \n @@mod=0\n @returnstrXML=@@strXML\n @@strXML='' \n @@cat_strXML=''\n @@multi_strXML=''\n @@xml_hash=nil\n @@xml_hash={:xml_string=>@returnstrXML }\n return @@xml_hash\n rescue Exception=>e\n puts \"DEBUGGER :: ERROR :: in admin_xml_builder under generate_query method. The error is #{e.to_s}\"\n end\n end", "def create_new_report!; end", "def create_new_report!; end", "def report_body; end", "def report_body; end", "def report\n @report || @schedule\n end", "def report\n @logger\n end", "def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"count_of_table_sid_by_field_sid\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = AccessReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end", "def prepare_report_object_hook\n # Nothing in base method\n end", "def reporting_mode\n process_commands!(REPORTING)\n end", "def info_sql\n INFO_SQL\n end", "def report_title\n \"\\n\\e[4mMinitest Reporters: Mean Time Report\\e[24m \" \\\n \"(Samples: #{samples}, Order: #{sort_column.inspect} \" \\\n \"#{order.inspect})\\n\"\n end", "def output_report\n\t\toutput_start\n\t\toutput_head\n\t\toutput_body_start\n\t\toutput_body\n\t\toutput_body_end\n\t\toutput_end\n\tend", "def init_report\n raise if @report.new_record?\n \n # if not a new record, run it and record viewing\n @report.record_viewing\n \n return run_and_handle_errors\n end", "def print_report\n sum = 0.0\n puts \"\\nSummary:\"\n puts '-'*8\n @days.each do |day|\n puts \"#{day[:day].strftime(\"%m/%d/%y\")}, %.2f hours\" % day[:hours]\n sum += day[:hours]\n end\n puts \"\\nTotal hours = %.2f\" % sum\n days = elapsed_days(@days[0][:day])\n puts \"Elapsed days = %d\" % days\n puts \"Average hrs per week = %.2f\" % (sum / (days / 7.0))\n puts\n end", "def reporters=(_arg0); end", "def reporters=(_arg0); end", "def reporters=(_arg0); end", "def default_report_settings!\n\n #set up default values\n self.network_perf = true\n self.network_perf = true\n self.route_perf_t = true\n self.route_tt_t = true\n self.route_perf_c = true\n self.route_tt_c = true\n self.duration = 86400\n\n #These are used for ScaterPlots and ScatterGroups in \n #report generator. Will add when we get there.\n #@simulation_batches = Array.new\n #@scenarios = Array.new\n # begin\n # params[:sim_ids].each do |s|\n # sb = SimulationBatch.find_by_id(s)\n # @simulation_batches.push(sb)\n # @scenarios.push(Scenario.find_by_id(sb.scenario_id))\n # end\n # rescue NoMethodError\n # \n # end\n\n end", "def report_moab_jobs\n self.report('moab_jobs_report')\n end", "def report_params\n end", "def report\n @report ||= \"#{RESULTS_DIR}/#{GROUP_NAME}-#{Time.now.strftime \"%d-%m-%Y-%H%M\"}.yaml\"\nend", "def execute\n puts @robot.report\n end", "def report\n\t\t dir = \"./report/\"\n File.open(dir + \"method.mmd\", \"w\") do |f|\n f.puts \"# Methods #\"\n Dir[\"./experiments/*/*.rb\"].each do |desc|\n if File.basename(desc) == File.basename(File.dirname(desc)) + \".rb\"\n File.read(desc).split(\"\\n\").each do |line|\n if m = line.match(/^\\# (.+)/)\n f.puts m[1]\n else\n break\n end\n end\n f.puts\n f.puts\n end\n end\n end\n require 'csv'\n require \"yaml\"\n require File.dirname(__FILE__) + \"/stats\"\n CSV.open(dir + \"/data.csv\", \"w\") do |csv|\n data = {}\n Dir[\"./results/*/results.yaml\"].each do |res|\n d = YAML::load_file(res)\n da = {}\n d.each do |k, vals|\n da[k.to_s + \" mean\"], da[k.to_s + \" sd\"] = Stats::mean(vals), Stats::standard_deviation(vals)\n vals.each_with_index do |v, i|\n da[k.to_s + \" cv:\" + i.to_s] = v\n end\n end\n array_merge(data, da)\n end\n data.keys.map do |key| \n \t\t # calculate stats\n \t\t a = data[key]\n \t\t [key] + a\n \t\t end.transpose.each do |row|\n \t\t csv << row\n \t\t end\n end\n\t\t\n\t\tend", "def reports_path; end", "def reports_path; end", "def report_time time\n end", "def quick_stats\n\tend", "def setup_summary_report\n assign_to_from_dates\n @filter = @filter.remove_blanks_in_arrays\n @filter_name = @filter[:name]\n assign_grouping_type\n assign_facilities\n end", "def statistics; end", "def report( display_object = Kernel, display_method = :puts )\n return if display_method.nil? || !display_object.respond_to?( display_method )\n\n if processed_rows + errors_count > 0\n if edited_rows_count > 0\n display_object.send( display_method, \"\\r\\n--- UPDATED Meetings in calendar: #{ edited_rows_count }\" )\n @edited_rows_codes.each do |meeting_code|\n display_object.send( display_method, \"- #{ meeting_code }\" )\n end\n end\n if created_rows_count > 0\n display_object.send( display_method, \"\\r\\n--- CREATED Meetings in calendar: #{ created_rows_count }\" )\n @created_rows_codes.each do |meeting_code|\n display_object.send( display_method, \"- #{ meeting_code }\" )\n end\n end\n if errors_count > 0\n display_object.send( display_method, \"\\r\\n--- Tot. ERRORS during calendar processing: #{ errors_count }\" )\n @error_rows_codes.each do |meeting_code|\n display_object.send( display_method, \"- #{ meeting_code }\" )\n end\n end\n end\n end", "def report\nputs \"Im #{@name}, I've delivered #{quota}\"\nend", "def report\n filtered = apply_filter(self.relation)\n\n count = self.count(filtered) if @q.select.count?\n\n list = if @q.select.list?\n self.list(filtered)\n else\n []\n end\n\n calculations = self.calculations(filtered)\n Listing::Report.new(\n @q.options,\n list,\n calculations,\n count\n )\n end", "def details\n p '===== details ====='\n p \"Main TABLE: #{@main_t}\"\n p \"MAX_FREQUENCY_METRIX\"\n p @cache_mfx_table\n '===== details ====='\n end", "def raw_report\n return unless has_permission :can_do_billing\n @page_title = 'Generate Raw Data Report'\n @from = Time.now.beginning_of_month\n @to = @from.next_month\nend", "def reporter(name); end", "def report\n puts current_location\n end", "def snapshots_redact_sql_queries; end", "def reports(wspace=workspace)\n\t\twspace.reports\n\tend", "def create_report\n\tcreate_rep_heading\n \tcreate_product_data\n \tcreate_brand_data\nend", "def run\n schedule_data_reports\n end", "def report_list(_)\n report_templates = ReportPrivate.all_report_templates(@path_to)\n report_templates = yield(report_templates) if block_given?\n @console.info self, ReportPrivate.table(report_templates)\n end", "def diagnostics; end", "def diagnostics; end", "def diagnostics; end", "def diagnostics; end", "def report_start\n @report= \"Kampfbericht: \\n \\n Angreifer: #{self.attacker.username} Verteidiger: #{self.defender.username} \\n \\n \"\n end", "def report_data(name, email)\n\n @greeting = \"Hello!\"\n @assembly = Assembly.find_by_name(name)\n @hits=Hit.where(subject: Gene.where(sequence: Sequence.where(assembly: @assembly))).order(percent_similarity: :desc)\n @report=CSV.open(\"your-super-report.csv\", \"w+\") do |csv|\n csv << [\"Assembly Name\", \"Assembly Date,\" \"Sequence\", \"Sequence Quality\", \"Gene Sequence\", \"Gene Starting Position\", \"Gene Direction\", \"Hit Name\", \"Hit Sequence\", \"Hit Similarity\"]\n @hits.each do |h|\n csv << h.match_gene_name, h.match_gene_dna.first(100), h.percent_similarity\n end\n end\n\n mail to: email, subject: \"Your Report\", from: \"[email protected]\"\n\n end\nend", "def plsc_report\n #Initial coding done by John Evans this will return 4 columns from the User table\n @data = User.find(:all , :select => \"id as id, name as name, c_type as type, zipcode as zipcode\", :group => \"id\")\n end", "def report_data\n ReportMailer.report_data\n end", "def report( opts )\n\tdb = PG.connect(\n\t\t:dbname => opts.database,\n\t\t:host => opts.host,\n\t\t:port => opts.port,\n\t\t:user => opts.user,\n\t\t:password => opts.pass,\n\t\t:sslmode => 'prefer'\n\t)\n\n\t# -----------------------------------------\n\n\tdb_info = db.exec %Q{\n\t\tSELECT\n\t\t\tcount(oid) AS num_relations,\n\t\t\tpg_size_pretty(pg_database_size('#{opts.database}')) AS dbsize\n\t\tFROM\n\t\t\tpg_class\n\t}\n\n\tputs '=' * 70\n\tputs \"Disk usage information for %s: (%d relations, %s total)\" % [\n\t\topts.database,\n\t\tdb_info[0]['num_relations'],\n\t\tdb_info[0]['dbsize']\n\t]\n\tputs '=' * 70\n\n\t# -----------------------------------------\n\n\ttop_twenty = db.exec %q{\n\t\tSELECT\n\t\t\trelname AS name,\n\t\t\trelkind AS kind,\n\t\t\tpg_size_pretty(pg_relation_size(pg_class.oid)) AS size\n\t\tFROM\n\t\t\tpg_class\n\t\tORDER BY\n\t\t\tpg_relation_size(pg_class.oid) DESC\n\t\tLIMIT 20\n\t}\n\n\tputs 'Top twenty objects by size:'\n\tputs '-' * 70\n\ttop_twenty.each do |row|\n\t\ttype = case row['kind']\n\t\t\t when 'i'; 'index'\n\t\t\t when 't'; 'toast'\n\t\t\t when 'r'; 'table'\n\t\t\t when 'S'; 'sequence'\n\t\t\t else; '???'\n\t\t\t end\n\n\t\tputs \"%40s %10s (%s)\" % [ row['name'], row['size'], type ]\n\tend\n\tputs '-' * 70\n\n\t# -----------------------------------------\n\n\tschema_sizes = db.exec %q{\n\t\tSELECT\n\t\t\ttable_schema,\n\t\t\tpg_size_pretty( CAST( SUM(pg_total_relation_size(table_schema || '.' || table_name)) AS bigint)) AS size\n\t\tFROM\n\t\t\tinformation_schema.tables\n\t\tGROUP BY\n\t\t\ttable_schema\n\t\tORDER BY\n\t\t\tCAST( SUM(pg_total_relation_size(table_schema || '.' || table_name)) AS bigint ) DESC\n\t}\n\n\n\tputs 'Size per schema:'\n\tputs '-' * 70\n\tschema_sizes.each do |row|\n\t\tputs \"%20s %10s\" % [ row['table_schema'], row['size'] ]\n\tend\n\tputs '-' * 70\n\tputs\n\n\tdb.finish\nend", "def build_report_body\n #@output << erb(RAILS_ROOT + \"/app/views/reports/_users.html.erb\") \n pad(10) do\n add_text usernotes\n end\n if timespan == \"Daily\" \n add_text \"Current Tasks and Tasks Modified in the last Day\"\n elsif timespan == \"Weekly\"\n add_text \"Current Tasks and Tasks Modified in the last Week\"\n else\n add_text \"Current Tasks\"\n end\n pad(10) do\n draw_table(data, :width => 600)\n end\n if timespan == \"Daily\" \n add_text \"Current Goals and Goals Modified in the last Day\"\n elsif timespan == \"Weekly\"\n add_text \"Current Goals and Goals Modified in the last Week\"\n else\n add_text \"Current Goals\"\n end\n pad(10) do\n draw_table(goaldata, :width => 600)\n end\n end", "def fetch_reports\n # fetch all the reports using this method and then create a Report for each of them\n end", "def name()\n raise \"No name() function defined by report subclass\"\n end", "def print_stats\n puts \"==================================================\"\n puts \"================= Statistics =====================\"\n puts \"==================================================\"\n \n calc_stats()\n \n puts \"Total Records = #{@total_rec_cnt}\"\n puts \"Well Formed Records = #{@well_formed_rec_cnt}\"\n puts \"Malformed Records = #{@malformed_rec_cnt}\"\n puts \"Unique Business Records = #{@biz_rec_cnt}\"\n puts \"Unique User Records = #{@user_rec_cnt}\"\n puts \"\"\n end", "def reports_collection\n report_tables = select_tables(REPORT_TITLE)\n\n report_tables.map do |report_table|\n report_builder(report_table)\n end\n end", "def auto_analyze; end", "def reports\n backend.reports\n end", "def run\n puts \"Called with time of #{Time.now.strftime(\"%m/%d/%Y %H:%M:%S %P\")}\"\n update_accounts \n create_statements \n create_coverge\n create_freight_benefit_records \nend", "def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = BgWorkerReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end", "def report_definition\n\t\treport_def = {\n\t\t\tname: {difficulty: 40, approximator: \"none\", field_name:\"name\", max_datum:nil},\n\t\t\tdescription: {difficulty: 40, approximator:\"none\", field_name:\"description\", max_datum:nil},\n\t\t\tis_church: {difficulty: 40, approximiator:\"none\", field_name:\"is_church\", max_datum:nil},\n\t\t\tis_kingdom: {difficulty: 40, approximiator:\"none\", field_name:\"is_kingdom\", max_datum:nil},\n\t\t\tleader: {difficulty: 60, approximator:\"none\", field_name:\"leader_name\", max_datum:nil},\n\t\t\tsuzerain: {difficulty: 60, approximator:\"none\", field_name:\"suzerain_name\", max_datum:nil}\n\t\t}\t\t\t\n\tend", "def start\n setup_files\n create_report\nend", "def admin_report\n @current_teacher = current_teacher\n @school = School.find(@current_teacher.school_id)\n @students = Student.where(school_id: current_teacher.school_id).order('full_name ASC')\n @teachers = Teacher.where(school_id: current_teacher.school_id).order('full_name ASC')\n @squares = Square.where(school_id: current_teacher.school_id).order('full_name ASC')\n end", "def begin_report_app(app, report)\n shell.info \"Checking cached dependency records for #{app[\"name\"]}\"\n end", "def run_report(report)\n report.update! status: 'running'\n\n klass = report.name.constantize\n\n r = klass.new(report.parameters)\n if r.parameters_valid?\n record_set = r.query\n report_template = klass.template\n\n output = ApplicationController.new\n .render_to_string(template: report_template, formats: report.format,\n locals: { klass: klass, record_set: record_set,\n created_at: report.created_at })\n report.update! status: 'completed', output: output\n else\n report.update status: 'error'\n report.update status_message: r.error_message\n end\n end" ]
[ "0.69006", "0.6844597", "0.6844597", "0.6844597", "0.6844597", "0.6844597", "0.6657424", "0.6475766", "0.6475766", "0.6461063", "0.644856", "0.64197797", "0.63552904", "0.63552904", "0.63552904", "0.63552904", "0.63552904", "0.62652844", "0.62374854", "0.6209558", "0.6192845", "0.60981864", "0.6094764", "0.6063829", "0.6062836", "0.6060563", "0.6051151", "0.60164195", "0.60160786", "0.5992159", "0.5989928", "0.5979811", "0.59787726", "0.5952692", "0.5931231", "0.5881166", "0.58773893", "0.58773893", "0.5876116", "0.5876116", "0.5860618", "0.58582556", "0.58145154", "0.57341266", "0.57289076", "0.57258874", "0.572215", "0.5714441", "0.56980586", "0.56960464", "0.5693458", "0.5693458", "0.5693458", "0.5683853", "0.5677357", "0.5664851", "0.56558716", "0.56403905", "0.5637338", "0.5630889", "0.5630889", "0.56296474", "0.56295955", "0.5624009", "0.56211936", "0.5618004", "0.5615651", "0.56077677", "0.5600718", "0.5599635", "0.5597896", "0.55758536", "0.5573222", "0.55683786", "0.5565707", "0.55607253", "0.55591154", "0.5552129", "0.5552129", "0.5552129", "0.5552129", "0.5544215", "0.55399245", "0.5533578", "0.55294734", "0.55249417", "0.55158186", "0.5502144", "0.5487565", "0.5485113", "0.54726136", "0.54703736", "0.54661167", "0.546358", "0.546004", "0.54546773", "0.5453932", "0.5447027", "0.5445046", "0.5442121" ]
0.5475512
90
TODO: Refactor with chef_clone_repo method
def git_clone_repo(repo_path, repo = git.remote_git_repo, type = {'branch' => 'master'} , deep_clone = true) in_dir do pth = Pathname(repo_path).expand_path gritty = ::Grit::Git.new((pth + '.git').to_s) announce_or_puts gritty.inspect clone_opts = {:quiet => false, :verbose => true, :progress => true} clone_opts[:depth] = 1 unless deep_clone type['branch'] = type['branch'].nil? ? '' : type['branch'] type['tag'] = type['tag'].nil? ? '' : type['tag'] type['ref'] = type['ref'].nil? ? '' : type['ref'] if pth.directory? announce_or_puts "Pulling: #{repo} into #{pth}" FileUtils.cd(pth.to_s) do res = gritty.pull(clone_opts, repo) end clone_opts[:branch] = type['branch'].empty? ? 'master' : type['branch'] else clone_opts[:branch] = type['branch'].empty? ? 'master' : type['branch'] announce_or_puts "Cloning: #{repo} into #{pth}" res = gritty.clone(clone_opts, repo, pth.to_s) end clone_pull_error_check(res) if res grotty = ::Grit::Git.new((pth + '.git').to_s) grotty.checkout( { :B => clone_opts[:branch]||'master' } ) if !type['tag'].empty? || !type['ref'].empty? grotty.checkout( { :B => true }, 'cuken', type['tag']||type['ref'] ) else grotty.checkout( { :B => true }, 'cuken' ) end pth end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clone_repo(root, repo)\n begin \n destination = \"#{root}/#{repo[\"destination\"]}\"\n rm_rf destination\n sh \"git clone https://github.com/rethinkdb/#{repo[\"repo\"]}.git #{destination}\"\n cd destination\n sh \"git checkout #{repo[\"branch\"]}\"\n rescue Exception\n $stderr.puts \"Error while cloning #{repo[\"repo\"]}\"\n exit 1\n end\nend", "def clone_repository\n `cd #{client.config.tmp_folder} && git clone #{client.config.repository_url}.git`\n `cd #{client.config.tmp_folder}/#{client.config.repository_name} && git fetch origin #{client.config.ref_tree} && git reset --hard FETCH_HEAD`\n end", "def clone_repo\n Dir.chdir(@dir) do\n command = ['clone', @configuration.repository, '.']\n git!(command)\n end\n end", "def repo_clone(from_name, to_name)\n Dir.chdir(tmp_repos_path) { Pod::Executable.capture_command!('git', %W(clone #{from_name} -- #{to_name})) }\n repo_path(to_name)\n end", "def clone\n fetch\n with_temporary_dir do |scratch_repo_path|\n yield(Rugged::Repository.clone_at(repo_path, scratch_repo_path))\n end\n end", "def clone_git_repo(nr)\n checkout_path = ::File.join(Chef::Config[:file_cache_path], nr.gem_name)\n at_compile_time do\n git checkout_path do\n action :checkout\n repository nr.repository\n revision nr.revision\n end\n end\n checkout_path\n end", "def git_clone\n\n Rugged::Repository.clone_at git_url, root_path.to_s if git_url\n end", "def clone_repos(repos, shallow=true)\n repos.each do |repo|\n name = repo['name']\n subtitle \"Cloning #{name}\"\n url = repo['clone_url']\n if File.exist?(name)\n puts 'Already cloned'\n else\n if shallow\n system(\"git\", \"clone\", url, \"--depth\", \"1\", \"--recursive\")\n else\n system(\"git\", \"clone\", url)\n end\n end\n end\nend", "def git_clone_repo(host, git_clone_path, git_source)\n on(host, \"git clone #{git_source} #{git_clone_path}\")\nend", "def test_clone_repo\n clone_to_path = \"#{TEST_DATA_DIR}/clone.git\"\n \n assert_nothing_raised RuntimeError do\n Gitit.clone(@repo_path, clone_to_path)\n end\n \n assert(File.exist?(\"#{clone_to_path}/HEAD\"), \"Checking HEAD file exists at #{clone_to_path}\")\n \n cleanup_dir(clone_to_path)\n end", "def clone_bare_repo(repo_dir_base, repo_name, value, using_install)\n puts \"#{'***'.cyan} fetching #{repo_name.green.bold}\"\n repo_dir = \"#{repo_dir_base}/#{repo_name}.git\"\n\n # using tag or branch ?\n if value.repo_type == GitRepoType::TAG\n git_target_head = VersionHelper.identify(value.version)\n elsif value.repo_type == GitRepoType::BRANCH\n git_target_head = value.branch\n else\n raise 'no target branch or tag?'\n end\n\n # check current repo had been cloned or not.\n if File.exist? repo_dir\n\n # check current git repo's status\n if RepoHelper.is_status?(repo_dir, git_target_head)\n case value.repo_type\n when GitRepoType::TAG\n value.hash = RepoHelper.current_status(repo_dir)\n when GitRepoType::BRANCH\n value.hash = RepoHelper.current_hash(repo_dir)\n else\n raise 'no target branch or tag?'\n end\n\n return\n end\n else\n # clone\n puts \"#{'***'.cyan} Cloning #{repo_name.green.bold}\"\n RepoHelper.clone_bare(repo_dir_base, value.url, repo_name, using_install, PanConstants.disable_verbose)\n end\n\n RepoHelper.reset_repo_config(repo_dir_base, repo_name, value.url)\n\n # fetch the commit hash value by using branch name or tags\n if value.repo_type == GitRepoType::TAG\n commit_hash = RepoHelper.clone_with_tag(\n repo_name,\n git_target_head,\n repo_dir_base,\n value.compare_method,\n PanConstants.disable_verbose\n )\n\n elsif value.repo_type == GitRepoType::BRANCH\n commit_hash = RepoHelper.clone_with_branch(\n repo_name,\n git_target_head,\n repo_dir_base,\n using_install,\n PanConstants.disable_verbose\n )\n else\n raise \"unknown repo type #{value.repo_type}\"\n end\n\n raise \"unknown branch or tag or commit #{value} and commit hash:#{commit_hash}.\" if value.repo_type == GitRepoType::BRANCH && commit_hash.length != 40\n raise \"unknown branch or tag or commit #{value} and commit hash:#{commit_hash}.\" if value.repo_type == GitRepoType::TAG && commit_hash.empty?\n\n # save the commit's SHA1 hash.\n value.hash = commit_hash.strip.freeze\n\n # print \"#{'***'.cyan} Fetch #{name.green.bold} Done.\\n\\n\"\nend", "def clone\n require_dep! 'awesome_spawn'\n require_cmd! pkg_cmd\n\n clobber!\n Dir.mkdir path unless File.directory? path\n in_repo do\n result = AwesomeSpawn.run \"#{pkg_cmd} clone #{rpm_name}\"\n raise PolisherError,\n \"could not clone #{rpm_name}\" unless result.exit_status == 0\n\n # pkg_cmd will clone into the rpm_name subdir,\n # move everything up a dir\n Dir.foreach(\"#{rpm_name}/\") do |f|\n orig = \"#{rpm_name}/#{f}\"\n skip = ['.', '..'].include?(f)\n FileUtils.move orig, '.' unless skip\n end\n\n FileUtils.rm_rf rpm_name\n end\n\n self\n end", "def git_init_bare_repo_and_clone(host, git_repo_parent_path, git_repo_name, git_clone_path)\n origin_git_repo_path = git_init_bare_repo(host, git_repo_parent_path, git_repo_name)\n git_clone_repo(host, git_clone_path, origin_git_repo_path)\nend", "def subdir_clone( directory, name, git_repo )\n if not File.directory? \"#{directory}/#{name}\"\n FileUtils.mkdir_p directory\n sh \"git clone #{git_repo} '#{directory}/#{name}'\"\n end\nend", "def _clone_repository(project:, path:)\n if _has_ssh_key_setting?(project)\n _clone_with_setting_key(project: project, path: path)\n else\n _clone_with_system_key(project: project, path: path)\n end\n end", "def process_github_clones\n repos = get_github_repos_already_cloned\n repos.each do |r|\n # SMELL: does not work if the working copy directory does\n # not match the repo name\n clone_path = configatron.dir + r.name\n set_upstream(clone_path, r.parent.html_url)\n end\nend", "def clone_addon_repo(repoName, repoAddonURL, repoBlessedURL)\n self.log(INFO,repoName,\"Cloning : #{repoName} from #{repoAddonURL}...\")\n s = system(\"git clone --quiet #{repoAddonURL}\")\n if !s\n abort(\"[ERROR] Cloning of repository #{repoName} failed !!!\\n\")\n end\n self.log(INFO,repoName,\"Done.\")\n Dir.chdir repoName\n self.log(INFO,repoName,\"Add blessed repository #{repoBlessedURL} for #{repoName} ...\")\n s = system(\"git remote add blessed #{repoBlessedURL}\")\n if !s\n abort(\"[ERROR] Adding blessed remote of repository #{repoName} failed !!!\\n\")\n end\n self.log(INFO,repoName,\"Done.\")\n end", "def clone\n # We do the clone against the target repo using the `--reference` flag so\n # that doing a normal `git pull` on a directory will work.\n git \"clone --reference #{@cache.path} #{@remote} #{@full_path}\"\n git \"remote add cache #{@cache.path}\", :path => @full_path\n end", "def ensure_cloned(repository)\n RepositoryService.clone(repository)\n end", "def clone_repo(repo_name, username)\n ` git clone http://github.com/#{username}/#{repo_name}.git /tmp/#{repo_name} `\n end", "def clone_to(repo, destination)\n ::RightGit::Git::Repository.clone_to(repo, destination, DEFAULT_REPO_OPTIONS)\n true\n end", "def remote_clone\n raise CommandNotImplemented\n end", "def copy_repo(host, repo_filename, repo_name = 'simp_manual.repo')\n if File.exists?(repo_filename)\n puts('='*72)\n puts(\"Using repos defined in #{repo_filename}\")\n puts('='*72)\n scp_to(hosts, repo_filename, \"/etc/yum.repos.d/#{repo_name}\")\n else\n fail(\"File #{repo_filename} could not be found\")\n end\nend", "def git_clone(remote, dest)\n Dir.chdir(__dir__) do\n system \"git clone #{remote} #{dest}\"\n end\nend", "def clone_and_pull_repo\n FileUtils.mkdir(project_path, :mode => 0744) unless File.directory?(project_path)\n\n clone_project_repo unless File.directory?(project_repo_path)\n fetch_and_pull_trunk\n end", "def clone(user, repo, update = false)\n\n def spawn(cmd)\n proc = IO.popen(cmd, 'r')\n\n proc_out = Thread.new {\n while !proc.eof\n STDERR.puts \"#{proc.gets}\"\n end\n }\n\n proc_out.join\n end\n\n checkout_dir = File.join('cache', user, repo)\n\n begin\n repo = Rugged::Repository.new(checkout_dir)\n if update\n spawn(\"cd #{checkout_dir} && git pull\")\n end\n repo\n rescue\n spawn(\"git clone git://github.com/#{user}/#{repo}.git #{checkout_dir}\")\n Rugged::Repository.new(checkout_dir)\n end\n end", "def clone_repos repos\n $logger.info \"Detecting if clones repos #{repos}\"\n failed_repos = []\n repos.each do |repo|\n repo_path = \"#{GIT_DIR}/#{repo}\"\n # TODO: Use ssh instead of http\n clone_url = \"http://#{GIT_USER}:#{GIT_PASSWORD}@#{BASE_GIT_URL}:#{BASE_GIT_PORT}/scm/#{PROJECT_ID}/#{repo}.git\"\n unless `git --git-dir='#{repo_path}/.git' --work-tree='#{repo_path}' config --get remote.origin.url`.to_s.strip == clone_url\n $logger.info \"No git repo found or invalid git repo detected at #{repo_path}. Deleting and recloning project #{repo}\"\n # If for some reason we didn't detect that it's a git repo, just clear the whole directory\n # And reclone (note that we only need to clone the latest commit on the master branch)\n successfully_cloned = system \"git clone #{clone_url} --branch master --single-branch --depth 1 #{repo_path}\"\n unless successfully_cloned\n $logger.warn \"Could not git clone repo #{clone_url} to #{repo_path}\"\n failed_repos.push repo\n FileUtils.rm_rf repo_path\n end\n end\n # Make sure the git repos are unmodified before we do anything\n `git --git-dir='#{repo_path}/.git' --work-tree='#{repo_path}' reset --hard HEAD`\n end\n $logger.info \"Removing failed repos #{failed_repos}\"\n repos -= failed_repos\n return repos\nend", "def git_clone_main\n raise \"oops, not done\"\nend", "def test_git_clone_naming_assumptions\n in_temp_dir do |_path|\n setup_test_repositories\n\n GIT_CLONE_COMMANDS.each do |command_data|\n command = command_data[:command]\n expected_path = command_data[:expected_path]\n\n output = `#{command} 2>&1`\n\n assert_match(/Cloning into (?:bare repository )?'#{expected_path}'/, output)\n FileUtils.rm_rf(expected_path)\n end\n end\n end", "def clone(user, repo, update = false)\n\n def spawn(cmd)\n proc = IO.popen(cmd, 'r')\n\n proc_out = Thread.new {\n while !proc.eof\n logger.debug \"#{proc.gets}\"\n end\n }\n\n proc_out.join\n end\n\n checkout_dir = File.join(config(:cache_dir), \"repos\", user, repo)\n\n begin\n repo = Grit::Repo.new(checkout_dir)\n if update\n spawn(\"cd #{checkout_dir} && git pull\")\n end\n repo\n rescue\n spawn(\"git clone git://github.com/#{user}/#{repo}.git #{checkout_dir}\")\n Grit::Repo.new(checkout_dir)\n end\n end", "def initialize_client_clone_and_push(type, module_name, branch, repo_url, local_repo_dir, version=nil)\n # moved this part from 'check_local_dir_exists_with_content' to this method since this only deletes .git folder\n # which can cause us problems if import fails\n if File.directory?(\"#{local_repo_dir}/.git\")\n response = unlink_local_clone?(type,module_name,version)\n unless response.ok?\n # in case delete went wrong, we raise usage error\n raise DtkError.new(\"Directory (#{local_repo_dir} is set as a git repo; to continue it must be a non git repo; this can be handled by shell command 'rm -rf #{local_repo_dir}/.git'\")\n end\n # we return to normal flow, since .git dir is removed\n end\n\n Response.wrap_helper_actions() do\n ret = Hash.new\n repo_dir = local_repo_dir(type,module_name)\n\n repo = create(repo_dir,branch,:init => true, :no_initial_commit => true)\n repo.add_remote(remote(),repo_url)\n remote_branch = local_branch = branch\n\n repo.pull_remote_to_local(remote_branch,local_branch,remote())\n repo.stage_changes()\n repo.commit(\"Adding files during initialization\")\n repo.push_with_remote(remote(), remote_branch)\n\n commit_sha = repo.head_commit_sha()\n {\"repo_obj\" => repo,\"commit_sha\" => commit_sha}\n end\n end", "def git_clone(repo, config = {})\n config ||= {}\n destination = config[:destination] || File.basename(repo, '.git')\n\n destination = Pathname.new(destination) unless destination.is_a?(Pathname)\n FileUtils.mkdir_p destination.dirname\n\n if destination.directory?\n say_status :exist, destination.expand_path, :blue\n else\n say_status 'git clone',\n \"#{repo} to #{destination.expand_path}\",\n :green\n system \"git clone -q --config push.default=upstream --recursive #{repo} #{destination}\"\n end\n end", "def initial_path_setup\n repo_name = @repo.repo_name.gsub(/[.]+/, '-') || @repo.repo_name\n repo_path = Rails.root.join('storage', 'repos', @repo.username, @repo.supplier_project_id.to_s, repo_name)\n FileUtils.mkdir_p(repo_path) unless File.directory?(repo_path)\n Dir.chdir(repo_path)\n ActiveRecord::Base.connection_pool.with_connection do \n @repo.update(clone_path: repo_path)\n end\n end", "def local_clone\n raise CommandNotImplemented\n end", "def git_clone_latest(repo, dir)\n assert_system(\"git clone #{repo} #{dir}\") unless Dir.exist?(dir)\n Dir.chdir(dir) do\n assert_system('git pretty-pull')\n end\n end", "def clone\n\t\t did_clone = system \"git clone #{remote_path} projects/#{name}\"\n\t\t\tsystem \"cd projects/#{name} && git pull origin\" if !did_clone\n\t\tend", "def git_clone(name, repo_with_branch)\n repo, branch = repo_with_branch.split('#')\n dir = \"#{@dir}/#{name}\"\n\n sh \"git clone --depth 1 -b #{branch} https://github.com/#{repo}.git #{dir}\"\n end", "def clone_destination\n @clone_destination ||= Dir.mktmpdir('chef-steel-')\n end", "def clone_f2f_repo(tmpdir)\n repo_dir = File.join(tmpdir, \"f2f\")\n run! \"git\", \"clone\", repo_url, repo_dir\n repo_dir\n end", "def clone\n @cache.sync\n\n # We do the clone against the target repo using the `--reference` flag so\n # that doing a normal `git pull` on a directory will work.\n git [\"clone\", \"--reference\", @cache.git_dir, @remote, @full_path]\n git [\"remote\", \"add\", \"cache\", @cache.git_dir], :path => @full_path\n git ['fetch', 'cache'], :path => @full_path\n checkout(@ref)\n end", "def fetch_latest_code!\n `git clone --quiet #{Shellwords.escape(SOURCE_REPO)} .`\nend", "def setup_path\n if [email protected]_path.nil? and [email protected]_path.empty?\n Dir.chdir(@repo.clone_path)\n else\n initial_path_setup\n end\n end", "def clone(repo_url)\n FileUtils.mkdir_p(File.dirname(working_dir))\n git 'clone', '--recursive', repo_url, working_dir\n end", "def clone(repo_url)\n FileUtils.mkdir_p(File.dirname(working_dir))\n git 'clone', '--recursive', repo_url, working_dir\n end", "def get_github_repos_already_cloned\n repos = Array.new\n\n configatron.dir.children.each do |repo_name|\n if repo_name.directory?\n begin\n repo = Github.repos.get(\n user: ENV['GITHUB_ACCOUNT'],\n oauth_token: ENV['GITHUB_API_TOKEN'],\n repo: repo_name.basename.to_s\n )\n rescue Exception => e\n puts \"\\n#{e}\"\n next\n end\n repos << repo if repo.fork\n end\n end # configatron.dir.children.each do |repo_name|\n\n return repos\nend", "def create_clone_with_branch(type, module_name, repo_url, branch=nil, version=nil, module_namespace=nil, opts={})\n Response.wrap_helper_actions do\n full_name = module_namespace ? ModuleUtil.resolve_name(module_name, module_namespace) : module_name\n\n modules_dir = modules_dir(type,full_name,version,opts)\n FileUtils.mkdir_p(modules_dir) unless File.directory?(modules_dir)\n\n target_repo_dir = local_repo_dir(type,full_name,version,opts)\n if File.exists?(target_repo_dir)\n # if local copy of module exists then move that module to backups location\n if opts[:backup_if_exist]\n backup_dir = backup_dir(type, full_name)\n FileUtils.mv(target_repo_dir, backup_dir)\n puts \"Backup of existing module directory moved to '#{backup_dir}'\"\n else\n raise ErrorUsage.new(\"Directory '#{target_repo_dir}' is not empty; it must be deleted or removed before retrying the command\", :log_error => false)\n end\n end\n\n begin\n opts_clone = (opts[:track_remote_branch] ? {:track_remote_branch => true} : {})\n GitAdapter.clone(repo_url, target_repo_dir, branch, opts_clone)\n rescue => e\n # Handling Git error messages with more user friendly messages\n e = GitErrorHandler.handle(e)\n\n #cleanup by deleting directory\n FileUtils.rm_rf(target_repo_dir) if File.directory?(target_repo_dir)\n error_msg = \"Clone to directory (#{target_repo_dir}) failed\"\n\n DtkLogger.instance.error_pp(e.message, e.backtrace)\n\n raise ErrorUsage.new(error_msg, :log_error => false)\n end\n {\"module_directory\" => target_repo_dir}\n end\n end", "def make_copy_of_repository\n false # true #false\nend", "def clone_appd_cookbook\n @ssh.exec! \"rm -rf #{APPD_COOKBOOK_PATH}\", sudo: true\n @ssh.exec! \"git clone #{APPD_COOKBOOK_URI} #{APPD_COOKBOOK_PATH}\", sudo: true\n end", "def clone_repository\n if File.directory?(base_path)\n repo = ::Git.open(base_path)\n repo.checkout(\"master\")\n repo.pull\n repo.fetch\n else\n ::Git.clone(url, base_path)\n end\n true\n end", "def clone_dir\n \"#{RdocInfo.config[:tmp_dir]}/#{@project.owner}/#{@project.name}/blob/#{@project.commit_hash}\"\n end", "def clone_repo_into_temp_directory\n require \"tmpdir\"\n tempdir = Dir.mktmpdir(REPO_NAME)\n puts \"*** tempdir: (#{tempdir})\"\n\n at_exit { FileUtils.remove_entry(tempdir) }\n\n git clone: [\"--quiet\", REPO, tempdir].map(&:shellescape).join(\" \")\n\n if (branch = __FILE__[BRANCH_NAME_REGEX, 1])\n Dir.chdir(tempdir) do\n git checkout: branch\n end\n end\n\n # template_dir\n File.join(tempdir,TEMPLATE_DIR_NAME)\nend", "def git\n # log \"Thread.current[:repo] nil? \" + Thread.current[:repo].nil?.to_s\n Thread.current[:repo] ||= clone(ARGV[0], ARGV[1])\n Thread.current[:repo]\n end", "def repo; end", "def repo; end", "def repo; end", "def repo; end", "def clone_repo(repo, branch = 'master')\n # For the destination, stick it in a timestamped dir so if multiple builds\n # are going on, each has their own spot\n checkout_destination = Pathname(@@data_dir_location.to_s + (Time.now.utc.to_s + File::SEPARATOR))\n repo_name = Pathname(repo).basename.to_s.split('.')[0]\n repo_path = Pathname(checkout_destination.to_s + repo_name + File::SEPARATOR)\n FileUtils.mkdir_p(checkout_destination)\n Dir.chdir(checkout_destination) {\n system(\"git clone #{repo}\")\n }\n checkout_branch(repo_path, branch) unless branch.downcase.eql? 'master'\n return repo_path\n end", "def git_clone(repo, destination)\n result = `git clone -q #{repo} #{destination}`\n if $?.exitstatus != 0\n error \"Failed to clone #{repo} into #{destination} (Exit status: #{$?.exitstatus})!\"\n error \"Result: #{result}\" unless result.empty?\n exit $?.exitstatus\n end\n end", "def repo_dir; end", "def clone(uri, destination = Dir.mktmpdir)\n git(\"clone\", uri, destination.to_s)\n\n destination\n end", "def test_clone_to_existing_directory\n clone_to_path = \"#{TEST_DATA_DIR}/clone.git\"\n\n # Create an empty dir where we want to clone a new Gitit to\n create_dir_not_exist(clone_to_path)\n\n # Try the clone\n assert_raise RuntimeError do\n Gitit.clone(@repo_path, clone_to_path)\n end\n\n cleanup_dir(clone_to_path)\n end", "def reset_repo(&block)\n yield\n=begin\n Dir.chdir(@saved_cwd){\n system 'rm', '-rf', repo4test\n if !File.directory?(repo4test)\n repo = File.join(repo4test, Juli::REPO)\n FileUtils.mkdir_p(repo)\n FileUtils.cp(File.join(repo4test, '../data/config'), repo,\n :preserve=>true)\n end\n Dir.chdir(repo4test){\n yield\n }\n }\n=end\n end", "def clone_url\n \"git://github.com/#{@account}/#{name}.git\"\n end", "def clone(repo_url)\n mkpdir working_dir\n run 'git', 'clone', '--recursive', repo_url.split('#')[0], working_dir\n branch_from_repo_url(repo_url)\n update\n end", "def git_clone_homepage_or_source_code_uri_or_homepage_uri_or_github_organization_uri\n return false if File.exist? clone_dir\n\n now = Time.now\n\n if IRREGULAR_REPOSITORIES.key? @spec.name\n return git_clone IRREGULAR_REPOSITORIES[@spec.name]\n end\n\n result =\n git_clone_if_github(github_url(source_code_uri_from_metadata)) ||\n git_clone_if_github(source_code_uri_from_metadata) ||\n git_clone_if_github(github_url(@spec.homepage)) ||\n git_clone_if_github(@spec.homepage) ||\n git_clone_if_github(github_url(source_code_uri)) ||\n git_clone_if_github(source_code_uri) ||\n git_clone_if_github(github_url(homepage_uri)) ||\n git_clone_if_github(homepage_uri) ||\n git_clone(github_url(source_code_uri_from_metadata)) ||\n git_clone(source_code_uri_from_metadata) ||\n git_clone(github_url(@spec.homepage)) ||\n git_clone(@spec.homepage) ||\n git_clone(github_url(source_code_uri)) ||\n git_clone(source_code_uri) ||\n git_clone(github_url(homepage_uri)) ||\n git_clone(homepage_uri) ||\n git_clone(github_organization_uri(@spec.name))\n\n if verbose?\n puts \"gem-src: #{@spec.name} - !!! Failed to find a repo.\" if result.nil?\n puts \"gem-src: #{@spec.name} - #{Time.now - now}s\"\n end\n result\n end", "def perform(args = {})\n if repo_mirror_exists?\n update_mirror\n else\n clone_repo\n end\n end", "def clone(commit)\n repos_path = File.expand_path('repos')\n repo_path = File.join(repos_path, commit)\n @git = Git.open(repo_path) if FileTest.exist?(repo_path)\n @git = Git.clone(url, commit, path: repos_path) if @git.nil?\n end", "def clone(where)\n unless self.class.empty_dir?(where)\n raise ArgumentError, \"File already exists `#{where}`\"\n end\n FileUtils.mkdir_p(where)\n g = Grit::Git.new(where)\n g.clone({}, \"--\", path, where)\n wdir = WorkingDir::Git.new(where)\n yield(wdir) if block_given?\n wdir\n end", "def install\n if cached?\n # Update and checkout the correct ref\n Dir.chdir(cache_path) do\n hg %|pull|\n end\n else\n # Ensure the cache directory is present before doing anything\n FileUtils.mkdir_p(cache_path)\n\n Dir.chdir(cache_path) do\n hg %|clone #{uri} .|\n end\n end\n\n Dir.chdir(cache_path) do\n hg %|update --clean --rev #{revision || ref}|\n @revision ||= hg %|id -i|\n end\n\n # Gab the path where we should copy from (since it might be relative to\n # the root).\n copy_path = rel ? cache_path.join(rel) : cache_path\n\n begin \n # Validate the thing we are copying is a Chef cookbook\n validate_cached!(copy_path)\n\n # Remove the current cookbook at this location (this is required or else\n # FileUtils will copy into a subdirectory in the next step)\n FileUtils.rm_rf(install_path)\n\n # Create the containing parent directory\n FileUtils.mkdir_p(install_path.parent)\n\n # Copy whatever is in the current cache over to the store\n FileUtils.cp_r(copy_path, install_path)\n\n ensure\n\n # Remove the .hg directory to save storage space\n # TODO this can have huge performance implications, \n # make it a config option?\n if (hg_path = install_path.join('.hg')).exist?\n FileUtils.rm_r(hg_path)\n end\n\n FileUtils.rm_rf (copy_path)\n end\n end", "def repo_root; end", "def git_get(dir=nil)\n if dir.nil?\n directory = Dir.pwd\n else\n directory = dir\n end\n Dir.chdir(directory) do \n system('git clone https://github.com/offensive-security/exploit-database.git ~/src/exploit-db-git')\n end\nend", "def git_clone_or_pull(repo,dest,ref=\"master\")\n run \"#{sudo} mkdir -p #{File.dirname(dest)}; #{sudo} chown -R #{user} #{File.dirname(dest)}\"\n cmd = compressed_join %Q{\n if [ -d #{dest} ]; then\n cd #{dest};\n git fetch;\n else\n git clone #{repo} #{dest};\n cd #{dest};\n git checkout -b deploy;\n fi\n }\n run_with_input(cmd,%r{\\(yes/no\\)}, \"yes\\n\")\n run_compressed %Q{\n if [ `cd #{dest} && git tag | grep -c #{ref}` = '1' ]; then\n cd #{dest}; git reset --hard #{ref};\n else\n cd #{dest}; git reset --hard origin/#{ref};\n fi\n }\n end", "def cloned?\n File.directory? @git_dir\n end", "def setup_repo\n status(2) {\n setup_path\n if @type == 'full'\n Repository::Git.clone(@repo, @type)\n end\n Repository::Git.pull(@repo, @type)\n }\n end", "def cloned?\n File.directory? git_dir\n end", "def install_git(module_path, module_name, repo, ref = nil)\n module_dir = File.join(module_path, module_name)\n\n Dir.chdir(module_path) do\n print_verbose \"cloning #{repo}\"\n system_cmd(\"git clone #{repo} #{module_name}\")\n Dir.chdir(module_dir) do\n system_cmd('git branch -r')\n system_cmd(\"git checkout #{ref}\") if ref\n end\n end\n end", "def execute\n get_repo(repo_name).repo.fetch\n end", "def install_repo!\n if new_resource.version != 'latest'\n raise(Chef::Exceptions::UnsupportedAction,\n 'A version property cannot be used with the :repo source')\n end\n if new_resource.channel != :stable\n raise(Chef::Exceptions::UnsupportedAction,\n 'A channel property cannot be used with the :repo source')\n end\n include_recipe 'homebrew'\n homebrew_cask 'chefdk'\n end", "def git_clone_repo(repo, branch, destination)\n abort(\"📖 ❗️ No branch to clone specified, aborting…\") if branch.empty?\n abort(\"📖 ❗️ No repo to clone specified, aborting…\") if repo.empty?\n abort(\"📖 ❗️ No destination where to clone specified, aborting…\") if branch.empty?\n\n system('git', 'clone', '--quiet', '-b', branch, repo, destination)\n end", "def build_bare(path)\n template = PathUtils.join(@container.container_dir, 'git', 'template')\n FileUtils.rm_r(template) if File.exist? template\n\n git_path = PathUtils.join(@container.container_dir, 'git')\n ::OpenShift::Runtime::Utils::oo_spawn(\"/bin/cp -ad #{path} #{git_path}\",\n expected_exitstatus: 0)\n\n ::OpenShift::Runtime::Utils::oo_spawn(ERB.new(GIT_INIT).result(binding),\n chdir: template,\n expected_exitstatus: 0)\n begin\n # trying to clone as the user proved to be painful as git managed to \"lose\" the selinux context\n ::OpenShift::Runtime::Utils::oo_spawn(ERB.new(GIT_LOCAL_CLONE).result(binding),\n chdir: git_path,\n expected_exitstatus: 0)\n rescue ShellExecutionException => e\n FileUtils.rm_r(@path) if File.exist? @path\n\n raise ShellExecutionException.new(\n 'Failed to clone application git repository from template repository',\n e.rc, e.stdout, e.stderr)\n ensure\n FileUtils.rm_r(template)\n end\n end", "def clone_match\n git_url = 'https://github.com/hawkrives/carls-keys'\n dir = Dir.mktmpdir\n command = \"git clone --depth 1 '#{git_url}' '#{dir}'\"\n\n # this block pulled from https://github.com/fastlane/fastlane/blob/master/match/lib/match/git_helper.rb\n UI.message 'Cloning remote git repo...'\n begin\n # GIT_TERMINAL_PROMPT will fail the `git clone` command if user credentials are missing\n FastlaneCore::CommandExecutor.execute(command: \"GIT_TERMINAL_PROMPT=0 #{command}\",\n print_all: true,\n print_command: true)\n rescue\n UI.error 'Error cloning the certificates repo. Please make sure you have read access to the repository you want to use'\n UI.error \"Run the following command manually to make sure you're properly authenticated:\"\n UI.command command\n UI.user_error! 'Error cloning the certificates git repo. Please make sure you have access to the repository - see instructions above'\n end\n\n dir\nend", "def fetch_repository(payload)\n repo_path = repository_path(payload)\n if(File.directory?(repo_path))\n debug \"Pulling changes to: #{repo_path}\"\n repo = Git.open(repo_path)\n repo.checkout('master')\n repo.pull\n repo.fetch\n else\n debug \"Initiating repository clone to: #{repo_path}\"\n Git.clone(github_url(payload), repo_path)\n end\n repo_path\n end", "def install_repo!\n if new_resource.channel != :stable\n raise(Chef::Exceptions::UnsupportedAction,\n 'A channel property cannot be used with the :repo source')\n end\n include_recipe 'chocolatey'\n chocolatey_package 'chefdk' do\n unless [nil, 'latest'].include?(new_resource.version)\n version new_resource.version\n end\n end\n end", "def sync_available_sibling_repos(hostname, remote_repo_parent_dir=\"/root\", ssh_user=\"root\")\n working_dirs = ''\n clone_commands = ''\n SIBLING_REPOS.each do |repo_name, repo_dirs|\n repo_dirs.each do |repo_dir|\n if sync_sibling_repo(repo_name, repo_dir, hostname, remote_repo_parent_dir, ssh_user)\n working_dirs += \"#{repo_name}-working \"\n clone_commands += \"git clone #{repo_name} #{repo_name}-working; \"\n break # just need the first repo found\n end\n end\n end\n return clone_commands, working_dirs\n end", "def clone(uri, destination = Dir.mktmpdir)\n if File::ALT_SEPARATOR\n destination = destination.to_s.gsub(File::SEPARATOR, File::ALT_SEPARATOR)\n end\n\n git('clone', uri, destination.to_s)\n\n destination\n end", "def ensure_cloned(repository_url)\n repository_url && :not_implemented\n end", "def clone(uri, destination = Dir.mktmpdir)\n hg('clone', uri, destination.to_s)\n destination\n end", "def clone(url, depth = 10)\n puts \"+ git clone --depth=#{depth} #{url}\"\n system \"git clone --depth=#{depth} #{url}\"\n end", "def cache # :nodoc:\n if File.exist? repo_cache_dir then\n Dir.chdir repo_cache_dir do\n system @git, 'fetch', '--quiet', '--force', '--tags',\n @repository, 'refs/heads/*:refs/heads/*'\n end\n else\n system @git, 'clone', '--quiet', '--bare', '--no-hardlinks',\n @repository, repo_cache_dir\n end\n end", "def repos\n @client.repos.all.collect(&:clone_url)\n end", "def call\n clone_revision\n end", "def create_mirror\n puts \"## Create mirror for project #{@name}\"\n # TODO : Check that all required data is here!\n load_attributes\n\n @config = Ow2mirror::Config.new(@workspace, @name)\n @config.load_attributes\n\n puts \"### Attributes\"\n pp @attributes\n\n puts \"### Configuration\"\n pp @config\n\n puts \"### Clone\"\n puts \"- Mirroring stuff from #{@source_project} source project to #{@target_project}...\"\n cd(folder)\n\n puts \" - Working in the folder #{pwd}\"\n\n # Get the repositories with their name and gitorious git URL\n # TODO :Make it in a generic way (load class from name)...\n\n source = {}\n source[:username] = @config.attributes['source']['username']\n source[:password] = @config.attributes['source']['password']\n source[:url] = @config.attributes['source']['url']\n source[:project] = @attributes['source']\n source_client = Ow2mirror::Client::GitoriousClient.new(source)\n sources = source_client.repositories(@source_project)\n\n target = {}\n target[:username] = @config.attributes['destination']['username']\n target[:password] = @config.attributes['destination']['password']\n target[:url] = @config.attributes['destination']['url']\n target[:project] = @attributes['target']\n target_client = Ow2mirror::Client::GithubClient.new(target)\n\n puts \" - Retrieved the following repositories from sources:\"\n sources.each do |repository|\n puts \" - #{repository[:name]} @ #{repository[:giturl]}\"\n end\n\n repos = []\n\n # For each repository, create the new one on the destination host\n # TODO : Filter from user choices...\n puts \" - Process repositories:\"\n sources.each do |repository|\n cd(folder)\n\n name = repository[:name]\n git = repository[:giturl]\n\n puts \" - Working on repository #{name} - #{git}\"\n puts \" - Clone source locally into #{name}\"\n\n Ow2mirror::Command.git(\"clone --bare --mirror #{git}\")\n\n folder = repository_folder(name)\n\n puts \" - cd to #{folder}\"\n if File.directory?(repository_folder(repository)) and File.exist?(repository_folder(repository))\n # No folder means that something failed...\n end\n\n cd(folder)\n\n target_repo = (@prefix.nil? or @prefix.empty?) ? name : \"#{@prefix}-#{name}\"\n\n puts \" - Target repository is #{target_repo}\"\n\n remote = target_client.create(@attributes['target'], target_repo, \"Official mirror of OW2 repository #{name} hosted at #{git}\")\n Ow2mirror::Command.git(\"remote add #{@config.attributes['destination']['type']} #{remote}\")\n\n Ow2mirror::Command.git(\"config remote.#{@config.attributes['destination']['type']}.mirror true\")\n\n # cache repo\n repos << {:name => name, :source => git, :destination => remote}\n\n end\n\n puts \"#### Clone summary\"\n puts \"- Generated repositories:\"\n pp repos\n\n save\n save_repos repos\n\n @workspace.add_project(@name)\n\n mirror\n end", "def prepare_git_repository\n # Allow one minute for slow repositories\n Grit::Git.git_timeout = 60.0\n\n Dir.chdir(@repository_path) do\n begin\n @repo = Grit::Repo.new('.')\n\n # Figure out the remote branch\n @remote = @repo.git.list_remotes.first\n @branch = @repo.head.name\n\n # Do a git-pull to make sure we have the newest changes from the repo\n if @remote\n puts \"Pulling any changes from the remote git repository...\"\n @repo.git.pull({}, @remote, @branch)\n end\n rescue Grit::InvalidGitRepositoryError\n puts \"ERROR: #{@repository_path} doesn't seem to be a git repository.\"\n end\n end\n end", "def repo *extras, &block\n old_repo = @repo if defined? @repo\n @repo = repo = Gem::Repo.new(Dir.mktmpdir, *extras)\n\n begin\n yield repo\n ensure\n @repo = old_repo\n FileUtils.rm_rf repo.home\n end\n\n repo\n end", "def repo=(_arg0); end", "def repo=(_arg0); end", "def repo=(_arg0); end", "def repo=(_arg0); end", "def chef_repo\n File.join(docker_context, 'chef')\n end", "def create\n final_params = repository_params\n languages = Language.where(name: repository_params[:languages])\n final_params[:languages] = languages\n \n @repository = Repository.new(final_params)\n @uri = URI(@repository.repo_location)\n @repository.secret_path = SecureRandom.hex.to_s + @uri.path.split(\"/\").last.to_s\n @secret_path_to_clone_to = @repository.secret_path\n \n respond_to do |format|\n if @repository.save\n Git.clone(@uri, @secret_path_to_clone_to, :path => Rails.root.join(\"storage\", \"repositories\"))\n format.html { redirect_to @repository, notice: 'Repository was successfully created.' }\n format.json { render :show, status: :created, location: @repository }\n else\n format.html { render :new }\n format.json { render json: @repository.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7670641", "0.76172906", "0.74792695", "0.7458879", "0.74219006", "0.7401429", "0.7334391", "0.7257985", "0.7220069", "0.715019", "0.6993517", "0.6969926", "0.6916874", "0.6895242", "0.68552864", "0.6853401", "0.68142575", "0.6811783", "0.68096775", "0.6799639", "0.67562395", "0.6744094", "0.6738001", "0.6690144", "0.6624705", "0.6593854", "0.65731394", "0.6569365", "0.6552379", "0.6550261", "0.65462565", "0.6545347", "0.652421", "0.65094495", "0.6467626", "0.6446784", "0.6433213", "0.641046", "0.64026785", "0.6400369", "0.63865465", "0.63768864", "0.6375059", "0.6375059", "0.6369524", "0.63550955", "0.63495594", "0.6348547", "0.6346026", "0.63418823", "0.6327093", "0.62934315", "0.6276547", "0.6276547", "0.6276547", "0.6276547", "0.62574035", "0.6245644", "0.62446827", "0.6241305", "0.6236997", "0.6231928", "0.6218991", "0.6211388", "0.61961627", "0.6192198", "0.61709195", "0.6169847", "0.6168372", "0.61366546", "0.6129149", "0.61264515", "0.6094686", "0.6087467", "0.6071431", "0.60629946", "0.6058075", "0.6055167", "0.6045801", "0.6029168", "0.6016485", "0.6000963", "0.5990765", "0.59830505", "0.59719163", "0.5964663", "0.59645206", "0.595734", "0.59523726", "0.5945043", "0.5943421", "0.59421784", "0.59393173", "0.59161925", "0.59160846", "0.59160846", "0.59160846", "0.59160846", "0.5908421", "0.59079134" ]
0.70112795
10
Empty action just a wait and a callback
def delayed_action(wait, repeat=1, &block) new_action({}, wait, :linear, :round, repeat, &block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def waiting; end", "def waiting; end", "def wait; end", "def wait; end", "def wait; end", "def wait\n\tend", "def action_callback(options)\n # Wait until the calling thread goes to sleep.\n while options[:thread].status == \"run\"\n sleep 0.1\n end\n\n # Run the block.\n if options[:thread].status == \"sleep\"\n # Call the callback.\n options[:block].call\n end\n rescue => e\n Log.exception(e)\n ensure\n # Wake up the thread.\n if options[:thread].status == \"sleep\"\n options[:thread].run\n end\n end", "def wait(arg0)\n end", "def yield\n wait\n callback\n end", "def wait_connection=(_arg0); end", "def wait_for_callback\n turnstile.wait unless paused\n end", "def wait_for_callback\n @turnstile.wait unless @paused\n end", "def implicit_wait; end", "def wait_until_not_full; end", "def action_complete() self.finished = true; end", "def wait\n #$_api_queue.clear\n wait_for(/>/)\nend", "def wait(on=nil)\n []\n end", "def wait\n 0\n end", "def wait(what = T.unsafe(nil)); end", "def wait\n true\n end", "def send_and_wait(type, *args); end", "def done\n # Do nothing.\n end", "def then &action\n callbacks << action\n self\n end", "def callback\n head :ok\n end", "def wait_connection; end", "def wait_connection; end", "def done!\n # Do nothing\n end", "def done!\n # Do nothing\n end", "def run(&action)\n raise \"Must override AsyncHandler#run\"\n end", "def wait!\n sleep(@sleep)\n end", "def actions\n response = nil\n\n lambda do |reason, data|\n puts \"Execute block code with reason : #{reason}\"\n break response = data\n end\n\n response\n end", "def recv_action &block\n @actions[:recv] = block\n end", "def run_actions; end", "def done?; true end", "def default_wait\n @default_wait\n end", "def halt; end", "def halt; end", "def call_ok_handler; call_handler(:ok); end", "def callback\n end", "def wait\n sleep 0.0001\n end", "def wait\n sleep WAIT_TIME unless @skip_wait\n end", "def enter_pending; end", "def wake_up()\n # Do nothing by default\n end", "def done?; end", "def busy?; end", "def call\n transaction do\n discard_drafts\n end\n\n broadcast(:ok)\n end", "def wait_async\n @wait_async = true\n end", "def acknowledge\n # do nothing\n end", "def wait\n loop do sleep 1 end\n end", "def call\n advance until done?\n end", "def no_wait_poll\n remove if can_remove_no_wait?\n end", "def callback=(_arg0); end", "def wakeup() end", "def callback\n\n end", "def finally_do\n pause_rt\n put \"put my compendium in my shroud\"\nend", "def no_wait_poll\n remove if can_remove_no_wait?\n end", "def done; end", "def action(&block)\n @action = block\n end", "def proceed!; end", "def proceed!; end", "def wait_done\n sleep 0.01 until done?\n end", "def callback_get\n render nothing: true\n end", "def noop\n write_noop\n response_processor.consume_all_responses_until_mn\n end", "def sleepy_run; end", "def finished=(_arg0); end", "def wait\n return if @op_notifier.nil?\n GRPC.logger.debug(\"active_call.wait: on #{@op_notifier}\")\n @op_notifier.wait\n end", "def attempt(message, &block)\n perform_action(message, false, nil, false, &block)\nend", "def wakeup; end", "def finish\n noth\n end", "def wait_for_pending_sends; end", "def wait\n\t\t\t\tif @count > 0\n\t\t\t\t\tFiber.yield\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tsucceeded?\n\t\t\tend", "def noop(msg); \"200 \"; end", "def wait_action_cable_subscription\n sleep 1\n end", "def wait_until_ready\n # this method may be left unimplemented if that is applicable\n end", "def execute(callback)\n callback.call if unlock(:server)\n yield\n end", "def callback(&blk)\n @blk=blk\n end", "def setup_end_action\n @break_action = true\n @finish = true\n end", "def alaram_operation action\n @state = action\n notify\nend", "def ps_skip_callback?(_action)\n false\n end", "def action &block\n if block.nil?\n raise RuntimeError, 'expected a block but none given'\n end\n @actions << block\n end", "def wait\n self.listener.wait if self.listener\n end", "def action\n load_client\n count_action\n # Increment our sleep counter aggressively based on the number of transactions\n sleep(@action_counter / 100.0)\n # The yield must be last!\n yield @aws_client\n end", "def when_no_pending_instances(&block)\n reset! \n if list_of_pending_instances.size == 0\n block.call if block\n else\n vprint \".\"\n wait \"5.seconds\"\n when_no_pending_instances(&block)\n end\n end", "def go callback\n loop do\n callback.call receive\n end\n end", "def cancel!\n @callback = nil\n end", "def callback\n\tend", "def initialize\n @timeOut = 60 #default timeout per action is 1 minute\n self.check = false\n end", "def wait\n\t\t\t\[email protected]\n\t\t\tend", "def wait_until_open_confirmed; end", "def noop\n -> { }\n end", "def pre_sleep; end", "def busy( &block )\n self.connection.status( :dnd, \"Working...\" )\n yield\n self.connection.status( :chat, \"JabberListener waiting for instructions\" )\n end", "def send_pending; end", "def behold_nothing_happens!\n behold! {}\n end", "def no_wait_poll\n remove if can_remove_no_wait?\n end", "def wait\n @notifier.wait if @notifier\n end", "def wait\n @notifier.wait if @notifier\n end", "def done\n end", "def done\n end", "def enqueue_pending_output; end", "def check_action\n @active_players[0].acted = true\n system 'clear'\n puts 'You have checked.'\n sleep(3)\nend" ]
[ "0.67175", "0.67175", "0.6684758", "0.6684758", "0.6684758", "0.64825755", "0.6454294", "0.64399797", "0.6278872", "0.61987394", "0.61979276", "0.61863536", "0.6174544", "0.6166935", "0.6091581", "0.6079799", "0.60047877", "0.59817475", "0.59708583", "0.59698886", "0.59010524", "0.5900063", "0.5832456", "0.5800641", "0.57864636", "0.57864636", "0.57864094", "0.57864094", "0.5781791", "0.5780248", "0.57731646", "0.5720238", "0.57056075", "0.5705093", "0.5700248", "0.5698996", "0.5698996", "0.56786317", "0.56680644", "0.56487256", "0.5638453", "0.56326073", "0.56198156", "0.56059164", "0.56030065", "0.5600488", "0.5563803", "0.5556044", "0.554397", "0.55394524", "0.55307543", "0.5526757", "0.5526672", "0.5525834", "0.55253464", "0.55197304", "0.551886", "0.55188197", "0.5508479", "0.5508479", "0.5494702", "0.5493536", "0.5487113", "0.5483402", "0.5466966", "0.545881", "0.545813", "0.5456197", "0.5454933", "0.5447433", "0.54430795", "0.5439425", "0.5425397", "0.54234004", "0.541652", "0.5416236", "0.54057854", "0.5401288", "0.5397379", "0.53959507", "0.5394095", "0.539342", "0.5391758", "0.53805184", "0.5363781", "0.53605586", "0.53551704", "0.5352879", "0.53525054", "0.53506684", "0.5346372", "0.5345415", "0.53383744", "0.5337426", "0.53319573", "0.5327115", "0.5327115", "0.53256994", "0.53256994", "0.53250426", "0.53209066" ]
0.0
-1
Write a method that returns an Array that contains every other element of an Array that is passed in as an argument. The values in the returned list should be those values that are in the 1st, 3rd, 5th, and so on elements of the argument Array. Examples: oddities([2, 3, 4, 5, 6]) == [2, 4, 6] oddities([1, 2, 3, 4, 5, 6]) == [1, 3, 5] oddities(['abc', 'def']) == ['abc'] oddities([123]) == [123] oddities([]) == [] Answer:
def even_index_nums(array) even_index_array = [] array.each_with_index do |element, index| if index.even? even_index_array << element end end even_index_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def oddities(array)\n return_array =[]\n array.each_with_index do |element, index|\n return_array << element if index.even?\n end\n return_array\nend", "def oddities(array)\n\n result = [] # empty array to push each item in the array to.\n index = 0 # creates a counter called index\n\n while index < array.size\n result << array[index] # array index is the number in the array.\n index += 2 # += 2 iterates over and returns even items.\n end\n result # again with loops put the result outside of the loop.\nend", "def oddities(array)\n odd_elements = []\n index = 0\n while index < array.size\n odd_elements << array[index]\n index += 2\n end\n odd_elements\nend", "def oddities(array)\n odd_elements = []\n index = 0\n while index < array.size\n odd_elements << array[index]\n index += 2\n end\n odd_elements\nend", "def oddities(array)\n ret_array = []\n array.each_with_index do |value, index|\n if index.even?\n ret_array << value\n end\n end\n ret_array\nend", "def oddities(array)\n elements = []\n index = 0\n while index < array.size\n elements << array[index]\n index += 2\n end\n elements\nend", "def oddities(array)\n odd_values = []\n index = 0\n \n while index < array.size\n odd_values << array[index]\n index += 2\n end\n odd_values\nend", "def oddities(array)\n new_array = []\n array.each_with_index { |val, idx| new_array << val if idx.even? }\n new_array\nend", "def oddities(array)\n result = []\n index = 0\n\n while index < array.size\n result << array[index]\n index += 2\n end\n\n result\nend", "def oddities(array)\n new_array = []\n i = 0\n while i < array.size\n new_array << array[i]\n i += 2\n end\n new_array\nend", "def oddities(array)\n result = []\n index = 0\n\n loop do\n result << array[index]\n index += 2\n break if index >= array.size\n end\n\n result\nend", "def oddities(arr)\n every_other_value = []\n\n counter = 0\n while counter < arr.size\n every_other_value << arr[counter]\n counter += 2\n end\n every_other_value\nend", "def oddities(array)\n odd_array = []\n array.each_with_index { |e, idx| odd_array << e if idx.even? }\n odd_array\nend", "def oddities(array)\n odd_array = []\n array.each_with_index do |e, idx|\n odd_array << e if idx.even?\n end\n odd_array\nend", "def oddities_method_1(arr)\n new_arr = []\n arr.each_with_index do |item, ind|\n new_arr << item if ind.even?\n end\n new_arr\nend", "def oddities(array)\n odd_element_array = []\n index = 0\n loop do\n break if index >= array.size\n odd_element_array << array[index] if index.even?\n index += 1\n end\n odd_element_array\nend", "def oddities(array)\n new_array = []\n\n index = 0\n while index < array.size\n new_array << array[index] if index.even?\n index += 1\n end\n new_array\nend", "def oddities2(arr)\n index = 0\n result = []\n loop do\n break if index >= arr.size\n result << arr[index]\n index += 2\n end\n result\nend", "def oddities(array)\n new_array = []\n array.each_with_index { |num, idx| new_array << num if idx.even? }\n new_array\nend", "def oddities(array)\n new_array = []\n array.each_with_index do |item, index|\n new_array << item if index.even?\n end\n new_array\nend", "def oddities(array)\n odd_elements = []\n array.each do |element|\n odd_elements << element if array.index(element).even?\n end\n odd_elements\nend", "def oddities(arr)\n arr2 = []\n arr.each_with_index { |elem, ndx| arr2 << elem if ndx.even? }\n arr2\nend", "def oddities(arr)\n counter = 0\n return_array = []\n loop do\n return_array << arr[counter]\n counter += 2\n break if counter >= arr.size\n end\n return_array.compact\nend", "def evenities1(array)\n index = 1\n even_array = []\n while index < array.length\n even_array << array[index]\n index += 2\n end\n even_array\nend", "def oddities(array)\n count = 0\n new_array = []\n loop do\n break if array.size == 0\n new_array << array[count]\n count += 2\n break if count >= array.size\n end\n new_array\nend", "def evenies(array)\n even_array = []\n array.each_with_index { |e, idx| even_array << e if idx.odd? }\n even_array\nend", "def oddities(arr)\n new_arr = []\n arr.each_with_index { |v, idx| new_arr << v if idx.even? }\n new_arr\nend", "def oddities(arr)\n new_arr = []\n arr.each_with_index do |val, index|\n new_arr << val if index.even?\n end\n new_arr\nend", "def oddities(ary)\n new_array = []\n counter = 0\n loop do\n break if counter == ary.size\n new_array << ary[counter] if counter.even?\n counter += 1\n end\n new_array\nend", "def oddities(init_array)\n odd_bods = []\n init_array.each_with_index do |element, index|\n odd_bods << element if index.odd?\n end\n odd_bods\nend", "def odd_array(numbers)\n odd_value = []\n \n numbers.each_with_index do |value, idx|\n odd_value << value if idx.even?\n end\n odd_value\nend", "def oddities(arr)\n new_arr = []\n arr.each.with_index do |item, idx|\n new_arr << item if idx == 0 || idx.even?\n end\n new_arr\nend", "def oddities(array)\n new_array = []\n index_range = (1..array.size-1)\n for n in index_range do \n new_array << array[n] if n.odd?\n end\n new_array\nend", "def oddities(int_array)\n index = 0\n odds = []\n\n while index < int_array.size\n odds.push(int_array[index])\n index += 2\n end\n odds\nend", "def oddities(arr)\n arr.each_with_index.with_object([]) do |(el, i), new_arr|\n new_arr << el if i.even?\n end\nend", "def oddities(array)\n result = []\n count = 0\n array.each do |element|\n result << element if count.even?\n count += 1\n end\n result\nend", "def oddities(array)\nresult = []\narray.each_with_index do |value, idx|\n result << value if (idx + 1).odd?\nend\nresult\nend", "def oddities(array)\n result = []\n array.select do |element|\n result << element if array.index(element).even?\n end\n result\nend", "def oddities_1(array)\n array.select { |element| array.index(element) % 2 == 0 }\nend", "def every_other(arr)\n new_array = []\n arr.each_with_index do |int, index|\n new_array << int if index.even?\n end\n new_array\nend", "def oddities(array)\n new_array = []\n array.each_with_index do |num, index|\n new_array << num if index.odd?\n end\n new_array\nend", "def oddities1(arr)\n (arr.map.with_index { |element,i| element if i.even? }).compact\nend", "def oddities(array)\n new_array = []\n array.each_with_index do |element, index|\n new_array.push(element) if (index + 1).odd?\n end\n new_array\nend", "def odds(arr)\n\tret = []\n\tarr.each_index { |i|\n\t\tif i % 2 == 1\n\t\t\tret << arr[i]\n\t\tend\n\t}\n\tret\nend", "def oddities(input_array)\n input_array.select.each_with_index { |_, i| i.even? } # => [2, 4, 6], [\"abc\"], [123], []\nend", "def every_other_array(array)\n result = []\n array.each_with_index { |item, index| result << item if (index + 1).odd?}\n p result\nend", "def oddities(array)\r\n array.select.with_index { |_, i| i.even? }\r\n end", "def oddities(array)\n array.select.with_index { |e, idx| e if idx.even? }\nend", "def oddities(arry)\n arry.select { |n| n if arry.index(n).even? }\nend", "def oddities(array)\n array.select { |element| array.index(element).even? }\nend", "def oddities(arr)\n\tarr.select.with_index { |num, index| num if index.even? }\nend", "def oddities(arr)\r\n arr2 = arr.select do |x|\r\n arr.index(x).even?\r\n end\r\n arr2\r\nend", "def get_even_numbers_from_array(numbers)\n even_numbers = []\n\n for number in numbers\n\n if number.even? == true\n even_numbers << number\n end\n \n end\n\n return even_numbers\nend", "def oddities(arr)\n i = 0\n new_arr = []\n while i < arr.length\n new_arr.push(arr[i])\n i += 2\n end\n print new_arr\nend", "def even_index_nums(array)\n counter = 0\n even_index_array = []\n \n loop do\n break if counter == array.length\n \n current_element = array[counter]\n \n if counter % 2 == 0\n even_index_array << current_element\n end\n \n counter += 1\n end \n even_index_array\nend", "def eveness(array)\n new_array = []\n index = 1\n while index < array.size\n new_array << array[index]\n index += 2\n end\n new_array\nend", "def odd_index_values_from_array(array)\n odd_elements = []\n array.each_with_index do |element, idx|\n odd_elements << element if idx.even?\n end\n odd_elements\nend", "def oddities(array)\nselected_index = []\nindex = 0\n\n\tloop do \n\tcurrent_array = array[index]\n\t\tif index.even?\n\t\t\tselected_index << current_array\n\t\tend\n\tindex += 1\n\tbreak if index == array.size\n\tend\nselected_index\n\nend", "def oddities(values)\n list = []\n values.each_index do |item|\n list << values[item] if item.even?\n end\n list\nend", "def non_oddities(arr)\n arr_length = arr.size\n index = 0\n even_elements = []\n\n loop do\n even_elements << arr[index] if index.odd?\n\n index += 1\n break if index > arr_length\n end\n even_elements.compact\nend", "def odd_integers(array)\nend", "def oddities(arr)\n arr.select{ |a| arr.index(a).even? }\nend", "def another_example_of_even_odd(array)\n arr_evens = []\n arr_odds = []\n\n array.each { |num| num.even? ? arr_evens << num : arr_odds << num }\n p arr_evens \n p arr_odds\nend", "def oddities(list)\n new_list = []\n list.each_index do |ind|\n new_list << list[ind] if (ind + 1).odd?\n end\n new_list\nend", "def select_odds(numbers)\n new_arr = []\n\n i = 0\n while i < numbers.length\n if numbers[i] % 2 == 1\n new_arr << numbers[i]\n else \n end\n\n i += 1\n end\n\n return new_arr\n \nend", "def oddities(array)\n array.select {|element| array.index(element).even?}\nend", "def evil_even_numbers(array_of_numbers)\n result = []\n for number in array_of_numbers\n result.push(number) if(number % 2 == 0)\n end\n \n return result \nend", "def oddities(array)\n array.select {|item| array.index(item).even?}\nend", "def select_odds(numbers)\n odd_numbers = []\n \n i = 0\n while i < numbers.length\n if numbers [i] % 2 == 1\n odd_numbers << numbers [i]\n end\n \n i += 1\n end\n \n return odd_numbers\nend", "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 select_odds(numbers)\n \n i = 0\n \n new_array = []\n \n while i < numbers.length\n \n if numbers[i] % 2 != 0\n \n \tnew_array << numbers[i]\n end\n \n i += 1\n end\n return new_array\n\nend", "def select_odds(numbers)\n index = 0 \n \n odds = [] \n \n while index < numbers.length \n if numbers[index] % 2 != 0\n odds << numbers[index]\n end \n \n index += 1 \n end \n \n return odds \n \nend", "def evenies(array)\n array.select.with_index { |e, idx| e if idx.odd? }\nend", "def odd_numbers(array)\n end", "def select_every_even arr\n ans = []\n arr.each_with_index do |item, i|\n if i%2 == 0 \n ans.push item\n end\n end\n ans\nend", "def odd_elements(array)\n res = []\n (1...array.length).step(2).each do |idx|\n elem = array[idx]\n elem = yield elem if block_given?\n res.push(elem)\n end\n\n res\nend", "def odd_index_values_from_array(array)\n index = 0\n odd_elements = []\n while index < array.size\n odd_elements << array.fetch(index) if index.even?\n index += 1\n end\n odd_elements\nend", "def oddities(arr)\n arr.select.with_index do |_, idx|\n idx.even?\n end\nend", "def select_odds(numbers)\n\tarry = []\n \ti = 0\n while i < numbers.length\n if numbers[i] % 2 == 1\n arry << numbers[i]\n end\n i += 1\n end\n return arry\nend", "def oddities(arr)\n arr.select.with_index do |element, index|\n index.even?\n end\nend", "def odd_indexed_integers(array)\n\nend", "def select_odds(numbers)\n odds = []\n\n i = 0\n\n while i < numbers.length\n if numbers[i] % 2 == 1\n odds << numbers[i]\n end\n i += 1\n end\n\n return odds\nend", "def select_every_odd arr\n ans = []\n arr.each_with_index do |item, i|\n if i%2 == 1 \n ans.push item\n end\n end\n ans\nend", "def oddities3(arr)\n result = []\n index_array = (0..arr.size-1).select {|idx| idx.even?}\n index_array.each do |index|\n result << arr.fetch(index)\n end\n result\nend", "def evenlists(array)\n even = []\n j = 0\n while array.count >= j \n even << array[j]\n j +=2\n end \n p even\nend", "def select_odds(numbers)\n i = 0\n newArr = []\n while i < numbers.length\n if numbers[i] % 2 != 0\n newArr << numbers[i]\n end\n i += 1\n end\n return newArr\n end", "def oddities(array)\n array.select.with_index { |e, i| (i + 1).odd? }\nend", "def oddities(arr)\n selected_objects = []\n arr.each_with_index { |obj, i| selected_objects << obj if i.even?}\n selected_objects\nend", "def select_odds(nums)\n odds = []\n\n i = 0\n while i < nums.length\n if nums[i] % 2 == 1\n odds << nums[i]\n end\n i += 1\n end\n return odds\nend", "def get_evens(arr)\n even_array = []\n arr.each{|int| even_array.push(int) if int % 2 == 0}\n even_array\nend", "def double_odd_index_numbers(numbers)\n result = []\n numbers.each_with_index do |number,i|\n result << number*2 if i.odd?\n result << number if i.even?\n end\n result\nend", "def oddities(array)\n array.partition {|element| array.index(element).even?}\nend", "def evens(array)\n index = 1\n even_array = []\n while index < array.size\n even_array << array[index]\n index += 2\n end\n p even_array\nend", "def no_odds( values )\n evenOnly = []\n values.each do |i|\n if i%2 == 0\n evenOnly.push(i)\n end\n end\n return evenOnly\nend", "def odds_only array\n array.select do |value|\n value.odd?\n end\nend", "def evens(arr)\n even_places = []\n arr.each_with_index do |el, idx|\n even_places << el if idx.odd?\n end\n even_places\nend", "def even_numbers(num_array)\n\n\tnum_array.select! do |num|\n\t\tnum % 2 == 0\n\tend\n\n\tnum_array\n\nend", "def odd_indexed_elements(array)\n odd_indx_array = []\n array.each_with_index do |item, idx|\n if idx.odd?\n odd_indx_array << item\n end\n end\n return odd_indx_array\nend", "def oddball(arr)\r\n # your code goes here\r\n evens = []\r\n odds = []\r\n\r\n arr.each do |int|\r\n\r\n if int % 2 == 0\r\n evens << int\r\n else\r\n odds << int\r\n end\r\n\r\n end\r\n if evens.length == 1\r\n return evens[0]\r\n else\r\n return odds[0]\r\n end\r\n\r\nend", "def select_odds(numbers)\n odds = []\n \n i = 0\n while i < numbers.length\n num = numbers[i]\n if num % 2 == 1\n odds << num\n end\n \n i += 1\n end\n \n return odds\n end" ]
[ "0.8365474", "0.8301856", "0.83014846", "0.83006966", "0.82734734", "0.8236041", "0.8226449", "0.8203163", "0.8202177", "0.8184364", "0.81677264", "0.8148469", "0.81305015", "0.8124606", "0.81222236", "0.8121219", "0.812029", "0.80923206", "0.80799174", "0.8073462", "0.8063247", "0.8044717", "0.8011272", "0.7985579", "0.7950623", "0.79264486", "0.79065704", "0.7863369", "0.7854358", "0.78492635", "0.7847925", "0.783501", "0.7830425", "0.78251565", "0.78181815", "0.77977955", "0.77898484", "0.77763486", "0.7761498", "0.7750637", "0.7747328", "0.77360374", "0.7728365", "0.77067846", "0.7650656", "0.76480263", "0.7646037", "0.7609071", "0.75994104", "0.7586394", "0.75682074", "0.7567262", "0.7540768", "0.753305", "0.7528654", "0.75281173", "0.7521708", "0.7471137", "0.74553996", "0.7427353", "0.74197924", "0.7403654", "0.7373467", "0.7352837", "0.7344661", "0.7339057", "0.7337614", "0.7334718", "0.73338646", "0.732252", "0.7315159", "0.7314607", "0.7308803", "0.7298488", "0.729766", "0.7294011", "0.72919184", "0.72895443", "0.72844124", "0.72839856", "0.7281791", "0.72618175", "0.7250999", "0.72445023", "0.72321445", "0.7229352", "0.71999305", "0.7193868", "0.717967", "0.7164164", "0.7157416", "0.7140549", "0.7130082", "0.71222955", "0.7103234", "0.71001357", "0.7099222", "0.7090788", "0.70787084", "0.707659" ]
0.7278168
81
=> true or this way
def even_index_nums(array) counter = 0 even_index_array = [] loop do break if counter == array.length current_element = array[counter] if counter % 2 == 0 even_index_array << current_element end counter += 1 end even_index_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def true?\n self == true\n end", "def to_bool() true end", "def conditionally_true\n\t\t!!self\n\tend", "def true \n \"true\" \n end", "def true?\n self.eql?(true)\n end", "def true(_argvs)\n return nil\n end", "def result?\n true\n end", "def qwerty\n\t\tfalse\n\tend", "def simple?\n true\n end", "def true?\n !false?\n end", "def trueish?\n %w(1 t).include? self\n end", "def one?\n true\n end", "def to_bool; self; end", "def to_bool; self; end", "def check ; true ; end", "def always_true\n true\n end", "def semact?; false; end", "def ai?\n\ttrue\n end", "def aye?\n true\n end", "def to_bool() false end", "def truth\n\t\t\t\"You can't handle the truth\" ; true\n\t\tend", "def applicable?\n true\n end", "def result?\n false\n end", "def truth?\n truth\n end", "def on_true(node)\n :true\n end", "def supports_is_true?\n false\n end", "def applicable?\n true\n end", "def true?\n self.value == '1'\n end", "def basic?\n false\n end", "def true?(obj)\n [\"true\",\"1\"].include? obj.to_s.downcase\n end", "def multi_arged?\n false\n end", "def success?() end", "def what_am_i?\r\n\t\t\"#{self}\"\r\n \tend", "def ygg_ally? ; return true ; end", "def test?\n false\n end", "def true?\n self.value == '1'\n end", "def open_status?\n return @ajar == true\n end", "def target; true; end", "def to_bool\n true\n end", "def is_boolean()\n res = super(context,self)\n return res\n end", "def way(way)\n true\n end", "def value\n true\n end", "def true?(obj)\n obj.to_s.downcase == \"true\"\n end", "def recommendable?() false end", "def test?\n true\n end", "def isSatisfiable?()\n\tend", "def value?(value) true end", "def to_boolean()\n res = super(context,self)\n return res\n end", "def actif?\n @actif == true\n end", "def alto?\n @cr[0xb][7] == 1\n end", "def parse_bool() true end", "def void_true(*args)\n return true\n end", "def pro?\n !!self.pro\n end", "def do_pigs_fly?\n return true,false\nend", "def active?\n\t\tactive\n\tend", "def scholarly?\n false\n end", "def complex_condition?(condition); end", "def single_value?\n return false\n end", "def ordinary?\n raise \"Not implemented yet\"\n end", "def enotsup?() super; end", "def delicious?\n\t\treturn true\n\tend", "def nd?\n true\n end", "def ok? \n @funct == nil ? (return false) : (return true)\n end", "def mixed?\n return true\n end", "def flag; end", "def composite?\n false\n end", "def composite?\n false\n end", "def to_bool\n true\n end", "def single?; false; end", "def single?; false; end", "def mixed?\n return false\n end", "def get_boolean_value\n\t\tend", "def ==(*)\n true\n end", "def delicious?\n #its automattically true\n true\n end", "def despined?(*)\n end", "def atom?\n true\n end", "def real?\n true\n end", "def consigned?\n false\n end", "def stand\r\n return true\r\n end", "def tpl_boolean; @original; end", "def bastard?\n end", "def success?(*) end", "def working?\n true\n end", "def working?\n true\n end", "def value_if_true\n return @value_if_true\n end", "def false_true\n alternatives false, true\n end", "def default_true\n return (@acts[1].nil? ? true : @acts[1])\n end", "def state?\n usa?\n end", "def trux\n true\nend", "def entire?\n entire\n end", "def result_to_get?\n if not @result.nil?\n if @result.downcase == 'true'\n return true\n else\n return false\n end\n else\n return false\n end\n end", "def is_bool(value) #method\n if value == 'verdadero' || value == 'falso'\n true\n else\n false\n end\n end", "def working?\n \t@working\n end", "def lit?\n @lit\n end", "def quorate?\n\t\t@quorate\n\tend", "def simple?\n !! ( origins && target || sequence? )\n end", "def usable?; end", "def person?\n !!self.person\n end", "def person?\n !!self.person\n end", "def checked?; end", "def dumb?\n false\n end" ]
[ "0.7231769", "0.7095801", "0.7051262", "0.7042259", "0.69669193", "0.6882134", "0.6846522", "0.6778649", "0.67663944", "0.6745763", "0.6745388", "0.67389166", "0.6734261", "0.6734261", "0.673201", "0.6730588", "0.6723103", "0.6703069", "0.6694369", "0.6689606", "0.6683062", "0.6678622", "0.66781765", "0.6649467", "0.66219735", "0.662163", "0.65958107", "0.6567642", "0.6556604", "0.6548503", "0.6545962", "0.6538852", "0.6522044", "0.65181226", "0.65135723", "0.65050226", "0.6489743", "0.64845484", "0.64840686", "0.6481162", "0.6480116", "0.6479165", "0.6477123", "0.6471243", "0.6468177", "0.6442433", "0.6431419", "0.64313066", "0.6421259", "0.64157647", "0.6414386", "0.64135057", "0.63999754", "0.63925", "0.638993", "0.6388698", "0.6388413", "0.638462", "0.6380581", "0.63702583", "0.6351546", "0.63369244", "0.6323465", "0.6322304", "0.6317586", "0.6309991", "0.6309991", "0.63059545", "0.6303896", "0.6303896", "0.63014865", "0.63010436", "0.62932056", "0.6293005", "0.62927485", "0.6287865", "0.6287475", "0.62825453", "0.6276418", "0.6271989", "0.62683135", "0.6267083", "0.6264152", "0.6264152", "0.6258954", "0.62585586", "0.62582254", "0.6256758", "0.62499547", "0.6249345", "0.6245582", "0.6243043", "0.6236426", "0.62292707", "0.6227634", "0.6226225", "0.6222428", "0.6220851", "0.6220851", "0.6220549", "0.6216128" ]
0.0
-1
=> true Further Exploration: Write a companion method that returns the 2nd, 4th, 6th, and so on elements of an array. Try to solve this exercise in at least 2 additional ways. 1st way:
def odd_index_nums(array) odd_index_array = [] array.each_with_index do |element, index| if index.odd? odd_index_array << element end end odd_index_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fifth_of_array(array)\nend", "def second_great_low(arr)\r\n\r\nend", "def odd_indexed_integers(array)\n\nend", "def return_edinburgh(array)\n return array[1]\nend", "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 oddities(array)\n result = []\n index = 0\n\n loop do\n result << array[index]\n index += 2\n break if index >= array.size\n end\n\n result\nend", "def my_function2(arr)\n final_arr = []\n first_half = []\n first_product = 1\n last_half = []\n arr.each_with_index do |n, i|\n first_half = arr[0...i]\n last_half = arr[i+1..-1]\n first_product = first_half.reduce(:*) || 1\n last_product = last_half.reduce(:*) || 1\n products = first_product * last_product\n final_arr.push(products)\n end\n return \"Products: #{final_arr}\"\nend", "def third_element(array)\n array[2]\nend", "def third_element(array)\n array[2]\nend", "def oddities(array)\n return_array =[]\n array.each_with_index do |element, index|\n return_array << element if index.even?\n end\n return_array\nend", "def find_even(array)\nend", "def answer\n composition = 1\n array = ['2,3,4,5']\n puts array\n array.split(',')\n #@inputArray = array\n #array.map!{|x| x.to_i}\n puts array\n #lastEvenIndex = last_even(array)\n #array.each_index {|x| composition*=array[x] if (array[x]%7).zero?}\n #array[lastEvenIndex] = composition\n #@modifiedArray = array\nend", "def check_array(nums)\n if(nums.length >= 2)\n\t\treturn (nums[0] + nums[1])\n\tend\n\tif(nums.length == 1)\n\t\treturn nums[0];\n\tend\n\treturn 0;\n\nend", "def oddities(array)\n odd_element_array = []\n index = 0\n loop do\n break if index >= array.size\n odd_element_array << array[index] if index.even?\n index += 1\n end\n odd_element_array\nend", "def first_even\n\t@array[0]\n\t\t#returns 30\n\t\tarray_2 = @array.split(',')\n\t\t#splits apart the original array\n\t\t\tarray_3 =[]\n\t\t\t#creates a new array, in which I can shove in whatever I want\n\t\t\t\tarray_3 << [50, 3, 5, 15, 16, 23, 42, 300, 22, 1, 55, 42, 30, 17, 77, 102, 5, 11]\n\t\t\t\t\tarray_3.flatten!\n\t\t\t\t\t\n\n\nend", "def oddities(arr)\n counter = 0\n return_array = []\n loop do\n return_array << arr[counter]\n counter += 2\n break if counter >= arr.size\n end\n return_array.compact\nend", "def basic_9 (array_iterate)\n square_array = array_iterate.collect { |n| n * n}\n return square_array\nend", "def oddities(array)\nselected_index = []\nindex = 0\n\n\tloop do \n\tcurrent_array = array[index]\n\t\tif index.even?\n\t\t\tselected_index << current_array\n\t\tend\n\tindex += 1\n\tbreak if index == array.size\n\tend\nselected_index\n\nend", "def oddball(arr)\n a, b, c = arr\n if a %2 == b %2\n expected = a %2\n arr.drop(2).each{|n| return n if n != a}\n elsif a%2 == c %2\n return b\n else\n return a\n end\nend", "def third_element(array)\n taylor_swift = [\"Welcome to New York\", \"Blank Space\", \"Style\", \"Out of The Woods\"]\n taylor_swift[2]\nend", "def my_function3(arr)\n final_arr = []\n first_product = 1\n last_half = []\n arr.each_with_index do |n, i|\n last_half = arr[i+1..-1]\n first_product *= arr[i-1] unless i == 0\n last_product = last_half.reduce(:*) || 1\n products = first_product * last_product\n final_arr.push(products)\n end\n return \"Products: #{final_arr}\"\nend", "def my_method(array)\n if array.empty?\n []\n elsif array.size >= 2\n array.map do |value|\n value * value\n end\n else\n [7 * array.first]\n end\nend", "def given\n [6,5,3,1,8,7,2,3]\nend", "def oddball(arr)\n odd = arr.select {|x| x.odd? }\n even = arr.select {|x| x.even? }\n if even.length > odd.length\n odd[0]\n else\n even[0]\n end\nend", "def oddities2(arr)\n index = 0\n result = []\n loop do\n break if index >= arr.size\n result << arr[index]\n index += 2\n end\n result\nend", "def evenities1(array)\n index = 1\n even_array = []\n while index < array.length\n even_array << array[index]\n index += 2\n end\n even_array\nend", "def find_unsorted_subarray(nums)\n \nend", "def array_translate(array)\n new_arr = []\n \n array.each_with_index do |subArray, idx|\n if idx % 2 == 1\n subArray = ele\n else\n subArray = num\n \n #num.times { new_arr << ele }\n end\n end\n\n #return new_arr\nend", "def even_index_nums(array)\n counter = 0\n even_index_array = []\n \n loop do\n break if counter == array.length\n \n current_element = array[counter]\n \n if counter % 2 == 0\n even_index_array << current_element\n end\n \n counter += 1\n end \n even_index_array\nend", "def array_with_two_elements\n [1,2]\nend", "def oddities(array)\n ret_array = []\n array.each_with_index do |value, index|\n if index.even?\n ret_array << value\n end\n end\n ret_array\nend", "def mex(arr)\n 0.upto($n) do |nn|\n if arr.any? nn\n next\n else\n return nn\n end\n end\n $n\nend", "def even_index_nums(array)\n even_index_array = []\n \n array.each_with_index do |element, index|\n if index.even?\n even_index_array << element\n end\n end\n even_index_array\nend", "def odd_integers(array)\nend", "def array_method(input)\n\treturn input[input.length/2]\nend", "def oddities_1(array)\n array.select { |element| array.index(element) % 2 == 0 }\nend", "def pick_these(arr, i, j)\n\nend", "def oddities(array)\n odd_elements = []\n index = 0\n while index < array.size\n odd_elements << array[index]\n index += 2\n end\n odd_elements\nend", "def oddities(array)\n odd_elements = []\n index = 0\n while index < array.size\n odd_elements << array[index]\n index += 2\n end\n odd_elements\nend", "def oddities(array)\n\n result = [] # empty array to push each item in the array to.\n index = 0 # creates a counter called index\n\n while index < array.size\n result << array[index] # array index is the number in the array.\n index += 2 # += 2 iterates over and returns even items.\n end\n result # again with loops put the result outside of the loop.\nend", "def oddities(array)\n elements = []\n index = 0\n while index < array.size\n elements << array[index]\n index += 2\n end\n elements\nend", "def print_arr_2(arr)\n arr.each_with_index do |el, idx|\n break if idx == arr.length/2 - 1\n puts el\n end\nend", "def odd_numbers(array)\n end", "def oddities_method_1(arr)\n new_arr = []\n arr.each_with_index do |item, ind|\n new_arr << item if ind.even?\n end\n new_arr\nend", "def oddities(arr)\n # Same problem here. arr.index returns the index of the first element with that value. Do not use!\n arr.select.with_index do |elem, index|\n index % 2 == 0\n end\nend", "def array_of_ints(arr)\n return arr[0] * arr[1] * arr[2] if arr.length == 3\n\n comp_arr = arr.pop(3).sort\n\n arr.each do |num|\n if num > comp_arr[2]\n comp_arr.push(num)\n comp_arr.shift\n elsif num > comp_arr[1]\n comp_arr[0] = comp_arr[1]\n comp_arr[1] = num\n elsif num > comp_arr[0]\n comp_arr[0] = num\n end\n end\n comp_arr[0] * comp_arr[1] * comp_arr[2]\n\nend", "def oddball(arr)\n # first_even = 1\n # first_odd = 2\n # arr.each do |n|\n # # puts \"checking #{n}\"\n # if n%2==0\n # if first_even==1\n # first_even = n\n # # puts \"set first_even to #{n}\"\n # else\n # return first_odd\n # end\n # else\n # if first_odd==2\n # first_odd = n\n # # puts \"set first_odd to #{n}\"\n # else\n # return first_even\n # end\n # end\n # end\n odds = []\n evens = []\n arr.each do |n|\n if n%2==0\n evens << n\n else\n odds << n\n end\n end\n if odds.length > 1\n return evens[0]\n else\n return odds[0]\n end\nend", "def oddball(arr)\r\n # your code goes here\r\n evens = []\r\n odds = []\r\n\r\n arr.each do |int|\r\n\r\n if int % 2 == 0\r\n evens << int\r\n else\r\n odds << int\r\n end\r\n\r\n end\r\n if evens.length == 1\r\n return evens[0]\r\n else\r\n return odds[0]\r\n end\r\n\r\nend", "def oddball(arr)\n odds = arr.select {|num| num.odd?}\n evens = arr.select {|num| num.even?}\n odds.size > evens.size ? evens[0] : odds[0]\nend", "def element_times_index(numbers)\n new_arry = []\n i = 0\n while i < numbers.length\n new_arry << numbers[i] * i\n i += 1\n end\n return new_arry\n\nend", "def oddities(array)\n result = []\n index = 0\n\n while index < array.size\n result << array[index]\n index += 2\n end\n\n result\nend", "def fold_array(array, runs)\n solution = []\n\n\n if runs ==1 and array.length == 1\n solution.push(array[0])\n return solution\n####################\n elsif runs == 1\n if array.length.even?\n mid = array.length / 2\n midpoint = array[mid]\n 0.upto(mid-2) do |x|\n solution[x] = array[x] + array[array.length - (x+1)]\n end\n solution.push(array[mid] + array[mid - 1])\n else\n mid = array.length / 2\n midpoint = array[mid]\n 0.upto(mid-1) do |x|\n solution[x] = array[x] + array[array.length - (x+1)]\n solution[mid] = midpoint\n end\n end\n return solution\n#######################\n elsif runs == 2\n if array.length.even?\n mid = array.length / 2\n midpoint = array[mid]\n 0.upto(mid-2) do |x|\n solution[x] = array[x] + array[array.length - (x+1)]\n end\n solution.push(array[mid] + array[mid - 1])\n else\n mid = array.length / 2\n midpoint = array[mid]\n 0.upto(mid-1) do |x|\n solution[x] = array[x] + array[array.length - (x+1)]\n solution[mid] = midpoint\n end\n end\n nextrun = solution\n if nextrun.length.even?\n mid = nextrun.length / 2\n midpoint = nextrun[mid]\n 0.upto(mid-2) do |x|\n solution[x] = nextrun[x] + nextrun[array.length - (x+1)]\n end\n solution.push(nextrun[mid] + nextrun[mid - 1])\n else\n mid = nextrun.length / 2\n midpoint = nextrun[mid]\n 0.upto(mid-1) do |x|\n solution[x] = nextrun[x] + nextrun[nextrun.length - (x+1)]\n solution[mid] = midpoint\n nextrun.pop\n end\n end\n return nextrun\n########################\n elsif runs == 3\n if array.length.even?\n mid = array.length / 2\n midpoint = array[mid]\n 0.upto(mid-2) do |x|\n solution[x] = array[x] + array[array.length - (x+1)]\n end\n solution.push(array[mid] + array[mid - 1])\n else\n mid = array.length / 2\n midpoint = array[mid]\n 0.upto(mid-1) do |x|\n solution[x] = array[x] + array[array.length - (x+1)]\n solution[mid] = midpoint\n end\n end\n nextrun = solution\n if nextrun.length.even?\n mid = nextrun.length / 2\n midpoint = nextrun[mid]\n 0.upto(mid-2) do |x|\n solution[x] = nextrun[x] + nextrun[array.length - (x+1)]\n end\n solution.push(nextrun[mid] + nextrun[mid - 1])\n else\n mid = nextrun.length / 2\n midpoint = nextrun[mid]\n 0.upto(mid-1) do |x|\n solution[x] = nextrun[x] + nextrun[nextrun.length - (x+1)]\n solution[mid] = midpoint\n nextrun.pop\n end\n end\n ######\n mid = nextrun.length / 2\n midpoint = nextrun[mid]\n 0.upto(mid-1) do |x|\n solution[x] = nextrun[x] + nextrun[nextrun.length - (x+1)]\n solution[mid] = midpoint\n nextrun.pop\n end\n return nextrun\n #return [nextrun[0] + nextrun[1]] if nextrun.length == 2\n\n\n end\n\n\n\nend", "def oddOrEven(arr)\n even = false\n evenCnt = 0\n for i in 0..2 do\n if arr[i] % 2 == 0 then\n evenCnt += 1\n end\n end\n\n if evenCnt > 1 then\n even = true\n for x in arr do\n if x % 2 != 0 then\n return x\n end\n end\n else\n for x in arr do\n if x % 2 == 0 then\n return x\n end\n end\n end\n\nend", "def calls_array\n a = return_array\n a[1]\n end", "def oddities3(arr)\n result = []\n index_array = (0..arr.size-1).select {|idx| idx.even?}\n index_array.each do |index|\n result << arr.fetch(index)\n end\n result\nend", "def oddities(array)\n odd_array = []\n array.each_with_index do |e, idx|\n odd_array << e if idx.even?\n end\n odd_array\nend", "def oddities(arr)\r\n arr2 = arr.select do |x|\r\n arr.index(x).even?\r\n end\r\n arr2\r\nend", "def solution(a)\r\n a.each do |num|\r\n if (a.count(num) % 2) != 0\r\n return num\r\n end\r\n end\r\nend", "def my_method(array)\n if array.size == 1\n [7 * array.first]\n elsif array.size > 1\n array.map do |value|\n value * value\n end\n else\n []\n end\nend", "def all_elements_except_first_3(num_array)\n 3.times {\n num_array.shift\n }\n return num_array\nend", "def element_times_index(numbers)\n\tnumber_multiplied = []\n\ti = 0\n\n\twhile i < numbers.length\n\t\tnumber = numbers[i] * i\n\t\tnumber_multiplied << number\n\n\t\ti += \n\tend\n\n\treturn number_multiplied\t\nend\n\n\n# ---------- Their Solution ----------\n# Line 37 is better than what I did in line 20-21\n\n# def element_times_index(numbers)\n# new_nums = []\n\n# i = 0\n# while i < numbers.length\n# new_nums << numbers[i] * i\n\n# i += 1\n# end\n\n# return new_nums\n# end\n\n# ---------- Tests ----------\nprint element_times_index([4, 7, 6, 5]) # => [0, 7, 12, 15]\nputs\nprint element_times_index([1, 1, 1, 1, 1, 1]) # => [0, 1, 2, 3, 4, 5]", "def an_array_with_5_elements\n [1, 2, 3, 4, 5]\nend", "def summer (array, target_number)\n\t#tracks number position in array \n\tindex = 0\n\t#array of two element arrays that is returned by function\n\tanswer_array = []\n\twhile index <= array.length\n\t \tarray.each do |number|\n\t\t\tif (((array[index].to_i + array[number].to_i) == target_number) && index != number)\n\t\t\t\tanswer_array.push([array[index], array[number]])\n\t\t\tend \n end\n index += 1 \n end \t\n answer_array\nend", "def element_selection(array)\n puts array[0]\n puts array[-1]\n puts array.first(2)\n return array.last(2)\nend", "def array_times_two(array)\nend", "def oddities(array)\n odd_elements = []\n array.each do |element|\n odd_elements << element if array.index(element).even?\n end\n odd_elements\nend", "def first_even(array_of_numbers)\n even_number_array = []\n array_of_numbers.each do |num| \n if num % 2 == 0\n even_number_array << num\n end\n end\n even_number_array[0]\nend", "def third_element(my_third_element)\n my_third_element = @taylor_swift[3-1]\nend", "def mtdarray\n\t10.times do |num|\n\t\tsquare = num + num\n\t\treturn num, square if num > 5\n\tend\nend", "def oddities(array)\n count = 0\n new_array = []\n loop do\n break if array.size == 0\n new_array << array[count]\n count += 2\n break if count >= array.size\n end\n new_array\nend", "def oddities(array)\n odd_array = []\n array.each_with_index { |e, idx| odd_array << e if idx.even? }\n odd_array\nend", "def element_times_index(numbers)\n\tfor i in 0..numbers.length-1\n numbers[i] *= i\n end\n return numbers\nend", "def my_method(array)\n if array.empty?\n []\n elsif array.length == 1\n [7 * array.first]\n else\n array.map do |value|\n value * value\n end\n end\nend", "def mod_three my_array\n\t@my_array = my_array\n\tto_return = []\n\tto_return = @my_array.map { |nr| nr % 3 }\n\tto_return = to_return.reject { |nr| nr == 0 }\n\tp to_return\nend", "def oddball(arr)\n even_arr = arr.select { |n| n % 2 == 0 }\n odd_arr = arr.reject { |n| n % 2 == 0 }\n\n return even_arr[0] if even_arr.length == 1\n return odd_arr[0]\nend", "def oddball(arr)\n odds = []\n evens = []\n\n arr.each do |el|\n if el.even?\n evens << el\n else\n odds << el\n end\n end\n if odds.length < evens.length\n print odds[0]\n return odds[0]\n else\n print evens[0]\n return evens[0]\n end\nend", "def double_numbers(array)\n doubled_numbers = []\n array.each do |number|\n doubled_numbers << number * 2\n end\n return doubled_numbers\nend", "def match_maker(determine, *elements)\n # Create a new array\n return_array = []\n # Loop through each item in the elements array, slicing into two\n elements.each_slice 2 do | first, last |\n # Create a variable that checks if the element is the opposite\n first = !!first\n last = !!last\n result = determine ? first != last : first == last\n # Push the result to the array\n return_array << result\n end\n # Return the array\n return_array\nend", "def alternate_order(array)\n array.select{ |a| a % 2 != 0 }\nend", "def element_times_index(numbers)\n \n new_arr = []\n\n i = 0 \n while i < numbers.length\n new_num = numbers[i] * i\n new_arr << new_num\n i += 1\n end\n\n return new_arr\nend", "def double_array(array)\n # your code here\nend", "def even_numbers(array)\n\n unless array.is_a?(Array)\n # would be raise Argument error exception anyway, just for illustrate\n raise ArgumentError\n end\n\n if array.length == 0\n raise StandardError.new(\"Too few elements\")\n end\n\n array.find_all { |el| el.to_i % 2 == 0 }\n\nend", "def oddities1(arr)\n (arr.map.with_index { |element,i| element if i.even? }).compact\nend", "def my_method(array)\n if array.empty?\n []\n elsif array.size > 1\n array.map do |value|\n value * value\n end\n else\n [7 * array.first]\n end\nend", "def my_method(array)\n if array.empty?\n []\n elsif array.size > 1\n array.map do |value|\n value * value\n end\n else\n [7 * array.first]\n end\nend", "def my_method(array)\n if array.empty?\n []\n elsif array.size > 1\n array.map do |value|\n value * value\n end\n else\n [7 * array.first]\n end\nend", "def buy_fruit(array)\n returner = []\n array.each{|subarray| subarray[1].times{returner << subarray[0]}}\n returner\nend", "def even_numbers(array)\n array.select{ |num| num.even? }\n\n # TODO: Return the even numbers from a list of integers.\n # You should use Enumerable#select\nend", "def second_element(arry)\n arry.reduce { |x, y| x - y ? x : y }\nend", "def oddities(arr)\n arr.select.with_index do |element, index|\n index.even?\n end\nend", "def oddities(array)\n new_array = []\n array.each_with_index { |num, idx| new_array << num if idx.even? }\n new_array\nend", "def odd_array(numbers)\n odd_value = []\n \n numbers.each_with_index do |value, idx|\n odd_value << value if idx.even?\n end\n odd_value\nend", "def oddities(array)\n odd_values = []\n index = 0\n \n while index < array.size\n odd_values << array[index]\n index += 2\n end\n odd_values\nend", "def my_method(array)\n if array.empty?\n []\n elsif array.size > 1 # missing elsif condition in original code on line 4\n array.map do |value|\n value * value\n end\n else\n [7 * array.first]\n end\nend", "def oddities(array)\n new_array = []\n array.each_with_index do |item, index|\n new_array << item if index.even?\n end\n new_array\nend", "def oddball(arr)\n evens = []\n odds = []\n arr.each do |int|\n if int.even?\n evens << int\n else\n odds << int\n end\n end\n evens.length > 1 ? odds[0] : evens[0]\nend", "def oddities(arr)\n new_arr = []\n arr.each_with_index do |val, index|\n new_arr << val if index.even?\n end\n new_arr\nend", "def first_even(nums)\n nums.each do |num|\n return num if num.even?\n end\n nil\nend", "def double_array(array)\n array*2\nend", "def new_array\n\tfull_array.map! {|x| #We call upon the definition from above to create the conditionals for this \n\t\t #function. By defining these arrays (full and new) in separate functions, it \n\t #allows testing to run in increments. \n\t #The block argument (pipes) isolate the element within the array that will be \n\t\t #called upon.\n\t#Using 'map' lays out the array 1-100 (element after element joined together, yet separated by commas).\n\t#Using the exclamation point with map makes sure the array doesn't return back to the \n\t#1-100 array after the changes were made/if there isn't an exclamation point then\n\t#the array would revert back to what it was prior to the changes(conditionals).\n\t\tif x % 3 == 0 && x % 5 == 0 #The double ampersand symbol means 'and' in this case.\n\t\t\t\"mined_minds\" #This is what will replace the current element within the array.\n\t\telsif x % 3 == 0 #The percent sign is a modulo operater in this case--meaning 'if x is divisble \n\t\t\t\"mined\" #by 3 with no remainders' (\"mined\" will replace any element divisible by 3)\n\t\telsif x % 5 == 0 #The percent sign is a modulo operater in this case--meaning 'if x is divisble\n\t\t\t\"minds\" #by 5 with no remainders' (\"minds\" will replace any element divisible by 5)\n\t\telsif x == 11 #The double equals sign means that \"if x 'is the same' as 11\" when the elements \n\t\t\t\"class\" #are cycling through. \n\t\telse\n\t\t\tx #This means that the element within the array must be returned if the element doesn't meet \n\t\t\t #any of the requirements in any of the conditionals listed above.\n\t\tend #Must include 'end' to close out the conditional (lines up with the beginning of 'if' statements)\n\t} #The curly brackets are used when referencing the conditional and replaces the word 'do' in this case.\n\n\t\nend", "def double_array(array)\n output_array = []\n\n array.each do |thing|\n output_array << thing * 2\n end\n\n return output_array\nend" ]
[ "0.7151113", "0.68980896", "0.65920633", "0.6547472", "0.6538001", "0.65055406", "0.6490328", "0.6488265", "0.6488265", "0.6480371", "0.64637697", "0.6453169", "0.6447818", "0.6446534", "0.64377147", "0.6430218", "0.6419768", "0.64142853", "0.6382456", "0.6381374", "0.6378092", "0.63775957", "0.6351031", "0.63335234", "0.63213307", "0.6320498", "0.62959784", "0.6288484", "0.6279686", "0.6274222", "0.62707657", "0.6259414", "0.6257043", "0.62547845", "0.62513494", "0.62438184", "0.62308586", "0.62235045", "0.6223367", "0.62213576", "0.6220498", "0.6205587", "0.62054336", "0.6203873", "0.619896", "0.61881137", "0.618612", "0.61822337", "0.61796767", "0.61737883", "0.616812", "0.6160625", "0.61575496", "0.61539215", "0.614764", "0.6144195", "0.6142623", "0.6139448", "0.6139242", "0.6134835", "0.6134349", "0.61292124", "0.612666", "0.61254793", "0.6123788", "0.6119057", "0.6117233", "0.61092323", "0.61022455", "0.60947573", "0.6092583", "0.60911393", "0.60902536", "0.60894096", "0.60801864", "0.6079324", "0.60731673", "0.6067919", "0.60630536", "0.6060882", "0.60541624", "0.6053387", "0.60513633", "0.6047053", "0.6047053", "0.6047053", "0.604574", "0.60456836", "0.60440224", "0.6043716", "0.6041577", "0.6029231", "0.60243714", "0.60215586", "0.6020524", "0.6019778", "0.6018066", "0.60169935", "0.6016673", "0.60149205", "0.60145557" ]
0.0
-1
=> true 2nd way:
def odd_index_nums(array) array.select do |num| current_index = array.index(num) if current_index % 2 == 1 num end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_bool() true end", "def check ; true ; end", "def test?\n false\n end", "def ==(*)\n true\n end", "def true?\n self == true\n end", "def to_bool() false end", "def nd?\n true\n end", "def aye?\n true\n end", "def result?\n true\n end", "def qwerty\n\t\tfalse\n\tend", "def trueish?\n %w(1 t).include? self\n end", "def equal?(p0) end", "def true?\n self.eql?(true)\n end", "def alto?\n @cr[0xb][7] == 1\n end", "def test?\n true\n end", "def result?\n false\n end", "def entire?\n entire\n end", "def success?() end", "def multi_arged?\n false\n end", "def scholarly?\n false\n end", "def simple?\n true\n end", "def true(_argvs)\n return nil\n end", "def delicious?\n\t\treturn true\n\tend", "def semact?; false; end", "def ai?\n\ttrue\n end", "def true \n \"true\" \n end", "def to_bool; self; end", "def to_bool; self; end", "def value?(value) true end", "def true?(obj)\n [\"true\",\"1\"].include? obj.to_s.downcase\n end", "def delicious?\n #its automattically true\n true\n end", "def single_value?\n return false\n end", "def to_bool\n true\n end", "def true?\n !false?\n end", "def always_true\n true\n end", "def despined?(*)\n end", "def consigned?\n false\n end", "def applicable?\n true\n end", "def do_pigs_fly?\n return true,false\nend", "def isSatisfiable?()\n\tend", "def stand\r\n return true\r\n end", "def value?(p0) end", "def success?\n return true\n end", "def match\n true\n end", "def truth?\n truth\n end", "def ordinary?\n raise \"Not implemented yet\"\n end", "def real?\n true\n end", "def composite?\n false\n end", "def composite?\n false\n end", "def passed?\n\t\t\t@passed\n\t\tend", "def basic?\n false\n end", "def percolates?\n end", "def over?\n\n end", "def true?\n self.value == '1'\n end", "def check!\n true\n end", "def success?(*) end", "def member?(p0) end", "def member?(p0) end", "def member?(p0) end", "def first?\n\t locate == 1\n\tend", "def delicious?()\n\t\treturn TRUE\n\tend", "def match?\n false\n end", "def true?(obj)\n obj.to_s.downcase == \"true\"\n end", "def bass?\n @cr[0xa][7] == 1\n end", "def conditionally_true\n\t\t!!self\n\tend", "def to_bool\n true\n end", "def ok? \n @funct == nil ? (return false) : (return true)\n end", "def evaluate?\n false\n end", "def evaluate?\n false\n end", "def truth\n\t\t\t\"You can't handle the truth\" ; true\n\t\tend", "def dumb?\n false\n end", "def tested?\n @tested\n end", "def state?\n usa?\n end", "def found?\n\t\t\t!!@found\n\t\tend", "def open_status?\n return @ajar == true\n end", "def assign?\n\t\ttrue\n\tend", "def true?\n self.value == '1'\n end", "def used_by?(element)\n end", "def used_by?(element)\n end", "def recommendable?() false end", "def has_value?(p0) end", "def expected?\n false\n end", "def atom?\n true\n end", "def ==(p0) end", "def ==(p0) end", "def ==(p0) end", "def ==(p0) end", "def ==(p0) end", "def ==(p0) end", "def ==(p0) end", "def one?\n true\n end", "def double?\n if self.id\n return true if self.torrent_url && Torrent.not_self(self.id).find_by_torrent_url(self.torrent_url)\n return true if self.transmission_hash_string && Torrent.not_self(self.id).find_by_transmission_hash_string(self.transmission_hash_string)\n return true if self.name && Torrent.not_self(self.id).find_by_name(self.name)\n else\n return true if self.torrent_url && Torrent.find_by_torrent_url(self.torrent_url)\n return true if self.transmission_hash_string && Torrent.find_by_transmission_hash_string(self.transmission_hash_string)\n return true if self.name && Torrent.find_by_name(self.name) \n end\n \n \n return false\n end", "def value\n true\n end", "def bastard?\n end", "def value?(value); end", "def value?(value); end", "def pro?\n !!self.pro\n end", "def repealed?\n !!repealed_on\n end", "def over?\n end", "def success?\n got.equal?(true)\n end", "def ==(*) end" ]
[ "0.6989526", "0.69693667", "0.6743636", "0.6725762", "0.6703968", "0.6672206", "0.66494733", "0.66469765", "0.66291654", "0.6627751", "0.6624861", "0.6598645", "0.6589213", "0.65876704", "0.65842736", "0.65562344", "0.65394616", "0.65304446", "0.652744", "0.6525513", "0.6525387", "0.6518471", "0.6513989", "0.6508938", "0.6508137", "0.65063554", "0.6505012", "0.6505012", "0.64952993", "0.6490818", "0.6485988", "0.6482851", "0.648188", "0.64779925", "0.64720243", "0.6448469", "0.64128715", "0.6407183", "0.639648", "0.6387093", "0.6386281", "0.6383505", "0.637685", "0.63593066", "0.6355744", "0.63505983", "0.6328741", "0.6324252", "0.6324252", "0.6322862", "0.6312066", "0.629328", "0.6292588", "0.6290085", "0.62827086", "0.62821144", "0.6279524", "0.6279524", "0.6279524", "0.62757117", "0.627458", "0.62727255", "0.6272246", "0.626368", "0.62636125", "0.6262442", "0.6260646", "0.6259148", "0.6259148", "0.6256334", "0.625461", "0.62541413", "0.624601", "0.62419045", "0.6230172", "0.62258554", "0.62248", "0.6222363", "0.6222363", "0.6215973", "0.6211711", "0.62069756", "0.6205543", "0.6203135", "0.6203135", "0.6203135", "0.6203135", "0.6203135", "0.6203135", "0.6203135", "0.62010914", "0.62006706", "0.61958283", "0.6195211", "0.61923885", "0.61923885", "0.61890507", "0.618362", "0.61815494", "0.6168116", "0.6166639" ]
0.0
-1
finds all stops from first_stop to last_stop on a single line. excludes first_stop
def get_stops (line, first_stop, last_stop) # puts "line #{ line } stop #{ first_stop } -> stop #{ last_stop }" first_index = lines[line.to_sym].index(first_stop) last_index = lines[line.to_sym].index(last_stop) if first_index <= last_index trip = lines[line.to_sym][first_index..last_index] else trip = lines[line.to_sym][last_index..first_index].reverse end trip.shift # remove first stop return trip end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trip(line, start_stop, end_stop)\n trip_line = s_line(line)\n p trip_line\n start_index = trip_line.index(start_stop)\n end_index = trip_line.index(end_stop)\n stops = \"\"\n\n if start_index < end_index\n until start_index == end_index\n stops += trip_line[start_index]\n start_index += 1\n end\n else\n until start_index == end_index\n stops += trip_line[start_index]\n start_index -= 1\n end\n end\n return stops\nend", "def get_line_stops(lines, origin_line)\n lines[origin_line.to_sym]\nend", "def stopGetter(stop_1, stop_2, line)\n if stop_1 > stop_2\n return line[stop_2..stop_1].reverse!\n else\n return line[stop_1..stop_2]\n end\nend", "def get_users_stops_by_line(line,origin_stop,destination_stop)\n # stop_list is an array which is line details\n stop_list = get_stop_details(line)\n origin_stop_index = stop_list.index(origin_stop)\n destination_stop_index = stop_list.index(destination_stop)\n\n if origin_stop_index < destination_stop_index\n stop_list[origin_stop_index + 1..destination_stop_index]\n\n else\n stop_list[destination_stop_index..origin_stop_index - 1].reverse()\n end\n end", "def getting_stops on_line, on_stop, off_line, off_stop\n\tstops = []\n\n\tif is_same_line(on_line, off_line)\n\t\texit if on_line.index(on_stop) == on_line.index(off_stop) \n\t\t\t\n\t\tstops << (on_line[ on_line.index(on_stop)..on_line.index(off_stop) ]) \n\t\t\"you have to travel through: #{ stops.join(\" -> \") }\"\n\n\telse\n\t\tif is_left_to_union(on_line, on_stop, \"Union Square\")\n\t\t\tstops << on_line[on_line.index(on_stop)..on_line.index(\"Union Square\")]\n\n\t\telse\n\t\t\tstops << on_line[on_line.index(\"Union Square\")..on_line.index(on_stop)].reverse\n\t\tend\n\n\t\tif is_left_to_union(off_line, off_stop, \"Union Square\")\n\t\t\tstops << off_line[off_line.index(off_stop)..off_line.index(\"Union Square\")].reverse\n\n\t\telse\n\t\t\tstops << off_line[off_line.index(\"Union Square\")..off_line.index(off_stop)]\n\t\tend\n\n\t\t# delete \"Union Square\" from stops[1] as it is duplicate with stops[0]\n\t\tstops[1].shift\n\n\t\t\"You have to travel through: #{ stops[0].join(\" -> \") }\\n Change at: Union Square\\n Your travel continues through: #{ stops[1].join(\" -> \") }\\n The total number of stops you have to travel is: #{ stops.flatten.length }\"\n\tend\nend", "def stops_to(lines, start_stop, end_stop)\n\tstart_line = find_line(lines, start_stop)\n\tend_line = find_line(lines, end_stop)\n\n\tif start_line == end_line # Just calculate the one distance \n\t\treturn line_distance(lines, start_line, start_stop, end_stop)\n\t\n\telse # Calculate distance for each line and direction from US seperately then add\n\t\tfirst_distance = line_distance(lines, start_line, start_stop, \"Union Square\")\n\t\tsecond_distance = line_distance(lines, end_line, \"Union Square\", end_stop)\n\t\treturn first_distance[0] + second_distance[0], first_distance[1] + second_distance[1]\n\tend\nend", "def stops_to(lines, start_stop, end_stop)\n\tstart_line = find_line(lines, start_stop)\n\tend_line = find_line(lines, end_stop)\n\n\tif start_line == end_line # Just calculate the one distance \n\t\treturn line_distance(lines, start_line, start_stop, end_stop)\n\t\n\telse # Calculate distance for each line and direction from US seperately then add\n\t\tfirst_distance = line_distance(lines, start_line, start_stop, \"Union Square\")\n\t\tsecond_distance = line_distance(lines, end_line, \"Union Square\", end_stop)\n\t\treturn first_distance[0] + second_distance[0], first_distance[1] + second_distance[1]\n\tend\nend", "def find_line(lines, stop)\n\tlines.each_pair { |key, line| return key if line.include?(stop) }\nend", "def find_line(lines, stop)\n\tlines.each_pair { |key, line| return key if line.include?(stop) }\nend", "def get_stop_details(line)\nx = $subway_lines\n for i in x do\n if line == i[:line]\nline_details = i[:stops]\n end\nend\nline_details\nend", "def build_leg(line, start, stop)\n trip = []\n until start == stop do\n start += (start < stop) ? 1 : - 1\n trip.push line[start]\n end\n return trip\nend", "def train_travel(first_stop, last_stop, line)\n line_stop = @railwayslines[line]\n\n stop_a = line_stop.index(first_stop)\n stop_b = line_stop.index(last_stop)\n if stop_a < stop_b\n travelled = line_stop[stop_a..stop_b]\n else\n travelled = line_stop[stop_b..stop_a]\n travelled = travelled.reverse\n # return travelled\n end\n travelled\nend", "def move_subway start_stop, end_stop, line\n if start_stop > end_stop\n subway_stops = line[end_stop..start_stop - 1].reverse\n else\n subway_stops = line[start_stop + 1..end_stop]\n end\nend", "def show_stops(lines, line1)\n\tlines.each do |line|\n\t\tif line[:lines] == line1\n\t\t\tputs line[:stops]\n\t\tend\n\tend\nend", "def find_lines mta, start_station, end_station\n lines = [[],[]]\n mta.each do |line, stations|\n lines[0].push line if stations.include?(start_station)\n lines[1].push line if stations.include?(end_station)\n end\n\n if lines[0] & lines[1] != []\n common_line = lines[0] & lines[1]\n return [ common_line[0], common_line[0] ] # The 1st line both stations are on\n else\n return [ lines[0][0], lines[1][0] ] # The 1st line the staions are found on\n end\nend", "def list_stops(line)\n puts line\n return \"all the stops on a line\"\nend", "def last_line_only(range); end", "def last_line_only(range); end", "def last_line_only(range); end", "def startstop minsize=30\n stopstop(minsize).find_all { | orf | \n codon1= orf.nt.seq[0..2].upcase\n ['ATG','TTG','CTG','AUG','UUG','CUG'].index(codon1) != nil\n }\n end", "def regex_stop_or_semicolon\n Regexp.new(\"(?:\\\\.line#{VM_PREFIX}|;line#{VM_PREFIX})\")\nend", "def first_line_only(range); end", "def first_line_only(range); end", "def first_line_only(range); end", "def getLineStops (l)\n @lines[l][:stops]\nend", "def total_stops(line_start, station_start, line_end, station_end)\n\t# if travelling on the same line the number of stops is the differential in array indexes\n if line_start == line_end\n \ttotal_stops = line_start.index(station_start) - line_end.index(station_end)\n\n\t# the next 3 are for when union station is a start or end point in the journey\t\n\t# if union is one of the stops then you onlyu need to calculate the number of stops to other station \t\n elsif\n \tstation_start == station_end\n \ttotal_stops = 0\n\n elsif station_start.include?(\"union\")\n \ttotal_stops = stops_from_union(station_end, line_end)\n\n elsif station_end.include?(\"union\")\n \ttotal_stops = stops_from_union(station_start, line_start)\n\n\t# when journey begins and ends on different lines you add the number of stops from union station\n else\n \ttotal_stops = stops_from_union(station_start, line_start) + stops_from_union(station_end, line_end)\n\n end\n\n\t# total stops needs to be an absolute value\n\ttotal_stops = total_stops.abs\nend", "def stops_between_stations (start_line,start_staion ,end_line, end_station )\n \n lines{\n red =[ 'South Station','Park Street', 'Kendall','Central','Harvard', 'Porter', 'Davis', 'Alewife']\ngreen = ['Government Center','Park Street','Boylston','Arlington','Copley','Hynes','Kenmore']\norange =['North Station','Haymarket','Park Street','State','Downtown Crossing','Chinatown','Back Bay','Forest Hills']\n }\n \n\n # return \"You have #{start_station - red_line.index(\"South Station\")} to go \" \n if start_line == end_line # Both dests are in in same line \n return start_line.index(start_staion) - end_line.index(stop_station) # i'd use abs = absloute here to avoid negative values \n\n else puts 'I have no clue what to do here -.-'\n \n end \n \n end", "def find_stations(si, ei, line) # si is short for start index and ei is short for end index\n if ei >= si\n line_stop_count = ei - si\n passing_stations = line[(si+1)..ei].join(\", \")\n else\n line_stop_count = si - ei\n passing_stations = line[(ei)..(si-1)].reverse.join(\", \")\n end\n return {:num_stops => line_stop_count, :stops => passing_stations}\nend", "def regex_stop_prefix\n Regexp.new(\"\\\\.line#{VM_PREFIX}\")\nend", "def second_trip(l2, s2)\n ## find index of stop s2 on line l2\n index_s2 = $lines[l2].index(s2)\n ## find index of Union Square Staion on line l2\n index_of_USquare = $lines[l2].index('Union Square')\n\n trip2 = []\n\n if index_s2 > index_of_USquare\n trip2 = $lines[l2][index_of_USquare..index_s2].drop(1) # drop(1) to exclude Union Square station from the list\n else\n trip2 = $lines[l2][index_s2..index_of_USquare].reverse.drop(1) # drop(1) to exclude Union Square station from the list\n end\n\n\n puts \">>> Your journey continues through the following stops on the #{l2} line: #{trip2.join(', ')}.\"\n\n trip2\nend", "def single_line_trip( line, start_station, end_station )\n stations = @stations[ line ]\n if stations.index( start_station ) > stations.index( end_station )\n stations.reverse!\n end\n stations[stations.index( start_station )..stations.index( end_station )]\nend", "def before_and_after begin_delimeter, end_delimeter\n\n Throw.if_nil_or_empty_strings [ self, begin_delimeter, end_delimeter ]\n\n before_after_lines = []\n in_middle_bit = false\n\n self.each do |candidate_line|\n\n is_middle_boundary = !in_middle_bit && candidate_line.downcase.include?(begin_delimeter.downcase)\n if is_middle_boundary\n in_middle_bit = true\n next\n end\n\n unless in_middle_bit\n before_after_lines.push candidate_line\n next\n end\n\n #--\n #-- Now we are definitely in the middle bit.\n #-- Let's check for the middle end delimeter\n #--\n if candidate_line.downcase.include? end_delimeter.downcase\n in_middle_bit = false\n end\n\n end\n\n return before_after_lines\n\n end", "def line_distance(lines, line, start, stop)\n\n\t# Find the distance and range between stops\n\tdistance = lines[line].index(stop) - lines[line].index(start)\n\trange = 1..distance \n\trange = distance..-1 if distance < 0\n\n\t# Create the list of stations\n\tstations_array = []\n\trange.each do |x|\n\t\t\tstations_array << lines[line][lines[line].index(start) + x]\n\tend\n\t\n\t# Reverse if needed\n\tstations_array.reverse! if distance < 0\n\n\treturn distance.abs, stations_array\nend", "def line_distance(lines, line, start, stop)\n\n\t# Find the distance and range between stops\n\tdistance = lines[line].index(stop) - lines[line].index(start)\n\trange = 1..distance \n\trange = distance..-1 if distance < 0\n\n\t# Create the list of stations\n\tstations_array = []\n\trange.each do |x|\n\t\t\tstations_array << lines[line][lines[line].index(start) + x]\n\tend\n\t\n\t# Reverse if needed\n\tstations_array.reverse! if distance < 0\n\n\treturn distance.abs, stations_array\nend", "def calculate_line(stop1, stop2)\n if @purple_line.include?(stop1) && @purple_line.include?(stop2)\n \"either\"\n elsif @purple_line.include?(stop1) && @blue_line_west.include?(stop2)\n \"blue\"\n elsif @purple_line.include?(stop1) && @red_line_only.include?(stop2)\n \"red\"\n elsif @red_line_only.include?(stop1)\n \"red\"\n elsif @blue_line_west.include?(stop1)\n \"blue\"\n end\n end", "def partition_and_process_non_tabular_lines\n non_tabular_lines.each do |line|\n if line =~ @start_line_pattern\n # This is a start line\n start_record(line)\n elsif line =~ @end_line_pattern\n # This is an end line\n end_record(line)\n else\n @non_tabular_record << line if @in_a_record\n end\n end\n end", "def longest_startstop\n startstop(0).first\n end", "def first_trip(l1, s1)\n ## find index of stop s1 on line l1\n index_s1 = $lines[l1].index(s1)\n ## find index of Union Square Staion on line l1\n index_of_USquare = $lines[l1].index('Union Square')\n\n trip1 = []\n\n if index_s1 <= index_of_USquare\n trip1 = $lines[l1][index_s1..index_of_USquare]\n else\n trip1 = $lines[l1][index_of_USquare..index_s1].reverse\n end\n\n puts \">>> You must travel through the following stops on the #{l1} line: #{trip1.join(', ')}.\"\n puts \">>> Change at Union Square.\"\n\n trip1\nend", "def reachable_stops(initial_s)\n k = [initial_s, 0]\n examine(*k)\n @stops_from[k]\n end", "def plan_trip (first_s, last_s)\n stations = []\n beginning = $lineN.index(first_s.to_s)\n ending = $lineN.index(last_s.to_s)\n this_many = beginning + ending\n stations = $lineN[beginning, this_many]\n return stations\nend", "def range_encompassing first_text_element, last_text_element\n first_pos = last_pos = last_limit = nil\n each_with_index do |pair, index|\n if !first_pos && pair.first == first_text_element\n first_pos = pair.last\n end\n if !last_pos && pair.first == last_text_element\n last_pos = pair.last\n last_limit = elmt_offset_at(index+1)\n break\n end\n end\n [first_pos, last_limit]\n end", "def singleTrip (start_station, end_station, line)\n start_index = MTA[line].index(start_station)\n end_index = MTA[line].index(end_station)\n\n if start_index < end_index\n stops = MTA[line][start_index ... end_index]\n num_stops = end_index - start_index\n end\n\n if end_index < start_index\n stops = MTA[line][end_index ... start_index]\n stops = stops.reverse\n num_stops = start_index - end_index\n\n end\n print = \"You must travel through the following stops on the #{line}: #{stops}\"\n # print = \"#{num_stops} in total\"\nend", "def exclude_ends input\n\n input[1..-2]\n\n end", "def range_by_lines(range); end", "def structure_lines(lines)\n last_structure_line = lines.index{ |line| line =~ /\\AM END/ }\n lines[4..last_structure_line].join\n end", "def slice_of_css(start, stop)\n start == stop ? [start] : [start, *slice_of_css(start.next, stop)]\nend", "def find_start_and_finish\n grid.each_with_index do |row, row_idx|\n row.each_with_index do |spot, col_idx|\n if spot == START_MARK\n @start = [row_idx, col_idx]\n elsif spot == END_MARK\n @finish = [row_idx, col_idx]\n end\n end\n end\n end", "def scan_for_index_start_and_end(code, regex)\n res = []\n code.scan(regex) do\n res << {starts: Regexp.last_match.offset(0).first,\n ends: Regexp.last_match.offset(0).last}\n end\n res\nend", "def next_stop\n stops.first\n end", "def plan_trip (first_l, first_s, last_l, last_s)\n# Get the program to work for a single line:\n# Different way to do global use $\n stations = [ ]\n start = $train_lines[first_l.to_s].index(first_s.to_s)\n finish = $train_lines[last_l.to_s].index(last_s.to_s)\n\n# 2.7.2 :012 > $train_lines.values\n# => [[\"Times Square\", \"34th\", \"28th\", \"23rd\", \"Union Square\", \"8th\"], [\"8th\", \"6th\", \"Union Square\", \"3rd\", \"1st\"], [\"Grand Central\", \"33rd\", \"28th\", \"23rd\", \"Union Square\", \"Astor Place\"]]\n# 2.7.2 :013 > $train_lines.keys\n# => [\"lineN\", \"lineL\", \"line6\"]\n\n if start < finish\n stations = $lineN[start..finish]\n elsif\n stations = $lineN[finish..start].reverse\n end\n\n return stations\n\nend", "def good_divider(lines,i)\n above_and_below = lines.rows(0...i)+lines.rows((i+1)..-1)\n segments(lines[i]).all? { |text,range|\n text =~ /^( +|---+)$/ or above_and_below.columns(range).blank?\n }\n end", "def query_lines(chr = nil, start = nil, stop = nil)\n raise EntryFileError, \"Do not know how to query for lines in #{File.basename(@data_file)}!\"\n end", "def between(start_line, end_line=nil)\n return self unless start_line\n\n if start_line.is_a? Range\n end_line = start_line.last\n end_line -= 1 if start_line.exclude_end?\n\n start_line = start_line.first\n else\n end_line ||= start_line\n end\n\n if start_line > 0\n start_idx = @lines.index { |l| l.last >= start_line } || @lines.length\n else\n start_idx = start_line\n end\n\n if end_line > 0\n end_idx = (@lines.index { |l| l.last > end_line } || 0) - 1\n else\n end_idx = end_line\n end\n\n alter do\n @lines = @lines[start_idx..end_idx] || []\n end\n end", "def line_ranges=(_); end", "def find_middle(start, stop)\n index = ((stop - start) / 2) + start\n time = time_at(index)\n [index, time]\n end", "def stops_from_union(station, line)\n\n\tnum_stops = line.index(station) - line.index(\"Union Square\")\n\tnum_stops.abs\nend", "def find_stop(name)\n stop = stops.find { |s| s.name == name }\n\n if stop.nil? # No exact match found, try fuzzier match.\n stop = stops.find { |s| s.name.downcase.start_with?(name.downcase) }\n raise ArgumentError, \"Unknown stop: #{name}\" if stop.nil?\n\n warn \"Expanded #{name.inspect} to #{stop.name.inspect}\"\n end\n\n stop\n end", "def find(boundary,value,start,stop)\n return start if start == stop\n mid_index, mid_time = find_middle(start,stop)\n # puts \"+ find_#{boundary} (#{value}, #{start}, #{stop}) [mid_index #{mid_index}:#{mid_time}]\"\n if mid_time == value\n find_adjacent(boundary,value,start,stop,mid_index)\n elsif mid_time > value\n mid_index -= 1 if mid_index == stop\n find(boundary, value, start, mid_index)\n elsif mid_time < value\n mid_index += 1 if mid_index == start\n find(boundary, value, mid_index, stop)\n end\n end", "def find_last(value,start,stop)\n return stop if time_at(stop) < value\n find(:last,value,start,stop)\n end", "def line_range\n max_lines = source_file.content.lines.size - 1\n context_lines = 3\n first_line = [0, location_line - context_lines - 1].max\n last_line = [max_lines, location_line + context_lines - 1].min\n first_line..last_line\n end", "def last_line_only(range)\n if range.line != range.last_line\n range.adjust(begin_pos: range.source =~ /[^\\n]*\\z/)\n else\n range\n end\n end", "def exclude_ends list\n list[1..-2]\nend", "def whichLine(stop)\n\tif lines[\"n\"].include? 'Times'\n\t\t# puts \"yes\"\n\telse\n\t\t# puts \"no\"\n\tend\nend", "def is_left_to_union line, on_stop, changing_stop\n\tif line.index(on_stop) <= line.index(changing_stop)\n\t\ttrue\n\telse\n\t\tfalse\n\tend\nend", "def calc_stop(checked_stations, curr_st, end_st, final_values)\n if (curr_st == end_st)\n checked_stations.push(curr_st)\n final_values.push(checked_stations)\n else\n arr_of_stops = $stations[curr_st]\n arr_of_stops.each do |station|\n if (checked_stations.include?(station))\n next\n else\n calc_stop(checked_stations + [curr_st], station, end_st, final_values)\n end\n end\n end\n return final_values\nend", "def find_scene_starts(script)\n script = script.split(\"\\n\") if script.is_a?(String)\n scene_ends = find_scene_ends(script)\n scene_starts = scene_ends.map{|e| e+1} # Point to the next line after the \"- fin -\" marker\n scene_starts.unshift(start_of_first_scene(script)) # Add a scene start to the beginning\n scene_starts.pop # don't need the last one\n scene_starts\n end", "def travel_diff(line1, line2)\n\t\tputs \"You will need to change trains at UNION SQUARE!\"\n\t\tputs \"Board the train at #{$subway_station[$get_on - 1]}\"\n\t\tend_point_diff = line2.index $subway_station[$get_off - 1]\n\t\tstart_point_diff = line2.index $intersect\n\n\t\t### STARTING LINE IS WHICH?\n\t\tif line1 == $line_n\n\t\t\tlist_stops_int(4, line1, line2)\n\t\t\tdirection(start_point_diff, end_point_diff, line2)\n\n\t\telsif line1 == $line_l\n\t\t\tlist_stops_int(2, line1, line2)\n\t\t\tdirection(start_point_diff, end_point_diff, line2)\n\n\t\telsif line1 == $line_6\n\t\t\tlist_stops_int(3, line1, line2)\n\t\t\tdirection(start_point_diff, end_point_diff, line2)\n\t\tend\n\tend", "def find_line_boundary(text, start_index, rightwards)\n index = start_index\n vector = -1\n vector = 1 if rightwards\n\n loop do\n character = text[index]\n\n if rightwards\n break if index >= text.length\n break if character == \"\\n\"\n else\n break if index <= 0\n break if text[index - 1] == \"\\n\"\n end\n\n index = index + vector\n end\n\n index\n end", "def check_endpoints(line1, line2, delta)\n if (line1.start_point.same?(line2.start_point) ||\n line1.start_point.same?(line2.end_point) ||\n line1.end_point.same?(line2.start_point) ||\n line1.end_point.same?(line2.end_point))\n return true\n end\n return false\nend", "def find_adjacent(boundary,value,start,stop,mid_index)\n case boundary\n when :first\n (time_at(mid_index,-1) == value) ? find_first(value,start-1,stop) : mid_index\n when :last\n (time_at(mid_index,1) == value) ? find_last(value,start,stop+1) : mid_index\n end\n end", "def find_variable_range(lines, start_index)\n closing_brace_index = 0\n\n lines[start_index..-1].each_with_index do |line, idx|\n\n # ignore maps and lists\n if line =~ /default/ && (line =~ /\\[/ || line =~ /\\{/)\n return nil\n end\n\n if line =~ /^\\}$/\n closing_brace_index = idx\n break\n end\n end\n\n lines[start_index..start_index + closing_brace_index]\n end", "def lines_of(range)\n min_words = range.first\n max_words = range.last\n words_left = 0\n line = []\n\n @sentences.inject([]) do |result, sentence|\n too_few_words = proc { line.size < min_words || words_left < min_words }\n too_many_words = proc { line.size >= max_words ||\n line.size + words_left > max_words && words_left <= min_words }\n end_line = proc { result << line.join(\" \") and line.clear }\n words = sentence.split\n word_count = words.size\n\n next result << sentence if word_count < min_words * 2\n\n line.clear\n words.each_with_index do |word, i|\n words_left = word_count - i\n if too_few_words[]\n line << word\n end_line.call if word =~ /[,;]$/ && !too_few_words[]\n elsif too_many_words[] || word =~ /^['\"]|^(and|that|or|for|nor|if)$/\n end_line.call\n line << word\n elsif word =~ /[,;]$/\n line << word\n end_line.call\n else\n line << word\n end\n end\n result << line.join(\" \")\n end\n end", "def find_stations(mta, start_station, end_station)\n\n # Find the lines the stations are on\n lines = find_lines mta, start_station, end_station\n\n # Find the indexes on the found lines\n origin_index = mta[lines[0]].index(start_station)\n origin_union_index = mta[lines[0]].index(\"Union Square\")\n dest_union_index = mta[lines[1]].index(\"Union Square\")\n dest_index = mta[lines[1]].index(end_station)\n\n # Return an array of the results\n stations = [lines[0], origin_index, origin_union_index, lines[1], dest_union_index, dest_index]\nend", "def get_word_end_marks(startpos, endpos)\n startpos = 0 if startpos < 0\n endpos = self.size if endpos > self.size\n search_str = self[(startpos)..(endpos)]\n return if search_str == nil\n wsmarks = scan_indexes(search_str, /(?<=\\p{Word})[^\\p{Word}]/)\n wsmarks = wsmarks.collect { |x| x + startpos - 1 }\n return wsmarks\n end", "def format_start_stop(start, stop)\n tmp_start = start\n tmp_stop = stop\n\n if start > stop\n tmp_start, tmp_stop = stop, start\n end\n return tmp_start, tmp_stop\n end", "def compute_skips(pattern)\n \n end", "def exclude_end?() end", "def remove_before(stop)\n remove_by_range(nil, stop)\n end", "def stops_between_stations(startLine, startPos, endLine, endPos)\n#defining the lines \nredline = [\"South Station\",\"Park Street\",\"Kendall\",\"Central\",\"Harvard\",\"Porter\",\"Davis\",\"Alewife\"]\ngreenline = [\"Government Center\",\"Park Street\",\"Boylston\",\"Arlington\",\"Copley\",\"Hynes\",\"Kenmore\"]\norangeline = [\"North Station\",\"Haymarket\",\"Park Street\",\"State\",\"Downtown Crossing\",\"Chinatown\",\"Back Bay\",\"Forest Hills\"]\n\nrefer = {\n\"Red\" => redline,\n\"Green\" => greenline,\n\"Orange\" => orangeline,\n} \n\n\n intro1 = \"You must travel through the following stops on the #{startLine}:\"\n intro2 = \"Your trip continues through the following stops on #{endLine}:\" \n\n\n #if you are in the same line then just count it onece \nif startLine == endLine\nsingleLine(refer[startLine], startPos, endPos)\nelse\np intro1\narr1 = singleLine(refer[startLine], startPos, \"Park Street\")\np arr1[0]\np intro2\narr2 = singleLine(refer[endLine], \"Park Street\", endPos)\np arr2[0]\np \"#{arr1[1]+arr2[1]} stops in total.\"\nend\n\n\nend", "def get_path_by_names(start, stop)\n s1 = get_node(start)\n s2 = get_node(stop)\n if s1 != nil && s2 != nil\n return get_path(s1, s2)\n end\n Array.new \n end", "def from_first_line_matching(regex_from)\n arr_lines = self.split(\"\\n\")\n ix1 = arr_lines.index_regex(regex_from) || 0\n if ! ix1\n throw \"Cattivo Indice per arr_lines. Non greppa una fava con: #{regex_from}\"\n ix1 = 0\n end\n ix2 = arr_lines.length\n deb \"#{ix1}..#{ix2}\"\n joint = arr_lines[ix1..ix2].join(\"\\n\") #rescue ''\n return joint \n end", "def around_lines(needle)\n\n file = @file\n pos = file.pos\n result = \"\"\n\n # scan min\n file.seek(pos)\n min = seek_contiguous_min(needle) || pos\n\n # scan max\n file.seek(pos)\n max = seek_contiguous_max(needle) || pos\n\n # for debug\n # p [\n # pos: pos,\n # min: min,\n # max: max\n # ].to_s\n # sleep 0.05\n\n # read\n # - require succeed scan processes\n if max > min\n file.seek(min)\n result = file.read(max - min)\n end\n\n result\n end", "def first_ip_on_line(line, start=nil)\n i = 1\n total = @lines.size\n\n while i < total\n cur_line = @lines.at(i)\n if cur_line >= line\n ip = @lines.at(i-1)\n\n if !start or ip > start\n # matched the definition line, return 0\n return 0 if ip == -1\n return ip\n end\n end\n\n i += 2\n end\n\n nil\n end", "def apply_to(tokenstream)\n start_idxs=nil\n end_idxs=nil\n @start_rules.each do |rule|\n start_idxs=rule.apply_to tokenstream\n break if !start_idxs.empty?\n end\n @end_rules.each do |rule|\n end_idxs=rule.apply_to tokenstream\n end_idxs.reverse! #So the start_idxs and end_idxs match up\n break if !end_idxs.empty?\n end\n result=[]\n unless start_idxs.empty? && end_idxs.empty?\n # Following expression deals with the case where the first start rule\n # matches after the first end rule, indicating that all tokens up to the\n # end rule match should be a list item\n if start_idxs.first > end_idxs.first\n start_idxs.insert(0, 0)\n Log.debug \"First start rule matched after the first end rule\"\n end\n if end_idxs.last < start_idxs.last\n end_idxs << (tokenstream.size - 1)\n Log.debug \"Last end rule matches before the last start rule\"\n end\n Log.debug \"RuleSet matched with start_idxs=#{start_idxs.inspect} and end_idxs=#{end_idxs.inspect}\"\n start_idxs.zip(end_idxs) do |start_idx, end_idx|\n if start_idx && end_idx\n if start_idx > end_idx\n Log.debug \"start_idx=#{start_idx} was larger than end_idx=#{end_idx}, have to skip this pair\"\n next\n end\n result << tokenstream.slice_by_token_index(start_idx, end_idx)\n yield result.last if block_given?\n else\n break\n end\n end\n end\n return result\n end", "def stopped_at; end", "def stopped_at; end", "def stopped_at; end", "def next_match str, startline=nil, endline=nil\n # 1. look in current row after the curpos\n # 2. if no match look in rest of array\n # 3. if no match and you started from current_index, then search\n # from start of file to current_index. call _next_match with 0.\n _arr = _getarray\n if !startline\n startline = @current_index\n pos = @curpos + 1\n # FIXME you could be at end of line\n #_line = _arr[startline]\n _line = to_searchable(startline)\n _col = _line.index(str, pos) if _line\n if _col\n return [startline, _col]\n end\n startline += 1 # FIXME check this end of file\n end\n # FIXME iterate only through the ones we need, not all\n _arr.each_with_index do |line, ix|\n next if ix < startline\n break if endline && ix > endline\n # next line just a hack and not correct if only one match in file FIXME\n line = to_searchable(ix)\n _col = line.index str\n if _col\n return [ix, _col]\n end\n end\n if startline > 0\n return next_match str, 0, @current_index\n end\n return nil\n\n end", "def getTripString(line, startStop, endStop) \n lineArray = getLine(line)\n string = \"\" # to save the station \n start_point = lineArray.index(startStop) # save the index of start point\n end_point = lineArray.index(endStop) # save the index of end point\n # p start_point \n # p end_point\n if start_point > end_point\n start_point.downto(end_point) do |j| \n string += \"#{lineArray[j]}, \"\n end\n else\n start_point.upto(end_point) do |j|\n string += \"#{lineArray[j]}, \"\n end \n end \n return string[0...-2] \nend", "def getStops(stopA, stopB, cL)\n $count += (stopA - stopB).abs;\n stopA < stopB ? cL[stopA..stopB][1..-1].join(\", \") : cL[stopB..stopA].reverse[1..-1].join(\", \") end", "def rm_block(start_id, end_id, path)\n puts \"Removing string block from #{start_id} to #{end_id} #{path}\".colorize(:light_red)\n\t\tstart_regexp = Regexp.new(Regexp.escape(start_id))\n\t\tend_regexp = Regexp.new(Regexp.escape(end_id))\n\t\tlines, new_lines, result = [], [], true\n\t\tFile.open(path, 'r'){|f| lines = f.readlines }\n\t\tlines.chunk { |line|\n\t\t\tif line =~ start_regexp\n\t\t\t\tresult = false\n\t\t\telsif line =~ end_regexp\n\t\t\t\tresult = true\n\t\t\tend\n\t\t\tresult\n\t\t}.each{ |result, arr| \n\t\t\tif result\n\t\t\t\tarr[0] =~ end_regexp ? arr.shift : arr\n\t\t\t\tnew_lines << arr\n\t\t\tend\n\t\t}\n\t\tFile.open(path, 'w+'){|f| f.write(new_lines.join)}\n\tend", "def lex_end line\n ends << line\n end", "def def_and_end_lines(tokens, t_ix)\n t1 = tokens[t_ix]\n t2 = tokens[(t_ix + 1)..-1].find(-> { tokens[-1] }) do |t|\n [t1.pos.column, t.type, t.text] == [t.pos.column, :on_kw, 'end']\n end\n [t1.pos.lineno, t2.pos.lineno]\n end", "def range_by_lines(range)\n begin_of_first_line = range.begin_pos - range.column\n\n last_line = range.source_buffer.source_line(range.last_line)\n last_line_offset = last_line.length - range.last_column\n end_of_last_line = range.end_pos + last_line_offset\n\n Parser::Source::Range.new(range.source_buffer,\n begin_of_first_line,\n end_of_last_line)\n end", "def seek_pos lines, series\n i, j = 0, 0\n best_match = [nil, nil]\n while line = lines[i]\n i += 1\n if line !~ /^\\s*$/\n indent, _, _, pattern = series[j]\n return [i, j] if !indent # max match\n if line =~ pattern\n j += 1\n best_match = [i, j] if !best_match[1] or best_match[1] < j\n else\n leading = line[/^\\s*/].size\n # when 0?\n if leading > 0 and leading < indent.size\n i -= 1\n j = leading / 2 - 1\n end\n end\n end\n end\n best_match\nend", "def start_word_pattern; end", "def validate_trailing_stop_constraints\n if trailing_stop\n raise ArgumentError, 'do not set stop_level when trailing_stop is true' if stop_level\n raise ArgumentError, 'set stop_distance when trailing_stop is true' unless stop_distance\n raise ArgumentError, 'set trailing_stop_increment when trailing_stop is true' unless trailing_stop_increment\n elsif trailing_stop_increment\n raise ArgumentError, 'do not set trailing_stop_increment when trailing_stop is false'\n end\n end", "def search_for_a_node_after_another( nokogiri_nodeset, first_key_word, last_key_word )\n matches_found = 0\n start_copy = false\n\n # Convert node content to text lines and scan them all:\n nokogiri_nodeset.text.split(\"\\n\").each do |line|\n\n # Search for a terminator key only if we have begun:\n if start_copy\n start_copy = false if !( line =~ /#{ last_key_word }/ui ).nil?\n # Increase sequences found on end copy:\n matches_found += 1 if !start_copy\n# DEBUG\n puts line if start_copy\n\n # Search for a start only if we haven't already found one:\n else\n start_copy = !( line =~ /#{ first_key_word }/ui ).nil?\n end\n end\n matches_found\n end", "def last_lines\n @last_lines ||= begin\n list = []\n @text.lines.to_a.reverse.each do |line|\n list << line\n break if line =~ /^\\S/\n end\n list.reverse\n end\n end", "def stop\n [ @start_time, (@stop_time = @stop_time.nil? ? Time.now : @stop_time) ]\n end" ]
[ "0.63357574", "0.6192202", "0.6184756", "0.61638033", "0.60248387", "0.59344727", "0.59344727", "0.58625984", "0.58625984", "0.5849838", "0.57943946", "0.57723165", "0.5752128", "0.5701853", "0.5661415", "0.5562728", "0.55192155", "0.55192155", "0.55192155", "0.5507625", "0.5498823", "0.5470617", "0.5470617", "0.5470617", "0.546455", "0.5436145", "0.5435312", "0.54228354", "0.54092216", "0.5386538", "0.53839874", "0.538222", "0.53733677", "0.53725857", "0.5367168", "0.5354431", "0.53510773", "0.53287995", "0.5322422", "0.52012783", "0.5162515", "0.51261634", "0.5103653", "0.509882", "0.5073881", "0.5042747", "0.5033876", "0.5030487", "0.5014299", "0.49985695", "0.49897394", "0.4959255", "0.49533147", "0.4950984", "0.49418548", "0.4926921", "0.4921322", "0.49019983", "0.48972023", "0.48963618", "0.48922616", "0.48896173", "0.48707813", "0.48686686", "0.4868341", "0.48678297", "0.4864057", "0.48624778", "0.48557428", "0.48217764", "0.4821621", "0.4813358", "0.4796252", "0.47874457", "0.47848797", "0.47716182", "0.4758646", "0.47565332", "0.47359928", "0.47271332", "0.4725946", "0.47248897", "0.4715946", "0.471479", "0.47077549", "0.47077549", "0.47077549", "0.47060856", "0.46924573", "0.46923554", "0.4690955", "0.4690348", "0.46897718", "0.46741694", "0.4673147", "0.46665847", "0.46652836", "0.4650644", "0.4649043", "0.46437693" ]
0.7444937
0
You were given a natural number 'number'. Return all its digits one by one in reverse order separating them by spaces or new lines You should not use string, array or loops. Use only recursion and arithmetic operators. 961 = 169
def reverse_digits(num) num_array = num.to_s.chars return num_array[0] if num_array.length == 1 "#{num_array.pop} " + reverse_digits(num_array.join.to_i) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse(number)\n digits = number.to_s.chars\n reversed = []\n if digits.length <= 1\n number\n else\n reversed << digits.pop\n reversed << reverse(digits.join.to_i)\n reversed.join.to_i\n end\nend", "def reverse(number)\n return number if number < 10\n array = number.to_s.split(//)\n\n test_number = array.first.to_i\n new_array = array.drop(1)\n\n new_number = reverse(new_array.join.to_i)\n new_number * 10 + test_number\nend", "def reversed_number(number)\n list_reversed = []\n number.to_s.split('').each {|num| list_reversed.unshift(num) }\n list_reversed.join.to_i\nend", "def reverse(number)\n return number if number.to_s.length == 1 #1 is the last number to go\n number_array = number.to_s.split(\"\")\n first_element = number_array.pop #ie 2 (from base)\n new_number = number_array.join(\"\").to_i\n recursive_call = first_element.to_s + reverse(new_number).to_s #take advantage of string concat\n\n output_string = \"\"\n number = output_string + recursive_call\n number.to_i\nend", "def reversed_number(number)\n result = ''\n numbers = number.to_s\n numbers.each_char do |num|\n result.prepend(num) # prepend to take the end of the array and add it to the 'result' array.\n end\n result.to_i # convert to integer\nend", "def number_reverser(number)\n result = 0\n while number != 0\n digit = number % 10\n result = (result * 10) + digit\n number = number / 10\n end\n result\nend", "def reverse(number)\n digits = number.to_s.split(\"\")\n digits.reverse!\n return digits.to_s.to_i\nend", "def reversed_number(number)\n reversed = []\n leading = true\n\n number.digits.each do |digit|\n unless leading && digit == 0\n leading = false\n reversed.push(digit)\n end\n end\n\n reversed.join.to_i\nend", "def reversed_number(integer)\n result = []\n until integer.zero?\n integer, remainder = integer.divmod(10)\n result.push(remainder)\n end \n p result.inject { |number, digit| number * 10 + digit }\nend", "def digits(number)\n digits = []\n\n while number != 0\n digits << number % 10\n number = number / 10\n end\n\n digits.reverse.join\nend", "def reversed_number(number)\n number.to_s.chars.reverse.join.to_i\nend", "def reversed_number(number)\n number_string = number.to_s # convert to string\n number_chars = number_string.chars # chars to split string to individual characters in an array\n reversed_string = number_chars.reverse # 'reverse' the array\n numbers = reversed_string.join('') # join the array\n numbers.to_i # convert array to integers\nend", "def digitize_1(n)\n list = []\n puts n.to_s\n \n n.to_s.each_char do |char| \n list << char.to_i\n end\n\n return list.reverse\nend", "def reverse_digits(number)\n numberArray = number.to_s.split('')\n numberArray = numberArray.reverse\n \n newInt = \"\"\n numberArray.each do |element|\n newInt += element\n end\n return newInt.to_i\n \n \nend", "def reverse(number)\n \n digits = number.to_s.split(\"\").dup\n return number if digits.length == 1\n last = digits.pop\n p \"last == #{last.inspect}\"\n new_num = Integer(digits.to_s)\n Integer(last << reverse(new_num).to_s)\nend", "def reversed_number(number)\n number.to_s.chars.reverse.join('').to_i\nend", "def reversed_number(num)\n num.to_s.split(//).reverse.join.to_i\nend", "def reverse(number)\n if number < 10\n return number\n end\n \n multiplier = 10\n \n until multiplier > number / 10\n multiplier *= 10\n end\n \n return ((number % 10) * multiplier) + reverse(number / 10) \n \nend", "def reversed_number(num)\n num.to_s.chars.reverse.join.to_i\nend", "def expanded_form(num)\n number = num.to_s # This will be \"12\"\n num_digits = num.to_s.length\n split_number = number.split(\"\").reverse # This will be [\"2\",\"1\"]\n expanded_array = []\n 0.upto(num_digits-1) do |n| # This will be 0 up to 1\n single_split_number = split_number[n].to_i*(10**n)\n next if single_split_number == 0\n expanded_array << single_split_number.to_s\n end\n expanded_array.reverse! # This will be [\"10\",\"2\"]\n output_array = expanded_array.join(\" + \") # Final statement\nend", "def reversed_number(num)\n num.digits.join.to_i\nend", "def digitize(n)\n split_array_numbers = n.to_s.split(//).map { |x| x.to_i}.reverse\nend", "def reversed_number(num)\n num.to_s.chars.reverse.join('').to_i\nend", "def digit_list(integer)\n integer.digits.reverse\nend", "def reverse(num)\n reverse = 0\n while num > 0\n last_num = num % 10\n reverse = (reverse * 10) + last_num\n num = num / 10\n end\n return reverse\nend", "def reverse(n)\n reversed = 0\n while n > 0\n reversed = 10 * reversed + n % 10\n n = n / 10\n end\n reversed\nend", "def reversed_number(num)\n num.to_s.split('').reverse.join('').to_i\nend", "def digit_list(num)\n num.digits.reverse\nend", "def digit_list(num)\n num.digits.reverse\nend", "def digit_list1(num)\n num.digits.reverse\nend", "def reversed_number_re(num)\n num.to_s.reverse.to_i\nend", "def reverse_number\n number = 12345\n tmp = 0\n while number != 0 do\n tmp = tmp * 10 + (number % 10)\n number = number / 10\n end\n puts tmp\nend", "def reversed_number(int)\n final = []\n until int <= 0\n int, to_push = int.divmod(10)\n final << to_push\n end\n final.join.to_i\nend", "def digit_list(integer)\n integer.digits.reverse\nend", "def reversed_number(number)\n \n reversed_num = number.to_s.reverse\n reversed_num.to_i\nend", "def reversed_number(integer)\n integer_array = integer.to_s.chars\n\n reversed_string = integer_array.reverse.join\n\n result = ''\n reversed_string.each_char do |int|\n result << Integer(int, 10).to_s\n end\n result.to_i\nend", "def reversed_number(integer)\n p integer.digits.join.to_i # .to_i automatically omit the leading 0s\n end", "def reversed_number(n)\n n.to_s.reverse.to_i\nend", "def reversed_number(n)\n n.to_s.reverse.to_i\nend", "def digit_list(int)\n int.digits.reverse\nend", "def digit_list(int)\n int.digits.reverse\nend", "def reversed_number(number)\n number.to_s.reverse.to_i\nend", "def reversed_number(number)\n number.to_s.reverse.to_i\nend", "def reversed_number(number)\n number.to_s.reverse.to_i\nend", "def reversed_number(int)\r\n int.digits.join.to_i\r\nend", "def descending_order(n)\n array = n.digits\n puts array.sort!.reverse!.join.to_i\n \nend", "def descending_order(n)\n n.digits.sort().reverse.join.to_i\nend", "def descending_order(n)\n n.digits.sort.reverse.join.to_i\nend", "def descending_order(n)\n digit_arr = n.to_s.chars\n sorted_str = digit_arr.sort.reverse.join\n sorted_num = sorted_str.to_i\nend", "def solution(number)\n roman_numeral = { 1 => 'I', 4 => 'IV', 5=> 'V', 6 => 'VI', 10=> 'X', 50=> 'L', 100=> 'C', 500=> 'D', 1000=> 'M' }\n numbers = number.digits.map.with_index{ |int, idx| int * 10**idx }\n numbers.map{ |number| roman_numeral[number] }.reverse.join\nend", "def descending_order(n)\n if n.to_i >= 0\n n.digits.sort.reverse.join.to_i\n end\n\nend", "def reversed_number(num)\n num.to_s.reverse.to_i \nend", "def reversed_number(num)\n\tnum.to_s.reverse.to_i\nend", "def separate_comma(number)\n reversed_array = number.to_i.to_s.split(\"\").reverse\n commaized = []\n\n current_digit = 0\n while current_digit < reversed_array.length\n commaized.unshift(reversed_array[current_digit])\n\n if ((current_digit + 1) % 3 == 0) && (reversed_array[current_digit + 1] != nil)\n commaized.unshift(\",\")\n end\n\n current_digit += 1\n end\n\n return commaized.join\nend", "def reversed_number(num)\n num.to_s.reverse.to_i\nend", "def reversed_number(num)\n num.to_s.reverse.to_i\nend", "def reversed_number(num)\n num.to_s.reverse.to_i\nend", "def reversed_number(num)\n num.to_s.reverse.to_i\nend", "def reversed_number(num)\n num.to_s.reverse.to_i\nend", "def reversed_number(num)\n num.to_s.reverse.to_i\nend", "def reverse_digits(int)\n # return int.to_s.reverse.to_i\n\n digs = int.to_s\n rev_digs = \"\" \n\n i = digs.length - 1\n while i >= 0\n rev_digs << digs[i]\n i -= 1\n end\n return rev_digs\nend", "def separate_comma(integer)\n if integer >= 1000\n number_array = integer.to_s.split(\"\").reverse\n counter = 0\n array_for_reverse = []\n number_array.each do |digit|\n if counter % 3 == 0 && counter != 0\n array_for_reverse << \",\"\n end\n array_for_reverse << digit\n counter += 1\n end\n final = \"\"\n array_for_reverse.reverse.each do |digit|\n final << digit\n end\n else\n final = integer.to_s\n end\n return final\nend", "def number_to_string(integer)\n array_of_integers = []\n while integer != 0\n array_of_integers << integer % 10\n integer /= 10\n end\n array_of_integers.reverse.join\nend", "def integer_to_string(number)\n result = []\n loop do\n divisor, remainder = number.divmod 10\n result.unshift(remainder) # or use push/<<, then reverse the array after loop ends\n break if divisor == 0\n number = divisor\n end\n \n result.join\nend", "def rotate_rightmost_digits(number, n)\nall_digits = number.to_s.chars\nall_digits[-n..-1] = rotate_array(all_digits[-n..-1])\nall_digits.join.to_i\nend", "def digit_list(positive_integer)\n positive_integer.digits.reverse!\nend", "def solution(n)\n n.to_s.reverse.scan(/\\d{1,3}/).join(',').reverse\nend", "def rotate_rightmost_digits(number, n)\n number_array = number.to_s.chars\n number_array[-n..-1] = rotate_array(number_array[-n..-1])\n number_array.join.to_i\nend", "def expanded_form(num)\n array = num.to_s.split(\"\")\n length = num.to_s.size - 1\n numbers_array = []\n\n array.each do |number|\n numbers_array << number.to_i * 10**(length)\n length -= 1\n end\n\n numbers_array.delete_if {|i| i == 0} # cleans up 0s from array. For example: expanded_form(70304)\n numbers_array.join(\" + \")\n\nend", "def rev(n)\n n.to_s.chars.reverse.join('').to_i\nend", "def rotate_rightmost_digits(number, n)\np all_digits = number.to_s.chars\n# all_digits[-n..-1] = rotate_array(all_digits[-n..-1])\nend", "def rotate_rightmost_digits(number, n)\n all_digits = number.to_s.chars\n all_digits[-n..-1] = rotate_array(all_digits[-n..-1])\n all_digits.join.to_i\nend", "def digit_list(number)\n digits = []\n\n until number == 0 do\n digits.unshift(number % 10)\n number /= 10\n end\n\n digits\nend", "def reverse_digit(original)\n reverse = 0\n # check if there is any numbers left\n while original > 0\n # adding the lass digit to reverse\n reverse = (reverse*10) + (original%10)\n # removing the lass digit from the original\n original=original/10\n end\n return reverse\nend", "def delete_digit(number)\n deleted = number.digits.reverse.combination(number.digits.length - 1).to_a\n int_to_string = deleted.map do |sub_arr|\n sub_arr.map do |num|\n num.to_s\n sub_arr.join\n end\n end\n \n int_to_string.flatten.sort_by {|a| a.to_i}.last.to_i\nend", "def reversed_number(int)\n # output = 0\n # reversed_array = int.to_s.chars.reverse\n # p reversed_array\n int.to_s.reverse.to_i\nend", "def rotate_rightmost_digits(number, n)\n arr = number.digits.reverse\n e = arr.delete_at(-n)\n arr << e\n arr.join.to_i\nend", "def descending_order(n)\n\tsplit_up = n.to_s.chars.map(&:to_i)\n\tsorted = split_up.sort\n\tputs sorted.reverse.join.to_i\nend", "def digit_list(number)\n digits = []\n\n loop do\n break if number == 0\n\n digit = number % 10\n digits.unshift(digit)\n\n number = number / 10\n end\n\n digits\nend", "def reversed_number2(num)\n num.to_s.reverse.to_i\nend", "def rotate_rightmost_digits(number, n)\n array = number.to_s.split(//)\n removed_element = array[-n]\n array.slice!(-n)\n [array, removed_element].flatten.join.to_i\nend", "def number_reverser(integer)\n string = integer.to_s.reverse!\n string.to_i\nend", "def reversed_number(num)\n\nend", "def reversed_number(integer)\n integer.to_s.reverse.to_i\nend", "def reversed_number(integer)\n integer.to_s.reverse.to_i\nend", "def reversed_number(integer)\n integer.to_s.reverse.to_i\nend", "def to_string(number)\n str_array = []\n loop do\n str_array.unshift(number % 10)\n number /= 10\n break if number == 0\n end\n str_array.join\nend", "def descending_digits(int)\n # your code goes here\n int.to_s.split('').sort.reverse\nend", "def rotate_rightmost_digits_alt(number, n)\n digits = number.digits.reverse\n digits[-n..-1] = rotate_array_alt(digits[-n..-1])\n digits.join.to_i\nend", "def descending_digits(int)\r\n # your code goes here\r\n\r\n int.to_s.split(\"\").sort.reverse\r\nend", "def expanded_form(num)\n size = num.to_s.size\n result = []\n i = 1\n while i < size\n rest = num % 10**i\n num -= rest\n result.unshift(rest)\n i += 1\n end\n result.unshift(num).delete(0)\n result.join(\" + \")\nend", "def descending_digits(int)\n int.to_s.split('').sort.reverse\nend", "def descending_digits(int)\n int.to_s.split('').sort.reverse\nend", "def descending_digits(int)\n int.to_s.split(\"\").sort.reverse\nend", "def rotate_rightmost_digits(num, n)\n num = num.digits.reverse\n rotators = num.pop(n)\n result = num + rotate_array(rotators)\n result.join.to_i\nend", "def reversed_number(num)\n num_as_str = num.to_s\n num_as_str.reverse.to_i\nend", "def descending_digits(int)\n int.to_s.split(\"\").sort.reverse\nend", "def reverse(num)\n num.to_s.reverse.to_i\nend", "def rotate_rightmost_digits(num, n)\n arr = num.digits.reverse\n rotate_arr = rotate_array(arr.pop(n))\n (arr + rotate_arr).join.to_i\nend", "def reversed_number(int)\n int.to_s.reverse.to_i\nend" ]
[ "0.7983433", "0.7924465", "0.7897425", "0.78974044", "0.7748002", "0.7695915", "0.7676868", "0.7644665", "0.7576181", "0.7562105", "0.7555308", "0.7548733", "0.7544453", "0.7520428", "0.74918747", "0.745448", "0.7442109", "0.74349946", "0.7390438", "0.73695767", "0.73675334", "0.7316686", "0.72942245", "0.7278972", "0.72686255", "0.72555804", "0.72510827", "0.7243563", "0.7243563", "0.7218975", "0.7197505", "0.7190111", "0.7175183", "0.71555567", "0.71217394", "0.7118932", "0.71065074", "0.7106482", "0.7106482", "0.71007043", "0.71007043", "0.71003866", "0.71003866", "0.71003866", "0.7098482", "0.7086834", "0.7077377", "0.70439297", "0.7008867", "0.6984051", "0.69765544", "0.697297", "0.69617534", "0.6958275", "0.69335324", "0.69335324", "0.69335324", "0.69335324", "0.69335324", "0.69335324", "0.69305634", "0.6924741", "0.6889847", "0.6888836", "0.68805814", "0.68747467", "0.68652374", "0.6860223", "0.6848812", "0.68445015", "0.6836431", "0.6829449", "0.6820314", "0.68103445", "0.6793693", "0.6781001", "0.67767674", "0.67700577", "0.6758457", "0.6754792", "0.6748125", "0.67379427", "0.6724135", "0.6723111", "0.6723111", "0.6723111", "0.67208225", "0.67178667", "0.6713133", "0.6705989", "0.670239", "0.67018", "0.67018", "0.66990906", "0.6695552", "0.66920424", "0.66814953", "0.6670793", "0.66700715", "0.6668193" ]
0.72806966
23
This method compares the users response to the list of valid responses and outputs an error and main menu return if not valid. LOVE THIS!!!
def verified_answer(user_response, list_of_responses) if list_of_responses.include? user_response user_response else invalid_return_mm end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_for_valid_response(resp)\n if resp == 'exit!'\n game_data.save\n elsif game_data.chosen_letters.include?(resp)\n repeat_response_query('repeat')\n elsif resp.length > 1\n repeat_response_query('multiple')\n else\n action(resp)\n end\n end", "def validate_user_responses(responses)\n failed = false\n puts \"*** VALIDATING USER RESPONSES ***\"\n\n @i = 0\n \n while(@i < responses.length)\n @response = nil\n @index = @i.to_s\n @resp = responses[@index]\n @id = @resp[:id]\n puts \"*** VALIDATING response no. \" + @i.to_s + \", ID=\" + @id + \" ***\" \n \n begin \n @response = Response.find(@id) \n rescue ActiveRecord::RecordNotFound\n puts \"RESPONSE NOT FOUND\"\n failed = true\n break\n end\n\t\n\t\t if (@response.user.id != current_user.id)\n\t\t puts (\"ID MISMATCH: actual: #{current_user.id} expected: #{@response.user.id}\")\n\t\t failed = true\n\t\t break \n\t\t end\n\t\t @i += 1\n\t end\n\t \n return !failed\n end", "def checkUserInput\r\n #initialize mainmenu selection characters array\r\n @mainMenuCharSelection = [\"c\",\"l\",\"u\",\"d\",\"e\"];\r\n #check user input for input validation\r\n if(@mainMenuCharSelection.include? @userInput.downcase)\r\n case @userInput.downcase\r\n when \"c\"\r\n result = BackEndLogic.create(politicians);\r\n \r\n politicians << result;\r\n when \"l\"\r\n BackEndLogic.list(politicians);\r\n when \"u\"\r\n BackEndLogic.update(politicians);\r\n when \"d\"\r\n result = BackEndLogic.remove(politicians);\r\n when \"e\"\r\n @ismainMenuLoop = false;\r\n else\r\n puts \"entry unkown! Try again! \\n\\n\"\r\n end\r\n else\r\n puts \"Please enter a valid choice from the menu options! You chose (#{@userInput}) \\n\\n\";\r\n end\r\n end", "def menu_prompt( input_list, prompt_str )\n # go in to an infinite loop\n while true\n puts menu_print( \"Please choose one option:\", \" \" )\n puts menu_print( prompt_str, \" \")\n # note: even tho the name is the same, this is separate from the\n # var user_response in the procedure outside this method!!! :)\n user_response = gets.chomp.downcase.to_sym\n \n # check user_response against acceptable input list\n if input_list.include?( user_response )\n return user_response # explicit return breaks the loop\n end\n \n puts \"\\n\" + menu_print( \"Sorry, that is not acceptable input...\", \"*\" ) + \"\\n\"\n end\nend", "def check_response\n errors.add(:base, :invalid) unless response.present? && response[\"res\"] == 1\n end", "def get_menu_or_exit\n puts \"\\n\n There you go! Interesting, amirite?\\n\n Enter 'main' to return to the main menu,\\n\n or if you're done here enter 'exit':\"\n valid_response = false\n until valid_response == true\n user_input = gets.chomp\n if user_input == 'exit'\n valid_response = true\n elsif user_input == 'menu'\n valid_response = true\n else\n puts \"\\n\n Invalid input. Please enter 'main' or 'quit' below:\"\n end\n end\n user_input\n end", "def invalid_return_mm\n puts \"Invalid option : No match found. Returning to the main menu.\".center(80)\n main_menu\n end", "def checkUserInputForCreateMenu(arr)\r\n #initialize mainmenu selection characters array\r\n @mainMenuCharSelection = [\"p\",\"v\"];\r\n #check user input for input validation\r\n if(@mainMenuCharSelection.include? @userInput.downcase)\r\n case @userInput.downcase\r\n when \"p\"\r\n puts \"Name?\";\r\n\r\n checkExistingNames(arr);\r\n\r\n name = @userInput;\r\n\r\n @userInput = \"\";\r\n while(@userInput.downcase != \"d\" && @userInput.downcase != \"r\" )\r\n puts \"Party? (D)emocrat or (R)epublican\"\r\n @userInput = gets.chomp;\r\n end\r\n\r\n party = @userInput == \"d\" ? \"Democrat\" : \"Republican\";\r\n p = Politician.new(name,party,\"Politician\")\r\n \r\n @ismainMenuLoop = false;\r\n return p;\r\n when \"v\"\r\n puts \"Name?\"\r\n \r\n checkExistingNames(arr);\r\n\r\n name = @userInput;\r\n\r\n @userInput = \"\";\r\n compareArr = [\"l\",\"c\",\"t\",\"s\",\"n\"];\r\n while(!compareArr.include? @userInput.downcase)\r\n puts \"Politics?\\n(L)iberal, (C)onservative, (T)ea Party, (S)ocialist, or (N)eutral\"\r\n @userInput = gets.chomp;\r\n end\r\n\r\n politics = \"\";\r\n case @userInput.downcase\r\n when compareArr[0]\r\n politics = \"Liberal\";\r\n when compareArr[1]\r\n politics = \"Conservative\"\r\n when compareArr[2]\r\n politics = \"Tea Party\"\r\n when compareArr[3]\r\n politics = \"Socialist\"\r\n when compareArr[4]\r\n politics = \"Neutral\"\r\n else\r\n puts \"Wrong choice\"\r\n end\r\n p = Politician.new(name,politics,\"Voter\")\r\n \r\n @ismainMenuLoop = false;\r\n return p;\r\n else\r\n puts \"entry unkown! Try again! \\n\\n\"\r\n end\r\n else\r\n puts \"Please enter a valid choice from the menu options! You chose (#{@userInput}) \\n\\n\";\r\n end\r\n end", "def antibody_test_result_prompt\n puts \"\\nIf you know the antibody test result, please enter if it was positive or negative by typing 'positive' or 'negative'.\"\n antibody_res_response = gets.strip.downcase\n return_to_menu(antibody_res_response)\n exit_anything(antibody_res_response)\n if antibody_res_response == \"positive\" \n anti_body_test_result = true\n elsif antibody_res_response == \"negative\"\n anti_body_test_result = false\n else puts \"\\nDid you mean to hit 'positive', 'negative', 'menu', or 'exit'?\"\n antibody_test_result_prompt\n end\n anti_body_test_result\nend", "def showMainMenu\r\n #clear user input field\r\n @userInput = \"\";\r\n #display main menu respond to user and wait for response\r\n @userRespone = \"Welcome To Voter Simulation! \\n\\nWhat would you like to do?\\n(C)reate, (L)ist, (U)pdate, (D)elete or (E)xit\"\r\n puts @userRespone;\r\n @userInput = gets.chomp;\r\n #call check user input after coming out of the loop\r\n checkUserInput();\r\n end", "def validation\n\n\t\tputs \"Enter user name\"\n\t\tuser_name = gets.chomp\n\n\t\tputs \"Enter password\"\n\t\tanswer_password = gets.chomp\n\t\tif answer_password == @password\n\t\t\tget_text\n\t\telse\n\t\t\tcounter = 0\n\t\t\twhile counter !=3 || answer_password!=@password do\n\t\t\t puts \"invalid password\"\n\t\t\t $stdin.gets.chomp\n\t\t\t counter += 1\n\t\t\tend\n\t\tend\n\tend", "def validate_user_choice\n input = gets.chomp\n if input ==\"exit\"\n exit_screen\n elsif input == \"buy\"\n ticketing_screen\n elsif input.to_i == 1\n concert_screen\n elsif input.to_i == 2\n # if user doesn't want to buy a ticket yet, they can look for other upcoming bands and/or concerts by typing bands.\n bands_screen\n else\n unrecognized_input\n end\n end", "def validate_response(player)\n if response_equal_answer?\n player.score += 1\n return \"correct\"\n else\n player.lives -= 1\n return \"incorrect\"\n end\n end", "def get_valid_user_choice ###\n print \"\\nWhat would you like to do next? \\n(Enter 'list planets', 'planet details', 'add planet', or 'exit'.) \"\n @user_choice = gets.chomp.downcase\n\n until @user_choice == \"list planets\" || @user_choice == \"exit\" || @user_choice == \"planet details\" || @user_choice == \"add planet\"\n puts \"Please enter a valid choice: list planets, planet details, add planet, or exit.\"\n @user_choice = gets.chomp.downcase\n end\n end", "def answer_present\n if self.question.qtype == 'one_response' && self.response_id.nil?\n errors.add(:base, 'Please fill in an answer before leaving this page.' )\n return false\n elsif self.question.qtype == 'likert_scale' && self.response_id.nil?\n errors.add(:base, 'Please fill in an answer before leaving this page.' )\n return false\n\n elsif self.question.qtype == 'rank_three' \n responses = self.multianswers.map( &:rank ).compact\n if responses.length == 3 \n array_wanted = [1, 2, 3]\n if array_wanted == responses.sort\n return true\n else \n errors.add(:base, 'Please ensure all items are unique.' )\n return false\n end \n else \n errors.add(:base, 'Please ensure 3 items are ranked.' )\n return false\n end\n\n elsif self.question.qtype == 'rank_five' \n responses = self.multianswers.map( &:rank ).compact\n if responses.length == 5 \n array_wanted = [1, 2, 3, 4, 5]\n if array_wanted == responses.sort\n return true\n else \n errors.add(:base, 'Please ensure all items are unique.' )\n return false\n end \n else \n errors.add(:base, 'Please ensure 5 items are ranked.' )\n return false\n end\n end\n end", "def menu\n puts \"\\nPlease pick an option from the choices below:\\n1.) Follow a sport\\n2.) Remove a sport\\n3.) Show all the sports you follow\\n4.) Show sports teams\\n5.) Sign out\"\n answer = gets.chomp\n while answer != \"sign out\" || answer == \"4\"\n if answer == \"1\"\n create_subscription\n menu_prompt\n answer = gets.chomp\n #do we need to update the database now?\n elsif answer == \"2\"\n delete_subscription\n menu_prompt\n answer = gets.chomp\n elsif answer == \"3\"\n show_subscriptions\n menu_prompt\n answer = gets.chomp\n elsif answer == \"4\"\n show_teams\n puts \"\\nWould you like to see more info on any specific team? (Answer y for yes or n for no)\"\n reply = gets.chomp\n\n if reply == \"yes\" || reply == \"y\"\n show_team_info\n end\n\n menu_prompt\n answer = gets.chomp\n elsif answer == \"5\"\n puts \"\\nThanks for stopping by. See you soon!\"\n break\n else\n puts \"\\nThat is not a valid response, smart guy!\"\n menu_prompt\n answer = gets.chomp\n end\n end\n end", "def validate_allows_response\n if self.kase\n # self.errors.add(:kase, \"is %{status}\".t % {:status => self.kase.current_state_t}) unless self.kase.active?\n # self.errors.add(:kase, \"is not open\".t) unless self.kase.open?\n \n if self.person \n if self.kase.offers_reward?\n\n # only disallow rewarded self answers\n self.errors.add(:base, \"You cannot respond to your own rewarded %{type}\".t % {:type => self.kase.class.human_name}) unless self.person != self.kase.person\n\n end\n end\n end\n end", "def user_decision(x)\n loop do\n\n puts \"What would you like to do? (view, add, update, remove, search or exit)\"\n user_input = gets.chomp.downcase\n\n if user_input == 'exit'\n break\n\n elsif user_input == 'view'\n puts \"processing...\"\n view_contact_list(x)\n break\n\n elsif user_input == 'add'\n add_contact(x)\n puts \"processing...\"\n break\n\n elsif user_input == 'update'\n puts \"processing...\"\n update_contact(x)\n break\n\n elsif user_input == 'remove'\n puts \"processing...\"\n remove(x)\n break\n\n elsif user_input == 'search'\n puts \"processing...\"\n print_individual_contact(x)\n break\n\n else\n puts \"Invalid response. Please try again.\"\n end\n end\nend", "def error_response\n [\"I'm Sorry, I don't understand. Please try again\",\n \"Oh oh! Something went wrong. Please try again\",\n \"Um... Sorry, I don't understand. Did you input correct words?\"].sample\n end", "def error_response\n [\"I'm Sorry, I don't understand. Please try again\",\n \"Oh oh! Something went wrong. Please try again\", \n \"Um... Sorry, I don't understand. Did you input correct words?\"].sample\n end", "def get_response\r\n if @letter.size != 1\r\n puts \"Invalid input, try again\"\r\n elsif @secret_word_letters.include? @letter\r\n puts \"Yes! This word does include #{@letter}!\"\r\n elsif @chances > 1\r\n @chances -= 1\r\n puts \"#{@letter} is not a letter in the word. You have #{@chances} guesses left.\"\r\n else\r\n lost\r\n end\r\n end", "def options(name_input)\r\n puts \"Hi, #{name_input}! What would you like to do? \\n Press 1 for Appliance List \\n Press 2 to Add New Appliance \\n Press 3 for Warranty Status Report \\n Press 4 to exit\".colorize(:green)\r\n option_input = gets.chomp.strip.to_i\r\n #error prevention check if user input is not valid, they will be requested to re-enter their option choice. \r\n while option_input != 1 && option_input != 2 && option_input != 3 && option_input != 4\r\n puts \"Error. Invalid option. Please try again.\".colorize(:red)\r\n puts \"What would you like to do? \\n Press 1 for Appliance List \\n Press 2 to Add New Appliance \\n Press 3 for Warranty Status Report \\n Press 4 to exit\".colorize(:green)\r\n option_input = gets.chomp.strip.to_i\r\n 100.times {print \"-\"}\r\n puts()\r\n end\r\n #While loop is used here to allow continuous interaction with the app until user chooses to exit (4). \r\n counter = 0\r\n while counter == 0\r\n if option_input == 1\r\n 100.times {print \"=\"}\r\n puts()\r\n show_list_of_appliances(name_input)\r\n puts \"What would you like to do? \\n Press 1 for Appliance List \\n Press 2 to Add New Appliance \\n Press 3 for Warranty Status Report \\n Press 4 to exit\".colorize(:green)\r\n option_input = gets().chomp.strip.to_i\r\n 100.times {print \"-\"}\r\n puts()\r\n elsif option_input == 2\r\n puts \"What is your appliance name?\".colorize(:blue)\r\n appliance_type_input = gets().chomp.strip\r\n puts \"Which part of the house is it located in?\".colorize(:blue)\r\n location_input = gets().chomp.strip\r\n puts \"When did you purchase this appliance? Enter a valid date.\".colorize(:blue)\r\n purchase_date_input = nil\r\n #Error prevention check. If date input by user is invalid, they will be prompted to re-enter their date until it is acccepted by Date.parse.\r\n while purchase_date_input == nil\r\n begin\r\n purchase_date_input = Date.parse(gets().strip.chomp)\r\n rescue \r\n puts \"Wrong Date Format. Please try again.\".colorize(:red)\r\n puts \"When did you purchase this appliance?\".colorize(:blue)\r\n end \r\n end \r\n puts \"How long is your appliance's warranty? (in years)\".colorize(:blue)\r\n warranty_length_input = gets.chomp.strip.to_i\r\n puts \"What is your appliance's Warranty Serial Number?\".colorize(:blue)\r\n serial_number_input = gets().chomp.strip\r\n #New device information is initialised under Appliance class and is appended to the CSV device list file of that user.\r\n Appliances.new(appliance_type_input,location_input,purchase_date_input,warranty_length_input,serial_number_input).add_new_appliance(name_input)\r\n puts \"New Appliance Added.\".colorize(:green).bold\r\n puts \"#{appliance_type_input} situated in your #{location_input} was purchased on #{purchase_date_input} with warranty number #{serial_number_input} that lasts for #{warranty_length_input} years.\".colorize(:yellow)\r\n 100.times {print \"=\"}\r\n puts \"\\nWould you like to add another appliance \\nPress 2 for yes.\\nPress 1 to go back and view appliance list.\\nPress 3 for Warranty Status Report.\\nPress 4 to exit.\".colorize(:green)\r\n option_input = gets().chomp.strip.to_i\r\n elsif option_input == 3\r\n puts \"Which product would you like to check?\".colorize(:blue)\r\n product_check_input = gets().chomp\r\n product_details = calc_warranty_of_appliances(product_check_input, name_input)\r\n #If the product is not found in the user's CSV file, user is required to retype their selection until it matches one of the appliances in the CSV file list. \r\n while product_details == []\r\n puts \"Which product would you like to check?\".colorize(:blue)\r\n product_check_input = gets().chomp.strip\r\n product_details = calc_warranty_of_appliances(product_check_input, name_input)\r\n end\r\n #calling the date_of_purchase from the array and changed to Date.parse format, stored in variable called purchase_date_calc\r\n #This is the calculaton formula to calculate when the warranty ends and store it in variable warranty_end_date.\r\n purchase_date_calc = Date.parse(product_details[2])\r\n warranty_length_calc = product_details[3].to_i * 365\r\n warranty_end_date = purchase_date_calc + warranty_length_calc\r\n today_date = Date.today\r\n #This is the calculaton formula to calculate how many days are left until the warranty expiry date and store it in variable called warranty_days_left. \r\n warranty_days_left = (warranty_end_date - today_date).to_i\r\n puts \"Warranty days left = #{warranty_days_left}\".colorize(:light_blue)\r\n 100.times {print \"-\"}\r\n puts()\r\n puts \"What would you like to do? \\n Press 1 for Appliance List \\n Press 2 to Add New Appliance \\n Press 3 for Warranty Status Report \\n Press 4 to exit\".colorize(:green)\r\n option_input = gets().chomp.strip.to_i\r\n #This is option(4), which is to allow user to exit the app.\r\n elsif option_input == 4\r\n puts \"Thank you for using our app!\".colorize(:magenta)\r\n counter += 1\r\n #Error prevention check. When user inputs an invalid option other than option 1, 2, 3 or 4, user will be prompted to re-type their option.\r\n else\r\n puts \"Error. Please enter a valid option.\".colorize(:red)\r\n puts \"What would you like to do? \\n Press 1 for Appliance List \\n Press 2 to Add New Appliance \\n Press 3 for Warranty Status Report \\n Press 4 to exit\".colorize(:green)\r\n option_input = gets().chomp.strip.to_i\r\n 100.times {print \"-\"}\r\n puts()\r\n \r\n end\r\n end\r\nend", "def player_response\n\n if compare_answer\n return puts \"#{@current_asker.name}: YES! You are correct.\"\n end\n\n puts \"#{@current_asker.name}: Seriously? No!\"\n\n end", "def present_test(challenge)\n\n\tConsole_Screen.cls #clear the display area\n\tprint challenge + \"\\n\\n: \" #display the challenge sentence\n\tresult = STDIN.gets #collect the player's input\n\tresult.chop! #remove the end of line marker\n\n\t#analyze the player input and see if it is correct\n\tif challenge == result then\n\n\t#keep track of the number of corretly retyped challenge sentences \n\t$noRight += 1\n\tConsole_Screen.cls #clear the display area\n\t#keep player informed\n\tprint \"Correct!\\n\\nPress Enter to continue.\"\n\tConsole_Screen.pause #pause the game\n\nelse \n\n\tConsole_Screen.cls #clear the diplay area\n\t#keep the player informed\n\tprint \"Incorrect!\\n\\nPress Enter to continue\"\n\tprint \" Correct sentence: \" + challenge.to_s + \"\\tYour sentence: \" + result.to_s \n\tConsole_Screen.pause #clear the game\n\nuntil result != \" \"\n\n\tConsole_Screen.cls #clear the diplay area\n \n #prompt the playwer for permission to bein the test\n print \"You have to type something \"\n\n result = STDIN.gets #collect the player's response \n result.chop! #remove any extra characters appended to the string\t\nend\nend\nend", "def process_user_response(arr)\r\n while (key = gets.chomp) != 'exit'\r\n puts \"Please write u, l, r, d or 'exit' to quite\"\r\n case key\r\n when 'u' then move_up(arr)\r\n when 'l' then move_left(arr)\r\n when 'r' then move_right(arr)\r\n when 'd' then move_down(arr)\r\n when 'exit' then break\r\n end\r\n arr.to_s\r\n end\r\n end", "def exit_or_rerun\n puts \"\\nDo you want to select another category? (yes/no/exit)\\n\\n\"\n response = user_input_capture\n if AFFIRMATIVE_INPUT.include?(response.downcase)\n select_category\n elsif NEGATIVE_INPUT.include?(response.downcase) || QUIT_INPUT.include?(response.downcase)\n exit_app\n else\n puts \"Invalid response! Please enter 'yes', 'no', or 'exit' to quit\"\n exit_or_rerun\n end\n \n end", "def answer_validation(name)\n puts \"\\nHello, #{name}! What would you like to do today?\\n\n [1] Check allergy score.\n [2] Check allergies based on score.\n [3] Check if allergic to.\n [4] See allergy score table\n [5] Exit\"\n answer_keys = [*1..5]\n ans = gets.chomp.to_i\n while !answer_keys.include?(ans)\n puts \"Please navigate through the options using the numbers given.\"\n ans = gets.chomp.to_i\n end\n ans\nend", "def validator(response, task_information)\n !response.body_utf8.match(/The login information you entered does not match an account on record. Please try again./i)\n end", "def ask_the_question(question, valid_response)\n loop do\n answer = ask(question + \"? [Y/N] \") { |yn| yn.limit = 1, yn.validate = /[yn]/i }\n return answer if answer.downcase == valid_response.downcase || valid_response == ''\n end\nend", "def try_again\n puts \"Would you like to try again? \"\n response = gets\n response = response.chomp.upcase\n \n if @yes_options.include?(response)\n find_name\n elsif @no_options.include?(response)\n puts \"Thank you for your time.\"\n else\n puts \"I did not understand your response.\"\n try_again\n end \n end", "def handle_main_menu(response)\n prompt = TTY::Prompt.new\n\n if (['n', 'q', 'o', 'c', \"exit\"].include?(response))\n # Features that won't require an extra input argument.\n case response\n when \"n\"\n @tm.new_task\n when \"q\"\n sign_out\n when \"exit\"\n exit\n when \"o\"\n @tm.calendar.options\n when \"c\"\n @tm.create_calendar\n @tm.print_calendar\n else\n puts \"Error: Argument not accounted for!\"\n raise \n end\n else\n # Features that require an input argument.\n arg = prompt.select(\"Enter a valid Task ID: \", \n @tm.available_tasks\n .map {|task| {name: \"#{task.id.to_s} - #{task.title}\",\n value: task.id}})\n\n case response\n when \"s\"\n t = @tm.get_task(arg)\n t.print_task unless t==-1\n when \"e\"\n @tm.edit_task(arg)\n when \"d\"\n ans = prompt.yes?(\"Are you sure you want to delete task #{arg}?\") do |q|\n q.suffix \"Yes/No\"\n end\n\n if ans\n @tm.destroy_task(arg)\n end\n when \"c\"\n @tm.create_calendar(arg)\n @tm.print_calendar\n else\n puts \"Error: Argument not accounted for!\"\n raise \n end\n end\n end", "def validate_answer\n skip_authorization\n active_cell = @play.cell_active\n return unless active_cell\n\n if active_cell.npc.correct_answer?(params[:answer])\n @play.active_next_cell\n @play.check_if_game_over\n render json: { message: random_phrase_correct(@play), correct: true }\n else\n render json: { message: \"#{random_phrase_incorrect_and_tip(@play)}<br><br>#{active_cell.npc.question}\",\n correct: false }\n end\n end", "def antibody_test_prompt\n puts \"\\nDid you receive an antibody test? Please type 'yes' or 'no'. (For informaiton about antibody testing or other testing types, please visit https://www.cdc.gov/coronavirus/2019-ncov/lab/resources/antibody-tests.html\"\n antibody_response = gets.strip.downcase\n return_to_menu(antibody_response)\n exit_anything(antibody_response)\n if antibody_response == \"yes\"\n anti_body_test = true\n elsif antibody_response == \"no\"\n anti_body_test = false\n else puts \"\\nDid you mean to hit 'yes', 'no', 'menu', or 'exit'?\"\n antibody_test_prompt\n end\n anti_body_test\nend", "def menu\n\n puts \"________________\"\n\n puts \"insert the user name to continue\"\n @user_name = gets.chomp\n response = User.find_by(user_name: @user_name)\n\n puts \"________________\"\n\n if response\n \n mainscreen\n else\n puts \"try again\"\n menu\n end\n end", "def validate\n @result = POSSIBLE_RESULT[@index]\n $game_system.se_play($data_system.decision_se)\n end", "def matchup_validator\n if errors.messages.empty? && @matchup.nil?\n args = {\n champion1: @name1,\n champion2: @name2,\n elo: @elo.humanize,\n role1: @role1.try(:humanize),\n role2: @role2.try(:humanize),\n matchup_role: @matchup_role.try(:humanize)\n }\n\n if @role1.present? && @role2.present?\n errors[:base] << ApiResponse.get_response({ errors: { matchups: :duo_role_no_matchup } }, args)\n elsif @matchup_role\n errors[:base] << ApiResponse.get_response({ errors: { matchups: :solo_role_no_matchup } }, args)\n elsif @shared_matchups.length > 1\n @expect_user_response = true\n errors[:base] << ApiResponse.get_response({ errors: { matchups: :multiple_shared_roles } }, args)\n elsif @shared_matchups.length == 0\n errors[:base] << ApiResponse.get_response({ errors: { matchups: :no_shared_roles } }, args)\n end\n end\n end", "def response\n response = gets.chomp\n if (response.downcase == \"yes\" || response.downcase == \"y\")\n initialize\n welcome\n return true\n elsif (response.downcase == \"no\" || response.downcase == \"n\")\n return true\n end\n end", "def check_users\n dups = valids = invalid_format = total = 0\n @summary = '<ol>'\n each_user_line(params[:users_to_add]) do |line|\n total += 1\n (status, email, first_name, last_name) = check_new_user(line)\n case status\n when 'already_exists'\n line_out = \"email: #{email} already exists in the system, won't be added, but may add new roles.\"\n dups += 1\n when 'invalid_format'\n line_out = \"#{line} Unrecognized format, won't be added\"\n invalid_format += 1\n when 'good'\n line_out = \"email-(#{email}) first_name-(#{first_name}) last_name-(#{last_name})\"\n valids += 1\n end\n\t\n @summary += '<li>' + line_out + '</li>'\n end\n @summary += '</ol>'\n \n @summary = \"<p>Out of #{total} users to add: #{valids} are valid, #{dups} already exist, and #{invalid_format} are in the wrong format.</p>\" + @summary\n render :update do |page|\n page.replace_html :summary, \"<h2>Summary</h2>\" + @summary\n end\n\n end", "def check_response\n if @res.blank? || @res.error\n flash[:error] = t \"errors.api\"\n end\n end", "def validate()\n print \"Username: \"\n user = gets.chomp\n\n # Check user value\n user_state = [false]\n @users.keys.each do |u|\n if u == user then\n user_state[0] = true\n user_state << @users[user][\"group\"]\n next\n end\n end\n\n if user_state and (not user_state.nil? or not user_state.empty?) then\n print \"Password: \"\n password = STDIN.noecho(&:gets).gsub(/\\n/,\"\")\n\n # Check password value\n password_state = false\n @sudo[\"passphrases\"].each do |p|\n if (p[0] == user_state[1]) and (p[1] == password) then\n password_state = true\n next\n end\n end\n\n if password_state then\n group = @users[user][\"group\"]\n return group unless group.empty?\n else\n return \"guest\"\n end\n else\n return \"guest\"\n end\n end", "def menu\n input = gets.strip.downcase\n \n if input == \"hungry\"\n cuisine_list\n menu # return 'menu' don't want my user to get kicked out of application \n elsif input == \"goodbye\"\n goodbye\n else \n invalid_entry\n end \n end", "def get_incorrect\n @mismatches = @solution.crossword.get_mismatches(params[:letters])\n if @mismatches.empty?\n @solution.update_attributes(is_complete: true)\n end\n end", "def main_menu\n puts \"\"\n puts \"-----------------------------------------------\"\n puts \"\"\n puts \"Please select an option:\"\n puts \"\"\n puts \"Enter 'list' for a list characters, 'quote' for a random Stan Lee quote, or 'exit' to bid farewell.\"\n puts \"\"\n input = user_input\n\n if input == 'list'\n list_characters\n elsif input == 'quote'\n stan_lee_quote\n elsif input == 'exit'\n goodbye\n elsif input != 'list' || input != 'exit' # had to add \"input !=\" each time to avoid the string literal warning\n invalid_input\n main_menu\n end\n \n end", "def main_menu\n puts\n puts \"What would you like to do? Please enter a number:\".colorize(:green)\n puts \"---------------------\"\n puts \"1. Search Developer Jobs\".colorize(:color => :blue, :background => :white)\n puts \"---------------------\"\n puts \"2. See Saved Jobs\".colorize(:color => :blue, :background => :white)\n puts \"---------------------\"\n puts \"3. Apply From Saved Jobs\".colorize(:color => :blue, :background => :white)\n puts \"---------------------\"\n puts \"4. Have You Moved? Update Location Here\".colorize(:color => :blue, :background => :white)\n puts \"---------------------\"\n puts \"5. Sign Out\".colorize(:color => :blue, :background => :white)\n puts \"---------------------\"\n puts \"6. Exit Program\".colorize(:color => :blue, :background => :white)\n puts \"---------------------\"\n main_menu_response = gets.chomp.downcase\n if main_menu_response == \"1\"\n search_jobs\n elsif main_menu_response == \"2\"\n saved_jobs\n elsif main_menu_response == \"3\"\n apply_job\n elsif main_menu_response == \"4\"\n update_location\n elsif main_menu_response == \"5\"\n @@user_id = nil\n puts \"Signing out\".colorize(:color => :blue, :background => :white)\n sleep(1)\n welcome\n elsif main_menu_response == \"6\"\n exit\n else\n invalid_response\n main_menu\n end\n end", "def invalid_response(response)\n puts(\"\\\"#{response}\\\" was not a valid input. Please input a number corresponding to your choice.\")\nend", "def view_meds\n result = nil\n prompt = TTY::Prompt.new\n name = prompt.ask(\"Can we please re-confirm your username\", require: true)\n begin \n user_list = JSON.parse(File.read(\"./files/user_info.json\"))\n user_list[\"Users\"].each do |user|\n if user[\"Name\"] == name\n user[\"Medication\"].each do |med|\n puts \"Name: #{med[\"Med_Name\"]}\"\n puts \"Intake Time: #{med[\"Intake_Time\"]}\"\n puts \"Duration: #{med[\"Duration\"]}\"\n puts \"Extra Info: #{med[\"Extra_Info\"]}\"\n end\n result = 1\n end\n end\n if result != 1\n puts \"Invalid details, Please Try again\"\n profile_menu\n end\n rescue Errno::ENOENT\n puts \"We're not able to the medications on file. Please check your list or add it in\"\n end \nend", "def validate_response(guess_string)\n guess_array = []\n guess_string = guess_string.split(\" \")\n if guess_string.length > 4 \n return false\n end\n guess_string.each do |color_guess|\n color_guess = color_guess.downcase\n if is_valid_color?(color_guess)\n guess_array.push(color_guess)\n elsif color_guess == 'options'\n list_colors\n return false\n else \n return false\n end\n end\n guess_array\n end", "def ask\n\t\tbegin\n\t\t\tputs self\n\t\t\tprint \"Su respuesta: \" \n\t\t\tanswerno = gets.to_i - 1\n\t\tend while (answerno < 0 or answerno >= @answers.length)\n\t\t#Comprobamos si es correcta la respuesta\n\t\t@answers[answerno].is_right? \n\tend", "def get_menu_choice\n\n valid_cmds = [ # array of valid commands we will accept\n \"exit\",\n \"0\", \"00\",\n \"1\",\"2\",\"3\",\"4\",\"5\",\n \"show recent\",\n \"scrape more\",\n \"search\",\n \"search by pay\",\n \"results\"\n ]\n\n response = \"\"\n until valid_cmds.include?(response)\n print \"Please Enter a Command or Number: \".blue\n response = gets.chomp.downcase\n end\n\n clear_screen\n response\n end", "def greet_and_selection\r\n @view.greeting\r\n exit = true\r\n while exit\r\n user_selection = @view.selection\r\n if(user_selection != 1 && user_selection != 2)\r\n @view.wrong_answer\r\n else\r\n exit = false\r\n end\r\n end\r\n return user_selection\r\n end", "def compare_answers(user_res, machine_res)\n\tresult =\"\"\n\tif user_res == machine_res\n\t\tresult << \"Empate!!\"\n\telse\n\t\tif user_res = \"piedra\" && machine_res = \"papel\"\n\t\t\tresult << \"Gana el segundo jugador!!\"\n\n\t\telsif user_res = \"piedra\" && machine_res = \"tijeras\"\n\t\t\tresult << \"Gana el primer jugador!!\"\n\n\t\telsif user_res = \"papel\" && machine_res = \"piedra\"\n\t\t\tresult << \"Gana el primer jugador!!\"\n\n\t\telsif user_res = \"papel\" && machine_res = \"tijeras\"\n\t\t\tresult << \"Gana el segundo jugador!!\"\n\n\t\telsif user_res = \"tijeras\" && machine_res = \"piedra\"\n\t\t\tresult << \"Gana el segundo jugador!!\"\n\n\t\telsif user_res = \"tijeras\" && machine_res = \"papel\"\n\t\t\tresult << \"Gana el primer jugador!!\"\n\t\tend\n\tend\n\tputs result\nend", "def validate(input_selection, num_stops, msg)\n puts \"you selected #{input_selection}\"\n puts \"there are #{num_stops} on this line\"\n\n if input_selection.between?(1, num_stops)\n bool = 1\n puts \" in first if: i.sel = #{input_selection} and numstops = #{num_stops}\"\n else\n bool = 0\n puts \"else returned boo = 0\"\n end\n while bool > 0\n puts \"Error, Invalid Entry\"\n puts \"#{msg}\"\n try_again = gets.chomp.to_i\n if try_again.between?(1, num_stops)\n bool = 0\n puts \"bool = 0 in nested if statement\"\n else\n bool = 1\n end\n end\n\n #return input_selection\nend", "def user_permission\n\n#ask the user if they pay their bills (yes/no)\n\nputs(\"Are your bills paid?\")\n\n#store their answer in a variable\n\nuser_bills_status = gets.strip\n\n#ask the user if they have canceled a deal (yes/no)\n\nputs(\"Have you canceled a deal?\")\n\n#store their answer in a variable\n\nuser_deal_status = gets.strip\n\n#ask the user if they are an admin (yes/no)\n\nputs(\"Are you an admin?\")\n\n#store their answer in a variable\n\nuser_admin_status = gets.strip\n\n#ask the user if they are signed in (yes/no)\n\nputs(\"Are you signed in?\")\n\n#store their answer in a variable\n\nuser_signin_status = gets.strip\n\n#call the function \n\n\tif user_bills_status == \"no\" or user_deal_status == \"yes\"\n\n\t\tputs(\"Go away, please.\")\n\n\telsif user_signin_status == \"yes\" and user_admin_status == \"yes\"\n\n\t\tputs(\"You can see and do everything.\")\n\n\telsif user_signin_status == \"yes\" and user_admin_status == \"no\"\n\n\t\tputs(\"You can see everything.\")\n\n\telsif user_signin_status == \"no\"\n\n\t\tputs(\"Please sign in.\")\n\t\t\n\tend\n\nend", "def check_info\n puts \"\\nHere's the account information you submitted\n Name: #{@name}\n Address: #{@address}\"\n\n answer2 = nil\n until answer2 == \"YES\" || answer2 == \"NO\"\n puts \"Is this information correct? (YES/NO)\"\n answer2 = gets.chomp.upcase\n if answer2 == \"NO\"\n puts \"You indicated that the information was incorrect. Please re-enter your account information.\"\n get_info\n elsif answer2 == \"YES\"\n puts \"Thank you for verifying the information.\"\n else\n puts \"Please try again. Is the above information correct?\"\n answer2 = gets.chomp.upcase\n end\n end\n end", "def validate_response(response) \n case response.code\n when '200' \n return\n when '400' # Bad Request error - invalid request\n raise ResponseError::BadRequestError.new(extact_error_message(response.body))\n when '401' # Unauthorised error\n raise ResponseError::UnauthorisedError.new(extact_error_message(response.body))\n when '403' # Forbidden error - valid request but server is refusing, may be due to lack of permissions (RETRY enabled)\n raise ResponseError::ForbiddenError.new(extact_error_message(response.body))\n when '404' # Not Found error - server is unable to locate the resource to serve\n raise ResponseError::NotFoundError.new(extact_error_message(response.body))\n when '500' # Internal Server error - error due to unknown reason\n raise ResponseError::InternalServerError.new(extact_error_message(response.body))\n when '502' # Bad Gateway error - error due to not receiving valid response from backend server \n raise ResponseError::BadGatewayError.new(extact_error_message(response.body))\n when '503' # Service Unavailable error - server is overloded or under maintainance (RETRY enabled)\n raise ResponseError::ServiceUnavailableError.new(extact_error_message(response.body))\n when '504' # Gateway Timeout error - not receiving response within the allowed time period (RETRY enabled)\n raise ResponseError::GatewayTimeoutError.new(extact_error_message(response.body))\n else\n raise ResponseError::UnexpectedError.new(extact_error_message(response.body))\n end\n end", "def other_responses\r\n\tif @user_command.include?(\"hot\") &&\r\n\t\t@user_command.include?(\"dog\")\r\n\t\tif @inventory.include?(\"Hot Dog\")\r\n\t\t\[email protected](\"Hot Dog\")\r\n\t\t\ttake_health_hit(-3)\r\n\t\t\tplayer_update_vitals\r\n\t\t\treload_display\r\n\t\t\tputs \"You ate your hot dog.\"\r\n\t\t\tputs \"Health increased by 3.\"\r\n\t\telse\r\n\t\t\tputs \"You don't have a hot dog.\"\r\n\t\tend\r\n\telse\r\n\t\tputs \"You can't do that.\"\r\n\tend \r\nend", "def auth_0 (uname, pw, users_list) #bracket maa method lai use hune arguments haru #user_list chai array ho\n users_list.each do |nue| #yo statement le each element thru jancha from the array #nue will house each element of the users array\n if nue[:username] == uname && nue[:password] == pw #symbol use gareko bhayera colon (:) use gareko \n return \"You have logged in to the program\" #return halyo bhane break halna pardaina as return exists the method\n end\n end\n \"CREDENTIALS you provided are NOT CORRECT\" #yaa chaincha o line so that it doesnot return \"not correct\" for an element\n #that comes after the first one. you else maa bhayo bhane 2nd element lai ni error dincha as the 2nd element is compared to the\n #1st one.\nend", "def verify_user_answer(user_answer)\n until user_answer == \"1\" || user_answer == \"2\" || user_answer == \"3\"\n puts \"That's not a valid answer. Please enter 1, 2, or 3\"\n user_answer = gets.chomp.to_s\n end\n return user_answer\n end", "def pcr_result_prompt\n puts \"\\nIf you know the PCR test result, please enter if it was positive or negative by typing 'positive' or 'negative'.\"\n pcr_res_response = gets.strip.downcase\n return_to_menu(pcr_res_response)\n exit_anything(pcr_res_response)\n if pcr_res_response == \"positive\" \n pcr_test_result = true\n elsif pcr_res_response == \"negative\" \n pcr_test_result = false\n else puts \"\\nDid you mean to hit 'yes', 'no', 'menu', or 'exit'?\"\n pcr_result_prompt\n end\n pcr_test_result\nend", "def is_user_choice_valid?\n return false if @user_choice.empty?\n return true if @user_choice == 'X' || @user_choice == 'x' || (@menu_map.has_key? @current_level + '.' + @user_choice)\n return true if @user_choice == \"\\e[D\"\n end", "def get_response(name)\n puts `clear`\n puts \"*** Welcome to #{name} ****\"\n puts \"Please select one of the choices below.\"\n print \"a(d)d user, (l)ist of all animals, (g)ive animal, (a)doption a pet, (c)lient list, (e)dit animal, edit (u)ser, (q)uit: \"\n gets.chomp.downcase\nend", "def sanitize_choice(choice)\nif choice.include? ' '\nputs 'Please choose from the three option above....sans typos'\nexit\nelse\nuser_mashable = Mashable.new(choice)\nuser_mashable.get\nputs user_mashable.parsed_response\nend\nend", "def check_main_menu_choice(given_choice)\n if given_choice == \"First Time User, Want To Register\"\n choice = 1\n end\n if given_choice == \"Already A Registered User, Want To Login\"\n choice = 2\n end\n if given_choice == \"Do Not Wish To Register, Just Browsing\"\n choice = 3\n end\n if given_choice == \"Looking For Info About The App\"\n choice = 4\n end\n if given_choice == \"Nothing Really, Spare Me Your @?%#&?|%!\"\n choice = 5\n end\n choice\nend", "def check_submit_valid\n begin\n if params[:status][:source].length > \n JS_CONFIG[\"limits\"][\"max_source_code_len\"]\n raise t(\"status.prompts.source_code_too_long\") \n end\n begin\n @problem = Problem.find(params[:status][:pid])\n rescue\n raise t(\"problem.prompts.nonexist\")\n end\n if params[:status][:contest_belong].to_i == 0 &&\n @problem.hide && !current_user.is_admin?\n raise t(\"problem.prompts.nonexist\")\n else\n begin\n @contest = Contest.find(params[:status][:contest_belong].to_i)\n rescue\n raise t(\"contest.prompts.nonexist\")\n end\n unless @contest.has_user(current_user.username)\n raise t(\"global.prompts.access_denied\");\n end\n if ContestProblem.where(\n cid: params[:status][:contest_belong].to_i,\n pid: params[:status][:pid].to_i).empty?\n raise t(\"problem.prompts.nonexist\")\n end\n end\n raise t(\"status.prompts.language_unspecified\") if \n params[:status][:language].to_i == 0\n last_status = Status.where(username: current_user.username)\n .order(time_submit: :desc).first\n raise t(\"global.prompts.too_frequent\") if\n Time.now - last_status.time_submit < 5\n rescue Exception => e\n render status: :not_acceptable, json: { msg: e.message }\n return\n end\n end", "def correct?\n if !( /^[0-9]{4}$/ =~ @user_try) || @user_try.split(\"\").uniq!\n puts 'Please, enter different 4 numbers'\n return false\n end\n return true\n end", "def whos_your_enemy(enemy)\n\n # validate enemy response\n valid_options = [\"Riddler\", \"Penguin\", \"Joker\"]\n until valid_options.include?(enemy)\n # puts [\"Huh?\", \"Wha?\", \"Que?\", \"Como?\"].sample\n question = [\"Huh?\", \"Wha?\", \"Que?\", \"Como?\"].sample\n\n # puts \"Options: Joker, Penguin, Riddler\"\n options = \"Joker, Penguin, Riddler\"\n\n # enemy = gets.chomp.capitalize.strip\n enemy = ask_question question, options\n end\n\n # alternate validation strategy\n # loop do\n # puts \"Huh?\"\n # puts \"Options: Joker, Penguin, Riddler\"\n # enemy = gets.chomp.capitalize.strip\n #\n # if valid_options.include?(enemy)\n # break\n # end\n # end\n\n case enemy\n when \"Riddler\"\n say \"#{enemy}: Puzzle me this, Batman.\"\n when \"Joker\"\n say \"#{enemy}: Ha ha ha ha... ha ha.\"\n when \"Penguin\"\n say \"#{enemy}: Rweh rweh rweh... rweh...\"\n else\n say \"This should never happen.\"\n # ... if the validation is correct\n end\nend", "def validate(answers, input)\n until answers.include?(input)\n puts \"#Invalid input: #{input}\"\n input_answer\n end\n end", "def validate_player_input(temp_input, comparison_array = @MAIN_CHOICES)\n validation_results = []\n temp_input.each do |input|\n validation_results << comparison_array.include?(input)\n end\n if (validation_results.all?(true) && (validation_results.length == 4)) == false\n temp_input = request_player_input('Please choose FOUR of the AVAILABLE colors >:(')\n validate_player_input(temp_input, comparison_array)\n else\n temp_input\n end\n end", "def valid_message?(response)\n command, identifier, @group = response.args\n\n unless identifier && @group\n response.reply \"Format: #{robot.name} auth add USER GROUP\"\n return\n end\n\n if @group.downcase.strip == \"admins\"\n response.reply \"Administrators can only be managed via Lita config.\"\n return\n end\n\n @user = User.find_by_id(identifier)\n @user = User.find_by_name(identifier) unless @user\n\n unless @user\n response.reply <<-REPLY.chomp\nNo user was found with the identifier \"#{identifier}\".\nREPLY\n return\n end\n\n true\n end", "def main\n puts \"What is your name?\"\n user = gets.strip\n ans = answer_validation(user)\n\n running = true\n while running\n case ans\n when 1\n puts \"Please list all your allergies. Press \\\"q\\\" to exit.\"\n user_allergies = Array.new\n user_input = gets.strip\n while user_input.downcase[0] != 'q'\n user_allergies << user_input\n user_input = gets.strip\n end\n score = test_by_allergy(user_allergies)\n system(\"clear\")\n puts \"\\nYour Allergy Score is #{score}\\n\"\n\n when 2\n system(\"clear\")\n print_allergies(score_validation)\n\n when 3\n puts \"What do you think you are allergic to?: \"\n user_allergy = gets.strip\n system(\"clear\")\n if is_allergic?(score_validation, user_allergy)\n puts \"\\nYes, You are allergic to #{user_allergy}!\"\n else\n puts \"\\nNo, You are not allergic to #{user_allergy}!\"\n end\n\n\n when 4\n system(\"clear\")\n $all_allergies.each{|k,v| puts \"#{k} has a score of #{v}\"}\n\n else\n return puts \"Thank you for using our program! Always be safe!\"\n end\n ans = answer_validation\n end\nend", "def validate_answer(result, right_answer, status, start_time, time)\r\n case result\r\n when right_answer\r\n # Get the stop time stamp to calculate the score, the faster to get the answer, the more bounds score is earned.\r\n answer_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)\r\n time_used = (answer_time - start_time).round(1)\r\n # Basic socre for each corrent answer is 500\r\n total_score = 500 + (time - time_used) * 10\r\n # Update the score and pass back to the loop\r\n status[0] += total_score\r\n status[1] += 1\r\n puts \"\\n\\n Hooray!!! You got it!!\"\r\n\r\n else\r\n puts \"\\n\\nSorry, not correct answer or time expired!\\nIt's fine. Let's keep going\"\r\n status[2] += 1\r\n end\r\n enter_to_continue\r\n end", "def generate_results\n !(@incomplete_word.include? \"_\") ?\n puts(\"Congratulations, you won.\") :\n puts(\"\\nYou failed to guess the words.\")\n end", "def validate_response!(response)\n raise \"empty response\" unless response\n\n status = response[\"stat\"]\n if status and status != \"ok\"\n error = response[\"err\"]\n if error\n raise RequestFailed, \"#{error[\"code\"]}: #{error[\"msg\"]}, explanation: #{error[\"expl\"]}\"\n else\n raise RequestFailed, \"Error: #{status}, no error message\"\n end\n end\n end", "def student_main_menu(student_user) \n self.line_break\n puts \"Please select a command:\".colorize(:light_blue), \"1: Return to Main Menu\".colorize(:cyan), \"2: Exit\".colorize(:cyan)\n self.line_break\n input = gets.chomp\n until input == \"1\" || input == \"2\"\n puts \"Invalid response. Please select a command:\".colorize(:yellow), \"1: Return to Main Menu\".colorize(:cyan), \"2: Exit\".colorize(:cyan) \n input = gets.chomp\n end\n if input == \"1\"\n self.student_tasks(student_user)\n elsif input == \"2\"\n puts \"Have a great day!\".colorize(:light_green)\n end\n end", "def validate_access\n if @user_logged_in != @answer.user\n render status: :forbidden\n end\n end", "def main_menu\n finished = false\n while finished == false\n user_input = @prompt.select(\"\\nWelcome, Please choose from the following options\") do |menu|\n menu.choice 'View Rules'\n menu.choice 'View Balance'\n menu.choice 'View Ratio'\n menu.choice 'Play Game'\n menu.choice 'Quit'\n end\n\n if user_input == 'View Rules'\n @rules.each do |rule|\n puts rule\n end \n elsif user_input == 'View Balance'\n puts \"\\nYour bank balance is $#{@user[:balance]}\"\n elsif user_input == 'View Ratio'\n puts \"\\nYour win/loss ratio is #{@user[:ratio]}\"\n elsif user_input == 'Play Game'\n run_game() \n clear_hands()\n else user_input == 'Quit'\n finished = true\n update_file()\n end\n end\n end", "def menu_choice\n puts \"Votre réponse :\"\n print \">\"\n user_answer = gets.chomp\n\n if(user_answer == \"a\")\n then @human_player.search_weapon\n end\n if(user_answer == \"s\")\n then @human_player.search_health_pack\n end\n if(user_answer == 0.to_s)\n then @human_player.attacks(@player1)\n end\n if(user_answer == 1.to_s)\n then @human_player.attacks(@player2)\n end\n if(user_answer == 2.to_s)\n then @human_player.attacks(@player3)\n end\n if(user_answer == 3.to_s)\n then @human_player.attacks(@player4)\n end\n kill_player\n end", "def validate_user\n #Validate rut and form\n user = rut_verification(params[:user_rut])\n form = params[:request_type]\n # Redirect to correct form\n if user != 0 and user != -1\n if user\n # User data\n session[:user] = user.attributes\n # selected request and item data\n session[:user][\"request\"] = params[:request_type]\n\n if params[:request_type] == 'renew' || params[:request_type] == 'technical service'\n session[:user][\"item\"] = params[:request_hw_renew_tech]\n elsif params[:request_type] == 'new'\n session[:user][\"item\"] = params[:request_hw_new]\n elsif params[:request_type] == 'stolen/lost'\n session[:user][\"item\"] = params[:request_hw_lost]\n else\n session[:user][\"item\"] = \"smartphone line\"\n end\n\n # Transfer Line\n if form == 'transfer line'\n redirect_to '/requests/forms/transferline'\n # New Request\n elsif form == 'new'\n redirect_to '/requests/forms/new'\n # Renew Request\n elsif form == 'renew'\n # check if selected item is owned by user\n # item = item_verification(params[:request_hw])\n redirect_to '/requests/forms/renew'\n # Stolen or Lost\n elsif form == 'stolen/lost'\n redirect_to '/requests/forms/stolenlost'\n # Technical service\n elsif form == 'technical service'\n redirect_to '/requests/forms/technicalservice'\n end\n\n else\n redirect_to '/requests/home/menu', alert: 'El usuario con Identificador nacional: '+params[:user_rut].to_s+ ' No se encuentra en la Base de datos de CCU'\n end\n\n elsif user == 0\n redirect_to '/requests/home/menu', alert: 'El usuario con Identificador nacional: '+params[:user_rut].to_s+ ' No se encuentra en la Base de datos de CCU'\n else\n redirect_to '/requests/home/menu', alert: 'No se puede conectar a la Base de datos de CCU, intente mas tarde'\n\n end\n end", "def validate(response, opt = {})\n\n unless opt[:body_only]\n status, _description = response.status\n if @definition['status'] != status\n return [\"Invalid status: expected #{@definition['status']} but got #{status}\"]\n end\n\n headers_to_validate = @definition['headers'].dup\n expected_location = headers_to_validate.delete 'Location'\n unless headers_to_validate.normalize_keys.subset_of?(response.headers.normalize_keys)\n return [\"Invalid headers: expected #{@definition['headers'].inspect} to be a subset of #{response.headers.inspect}\"]\n end\n\n if expected_location\n location_template = Addressable::Template.new(expected_location)\n location = response.headers['Location']\n if location.nil?\n return ['Expected a Location Header in the response']\n elsif !location_template.match(Addressable::URI.parse(location))\n return [\"Location mismatch: expected URI #{location} to match URI Template #{location_template.pattern}\"]\n end\n end\n end\n\n if @definition['body']\n if @definition['body']['type'] && @definition['body']['type'] == 'string'\n validate_as_pure_string response.body\n else\n response.respond_to?(:body) ? validate_as_json(response.body) : validate_as_json(response)\n end\n else\n []\n end\n end", "def handle_menu(menu_item, apartments,tenants)\n case menu_item\n when 1\n view_all_apts(apartments)\n puts(\"Press [ENTER] to continue\")\n gets\n return false\n when 2\n view_all_tenants(tenants)\n puts(\"Press [ENTER] to continue\")\n gets\n return false\n when 99\n return true\n else\n puts(\"Please type a Valid Menu Item\")\n puts(\"Press [ENTER] to continue\")\n gets\n return false\n end #case\nend", "def not_author_response\n if author_respondent?\n errors[:author] << 'cannot answer their own poll'\n end\n end", "def validate_hotel_list_result\n result = OK\n list_hotel_response = hotel_service.get_list_hotels_with_destination_value(params)\n service_reponse = process_response(list_hotel_response, 'HotelListResponse')\n if (service_reponse && service_reponse[\"status\"] != OK)\n @error = service_reponse[\"error\"]\n result = service_reponse[\"status\"]\n if @error[\"error_code\"] == I18n.t('label.error_code.multiple_locations')\n result = 'light_box'\n end\n end\n render :json => {:status => result.to_s}\n end", "def repeat_response_query(condition)\n if condition == 'repeat'\n puts 'You already chose that letter! Please choose another one:'\n elsif condition == 'multiple'\n puts 'Please only enter one letter!'\n end\n @input = user_response(false)\n check_for_valid_response(@input)\n end", "def not_duplicate_response\n if respondent_already_answered?\n errors[:user_id] << 'this user has already answered this question'\n end\n # unless sibling_responses.where(user_id: user_id).empty?\n end", "def response_status_correctness\n\t\treturn if response_status.blank?\n\t\tunless Response_statuses.values.include? response_status\n\t\t\terrors.add(:response_status, \"must be one between #{Response_statuses.values}\")\n\t\tend\n\tend", "def pcr_prompt\n puts \"\\n***************For the following questions, Please provide which test you have receieved.***********************************\"\n puts \"\\n\\nDid you receive a PCR swab test? Please type 'yes' or 'no'. (For informaiton about PCR or other testing types, please visit https://www.cdc.gov/coronavirus/2019-ncov/lab/testing.html\"\n pcr_response = gets.strip.downcase\n return_to_menu(pcr_response)\n exit_anything(pcr_response)\n if pcr_response == \"yes\"\n pcr_test = true\n elsif pcr_response == \"no\"\n pcr_test = false\n else puts \"\\nDid you mean to hit 'yes', 'no', 'menu', or 'exit'?\"\n pcr_prompt\n end\n pcr_test\nend", "def save_user_responses(resp)\n @response = Response.find(resp[:id])\n @question = @response.question\n resp_val_string = Response::EMPTY_RESPONSE_VALUE\n if (@question.question_type == Question::TYPES['short_answer'])\n resp_val_string = resp[:response_value]\n elsif (@question.question_type == Question::TYPES['multiple_choice'] || @question.question_type == Question::TYPES['scale'])\n # look through the multiple choice options and see which one is selected\n # note: for now these are implemented in the same way. in the future, scale may be a slider.\n resp_val_string = resp[:response_value]\n elsif (@question.question_type == Question::TYPES['multiple_select'])\n # look through the multiple select options and see which one(s) are selected\n\t @option_count = 0\n\t @option_arr = []\n\t while(@option_count < @response.question.question_options.length)\n\t\tputs \"** OPTION \" + @option_count.to_s + \" ***\"\n\t\t@index = @option_count.to_s\n\t\tif(resp[\"response_values\"][@index] != \"\")\n\t\t\t@option_arr << resp[\"response_values\"][@index]\n\t\tend\n\t\t@option_count += 1\n\t end\n resp_val_string = @option_arr.join(\",\")\n end\n \n puts \"RESPONSE VALUE STRING: #{resp_val_string}\"\n \n if (resp_val_string == \"\")\n return false\n else\n # update the stuff here\n @response.response_value = resp_val_string\n @response.save!\n return true\n end\n end", "def check_access\n @response = Response.new\n \n check_hash()\n \n if @response.error?\n access_denied\n return\n end\n end", "def teacher_main_menu(teacher_user) \n self.line_break\n puts \"Please select a command:\".colorize(:light_blue), \"1: Return to Main Menu\".colorize(:cyan), \"2: Exit\".colorize(:cyan)\n self.line_break\n input = gets.chomp\n until input == \"1\" || input == \"2\"\n puts \"Invalid response. Please select a command:\".colorize(:yellow), \"1: Return to Main Menu\".colorize(:cyan), \"2: Exit\".colorize(:cyan)\n input = gets.chomp\n end\n if input == \"1\"\n self.teacher_tasks(teacher_user)\n elsif input == \"2\"\n puts \"Have a great day!\".colorize(:light_green)\n end\n end", "def choice_check\n begin\n choice = gets.chop.upcase\n if choice != \"GET\" && choice != \"POST\" && choice != \"EXIT\"\n raise \"Wrong input!\"\n end\n rescue StandardError => e\n puts \"#{e} You can choose between GET, POST and EXIT\"\n retry\n else\n choice\n end \n end", "def valid_input\n\t\t#adds single word commands\n\t\tvalid = ['help', 'wait', 'inventory']\n\t\tlocation = find_room_in_dungeon(@player.location)\n\t\tlocation.connections.each do |direction, destination|\n\t\t\tvalid << direction.to_s\n\t\tend\n\t\t\n\t\t#adds two word commands\n\t\[email protected] do |reference|\n\t\t\t['eat', 'throw', 'examine', 'drop'].each do |action|\n\t\t\tvalid << action + \" \" + reference.to_s\n\t\t\tend\n\t\tend\n\t\tif @player.location == @other_player.location || @player.location == :Lair\n\t\t\[email protected] do |reference|\n\t\t\t\tvalid << 'give' + \" \" + reference.to_s\n\t\t\tend\n\t\tend\n\t\tif @player.inventory.include?(:crystal) && @other_player.inventory.include?(:crystal)\n\t\t\tvalid << 'wob crystal'\n\t\tend\n\t\tcase @player.location\n\t\twhen :Laboratorium then\n\t\t\tvalid << 'look tools'\n\t\t\tvalid << 'take crystal' unless @crystal_taken > 1\n\t\twhen :garden then\n\t\t\tvalid << 'look plants'\n\t\t\tvalid << 'take beans' unless @beans_taken\n\t\twhen :Lounge then\n\t\t\tvalid << 'look chair'\n\t\t\tvalid << 'take pills' unless @pills_taken\n\t\twhen :Library then\n\t\t\tvalid << 'look pedestal'\n\t\t\tvalid << 'take box' unless @box_taken\n\t\twhen :Study then\n\t\t\tvalid << 'look papers'\n\t\t\tvalid << 'take notes' unless @notes_taken\n\t\twhen :Lair then\n\t\t\tvalid << 'wob box' if @player.inventory.include?(:box)\n\t\t\tvalid << 'look creature'\n\t\t\tvalid << 'take creature'\n\t\tend\n\t\tvalid.each do |string|\n\t\t\tputs string\n\t\tend\n\tend", "def incorrect\n if !@user_1_array.include? user_2\n correct == false\n wrong_letters << user_2\n end\nend", "def again_or_exit?(crate)\n puts \"\\n\\nWhat would you like to do now?\\n1. View another genre.\\n2. Exit\"\n input = gets.strip\n input_i = input.to_i\n acceptable_answers = (1..2).to_a\n while acceptable_answers.none? { |answer| answer == input_i }\n puts \"\\nI'm sorry, that's not a valid option.\"\n puts \"Please enter 1 or 2.\"\n input_i = gets.strip.to_i\n end \n\n if input_i == 1\n self.start(crate)\n else\n puts \"Have a good one!\"\n end\n end", "def main_menu(user=\"guest\")\n game = nil\n router = nil\n message = []\n # base options\n options = [\n [\"Continue as a Guest\", 8],\n [\"Log In\", 3],\n [\"Create Account\", 5],\n [\"Select a Game\", 8],\n [\"My Reviewed Games\", 13],\n [\"Log Out\", 4],\n [\"My Account\", 6],\n [\"Exit\", 1]\n ]\n # removing options based on status\n if user == \"guest\"\n options.delete_at(6)\n options.delete_at(5)\n options.delete_at(4)\n options.delete_at(3)\n elsif Review.where(user_id: user.id).count == 0\n options.delete_at(4)\n options.delete_at(2)\n options.delete_at(1)\n options.delete_at(0)\n else\n options.delete_at(2)\n options.delete_at(1)\n options.delete_at(0)\n end\n # display loop until validated choice\n until router\n display_menu_header([\"Main Menu:\"], user)\n router = display_options_menu(options, message)\n message = [\"Sorry, invalid selection. Please choose again...\"]\n end\n menu_routing(user, \"\", router)\nend", "def problems(current_user=nil)\n user = current_user || self.corresponding_author\n\n list = []\n \n page_valid?(:general) or list << 'Complete the General Info page.'\n page_valid?(:coauthors) or list << 'Complete the Co-Authors page.'\n page_valid?(:reviewers) or list << 'Complete the Reviewers page.'\n page_valid?(:fees) or list << 'Complete the Fees page.'\n page_valid?(:checklist) or list << 'Complete the Checklist page.'\n page_valid?(:review) or list << 'Complete the Review page.'\n completed_coi?(user) or list << 'Complete the Financial Disclosure form.'\n coauthors_valid? or list << 'You specified that you are not the sole author of this manuscript. Please add the coauthor(s)'\n ca_contribution = Contribution.find_by_article_submission_and_user(self.id, user.id)\n ca_contribution.responsibilities_sig_assent or list << 'Complete the Author Responsibilities Form.'\n ca_contribution.copyright_sig_assent or list << 'Complete the Copyright Assignment Form.'\n \n unless(self.isVideo?)\n self.manuscript or list << 'Upload your manuscript.'\n self.cover_letter or list << 'Upload your cover letter.'\n if self.provisionally_accepted\n self.has_had_status?(ArticleSubmission::MANUSCRIPT_RESUBMITTED) or list << \"Resubmit your manuscript\"\n self.has_had_status?(ArticleSubmission::COVER_LETTER_RESUBMITTED) or list << \"Resubmit your cover letter\"\n \n end\n else\n !self.manuscript_video_link.blank? or list << 'Upload Video Link'\n end\n list.compact!\n \n (list.length > 0) ? list : nil\n end", "def ask_user\n\tmessages = [\"You will get it!\", \"Sorry it won't happen\", \"You bet\", \"No way\", \"Maybe\", \"It depends on you\", \"I believe in you\", \"The odds are against you\"]\n\tquestion = puts \"This is magic 8-Ball. Do you want to shake the eight ball? Y/N\"\n\tuser_response = gets.chomp.capitalize\n\twhile(true)\n\t\tif user_response == \"Y\" || user_response == \"Yes\"\n\t\t\tputs messages[rand(0..7)]\n\t\t\task_user\n\t\t\tbreak\n\t\telsif user_response == \"N\" || user_response == \"No\"\n\t\t\tputs \"Bye!\"\n\t\t\tbreak\n\t\telse\n\t puts \"Type Y/N please\"\n\t ask_user\n\t\t\tbreak\n\t\tend\n\tend\nend", "def check_values(user_hash)\n flag = 0\n feedback = \"\"\n detail = \"\"\n user_hash.each do |key, value|\n flag = 2 if key == \"age\" && value.to_i > 120\n (flag = 3; detail = key) if key !~ /quote/ && value.length > 20\n flag = 4 if key == \"quote\" && value.length > 80\n flag = 5 if key == \"name\" && value =~ /[^a-zA-Z ]/\n (flag = 6; detail = key) if key =~ /age|n1|n2|n3/ && value =~ /[^0-9.,]/\n end\n # users = get_names()\n # users.each { |user| flag = 1 if user == user_hash[\"name\"]}\n flag = 7 if validate_file(user_hash) == false\n case flag\n # when 1 then feedback = \"We already have details for that person - please enter a different person.\"\n when 2 then feedback = \"I don't think you're really that old - please try again.\"\n when 3 then feedback = \"The value for '#{detail}' is too long - please try again with a shorter value.\"\n when 4 then feedback = \"Your quote is too long - please try again with a shorter value.\"\n when 5 then feedback = \"Your name should only contain letters - please try again.\"\n when 6 then feedback = \"The value for '#{detail}' should only have numbers - please try again.\"\n when 7 then feedback = \"Invalid image file - please upload a valid image in BMP, GIF, JPG, PNG or TIFF format.\"\n end\n return feedback\nend", "def get_input(message, choices)\n print(message)\n response = gets.chomp.downcase\n while response.length < 1 || !choices.include?(response[0])\n print(\"Invalid selection. \" + message)\n response = gets.chomp.downcase\n end\n return response[0]\nend", "def validate_username(username, password, users_json)\n users_json.each_with_index do |user, index|\n name_current = user['name']\n username_current = user['username']\n password_current = decrypt(user['password'])\n active_current = user['active']\n # puts \"Looking at: #{username_current} = #{username}\"\n # puts \"User is active? #{active_current}\"\n if username_current == username && active_current == true && password_current == password\n # puts \"#{username} was selected\"\n return username\n elsif username_current == username && active_current == true && password_current != password\n clear\n # puts \"Incorrect username or password. Please try again.\"\n return \"password_error\"\n elsif username_current == username && active_current == false\n # puts \"#{username} is not active\"\n return false\n end\n end \n return false\nend", "def login_check(name, password)\n result = nil\n begin \n user_list = JSON.parse(File.read(\"./files/user_info.json\"))\n user_list[\"Users\"].each do |user|\n if user[\"Name\"] == name && user[\"Password\"] == password\n puts \"Welcome back #{name}!\"\n profile_menu\n result = \"match\"\n elsif user[\"Name\"] == name && user[\"Password\"] != password\n result = \"invalid pw\"\n end\n end\n puts \"Sorry - those details couldn't be found\" if result.nil?\n if result.nil?\n puts \"Sorry - those details couldn't be found. Please try again\"\n elsif result == \"invalid pw\"\n puts \"User password detail Invalid. Please try again\"\n result = nil\n end\n return result\n rescue Errno::ENOENT\n puts \"We cannot find your details on file. Please create an account.\"\n end \n\nend" ]
[ "0.71117836", "0.680651", "0.6579025", "0.63688767", "0.6296479", "0.62316084", "0.6231399", "0.6179783", "0.6156473", "0.6141003", "0.6056366", "0.60482544", "0.6031552", "0.60153294", "0.6012729", "0.5986018", "0.5982685", "0.5978555", "0.5967713", "0.59655213", "0.59247553", "0.5896004", "0.589151", "0.58693653", "0.5861708", "0.58450025", "0.5844236", "0.5840389", "0.5837585", "0.58362114", "0.5819097", "0.58117527", "0.5811149", "0.5806947", "0.580571", "0.5805703", "0.58040893", "0.5797258", "0.5786821", "0.5774013", "0.57612634", "0.5758642", "0.57408446", "0.57329005", "0.57317454", "0.57278186", "0.57260495", "0.57245827", "0.5717951", "0.5714867", "0.57074505", "0.5695775", "0.5693977", "0.56913507", "0.5684658", "0.5683828", "0.567999", "0.5678996", "0.5676283", "0.56760347", "0.56745064", "0.5666574", "0.5659978", "0.5659413", "0.56569785", "0.5647062", "0.56407946", "0.5638313", "0.56380963", "0.56273407", "0.5627336", "0.5622158", "0.5622065", "0.56214875", "0.56195", "0.5601402", "0.55965626", "0.55892617", "0.55885845", "0.5587875", "0.557719", "0.5575656", "0.55731076", "0.55659103", "0.5560692", "0.55593884", "0.5556993", "0.5542631", "0.55393237", "0.55383676", "0.55307055", "0.5527484", "0.551347", "0.5510583", "0.5505635", "0.55047727", "0.54921854", "0.54883", "0.54803723", "0.5477002" ]
0.65853333
2
This method stores whole words for politicians political affiliation.
def whole_affil (new_party_affiliation) if new_party_affiliation == "d" "Democrat" else new_party_affiliation == "r" "Republican" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cryptic_dictionary(words)\nend", "def add_adjective!(word)\n new_word = Unicode.downcase(word)\n new_word[-2..-1] = \"ая\"\n @redis.rpush(\"store:adjectives\", new_word) \n end", "def affiliation=(affil)\n affiliations.clear\n affiliations << affil\n end", "def add_word word #Function shovels individual strings into the dictionary array\n @dictionary << word\n end", "def collect_words(stored_data, words)\n return stored_data if words.length == 0\n w = words.shift\n stored_data[w] ||= {}\n stored_data[w] = collect_words(stored_data[w],words)\n stored_data\nend", "def initialize\n @words = (KEYWORDS + OTHERS).map(&:downcase)\n end", "def add_all(words)\n end", "def derived_words(html)\n @derived_words ||= parse_derived_words(html)\n end", "def populate(words)\n # Create an array of words and normailze it: we delete all cr chars (\\r) and put all letters downcase\n words = words.downcase.delete(\"\\r\").split(\"\\n\")\n # The anagram words contain the same letters, so we can create an hash where the key is a common index,\n # and the value is an array of words with the same key\n self.words_hash = words.each_with_object(Hash.new []) do |word,hash|\n hash[create_index(word)] += [word]\n end\n end", "def political_affiliation(voter_name)\n puts \"Which party does #{voter_name} belong to? Type letter in parenthesis.\"\n puts \"(l)iberal (c)onservative (t)ea party (s)ocialist (n)eutral\"\n\n @voters_list = []\n\n political_affiliation = gets.chomp.downcase\n\n case political_affiliation\n\n when \"l\"\n @voter = Voter.new(voter_name, political_affiliation)\n @voters_list << @voter\n\n when \"c\"\n @voter = Voter.new(voter_name, political_affiliation)\n @voters_list << @voter\n\n when \"t\"\n @voter = Voter.new(voter_name, political_affiliation)\n @voters_list << @voter\n\n when \"s\"\n @voter = Voter.new(voter_name, political_affiliation)\n @voters_list << @voter\n\n when \"n\"\n @voter = Voter.new(voter_name, political_affiliation)\n @voters_list << @voter\n\n else\n political_affiliation(voter_name)\n end\n prompt_user_for_initial_choices\n end", "def set_words\n @en_word = params[:en] && English.find_by(name: params[:en].downcase)\n @ru_word = params[:ru] && Russian.find_by(name: params[:ru].downcase)\n end", "def raw_acronyms(acronyms, words)\n list = Hash.new\n working_acronyms = Array.new\n acronyms.each {|candidate_acronym| working_acronyms.push(candidate_acronym.join)}\n i = 0\n working_acronyms.each do |acronym|\n\tlist[acronym] = words[i].map(&:capitalize).join(\" \")\n\ti = i + 1\n end\n return list\nend", "def generate_secret_word\n dictionary = File.open('5desk.txt', 'r').readlines\n legal_words = []\n\n dictionary.each do |line|\n word = line.chomp\n legal_words << word if legal_word?(word)\n end\n\n legal_words.sample\n end", "def check(words:)\n dictionary = Set.new([\"hello\", \"my\", \"name\", \"is\", \"orange\"])\n corrected = []\n words.each do | word |\n dictionary.include?(word) ? corrected.push(word) : corrected.push(\"~#{word}~\")\n end\n corrected\nend", "def save_words\n\t\t @word_weight.each do |word, weight|\n\t\t \[email protected]_or_create_word(word, @filename, weight, @word_frequency[word])\n\t\t end\n\t\tend", "def get_my_words\n # Words associated with online harassment\n trigger_words = [\"rape\",\"murder\",\"nigger\",\"slut\",\"whore\",\"bitch\",\"cunt\",\"kill\",\"die\",\"testword\"]\n my_words = Word.where(user_id: self.id)\n my_words.each do |word|\n trigger_words << word.word\n end\n return trigger_words\n end", "def collect_words_of_length\n\t\[email protected]! { |el| el.length == @word_length + 1 }\n\t\tmake_smart_dictionary\n\tend", "def add(entry) \r\n if entry.is_a? String\r\n @@words[entry] = nil\r\n else \r\n learn = entry.to_a \r\n learnit = learn[0]\r\n @@words[learnit[0]] = learnit[1]\t\r\n end\r\nend", "def update_pose_words\n\n # Step 1: get an array of all words for the current object.\n search_text = instance_eval &(self.class.pose_content)\n new_words = Query.new([], search_text.to_s).query_words\n\n # Step 2: Add new words to the search index.\n Helpers.get_words_to_add(self.pose_words, new_words).each do |word_to_add|\n self.pose_words << Word.find_or_create_by(text: word_to_add)\n end\n\n # Step 3: Remove now obsolete words from search index.\n Helpers.get_words_to_remove(self.pose_words, new_words).each do |word_to_remove|\n self.pose_words.delete word_to_remove\n end\n end", "def make_word\n @secret_word = File.readlines('dictionary.txt').sample.chomp.downcase.split('')\n @working_word = Array.new(@secret_word.length) { \"_\" }\n end", "def whisper_words(words)\n\nend", "def add_word(word)\n \n end", "def add_word(new_word, categories)\r\n categories.each do |category|\r\n fandom = fetch_fandom(category)\r\n fandom << new_word unless fandom.include? new_word\r\n end\r\n end", "def possible_words\n\t\t\[email protected] to_r\n\t\tend", "def persist_words!\n start = Time.now\n # gdbm is a fast, simple key-value DB\n require 'gdbm'\n gdbm = GDBM.new('db/word_count.db')\n count = 0\n read_text_into_hash.each do |k, v|\n # gdbm stores values as strings, so values have to be converted to\n # integers, added together and then converted to strings again\n # to be stored\n current_value = gdbm[k].to_i\n gdbm[k] = (v.to_i + current_value).to_s\n count += 1\n end\n print_status(start, count)\n end", "def user_add_vocab(db)\n\tuser_word = nil\n\twhile true\n\t\t#display without recognition column\n\t\tplain_display_vocab(db)\n\t\tputs \"What word would you like to insert? (or done)\"\n\t\tuser_word = gets.chomp.capitalize\n\t\tif user_word != \"Done\"\n\t\t\tputs \"What is the definition for #{user_word}?\"\n\t\t\tuser_def = gets.chomp.downcase\n\t\t\t#add new word and definition to table\n\t\t\tdb.execute(\"INSERT INTO nursing (word, definition) VALUES (?, ?)\", [user_word, user_def])\n\t\telse\n\t\t\treturn\n\t\tend\n\tend\nend", "def stuff(input)\n\twords = input.split(\" \")\n\n\twords.each do |x| \n\t\tif x == 'the' || x == 'of' || x == 'and' || x == 'is' || x == 'a'\n\t\t\telse\n\t\t\t\t@acronym << x.to_s.chars.first.upcase + \".\"\n\t\tend\n\tend\nend", "def all_phrases\n mario\n toadstool\n link\nend", "def all_phrases\n mario\n toadstool\n link\nend", "def display_words\n words = self.dictionary.map do |dictionary_entry|\n dictionary_entry.word.lexical_item\n end\n words \n end", "def insert_words(words)\n cm.populate(words.join(\"\\n\"))\n end", "def word_substituter(string)\ntweet=string.split(\" \")\ni = 0 \nwhile i < tweet.length \nif dictionary.keys.include?(tweet[i].downcase)\ntweet[i] = dictionary[tweet[i].downcase]\nend \ni+=1\nend\ntweet.join(\" \")\nend", "def add_ata!(word)\n @redis.rpush(\"store:atas\", Unicode.downcase(word))\n end", "def affiliation\n []\n end", "def security_questions_presented\r\n input_names = form_dynamic_textinput_names\r\n ha = {}\r\n input_names.each do |name|\r\n case\r\n when name =~ /mother__/\r\n (pre,pos) = name.split(\"__\")\r\n ha[pre] = ha.has_key?(pre) ? ha[pre]+\",\"+pos : pos\r\n when name =~ /fattwn__/\r\n (pre,pos) = name.split(\"__\")\r\n ha[pre] = ha.has_key?(pre) ? ha[pre]+\",\"+pos : pos\r\n when name =~ /school__/\r\n (pre,pos) = name.split(\"__\")\r\n ha[pre] = ha.has_key?(pre) ? ha[pre]+\",\"+pos : pos\r\n when name =~ /town__/\r\n (pre,pos) = name.split(\"__\")\r\n ha[pre] = ha.has_key?(pre) ? ha[pre]+\",\"+pos : pos\r\n when name =~ /dob__/\r\n (pre,pos) = name.split(\"__\")\r\n ha[pre] = ha.has_key?(pre) ? ha[pre]+\",\"+pos : pos\r\n end\r\n end\r\n # join upper-cased keys and values with a + in between\r\n db_row=\"\"\r\n ha.each do |k,v|\r\n v.gsub!(/day/, \"1\")\r\n v.gsub!(/month/, \"2\")\r\n v.gsub!(/year/, \"3\")\r\n\r\n db_row << k.upcase + \"\\+\" + v + \"\\/\"\r\n end\r\n db_row.chomp(\"/\")\r\n end", "def add_words(new_words)\n new_words.each do |word|\n add(word)\n end\n end", "def setsecretword word\r\n\t\t @secretword = word\r\n\t\t templ = createtemplate\r\n\t\t\t\t\tword_templ = templ.gsub(\"[\",\"\").gsub(\"]\",\"\")\r\n\t\t\t\t\ti=0\r\n\t\t\t\t\[email protected]\r\n\t\t\t\t\twhile i < sec_word_array.length do\r\n\t\t\t\t\t\tif sec_word_array[i] == \" \"\r\n\t\t\t\t\t @resulta[i] = \" \"\r\n\t\t\t\t\t else\r\n\t\t\t\t\t \t@resulta[i] = \"_\"\r\n\t\t\t\t end\r\n\t\t\t\t i+=1\r\n\t\t\t\t end\r\n\t\t end", "def properties_word_ml; end", "def primary_terms\n [:title, :description, :source, :rights_note]\n end", "def whisper_words(words)\n\twhisper = words.map { |word| word.downcase + \"...\"}\n \treturn whisper\nend", "def tell_secret_word_length\n @secret_word = @dictionary.sample\n @secret_word.length\n end", "def add(word, w)\n if word != \"\" \n cur = self\n word.downcase.each_char do |character|\n modified_char = @@vowels.include?(character) ? '*' : character\n cur.kids[modified_char] = SpellingTrie.new if not cur.kids.has_key? modified_char\n cur = cur.kids[modified_char]\n end\n cur.words_here.add(w)\n end\n end", "def initialize(name, political_affiliation)\n @name = name\n @political_affiliation = political_affiliation\n end", "def non_opt_words(current)\n output = []\n (0..(current.length-1)).each do |index|\n ('a'..'z').each do |let|\n test_word = current.clone\n test_word[index] = let\n output << test_word if legal_word?(test_word)\n end\n end\n output.uniq\nend", "def wookie_sentence; end", "def sentence(word_count: T.unsafe(nil), supplemental: T.unsafe(nil), random_words_to_add: T.unsafe(nil), open_compounds_allowed: T.unsafe(nil)); end", "def kase_description_in_words(kase)\n result = []\n result << followers_count_in_words(kase).to_s.capitalize\n\t result << replies_count_in_words(kase)\n\t result << kase_type_and_time_in_words(kase)\n\t result.compact.map {|m| m.to_s.strip}.reject {|i| i.empty?}.join(', ')\n end", "def write_inscription(description)\n if @inscription.empty? == true\n @inscription << description\n\n return @inscription\n else\n raise \"Raise ArgumentError: you cannot add more words to a door that already has a description written for it. \"\n end\n end", "def create_keywords\n\n keywords = t(LOCALE_KEYWORDS_KEY, default: SiteMetaInfoDefaults.keywords)\n business_cats = BusinessCategory.pluck(:name).uniq\n\n cats_str = business_cats.empty? ? '' : ', ' + business_cats.join(', ')\n keywords + cats_str\n end", "def store_valid_word(word)\n @words << word\n @word_index[word] = @last_letter\n end", "def personalise campaign, person={}\n #your code here\n campaign.gsub!\"<NAME>\", person[:name]\n campaign.gsub!\"<CITY>\", person[:city]\n campaign.gsub!\"<FAVOURITE PRODUCTS>\", person[:favourite_product]\n return campaign\nend", "def train!(word_list)\n word_list.each do |s|\n @dictionary[s] += 1\n end\n end", "def word_substituter (tweet=\"some thing need to be shorten, like two too\")\n tweet= tweet.strip\n temp_a = tweet.split(\" \")\n words_can_b_sh = dictionary.keys\n #puts words_can_b_sh\n temp = \"\"\n# puts temp_a\n temp_a.each do |word|\n if words_can_b_sh.include?(word.downcase)\n temp << dictionary[word.downcase]\n else\n temp << word\n end\n temp << \" \"\n end\n temp.strip\nend", "def secret_word=(word)\n @secret_word = word.upcase\n @secret_word_length = word.length\n end", "def word_list=(list)\n end", "def process_words\n reset_counts\n # iterate through radlib_array and add counts\n self.each do |w|\n Rails.logger.debug(w.inspect)\n case w[\"type\"]\n when \"word\"\n @num_words += 1\n if w[\"selectable\"] && w[\"selected\"]\n @num_blanks += 1\n # fix for old radlibs\n unless w[\"user_pos\"]\n w[\"user_pos\"] = w[\"predicted_pos\"]\n end\n type = w[\"user_pos\"].gsub(\"-\", \"_\").to_sym\n Rails.logger.debug(type)\n @num_blanks_by_type[type] += 1\n end\n when \"whitespace\"\n # don't need to do anything here\n when \"punc\"\n @num_sentences += 1 if w[\"text\"] == \".\" || w[\"text\"] == \"!\" || w[\"text\"] == \"?\"\n end\n end\n end", "def set_RelatedWords(value)\n set_input(\"RelatedWords\", value)\n end", "def add_word(word)\r\n \r\n end", "def yell_happily(words)\r\n words + \"!!!\" + \" :)\"\r\n end", "def dictionary\n if File.file?('/usr/share/dict/words')\n words_file('/usr/share/dict/words')\n elsif File.file?('/usr/dict/words')\n words_file('/usr/dict/words')\n else\n %w(\n this is a jury rigged dictionary banana monkey apple pear peach\n computers are so great robot dance\n )\n end\n end", "def existing_words\n draw_current = draw\n p \"The 7 letters drawn are:\"\n p draw_current\n p \"-\"*70\n\n combinations = combine(draw_current).flat_map{ |w| w.permutation.to_a}.uniq.map { |e| e.join }\n combinations.map{|i| search(i, UPPER_BOUND_INI, LOWER_BOUND_INI, NO_ITERATION_INI)}.flatten.reject{|x| x==nil}\nend", "def load_words\n case @strategy\n when :user\n @words = twitter_user.status.text.split(/\\s/) \n when :search\n @words = twitter_search(@term).statuses.map(&:text).join(\" \").split(/\\s/)\n end\n end", "def yell_happily(words)\r\n words + \"!!!\" + \" :)\"\r\n end", "def save_ambigious_words(file_name)\n File.open(file_name, 'w') do |f|\n sentences.each do |s|\n s.words.each do |w|\n tag_strings = w.get_correct_tags().collect { |t| t.clean_out_tag }\n f.puts w.string + \"\\t\" + tag_strings.sort.join(\"\\t\") if tag_strings.count > 1\n end\n end\n end\n\n nil\n end", "def dictionary()\n word_list = {\n \"hello\" => \"hi\",\n \"to\" => \"2\",\n \"two\" => \"2\",\n \"too\" => \"2\",\n \"for\" => \"4\",\n \"four\" => \"4\",\n \"be\" => \"b\",\n \"you\" => \"u\",\n \"at\" => \"@\",\n \"and\" => \"&\"\n }\nend", "def does_not_include_badwords\n\n badwords = %w(\n aloha!\n href=\n -online\n 1freewebspace.com\n 4u\n 5gighost.com\n accutane\n adipex\n adultsex\n advicer\n alprazolam\n amoxil\n arcadepages\n arimidex\n associations.missouristate.edu\n ativan\n augmentin\n baccarrat\n baclofen\n beaver\n blackjack\n bllogspot\n blogs.blackmarble.co.uk\n blowjob\n booker\n buspar\n byob\n car-rental-e-site\n car-rentals-e-site\n carisoprodol\n casino\n casinos\n chatroom\n cialis\n cipro\n citalopram\n clomid\n clonazepam\n comment1\n comment2\n comment3\n comment4\n comment5\n comment6\n coolcoolhu\n coolhu\n credit-card-debt\n credit-report-4u\n creditonlinepersonalloans\n cwas\n cyclen\n cyclobenzaprine\n dating-e-site\n day-trading\n debt-consolidation\n debt-consolidation-consultant\n diazepam\n diovan\n discreetordering\n dostinex\n duty-free\n dutyfree\n dvxuser.com\n equityloans\n fanreach.com\n fioricet\n flagyl\n flowers-leading-site\n fosamax\n freenet\n freenet-shopping\n gambling-\n hair-loss\n health-insurancedeals-4u\n hi5.com\n holdem\n holdempoker\n holdemsoftware\n holdemtexasturbowilson\n homeequityloans\n homefinance\n hotel-dealse-site\n hotele-site\n hotelse-site\n hydrocodone\n hyves.mn\n incest\n insurance-quotesdeals-4u\n insurancedeals-4u\n isuzuforums.com\n jestmaster\n jizz\n jrcreations\n kaboodle.com\n kamagra\n klonopin\n lamictal\n lesbian\n levaquin\n levitra\n lezbian\n loans\n lorazepam\n lycos\n macinstruct\n metformin\n metronidazole\n mortgage-4-u\n mortgagequotes\n musicstation\n nojazzfest\n nolvadex\n online-gambling\n onlinegambling-4u\n ottawavalleyag\n ownsthis\n palm-texas-holdem-game\n paxil\n paydal\n penguinforum\n penis\n personalloansbad\n pharmacy\n phenergan\n phentermine\n poker-chip\n porn\n poze\n profiles.friendster.com\n propecia\n proscar\n pussy\n remeron\n rental-car-e-site\n ringtone\n ringtones\n roulette\n shemale\n shoes\n slot-machine\n Staphcillin\n tamiflu\n tegretol\n texas-holdem\n thorcarlson\n top-e-site\n top-site\n toprol\n toradol\n tramadol\n tramodal\n tramodol\n trim-spa\n ultram\n valeofglamorganconservatives\n valium\n viagra\n vibramycin\n vicodin\n vioxx\n voltaren\n vytorin\n xanax\n zantac\n zithromax\n zofran\n zolpidem\n zolus\n )\n badwords.each do |bw|\n if !comment.nil? && comment.downcase.include?(bw) \n errors.add_to_base(\"Comment Rejected\") \n break\n end\n end\n end", "def words_count\n get_at_words_count + \n get_ata_words_count + \n get_noun_words_count + \n get_adjective_words_count\n end", "def remove_privacy_sensitive_things!(text)\n # Remove any email addresses - we don't want bounce messages to leak out\n # either the requestor's email address or the request's response email\n # address out onto the internet\n text.gsub!(MySociety::Validate.email_find_regexp, \"[email address]\")\n\n # Mobile phone numbers\n # http://www.whatdotheyknow.com/request/failed_test_purchases_off_licenc#incoming-1013\n # http://www.whatdotheyknow.com/request/selective_licensing_statistics_i#incoming-550\n # http://www.whatdotheyknow.com/request/common_purpose_training_graduate#incoming-774\n text.gsub!(/(Mobile|Mob)([\\s\\/]*(Fax|Tel))*\\s*:?[\\s\\d]*\\d/, \"[mobile number]\")\n\n # Specific removals # XXX remove these and turn them into censor rules in database\n # http://www.whatdotheyknow.com/request/total_number_of_objects_in_the_n_6\n text.gsub!(/\\*\\*\\*+\\nPolly Tucker.*/ms, \"\")\n # http://www.whatdotheyknow.com/request/cctv_data_retention_and_use\n text.gsub!(/Andy 079.*/, \"Andy [mobile number]\")\n # http://www.whatdotheyknow.com/request/how_do_the_pct_deal_with_retirin_113\n text.gsub!(/(Complaints and Corporate Affairs Officer)\\s+Westminster Primary Care Trust.+/ms, \"\\\\1\")\n\n # Remove WhatDoTheyKnow signup links\n text.gsub!(/http:\\/\\/www.whatdotheyknow.com\\/c\\/[^\\s]+/, \"[WDTK login link]\")\n\n # Remove Home Office survey links\n # e.g. http://www.whatdotheyknow.com/request/serious_crime_act_2007_section_7#incoming-12650\n if self.info_request.public_body.url_name == 'home_office'\n text.gsub!(/Your password:-\\s+[^\\s]+/, '[password]')\n text.gsub!(/Password=[^\\s]+/, '[password]')\n end\n\n # Remove things from censor rules\n self.info_request.apply_censor_rules_to_text!(text)\n end", "def whisper_words(words)\nreturn words.map{ |elem| elem.downcase + \"...\"}\nend", "def get_secret_word\n @active_list.fetch(0)\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 seed_with_adjectives\n words = AdjectiveSeed::get_adjective_list\n\n words.each do |word|\n word = word.downcase.squish.strip # Remove unnecessary whitespace\n Adjective.create(word: word)\n puts word\n end\nend", "def word_list\n @word_list ||= Set.new File.read(\"dictionary.txt\").split(\"\\n\").map(&:downcase)\n end", "def complex_words\n @complex_words ||= unique_words.select { |word| syllables_in(word) >= 3 }\n end", "def update_search_words!\n my_string = to_s\n if latest_resource\n my_string << \" #{latest_resource.title}\"\n my_string << ' ' << latest_resource.authors.map do |author|\n \"#{author.author_first_name} #{author.author_last_name} #{author.author_email} #{author.author_orcid}\"\n end.join(' ')\n my_string << abstracts\n end\n self.search_words = my_string\n # this updates without futher callbacks on me\n update_column :search_words, my_string\n end", "def update_search_words!\n my_string = to_s\n if latest_resource\n my_string << \" #{latest_resource.title}\"\n my_string << ' ' << latest_resource.authors.map do |author|\n \"#{author.author_first_name} #{author.author_last_name} #{author.author_email} #{author.author_orcid}\"\n end.join(' ')\n my_string << abstracts\n end\n self.search_words = my_string\n # this updates without futher callbacks on me\n update_column :search_words, my_string\n end", "def new_illegal_words(board, dict)\n new_words(board).reject {|word| dict.legal_word?(word.to_s)}\n end", "def hardCodedPolicies()\n\n return [\"Ice time rates are subject to change.\",\n \"Booking total is subject to change depending on activity at the discretion of the \" + long_name + \".\",\n \"Ice schedules are subject to change and Playogo does not guarantee that the timeslot is available until it is confirmed by the \" + long_name + \".\",\n \"Once your booking request has been confirmed by the \" + long_name + \", the price of the booking will be charged to your credit card.\",\n \"Your ice contract will be with the \" + long_name + \".\",\n \"Refer to all terms and conditions of your contract with the \" + long_name + \".\",\n \"Playogo is a non-affiliated third party, who simply makes it easier to find available ice time across a number of markets.\",\n \"There are no additional fees to book ice time through Playogo.\"\n ]\n end", "def educational_attainment; end", "def word_params\n params.require(:word).permit( :user_id,\n :language,\n :untranslated_word,\n :translated_word,\n :user_phonem,\n :common_rank,\n :audio_link,)\n end", "def word_substituter(tweet)\n tweet.split.map { |word| \n dictionary[word.downcase] || word }.join(\" \")\n end", "def init\n @words = dictionary.sample(20).map(&:strip)\n end", "def get_current_state_of_word()\r\n\r\n wordString = \"\"\r\n\r\n for i in 0..@secretWordLength-1 do\r\n\r\n key = @secretWord[i]\r\n\r\n if @lettersGuessed[key] == true \r\n wordString += key\r\n elsif @lettersGuessed[key] == false\r\n wordString += \"_ \" \r\n end\r\n\r\n end\r\n\r\n return wordString\r\n end", "def update_word_state\n @secret.chars.each_with_index do |letter, idx| \n @word_state[idx] = letter if @guesses[-1] == letter\n end\n @word_state\n end", "def read_word_file(file)\n\t\tFile.foreach(file) do |line|\n\t\t\tif(@@word.legal?(line.chomp)) # Check if current line/word is legal\n\t\t\t\tLEGAL_WORDS << line.chomp # Add line/word to array of legal words\n\t\t\tend\n end\n LEGAL_WORDS.freeze # Freeze LEGAL_WORDS to make it immutable\n\tend", "def morph_words\n words = @query.split(/[^a-zA-Z0-9]/)\n morphed_words = words.map{|word| [word,Text::Metaphone.double_metaphone(word)]}\n morphed_words\n end", "def initialize\n @words = I18n.t :dictionary\n @max_word_index = @words.size - 1\n end", "def calculate_nice_words (users)\n\thappy_word = Hash.new(0)\n\tfile_name = \"happywords.txt\"\n\tyour_happy_Words = []\n\tFile.open(file_name, \"r\").each_line do |line|\n\t\tline.strip.split(' ' || '\\t').each do |s|\n\t\t\thappy_word[s] = 1\n\t\tend \n\tend\n\thappy_count = 0\n\tusers.each do |user|\n\t\tuser[\"text\"].strip.split(' ').each do |s|\n\t\t\tif happy_word[s] == 1 then\n\t\t\t\tnewWordObj= Word.new(s, user[\"text\"])\n\t\t\t\tyour_happy_Words.push(newWordObj)\n\t\t\tend\n\t\tend\n\tend\n\tyour_happy_Words\nend", "def initialize *args\n @attempts = Hash.new(nil)\n @sentence = args[0] || DEFAULT_SENTENCE\n @words = args[1] || ENGLISH_NUMBERS\n @words = @words.dup\n @thirty_plus = args[1] || ENGLISH_THIRTY_PLUS\n count = 30\n @thirty_plus.each do |word|\n @words[count] = word\n count += 10\n end\n\n extend_wordlist MAX_COUNT\n #puts \"@sentence=#{@sentence}\"\n # only add one the first time, all the others already have the extra one\n\n @result = letter_frequency @sentence\n @result.each { |k,v| @result[k] += 1 }\n #puts full_sentence( @result )\n self\n end", "def save_adword_urls(page)\n\t\tsave_adword_urls_right(page) \n\t\tsave_adword_urls_top(page)\n\tend", "def test_supplemental_words\n @words = @tester.words(number: 10_000, supplemental: true)\n\n @words.each { |w| assert_includes @complete_wordlist, w }\n end", "def test_supplemental_words\n @words = @tester.words(number: 10_000, supplemental: true)\n\n @words.each { |w| assert_includes @complete_wordlist, w }\n end", "def gluck_italian; end", "def word_frequency\n @word_use = Hash.new(0)\n words.each { |w| @word_use[w] += 1 }\n @word_use\n end", "def insertions\n new_words = []\n @words.each do |word|\n @word = word || '' \n (length + 1).times do |i|\n ('a'..'z').each { |c| new_words << \"#{@word[0...i]}#{c}#{@word[i..-1]}\" }\n end\n end\n new_words\n end", "def pick_secret_word\n @word = dictionary.sample\n word\n end", "def pword\n end", "def snippet(text, wordcount, omission)\n return '' if text.blank?\n text.split[0..(wordcount-1)].join(\" \") + (text.split.size > wordcount ? \" \" + omission : \"\")\n end", "def polly_wanna word\n word*3\n end", "def save_text\n @lexemes << @lexeme\n end" ]
[ "0.5727451", "0.5593518", "0.55619323", "0.5515267", "0.54821146", "0.5475592", "0.5460208", "0.54224265", "0.5398076", "0.5379724", "0.53557044", "0.53491235", "0.5321153", "0.52687573", "0.52671456", "0.5242141", "0.52264255", "0.52238184", "0.5209235", "0.5204786", "0.5204431", "0.51795065", "0.5174485", "0.51737493", "0.51721776", "0.51633567", "0.5162806", "0.5149428", "0.5149428", "0.5134028", "0.51306206", "0.51293737", "0.5127178", "0.5109578", "0.5101757", "0.5098203", "0.50837904", "0.5079412", "0.5078954", "0.5074785", "0.5066881", "0.5065833", "0.5050717", "0.50439715", "0.5039136", "0.5038059", "0.50364846", "0.50327796", "0.50285107", "0.50257325", "0.50201416", "0.5010234", "0.50097454", "0.50034565", "0.5002377", "0.49924496", "0.4992437", "0.49919575", "0.49904647", "0.498898", "0.49868408", "0.49858236", "0.4971668", "0.49704108", "0.49697828", "0.4969494", "0.49624708", "0.4958257", "0.49579337", "0.49558395", "0.49438357", "0.4943607", "0.4938565", "0.49376976", "0.49348775", "0.49348775", "0.49341774", "0.49297658", "0.49268505", "0.4920429", "0.49190077", "0.49177206", "0.49164507", "0.49099818", "0.49096015", "0.4907948", "0.49010614", "0.48922634", "0.489064", "0.48875374", "0.48840156", "0.48840156", "0.48770952", "0.48723993", "0.48716775", "0.48712963", "0.48712355", "0.4870338", "0.4869116", "0.48662987" ]
0.5241604
16
This method stores whole words for voters political view.
def whole_views(new_political_view) case new_political_view when "l" "Liberal" when "c" "Conservative" when "t" "Tea Party" when "s" "Socialist" when "n" "Neutral" else "Liberal" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_pose_words\n\n # Step 1: get an array of all words for the current object.\n search_text = instance_eval &(self.class.pose_content)\n new_words = Query.new([], search_text.to_s).query_words\n\n # Step 2: Add new words to the search index.\n Helpers.get_words_to_add(self.pose_words, new_words).each do |word_to_add|\n self.pose_words << Word.find_or_create_by(text: word_to_add)\n end\n\n # Step 3: Remove now obsolete words from search index.\n Helpers.get_words_to_remove(self.pose_words, new_words).each do |word_to_remove|\n self.pose_words.delete word_to_remove\n end\n end", "def set_words\n @en_word = params[:en] && English.find_by(name: params[:en].downcase)\n @ru_word = params[:ru] && Russian.find_by(name: params[:ru].downcase)\n end", "def collect_words(stored_data, words)\n return stored_data if words.length == 0\n w = words.shift\n stored_data[w] ||= {}\n stored_data[w] = collect_words(stored_data[w],words)\n stored_data\nend", "def save_words\n\t\t @word_weight.each do |word, weight|\n\t\t \[email protected]_or_create_word(word, @filename, weight, @word_frequency[word])\n\t\t end\n\t\tend", "def get_my_words\n # Words associated with online harassment\n trigger_words = [\"rape\",\"murder\",\"nigger\",\"slut\",\"whore\",\"bitch\",\"cunt\",\"kill\",\"die\",\"testword\"]\n my_words = Word.where(user_id: self.id)\n my_words.each do |word|\n trigger_words << word.word\n end\n return trigger_words\n end", "def persist_words!\n start = Time.now\n # gdbm is a fast, simple key-value DB\n require 'gdbm'\n gdbm = GDBM.new('db/word_count.db')\n count = 0\n read_text_into_hash.each do |k, v|\n # gdbm stores values as strings, so values have to be converted to\n # integers, added together and then converted to strings again\n # to be stored\n current_value = gdbm[k].to_i\n gdbm[k] = (v.to_i + current_value).to_s\n count += 1\n end\n print_status(start, count)\n end", "def whisper_words(words)\n\nend", "def words\n @words\n end", "def words\n @phrase = @phrase.split(' ')\n end", "def switch_viewpoint (words)\n \t\tnew_string = \"\"\n\t\t\n \t\t# TODO move to config file\n \t\tviewpoints = {\"i\" => \"you\", \"you\" => \"I\", \"me\" => \"are\", \"my\" => \"your\"}\n\t\t\n \t\twords.split.each do |word|\n \t\t\tif(viewpoints[word.downcase])\n \t\t\t\tword = viewpoints[word.downcase]\n \t\t\tend\t\n\t\t\t\n \t\t\tnew_string += word + \" \"\t\t\n \t\tend\n\t\t\n \t\t# trim trailing space\n \t\tnew_string.chop\n \tend", "def load_words\n case @strategy\n when :user\n @words = twitter_user.status.text.split(/\\s/) \n when :search\n @words = twitter_search(@term).statuses.map(&:text).join(\" \").split(/\\s/)\n end\n end", "def words\n @words\n end", "def possible_words\n\t\t\[email protected] to_r\n\t\tend", "def words\n words = @phrase.split(\" \")\n words.each do |word|\n translate(word)\n end\n end", "def collect_words_of_length\n\t\[email protected]! { |el| el.length == @word_length + 1 }\n\t\tmake_smart_dictionary\n\tend", "def process_words\n reset_counts\n # iterate through radlib_array and add counts\n self.each do |w|\n Rails.logger.debug(w.inspect)\n case w[\"type\"]\n when \"word\"\n @num_words += 1\n if w[\"selectable\"] && w[\"selected\"]\n @num_blanks += 1\n # fix for old radlibs\n unless w[\"user_pos\"]\n w[\"user_pos\"] = w[\"predicted_pos\"]\n end\n type = w[\"user_pos\"].gsub(\"-\", \"_\").to_sym\n Rails.logger.debug(type)\n @num_blanks_by_type[type] += 1\n end\n when \"whitespace\"\n # don't need to do anything here\n when \"punc\"\n @num_sentences += 1 if w[\"text\"] == \".\" || w[\"text\"] == \"!\" || w[\"text\"] == \"?\"\n end\n end\n end", "def get_current_state_of_word()\r\n\r\n wordString = \"\"\r\n\r\n for i in 0..@secretWordLength-1 do\r\n\r\n key = @secretWord[i]\r\n\r\n if @lettersGuessed[key] == true \r\n wordString += key\r\n elsif @lettersGuessed[key] == false\r\n wordString += \"_ \" \r\n end\r\n\r\n end\r\n\r\n return wordString\r\n end", "def display_words\n words = self.dictionary.map do |dictionary_entry|\n dictionary_entry.word.lexical_item\n end\n words \n end", "def update_search_words!\n my_string = to_s\n if latest_resource\n my_string << \" #{latest_resource.title}\"\n my_string << ' ' << latest_resource.authors.map do |author|\n \"#{author.author_first_name} #{author.author_last_name} #{author.author_email} #{author.author_orcid}\"\n end.join(' ')\n my_string << abstracts\n end\n self.search_words = my_string\n # this updates without futher callbacks on me\n update_column :search_words, my_string\n end", "def update_search_words!\n my_string = to_s\n if latest_resource\n my_string << \" #{latest_resource.title}\"\n my_string << ' ' << latest_resource.authors.map do |author|\n \"#{author.author_first_name} #{author.author_last_name} #{author.author_email} #{author.author_orcid}\"\n end.join(' ')\n my_string << abstracts\n end\n self.search_words = my_string\n # this updates without futher callbacks on me\n update_column :search_words, my_string\n end", "def update_word_state\n @secret.chars.each_with_index do |letter, idx| \n @word_state[idx] = letter if @guesses[-1] == letter\n end\n @word_state\n end", "def word_list\n @word_list\n end", "def gensecretword \n @wordtable.sample.gsub(/\\s+/, \"\") # revoving all whitespaces as wordfile has phrases as possible secret words\nend", "def words=(v)\n Axlsx.validate_int v\n @words = v\n end", "def setsecretword word\r\n\t\t @secretword = word\r\n\t\t templ = createtemplate\r\n\t\t\t\t\tword_templ = templ.gsub(\"[\",\"\").gsub(\"]\",\"\")\r\n\t\t\t\t\ti=0\r\n\t\t\t\t\[email protected]\r\n\t\t\t\t\twhile i < sec_word_array.length do\r\n\t\t\t\t\t\tif sec_word_array[i] == \" \"\r\n\t\t\t\t\t @resulta[i] = \" \"\r\n\t\t\t\t\t else\r\n\t\t\t\t\t \t@resulta[i] = \"_\"\r\n\t\t\t\t end\r\n\t\t\t\t i+=1\r\n\t\t\t\t end\r\n\t\t end", "def scream(word)\n words = words + \"!!!!\"\nend", "def words\n @words_array = @phrase.split(' ')\n end", "def set_game_variables\n\t\tword = @dictionary.random_word\n\t\t@answer_array = word.split('')\n\t\t@blank_word_array = []\n\t\tword.length.times do \n\t\t\t@blank_word_array << \"_\"\n\t\tend\n\t\t@guess_counter = 6\n\t\t@incorrect_array = []\n\tend", "def get_words\n @sentences.each_index do |i|\n s = @sentences[i]\n words = s.split(' ')\n words.each do |w|\n word = w.gsub(WORD_SANITIZE, '').downcase\n if belongs_to_known_abbreviations? word\n add_word_to_result(word, i)\n else\n add_word_to_result(word.gsub(DOT_SANITIZE, ''), i)\n end\n end\n end\n end", "def scream(words)\n words = words + \"!!!!!\"\n words\nend", "def all_phrases\n mario\n toadstool\n link\nend", "def all_phrases\n mario\n toadstool\n link\nend", "def properties_word_ml; end", "def scream(words)\n\twords = words + \"!!!!\"\nend", "def word_list=(list)\n end", "def add_all(words)\n end", "def update!(**args)\n @words = args[:words] if args.key?(:words)\n end", "def words\n []\n end", "def adv\n @words1 = Word.all.sample(1)[0].word\n @words2 = Word.all.sample(1)[0].word\n end", "def initialize\n @words = (KEYWORDS + OTHERS).map(&:downcase)\n end", "def stop_words\n return {} if self.collection_yaml.nil?\n return self[:stop_words] unless self[:stop_words].nil?\n \n self[:stop_words] = Treat.languages[self.treat_collection.language].stop_words\n self.save!\n \n self[:stop_words]\n end", "def analyze phrase\n\t\t@meaningful_words = meaningful_words(phrase, \" \")\n\tend", "def words\n @words ||= Array(@grpc.words).map do |b|\n Word.from_grpc b\n end\n end", "def words\n grid.words.map {|word| decorate_word(word) }\n end", "def save_unmatched_words # :nodoc:\n tokens = phrase_without_matches.split(' ')\n unmatched_db = Corpus.new(\"unmatched-#{program_name}.db\")\n tokens.each do |token|\n if !complex_token_matches?(token) # token was not transformed earlier\n @to_match << token\n unmatched_db[token] = @processor.original_text\n end\n end\n unmatched_db.close\n end", "def update_teaser(last_guess)\n new_teaser = @word_teaser.split\n\n new_teaser.each_with_index do |letter, index|\n if letter == '_' && @secret_word[index] == last_guess\n new_teaser[index] = last_guess\n end\n end\n\n @word_teaser = new_teaser.join(' ')\n end", "def add_words(new_words)\n new_words.each do |word|\n add(word)\n end\n end", "def e_words(str)\r\n \r\nend", "def words\n @content.split\n end", "def words\n @content.split\n end", "def scream(words)\n words = words + \"!!!!\"\n puts words\n end", "def scream(words)\n words = words + \"!!!!\"\n puts words\n end", "def add(word, w)\n if word != \"\" \n cur = self\n word.downcase.each_char do |character|\n modified_char = @@vowels.include?(character) ? '*' : character\n cur.kids[modified_char] = SpellingTrie.new if not cur.kids.has_key? modified_char\n cur = cur.kids[modified_char]\n end\n cur.words_here.add(w)\n end\n end", "def explore_current_words\n\t\tnew_curr_words = []\t# all new words 1, 2, 3...steps away\n\t\t@current_words.each do |curr_word|\n\t\t\tadjacent_words(curr_word).each do |adj_word|\n\t\t\t\tnext if @all_seen_words.has_key?(adj_word) \n\t\t\t\t# else, add new word to this layer\n\t\t\t\tnew_curr_words << adj_word\n\t\t\t\t@all_seen_words[adj_word] = curr_word\n\t\t\tend\n\t\tend\n\n\t\t@current_words = new_curr_words # start new layer\n\tend", "def wake_words\n\t\t[\"light\", \"lights\", \"scene\", \"seen\"]\n\tend", "def pword\n end", "def texts=(texts); end", "def texts=(texts); end", "def update_display \r\n \tletters = @secret_word.chars\r\n \tletters.each_with_index {|letter, index| @word_display[index] = letter if letter == @guess}\r\n \t@word_display\r\n end", "def scream(words)\n words = words + \"!!!!\"\n return words\nend", "def scream(words)\n words = words + \"!!!!\"\n return words\nend", "def scream(words)\n words = words + \"!!!!\"\n return words\nend", "def make_word\n @secret_word = File.readlines('dictionary.txt').sample.chomp.downcase.split('')\n @working_word = Array.new(@secret_word.length) { \"_\" }\n end", "def scream(words)\n words = words + \"!!!\"\n puts words \nend", "def scream(words)\n words = words + '!!!!'\nend", "def wake_words\n [\"light\", \"lights\", \"scene\", \"seen\"]\n end", "def wookie_sentence; end", "def format_words\n return \"@words = #{@words.inspect}\"\n end", "def scream(words)\n words = words + \"!!!!\"\nend", "def scream(words)\n words = words + \"!!!!\"\nend", "def scream(words)\n words = words + \"!!!!\"\nend", "def scream(words)\n words = words + \"!!!!\"\nend", "def scream(words)\n words = words + \"!!!!\"\nend", "def words\n %w(this array has five words)\nend", "def get_lemmatized_words(uid)\n doc = Document.find(uid, fulltext: true, term_vectors: true)\n add_dfs(doc)\n\n yml = Cheetah.run(Admin::Setting.nlp_tool_path, '-l',\n stdin: doc.fulltext, stdout: :capture)\n YAML.load(yml)\n end", "def translate\n @new_phrase = []\n words\n @phrase.each do |word|\n @new_phrase << changer(word)\n end\n end", "def variation_words word\n ( deletions(word) + transpositions(word) + replacements(word) + insertions(word) ).uniq\n end", "def whisper_words(words)\n\twhisper = words.map { |word| word.downcase + \"...\"}\n \treturn whisper\nend", "def add_word word #Function shovels individual strings into the dictionary array\n @dictionary << word\n end", "def words\n @words ||= (\n load_words(1000) || corpus.words.to_h(1000)\n )\n end", "def save_text\n @lexemes << @lexeme\n end", "def scream(word)\n words = words + \"!!!!\"\n puts words\nend", "def morph_words\n words = @query.split(/[^a-zA-Z0-9]/)\n morphed_words = words.map{|word| [word,Text::Metaphone.double_metaphone(word)]}\n morphed_words\n end", "def tell_secret_word_length\n @secret_word = @dictionary.sample\n @secret_word.length\n end", "def yell_happily(words)\r\n words + \"!!!\" + \" :)\"\r\n end", "def get_word_collection\n\t\tword_collection = GpInSignal.get_input_signals_names.map {|n| n.name }\n\t\tword_collection += GpOutSignal.get_output_signals_names.map {|n| n.name }\n\t\tword_collection += GpInput.get_input_names(@system).map {|n| n.name }\n\t\tword_collection += GpOutput.get_output_names(@system).map {|n| n.name }\n word_collection << \"Crosspoint\"\n\t\treturn word_collection\n\tend", "def scream(words)\n words = words + \"!!!!\"\n puts words\n end", "def words\n @words ||= dictionary.select { |word| word.length > 3 }\n end", "def yell_happily(words)\r\n words + \"!!!\" + \" :)\"\r\n end", "def show_word(secretword)\n\t\tanswers = []\n\t\tsecretword.length.times do\n\t\t\tanswers.push(\"\")\n\t\tend\n\t\tanswers\n\tend", "def current_word()\n current = $build_word.join(\" \") # return a string of placeholder underscores + correctly guessed letters\nend", "def scream(words)\n words = words + \"!!!!\"\n puts words\n\t#words\nend", "def global_vars\n @title = 'Wytwarzanie Pomocy Dydaktycznych: Pomoce dydaktyczne, szkolne i naukowe dla przedszkoli szkoł'\n @desription = ''\n @keywords = 'pomoce dydaktyczne, pomoce szkolne, pomoce naukowe, pomoce dydaktyczne dla szkół, pomoce dydaktyczne dla przedszkoli, radosna szkoła, Wytwarzanie Pomocy Dydaktycznych, wpd, wpd.pl'\n end", "def list\n @list ||= Vidibus::Words.words(input)\n end", "def add_word(word)\n \n end", "def array_word\n p @arrayed_word = @secret_word.split(\"\")\n end", "def original_word\n\t\tword\n\tend", "def existing_words\n draw_current = draw\n p \"The 7 letters drawn are:\"\n p draw_current\n p \"-\"*70\n\n combinations = combine(draw_current).flat_map{ |w| w.permutation.to_a}.uniq.map { |e| e.join }\n combinations.map{|i| search(i, UPPER_BOUND_INI, LOWER_BOUND_INI, NO_ITERATION_INI)}.flatten.reject{|x| x==nil}\nend", "def word_status\n\t\t@ans_word.length.times do\n\t\t\t@guess << \"_\"\n\t\tend\n\t\tputs \"Guesser, your secret word has #{@ans_word.length} characters: #{@guess*\"\"}\"\n\tend", "def init\n @words = dictionary.sample(20).map(&:strip)\n end", "def sentence(word_count: T.unsafe(nil), supplemental: T.unsafe(nil), random_words_to_add: T.unsafe(nil), open_compounds_allowed: T.unsafe(nil)); end" ]
[ "0.64821327", "0.60820365", "0.605837", "0.6032767", "0.5932973", "0.5908903", "0.58927476", "0.58840084", "0.5870585", "0.5862464", "0.58551824", "0.58437544", "0.58405465", "0.5830367", "0.5804689", "0.57679665", "0.57364255", "0.57329744", "0.5729428", "0.5729428", "0.57278794", "0.5704793", "0.56799245", "0.56675845", "0.5662913", "0.5646081", "0.5643763", "0.56394494", "0.5603156", "0.56022024", "0.55941856", "0.55941856", "0.5593185", "0.5591966", "0.5584675", "0.5580538", "0.55771697", "0.5564747", "0.55645555", "0.55633533", "0.5551862", "0.55501294", "0.55480677", "0.55383754", "0.5529648", "0.55217177", "0.5512779", "0.5499092", "0.54857594", "0.54857594", "0.5485169", "0.5485169", "0.548231", "0.547976", "0.54787236", "0.54748416", "0.54744893", "0.54744893", "0.5473587", "0.54697996", "0.54697996", "0.54697996", "0.5464623", "0.5462117", "0.54619354", "0.5460925", "0.54577786", "0.54542243", "0.5453718", "0.5453718", "0.5453718", "0.5453718", "0.5453718", "0.5452079", "0.54517215", "0.544794", "0.54473615", "0.54428625", "0.54413813", "0.5426574", "0.5425416", "0.54249287", "0.5422318", "0.54178035", "0.54127884", "0.54104364", "0.54063576", "0.5403448", "0.53946364", "0.53935885", "0.5393273", "0.5391608", "0.5389942", "0.5383546", "0.5381615", "0.53782797", "0.5376685", "0.53728294", "0.5372094", "0.53616756", "0.5351711" ]
0.0
-1
This slows down the text, all spy like. ;)
def slow_r_down(text) text.to_s.each_char do |x| print x case x when ".", "!", "?" sleep(0.35) else sleep(0.03) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_line_speed\n @line_show_fast = CP::CMS::TEXT_TYPE_OR_SKIP\n end", "def slow_scroll()\r\n 10.times do\r\n sleep 0.05\r\n puts \"\"\r\n end\r\nend", "def animate(text: 'Downloading')\n\tt = Thread.new {\n\t\ti = 0\n\t\tlen = text.length\n\t\tchars = %W(\\u2802 \\u2812 \\u2832 \\u2834 \\u2826)\n\n\t\twhile true\n\t\t\ti += 1\n\t\t\ti_m_l = i % len\n\n\t\t\tprint \"\\e[2K #{chars.rotate![0]} #{text[0...i_m_l]}#{text[i_m_l].swapcase}#{text[i_m_l + 1..-1]}\\r\"\n\t\t\tsleep 0.1\n\t\tend\n\t}\n\n\tv = yield\n\tt &.kill\n\tputs\n\treturn v\nend", "def process\n @viewport.visible = true\n while Core::LOCK.locked?\n Graphics.update\n @text.text = @texts[Graphics.frame_count % 60 / 20] if Graphics.frame_count % 20 == 0\n end\n @viewport.visible = false\n end", "def update\n if @think_time % 6 == 0\n self.bitmap.clear \n @think_text +=\".\" \n if self.bitmap.text_size(@think_text).width > self.width\n reset_text\n end\n self.bitmap.draw_outline_text(0, 0, self.width, self.height, @think_text)\n end\n super\n if @think_time > 0\n @think_time -= 1\n return true\n else\n return false\n end\n end", "def half_refresh\n contents.clear_rect(24, 0, contents_width - 24, line_height)\n draw_text(24, 0, contents_width - 24, line_height, $game_system.playtime_s, 2)\n end", "def scrolling_text(text)\n # Good luck\n results = []\n counter = text.length\n new_text = text.upcase \n\n counter.times do \n results << new_text\n head = new_text[0]\n tail = new_text[1..-1]\n new_text = tail + head\n \n end\n results\nend", "def game_complete_text\n slow_type(\"\\nCongratulations, #{@new_player_name}! You have found your way out!\")\n pause(0.3)\n slow_type(\"Written, developed and coded by Adam Vaughan and Danny Smith.\")\n pause(0.3)\n slow_type(\"Stayed tuned for more levels!\")\n end", "def improve(text)\n return Typogruby.improve(text.to_s)\n end", "def draw\r\n @font.draw_text(\"No Longer Human!\", 50,50,0)\r\n end", "def notebooktext_short\n truncate_text_words(self.notebooktext, 100)\n end", "def loading\n chars = %w[| / ― \\\\]\n fps = 10\n delay = 1.0/fps\n\n fps.round.times do |i|\n print chars[ i % chars.length]\n sleep delay\n print \"\\b\"\n end\nend", "def adjust_transition_text\n if @temporary_objects[:title].width > Window.width - (@margin * 2)\n length_per_char = @temporary_objects[:title].width / @temporary_objects[:title].text.length\n split_title = @temporary_objects[:title].text.split(' ')\n\n remove_from_temporary(:title)\n title_parts = []\n grouped_text = []\n grouped_text_length = 0\n split_title.each_index do |i|\n grouped_text_length += (split_title[i].length + 1) * length_per_char\n if grouped_text_length > Window.width - (@margin * 2)\n if i < split_title.length - 1\n text = grouped_text.join(' ').rstrip\n sym = \"divided_text_#{i}\".to_sym\n # make a new text object\n @temporary_objects[sym] = Text.new(text, {x: 0, y: 0, size: 20, z: 6, font: 'assets/fonts/PressStart2P.ttf'})\n \n title_parts << @temporary_objects[sym]\n\n grouped_text = []\n grouped_text << split_title[i]\n grouped_text_length = (split_title[i].length + 1) * length_per_char\n else\n text = grouped_text.join(' ').rstrip\n sym = \"divided_text_#{i}\".to_sym\n sym2 = \"divided_text_#{i + 1}\".to_sym\n\n # make a new text object with grouped_text\n @temporary_objects[sym] = Text.new(text, {x: 0, y: 0, size: 20, z: 6, font: 'assets/fonts/PressStart2P.ttf'})\n # make a new text object with split_title[i]\n @temporary_objects[sym2] = Text.new(split_title[i], {x: 0, y: 0, size: 20, z: 6, font: 'assets/fonts/PressStart2P.ttf'})\n\n title_parts << @temporary_objects[sym]\n title_parts << @temporary_objects[sym2]\n end\n else\n if i < split_title.length - 1\n grouped_text << split_title[i]\n else\n grouped_text << split_title[i]\n text = grouped_text.join(' ').rstrip\n sym = \"divided_text_#{i}\".to_sym\n # make a new text object with grouped_text\n @temporary_objects[sym] = Text.new(text, {x: 0, y: 0, size: 20, z: 6, font: 'assets/fonts/PressStart2P.ttf'})\n title_parts << @temporary_objects[sym]\n end\n end\n end\n\n positions = get_centered_positions(title_parts, 5)\n title_parts.each_index do |i|\n title_parts[i].x = positions[i][:x]\n title_parts[i].y = positions[i][:y]\n end\n end\n end", "def update_text_animation()\n unless @animchars.empty?\n @animchars.each do |letter|\n letter.update\n end\n end\n end", "def go_very_slow\n puts \"I am a heavy truck and like going very slow.\"\n end", "def scrollspy_item(text)\n text.length > LIMIT ? text[0..LIMIT].split(\" \")[0..-2].join(' ') << '...' : text\n end", "def play_name_animation(name)\n 3.times do |i|\n puts \"\\e[H\\e[2J\" \n letterify_name(name)\n sleep(0.3)\n puts \"\\e[H\\e[2J\" \n blankify_name(name)\n sleep(0.3)\n end\nend", "def refresh\n contents.clear\n for i in 0...(@cw_data.size / 2)\n draw_text_ex(0, line_height*i, \"\\\\c[16]\" + @cw_data[i*2])\n reset_font_settings\n draw_text(0, line_height*i, contents_width, line_height, value(@cw_data[i*2 + 1]), 2)\n end\n end", "def shrink_to_fit(text)\n wrap(text)\n until @everything_printed || @font_size <= @min_font_size\n @font_size = [@font_size - 0.3, @min_font_size].max\n @document.font_size = @font_size\n wrap(text)\n end\n end", "def preview(text, length=400)\n text.split(/\\s/).inject(\"\") do |out, chunk|\n if (out.size + 1 + chunk.size) <= length\n out + \" \" + chunk\n else\n return out + \" ...\"\n end\n end\n end", "def display_word\n system \"clear\"\n wave_display\n puts \"Watch carefully and remember...\"\n puts \" \" + fetch_current_word + \" \\r\"\n # time_limit\n sleep($hide_speed)\n player_input_word\nend", "def character\n system(\"clear\")\n a = Artii::Base.new :font => 'slant'\n puts a.asciify('Fantasy Final')\n sleep(5)\n end", "def shrink_text(text, num_words=5)\n text = text.split[0..(num_words-1)].join(\" \") + (text.split.size > num_words ? \"...\" : \"\")\n return text\n end", "def teaser(text, options = {})\n options.reverse_merge!(:length => 150, :omission => '...')\n format = options.delete(:format) if options[:format]\n truncate(strip_tags(to_html(text.to_s, format)).strip, options)\n end", "def draw_text(xp, yp, step, strs, draw, canvas) # xp,yp is X,Y position. draw is the drawing method, canvas is where to draw on\n for str in strs\n yp = yp + step\n draw.annotate(canvas,647,600,xp,yp,str){\n draw.fill = '#ddd'\n draw.stroke = 'transparent'\n draw.pointsize = 20\n # self.font = \"BS.ttf\" \n draw.font = $config[\"fonts\"][3] \n }\n end\n return yp\nend", "def take_refresh\n rect = line_rect\n contents.clear_rect(rect)\n return if @dummy_num == 0\n draw_item_name(product.item, 0, 0)\n w = number_width\n x = contents_width - number_width\n draw_text(x, 0, w, line_height, @dummy_num)\n end", "def credits(text, speed, name, size, color, bold, italic, outline, shadow)\r\n #reset original position\r\n self.ox = self.oy = 0\r\n #flag bitmap for disposal\r\n @text_flag = true\r\n #get the text array\r\n text = text.split(\"\\n\")\r\n #setup the bitmap\r\n bitmap_size = 0\r\n font_size = size\r\n #check each line\r\n text.each do |line|\r\n #if it is a font changing line\r\n if line =~ /font_(\\w*)\\((.*)\\)/\r\n #change font size if needed\r\n font_size = $2.to_i if $1 == 'size'\r\n #skip bitmap size increment\r\n next\r\n end\r\n #increase the bitmap size by the font size\r\n bitmap_size += (font_size + 10)\r\n end\r\n self.bitmap = Bitmap.new(640, bitmap_size)\r\n #setup font\r\n self.bitmap.font.name = name\r\n self.bitmap.font.size = size\r\n self.bitmap.font.color = color\r\n self.bitmap.font.bold = bold\r\n self.bitmap.font.italic = italic\r\n @outline = outline\r\n @shadow = shadow\r\n #location to draw the text\r\n y = 0\r\n #loop through each line of text\r\n text.each do |line|\r\n #adjust the font if needed\r\n if line =~ /font_(\\w*)\\(['\"]?(\\w*)['\"]?,?(\\d*),?(\\d*),?(\\d*)\\)/\r\n case $1\r\n when 'name'\r\n self.bitmap.font.name = $2\r\n when 'size'\r\n self.bitmap.font.size = $2.to_i\r\n when 'color'\r\n self.bitmap.font.color = Color.new($2.to_i,$3.to_i,$4.to_i,$5.to_i)\r\n when 'bold'\r\n eval(\"self.bitmap.font.bold = #{$2}\")\r\n when'italic'\r\n eval(\"self.bitmap.font.italic = #{$2}\")\r\n when 'outline'\r\n eval(\"@outline = #{$2}\")\r\n when 'shadow'\r\n eval(\"@shadow = #{$2}\")\r\n end\r\n next\r\n end\r\n #draw the text\r\n draw_text(0, y, 640, self.bitmap.font.size, line, 1)\r\n #increment the next drawing location\r\n y += (self.bitmap.font.size + 10)\r\n end\r\n #move to the bottom of the screen and set the scrolling speed\r\n self.y = 480\r\n @scroll_speed = speed\r\n #return the time taken to scroll to the end\r\n return (bitmap_size + 480) / speed\r\n end", "def speed_benchmark(string, n)\n initialize()\n bm(15) do |test|\n test.report(\"reverse markdown:\") { n.times do; parse_string(string); initialize(); end; }\n end\n end", "def slowly\n yield.each_char {|x| putc x ; sleep(0.009) }\n puts \"\"\n end", "def printStringRandomFont(printMe, duration)\n x = printMe.split(\", \")\n currentTime = Time.now.to_i\n futureTime = currentTime + duration\n while (currentTime <= futureTime) do\n print \"#{isMe(onMe(\"\\n#{returnFont(x[$prng.rand(0...x.length())])}\\n\\n\"))}\"\n currentTime = Time.now.to_i\n end\n menu()\nend", "def draw\n return if @hidden\n cur_y = @cur_start_y\n @lines.each do |line|\n if cur_y >= (600 - START_Y - FONT_HEIGHT) then\n newline = find_line_length(@lines.shift)\n if newline.length > 1 then\n @lines.unshift(newline[1..-1].join(\" \"))\n else\n if @cur_start_y != START_Y then\n @cur_start_y = START_Y\n else\n @cur_start_y = START_Y + FONT_HEIGHT\n end\n end\n end\n \n line = line[0, @current_pos] if line == @lines.last and !@current\n width = @font.text_width(line)\n if width.to_i >= TEXT_WIDTH then\n # now break down each segment~\n # try to find a word break if possible\n new_lines = find_line_length(line)\n new_lines.each do |l|\n if cur_y >= (600 - START_Y - FONT_HEIGHT) then\n newline = find_line_length(@lines.shift)\n if newline.length > 1 then\n @lines.unshift(newline[1..-1].join(\" \"))\n else\n if @cur_start_y != START_Y then\n @cur_start_y = START_Y\n else\n @cur_start_y = START_Y + FONT_HEIGHT\n end\n end\n end\n \n @font.draw(l, START_X, cur_y, 9)\n cur_y += FONT_HEIGHT\n cur_y += FONT_HEIGHT if l == new_lines.last\n end\n else \n @font.draw(line, START_X, cur_y, 9)\n cur_y += FONT_HEIGHT * 2\n end\n end\n if @current then\n # draw CTC indicator\n img = @ctc[Gosu::milliseconds / 150 % @ctc.size];\n img.draw(720, 520, 10)\n end\n end", "def test_verticalScrollSpeed\n w = Window_Scrollable.new(0,192,640,96, 2)\n w.contents = Bitmap.update_bitmap_size(w.contents, w.contents.width, 192)\n c = CLabel.new(w.contents, Rect.new(0, 0, w.contents.width, 24), MULTILINE_TEXT)\n c.multiline = true\n c.draw()\n @windows.push(w)\n return true\n end", "def hamstrings_stretch\n \"Remaining seated, extend one leg outward. Reach toward your toes. Hold for 10 to 30 seconds. Repeat on the other side. Be sure to do this one leg at a time, as doing this exercise with both legs out can cause back issues.\"\nend", "def speed_up\n self.speed += 5\n info\n end", "def speed_up\n self.speed += 5\n info\n end", "def dispose_text_animation\n @animchars.each do |letter|\n letter.dispose\n end\n @animchars = []\n @anim_type = 7\n end", "def render_chat_tavolo(msg)\n @txtrender_tavolo_chat.text += msg\n # ugly autoscrolling... \n @txtrender_tavolo_chat.makePositionVisible(\n @txtrender_tavolo_chat.rowStart(@txtrender_tavolo_chat.getLength))\n \n \n end", "def scroll_to_exact(text)\n err = nil\n w_s = window_rect\n\n (1..30).each do |_count|\n action\n .move_to_location(w_s.width / 2, (w_s.height * 2) / 5) # pointer based magic number\n .pointer_down(:left)\n .move_to_location(0, w_s.height / 5)\n .release\n .perform\n sleep 1 # we must wait finish scrolling\n\n return text_exact(text)\n rescue StandardError => e\n err = e\n end\n\n raise err\n end", "def update_text_draw\n if @fade_out == false && !$game_temp.message_text.nil?\n @contents_showing = true\n $game_temp.message_window_showing = true\n @text_stack.dispose\n set_origin(0, 0)\n @fade_in = true\n self.visible = true\n init_window\n @name_window.contents_opacity = self.contents_opacity = 0\n @name_window.opacity = self.opacity = $game_temp.message_text.size == 0 ? 0 : 255\n refresh\n return true\n end\n return false\n end", "def display_guts_text(target)\n Sound.play_guts_text\n add_text(sprintf(target.personal_guts_text, target.name))\n wait\n end", "def dump_text(screen,refresh=false)\n\t\t# get only the rows of interest\n\t\ttext = @text[@linefeed,screen.rows-2]\n\t\t# store up lines\n\t\tscreen_buffer = []\n\t\tir = 0\n\t\ttext.each{ |line|\n\t\t\tir += 1\n\t\t\tsline = tabs2spaces(line)\n\t\t\tif @syntax_color\n\t\t\t\taline = syntax_color(sline)\n\t\t\telse\n\t\t\t\taline = sline\n\t\t\tend\n\t\t\tscreen_buffer.push(aline)\n\t\t}\n\t\t# vi-style blank lines\n\t\tir+=1\n\t\twhile ir < (screen.rows-1)\n\t\t\tscreen_buffer.push(\"~\"+\" \"*(screen.cols-1))\n\t\t\tir += 1\n\t\tend\n\n\t\t#write out the text\n\t\tir = 0\n\t\tif (@colfeed==@colfeed_old) && (@marked==false) \\\n\t\t&& (@marked_old==false) && (refresh==false)\n\t\t\tscreen_buffer.each { |line|\n\t\t\t\tir += 1\n\t\t\t\tif ($screen_buffer.length >= ir) && (line == $screen_buffer[ir-1])\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tscreen.write_line(ir,@colfeed,line)\n\t\t\t}\n\t\telse\n\t\t\tscreen_buffer.each { |line|\n\t\t\t\tir += 1\n\t\t\t\tscreen.write_line(ir,@colfeed,line)\n\t\t\t}\n\t\tend\n\t\t$screen_buffer = screen_buffer.dup\n\t\t@colfeed_old = @colfeed\n\t\t@marked_old = @marked\n\t\t# now go back and do marked text highlighting\n\t\tif @marked\n\t\t\tif @row == @mark_row\n\t\t\t\tif @col < @mark_col\n\t\t\t\t\tcol = @mark_col\n\t\t\t\t\tmark_col = @col\n\t\t\t\telse\n\t\t\t\t\tcol = @col\n\t\t\t\t\tmark_col = @mark_col\n\t\t\t\tend\n\t\t\t\tif @colmode == false\n\t\t\t\t\thighlight(@row,mark_col,col)\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tif @row < @mark_row\n\t\t\t\t\trow = @mark_row\n\t\t\t\t\tmark_row = @row\n\t\t\t\t\tcol = @mark_col\n\t\t\t\t\tmark_col = @col\n\t\t\t\telse\n\t\t\t\t\trow = @row\n\t\t\t\t\tmark_row = @mark_row\n\t\t\t\t\tcol = @col\n\t\t\t\t\tmark_col = @mark_col\n\t\t\t\tend\n\t\t\t\tif @colmode\n\t\t\t\t\tsc = bc2sc(@row,@col)\n\t\t\t\t\tfor r in mark_row..row\n\t\t\t\t\t\tc = sc2bc(r,sc)\n\t\t\t\t\t\thighlight(r,c,c)\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tsl = @text[mark_row].length\n\t\t\t\t\thighlight(mark_row,mark_col,sl)\n\t\t\t\t\tfor r in (mark_row+1)..(row-1)\n\t\t\t\t\t\tsl = @text[r].length\n\t\t\t\t\t\thighlight(r,0,sl)\n\t\t\t\t\tend\n\t\t\t\t\thighlight(row,0,col)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def lede(word_count = 25)\n doc = self.hpricot_body\n #wipe images\n doc.search(\"img\").remove\n paras = doc.search(\"//p\")\n text = \"\" \n while paras.size > 0 && text.split(\" \").size < word_count\n text += paras.shift.to_html\n end\n if (arr = text.split(\" \")).size > word_count\n return arr[0..word_count].join(\" \") + \" ...\"\n else \n return arr.join(\" \")\n end\n end", "def slow_puts(string, delay: 1, press_any_key: true) \n (0..string.size).each do |i| # Iterates over each index in a given string\n # Clear the screen to provide an animated effect.\n system \"clear\"\n\n # Puts all characters in the string up to the index being iterated over.\n puts string[0, i]\n sleep delay * 0.01\n end\n \n if press_any_key\n STDIN.getch\n end\nend", "def display_text\n\t\t\t#specifying font to be used\n\t\t\t#text_font @font, 16\n\t\t\t#text \"Mmmmm ... Strings .... \", 10, 100\n\t\tend", "def redisplay_delay\r\n 20\r\n end", "def loading_screen(string) \n string.length.times do |i| # Iterates over each index in a given string\n # Clear the screen to provide an animated effect.\n clear\n \n # Please wait header \n puts HEADER_LINE\n puts \"Please Wait...\".upcase.center(HEADER_LENGTH)\n puts HEADER_LINE\n puts\n \n # Displays all characters in the string up to the index being iterated over.\n puts string[0, i].center(HEADER_LENGTH)\n sleep(0.2)\n end\nend", "def try_again\n wave_display\n puts \"Here's the word again...\"\n\tputs $current_word.colorize(:color => :black, :background => :green) + \"\\r\"\n sleep($hide_speed)\n player_input_word\nend", "def display_splash_text\n splash = Artii::Base.new :font => 'slant'\n puts splash.asciify('Country Trivia').blue\n splash\n end", "def draw_text_cs(x, y, w, h, t, a = 0)\r\n original_color = self.font.color.clone\r\n self.font.color = Color.new(0,0,0,100)\r\n draw_text(x + 2, y + 2, w, h, t, a)\r\n self.font.color = original_color\r\n draw_text(x, y, w, h, t, a) \r\n end", "def truncate(text, url)\n return text if text.bytesize <= TEXT_BYTESIZE_MAX\n tail = \"...\\n<#{url}|Read more at Qiita:Team...>\"\n text.byteslice(0, TEXT_BYTESIZE_MAX - tail.bytesize).scrub(\"\") + tail\n end", "def slow_command\n EventMachine::Timer.new(3) { send_output \"This is the output.\" }\n end", "def display_text word\n raise \"word should be string\" unless word.is_a? String\n w = @form.by_name[\"tv\"]; \n lines = get_data word\n #file = `ri -f bs #{word}`\n #lines = convert_man_to_ansi file\n return if lines.nil? || lines.size == 0\n # ansi can have overflow\n w.add_content(lines, :content_type => :ansi, :title => word)\n\n # Since i am trying without border, so need to put class on top right\n header = @form.by_name[\"header\"]; \n header.text_right(word)\n\n $visited << word unless $visited.index(word)\n #w.add_content(lines, :title => word)\n w.buffer_last\nend", "def drum_roll(dramatic_text, beep)\n print \"\\a\" unless beep == false\n c = 0\n dramatic_text.length.times do\n print dramatic_text[c]\n c += 1\n sleep 0.05\nend\nend", "def improve(text)\n initial_quotes(entities(caps(smartypants(widont(amp(text))))))\n end", "def init_fps_text\n return if @ingame_fps_text && !@ingame_fps_text.disposed?\n @ingame_fps_text = Text.new(0, nil, 0, 0, w = Graphics.width - 2, 13, '', 2, 1)\n @gpu_fps_text = Text.new(0, nil, 0, 16, w, 13, '', 2, 1)\n @ruby_fps_text = Text.new(0, nil, 0, 32, w, 13, '', 2, 1)\n @ingame_fps_text.z = @gpu_fps_text.z = @ruby_fps_text.z = 200_000\n self.fps_visible = PARGV[:\"show-fps\"]\n end", "def print_logo()\n sleep(0.2)\n line = \"===================================================\\n\"\n text = [\" _____ _ _ _ ____ _ _ \", \"| __ \\\\ | | (_)| || _ \\\\ (_)| |\", \"| |__) || |__ _ | || |_) | _ __ __ _ ___ _ | |\", \"| ___/ | '_ \\\\ | || || _ < | '__|/ _` |/ __|| || |\", \"| | | | | || || || |_) || | | (_| |\\\\__ \\\\| || |\", \"|_| |_| |_||_||_||____/ |_| \\\\__,_||___/|_||_|\"]\n print line\n text.each do |t|\n sleep(0.2)\n puts t\n end\n sleep(0.2)\n print \"\\n\"\n sleep(0.2)\n print line\n sleep(0.2)\nend", "def pectoralis_stretch\n \"Clasp hands behind your back. Push the chest outward, and raise the chin. Hold the pose for 10 to 30 seconds.\"\nend", "def text_urgent(text); text_green(text);end", "def start_message\n @all_text_width = 0\n @pop = nil\n \n @text = \"\"\n @text_line = $game_message.texts.size < $game_message.max_line ? $game_message.texts.size + 1 : MAX_LINE + 1\n for i in 0...$game_message.texts.size\n # Change \" \" to \"\" (Spacing for choice)\n @text += \"\" if i >= $game_message.choice_start\n @text += $game_message.texts[i].clone + \"\\x00\"\n end\n \n @item_max = $game_message.choice_max\n convert_special_characters\n reset_window\n update_window_size\n new_page\n end", "def test_horizontalScrollSpeed\n w = Window_Scrollable.new(320,288,320,150, 2, true)\n w.contents = Bitmap.update_bitmap_size(w.contents, 640, w.contents.height)\n c = CLabel.new(w.contents, Rect.new(0, 0, w.contents.width, 24), MULTILINE_TEXT)\n c.multiline = true\n c.draw()\n @windows.push(w)\n return true\n end", "def scroll_up(n); puts \"\\e[#{n}S\" end", "def replace_instant_text(text)\n @lines.pop\n @lines.push(text)\n refresh\n end", "def cycle\n allOn(0.1)\n allOff(0.1)\n \n \"hello\".chars.each do |letter|\n writeLetter(letter.to_sym)\n sleep(0.5)\n allOff()\n sleep(0.25)\n end\n end", "def set_text(text, align = 0)\n # If at least one part of text and alignment differ from last time\n if text != @text or align != @align\n # Redraw text\n self.contents.clear\n self.contents.font.color = normal_color\n self.contents.draw_text(4, 0, self.width - 40, 32, text, align)\n @text = text\n @align = align\n @actor = nil\n end\n self.visible = true\n end", "def draw_remaining_characters\n contents.clear_rect(remaining_characters_rect)\n old_size = contents.font.size\n contents.font.size = 12\n draw_text(remaining_characters_rect, remaining_characters, 2)\n contents.font.size = old_size\n 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 text\n\tif @object_id != nil\n\t @text = @selenium.get_text(@object_id)\n\telse\n\t for wait in 1..20 do\n\t\tbegin\n\t\t @text = @selenium.get_text(@locator)\n\t\t break\n\t\trescue => e\n\t\t sleep(0.5)\n\t\tend\n\t end\n\tend\n\treturn @text\n end", "def filtered_text\r\n return @cat.cached_text if @cat.has_cached_text?\r\n @cat.clear\r\n create_text\r\n @iteration += 1\r\n return @cat.text\r\n end", "def pedal_faster\n\t\t@speed += 10\n\tend", "def texts=(texts); end", "def texts=(texts); end", "def driver\n paragraph = ParagraphTruncate.new\n puts \"This is going to be the sentence that I'll truncate.\".truncate(40, omission: \"... (continued)\")\n end", "def new_text(text, parent: nil)\n parent ||= @screen\n\n el = ShadedText.new(parent)\n el.set_long_mode(LVGL::LABEL_LONG::BREAK)\n el.set_align(LVGL::LABEL_ALIGN::CENTER)\n el.set_width((parent.get_width - 2*padding).to_i)\n el.set_text(text)\n el\n end", "def create_sample_text\n Text.new(0, viewport, 0, 0, 0, 0, ' ')\n end", "def process_name(c, pos)\n c = WiggleText::NAMES[c]\n text_width = text_size(c).width\n if defined? Graphics.fullscreen #MKXP fix\n text_width += text_width * 0.6\n text_width = text_width.round\n end\n letter = Sprite_TextAnim.new(self.viewport)\n bitmap = Bitmap.new(text_width, 12)\n letter.bitmap = bitmap\n letter.x = 23\n letter.y = self.y - 10\n letter.z = self.z + 10\n letter.anim_offset = @animchars.size\n letter.anim_type = 7 #@anim_type\n tuckie_extra(letter)\n letter.update\n bitmap.draw_text(0, 0, 10, 12, c)\n @animchars.push(letter)\n end", "def printRandomFont(duration)\n st = \"A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9\"\n x = st.split(\",\")\n currentTime = Time.now.to_i\n futureTime = currentTime + duration\n while (currentTime <= futureTime)do\n print \"#{isMe(onMe(\"\\n#{returnFont(x[$prng.rand(0...x.length())])}\\n\\n\"))}\"\n currentTime = Time.now.to_i\n end\n menu()\nend", "def print_text_statistics (text)\n\n=begin\n\t\ttext = ''\n\t\tline_count = 0\n\t\tFile.open(\"text.txt\").each do |line|\n\n\t\t\tline_count += 1\n\t\t\ttext << line\n\t\tend #Here I'm using the File class's .open(dir) to open up a file\n\t\t #that is located at an specific directory and then I'm looping\n\t\t #trough its content with a .each{} method.\n\t\t#puts \"#{line_count} lines\"\n=end\n\n\t#the File class has a method that allows you to read the lines on a text file more efficiently\n\t#it has the .readlines(dir); this method returns an array with the readed file\n\tstop_words = %w{the a by on for of are just with but and to the my I has some in}\n\tline = File.readlines(text[0]) #receives the parameter passed on the command line and holds it into the first \n\t #position of the ARGV array. This is an special array\n\tline_count = line.size\n\ttext = line.join\n\ttotal_characters = text.length\n\ttotal_characters_nospace = text.gsub(/\\s+/,'').length\n\tword_count = text.split.length\n\tparagraph_count = text.split(/\\n\\n/).length\n\tsentence_count = text.split(/\\?|\\.|!/).length\n\tall_words = text.scan(/\\w+/)\n\tgood_words = all_words.select {|word| !stop_words.include?(word)} #the .select method can be applied to arrays,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t #hases and ranges and is used to return an object of those types\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t #that stiesfied the conditional statement written whithin the blockb (it's a filter)\n\tgood_percentage = ((good_words.length.to_f/all_words.length.to_f)*100).to_i\n\tsentences = text.gsub(/\\s+/,' ').strip.split(/\\?|\\.|!/) #strip deletes the first and the last blank strip of spaces\n\tsentences_sorted = sentences.sort_by { |sentence| sentence.length } #sort an array, hash or range, by defining \n\t #a condition whithin the block. array.sort_by { |item| <condition> }\n\tone_third = sentences_sorted.length/3\n\tideal_sentences = sentences_sorted.slice(one_third, one_third + 1).select { |sentence| sentence =~ /is|are/}\n\n\tputs \"#{line_count} lines\"\n\tputs \"#{total_characters} characters\"\n\tputs \"#{total_characters_nospace} characters (excluding spaces)\"\n\tputs \"#{word_count} words\"\n\tputs \"#{paragraph_count} paragraphs\"\n\tputs \"#{sentence_count} sentences\"\n\tputs \"#{(sentence_count/paragraph_count).to_f} sentences per paragraph (average)\"\n\tputs \"#{(word_count/paragraph_count).to_f} words per paragraph (average)\"\n\tputs \"#{good_percentage}% of words are non fluff-words\"\n\tputs \"Summary:\\n\\n#{ideal_sentences.join('.')}\"\n\tputs \"-- End of analysis\"\n\nend", "def update_text_draw\n unless $game_temp.message_text.nil?\n @contents_showing = true\n $game_temp.message_window_showing = true\n @text_stack.dispose\n set_origin(0, 0)\n self.visible = true\n init_window\n refresh\n return true\n end\n return false\n end", "def textilize(text) \n text = swear_generator(text)\n RedCloth.new(text).to_html.html_safe unless text.blank? \n end", "def text(text)\n (0..text.length).each do |x|\n \n end\nend", "def refresh\n self.contents.clear\n if @messages[@messages_index] != nil\n # Use lines configuration\n if Wep::Lines_to_show == 1\n self.contents.draw_text(0, 0, 640, 32, @messages[@messages_index])\n else\n for i in 0...Wep::Lines_to_show\n # It adds the line count to message index to show more lines\n if @messages[@messages_index + i] != nil\n self.contents.draw_text(0, i * 32, 640, 32, @messages[@messages_index + i])\n end\n end\n end\n @messages_index += Wep::Lines_to_show\n end\n # When false, it will end battle\n if @messages_index >= @messages.size - 1\n return false\n else\n return true\n end\n end", "def draw_text_ex(x, y, text, reset = true)\n reset_font_settings if reset\n text = convert_escape_characters(text)\n pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}\n process_character(text.slice!(0, 1), text, pos) until text.empty?\n end", "def close_text\n puts 'Cerrando programa'\n print '.'\n sleep(0.3)\n print '.'\n sleep(0.3)\n print '.'\n print \"\\n\"\nend", "def calculate(text)\n return 1 if text.blank?\n stripped_text = strip_tags(text).mb_chars.gsub('&#13;', '').gsub(/[^a-zA-ZA-Яа-я0-9]/, '')\n symbols_count = stripped_text.length\n [(symbols_count / READING_SPEED).ceil, 1].max\n end", "def slowercase(a_string)\n #sleep 0.5\n a_string.downcase\nend", "def osd_show_text _string, _duration=0, _level=0\n send_cmd(\"osd_show_text #{_string} #{_duration} #{_level}\")\n end", "def text text\n end", "def display_homunculus_sacrifice(target, item)\n if target.result.homunculus_item_used\n id = target.homunculus_item_id\n text = sprintf(Bubs::HomunculusItem::HOMUNCULUS_TEXT, $data_items[id].name)\n add_text(text)\n Sound.play_homunculus_item_break\n Bubs::HomunculusItem::HOMUNCULUS_TEXT_WAIT.times do; wait; end\n wait_for_effect\n back_one\n end\n end", "def draw\n return if @destoryed\n return unless @verbose\n unless DEBUG_PRINT_WAIT.nil?\n @string = get_debug_string\n end\n @hud_font.draw_text(@string, $program.width - 200, $program.height - 300, 100, 1, 1, 0xff_000000, :default)\n end", "def loading_screen(string) \n string.length.times do |i|\n clear\n \n # Please wait header \n puts HEADER_LINE\n puts \"Please Wait...\".upcase.center(HEADER_LENGTH)\n puts HEADER_LINE\n puts\n puts string[0, i].center(HEADER_LENGTH)\n sleep(0.2)\n end\nend", "def texts; end", "def wookiee_sentence; end", "def retornar_text_prazo\n text_prazo.greenify\n text_prazo.text\n end", "def text= text\n @text = text\n @w,@h = @font.size_text text\n @surface = @font.render_blended text, @color\n render\n @text\n end", "def text=(text); end", "def scroll_speed() 6 end", "def slowercase(a_string)\n #sleep 2\n a_string.downcase\nend", "def draw_text_full(x2, y2, w2 = 0, h2 = 0, text2 = '', a2 = 0)\n # set coordinates whether x2 is rectangle\n if x2.is_a?(Rect)\n x, y, w, h, text, a = x2.x, x2.y, x2.width, x2.height, y2, w2\n else\n x, y, w, h, text, a = x2, y2, w2, h2, text2, a2\n end\n # store font color\n save_color = self.font.color.clone\n # set font color to black\n self.font.color = Color.new(0, 0, 0)\n # draw outline\n draw_text_shaded_later(x+1, y+1, w, h, text, a)\n draw_text_shaded_later(x-1, y+1, w, h, text, a)\n draw_text_shaded_later(x-1, y-1, w, h, text, a)\n draw_text_shaded_later(x+1, y-1, w, h, text, a)\n # restore font color\n self.font.color = save_color\n # draw normal text\n draw_text_shaded_later(x, y, w, h, text, a)\n end", "def draw_text_full(x2, y2, w2 = 0, h2 = 0, text2 = '', a2 = 0)\n # set coordinates whether x2 is rectangle\n if x2.is_a?(Rect)\n x, y, w, h, text, a = x2.x, x2.y, x2.width, x2.height, y2, w2\n else\n x, y, w, h, text, a = x2, y2, w2, h2, text2, a2\n end\n # store font color\n save_color = self.font.color.clone\n # set font color to black\n self.font.color = Color.new(0, 0, 0)\n # draw outline\n draw_text_shaded_later(x+1, y+1, w, h, text, a)\n draw_text_shaded_later(x-1, y+1, w, h, text, a)\n draw_text_shaded_later(x-1, y-1, w, h, text, a)\n draw_text_shaded_later(x+1, y-1, w, h, text, a)\n # restore font color\n self.font.color = save_color\n # draw normal text\n draw_text_shaded_later(x, y, w, h, text, a)\n end", "def generate_teaser(text, length=180)\n return '' if text.blank?\n teaser = ''\n\n stripped_body = ActionController::Base.helpers.strip_tags(text)\n .gsub(\"&nbsp;\",\" \").gsub(/\\r/,'').strip\n\n stripped_body.match(/^.+/) do |match|\n first_paragraph = match[0]\n\n if first_paragraph.length <= length\n teaser = first_paragraph\n else\n shortened_paragraph = first_paragraph.match(/\\A.{#{length}}[^\\.]*\\.?/)\n\n teaser = if shortened_paragraph\n \"#{shortened_paragraph[0]}\"\n else\n first_paragraph\n end\n end\n end\n\n teaser\n end" ]
[ "0.65833825", "0.6523232", "0.64904755", "0.64749813", "0.6376131", "0.6254747", "0.62546295", "0.6189177", "0.61624795", "0.60285467", "0.60163164", "0.59184855", "0.5898979", "0.5821023", "0.5798578", "0.57925904", "0.5767543", "0.5766939", "0.57489055", "0.5728405", "0.57269907", "0.5716128", "0.57070005", "0.5697165", "0.5691318", "0.567829", "0.5649562", "0.5649443", "0.56292856", "0.56223935", "0.5612886", "0.5593124", "0.5569941", "0.5569458", "0.5569458", "0.5562179", "0.5546346", "0.554448", "0.5540029", "0.5537696", "0.55102277", "0.5501113", "0.54822564", "0.5475752", "0.5464187", "0.5460022", "0.5459145", "0.54580504", "0.5455563", "0.54503405", "0.54489034", "0.5440146", "0.5424037", "0.5391658", "0.53755414", "0.537547", "0.537541", "0.53521276", "0.534385", "0.5329646", "0.5321742", "0.5321482", "0.5317946", "0.53062767", "0.53003687", "0.5298174", "0.5294484", "0.5289821", "0.5288494", "0.5284728", "0.5284728", "0.5284065", "0.52838296", "0.5259116", "0.52573967", "0.5257138", "0.5254615", "0.52440464", "0.524378", "0.52404577", "0.5239175", "0.5238133", "0.5234098", "0.5230205", "0.5223125", "0.52184534", "0.52106416", "0.5209165", "0.5208131", "0.52073175", "0.5201333", "0.51988703", "0.51982784", "0.5197538", "0.5194841", "0.51837164", "0.51788014", "0.517202", "0.517202", "0.5162515" ]
0.70689255
0
If user selects an invalid option it takes them back to main menu.
def invalid_return_mm puts "Invalid option : No match found. Returning to the main menu.".center(80) main_menu end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_wrong_option\n print \"Option not available. \".red\n determine_action(get_entry(\"Select option: \"))\n end", "def invalid_option\n\t\t\t\talert_menu \"Invalid option!\"\n\t\t\tend", "def main_menu\n\tputs \"Welcome to Roy Bank!\"\n\tputs\"Please make a selection:\"\n\tputs \"____________________________\"\n\tputs \"1. Create a new account\"\n\tputs \"2. View Account Information\"\n\tputs \"3. Exit Program\"\n\nprint \"Option: \"\n\noption = gets.chomp.to_i\n\nif option == 1\n\tcreate_account\n\tmain_menu\n\telsif option == 2\n\t\t# some code here\n\t\t#user_login\n\t\taccount_menu\n\telsif option == 3\n\t\tputs \"Thank you for stopping by!\"\n\telse \n\t\tputs \"Invalid entry! Please choose from the available options!\"\n\n\t\tmain_menu\n\n\tend\n\t\t\t\n\t\t\n\n\n\n\nend", "def main_menu\n\tputs \"Welcome to Creighton Bank!\"\n\tputs \"Please make choose an option:\"\n\tputs \"------------------------------\"\n\tputs \"1. Create a new account\"\n\tputs \"2. View Account Information\"\n\tputs \"3. Exit Program\"\n\n\tprint \"Option: \"\n\n\toption = gets.chomp.to_i\n\n\tif option == 1\n\t\t\tcreate_account\n\t\t\tmain_menu\n\telsif option == 2\n\t\t\taccount_menu\n\telsif option == 3\n\t\t\tputs \"Thank you for stopping by!\"\n\telse\n\t\tputs \"Invalid entry! Please choose from the available options!\"\n\t\tmain_menu\n\n\tend\t\nend", "def pick_option\n input = get_input\n if input == '1'\n events_array = search_by_city\n display_events_by_city(events_array)\n save_event_or_main_menu(events_array)\n elsif input == '2'\n attractions_array = search_by_keyword\n display_by_keyword(attractions_array)\n save_event_or_main_menu(attractions_array)\n elsif input == '3'\n display_user_events\n elsif input == '4'\n delete_account\n elsif input == '5'\n space(1)\n puts \"#{$logged_in.username}, thanks for checking us out. See ya later!\"\n exit\n else\n space(1)\n invalid_input\n pick_option\n end\nend", "def main_menu\n puts \"\"\n puts \"-----------------------------------------------\"\n puts \"\"\n puts \"Please select an option:\"\n puts \"\"\n puts \"Enter 'list' for a list characters, 'quote' for a random Stan Lee quote, or 'exit' to bid farewell.\"\n puts \"\"\n input = user_input\n\n if input == 'list'\n list_characters\n elsif input == 'quote'\n stan_lee_quote\n elsif input == 'exit'\n goodbye\n elsif input != 'list' || input != 'exit' # had to add \"input !=\" each time to avoid the string literal warning\n invalid_input\n main_menu\n end\n \n end", "def user_selection\n menu\n choice = gets.to_i\n case choice\n when 1\n add_items\n when 2\n view_cart\n when 3\n remove_items\n when 4\n check_out\n when 5\n puts \"Thank you, come again!\"\n exit\n else\n puts \"Invalid Choice Try Again\"\n sleep(2)\n end\nend", "def main_menu\n @ui.input_1_change\n @ui.user_input1.downcase\n unless %w[trains routes stations cars].include? @ui.user_input1\n puts 'There is no such option in the main menu.'\n end\n main_menu_choose_option(@ui.user_input1)\n end", "def user_selection\n menu\n choice = gets.to_i\n case choice\n when 1\n create_contact\n when 2\n view_contacts\n when 3\n delete_contact\n when 4\n edit_contact\n when 5\n puts \"Adios Amigo!\"\n exit\n else\n puts \"Invalid Choice Try Again\"\n end\nend", "def main_menu\n\tputs \"\\n1 Library\\n2 Staff Members\\n3 Books\\n4 Patrons\\n0 Exit\\n\"\n\tselect = make_selection\n\n\twhile select != \"1\" && select != \"2\" && select != \"3\" && select != \"4\" && select != \"0\"\n\t\tputs \"\\nInvalid choice selected\\n\"\t\t \t\t\n\t\tselect = make_selection\n\tend\n\n\tif select == \"1\"\n\t\tlibrary_choice = \"9\"\n\t\twhile library_choice != \"0\"\n\t\t\tlibrary_choice = select_choice_library\n\t\tend\n\n \telsif select == \"2\"\n\t\tstaff_member_choice = \"9\"\n\t\twhile staff_member_choice != \"0\"\n\t\t\tstaff_member_choice = select_choice_staff_member\n\t\tend\n\n\n\telsif select == \"3\"\n\t\tbook_choice = \"9\"\n\t\twhile book_choice != \"0\"\n\t\t\tbook_choice = select_choice_book\n\t\tend\n\n\n\telsif select == \"4\"\n\t\tpatron_choice = \"9\"\n\t\twhile patron_choice != \"0\"\n\t\t\tpatron_choice = select_choice_patron\n\t\tend\n\n\n\telsif select == \"0\"\n\t\tputs \"\\nGoodbye\"\t\t \t\t\n\tend\n\tselect \nend", "def main_menu\n\tputs \"Welcome, what would you like to do today?\"\n\tputs \"1) Add Items to Cart\"\n\tputs \"2) View Items in Cart\"\n\tputs \"3) Remove Items from Cart\"\n\tputs \"4) View Total\"\n\tputs \"5) Exit\"\n\tuser_input = gets.strip.to_i\n\n\n\tcase user_input\n\twhen 1\n\t\tadd_items\n\twhen 2\n\t\tview_items\n\twhen 3\n\t\tremove_item\n\twhen 4\n\t\tshow_total\n\twhen 5\n\t\tputs \"Thank you for shopping with DPL Grocery!\"\n\t\texit!\n\telse\n\t\tputs \"Wrong option bruuuh, try again!\"\n\t\t# puts \"Please choose from the options above, try again.\"\n\tmain_menu\n\tend\nend", "def choice_check\n begin\n choice = gets.chop.upcase\n if choice != \"GET\" && choice != \"POST\" && choice != \"EXIT\"\n raise \"Wrong input!\"\n end\n rescue StandardError => e\n puts \"#{e} You can choose between GET, POST and EXIT\"\n retry\n else\n choice\n end \n end", "def user_menu \n system(\"clear\")\n puts \"=================\"\n puts \"Welcome to Lunch\"\n puts \"Would you like to make an order? Y or N?\"\n order_choice = gets.strip \n if order_choice == \"Y\" || order_choice == \"y\"\n main_dishes \n elsif order_choice == \"N\" || order_choice == \"n\"\n puts \"Come back soon!\"\n exit \n else \n puts \"Invalid Choice.\"\n user_menu \n end \nend", "def manage_account_menu\n choice = @prompt.select(\"Please choose from the following options:\") do |menu|\n menu.choice 'Change my name'\n menu.choice 'Change my password'\n menu.choice 'Delete my account'.blue\n menu.choice \"Back to Main Menu\"\n end\n\n if choice == \"Change my name\"\n change_name\n elsif choice == \"Change my password\"\n change_password\n elsif choice == \"Delete my account\".blue\n delete_account\n elsif choice == \"Back to Main Menu\"\n start_menu\n end\nend", "def main_menu\n options = [\"View recipe book\", \"Search by ingredient\", \"Quit app\"]\n answer = @prompt.select(\"Choose an option:\".colorize(:color => :blue), (options))\n if answer == options[0]\n select_recipe_from_book(@user.view_recipe_book)\n elsif answer == options[1]\n find_recipe\n elsif answer == options[2]\n puts ''\n puts \"Thanks for using Feed. See you next time!\".colorize(:color => :blue)\n system exit\n end\nend", "def validate_user_choice\n input = gets.chomp\n if input ==\"exit\"\n exit_screen\n elsif input == \"buy\"\n ticketing_screen\n elsif input.to_i == 1\n concert_screen\n elsif input.to_i == 2\n # if user doesn't want to buy a ticket yet, they can look for other upcoming bands and/or concerts by typing bands.\n bands_screen\n else\n unrecognized_input\n end\n end", "def login_menu\n\t\tlogin_display\n option = gets.chomp.downcase\n if option == \"1\" || option == \"1.\" || option == \"new user\"\n get_user_info\n elsif option == \"2\" || option == \"2.\" || option == \"returning user\"\n login\n elsif option == \"3\" || option == \"3.\" || option == \"exit\"\n goodbye\n else\n\t\t\tputs \"Check your input and make sure you are selecting a number. \"\n\t\t\tsleep(2)\n login_menu\n end\n end", "def select_item #this gets the user input when a specific item in the list needs to be selected\n valid_option = false\n while valid_option == false\n item_num = Integer(gets) rescue false\n if item_num == false\n\t puts \"Please enter a valid option.\"\n \telsif item_num > 0 and $to_do_list[item_num - 1] != nil\n valid_option = true\n\telse\n\t puts \"Please enter a valid option.\"\n\tend\n end\n return item_num - 1\nend", "def handle_menu(menu_item, apartments,tenants)\n case menu_item\n when 1\n view_all_apts(apartments)\n puts(\"Press [ENTER] to continue\")\n gets\n return false\n when 2\n view_all_tenants(tenants)\n puts(\"Press [ENTER] to continue\")\n gets\n return false\n when 99\n return true\n else\n puts(\"Please type a Valid Menu Item\")\n puts(\"Press [ENTER] to continue\")\n gets\n return false\n end #case\nend", "def menu\n\tputs \"Please select your calculator.\"\n\tputs \"1. Basic calculator\"\n\tputs \"2. Advanced calculator\"\n puts \"3. BMI calculator\"\n puts \"4. Mortgage calculator\"\n puts \"Q. Quit\"\n\t\n\tchoice = gets.chomp.to_i\n\t\n\tcase choice\n when 0\n quit\n when 1\n\t\tbasic_calculator\n\twhen 2\n\t\tadvanced_calculator\n when 3\n bmi_calc\n when 4\n mortgage_calc\n when 5\n puts \"Please make a valid selection\"\n choice = gets.chomp.to_i\n\n end\nend", "def main_menu_choose_option(user_input)\n case user_input\n when 'trains'\n manage_trains\n when 'routes'\n manage_routes\n when 'stations'\n manage_stations\n when 'cars'\n manage_cars\n else\n @ui.wrong_input_msg\n end\n end", "def main_menu\n \twhile true\n \t\tprint_main_menu\n\n \t\tprint \"Choose an option:\"\n \t\tuser_input = gets.chomp.to_i\n\n \t\tbreak if user_input == 7\n \t\t\n choose_option(user_input)\n \tend\n end", "def invalid_page\n redirect_to(:back)\n end", "def call_option(user_selected) \n\t case user_selected\n\t when 1 then add_new_contact\t\t\n\t when 2 then modify_existing_contact\n\t when 3 then display_one_contact\n\t when 4 then delete_contact\n\t when 5 then display_all_contacts\n\t when 6 then display_by_attribute\n\t when 7\n\t\t\tputs \"Current session ended, goodbye!\"\n\t\t\treturn\n\t\telse\n\t\t\tputs \"Invalid Option, try again.\"\n\t\t\treturn\n\t\tend\t\n\tend", "def user_menu_input\n menu\n user_menu_selection = gets.strip.to_i\n if valid_menu_selection?(user_menu_selection)\n user_menu_selection\n else\n puts \"\\nInvalid input \\u{1f4a9} !\\n \".colorize(:red).bold\n user_menu_input\n end\n end", "def run_menu(menu)\n display_menu(menu)\n user_choice = get_user_input(menu.user_pick_one_prompt)\n while !menu.user_input_valid?(user_choice)\n user_choice = get_user_input(menu.user_wrong_choice_prompt)\n end\n if menu.user_wants_to_quit?(user_choice)\n exit 0\n else\n menu.find_menu_item_chosen(user_choice).do_if_chosen\n end\n end", "def main_menu(user=\"guest\")\n game = nil\n router = nil\n message = []\n # base options\n options = [\n [\"Continue as a Guest\", 8],\n [\"Log In\", 3],\n [\"Create Account\", 5],\n [\"Select a Game\", 8],\n [\"My Reviewed Games\", 13],\n [\"Log Out\", 4],\n [\"My Account\", 6],\n [\"Exit\", 1]\n ]\n # removing options based on status\n if user == \"guest\"\n options.delete_at(6)\n options.delete_at(5)\n options.delete_at(4)\n options.delete_at(3)\n elsif Review.where(user_id: user.id).count == 0\n options.delete_at(4)\n options.delete_at(2)\n options.delete_at(1)\n options.delete_at(0)\n else\n options.delete_at(2)\n options.delete_at(1)\n options.delete_at(0)\n end\n # display loop until validated choice\n until router\n display_menu_header([\"Main Menu:\"], user)\n router = display_options_menu(options, message)\n message = [\"Sorry, invalid selection. Please choose again...\"]\n end\n menu_routing(user, \"\", router)\nend", "def main_menu\n puts \"===============\"\n puts \"Make a selection\"\n puts \"===============\"\n puts \"1: Command line\"\n puts \"2: Atom\"\n puts \"3: Search?\"\n puts \"4: Quit\"\n puts \"===============\"\n\n case gets.strip\n when \"1\"\n command_line_menu\n when \"2\"\n atom_menu\n when \"3\"\n search_function\n reset\n when \"4\"\n exit 0\n else\n bad_choice\n main_menu\n end\nend", "def get_action\n begin\n num = Integer(gets.strip)\n rescue ArgumentError\n puts(\"Please enter a valid option\")\n print(@prompt_string)\n return get_action\n end\n if num > @options.length\n puts(\"Please enter a valid option\")\n print(@prompt_string)\n return get_action\n end\n return @options[num-1]\n end", "def main_menu\n\t\twhile true\n\t\t\tprint_main_menu\n\t\t\tuser_selected = gets.chomp.to_i\n\t\t\t\tif user_selected == 7\n\t\t\t\tputs \"Current session ended, goodbye!\"\n\t\t\t\treturn\n\t\t\tend\n\t\t\tcall_option(user_selected)\n\t\tend\n\tend", "def main_menu\n menu_options = [\"Start exploring\", \"Check Inventory\", \"Check Your Score\", \"Go to Pokemon Center\", \"Quit\"]\n menu_prompt = Interactivity.mainMenu \n \n if user.pokemon == nil\n menu_options.shift()\n menu_options.unshift(\"Choose a Pokemon and start exploring\")\n elsif self.user_current_location\n menu_options.shift()\n menu_options.unshift(\"Keep Exploring\")\n end\n \n choice = prompt.select(menu_prompt, menu_options) \n if choice == \"Start exploring\" || choice == \"Choose a Pokemon and start exploring\" || choice == \"Keep Exploring\"\n self.trainer_chooses_pokemon if user.pokemon == nil \n self.trainer_chooses_town\n self.exploring_town\n elsif choice == \"Check Inventory\"\n puts \"MANAGE INVENTORY - CHANGE POKEMONS AROUND\"\n elsif choice == \"Go to Pokemon Center\"\n self.pokemon_center\n elsif choice == \"Check Your Score\"\n puts \"CHECK YOUR SCORE\"\n else\n Interactivity.quit\n end\n end", "def menu\n\tputs \"Welcome to My Tournament Generator. Enter a selection:\"\n\tputs \"1. Enter teams\"\n\tputs \"2. List teams\"\n\tputs \"3. List matchups\"\n\tputs \"0. Exit program\"\n\n\tchoice = gets.chomp.to_i\n\n\t# use case or if/elsif\n\tcase choice\n\t\twhen 1\n\t\t\tclear_screen # see very next method defined!\n\t\t\tenter_teams\n\t\twhen 2\n\t\t\tclear_screen\n\t\t\tlist_teams\n\t\twhen 3\n\t\t\tclear_screen\n\t\t\tmatchups\n\t\twhen 0\n\t\t\tclear_screen\n\t\t\tputs \"Okay, catch ya later.\"\n\t\telse\n\t\t\tclear_screen\n\t\t\t# return to the top of this method\n\t\t\t# if given a number not listed in menu\n\t\t\tputs \"Not a valid selection. Try again, please.\"\n\t\t\tmenu\n\tend\nend", "def rules_option(back_option)\n\t\tif back_option == 1\n\t\t\tworld = World.new\n\t\t\tworld.menu\n\t\telsif back_option == 2\n\t\t\treturn puts \"À bientot !\"\n\t\telse\n\t\t\tputs \"Oops ! Choisissez entre l'option 1 ou 2 !\"\n\t\t\tback_option = gets.chomp.to_i\n\t\t\trules_option(back_option)\n\t\tend\n\tend", "def options(name_input)\r\n puts \"Hi, #{name_input}! What would you like to do? \\n Press 1 for Appliance List \\n Press 2 to Add New Appliance \\n Press 3 for Warranty Status Report \\n Press 4 to exit\".colorize(:green)\r\n option_input = gets.chomp.strip.to_i\r\n #error prevention check if user input is not valid, they will be requested to re-enter their option choice. \r\n while option_input != 1 && option_input != 2 && option_input != 3 && option_input != 4\r\n puts \"Error. Invalid option. Please try again.\".colorize(:red)\r\n puts \"What would you like to do? \\n Press 1 for Appliance List \\n Press 2 to Add New Appliance \\n Press 3 for Warranty Status Report \\n Press 4 to exit\".colorize(:green)\r\n option_input = gets.chomp.strip.to_i\r\n 100.times {print \"-\"}\r\n puts()\r\n end\r\n #While loop is used here to allow continuous interaction with the app until user chooses to exit (4). \r\n counter = 0\r\n while counter == 0\r\n if option_input == 1\r\n 100.times {print \"=\"}\r\n puts()\r\n show_list_of_appliances(name_input)\r\n puts \"What would you like to do? \\n Press 1 for Appliance List \\n Press 2 to Add New Appliance \\n Press 3 for Warranty Status Report \\n Press 4 to exit\".colorize(:green)\r\n option_input = gets().chomp.strip.to_i\r\n 100.times {print \"-\"}\r\n puts()\r\n elsif option_input == 2\r\n puts \"What is your appliance name?\".colorize(:blue)\r\n appliance_type_input = gets().chomp.strip\r\n puts \"Which part of the house is it located in?\".colorize(:blue)\r\n location_input = gets().chomp.strip\r\n puts \"When did you purchase this appliance? Enter a valid date.\".colorize(:blue)\r\n purchase_date_input = nil\r\n #Error prevention check. If date input by user is invalid, they will be prompted to re-enter their date until it is acccepted by Date.parse.\r\n while purchase_date_input == nil\r\n begin\r\n purchase_date_input = Date.parse(gets().strip.chomp)\r\n rescue \r\n puts \"Wrong Date Format. Please try again.\".colorize(:red)\r\n puts \"When did you purchase this appliance?\".colorize(:blue)\r\n end \r\n end \r\n puts \"How long is your appliance's warranty? (in years)\".colorize(:blue)\r\n warranty_length_input = gets.chomp.strip.to_i\r\n puts \"What is your appliance's Warranty Serial Number?\".colorize(:blue)\r\n serial_number_input = gets().chomp.strip\r\n #New device information is initialised under Appliance class and is appended to the CSV device list file of that user.\r\n Appliances.new(appliance_type_input,location_input,purchase_date_input,warranty_length_input,serial_number_input).add_new_appliance(name_input)\r\n puts \"New Appliance Added.\".colorize(:green).bold\r\n puts \"#{appliance_type_input} situated in your #{location_input} was purchased on #{purchase_date_input} with warranty number #{serial_number_input} that lasts for #{warranty_length_input} years.\".colorize(:yellow)\r\n 100.times {print \"=\"}\r\n puts \"\\nWould you like to add another appliance \\nPress 2 for yes.\\nPress 1 to go back and view appliance list.\\nPress 3 for Warranty Status Report.\\nPress 4 to exit.\".colorize(:green)\r\n option_input = gets().chomp.strip.to_i\r\n elsif option_input == 3\r\n puts \"Which product would you like to check?\".colorize(:blue)\r\n product_check_input = gets().chomp\r\n product_details = calc_warranty_of_appliances(product_check_input, name_input)\r\n #If the product is not found in the user's CSV file, user is required to retype their selection until it matches one of the appliances in the CSV file list. \r\n while product_details == []\r\n puts \"Which product would you like to check?\".colorize(:blue)\r\n product_check_input = gets().chomp.strip\r\n product_details = calc_warranty_of_appliances(product_check_input, name_input)\r\n end\r\n #calling the date_of_purchase from the array and changed to Date.parse format, stored in variable called purchase_date_calc\r\n #This is the calculaton formula to calculate when the warranty ends and store it in variable warranty_end_date.\r\n purchase_date_calc = Date.parse(product_details[2])\r\n warranty_length_calc = product_details[3].to_i * 365\r\n warranty_end_date = purchase_date_calc + warranty_length_calc\r\n today_date = Date.today\r\n #This is the calculaton formula to calculate how many days are left until the warranty expiry date and store it in variable called warranty_days_left. \r\n warranty_days_left = (warranty_end_date - today_date).to_i\r\n puts \"Warranty days left = #{warranty_days_left}\".colorize(:light_blue)\r\n 100.times {print \"-\"}\r\n puts()\r\n puts \"What would you like to do? \\n Press 1 for Appliance List \\n Press 2 to Add New Appliance \\n Press 3 for Warranty Status Report \\n Press 4 to exit\".colorize(:green)\r\n option_input = gets().chomp.strip.to_i\r\n #This is option(4), which is to allow user to exit the app.\r\n elsif option_input == 4\r\n puts \"Thank you for using our app!\".colorize(:magenta)\r\n counter += 1\r\n #Error prevention check. When user inputs an invalid option other than option 1, 2, 3 or 4, user will be prompted to re-type their option.\r\n else\r\n puts \"Error. Please enter a valid option.\".colorize(:red)\r\n puts \"What would you like to do? \\n Press 1 for Appliance List \\n Press 2 to Add New Appliance \\n Press 3 for Warranty Status Report \\n Press 4 to exit\".colorize(:green)\r\n option_input = gets().chomp.strip.to_i\r\n 100.times {print \"-\"}\r\n puts()\r\n \r\n end\r\n end\r\nend", "def check_main_menu_choice(given_choice)\n if given_choice == \"First Time User, Want To Register\"\n choice = 1\n end\n if given_choice == \"Already A Registered User, Want To Login\"\n choice = 2\n end\n if given_choice == \"Do Not Wish To Register, Just Browsing\"\n choice = 3\n end\n if given_choice == \"Looking For Info About The App\"\n choice = 4\n end\n if given_choice == \"Nothing Really, Spare Me Your @?%#&?|%!\"\n choice = 5\n end\n choice\nend", "def menu\n input = gets.strip.downcase\n \n if input == \"hungry\"\n cuisine_list\n menu # return 'menu' don't want my user to get kicked out of application \n elsif input == \"goodbye\"\n goodbye\n else \n invalid_entry\n end \n end", "def user_menu\n puts \"1-input data from file\"\n puts \"2-edit data\"\n puts \"3-form groups\"\n puts \"4-list groups\"\n puts \"5-write groups to file\"\n puts \"6-view course information\"\n puts \"0-exit the program\" \n user_selection = gets.chomp\n # case statement calls respective methods based on user's selection.\n # gives error if file is not loaded and returns to menu\n case user_selection\n when \"0\"\n abort\n when \"1\"\n input_data\n when \"2\"\n if @file_loaded\n edit_data\n else\n puts @dash+\"error-file-not-loaded\"+@dash\n user_menu\n end \n when \"3\"\n if @file_loaded\n form_groups\n else\n puts @dash+\"error-file-not-loaded\"+@dash\n user_menu\n end \n when \"4\"\n if @file_loaded\n list_groups\n else\n puts @dash+\"error-file-not-loaded\"+@dash\n user_menu\n end \n when \"5\"\n if @file_loaded\n write_groups\n else\n puts @dash+\"error-file-not-loaded\"+@dash\n user_menu\n end \n when \"6\"\n if @file_loaded\n list_course_info\n else\n puts @dash+\"error-file-not-loaded\"+@dash\n user_menu\n end \n else\n puts @dash+\"error-invalid-selection\"+@dash\n user_menu\n end\n end", "def ask_menu_option\n puts 'What would you like to do?'\n puts ''\n puts '1. Start New Game'\n puts '2. Load Game From Save File'\n puts ''\n correct_input = 0\n until correct_input == 1\n print 'Enter a number: '\n option = gets.chomp\n if %w[1 2].include?(option)\n correct_input = 1\n else\n puts 'PLEASE ENTER 1 OR 2'\n end\n end\n puts \"\\n\\n\"\n option\n end", "def menu\n puts \"Welcome to RubyCo! What would you like to do?\"\n puts \"1) View Available Products\"\n puts \"2) View My Cart\"\n puts \"3) Exit Store\"\n puts \"Please choose 1, 2, or 3\"\n user_input = gets.strip.to_i\n if user_input == 1\n puts \"----------------\"\n avail_products \n elsif user_input == 2\n view_cart\n elsif user_input == 3\n puts \"Thanks for shopping today! Goodbye!\"\n exit \n else\n puts \"Invalid Input. Try 1, 2, or 3.\"\n menu\n end\nend", "def give_next_options_to_continue\n puts \"\\n\\n\"\n puts \"------------------------------------Please select any of the following options-------------------------------------------\"\n puts \"1: Book another ticket\"\n puts \"2: Print total revenue with taxes\"\n puts \"3: Exit\"\n @selected_option = receive_input.to_i\n execute_on_basis_of_selected_option\n end", "def choose(choices, title)\n res = @dialog.menu(title, choices)\n\n raise CancelPressed.new unless res\n\n res\nend", "def get_valid_user_choice ###\n print \"\\nWhat would you like to do next? \\n(Enter 'list planets', 'planet details', 'add planet', or 'exit'.) \"\n @user_choice = gets.chomp.downcase\n\n until @user_choice == \"list planets\" || @user_choice == \"exit\" || @user_choice == \"planet details\" || @user_choice == \"add planet\"\n puts \"Please enter a valid choice: list planets, planet details, add planet, or exit.\"\n @user_choice = gets.chomp.downcase\n end\n end", "def get_menu_or_exit\n puts \"\\n\n There you go! Interesting, amirite?\\n\n Enter 'main' to return to the main menu,\\n\n or if you're done here enter 'exit':\"\n valid_response = false\n until valid_response == true\n user_input = gets.chomp\n if user_input == 'exit'\n valid_response = true\n elsif user_input == 'menu'\n valid_response = true\n else\n puts \"\\n\n Invalid input. Please enter 'main' or 'quit' below:\"\n end\n end\n user_input\n end", "def action\n (@current_level = 'X' ; return) if ( @user_choice == 'X' || @user_choice == 'x')\n\n (menu_level_left ; return) if @user_choice == \"\\e[D\"\n\n tmp_lvl = @current_level + '.' + @user_choice\n cmd = @menu_map[tmp_lvl][1]\n cmd ? execute_action(cmd) : @current_level = tmp_lvl\n end", "def return_to_menu\n puts Rainbow(\"\\nWould you like to return to the menu? (y/n)\").white.bright\n user_input = gets.chomp\n if user_input == \"y\"\n menu\n menu_choice\n elsif user_input == \"n\"\n puts Rainbow(\"Would you like to quit the app? (y/n)\").white.bright\n user_input = gets.chomp\n if user_input == \"y\"\n exit\n else\n menu\n menu_choice\n end\n end\n end", "def menu\n puts \"Welcome to RubyCo! What would you like to do?\"\n puts \"1) View Available Products\"\n puts \"2) View My Cart\"\n puts \"3) Exit Store\"\n puts \"Please choose 1, 2, or 3\"\n user_input = gets.strip.to_i\n if user_input == 1\n puts \"----------------\"\n avail_products\n elsif user_input == 2\n view_cart\n elsif user_input == 3\n puts \"Thanks for shopping today! Goodbye!\"\n exit\n else\n puts \"Invalid Input. Try 1, 2, or 3.\"\n menu\n end\nend", "def menu_exit\n puts \"\\nPlease type 'Menu' to navigate to the menu, or 'Exit' to exit\"\n puts\"\\n-------------------------------------------------------------------------------------------\"\n input = gets.strip.downcase\n if input == \"menu\"\n menu_items\n elsif input == \"exit\"\n exit_statement\n else\n puts \"\\nDid you mean to type 'menu' or 'exit'?\" # Or do they want to re enter info(next iteration)\n menu_exit\n end\nend", "def redirect_to_new_costume_form_if_assignment_incomplete\n redirect_to_new_costume_form(danger: 'Must select at least 1 dancer w/ costume size & costume condition') if @costume.costume_assignments.empty?\n end", "def menu_choice\n user_input = gets.chomp\n case user_input\n when \"1\"\n # Call function to show all of the doctors by region\n\n # show_all_doctors_by_region\n\n show_all_article_by_with_authors\n return_to_menu\n when \"2\"\n # Call function to show all of the doctors by specialties\n show_all_article_titles_with_content\n return_to_menu\n when \"3\"\n # Call function to show all of the doctors a user has visited\n show_all_authors\n return_to_menu\n when \"4\"\n puts Rainbow(\"Here are all the authors to choose from:\\n\").white.bright\n show_all_authors\n puts Rainbow(\"\\nPlease provide an author name:\").white.bright\n author = gets.chomp\n find_article_titles_by_author(author)\n show_full_list_of_articles(author)\n return_to_menu\n when \"5\"\n show_latest_article\n return_to_menu\n when \"6\"\n quit\n else\n puts Rainbow(\"Invalid option. Please select a number between 1 and 6.\").white.bright\n menu\n menu_choice\n end\n end", "def input_logic(value_from_user_input_method)\n\tcase value_from_user_input_method\n\t\twhen 1\n\t\t\tcommand_line_menu\n\t\twhen 2\n\t\t\tsearch\n\t\twhen 3\n\t\t\tputs \"GOODBYE\"\n\t\t\texit(0)\n\t\telse\n\t\t\tputs \"Please make a selection between 1-3. Typing anything else will only show you this message again.\"\n\t\t\tmenu\n\tend\nend", "def recipe_ask_for_options\n puts \"\"\n puts \"What would you like to do?\".colorize(:yellow)\n puts \"\\n- [1] Save recipe\\n- [2] See Conversion tool\\n- [3] Back to main menu\".colorize(:yellow)\n user_input = gets.chomp\n if @answers[1][1].include?(user_input)\n @recipe.save_recipe\n self.save_menu_options\n elsif @answers[1][2].include?(user_input)\n self.start_convert\n elsif @answers[1][3].include?(user_input)\n self.start_main_menu\n elsif user_input == \"end\"\n exit \n else\n puts \"Thats wasn't a valid input, type 1 to start program, type 2 to navigate to the conversion feature and type 3 to see help.\".colorize(:red)\n end\n end", "def menu\n\n puts \"________________\"\n\n puts \"insert the user name to continue\"\n @user_name = gets.chomp\n response = User.find_by(user_name: @user_name)\n\n puts \"________________\"\n\n if response\n \n mainscreen\n else\n puts \"try again\"\n menu\n end\n end", "def main_menu\n selection = input(@menu) {|o| (1..2) === o.to_i }.to_i\n \n if 1 == selection\n :continue\n elsif 2 == selection\n :quit\n end\n end", "def menu_options\n puts \"Good morning, you have two options; you can either\"\n puts \"1. Add students to the directory\\n 2. View a list of students enrolled at Makers Academy\\n 3. Save the list of students to a file\\n 9. Exit the programme.\"\n puts \"Please type the option you would like?\"\nend", "def unrecognized_input\n puts \"Input not recognized or is invalid.\"\n exit_screen\n end", "def menu\n selection = gets.chomp.to_i\n case selection\n when 1\n all_tickets = Tickets.new(@zendesk_tickets)\n all_tickets.view_all\n when 2\n single_ticket = Ticket.new(@zendesk_tickets)\n single_ticket.view_all\n when 3\n system 'clear'\n puts \"Goodbye!\"\n exit\n else\n system 'clear'\n puts \"Invalid choice, select between 1, 2 or 3\"\n welcome_message \n menu\n end\n end", "def get_selection\n # get input from user convert to int\n puts \"Select a value\"\n input = gets.strip\n # if input is not a valid integer it will go to rescue\n selection = Integer(input)\n # check if input is int, maybe check is a valid int ie if we four option in our menu the value 1,2,3,4\n if (selection >= 1 && selection <= @menu[:options].size)\n return selection\n else\n puts \"#{selection} need to be in between 1 and #{@menu[:options].size}, please try again\"\n self.get_selection\n end\n rescue ArgumentError\n #if a ArgumentError occurs above than ruby will come here instead of throwing error\n puts \"#{input} is not a integer please select a integer\"\n self.get_selection\n end", "def student_main_menu(student_user) \n self.line_break\n puts \"Please select a command:\".colorize(:light_blue), \"1: Return to Main Menu\".colorize(:cyan), \"2: Exit\".colorize(:cyan)\n self.line_break\n input = gets.chomp\n until input == \"1\" || input == \"2\"\n puts \"Invalid response. Please select a command:\".colorize(:yellow), \"1: Return to Main Menu\".colorize(:cyan), \"2: Exit\".colorize(:cyan) \n input = gets.chomp\n end\n if input == \"1\"\n self.student_tasks(student_user)\n elsif input == \"2\"\n puts \"Have a great day!\".colorize(:light_green)\n end\n end", "def menu\n\t\tmenu_display\n\t\tdecision = gets.chomp.downcase\n\t\tif decision == '1' || decision == '1.' || decision == 'balance'\n\t\t\tcheck_balance\n\t\telsif decision == '2' || decision == '2.' || decision == 'deposit'\n\t\t\tdeposit\n\t\telsif decision == '3' || decision == '3.' || decision == 'withdraw'\n\t\t\twithdraw\n\t\telsif decision == '4' || decision == '4.' || decision == 'history'\n\t\t\thistory\n\t\telsif decision == '5' || decision == '5.' || decision == 'exit'\n\t\t\tgoodbye\n\t\telse\n\t\t\t\"Please check your input and enter the correct number. \"\n\t\t\tsleep(3)\n\t\t\tmenu\n\t\tend\n\tend", "def main_menu\n prompt = TTY::Prompt.new(\n active_color: :red,\n symbols: {marker: \"⮊\"},\n quiet: true\n )\n\n puts \"\"\n menu_selection = prompt.select(\"Select an option:\") do |menu|\n menu.choice \"➊ Start a new game\", 1\n menu.choice \"➋ How to play\", 2\n menu.choice \"➌ Display win counts\", 3\n menu.choice \"➍ Exit program\", 4\n end\n\n case menu_selection\n when 1\n start_game\n when 2\n instructions\n when 3\n check_win_history\n when 4\n puts \"\\nThanks for playing\\n\\nGoodbye!\"\n exit\n else\n raise InvalidMenu\n end\n\n rescue InvalidMenu\n puts \"Invalid menu input. Please try again!\"\n retry\n rescue\n puts \"An unexpected error has occured. The program will now exit.\"\nend", "def main_menu(current_user)\n puts \"*****************************************************\"\n puts \"What would you like to choose?\"\n puts \" \"\n puts \"1. Make appointment\"\n puts \"2. My appointments\"\n puts \"3. Change user\"\n puts \"4. Exit\"\n\n input = gets.chomp\n case input\n when \"1\"\n stylists_menu(current_user)\n when \"2\"\n my_appointments_menu(current_user)\n when \"3\"\n puts \"Enter new username\"\n username = gets.chomp\n current_user = User.find_or_create_by(name: username)\n main_menu(current_user)\n when \"4\"\n close_app\n\n else\n puts \"Please choose numbers 1 to 3\"\n main_menu(current_user)\n end\nend", "def choose_option(input)\n \t# input = user_input\n case input\n when 1 then add_contact\n when 2 then modify_contact\n when 3 then display_all_contacts\n when 4 then display_contact\n when 5 then display_contact_attributes\n when 6 then delete_contact\n when 7 then exit \t\n else puts \"I'm sorry Dave, but you cant do that.\"\n end\n end", "def menu\n input = nil\n puts \"Enter the number of the question you want to see, type 'list' to choose a new list of quesitons or type 'exit': \"\n puts @@divider\n input = gets.strip.downcase\n if input.to_i > 0 && input.to_i < @questions.length + 1\n question = @questions[input.to_i - 1]\n display_question(question)\n elsif input == \"list\"\n list_questions\n elsif input == \"exit\"\n goodbye\n else\n puts \"Please make a valid selection.\"\n menu\n end\n end", "def main_menu\n while true\n puts \"Options:\"\n puts \"[1] Add a new field of crops\"\n puts \"[2] Harvest crops\"\n puts \"[3] Status of farm\"\n puts \"[4] Relax and view fields\"\n puts \"[5] Exit\"\n puts \"Enter a Number\"\n main_menu_opt = gets.chomp.to_i\n case main_menu_opt\n when 1 then field #will run field method\n when 2 then harvest #will run harvest method\n when 3 then status #will run status method\n when 4 then relax #will run relax method\n else exit\n end\n end\n end", "def return_to_menu\n\tputs \"Return to Menu? [y/n]\"\n\tans = gets.chomp.downcase\n\n\tcase ans[0]\n\t\twhen \"y\"\n\t\t\tclear_screen\n\t\t\tmenu\n\t\twhen \"n\"\n\t\t\tclear_screen\n\t\t\tputs \"Okay. Well...see you around, then. I guess.\"\n\t\telse\n\t\t\tclear_screen\n\t\t\tputs \"Huh? Yes or No, please.\"\n\t\t\treturn_to_menu\n\tend\nend", "def main_menu(user_instance)\n user_greeting(user_instance)\n case help\n when \"1\", \"playlist\", \"playlists\"\n system(\"clear\")\n playlists_menu(user_instance)\n when \"2\", \"songs\", \"song\"\n system(\"clear\")\n songs_menu(user_instance)\n # when \"3\", \"artists\", \"artist\"\n # system(\"clear\")\n # artists_menu(user_instance)\n when \"exit\"\n system(\"clear\")\n goodbye\n exit\n else\n system(\"clear\")\n puts \"Please enter a valid command.\".colorize(:red).bold\n main_menu(user_instance)\n end\nend", "def select_option\n print_menu\n @choice = gets.chomp\n perform_selection\n end", "def select_view\n #redirect_to :action => params[:selection]\n if (SELECTABLE_ACTIONS_ADMIN.include? params[:selection].to_sym) || (SELECTABLE_ACTIONS.include? params[:selection].to_sym)\n redirect_to :action => params[:selection]\n else\n redirect_to :action => 'home'\n end\n end", "def unrecognized_option(err); end", "def start_menu\n\n puts \" \"\n puts \" WELCOME TO TIC-TAC-TOE! \"\n\n puts \"Choose how many players will be playing the game (0, 1, or 2):\"\n puts \"Type 'exit' to EXIT\"\n\n user_input = gets.strip.downcase\n\n case user_input\n when '0'\n zero_players\n play_again?\n when '1'\n one_player\n play_again?\n when '2'\n two_players\n play_again?\n when 'exit'\n abort(\"You Exited the Game\")\n else\n puts \"Invalid entry. The choices are 0, 1, 2, or exit!\"\n start_menu\n end # case start_menu\n end", "def again_or_exit?(crate)\n puts \"\\n\\nWhat would you like to do now?\\n1. View another genre.\\n2. Exit\"\n input = gets.strip\n input_i = input.to_i\n acceptable_answers = (1..2).to_a\n while acceptable_answers.none? { |answer| answer == input_i }\n puts \"\\nI'm sorry, that's not a valid option.\"\n puts \"Please enter 1 or 2.\"\n input_i = gets.strip.to_i\n end \n\n if input_i == 1\n self.start(crate)\n else\n puts \"Have a good one!\"\n end\n end", "def main_menu\n while true\n print_main_menu\n user_selected =gets.to_i\n call_option(user_selected)\n end\n end", "def main_menu\n while true\n print_main_menu\n user_selected = gets.chomp.to_s\n call_option(user_selected)\n end\n end", "def checkUserInput\r\n #initialize mainmenu selection characters array\r\n @mainMenuCharSelection = [\"c\",\"l\",\"u\",\"d\",\"e\"];\r\n #check user input for input validation\r\n if(@mainMenuCharSelection.include? @userInput.downcase)\r\n case @userInput.downcase\r\n when \"c\"\r\n result = BackEndLogic.create(politicians);\r\n \r\n politicians << result;\r\n when \"l\"\r\n BackEndLogic.list(politicians);\r\n when \"u\"\r\n BackEndLogic.update(politicians);\r\n when \"d\"\r\n result = BackEndLogic.remove(politicians);\r\n when \"e\"\r\n @ismainMenuLoop = false;\r\n else\r\n puts \"entry unkown! Try again! \\n\\n\"\r\n end\r\n else\r\n puts \"Please enter a valid choice from the menu options! You chose (#{@userInput}) \\n\\n\";\r\n end\r\n end", "def settings_menu\n display_settings\n\n case user_input(caps: true)\n when interface[:home] then clear_and_home_navigation\n when interface[:difficulty] then clear_and_set_difficulty\n when interface[:interface] then clear_and_set_interface\n when interface[:markers] then set_markers\n when interface[:names] then set_names\n when interface[:help] then toggle_helper_and_settings_menu\n when interface[:reset]\n if default_settings?\n invalid\n else\n reset_default_settings\n end\n else\n invalid\n end\n end", "def main_menu\n puts \"----------------\"\n puts \"1. Play a Game\"\n puts \"2. Add Money\"\n puts \"3. Exit Casino\"\n user_input = gets.strip.to_i\n if user_input == 1\n game_floor\n elsif user_input == 2\n money = gets.strip.to_i\n @wallet = Wallet.new(money)\n if @wallet.validate_money(money)\n @wallet.add_money(money)\n puts \"Higher risks = higher rewards! Your bankroll is now: $#{@wallet.current_balance}\"\n main_menu\n else puts \"Invalid amount. Try again.\"\n main_menu\n end\n elsif user_input == 3\n puts \"Thanks for visiting DPL Casino!\"\n exit\n end\n end", "def exit_or_rerun\n puts \"\\nDo you want to select another category? (yes/no/exit)\\n\\n\"\n response = user_input_capture\n if AFFIRMATIVE_INPUT.include?(response.downcase)\n select_category\n elsif NEGATIVE_INPUT.include?(response.downcase) || QUIT_INPUT.include?(response.downcase)\n exit_app\n else\n puts \"Invalid response! Please enter 'yes', 'no', or 'exit' to quit\"\n exit_or_rerun\n end\n \n end", "def select(option)\n\t\tcase option \n\t\twhen \"1\" then login\n\t\twhen \"2\" then register\n\t\twhen \"3\" then exit\n\t\tend\n\tend", "def main_menu\n\t\twhile true\n\t\t\tprint_main_menu\n\t\t\tinput = gets.chomp.to_i\n\t\t\treturn if input == 7\n\t\t\tchoose_option(input)\n\t\tend\n\tend", "def handle_menu(menu_item,battleship)\n\n case menu_item.to_i\n\n when 1\n # view_all_apts(apartments)\n menu_item=0\n battleship=start_game\n battleship.build_ship\n battleship.build_ship\n return false\n when 2\n battleship.showship = !battleship.showship\n return false\n when 3\n battleship.build_ship\n battleship.show_board\n return false\n\n when 99\n return true\n else\n puts(\"Please type a Valid Menu Item\")\n puts(\"Press [ENTER] to continue\")\n gets\n return false\n end #case\n end", "def main_menu\n choice = true\n while choice\n puts \"What would you like to do?\"\n puts \"(C)reate, (L)ist, (U)pdate, (D)elete, or (E)xit \"\n options = gets.chomp.downcase\n\n case options\n when \"c\"\n # runs method create line 101\n create\n when \"l\"\n #runs method list line 144\n list\n when \"u\"\n #runs method update line 161\n update\n when \"d\"\n #runs method delete line 229\n delete\n when \"e\"\n choice = false #exits world\n else\n puts \"Wrong Input. Please input C, L, U, D or E\"\n end\n end\n end", "def main_menu\n\n\tif @count < 3\n\n\tputs \"Welcome to The Bank\"\n\tputs \"Please select action from the following menu options:\"\n\tputs \"-----------------------------------------------------\"\n\tputs \"1. Add an account\"\n\tputs \"2. View existing acocunt\"\n\tputs \"3. Exit Menu\"\n\n\n\toption = gets.chomp.to_i # User Choice\n\tif option == 1 \n\t\t@count = 0 #resetting the count\n\t\tadd_account #calling the method\n\telsif option == 2\n\t\t@count = 0 #resetting the count\n\t\tview_account #calling \n\telsif option == 3\n\t\tputs \"Thank you for visiting The Bank\"\n\t\texit\n\telse\n\t\t\tif @account != (1..3)\n\t\t\t\tputs \"invalid selection. Try Again.\"\n\t\t\tend\n\t\t\t@count += 1\n\t\t\tmain_menu\n\t\tend\n\n\telse \n\t\tputs \"You seem to be having trouble. Contact Customer Service.\"\n\t\texit\n\tend\n\nend", "def redirect_if_no_plan_selected\n if params[:plan_id].nil?\n redirect_to action: \"choose_plan\"\n end\n end", "def present_menu_options\n space(1)\n puts \"Choose an option from the list below.\"\n space(1)\n puts '1. Search for events by city'\n puts '2. Search for events by artist or sports team'\n puts '3. See what I have coming up'\n puts '4. Delete my account'\n puts '5. Exit'\n space(1)\n pick_option\nend", "def level_2_option_2\n recipe = display_recipe_options\n if recipe == 1 #Show all recipes\n clear\n display_all_recipes\n elsif recipe == 2\n clear\n begin\n new_recipe_prompts #Add a new recipe\n rescue InvalidCookingTimeError, InvalidDishError => e\n clear\n puts \"\"\n puts e.message.colorize(:red)\n retry\n rescue DuplicateError => e\n clear\n puts \"\"\n puts e.message.colorize(:red)\n puts \"\"\n puts \"\"\n $prompt.keypress(\"Press any key to go back to Main Menu\".colorize(:red))\n end\n elsif recipe == 3\n clear\n delete_recipe_prompts #Delete a recipe\n end\nend", "def stylists_menu(current_user)\n puts \"Please choose stylist\"\n puts \" \"\n puts \" 1. Jessica\"\n puts \" 2. Vanessa\"\n puts \" 3. Max\"\n puts \" 4. Exit\"\n\n input = gets.chomp\n\n case input\n\n when \"1\"\n stylist_name = \"Jessica\"\n stylist = Stylist.find_by(name: stylist_name)\n create_new_appointment(current_user, stylist)\n appt_conf\n main_menu(current_user)\n\n when \"2\"\n stylist_name = \"Vanessa\"\n stylist = Stylist.find_by(name: stylist_name)\n create_new_appointment(current_user, stylist)\n appt_conf\n main_menu(current_user)\n\n when \"3\"\n stylist_name = \"Max\"\n stylist = Stylist.find_by(name: stylist_name)\n create_new_appointment(current_user, stylist)\n appt_conf\n main_menu(current_user)\n\n when \"4\"\n main_menu(current_user)\n else\n puts \"Please, choose 1 or 4\"\n stylists_menu(current_user)\n end\nend", "def menu_error\n system(\"clear\")\n puts Spacer\n puts \"Sorry! I didn't understand that.\".colorize(:red)\n end", "def opt_strt_chk(input)\n until input == 'options' || input == 'start'\n puts \"\\n Type 'options' to go into the options menu or 'start' to begin a new game\"\n input = gets.chomp\n end\n if input == 'options'\n options\n else\n end\n end", "def handle_failed_option param, value\n @options_ok = false\n end", "def main_menu_options\n a = Artii::Base.new #display main title greeting\n a.asciify('Menu')\n puts a.asciify('Menu').colorize(:blue)\n\n puts \"\"\n puts \"1. Search movies.\"\n puts \"2. View your list.\"\n puts \"\"\n puts \"Please input the number corresponding to your choice.\"\n input = gets.chomp #todo Check to see if you can break this\n system \"clear\"\n if input == '1'\n puts \"Let's look at some movies.\"\n movie_search #send user to the movie search screen\n elsif input == '2'\n display_movie_list_and_movie_list_options #send movie to the movie list screen\n else\n \"Please select a valid option\"\n main_menu_options #call the method again\n end\n end", "def menu\n puts \"------Calculator----\"\n puts \"Welcome to the calculator!\"\n puts \"Please select an option:\"\n puts \"\\t1) Enter numbers and modifier\"\n puts \"\\t2) Enter a string input\"\n puts \"\\t3) View the calculations you have preformed\"\n puts \"\\t4) Exit\"\n main_menu\n end", "def main_menu_check\n input = user_input\n until input == 'p'\n if input == 'q'\n exit!\n end\n puts \"Wrong input, enter p to play or q to quit\"\n input = user_input\n end\n end", "def main_menu\n\n puts \"Doctor's Office Manager\"\n puts \"Enter 'a' to access the appointments menu.\"\n puts \"Enter 's' to access specialities menu.\"\n puts \"Enter 'p' to access patient menu.\"\n puts \"Enter 'i' to access insurance menu.\"\n puts \"Enter 'd' to access doctor menu.\"\n puts \"Enter 'e' to exit\"\n puts \"Enter 'r' to access README\"\n\n user_choice = gets.chomp.downcase\n\n case user_choice\n when 'a'\n appointment_menu\n when 's'\n specialties_menu\n when 'p'\n patient_menu\n when 'i'\n insurance_menu\n when 'd'\n doctor_menu\n when 'e'\n puts \"Goodbye!\"\n sleep 1\n exit\n when 'r'\n display_readme\n else\n puts \"Enter something proper, ya jackass\"\n end\n\nmain_menu\nend", "def menu_choice(action)\n if action == \"a\"\n @humanplayer.search_weapon\n elsif action == \"s\"\n @humanplayer.search_health_pack\n elsif action == \"1\"\n @humanplayer.attack(@player_1)\n elsif action == \"2\"\n @humanplayer.attack(@player_2)\n elsif action == \"3\"\n @humanplayer.attack(@player_3)\n elsif action == \"4\"\n @humanplayer.attack(@player_4)\n else puts \"Please select option a, s, 1, 2, 3 or 4\"\n end\n\n kill_player\n end", "def search_submenu(entry)\n #print out submenu for entry\n puts \"\\nd - delete entry\"\n puts \"e - edit this entry\"\n puts \"m - return to main menu\"\n #save user input to selection\n selection = gets.chomp\n\n #case to take specific action based on user input\n case selection\n #call delete_entry and call main_menu after it returns\n when \"d\"\n system \"clear\"\n delete_entry(entry)\n main_menu\n #call edit_entry\n when \"e\"\n edit_entry(entry)\n system \"clear\"\n main_menu\n #returns to main_menu\n when \"m\"\n system \"clear\"\n main_menu\n #if no match, clear the screen and ask for input again\n #by calling search_submenu\n else\n system \"clear\"\n puts \"#{selection} is not a valid input\"\n puts entry.to_s\n search_submenu(entry)\n end\n end", "def pbItemMenu(index)\n pbDisplayMessage(\"Items can't be used here.\")\n return -1\n end", "def menu\n puts \"\\nPlease pick an option from the choices below:\\n1.) Follow a sport\\n2.) Remove a sport\\n3.) Show all the sports you follow\\n4.) Show sports teams\\n5.) Sign out\"\n answer = gets.chomp\n while answer != \"sign out\" || answer == \"4\"\n if answer == \"1\"\n create_subscription\n menu_prompt\n answer = gets.chomp\n #do we need to update the database now?\n elsif answer == \"2\"\n delete_subscription\n menu_prompt\n answer = gets.chomp\n elsif answer == \"3\"\n show_subscriptions\n menu_prompt\n answer = gets.chomp\n elsif answer == \"4\"\n show_teams\n puts \"\\nWould you like to see more info on any specific team? (Answer y for yes or n for no)\"\n reply = gets.chomp\n\n if reply == \"yes\" || reply == \"y\"\n show_team_info\n end\n\n menu_prompt\n answer = gets.chomp\n elsif answer == \"5\"\n puts \"\\nThanks for stopping by. See you soon!\"\n break\n else\n puts \"\\nThat is not a valid response, smart guy!\"\n menu_prompt\n answer = gets.chomp\n end\n end\n end", "def select_choice_staff_member\n\tputs \"\\n1 Add a Staff Member\\n2 Information on a Staff Member\\n3 Edit a Staff Member\\n4 Remove a Staff Member\\n5 View All Staff Members\\n6 Reassign a Staff Member to a Different Branch\\n0 Return to Main Menu\"\n\tselect = make_selection\n\n\twhile select != \"1\" && select != \"2\" && select != \"3\" && select != \"4\" && select != \"5\" && select != \"6\" && select != \"0\"\n\t\tputs \"\\nInvalid choice selected\\n\"\t\t \t\t\n\t\tselect = make_selection\n\tend\n\n\tif select == \"1\"\n\t\tadd_staff_member\n\n\telsif select == \"2\"\n\t\tputs \"\\nTo get information about a staff member please enter their ID #\\n\"\n\t\tshow_all_staff_members\n\t\tselect = make_selection.to_i\n\t\tselect = verify_staff_member_exists(select)\n\t\tdisplay_staff_member(select)\n\n\telsif select == \"3\"\n\t\tputs \"\\nTo edit a please enter their ID #\\n\"\n\t\tshow_all_staff_members\n\t\tselect = make_selection.to_i\n\t\tselect = verify_staff_member_exists(select)\n\t\tedit_staff_member(select)\n\n\telsif select == \"4\"\n\t\tputs \"\\nTo remove a staff member please enter their ID #\\n\"\n\t\tshow_all_staff_members\n\t\tselect = make_selection.to_i\n\t\tselect = verify_staff_member_exists(select)\n\t\tremove_staff_member(select)\n\n\telsif select == \"5\"\n\t\tshow_all_staff_members\n\n\telsif select == \"6\"\n\t\tputs \"\\nTo reassign an employee to a different branch please enter their ID #\\n\"\n\t\tshow_all_staff_members\n\t\tselect = make_selection.to_i\n\t\tselect = verify_staff_member_exists(select)\n\t\treassign_staff_member(select)\n\n\n\telsif select == \"0\"\n\t\tputs \"\\nNow entering main menu\\n\"\n\n\tend\n\tselect\t\t\nend", "def main_menu(season)\n self.print_main_menu(season)\n\n input = gets.strip.downcase\n\n # Uses case statement to check input\n case input \n when \"1\"\n self.handle_standings(season)\n when \"2\"\n self.handle_home_court_records(season)\n when \"3\"\n self.handle_home_court_advantages(season)\n when \"4\"\n self.handle_point_differentials(season)\n when \"5\"\n self.handle_team_stats(season)\n when \"6\"\n self.handle_head_to_head(season)\n when \"7\"\n self.handle_new_season\n when \"exit\"\n self.exit_program\n else\n puts \"Invalid input. Try Again\"\n self.main_menu(season)\n end\n end", "def menu(balance)\n puts \"What do you want to do?\"\n puts \"|| {B}alance update || {D}eposit || {W}ithdraw ||\"\n puts\n\n input = gets.chomp.to_s\n case input\n when \"b\"\n balance_display(bqalance)\n when \"d\"\n deposit(balance)\n when \"w\"\n withdraw(balance)\n # if none of the options are chosen, restart from the beginning\n else\n error\n welcome(balance)\n end\n end" ]
[ "0.7783703", "0.75411755", "0.6689158", "0.66183287", "0.64742786", "0.6465329", "0.64648294", "0.6400918", "0.638639", "0.63639075", "0.6319928", "0.6272095", "0.6263153", "0.62389815", "0.62364393", "0.6224212", "0.62218475", "0.62150705", "0.61905396", "0.60984504", "0.6090199", "0.6077337", "0.60752046", "0.6059087", "0.6058501", "0.6055226", "0.6028971", "0.6025728", "0.60070616", "0.6005803", "0.6004127", "0.600218", "0.6000095", "0.59906685", "0.59767556", "0.59759957", "0.59748906", "0.5966042", "0.5962493", "0.59586656", "0.5955351", "0.5946279", "0.5945825", "0.5938911", "0.59309167", "0.59239835", "0.59198636", "0.5867416", "0.586593", "0.5861028", "0.5838196", "0.5833382", "0.58314633", "0.5829211", "0.5825351", "0.5820651", "0.5818439", "0.5816164", "0.5815566", "0.58106023", "0.5806078", "0.58043355", "0.5801389", "0.5798742", "0.5791714", "0.578373", "0.5782883", "0.5776776", "0.5773216", "0.5767652", "0.5759492", "0.57569855", "0.5755482", "0.575252", "0.57520753", "0.5749237", "0.57490695", "0.5737987", "0.5725678", "0.57254577", "0.57243276", "0.57240117", "0.57207257", "0.57145655", "0.5692911", "0.56887704", "0.568781", "0.56838316", "0.5680245", "0.56762356", "0.5676012", "0.56726354", "0.5669702", "0.5663016", "0.5661074", "0.5660235", "0.5644808", "0.56419116", "0.5639564", "0.56325376" ]
0.7325123
2
The following methods update a voter or politician in the directory.
def update_option puts "Would you like to Update a (V)oter or (P)olitician record?".center(80) update_type = verified_answer(gets.chomp.downcase, ["p", "v"]) if update_type == "p" update_politician list_politicians else update_voter list_voters end puts "Record successfully updated.".center(80).green puts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @voter = Voter.find(params[:id])\n\n respond_to do |format|\n if @voter.update_attributes(params[:voter])\n format.html { redirect_to @voter, notice: 'Voter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @voter.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @voter.update(voter_params)\n format.html { redirect_to @voter, notice: 'Voter was successfully updated.' }\n format.json { render :show, status: :ok, location: @voter }\n else\n format.html { render :edit }\n format.json { render json: @voter.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @voter.update(voter_params)\n format.html { redirect_to @voter, notice: 'Voter was successfully updated.' }\n format.json { render :show, status: :ok, location: @voter }\n else\n format.html { render :edit }\n format.json { render json: @voter.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_voter_state(voter_id, name, value)\n send_and_process(\"voters/set/#{voter_id}?#{name}=#{value}\", 'voter')\n end", "def update(update_choice)\n if update_choice == \"v\"\n puts \"Which Voter would you like to update?\"\n voter = gets.chomp.downcase\n voter_find(voter)\n elsif update_choice == \"p\"\n puts \"Which Politician would you like to update?\"\n politician = gets.chomp.downcase\n politician_find(politician)\n else\n end\n end", "def update\n @vote = Vote.find(params[:id])\n\n respond_to do |format|\n if @vote.update_attributes(params[:vote])\n format.html { redirect_to([:admin,@vote], :notice => 'Vote was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vote.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @vote = @votable.votes.find(params[:id])\n\n respond_to do |format|\n if @vote.update(vote_params)\n format.html { redirect_to build_path_vote(@vote), notice: 'Vote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vote = Vote.find(params[:id])\n\n respond_to do |format|\n if @vote.update_attributes(params[:vote].merge(:user => current_user))\n format.html { redirect_to(@vote, :notice => 'Vote was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vote.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n put :update\n end", "def update\n @vote = Vote.find(params[:id])\n\n previous_value = @vote.vote\n\n respond_to do |format|\n if @vote.update_attributes(vote_params)\n InformCommitteeMembers.vote_changed(@vote.proposal, current_user, previous_value, @vote.vote)\n format.html { redirect_to [@proposal, @vote], notice: 'Vote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admins_politician.update(admins_politician_params)\n format.html { redirect_to @admins_politician, notice: 'Politician was successfully updated.' }\n format.json { render :show, status: :ok, location: @admins_politician }\n else\n format.html { render :edit }\n format.json { render json: @admins_politician.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @politician.update(politician_params)\n format.html { redirect_to @politician, notice: 'Politician was successfully updated.' }\n format.json { render :show, status: :ok, location: @politician }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @politician.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vote = Vote.find(params[:id])\n\n respond_to do |format|\n if @vote.update_attributes(params[:vote])\n format.html { redirect_to @vote, notice: 'Vote was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vote = Vote.find(params[:id])\n\n respond_to do |format|\n if @vote.update_attributes(params[:vote])\n format.html { redirect_to @vote, notice: 'Vote was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vote = Vote.find(params[:id])\n\n respond_to do |format|\n if @vote.update_attributes(params[:vote])\n format.html { redirect_to @vote, notice: 'Vote was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vote = Vote.find(params[:id])\n\n respond_to do |format|\n if @vote.update_attributes(params[:vote])\n format.html { redirect_to @vote, notice: 'Vote was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vote = Vote.find(params[:id])\n\n respond_to do |format|\n if @vote.update_attributes(params[:vote])\n format.html { redirect_to @vote, notice: 'Vote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vote = Vote.find(params[:id])\n\n respond_to do |format|\n if @vote.update_attributes(params[:vote])\n format.html { redirect_to @vote, notice: 'Vote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vote = Vote.find(params[:id])\n\n respond_to do |format|\n if @vote.update_attributes(params[:vote])\n format.html { redirect_to @vote, notice: 'Vote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vote = Vote.find(params[:id])\n\n respond_to do |format|\n if @vote.update_attributes(params[:vote])\n format.html { redirect_to @vote, notice: 'Vote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vote = Vote.find(params[:id])\n\n respond_to do |format|\n if @vote.update_attributes(params[:vote])\n format.html { redirect_to @vote, notice: 'Vote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vote = Vote.find(params[:id])\n\n respond_to do |format|\n if @vote.update_attributes(params[:vote])\n format.html { redirect_to @vote, notice: 'Vote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vote = Vote.find(params[:id])\n\n respond_to do |format|\n if @vote.update_attributes(params[:vote])\n format.html { redirect_to @vote, notice: 'Vote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @vote.update(vote_params)\n redirects_to @vote, notice: \"vote was update\"\n else\n render action: 'edit'\n end\n end", "def update\n @lector = Lector.find(params[:id])\n\n respond_to do |format|\n if @lector.update_attributes(params[:lector])\n format.html { redirect_to @lector, notice: 'Las modificaciones al Lector se han guardado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lector.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_voter\n @voter = Voter.find(params[:id])\n end", "def set_voter\n @voter = Voter.find(params[:id])\n end", "def update\n @vote = @retort.votes.find(params[:id])\n\n respond_to do |format|\n if @vote.update_attributes(params[:vote])\n flash[:notice] = 'Vote was successfully updated.'\n format.html { redirect_to(@retort) }\n format.xml { head :ok }\n else\n flash[:error] = 'Vote could not be updated.'\n format.html { redirect_to(@retort) }\n format.xml { render :xml => @vote.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_vote!(new_value)\n if @vote\n authorize @vote, :update?\n @vote.update_attribute(:value, new_value)\n else\n @vote = current_user.votes.build(value: new_value, post: @post)\n authorize @vote, :create?\n @vote.save\n end\n end", "def update\n @virtual_assignment = @object\n vmhost = @virtual_assignment.parent\n return unless filter_perms(@auth,vmhost,['updater'])\n vmguest = @virtual_assignment.child\n return unless filter_perms(@auth,vmguest,['updater'])\n\n respond_to do |format|\n if @virtual_assignment.update_attributes(params[:virtual_assignment])\n flash[:notice] = 'VirtualAssignment was successfully updated.'\n format.html { redirect_to virtual_assignment_url(@virtual_assignment) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @virtual_assignment.errors.to_xml, :status => :unprocessable_entity }\n end\n end\n end", "def update!\n @authorize = nil\n update_plan! &&\n resp = put(\"/users/#{username}.xml\", {\n :user_key => apikey,\n \"user[first_name]\" => first_name,\n \"user[last_name]\" => last_name\n })\n end", "def update\n @vote = Vote.find(params[:id])\n\n respond_to do |format|\n if @vote.update_attributes(params[:vote])\n flash[:notice] = 'Vote was successfully updated.'\n format.html { redirect_to(@vote) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vote.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @vote = Vote.find(params[:id])\n\n respond_to do |format|\n if @vote.update_attributes(params[:vote])\n flash[:notice] = 'Vote was successfully updated.'\n format.html { redirect_to(@vote) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vote.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_voter\n\t\t@voter = Voter.find_by_id(params[:id])\n\t\tif @voter.nil?\n\t\t\tredirect_to main_app.admin_voters_path, alert: I18n.t(\"activerecord.errors.models.voter.not_found\")\n\t\tend\n\tend", "def update\n @optician = Optician.find(params[:id])\n\n respond_to do |format|\n if @optician.update_attributes(params[:optician])\n format.html { redirect_to @optician, notice: 'Optician was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @optician.errors, status: :unprocessable_entity }\n end\n end\n end", "def voter_find(voter)\n @voters.each do |voter1|\n if voter1[:name] == voter\n puts \"What would you like to update?\"\n puts \"(N)ame or (A)ffiliation?\"\n specific = gets.chomp.downcase\n if specific == \"n\"\n puts \"What is the voter's new name?\"\n voter1[:name] = gets.chomp.downcase\n elsif specific == \"a\"\n puts \"What is the voter's new affiliation?\"\n voter1[:affiliation] = gets.chomp.downcase\n end\n end\n end\n end", "def update\n if student_signed_in?\n update_for_student\n elsif teacher_signed_in?\n update_for_teacher\n end\n end", "def update\n\n end", "def update\n @vpn = current_user.vpn\n\n respond_to do |format|\n if @vpn.update_attributes(params[:vpn])\n format.html { redirect_to vpn_path, notice: 'Vpn was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vpn.errors, status: :unprocessable_entity }\n end\n end\n end", "def vote(vtr, value)\n\n original_points = self.point #Record original points to update user \n\n #Check that voter is not self's voter \n return nil if vtr == self.voter\n\n vt = Vote.where(voter_id:vtr.id, voteable_id:self.id).first\n if vt && vt.vote == value\n unvote(vtr,vt)\n return nil\n elsif vt\n self.point -= self.class.options(vt.vote) #Remove old vote points\n vtr.reputation -= self.class.vtback(vt.vote)\n else\n self.count += 1\n vt = Vote.new(voter_id:vtr.id, voteable_id:self.id)\n votes << vt\n end\n\n case value\n when :up ; self.up += 1\n when :down ; self.down += 1\n end\n\n self.point += self.class.options(value) #Add new vote points\n vtr.reputation += self.class.vtback(value)\n self.save\n vtr.save\n\n #Update votee reputation\n self.voter.reputation += self.point - original_points\n self.voter.save\n\n # Set vote to up or down\n vt.vote= value\n vt.save\n return vt\n end", "def update\n @volunteer = Volunteer.find(params[:id])\n\n respond_to do |format|\n if @volunteer.update_attributes(params[:volunteer])\n format.html { redirect_to @volunteer, notice: 'Volunteer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @volunteer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n puts \"\n Who do you want to update: (Politician or Person)\"\n update_input= gets.chomp.downcase\n\n if update_input == \"politician\"\n Politician.update_politician\n elsif update_input == \"person\"\n Person.update_person\n else\n update\n\n end #end of if\nend", "def update\n @travel = Travel.find(params[:travel_id])\n @itinerary = @travel.itineraries.find(params[:id])\n\n respond_to do |format|\n if @itinerary.update_attributes(itinerary_param)\n format.html { redirect_to([:admin, @travel, @itinerary], :notice => 'Itinerary was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @itinerary.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :manage, Pupil\n respond_to do |format|\n if @pupil.update(pupil_attrs)\n format.html { redirect_to @pupil, notice: t('action.update.succeed', entity: Pupil.model_name.human) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pupil.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @vote.update(vote_params)\n format.html { redirect_to @vote, notice: 'Vote was successfully updated.' }\n format.json { render :show, status: :ok, location: @vote }\n else\n format.html { render :edit }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @vote.update(vote_params)\n format.html { redirect_to @vote, notice: 'Vote was successfully updated.' }\n format.json { render :show, status: :ok, location: @vote }\n else\n format.html { render :edit }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @vote.update(vote_params)\n format.html { redirect_to @vote, notice: 'Vote was successfully updated.' }\n format.json { render :show, status: :ok, location: @vote }\n else\n format.html { render :edit }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @vote.update(vote_params)\n format.html { redirect_to @vote, notice: 'Vote was successfully updated.' }\n format.json { render :show, status: :ok, location: @vote }\n else\n format.html { render :edit }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @bitotsav_volunteer.Team == session[:bitotsav] || session[:bitotsav] == \"Admins\"\n respond_to do |format|\n if @bitotsav_volunteer.update(bitotsav_volunteer_params)\n format.html { redirect_to @bitotsav_volunteer, notice: 'Volunteer was successfully updated.' }\n format.json { render :show, status: :ok, location: @bitotsav_volunteer }\n else\n format.html { render :edit }\n format.json { render json: @bitotsav_volunteer.errors, status: :unprocessable_entity }\n end\n \n end\n else\n redirect_to '/bitotsav/volunteers'\n end\n end", "def update\n respond_to do |format|\n if @voting.update(voting_params)\n format.html { redirect_to @voting, notice: 'Voting was successfully updated.' }\n format.json { render :show, status: :ok, location: @voting }\n else\n format.html { render :edit }\n format.json { render json: @voting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n redirect_to(root_url) && return unless current_user.can_edit_patient_laboratories?\n\n lab = Laboratory.find_by(id: params.permit(:id)[:id])\n lab.update!(lab_type: params.permit(:lab_type)[:lab_type],\n specimen_collection: params.permit(:specimen_collection)[:specimen_collection],\n report: params.permit(:report)[:report],\n result: params.permit(:result)[:result])\n History.lab_result_edit(patient: params.permit(:patient_id)[:patient_id],\n created_by: current_user.email,\n comment: \"User edited a lab result (ID: #{lab.id}).\")\n end", "def update\n\n end", "def update\n respond_to do |format|\n if @vote.update(vote_params)\n format.html { redirect_to @vote, notice: 'Vote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n end", "def update\r\n end", "def update\r\n end", "def update\r\n end", "def update\r\n end", "def update_citizen\n\t\tif @citizens.any?\n\t\t\tvoter_id = get_voter_id\n\t\t\tif citizen = @citizens.select{ |whose| whose.voter_id == voter_id }.pop\n\t\t\t\tcitizen.update_name\t\n\t\t\t\tcase citizen\n\t\t\t\twhen Person then citizen.update_politics\n\t\t\t\twhen Politician then citizen.update_party\t\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tputs \"Citizen not found!\"\n\t\t\tend\n\t\telse\n\t\t\tputs \"No citizens yet!\"\n\t\tend\n\tend", "def update # PATCH\n raise NotImplementedError\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\n\n end", "def update\r\n\r\n end", "def update\n @fundamental_alliance_leader_vote = Fundamental::AllianceLeaderVote.find(params[:id])\n\n respond_to do |format|\n if @fundamental_alliance_leader_vote.update_attributes(params[:fundamental_alliance_leader_vote])\n format.html { redirect_to @fundamental_alliance_leader_vote, notice: 'Alliance leader vote was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fundamental_alliance_leader_vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @volunteer_offering = VolunteerOffering.find(params[:id])\n\n respond_to do |format|\n if @volunteer_offering.update_attributes(params[:volunteer_offering])\n flash[:notice] = 'VolunteerOffering was successfully updated.'\n format.html { redirect_to(@volunteer_offering) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @volunteer_offering.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\r\n end", "def update\n respond_to do |format|\n if @vote.update(vote_params)\n format.html { redirect_to @vote, notice: \"Vote was successfully updated.\" }\n format.json { render :show, status: :ok, location: @vote }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #if @visto.users.include?(current_user)\n # @visto.users.push(current_user)\n #else\n # @visto.users.delete(current_user)\n #end\n #if @visto.update({users:@visto.users})\n # redirect_to serial_chapter_path(@serial,@chapter)\n #else\n # render 'edit'\n #end\n end", "def update\n if (@user == @responsavel || admin_signed_in?)\n respond_to do |format|\n if @laboratorio.update(laboratorio_params)\n format.html { redirect_to @laboratorio, notice: 'Laboratorio was successfully updated.' }\n format.json { render :show, status: :ok, location: @laboratorio }\n else\n format.html { redirect_to laboratorios_url, notice: 'Sem permissão para editar laboratório.' }\n format.json { head :no_content }\n end\n end\n end\n end" ]
[ "0.7033077", "0.6857245", "0.6857245", "0.65347373", "0.6312179", "0.6284006", "0.62395316", "0.620653", "0.6136139", "0.6128933", "0.6108235", "0.6079499", "0.6053282", "0.6053282", "0.6053282", "0.6053282", "0.6047056", "0.6047056", "0.6047056", "0.6047056", "0.6047056", "0.6047056", "0.604675", "0.6043173", "0.60149974", "0.60088885", "0.60088885", "0.59694535", "0.59635174", "0.5940711", "0.59387827", "0.5935476", "0.5935476", "0.5934773", "0.59338266", "0.58984476", "0.5883172", "0.5881248", "0.5835115", "0.5832878", "0.58222467", "0.5814551", "0.5811152", "0.58108383", "0.5809643", "0.5809643", "0.5809643", "0.5809643", "0.5803919", "0.58030665", "0.58013546", "0.57754797", "0.5770804", "0.5770384", "0.5766142", "0.5766142", "0.5766142", "0.5766142", "0.5765829", "0.5762722", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758693", "0.5758662", "0.5755777", "0.5747489", "0.5745305", "0.57433486", "0.5740807", "0.5727286" ]
0.0
-1
These methods create a new voter or politician.
def create_option puts "Create new (P)olitician or (V)oter?".center(80) creation_type = verified_answer(gets.chomp.downcase, ["p", "v"]) if creation_type.downcase == "p" puts "Enter new politician details.".center(80) puts "NAME:".center(80) new_name = gets.chomp.downcase puts "PARTY AFFILIATION: (R)epublican or (D)emocrat?".center(80) new_party_affiliation = verified_answer(gets.chomp.downcase, ["d", "r"]) @politician_directory << Politician.new(new_name, whole_affil(new_party_affiliation)) list_politicians else puts "Enter new voter details.".center(80) puts "NAME:".center(80) new_name = gets.chomp.downcase puts """ POLITICAL VIEW: (L)iberal, (C)onservative, (T)ea Party, (S)ocialist, or (N)eutral.""".center(80) new_political_view = verified_answer(gets.chomp.downcase, ["l", "c", "t", "s", "n"]) @voter_directory << Voter.new(new_name, whole_views(new_political_view)) list_voters end puts "New record created.".center(80).green puts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def voter_politician_create(person)\n case person.downcase\n when \"v\"\n ask_name()\n name = gets.chomp\n ask_politics()\n politics = pick_politics()\n @world.create_voter(name, politics)\n restart()\n when \"p\"\n ask_name()\n name = gets.chomp\n ask_party()\n party = pick_party() \n @world.create_politician(name, party)\n restart()\n else \n restart()\n end\n end", "def create\n @voter = Voter.new(params[:voter])\n\n respond_to do |format|\n if @voter.save\n format.html { redirect_to @voter, notice: 'Voter was successfully created.' }\n format.json { render json: @voter, status: :created, location: @voter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @voter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @voter = Voter.new(voter_params)\n\n respond_to do |format|\n if @voter.save\n format.html { redirect_to @voter, notice: 'Voter was successfully created.' }\n format.json { render :show, status: :created, location: @voter }\n else\n format.html { render :new }\n format.json { render json: @voter.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\tputs \"\\nWhat would you like to create? (P)olitician or (V)oter\"\n\t\tpolitics = gets.chomp.upcase\n\t\tcase politics\n\t\twhen \"V\"\n\t\t\tvoter_creation\n\t\twhen \"P\"\n\t\t\tpolitician_creation\n\t\telse\n\t\t\tputs \"\\nSomething went wrong. Please select again\"\n\t\t\tcreate\n\t\tend\n\t\tmain_menu\n\tend", "def create_person_or_politician\n print \"Would you like to create a Voter or Candidate? \"\n main_decision = gets.chomp.downcase\n main_decision = main_decision[0]\n case main_decision\n # Voter chosen\n #################################################################\n when \"v\"\n print \"Name: \"\n @name = gets.chomp\n choose_party\n choose_politics\n @voters.push(Voter.new(@name, @party, @politics)) # Not sure if correct\n main_selector\n # Candidate chosen\n #################################################################\n when \"c\"\n print \"Name: \"\n @name = gets.chomp\n choose_party\n @candidates.push(Candidate.new(@name, @party))\n main_selector\n else\n puts \"That is not a valid entry please try again!\"\n create_person_or_politician\n end\n end", "def create\n @vote = Vote.new vote_params\n @vote.user = current_user\n if @vote.save\n @vote.votable.create_trophy_if_warranted\n end\n respond_with @vote\n end", "def create\n puts \"(V)oter or (P)olitician\"\n options = gets.chomp.downcase # voter or politician\n case(options)\n when \"v\"\n voterclass\n when \"p\"\n politicianclass\n end\n end", "def create(create_choice)\n if create_choice == \"v\"\n puts \"What is the voter's name?\"\n name = gets.chomp.downcase\n puts \"What is the voter's affiliation?\"\n puts \"\"\n puts \"Democratic, Republican, or Other\"\n affiliation = gets.chomp.downcase\n @voters << Voter.new(name, affiliation).data_hash\n puts \"Saved!\"\n elsif create_choice == \"p\"\n puts \"What is the politician's name?\"\n name = gets.chomp.downcase\n puts \"What is the politician's affiliation?\"\n puts \"\"\n puts \"Democratic, Republican, or Other\"\n affiliation = gets.chomp.downcase\n @politicians << Politician.new(name, affiliation).data_hash\n puts \"Saved!\"\n end\n end", "def create\n @politician = Politician.new(politician_params)\n\n respond_to do |format|\n if @politician.save\n format.html { redirect_to @politician, notice: 'Politician was successfully created.' }\n format.json { render :show, status: :created, location: @politician }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @politician.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vote = Vote.new(:voteable_id => params[:voteable_id], :voteable_type => params[:voteable_type], :user => User.find(params[:user_id]))\n authorize! :create, @vote\n\n respond_to do |format|\n if @vote.save\n format.html { redirect_to @vote, notice: 'Vote was successfully created.' }\n format.json { render json: @vote, status: :created, location: @vote }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_vote\n \t\t#self.votes.create(value: 1, user: self.user )\n \t#\tvotes.create(value: 1, user: user )\n\t \tuser.votes.create(value: 1, post: self)\n \tend", "def create\n @admins_politician = Admins::Politician.new(admins_politician_params)\n\n respond_to do |format|\n if @admins_politician.save\n format.html { redirect_to @admins_politician, notice: 'Politician was successfully created.' }\n format.json { render :show, status: :created, location: @admins_politician }\n else\n format.html { render :new }\n format.json { render json: @admins_politician.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vote = current_user.votes.build(vote_params)\n if @vote.save\n redirect_to @vote, notice: 'Vote was successfully submitted'\n else\n render action: 'new'\n end\n end", "def create\n @vote = @votable.votes.new(vote_params)\n\n respond_to do |format|\n if @vote.save\n format.html { redirect_to build_path_vote(@vote), notice: 'Vote was successfully created.' }\n format.json { render action: 'show', status: :created, location: @vote }\n else\n format.html { render action: 'new' }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n puts \"What type of character would you like to create?\"\n puts \"(1) Politician, (2) Voter\"\n create_choice = gets.chomp.to_i\n if create_choice == 1\n puts \"What is the politician's name?\"\n name = gets.chomp\n puts \"Party? (1) Republican, (2) Democrat\"\n party = gets.chomp.to_i\n if party == 1\n party = \"Republican\"\n elsif party == 2\n party = \"Democrat\"\n else\n puts \"Invalid selection\"\n create\n end\n add_politician(name, party)\n elsif create_choice == 2\n puts \"What is the voter's name?\"\n name = gets.chomp\n puts \"What is the voter's political affiliation?\"\n Voter.affiliation\n affiliation = gets.chomp\n add_voter(name, affiliation)\n else\n puts \"Invalid selection. Try again\"\n create\n end\n start\n end", "def create_vote\n\t\tuser.votes.create(value: 1, post: self)\n\tend", "def create\n # Create election from parameters\n @election = Election.new(params[:election])\n user_id = params[:election][:user_id]\n if user_id == \"\"\n flash[:error] = \"You may choose owner for election\"\n redirect_back_or_default(:action => 'new')\n return\n end\n @election.owner = ::User.find(user_id)#current_user\n\n faculty_id = params[:election][:faculty_id]\n # validate\n if faculty_id == \"\"\n flash[:error] = \"You may choose faculty for election\"\n redirect_back_or_default(:action => 'new')\n return\n end\n\n faculty_num = Faculty.find(@election.faculty_id).num\n\n # Get votes by faculty\n voters = Array.new\n voters = ::User.find_users_by_faculty(faculty_num)\n\n # Validates existence of voters\n if voters.empty?\n flash[:error] = \"The are no registered students on a faculty\"\n redirect_back_or_default(:action => 'new')\n return\n end\n\n # Create voting ballots\n ballots = Array.new\n voters.each do |voter|\n ballot = Ballot.new_from_params(voter, @election)\n ballots << ballot\n end\n\n # Save the records to the database\n begin\n Election.transaction do\n @election.save!\n ballots.each {|b| b.save!}\n end\n rescue Exception\n render :action => :new and return\n end\n\n flash[:notice] = \"Election created successfully\"\n redirect_to(object_url(@election))\n end", "def create_vote\n user.votes.create(value: 1, post: self)\n end", "def create_vote\r\n\t\tuser.votes.create(value: 1, post: self)\r\n\tend", "def create\n @vote = Vote.new\n end", "def vote!(itinerario)\n votatos.create!(itinerario_id: itinerario.id)\n end", "def set_voter\n @voter = Voter.find(params[:id])\n end", "def set_voter\n @voter = Voter.find(params[:id])\n end", "def create\n votes = params[:vote]\n voter = params[:voter_id]\n\n if votes\n votes.each do |k,v|\n @vote = Vote.new({:voter_id => voter,\n :position_id => v,\n :candidate_id => k })\n @vote.save\n end\n end\n\n\n redirect_to '/vote'\n\n #respond_to do |format|\n #if @vote.save\n #format.html { redirect_to @vote, notice: 'Vote was successfully created.' }\n #format.json { render json: @vote, status: :created, location: @vote }\n #else\n #format.html { render action: \"new\" }\n #format.json { render json: @vote.errors, status: :unprocessable_entity }\n #end\n #end\n end", "def create\n @teacher = Teacher.new(params[:teacher])\n<<<<<<< HEAD\n @vote = @teacher.votes.build(params[:vote])\n @vote.user_id = current_user.id\n @vote.teacher_id = @teacher.id\n=======\n>>>>>>> dca75f7c24244f2a9b84649ee8642ecab0988738\n\n respond_to do |format|\n if @teacher.save\n format.html { redirect_to @teacher, notice: 'Teacher was successfully created.' }\n format.json { render json: @teacher, status: :created, location: @teacher }\n else\n format.html { render action: \"new\" }\n format.json { render json: @teacher.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_vote\n\t\tif logged_in?\n\t\t\t@vote = Vote.find_by(user_id: current_user.id, complaint_id: params[:id])\n\n\t\t\t#check if vote already exists or not\n\n\t\t\tif @vote == nil\n\t\t\t\t@vote = Vote.new(vote_params)\n\t\t\t\trespond_to do |format|\n\t\t\t\t if @vote.save\n\t\t\t\t format.html { redirect_to complaint_path, notice: 'Successfully Voted' }\n\t\t\t\t format.json { render json: {\"success\" => 1}}\n\t\t\t\t else\n\t\t\t\t format.html { render :new }\n\t\t\t\t format.json { render json: {\"success\" => 0}}\n\t\t\t\t end\n\t\t\t end\t\n\t\t\telse\n\t\t\t respond_to do |format|\n\t\t\t\t if @vote.update_attributes(vote_params)\n\t\t\t\t format.html { redirect_to complaint_path, notice: 'Vote was successfully updated.' }\n\t\t\t\t format.json {render json: {\"success\" => 1}}\n\t\t\t\t else\n\t\t\t\t format.html { render :edit }\n\t\t\t\t format.json { render json: @vote.errors, status: :unprocessable_entity }\n\t\t\t\t end\n\t\t\t\tend\n\t \tend\n \telse\n\t \trespond_to do |format|\n\t\t format.html {redirect_to login_path}\n\t\t format.json {render json: {\"success\" => 0}}\n\t \tend\n\t \tend\n \tend", "def create\n @vote = Vote.new(params[:vote])\n if user_signed_in?\n @vote.user_id = current_user.id\n @vote.save\n redirect_to root_path\n else\n @vote.user_id = nil # explicitly assign nil to prevent injection\n @vote.save\n redirect_to new_user_registration_path(vote_id: @vote.id, label: @vote.chicken ? 'cobra' : 'chicken')\n end\n end", "def create_vote\n self.user.votes.create(value: 1, post: self)\n end", "def create_vote\n self.user.votes.create(value: 1, post: self)\n end", "def create\n\t\tif @question.vote_not_present?(current_user)\n vote = @question.votes.new\n vote.user = current_user\n end\n if vote.save\n render json: { success: true,message: \"Vote has Successfully Created.\"},:status=>200\n else\n render :json=> { success: false, message: \"Questions are not present\" },:status=> 203\n end\n\tend", "def create_vote\n user.votes.create(value: 1, post: self)\n end", "def create\n @vip_privilege = VipPrivilege.new(vip_privilege_params)\n\n respond_to do |format|\n if @vip_privilege.save\n format.html { redirect_to @vip_privilege, notice: 'Vip privilege was successfully created.' }\n format.json { render action: 'show', status: :created, location: @vip_privilege }\n else\n format.html { render action: 'new' }\n format.json { render json: @vip_privilege.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_technician\n @technician = Technician.new(params[:technician])\n if @technician.save\n redirect_to technician_show_path\n else\n flash[:notice] = \"Please enter Technician Name\"\n render technician_new_path\n end\n end", "def create_vote\n user.answer_votes.create(value: 1, answer: self)\n end", "def create\n @voting = Voting.new(voting_params)\n\n respond_to do |format|\n if @voting.save\n format.html { redirect_to @voting, notice: 'Voting was successfully created.' }\n format.json { render :show, status: :created, location: @voting }\n else\n format.html { render :new }\n format.json { render json: @voting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vote = Vote.new(vote_params)\n\n respond_to do |format|\n if @vote.save\n\n tracker = Generic.get_mixpanel_tracker\n tracker.track(vote_params[:user_id], 'Vote')\n\n Generic.send_notificatioin(params[:vote][:user_id], 'חבר/ה שלך הצביע/ה באפליקציית iVote.')\n\n format.html { redirect_to @vote, notice: 'Vote was successfully created.' }\n format.json { render :show, status: :created, location: @vote }\n else\n format.html { render :new }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_vote\n user.answer_votes.create(value: 1, answer: self)\n end", "def create\n @volunteer = Volunteer.new(params[:volunteer])\n @volunteer.status = \"New\"\n \n respond_to do |format|\n if @volunteer.save\n @volunteer.orientation.numCurrParticipant = @volunteer.orientation.numCurrParticipant + 1\n\[email protected]\n format.html { \n redirect_to @volunteer, \n notice: \"Volunteer was successfully created.\" }\n format.json { \n render json: @volunteer, status: :created, location: @volunteer }\n else\n format.html { render action: \"new\" }\n format.json { \n render json: @volunteer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vote_candidate = VoteCandidate.new(vote_candidate_params)\n authorize @vote_candidate\n\n respond_to do |format|\n if @vote_candidate.save\n format.html { redirect_to @vote_candidate, notice: 'Vote candidate was successfully created.' }\n format.json { render :show, status: :created, location: @vote_candidate }\n else\n format.html { render :new }\n format.json { render json: @vote_candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vote = Vote.new(params[:vote])\n\n respond_to do |format|\n if @vote.save\n format.html { redirect_to @vote, notice: 'Vote was successfully created.' }\n format.json { render json: @vote, status: :created, location: @vote }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vote = Vote.new(params[:vote])\n\n respond_to do |format|\n if @vote.save\n format.html { redirect_to @vote, notice: 'Vote was successfully created.' }\n format.json { render json: @vote, status: :created, location: @vote }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @technician = Technician.new(params[:technician])\n\n respond_to do |format|\n if @technician.save\n format.html { redirect_to(@technician, :notice => 'Technician was successfully created.') }\n format.xml { render :xml => @technician, :status => :created, :location => @technician }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @technician.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @vote = Vote.new(params[:vote].merge(:user => current_user))\n\n respond_to do |format|\n if @vote.save\n format.html { redirect_to(@vote, :notice => 'Vote was successfully created.') }\n format.xml { render :xml => @vote, :status => :created, :location => @vote }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @vote.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @vote = @change.votes.new(params[:vote])\n\n respond_to do |format|\n if @vote.save\n flash[:notice] = t('votes.new.success')\n format.html { priority_change_vote(@priority,@change,@vote) }\n else\n format.html { render :action => \"new\" }\n end\n end\n end", "def create\n @type= params[:type]\n @student= current_user\n @position = Position.where(position_type: @type)\n @position.each do |pos|\n if !params[pos.name].nil?\n @candidate = Candidate.find_by_name(params[pos.name])\n @vote = current_user.votes.build(position_id: pos.id, candidate_id: @candidate.id) \n redirect_to(root_path) and flash[:error] = \"Something went wrong and your vote was not created!\" unless @vote.save\n end\n end\n change_type\n sign_in @student\n redirect_to root_path\n flash[:notice]= \"Your vote has been created! Thanks for voting!\"\n end", "def cast_vote(politician)\n \tif ((self.is_a? Voter) && !(self.is_a? Politician) && (self.voted == false))\n \t\tif politician.party == \"Democrat\"\n \t if ((self.politics == \"Socialist\") && ((1..90).include? rand(100) + 1))\n self.voted = true\n return true\n \t\t\tend\n \t\t\tif ((self.politics == \"Liberal\") && ((1..75).include? rand(100) + 1))\n self.voted = true\n return true\n \t\t\tend\n \t\t\tif ((self.politics == \"Neutral\") && ((1..50).include? rand(100) + 1)) \t\n self.voted = true\n return true\n \t\t\tend\n \t\t\tif ((self.politics == \"Conservative\") && ((1..25).include? rand(100) + 1))\n self.voted = true\n return true\n \t\t\tend\n \t\t\tif ((self.politics == \"Tea Party\") && ((1..10).include? rand(100)+ 1))\n self.voted = true\n return true\n \t\t\tend\n \t\telsif politician.party == \"Republican\"\n \t\t\tif ((self.politics == \"Tea Party\") && ((1..90).include? rand(100) + 1))\n self.voted = true\n return true\n \t\t\tend\n \t\t\tif ((self.politics == \"Conservative\") && ((1..75).include? rand(100) + 1))\n self.voted = true\n return true\n \t\t\tend\n \t\t\tif ((self.politics == \"Neutral\") && ((1..50).include? rand(100) + 1))\n self.voted = true\n return true\n \t\t\tend\n \t\t\tif ((self.politics == \"Liberal\") && ((1..25).include? rand(100) + 1))\n self.voted = true\n return true\n \t\t\tend\n \t\t\tif ((self.politics == \"Socialist\") && ((1..10).include? rand(100)+ 1))\n self.voted = true\n return true\n \t\t\tend\n \t\tend \n \telsif ((self.is_a? Voter) && (self.is_a? Politician))\n \t\tif self == politician\n self.voted = true\n \t\t\treturn true \n \t\tend \n else \n return false\n end\n end", "def cast_vote(politician)\n \tif ((self.is_a? Voter) && !(self.is_a? Politician) && (self.voted == false))\n \t\tif politician.party == \"Democrat\"\n \t if ((self.politics == \"Socialist\") && ((1..90).include? rand(100) + 1))\n self.voted = true\n return true\n \t\t\tend\n \t\t\tif ((self.politics == \"Liberal\") && ((1..75).include? rand(100) + 1))\n self.voted = true\n return true\n \t\t\tend\n \t\t\tif ((self.politics == \"Neutral\") && ((1..50).include? rand(100) + 1)) \t\n self.voted = true\n return true\n \t\t\tend\n \t\t\tif ((self.politics == \"Conservative\") && ((1..25).include? rand(100) + 1))\n self.voted = true\n return true\n \t\t\tend\n \t\t\tif ((self.politics == \"Tea Party\") && ((1..10).include? rand(100)+ 1))\n self.voted = true\n return true\n \t\t\tend\n \t\telsif politician.party == \"Republican\"\n \t\t\tif ((self.politics == \"Tea Party\") && ((1..90).include? rand(100) + 1))\n self.voted = true\n return true\n \t\t\tend\n \t\t\tif ((self.politics == \"Conservative\") && ((1..75).include? rand(100) + 1))\n self.voted = true\n return true\n \t\t\tend\n \t\t\tif ((self.politics == \"Neutral\") && ((1..50).include? rand(100) + 1))\n self.voted = true\n return true\n \t\t\tend\n \t\t\tif ((self.politics == \"Liberal\") && ((1..25).include? rand(100) + 1))\n self.voted = true\n return true\n \t\t\tend\n \t\t\tif ((self.politics == \"Socialist\") && ((1..10).include? rand(100)+ 1))\n self.voted = true\n return true\n \t\t\tend\n \t\tend \n \telsif ((self.is_a? Voter) && (self.is_a? Politician))\n \t\tif self == politician\n self.voted = true\n \t\t\treturn true \n \t\tend \n else \n return false\n end\n end", "def create\n if(Post.find(params[:post_vote][:post_id]).user_id != params[:post_vote][:user_id]) # only vote if it's not the same user who wrote the post!\n @api_v1_post_vote=PostVote.find_by_post_id_and_user_id(params[:post_vote][:post_id], params[:post_vote][:user_id])\n if @api_v1_post_vote.nil?\n @api_v1_post_vote = PostVote.new(params[:post_vote])\n else\n @api_v1_post_vote.vote = params[:post_vote][:vote]\n end\n\n respond_to do |format|\n if @api_v1_post_vote.save\n #format.html { redirect_to @api_v1_post_vote, notice: 'Post vote was successfully created.' }\n format.json { render json: @api_v1_post_vote, status: :created }\n else\n # format.html { render action: \"new\" }\n format.json { render json: @api_v1_post_vote.errors.messages.values, status: 400 }\n end\n end\n else\n render json: \"Can't vote for yourself.\", status: 400\n end\n end", "def create\n @voting = Voting.new(voting_params)\n\n respond_to do |format|\n if @voting.save\n flash[:success] = 'Voting was successfully created.'\n format.html { redirect_to votings_path }\n format.json { render :show, status: :created, location: @voting }\n else\n format.html { render :new }\n format.json { render json: @voting.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_vote(vote, votable, voter)\n vote == 'up' ? votable.upvote_by(voter) : votable.downvote_by(voter)\n change_carma(vote, votable, voter,\n ex_up: 2, ex_down: -1, ph_up: 4, ph_down: -2, usr: 1)\n flash[:notice] = 'Thank you for your vote.'\n end", "def create\n @pv = Pv.new(pv_params)\n @pv.proyect = @proyect\n\n respond_to do |format|\n if @pv.save\n format.html { redirect_to proyect_pv_path(@proyect,@pv), notice: 'Propuesta de Valor ha sido creada.' }\n format.json { render :show, status: :created, location: @pv }\n else\n format.html { render :new }\n format.json { render json: @pv.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vote = Vote.new(vote_params)\n\n respond_to do |format|\n if @vote.save\n format.html { redirect_to @vote, notice: 'Vote was successfully created.' }\n format.json { render :show, status: :created, location: @vote }\n else\n format.html { render :new }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vote = Vote.new(vote_params)\n\n respond_to do |format|\n if @vote.save\n format.html { redirect_to @vote, notice: 'Vote was successfully created.' }\n format.json { render :show, status: :created, location: @vote }\n else\n format.html { render :new }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vote = Vote.new(vote_params)\n\n respond_to do |format|\n if @vote.save\n format.html { redirect_to @vote, notice: 'Vote was successfully created.' }\n format.json { render :show, status: :created, location: @vote }\n else\n format.html { render :new }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @idea = Idea.find(params[:idea_id])\n @vote = @idea.votes.new(params[:vote])\n @vote.username = current_user.to_s\n respond_to do |format|\n if @vote.save \n format.json { render json: @vote, status: :created, location: @vote }\n else \n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @election = Election.find(params[:election][:id])\n\n @ballot = Ballot.new\n @election.ballots << @ballot\n\n if params[:commit] == \"Spoil Ballot\"\n @ballot.votes << Vote.new(:choice_id => 0, :result => 1, :election_id => @election.id)\n elsif @election.method == \"single_choice\"\n @ballot.votes << Vote.new(:choice_id => params[:vote_single][:choice_id], :result => 1, :election_id => @election.id)\n else #preferential and multiple choice elections\n \t @votes = @election.votes.build params[:vote].values\n @votes.each do |v|\n v.ballot_id = @ballot.id\n #@votes = @ballot.votes.build params[:vote].values\n end\n\n @election.voters << current_voter\n\n if @election.save\n if params[:commit] == \"Spoil Ballot\"\n flash[:notice] = 'Ballot was succesfully spoiled.'\n else\n flash[:notice] = 'Vote was successfully cast.'\n end\n redirect_to(\"/\")\n else\n render :action => \"new\"\n end\n\n end\n\nend", "def create\n @optician = Optician.new(params[:optician])\n\n respond_to do |format|\n if @optician.save\n format.html { redirect_to @optician, notice: 'Optician was successfully created.' }\n format.json { render json: @optician, status: :created, location: @optician }\n else\n format.html { render action: \"new\" }\n format.json { render json: @optician.errors, status: :unprocessable_entity }\n flash.now[:error] = \"Invalid name/password combination.\" \n end\n end\n end", "def create\n is_logged\n @vote = Vote.new(vote_params)\n @user = current_user\n respond_to do |format|\n if @vote.save\n if @vote.id_tour == 1\n @user.tour1 = 1\n @vote.save\n @user.save\n\n format.html { redirect_to root_path, notice: 'Votre vote a été pris en compte' }\n format.json { render :show, status: :created, location: root_path }\n\n elsif @vote.id_tour == 2\n @user.tour2 = 1\n @vote.save\n @user.save\n\n format.html { redirect_to root_path, notice: 'Votre vote a été pris en compte' }\n format.json { render :show, status: :created, location: root_path }\n\n else\n format.html { render :new }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n @vote = @parent.votes.new\n# change this later for user login feature\n @vote.user_id = session[:user_id]\n\n respond_to do |format|\n if @vote.save\n @vote.update_post\n format.html { redirect_to :back, notice: 'Vote was successfully created.' }\n format.json { render json: @vote, status: :created, location: @vote }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vote = @retort.votes.new(params[:vote])\n @vote.user = current_user\n\n respond_to do |format|\n if @vote.save\n flash[:notice] = 'Vote was successfully created.'\n format.html { redirect_to(@retort) }\n format.xml { render :xml => @vote, :status => :created, :location => [@retort, @vote] }\n else\n flash[:error] = 'Vote could not be created.'\n format.html { redirect_to(@retort) }\n format.xml { render :xml => @vote.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new_vote(new_vote,voter_name)\n # puts \"iNSERT NEW VOTES WITH VOTES #{new_vote.inspect}\"\n\n self.votes = Array.new\n hash = Hash.new\n hash[new_vote] = voter_name\n self.votes << hash\n new_pg_vote(self.votes,self)\n\n end", "def create\n @patient = Patient.find_existing(patient_params)\n @patient ||= Patient.new(patient_params)\n if @patient.save\n @patient.patient_caretakers.find_or_create_by(user_id: current_user.id, \n role: current_user.title)\n redirect_to(@patient)\n else\n render :new\n end\n end", "def create\n @protectora = Protectora.new(params[:protectora])\n\n respond_to do |format|\n if @protectora.save\n format.html { redirect_to @protectora, notice: 'Protectora was successfully created.' }\n format.json { render json: @protectora, status: :created, location: @protectora }\n else\n format.html { render action: \"new\" }\n format.json { render json: @protectora.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @przedmiot = Przedmiot.new(params[:przedmiot])\n @przedmiot.user_id = current_user.id\n respond_to do |format|\n if @przedmiot.save\n format.html { redirect_to @przedmiot, notice: 'Przedmiot został dodany.' }\n format.json { render json: @przedmiot, status: :created, location: @przedmiot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @przedmiot.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n # Not generally used. Most people want to vote via AJAX calls.\n end", "def create\n @vote = Vote.new(params[:vote])\n @vote.user_id = current_user.id\n if @vote.save\n @vote.vote_options.each do |option_name|\n next if option_name.blank?\n VoteOption.create(:title => option_name,:voter_id => @vote.id)\n end\n flash[:notice] = 'Vote was successfully created.'\n redirect_to :action => :index\n else\n render :action => \"new\"\n end\n end", "def create\n @lector = Lector.new(params[:lector])\n\n respond_to do |format|\n if @lector.save\n format.html { redirect_to @lector, notice: 'El nuevo lector se ha guardado correctamente.' }\n format.json { render json: @lector, status: :created, location: @lector }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lector.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_user_and_participant\n @participant = Participant.new\n end", "def create\n @physician = Physician.new(params[:physician])\n\n respond_to do |format|\n if @physician.save\n format.html { redirect_to @physician, :notice => 'Physician was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @physician.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @tier = Tier.new(params[:tier])\n @tier.member = current_member\n\n respond_to do |format|\n if @tier.save\n if params[:endeavor_id]\n @tier.tierings.create :endeavor_id => params[:endeavor_id]\n end\n format.html { redirect_to @tier, :notice => \"Your #{current_member.tiers.count.ordinalize} tier.\" }\n format.json { render :json => @tier, :status => :created, :location => @tier }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @tier.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @vote = Vote.find_or_initialize_by(vote_params)\n if @vote.persisted?\n @vote.deleted = [email protected]\n end\n\n respond_to do |format|\n if @vote.save\n format.json { render :show, status: :created, location: @vote }\n else\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @physician = Physician.new(params[:physician])\n\n respond_to do |format|\n if @physician.save\n format.html { redirect_to @physician, :notice => 'Physician was successfully created.' }\n format.json { render :json => @physician, :status => :created, :location => @physician }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @physician.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @vpn = current_user.build_vpn(params[:vpn])\n\n respond_to do |format|\n if @vpn.save\n format.html { redirect_to vpn_path, notice: 'Vpn was successfully created.' }\n format.json { render json: @vpn, status: :created, location: @vpn }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vpn.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vote = Vote.new(vote_params)\n if vote_params['positive'] == 'true'\n @vote.positive = true\n elsif\n vote_params['positive'] == 'false'\n @vote.positive = false\n end\n\n @vote.player ||= @player\n\n respond_to do |format|\n if @vote.save\n format.html { redirect_to new_vote_path(fbuid: @vote.player.fbuid, prev_vote: @vote)}\n format.json { render action: 'show', status: :created, location: @vote }\n else\n format.html { render action: 'new' }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipp = Tipp.new(params[:tipp])\n \[email protected] = current_user.name\n respond_to do |format|\n if @tipp.save\n format.html { redirect_to(current_user, :notice => 'Tipp was successfully created.') }\n format.xml { render :xml => @tipp, :status => :created, :location => @tipp }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tipp.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_answer_votes\n\t\tif @answer.vote_not_present?(current_user)\n vote = @answer.votes.new\n vote.user = current_user\n end\n if vote.save\n render json: { success: true,message: \"Vote Successfully Created.\"},:status=>200\n else\n render :json=> { success: false, message: \"Answers are not present\" },:status=> 203\n end\n\tend", "def create\n # Crear nuevo voto\n @voto = Voto.new(params[:voto])\n\n # Asociarlo con el usuario\n @voto.usuario_id = current_usuario.id\n\n # Asociarlo con la Pregunta o Respuesta\n votable_type = params[:voto][:votable_type]\n votable_id = params[:voto][:votable_id]\n if votable_type=='Pregunta'\n @voto.votable = Pregunta.find(votable_id)\n else\n @voto.votable = Respuesta.find(votable_id)\n end\n\n respond_to do |format|\n if @voto.save\n resp = {\n :votos_total => @voto.votable.votos_total,\n :votos_menos => @voto.votable.votos_menos,\n :votos_mas => @voto.votable.votos_mas\n }\n format.json { render json: resp, status: :created, location: @voto }\n else\n format.json { render json: @voto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @subscriber = Subscriber.where(openid: volunteer_params[:openid]).first\n if @subscriber.present?\n @volunteer = Volunteer.find_or_create_by(subscriber: @subscriber)\n @volunteer.name = volunteer_params[:name]\n @volunteer.tel = volunteer_params[:tel]\n @volunteer.commun = volunteer_params[:commun]\n @volunteer.neighborhood = volunteer_params[:neighborhood]\n respond_to do |format|\n if @volunteer.save\n format.html { render \"volunteers/success\" }\n format.json { render :show, status: :created, location: @volunteer }\n else\n format.html { render :new }\n format.json { render json: @volunteer.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { render :new }\n format.json { render json: @volunteer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vote.proposal = @proposal\n @vote.user = current_user\n @comment = @proposal.comments.new\n\n respond_to do |format|\n if @vote.save\n InformCommitteeMembers.vote_submitted(@vote)\n format.html { redirect_to @proposal, notice: 'Vote was successfully created.' }\n format.json { render json: @proposal, status: :created, location: @proposal }\n else\n format.html { render \"proposals/show\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def voter_params\n params.require(:voter).permit(:name, :date_of_birth, :state, :voted)\n end", "def create\n @politician_approval = PoliticianApproval.new(politician_approval_params)\n\n respond_to do |format|\n if @politician_approval.save\n format.html { redirect_to @politician_approval, notice: 'Politician approval was successfully created.' }\n format.json { render :show, status: :created, location: @politician_approval }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @politician_approval.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n get_school\n get_vocational\n @school_vocational = @school.vocationals.new\n end", "def create\n @vet_profile = VetProfile.new(vet_profile_params)\n @vet_profile.vet_id = current_vet.id\n respond_to do |format|\n if @vet_profile.save\n format.html { redirect_to @vet_profile, notice: 'Vet profile was successfully created.' }\n format.json { render :show, status: :created, location: @vet_profile }\n else\n format.html { render :new }\n format.json { render json: @vet_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vote = Vote.new(params[:vote])\n\n respond_to do |format|\n if @vote.save\n format.html { redirect_to([:admin,@vote], :notice => 'Vote was successfully created.') }\n format.xml { render :xml => @vote, :status => :created, :location => @vote }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @vote.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n super\n if current_user != nil\n p = Privilege.new\n puts current_user.class\n p.user_id = current_user.id;\n p.role_id = Role.find_by_role_name(\"user\").id;\n p.save;\n end\n end", "def create\n @model_vote = ModelVote.new(model_vote_params)\n\n respond_to do |format|\n if @model_vote.save\n format.html { redirect_to @model_vote, notice: 'Model vote was successfully created.' }\n format.json { render :show, status: :created, location: @model_vote }\n else\n format.html { render :new }\n format.json { render json: @model_vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @trivium = Trivium.new(trivium_params.merge({user_id:current_user.id}))\n\n respond_to do |format|\n if @trivium.save\n format.html { redirect_to new_trivium_path, notice: 'Trivium was successfully created.' }\n format.json { render :show, status: :created, location: @trivium }\n else\n format.html { render :new }\n format.json { render json: @trivium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @election_type = ElectionType.new(params[:election_type])\n\n respond_to do |format|\n if @election_type.save\n format.html { redirect_to @election_type, notice: 'Election type was successfully created.' }\n format.json { render json: @election_type, status: :created, location: @election_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @election_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @curriculum_vitae = findable_curriculum_vitaes.new(curriculum_vitae_params)\n\n respond_to do |format|\n if @curriculum_vitae.save\n format.html { redirect_to @curriculum_vitae, notice: I18n.t('controllers.curriculum_vitaes.create.success') }\n format.json { render :show, status: :created, location: @curriculum_vitae }\n else\n format.html { render :new }\n format.json { render json: @curriculum_vitae.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @votacion = Votacion.new(votacion_params)\n @votacion.etapa = \"Previa a la votación.\"\n respond_to do |format|\n if @votacion.save\n format.html { redirect_to @votacion, notice: 'La votación se creo correctamente.' }\n format.json { render :show, status: :created, location: @votacion }\n else\n format.html { render :new }\n format.json { render json: @votacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cultivator = Cultivator.new(cultivator_params)\n\n respond_to do |format|\n if @cultivator.save\n format.html { redirect_to @cultivator, notice: 'Cultivator was successfully created.' }\n format.json { render :show, status: :created, location: @cultivator }\n else\n format.html { render :new }\n format.json { render json: @cultivator.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n vote = Vote.new\n @idea = Idea.find(params[:id])\n @idea.votes << vote\n @idea.save\n vote.save\n current_user.votes << vote\n current_user.save\n respond_to do |format|\n format.html\n format.js {}\n end\n end", "def create\n\n @vehicel = @user.vehicels.create(vehicel_params)\n respond_to do |format|\n if @vehicel.save\n format.html { redirect_to user_vehicels_path(@user, @vehicel) }\n format.json { render :show, status: :created, location: @vehicel }\n else\n format.html { render :new }\n format.json { render json: @vehicel.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @person = Person.new(params[:karteikarte][:person])\n @person.save\n\n @tier = Tier.new(params[:karteikarte][:tier])\n if params[:neue_behandlung] == \"true\"\n @tier.behandlungen << Behandlung.new\n end\n @tier.save\n\n @karteikarte = Karteikarte.new(:person_id => @person.id, :tier_id => @tier.id)\n @karteikarte.save\n\n render :action => :edit\n end", "def create\n @vote = Vote.new\n if params[:problem_id] && params[:vote_type] && params[:post_type]\n vote_exists = false\n author_vote = false\n @post_type = params[:post_type].to_s.downcase\n @post_id = params[:id]\n \n votetype = VoteType.find_by_name(params[:vote_type])\n @vote.vote_type = votetype\n @vote.user_id = session[:user_id]\n if params[:post_type] == \"Post\"\n @vote.post = Post.find_by_id(params[:id])\n @vote_object = @vote.post\n vote_exists = true unless Vote.where(\"post_id=#{params[:id]} AND user_id=#{session[:user_id]}\").blank?\n author_vote = true if @vote.user_id == @vote.post.user_id\n elsif params[:post_type] == \"Solution\"\n @vote.solution = Solution.find_by_id(params[:id])\n @vote_object = @vote.solution\n vote_exists = true unless Vote.where(\"solution_id=#{params[:id]} AND user_id=#{session[:user_id]}\").blank?\n author_vote = true if @vote.user_id == @vote.solution.user_id\n elsif params[:post_type] == \"Comment\"\n @vote.comment = Comment.find_by_id(params[:id])\n @vote_object = @vote.comment\n vote_exists = true unless Vote.where(\"comment_id=#{params[:id]} AND user_id=#{session[:user_id]}\").blank?\n author_vote = true if @vote.user_id == @vote.comment.user_id\n else\n @vote = Vote.new\n end\n if !vote_exists && !author_vote && @vote.save\n respond_to do |format|\n format.html { \n flash[:notice] = \"#{params[:post_type].to_s} Vote Successful\"\n redirect_to(:controller => 'posts', :action => 'show', :id => params[:problem_id])\n }\n format.js {\n @vote_failed = false\n @notice = \"Vote Successful\" \n }\n end\n else \n respond_to do |format|\n format.html { \n flash[:notice] = \"Vote Failed\"\n flash[:notice] += \". You have already voted on this #{@post_type}\" if vote_exists\n flash[:notice] += \". You cannot vote on a #{@post_type} that you created.\" if author_vote\n redirect_to(:controller => 'posts', :action => 'show', :id => params[:problem_id])\n }\n format.js {\n @vote_failed = true\n @notice = \"Vote Failed\"\n @notice += \". You have already voted on this #{@post_type}\" if vote_exists\n @notice += \". You cannot vote on a #{@post_type} that you created.\" if author_vote\n }\n end\n end\n else\n flash[:notice] = \"An error occured\"\n redirect_to(:controller => 'public', :action => 'index')\n end\n end", "def create\n @voc = Voc.new(params[:voc])\n @voc.user_id = current_user.id\n\n respond_to do |format|\n if @voc.save\n format.html { redirect_to @voc, notice: 'Voc was successfully created.' }\n format.json { render json: @voc, status: :created, location: @voc }\n else\n format.html { render action: \"new\" }\n format.json { render json: @voc.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @person = Person.new(params[:person])\n current_user.confirm(@person)\n\n #Atribui a filial do usuário corrente, caso o mesmo não seja administrador ou diretor\n @person.subsidiary = current_user.person.subsidiary if logged_in? && !current_user.is_director? && !current_user.is_administrator?\n\n respond_to do |format|\n if @person.save\n flash[:notice] = 'Pessoa criada com sucesso!'\n format.html { redirect_to(@person) }\n format.xml { render :xml => @person, :status => :created, :location => @person }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @emitted_vote = EmittedVote.new(emitted_vote_params)\n\n respond_to do |format|\n if @emitted_vote.save\n format.html { redirect_to @emitted_vote , notice: 'Emitted vote was successfully created.' }\n format.json { render 'show' , status: :created , location: @emitted_vote }\n else\n format.json { render json: @emitted_vote.errors , status: :unprocessable_entity }\n end\n end\n end", "def create\n name = params[\"patient_vaccination\"].delete(\"name\")\n patient = params[\"patient_vaccination\"].delete(\"patient_id\")\n @patient_vaccination = PatientVaccination.new(params[:patient_vaccination]) \n vacc = Vaccination.find_by_name(name)\n if !vacc\n vacc = Vaccination.new(:name => name)\n end\n @patient_vaccination.vaccination = vacc\n @patient_vaccination.patient = Patient.find(patient)\n \n APP_LOGGER_LOG.info \"VACCINATION CREATED - for PATIENT ID \" + \n @patient_vaccination.patient[:medical_record_number].to_s + \" by USER \" + self.current_user[:login]\n \n respond_to do |format|\n if @patient_vaccination.save\n flash[:notice] = \"The patient's vaccination was successfully created.\"\n format.html { redirect_to(patient_patient_vaccinations_path(@patient)) }\n format.xml { render :xml => @patient_vaccination, :status => :created, :location => @patient_vaccination }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @patient_vaccination.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @vote = Vote.new(params[:vote])\n\n respond_to do |format|\n if @vote.save\n format.html { redirect_to @vote, flash: { success: '投票创建成功。' } }\n format.json { render json: @vote, status: :created, location: @vote }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vote.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.79145575", "0.7381869", "0.7296676", "0.6968626", "0.69597816", "0.69418776", "0.6602408", "0.65851545", "0.6567758", "0.6473178", "0.637075", "0.6336152", "0.6316188", "0.63089055", "0.63049763", "0.6303649", "0.6271796", "0.6271324", "0.62332004", "0.62214303", "0.6211095", "0.62094027", "0.62094027", "0.6179425", "0.615958", "0.61556065", "0.61524254", "0.6140378", "0.6140378", "0.61362034", "0.6127794", "0.61177176", "0.6100507", "0.609253", "0.60786605", "0.60525984", "0.6039371", "0.6032061", "0.5996883", "0.5994025", "0.5994025", "0.59822273", "0.5981037", "0.5975637", "0.59571046", "0.5955853", "0.5955853", "0.5951801", "0.5943477", "0.59386355", "0.5936556", "0.5936486", "0.5935465", "0.5935465", "0.593524", "0.59331614", "0.5928918", "0.5916659", "0.59135157", "0.591065", "0.5908807", "0.5864147", "0.5853693", "0.58477634", "0.58450776", "0.58393276", "0.58335936", "0.58333933", "0.5831772", "0.5829735", "0.5829678", "0.5819285", "0.5815191", "0.57948154", "0.5785172", "0.57795626", "0.57782197", "0.57631254", "0.5736865", "0.5735209", "0.57292295", "0.57267237", "0.5726605", "0.57205254", "0.57204473", "0.5719458", "0.5718168", "0.57163817", "0.5715877", "0.5714573", "0.5711181", "0.5710874", "0.57089436", "0.57074213", "0.5706926", "0.57013434", "0.5700976", "0.56983", "0.5694662", "0.56884384" ]
0.6240167
18
These methods list records in the directory.
def list_option list_politicians list_voters puts puts "(R)eturn to the main menu?".center(80).green menu_return = gets end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @file_records = FileRecord.all\n end", "def index\n @file_records = FileRecord.all\n end", "def list\n call(:get, path)\n end", "def get_file_listing\n execute!(drive.files.list).data\n end", "def list\n Lib.list @path, @no_follow\n end", "def list(path='root')\n puts \"#list('#{path}')\"\n listed_files =[]\n @drive.folder = path\n children = @drive.children\n list_files_metadata(children)\n raise 'There are no files in directory' if children.count < 1\n children.each do |item|\n listed_files << \"#{item.path.gsub('/drive/', 'drive/')}/#{item.name}\" unless item.folder?\n end\n @logger.info 'Children list acquired.'\n pp listed_files\n end", "def cmd_list(param)\n send_unauthorised and return unless logged_in?\n send_response \"150 Opening ASCII mode data connection for file list\"\n\n param = '' if param.to_s == '-a'\n\n dir = File.join(@name_prefix.to_s, param.to_s)\n\n now = Time.now\n\n items = list_dir(build_path(param))\n lines = items.map do |item|\n \"#{item.directory ? 'd' : '-'}#{item.permissions || 'rwxrwxrwx'} 1 #{item.owner || 'owner'} #{item.group || 'group'} #{item.size || 0} #{(item.time || now).strftime(\"%b %d %H:%M\")} #{item.name}\"\n end\n send_outofband_data(lines)\n # send_action_not_taken\n end", "def file_list\n end", "def list(path, show_all)\n begin\n unless (@cmd.model[:public] + path).directory?\n return false\n end\n\n (@cmd.model[:public] + path).entries.each_with_object([]) do |entry, list|\n if show_all or not(entry.basename.start_with?(\".\"))\n list << {\n \"name\" => entry.basename,\n \"type\" => entry.directory? ? \"dir\" : \"file\",\n \"mtime\" => entry.mtime.iso8601,\n \"size\" => entry.size\n }\n end\n end\n rescue => e\n return nil\n end\n end", "def list\n FileOperations.find_all(self)\n end", "def list_records\n @stats[RECORDS_LISTING_KEY] = [] unless @stats[RECORDS_LISTING_KEY]\n @stats[RECORDS_LISTING_KEY] << ListField.new(RECORDS_LISTING_KEY,nil)\n end", "def list\n\t\t\tbegin\n\n\t\t\t\t# Prepare result, array of absolute paths for found files\n # within given directory. Also empty cache\n\t\t\t\tresult = []\n @scan_history = {}\n\n\t\t\t\t# Recursively scan current folder for files\n\t\t\t\tFind.find(@scan_path) do |current_full_path|\n\n\t\t\t\t\t# Get filename, prune if dot\n\t\t\t\t\tfilename = File.basename(current_full_path)\n Find.prune if filename[0] == ?.\n\n # Get extension\n extension = File.extname(current_full_path)\n\n\t\t\t\t\t# Check for file extension, if provided\n\t\t\t\t\tif @scan_extension && extension.eql?(@scan_extension)\n\n # Get foldername\n folder_name = File.dirname(current_full_path)\n\n # Get number of files parsed in current folder, default 0\n folder_depth = @scan_history.fetch(folder_name, nil) || 0\n Logging[self].debug \"At #{folder_name}\" if folder_depth == 0\n\n # If the desired depth hasn't been reached\n unless folder_depth == @scan_depth\n\n # Increase current depth\n folder_depth += 1\n\n # Add and log result\n Logging[self].warn \"Result: '#{current_full_path}'\"\n result << current_full_path\n\n # Update cache, proceed no further in this folder\n @scan_history[folder_name] = folder_depth\n Find.prune\n end\n\t\t\t\t\telse\n\t\t\t\t\t\n\t\t\t\t\t\t# Either move beyond this file, if we're searching\n\t\t\t\t\t\t# for specific files (filtered by extension), or add\n # the path to the result (since no filter applied)\n\t\t\t\t\t\t@scan_extension ? next : (result << current_full_path)\n\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\n end # find block\n\n # Log final result length\n Logging[self].info \"Retrieved #{result.length} results\"\n\n\t\t\t\t# Return result\n\t\t\t\tresult\n\n\t\t\t# Rescue any exceptions\n\t\t\trescue Exception => e\n\t\t\t\tLogging[self].error e\n nil\n\t\t\tend\n\t\tend", "def list(folder)\n\t\tc = 0\n\t\tfolder = '/' + folder\t\t\t\n\t\tresp = @client.metadata(folder)\n\t\tputs \"\\n List of contents in \" + folder + \"\\n\"\n\t\tfor item in resp['contents']\t\t\n\t\t\tputs item['path']\n\n\t\t\tc=c+1\n\t\tend\t\n\t\t\n\tend", "def recordings_list_stored\n get \"recordings/stored\"\n end", "def list\n BakFile.where('saved = ?', true).each do |file|\n Log.instance.info(\"#{file.fid},#{file.dkey},#{file.length},#{file.classname}\")\n break if SignalHandler.instance.should_quit\n end\n end", "def index\n @directories = Directory.all\n end", "def index\n @records = record_class.all\n end", "def generate_listing(path)\n client\n listing = client.list_objects(bucket: config[:bucket], delimiter: '/', prefix: full_path(path))\n add_directories(listing)\n add_files(listing, path)\n end", "def list\n items = storage.items\n if items.empty?\n puts 'No items in the list.'\n return\n end\n\n storage.items.each do |(id, data)|\n puts \"#{id} #{data[:stamp]} #{data[:source].ljust(48)}\"\n end\n end", "def list\n @file_list.to_a\n end", "def list\n client = get_dropbox_client\n unless client\n redirect_to(:action => 'auth_start') and return\n end\n @dropbox_docs = []\n path = \"/\"\n\n metadata = client.metadata(path, file_limit=25000, list=true, hash=nil, rev=nil, include_deleted=false)\n for dfile in metadata['contents']\n \tname = dfile['path']\n \t@dropbox_docs << name[1..-1]\n \tend\n \tgoogle_session = GoogleDrive.login_with_oauth(session[:google_token])\n \t@google_docs = []\n \tfor file in google_session.files\n \t\t@google_docs << file.title \n \tend\n #drivelist = get_dr.slice!(-)\n #render :inline => \"#{metadata['contents']} \\n\\n\\n\"\n #render json: metadata\n\n end", "def records\n @records ||= search.records\n end", "def ls( *args )\r\n \r\n directory = nil\r\n opts = {}\r\n \r\n case args.count\r\n when 1\r\n if args[0].kind_of? Hash\r\n opts = args[0]\r\n else\r\n directory = args[0]\r\n end\r\n when 2\r\n directory = args[0]\r\n opts = args[1] \r\n end\r\n \r\n # args are the RPC arguments ...\r\n args = {}\r\n args[:path] = directory if directory\r\n args[:recursive] = true if opts[:recurse]\r\n args[:detail] = true if opts[:detail] \r\n args.delete(:detail) if( args[:detail] and args[:recursive])\r\n \r\n # RPC output format, default is XML\r\n outf = { :format => 'text' } if opts[:format] == :text\r\n \r\n got = @ndev.rpc.file_list( args, outf )\r\n return nil unless got\r\n \r\n return got.text if opts[:format] == :text\r\n return got if opts[:format] == :xml\r\n \r\n # if we're here, then we need to conver the output \r\n # to a Hash. Joy!\r\n \r\n collect_detail = args[:detail] || args[:recursive]\r\n \r\n ls_hash = {}\r\n got.xpath('directory').each do |dir|\r\n \r\n dir_name = dir.xpath('directory-name').text.strip\r\n dir_hash = {}\r\n \r\n dir_hash[:fileblocks] = dir.xpath('total-file-blocks').text.to_i\r\n files_info = dir.xpath('file-information')\r\n \r\n dir_hash[:files] = {} \r\n dir_hash[:dirs] = {} # sub-directories\r\n \r\n files_info.each do |file|\r\n f_name = file.xpath('file-name').text.strip\r\n f_h = {} \r\n \r\n if file.xpath('file-directory')[0]\r\n dir_hash[:dirs][f_name] = f_h\r\n else\r\n dir_hash[:files][f_name] = f_h \r\n end\r\n \r\n next unless collect_detail\r\n \r\n f_h[:owner] = file.xpath('file-owner').text.strip\r\n f_h[:group] = file.xpath('file-group').text.strip\r\n f_h[:links] = file.xpath('file-links').text.to_i\r\n f_h[:size] = file.xpath('file-size').text.to_i\r\n \r\n xml_when_item(file.xpath('file-symlink-target')) { |i|\r\n f_h[:symlink] = i.text.strip\r\n }\r\n \r\n fp = file.xpath('file-permissions')[0]\r\n f_h[:permissions_text] = fp.attribute('format').value\r\n f_h[:permissions] = fp.text.to_i\r\n \r\n fd = file.xpath('file-date')[0]\r\n f_h[:date] = fd.attribute('format').value\r\n f_h[:date_epoc] = fd.text.to_i\r\n \r\n end # each directory file\r\n ls_hash[ dir_name ] = dir_hash \r\n end # each directory\r\n \r\n return nil if ls_hash.empty?\r\n ls_hash\r\n end", "def records\n @records ||= []\n end", "def index\n @records = Record.all\n end", "def index\n @records = Record.all\n end", "def index\n @records = Record.all\n end", "def index\n @records = Record.all\n end", "def index\n @records = Record.all\n end", "def list(keydir)\n\n # FIXME: insert code that connects to the backend and affects the list\n # operation\n #\n # - Convert any exceptions into a failed status result with a meaningful\n # error message.\n #\n\n { :result => nil, :err_msg => 'FIXME: not implemented' }\n end", "def ls\n Dir.entries(@working_dir)\n end", "def cmd_ls(*args)\n\t\tpath = args[0] || client.fs.dir.getwd\n\t\ttbl = Rex::Ui::Text::Table.new(\n\t\t\t'Header' => \"Listing: #{path}\",\n\t\t\t'Columns' =>\n\t\t\t\t[\n\t\t\t\t\t'Mode',\n\t\t\t\t\t'Size',\n\t\t\t\t\t'Type',\n\t\t\t\t\t'Last modified',\n\t\t\t\t\t'Name',\n\t\t\t\t])\n\n\t\titems = 0\n\n\t\t# Enumerate each item...\n\t\tclient.fs.dir.entries_with_info(path).sort { |a,b| a['FileName'] <=> b['FileName'] }.each { |p|\n\n\t\t\ttbl <<\n\t\t\t\t[\n\t\t\t\t\tp['StatBuf'] ? p['StatBuf'].prettymode : '',\n\t\t\t\t\tp['StatBuf'] ? p['StatBuf'].size : '',\n\t\t\t\t\tp['StatBuf'] ? p['StatBuf'].ftype[0,3] : '',\n\t\t\t\t\tp['StatBuf'] ? p['StatBuf'].mtime : '',\n\t\t\t\t\tp['FileName'] || 'unknown'\n\t\t\t\t]\n\n\t\t\titems += 1\n\t\t}\n\n\t\tif (items > 0)\n\t\t\tprint(\"\\n\" + tbl.to_s + \"\\n\")\n\t\telse\n\t\t\tprint_line(\"No entries exist in #{path}\")\n\t\tend\n\n\t\treturn true\n\tend", "def get_entries(dir, subfolder); end", "def listFiles()\n #N Without this the files won't get listed\n contentHost.listFiles(baseDir)\n end", "def get_list(dir = nil)\n @ftp.ls(dir)[3..-1]\n end", "def provider_readdir(dirname, recursive=true, allowed_types = [:regular, :directory]) #:nodoc:\n\n dirname = Pathname.new(dirname)\n allowed_types = Array(allowed_types)\n\n list = []\n\n # Syscall caches\n uid_to_owner = {}\n gid_to_group = {}\n\n # Call the datalad repository method to get the short\n # reports about each entry\n DataladRepository.list_contents_from_dataset(dirname,recursive).each do |fname|\n\n # There are only three attributes in the reports\n name = fname[:name] # relative path, e.g. \"a/b/c.txt\"\n size = fname[:size_in_bytes]\n type = fname[:type]\n\n dl_full_path = dirname.join(name)\n\n # fix type\n type = :regular if type == :file || type == :gitannexlink\n\n next unless allowed_types.include? type\n next if is_excluded?(name)\n\n # get stat with lstat\n stat = File.lstat(dl_full_path)\n\n # Look up user name from uid\n uid = stat.uid\n owner_name = (uid_to_owner[uid] ||= (Etc.getpwuid(uid).name rescue uid.to_s))\n\n # Lookup group name from gid\n gid = stat.gid\n group_name = (gid_to_group[gid] ||= (Etc.getgrgid(gid).name rescue gid.to_s))\n\n # Create a FileInfo\n fileinfo = FileInfo.new\n\n # From Datalad\n fileinfo.name = name\n fileinfo.symbolic_type = type\n fileinfo.size = size\n\n # From lstat():\n fileinfo.permissions = stat.mode\n fileinfo.atime = stat.atime\n fileinfo.ctime = stat.ctime\n fileinfo.mtime = stat.mtime\n fileinfo.uid = uid\n fileinfo.owner = owner_name\n fileinfo.gid = gid\n fileinfo.group = group_name\n\n list << fileinfo\n end\n\n list.sort! { |a,b| a.name <=> b.name }\n list\n end", "def list\n ret = get()\n return [] if ret.is_a? Hash and ret.has_key? :error\n ret.map{|i| FileItem.new(i)}\n end", "def list(directory = nil)\n @ftp.nlst(directory)\n end", "def index\n @filenames = Filename.all\n end", "def batch_directory_listing(prefix, batch_size = MAX_KEYS)\n @directory.files.all('prefix' => prefix, 'max-keys' => batch_size)\n end", "def list\n require_public = ( params[:user].nil? ? false : true )\n user = ( params[:user].nil? ? session[:user] : User.first(id: params[:user]) )\n raise RequestError.new(:bad_params, \"User does not exist\") unless user\n raise RequestError.new(:bad_params, \"Depth not valid\") if params[:depth].to_i < 0\n depth = (params[:depth] ? params[:depth].to_i : -1)\n xfile = ( params[:id].nil? ? user.root_folder : WFolder.get(params[:id]) )\n raise RequestError.new(:internal_error, \"No root directory. Please contact your administrator\") if xfile.nil? && params[:id].nil?\n raise RequestError.new(:folder_not_found, \"File or folder not found\") if xfile.nil?\n if (require_public && params[:id] && session[:user].admin == false) then\n raise RequestError.new(:folder_not_public, \"Folder is not public\") if xfile.folder == true && xfile.public == false\n raise RequestError.new(:folder_not_public, \"File is not public\") if xfile.folder == false && xfile.public == false\n end\n if xfile.folder then\n @result = { folder: crawl_folder(xfile, require_public, depth), success: true }\n else \n @result = { file: xfile.description(session[:user]) , success: true }\n end\n end", "def file_list\n @file_list\n end", "def dir_list(path, bases, paging)\n items = paging[:items]\n page = paging[:page]\n offset = paging[:offset]\n raise 'Disabling paging is not supported for a directory listing' if paging[:disable_paging]\n\n max_items = 1000\n\n child_paths, total = FileSystems::Combined.directory_list(path, items, offset, max_items)\n\n children = child_paths.map { |full_path|\n if FileSystems::Combined.directory_exists?(full_path)\n dir_info(full_path, bases)\n else\n raise 'File should exist' unless FileSystems::Combined.file_exists?(full_path)\n\n file_info(full_path)\n end\n }\n\n paging[:total] = total\n paging[:warning] = \"Only first #{max_items} results are available\" if total >= max_items\n\n children\n end", "def records(opts = {})\n opts = opts.merge(@opts)\n client.list_records(opts).full.lazy.flat_map do |rec|\n @record_class.build(mint_id(rec.header.identifier),\n record_xml(rec))\n\n end\n end", "def filelist\n puts_message \"filelist start\" \n\n user = current_user\n\n request = params[:request].force_encoding(\"UTF-8\")\n puts_message \"Requested Path: \" + params[:request]\n \n if user and check_existance_of_path(request) \n if request == nil\n @file_names = 'error'\n elsif request_is_directory?(request)\n fire_the_list(request)\n # @file_names = absolute_path(request)\n elsif request_is_file?(request)\n last = request.split('/').last\n path = absolute_path(request)\n send_file_info(last, request) \n else\n @file_names = 'error'\n end\n else \n @file_names = 'error'\n end\n\n puts_message \"filelist end\" \n \n @output = <<-END\n\n END\n \n if request == \"/images/\"\n @folders = Folder.all(:user_id => current_user.id)\n \n @output << \"photo\" + \"\\n\"\n \n @folders.each do |f|\n @output << f.name + \"\\n\"\n end\n \n @file_names = @output\n end\n \n return @file_names\n\n end", "def read_logs_all()\n #logs = Log.find(:all, :order => 'created_at asc')\n logs = Log.all.order('created_at asc')\n end", "def ls(path)\n # FIXME: remove 'path' from listing?\n list(path, false, true)\n end", "def list_files\n @synth_files = CreatedFile.find_all_by_content_type(\"synthesis\",\n :include => :researcher, \n :order => \"created_at DESC, created_file DESC\")\n end", "def read_logs_all()\n logs = Log.find(:all, :order => 'created_at asc')\n end", "def list(client, current_path)\n\n\tfiles = Dir.glob(\"#{current_path}/files/*\")\n\tclient.puts \"\\nList of Files:\"\n\tfiles.each{ |file|\n\tfile.slice! \"#{current_path}/files/\"}\n\tclient.puts files\n\nend", "def index\n @recordings = Recording.where(is_recorded: false).order(:start_datetime).reverse_order.page(params[:page]).per(20)\n end", "def index\n @test_results_from_files = Paginate.get_records(\n relation_object: current_teacher.test_results_from_files,\n page: params[:page],\n per_page: params[:per_page]\n )\n end", "def list(path)\n output { get(path) }\n end", "def records(options = {})\n records_base(options)\n end", "def index\n @file_descriptions = FileDescription.all\n end", "def files\n db = Database.find(params[:id])\n @files = Dir.entries(db.path)\n @files.delete_if{|f| !f.include?'.dat'}\n @results = []\n @files.each do |entry|\n @results << {:name=>entry,:version=>db.version}\n end\n respond_to do |format|\n format.html\n format.json { render json: @results }\n end\n end", "def files\n page = get_page\n offset = PER_PAGE * page\n get_run_logs(:limit => PER_PAGE, :offset => offset)\n end", "def list\r\n # Get the folder\r\n @folder = Folder.find_by_id(folder_id)\r\n\r\n # Set if the user is allowed to update or delete in this folder;\r\n # these instance variables are used in the view.\r\n @can_update = @logged_in_user.can_update(@folder.id)\r\n @can_delete = @logged_in_user.can_delete(@folder.id)\r\n\r\n # determine the order in which files are shown\r\n file_order = 'filename '\r\n file_order = params[:order_by].sub('name', 'filename') + ' ' if params[:order_by]\r\n file_order += params[:order] if params[:order]\r\n\r\n # determine the order in which folders are shown\r\n folder_order = 'name '\r\n if params[:order_by] and params[:order_by] != 'filesize' \r\n folder_order = params[:order_by] + ' '\r\n folder_order += params[:order] if params[:order]\r\n end\r\n\r\n # List of subfolders\r\n @folders = @folder.list_subfolders(@logged_in_user, folder_order.rstrip)\r\n\r\n # List of files in the folder\r\n @myfiles = @folder.list_files(@logged_in_user, file_order.rstrip)\r\n\r\n #get the correct URL\r\n url = url_for(:controller => 'folder', :action => 'list', :id => nil)\r\n\r\n # it's nice to have the possibility to go up one level\r\n @folder_up = '<a href=\"' + url + '/' + @folder.parent.id.to_s + '\">..</a>' if @folder.parent\r\n end", "def list\n factory.system.list(@path).collect do |item|\n candidate = dir(item)\n if (not candidate.exists?)\n candidate = file(item)\n end\n candidate\n end\n end", "def index\n @datafiles = Datafile.all\n end", "def index\n @datafiles = Datafile.all\n end", "def index\n @record_objects = RecordObject.all\n end", "def index\n client = DropboxApi::Client.new(\"C8Eg7_xlTzAAAAAAAAAAMduh226EdjZy_X_pVqXkbOUenDBMOVpQwo0zhF9sr8bC\")\n @result = client.list_folder \"/Yann Doré\"\n pp @result.entries\n @result.has_more? \n end", "def get_recordings()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}/#{id}/recordings\"))[0]\n end", "def records\n doc = @session.request(:get, @records_url)\n return doc.css(\"entry\").map(){ |e| Record.new(@session, e) }\n end", "def retrieve_posts(dir); end", "def list_files\n Find.find(path) do |element| yield element end\n end", "def list\n\n end", "def list_all\n store_location\n query = create_query(:HerbariumRecord, :all, by: default_sort_order)\n show_selected_herbarium_records(query)\n end", "def list(klass, params)\n DSpaceObj.get(self, self.link + klass::PATH, params)\n end", "def ls(path, revision = nil, include_deleted = false)\n @client.metadata(path, 25000, true, nil, revision, include_deleted)\n rescue\n puts $! if @@verbose\n nil\n end", "def all\n @files\n end", "def get_all_files()\n return $db.execute(\"SELECT * FROM files\")\nend", "def list\n Dir.glob(\"#{@directory}/**/*\").reject(&File.directory?).map do |p|\n Pathname.new(p).relative_path_from(@directory)\n end\n end", "def files(params = {}, &block)\n params = convert_params(params)\n return execute_paged!(\n :api_method => self.drive.files.list,\n :parameters => params,\n :converter => proc(){ |af| wrap_api_file(af) },\n &block)\n end", "def list_files_from path,opts = {}\n unless Dir.exists? path\n Logger.<<(__FILE__,\"ERROR\",\"Local fetcher: path does not exists for listing... #{path} \")\n raise \"Error LocalFileFetcher !\"\n end\n if opts[:directories]\n cmd = \"ls -td #{path}/*/\"\n else\n cmd = \"ls #{path}\"\n cmd += \"/#{opts[:regexp]}\" if opts[:regexp]\n end\n out = `#{cmd}`\n return out.split(\"\\n\")\n end", "def files_list(params = {})\n response = @session.do_post \"#{SCOPE}.list\", params\n Slack.parse_response(response)\n end", "def index\n @recs = Rec.all\n end", "def list_files\n User.sync_files!(@context)\n files = user_real_files(params, @context)\n\n if unsafe_params[:limit] && unsafe_params[:offset]\n files = files.limit(unsafe_params[:limit]).offset(unsafe_params[:offset])\n end\n\n search_string = params[:search_string].presence || \"\"\n\n result = files.eager_load(:license, user: :org).\n where(\"nodes.name LIKE ?\", \"%#{search_string}%\").\n order(id: :desc).map do |file|\n describe_for_api(file, unsafe_params[:describe])\n end.compact\n\n render json: unsafe_params[:offset]&.zero? ? { objects: result, count: result.length } : result\n end", "def index\n # In case the user clicks the search button on a Records page\n unless params[:q].nil?\n redirect_to :controller => 'catalog', action: \"index\", q: params[:q]\n end\n\n @records = Record.order('id ASC').all()\n end", "def list\n\t\tdocs = proxy_database.view(\"#{shared_data_context.name}/all\")[\"rows\"]\n\t\treturn docs\n \tend", "def list\n \tputs \"The list of backups for #{self.name}\"\n \tself.each do |bck|\n \t puts bck.filepath\n \tend\n end", "def get_directory_listing_for(params)\n # Get parent folder id\n parent_folder_id = params[:folder_id].present? ? self.get_parent_folder_id(params[:folder_id]) : nil\n \n # Get root folder id if blank\n params[:folder_id] ||= '/'\n \n # Set default params\n result = {:folder_id => params[:folder_id], :parent_folder_id => parent_folder_id, :per_page => 500, :results => []}\n\n begin\n api_result = @client.metadata(result[:folder_id], 1000, true)\n rescue\n return nil\n end\n \n if api_result.present? && api_result['contents'].present?\n api_result['contents'].each do |item|\n result[:results] << self.item_into_standard_format(item)\n end\n end\n \n result\n end", "def index\n @audio_recordings = AudioRecording.all\n end", "def index\n @reading_records = ReadingRecord.all\n end", "def list(directory: '\\\\', pattern: '*', type: RubySMB::Fscc::FileInformation::FileFullDirectoryInformation)\n find_first_request = RubySMB::SMB1::Packet::Trans2::FindFirst2Request.new\n find_first_request.smb_header.tid = id\n find_first_request.smb_header.flags2.eas = 1\n find_first_request.smb_header.flags2.unicode = 1\n\n search_path = directory.dup\n search_path << '\\\\' unless search_path.end_with?('\\\\')\n search_path << pattern\n search_path = '\\\\' + search_path unless search_path.start_with?('\\\\')\n\n # Set the search parameters\n t2_params = find_first_request.data_block.trans2_parameters\n t2_params.search_attributes.hidden = 1\n t2_params.search_attributes.system = 1\n t2_params.search_attributes.directory = 1\n t2_params.flags.close_eos = 1\n t2_params.flags.resume_keys = 0\n t2_params.information_level = type::SMB1_FLAG\n t2_params.filename = search_path\n t2_params.search_count = 10\n\n find_first_request = set_find_params(find_first_request)\n\n raw_response = client.send_recv(find_first_request)\n response = RubySMB::SMB1::Packet::Trans2::FindFirst2Response.read(raw_response)\n\n results = response.results(type)\n\n eos = response.data_block.trans2_parameters.eos\n sid = response.data_block.trans2_parameters.sid\n last = results.last.file_name\n\n while eos.zero?\n find_next_request = RubySMB::SMB1::Packet::Trans2::FindNext2Request.new\n find_next_request.smb_header.tid = id\n find_next_request.smb_header.flags2.eas = 1\n find_next_request.smb_header.flags2.unicode = 1\n\n t2_params = find_next_request.data_block.trans2_parameters\n t2_params.sid = sid\n t2_params.flags.close_eos = 1\n t2_params.flags.resume_keys = 0\n t2_params.information_level = type::SMB1_FLAG\n t2_params.filename = last\n t2_params.search_count = 10\n\n find_next_request = set_find_params(find_next_request)\n\n raw_response = client.send_recv(find_next_request)\n response = RubySMB::SMB1::Packet::Trans2::FindNext2Response.read(raw_response)\n\n results += response.results(type)\n\n eos = response.data_block.trans2_parameters.eos\n last = results.last.file_name\n end\n\n results\n end", "def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend", "def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend", "def list\n url = prefix + \"list\"\n return response(url)\n end", "def list(filter=KalturaNotImplemented, pager=KalturaNotImplemented)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'filter', filter)\n\t\t\tclient.add_param(kparams, 'pager', pager)\n\t\t\tclient.queue_service_action_call('recording', 'list', 'KalturaRecordingListResponse', 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 index\n @file_folders = FileFolder.all\n end", "def index\n @attachfiles = Attachfile.all\n end", "def list_directories(client)\n client.directories.each do |directory|\n puts \"Directory: #{directory.name}\"\n puts \" Description: #{directory.description}\"\n puts \" Status: #{directory.status}\"\n puts \" Href: #{directory.href}\"\n end\nend", "def list_files\n source_dir = Path.new(params[:source_dir])\n if params.has_key?(:show_catalogues)\n show_catalogues = params[:show_catalogues]\n else\n show_catalogues = false\n end\n if params[:ext].present?\n file_type = params[:ext]\n else\n file_type = nil\n end\n render json: source_dir.files(file_type: file_type, show_catalogues: show_catalogues)\n end", "def list_files(dir)\n# Getting all the files names in the directory\n file_names = Dir[dir + \"*\"]\n return file_names\nend", "def entries(path=nil, identifier=nil)\r\n logger.debug \"<cvs> entries '#{path}' with identifier '#{identifier}'\"\r\n path_with_project=\"#{url}#{with_leading_slash(path)}\"\r\n entries = Entries.new\r\n cmd = \"#{CVS_BIN} -d #{root_url} rls -e\"\r\n cmd << \" -D \\\"#{time_to_cvstime(identifier)}\\\"\" if identifier\r\n cmd << \" #{shell_quote path_with_project}\"\r\n shellout(cmd) do |io|\r\n io.each_line(){|line|\r\n fields=line.chop.split('/',-1)\r\n logger.debug(\">>InspectLine #{fields.inspect}\")\r\n \r\n if fields[0]!=\"D\"\r\n entries << Entry.new({:name => fields[-5],\r\n #:path => fields[-4].include?(path)?fields[-4]:(path + \"/\"+ fields[-4]),\r\n :path => \"#{path}/#{fields[-5]}\",\r\n :kind => 'file',\r\n :size => nil,\r\n :lastrev => Revision.new({\r\n :revision => fields[-4],\r\n :name => fields[-4],\r\n :time => Time.parse(fields[-3]),\r\n :author => ''\r\n })\r\n })\r\n else\r\n entries << Entry.new({:name => fields[1],\r\n :path => \"#{path}/#{fields[1]}\",\r\n :kind => 'dir',\r\n :size => nil,\r\n :lastrev => nil\r\n })\r\n end\r\n }\r\n end\r\n return nil if $? && $?.exitstatus != 0\r\n entries.sort_by_name\r\n end", "def get_directory_listing_for(params)\n # Get parent folder id\n parent_folder_id = params[:folder_id].present? ? self.get_parent_folder_id(params[:folder_id]) : nil\n \n # Get root folder id if blank\n params[:folder_id] ||= self.get_root_folder_id\n return nil if params[:folder_id].blank?\n \n # Set default params\n result = {:folder_id => params[:folder_id], :parent_folder_id => parent_folder_id, :per_page => 500, :results => []}\n parameters = {}\n parameters['q'] = \"'#{params[:folder_id]}' in parents\"\n parameters['maxResults'] = result[:per_page]\n \n # Make api request\n begin\n drive = @client.discovered_api('drive', 'v2')\n api_result = @client.execute(:api_method => drive.files.list, :parameters => parameters)\n rescue\n return nil\n end\n \n \n if api_result.status == 200\n files = api_result.data\n files.items.each do |item|\n result[:results] << self.item_into_standard_format(item)\n end\n else\n result[:error] = {:code => api_result.status, :message => api_result.data['error']['message']} \n end\n result\n end", "def index\n @title = 'Filenames'\n @filenames = Filename.all\n \n if match = params[:contains] || params[:match]\n @filenames = @filenames.where(\n 'name ILIKE ?', \"%#{match}%\"\n )\n end\n\n @filenames = (\n @filenames\n .order(:name)\n .page(params[:page])\n .per(params[:per_page])\n )\n end", "def records\n fail 'Not yet implemented'\n end", "def list_status(dir) \n response = HTTParty.get(\"https://#{accountName}.azuredatalakestore.net\" +\n \"/webhdfs/v1/#{dir}?op=LISTSTATUS\", {\n body: \"grant_type=client_credentials&client_id=#{clientId}\"+\n \"&client_secret=#{clientSecret}\"+\n \"&resource=https%3A%2F%2Fmanagement.azure.com%2F\",\n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Accept\" => '*/*',\n \"Cache-Control\" => 'no-cache',\n \"Host\" => \"#{accountName}.azuredatalakestore.net\",\n \"Connection\" => 'keep-alive',\n \"cache-control\" => 'no-cache'\n },\n verify: true,\n })\n\n return JSON.parse response.read_body\n end", "def ls(dirpath = nil, filesmatch = '*')\n dirpath << '/' unless dirpath.nil? || dirpath.end_with?('/')\n offset = dirpath.nil? ? 0 : dirpath.length\n r = Regexp.new(\"^#{Regexp.escape(filesmatch)}$\".gsub('\\*','.*').gsub('\\?','.'))\n bucket.as_tree(:prefix => dirpath).children.select(&:leaf?).map{|f| f.key[offset..-1]}.select{|f| f.match(r)}\n end" ]
[ "0.69430274", "0.69430274", "0.67232615", "0.65175796", "0.64744735", "0.6373912", "0.63653886", "0.6316174", "0.6303739", "0.62991416", "0.626525", "0.6252788", "0.6237202", "0.6208921", "0.6205405", "0.61729693", "0.6140949", "0.6131978", "0.61298907", "0.61233455", "0.61208194", "0.61163294", "0.60871977", "0.6083487", "0.6072264", "0.6072264", "0.6072264", "0.6072264", "0.6072264", "0.60720676", "0.607159", "0.60643077", "0.6055088", "0.60505116", "0.6046912", "0.60305035", "0.60242844", "0.5992668", "0.59923404", "0.59705436", "0.59689486", "0.5954865", "0.5945892", "0.59188044", "0.59099287", "0.59056324", "0.5867198", "0.58637625", "0.58598804", "0.5854356", "0.585081", "0.58367926", "0.58356327", "0.58298266", "0.58293283", "0.58220655", "0.57970357", "0.57919985", "0.57902783", "0.5777603", "0.5777603", "0.5775276", "0.57731515", "0.5771443", "0.57656044", "0.5759425", "0.57579064", "0.57491463", "0.57433724", "0.5724499", "0.5722914", "0.57210094", "0.57179546", "0.5708051", "0.57066816", "0.5705392", "0.56990147", "0.5698743", "0.56974524", "0.5694979", "0.5690557", "0.5684959", "0.5684955", "0.56827873", "0.5671362", "0.56460303", "0.5639421", "0.5639421", "0.56302804", "0.5629703", "0.56278193", "0.56273127", "0.5625402", "0.5618183", "0.5612503", "0.5609999", "0.56080216", "0.56021893", "0.55991256", "0.5598928", "0.5596012" ]
0.0
-1
These methods delete records from the directory.
def delete_option puts "PROCEED WITH CAUTION".center(80).red puts "Delete (P)olitician or (V)oter record?".center(80) delete_type = verified_answer(gets.chomp.downcase, ["p", "v"]) if delete_type == "p" delete_politician list_politicians else delete_voter list_voters end puts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_all\n records.clear\n end", "def deleteAll\n Record.destroy_all()\n redirect_to(records_path)\n end", "def delete(*records)\n records.each do |record|\n target.delete(record)\n end\n end", "def delete\n Modeles::File.delete @fileInTable.id\n @errors = nil\n @fileInTable = nil\n @path = nil\n @user = nil\n @group = nil\n @userRights = nil\n @groupRights = nil\n @othersRights = nil\n end", "def delete(*records)\n records = flatten_deeper(records)\n records.each { |record| raise_on_type_mismatch(record) }\n delete_records(records)\n records.each { |record| @collection.delete(record) } if loaded?\n end", "def delete(record)\n record.del\n end", "def delete(id)\n record = find(id)\n return unless record\n\n delete_from_file(@file, record)\n @records = read_file(@file)\n end", "def _delete_records\n @ids_to_delete.each do |table, ids|\n delete_from_table(table, ids)\n end\n end", "def delete_files\n return if id.nil?\n return unless File.exist?(directory_path)\n\n FileUtils.rm_rf(directory_path)\n s3_delete_files\n end", "def del\n delete\n end", "def delete_records(records, method)\n raise NotImplementedError\n end", "def delete record\n db_name = database_name_for(record)\n coll_name = collection_name_for(record)\n case\n when id = id_for(record)\n pointer = \"/#{db_name}/#{coll_name}/#{id}\"\n res = collection_for(record).remove({:_id => id})\n if res[\"err\"]\n log.error(res[\"err\"])\n else\n log.debug(\"Deleted #{pointer}\")\n end\n when query = delete_query_for(record)\n pointer = \"/#{db_name}/#{coll_name}\"\n res = collection_for(record).remove(query)\n if res[\"err\"]\n log.error(res[\"err\"])\n else\n log.debug(\"Deleted #{res['n']} records from #{pointer}\")\n end\n end\n end", "def delete\n \n end", "def delete(*records)\n load_target\n flatten_deeper(records).compact.each do |record|\n unless @target.delete(record).nil?\n callback(:before_remove, record)\n unlinks << record\n links.delete(record)\n record.send(:mark_as_linked, false)\n callback(:after_remove, record)\n end\n end\n self\n end", "def delete(*records)\n records = flatten_deeper(records)\n records.each { |record| raise_on_type_mismatch(record) }\n\n transaction do\n records.each { |record| callback(:before_remove, record) }\n\n old_records = records.reject {|r| r.new_record? }\n delete_records(old_records) if old_records.any?\n\n records.each do |record|\n @target.delete(record)\n callback(:after_remove, record)\n end\n end\n\n @owner.send(:cache_write, @reflection, self) if @reflection.options[:cached]\n end", "def destroy(*records)\n delete_or_destroy(records, :destroy)\n end", "def delete\n# if stat.directory?\n# FileUtils.rm_rf(file_path)\n# else\n# File.unlink(file_path)\n# end\n if collection?\n @collection.find({:filename => /^#{Regexp.escape(@bson['filename'])}/}).each do |bson|\n @collection.remove(bson)\n end\n else\n @collection.remove(@bson)\n end\n NoContent\n end", "def delete_records\n return error_response unless is_delete_records_request?\n if params[:selected]\n params[:selected].each_value do |id|\n record = @record_class.find id\n record.destroy if record.present?\n end\n end\n succes_response\n end", "def delete_record(rec_label)\n record = records.find { |r| r.label == rec_label }\n return unless record\n\n File.delete(record.path)\n records.delete(record)\n end", "def destroy\n r = self.class.delete(\"/domains/#{@@parent_id}/records/#{self.id}\")\n if r.code == 200\n self\n else\n raise StandardError, 'Could not delete the record'\n end \n end", "def delete\n del unless new_record?\n set_deleted_properties\n end", "def delete type\n return if type == :records\n @db.connect do\n TableUtil::delete_table @table_files \n Logger.<<(__FILE__,\"INFO\",\"Deleted files table for #{@source.name}\")\n end\n end", "def delete_records(records, method)\n if method == :destroy\n records.each(&:destroy)\n else\n keys = records.map { |r| r[reflection.association_primary_key] }\n scope = scoped.where(reflection.association_primary_key => keys)\n\n if method == :delete_all\n scope.delete_all\n else\n # This is for :nullify which isn't actually supported yet,\n # but this should work once it is\n scope.update_all(reflection.foreign_key => nil)\n end\n end\n end", "def delete_from_disk; end", "def delete_files(uuids)\n Uploadcare::FileList.batch_delete(uuids)\n end", "def del\n File.delete(@file)\n end", "def delete(*args)\n if args.blank?\n raise \"Using delete with no args is not allowed. Please use delete_all to delete all records\"\n end\n keys = find_keys(*args)\n self.store.delete_keys(keys)\n end", "def destroy\n @record = Record.find(params[:id])\n @record.destroy\n redirect_to(records_path)\n end", "def delete\n FileUtils.rm_rf(to_s)\n self\n end", "def delete\n if (exists?)\n list.each do |children|\n children.delete\n end\n factory.system.delete_dir(@path)\n end\n end", "def delete!\n if new_record?\n raise Errors::FolderNotFound.new(@id, \"Folder does only exist locally\")\n else\n self.class.delete(@conn_id, @location.path)\n @id = nil\n end\n end", "def delete_records(records:, record_class: nil)\n records.each do |record|\n key = get_key_for_record(record: record, record_class: record_class)\n REDIS_APP_JOIN.del(key)\n end\n end", "def delete_record *rid\n db.delete_record rid\n end", "def delete\n stop\n [ @resource['instances_dir'] + \"/\" + @resource[:name],\n @resource['instances_dir'] + \"/\" + \"_\" + @resource[:name]\n ].each do |dir|\n FileUtils.rm_rf(dir) if File.directory?(dir)\n end\n end", "def delete_all\n self.store.delete_keys(find_keys)\n end", "def delete\n \n end", "def delete\n end", "def destroy\n\t\t@directory = Directory.find(params[:id])\n\t\[email protected]_flag = 'N'\n\t\[email protected]\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to(directories_url) }\n\t\t\tformat.xml\t{ head :ok }\n\t\tend\n\tend", "def delete\n end", "def delete_record!(record)\n record.public_send(inventory_collection.delete_method)\n inventory_collection.store_deleted_records(record)\n end", "def delete_file_from_database(file_id)\n $db.execute(\"DELETE FROM files WHERE id = ?\", file_id)\n $db.execute(\"DELETE FROM file_share_table WHERE file_id = ?\", file_id)\nend", "def destroy\n # Delete all associated records first\n MysqlAdapter.delete \"DELETE FROM #{Record.table_name} WHERE domain_id = #{id}\"\n\n # Then proceed with deletion\n super\n rescue Mysql::Error\n false\n end", "def delete(filename); end", "def delete(*records)\n delete_or_destroy(records, options[:dependent])\n end", "def delete_objects(resource, ids)\n records = resource.find(ids)\n ActiveRecord::Base.transaction do\n records.each(&:destroy)\n end\n end", "def delete\n records = ReadLater.find_by_url(params[:url])\n records.destroy\n\n redirect_to read_laters_path\n end", "def delete\n @record = Record.find(params[:id])\n end", "def delete\n ::File.unlink(@path)\n end", "def destroy\r\n @patient = Patient.find(params[:id])\r\n @patient.destroy\r\n \r\n #DELETE PROFILE PIC - ADDED BY UPINDER\r\n @patientID = params[:id]\r\n @directory = File.join(RAILS_ROOT,\"public/patients/photos\")\r\n @directory = File.join(@directory,@patientID)\r\n Upload.delete(@directory)\r\n #END DELETE PROFILE PIC\r\n \r\n APP_LOGGER_LOG.info \"PATIENT DELETED - for PATIENT ID \" + \r\n @patient[:medical_record_number] + \" by USER \" + self.current_user[:login]\r\n \r\n respond_to do |format|\r\n format.html { redirect_to(patients_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n delete_files_and_empty_parent_directories\n end", "def delete\n end", "def destroy\n @file_record = FileRecord.find(params[:id])\n @file_record.destroy\n\n respond_to do |format|\n format.html { redirect_to file_records_url }\n format.json { head :no_content }\n end\n end", "def delete(*filenames); end", "def delete_file_from_db(file_id)\n $db.execute(\"DELETE FROM files WHERE file_id = ?\", file_id)\nend", "def delete_files\n self.bruse_files.each do |file|\n file.destroy\n end\n end", "def destroy; delete end", "def delete!\n clear!\n delete\n end", "def destroy\n @records = user_records.where(id: params[:id]).destroy_all if params[:id]\n if @records.blank? && params[:record]\n @records = [params[:record]].flatten.collect { |record|\n next unless (record[:external_system] && record[:external_id])\n user_records.where(external_system: record[:external_system], external_id: record[:external_id]).destroy_all\n }.compact.flatten\n end\n flash[:notice] = t('record.flash.actions.destroy.notice')\n respond_with(@records, location: records_url)\n end", "def delete_collection\n FileUtils.rm_r @src_path\n FileUtils.rm_r @store_path if store_exist?\n end", "def delete\n Iterable.request(conf, base_path).delete\n end", "def delete\n deleted\n save\n end", "def delete_records o_class, where: {}\n logger.progname = 'RestDelete#DeleteRecords'\n records_to_delete = get_records(from: o_class, where: where)\n if records_to_delete.empty?\n logger.info{\"No record found\"}\n else\n delete_record records_to_delete\n end\n end", "def delete(files)\n # sync before we delete\n sync\n Array.wrap(files).each do |f|\n info \"removing #{f}\"\n FileUtils.rm(f)\n error \"#{f} wasn't removed\" if File.exists?(f)\n end\n end", "def delete\n dataset.delete\n end", "def destroy(record)\n record.destroy\n end", "def delete!\n deleted\n save!\n end", "def destroy\n \tself.class.mongo_client.database.fs.find(:_id => BSON::ObjectId(@id)).delete_one\n end", "def destroy\n m = model.find(user_scoped.find(params[:id]).id)\n @record_saved = m # copy for possible later use\n m.destroy\n\n prepare_list\n @record = model.new\n @flash_notice = t('delete_ok')\n end", "def delete_entries(entries)\n delete_all(:id => entries)\n end", "def record_destroy\n paper_trail.record_destroy\n end", "def delete\n # TODO: implement delete\n end", "def delete\n\n end", "def delete_records(records)\n if sql = @reflection.options[:delete_sql]\n records.each { |record| @owner.connection.delete(interpolate_and_sanitize_sql(sql, record)) }\n else\n\n relation = Arel::Table.new(@reflection.options[:join_table], arel_engine)\n \n relation.where(relation[@reflection.primary_key_name].eq(@owner.id).\n and(relation[@reflection.association_foreign_key].in(records.map { |x| x.id }.compact))\n ).delete\n end\n end", "def handle_file_deletions(model)\n record = instance_variable_get(\"@#{model}\")\n if params[\"#{model}_delete\"]\n params[\"#{model}_delete\"].keys.each do |column|\n if record.respond_to?(column) and record.send(column) and File.exists?(record.send(column))\n File.delete(record.send(column))\n #record.update_attribute(column, nil)\n end\n end\n end\n end", "def handle_file_deletions(model)\n record = instance_variable_get(\"@#{model}\")\n if params[\"#{model}_delete\"]\n params[\"#{model}_delete\"].keys.each do |column|\n if record.respond_to?(column) and record.send(column) and File.exists?(record.send(column))\n File.delete(record.send(column))\n #record.update_attribute(column, nil)\n end\n end\n end\n end", "def delete\n FileUtils.remove_entry_secure(@directory)\n ObjectSpace.undefine_finalizer(self)\n rescue Errno::ENOENT\n end", "def delete\n begin\n object = bucket.objects.find(@path)\n object.destroy\n true\n rescue Exception => e\n # If the file's not there, don't panic\n nil\n end\n end", "def destroy\n self.class.mongo_client.database.fs.find(:_id=>BSON::ObjectId.from_string(@id)).delete_one\n end", "def destroy\n self.class.mongo_client.database.fs.find(:_id=>BSON::ObjectId.from_string(@id)).delete_one\n end", "def destroy\r\n find_record\r\n # check permission required to delete\r\n permission = if params['operation'].nil?\r\n if @record.respond_to?('created_by') # needs can_delete_all if created_by is present and not owner\r\n (@record.created_by == session[:user_id]) ? DcPermission::CAN_DELETE : DcPermission::CAN_DELETE_ALL\r\n else\r\n DcPermission::CAN_DELETE # by default\r\n end\r\n else # enable or disable record\r\n if @record.respond_to?('created_by')\r\n (@record.created_by == session[:user_id]) ? DcPermission::CAN_EDIT : DcPermission::CAN_EDIT_ALL\r\n else\r\n DcPermission::CAN_EDIT # by default\r\n end\r\n end\r\n ok2delete = dc_user_can(permission)\r\n\r\n case\r\n # not authorized\r\n when !ok2delete then\r\n flash[:error] = t('drgcms.not_authorized')\r\n return index\r\n\r\n # delete document\r\n when params['operation'].nil? then\r\n # before_delete callback\r\n if (m = callback_method('before_delete') )\r\n ret = call_callback_method(m)\r\n # don't do anything if return is false\r\n return index if ret.class == FalseClass\r\n end\r\n\r\n if @record.destroy\r\n save_journal(:delete)\r\n flash[:info] = t('drgcms.record_deleted')\r\n # after_delete callback\r\n if (m = callback_method('after_delete') )\r\n call_callback_method(m)\r\n elsif params['after-delete'].to_s.match('return_to')\r\n params[:return_to] = params['after-delete']\r\n end\r\n # Process return_to link\r\n return process_return_to(params[:return_to]) if params[:return_to]\r\n else\r\n flash[:error] = dc_error_messages_for(@record)\r\n end\r\n return index\r\n \r\n # deactivate document\r\n when params['operation'] == 'disable' then\r\n if @record.respond_to?('active')\r\n @record.active = false\r\n save_journal(:update, @record.changes)\r\n update_standards()\r\n @record.save\r\n flash[:info] = t('drgcms.doc_disabled')\r\n end\r\n \r\n # reactivate document\r\n when params['operation'] == 'enable' then\r\n if @record.respond_to?('active')\r\n @record.active = true\r\n update_standards()\r\n save_journal(:update, @record.changes)\r\n @record.save\r\n flash[:info] = t('drgcms.doc_enabled')\r\n end\r\n\r\n #TODO reorder documents\r\n when params['operation'] == 'reorder' then\r\n\r\n end\r\n\r\n @form_params['action'] = 'update'\r\n render action: :edit\r\nend", "def flush_deletes\n @queued_for_delete.each do |path|\n Paperclip.log(\"Delete: #{ path }\")\n file_id = search_for_title(path)\n google_api_client.delete_file(file_id) unless file_id.nil?\n end\n @queued_for_delete = []\n end", "def delete\n if processable? or unset?\n dir.delete\n else\n raise JobError.cannot_delete(@id, state)\n end\n end", "def deleteT(dir1, dir2)\n\t\tFileUtils.rm_rf Dir.glob(\"#{dir1}*\")\n\t\tFileUtils.rm_rf Dir.glob(\"#{dir2}*\")\n\tend", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def destroy\n all.each { |file| FileUtils.rm_f(file) }\n end", "def delete \n orientdb.delete_record self \nend", "def delete_files_from dir\n Dir[dir+\"/*\"].each do |file|\n File::delete(file)\n end \n rescue => e\n Logger.<<(__FILE__,\"WARNING\",\"Files from #{dir} could not be deleted.\\n#{e.message}\")\n end", "def delete\n FileUtils.rm(self.path) if exists?\n end", "def destroy\n \n @attachment = Attachment.find(params[:attachment_id])\n @attachment.destroy\n Keys.where(attachment_id: @attachment.id).destroy_all\n GetModel(params[:type]).where(file_id: @attachment.id).destroy_all\n \n respond_to do |format| \n format.html { redirect_to '/imports/'+params[:profile_id].to_s+'/csv/'+params[:type].to_s,notice: 'File has been deleted!' }\n end\n \n end", "def delete\n raise \"'id' is not set.\" if @id == nil\n sql = \"DELETE FROM #{table} WHERE id=#{@id}\"\n Database.transaction(sql)\n @log.debug \"Record[#{self}] is deleted from Table[#{table}]\"\n end", "def destroy_bulk(list_of_native_records)\n #TODO: Investigate why mutiple ids may be returned for the same record\n #Answer Database Corruption\n list_of_native_records.uniq!\n #puts \"List of all records: #{list_of_native_records.map{|r| r['_id']}.inspect}\"\n list_of_native_records.each do |r|\n begin\n att_doc_id = r['_id'] + CouchrestAttachment::AttachmentID\n #puts \"Node ID: #{r['_id'].inspect}\"\n #puts \"DB: #{@db.all.inspect}\"\n @db.delete_doc(r)\n begin\n att_doc = @db.get(att_doc_id)\n rescue\n att_doc = nil\n end\n @db.delete_doc(att_doc) if att_doc\n rescue RestClient::RequestFailed\n puts \"Warning:: Failed to delete document?\"\n end\n end\n nil #TODO ok to return nil if all docs destroyed? also, not verifying\n end", "def deletevideos\n @video = params[:records]\n @video.each do |id|\n Video.find_by_id(id).destroy\n end\n redirect_to admin_videos_path\n end", "def delete_students\n CSV.open(\"students.csv\", \"w\") do |csv|\n @students.clear\n end\nend", "def destroy\n @directory = Directory.find(params[:id])\n @directory.destroy\n\n respond_to do |format|\n format.html { redirect_to(directories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @directory = Directory.find(params[:id])\n @directory.destroy\n\n respond_to do |format|\n format.html { redirect_to(directories_url) }\n format.xml { head :ok }\n end\n end" ]
[ "0.71038073", "0.7043321", "0.6852107", "0.68262476", "0.67966056", "0.6752839", "0.6752663", "0.67201227", "0.6692268", "0.6676397", "0.66696036", "0.66558874", "0.6616819", "0.66001105", "0.65852606", "0.65490115", "0.64989024", "0.6414904", "0.6413997", "0.6392567", "0.6366555", "0.63648665", "0.636428", "0.6354356", "0.6332756", "0.631345", "0.6299209", "0.6283937", "0.62827843", "0.62716496", "0.62686175", "0.62603474", "0.62456036", "0.6233759", "0.6217053", "0.6215604", "0.6211658", "0.6203582", "0.6200784", "0.61938035", "0.6190022", "0.61778045", "0.61672616", "0.61622113", "0.6157343", "0.6155139", "0.61435217", "0.61406285", "0.6138454", "0.61349934", "0.6131201", "0.6130526", "0.6124957", "0.6118532", "0.61136043", "0.61112535", "0.6108319", "0.60910296", "0.6089334", "0.60844517", "0.60765254", "0.6052632", "0.6044198", "0.60409504", "0.6030973", "0.6028333", "0.6024995", "0.6024164", "0.6023963", "0.6023752", "0.60113925", "0.60109377", "0.6010755", "0.59872466", "0.59872466", "0.59865737", "0.59857094", "0.5983305", "0.5983305", "0.59827775", "0.5976698", "0.5970302", "0.59475195", "0.59436715", "0.59436715", "0.59436715", "0.59436715", "0.59436715", "0.59436715", "0.59436715", "0.5940667", "0.5938921", "0.5929984", "0.59270203", "0.5924031", "0.59186393", "0.5917682", "0.5915892", "0.5910803", "0.5908346", "0.5908346" ]
0.0
-1
Call back to index action and render on index.html.erb
def search index render :index end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n render\n end", "def index\n render\n end", "def index\n render_index\n end", "def index\n\t\tlist\n\t\trender('list')\n\tend", "def index\n\t\tlist\n\t\trender('list')\n\tend", "def index\n render 'index'\n\n end", "def index\n list\n render(\"list\")\n end", "def index\n list\n\trender('list')\n end", "def index\n list #call the action\n render('list') #render the correct template not 'index'\n end", "def index\n render 'index.html.erb'\n \n end", "def index\r\n list\r\n render_action 'list'\r\n end", "def index\n list\n render :action => 'list'\n end", "def index\n list\n render :action => 'list'\n end", "def index\n list\n render :action => 'list'\n end", "def index\n list\n render :action => 'list'\n end", "def index\n list\n render :action => 'list'\n end", "def index\n list\n render :action => 'list'\n end", "def index\n list\n render :action => 'list'\n end", "def index\n # render index.html \n end", "def index\n pp 'render index'\n search_and_sort\n end", "def index\n list\n render_action 'list'\n end", "def index\n \tlist\n \t#this renders out the list view template, you can make it any other if you want \n \trender('list')\n end", "def index\r\n end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index\n render_result('ok')\n end", "def index\n list\n #render :action => 'list'\n\n end", "def index\n\t\trender :nothing => true\n\tend", "def index\r\n end", "def index\r\n end", "def index\r\n end", "def index \n end", "def show\n index\n render :index\n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n respond_to do |format|\n format.html {render 'index'}\n end\n end", "def index\n handle_view\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n end", "def index\n \t\n end", "def index\n \t\n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n \n end" ]
[ "0.868087", "0.8500112", "0.8499079", "0.82721514", "0.82721514", "0.8257826", "0.8201098", "0.8182875", "0.806883", "0.806812", "0.80245614", "0.8024383", "0.8024383", "0.8024383", "0.8024383", "0.8024383", "0.8024383", "0.8024383", "0.7962438", "0.7921645", "0.79107165", "0.7905152", "0.78880435", "0.78828907", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7882489", "0.7877228", "0.7875045", "0.7843514", "0.7840637", "0.7840637", "0.7840637", "0.7813268", "0.77548397", "0.77529573", "0.77529573", "0.77529573", "0.77498233", "0.7748714", "0.7746217", "0.7746217", "0.7746217", "0.7746217", "0.7746217", "0.7746217", "0.7746217", "0.7746217", "0.7738894", "0.7738894", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854", "0.77209854" ]
0.0
-1
Paramaters that can be changed in the web forms
def resource_params params.require(:contact).permit(:name, :company, :position, :birth) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_params\n raise 'Sovrascrivi in figli'\n end", "def params=(value); end", "def params() request.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 user_page_setting_params\n params.permit(:is_regist_group, :is_edit_group, :is_edit_sub_rep, :is_edit_place, :is_edit_power_order, :is_edit_rental_order, :is_edit_stage_order, :is_edit_employee, :is_edit_food_product, :is_edit_purchase_list,:add_power_order,:add_rental_order,:add_employee,:add_food_product,:add_purchase_list, :fes_year_id)\n end", "def form_fields\n params\n end", "def query_parameters; end", "def query_parameters\n end", "def parameter_control_params\n params.require(:parameter_control).permit(:result_no, :generate_no, :e_no, :cond, :day, :mod, :cvp, :pvp)\n end", "def formulary_params\n allow = [:responsable_llenado,:cod01,:cod02,:ape01,:ape04,:ape07,:ape02,:ape05,:ape03,:ape06,:api01,:api04,:api02,:ssb01,:api03,:cao01,:cao04,:cao07,:cao10,:tit01,:cao02,:cao05,:cao08,:cao11,:cao03,:cao06,:cao09,:cao12,:uni01,:uni02,:uni03,:ben01,:ben02,:per01,:per02,:user_id]\n params.require(:formulary).permit(allow)\n end", "def parameters=(_); end", "def user_params\r\n end", "def request_params; 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 permitir_parametros\n \t\tparams.permit!\n \tend", "def request_parameters; end", "def setting_params\n params[:setting]\n end", "def setup_params(parms, for_download=false)\n report_state_hash = YAML.load(self.view_state)\n\n parms[:parameter_field] = {:excel_only => '0' }\n report_state_hash[:parameter_fields_values].each do |parm_set|\n parms[:parameter_field][parm_set[:field_name]] = parm_set[:field_value]\n parms[:parameter_field][\"#{parm_set[:field_name]}-sign\"] = report_state_hash[:operator_signs][parm_set[:field_value]]\n end\n parms[:parameter_field]['excel_only'] = for_download ? '0' : '1'\n parms['apply_functions_hidden_field'] = report_state_hash[:functions]\n parms['group_by_hidden_field'] = report_state_hash[:search_engine_group_by_columns]\n parms['order_by_hidden_field'] = report_state_hash[:search_engine_order_by_columns]\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end", "def params_to_pass\n settings\n end", "def params=(_); end", "def all_params; end", "def query_params; 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 user_params\n end", "def extra_field_params\n params.require(:extra_field).permit(:cms_page_id, :field_name, :field_value, :field_setting, :back)\n end", "def activity_params \n \n raw_parameters = { \n :activity_Name => \"#{params[:activity_name]}\",\n :active => \"#{params[:active]}\",\n :activity_description => \"#{params[:activity_description]}\",\n :is_page => \"#{params[:is_page]}\"\n }\n parameters = ActionController::Parameters.new(raw_parameters)\n parameters.permit( :activity_Name, :active, :activity_description, :is_page)\n \n end", "def page_element_params \n params.fetch(:page_element).permit(:page_id,:displayIndex, :sidebar, :visible,:text, :headline, :border, :name, :pictureR,:picture)\n end", "def form_field_params\n params[:form_field]\n end", "def query_string_params\n super + [:chg]\n end", "def set_duration\n #These need to be passed on to recreate the original form should cancel then set be pressed\n @object_name = params[:object_name]\n @field_name = params[:field_name]\n @optional = params[:optional]\n @prefix = params[:prefix]\n end", "def parametro_params\n params.require(:parametro).permit(:descripcion, :observacion)\n end", "def valid_params?; end", "def parameters()\n @melody = params[:melody].upcase.split(\",\") # create array of notes in melody parameter\n @shift = params[:shift] # shift parameter\nend", "def controlpleit_params\n params.require(:controlpleit).permit(:n1, :n2, :siglas, :limite, :vendida)\n end", "def attr_params\n params[:attr].permit(:name, :type, :value, :foreign_key, :ordinal, :group, :visible, :editable, :required, :input)\n end", "def get_params\n @set_params\n end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def internalform_params\n params.permit( :goal, :infu_id)\n end", "def user_params\nend", "def page_params\n end", "def permitted_params\n @wfd_edit_parameters\n end", "def form_params\n params.require(:form).permit(:name, :user_id, :search, :description, :parent_id,\n :status, :version_independent_id, :control_number)\n end", "def valid_params_request?; end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def tbl_form_field_params\n params.require(:tbl_form_field).permit(:FieldID, :FieldTitle, :FieldType, :FieldValue, :Tooltip, :Status)\n end", "def parameter_detail_params\n params.require(:parameter_detail).permit(:parameter_id, :afp_id, :aporte, :seguro, :comision_flujo,:comision_mixta,:comision_mixta_saldo)\n end", "def get_params\r\n #params.require(:widget).permit(:name)\r\n params.require(:widget).permit!\r\n end", "def form_params\n params.require(:form).permit(:name, :alias, :type, :active, :structure_id, :user_id)\n end", "def controlqreat_params\n params.require(:controlqreat).permit(:numero, :limite, :vendida)\n end", "def controldepagogt_params\n params.require(:controldepagogt).permit(:tipojugada, :limitexticket, :limiteglobal)\n end", "def get_parameters; end", "def get_parameters; end", "def crud_params\n params.require(:crud).permit(:field1, :field2)\n end", "def setting_params\n puts params\n params.require(:user).permit(:phone, :other_phone, :other_email)\n end", "def params\n @_params\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 business_params\n #params.require(:branch).permit(:name, :active, :user_id)\n\n raw_parameters = { :name => \"#{params[:name]}\", :active => \"#{params[:active]}\", :user_id => \"#{params[:user_id]}\", :description => \"#{params[:description]}\" }\n parameters = ActionController::Parameters.new(raw_parameters)\n parameters.permit(:name, :active, :description, :user_id)\n \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_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end", "def customizing_params\n params.require(:customizing).permit(:id, :name_id, :version, :software_id, :feature, :freigabe_status_id, :software_req_min, :software_req_max) \n # params[:customizing]\n end", "def field=(field_name)\n parameters[:field] = field_name\n end", "def parametrage_params\n params.require(:parametrage).permit(:libelle, :typeParam)\n end", "def load_edit(params)\n self.first_name = params.fetch(\"first_name\", \"\").strip\n self.surname = params.fetch(\"surname\", \"\").strip\n self.username = params.fetch(\"username\", \"\").strip\n self.email = params.fetch(\"email\", \"\").strip\n end", "def usuario_params\n \n end", "def update_form(params)\n params.reject do |key, _value|\n attribute_parameter?(key)\n end.each do |key, value|\n self[key.to_sym] = SmartAttributes::AttributeFactory.build(key, default_attributes(key)) if self[key.to_sym].nil?\n self[key.to_sym].value = value\n end\n end", "def evaluation_params\n params.permit(:date_completed,:purpose ,:contribution, :team_contribution, :managers, :manager_performance, :outstanding_participation, :poor_participation, :other)\n end", "def field_params\n params.require(:field).permit(:title, :height, :width, :price, :magazine_id, :status)\n end", "def set_questionnaire_parameters(private_flag, display)\n @questionnaire.private = private_flag\n @questionnaire.name = params[:questionnaire][:name]\n @questionnaire.instructor_id = session[:user].id\n @questionnaire.min_question_score = params[:questionnaire][:min_question_score]\n @questionnaire.max_question_score = params[:questionnaire][:max_question_score]\n @questionnaire.type = params[:questionnaire][:type]\n @questionnaire.display_type = display\n @questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL\n @questionnaire.save\n end", "def params\n raise NotImplementedError\n end", "def params\n raise \"Invalid CGI\" unless @cgi\n @cgi.params\n end", "def parameters\n @ui_parameters ||= []\n @ui_parameters\n end", "def parameter_string\n\t\tend", "def verb_params\n @forms = [:je, :tu, :il, :nous, :vous, :ils]\n @t = [:présent => @forms, :passé_composé => @forms, :imparfait => @forms, :plus_que_parfait => @forms,\n :passé_simple => @forms, :passé_antérieur => @forms, :futur_simple => @forms, :futur_antérieur => @forms,:subjonctif_présent => @forms,\n :subjonctif_passé => @forms,:subjonctif_imparfait => @forms, :subjonctif_plus_que_parfait => @forms, :conditionnel_présent => @forms, :conditionnel_passé_première => @forms, :conditionnel_passé_deuxième => @forms]\n @par = [:infinitive, :translation, :group].concat(@t)\n params.require(:verb).permit(@par)\n end", "def controlpreat_params\n params.require(:controlpreat).permit(:n1, :n2, :siglas, :limite, :vendida)\n end", "def params\n { username: 'admin', password: 'admin' }\n end", "def special_params\n @special_params ||= %i[id class inherited border borders]\n end", "def option_params\n params.permit(:name, :value)\n end" ]
[ "0.6702531", "0.6601398", "0.64557844", "0.6426045", "0.6426045", "0.6426045", "0.6426045", "0.6426045", "0.6426045", "0.6426045", "0.6426045", "0.6426045", "0.6426045", "0.6426045", "0.6426045", "0.6426045", "0.6426045", "0.6426045", "0.6426045", "0.6426045", "0.64106864", "0.6329096", "0.62635", "0.62362826", "0.61965966", "0.6180983", "0.6168263", "0.61550087", "0.6145211", "0.6128048", "0.6128048", "0.6128048", "0.6128048", "0.6128048", "0.6128048", "0.6128048", "0.6128048", "0.61207026", "0.61199635", "0.61006474", "0.6081149", "0.6074017", "0.60554093", "0.60519344", "0.6030663", "0.60168904", "0.59969324", "0.5995233", "0.59882915", "0.5971995", "0.59390146", "0.593888", "0.5927504", "0.59222883", "0.5922047", "0.591035", "0.5907172", "0.5904605", "0.5893775", "0.58863336", "0.58671355", "0.5864089", "0.58579403", "0.58526707", "0.58516145", "0.58315766", "0.58217126", "0.58190995", "0.58186513", "0.5817807", "0.5812206", "0.5807694", "0.5801757", "0.5801029", "0.57902926", "0.57902926", "0.5787944", "0.578577", "0.57829183", "0.57820696", "0.57800317", "0.5779886", "0.5772759", "0.5766396", "0.5766002", "0.57653785", "0.57650167", "0.5764789", "0.57555354", "0.5746153", "0.5738623", "0.57327604", "0.57297945", "0.5727611", "0.57253194", "0.57236224", "0.57211924", "0.5719249", "0.57160765", "0.57106286", "0.570789" ]
0.0
-1
Provide a humanfriendly refresh process
def recall_item if is_downloadable? if is_viewable? respond_to do |format| format.html { render 'recall_item', status: :see_other } format.json { json_delegate_response } end else respond_to do |format| format.html { render unauthorized_template, status: :unauthorized } format.json { json_unauthorized_response } end end else respond_to do |format| format.html { render 'item_not_found', status: :not_found } format.json { json_not_found_response } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def refresh!; end", "def refresh\n do_refresh\n end", "def refresh\n do_refresh\n end", "def refresh\n send_cmd \"refresh\"\n nil\n end", "def refresh\r\n end", "def refresh; schedule_update end", "def refresh\n end", "def refresh; end", "def refresh\n end", "def refresh\n end", "def process\n @type = 'refresh'\n full_analysis\n end", "def refresh\r\n command 'refresh'\r\n end", "def refresh\r\n command 'refresh'\r\n end", "def refresh\n # FIXME\n end", "def refresh\n Vedeu.trigger(\"_refresh_#{current}_\".to_sym)\n end", "def refresh\n do_refresh\n self\n end", "def meta_refresh; end", "def refresh\n command(\"Page.reload\", wait: timeout, slowmoable: true)\n end", "def refresh\n Vedeu.trigger(:_refresh_, current)\n end", "def reload\n refresh\n end", "def reload\n refresh\n end", "def refresh()\n\t\[email protected] \"refresh\"\n\tend", "def refresh!\n load if changed?\n end", "def refresh\n if @mode == :info\n refresh_info\n elsif @mode == :reward\n refresh_rewards\n end\n end", "def refresh!\n description.update!(send_messages([ refresh_command ]).documents[0])\n end", "def refresh\n conf['dashboard']['refresh'].to_s\n end", "def request_ui_refresh\n @ui_refresh_executor.call\n end", "def after_refresh(_options = {}); end", "def refresh\n load if changed?\n end", "def refresh!\n refresh\n @window.refresh\n end", "def refresh\n raise NotImplementedError.new('I do not know how to refresh myself, please implement it in subclass.')\n end", "def start_refresh\n self.refresh_in_progress = true\n save\n end", "def refresh\n update_databases()\n render json: {message: \"Information will be updated shortly\"}, status: :ok\n end", "def refresh()\r\n #set_browser_document()\r\n $jssh_socket.send(\"#{BROWSER_VAR}.reload();\\n\", 0)\r\n read_socket();\r\n wait()\r\n end", "def refresh!\n raise NotImplementedError, \"#refresh! is not implemented on #{@provider}:#{@type}\"\n end", "def refresh\r\n @view.refresh\r\n end", "def refresh\n @browser.refresh\n end", "def enable_refresh\n add option: \"-refresh=true\"\n end", "def refresh!\n self.size! if @size\n refresh_digests! if respond_to?(:refresh_all_digests!)\n self.mimetype! if @mimetype\n self\n end", "def refresh!(params = {})\n super\n .tap { |result| __ext_debug(\"--> #{result.inspect}\") }\n end", "def refresh\n @server.make_json_request('show.refresh', tvdbid: @tvdbid)['message']\n end", "def refresh(op)\n check_connection\n @protocol.refresh_command op\n self\n end", "def reload\n Howitzer::Log.info \"Reload '#{current_url}'\"\n visit current_url\n end", "def refresh(*args)\n alloc(*args).refresh\n end", "def reloads\n load_page\n end", "def refresh\n tracking = tracking_handler.refresh!\n if tracking.success?\n flash[:success] = 'Tracking was successfully refreshed'\n else\n flash[:error] = tracking.error\n end\n redirect_to navigation.back(1)\n end", "def refresh!\n unpack(agent.get(url))\n self\n end", "def reload!; end", "def reload!; end", "def reload!; end", "def reload!; end", "def update_feature\n @feature = params[:feature] \n @series = MoleLog.compute_series( @feature, @app_name, @min_date, @max_date ) \n @delay = rand( 10 ) + REFRESH_RATE \n @title = @feature\n @url = \"/graphs/update_feature?feature=#{CGI.escape(@feature)}\"\n render :template => 'graphs/partial_refresh', :layout => false\n end", "def refresh\n render js: \"location.reload()\"\n end", "def refresh(params={})\n body = refresh_body(params)\n raw_request = post(body)\n\n parse(raw_request)\n end", "def refresh()\r\n Fiber.yield\r\n end", "def refresh()\r\n Fiber.yield\r\n end", "def reload\n end", "def reload\n end", "def reload\n end", "def reload\n end", "def reload\n end", "def reload\n end", "def reload\n end", "def reload\n end", "def reload\n end", "def refresh!(*args)\n alloc(*args).refresh!\n end", "def do_refresh_confirmed!\n end", "def follow_meta_refresh; end", "def follow_meta_refresh; end", "def refresh\n store\n\n render\n\n self\n end", "def reload\n stop\n start\n end", "def follow_meta_refresh=(_arg0); end", "def refresh\n response = Clever.request :get, url\n refresh_from response[:data]\n self\n end", "def refresh\n @window.refresh\n end", "def refresh\n if address.resolve(current_actor)\n begin\n @refreshed_at = Time.now\n if synchronize.value(refresh_timeout)\n cluster.handle_refresh(current_actor)\n else\n down\n end\n rescue Timeout::Error\n down\n end\n end\n end", "def reload\n do_url 'reload', :put\n end", "def refresh\n return false\n end", "def refresh!\n # if self.payment_preauthorized? || self.confirmed? || self.started? || self.archived?\n # LOG.info \"Not possible to refresh.\"\n # end\n\n if self.created?\n do_refresh_created!\n elsif self.confirmed?\n #do_refresh_confirmed!\n else\n LOG.info \"Not possible to refresh.\"\n LOG.info message: \"Nothing to do for this booking.\", booking_id: self.id, booking_status: self.status\n end\n end", "def reload\n end", "def refresh(command, freshness = 0.0, &block)\n if (estimate_world_time - message_time(command)) > freshness\n # Note: Because global callbacks occur before local, on_* will\n # have a chance to update data before the following block.call\n ignore_arg = Proc.new { |r| block.call if block }\n\n #puts \"refreshing #{command.to_s}\"\n send(command, &ignore_arg)\n else\n #puts \"calling secondary block for #{command.to_s}\"\n block.call if block\n end\n end", "def refresh_all!\n self.size!\n refresh_all_digests! if respond_to?(:refresh_all_digests!)\n self.mimetype!\n self\n end", "def reload\n restart_and_ping\n end", "def render_refresh_time\n \"#{@pattern ? \"search: /#{@pattern}/\" : ''} page: #{model.index} Refresh: #{model.last_refresh.strftime('%Y-%m-%d %H:%M:%S')}\"\n end", "def reload;end", "def reload\n reset\n fetch\n end", "def reload\n reset\n fetch\n end", "def refresh\n respond_to do |format|\n @endpoint.last_refresh_request_at = Time.now\n\n if @endpoint.save\n RefreshEndpointWorker.perform_async RefreshSubmission.new(@endpoint.id)\n\n format.html { redirect_to root_url, notice: 'Endpoint refreshing.' }\n format.json { head :ok }\n else\n format.html { head :unprocessable_entity }\n format.json { render json: @endpoint.errors, status: :unprocessable_entity }\n end\n end\n end", "def process_refresh!\n case self.transaction_type.to_sym\n when :preauth\n do_preauth_refresh\n when :payout\n do_payout_refresh\n when :payin_refund\n do_refund_refresh\n when :payin\n do_payin_refresh\n else\n LOG.error message: \"Cannot refresh this type of transaction\", financial_transaction_id: self.id, transaction_type: self.transaction_type\n raise \"Cannot refresh this type of transaction\"\n end\n end", "def refresh\n page = @agent.get('https://wwws.mint.com/overview.event')\n\n @agent.post(\"https://wwws.mint.com/refreshFILogins.xevent\", {\"token\"=>@token})\n\n true\n \n end", "def refresh\n fetch_api_data\n self\n end", "def refresh\n @patt = nil\n @title = nil\n rescan_required\nend", "def reload(request, response)\n @roundhouse.load(@cfg)\n give_X(response, 200, \"text/plain\", \"Reloading..\")\n end", "def render_refresh(tags)\n if refresh = meta_tags.extract(:refresh)\n tags << Tag.new(:meta, 'http-equiv' => 'refresh', :content => refresh.to_s) if refresh.present?\n end\n end", "def follow_meta_refresh_self; end", "def follow_meta_refresh_self; end", "def refresh\n\t\t\treturn if completed?\n\t\t\t_runner.refresh\n\t\tend", "def refresh\n Vedeu.trigger(:_refresh_view_, current)\n\n Vedeu.trigger(:_refresh_cursor_, current)\n end", "def reload_status\n get(\"reload\")\n end", "def action_reload\n return if options['never_reload']\n notify_if_service do\n service_resource.run_action(:hup)\n end\n end", "def menu_refresh\n @refresh_signals.each do |signal|\n signal.call\n end\n end", "def menu_refresh\n @refresh_signals.each do |signal|\n signal.call\n end\n end" ]
[ "0.80257064", "0.7986451", "0.7986451", "0.78527427", "0.7835058", "0.7789048", "0.77886134", "0.77767205", "0.7774065", "0.7774065", "0.75796705", "0.75768477", "0.75768477", "0.7533585", "0.75304383", "0.73102164", "0.71657956", "0.6979179", "0.6946377", "0.6922163", "0.6922163", "0.6860016", "0.6855283", "0.68097895", "0.67518246", "0.6744689", "0.6687377", "0.6659715", "0.66545445", "0.664202", "0.66239667", "0.66009575", "0.65879494", "0.6552637", "0.6535814", "0.65145785", "0.64982015", "0.64954954", "0.6493308", "0.6462008", "0.6401527", "0.6401242", "0.63807434", "0.6370988", "0.6360686", "0.63515466", "0.6343709", "0.63380265", "0.63380265", "0.63380265", "0.63380265", "0.6334248", "0.6333509", "0.63253", "0.6324516", "0.6324516", "0.6318512", "0.6318512", "0.62931186", "0.62931186", "0.62931186", "0.62931186", "0.62931186", "0.62931186", "0.62931186", "0.6270784", "0.6263784", "0.62509423", "0.62509423", "0.62386006", "0.6236007", "0.62354887", "0.62293434", "0.622151", "0.6215074", "0.6213544", "0.6210941", "0.62015676", "0.6176239", "0.6174296", "0.61668164", "0.6166607", "0.61634463", "0.6160229", "0.6158144", "0.6158144", "0.6156145", "0.61528546", "0.61396533", "0.61373633", "0.6130754", "0.61231625", "0.61231184", "0.6122095", "0.6122095", "0.61090994", "0.610116", "0.6097327", "0.6088947", "0.6088141", "0.6088141" ]
0.0
-1
JSON API requests & noscript fallback HTML responses
def request_item if is_downloadable? if is_viewable? respond_to do |format| format.html do flash[:notice] = 'File retrieval request received.' redirect_to( recall_bendo_item_path(id: noid), status: :found ) end format.json { json_api_response } end else respond_to do |format| format.html do flash[:alert] = "You are not permitted to view the item with ID: #{noid}" redirect_to recall_bendo_item_path(id: noid) end format.json { json_unauthorized_response } end end else respond_to do |format| format.html do flash[:alert] = "No files can be downloaded for ID: #{noid}" redirect_to recall_bendo_item_path(id: noid) end format.json { json_not_found_response } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_xhrml\n if get? || !has_errors? || response_overridden?\n to_html\n else\n render action: default_action, status: :unprocessable_entity\n end\n end", "def json_get\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n write_json @note if @note\n render :nothing => true\n end", "def api_response\n response api_html(to_markup)\n end", "def non_xhr_javascript_response?; end", "def render_figgy_404 # rubocop:disable Naming/VariableNumber\n respond_to do |format|\n format.html { render \"errors/not_found\", status: :not_found }\n format.json { head :not_found }\n end\n end", "def api_render\n # Format?\n request.format = \"xml\" if request.format.html? # weird hack to support legacy behavior, with xml as default\n if params[\"umlaut.response_format\"] == \"jsonp\"\n request.format = \"json\"\n params[\"umlaut.jsonp\"] ||= \"umlautLoaded\"\n elsif params[\"umlaut.response_format\"]\n request.format = params[\"umlaut.response_format\"]\n end\n\n respond_to do |format|\n format.xml do\n render(:layout => false)\n end\n\n format.json do\n # get the xml in a string\n xml_str =\n with_format(:xml) do\n render_to_string(:layout=>false)\n end\n # convert to hash. For some reason the ActionView::OutputBuffer\n # we actually have (which looks like a String but isn't exactly)\n # can't be converted to a hash, we need to really force String\n # with #to_str\n data_as_hash = Hash.from_xml( xml_str.to_str )\n # And conver to json. Ta-da!\n json_str = data_as_hash.to_json\n # Handle jsonp, deliver JSON inside a javascript function call,\n # with function name specified in parameters.\n render(:json => json_str, :callback => params[\"umlaut.jsonp\"] )\n end\n end\n end", "def xhr?; end", "def render_404\n unless request.format.json?\n request.format = \"html\"\n end\n respond_to do |format|\n format.json { render json: { error: t(:not_found) }, status: 404 }\n format.all { render template: \"errors/error_404\", status: 404, layout: \"application\" }\n end\n end", "def not_found\n render json: nil, status: :not_found\n end", "def render_not_found(error)\n json_response({ error: { message: error.message } }, :not_found)\n end", "def test_non_json_response\n app = TestApp.new(JsonP) do |env|\n [200, {'Content-Type' => 'test/html'}, ['<p>User: alice</p>']]\n end\n\n response = app.get('/user', params: {'callback' => 'parseUser'})\n\n expected_body = '<p>User: alice</p>'\n assert_equal expected_body, response.body\n end", "def url_to_html\n # Registering Providers - Youtube and Instagram\n OEmbed::Providers.register(OEmbed::Providers::Youtube, OEmbed::Providers::Instagram)\n resource = OEmbed::Providers.get(params[:url])\n respond_to do |format|\n format.html { render json: { error: false, html: resource.html } }\n format.json { render json: { error: false, html: resource.html } }\n end\n rescue\n respond_to do |format|\n format.html { render json: { error: true, message: 'Something wrong with URL' } }\n format.json { render json: { error: true, message: 'Something wrong with URL' } }\n end\n end", "def default_render\n # if this api_method is blank, and error should already have been rendered\n return if @api_method.blank?\n if Rails.env.development? || Rails.env.test_dev?\n @json_response = @api_method.call(params)\n else\n begin\n @json_response = @api_method.call(params)\n rescue ActiveRecord::RecordNotFound => e\n return render_error(e.message, 404)\n rescue EOL::Exceptions::ApiException => e\n return render_error(e.message)\n rescue => e\n EOL.log(\"API error (#{@api_method})\")\n EOL.log_error(e)\n return render_error('Sorry, there was a problem')\n end\n end\n\n # return the JSON object generated above, OR\n # render the default (or custom) partial for this method: e.g. api/search_1_0.xml.builder\n respond_to do |format|\n if @api_method::TEMPLATE\n xml_template = @api_method::TEMPLATE\n else\n xml_template = \"api/#{params[:action]}_#{@api_method::VERSION.tr('.', '_')}\"\n end\n format.xml { render template: xml_template, layout: false }\n format.json { render json: @json_response, callback: params[:callback] }\n end\n end", "def not_found\n render(\n json: {\n errors: [{\n type: \"Not Found\"\n }]\n },\n status: :not_found #alias for 404 in rails\n )\n end", "def not_found!\n [404, {\"Content-Type\" => \"text/plain\"}, [\"Jsus doesn't know anything about this entity\"]]\n end", "def show_not_found\n render_json_error(code: :show_not_found, status: :not_found)\n end", "def treat_as_standard_html_request?\n !request.format.json? and !request.format.print? and !request.format.video?\n end", "def treat_as_standard_html_request?\n !request.format.json? and !request.format.print? and !request.format.video?\n end", "def unrecognizedResponse( text )\n end", "def get_domoticz_json(domoticz_uri)\n uri = URI(domoticz_uri)\n response = Net::HTTP.get(uri)\n JSON.parse(response)\nend", "def json_ld_script_block\n resource = eval('@' + controller_name.singularize)\n if resource && resource.rdf_supported?\n begin\n content_tag :script, type: 'application/ld+json' do\n resource.to_json_ld.html_safe\n end\n rescue Exception => exception\n if Seek::Config.exception_notification_enabled\n data[:message] = 'Error embedding JSON-LD into page HEAD'\n data[:item] = resource.inspect\n ExceptionNotifier.notify_exception(exception, data: data)\n end\n ''\n end\n end\n end", "def bar\n respond_to(:json)\n erase_render_results\n end", "def xhr_script; end", "def show_broken\n @objects = Node.find_broken\n respond_to do |format|\n format.html\n format.json {render json: @objects}\n end\n end", "def index\n @search = Quirk.accessible_by(current_ability).search(params[:search])\n @quirks = @search.result(:order => 'name', :include=>[:servers])\n if request.xhr?\n render :partial => 'listing'\n else\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @quirks }\n format.json { render :json => @quirks}\n end\n end\n end", "def show_simple_json\n @document_object = Document.find(params[:id]).as_json\n\n job = Job.find(@document_object[\"job_id\"].to_i)\n\n #Let's add some extra stuff, like some job data, for JS.\n @document_object['job_succeeded'] = job[:succeeded] \\\n rescue @document_object['job_succeeded'] = false\n @document_object['job_waiting'] = job[:waiting] \\\n rescue @document_object['job_waiting'] = false\n @document_object['job_started'] = job[:started] \\\n rescue @document_object['job_started'] = false\n @document_object['job_error_or_output'] = job.get_error_or_output \\\n rescue @document_object['job_error_or_output'] = false\n\n respond_to do |format|\n format.json { render json: @document_object }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @hack }\n end\n end", "def show_json\n end", "def show\n respond_to do |format|\n format.any { head :no_content }\n end\n end", "def no_content\n halt 204, \"\"\n end", "def not_found\n render :format => :html\n end", "def render_404\n render(\n json: {\n error_messages: ['Resource does not exist'],\n error_code: 'NOT_FOUND'\n },\n status: 404\n )\n end", "def render_not_found(type, id, option='id')\n payload = { errors: { general: [\"Could not find #{type} with '#{option}'=#{id}\"] } }\n render json: payload, status: 404\n end", "def object_not_found\n render json: 'Object not found', status: :not_found\n end", "def check_format\n not_found unless request.xhr?\n end", "def not_found_body\n\n # Don't show google search if it's embedded in the Ember app\n @hide_google = true\n\n render text: build_not_found_page(200, false)\n end", "def response_not_found\n render status: 404,\n json: {\n source: {\n pointer: request.original_url\n },\n errors: [ { message: \"Not Found\" } ]\n }\n end", "def render(*)\n respond_to do |format|\n format.jsonapi { super }\n format.json { super }\n end\n end", "def ensure_json_request\n return render_message({status:ERR_STATUS,responseMessage: NOT_ACCEPTABLE_MESSAGE, responseCode: NOT_ACCEPTABLE }) unless request.format == :json\n end", "def fallback\n head :ok\n end", "def return_404\n render :json => {:error => \"not-found\"}.to_json, :status => 404\n end", "def get_content_from_server(language)\n Browser::HTTP.get(\"try_ruby_#{language}.json\") do\n on :success do |response|\n TryRuby.instance.update_json(response.json)\n end\n\n on :failure do |response|\n puts \"\\nWhoops! Loading the tutorial failed \" \\\n \"(status = #{response.status_code}).\\n\" \\\n \"Please reload the page.\"\n end\n end\n end", "def index\n respond_to do |format|\n format.html {\n if params['f'].nil?\n params['f'] = {'generic_type_sim' => ['Work']}\n end\n }\n end\n (@response, @document_list) = get_search_results\n respond_to do |format|\n format.html { }\n format.rss { render :layout => false }\n format.atom { render :layout => false }\n format.oaipmh { render :layout => false } # <-- This is the only line that we actually want to override.\n format.json do\n render json: render_search_results_as_json\n end\n\n additional_response_formats(format)\n document_export_formats(format)\n end\n end", "def not_found\n render(status: :not_found, json: { errors: [{\n status: '404', code: :not_found, title: 'Not Found'\n }]})\n # render jsonapi: nil, code: 404, title: 'Invalid Path', detail: params[:path], status: :not_found\n end", "def show\n # TODO: this is a placeholder for logic using Sentence\n render :json => { :index => params[:id],\n :contents => \"SERVER: this would be the contents of page \" + params[:id]\n }\n end", "def show\n respond_to do |wants|\n wants.html\n wants.json\n wants.jsonld { render body: export_as_jsonld, content_type: 'application/ld+json' }\n wants.nt { render body: export_as_nt, content_type: 'application/n-triples' }\n wants.ttl { render body: export_as_ttl, content_type: 'text/turtle' }\n end\n end", "def show\n respond_to do |wants|\n wants.html\n wants.json\n wants.jsonld { render body: export_as_jsonld, content_type: 'application/ld+json' }\n wants.nt { render body: export_as_nt, content_type: 'application/n-triples' }\n wants.ttl { render body: export_as_ttl, content_type: 'text/turtle' }\n end\n end", "def undocumented_method\n render :json => {:result => \"ok\"}\n end", "def invalid_json_response\n <<~RESPONSE\n {\n foo : bar\n }\n RESPONSE\n end", "def not_found\n render json: { error: { message: 'There was nothing found at this address.' }}, status: :not_found\n end", "def not_acceptable\n render :format => :html\n end", "def not_acceptable\n render :format => :html\n end", "def not_acceptable\n render :format => :html\n end", "def not_acceptable\n render :format => :html\n end", "def not_acceptable\n render :format => :html\n end", "def no_ajax # :nologin: :norobots:\n end", "def not_implemented(object)\n render json: object, status: 501\n end", "def raw\n raise(ActionController::RoutingError, 'Not Found') unless blacklight_config.raw_endpoint.enabled\n\n @document = search_service.fetch(params[:id])\n render json: @document\n end", "def render_forbidden(obj)\n render json: nil_protection(obj), status: :forbidden\n end", "def render_json\n end", "def render_json(json)\n self.response[:headers]['Content-Type'] = 'text/javascript'\n self.response[:body] = json\n end", "def show\n @resp = Response.find(params[:id])\n\n respond_to do |format|\n format.html\n format.js do\n content = render_to_string(:layout => false)\n render :update do |page|\n page.replace_html 'responsebody', content\n page.replace_html 'responsetitle', @resp.title\n page.call 'showResponseViewer', @resp.id\n page << \"$$('#responsebody > form input[type=submit]').each(function(elt) { elt.hide(); });\"\n end\n end\n end\n end", "def index\r\n #respond_with\r\n if current_user_from_api_access\r\n respond_to do |format|\r\n format.json { render json: current_user_from_api_access.measurements.all.to_json }\r\n\tformat.html { render text: current_user_from_api_access.measurements.all.to_json }\r\n end\r\n else\r\n respond_to do |format|\r\n format.json { render json: { \"result\" => \"Fail\", \"message\" => \"Invalid user\" }.to_json }\r\n end\r\n end\r\n end", "def api_response\n nil\n end", "def interesting(options = {})\n response = Typhoeus::Request.get(\"#{DARKSKY_API_URL}/interesting/#{@api_key}\", DEFAULT_OPTIONS.dup.merge(options))\n JSON.parse(response.body) if response.code == 200 \n end", "def render_nil?\n JSON_RENDER_NIL\n end", "def not_found(exception)\n render json: { status: \"404\", \"#{exception.message}\": \"page not found\"}\n end", "def get\n puts \"In entries#get, params=#{params}\"\n context = params\n context[:entry_id] = params[:id]\n context[:mode] = 'display'\n context[:view_type] = \"table\"\n\n @entryHtml = getEntryHtml(context)\n if request.xhr? \n render :json => {:html => @entryHtml, :context => context}\n else\n render :template => \"/entries/get.html.erb\"\n\n end\n\n end", "def json_render(json = {})\n json_render_html('success', json)\n end", "def render_error_response_for(service_response)\n http_code = service_response.http_code\n @page_assets_data = {specific_js_required: 0}\n\n # Clean critical data\n service_response.data = {}\n\n if request.xhr?\n (render plain: Oj.dump(service_response.to_json, mode: :compat), status: http_code) and return\n else\n render file: \"public/#{http_code}.html\", layout: false, status: http_code and return\n end\n\n end", "def respond(link, url)\n case params['format']\n # Handle format = html\n when 'html'\n return haml :main, locals: { link: link }\n # Handle format = image\n when 'image'\n link.sub!('https://', 'http://')\n uri = URI(link)\n\n head = Net::HTTP.start(uri.host, uri.port) do |http|\n http.head(uri.request_uri)\n end\n\n headers 'Content-Type' => 'image/jpeg'\n headers 'Cache-Control' => 'max-age=2592000, no-transform, public'\n headers 'Expires' => 'Thu, 29 Sep 2022 01:22:54 GMT+00:00'\n\n return stream do |out|\n Net::HTTP.get_response(uri) do |f|\n f.read_body { |ch| out << ch }\n end\n end\n # Handle no format or format = json.\n else\n content_type :json\n return JSONP({ link: link, website: url }) # JSONP is an alias for jsonp method\n end\nend", "def respond_to_empty\n respond_to do |f|\n f.json { render nothing: true, layout: \"axel\", status: header_status }\n f.xml { render nothing: true, layout: \"axel\", status: header_status }\n end\n end", "def record_not_found\n render :json => {:success=>false, :error_code => 404, :error_msg=>\"Record not Found\"}\n end", "def index\n if request.format.html?\n api_canon_docs\n else\n super\n end\n end", "def h1; api.out \"<h1>#{api.data}</h1>\"; end", "def blank; render :plain => \"Not Found.\", :status => 404 end", "def index\n @articles = Article.un_verified\n\n respond_to do |format|\n format.html {\n if params[:raw]\n render layout: false\n else\n render\n end\n } # index.html.erb\n format.json { render json: @articles }\n end\n end", "def render_output name = nil, items = nil\n content_type :json\n\n #compose output JSON\n output = {:status => \"ok\", :executed_at => Time.now.strftime(\"%Y-%m-%d %H:%M:%S\"), :message => \"ok\"}\n \n #items and name specified\n return JSON.pretty_generate(output.merge({ name => items })) if name && items\n\n #name specified\n return JSON.pretty_generate(output.merge({ :output => name })) if name\n\n #only response with ok message\n return JSON.pretty_generate(output)\nend", "def index\r\n render json: { status: \"Test API\"}\r\n end", "def json_get(url)\n get url, :parse=>true\n end", "def handle_links(json) end", "def processJSON(json)\n # \"Pretty Print\" the JSON response\n pp json\nend", "def get_json(url)\n JSON.parse(Net::HTTP.get(URI(url)))\nrescue StandardError => e\n puts \"Could not fetch notes from the GitHub API (#{e})\"\nend", "def deny_access\n respond_to do |format|\n format.json {\n # Some schools of thought advocate the use of 404 (:not_found). See\n # http://www.bennadel.com/blog/2400-handling-forbidden-restful-requests-401-vs-403-vs-404.htm\n render json: {}, status: :unauthorized\n }\n end\n end", "def show\n respond_to do |format|\n format.html\n format.json { render jsonapi: @post }\n end\n end", "def render(opts = {}, &block)\n \n opts[:status] = 200 if !opts[:status]\n if opts[:to_yaml] then\n headers[\"Content-Type\"] = \"text/plain;\"\n yaml = Hash.from_xml(render_to_string(:template => opts[:to_yaml], :layout => false)).to_yaml\n render :text => yaml, :layout => false, :status => opts[:status]\n elsif opts[:to_json] then\n hash = Hash.from_xml(render_to_string(:template => opts[:to_json], :layout => false))\n hash = hash[hash.keys.first] if hash.keys.length == 1\n content = hash.to_json\n cbparam = params[:callback] || params[:jsonp]\n content = \"#{cbparam}(#{content})\" unless cbparam.blank?\n render :json => content, :layout => false, :status => opts[:status]\n elsif opts[:to_xml]\n content = render_to_string(:template => opts[:to_xml], :layout => false)\n headers[\"Content-Type\"] = \"application/xml;\"\n render :text => content, :layout => false, :status => opts[:status]\n elsif opts[:response]\n render_rest_response opts[:response]\n else\n super opts, &block\n end\nend", "def raw_response; end", "def general_response(opts = {})\n success = opts[:success] || opts[:success] == nil\n success = false if opts[:errs].present? || opts[:err].present?\n render :json => { :success => success }.merge(opts)\n end", "def ajax\n\n uri_string = @params[:uri]\n # uri_string = \"http://www.phase-eight.com#{path_string}\"\n uri = construct_uri_object uri_string\n response = network_response uri\n logger.debug \"XHR response type #{response.content_type}\"\n logger.debug \"XHR response body #{response.body.html_safe}\"\n render text: response.body\n end", "def record_not_found\n render json: {error: \"Record not found\"}.to_json, status: 404\n end", "def error_404\n if !request.xhr?\n render :template => \"errors/404\", :status => \"404 Error\"\n else\n respond_to do |format|\n format.json {render :json => {\n :error => \"404\",\n }, :status => \"404\"}\n end\n end\n end", "def make_not_acceptable_body( response )\n\t\t# :TODO: Unless it was a HEAD request, the response SHOULD include\n\t\t# an entity containing a list of available entity characteristics and\n\t\t# location(s) from which the user or user agent can choose the one\n\t\t# most appropriate. The entity format is specified by the media type\n\t\t# given in the Content-Type header field. Depending upon the format\n\t\t# and the capabilities of the user agent, selection of the most\n\t\t# appropriate choice MAY be performed automatically. However, this\n\t\t# specification does not define any standard for such automatic\n\t\t# selection. [RFC2616]\n\t\treturn \"No way to respond given the requested acceptance criteria.\"\n\tend", "def render_404\n render json: {\n message: '404 Not Found',\n details: exception.error_codes\n }, status: 404\n end", "def respond_with(text)\n response = formatted_errors + postproc(text)\n cache_response!(response) if cache?\n [200, {\"Content-Type\" => \"text/javascript\"}, [response]]\n end", "def get_page(url)\n # If Nokogiri can't get the url stop the execution\n # and return a message to client\n begin\n Nokogiri::HTML(open(params[:url]))\n rescue => exception\n return render json: {errors: exception.message}, status: 422\n end\n end", "def printresp(resp)\n if (!resp.is_a?(String))\n puts JSON.pretty_generate(resp)\n else\n puts resp\n end\nend", "def from_api?; false end", "def response_from_page_or_rjs()\n content_type = @response.content_type\n\n if content_type && content_type =~ /text\\/javascript/\n body = @response.body.dup\n root = HTML::Node.new(nil)\n\n while true\n next if body.sub!(RJS_PATTERN_EVERYTHING) do |match|\n html = unescape_rjs($3)\n matches = HTML::Document.new(html).root.children.select { |n| n.tag? }\n root.children.concat matches\n \"\"\n end\n break\n end\n\n root\n else\n html_document.root\n end\n end", "def render(*args, &block)\n super(*args, &block)\n opts = args.first\n if opts.has_key?(:text) && opts[:text].present?\n self.response_body = opts[:text]\n elsif opts.has_key?(:nothing) && opts[:nothing]\n self.response_body = \" \"\n else\n raise UnsupportedOperationError\n end\n end", "def show\n @api_javascript = Api::Javascript.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_javascript }\n end\n end", "def render_default_view\n respond_to do |format|\n format.html { render 'admin/common/action' }\n format.json { render json: { message: 'No content' }, status: :unprocessable_entity }\n end\n end" ]
[ "0.63856804", "0.62497216", "0.59970534", "0.58837616", "0.58267385", "0.58155936", "0.57989675", "0.5788801", "0.5761254", "0.5701413", "0.5698152", "0.5696378", "0.5694431", "0.5647853", "0.5647008", "0.56408644", "0.56280583", "0.56280583", "0.56191885", "0.5619025", "0.56169784", "0.56143886", "0.56136775", "0.5596272", "0.55772656", "0.5569338", "0.556638", "0.5563648", "0.55601466", "0.5558041", "0.55566835", "0.555331", "0.5549964", "0.554698", "0.554349", "0.553587", "0.55342966", "0.5522404", "0.5512431", "0.5505416", "0.5501415", "0.54834247", "0.5461109", "0.5452362", "0.5444965", "0.54294074", "0.54294074", "0.5416065", "0.54082924", "0.5401635", "0.54010284", "0.54010284", "0.54010284", "0.54010284", "0.54010284", "0.53970164", "0.5390153", "0.5387912", "0.53518486", "0.53476065", "0.5337942", "0.5327344", "0.5324178", "0.53219867", "0.5318949", "0.53174406", "0.53140664", "0.53113276", "0.5307256", "0.53032887", "0.5295399", "0.5290418", "0.5286326", "0.5280661", "0.5276658", "0.5274039", "0.5267995", "0.52644324", "0.52544826", "0.52540785", "0.52512604", "0.5250559", "0.5248486", "0.5247748", "0.5244847", "0.5244133", "0.5242825", "0.5242348", "0.52366954", "0.5232567", "0.5223162", "0.52229947", "0.52221495", "0.5218869", "0.5214161", "0.52104384", "0.5207894", "0.5206585", "0.5206145", "0.520455", "0.5204504" ]
0.0
-1
GET /messages GET /messages.json
def index end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def messages\n get_json('messages.json')\n end", "def index\n messages = Message.all\n render json: messages\n end", "def index\n @messages = Message.all\n render json: @messages\n end", "def index\n @messages = Message.all\n render json: @messages\n end", "def index\n @messages = Message.all\n\n render json: @messages\n end", "def index\n raise ApiAccessEvanta::PermissionDenied unless AppSettings::Value.new(:messages, user: current_user).on?\n @messages = Message.get_message_list(current_user)\n render json: @messages\n end", "def index\n @messages = message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end", "def index\n\t\t@messages = Message.all.order('created_at DESC')\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @messages }\n\t\tend\n\tend", "def get_messages\n \tuser = User.find(params[:user_id]);\n \tif user\n \t\tmessages = Message.where(message_type: user.user_type)\n \t\tconversation = Conversation.where(request_id: params[:request_id])\n texts = []\n conversation.each{ |msg| texts.push(Message.find_by(id: msg.message_id) ? Message.find(msg.message_id) : {})}\n \t\trender json: {messages: messages, conversation: conversation, texts: texts}\n \telse\n\t\trender json: {error: 'User not found.'}\n \tend\n end", "def show\n\t\t@messages = Message.where(recipient: params[:id]).order('created_at DESC')\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @messages }\n\t\tend\n\tend", "def index\n @messages = current_user.received_messages\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end", "def index\n @messages = current_user.received_messages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end", "def index\n @messages = Message.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end", "def index\n @messages = Message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end", "def index\n @messages = Message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end", "def get_all\n if @messages = Message.all\n render json: @messages\n else\n render json: \"Error!\"\n end\n\n end", "def get_messages(page = 0)\r\n if page > 0\r\n message_url = \"/message_threads?page=#{page}\"\r\n else\r\n message_url = \"/message_threads\"\r\n end\r\n response = self.class.get(message_url, headers: { \"authorization\" => @user_auth_token })\r\n JSON.parse(response.body)\r\n end", "def read_all_messages\n post(\"/api/read_all_messages\")\n end", "def index\n @messages = Message.all\n respond_to do |format|\n format.html { render :index }\n format.json { render :json => @messages}\n end\n end", "def get_messages(options = nil)\r\n @client.raw('get', '/content/messages', options, nil, @contact_v1_url)\r\n end", "def show\n @message = Message.find(params[:id])\n render json: @message\n\n end", "def index\n @messages = Message.order(\"time desc\").page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def index\n @messages = current_user.received_messages.paginate(:page => params[:page])\n @title = \"Входящие сообщения\"\n @path = \"index\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end", "def show\n authorize! :read, Message\n @messages = Message.find_conversation(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def index\n render json: Message.all\n end", "def my_messages(opts = {})\n client.get_my_messages(opts)\n end", "def show\n @message = Message.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end", "def index\n @messaging_messages = Messaging::Message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messaging_messages }\n end\n end", "def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :_message }\n end\n end", "def sent_messages\n get('/direct_messages/sent.json')\n end", "def index\n\t\t@messages = Message.where(:to_user => current_user.id)\n\t\trespond_with(@messages) \n\tend", "def index\n phone_number = params[:phone_number]\n\n response = Faraday.get \"#{BASE_URL}/api/v1/getMessages/#{phone_number}\", nil, {'Authorization': \"Bearer \"}\n\n @data = {\n phone_number: phone_number\n }\n\n if response.status === 200\n response_body = JSON.parse(response.body)\n @data[:messages] = response_body['messages']['items']\n end\n\n render json: @data\n end", "def show\n render json: @message\n end", "def show\n render json: @message\n end", "def index\n @messages = Message.find_all_by_user_id(session[:user_id], :order => \"timestamp DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @messages }\n end\n end", "def show\n\n render json: @message\n\n end", "def show\n render json: get_message()\n end", "def index\n @messages = Rails.cache.fetch('all_messages', :expires_in => 30.seconds) do\n Message.all\n end\n\n respond_to do |format|\n format.json { render json: @messages }\n end\n end", "def index\n\n if params[:user_id]\n @messages = Message.where(:user_id => params[:user_id].to_i)\n else\n @messages = Message.all\n end\n if params[:page] and params[:per_page]\n @messages = @messages.paginate(:per_page=>params[:per_page].to_i,:page=>params[:page].to_i).order(\"id desc\")\n @page = params[:page]\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :messages }\n end\n end", "def show\n render_json :entry => @message\n end", "def messages_get(opts = {})\n data, _status_code, _headers = messages_get_with_http_info(opts)\n data\n end", "def read\n @message = Message.find(params[:id])\n @message.read(current_user)\n respond_to do |format|\n format.html # read.html.erb\n format.json { render json: @message }\n end\n end", "def messages_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: MessagesApi.messages_get ...'\n end\n # resource path\n local_var_path = '/messages'\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['apiKey']\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 => 'MessagesResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MessagesApi#messages_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n #@messages = Message.all\n \n @messages = Message.page(params[:page]).order(\"created_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end", "def index\n @messages = current_user.messages\n respond_with(@messages)\n end", "def index\n @response_messages = @request_message.response_messages\n respond_to do |format|\n format.html { raise ActionController::RoutingError.new('Not Found') }\n format.json {}\n end\n end", "def show\n @v1_message = V1::Message.find(params[:id])\n\n render json: @v1_message\n end", "def direct_messages(params = {})\n get \"direct_messages\", params\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message_template }\n end\n end", "def show\n @text_message = TextMessage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @text_message }\n end\n end", "def index\n @mod_messages = ModMessage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mod_messages }\n end\n end", "def index\n # @messages = Message.message_in_area(params[:latitude], params[:longitude], current_user.message_zone).main_information\n\t @messages = Message.all\n render json: @messages\n end", "def show\n @chat = Chat.find(params[:id])\n @receiver = interlocutor(@chat)\n @messages = @chat.messages\n @message = Message.new\n render json: $message\n end", "def new\n @message = Message.new\n @users = User.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message }\n end\n end", "def new\n @message = current_user.messages.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message }\n end\n end", "def get_message\n @msg = Message.find_by_id(get_message_params[:message_id])\n\n if request.xhr?\n render :json => {\n :text => @msg.m_message,\n :offset => @msg.m_offset\n }\n end\n\n end", "def index\n messages = Message.all\n end", "def get_messages where = \"inbox\", opts = {}\n query = {\n mark: false\n }\n query.merge! opts\n get(\"/message/#{where}.json\", query: query)\n end", "def messages\n\t\t@content_title = \"Messages\"\n\t\t@messages = Message.paginate(:order => 'created_at DESC', :page => params[:page])\n\tend", "def show\n @home_searches_message = Home::Searches::Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @home_searches_message }\n end\n end", "def index\n @messages = Room.find(params['room_id']).messages\n end", "def show\n @chatroom = Chatroom.find(params[:id])\n @messages = @chatroom.messages.order(\"created_at DESC\")\n @user = User.find(session[:user_id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chatroom }\n end\n end", "def conversation\n current_user_id = current_user.id\n other_user_id = params[:id]\n @messages = Message.get_conversation(current_user_id, other_user_id)\n render json: @messages\n end", "def fetch\n messages = paginate ConversationMessage.where(conversation_id: params[:conversation_id])\n .order('created_at DESC')\n render json: messages.to_json(:include => :user)\n end", "def messages\n\t\t@musician = User.find_by_id(params[:id])\n\t\t@messages = @musician.messages\n\tend", "def show\n @room_message = RoomMessage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room_message }\n end\n end", "def show\n @chat_room = ChatRoom.find(params[:chat_room_id])\n #@chat_messages = @chat_room.chat_messages\n @chat_messages = @chat_room.chat_messages.order(created_at: :desc).page(params[:page]).per(5)\n\n render json: @chat_messages, each_serializer: ChatMessageSerializer\n end", "def index\n @messies = Messy.all\n\n render json: @messies\n end", "def index\n # Only get the messages for the user currently signed in\n if current_user.group.messages_released\n \t@messages = current_user.messages\n else\n \t@messages = {}\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { send_data @messages }\n end\n end", "def show\n @topic = Topic.find(params[:id])\n @messages = @topic.messages.order(\"created_at DESC\")\n @message = Message.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end", "def messages options = {}\n LazyArray.new do |page, size|\n messages, _headers = get 'messages', options.merge(page: page, size: size)\n\n messages.map do |message|\n Types::Message.new message\n end\n end\n end", "def index\n @mentor_messages = MentorMessage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mentor_messages }\n end\n end", "def index\n if params[:last_message_id]\n @messages = Message.includes(:user).where(\"id > ?\", params[:last_message_id])\n else\n @messages = Message.includes(:user).limit(5).order(:created_at).reverse_order\n end\n\n @message_data = []\n @messages.each do |message|\n @message_data.push({\n :id => message.id,\n :user => message.user.name,\n :content => message.content\n })\n end\n \n respond_to do |format|\n format.json { render :json => @message_data}\n end\n end", "def index\n\n if @current_user.admin?\n @v1_messages = V1::Message.all\n else\n @v1_messages = V1::Message.all.where(company_id: @current_user.company.id)\n end\n\n render json: @v1_messages\n end", "def show\n @user = User.find(params[:user_id])\n @message = @user.messages.find(params[:id])\n @message.update_attribute(:read, true)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: user_messages_path(@user) }\n end\n end", "def conversation\n @messages = Message.get_conversation(current_user, params[:user_id])\n render json: @messages, each_serializer: MessageConversationSerializer\n end", "def show\n @store_manager_messages_read = Store::Manager::Messages::Read.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @store_manager_messages_read }\n end\n end", "def message\n @message ||= (request.GET[:msg] || Hash.new)\n end", "def show_messages\n @messages = get_user.messages.search(params[:page])\n end" ]
[ "0.8394855", "0.75543094", "0.7462283", "0.7462283", "0.7439893", "0.7431661", "0.7429978", "0.74292123", "0.7412184", "0.73673457", "0.73555905", "0.73495036", "0.72967225", "0.72900546", "0.7289403", "0.7268556", "0.7183999", "0.71553916", "0.7153012", "0.71380496", "0.71022743", "0.70482457", "0.7040314", "0.70295817", "0.70292324", "0.7017771", "0.70024794", "0.69886464", "0.69810665", "0.69810665", "0.69810665", "0.69810665", "0.69810665", "0.69810665", "0.69810665", "0.69810665", "0.69810665", "0.69810665", "0.69810665", "0.69810665", "0.69810665", "0.69810665", "0.69810665", "0.69810665", "0.69810665", "0.69810665", "0.69810665", "0.69810665", "0.69803965", "0.6974364", "0.6922153", "0.69009936", "0.68936914", "0.68903637", "0.68689084", "0.68689084", "0.6854836", "0.68539685", "0.68511206", "0.68448645", "0.68280727", "0.6815796", "0.680671", "0.6798018", "0.67887235", "0.67494226", "0.6735724", "0.67294914", "0.6706331", "0.66902477", "0.6688329", "0.66870123", "0.6673608", "0.6657657", "0.66215414", "0.66073585", "0.6598612", "0.6585353", "0.6581137", "0.65683365", "0.6553663", "0.6547331", "0.65465385", "0.65455735", "0.65403765", "0.6527945", "0.65170485", "0.6509563", "0.650896", "0.6499718", "0.64963967", "0.6489521", "0.6452889", "0.64362925", "0.64362174", "0.6432528", "0.6428455", "0.6405753", "0.64008176", "0.6399041", "0.6396283" ]
0.0
-1
POST /messages POST /messages.json
def create @message = Message.new(message_params) respond_to do |format| if @message.save format.html { redirect_to messages_url, notice: 'Message was successfully created.' } else format.html { render :new } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post(content)\n post_to(\"/api/v1/messages/\", {:body => content})\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 = Message.new(message_params)\n\n if @message.save\n render json: @message, status: :created, location: [:api, @message]\n else\n render json: @message.errors, status: :unprocessable_entity\n end\n end", "def create\n @message = Message.new(message_params)\n\n if @message.save\n @user = User.find(@message.user_id)\n @user.messages << @message\n render json: @message, 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\n if @message.save\n render json: @message, status: :created, location: @message\n else\n render json: @message.errors, status: :unprocessable_entity\n end\n end", "def create\n @message = Message.new(message_params)\n\n if @message.save\n render json: @message, status: :created, location: @message\n else \n render json: @message.errors, status: :unprocessable_entity\n end\n end", "def create\n @message = Message.new(params[:message])\n\n respond_to do |format|\n if @message.save\n format.html { redirect_to new_message_url, notice: t(\"messages.created\") }\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(message_params)\n message.messager = current_user\n\n if message.valid?\n message.save!\n render json: MessageSerializer.new(message).serialize\n else\n render json: { errors: message.errors.messages }, status: 422\n end\n end", "def create\n\n @message = current_user.messages.new(message_params)\n\n if @message\n respond_to do |format|\n if @message.save\n # debugger\n format.html do\n redirect_to @message, notice: 'Message was successfully created.'\n end\n format.json { render :_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\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 message(user, text)\n post('/direct_messages/new.json', :user => user, :text => text)\n end", "def message(user, text)\n post('/direct_messages/new.json', :user => user, :text => text)\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 create_message(user_id, recipient_id, token , subject, message)\n response = self.class.post('/messages', body: { \"user_id\": user_id, \"recipient_id\": recipient_id,\"token\": token , \"subject\": subject, \"stripped-text\": message }, headers: { \"authorization\" => @auth_token })\n puts response\n\n end", "def create\n @message = Message.new(params[: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 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\n respond_to do |format|\n if @message.save\n format.html { redirect_to @message, notice: 'Message was successfully created.' }\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(message: params[:message_content], from_id: current_user.id, to_id: params[:to_id])\n respond_to do |format|\n if @message.save\n format.html { redirect_to user_path(@message.to_id), notice: 'Message was successfully sent.' }\n else\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @message = Message.new(post_params)\n respond_to do |format|\n if @message.save\n flash[:success] = \"문자가 성공적으로 업로드 되었습니다.\"\n format.html { render :show}\n else\n flash[:error] = \"부족한 곳을 채워주세요\"\n format.html { render :new}\n format.json { render json: @message.errors }\n end\n end\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 crée avec succès.' }\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 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 = Message.new(message_params)\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\n end", "def create\n @message = @conversation.messages.build(message_params)\n\n respond_to do |format|\n if @message.save\n format.html { redirect_to conversation_messages_path(@conversation), notice: 'メッセージを送信しました。' }\n format.json { render :show, status: :created, location: conversation_messages_path(@conversation) }\n else\n format.html { render :index }\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 \n respond_to do |format|\n if @message.save\n format.html { redirect_to @message, notice: 'Message was successfully sent.' }\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 @room = Room.find_or_create_by(room_params)\n @message = @room.messages.new(message_params)\n\n if @message.save\n render json: @message, status: :created, location: [@room, @message]\n else\n render json: @message.errors, status: :unprocessable_entity\n end\n end", "def send\n inf = params.permit(:to, :from, :time, :priority, :message, :til)\n message = Message.new\n message.user = current_user\n message.entered = DateTime.now.in_time_zone\n message.year = DateTime.now.in_time_zone.year\n\n message.to = inf[:to]\n message.from = inf[:from]\n message.message_time = inf[:time]\n message.priority = inf[:priority]\n message.message = inf[:message]\n message.til = inf[:til]\n\n unless message.save\n render json: {message: @message.errors}.to_json, \\\n status: :unprocessable_entity\n end\n\n render json: {message: 'Success'}.to_json, status: 200\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 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 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 = 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\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\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\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\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\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\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\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\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 message(message)\n render json: {\n message: message,\n status: :success\n }, status: 200\n end", "def create\n mesg = Message.new({user_id: @current_user.id, receiver_id: params[:receiver_id], content: params[:content], request_id: params[:request_id]})\n if mesg.save\n render json: {\n status: 'success',\n message: 'Your message was sent',\n data: mesg,\n },\n status: :created\n else\n render json: {\n status: 'error',\n message: 'Message not sent',\n data: mesg.errors\n },\n status: :unprocessable_entity\n end\n end", "def post_message(token, channel, text, username)\n uri = URI.parse(URL[\"post_msg\"])\n params = { :token => token,\n :channel => channel,\n :text => text,\n :username => username,\n :as_user => true }\n uri.query = URI.encode_www_form( params )\n return JSON.parse( uri.open.read )\n end", "def post(message)\n puts message\n end", "def create\n @message = Message.new(message_params)\n\n if @message.save\n render json: { \"status\": \"success\" }, status: 200\n else\n render json: {}, status: 401\n end\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", "def create\n @message = @app_thread.messages.new(message_params)\n @message.user_id = @user.id\n\n respond_to do |format|\n if @message.save\n format.js {}\n format.html { redirect_to user_project_app_thread_url(@user, @project, @app_thread), notice: 'Message was successfully created.' }\n format.json { render :show, status: :created, location: @message }\n else\n format.html { redirect_to user_project_app_thread_url(@user, @project, @app_thread), notice: @message.errors.full_messages.inspect }\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 respond_to do |format|\n if @message.save\n format.html { redirect_to @message, notice: 'Message was successfully created.' }\n format.json { render action: 'show', 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\n respond_to do |format|\n if @message.save\n format.html { redirect_to admin_message_path(@message), notice: 'Message was successfully created.' }\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 post_message(text)\n body ={\n \"title\" => @from_name,\n \"picture\" => @from_picture,\n \"message\" => text\n }\n\n self.class.post(room_path, request_options(body))\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 create\n @conversation = Conversation.find(params[:conversation_id])\n if @conversation.messages.create(sender: current_user,\n content: params[:message][:content])\n redirect_to @conversation\n else\n flash[:error] = \"A problem occured\"\n redirect_to @conversation\n end\n #respond_to do |format|\n # format.js { render json: @message }\n # format.html { redirect_back_or_to :back }\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 = @ride_request.messages.new(message_params)\n @message.user = current_user\n\n respond_to do |format|\n if @message.save\n format.html { redirect_to :back, notice: 'Message was successfully created.' }\n format.json { render :show, status: :created, location: @message }\n else\n format.html { render :back }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_message = UserMessage.new(user_message_params)\n\n if @user_message.save\n render :show, status: :created, location: @user_message\n else\n render json: @user_message.errors, status: :unprocessable_entity\n end\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 url_for(action: 'index'), notice: f(@message) }\n format.json { render :show, status: :created, location: url_for(action: 'show', id: @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(params[:message])\n @status = if @message.save then\n @message \n else\n render :json=> @message, :status=> :unprocessable_entity\n end\n end", "def post(message)\n puts message\n end", "def create\n\t\t@message = Message.create!(params[:message])\n\t\trespond_to do |format|\n\t\t\tformat.js\n\t\tend\n\tend", "def new\n @message = Message.new\n\n render json: @message\n end", "def post_message(params)\n self.class.post('/chat.postMessage', body: params.merge({token: @token})).tap do |response|\n raise \"error posting message: #{response.fetch('error', 'unknown error')}\" unless response['ok']\n end\n end", "def create\n @message = Message.new(message_params)\n @message.user = current_user\n respond_to do |format|\n if @message.save\n format.html { redirect_to root_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 create\n @message = Message.new(params[:message])\n\n respond_to do |format|\n if @message.save\n format.html { redirect_to user_url(@message.user_id), notice: 'Message was successfully created.' }\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(message_params)\n @message.user_sent_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 :text => '{\"message\": \"Your messages has been sent\"}' }\n #format.json { render action: 'show', status: :created, location: @message }\n else\n format.html { render action: 'new' }\n format.json { render text: 'message'}\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\n format.html { redirect_to outbox_path, notice: 'Message was successfully created.' }\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 message(session, message, options={})\n json_request \"message\", {:session => session,\n :message => message}, options\n end", "def post_messages!(hash)\n Net::HTTP.post_form(URI.parse(@target), {'data'=>hash.to_json})\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 @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 new\n @message = current_user.messages.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message }\n end\n end", "def create\n \n @message = current_user.messages.build(params[:message])\n if @message.save\n \n \n @account_sid = 'ACdb43c99b5deb7d4ed12083140f41bab3'\n @auth_token = '11dbb8cbba9b004652469aa77e51183c'\n\n # set up a client to talk to the Twilio REST API\n @client = Twilio::REST::Client.new(@account_sid, @auth_token)\n ha = HashWithIndifferentAccess.new(params[:message])\n mssg = ha['content']\n\n friends = {\n \"+14159006499\" => \"Jered\",\n \"+11111111111\" => \"Chris\",\n \"+11111111111\" => \"Kathryn\"}\n\n @account = @client.account\n @message = @account.sms.messages.create({:to => '+14159006499', :from => '+18319204556', :body => mssg})\n puts @message\n flash[:success] = \"Message created!\"\n redirect_to 'http://www.bugl.co/acknowledge.html'\n\n else\n @feed_items = []\n render 'static_pages/home'\n end\n \n @message = Message.new(params[:message])\n\n respond_to do |format|\n if @message.save\n \n format.json { render json: @message, status: :created, location: @message }\n else\n \n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def messages\n get_json('messages.json')\n end", "def new\n @text_message = TextMessage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @text_message }\n end\n end", "def create\n @room_message = RoomMessage.new(params[:room_message])\n\n respond_to do |format|\n if @room_message.save\n format.html { redirect_to @room_message, notice: 'Room message was successfully created.' }\n format.json { render json: @room_message, status: :created, location: @room_message }\n else\n format.html { render action: \"new\" }\n format.json { render json: @room_message.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @message = Message.new sender_id: current_user.id, recipient_id: message_params[:recipient_id], verb: message_params[:verb]\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 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 post_message(params)\n self.class.post('/chat.postMessage', body: params.merge({token: @token})).tap do |response|\n raise \"error posting message: #{response.fetch('error', 'unknown error')}\" unless response['ok']\n end\n end", "def create\n @message = Message.new(params[:message])\n\n respond_to do |format|\n if @message.deliver\n format.html { render :thank_you }\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 typer(session, message, options={})\n json_request \"message\", {:session => session,\n :message => message}, options\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 @msg = Msg.new(msg_params)\n\n respond_to do |format|\n if @msg.save\n format.html { redirect_to @msg, notice: 'Msg was successfully created.' }\n format.json { render action: 'show', status: :created, location: @msg }\n else\n format.html { render action: 'new' }\n format.json { render json: @msg.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n create_message(params)\n end", "def send_messages\n if Message.send_messages()\n render json: {status: :ok}\n else\n render json: \"Error\"\n end\n end", "def post(request, _params)\n formatter = WeChatMessageFormatter.new\n message = formatter.parse_incoming_message(request.body.read.to_s)\n # Parse the WeChat message XML format\n\n if message['valid']\n # Queue the message for delayed processing\n @db_manager.store_message(message)\n\n # WeChat always requires incoming user messages to be acknowledged at\n # least with an empty string (empty strings are not shown to users),\n # see: https://chatbotsmagazine.com/building-chatbots-for-wechat-part-1-dba8f160349\n # In this sample app, we simulate a \"Customer Service\"-like scenario\n # providing an instant reply to the user, announcing that a complete\n # reply will follow.\n reply = \"Thank you for your message. We will get back to you as soon as possible!\"\n return formatter.format_instant_reply(message, reply)\n end\n\n return 'Message was sent in a wrong format.'\n end", "def test_create_palindrome_message\n body = {\n \tdata: {\n \t\ttype: 'messages',\n \t\tattributes: {\n \t\t\tcontent: 'racecar'\n \t\t}\n \t}\n }\n\n post '/messages', body.to_json, 'CONTENT_TYPE' => AppConstants::CONTENT_TYPE\n assert last_response.created?\n assert_equal 'application/vnd.api+json', last_response.headers['Content-Type']\n\n response_body = JSON.parse last_response.body\n data = response_body['data']\n\n assert_equal 'messages', data['type']\n assert_equal body[:data][:attributes][:content], data['attributes']['content']\n assert data['attributes']['is_palindrome']\n assert_equal \"localhost:4567/messages/#{data['id']}\", last_response.headers['Location']\n end", "def create\n \n @message = Message.new(body: params[:message][:body], sender_id: current_user.id, receiver_id: params[:message][:receiver_id])\n \n #@message = current_user.messages.build(message_params)\n #@message.save\n #respond_with { @message }\n\n respond_to do |format|\n if @message.save\n format.html { redirect_to message_user_path(@message.sender_id, @message.receiver_id), 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 send_message\n \tuser = User.find(params[:user_id]);\n \tif user\n \t\tmessage = Conversation.new(user_id: params[:user_id], message_id: params[:message_id], request_id: params[:request_id])\n \t\tif message.save\n \t\t\tconversation = Conversation.find_by(request_id: params[:request_id])\n \t\t\trender json: conversation\n \t\tend\n \telse\n\t\trender json: {error: 'User not found.'}\n \tend\n end", "def create\n @admin_message = Admin::Message.new(admin_message_params)\n\n respond_to do |format|\n if @admin_message.save\n format.html { redirect_to @admin_message, notice: 'Message was successfully created.' }\n format.json { render :show, status: :created, location: @admin_message }\n else\n format.html { render :new }\n format.json { render json: @admin_message.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @message = Message.new(message_params)\n @message.room = Room.find(params[:room_id])\n @message.user = @current_user\n respond_to do |format|\n if @message.save\n format.html { redirect_to room_message_path(@message.room, @message), notice: 'Message was successfully created.' }\n format.json { render :show, status: :created }\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 if @message.save\n SharpenAPI.send_sms(@message.message, @message.recipient_numbers)\n redirect_to admin_bat_signal_path, notice: 'Message was successfully sent'\n else\n format.html { render :new }\n format.json do\n render json: @message.errors, status: :unprocessable_entity\n end\n end\n end", "def create\n message_params = params[:message]\n message_params[:text] = params[:text]\n message = Message.new(\n author_id: current_user.id,\n chat: Chat.find(message_params[:chat_id]),\n parse_mode: message_params[:parse_mode],\n text: (message_params[:text].join \"\\r\\n\\r\\n\")\n )\n message.image = message_params[:image] if message_params[:image].present?\n puts JSON.pretty_generate message.as_json\n message.save!\n redirect_to admin_message_path(message), notice: 'A message has been created'\n # Message.create!(\n # author_id: current_user.id,\n # chat: Chat.find(message_params[:chat_id]),\n # image: message_params[:image],\n # parse_mode: message_params[:parse_mode],\n # text: (message_params[:text].join \"\\r\\n\\r\\n\")\n # )\n end", "def new\n @message = Message.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message }\n end\n end", "def new\n @message = Message.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message }\n end\n end", "def create\n to = params[:to]\n\n unless to\n raise IOError, \"Incorrect params for sending text message\" \n end\n\n @client = Twilio::REST::Client.new(\n CONFIG[:twilio_account_sid],\n CONFIG[:twilio_auth_token])\n\n @account = @client.account\n @message = @account.sms.messages.create({\n :from => CONFIG[:twilio_phone_number],\n :to => to,\n :body => \"Happy Mining! #{CONFIG[:ios_app_link]}\"}) \n\n rescue => ex\n handle_exception(ex)\n ensure\n respond_to do |format|\n format.json\n end\n end", "def create\n inbound_messages.each(&:save)\n render :nothing => true, :status => 200\n end", "def create\n @message = Message.new(message_params) \n if params.has_key?(:message) and params[:message].has_key?(:users)\n @mu = params[:message][:user].map{ |mu| sg.to_i } - [0]\n end \n if @message.save\n if @mu.kind_of?(Array)\n @message.message_users.delete_all\n @mu.each do |mu_id|\n MessegerUser.create(user_id: mu_id.to_i, message: @message)\n end\n end\n end\n \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 = Message.new(message_params)\n\n respond_to do |format|\n if @message.save\n # Tell the UserMailer to send a welcome email after save\n MessageMailer.welcome_email(@message).deliver_now\n\n format.html { redirect_to(root_url, :notice => 'Message was successfully sent.') }\n format.json { render json: @message, status: :created, location: @message }\n else\n flash.now.alert = \"Please fill all fields.\"\n # format.html { render action: 'new' }\n # format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @message = Message.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message }\n end\n end", "def new\n @message = Message.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message }\n end\n end", "def new\n @message = Message.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message }\n end\n end", "def new\n @message = Message.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message }\n end\n end", "def new\n @message = Message.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message }\n end\n end", "def new\n @message = Message.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message }\n end\n end" ]
[ "0.7465461", "0.71704835", "0.71130985", "0.70958537", "0.7068939", "0.7020135", "0.6939461", "0.68449193", "0.68354475", "0.68308204", "0.6830379", "0.6830379", "0.67848176", "0.6765744", "0.67015487", "0.67001784", "0.66719586", "0.6634068", "0.6625937", "0.6624979", "0.6614474", "0.66113085", "0.66074044", "0.65992105", "0.65942234", "0.65877134", "0.65845823", "0.65845823", "0.65845823", "0.65845823", "0.65845823", "0.65845823", "0.65845823", "0.65845823", "0.65845823", "0.65845823", "0.6582492", "0.65793365", "0.6565495", "0.65612817", "0.6555453", "0.65478504", "0.6541063", "0.65239626", "0.6521933", "0.6518713", "0.65184534", "0.65026766", "0.6489746", "0.6487816", "0.64873815", "0.64650464", "0.6456943", "0.64568585", "0.6454683", "0.64321333", "0.64268816", "0.6422096", "0.6406275", "0.64056814", "0.6389567", "0.63835716", "0.6382803", "0.6381029", "0.63765156", "0.63658696", "0.6364803", "0.63579494", "0.6335968", "0.6328886", "0.63276196", "0.63225454", "0.6313378", "0.6309105", "0.63038474", "0.6294313", "0.628983", "0.6288954", "0.62854123", "0.62813985", "0.62749815", "0.62718415", "0.6257915", "0.6257126", "0.6255911", "0.6229005", "0.62171715", "0.6210752", "0.620629", "0.620629", "0.6203846", "0.62031436", "0.61998475", "0.61963135", "0.61929727", "0.61929727", "0.61929727", "0.61929727", "0.61929727", "0.61929727" ]
0.6227605
86
PATCH/PUT /messages/1 PATCH/PUT /messages/1.json
def update respond_to do |format| if @message.update(message_params) format.html { redirect_to messages_url, notice: 'Message was successfully updated.' } else format.html { render :edit } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @v1_message = V1::Message.find(params[:id])\n\n if @v1_message.update(message_params)\n render json: @v1_message, status: :ok\n else\n render json: @v1_message.errors, status: :unprocessable_entity\n end\n end", "def update\n message = Message.find(params[:id])\n message.update(message_params)\n render json: message\n end", "def update\n if @message.update(message_params)\n render json: @message\n else\n render json: @message.errors, status: :unprocessable_entity\n end\n end", "def update\n @message = Message.find(params[:id])\n @message.update(text: params[\"_json\"])\n render json: @message\n end", "def update\n if @message.update(message_params)\n render json: @message, status: :ok\n else\n render json: @message.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.json {render json: :created}\n else\n format.json {render json: \"not created\"}\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_back_to messages_path, flash: { success: 'Message was successfully updated.' } }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @message.update(message_params) \n render json: @message, status: :ok, location: @message\n else\n render json: @message.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, :notice => 'Message was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @message.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n @message.update_attributes(params[:message])\n respond_with(@message)\n end", "def update\n @message = Message.find(params[:id])\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, :notice => 'Message was successfully set.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @message.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @msg.update(msg_params)\n format.html { redirect_to @msg, notice: 'Msg was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @msg.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n params.require(:id)\n msg = Message.find(params[:id])\n msg.read = true\n msg.save\n render :json => msg.as_json, status: :ok\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n if @message.update_attributes(message_params)\n head :no_content\n else\n render json: @message.errors, status: :unprocessable_entity\n end\n end", "def update\n @message = Message.find(params[:id])\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to outbox_path, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n # format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n # format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n authorize! :update, @message\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: t(\"messages.updated\") }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\t\tdeny_access_unless(current_user?(@message.user))\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, :notice => 'Message was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @message.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: \"Message was successfully updated.\" }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: \"Message was successfully updated.\" }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n message = Message.find_by(params[:id])\n if message.nil?\n render_error(\"message with id #{params[:id]} does not exist\", :not_found)\n elsif message.created_at < Time.now.utc - MAX_EDIT_PERIOD\n render_error(\"cannot update message more than #{MAX_EDIT_PERIOD} seconds old\", :forbidden)\n else\n render json: message.update(message_params)\n end\n end", "def update\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to admin_message_path(@message), notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if request.headers[\"Authorization\"] == \"Basic 78f91d346838110d9edb6be3996624a9\"\n @message = Message.find(params[:id])\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n endrender :'messages/create'\n end\n end\n end", "def update\n respond_to do |format|\n if @msg.update(msg_params)\n format.html { redirect_to @msg, notice: 'Msg was successfully updated.' }\n format.json { render :show, status: :ok, location: @msg }\n else\n format.html { render :edit }\n format.json { render json: @msg.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { redirect :back }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to @message, notice: 'Le message a bien été mis à jour.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { render :edit }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # find and update a specific message\n end", "def update\n params[:topic].delete :messages_attributes\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to topic_url(@topic), notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @message = Message.find(params[:id])\n\tif !checkme? @message then return end\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to @message, notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @mess.update(mess_params)\n format.html { redirect_to @mess, notice: 'Mess was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @mess.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @message.update(message_params)\n format.html { redirect_to user_project_app_thread_url(@user,@project,@app_thread), notice: 'Message was successfully updated.' }\n format.json { render :show, status: :ok, location: @message }\n else\n format.html { redirect_to user_project_app_thread_url(@user,@project,@app_thread), notice: @message.errors.full_messages.inspect }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def update\n @messaging_inbox = Messaging::Inbox.find(params[:id])\n\n respond_to do |format|\n if @messaging_inbox.update_attributes(params[:messaging_inbox])\n format.html { redirect_to @messaging_inbox, notice: 'Inbox was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @messaging_inbox.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_message(token, payload, id, user = nil)\n request_url = user_context(user) << \"/Messages/\" << id\n\n update_message_response = make_api_call \"PATCH\", request_url, token, nil, payload\n\n parse_response(update_message_response)\n end", "def update\n respond_to do |format|\n if @hello_message.update(hello_message_params)\n format.html { redirect_to @hello_message, notice: 'Hello message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @hello_message.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.708431", "0.6978376", "0.690778", "0.6854797", "0.6815956", "0.6795405", "0.6790936", "0.67612135", "0.675905", "0.67395717", "0.67395717", "0.66698396", "0.66626984", "0.665636", "0.66526294", "0.6645645", "0.66447604", "0.66447604", "0.66447604", "0.66447604", "0.66447604", "0.66447604", "0.66447604", "0.66447604", "0.66447604", "0.66447604", "0.66447604", "0.66447604", "0.66447604", "0.66447604", "0.66447604", "0.66447604", "0.66447604", "0.66447604", "0.6643443", "0.66428834", "0.66340905", "0.6624554", "0.6624554", "0.66078484", "0.659286", "0.6579293", "0.65478176", "0.6546663", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6546634", "0.6545933", "0.653277", "0.6520008", "0.65170085", "0.64997274", "0.64975244", "0.64975244", "0.64905715", "0.64903444", "0.648561", "0.6469587", "0.64633715", "0.6461701", "0.6447637", "0.64356047", "0.64053893", "0.6393834", "0.63862115", "0.6382166", "0.6374207", "0.6338278", "0.6329917", "0.6327525", "0.6326193", "0.63250583" ]
0.0
-1
DELETE /messages/1 DELETE /messages/1.json
def destroy @message.destroy respond_to do |format| format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @v1_message = V1::Message.find(params[:id])\n @v1_message.destroy\n\n head :no_content\n end", "def delete\n @client.post('/api/del_msg', id: get_attribute(:name))\n end", "def destroy\n # delete a specific message\n end", "def destroy\n @message.destroy\n \n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n # delete a specific message\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n render json: 'Message was successfully deleted', status: :ok\n end", "def delete_message(id)\n record \"/msg/delete/#{id}\"\n end", "def destroy\n # delete a specific message\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def message_delete(id)\n request(:delete, \"messages/#{id.to_s}\")\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :ok }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :ok }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :ok }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :ok }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'message.deleted' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @msg.destroy\n respond_to do |format|\n format.html { redirect_to msgs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n respond_to do |format|\n format.html { redirect_to noticias_messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to [@member, :messages] }\n format.json { head :no_content }\n end\n end", "def message_destroy(id)\n post(\"/direct_messages/destroy/#{id}.json\")\n end", "def message_destroy(id)\n post(\"/direct_messages/destroy/#{id}.json\")\n end", "def destroy\n \t\n @message = Message.find(params[:id])\n @message.delete\n\n respond_to do |format|\n format.html { redirect_to(messages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def delete_message(message_id)\n RestClient.delete(\"#{@url}/messages/#{message_id}\")\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to success_path, notice: _('Message deleted') }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n head :no_content\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url, notice: t(:message_destroyed) }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n head :no_content\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to url_for(action: 'index'), notice: f(@message) }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n\n @message.destroy\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to conversations_url }\n format.json { head :ok }\n end\n end", "def destroy\n @message = Messages.find(params[:id])\n @message.destroy\n end", "def destroy\n message = Message.find(params[:id])\n message.destroy\n end", "def destroy\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to(messages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Le message a bien été supprimé.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.mark_deleted(current_user)\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.json { head :ok }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'El Mensaje ha sido eliminado correctamente!' }\n format.json { head :no_content }\n end\n end", "def destroy\n if @message.destroy\n head :no_content\n else\n render json: @message.errors, status: :unprocessable_entity\n end\n end", "def destroy\n @message = Admin::Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_messages_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to messages_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: \"Message was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @message.destroy\n respond_to do |format|\n format.html { redirect_to messages_url, notice: \"Message was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @hello_message.destroy\n respond_to do |format|\n format.html { redirect_to hello_messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_message = AdminMessage.find(params[:id])\n @admin_message.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_messages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @message = Message.find(params[:id])\n @message.destroy\n\n respond_to do |format|\n format.html { redirect_to(messages_url) }\n format.xml { head :ok }\n end\n end" ]
[ "0.7959872", "0.7747524", "0.77164423", "0.7661726", "0.76382256", "0.76306146", "0.76271677", "0.7610772", "0.76048714", "0.7604346", "0.7604346", "0.7591631", "0.7588635", "0.7588635", "0.7588635", "0.7588635", "0.7551851", "0.75501", "0.75501", "0.75501", "0.75501", "0.75501", "0.75501", "0.75501", "0.75501", "0.75501", "0.75501", "0.75501", "0.75501", "0.75501", "0.75501", "0.75501", "0.75501", "0.75501", "0.75501", "0.75501", "0.75501", "0.75501", "0.7549677", "0.75374776", "0.7505235", "0.7484382", "0.7474086", "0.74497586", "0.74497586", "0.7441099", "0.7439451", "0.7420431", "0.74173844", "0.73918736", "0.73913074", "0.73904884", "0.73826236", "0.73729974", "0.7367942", "0.73668224", "0.73590153", "0.73477876", "0.73451924", "0.73399603", "0.73395175", "0.73149216", "0.73086774", "0.72964966", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.7295206", "0.72927916", "0.7292447", "0.7292447", "0.7291626", "0.7286348", "0.72843003" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def message_params params.require(:message).permit(:text, :start_at, :end_at, :library, :request_type) 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 model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def 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 active_code_params\n params[:active_code].permit\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def filter_parameters; end", "def filter_parameters; end", "def list_params\n params.permit(:name)\n end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def 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 url_whitelist; 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 filter_params\n params.require(:filters).permit(:letters)\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 url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\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 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.69802505", "0.6781974", "0.67470175", "0.67430073", "0.67350477", "0.6593221", "0.6504263", "0.64988977", "0.6481794", "0.64800006", "0.64568025", "0.64411247", "0.6379476", "0.63765615", "0.6368045", "0.6320141", "0.6300363", "0.6300057", "0.62952244", "0.6294712", "0.6293856", "0.6290323", "0.62816143", "0.6241851", "0.6241208", "0.622036", "0.62128764", "0.62110275", "0.61966056", "0.61776453", "0.617547", "0.6174961", "0.61654735", "0.6153256", "0.61516005", "0.6149498", "0.6123234", "0.6118653", "0.61077267", "0.61061186", "0.6093616", "0.608318", "0.6074428", "0.60650206", "0.60244286", "0.6020295", "0.60155797", "0.6012826", "0.6010141", "0.6010141", "0.60037106", "0.600298", "0.59979576", "0.5994806", "0.5994283", "0.5993927", "0.5980616", "0.59667075", "0.59614897", "0.59610957", "0.596071", "0.5959614", "0.59554", "0.59542966", "0.5946781", "0.5940262", "0.5940262", "0.59401053", "0.5937168", "0.5932135", "0.59293395", "0.592659", "0.59202623", "0.59112674", "0.59088206", "0.590716", "0.59056735", "0.589997", "0.5899655", "0.5898926", "0.5896042", "0.589589", "0.5895867", "0.58894163", "0.5884936", "0.5879227", "0.58740723", "0.5871364", "0.5870148", "0.5869228", "0.5868196", "0.5867967", "0.5865532", "0.58653617", "0.58644646", "0.58631665", "0.5862611", "0.5857609", "0.58558804", "0.5853729", "0.5853025" ]
0.0
-1
Returns the unit of the dimension node.
def dimension @unit.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unit\n return @unit\n end", "def get_units(dimension)\n nil\n end", "def si_unit\n return self if self.dimensions.is_dimensionless?\n @dimensions.si_unit\n end", "def units\n return @units\n end", "def units\n attribute('yweather:units')\n end", "def units\n @units = SQF.units @this\n @units\n end", "def unit\n return @units[@index]\n end", "def unit\n return @units[@index]\n end", "def unit(n)\n\t\ta, b = n.split('_')\n\t\treturn a, Dim_Hash[b]\n\tend", "def base_unit\n units[0]\n end", "def unit\n parts[3]\n end", "def unit_s\n self.unit.to_s if self.unit\n end", "def unit \n\t\t\tunitq = self.dup\n\t\t\tmagnitude = self.abs\n\t\t\tunitq[0] /= magnitude\n\t\t\tunitq[1] /= magnitude\n\t\t\tunitq[2] /= magnitude\n\t\t\tunitq[3] /= magnitude\n\t\t\treturn unitq\n\t\tend", "def systemOfUnits \n \"systemOfUnits\" \n end", "def get_distance_unit\n\t\t@kilometers\n\tend", "def population_unit\n query_root_node(\"gdacs:population/@unit\", @@NAMESPACES)\n end", "def dimension\n map { |qnt, exp| qnt.dimension * exp }.reduce SY::Dimension.zero, :+\n end", "def get_temperature_unit\n\t\t@tempUnit\n\tend", "def duration_unit\n expr = self.timing_duration.blank? ? \"\" : self.timing_duration.split.last\n @duration_unit.nil? ? expr : @duration_unit\n end", "def dim\n @structure.dim\n end", "def population_unit\n query_root_node(\"fao:populationUnit/text()\", @@NAMESPACES).to_s\n end", "def width\n @dimensions.x\n end", "def severity_unit\n query_root_node(\"gdacs:severity/@unit\", @@NAMESPACES)\n end", "def unit=(value)\n @unit = value\n end", "def units _args\n \"units _args;\" \n end", "def dimensions\n dim = [width, height]\n def dim.to_s\n join 'x'\n end\n dim\n end", "def unit\n self[:unit] ? self[:unit].to_sym : :piece\n end", "def width\n dimensions.first\n end", "def width\n\t\tnode['width']\n\tend", "def unit\n self.dup.unit!\n end", "def interval_units\n if interval.parts.is_a? Array\n interval.parts[0][0]\n else\n interval.parts.keys[0]\n end\n end", "def get_resource_dimension(entry_datatype, entry_data)\n unit_type = (entry_data & 0xF)\n case unit_type\n when COMPLEX_UNIT_PX\n unit_name = \"px\"\n when COMPLEX_UNIT_DIP\n unit_name = \"dp\"\n when COMPLEX_UNIT_SP\n unit_name = \"sp\"\n when COMPLEX_UNIT_PT\n unit_name = \"pt\"\n when COMPLEX_UNIT_IN\n unit_name = \"in\"\n when COMPLEX_UNIT_MM\n unit_name = \"mm\"\n else\n unit_name = \"\"\n end\n\n return complex_to_float(entry_data).to_s + unit_name\n #return ((entry_data >> 8) & 0xFFFFFF).to_s + unit_name\n end", "def total_units\n return @total_units\n end", "def units(metric=nil)\n (metric || (metric.nil? && self.metric?)) ? METRIC_UNITS : IMPERIAL_UNITS\n end", "def width\n dimensions()[:x]\n end", "def get_dimensions\n @netcdf_elmt.getDimensions()\n end", "def dim\n composition_string\n end", "def dim\n composition_string\n end", "def as unit\n check_unit! unit\n dist = self.dup\n dist.number = convert_to_meters * meters_map[unit]\n dist.unit = unit\n dist \n end", "def no_Units\n val = self.no_inch\n val = val.no_foot\n val = val.no_cm\n val = val.no_mm\n val = val.gsub(/[~]/,\"\")\n return val\n end", "def emission_units\n data['emission_units']\n end", "def units\n\t\tret = []\n\t\[email protected]('sgt-structure:' + @id + ':units').each do |uid|\n\t\t\tret.push(getUnit(@db, uid))\n\t\tend\n\t\tret\n\tend", "def describe\n return @magnitude.to_s if magnitude?\n u_descr = Units.units_descr(@units, true)\n \"#{@magnitude} #{u_descr}\"\n end", "def units(units=nil)\n cur_page.units(units)\n end", "def unit\n self[:unit].to_s.empty? ? :piece : self[:unit].to_sym\n end", "def convert_dimension(value)\n\t\twholeNum = value[0,3] #Pulls the whole number portion of the eVS dimension/size convention\n\t\tdecimal = value[3, 2] #Pulls the decimal portion\n\t\treturn \"#{wholeNum}.#{decimal}\".to_f.round.to_s\n\tend", "def measures\n @dimensions.describe\n end", "def denom()\n\t\treturn @den\n\tend", "def presentation_unit_type_measure\n packing_material.presentation_unit_type_measure\n end", "def dimensions\n data[:dimensions]\n end", "def dimension\n raise Error::UnsupportedOperation, \"Method Geometry#dimension not defined.\"\n end", "def eval_unit expr\n return 1.0 if expr.nil? or expr.strip.empty?\n # base SI units\n m = _K = _J = s = 1.0\n # derived units\n _W = _J/s\n # orders\n cm = m / 100\n mm = m / 1000\n # constants\n pi = Math::PI\n return Kernel.eval expr.gsub('%','0.01').gsub(/([A-Z]+)/, \"_\\\\1\").gsub('^','**')\n end", "def to_unit\n timemap.last\n end", "def presentation_unit_type_measurement\n packing_material.presentation_unit_type_measurement\n end", "def pretty_unit\n return if unitless?\n\n numerator = Inspection.prettify_unit_part(numerators)\n denominator = Inspection.prettify_unit_part(denominators)\n\n numerator = '1' if numerator.empty?\n return \" #{numerator}\" if denominator.empty?\n\n UNIT_FORMAT % [numerator, denominator]\n end", "def normalized_size\n\t\t\ttile_size(max_level) * @unit_size\n\t\tend", "def dimensionality\n return nil if self.points.count == 0\n self.points.first.dimensions\n end", "def unit_t\n I18n.t \"#{self.unit_s}\", :count => 1\n end", "def find_dimension(name)\n NetCDF::Dimension.new(@netcdf_elmt.findDimension(name))\n end", "def administrative_units\n return @administrative_units\n end", "def units_per_package\n unit_factor = self.service.displayed_pricing_map.unit_factor\n units_per_package = unit_factor || 1\n\n return units_per_package\n end", "def denominator\n @data[1]\n end", "def unit_class\n UNIT_CLASSES[ @type ]\n end", "def volume\n return nil if dimension_u.nil? || dimension_v.nil? || dimension_w.nil?\n (dimension_u * dimension_v * dimension_w) / 1_000_000_000.0\n end", "def unit_weight\n (unit_area * product_thickness * 2.5).round(2)\n end", "def si_unit\n return Unit.steridian if describe == 'solid angle'\n return Unit.radian if describe == 'plane angle'\n\n val = si_base_units\n return nil unless val\n return val[0] if val.length == 1\n val = val.inject(Unit.unity) do |compound,unit|\n compound * unit\n end\n val = val.or_equivalent unless val.acts_as_equivalent_unit\n end", "def dimensions\n @dimensions ||= extract_dimensions\n end", "def time_unit\n @time_unit ||= PERIOD_MAPPING[@name]\n end", "def width\r\n assert_exists\r\n return @o.invoke(\"width\").to_s\r\n end", "def units=(value)\n @units = value\n end", "def get_unit(key)\n round_to(super, @nearest)\n end", "def dimensions\n eval_cexpression(\"tcb->ndices\")\n end", "def get_space_height\n return get_keyword_value(\"SPACE-HEIGHT\").to_f\n end", "def unit_name\n @data[@index]\n end", "def user_units\n @user.units\n end", "def size\n ['o', 'k', 'G'].inject(super.to_f) do |s, unit|\n # recusively divide by 1024 until...\n if s.is_a?(Float) && s >= 1024\n s = s / 1024\n # we format it here with the unit\n elsif !s.is_a?(String)\n s = \"#{s.to_s.gsub(/(\\.\\d{3})\\d+$/, \"\\\\1\")} #{unit}\"\n end\n s\n end\n end", "def unit_id\n\t\tif organisation.nil? || organisation.parent_id.nil?\n\t\t\treturn nil\n\t\telse\n\t\t\treturn organisation_id\n\t\tend\n\tend", "def width\n size.last\n end", "def width\n size.last\n end", "def units\n self.ListUnits.first.map { |u| map_unit(u) }\n end", "def units(by=nil)\n Unit.units.values.select { |unit| unit.dimensions == self }.map(&by).to_a\n end", "def find_unlimited_dimension\n NetCDF::Dimension.new(@netcdf_elmt.getUnlimitedDimension())\n end", "def length\n @node[\"length\"]\n end", "def get_dimension(dim, dta)\n dim_div = :\"div_#{dim}\"\n dim_sym = dim.to_sym\n\n dta[dim_div] = if options.key?(:fullscreen)\n Display.size[dim_sym].to_s + 'px'\n elsif options.key?(dim_div)\n if options[dim_div] == :full\n Display.size[dim_sym].to_s + 'px'\n elsif options[dim_div].is_a?(Integer)\n options[dim_div].to_s + '%'\n else\n options[dim_div].to_s\n end\n else\n '100%'\n end\n end", "def unit(x=1,y=1,z=1)\n point3.unit!\n end", "def coord_dimension_for(column_name)\n spatial_column_by_name(column_name).coord_dimension\n end", "def den()\n @den\n end", "def unit(unit_id=nil)\n unit_content = @xbrl_content[\"unit\"]\n return nil if unit_content.nil?\n\n units=[]\n\n l = lambda {|measure_list| measures=[]; measure_list.each { |measure| measures << measure[\"content\"]}; return measures}\n unit_content.each do |unit|\n\n next unless unit_id.nil? || unit[\"id\"].to_s == unit_id\n\n _unit=nil\n unless unit[\"measure\"].nil?\n _unit = Unit.new(unit[\"id\"], l.call(unit[\"measure\"]))\n else\n divide_content = unit[\"divide\"][0]\n\n numerator = l.call(divide_content[\"unitNumerator\"][0][\"measure\"])\n denominator = l.call(divide_content[\"unitDenominator\"][0][\"measure\"])\n\n divide=Unit::Divide.new(numerator, denominator)\n _unit = Unit.new(unit[\"id\"], divide)\n end\n _unit.ns=unit[\"nspace\"]\n _unit.nsp=unit[\"nspace_prefix\"]\n units << _unit\n end\n return units[0] unless unit_id.nil?\n units\n end", "def to_d() \n\t @n.to_f / @d\n\tend", "def width\n self.size[:x]\n end", "def totalMeters\n (self.floor_width*self.floor_length)\n end", "def height\n dimensions()[:y]\n end", "def currency_unit\n @currency_unit\n end", "def column\n Vedeu.width / 12\n end", "def column\n Vedeu.width / 12\n end", "def unit_at(x,y)\n cell = @cells.find {|cell| cell.x == x and cell.y == y }\n cell.unit.view if cell\n end", "def land_area_unit\n query_root_node(\"fao:landAreaUnit/text()\", @@NAMESPACES).to_s\n end", "def dimension_names\n two_dimensions | three_dimensions\n end", "def normal_units_uri\n UrisAreEolTerms.new(self).uri(:normal_units_uri)\n end", "def height\n @dimensions.y\n end" ]
[ "0.73316276", "0.73153585", "0.7066636", "0.69787794", "0.67842335", "0.6745625", "0.6684465", "0.6684465", "0.6653205", "0.6606556", "0.6606248", "0.6522029", "0.6455677", "0.63878477", "0.6315979", "0.6314739", "0.6244463", "0.62125117", "0.61903274", "0.6174105", "0.61657745", "0.614157", "0.6116957", "0.608741", "0.6082215", "0.6062608", "0.6044631", "0.60437787", "0.60047495", "0.5994173", "0.5962662", "0.59270597", "0.5919952", "0.5918969", "0.588523", "0.58834046", "0.58468014", "0.58468014", "0.5821104", "0.58107847", "0.5809934", "0.5760624", "0.5744305", "0.5740786", "0.57189757", "0.5717317", "0.5710658", "0.5705771", "0.56854886", "0.56808126", "0.56602615", "0.56523424", "0.56409985", "0.56377673", "0.5626696", "0.56198806", "0.5606771", "0.56061006", "0.55972534", "0.5592795", "0.55706906", "0.5546125", "0.55322963", "0.55183804", "0.5502987", "0.5502215", "0.550058", "0.54977155", "0.5497483", "0.5486549", "0.54744905", "0.5456892", "0.54521114", "0.5449303", "0.5448163", "0.5443444", "0.54339546", "0.5413095", "0.5413095", "0.5411172", "0.5404864", "0.53948426", "0.5359582", "0.5353328", "0.5337896", "0.53312296", "0.5330807", "0.53278303", "0.53274935", "0.5317842", "0.53051794", "0.5303602", "0.530338", "0.52896595", "0.52896595", "0.52856624", "0.52850485", "0.5281656", "0.52814656", "0.52683574" ]
0.8101753
0
Update one or more.
def update record, resources result = [resources].flatten.map do |resource| resource = record.new(resource) unless resource.kind_of?(record) keys = resource.tuple.values_at(*record.header.keys) # TODO: Name the key field(s) missing. raise ArgumentError, "#{record} resource has incomplete key: #{resource.inspect}" \ unless keys.select(&:nil?).empty? execute(command_update(record), *resource.tuple.values_at(*record.header.updatable), *keys) resource end resources.kind_of?(Array) ? result : result.first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(*args)\n each{|r| r.update(*args)}\n end", "def update\n update_all\n end", "def update(*args)\n put(*args)\n end", "def update(*args)\n put(*args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end", "def update!(**args)\n end" ]
[ "0.8030889", "0.74449974", "0.73343164", "0.73343164", "0.719129", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003", "0.7190003" ]
0.0
-1
Delete one or more.
def delete record, resources result = [resources].flatten.map do |resource| resource = record.new(resource) unless resource.kind_of?(record) keys = resource.tuple.values_at(*record.header.keys) # TODO: Name the key field(s) missing. raise ArgumentError, "#{record} resource has incomplete key: #{resource.inspect}" \ unless keys.select(&:nil?).empty? if result = execute(command_delete(record), *keys) resource.freeze end result end resources.kind_of?(Array) ? result : result.first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(*args)\n execute(:delete, *args)\n end", "def delete(*rest) end", "def delete!(*rest) end", "def delete(*ids)\n ids.flatten!\n @write_connection.delete_by_id(ids)\n end", "def delete_multiple(keys = [])\n verify_connection_url\n\n keys.each { |key| delete key }\n end", "def delete(first, last = None)\n execute_only(:delete, first, last)\n end", "def delete(table, ids) # abstract\n end", "def delete(*args)\n commit(\"delete\", *args)\n end", "def delete(*args)\n commit(\"delete\", *args)\n end", "def delete(*args)\n request(:delete, *args)\n end", "def del(*keys)\n keys.flatten!(1)\n return 0 if keys.empty?\n\n send_command([:del] + keys)\n end", "def delete(*names)\n names.each { |name| commands.delete name }\n end", "def delete(*args)\n if args.blank?\n raise \"Using delete with no args is not allowed. Please use delete_all to delete all records\"\n end\n keys = find_keys(*args)\n self.store.delete_keys(keys)\n end", "def destroy(ids)\n end", "def destroy(ids)\n end", "def del\n delete\n end", "def delete\n Iterable.request(conf, base_path).delete\n end", "def delete\n \n end", "def delete(*uris); end", "def delete(*args)\n if args.length == 1\n index = *args\n delete_index(index)\n elsif args.length == 2\n start_index, end_index = *args\n delete_range(start_index, end_index)\n elsif args.length > 2 && args.length < @items.length\n indices = *args.each { |arg| arg }\n delete_indices(indices)\n else\n raise UdaciListErrors::ArgumentError, \"Too many arguments\" if args.length\n end\n end", "def delete(*args)\n delete!(*args)\n rescue *exceptions\n false\n end", "def delete(*ids)\n collection.remove(to_criteria(:_id => ids.flatten))\n end", "def delete!\n uniq.bulk_job { |e| e.delete! }\n end", "def delete_list(params={})\n @obj.delete('delete', @auth.merge(params))\n end", "def destroy(*ids)\n find_some(ids.flatten).each(&:destroy)\n end", "def delete\n end", "def delete_all(name); end", "def delete!\n uniq.both_e.uniq.bulk_job { |e| e.delete! }\n uniq.bulk_job { |e| e.delete! }\n end", "def delete(*args)\n Request.delete(*args)\n end", "def delete!\n clear!\n delete\n end", "def delete\n end", "def delete\n \n end", "def delete(*records)\n delete_or_destroy(records, options[:dependent])\n end", "def delete *entities_or_keys\n @commit.delete(*entities_or_keys)\n # Do not delete yet\n true\n end", "def delete_related!(*names)\n # Nothing to do by default.\n end", "def delete!\n delete( nil, true ) \n end", "def destroy_multiple\n\t @list.delete(params[:id])\n\t redirect_to '/tasks'\n\tend", "def del(*args); end", "def remove!(*ids)\n remove(ids)\n session.commit\n end", "def delete\n if body.empty? && params[:id]\n client.delete(params)\n elsif body.empty?\n client.delete_by_query(params.merge(body: body.merge(ALL)))\n else\n client.delete_by_query(params.merge(body: body))\n end\n end", "def delete(*records)\n records.each do |record|\n target.delete(record)\n end\n end", "def delete\n end", "def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end", "def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end", "def delete\n\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def destroy; delete end", "def delete(*filenames); end", "def delete!(defer = false)\n delete_logic( defer, false ) \n end", "def delete(*args, &block)\n map_method(:delete, args, &block)\n end", "def delete(*names)\n Tk.execute(:image, :delete, *names)\n end", "def destroy(*records)\n delete_or_destroy(records, :destroy)\n end", "def delete( *regexs )\n self.dup.delete!( *regexs )\n end", "def delete(*args)\n dataset.delete(*args)\n self\n end", "def deleteAll(xs)\n xs.each do |x|\n x.destroy\n end\n end", "def delete(defer = false)\n delete_logic( defer )\n end", "def delete_multi(names, options = nil)\n return 0 if names.empty?\n\n options = merged_options(options)\n names.map! { |key| normalize_key(key, options) }\n\n instrument_multi :delete_multi, names do\n delete_multi_entries(names, **options)\n end\n end", "def delete\n request(:delete)\n end", "def delete_entries(entries)\n delete_all(:id => entries)\n end", "def delete\n destroy\n end", "def delete *args, &block\n res = @conn.delete *args, &block\n handle res, parse: false\n end", "def destroy\n super(:multiple_delete)\n end", "def delete_all\n klass.delete_all(:conditions => selector)\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def delete_entries(entries)\n all(:id => entries.map(&:id)).destroy!\n end", "def destroy_multiple\n # Remove selected patients from database\n id_list = params[:patient_ids].split(',')\n number_deleted = Patient.where(id: { '$in': id_list }).destroy_all\n redirect_back(fallback_location: root_path)\n # If something can't be deleted, we want to flash that as well as anything that was deleted.\n if number_deleted == id_list.length\n flash[:notice] = \"Deleted #{number_deleted} #{'patient'.pluralize(number_deleted)}.\"\n else\n difference = id_list.length - number_deleted\n flash[:notice] = \"#{difference} #{'patient'.pluralize(difference)} could not be deleted. \\\n Deleted #{number_deleted} #{'patient'.pluralize(number_deleted)}.\"\n end\n end", "def del(*keys); end", "def delete_files(*files)\n files = files.flatten\n unless files.empty?\n @perforce.run(\"delete\", \"-c\", @number, *files)\n end\n end", "def delete_all(attributes = {})\n raise NotImplementedError.new\n end", "def delete() #DELETE film1.delete (removes 1 film)\n sql = \"DELETE FROM films WHERE id = $1;\"\n values = [@id]\n SqlRunner.run(sql, values)\n end", "def delete(files)\n # sync before we delete\n sync\n Array.wrap(files).each do |f|\n info \"removing #{f}\"\n FileUtils.rm(f)\n error \"#{f} wasn't removed\" if File.exists?(f)\n end\n end", "def delete()\n sql = \"DELETE FROM albums\n WHERE id = $1;\"\n values = [@id]\n SqlRunner.run( sql, values )\n end", "def deleteCollection _args\n \"deleteCollection _args;\" \n end", "def delete\n\n\tend", "def delete\n # TODO: implement delete\n end", "def delete(id_or_array)\n delete_by(primary_key => id_or_array)\n end", "def delete_many(filter = nil, options = nil)\n native.delete_many(filter, options || {}).deleted_count\n end", "def delete\n sql = 'DELETE FROM members WHERE id = $1'\n values = [@id]\n SqlRunner.run(sql, values)\nend", "def delete(name)\n\n end", "def delete(action, **args); end", "def delete(id_or_array)\n if id_or_array.is_a? Array\n id_or_array.each {|id| @model_class.resource[id].delete} # todo: can this be optimized into one call?\n else\n @model_class.resource[id_or_array].delete\n end\n end", "def delete_all!\n delete(query: \"*:*\")\n end", "def delete(statements)\n raise TriplestoreAdapter::TriplestoreException.new(\"#{@provider.class.name} missing delete method.\") unless @provider.respond_to?(:delete)\n @provider.delete(statements)\n end", "def delete()\n sql = \"DELETE FROM stock_items WHERE id = $1\"\n values = [@id]\n SqlRunner.run(sql, values)\n end", "def delete\n\ta = Legislator.where(\"in_office = ? AND title = ?\", false ,'Sen').destroy_all\n\tb = Legislator.where(\"in_office = ? AND title = ?\",false, 'Sen').destroy_all \n\n\t#check if delete\n\tc = Legislator.where(\"title=?\",\"Sen\")\n\tputs \"Senators:\" + \"#{c.count}\"\n\td = Legislator.where(\"title=?\",\"Rep\")\n\tputs \"Representatives:\" + \"#{d.count}\"\nend", "def delete!\n values.delete!\n end", "def delete(labels = [])\n call_container_method(:delete, labels)\n end", "def delete\n destroy\n end", "def delete\n destroy\n end", "def destroy(*args)\n ids = self.map(&:id)\n self.any? ? self.first.class.destroy(ids.first) : false\n end", "def delete\n sql = \"DELETE FROM tickets WHERE id = $1\"\n values = [id]\n SqlRunner.run(sql, values)\n end", "def delete_one(filter = nil, options = nil)\n native.delete_many(filter, options || {}).deleted_count\n end", "def delete()\n sql = \"DELETE FROM transactions\n WHERE id = $1\"\n values = [@id]\n SqlRunner.run(sql, values)\nend", "def delete\n api(\"Delete\")\n end", "def delete_related!(*names)\n # Recurse on the statement.\n @statement.delete_related!(*names)\n end" ]
[ "0.7796597", "0.7616567", "0.7540228", "0.73775", "0.7331829", "0.7253921", "0.7207253", "0.71927065", "0.7171126", "0.7170078", "0.7156719", "0.71288824", "0.7098882", "0.7079333", "0.7079333", "0.7046401", "0.7033728", "0.70301384", "0.70279235", "0.7010921", "0.70014495", "0.69938666", "0.6946816", "0.69411343", "0.6937093", "0.6923692", "0.69028276", "0.68931437", "0.6892332", "0.68848574", "0.6881883", "0.6873561", "0.686767", "0.6860333", "0.68346167", "0.68002236", "0.679024", "0.6785217", "0.67791986", "0.6769385", "0.6768547", "0.67627215", "0.6761609", "0.6753507", "0.6742439", "0.6742293", "0.6742293", "0.6742293", "0.6742293", "0.6742293", "0.6742293", "0.6742293", "0.67395633", "0.6737281", "0.6726035", "0.6706834", "0.67001015", "0.66965836", "0.6659328", "0.66392165", "0.6631979", "0.6628457", "0.6624304", "0.6623195", "0.66184056", "0.66137904", "0.6603078", "0.6600015", "0.6597633", "0.6592137", "0.65820235", "0.65729606", "0.6562976", "0.6558843", "0.6550334", "0.65382373", "0.6534639", "0.6525362", "0.6524072", "0.6500673", "0.6500605", "0.6480748", "0.64782494", "0.64738476", "0.64733815", "0.6458553", "0.64464384", "0.6446363", "0.6437683", "0.64350253", "0.64299566", "0.64277583", "0.6427051", "0.64163274", "0.64163274", "0.6412363", "0.6409015", "0.6407464", "0.6399186", "0.6398178", "0.6395761" ]
0.0
-1
Create a server side prepared statement
def prepare record = nil, command record ? Statement.new(record, command) : db.prepare(command) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _set_prepared_statement_server(ps)\n if @server\n ps.server(@server)\n else\n ps\n end\n end", "def _execute_prepared_statement(conn, ps_name, args, opts)\n conn.exec_prepared(ps_name, args)\n end", "def prepare(type, name=nil, *values)\n ps = to_prepared_statement(type, values)\n ps.extend(JDBC::Dataset::PreparedStatementMethods)\n ps.extend(::Sequel::Fdbsql::DatasetMethods::PreparedStatementMethods)\n if name\n ps.prepared_statement_name = name\n db.set_prepared_statement(name, ps)\n end\n ps\n end", "def prepare(type, name=nil, *values)\n ps = to_prepared_statement(type, values)\n ps.extend(PreparedStatementMethods)\n if name\n ps.prepared_statement_name = name\n db.set_prepared_statement(name, ps)\n end\n ps\n end", "def to_prepared_statement(type, values=nil, opts=OPTS)\n mods = opts[:extend] || []\n mods += [PreparedStatementMethods]\n\n bind.\n clone(:prepared_statement_name=>opts[:name], :prepared_type=>type, :prepared_modify_values=>values, :orig_dataset=>self, :no_cache_sql=>true, :prepared_args=>@opts[:prepared_args]||[]).\n with_extend(*mods)\n end", "def prepare_statement(ds, type, vals=OPTS)\n ds.clone(:log_sql=>true).prepare(type, :\"smpsp_#{NEXT.call}\", vals)\n end", "def prepare(str)\n close\n begin\n @sqlstate = \"00000\"\n @statement_id, @param_count, @fields = @protocol.stmt_prepare_command(str)\n rescue ServerError => e\n @last_error = e\n @sqlstate = e.sqlstate\n raise\n end\n ObjectSpace.define_finalizer(self, self.class.finalizer(@protocol, @statement_id))\n self\n end", "def execute_prepared_statement(ps_name, opts)\n args = opts[:arguments]\n ps = prepared_statement(ps_name)\n sql = ps.prepared_sql\n synchronize(opts[:server]) do |conn|\n unless conn.prepared_statements.fetch(ps_name, []).first == sql\n log_connection_yield(\"PREPARE #{ps_name}: #{sql}\", conn){conn.prepare(sql, ps_name)}\n end\n args = args.map{|v| v.nil? ? nil : prepared_statement_arg(v)}\n log_sql = \"EXECUTE #{ps_name}\"\n if ps.log_sql\n log_sql += \" (\"\n log_sql << sql\n log_sql << \")\"\n end\n begin\n stmt = log_connection_yield(log_sql, conn, args){conn.execute_prepared(ps_name, *args)}\n if block_given?\n yield(stmt)\n else \n stmt.affected\n end\n ensure\n stmt.free_result if stmt\n end\n end\n end", "def prepare(*args)\n ps = super\n ps.extend(::Sequel::Postgres::DatasetMethods::PreparedStatementMethods)\n ps\n end", "def allow_preparing_prepared_statements?\n false\n end", "def prepare(sql, ps_name)\n if stmt = IBM_DB.prepare(@conn, sql)\n ps_name = ps_name.to_sym\n stmt = Statement.new(stmt)\n @prepared_statements[ps_name] = [sql, stmt]\n else\n err = error_msg\n err = \"Error preparing #{ps_name} with SQL: #{sql}\" if error_msg.nil? || error_msg.empty?\n raise Error.new(err, error_sqlstate)\n end\n end", "def prepare( sql )\n Statement.new( self, sql )\n end", "def execute_prepared(ps_name, *values)\n stmt = @prepared_statements[ps_name].last\n res = stmt.execute(*values)\n unless res\n raise Error.new(\"Error executing statement #{ps_name}: #{error_msg}\", error_sqlstate)\n end\n stmt\n end", "def set_prepared_statement(name, ps)\n Sequel.synchronize{prepared_statements[name] = ps}\n end", "def prepared_sql\n case prepared_type\n when :select, :all, :each\n # Most common scenario, so listed first.\n select_sql\n when :first\n clone(:limit=>1).select_sql\n when :insert_select\n insert_select_sql(*prepared_modify_values)\n when :insert, :insert_pk\n insert_sql(*prepared_modify_values)\n when :update\n update_sql(*prepared_modify_values)\n when :delete\n delete_sql\n else\n select_sql\n end\n end", "def execute(*values)\n raise ClientError, \"not prepared\" unless @param_count\n raise ClientError, \"parameter count mismatch\" if values.length != @param_count\n values = values.map{|v| @charset.convert v}\n begin\n @sqlstate = \"00000\"\n nfields = @protocol.stmt_execute_command @statement_id, values\n if nfields\n @fields = @protocol.retr_fields nfields\n @result = StatementResult.new @fields, @protocol, @charset\n else\n @affected_rows, @insert_id, @server_status, @warning_count, @info =\n @protocol.affected_rows, @protocol.insert_id, @protocol.server_status, @protocol.warning_count, @protocol.message\n end\n return self\n rescue ServerError => e\n @last_error = e\n @sqlstate = e.sqlstate\n raise\n end\n end", "def execute_prepared(plan_name, *args)\n # {{{\n args_string = ''\n if args.to_s != '' && args.length > 0 then \n args_string = \"(#{args.flatten.map { |a| \"'#{a}'\" }.join(',')})\" \n end\n query_string = \"EXECUTE #{plan_name.to_s} #{args_string}; \"\n return perform_select(query_string).get_rows()\n end", "def execute_prepared(sql,params_arr)\n prepared_statement = @database_handle.prepare(sql)\n params_arr.each_with_index do |param,index|\n prepared_statement.bind_param(index+1,param)\n end \n prepared_statement.execute\n end", "def prepare(sql, datatypes = nil, tx = nil)\n Statement.prepare(self, sql, datatypes, tx)\n end", "def prepare(str)\n close\n @protocol.synchronize do\n begin\n @sqlstate = \"00000\"\n @protocol.reset\n @protocol.send_packet Protocol::PreparePacket.new(@mysql.charset.convert(str))\n res_packet = @protocol.read_prepare_result_packet\n if res_packet.param_count > 0\n res_packet.param_count.times{@protocol.read} # skip parameter packet\n @protocol.read_eof_packet\n end\n if res_packet.field_count > 0\n fields = Array.new(res_packet.field_count).map{Field.new @protocol.read_field_packet}\n @protocol.read_eof_packet\n else\n fields = []\n end\n @statement_id = res_packet.statement_id\n @param_count = res_packet.param_count\n @fields = fields\n rescue ServerError => e\n @sqlstate = e.sqlstate\n raise\n end\n end\n ObjectSpace.define_finalizer(self, self.class.finalizer(@protocol, @statement_id))\n self\n end", "def prepared_statement_name\n @opts[:prepared_statement_name]\n end", "def execute_prepared_statement(name, args)\n check_disconnect_errors{exec_prepared(name, args)}\n end", "def prepared_statement(name)\n Sequel.synchronize{prepared_statements[name]}\n end", "def call(bind_vars={}, &block)\n sql = prepared_sql\n prepared_args.freeze\n ps = bind(bind_vars)\n ps.clone(:bind_arguments=>ps.map_to_prepared_args(ps.opts[:bind_vars]), :sql=>sql, :prepared_sql=>sql).run(&block)\n end", "def prepare(stmt)\n sanity_check(stmt)\n sth = StatementHandle.new(@handle.prepare(stmt), false, true, @convert_types)\n # FIXME trace sth.trace(@trace_mode, @trace_output)\n sth.dbh = self\n sth.raise_error = raise_error\n\n if block_given?\n begin\n yield sth\n ensure\n sth.finish unless sth.finished?\n end\n else\n return sth\n end\n end", "def select_prepared(plan_name, *args)\n # {{{\n args_string = ''\n if args.to_s != '' && args.length > 0 then \n args_string = \"(#{args.flatten.map { |a| \"'#{a}'\" }.join(',')})\" \n end\n query_string = \"EXECUTE #{plan_name.to_s} #{args_string}; \"\n return select_cached(query_string)\n end", "def prepareInsertUserStatement\n @conn.prepare(\"insert_user\", \"insert into users (id, name) values ($1, $2)\")\n end", "def prepare( str )\n @db.prepare( str )\n end", "def prepared_statements\n false\n end", "def set_prepared_statement(stmt, item, index, type)\n case item\n when NilClass\n stmt.set_object index, nil\n when String\n case type\n when :binary\n stmt.set_bytes index, item.to_java_bytes\n when :text\n stmt.set_string index, item\n else\n stmt.set_string index, item\n end\n when Symbol\n stmt.set_string index, item.to_s\n when Integer\n stmt.set_int index, item\n when Float\n stmt.set_float index, item\n when Time\n case type\n when :date\n stmt.set_date index, item.to_java_sql_date\n when :time\n stmt.set_time index, item.to_java_sql_time\n when :timestamp\n stmt.set_timestamp index, item.to_java_sql_time_stamp\n end\n when BigDecimal\n stmt.set_big_decimal index, java.math.BigDecimal.new(item.to_s('F'))\n when TrueClass, FalseClass\n stmt.set_boolean index, item\n else\n raise \"Can't find correct type to set prepared statement for #{item.inspect}\"\n end\n end", "def make_statement\n end", "def make_statement\n end", "def statement\n Cassandra::Statements::Simple.new(*build_cql_and_params, type_hints, idempotent?)\n end", "def execute_prepared_statement(conn, name, opts=OPTS, &block)\n ps = prepared_statement(name)\n sql = ps.prepared_sql\n ps_name = name.to_s\n\n if args = opts[:arguments]\n args = args.map{|arg| bound_variable_arg(arg, conn)}\n end\n\n unless conn.prepared_statements[ps_name] == sql\n conn.execute(\"DEALLOCATE #{ps_name}\") if conn.prepared_statements.include?(ps_name)\n conn.check_disconnect_errors{log_connection_yield(\"PREPARE #{ps_name} AS #{sql}\", conn){conn.prepare(ps_name, sql)}}\n conn.prepared_statements[ps_name] = sql\n end\n\n log_sql = \"EXECUTE #{ps_name}\"\n if ps.log_sql\n log_sql += \" (\"\n log_sql << sql\n log_sql << \")\"\n end\n\n q = conn.check_disconnect_errors{log_connection_yield(log_sql, conn, args){_execute_prepared_statement(conn, ps_name, args, opts)}}\n begin\n block_given? ? yield(q) : q.cmd_tuples\n ensure\n q.clear if q && q.respond_to?(:clear)\n end\n end", "def execute(sql, opts=OPTS, &block)\n super(prepared_statement_name, opts, &block)\n end", "def _prepare(name, sql, datatypes = nil, tx = nil)\n run(:_send_parse, [name, sql, datatypes], tx)\n end", "def inspect\n \"<#{visible_class_name}/PreparedStatement #{prepared_sql.inspect}>\"\n end", "def statements_prepared(conn)\n @statement_mutex.synchronize do\n @statements_prepared ||= {}\n @statements_prepared[conn] ||= {}\n end\n end", "def unprepare_sqlserver_statement(sql)\n if sql.starts_with?(SQLSERVER_STATEMENT_PREFIX)\n executesql = sql.from(SQLSERVER_STATEMENT_PREFIX.length)\n args = executesql.split(', ')\n unprepared_sql = args.shift.strip.match(SQLSERVER_NATIONAL_STRING_MATCHER)[1]\n unprepared_sql = Utils.unquote_string(unprepared_sql)\n args = args.from(args.length / 2)\n args.each_with_index do |arg, index|\n value = arg.match(SQLSERVER_PARAM_MATCHER)[1]\n unprepared_sql.sub! \"@#{index}\", value\n end\n unprepared_sql\n else\n sql\n end\n end", "def prepare(*)\n raise Error, \"cannot prepare an already prepared statement\" unless allow_preparing_prepared_statements?\n super\n end", "def execute(stmt, bindvars={})\n sanity_check(stmt)\n\n if @convert_types\n bindvars = DBI::Utils::ConvParam.conv_param(driver_name, bindvars)\n end\n\n sth = StatementHandle.new(@handle.execute(stmt, bindvars), true, true, @convert_types, true)\n # FIXME trace sth.trace(@trace_mode, @trace_output)\n sth.dbh = self\n sth.raise_error = raise_error\n\n if block_given?\n begin\n yield sth\n ensure\n sth.finish unless sth.finished?\n end\n else\n return sth\n end\n end", "def prepareInserturlStatement\n @conn.prepare(\"insert_url\", \"insert into urls (uid, loc) values ($1, $2)\")\n end", "def prepareInserturlStatement\n @conn.prepare(\"insert_url\", \"insert into urls (uid, loc) values ($1, $2)\")\n end", "def set_server_statement\n super\n end", "def prepare_statement_sub(sql)\n sql.gsub(/\\$\\d+/, '?')\n end", "def statement\n Cassandra::Statements::Simple.new(*build_cql_and_bindings)\n end", "def execute(statement, *bind_values)\n with_connection do |connection|\n command = connection.create_command(statement)\n command.execute_non_query(*bind_values)\n end\n end", "def prepare(str)\n st = Stmt.new @protocol, @charset\n st.prepare str\n st\n end", "def execute(*values)\n raise ClientError, \"not prepared\" unless @param_count\n raise ClientError, \"parameter count mismatch\" if values.length != @param_count\n values = values.map{|v| @mysql.charset.convert v}\n @protocol.synchronize do\n begin\n @sqlstate = \"00000\"\n @protocol.reset\n @protocol.send_packet Protocol::ExecutePacket.new(@statement_id, CURSOR_TYPE_NO_CURSOR, values)\n res_packet = @protocol.read_result_packet\n raise ProtocolError, \"invalid field_count\" unless res_packet.field_count == @fields.length\n @fieldname_with_table = nil\n if res_packet.field_count == 0\n @affected_rows, @insert_id, @server_status, @warning_conut =\n res_packet.affected_rows, res_packet.insert_id, res_packet.server_status, res_packet.warning_count\n return nil\n end\n @fields = Array.new(res_packet.field_count).map{Field.new @protocol.read_field_packet}\n @protocol.read_eof_packet\n return StatementResult.new(@mysql, @fields)\n rescue ServerError => e\n @sqlstate = e.sqlstate\n raise\n end\n end\n end", "def execute_dui(sql, opts=OPTS, &block)\n super(prepared_statement_name, opts, &block)\n end", "def sql\n @stmt_api.sql\n end", "def execute(sql, *bind_values)\n @pool.acquire { |conn| conn.execute(sql, *bind_values) }\n end", "def stmt_init\n Stmt.new @protocol, @charset\n end", "def create!(con)\n con.exec create_stmt\n end", "def prepare_statement(condition)\n args = condition.dup\n str = args.shift\n # ? handles a single type.\n # ?* handles an array.\n args.each { |arg| str.sub!(/\\?\\*/, quotea(arg)); str.sub!(/\\?/, quote(arg)) }\n condition = str\n end", "def prepare_explicit_statement(ds, type, vals=OPTS)\n f = ds.opts[:from]\n meth = type == :insert_select ? :returning : :select\n s = ds.opts[meth]\n if f && f.length == 1 && !ds.opts[:join] && (!s || s.empty?)\n ds = ds.send(meth, *columns.map{|c| Sequel.identifier(c)})\n end \n \n prepare_statement(ds, type, vals)\n end", "def prepared_statement_arg(v)\n case v\n when Numeric\n v.to_s\n when Date, Time\n literal(v).gsub(\"'\", '')\n else\n v\n end\n end", "def build_cmd(sql)\n # Only exists within the context of this script (not exported), so this\n # does not degrade security posture after the script has completed\n ENV['PGPASSWORD'] = conn_opts[:password] if conn_opts.has_key? :password\n\n cmd = \"psql\"\n cmd << \" -d #{conn_opts[:database]}\" if conn_opts.has_key? :database\n cmd << \" -h #{conn_opts[:host]}\" if conn_opts.has_key? :host\n cmd << \" -U #{conn_opts[:username]}\" if conn_opts.has_key? :username\n cmd << \" -p #{conn_opts[:port]}\" if conn_opts.has_key? :port\n cmd << \" -c \\\"#{sql}\\\"\"\n\n return cmd\n end", "def execute(sql, opts=OPTS, &block)\n if sql.is_a?(Symbol)\n execute_prepared_statement(sql, opts, &block)\n else\n synchronize(opts[:server]){|c| _execute(c, sql, opts, &block)}\n end\n rescue Connection::Error => e\n raise_error(e)\n end", "def execute_statement(statement, *arguments)\n if arguments.length > 5\n raise ArgumentError, 'Too many arguments, prepared statement with only upto 5 arguments is supported for simplicity'\n elsif arguments.length == 0\n @session.execute(\"#{statement}\")\n else\n prepared_statement = @session.prepare(\"#{statement}\")\n @session.execute(prepared_statement, arguments: arguments)\n end\n end", "def prepare(str, &block)\n st = Statement.new self\n st.prepare str\n if block\n begin\n return block.call(st)\n ensure\n st.close\n end\n end\n return st\n end", "def execute(sql, opts=OPTS, &block)\n if opts[:sproc]\n call_sproc(sql, opts, &block)\n elsif sql.is_a?(Symbol)\n execute_prepared_statement(sql, opts, &block)\n else\n synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)}\n end\n end", "def query(statement, *params) #Use of splat(*) parameter used with methods where you don't know how many arguements it will take \n @logger.info \"#{statement}: #{params}\" #Funtionailty for the ability to see in the local host terminal d-bug output from sinatra showing all of the requests it's accepting; this will alow us to see the SQL queries that are being executed in the db to help troubleshoot \n @db.exec_params(statement, params)\n end", "def prepared_sql\n if sql = @opts[:prepared_sql] || cache_get(:_prepared_sql)\n return sql\n end\n cache_set(:_prepared_sql, super)\n end", "def query( sql, *bind_vars, &block ) # :yields: result_set\n stmt = prepare( sql )\n stmt.bind_params( *bind_vars )\n stmt.execute( &block )\n end", "def query_statement(statement, *arguments)\n if arguments.length > 5\n raise ArgumentError, 'Too many arguments, prepared statement with only upto 5 arguments is supported for simplicity'\n elsif arguments.length == 0\n query_results = @session.execute(\"#{statement}\")\n else\n prepared_statement = @session.prepare(\"#{statement}\")\n query_results = @session.execute(prepared_statement, arguments: arguments)\n end\n return query_results\n end", "def prepare_sql_statements\n begin\n databases.each do |db|\n create_query[db][0] = create_query[db][0] + \" \" + create_query[db][1]\n create_query[db].delete_at(1)\n create_query[db] = create_query[db].join(\", \")\n create_query[db] << \");\"\n end\n rescue TypeError => e\n end\n end", "def sql\n @sql ||= begin\n bind_params = []\n 1.upto(selector_keys.length + setter_keys.length) { |i| bind_params << \"$#{i}\" }\n %{SELECT #{name}(#{bind_params.join(', ')})}\n end\n end", "def _insert_raw(ds)\n if use_prepared_statements_for?(:insert)\n _set_prepared_statement_server(model.send(:prepared_insert, @values.keys)).call(@values)\n else\n super\n end\n end", "def call(type, bind_vars=OPTS, *values, &block)\n ps = to_prepared_statement(type, values)\n ps.extend(BindArgumentMethods)\n ps.call(bind_vars, &block)\n end", "def call(*)\n raise Error, \"Cannot call prepared statement without a name\" if prepared_statement_name.nil?\n super\n end", "def save()\n #connect to database\n db = PG.connect({ dbname: 'bounty_hunters', host: 'localhost' })\n #write big long SQL string\n sql = \"INSERT INTO bounties\n (\n name,\n species,\n bounty_value,\n favourite_weapon\n )\n VALUES\n ($1, $2, $3, $4)\"\n\n #make array of values for prepared statement\n values = [@name, @species, @bounty_value, @favourite_weapon]\n #prepare statement\n db.prepare(\"save\", sql)\n #exec statement\n db.exec_prepared(\"save\", values)\n #close link to db\n db.close()\n end", "def do(stmt, bindvars={})\n sanity_check(stmt)\n @handle.do(stmt, bindvars)\n #@handle.do(stmt, DBI::Utils::ConvParam.conv_param(driver_name, bindvars))\n end", "def cached_prepared_statement(type, subtype)\n h = @prepared_statements[type]\n Sequel.synchronize do\n if v = h[subtype]\n return v\n end\n end\n ps = yield\n Sequel.synchronize{h[subtype] = ps}\n end", "def initialize(conn, sql)\r\n @connection = conn\r\n @call = @connection.prepare_call(sql)\r\n end", "def bind_params( *bind_vars )\n @statement.bind_params( *bind_vars )\n end", "def execute(sql)\n stmt = IBM_DB.exec(@conn, sql)\n raise Error.new(error_msg, error_sqlstate) unless stmt\n Statement.new(stmt)\n end", "def _insert_select_raw(ds)\n if use_prepared_statements_for?(:insert_select)\n if ps = model.send(:prepared_insert_select, @values.keys)\n _set_prepared_statement_server(ps).call(@values)\n end\n else\n super\n end\n end", "def prepareInsertPictureStatement\n @conn.prepare(\"insert_picture\", \"INSERT INTO image_store (name, pdesc) VALUES ($1, $2)\")\n end", "def generate_insert\n @binds = Array.new\n @insert_statement = \"insert into #{fully_qualified_table_name} (\"\n @insert_statement << column_details.keys.sort.map { |k| column_detail(k).column_name }.join(',')\n @insert_statement << ') values ('\n @insert_statement << column_details.keys.sort.map { |k|\n \":#{k}\"\n }.join(',')\n column_details.keys.sort.each { |k|\n if @column_values[k] == nil\n @binds.push [column_type_to_ruby_type(column_details[k]), nil]\n else\n @binds.push @column_values[k]\n end\n }\n @insert_statement << ')'\n @insert_statement\n end", "def execute(sql, *params)\n self.connect\n return nil if ! self.connected? && self.interpreter.preview?\n begin\n sth = self.dbh.prepare(sql)\n if params.empty?\n sth.execute\n else\n sth.execute(*params)\n end\n return sth\n rescue ::DBI::ProgrammingError => e\n raise \"#{e.message} -- #{sql}\"\n end\n end", "def execute(sql, opts=OPTS)\n _execute(sql, opts) do |conn|\n begin\n yield(stmt = log_connection_yield(sql, conn){conn.prepare(sql)})\n ensure\n stmt.close if stmt\n end\n end\n end", "def _execute(conn, sql, opts, &block)\n if sql.is_a?(Symbol)\n execute_prepared_statement(conn, sql, opts, &block)\n else\n conn.execute(sql, opts[:arguments], &block)\n end\n end", "def initialize( db, sql )\n @db = db\n #prepare_method = @db.utf16? ? :prepare16 : :prepare\n prepare_method = :prepare\n @param_positions = {}\n @stmt_api = @db.api.send( prepare_method, sql )\n @blobs_to_write = []\n @rowid_index = nil\n @result_meta = nil\n @open = true\n end", "def build_statement(constructor, field, options = T.unsafe(nil)); end", "def execute(sql, opts = {}, &block)\n res = nil\n synchronize(opts[:server]) do |conn|\n res = check_database_errors do\n if sql.is_a?(Symbol)\n execute_prepared_statement(conn, sql, opts, &block)\n else\n log_yield(sql) do\n conn.query(sql, opts[:arguments])\n end\n end\n end\n yield res if block_given?\n res.cmd_tuples\n end\n end", "def literal_string_append(sql, s)\n sql << \"'\" << db.synchronize(@opts[:server]){|c| c.escape(s)} << \"'\"\n end", "def prepared_refresh\n # SEQUEL5: Remove\n cached_prepared_statement(:fixed, :refresh){prepare_explicit_statement(naked.clone(:server=>dataset.opts.fetch(:server, :default)).where(prepared_statement_key_array(primary_key)), :first)}\n end", "def prepare(query)\n sth = nil\n mutex.synchronize do\n self.last_query = query\n sth = new_statement(query)\n yield sth if block_given?\n sth.finish if block_given?\n end\n\n return self.last_statement = sth\n end", "def execute(sql, args = nil, bulk_args = nil, http_options = {})\n @logger.debug sql\n req = Net::HTTP::Post.new('/_sql', headers)\n body = { 'stmt' => sql }\n body['args'] = args if args\n body['bulk_args'] = bulk_args if bulk_args\n req.body = body.to_json\n response = request(req, http_options)\n @logger.debug response.body\n\n case response.code\n when /^2\\d{2}/\n ResultSet.new response.body\n else\n @logger.info(response.body)\n raise CrateRuby::CrateError, response.body\n end\n end", "def sql(bindings, type = :find)\n statement, bind_values = build_statement(type)\n statement.gsub('?') { eval_bound_value(bind_values.shift, connection, bindings) }\n end", "def execute(sql, name = nil, binds = [])\n log(sql, name) do\n sql = bind_params(binds, sql) if prepared_statements\n @connection.do(sql)\n end\n end", "def run(&block)\n case prepared_type\n when :select, :all\n # Most common scenario, so listed first\n all(&block)\n when :each\n each(&block)\n when :insert_select\n with_sql(prepared_sql).first\n when :first\n first\n when :insert, :update, :delete\n if opts[:returning] && supports_returning?(prepared_type)\n returning_fetch_rows(prepared_sql)\n elsif prepared_type == :delete\n delete\n else\n send(prepared_type, *prepared_modify_values)\n end\n when :insert_pk\n fetch_rows(prepared_sql){|r| return r.values.first}\n when Array\n case prepared_type[0]\n when :map, :as_hash, :to_hash, :to_hash_groups\n send(*prepared_type, &block) \n end\n else\n Sequel::Deprecation.deprecate(\"Using an unsupported prepared statement type (#{prepared_type.inspect})\", 'Switch to using :select as the prepared statement type')\n all(&block)\n end\n end", "def sql_statement(report_state_hash, for_webquery=false)\n statement = FieldParser.new(report_state_hash[:full_parameter_query],\n report_state_hash[:parameter_fields_values],\n report_state_hash[:search_engine_or_values],\n report_state_hash[:operator_signs]).query\n\n if for_webquery # Always use maximum LIMIT.\n max_limit = Globals.webquery_max_rows\n if statement.upcase.index(\" LIMIT \") != nil\n pattern = / limit [0-9]+/i\n limit_clause = \" LIMIT #{max_limit}\"\n statement.gsub!(pattern, limit_clause)\n else\n statement << \" LIMIT #{max_limit}\"\n end\n else\n max_limit = Globals.search_engine_max_rows\n if report_state_hash[:search_engine_limit].to_s != \"\"\n if statement.upcase.index(\" LIMIT \") != nil\n pattern = / limit [0-9]+/i\n limit_clause = \" LIMIT #{report_state_hash[:search_engine_limit]}\"\n statement.gsub!(pattern, limit_clause)\n else\n if report_state_hash[:search_engine_limit].to_i > max_limit.to_i\n statement << \" LIMIT #{max_limit}\"\n else\n statement << \" LIMIT #{report_state_hash[:search_engine_limit]}\"\n end\n end\n else\n statement << \" LIMIT #{max_limit}\"\n end\n end\n statement\n end", "def prepared_insert(cols)\n cached_prepared_statement(:insert, prepared_columns(cols)){prepare_statement(dataset, :insert, prepared_statement_key_hash(cols))}\n end", "def prepared_args\n @opts[:prepared_args]\n end", "def statement_params\n params.require(:statement_parsers_parser_base).permit(:name, :description, :type, :plain_text_regex, :plain_text_date_format)\n end", "def create_psql_cmd(query, db)\n \"su postgres -c \\\"psql -d #{db} -p #{@port} -q -t -c #{escaped_query(query)}\\\"\"\n end", "def execute(sql, opts=OPTS, &block)\n super(sql, {:arguments=>bind_arguments}.merge(opts), &block)\n end", "def prepared_insert_select(cols)\n if dataset.supports_insert_select?\n cached_prepared_statement(:insert_select, prepared_columns(cols)){prepare_explicit_statement(naked.clone(:server=>dataset.opts.fetch(:server, :default)), :insert_select, prepared_statement_key_hash(cols))}\n end\n end" ]
[ "0.6981347", "0.6837139", "0.6787886", "0.6705023", "0.6595554", "0.65277636", "0.6479592", "0.6463498", "0.64207697", "0.6383033", "0.6373859", "0.63402313", "0.6266532", "0.62571156", "0.62253773", "0.60758793", "0.60536516", "0.6025458", "0.5980238", "0.5975573", "0.5968316", "0.59673136", "0.59671444", "0.5939031", "0.5910939", "0.5905673", "0.5898256", "0.5892415", "0.5853525", "0.5846914", "0.5797512", "0.5797512", "0.5787327", "0.5768661", "0.57611036", "0.57400227", "0.5721321", "0.5713188", "0.5654448", "0.5642254", "0.5636738", "0.5607073", "0.5607073", "0.5590811", "0.5590046", "0.55883807", "0.55771184", "0.5573305", "0.55718035", "0.5569009", "0.5560861", "0.5520339", "0.5492451", "0.5489333", "0.5481694", "0.5475935", "0.546548", "0.54566973", "0.54481053", "0.5433433", "0.5430309", "0.53869534", "0.53784454", "0.5374482", "0.5368006", "0.5355895", "0.53501666", "0.5343168", "0.53368556", "0.5329326", "0.53144115", "0.53049135", "0.5290329", "0.52712154", "0.5267234", "0.5258127", "0.52518266", "0.5237606", "0.5233916", "0.52206033", "0.52035964", "0.52008957", "0.5190632", "0.518058", "0.516701", "0.51645315", "0.5149702", "0.5135784", "0.5124095", "0.51153666", "0.51079124", "0.5087262", "0.5085168", "0.5084923", "0.507896", "0.50738883", "0.50719136", "0.5069971", "0.50657475", "0.5063297" ]
0.61603105
15
Check if the adapter commands are being traced.
def trace? !!@trace end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def traced?\n NewRelic::Agent.is_execution_traced?\n end", "def check_for_running_transaction\n # ignore this command when within transaction block\n # as this command is started at the begining of transaction\n return false if @transaction\n response = script_mode do\n query(\"cfgtransshow\")\n end\n response.data.match(/#{Replies::NO_ZONING_TRANSACTION}/) ? false : true\n end", "def check_command_policy\n true\n end", "def supports_track_and_trace?\n case closest_track_trace_method\n when CarrierProduct::TrackTraceMethods::TRACKLOAD, CarrierProduct::TrackTraceMethods::TRACKTRACE_CONTAINER\n true\n else\n false\n end\n end", "def main_commands_enabled\n TactBattleManager.tact_battle?\n end", "def sync_exec_required?\n Thread.current != DisplayProxy.thread\n end", "def trace_disabled?(options)\n !(traced? || options[:force])\n end", "def can_process_cmd?\n settings.queue.empty?\n end", "def command_issued?\n @channel_control.command_given?\n end", "def trace?\n Options[:trace]\n end", "def enabled?\n distributed_tracing_enabled? &&\n span_events_enabled? &&\n trace_observer_configured?\n end", "def cmd_delegated_on_site?\n [email protected]_monitoring and\n not @record.cmd_to_execute_code.blank? or not @record.cmd_to_execute.blank?\n end", "def method_checking_enabled?\n !Thread.current[:'method checking disabled']\n end", "def has_commands\n @commands.length > 0\n end", "def trace_observer_configured?\n trace_observer_host != NewRelic::EMPTY_STR\n end", "def is_straight_flush?\n is_flush? && is_straight?\n end", "def tracing?\n # The non-nil value of this instance variable\n # indicates if we are currently tracing\n # in this thread or not.\n self.current_trace ? true : false\n end", "def transaction_proxy?\n false\n end", "def has_transactions?\n queue.any?\n end", "def is_transference?\n %w(transin transout).include?(operation)\n end", "def probe?\n self.order == -1\n end", "def for_rollback?\n @method_name == :perform\n end", "def in_transaction?\n !@transaction_stack.empty?\n end", "def has_subcommands?(command)\n !subcommands(command).empty?\n end", "def command?\n @is_command\n end", "def command_enabled?(index)\n true\n end", "def has_queued_events?\n [email protected]?\n end", "def throbbing?\n return get_throb.running?\n end", "def tracking_enabled?\n Thread.current[track_history_flag] != false\n end", "def canary?\n @got.respond_to?('__stack_chk_fail') || @symbols.respond_to?('__stack_chk_fail')\n end", "def has_sub_commands?\n @subcommands and [email protected]?\n end", "def has_sub_commands?\n @subcommands and [email protected]?\n end", "def log_timings?\n @log_timings\n end", "def log_timings?\n @log_timings\n end", "def requesting_console?\n @requesting_console\n end", "def check_state\n EM.stop if @setup.report_state.content =~ /operational|stranded/\n end", "def time_to_call_before_methods?\n @@inside_methods == 0\n end", "def disabled_main_command?\r\n return false\r\n end", "def disabled_main_command?\r\n return false\r\n end", "def proceed?(global_options,command,options,arguments) #:nodoc:\n if command && command.skips_pre\n true\n elsif @@pre_block\n @@pre_block.call(global_options,command,options,arguments)\n else\n true\n end\n end", "def record?(command)\n !@command || @command.include?(command)\n end", "def is_dispatched\n (self.call_control_flag_1 & 2) == 2\n end", "def command? command\n Commands.method_defined? command\n end", "def command? command\n Commands.method_defined? command\n end", "def should_run?\n Time.zone.now - @info.last_sent - @config.delay_time >= @config.run_every\n end", "def agent_should_start?\n !blacklisted_constants? &&\n !blacklisted_executables? &&\n !in_blacklisted_rake_task?\n end", "def phase3_basic_command_disabled?\r\n return false\r\n end", "def inside_control?\n\t t = thread\n\t !t || t == Thread.current\n\tend", "def is_active?\n aborted_at.nil?\n end", "def debug_through?\r\n return false\r\n end", "def is_command_valid?(command)\n\t\tAVAILABLE_COMMANDS.include?(command)\n\tend", "def load_commands?\n @module\n end", "def command_enabled?(index)\n @list[index] == @list[@index]\n end", "def tb_event_still?\n !@tb_event || !@tb_event.move_route_forcing\n end", "def in_transaction?\n within_states?(STARTING_TRANSACTION_STATE, TRANSACTION_IN_PROGRESS_STATE)\n end", "def should_run?\n Time.zone.now - @info.last_sent - @config.delay_time >= @config.run_every\n end", "def is_requesting?\n @lock.synchronize { [email protected]? }\n end", "def settled?\n return !self.pending?\n end", "def is_internal_cmd?(cmd)\n pre_is_internal_cmd(cmd)\n @internal_cmds.include?(cmd[0])\n end", "def connected?\n !@aborted\n end", "def is_in_progress?\n self.id == self.device.trips.last.id && self.points.last.event != Point::IGNITION_OFF && (Time.now - self.points.last.occurred_at < Device::TRIP_REPORT_CUTOFF)\n end", "def step_completed?\n !object.waiting_on.include?(scope)\n end", "def perform?\n !song.synced?\n end", "def undocumented_commands?\n !undocumented_commands.empty?\n end", "def should_load?\n test_framework? || trace_observer_configured?\n end", "def transmit\n if self.sendcmd(\"main.get_trx_status\")==\"tx\"\n return true\n else\n self.sendcmd(\"main.tx\")\n end\n if self.sendcmd(\"main.get_trx_status\")==\"tx\"\n return true\n else\n self.error(\"main.tx failed\")\n return false\n end\n end", "def has_boot_diagnostics?\n if vm.diagnostics_profile\n vm.diagnostics_profile.boot_diagnostics.enabled\n else\n false\n end\n end", "def check_unknown_options?(config) #:nodoc:\n options = check_unknown_options\n return false unless options\n\n command = config[:current_command]\n return true unless command\n\n name = command.name\n\n if subcommands.include?(name)\n false\n elsif options[:except]\n !options[:except].include?(name.to_sym)\n elsif options[:only]\n options[:only].include?(name.to_sym)\n else\n true\n end\n end", "def within_transaction?\n !current_transaction.nil?\n end", "def should_advance_work?\n get_configuration 'auto_advance_work', @work_type_config.dig('hydra_endpoint', 'workflow_actions'), @config.dig('workflow_actions')\n rescue\n true\n end", "def healthy?\n %w(run sleep).include?(@transmitter.status)\n end", "def was_executed?\n execution_count > 0\n end", "def should_run_synchronously?\n cartodbfied_tables = fetch_cartodbfied_tables\n\n dropped_and_stale_tables = find_dropped_tables(cartodbfied_tables) + find_stale_tables(cartodbfied_tables)\n total_tables_to_be_linked = dropped_and_stale_tables + find_new_tables(cartodbfied_tables)\n\n dropped_and_stale_tables.count != 0 && total_tables_to_be_linked.count < MAX_TABLES_FOR_SYNC_RUN\n end", "def command_is?(command)\n @command.to_s == command\n end", "def pending_actions?\n return true if @log.pending_actions?\n @derivative_builds.each do |d|\n return true if d.pending_actions?\n end\n return false\n end", "def within_transaction?\n !current_transaction.nil?\n end", "def need_sync?\n if is_ignored || err_count >= MAX_SYNC_ERR\n false\n elsif last_sync == DUMMY_TIMESTAMP\n true\n else\n case sync_type.to_sym\n when :SYNC_UP\n clab_id.nil? || ext_last_update > last_sync\n when :SYNC_DOWN\n ext_obj_id.nil? || clab_last_update > last_sync\n else\n raise SyncError, 'sync mode not supported'\n end\n end\n end", "def has_transactional_callbacks?\n true\n end", "def find_command_enabled?\n $find_command_enabled ||= scanned_client_server!.features.find_command_enabled?\nend", "def find_command_enabled?\n $find_command_enabled ||= scanned_client_server!.features.find_command_enabled?\nend", "def missing_switches?\n !@missing_switches.nil?\n end", "def pre_operational?\n peek_current_state && peek_current_state == :PRE_OPERATIONAL\n end", "def tooling?\n true\n end", "def command_given?\n [email protected]?\n end", "def runnable?\n tool_class.public_instance_methods(false).include?(:run)\n end", "def do?\n execute_true? flush\n end", "def controlable?\n respond_to?(:call)\n end", "def waiting_for_response_tb?\n e = $game_map.events[@tb_ev_respond_id]\n # print \"e.list:\\n #{e.list}\\n\" if e\n !TM.response_queue.empty? || (e && e.tb_response_wait)\n end", "def executing_user_command?\n @executing_user_command\n end", "def passing?\n return false if self.test_executions.empty?\n \n most_recent_execution = self.ordered_executions.first\n return !most_recent_execution.nil? && most_recent_execution.passing?\n end", "def offloads_in_sync?\n get_config_changes\n additions = @changes['whole'].merge(@changes['partial'])\n offload_attrs = ['FCoEOffloadMode', 'iScsiOffloadMode']\n nic_changes = additions.select do |k,v|\n k.include?('NIC.') && offload_attrs.any? {|attr| v[attr]}\n end\n nic_changes.each do |nic_fqdd, attrs|\n attrs.each do |attr, value|\n if offload_attrs.include?(attr)\n existing_value = find_attribute_value(xml_base, nic_fqdd, attr, true)\n unless existing_value == value\n return false\n end\n end\n end\n end\n true\n end", "def tranch_available?\n current_tranch_open? and previous_tranch_all_sold_out_or_operated?\n end", "def command_exists?\n COMMANDS.include? @command\n end", "def outside_transaction?\n [email protected]_started\n end", "def _active_remote_track_changes?\n @_active_remote_track_changes != false\n end", "def on_softlayer?\n softlayer != nil\n end", "def on_softlayer?\n softlayer != nil\n end", "def should_queue?\n @options[:offline_queueing] && @offline_handler.queueing?\n end", "def tombstoned?\n return false unless @curation_concern.respond_to? :tombstone\n @curation_concern.tombstone.present?\n end", "def hooks?\n !before_hooks.empty? || !after_hooks.empty?\n end" ]
[ "0.6743287", "0.6211449", "0.6119923", "0.5899874", "0.5892366", "0.58054614", "0.5732865", "0.5731314", "0.57288957", "0.5662789", "0.5643164", "0.56370234", "0.5635921", "0.5632394", "0.5628458", "0.55960745", "0.55379957", "0.5531343", "0.553097", "0.5522248", "0.5509487", "0.5493849", "0.5469714", "0.5458358", "0.53973", "0.53951204", "0.53766257", "0.5350276", "0.534836", "0.5347137", "0.5345583", "0.5344267", "0.53413844", "0.53413844", "0.53131676", "0.5308795", "0.5308638", "0.52909464", "0.52909464", "0.5288107", "0.52871996", "0.52837175", "0.52727515", "0.52727515", "0.52679116", "0.5266599", "0.5261365", "0.5260746", "0.52514064", "0.52499485", "0.52461034", "0.5244524", "0.524363", "0.52391666", "0.52389437", "0.52384645", "0.5235486", "0.523282", "0.5231466", "0.52279055", "0.52000356", "0.51973385", "0.51929605", "0.5191825", "0.51841074", "0.5183826", "0.51809424", "0.51795477", "0.51780444", "0.5171497", "0.5167704", "0.5166076", "0.5161601", "0.5161298", "0.51583004", "0.5154884", "0.5153426", "0.5152397", "0.5148519", "0.5148519", "0.51416475", "0.51392645", "0.51321185", "0.5126303", "0.5120643", "0.51168025", "0.5113203", "0.5109438", "0.5104798", "0.5101007", "0.51000214", "0.50935197", "0.5087923", "0.50845003", "0.5081092", "0.5080839", "0.5080839", "0.50806457", "0.50745857", "0.5071941" ]
0.58926874
4
Execute a command using the underlying concrete adapter.
def execute command, *bind start = Time.now record, command = command, bind.shift if command.kind_of?(Class) && command < Record record ? Result.new(record, db.execute(command, *bind)) : db.execute(command, *bind) ensure log_command(start, command, bind) if @trace end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def execute\n raise NotImplementedError, 'Define `execute` in Command subclass'\n end", "def execute(command, opts=nil)\n end", "def command(*params)\n raise ErrorParams, \"command missing method name\" if params.empty?\n\n transp.adapter_request(*params)\n .then { |args| transp.send(*args) }\n .then { |resp| transp.adapter_response(resp) }\n end", "def execute_command command_text\r\n #TODO: really, what is point of this \"convenience\" method!?\r\n create_command( command_text ).execute\r\n end", "def execute(command)\n invoke_command(command, nil)\n end", "def execute_command(command)\n end", "def execute_command(command)\n end", "def execute(command)\n end", "def execute\n raise NotImplementedError, 'Generic command has no actions'\n end", "def execute\n parse_command\n run_command(command)\n end", "def execute(command)\n raise ClientError, \"#{self.class}#execute must be implemented\"\n end", "def execute\n raise NotImplementedError.new('run is an abstract method in BaseCommand. Please override.')\n end", "def execute(command)\n @session.blocking_call do\n @native_channel.exec(command)\n end\n end", "def execute(cmd)\n send(*cmd)\n end", "def execute(command) # rubocop:disable Lint/UnusedMethodArgument\n end", "def execute_command(parsed_command)\n execution_method = \"execute_#{parsed_command[:command]}\".to_sym\n if self.respond_to? execution_method, true\n self.send execution_method, parsed_command[:params]\n else\n raise \"Command '#{parsed_command[:command]}' not supported\"\n end\n end", "def execute(command)\n @command = command\n self\n end", "def execute\n\t\tdoCommandList.each do |commandItem|\n\t\t\tcommandItem.execute\n\t\tend\n\tend", "def execute_command(command)\n raw(*command)\n end", "def perform(command, *args)\n\n #\n # use the given command's attributes to perform the action\n #\n\n raise NotImplementedError\n end", "def run(host, command, options = {})\n execute(__method__, host, command, options)\n end", "def run_command_via_connection(_command, &_data_handler)\n raise NotImplementedError, \"#{self.class} does not implement #run_command_via_connection()\"\n end", "def execute\n raise NotImplementedError\n end", "def execute(cmd)\n Util.execute(cmd)\n end", "def method_missing(command, *args)\n execute(command.to_s, *args)\n end", "def method_missing(command, *args)\n execute(command.to_s, *args)\n end", "def run_command(full_command)\n raise NotImplementedError.new(\"run_command is only available in concrete implementations\")\n end", "def execute(command, argument)\n command = canonical_command(command)\n method = \"cmd_#{command}\"\n @commands[command.downcase].send(method, argument)\n end", "def exec\n binding.pry\n # command.run(*service.exec(args.command))\n end", "def call(*command); end", "def execute(command_string)\n Runner.instance.cross_call command_string\n end", "def execute(command, ignore_failure = false)\n return Simp::Cli::ExecUtils::execute(command, ignore_failure, logger)\n end", "def execute\n fail NotImplementedError\n end", "def execute(command = self)\n command.to_a\n end", "def execute\n raise NotImplementedError\n end", "def execute(command)\n if remote?\n @remote.exec(command)\n else\n rays_exec(command)\n end\n end", "def invoke_command(cmd, options={}, &block)\n options = options.dup\n via = options.delete(:via) || :run\n send(via, cmd, options, &block)\n end", "def execute\n raise NotImplementedError.new('Must override')\n end", "def execute(sql)\n raise NotImplementedError, \"#execute should be overridden by adapters\"\n end", "def execute(command)\n if valid_command?(command)\n apply_command(command)\n else\n return 'Invalid command.'\n end\n end", "def execute!(command, options)\n # Build up the arguments to pass to connection.execute!\n arguments = [command, name, *arguments_for(command)]\n arguments << \"--color\" if options[:color]\n if options[:provider]\n arguments << \"--provider\"\n arguments << options[:provider]\n end\n\n if options[:log_mode]\n arguments << {:mode => options[:log_mode]}\n end\n\n # Set up the block to use when executing -- if logging is\n # enabled, use a block that logs the output; otherwise no block.\n block = options[:log] ? shell_log_block : nil\n\n # Execute the command\n connection.execute! *arguments, &block\n end", "def execute(opt, argv)\n fail \"#{self.class.command} not implemented\"\n end", "def execute_command(command_class, method, args = [])\n command_class.new.send(method, *args)\n end", "def execute\n raise ArgumentError, 'Abstract Method'\n end", "def do_execute\n raise StandardError, \"Not implemented!\"\n end", "def call_command\n verb = match.captures[match.names.index('command')]\n verb = normalize_command_string(verb)\n public_send(verb)\n end", "def execute\n raise NotImplemented\n end", "def execute!\n if Mcir::Core.instance.dryrun?\n Mcir::Core.instance.debug(\"CMD: \".purple << \"#{self.to_s.gsub(\"\\r\", \"\")}\")\n \"skipped execution due to dryrun\"\n else\n case @mode\n when :exec then exec(self.to_s)\n when :open then IO.new(self).open3\n when :capture then IO.new(self).capture3\n when :backticks then IO.new(self).backtick\n end\n end\n end", "def execute_command(command, input)\n command.new(self, input).process\n end", "def run_command(cmd, opts = {}, &data_handler)\n # Some implementations do not accept an opts argument.\n # We cannot update all implementations to accept opts due to them being separate plugins.\n # Therefore here we check the implementation's arity to maintain compatibility.\n case method(:run_command_via_connection).arity.abs\n when 1\n return run_command_via_connection(cmd, &data_handler) unless cache_enabled?(:command)\n\n @cache[:command][cmd] ||= run_command_via_connection(cmd, &data_handler)\n when 2\n return run_command_via_connection(cmd, opts, &data_handler) unless cache_enabled?(:command)\n\n @cache[:command][cmd] ||= run_command_via_connection(cmd, opts, &data_handler)\n else\n raise NotImplementedError, \"#{self.class} does not implement run_command_via_connection with arity #{method(:run_command_via_connection).arity}\"\n end\n end", "def execute\n adapter.enqueue klass, *args\n end", "def execute command, *bind\n raise RuntimeError, 'Command already in progress' unless pending.empty?\n\n record, command = command, bind.shift if command.kind_of?(Class) && command < Record\n pending << [Time.now, command, bind]\n query(command, *bind)\n\n ::EM::DefaultDeferrable.new.tap do |defer|\n ::EM.watch(fileno, Handler, self, record, defer) {|c| c.notify_readable = true}\n end\n end", "def execute_command(command_arguments)\n self.class.from_arguments(config, ui, command_arguments).execute\n end", "def execute\n Tools.public_send(command, options.configuration_path)\n end", "def execute(&block)\n define_method(:execute, &block)\n end", "def execute(command)\n system(command)\n end", "def execute command\n if command_exists?\n eval \"Command::#{command}.new.init\"\n else\n raise UnknownCommand, \"Error: unknown command '#{command.downcase.to_s}'.\\nTry --help for help.\"\n end\n end", "def exec cwd, cmd\n raise NotImplementedError.new(\n \"exec should be implemented to execute cmd on current window\")\n end", "def base_execute\n execute\n end", "def execute(cmd, options = T.unsafe(nil)); end", "def execute_internal(cmd)\n class_invariant\n pre_execute_internal(cmd)\n begin\n send(@internal_cmds[cmd[0]], *cmd[1..-1])\n rescue ArgumentError\n puts \"Invalid arguments\"\n end\n class_invariant\n end", "def execute_command(target, command, options, *args)\n context = CommandContext.new\n\n # set some useful methods to be used by the action blocks\n context.opts = options\n context.target = target\n context.target_self = target.eval('self')\n context.output = output\n context.captures = options[:captures]\n context.eval_string = options[:eval_string]\n context.arg_string = options[:arg_string]\n context.command_set = commands\n context._pry_ = @pry_instance\n\n context.command_processor = self\n\n ret = commands.run_command(context, command, *args)\n\n options[:val].replace(\"\")\n\n ret\n end", "def command\n raise NotImplementedError, \"`command' is not implemented by #{self.class.name}\"\n end", "def execute_command(command)\n system(command)\n end", "def execute_command(target, command, options, *args)\n context = CommandContext.new\n\n # set some useful methods to be used by the action blocks\n context.opts = options\n context.target = target\n context.output = output\n context.command_set = commands\n\n context.command_processor = self\n\n ret = commands.run_command(context, command, *args)\n\n # Tick, tock, im getting rid of this shit soon.\n options[:val].clear\n\n ret\n end", "def exec_command(cmd)\n exec(cmd)\n # windows? ? exec(cmd) : fake_exec(cmd)\n end", "def execute_command_provider\n attributes.fetch(:executeCommandProvider)\n end", "def call\n raise NotImplementedError, 'Lotion::Command subclasses are expected to define #call'\n end", "def run\n raise \"`#{ real_command }' failed\" unless Kernel.system( real_command )\n end", "def exec(command, &block); end", "def execute(command_str)\n # get_params: gets the command to be executed. It formats in a hash like {command: 'method_name', options: {} }\n command_hash = @command_recognizer.get_params(command_str)\n command = command_hash[:command]\n options = command_hash[:options]\n\n if options.nil?\n send(command)\n else\n send(command, options)\n end\n end", "def call\n execute(*self.class.executes, abort_on_failure: true)\n end", "def exec(cmd, args, opts)\n # lazy-load dependencies to make the plugin as fast as possible\n require 'bolt/target'\n require 'logging'\n\n # opts can contain 'tty', 'stdin', and 'elevate'. If tty is set, apply it\n # to the target for this exec.\n target_opts = @target.transform_keys(&:to_s)\n target_opts['tty'] = true if opts[:tty]\n target = Bolt::Target.new(@target[:uri], target_opts)\n\n logger = Logging.logger($stderr)\n logger.level = :warn\n\n transport = target.transport || 'ssh'\n case transport\n when 'ssh'\n require_relative 'transport_ssh.rb'\n connection = BoltSSH.new(target, logger)\n when 'winrm'\n require_relative 'transport_winrm.rb'\n connection = BoltWinRM.new(target, logger)\n when 'docker'\n require_relative 'transport_docker.rb'\n connection = BoltDocker.new(target)\n else\n raise \"#{transport} unsupported\"\n end\n\n begin\n connection.connect\n # Returns exit code\n connection.execute(cmd, args, stdin: opts[:stdin])\n ensure\n begin\n connection&.disconnect\n rescue StandardError => e\n logger.info(\"Failed to close connection to #{target}: #{e}\")\n end\n end\n end", "def execute_command_from_command_line\n cmd = ARGV[0]\n if not cmd\n puts CMD_LINE_HELP\n elsif OPERATION_NAMES.include?(cmd) && !options.force_command\n begin\n self.send(*ARGV)\n rescue ArgumentError => ex\n $stderr.puts \"Wrong number of arguments (#{ARGV.size-1}) for operation: #{cmd}\"\n end\n else\n send_roku_command cmd\n end\n end", "def run_command(arguments)\n raise \"Specified command did not implement 'run_command' method.\"\n end", "def execute_command!(*argv)\n execute_command(argv)\n raise Error.new(\"Command failed!\") unless $?.success?\n end", "def method_missing(method_name, *arguments, &block)\n if @command_executor.respond_to?(method_name)\n @command_executor.send(method_name, *arguments)\n else\n super(method_name, *arguments, &block)\n end\n end", "def perform!\n send(\"perform_#{command}!\")\n end", "def execute(cmd)\n RawDB.execute(db, cmd)\n end", "def execute(cmd)\n eval(EXECUTE, binding, __FILE__, EXECUTE_LINE)\n nil\nend", "def call(*args)\n cache.fetch_or_store(args.hash) do\n id, adapter, ast, plugins, plugins_options, meta = args\n\n component = registry.components.get(:commands, id: id)\n\n command_class =\n if component\n component.constant\n else\n Command.adapter_namespace(adapter).const_get(Inflector.classify(id))\n end\n\n plugins_with_opts = Array(plugins)\n .map { |plugin| [plugin, plugins_options.fetch(plugin) { EMPTY_HASH }] }\n .to_h\n\n compiler = with(\n id: id,\n command_class: command_class,\n adapter: adapter,\n plugins: plugins_with_opts,\n meta: meta\n )\n\n graph_opts = compiler.visit(ast)\n command = ROM::Commands::Graph.build(registry.root.commands, graph_opts)\n\n if command.graph?\n root = Inflector.singularize(command.name.relation).to_sym\n CommandProxy.new(command, root)\n elsif command.lazy?\n command.unwrap\n else\n command\n end\n end\n end", "def call\n if event.command? && command_aliases.include?(event.command)\n handle_command\n end\n end", "def execute\n raise \"Not Implemented\"\n end", "def execute(command)\n return if command.empty?\n action_name = command.split(' ').first\n unless @context.action?(action_name)\n @context.puts \"unknown action \\\"#{action_name}\\\"\"\n return Cliqr::Executor::ExitCode.code(nil)\n end\n @context.forward(\"#{@base_command} #{command}\", environment: @context.environment)\n rescue StandardError => e\n @context.puts e.message\n end", "def execute(command,data,queue=false)\n (queue.is_a? TrueClass) ? exec_queue(command,data) : exec_interactive(command,data)\n end", "def execute_command(*args)\n if args.size < 2\n display_help\n exit(1)\n end\n \n command_class = Command.commands[args.first]\n \n if command_class\n command_class.command(self,*(args[2..-1]))\n else\n display_help\n exit(1)\n end\n end", "def execute(command)\r\n system \"#{command}\"\r\nend", "def execute(command_args)\n command_args = split_command(command_args)\n command = command_args[0].to_s\n parameter = command_args[1].to_s\n\n # Find the command to execute\n command_to_execute = search_for_command command.downcase\n\n # If the command is not found, show the help\n if command_to_execute == nil\n help command\n else\n # Create a pointer to the command's RUN method, and call it\n method = command_to_execute.method(\"run\")\n method.call(parameter)\n end\n end", "def call\n commands = self.commands.any? ? self.commands : self.class.commands\n commands.each do |command_klass|\n command = command_klass.new(kwargs)\n command.run\n _called << command\n end\n end", "def execute_operation\n unless options().target\n raise 'Nothing to do ...' \n end\n\n self.send(options().target)\n end", "def execute (task)\n\t\tif task['type'] === 'backend'\n\t\t\texec_vm_command(task)\n\t\telse\n\t\t\texec_sencha_command(task)\n\t\tend\n\tend", "def exec\n proxied_connection.exec\n end", "def call_internal(command,args)\n return @commands[command].clone.run(args)\n end", "def exec(cmd, *rest) end", "def run(command, *args)\n send(command, *args)\n end", "def command\n raise NotImplementedError\n end", "def execute(cmd)\n @log.info(\"Executing command '#{cmd}'...\")\n Kernel.system(cmd)\n end", "def execute command\n log command\n system(command) unless @options[:test]\n end", "def execute(method)\n send(method)\n end", "def execute(command)\n system \"#{command}\"\nend" ]
[ "0.72119004", "0.68694115", "0.68215925", "0.6781732", "0.6762745", "0.6761597", "0.6761597", "0.6737964", "0.6734464", "0.6719598", "0.670818", "0.66809684", "0.6673869", "0.6651498", "0.66461736", "0.663981", "0.6638179", "0.6600325", "0.6596317", "0.6558964", "0.6502242", "0.64315516", "0.6405184", "0.6399516", "0.63845545", "0.63845545", "0.63076305", "0.6250919", "0.6237855", "0.62321234", "0.62310183", "0.62146896", "0.62133646", "0.62020475", "0.61947274", "0.61869067", "0.6173544", "0.616919", "0.6162583", "0.61598957", "0.6154311", "0.6148517", "0.6143314", "0.61337507", "0.6106095", "0.6102181", "0.61008286", "0.6094549", "0.6087001", "0.6079661", "0.60748655", "0.60670334", "0.6061494", "0.6051779", "0.6042015", "0.60412014", "0.6038324", "0.6031301", "0.60264623", "0.60131955", "0.6009165", "0.6001566", "0.5995405", "0.59875846", "0.59779465", "0.5972202", "0.5971222", "0.5967974", "0.59459907", "0.5930903", "0.59282374", "0.592675", "0.592278", "0.59107894", "0.5908076", "0.5903107", "0.5903104", "0.59012985", "0.5890094", "0.5885673", "0.58792853", "0.5876546", "0.5874314", "0.5860169", "0.58505845", "0.5847164", "0.58396524", "0.58341557", "0.5824679", "0.5823447", "0.5818323", "0.5810918", "0.5810594", "0.5809401", "0.5805777", "0.5805526", "0.5805067", "0.57988673", "0.579298", "0.5783783" ]
0.59950155
63
assumes x.y.z all digit version
def next_version # x.y.z v = version.split '.' # bump z v[-1] = v[-1].to_i + 1 v.join '.' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def osgi_version_for(version)\n parts = version.split(/[\\.,-]/)\n result = Array.new(3, 0)\n parts.each_index { |i|\n if (result.size == 3) then\n if (parts[i] =~ /\\d+/) then result[i] = parts[i] else result = result << parts[i] end\n else\n result[3] = [result[3], parts[i]].join(\"-\")\n end\n }\n result.join(\".\")\nend", "def valid_version?(version)\n version =~ /\\d+\\.\\d+\\.\\d+(\\.(alpha|beta|rc)(\\.\\d+)?)?/\nend", "def check_version(v)\n return true if (!version || version[0..4].gsub(\".\",\"\").to_i>=v)\n return false\n end", "def jamm_version(version)\n case version.to_s.strip\n when /^0.[0-7]/\n '0.2.5'\n when /^0.8/\n '0.2.2'\n when /^1|^2.0/\n '0.2.5'\n when /^2.1.[0-1]$/\n '0.2.6'\n when /^2.1.[2-3]$/\n '0.2.8'\n when /^2.1/\n '0.3.1'\n when /^2.2/\n '0.3.1'\n when /^3.[0-9]/\n '0.3.1'\n end\nend", "def checkversion(major,minor,options=nil)\n caller[0]=~/`(.*?)'/\n caller_func=$1\n\n raise ZbxAPI_ExceptionVersion, \"#{caller_func} requires API version #{major}.#{minor} or higher\" if major>@major\n raise ZbxAPI_ExceptionVersion, \"#{caller_func} requires API version #{major}.#{minor} or higher\" if minor>@minor\n\n end", "def major_version(full_version)\n full_version.match(/^(\\d+\\.\\d+\\.\\d+)\\.\\d+$/)[1]\n end", "def valid_version?(arg)\n return true if arg == 'latest'\n arg =~ /^[0-9]+\\.[0-9]+\\.[0-9]+(-[0-9]+)?$/ ? true : false\n end", "def major(version)\n res = 0\n res = Regexp.last_match(1) if version =~ /^\\s*(\\d+)\\.\\d+\\.\\d+/\n res\n end", "def valid_version?(arg)\n return true if arg == false || arg == 'latest'\n arg =~ /^[0-9]+\\.[0-9]+\\.[0-9]+(-[0-9]+)?$/ ? true : false\n end", "def version\na = unpack\nv = (a[2] & 0xF000).to_s(16)[0].chr.to_i\nreturn v if (1..5).include? v\nreturn nil\nend", "def normalize_version(str)\n default = \"0.0.1\"\n\n if str.nil? or str.empty?\n default\n elsif str.match /^(\\d)+[.](\\d)+[.](\\d)+$/\n str\n elsif str.match /^((\\d)+[.])*(\\d)+$/\n fix_version(str)\n else\n raise VersionError, \"need a valid version number of the form 0.0.0\"\n end\n end", "def major_version\n version.match(/(\\d\\.\\d)/)[0] if name.is_a? String\n end", "def choose_version(version)\n if version =~ /(\\d+)\\.(\\d+)\\.(\\d+)/\n major = $1\n minor = $2\n patch = $3\n if config[:major]\n major = major.to_i + 1\n minor = 0\n patch = 0\n end\n if config[:minor]\n minor = minor.to_i + 1\n patch = 0\n end\n patch = patch.to_i + 1 if config[:patch]\n version = \"#{major}.#{minor}.#{patch}\"\n Chef::Log.debug(\"New version is #{version}\")\n else\n Chef::Log.error(\"Version is in a format I cannot auto-update\")\n exit 1\n end\n version\n end", "def clean_version(version)\n version.gsub!(/\\A(?:version|v)\\s*/i, '') # deletes leading v or version, eg: 'v1.2.3', 'Version 1.2'\n version.gsub!(/[\\r\\n]/, '') # deletes new lines chars\n version.gsub!(/\\s+/, '-') # replaces all spaces by '-'\n version.gsub!(/[\\.]{2,}/, '.') # replaces more than one consecutive dots by one dot, eg: '0..2.1'\n\n version = \"0#{version}\" if version[0] == '.' # adds leading 0 if first char is a dot, eg: '.2.3'\n\n version\n end", "def version_mismatch_detected\n end", "def is_bad_version(n)\r\n return true if n > 3\r\n false\r\nend", "def patch(version)\n res = 0\n res = Regexp.last_match(1) if version =~ /^\\s*\\d+\\.\\d+\\.(\\d+)/\n res\n end", "def parse_version( vers )\n @version_major = nil\n @version_minor = nil\n @version_patch = nil\n @version_extra = nil\n if vers\n vers.match(/(.*)\\.(.*)\\.(\\d*)(.*)/) do |matches|\n @version_major = matches[1]\n @version_minor = matches[2]\n @version_patch = matches[3]\n @version_extra = matches[4]\n end\n @version_plain = \"#{@version_major}.#{@version_minor}.#{@version_patch}\"\n end\n end", "def read_version\n # The version string is usually in one of the following formats:\n #\n # * 4.1.8r1234\n # * 4.1.8r1234_OSE\n # * 4.1.8_MacPortsr1234\n #\n # Below accounts for all of these:\n execute(\"--version\").split(\"_\")[0].split(\"r\")[0]\n end", "def version\n @version ||= version_hex.to_s(16).chars.entries.join('.')\n end", "def bump\n parts = parse_parts_from_version_string\n parts.pop while parts.any? { |part| part.alpha? }\n parts.pop if parts.size > 1\n parts[-1] = parts[-1].succ\n self.class.new(parts.join(\".\"))\n end", "def nextVersion(version)\n\n current_version = version.split('.').reverse;\n new_version = [];\n\n if version.split('.').length == 1\n (version.to_i + 1).to_s\n else\n current_version.map.with_index do |n,i|\n if i == 0\n new_n = (n.to_i + 1).to_s\n if new_n == '10'\n new_version.push('0')\n current_version[i+1] = (current_version[i+1].to_i + 1).to_s\n else\n new_version.push(new_n)\n end\n else\n if n == '10'\n if i == (current_version.length - 1)\n new_version.push(n)\n else\n new_version.push('0')\n current_version[i+1] = (current_version[i+1].to_i + 1).to_s\n end\n else\n new_version.push(n)\n end\n end\n end\n new_version.reverse.join('.')\n end\n\nend", "def version!\r\n fail\r\n end", "def test_parsing_trailing_zeros\n value_ = ::Versionomy.parse('2.0.0', :rubygems)\n assert_equal([2, 0, 0, 0, 0, 0, 0, 0], value_.values_array)\n assert_equal('2.0.0', value_.unparse)\n assert_equal('2.0.0.0.0', value_.unparse(:required_fields => [:field4]))\n assert_equal('2.0', value_.unparse(:optional_fields => [:field2]))\n end", "def dcl_version(version)\n return '' if version == 'ga'\n return '/beta' if version == 'beta'\n return '/alpha' if version == 'private'\n end", "def major_version; end", "def version_number\n self.name =~ /RHEL-([0-9]+)/\n return $1.to_i\n end", "def major_version(version = nil)\n version ||= installed_version?\n return \"0\" if version.nil?\n\n version.sub(/(\\.\\d+)+$/, '')\n end", "def have_version?(major, minor = nil, update = nil, build = nil)\n if major.class == Float\n major = major.to_s\n end\n if major.class == String\n major,minor,update = major.split('.').collect { |x| x.to_i }\n end\n if major == @major\n return false if minor != nil && minor != @minor\n return false if update != nil && update != @update\n return false if build != nil && build != @build\n return true\n else\n return false\n end\n end", "def validate_namecoind(wanted_version = 32190)\n version = NMCC.getinfo['version']\n\n if version == wanted_version\n true\n else\n warn \"namecoind version is #{version}, but we usually work with version #{wanted_version}\"\n end\nrescue => ex\n warn \"validate_namecoind failed: #{ex}\"\n exit\nend", "def get_version(version)\n \"V#{version.gsub('-','_')}\"\n end", "def deconstruct_version_string(version)\n match = version.match(/^(\\d+)\\.(\\d+)(?:\\.(\\d+))?$/)\n\n # Match should have 4 parts [0] = input string, [1] = major\n # [2] = minor, [3] = patch (possibly blank)\n if match && match.size == 4\n return [match[1].to_i, match[2].to_i, match[3].to_i || 0]\n else\n return nil\n end\n end", "def version_number(str)\n if str =~ /\\d/\n str.gsub(/^[^\\d]*/, '').gsub(/[^\\d]*$/, '').gsub(/(\\d*\\.\\d*).*/, '\\1')\n else\n '-'\n end\n end", "def has_version?; end", "def mock_to_dist_version_arch(mock)\n # We care about matching against two patterns here:\n # pupent-3.4-el5-i386 <= old style with PE_VER baked into the mock name\n # pupent-el5-i386 <= new style derived from a template\n mock.match(/pupent(-\\d\\.\\d)?-([a-z]*)(\\d*)-([^-]*)/)[2..4]\n end", "def breaking_changes?(version)\n\t\t\tDownloadTV::VERSION.split(\".\").zip(version.split(\".\")).find_index { |x, y| y > x }&.< 2\n\t\tend", "def nmap_version_at_least?(test_ver=nil)\n raise ArgumentError, \"Cannot compare a Float, use a String or Integer\" if test_ver.kind_of? Float\n unless test_ver.to_s[/^([0-9]+(\\x2e[0-9]+)?)/n]\n raise ArgumentError, \"Bad Nmap comparison version: #{test_ver.inspect}\"\n end\n test_ver_str = test_ver.to_s\n tnum_arr = $1.split(/\\x2e/n)[0,2].map {|x| x.to_i}\n installed_ver = get_nmap_ver()\n vtag = installed_ver.split[2] # Should be [\"Nmap\", \"version\", \"X.YZTAG\", \"(\", \"http..\", \")\"]\n return false if (vtag.nil? || vtag.empty?)\n return false unless (vtag =~ /^([0-9]+\\x2e[0-9]+)/n) # Drop the tag.\n inum_arr = $1.split(/\\x2e/n)[0,2].map {|x| x.to_i}\n return true if inum_arr[0] > tnum_arr[0]\n return false if inum_arr[0] < tnum_arr[0]\n inum_arr[1].to_i >= tnum_arr[1].to_i\nend", "def compare_version(remote_version)\n re = /(\\d+)\\./\n remote_version && re.match(remote_version)[1] != re.match(Replica.version)[1] \n end", "def compare_version(v1, v2)\r\n v1 = v1.split('.')\r\n v2 = v2.split('.')\r\n longest = v1.length > v2.length ? v1 : v2\r\n (0...(longest.length)).each do |idx|\r\n one = v1[idx] || '0'\r\n two = v2[idx] || '0'\r\n return -1 if two.to_i > one.to_i\r\n return 1 if one.to_i > two.to_i\r\n end\r\n 0\r\nend", "def platform_version_mac_os_x(arg)\n arg.match(/^[0-9]+\\.[0-9]+/).to_s\n end", "def mock_el_ver(mock_config)\n if Pkg::Config.build_pe\n # This uses a regex capture instead of splitting to allow the now defunct PE version component to be optional\n version = mock_config.match(/^pupent-(\\d\\.\\d-)?([a-z]+)([0-9]+)-(.*)$/)[3]\n else\n first, second, third = mock_config.split('-')\n if ['el', 'fedora'].include?(first) || (first == 'pl' && second.match(/^\\d+$/))\n version = second\n else\n version = third\n end\n end\n if [first, second].include?('fedora')\n version = \"f#{version}\"\n end\n version\nend", "def check_versions(json)\n # *_url fields are generated per board requirements, not in db\n=begin\n assert_equal(Firmware::HTTP_ROOT + 'external/v2/' +\n ActiveSupport::TestCase.EXTERNAL_VERSION,\n json[\"external_url\"],\n \"external_url must be correctly constructed\")\n=end\n assert_equal(Firmware::FTP_ROOT + 'internal/v2/' +\n ActiveSupport::TestCase.INTERNAL_VERSION,\n json[\"internal_url\"],\n \"internal_url must be correctly constructed\")\n assert_equal(Firmware::HTTP_BUCKET + 'external/v2/',\n json[\"external_path\"],\n \"external_path must be correctly constructed\")\n assert_equal('/internal/v2/',\n json[\"internal_path\"],\n \"internal_path must be correctly constructed\")\n # *_ip is temporary for alpha so the lock http code doesn't\n # have to resolve dns.\n resolver = Resolv::DNS.new\n external_ip = resolver.getaddress(Firmware::HTTP_HOST).to_s\n internal_ip = resolver.getaddress(Firmware::FTP_HOST).to_s\n resolver.close\n assert_equal(external_ip, json[\"external_ip\"],\n \"external_ip must be correctly constructed\")\n assert_equal(internal_ip, json[\"internal_ip\"],\n \"internal_ip must be correctly constructed\")\n assert_equal(Firmware::HTTP_HOST, json[\"external_host\"],\n \"external_host must be correctly constructed\")\n assert_equal(Firmware::FTP_HOST, json[\"internal_host\"],\n \"internal_host must be correctly constructed\")\n assert_equal(Firmware::FTP_USER, json[\"internal_user\"],\n \"internal_user must be correctly constructed\")\n assert_equal(Firmware::FTP_PASS, json[\"internal_pass\"],\n \"internal_pass must be correctly constructed\")\n end", "def test_parsing_with_string\n value_ = ::Versionomy.parse('1.9.2.pre.2', :rubygems)\n assert_equal([1, 9, 2, 'pre', 2, 0, 0, 0], value_.values_array)\n assert_equal('1.9.2.pre.2', value_.unparse)\n end", "def client_meta_version(version)\n regexp = /^([0-9]+\\.[0-9]+\\.[0-9]+)(\\.?[a-z0-9.-]+)?$/\n match = version.match(regexp)\n return \"#{match[1]}p\" if (match[2])\n\n version\n end", "def test_rubygems_to_standard_equality_comparison\n assert_operator(::Versionomy.parse('1.2.0', :rubygems), :==, ::Versionomy.parse('1.2'))\n assert_operator(::Versionomy.parse('1.2.b.3', :rubygems), :==, ::Versionomy.parse('1.2b3'))\n end", "def test_that_it_should_bump_versions\r\n v = Bumper::Version.new\r\n assert_equal '1', v.bump_build\r\n assert_equal '0.0.0.1', v.to_s\r\n assert_equal 1, v.bump_patch\r\n assert_equal '0.0.1.0', v.to_s\r\n assert_equal 1, v.bump_minor\r\n assert_equal '0.1.0.0', v.to_s\r\n assert_equal 1, v.bump_major\r\n assert_equal '1.0.0.0', v.to_s\r\n end", "def major\n @major ||= ruby_cc_version.match( /.*-(\\d.\\d).\\d/ )[1]\n end", "def test_method_parts\n value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)\n assert_equal([1, 9, 2, 'a', 2], value_.parts)\n value_ = ::Versionomy.create([1, 9, 0], :rubygems)\n assert_equal([1, 9], value_.parts)\n end", "def nextVersion(version)\n return version.to_i.next.to_s if !version.include? '.'\n\n top, bottom = version.split('.', 2)\n bottom = bottom.split('.').join\n\n new_bottom = bottom.to_i.next.to_s\n\n if new_bottom.length > bottom.length\n top = top.to_i.next\n new_bottom = new_bottom.chars.drop(1).join\n end\n\n [top, new_bottom.chars.join('.')].join '.'\nend", "def major_minor(version)\n version.split('.').map(&:to_i)\n end", "def GetVersionParts(versionStr)\n version_vals = versionStr.split('-')\n major, minor, patch = version_vals[0].split('.')\n build = version_vals[1]\n return major, minor, patch, build\n end", "def test_rubygems_to_standard_inequality_comparison\n assert_operator(::Versionomy.parse('1.2.3', :rubygems), :<, ::Versionomy.parse('1.2.4'))\n assert_operator(::Versionomy.parse('1.2.b.3', :rubygems), :>, ::Versionomy.parse('1.2b2'))\n assert_operator(::Versionomy.parse('1.2', :rubygems), :>, ::Versionomy.parse('1.2b1'))\n end", "def test_gen_ipaddr_ip3_ending\n assert_equal RFauxFactory.gen_ipaddr(protocol: :ip3).split('.')[-1], '0'\n end", "def binary_version; end", "def set_version(value)\n if value.nil?\n @version = 'latest'\n else\n return skip_resource 'Invalid character in version' unless value.to_s =~ /^(latest|[\\d\\.-]+)$/\n @version = value\n end\n end", "def _validate_version(v)\n if v.to_s.empty?\n results.add_error('version', 'A version is required.')\n elsif v <= Version::ZERO\n results.add_error('version', 'The version of the spec should be' \\\n ' higher than 0.')\n end\n end", "def version_from specification\n \n #\n # Require exactly one slash.\n parts = specification.split('/')\n raise HTTPStandardError.new(400, self) unless parts.count == 2\n \n protocol, version = parts\n \n #\n # Require HTTP and a 2-int version separated by .\n raise HTTPStandardError.new(400, self) unless protocol == \"HTTP\"\n versionParts = version.split('.')\n raise HTTPStandardError.new(400, self) unless versionParts.count == 2\n versionParts = versionParts.map do |part|\n # Throw up if anything other than a nonnegative integer is found on either side of the point.\n raise HTTPStandardError.new(400, self) if part.match(/[^\\d]/)\n part.to_i\n end\n \n return versionParts\n end", "def full_version\n segments = self.segments\n segments.push 0 while segments.size < 3\n segments.join(\".\")\n end", "def sub_version\n \">= \".concat(version.split('.').first(2).join('.'))\n end", "def minor(version)\n res = 0\n res = Regexp.last_match(1) if version =~ /^\\s*\\d+\\.(\\d+)\\.\\d+/\n res\n end", "def dot_separated_ip_address?(input_string)\n return false unless input_string.count('.') == 3\n dot_separated_words = input_string.split(\".\")\n# ls method - return false unless dot_seperated_words.size == 4\n while dot_separated_words.size > 0 do\n word = dot_separated_words.pop\n return false unless is_a_number?(word)\n end\n\n true\nend", "def version=(_arg0); end", "def version=(_arg0); end", "def version=(_arg0); end", "def version=(_arg0); end", "def version=(_arg0); end", "def parse(version)\n version.scan(/[0-9]+|[A-z]+/).map! do |str|\n str =~ /^\\d+$/ ? str.to_i : str\n end\n end", "def major ; version.major ; end", "def version_check\n version = params[:version]\n return render :status=>400, :json=>{:message=>\"The request must contain the a version number.\"} if version.blank?\n\n #check against current major version of app\n v = version.split(\".\")[0]\n if CURRENT_MAJOR_VERSION.to_i > v.to_i\n render :status=>600, :json=>{:status => \"Needs to upgrade to latest major version\"}\n return\n end\n render :status=>200, :json=>{:status => \"Success\"}\n end", "def is_version(string)\n return false if string === false || string === true || string.nil?\n string.to_s.match(/^\\d+[\\d\\.a-zA-Z\\-_~]*/)\n end", "def server_version; end", "def default_version; end", "def valid?(ver)\n !!(ver =~ /\\A#{REGEX_FULL}\\Z/)\n end", "def version(arg = nil)\n set_or_return(:version,\n arg,\n kind_of: String,\n default: 'latest',\n callbacks: {\n \"Valid versions are 'latest' or 'x.y.z'\" =>\n ->(a) { valid_version?(a) }\n })\n end", "def next_version #:nodoc:\n parts = version.split('.')\n parts[-1] = (parts[-1].to_i + 1).to_s\n parts.join('.')\n end", "def rpmvercmp(x, y)\n # easy! :)\n return 0 if x == y\n\n if x.nil?\n x = \"\"\n end\n\n if y.nil?\n y = \"\"\n end\n\n # not so easy :(\n #\n # takes 2 strings like\n #\n # x = \"1.20.b18.el5\"\n # y = \"1.20.b17.el5\"\n #\n # breaks into purely alpha and numeric segments and compares them using\n # some rules\n #\n # * 10 > 1\n # * 1 > a\n # * z > a\n # * Z > A\n # * z > Z\n # * leading zeros are ignored\n # * separators (periods, commas) are ignored\n # * \"1.20.b18.el5.extrastuff\" > \"1.20.b18.el5\"\n\n x_pos = 0 # overall string element reference position\n x_pos_max = x.length - 1 # number of elements in string, starting from 0\n x_seg_pos = 0 # segment string element reference position\n x_comp = nil # segment to compare\n\n y_pos = 0\n y_seg_pos = 0\n y_pos_max = y.length - 1\n y_comp = nil\n\n while x_pos <= x_pos_max && y_pos <= y_pos_max\n # first we skip over anything non alphanumeric\n while (x_pos <= x_pos_max) && (isalnum(x[x_pos]) == false)\n x_pos += 1 # +1 over pos_max if end of string\n end\n y_pos += 1 while (y_pos <= y_pos_max) && (isalnum(y[y_pos]) == false)\n\n # if we hit the end of either we are done matching segments\n if (x_pos == x_pos_max + 1) || (y_pos == y_pos_max + 1)\n break\n end\n\n # we are now at the start of a alpha or numeric segment\n x_seg_pos = x_pos\n y_seg_pos = y_pos\n\n # grab segment so we can compare them\n if isdigit(x[x_seg_pos].ord)\n x_seg_is_num = true\n\n # already know it's a digit\n x_seg_pos += 1\n\n # gather up our digits\n x_seg_pos += 1 while (x_seg_pos <= x_pos_max) && isdigit(x[x_seg_pos])\n # copy the segment but not the unmatched character that x_seg_pos will\n # refer to\n x_comp = x[x_pos, x_seg_pos - x_pos]\n\n y_seg_pos += 1 while (y_seg_pos <= y_pos_max) && isdigit(y[y_seg_pos])\n y_comp = y[y_pos, y_seg_pos - y_pos]\n else\n # we are comparing strings\n x_seg_is_num = false\n\n x_seg_pos += 1 while (x_seg_pos <= x_pos_max) && isalpha(x[x_seg_pos])\n x_comp = x[x_pos, x_seg_pos - x_pos]\n\n y_seg_pos += 1 while (y_seg_pos <= y_pos_max) && isalpha(y[y_seg_pos])\n y_comp = y[y_pos, y_seg_pos - y_pos]\n end\n\n # if y_seg_pos didn't advance in the above loop it means the segments are\n # different types\n if y_pos == y_seg_pos\n # numbers always win over letters\n return x_seg_is_num ? 1 : -1\n end\n\n # move the ball forward before we mess with the segments\n x_pos += x_comp.length # +1 over pos_max if end of string\n y_pos += y_comp.length\n\n # we are comparing numbers - simply convert them\n if x_seg_is_num\n x_comp = x_comp.to_i\n y_comp = y_comp.to_i\n end\n\n # compares ints or strings\n # don't return if equal - try the next segment\n if x_comp > y_comp\n return 1\n elsif x_comp < y_comp\n return -1\n end\n\n # if we've reached here than the segments are the same - try again\n end\n\n # we must have reached the end of one or both of the strings and they\n # matched up until this point\n\n # segments matched completely but the segment separators were different -\n # rpm reference code treats these as equal.\n if (x_pos == x_pos_max + 1) && (y_pos == y_pos_max + 1)\n return 0\n end\n\n # the most unprocessed characters left wins\n if (x_pos_max - x_pos) > (y_pos_max - y_pos)\n 1\n else\n -1\n end\n end", "def full_version\n return nil unless exact\n\n \"~> \".concat(version)\n end", "def minor_version; end", "def v81\n fetch_version(:v81)\n end", "def version_needed_to_extract\n 0x0014\n end", "def version_needed_to_extract\n 0x0014\n end", "def current_version\r\n version = File.read(\"VERSION\").strip\r\n fail \"Invalid version information\" unless version =~ /\\./\r\n version\r\nend", "def initialize(version)\n unless self.class.correct?(version)\n raise ArgumentError, \"Malformed version number string #{version}\"\n end\n\n # If version is an empty string convert it to 0\n version = 0 if version.is_a?(String) && version =~ /\\A\\s*\\Z/\n\n @version = version.to_s.strip.gsub(\"-\",\".pre.\")\n @segments = nil\n end", "def test_parsing_require_all_fields\n value_ = ::Versionomy.parse('2.0', :semver)\n assert_equal([2, 0, 0, ''], value_.values_array)\n assert_equal('2.0.0', value_.unparse)\n assert_raises(::Versionomy::Errors::ParseError) do\n value_ = ::Versionomy.parse('2.0b1', :semver)\n end\n end", "def test_standard_to_rubygems_inequality_comparison\n assert_operator(::Versionomy.parse('1.2.4'), :>, ::Versionomy.parse('1.2.3', :rubygems))\n assert_operator(::Versionomy.parse('1.2b2'), :<, ::Versionomy.parse('1.2.beta.3', :rubygems))\n assert_operator(::Versionomy.parse('1.2b2'), :<, ::Versionomy.parse('1.2', :rubygems))\n end", "def version_euristic(urls, regex = nil)\n urls.each do |url|\n puts \"Trying with url #{url}\" if ARGV.debug?\n match_version_map = {}\n case\n when DownloadStrategyDetector.detect(url) <= GitDownloadStrategy\n puts \"Possible git repo detected at #{url}\" if ARGV.debug?\n\n git_tags(url, regex).each do |tag|\n begin\n # Remove any character before the first number\n tag_cleaned = tag[/\\D*(.*)/, 1]\n match_version_map[tag] = Version.new(tag_cleaned)\n rescue TypeError\n end\n end\n when url =~ %r{(sourceforge\\.net|sf\\.net)/}\n project_name = url.match(%r{/projects?/(.*?)/})[1]\n page_url = \"https://sourceforge.net/api/file/index/project-name/\" \\\n \"#{project_name}/rss\"\n\n if ARGV.debug?\n puts \"Possible SourceForge project [#{project_name}] detected\" \\\n \"at #{url}\"\n end\n\n if regex.nil?\n regex = %r{/#{project_name}/([a-zA-Z0-9.]+(?:\\.[a-zA-Z0-9.]+)*)}i\n end\n\n page_matches(page_url, regex).each do |match|\n version = Version.new(match)\n # puts \"#{match} => #{version.inspect}\" if ARGV.debug?\n match_version_map[match] = version\n end\n when url =~ /gnu\\.org/\n project_name_regexps = [\n %r{/(?:software|gnu)/(.*?)/},\n %r{//(.*?)\\.gnu\\.org(?:/)?$},\n ]\n match_list = project_name_regexps.map do |r|\n url.match(r)\n end.compact\n\n if match_list.length > 1\n puts \"Multiple project names found: #{match_list}\"\n end\n\n unless match_list.empty?\n project_name = match_list[0][1]\n page_url = \"http://ftp.gnu.org/gnu/#{project_name}/?C=M&O=D\"\n\n if ARGV.debug?\n puts \"Possible GNU project [#{project_name}] detected at #{url}\"\n end\n\n if regex.nil?\n regex = /#{project_name}-(\\d+(?:\\.\\d+)*)/\n end\n\n page_matches(page_url, regex).each do |match|\n version = Version.new(match)\n match_version_map[match] = version\n end\n end\n when regex\n # Fallback\n page_matches(url, regex).each do |match|\n version = Version.new(match)\n match_version_map[match] = version\n end\n end\n\n if ARGV.debug?\n match_version_map.each do |match, version|\n puts \"#{match} => #{version.inspect}\"\n end\n end\n\n empty_version = Version.new(\"\")\n match_version_map.delete_if { |_match, version| version == empty_version }\n\n # TODO: return nil, defer the print to the caller\n return match_version_map.values.max unless match_version_map.empty?\n end\n\n fail TypeError, \"Unable to get versions for #{Tty.blue}#{name}#{Tty.reset}\"\nend", "def major_minor\n # TODO: It would be cool to try <major>.<minor + 1> if possible.\n ver = version_data['serverVersion']\n [ver['major'], ver['minor']]\n .map(&:to_i)\n .map(&:to_s)\n .join('.')\n end", "def connectorj_ver\n new_resource.url.match(/[0-9]+\\.[0-9]+\\.[0-9]+/)[0]\n end", "def version_conversion(ver, separator = '.')\n\tver_simple = ver.split(separator)\n\tver_simple.map { |i| i.to_s.sub!(/(^0)/, '') }\n\treturn ver_simple.join(separator)\nend", "def compare_versions\n if @local_version && \n (@local_version.to_machine_format >= @website_version.to_machine_format)\n display_versions\n puts \"You have the most recent version.\"\n puts \"Exiting...\"\n exit 0\n end\nend", "def get_version!(version)\n version.gsub!('_', '.')\n\n if version == 'latest'\n latest_extension_version\n else\n extension_versions.find_by!(version: version)\n end\n end", "def build_os_version(os)\n # NOTE: UA regexes don't always give us the versions back\n # they do get \"corrected\" for various OSes such as:\n # - Windows (Windows NT 6.0 => 'Vista')\n # - Windows ('Windows NT 6.3' => '8','1')\n # - Windows ('Windows NT 10.0' => '10')\n # - iOS ('Darwin/15.5' => '9','3','2')\n return unless major = os.major\n if major.to_i.to_s == major\n version, sep = duped_string(major), '.'\n else\n version, sep = duped_string(major), ' '\n end\n if os.minor\n version << sep << os.minor\n if os.patch\n version << '.' << os.patch\n if os.patchMinor\n version << '.' << os.patchMinor\n end\n end\n end\n version\n end", "def test_numeric_comparison\n value1_ = ::Versionomy.create([1, 9, 2], :rubygems)\n value2_ = ::Versionomy.create([1, 9], :rubygems)\n assert(value2_ < value1_)\n value1_ = ::Versionomy.create([1, 9, 0], :rubygems)\n value2_ = ::Versionomy.create([1, 9], :rubygems)\n assert(value2_ == value1_)\n end", "def test_standard_to_rubygems_with_v\n value_ = ::Versionomy.parse('v1.2b3')\n value2_ = value_.convert(:rubygems)\n assert_equal([1, 2, 'b', 3, 0, 0, 0, 0], value2_.values_array)\n value_ = ::Versionomy.parse('V 1.2b3')\n value2_ = value_.convert(:rubygems)\n assert_equal([1, 2, 'b', 3, 0, 0, 0, 0], value2_.values_array)\n end", "def test_standard_to_rubygems_equality_comparison\n assert_operator(::Versionomy.parse('1.2.0'), :==, ::Versionomy.parse('1.2', :rubygems))\n assert_operator(::Versionomy.parse('1.2b3'), :==, ::Versionomy.parse('1.2.beta.3', :rubygems))\n end", "def semantic_version(major: T.unsafe(nil), minor: T.unsafe(nil), patch: T.unsafe(nil)); end", "def test_parsing_with_string\n value_ = ::Versionomy.parse('1.9.2pre2', :semver)\n assert_equal([1, 9, 2, 'pre2'], value_.values_array)\n assert_equal('1.9.2pre2', value_.unparse)\n end", "def to_version_string(version)\n version = version.to_s\n if version.match(/\\./)\n version\n else\n from_version_code(version).to_s\n end\n end", "def http_major; end", "def version_tag(text); end" ]
[ "0.67268604", "0.67082983", "0.652006", "0.6492646", "0.6435036", "0.6413361", "0.64100623", "0.6325298", "0.629826", "0.62875336", "0.62479377", "0.62161833", "0.6209893", "0.6197964", "0.6139305", "0.6121343", "0.61207163", "0.610822", "0.60709566", "0.6014099", "0.6005496", "0.59969616", "0.5934682", "0.5915495", "0.59145683", "0.59013313", "0.589393", "0.5870729", "0.58443296", "0.5838319", "0.58303005", "0.5822749", "0.5809613", "0.58028615", "0.5794245", "0.5791221", "0.5786545", "0.5778896", "0.5776344", "0.5774649", "0.5772266", "0.57651186", "0.5759547", "0.5739821", "0.5732163", "0.5730209", "0.5730038", "0.57280326", "0.5725839", "0.5710765", "0.5693316", "0.5689363", "0.56872195", "0.5685891", "0.56706405", "0.56670076", "0.56558925", "0.56470984", "0.5643764", "0.56307745", "0.56235224", "0.56183755", "0.56183755", "0.56183755", "0.56183755", "0.56183755", "0.56168294", "0.56032723", "0.5599633", "0.5596713", "0.5590539", "0.55871314", "0.5585615", "0.5581212", "0.5580542", "0.557164", "0.5563325", "0.55559504", "0.55478066", "0.55411214", "0.55411214", "0.55371463", "0.5535182", "0.55347085", "0.55305165", "0.5527328", "0.5524456", "0.55234027", "0.5519741", "0.5517003", "0.55168706", "0.55167663", "0.5516223", "0.5515297", "0.55149966", "0.550526", "0.55026793", "0.5502008", "0.5500458", "0.54974365" ]
0.6655396
2
Actually builds the HTML file from the entry (actually from any composite entries)
def build @layout_path = bundle.layout_path # Render each filename. By default, the output goes to the resources # string @content_for_resources = '' entries.each { |fn| _render_one(fn) } # Finally, render the layout. This should produce the final output to # return input = File.read(@layout_path) # render using either erb or haml case File.extname(@layout_path) when /\.rhtml$/, /\.html.erb$/ return eval(Erubis::Eruby.new.convert(input)) when /\.haml$/, /\.html.haml$/ require 'haml' return Haml::Engine.new(input).to_html(self) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_entry(entry)\n %{<div class=\"hentry\" id=\"#{entry[:id]}\">\n <h2 class=\"entry-title\">#{entry[:title]}</h2>\n <span class=\"entry-content\">#{entry[:content]}</span>\n #{entry[:published_at].to_html}\n <span class=\"byline\">Posted by <span class=\"author vcard\"><span class=\"fn\"\n }\n end", "def build_dom(entries); end", "def build_html\r\n fetch_produce_items\r\n set_prices\r\n set_categories\r\n\r\n @monday = date_of_next('Monday')\r\n @grouped_items = @items.group_by(&:category)\r\n\r\n File.open(HTML_OUT, 'wb') do |f|\r\n f << template.render(self)\r\n end\r\nend", "def entryMaker(url)\n\n # set up for image links\n img_base = \"http://www.comicstriplibrary.org\"\n\n curPage = Nokogiri::HTML(open(url))\n\n curEntry = {}\n curTable = curPage.css(\"table#metadata\") \n\n # regexes strip id and stores it.\n foundID = url.match(/\\/(\\d+)/).to_s\n foundID.gsub!(/\\//,'')\n curEntry['comic_id'] = foundID\n puts \"I.D. added! it is #{foundID}\"\n \n curTable.css(\"tr\").each do |row|\n case row.css('th').text\n\n when \"Title\"\n curEntry['title'] = row.css('td').text.strip\n\n when \"Author\"\n curEntry['author'] = row.css('td').text.strip\n\n when \"Date Published\"\n cleaned_row = row.css('td').text.strip\n rawDate = cleaned_row.gsub(/^(\\d{4})-(\\d{2})-(\\d{2})\\s-\\s([a-zA-Z]+)/,'\\4, \\2-\\3-\\1')\n simpleDate = cleaned_row.gsub(/^(\\d{4})-(\\d{2})-(\\d{2})\\s-\\s([a-zA-Z]+\\s)/,'\\2-\\3-\\1')\n\n # for a friendlier date string\n curEntry['date_display'] = rawDate\n\n # standardized dates, to be sorted against\n begin\n parsedDate = Date.parse(simpleDate)\n curEntry['date_published'] = parsedDate\n rescue StandardError => e\n yearOnly = rawDate.match(/\\d{4}$|\\d{4}\\s$/)\n curEntry['date_published'] = yearOnly\n next\n end\n\n # curEntry['date_published'] = parsedDate\n\n when \"Summary\"\n curEntry['summary'] = row.css('td').text.strip\n\n when \"Characters\"\n cleaned_row = row.css('td').text.strip\n cleaned_row.gsub!(/\\n\\s+|\\n/, \"\")\n curEntry['characters'] = cleaned_row.split(',').collect(&:strip) \n\n when \"Contents\"\n cleaned_row = row.css('td').text.strip\n cleaned_row.gsub!(/\\n\\s+|\\n|\\_\\(\\d+\\)/, \"\")\n cleaned_row.gsub!(/\\_/,\" \")\n curEntry['contents'] = cleaned_row.split(',').collect(&:strip) \n\n when \"Notes\"\n curEntry['notes'] = row.css('td').text.strip\n\n when \"Transcript\"\n if row.text.match(/transcribe/)\n curEntry['transcript'] = false\n else\n curEntry['transcript'] = true\n curEntry['transcript_text'] = row.css('td').text.strip\n end\n\n end\n\n end\n\n\n this_img = curPage.css(\"#display-wrapper img\").map { |link| link[\"src\"] }[0]\n img_url = img_base + this_img\n\n # add standard img link\n curEntry['img'] = img_url\n\n # add smaller/thumb img link\n thumb = img_url.gsub(/-s/,\"-tn\")\n curEntry['img_thumb'] = thumb\n\n # add hi-res img link\n hiRes = img_url.gsub(/-s/,\"-l\")\n curEntry['img_link'] = hiRes\n\n return curEntry\n end", "def wrap_entry(entry_name, content); end", "def generate_recurse(entry)\n keyword = entry.full_name\n\n if keyword\n puts keyword\n @current_content = service.info(keyword) #lookup(keyword)\n else\n keyword = ''\n @current_content = \"Welcome\"\n end\n\n file = entry.file_name\n file = File.join(output, file)\n\n #file = keyword\n #file = file.gsub('::', '--')\n #file = file.gsub('.' , '--')\n #file = file.gsub('#' , '-')\n #file = File.join(output, file + '.html')\n\n write(file, service.info(keyword))\n\n cmethods = entry.class_methods.map{ |x| x.to_s }.sort\n cmethods.each do |name|\n mname = \"#{entry.full_name}.#{name}\"\n mfile = WebRI.entry_to_path(mname)\n mfile = File.join(output, mfile)\n #mfile = File.join(output, \"#{entry.file_name}/c-#{esc(name)}.html\")\n write(mfile, service.info(mname))\n end\n\n imethods = entry.instance_methods.map{ |x| x.to_s }.sort\n imethods.each do |name|\n mname = \"#{entry.full_name}##{name}\"\n mfile = WebRI.entry_to_path(mname)\n mfile = File.join(output, mfile)\n #mfile = File.join(output, \"#{entry.file_name}/i-#{esc(name)}.html\")\n write(mfile, service.info(mname))\n end\n\n entry.subspaces.each do |child_name, child_entry|\n next if child_entry == entry\n @directory_depth += 1\n generate_recurse(child_entry)\n @directory_depth -= 1\n end\n end", "def _render_one(entry)\n @entry = entry\n @filename = @entry.filename\n\n # avoid double render of layout path\n return if @entry.source_path == @layout_path\n\n # render. Result goes into @content_for_resources\n input = File.read(@entry.source_path)\n \n # render using either erb or haml\n case File.extname(@entry.source_path)\n when /\\.rhtml$/, /\\.html.erb$/\n @content_for_resources += eval(Erubis::Eruby.new.convert(input))\n when /\\.haml$/, /\\.html.haml$/\n require 'haml'\n @content_for_resources += Haml::Engine.new(input).to_html(self)\n end\n\n @filename =nil\n @entry = nil\n end", "def create_entries entries\n out = []\n\n entries.each do |entry, items|\n out << RDoc::Markup::Heading.new(3, entry)\n out << RDoc::Markup::BlankLine.new\n\n out << create_items(items)\n end\n\n out\n end", "def create_entries entries\n out = []\n\n entries.each do |entry, items|\n out << RDoc::Markup::Heading.new(3, entry)\n out << RDoc::Markup::BlankLine.new\n\n out << create_items(items)\n end\n\n out\n end", "def generate_bib_entry(entry)\n s = \"\"\n if entry.type == :book\n # author/editor, title, publisher, year\n if entry[:author].nil?\n # just eds\n raise \"No author or editors\" if entry[:editor].nil?\n s << \"#{process_authors process_bibtex(entry[:editor])} (editors), \"\n else \n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n end\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"#{process_bibtex entry[:publisher]}, \" if !entry[:publisher].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :article\n # author, title, journal, year\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"#{process_bibtex entry[:journal]}, \" if !entry[:journal].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :inbook\n # author/editor, title, chapter/pages, publisher, year\n if entry[:author].nil?\n # just eds\n raise \"No author or editors\" if entry[:editor].nil?\n s << \"#{process_authors process_bibtex(entry[:editor])} (editors), \"\n else \n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n end \n s << \"\\\"#{to_google_scholar process_bibtex(entry[:chapter])}\\\", \" if !entry[:chapter].nil?\n s << \"in #{process_bibtex entry[:title]}, \"\n s << \"pages #{process_bibtex entry[:pages]}, \" if !entry[:pages].nil?\n s << \"#{process_bibtex entry[:publisher]}, \" if !entry[:publisher].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :techreport\n # author, title, institution, year\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"Technical Report #{process_bibtex entry[:number]}, \" if !entry[:number].nil? \n s << \"#{process_bibtex entry[:institution]}, \" if !entry[:institution].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :inproceedings\n # author, title, booktitle, year\n if entry[:author].nil?\n # just eds\n raise \"No author or editors\" if entry[:editor].nil?\n s << \"#{process_authors process_bibtex(entry[:editor])} (editors), \"\n else\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n end \n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"in #{process_bibtex entry[:booktitle]}, \" if !entry[:booktitle].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :phdthesis\n # author, title, school, year\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"[PhD Thesis] \"\n s << \"#{process_bibtex entry[:school]}, \" if !entry[:school].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :mastersthesis\n # author, title, school, year\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"[Masters Thesis] \"\n s << \"#{process_bibtex entry[:school]}, \" if !entry[:school].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :incollection\n # author, title, booktitle, year\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"in #{process_bibtex entry[:booktitle]}, \" if !entry[:booktitle].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :conference\n # author, title, booktitle, year\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"in #{process_bibtex entry[:booktitle]}, \" if !entry[:booktitle].nil?\n s << \"#{process_bibtex entry[:year]}.\"\n elsif entry.type == :unpublished\n # author, title\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"#{process_bibtex entry[:year]}.\"\n\telsif entry.type == :manual\n # author, title\n s << \"#{process_authors process_bibtex(entry[:author])}, \"\n s << \"\\\"#{to_google_scholar process_bibtex(entry[:title])}\\\", \"\n s << \"#{process_bibtex entry[:year]}.\"\n else \n raise \"Unknown bibtex type: #{entry.type}\" \n end\n return s\nend", "def build_entry(entry, opts={})\n build_entries([entry], opts)\n end", "def to_html\n return \"\" unless file_name\n return e if e?\n page = render.to_html\n path = File.dirname(file_path)\n # Get child content.\n # A reflexive.\n files(path).each do |file|\n doc = Document.new :base_path => self.base_path, :lang => self.lang, :indent => self.indent, :settings => self.settings, :web_path => self.web_path, :commit => self.commit, :repository => self.repository, :filename => file\n self.browsers << doc\n page += doc.to_html\n end\n dirs(path).each do |dir|\n # Plus one indent from parent. Change h[1-6] tag to h[2-7] if indent is 1.\n doc = Document.new :base_path => dir, :lang => self.lang, :indent => self.indent + 1, :settings => self.settings, :web_path => self.web_path[0..-2] + dir.gsub(self.base_path, \"\"), :commit => self.commit, :repository => self.repository\n self.childs << doc\n page += doc.to_html\n end\n page\n end", "def generate_webpage(file_name)\n text=File.open(file_name).read\n text.gsub!(/\\r\\n?/, \"\")\n\n page = File.open(\"version.html\",\"w\")\n\n page.puts('<body style=\"padding-right:10%;padding-left:10%;margin-right:auto;margin-left:auto\">')\n\n text.each_line do |line|\n hs = JSON.parse(line)\n if ! hs[\"version\"].empty?\n page.puts \"<h2>\" + \"version\" + hs[\"version\"] + \"</h2>\"\n page.puts '<span style=\"font-size: 10pt\">Release Date:' + hs[\"release_date\"] + \"</span>\"\n page.puts '<hr>'\n else\n page.puts '<span style=\"font-size: 10pt\">Date:' + hs[\"release_date\"] + \"</span>\"\n end\n page.puts \"<h3>features</h3>\"\n page.puts '<ul>'\n hs[\"features\"].each do |feature|\n page.puts '<li>' + feature.to_s + '</li>'\n end\n page.puts '</ul>'\n\n page.puts \"<h3>issues</h3>\"\n page.puts '<ul>'\n hs[\"fix_issue\"].each do |issue|\n page.puts '<li>' + issue.to_s + '</li>'\n end\n page.puts '</ul>'\n end\n\n page.puts('</body>')\n\n page.close\n\nend", "def printHTML(entriesList, out)\n id = 0\n entriesList.each { |heading,entries|\n out.puts \"<h3>#{heading}</h3>\" if heading\n out.puts \"<ul>\"\n entries.each { |entry|\n out.puts \"<li>\"+entry.toHTML(id)+\"</li>\"\n id += 1\n }\n out.puts \"</ul>\"\n }\nend", "def generate_external_item_data(format, cgi, item_entry)\n item_data = \"\"\n item_metadata = generate_item_metadata(format, cgi, item_entry)\n \n case format.downcase\n when \"html\"\n item_data += cgi.li(\"class\" => \"link\"){\n cgi.div(\"class\" => \"external_item\") do\n cgi.div(\"class\" => \"item_data\") do\n \"#{item_entry.title} - \" + cgi.a(item_entry.uri){item_entry.uri} +\n \"<br/>Alternate link: \" + (item_entry.alternate_uri.nil? || item_entry.alternate_uri.blank? ? \"<span class='none_text'>none</span>\" : cgi.a(item_entry.alternate_uri){item_entry.alternate_uri}) + \"<br/>\"\n end +\n item_metadata\n end\n }\n \n when \"text\"\n item_data += \"+ #{item_entry.title} - #{item_entry.uri}\\n\"\n item_data += \" (alternate link: #{item_entry.alternate_uri.nil? || item_entry.alternate_uri.blank? ? \"none\" : item_entry.alternate_uri})\\n\"\n item_data += item_metadata\n \n else\n return \"ERROR\"\n end\n \n return item_data\n end", "def to_html\n # header\n puts Header % [convert_entity(@feed_name), convert_entity(@feed_description)]\n \n # the entries\n @feed_data.each do |item|\n puts Entry % [convert_link(item['link']), convert_entity(item['title'])]\n end\n \n # footer\n print Footer % Version\n end", "def build_web_page(info_hash, id_hash, id_date, id_status)\n image_counter = info_hash.length\n \n File.open('rovers_index.html', 'w') do |file|\n file.puts \"<html>\\n<head>\\n<title>Rovers Nasa!</title>\\n</head>\"\n file.puts \"<body>\\n<section class='container'>\"\n file.puts \"<h1> FOTOGRAFIAS DE LOS ROVERS DE LA NASA CON SUS CARACTERISTICAS</h1>\"\n file.puts\"<ul>\"\n image_counter.times do |i| \n file.puts \"\\t<img src='#{info_hash[i]}'width='250'>\"\n file.puts \"\\n<li><p> ID is: #{id_hash[i]}</p></li>\"\n file.puts \"<li><p>Date in Earth: #{id_date[i]}</p></li>\"\n file.puts \"<li><p> Satelite Status: #{id_status[i]}</p></li>\"\n\n end\n file.puts \"</ul>\\n</section>\\n</body>\\n<html>\"\n end\n end", "def parse(entry, content_id)\n return '' unless entry.respond_to?(:event)\n # clean the html\n html = white_list(entry.event)\n \n # parse all standard lj tags first\n html = parse_lj_embed_tags(html,entry)\n html = parse_lj_user_tags(html)\n html = parse_lj_comm_tags(html)\n \n # create a cut version of the entry data\n cut = self.parse_lj_cut_tags(html.dup, content_id)\n\n # anchor the cuts in the main entry\n html = anchor_lj_cut_tags(html, content_id)\n\n # viola!\n {:cut => cut, :full => html}\n end", "def OutputHTML( filters, results )\n\ttext =\n\"<html>\n\t<head>\n\t\t<STYLE TYPE=\\\"text/css\\\">\n\t\t<!--\n\t\t\t.dir {\n\t\t\t\tbackground-color: \\#A0A0A0;\n\t\t\t\tpadding-left: 10pt;\n\t\t\t\tpadding-right: 10pt;\n\t\t\t}\n\t\t\t.file {\n\t\t\t\tbackground-color: \\#838383;\n\t\t\t\tpadding-left: 10pt;\n\t\t\t\tpadding-right: 10pt;\n\t\t\t}\n\t\t\t.filter {\n\t\t\t\tbackground-color: #757575;\n\t\t\t\tpadding-left: 10pt;\n\t\t\t\tpadding-right: 10pt;\n\t\t\t\tpadding-top: 5pt;\n\t\t\t}\n\t\t-->\n\t\t</STYLE>\n\t</head>\n\t<body bgcolor=\\\"\\#BDBDBD\\\">\n\n\t\t<h1>Filters</h1>\n\t\t<dl>\n\"\n\t# List the filters\n\tfilters.each do |filterType|\n\t\ttext +=\n\"\t\t\t<dt><b>#{filterType.first}</b></dt>\n\t\t\t<dd>\n\t\t\t\t<dl>\n\"\n\t\tfilterType.last.each do |filter|\n\t\t\ttext +=\n\"\t\t\t\t\t<dt id=\\\"#{filter.name}\\\"><i>#{filter.title}</i></dt>\n\t\t\t\t\t<dd>\n\t\t\t\t\t\t#{HTMLEsc(filter.desc)}<p>\n\t\t\t\t\t</dd>\n\"\n\t\tend\n\n\t\ttext +=\n\"\t\t\t\t</dl>\n\t\t\t</dd>\n\"\n\tend\n\n\ttext +=\n\"\t\t</dl>\n\n\t\t<p>\n\n\t\t<h1>Directories</h1>\n\t\t<ul>\n\"\n\n\t# List the directories\n\tresults.each do |dir|\n\t\ttext +=\n\"\t\t\t<li>\n\t\t\t\t<a href=\\\"\\##{dir.first}\\\">#{dir.first}</a>\n\t\t\t</li>\n\"\n\tend\n\n\ttext +=\n\"\t\t</ul>\n\n\t\t<p>\n\n\t\t<h1>Results</h1>\n\"\n\n\tresults.each do |dir|\n\t\ttext +=\n\"\t\t<div class=\\\"dir\\\">\n\t\t\t<h2 id=\\\"#{dir.first}\\\">#{dir.first}</h2>\n\"\n\n\t\tdir.last.each do |file|\n\t\t\ttext +=\n\"\t\t\t<div class=\\\"file\\\">\n\t\t\t\t<h3>#{file.first}</h3>\n\n\t\t\t\t<ul>\n\"\n\n\t\t\tfile.last.each do |filter|\n\t\t\t\ttext +=\n\"\t\t\t\t\t<li>\n\t\t\t\t\t\t<div class=\\\"filter\\\">\n\t\t\t\t\t\t\t<b><a href=\\\"\\##{filter.first.name}\\\">#{filter.first.title}</a></b>\n\n\t\t\t\t\t\t\t<ul>\n\"\n\n\t\t\t\tfilter.last.each do |result|\n\t\t\t\t\tif result.line then\n\t\t\t\t\t\ttext +=\n\"\t\t\t\t\t\t\t\t<li><b>#{PadNum(result.line.number)}:</b> #{HTMLEsc(result.line.text.strip)}</li>\n\"\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\ttext +=\n\"\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</li>\n\"\n\t\t\tend\n\t\t\ttext +=\n\"\t\t\t\t</ul>\n\t\t\t</div>\n\"\n\t\tend\n\n\t\ttext +=\n\"\t\t</div>\n\n\t\t<p>\n\"\n\tend\n\n\ttext +=\n\"\t</body>\n</html>\"\n\n\treturn text;\nend", "def file2htmlSection( file )\n name = \"\"\n if file =~ /queryPair/\n name = \"Query Pairs\"\n elsif file =~ /queryClick/\n name = \"Query Click Pairs\"\n elsif file =~ /query/\n name = \"Queries\"\n end\n\n \n \n section = \"<div class='crowdlog' style='margin: 2px; padding: 10px; border: 1px gray solid'><h2><a name='#{file}'></a>#{name}</h2>File: #{file}<p>\"\n decrypted = []\n undecrypted = []\n fd = File.open( file, \"r\" )\n while line = fd.gets\n artifact = JSON.parse( line )\n if isDecrypted( artifact )\n decrypted << artifact\n else\n undecrypted << artifact\n end\n end\n fd.close\n\n ## Generate the HTML for all of the decrypted data --\n ## show the artifacts with the highest frequencies first.\n section += \"<h3>Decrypted data</h3>\\n\"\n section += \"<table border=1><tr><th>Distinct users</th><th>Total instances</th><th>Normalized form</th><th>Number of variations</th></tr>\\n\"\n decrypted.sort{ |x,y| \n if y['number_of_distinct_parts'] == x['number_of_distinct_parts'] \n y['total_instances'] <=> x['total_instances']\n else\n y['number_of_distinct_parts'] <=> x['number_of_distinct_parts'] \n end\n }.each do |a|\n\n primaryFieldParts = a['primary_private_field'].split( \"\\t\" )\n primaryFieldText = primaryFieldParts.join(\" &rarr; \")\n \n \n section += \"<tr><td>#{a['number_of_distinct_parts']}</td>\" +\n \"<td>#{a['total_instances']}</td>\" +\n \"<td>#{primaryFieldText}</td>\" +\n \"<td>#{a['secondary_private_fields'].keys.size}</td></tr>\\n\"\n \n end\n section += \"</table>\\n\\n\"\n\n ## Generate the HTML for all of the encrypted data --\n ## show the artifacts with the highest support first.\n section += \"<h3>Summary of undecryptable data</h3>\\n\"\n section += \"<table border=1><tr><th>Distinct users</th><th>Ditinct instances</th><th>Total instances</th></tr>\\n\"\n undecrypted.sort{ |x,y| y['support'] <=> x['support'] }.each do |a|\n section += \"<tr><td>#{a['support']}</td><td>#{a['distinct']}</td><td>#{a['instances']}</td></tr>\\n\"\n end\n section += \"</table>\\n\" \n\n section += \"</div>\\n\\n\"\n return section\nend", "def create\n puts \"In entries#create, params=#{params}\"\n entity_id = params[:entity_id]\n=begin\n @entity = Entity.find(entity_id)\n template_name = @entity.template.name\n\n @entry = EntryManager.initialize_entry(@entity)\n=end\n @entity = Entity.find(entity_id)\n @entry = Entry.new({:entity_id => entity_id})\n \n @context = {:display_mode => 'new' \n }\n \n template = \"/templates/predefined/#{@entity.template.name}.html.erb\"\n entry_html = render_to_string(:template=>template, \n :layout=>false,\n )\n\n \n @entry[:html] = entry_html\n @entry[:attr_values] = @entry.attr_values\n @entry[:attrs] = @entity.attrs\n\n render :json => {\n :entry => @entry\n\n }\n end", "def to_html\n render_file(main)\n end", "def generate_html\n # the individual descriptions for files and classes\n gen_into(@files)\n gen_into(@classes)\n # and the index files\n gen_file_index\n gen_class_index\n gen_method_index\n gen_main_index\n\n # this method is defined in the template file\n write_extra_pages if defined? write_extra_pages\n end", "def do_add_entry(entry,html_txt,infos)\n\t\t##debug(sprintf(\"ADD DICT ENTRY(%s)\\nINF(%s)\\n\",entry.inspect(),infos.inspect()))\n\n\t\t\n\t\tkey_words= entry['key_words']\n\t\tinfos[:key_words]=key_words\n\t\tinfos[:key_lang]=entry['key_lang']\n\n\n\t\tattr = \"\"\n\t\t[\"grammar\",\"category\"].each{|tag|\n\t\t\tattr << \"/\" << entry[tag] if entry[tag] != \"\"\n\t\t}\n\t\tattr << \"/\" if attr != \"\"\n\t\tprimary_lang=primary_lang(entry['dict_id'])\n\t\tif primary_lang==\"\"\n\t\t\tprimary_lang=entry['key_lang']\n\t\tend\n\t\tkey_term=\"\"\n\t\tif primary_lang != \"\" and infos[:xlated_word] != nil and infos[:xlated_word][primary_lang]!=nil\n\t\t\tinfos[:xlated_word][primary_lang].each{|w|\n\t\t\t\tkey_term << \",\" if key_term != \"\"\n\t\t\t\tkey_term << w \n\t\t\t}\n\t\tend\n\n\t\tinfos[:key_attr]=attr\n\t\tinfos[:attributes]=attr\n\t\tkey_txt = '<p class=\"dict_key_1\">'\n\t\tkey_txt << \"<b>\"\n\t\tif key_term==\"\"\n\t\t\tif key_words.index(\"$phrase$\")!= nil\n\t\t\t\tkey_txt << @to_search\n\t\t\telse\n\t\t\t\tkey_txt << key_words\n\t\t\tend\n\t\telse\n\t\t\tkey_txt << key_term\n\t\tend\n\t\tkey_txt << \"</b>\"\n\t\tif attr != \"\"\n\t\t\tkey_txt << ' <i>' + attr + '</i>' \n\t\tend\n\t\tkey_txt << '</p>'\n\n\t\tinfos[:dict_entry_key]= key_txt\n\t\tadd_entry(entry['dict_id'],\n\t\t\t key_words,\n\t\t\t [html_txt],\n\t\t\t infos)\n\t\t##debug(sprintf(\"INFOS-FINAL\\n %s\\n\",infos.inspect()))\n\tend", "def to_html!\n locales[\"locales\"].each do |locale_code|\n # contrary to what is said on https://developer.zendesk.com/rest_api/docs/core/locales\n # we do not get an ID, so I'm inventing one that is unique per locale\n locale = {\"name\" => locale_code, \"id\" => locale_code.chars.map {|ch| ch.ord - 'A'.ord + 10}.join}\n @raw_data[:locales] << locale\n\n categories(locale_code)['categories'].each do |category|\n log(category['name'].upcase)\n @raw_data[:categories] << category\n\n sections(locale_code, category['id'])['sections'].each do |section|\n @raw_data[:sections] << section\n log(\" #{section['name']}\")\n\n articles(locale_code, section['id'])['articles'].each do |article|\n log(\" #{article['name']}\", :standard)\n\n article_dir = dir_path(locale, category, section, article)\n file_path = \"#{article_dir}index.html\"\n article['backup_path'] = file_path\n @raw_data[:articles] << article\n\n File.open(file_path, \"w+\") { |f| f.puts article_html_content(article) }\n\n article_attachments(article['id'])['article_attachments'].each do |article_attachment|\n @raw_data[:article_attachments] << article_attachment\n # optimization, do not download attachment when already present (we could check based on the id)\n download_attachment!(article_attachment, article_dir)\n end\n end\n end\n end\n end\n end", "def build\n html = []\n scripts.each do |script|\n code = File.read(script)\n html << %[<div class=\"file\" id=\"#{script}\"><pre>]\n html << highlight(code)\n html << %[</pre></div>]\n end\n text = html.join(\"\\n\")\n text = interlink(text)\n text = garnish(text)\n text\n end", "def generate_file_data(format, cgi, item_entry, item, download_allowed)\n file_data = \"\"\n file_metadata = generate_item_metadata(format, cgi, item_entry)\n \n case format.downcase\n when \"html\"\n file_data += cgi.li(\"class\" => \"file\"){ \n cgi.div(\"class\" => \"file_item\") do\n cgi.div(\"class\" => \"item_data\") do\n \"<b>File: </b>\" + cgi.a(location_string(item_entry.contributable_type, item.id)){item.title} + \n (download_allowed ? (\"&nbsp;&nbsp;&nbsp;[ \" + cgi.a(\"./files/\" + item.local_name){\"open local copy\"} + \" ]\") : \"\") + \"<br/>\" +\n uploader_string(item.contributor_type, item.contributor_id, true) + \"<br/>\"\n end +\n file_metadata\n end\n }\n \n when \"text\"\n file_data += \"+ File: #{item.title}\"\n if download_allowed\n file_data += \" (local copy: files/#{item.local_name})\"\n end\n file_data += \"\\n Location: \" + location_string(item_entry.contributable_type, item.id)\n file_data += \"\\n \" + uploader_string(item.contributor_type, item.contributor_id, false) + \"\\n\"\n file_data += file_metadata\n \n else\n return \"ERROR\"\n end\n \n return file_data\n end", "def build_post_from_entry(entry)\n text = entry.text.gsub(/\\\\u([0-9a-zA-Z]{4})/) { |s| [$1.to_i(16)].pack(\"U\") }\n self.posts.build(\n :service_action => Service::SERVICE_ACTION_POST,\n :identifier => entry.id.to_s,\n :title => text,\n :markup => Post::HTML_MARKUP,\n :summary => text,\n :url => \"#{self.profile_url}/status/#{entry.id}\",\n :published_at => entry.created_at.to_time,\n :extra_content => {\n :original_tags => self.search_for_hashtags(text) # array de tags\n }\n )\n end", "def generate_workflow_data(format, cgi, item_entry, item, required_item_version, wf_version, download_allowed)\n workflow_data = \"\"\n workflow_metadata = generate_item_metadata(format, cgi, item_entry)\n \n case format.downcase\n when \"html\"\n workflow_data += cgi.li(\"class\" => \"workflow\"){\n cgi.div(\"class\" => \"workflow_item\") do\n cgi.div(\"class\" => \"item_data\") do\n \"<b>Workflow: </b>\" + cgi.a(location_string(item_entry.contributable_type, item.id, wf_version)){required_item_version.title} + \n (download_allowed ? (\"&nbsp;&nbsp;&nbsp;[ \" + cgi.a(\"./workflows/\" + item.filename(wf_version)){\"open local copy\"} + \" ]\") : \"\") + \"<br/>\" +\n \"Type: <span class='workflow_type'>\" + item.type_display_name() + \"</span><br/>\" +\n \"Originally uploaded by: \" + uploader_string(item.contribution.contributor_type, item.contribution.contributor_id, true, false) + \"<br/>\" +\n \"Version: #{wf_version} (created on: #{required_item_version.created_at.strftime(\"%d/%m/%Y\")}, last edited on: #{required_item_version.updated_at.strftime(\"%d/%m/%Y\")})<br/>\" +\n \"Version uploaded by: \" + uploader_string(required_item_version.contributor_type, required_item_version.contributor_id, true, false) + \"<br/>\"\n end +\n workflow_metadata \n end\n }\n \n when \"text\"\n workflow_data += \"+ Workflow: #{item.title}\"\n if download_allowed\n workflow_data += \" (local copy: workflows/#{item.filename(wf_version)})\"\n end\n workflow_data += \"\\n Type: \" + item.type_display_name()\n workflow_data += \"\\n Location: \" + location_string(item_entry.contributable_type, item.id, wf_version)\n workflow_data += \"\\n Originally uploaded by: \" + uploader_string(item.contribution.contributor_type, item.contribution.contributor_id, false, false)\n workflow_data += \"\\n Version: #{wf_version} (created on: #{required_item_version.created_at.strftime(\"%d/%m/%Y\")}, last edited on: #{required_item_version.updated_at.strftime(\"%d/%m/%Y\")})\"\n workflow_data += \"\\n Version uploaded by: \" + uploader_string(required_item_version.contributor_type, required_item_version.contributor_id, false, false) + \"\\n\"\n workflow_data += workflow_metadata\n else\n return \"ERROR\"\n end\n \n return workflow_data\n end", "def build_post_from_entry(entry)\n self.posts.build(\n :summary => entry[:description],\n :service_action => Service::SERVICE_ACTION_POST,\n :identifier => entry[:guid].to_s,\n :title => entry[:title],\n :markup => Post::PLAIN_MARKUP,\n :url => entry[:link],\n :published_at => entry[:pubDate]\n )\n end", "def md2html\n\t\tbook.toc.each do |source|\n\t\t\ttarget = 'build/raw_html/' + source.ext('html')\n\t\t\tcreate \"source/#{source}\" => target do\n\t\t\t\tinfo \"converting #{source} => #{target}\"\n\t\t\t\tm = Maruku.new IO.read(\"source/#{source}\")\n\t\t\t\tFile.open(target, 'w') do |f|\n\t\t\t\t\tif block_given?\n\t\t\t\t\t\thtml = m.to_filtered_html do |doc|\n\t\t\t\t\t\t\tyield doc\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\thtml = m.to_html\n\t\t\t\t\tend\n\t\t\t\t\tf.write html\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def filter_entry(entry_file)\n docs = get_docs(entry_file)\n return nil unless docs\n \n docs = docs.select do |doc|\n if @query.match(doc.content)\n doc.search(\".subentry\").each do |subentry|\n subentry.remove() unless @subquery.match(subentry.content)\n end\n doc.search(\"li\").each do |subentry|\n subentry.remove() unless @subquery.match(subentry.content)\n end\n else\n nil\n end\n end\n\n docs.map{|doc| doc.to_html}.join(\"\\n\")\n end", "def build_entries_output(pages, depth = 1, context)\n output = []\n\n pages.each_with_index do |page, index|\n css = []\n css << 'first' if index == 0\n css << 'last' if index == pages.size - 1\n\n output << self.render_entry_link(page, css.join(' '), depth, context)\n end\n\n output.join(\"\\n\")\n end", "def extract_web_info(report_file, tag, entries)\n entries.each do |e|\n report_file.write(\" <#{tag}>\\n\")\n e.attributes.each_pair do |k,v|\n el = create_xml_element(k,v)\n report_file.write(\" #{el}\\n\")\n end\n\n site = e.web_site\n el = create_xml_element(\"vhost\", site.vhost)\n report_file.write(\" #{el}\\n\")\n\n el = create_xml_element(\"host\", site.service.host.address)\n report_file.write(\" #{el}\\n\")\n\n el = create_xml_element(\"port\", site.service.port)\n report_file.write(\" #{el}\\n\")\n\n el = create_xml_element(\"ssl\", site.service.name == \"https\")\n report_file.write(\" #{el}\\n\")\n\n report_file.write(\" </#{tag}>\\n\")\n end\n report_file.flush\n end", "def build_entries(entries, opts={})\n\n with_hidden = opts[:hidden] || :none\n\n # First, start an \"already seen\" set.\n created_seen = @seen.nil?\n @seen ||= []\n\n # Now, process the entries, adding them to the seen set.\n entries.each do |entry|\n\n # skip if hidden, already seen, or already built (unless forced)\n if entry.hidden? && with_hidden == :none\n HP.logger.debug(\"~ Skipping Entry: #{entry.filename} because it is hidden\") \n next\n end\n\n if !entry.hidden? && with_hidden == :only\n HP.logger.debug(\"~ Skipping Entry: #{entry.filename} because it is not hidden\") \n next\n end\n\n # Nothing interesting to log here.\n next if @seen.include?(entry)\n @seen << entry\n\n # Do not build if file exists and source paths are not newer.\n if !opts[:force] && File.exists?(entry.build_path)\n source_mtime = entry.source_path_mtime\n if source_mtime && (File.mtime(entry.build_path) >= source_mtime)\n entry.fresh = false\n HP.logger.debug(\"~ Skipping Entry: #{entry.filename} because it has not changed\") \n next\n end\n end\n\n # OK, looks like this is ready to be built.\n # if the entry is served directly from source\n if entry.use_source_directly?\n HP.logger.debug(\"~ No Build Required: #{entry.filename} (will be served directly)\")\n else\n HP.logger.debug(\"~ Building #{entry.type.to_s.capitalize}: #{entry.filename}\")\n HPDev.send(\"build_#{entry.type}\".to_sym, entry, self)\n entry.fresh = true\n end\n end\n\n # Clean up the seen set when we exit.\n @seen = nil if created_seen\n end", "def generate_html(record)\n \"<!DOCTYPE html>\n <html>\n <head>\n <meta charset=\\\"utf-8\\\">\n <link rel=\\\"stylesheet\\\" href=\\\"./style.css\\\" />\n <script type=\\\"application/javascript\\\" src=\\\"./click_handlers.js\\\"></script>\n <title></title>\n </head>\n <body>\n #{main_text(record)}\n </body>\n </html>\"\nend", "def build_file(repo_rel_path, entry)\n full_path = repo_rel_path.join(entry)\n content = file_content(full_path)\n\n File.write(full_path, content)\n end", "def build_entry(attributes)\n ContentEntry.new(content_type: self).tap do |entry|\n # set the link to the mounting point\n entry.mounting_point = self.mounting_point\n\n # do not forget that we are manipulating dynamic fields\n attributes.each do |k, v|\n begin\n field = self.find_field(k)\n\n if field.nil? && v.is_a?(Hash) # not a dynamic field but localized (permalink ?)\n entry.send(:\"#{k}_translations=\", v)\n elsif field.nil?\n entry.send(:\"#{k}=\", v)\n else\n entry.send(:\"#{field.name}=\", v)\n end\n rescue NoMethodError => e\n Mounter.logger.error e.backtrace\n raise FieldDoesNotExistException.new(\"The '#{self.slug}' content type does not have a field named '#{k}'.\")\n end\n end\n\n # force the slug to be defined from its label and in all the locales\n entry.send :set_slug\n\n (self.entries ||= []) << entry\n end\n end", "def generate_project_file\n template_file = @template_dir + 'hhp_file.hhp.rhtml'\n\n @values = { :title => @options.title, :opname => @outputdir.basename }\n \n static_files = ['index.html', 'classindex.html', 'fileindex.html']\n @values[:html_files] = static_files + (@generated_files+@classes).map{|f| f.path}.uniq\n \n out_file = @outputdir + @project_name\n debug_msg \" rendering #{out_file}\"\n render_template template_file, out_file do |io| binding end\n end", "def generate_table_of_contents(table_of_contents, file_names)\n\n contents_hash = Hash.new\n file_names.each_with_index do |val,index|\n contents_hash[index+1] = val[0..-5]\n end\n\n table_of_contents.table(contents_hash) do |table|\n table.rows(file_names.length)\n end\n\n table_of_contents.render_file \"table_of_contents.pdf\"\n\n # contents_hash = Hash.new\n\n # # add anchor tag to each element\n # file_names.each_with_index do |val,index|\n # contents_hash[index+1] = table_of_contents.add_dest(val, 6)\n # end\n\n # p contents_hash[1].class\n\n # # table_of_contents.table(contents_hash) do |table|\n # # table.rows(contents_hash.length)\n # # end\n\n # table_of_contents.render_file \"table_of_contents.pdf\"\n\nend", "def markup_file_contents(contents); end", "def create_new_xml_blog( body, time )\n p \"new xml doc created for time=#{time}\"\n \n #this is our template for a an individual entry in the blog import file\n item_template = <<-eos\n<item>\n<title>xxx</title>\n<link>xxx</link>\n<pubDate>xxx</pubDate>\n<dc:creator><![CDATA[xxx]]></dc:creator>\n\n\t\t<category><![CDATA[Uncategorized]]></category>\n\n\t\t<category domain=\"category\" nicename=\"uncategorized\"><![CDATA[Uncategorized]]></category>\n\n<guid isPermaLink=\"false\">xxx</guid>\n<description></description>\n<content:encoded><![CDATA[xxx]]></content:encoded>\n<excerpt:encoded><![CDATA[]]></excerpt:encoded>\n<wp:post_id>xxx</wp:post_id>\n<wp:post_date>xxx</wp:post_date>\n<wp:post_date_gmt>xxx</wp:post_date_gmt>\n<wp:comment_status>closed</wp:comment_status>\n<wp:ping_status>closed</wp:ping_status>\n<wp:post_name>xxx</wp:post_name>\n<wp:status>publish</wp:status>\n<wp:post_parent>0</wp:post_parent>\n<wp:menu_order>0</wp:menu_order>\n<wp:post_type>post</wp:post_type>\n<wp:post_password></wp:post_password>\n</item>\n\n eos\n \n doc = Hpricot.XML(item_template)\n \n #xanga names entries on date, so we will do same\n doc.search(\"title\")[0].inner_html = \"#{time.gsub(\" +0000\",\"\")}\"\n #link is constructed as follows: [base_blog_url]/[YYYY]/[MM]/[DD]/[title.downcase]\n #for dates, this looks like: [base_blog_url]/[YYYY]/[MM]/[DD]/tue-10-mar-2009-001259-0000/, for example\n doc.search(\"link\")[0].inner_html = \"#{@options[:base_blog_url]}/#{Time.now.strftime(\"%Y\")}/#{Time.now.strftime(\"%m\")}/#{Time.now.strftime(\"%d\")}/#{time.downcase.gsub(\",\", \"\").gsub(\":\",\"\").gsub(\" +\",\"-\").gsub(\" \",\"-\")}/\"\n \n #pubDate is 'time' passed in\n doc.search(\"pubDate\")[0].inner_html = \"#{time}\"\n #the creator is the username that gets credit for the posting i guess\n doc.search(\"dc:creator\")[0].inner_html = \"<![CDATA[#{@options[:creator]}]]>\"\n #guid is, as far as i can tell follows base_blog_url/?p=N format, where N=sequence of blog \n doc.search(\"guid\")[0].inner_html = \"#{@options[:base_blog_url]}/?p=#{@curr_blog_entries}\"\n #content:encoded is the blog body passed here\n doc.search(\"content:encoded\")[0].inner_html = \"<![CDATA[#{body}]]>\"\n #wp:post_id is as far as i can tell, just the sequential ordering of imported entries \n doc.search(\"wp:post_id\")[0].inner_html = \"#{@curr_blog_entries}\"\n\n #I've a conflict with my Time class; so I have to hack around, so sorry\n #input: time formatted as Tue, 10 Mar 2009 00:12:59 +0000\n #output: 2009-03-10 00:12:59, for example\n def convert_to_wp_post_date(time)\n ret = time.split(\" \")\n month_value = { 'JAN' => 1, 'FEB' => 2, 'MAR' => 3, 'APR' => 4, 'MAY' => 5, 'JUN' => 6, 'JUL' => 7, 'AUG' => 8, 'SEP' => 9, 'OCT' =>10, 'NOV' =>11, 'DEC' =>12 }\n ret[2] = month_value[ ret[2].upcase ] \n ret[2] = \"0\" + ret[2].to_s if ret[2].to_s.size == 1 #we want month padded to 2 digits\n ret[1] = \"0\" + ret[1].to_s if ret[1].to_s.size == 1 #we want day padded to 2 digits\n \n \"#{ret[3]}-#{ret[2]}-#{ret[1]} #{ret[4]}\"\n end\n \n #wp:post_date /wp:post_date_gmt is yet another format for the time field passed in\n #it looks like: 2009-03-10 00:12:59, for example\n doc.search(\"wp:post_date\")[0].inner_html = \"#{convert_to_wp_post_date(time)}\"\n doc.search(\"wp:post_date_gmt\")[0].inner_html = \"#{convert_to_wp_post_date(time)}\"\n #wp:post_name with xanga, it is same asthe last part of the link tag\n doc.search(\"wp:post_name\")[0].inner_html = \"#{time.downcase.gsub(\",\", \"\").gsub(\":\",\"\").gsub(\" +\",\"-\").gsub(\" \",\"-\")}\"\n\n doc\n end", "def build\r\n self.ehtml, self.ecss, self.ejs = self.theme.page_layout.build_content() \r\n return self.ehtml, self.ecss, self.ejs\r\n end", "def convFile(f)\n\t\t\tdoc = Nokogiri::HTML(File.open(f))\n\t\t\tpage = {}\n\t\t\tpage[:title] = doc.xpath(\"/html/head/title/text()\").to_s\n\t\t\tpage[:fileName] = f.split(\"/\").last.split(\".\")[0]\n\t\t\tpage[:sections] = []\n\t\t\t# files this page relies on. Should be copied to the final directory\n\t\t\tpage[:dependencies] = [] \n\t\t\tdoc.xpath(\"/html/body/table[2]/tr[@valign=\\\"top\\\"]\").each do |e|\n\t\t\t\ts = {}\n\t\t\t\ts[:title] = e.xpath(\"td[1]/b/text()\").to_s.gsub(\"&nbsp;\",\"\").chomp\n\n\t\t\t\t#find the examples\n\t\t\t\te.xpath(\"td[2]/object\").each do |o|\n\t\t\t\t\texec = {}\n\t\t\t\t\tbutton = o.xpath(\"param[@name=\\\"Button\\\"]\").first[\"value\"].to_s\n\t\t\t\t\texec[:buttontext] = button[6..-1]\n\t\t\t\t\tcommand = o.xpath(\"param[@name=\\\"Item1\\\"]\").first[\"value\"].to_s\n\t\t\t\t\tcommarr = command.split(/[,;]/)\n\t\t\t\t\texec[:name] = commarr[2]\n\t\t\t\t\texec[:file] = commarr[1]\n\n\t\t\t\t\ts[:executables] ||= []\n\t\t\t\t\ts[:executables] << exec\n\t\t\t\t\to.remove # remove it from the content, we have processed it\n\t\t\t\tend\n\n\t\t\t\t#find the code\n\t\t\t\te.xpath(\"td[2]//pre\").each do |o|\n\t\t\t\t\tcode = o.content.to_s\n\t\t\t\t\ts[:code] ||= []\n\t\t\t\t\ts[:code] << code\n\t\t\t\t\to.remove # remove it from the content, we have processed it\n\t\t\t\tend\n\n\t\t\t\t#find images\n\t\t\t\te.xpath(\"td[2]//img\").each do |o|\n\t\t\t\t\tfile = o[\"src\"]\n\t\t\t\t\ts[:images] ||= []\n\t\t\t\t\ts[:images] << file\n\t\t\t\t\tpage[:dependencies] << file\n\t\t\t\t\t#o.remove # remove it from the content, we have processed it\n\t\t\t\tend\n\n\t\t\t\t#find links, mostly for processing utility\n\t\t\t\te.xpath(\"td[2]//a\").each do |o|\n\t\t\t\t\tfile = o[\"href\"]\n\t\t\t\t\ts[:links] ||= []\n\t\t\t\t\ts[:links] << file[0..-6] # strip .html\n\t\t\t\tend\n\n\t\t\t\t#format the content\n\t\t\t\tcontent = e.xpath(\"td[2]\").first\n\n\t\t\t\ttextcontent = content.content().to_s\n\t\t\t\tunless textcontent.empty?\n\t\t\t\t\thtml = content.to_s[4..-6].strip # The slice strips the <td> tags\n\t\t\t\t\ts[:raw_content] = html\n\t\t\t\t\ts[:text_content] = textcontent\n\t\t\t\t\ts[:mdown_content] = markdownFormat(html,s[:title] != \"Syntax\") \n\t\t\t\tend\n\t\t\t\tpage[:sections] << s\n\t\t\tend\n\n\t\t\t#It might be a tutorial page such as turing_admin\n\t\t\tif page[:sections].empty?\n\t\t\t\tpage[:htmlcontent] = doc.xpath(\"/html/body\").to_html(:encoding => 'UTF-8')[6..-8]\n\t\t\tend\n\n\t\t\tpage\n\t\tend", "def generate_pack_data(format, cgi, item_entry, item, download_allowed)\n pack_data = \"\"\n pack_metadata = generate_item_metadata(format, cgi, item_entry)\n \n case format.downcase\n when \"html\"\n pack_data += cgi.li(\"class\" => \"pack\"){\n cgi.div(\"class\" => \"pack_item\") do\n cgi.div(\"class\" => \"item_data\") do\n \"<b>Pack: </b>\" + cgi.a(location_string(item_entry.contributable_type, item.id)){item.title} + \n (download_allowed ? (\"&nbsp;&nbsp;&nbsp;[ #{cgi.a(location_string(item_entry.contributable_type, item.id) + '/download'){'click here to download this pack separately'}} ]\") : \"\") + \"<br/>\" +\n uploader_string(item.contributor_type, item.contributor_id, true) + \"<br/>\"\n end +\n pack_metadata\n end\n }\n \n when \"text\"\n pack_data += \"- Pack: #{item.title}\"\n pack_data += \"\\n Location: \" + location_string(item_entry.contributable_type, item.id)\n if download_allowed\n pack_data += \"\\n Download link: \" + location_string(item_entry.contributable_type, item.id) + \"/download ( --download of nested packs is not supported, however using this link it can be downloaded separately-- )\"\n end\n pack_data += \"\\n \" + uploader_string(item.contributor_type, item.contributor_id, false) + \"\\n\"\n pack_data += pack_metadata\n \n else\n return \"ERROR\"\n end\n \n return pack_data\n end", "def generate_html\n @main_url = main_url\n @sorted_files = @files.sort\n @sorted_classes = @classes.sort\n @sorted_methods = RDoc::Generator::Method.all_methods.sort\n\n # the individual descriptions for files and classes\n gen_into(@files)\n gen_into(@classes)\n\n # and the index files\n gen_file_index\n gen_class_index\n gen_method_index\n gen_main_index\n\n # this method is defined in the template file\n values = {\n :title_suffix => CGI.escapeHTML(\"[#{@options.title}]\"),\n :charset => @options.charset,\n :style_url => style_url('', @options.css),\n }\n\n @template.write_extra_pages(values) if\n @template.respond_to?(:write_extra_pages)\n end", "def to_html(datums)\n #, :id, :description, :conditions, :explanation, :format\n require 'markaby'\n mab = Markaby::Builder.new\n mab.html do\n head { title \"Loonheffing stuff\" }\n body do \n datums.each do |d|\n h1 d.name\n table do\n tr { td \"Identifier\"; td d.id }\n tr { td \"Description\"; td d.description }\n cs = d.conditions.split(/\\[[0-9]+\\]/)\n cs = cs[1..-1] # get strange first thing out of the way\n tr do \n td \"Conditions\"; td do\n ul do \n cs.each do |c|\n li c\n end\n end\n end\n end\n tr { td \"Explanation\"; td d.explanation }\n tr { td \"Format\"; td d.format }\n end\n end\n end\n end\n puts mab.to_s\nend", "def build_output(items, no_of_issues, v_name, r_date, n_branch, target)\n target = target\n\n output_filename = v_name + '_changelog_for_' + target + '.txt'\n out_file = File.new(output_filename, 'w')\n\n # Categories counter\n c_cnt = 0\n # Issues with category counter\n i_cnt = 0\n # Issues without category counter\n nc_i_cnt = 0\n\n if target == 'packaged_file'\n out_file << \"== #{r_date} v#{v_name}\\n\\n\"\n elsif target == 'website'\n out_file << \"h1. Changelog #{v_name}\\n\\n\" if n_branch == true\n out_file << \"h2. version:#{v_name} (#{r_date})\\n\\n\"\n end\n\n # Print the categories...\n items.each do |key, values|\n key = key.empty? ? '-none-' : key\n\n if target == 'packaged_file'\n out_file << \"=== [#{key}]\\n\"\n elsif target == 'website'\n out_file << \"h3. [#{key}]\\n\"\n end\n out_file << \"\\n\"\n (c_cnt += 1) unless key == '-none-'\n\n # ...and their associated issues\n values.each do |val|\n out_file << \"* #{val['tracker']} ##{val['id']}: #{val['subject']}\\n\"\n key == '-none-' ? (nc_i_cnt += 1) : (i_cnt += 1)\n end\n out_file << \"\\n\"\n end\n\n summary(v_name, target, i_cnt, nc_i_cnt, no_of_issues, c_cnt)\n\n out_file.close\n end", "def to_html\n m = Markaby::Builder.new({}, self)\n\n m.div do\n {\n :module => 'Module:', :description => 'Description:',\n :line_number => 'Line Number:', :submitted_by => 'Submitted By:',\n :owner => 'Owner:', :ticket => 'Ticket:',\n :resolved => 'Resolved:'\n }.each do |key, value|\n h5 value\n span self.send(key).to_s\n end\n end\n end", "def rebuildevent(e)\n if USEMEMCACHE != true\n static = Staticentry.find(e.staticentry.id)\n else\n static = Staticentry.get_cache(e.staticentry.id)\n end\n entries = e.payload.split('/111/')\n hash = Hash.new\n entries.each do |m|\n map = m.split('/000/')\n hash.store('<<<' + map[0] + '>>>',map[1])\n end\n p = static.data\n hash.each do |key, val|\n p = p.gsub(key,val)\n p = p.gsub(\"\\n\", \"<br/>\")\n end\n return p\n end", "def build_html(files)\n builder = Nokogiri::HTML::Builder.new do |doc|\n doc.html {\n doc.body {\n doc.table {\n build_table_header(doc)\n build_table_body(doc, files)\n }\n }\n }\n end\n\n builder.to_html\n end", "def main\n blog = File.read(FILE_PATH).gsub(/-----[\\r\\n|\\n|\\r]EXTENDED BODY:/, '<!-- more -->')\n articles = split_to_articles(blog)\n headers_and_bodies = split_to_headers_and_bodies(articles)\n\n headers_and_bodies.each do |header_and_body|\n header_and_body[:header] = convert_header(header_and_body[:header])\n header_and_body[:body] = ReverseMarkdown.convert header_and_body[:body]\n end\n\n create_md_file(headers_and_bodies)\nend", "def make_entry()\n\n seq_id = @filehandler.readline.chomp\n puts seq_id\n sequence = @filehandler.readline.chomp\n identifier = @filehandler.readline.chomp\n quality = @filehandler.readline.chomp\n\n Entry.new(seq_id, sequence, identifier, quality)\n end", "def build( special_contexts=[] )\r\n\r\n self.ehtmls, self.ecss, self.ejs = self.theme.original_page_layout_root.build_content(special_contexts)\r\n self.ehtml = self.ehtmls.first\r\n\r\n end", "def generate_html(individual_files: false, use_uuid: false)\n params = [individual_files, use_uuid]\n if @html && @html[params]\n return @html[params]\n end\n\n builder = Nokogiri::HTML::Builder.new(encoding: \"utf-8\") do |doc|\n doc.div {\n doc.h1 {\n doc.a(id: \"account_#{@primary_key}\") {\n doc.text @name\n }\n }\n\n if @user_record_name.length > 0\n doc.div {\n doc.b {\n doc.text \"Cloudkit Identifier:\"\n }\n\n doc.text \" \"\n doc.text @user_record_name\n }\n end\n\n doc.div {\n doc.b {\n doc.text \"Account Identifier:\"\n }\n\n doc.text \" \"\n doc.text @identifier\n }\n\n if @cloudkit_last_modified_device\n doc.div {\n doc.b {\n doc.text \"Last Modified Device:\"\n }\n\n doc.text \" \"\n doc.text @cloudkit_last_modified_device\n }\n end\n\n doc.div {\n doc.b {\n doc.text \"Number of Notes:\"\n }\n\n doc.text \" \"\n doc.text @notes.length\n }\n\n doc.div {\n doc.b {\n doc.text \"Folders:\"\n }\n\n doc.ul {\n sorted_folders.each do |folder|\n doc << folder.generate_folder_hierarchy_html(individual_files: individual_files, use_uuid: use_uuid) if !folder.is_child?\n end\n }\n }\n }\n end\n\n @html ||= {}\n @html[params] = builder.doc.root\n end", "def generate_html\n html_renderer = Carta::CLI::HTMLRenderer.new(@PROJECT_DIR)\n # puts @MANUSCRIPT_DIR\n book['html'] = html_renderer.manuscript_html\n book['outline'] = html_renderer.outline\n book['epub_toc_html'] = html_renderer.epub_toc_html\n book['html_toc_html'] = html_renderer.html_toc_html\n\n generate_epub_manifest\n end", "def create_HTML_file(loc_name, content, out_dir)\n File.open(\"#{out_dir}/#{loc_name}.html\", 'w') do |f|\n f.write(HEADER_TEXT)\n f.write(\"<h1>Lonely Planet: #{loc_name}</h1>\")\n f.write(NAV_TITLE)\n f.write($navigation_html)\n f.write(BLOCK_TITLE)\n f.write(\"<h1><li class='first'><a href='#'>#{loc_name}</a></li></h1>\")\n f.write(MAIN_BLOCK)\n f.write(content)\n f.write(CLOSE_HTML)\n end\nend", "def render!\n write_out('HTML', 'index.html', @html_template.render)\n write_out('feed', 'feed.xml', @feed_template.render)\n end", "def generate_entry(character, information)\n animated_file = \"svgs/\" + character.ord.to_s + \"_animated.svg\"\n\n return character + \"\\tA\\t\\t\\t\\t\\t\\t\\t\\t\\t\" + animated_file + \"\\t\" + information + \"\\thttps://en.wiktionary.org/wiki/\" + character\nend", "def build_text(dict_id,entry_data,key_lang,num)\n\t\tprimary_lang=primary_lang(dict_id)\n\t\tif primary_lang!=@src_lang and primary_lang!=\"\"\n\t\t\[email protected](true)\n\t\telse\n\t\t\[email protected](false)\n\t\tend\n\t\tif entry_data[\"#HTML\"]!=nil\n\t\t\t### this guy already has HTML text .. dont need to build\n\t\t\treturn @hili.hilite(entry_data[\"#HTML\"],is_html=true)\n\t\tend\n\t\tmulti_lingual= is_multilingual(dict_id)\n\n\t\ti = 1\n\t\thtml_txt = \"\"\n\n\t\t####### For tag TERM:LANG\n\t\tnum_text=\"\"\n\t\tif num != \"0\" \n\t\t\tnum_text=sprintf(\"<b>%s. </b>\",num)\n\t\tend\n\t\tentry_data.each{|tag,value|\n\t\t\tnext if tag[0,5]!=\"#TERM\"\n\t\t\tnext if tag[6,2]==primary_lang ## dont show key if it is in source language\n\t\t\thtml_txt << '<p class=\"dict_text\">'\n\t\t\tif num_text != \"\"\n\t\t\t\thtml_txt << num_text\n\t\t\t\tnum_text = \"\"\n\t\t\tend\n\t\t\thtml_txt << \"[\" + tag[6,2] + \"] \" if multi_lingual\n\t\t\thtml_txt << @hili.hilite(value) \n\t\t\thtml_txt << '</p>'\n\t\t}\n\t\t####### For tag EXPLAIN:LANG\n\t\tentry_data.each{|tag,value|\n\t\t\tnext if tag[0,8]!=\"#EXPLAIN\"\n\t\t\thtml_txt << '<p class=\"dict_text\">'\n\t\t\thtml_txt << \"[\" + tag[9,2] + \"] \" if multi_lingual\n\t\t\thtml_txt << @hili.hilite(value) \n\t\t\thtml_txt << '</p>'\n\t\t}\n\t\t####### For tag EXAMPLES:LANG\n\t\tentry_data.each{|tag,value|\n\t\t\tnext if tag[0,9]!=\"#EXAMPLES\"\n\t\t\thtml_txt << render_examples(value)\n\t\t}\n\t\treturn html_txt\n\tend", "def write_file\n\n File.open(\"rebuild.html\", \"w\") do |file|\n @write_array.each do |tags_and_text|\n file.write tags_and_text\n end\n end\n\n end", "def create_html_document(directory, filename, locale, deliverable_json = nil)\n version = Settings[:CURRENT_VERSION]\n \n # Why not let CouchDB create the ID? Because it actually affects performance.\n # Also, if we define the ID, then we can find the document without a view.\n id = \"#{Settings[:APP_NAME]}.#{filename}.#{locale}.#{version}\"\n \n # Create a Nokogiri document from the XML file on disk\n content_doc = Nokogiri::XML(open(\"#{directory}/#{filename}\")){|config| config.noent }\n content_doc.remove_namespaces!\n \n # Figure out the title for the document, pick it up from the\n # Dublin Core metadata, if available, otherwise grab it from the\n # title element.\n title=content_doc.xpath(\"/html/head/meta[@name = 'DC.Title']/@content\")\n title ||= content_doc.xpath('/html/head/title').inner_text().to_s\n title = title.to_s rescue nil\n \n # Add facets.\n # The rescue nil is there because if something happens, we're okay\n # with no value.\n app_area = content_doc.xpath(\"/html/head/meta[@name = 'app_area']/@content\").to_s rescue nil \n role = content_doc.xpath(\"/html/head/meta[@name = 'role']/@content\").to_s rescue nil\n edition = content_doc.xpath(\"/html/head/meta[@name = 'edition']/@content\").to_s rescue nil\n topic_type = content_doc.xpath(\"/html/head/meta[@name = 'topic_type']/@content\").to_s rescue nil\n technology = content_doc.xpath(\"/html/head/meta[@name = 'SFDC.Technology']/@content\").to_s rescue nil\n\n # Add deliverable title and other metadata\n deliverable_title = deliverable_json['title'] rescue nil\n deliverable_type = deliverable_json['type'] rescue nil\n deliverable_pdf_name = content_doc.xpath(\"/html/head/meta[@name = 'SFDC.RelatedPDF']/@content\").to_s rescue nil\n deliverable_pdf_url = content_doc.xpath(\"/html/head/meta[@name = 'SFDC.RelatedPDFURL']/@content\").to_s rescue nil\n deliverable_home = deliverable_json['default_topic'] rescue nil\n \n #scrub the table of data we don't need\n body_content = content_doc.xpath('/html/body/*')\n scrub_table(body_content)\n body_content = body_content.to_html\n \n\n # Create a document to add the searchable text. We have to create a\n # new document, we can't reuse content_doc. That's because nodesets\n # are queries of documents. In other words, if you do a\n # nodeset.xpath('//xpath').remove, it removes that xpath from all\n # nodesets created from a document, not just nodeset.\n search_doc = content_doc.dup\n \n # Remove items we don't want returned in the search snippet\n search_content=search_doc.xpath('/html/body')\n search_content.xpath('/html/body//table[contains(@class, \"permTable\") or contains(@class, \"editionTable\")]').remove\n search_content.xpath('/html/body//*[contains(@class, \"breadcrumb\")]').remove\n search_content.xpath('/html/body/h1[1]').remove\n \n # Encode the search_content, replacing unsafe codepoints. This allows search to find items like >\n coder = HTMLEntities.new\n search_content=coder.encode(search_content.children().inner_text()).strip\n \n #remove weird new line characters\n search_content = search_content.gsub(\"\\n\", ' ')\n search_content = HTMLEntities.new.decode(search_content)\n \n #doc fields to create, if needed\n newDoc = {\n '_id' => id,\n :name => filename,\n :locale => locale,\n :version => version,\n :title => title,\n :body_content => body_content,\n :app_area => app_area,\n :role => role,\n :edition => edition,\n :topic_type => topic_type,\n :technology => technology,\n :deliverable_title => deliverable_title,\n :deliverable_type => deliverable_type,\n :deliverable_pdf_name => deliverable_pdf_name,\n :deliverable_pdf_url => deliverable_pdf_url,\n :deliverable_home => deliverable_home,\n :search_content => search_content}\n \n #This content hash accounts for changes necessary from the deliverable metadata as well as changes to the xml document in general\n newDoc[:content_hash] = generateCheckSum(newDoc.inspect)\n \n #Dynamic content added after the hash\n newDoc[:updated] = Time.now.to_date.iso8601\n \n #upsert the document\n upsert_doc_via_checksum(@db, newDoc, [:locale, :version], @id_checksum_hash[id], @log)\n \n return id\n end", "def generate_item_metadata(format, cgi, item_entry)\n item_metadata = \"\"\n \n case format.downcase\n when \"html\"\n item_metadata += cgi.div(\"class\" => \"item_metadata\") do\n \"Added to pack by: \" + uploader_string(\"user\", item_entry.user_id, true, false) + \" (#{item_entry.created_at.strftime('%d/%m/%Y @ %H:%M:%S')})<br/>\" +\n item_comment_string(item_entry, true)\n end\n when \"text\"\n item_metadata += \" | Added to pack by: \" + uploader_string(\"user\", item_entry.user_id, false, false) + \"; added on (#{item_entry.created_at.strftime('%d/%m/%Y @ %H:%M:%S')})\\n\"\n item_metadata += \" | \" + item_comment_string(item_entry, false) + \"\\n\\n\"\n else\n return \"ERROR\" \n end\n \n return item_metadata\n end", "def generateReleaseNote_HTML\r\n rSuccess = true\r\n\r\n logOp('Generating release note in HTML format') do\r\n lLastChangesLines = []\r\n getLastChangeLog.each do |iLine|\r\n lLastChangesLines << iLine.\r\n gsub(/\\n/,\"<br/>\\n\").\r\n gsub(/^=== (.*)$/, '<h3>\\1</h3>').\r\n gsub(/^\\* (.*)$/, '<li>\\1</li>').\r\n gsub(/Bug correction/, '<span class=\"Bug\">Bug correction</span>')\r\n end\r\n lStrWhatsNew = ''\r\n if (@ReleaseComment != nil)\r\n lStrWhatsNew = \"\r\n<h2>What's new in this release</h2>\r\n#{@ReleaseComment.gsub(/\\n/,\"<br/>\\n\")}\r\n \"\r\n end\r\n File.open(\"#{@DocDir}/ReleaseNote.html\", 'w') do |oFile|\r\n oFile << \"\r\n<html>\r\n <head>\r\n <link rel=\\\"shortcut icon\\\" href=\\\"#{@ReleaseInfo.project_info[:favicon_url]}%>\\\" />\r\n <style type=\\\"text/css\\\">\r\n body {\r\n background: #fdfdfd;\r\n font: 14px \\\"Helvetica Neue\\\", Helvetica, Tahoma, sans-serif;\r\n }\r\n img {\r\n border: none;\r\n }\r\n h1 {\r\n text-shadow: rgba(135,145,135,0.65) 2px 2px 3px;\r\n color: #6C8C22;\r\n }\r\n h2 {\r\n padding: 2px 8px;\r\n background: #ccc;\r\n color: #666;\r\n -moz-border-radius-topleft: 4px;\r\n -moz-border-radius-topright: 4px;\r\n -webkit-border-top-left-radius: 4px;\r\n -webkit-border-top-right-radius: 4px;\r\n border-bottom: 1px solid #aaa;\r\n }\r\n h3 {\r\n padding: 2px 32px;\r\n background: #ddd;\r\n color: #666;\r\n -moz-border-radius-topleft: 4px;\r\n -moz-border-radius-topright: 4px;\r\n -webkit-border-top-left-radius: 4px;\r\n -webkit-border-top-right-radius: 4px;\r\n border-bottom: 1px solid #aaa;\r\n }\r\n .Bug {\r\n color: red;\r\n font-weight: bold;\r\n }\r\n .Important {\r\n color: #633;\r\n font-weight: bold;\r\n }\r\n ul {\r\n line-height: 160%;\r\n }\r\n li {\r\n padding-left: 20px;\r\n }\r\n </style>\r\n </head>\r\n <body>\r\n <a href=\\\"#{@ReleaseInfo.project_info[:web_page_url]}\\\"><img src=\\\"#{@ReleaseInfo.project_info[:image_url]}\\\" align=\\\"right\\\" width=\\\"100px\\\"/></a>\r\n <h1>Release Note for #{@ReleaseInfo.project_info[:name]} - v. #{@ReleaseVersion}</h1>\r\n <h2>Development status: <span class=\\\"Important\\\">#{@ReleaseInfo.project_info[:dev_status]}</span></h2>\r\n#{lStrWhatsNew}\r\n <h2>Detailed changes with previous version</h2>\r\n#{lLastChangesLines.join}\r\n <h2>Useful links</h2>\r\n <ul>\r\n <li><a href=\\\"#{@ReleaseInfo.project_info[:web_page_url]}\\\">Project web site</a></li>\r\n <li><a href=\\\"https://sourceforge.net/projects/#{@ReleaseInfo.sf_info[:project_unix_name]}/files/#{@ReleaseVersion}/#{@GemName}/download\\\">Download</a></li>\r\n <li>Author: <a href=\\\"#{@ReleaseInfo.author_info[:web_page_url]}\\\">#{@ReleaseInfo.author_info[:name]}</a> (<a href=\\\"mailto://#{@ReleaseInfo.author_info[:email]}\\\">Contact</a>)</li>\r\n <li><a href=\\\"#{@ReleaseInfo.project_info[:web_page_url]}rdoc/#{@ReleaseVersion}\\\">Browse RDoc</a></li>\r\n <li><a href=\\\"#{@ReleaseInfo.project_info[:browse_source_url]}\\\">Browse source</a></li>\r\n <li><a href=\\\"#{@ReleaseInfo.project_info[:browse_source_url]}ChangeLog?view=markup\\\">View complete ChangeLog</a></li>\r\n <li><a href=\\\"#{@ReleaseInfo.project_info[:browse_source_url]}README?view=markup\\\">View README file</a></li>\r\n </ul>\r\n </body>\r\n</html>\r\n\"\r\n end\r\n end\r\n\r\n return rSuccess\r\n end", "def generate_html(individual_files=false)\n return self.to_s\n end", "def generate_html(individual_files=false)\n return self.to_s\n end", "def create_display_template_file(directory)\n html = %{<!-- Template File -->\\n\n<div class=\"myWidget\">Hello World</div>}\n\n File.open(directory, \"w\") do |f|\n f.write(html)\n end\n end", "def generate_HTML(loc_hier, out_dir)\n loc_hier.each do |loc|\n id = loc[:id]\n loc_name = loc[:location]\n\n generate_HTML(loc[:sub_loc], out_dir) unless loc[:sub_loc].empty?\n\n loc_content = $destinations.elements[\"destination[@atlas_id='#{id}']\"]\n content = ''\n\n loc_content.elements.each do |el|\n content += '<p>'\n section_title = el.elements[1].name.split('_').each(&:capitalize!).join(' ')\n content += \"<h2>#{section_title}</h2>\"\n content += '<p>'\n content_string = el.elements[1].elements[1].cdatas[0].to_s\n content += content_string.gsub(\"\\n\\n\\n\", '<br><p>').gsub(\"\\n\\n\", '<p>').gsub(\"\\n\", '<br>')\n content += '<p>'\n end\n create_HTML_file(loc_name, content, out_dir)\n end\nend", "def build(ostream = nil)\n if File.exists? root(:output)\n raise Errno::EEXISTS unless File.directory? root(:output)\n else\n Dir.mkdir root(:output)\n end\n\n begin\n all.each do |page|\n ostream << \" * #{page.output_path}\\n\" if ostream\n\n begin\n rendered = page.render\n force_file_open(page.output_path) { |file| file << rendered }\n\n rescue RenderError => e\n ostream << \" *** Error: #{e.to_s}\".gsub(\"\\n\", \"\\n *** \") << \"\\n\"\n end\n end\n\n rescue NoGemError => e\n ostream << \" *** Error: #{e.message}\\n\"\n end\n end", "def write_page\n contents = [people,projects,events].inject({}) { |x,y| x.merge(y) }\n File.open('index.html','w') do |f|\n f.write(@template.render(contents))\n end\n end", "def get_entry(entry); end", "def build_index\n\n\t\t# Names the file based on date and time for uniqueness and ability to find which one you want later\n\t\tt = Time.now\n\t\t@file_time = t.strftime(\"%Y.%b.%d_%H.%M.%S\")\n\t\t@filename = \"quilt_pages/#{@needed_rows}x#{@needed_columns}_#{@file_time}.html\"\n\n\t\t# Store the quilt page template in a variable\n\t\tquilt_template = File.read \"templates/quilt_template.erb\"\n\t\t# Start a new ERB\n\t\terb_template = ERB.new quilt_template\n\t\t# Pull it all together and put info into one variable\n\t\tquilt_page = erb_template.result(binding)\n\n\t\t# Makes the directory for the quilt pages if there isn't one\n\t\tDir.mkdir(\"quilt_pages\") unless Dir.exists? \"quilt_pages\"\n\n\t\t# Opens the file and saves (actually writes) the quilt info\n\t\tFile.open(@filename, 'w') do |file|\n\t\t\tfile.puts quilt_page\n\t\tend\n\n\t\tsystem(\"open #{@filename}\")\n\tend", "def build_post_from_entry(entry, action)\n date = if (action == Service::SERVICE_ACTION_POST) || (self.posts.count == 0)\n entry[:pubDate]\n else\n Time.current\n end\n\n self.posts.build(\n :summary => (entry[:description].blank? ? '-' : entry[:description]),\n :service_action => action,\n :identifier => entry[:guid].to_s,\n :title => entry[:title],\n :markup => Post::PLAIN_MARKUP,\n :url => entry[:link],\n :published_at => date,\n :extra_content => {\n :author_name => entry[:author_name],\n :original_tags => entry[:categories] # array de tags\n }\n )\n end", "def initialize(settings, wildcat_file)\n @settings = settings\n @source_path = wildcat_file.path\n @source_text = wildcat_file.text\n @destination_path, @permalink, @relative_path = WildcatUtils.paths(@source_path, @settings.posts_folder, @settings.blog_output_folder, @settings.site_url, @settings.output_file_suffix)\n @attributes = wildcat_file.attributes\n @external_url = @attributes[LINK_KEY]\n @title = @attributes[TITLE_KEY]\n\n @content_html = wildcat_file.to_html\n if !@content_html.start_with?('<p>')\n \t@content_html = '<p>' + content_html\n end\n\n @pub_date = @attributes[PUB_DATE_KEY]\n @mod_date = @attributes[MOD_DATE_KEY]\n @rendered_html_including_link = nil\n @rendered_html = nil\n\n enclosure_url = @attributes[ENCLOSURE_URL_KEY]\n if !enclosure_url.nil? && !enclosure_url.empty?\n @enclosure = Enclosure.new(@attributes)\n else\n @enclosure = nil\n end\n\n @itunes_duration = @attributes[ITUNES_DURATION_KEY]\n @itunes_subtitle = @attributes[ITUNES_SUBTITLE_KEY]\n @itunes_summary = @attributes[ITUNES_SUMMARY_KEY]\n @itunes_explicit = @attributes[ITUNES_EXPLICIT_KEY]\n @media_thumbnail = @attributes[MEDIA_THUMBNAIL_KEY]\n\n end", "def firstHTMLEdit(file, logkey='')\n\tfilecontents = File.read(file)\n\n\thascreator = filecontents.match(/meta name=\"author\"/)\n\thaspublisher = filecontents.match(/meta name=\"publisher\"/)\n\n\tif hascreator.nil?\n\t\tfilecontents = filecontents.gsub(/<\\/head>/,\"<meta name='author' content=\\\"#{Metadata.bookauthor}\\\" /></head>\")\n\tend\n\n\tif haspublisher.nil?\n\t\tfilecontents = filecontents.gsub(/<\\/head>/,\"<meta name='publisher' content=\\\"#{Metadata.imprint}\\\" /></head>\")\n\tend\n\n\tfilecontents = filecontents.gsub(/<\\/head>/,\"<meta name='isbn-13' content='#{Metadata.eisbn}' /></head>\")\n\t\t\t\t\t\t\t\t \t\t\t\t\t\t\t.gsub(/&nbsp;/,\"&#160;\")\n\t\t\t\t\t\t\t\t \t\t\t\t\t\t\t.gsub(/src=\"images\\//,\"src=\\\"\")\n\treturn filecontents\nrescue => logstring\n\treturn ''\nensure\n\tMcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend", "def buid_web_page(info_hash)\n File.open('rover_index.html','w') do |file|\n \n file.puts \" <!doctype html>\n <html lang='es'>\n <head>\n <!-- Required meta tags -->\n <meta charset='utf-8'>\n <meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'> \n <title>Prueba nasa</title>\n </head> \n <body>\n <div class='container parrafo'>\n <div class='row'>\n <div class='col span='2' style='background-color:coral'> \n <ul>\" \n \n info_hash['photos'].each do |photo,id| \n file.puts \"<h1>'#{photo[\"camera\"][\"full_name\"]}'</h1>\"\n file.puts \"<li><img src='#{photo[\"img_src\"]}'width='150px'></li>\"\n file.puts \"<p>'#{photo[\"id\"]}'</p>\"\n end\n \n file.puts \"</ul>\n </div> \n </div>\n </div>\n </body>\n </html> \"\n end \nend", "def template(event={})\r\n content = <<EOF\r\n<?xml version=\"1.0\"?>\r\n<entry xmlns='http://www.w3.org/2005/Atom'\r\n xmlns:gd='http://schemas.google.com/g/2005'>\r\n <category scheme='http://schemas.google.com/g/2005#kind'\r\n term='http://schemas.google.com/g/2005#event'></category>\r\n <title type='text'>#{event[:title]}</title>\r\n <content type='text'>#{event[:content]}</content>\r\n <author>\r\n <name>#{event[:author]}</name>\r\n <email>#{event[:email]}</email>\r\n </author>\r\n <gd:transparency\r\n value='http://schemas.google.com/g/2005#event.opaque'>\r\n </gd:transparency>\r\n <gd:eventStatus\r\n value='http://schemas.google.com/g/2005#event.confirmed'>\r\n </gd:eventStatus>\r\n <gd:where valueString='#{event[:where]}'></gd:where>\r\n <gd:when startTime='#{event[:startTime]}' endTime='#{event[:endTime]}'>\r\n #{event[:reminders]}\r\n </gd:when>\r\n</entry>\r\nEOF\r\n end", "def generate_contents\n template_file = @template_dir + 'contents.hhc.rhtml'\n\n out_file = @outputdir + \"contents.hhc\"\n debug_msg \" rendering #{out_file}\"\n render_template template_file, out_file do |io| binding end\n end", "def html_from_template(filename, title, html)\n\t\tlevels = filename.count(\"/\") - 1\n\t\tcss_link = \"./\" + (\"../\" * levels) + \"css/style.css\"\n @template.result(:title => title, :css_link => css_link, :content => html)\n\tend", "def run\n print_line\n print_status 'Creating HTML report...'\n\n plugins = format_plugin_results( auditstore.plugins )\n @base_path = File.dirname( options['tpl'] ) + '/' +\n File.basename( options['tpl'], '.erb' ) + '/'\n\n title_url = auditstore.options['url']\n begin\n title_url = uri_parse( auditstore.options['url'] ).host\n rescue\n end\n\n params = prepare_data.merge(\n title_url: escapeHTML( title_url ),\n audit_store: auditstore,\n plugins: plugins,\n base_path: @base_path\n )\n\n File.open( outfile, 'w' ) { |f| f.write( erb( options['tpl'], params ) ) }\n\n print_status \"Saved in '#{outfile}'.\"\n end", "def build_html\r\n html = <<EOF\r\n<!DOCTYPE html>\r\n<html>\r\n <head>\r\n <meta http-equiv='content-type' content='text/html; charset=UTF-8'>\r\n <title>Lonely Planet</title>\r\n <link href='static/all.css' media='screen' rel='stylesheet' type='text/css'>\r\n </head>\r\n\r\n <body>\r\n <div id='container'>\r\n <div id='header'>\r\n <div id='logo'></div>\r\n <h1>Lonely Planet: #{destination.the_name}</h1>\r\n </div>\r\n\r\n <div id='wrapper'>\r\n <div id='sidebar'>\r\n <div class='block'>\r\n <h3>Navigation</h3>\r\n <div class='content'>\r\n <div class='inner'>\r\n <p>\r\n #{html_format(destination.the_top_hashs, ' >> ')}\r\n #{!destination.the_top_hashs.empty? ? \">>\" : ''}\r\n #{destination.the_name}\r\n </p>\r\n <p>\r\n #{html_format(destination.the_below_hashs, ' ')}\r\n </p>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div id='main'>\r\n <div class='block'>\r\n <div class='secondary-navigation'>\r\n <ul>\r\n <li class='first'><a href='#'>#{destination.the_name}</a></li>\r\n </ul>\r\n <div class='clear'></div>\r\n </div>\r\n <div class='content'>\r\n <div class='inner'>\r\n \t\t Introduction\r\n \t\t <p>\r\n \t\t#{destination.intro}\r\n \t </p>\r\n \t\tHistory Overview\r\n <p>\r\n #{destination.history_overview}\r\n \t\t </p>\r\n <p>\r\n #{destination.history}\r\n </p>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </body>\r\n</html>\r\nEOF\r\n html\r\n end", "def build()\n HP.logger.debug(\"~ Build Mode: #{build_mode}\")\n HP.logger.debug(\"~ Source Root: #{source_root}\")\n HP.logger.debug(\"~ Build Root: #{build_root}\")\n build_entries(entries())\n end", "def build_node(file)\n parent = parent_folder(file)\n category = parent == \".\" ? to_symbol(@directory) : to_symbol(parent)\n basename = basename(file)\n title = basename_to_title(basename)\n html = Renderer.new.render_internal(file)\n\n { title: title,\n basename: basename,\n path: File.realpath(file),\n category: category,\n html: html }\n end", "def generate(options = {})\n embed_outline(options[:selflink]) if options[:outline]\n\n #if options[:dirmap]\n # md_dir = Pathname.new(@md_file).dirname.expand_path\n # embed_sidebar( Madowu::DirectoryMapper.dirmap(md_dir) )\n #end\n\n if options[:sidebar]\n #lines = File.open( options[:sidebar], \"r\").readlines\n lines = `#{@markdown} #{options[:sidebar]}`.split(\"\\n\")\n embed_sidebar(lines)\n end\n\n result = [\n make_header(options[:css], options[:charset]),\n @markup_lines,\n \"</div></div></body></html>\",\n ''\n ].join(\"\\n\")\n end", "def build #title, form_name, form_action, script='', append_body='')\n \n @disable = []\n \n xhtml = %Q{ \n <html> \n <head>\n <title>#{self.meta['title']}</title>\n }\n if self.meta['stylesheets']\n self.meta['stylesheets'].each { |css|\n xhtml += %Q{ <link type=\"text/css\" src=\"#{css}\" /> \\n }\n }\n end\n if self.meta['javascripts']\n self.meta['javascripts'].each { |js|\n xhtml += %Q{ <script langauge=\"javascript\" src=\"#{jc}\" /> \\n }\n }\n end\n #xhtml += %Q{\n # <style type=\"text/css\">\n # #{build_css(self.style)}\n # </style>\n #}\n xhtml += %Q{ </head> }\n xhtml += %Q{\n <body onload=\"javascript: loadScript();\">\n #{self.meta['prepend']}\n #{self.main.build}\n #{self.meta['append']}\n </body>\n </html>\n }\n return CGI::pretty(xhtml)\n #return PrettyXML.pretty(html, 2)\n end", "def setup\n @html = <<-TEXTILE\n<h1>Give RedCloth a try!</h1>\n<p>A <strong>simple</strong> paragraph with<br />\na line break, some <em>emphasis</em> and a <a href=\"http://redcloth.org\">link</a></p>\n<ul>\n\t<li>an item</li>\n\t<li>and another</li>\n</ul>\n<ol>\n\t<li>one</li>\n\t<li>two</li>\n</ol>\nTEXTILE\n \n end", "def process_oldstyle_html contents\n\tdoc = Nokogiri::HTML(contents)\n\n\t# the HIB page keeps each entry in a div with class 'row'\n\t# plus a name based on the game name.\n\tdoc.css('div.row').each do |div|\n\t\tname = div['class'].sub(/\\s*row\\s*/,'')\n\t\troot = get_root name\n\t\tdiv.css('.downloads').each do |dd|\n\t\t\ttype = dd['class'].gsub(/\\s*(downloads|show)\\s*/,'')\n\t\t\tdd.css('.download').each do |dl|\n\t\t\t\taa = dl.css('a.a').first\n\t\t\t\tlink = aa['href']\n\t\t\t\tbtlink = aa['data-bt']\n\t\t\t\tif btlink.empty?\n\t\t\t\t\tbtlink = nil\n\t\t\t\tend\n\t\t\t\tmd5 = dl.css('a.dlmd5').first['href'].sub(/^#/,'') rescue nil\n\t\t\t\tts = dl.css('a.dldate').first['data-timestamp'] rescue nil\n\t\t\t\tsavepath = File.join(root, type)\n\n\t\t\t\tdl = true\n\n\t\t\t\tif link[-1] == '/'\n\t\t\t\t\tSTDERR.puts \"# No automatic downloads for #{savepath}, go to #{link}\"\n\t\t\t\t\tdl = false\n\t\t\t\tend\n\n\t\t\t\t$dirs << savepath\n\t\t\t\tif dl\n\t\t\t\t\tfname = get_filename link\n\t\t\t\t\tfkey = fname.intern\n\t\t\t\t\t$files[fkey] << Game.new(fname, md5, savepath, link, btlink)#, ts)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend", "def to_textile\n \n \n headings(@workingcopy)\n structure(@workingcopy)\n text_formatting(@workingcopy)\n entities(@workingcopy)\n tables(@workingcopy)\n @workingcopy = CGI::unescapeHTML(@workingcopy)\n @workingcopy\n \n end", "def create_filename(newpost)\n File.readlines(newpost).each do |line|\n tidytitle = ''\n # Extract title from the h2 line, and create tidytitle and filename\n if line =~ />\\w.*h2/\n # $& returns exact match, not entire line. Strip the tags surroundging the title.\n @title = $&.sub('>','').sub('</a></h2','') \n # Remove illegaal characters from title\n tidytitle = @title.downcase.gsub(/(#|%|&|\\*|<|>|\\{|\\}|\\\\|:|;|,|<|>|\\?|\\/|\\+|'|!|\\.)/,'').gsub(/ /,'-').gsub(/-+/,'-') + '.html'\n # Create filename preceded with datestamp\n @filename = @filedate + '-' + tidytitle\n break\n end\n end\nend", "def format_content(filename)\n # Remove outdated content files.\n if File.exist?(\"#{@content_dir}/formatted/#{filename}\")\n FileUtils.rm \"#{@content_dir}/formatted/#{filename}\", :force => true\n end\n\n buffer = []\n File.new(\"#{@content_dir}/#{filename}\", 'r').each { |line| buffer << line }\n\n # Create the formatted content directory if it doesn't exist\n unless File.exist?(\"#{@content_dir}/formatted\")\n FileUtils.mkdir_p \"#{@content_dir}/formatted\"\n end\n\n out_file = File.new(\"#{@content_dir}/formatted/#{filename}\", 'w', 0644)\n buffer.each do |row|\n if (/monster\\.com\\/unsub/ =~ row)\n row.gsub!(\"monster.com/unsub\",'monster.com/unsub?eml=#{hash}')\n elsif\n if ((/redlog\\.cgi/ =~ row) || (/outlog\\.cgi/ =~ row))\n if (/ESRC[^\">]*code/ =~ row)\n row.gsub!(/(ESRC[^\">]*)(code[^\"'>]*)([\"|'|>])/, '\\1\\2&eml=#{hash}\\3')\n elsif (/url[^\">]*code/ =~ row)\n row.gsub!(/(url[^\">]*)(code[^\"'>]*)([\"|'|>])/, '\\1\\2&eml=#{hash}\\3')\n end\n end\n end\n out_file.puts row\n end\n out_file.close\nend", "def process_html(document)\n\t\t\t\n\t\t\t# Add link and raw HTML to a hash as key/value\n\t\t\t# for later storage in database\n\t\t\tunless @raw_html.has_value?(document)\n\t\t \t\tprint \".\"\n\t\t \t\t@raw_html[@document.base_uri.to_s] = document\n\t\t\tend\n\t\t\t\t\n\t\tend", "def feed_list_html(env)\n\tpage = \"\"\n\tpage << '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\t\t<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n\t\t\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n\t\t<html xmlns=\"http://www.w3.org/1999/xhtml\"\n\t\t xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xsi:schemaLocation=\"http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd\"\n\t\t xml:lang=\"en\" >\n\t\t\t<head>\n\t\t\t\t<title>WoC scrapped feed list for '+CONFIG[\"host\"].to_s+'</title>\n\t\t\t</head>\n\t\t\t<body>'\n\t\t\tpage << '<dl>'\n\t\t\tfor year in CONFIG[\"years\"] do\n\t\t\t\tpage << \"<dt>#{year[0]}:</dt>\"\n\t\t\t\tpage << '<dd>'\n\t\t\t\tpage << '<dl>'\n\t\t\t\tfor course in CONFIG[\"courses\"] do\n\t\t\t\t\tpage << \"<dt>#{CONFIG[\"course_names\"][course[1]]}</dt>\"\n\t\t\t\t\tpage << \"<dd>\"\n\t\t\t\t\tpage << \"<a href=\\\"http://#{env[\"HTTP_HOST\"]}/#{year[0]}/#{course[0]}/rss.xml\\\">http://#{env[\"HTTP_HOST\"]}/#{year[0]}/#{course[0]}/rss.xml</a>\"\n\t\t\t\t\tpage << \"</dd>\"\n\t\t\t\tend\n\t\t\t\tpage << '</dl>'\n\t\t\t\tpage << '</dd>'\n\t\t\tend\n\t\t\tpage << '</dl>'\n\t\tpage << \t\t\n\t\t\t'</body>\n\t\t</html>'\n\t\treturn page\nend", "def html\n File.read(@folder + \"/data/#{@what}.html\")\n end", "def print_entry(entry)\n\n # Identify method entry\n debug_print \"#{ self } : #{ __method__ }\\n\"\n\n # If no issues for this file, print that and break\n # The filename print is repetative, but reduces another check later\n if !entry[:has_issues]\n if @config.show_type != 'dirty'\n debug_print \"No issues for #{ entry }\\n\"\n print_status \"o\", GREEN\n cprint BOLD + UNDERLINE + GREEN + \"#{ entry[:relative_path] }\" + RESET + \"\\n\"\n return true\n end\n else\n if @config.show_type != 'clean'\n debug_print \"Issues found for #{ entry }\\n\"\n cprint \"\\n\"\n print_status \"x\", RED\n cprint BOLD + UNDERLINE + RED + \"#{entry[:relative_path]}\" + RESET + \"\\n\"\n else\n return true\n end\n end\n\n\n # [review] - Should the tag structure be self contained in the hash\n # Or is it ok to reference @config to figure out the tags\n @config.tag_list.each do | _tag |\n debug_print \"Checking for #{ _tag }\\n\"\n\n # [review] - Better way to ignore tags through structure (hash) data\n # Maybe have individual has_issues for each one?\n if entry[_tag].size.zero?\n debug_print \"#{ _tag } has no issues, skipping\\n\"\n next\n end\n\n debug_print \"#{ _tag } has issues in it, print!\\n\"\n print_status \"#{ _tag }\", BLUE\n cprint \"\\n\"\n\n # Go through each issue in tag\n entry[_tag].each do | _issue |\n cprint WHITE + \" line #{ _issue[:line_number] } - \" + RESET\n cprint BOLD + \"#{ _issue[:title] }\" + RESET\n\n\n # Check to see if it has been resolved on GitHub/Bitbucket\n debug_print \"Checking if issue has been resolved\\n\"\n @config.github_issues[:closed].each do | _closed |\n if _closed[\"body\"].include?(_issue[:md5])\n debug_print \"Found in #{ _closed[:comment] }, not posting\\n\"\n cprint BOLD + \" [\" + RESET\n cprint GREEN + BOLD + \"Resolved on GitHub\" + RESET\n cprint BOLD + \"]\" + RESET\n end\n debug_print \"Did not find in #{ _closed[:comment] }\\n\"\n end\n\n debug_print \"Checking if issue has been resolved\\n\"\n @config.bitbucket_issues[:closed].each do | _closed |\n if _closed[\"content\"].include?(_issue[:md5])\n debug_print \"Found in #{ _closed[\"content\"] }, not posting\\n\"\n cprint BOLD + \" [\" + RESET\n cprint GREEN + BOLD + \"Resolved on Bitbucket\" + RESET\n cprint BOLD + \"]\\n\" + RESET\n end\n debug_print \"Did not find in #{ _closed[\"title\"] }\\n\"\n end\n cprint \"\\n\"\n\n end\n cprint \"\\n\"\n end\n end", "def generate_html()\n html = \"\"\n \n puts \"Generating HTML ...\"\n \n s3 = RightAws::S3.new(S3_ID, S3_KEY)\n bucket = s3.bucket(S3_BUCKET)\n \n thumb = ''\n original = ''\n large = ''\n bucket.keys.each do |key|\n if key.full_name.include?(IMG_DIR)\n if key.full_name.include?(IMG_THUMB)\n thumb = S3_PUBLIC + key.full_name \n elsif key.full_name.include?(IMG_FINAL)\n large = S3_PUBLIC + key.full_name\n else\n original = S3_PUBLIC + key.full_name\n end \n \n if thumb != '' && large != '' && original != ''\n html += HTML_ITEM_PREFIX \n html += '<img class=\"thumbnail\" src=\"' + thumb + '\" rev=\"' + original + '\" rel=\"' + large + '\" />' \n html += HTML_TOGGLE + HTML_ITEM_SUFFIX \n thumb = ''\n original = ''\n large = '' \n end\n end\n end\n \n File.open(HTML_FILE, 'a') { |f| f.write(html) } \nend", "def html\n if FUNCTION != 'none'\n if self.md.value != nil\n hm = self.md.value\n else\n hm = INDEX\n end\n @me = YAML.load(self.yaml.value)\n [\n ERB.new(HEAD).result(binding),\n Kramdown::Document.new(ERB.new(hm).result(binding)).to_html,\n \"</body></html>\"\n ].flatten.join('')\n end\n end", "def generate_template(datestamp, entrytext, starred, uuid)\n ERB.new <<-XMLTEMPLATE\n <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n <plist version=\"1.0\">\n <dict>\n <key>Creation Date</key>\n <date><%= datestamp %></date>\n <key>Entry Text</key>\n <string><%= entrytext %></string>\n <key>Starred</key>\n <<%= starred %>/>\n <key>Tags</key>\n <array>\n <string>daily logs</string>\n </array>\n <key>UUID</key>\n <string><%= uuid %></string>\n </dict>\n </plist>\n XMLTEMPLATE\n end", "def generate_html(filesystems, packages, users)\n service_status = are_services_running([\"ssh\", \"nfs\", \"http\"])\n\n html_content =\n \"\"\"\n <html><head><title>Linux box info</title></head>\n <body><table>\n <tr>\n <th>Logical Volume</th>\n <th>Mount Point</th>\n <th>Size</th>\n <th>Free</th>\n <th>FS Type</th>\n </tr>#{concatenate_html(filesystems)}\n\n <tr>\n <th>Name</th>\n <th>Version</th>\n <th>Release</th>\n <th>Architecture</th>\n <th>Description</th>\n </tr>#{concatenate_html(packages)}\n\n <tr>\n <th>Username</th>\n <th>Sudo</th>\n <th>Password expiration</th>\n </tr>#{concatenate_html(users)}\n\n <tr>\n <th>Service status</th>\n </tr>#{service_status}\n </table></body>\n </html>\n \"\"\"\n\n File.open(RESULT_FILE, 'w') { |file| file.write(html_content)}\nend", "def create_html(options)\n if(options[:html_template] && options[:html_template] == :scientific) then\n\n if(options[:language] && options[:language] == :english) then\n html = '<h2>Academic Interests<\\/h2>\\r\\n' +\n '<p>Add information about academic fields of interest.<\\/p>\\r\\n' +\n '<h2>Teaching<\\/h2>\\r\\n' +\n '<ul>\\r\\n' +\n ' <li>&lt;Link to programme of study/course&gt;<\\/li>\\r\\n' +\n ' <li>&lt;Link to programme of study/course&gt;<\\/li>\\r\\n' +\n ' <li>...<\\/li>\\r\\n' +\n '<\\/ul>\\r\\n' +\n '<h2>Higher education and employment history<\\/h2>\\r\\n' +\n '<p>Brief introduction to previous education and employment.<\\/p>\\r\\n' +\n '<h2>Honoraria<\\/h2>\\r\\n' +\n '<ul>\\r\\n' +\n ' <li>&lt;Name of prize and (if applicable) link 1&gt;<\\/li>\\r\\n' +\n ' <li>&lt;Name of prize and (if applicable) link 2&gt;<\\/li>\\r\\n' +\n ' <li>...<\\/li>\\r\\n' +\n '<\\/ul>\\r\\n' +\n '<h2>Appointments<\\/h2>\\r\\n' +\n '<ul>\\r\\n' +\n ' <li>&lt;Title and (if applicable) link 1&gt;<\\/li>\\r\\n' +\n ' <li>&lt;Title and (if applicable) link 2&gt;<\\/li>\\r\\n' +\n ' <li>...<\\/li>\\r\\n' +\n '<\\/ul>\\r\\n' +\n '<h2>Cooperation<\\/h2>\\r\\n' +\n '<p>&nbsp;<\\/p>'\n else\n html = '<h2>Faglige interesser<\\/h2>\\r\\n' +\n '<p>Her kan du skrive om faglige interesser.<\\/p>\\r\\n' +\n '<h2>Undervisning<\\/h2>\\r\\n<p>' +\n '&lt;Lenke til studieprogram/emne&gt; <br />\\r\\n' +\n '&lt;Lenke til studieprogram/emne&gt; <br />\\r\\n...<\\/p>\\r\\n' +\n '<h2>Bakgrunn<\\/h2>\\r\\n' +\n '<p>Kort om tidligere arbeidserfaring og utdanning<\\/p>\\r\\n' +\n '<h2>Priser<\\/h2>\\r\\n' +\n '<p>&lt;Navn og eventuelt lenke til pris 1&gt; <br />\\r\\n' +\n '&lt;Navn og eventuelt lenke til pris 2&gt; <br />\\r\\n' +\n '...<\\/p>\\r\\n' +\n '<h2>Verv<\\/h2>\\r\\n<p>' +\n '&lt;Navn og eventuelt lenke til verv 1&gt; <br />\\r\\n' +\n '&lt;Navn og eventuelt lenke til verv 2&gt; <br />\\r\\n...' +\n '<\\/p>\\r\\n' +\n '<h2>Samarbeid<\\/h2>\\r\\n' +\n '<p>&nbsp;<\\/p>'\n end\n else\n\n if(options[:language] && options[:language] == :english) then\n html = '<h2>Tasks performed<\\/h2>\\r\\n' +\n '<p>Add information about job duties, as a short text or a bulleted list:<\\/p>' +\n '\\r\\n<ul>\\r\\n' +\n ' <li>&lt;Task 1&gt;<\\/li>\\r\\n' +\n ' <li>&lt;Task 1&gt;<\\/li>\\r\\n' +\n ' <li>...<\\/li>\\r\\n' +\n '<\\/ul>\\r\\n' +\n '<h2>Background<\\/h2>\\r\\n' +\n '<p>Add information about previous education and employment.<\\/p>'\n else\n html = '<h2>Arbeidsomr&aring;der<\\/h2>\\r\\n' +\n '<p>Her kan du skrive om arbeidsomr&aring;der, ' +\n 'enten som kort tekst eller som listepunkter:</p>' +\n '\\r\\n' +\n '<ul>\\r\\n' +\n ' <li>&lt;Arbeidsomr&aring;de 1&gt;</li>\\r\\n' +\n ' <li>&lt;Arbeidsomr&aring;de 1&gt;</li>\\r\\n' +\n ' <li>...</li>\\r\\n' +\n '</ul>' +\n '\\r\\n' +\n '<h2>Bakgrunn</h2>\\r\\n' +\n '<p>Eventuelt kort om tidligere arbeidserfaring og utdanning.</p>'\n end\n end\n return html\n end", "def cut_html\n if not @layed\n raise 'cannot build. miter not loaded. use Miter#lay first.'\n end\n return html_build_table(@main)\n end" ]
[ "0.689124", "0.6867437", "0.67406434", "0.6359123", "0.63519", "0.6223772", "0.6172329", "0.6166777", "0.6166777", "0.6140824", "0.6120351", "0.60728174", "0.5949518", "0.5903462", "0.5878804", "0.5872136", "0.5856295", "0.58351064", "0.5831087", "0.58272076", "0.58025324", "0.5795784", "0.5788706", "0.5784345", "0.5780125", "0.57751036", "0.5754839", "0.57355523", "0.57278615", "0.5727045", "0.5726374", "0.57221174", "0.57138926", "0.57050544", "0.5694844", "0.56625676", "0.56226397", "0.5622113", "0.5609243", "0.55943704", "0.5584912", "0.5584098", "0.5583013", "0.5580296", "0.55760515", "0.5567273", "0.55565226", "0.55539966", "0.55440724", "0.55239415", "0.5508765", "0.55049944", "0.5503795", "0.5483991", "0.54805404", "0.54768026", "0.54744923", "0.54634106", "0.54610324", "0.5450852", "0.54374313", "0.54338133", "0.54248023", "0.5423796", "0.54237103", "0.54237103", "0.5417956", "0.5410446", "0.54038674", "0.54023236", "0.5389056", "0.5382843", "0.53782713", "0.5369979", "0.5359771", "0.5350287", "0.53450185", "0.5344505", "0.5330461", "0.53253657", "0.5321802", "0.5318164", "0.53090626", "0.53014976", "0.5298986", "0.5298312", "0.52926177", "0.5291898", "0.52802867", "0.5274064", "0.5273795", "0.52709615", "0.5270147", "0.52689797", "0.52564514", "0.5254901", "0.525161", "0.5248763", "0.52485913", "0.5247159" ]
0.5749229
27
render a single entry
def _render_one(entry) @entry = entry @filename = @entry.filename # avoid double render of layout path return if @entry.source_path == @layout_path # render. Result goes into @content_for_resources input = File.read(@entry.source_path) # render using either erb or haml case File.extname(@entry.source_path) when /\.rhtml$/, /\.html.erb$/ @content_for_resources += eval(Erubis::Eruby.new.convert(input)) when /\.haml$/, /\.html.haml$/ require 'haml' @content_for_resources += Haml::Engine.new(input).to_html(self) end @filename =nil @entry = nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_entry(entry)\n %{<div class=\"hentry\" id=\"#{entry[:id]}\">\n <h2 class=\"entry-title\">#{entry[:title]}</h2>\n <span class=\"entry-content\">#{entry[:content]}</span>\n #{entry[:published_at].to_html}\n <span class=\"byline\">Posted by <span class=\"author vcard\"><span class=\"fn\"\n }\n end", "def show\n @entry = Entry.find(params[:id])\n end", "def show\n @entry = Entry.find(params[:id])\n end", "def show\n @entry = Entry.find(params[:id])\n respond_to do |format|\n format.html {}\n format.json { render json: @entry }\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @entry }\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry }\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry }\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry }\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry }\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry }\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry }\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry }\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry }\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry }\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\n render json: @entry\n end", "def show\n @entry = Entry.find(params[:id])\n @title = @entry.title\n end", "def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n end\n end", "def show\n @id = @entry.id\n @href = @entry.href\n @comment_href = @entry.comment_href\n @respond_href = @entry.respond_href\n @trackback_href = @entry.trackback_href\n\n @title = h(@entry.title)\n @pub_iso = @entry.published.iso8601\n @pub_formatted = @entry.published.strftime(Blog.options.time_format)\n\n @comment_count = number_counter(@entry.comments.count, 'comment')\n end", "def show\n @entry_view = EntryView.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry_view }\n end\n end", "def show\n @entry = Entry.where(:numid => params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry }\n end\n end", "def show\n @entry = @entries.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def show\n @feed = Feed.find(params[:feed_id])\n @entry = Entry.find(params[:id])\n respond_to do |format|\n format.html { render :layout => 'feed'}\n format.json { render json: @entry }\n end\n end", "def entry\n @entry.object\n end", "def entry\n Entry.new\n end", "def show\n respond_to do |format|\n format.html { locals :entry => current_entry }\n format.js { render :partial => \"entry/update\", :locals => { :entry => current_entry } }\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\[email protected] += 1\n\[email protected]_attributes(params[:entry])\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n\t format.rss { render :rss => @entry }\n end\n end", "def show\n begin\n @entry = current_user.entries.find(params[:id])\n rescue\n logger.error \"Hacker id #{current_user.id} attempted to access an entry belonging to another user: #{params[:id]}.\"\n redirect_to(entries_url)\n else\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry }\n end\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\[email protected] += 1\n\[email protected]_attributes(params[:id])\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n\t format.rss { render :rss => @entry }\n end\n end", "def get_entry(entry); end", "def create\n puts \"In entries#create, params=#{params}\"\n entity_id = params[:entity_id]\n=begin\n @entity = Entity.find(entity_id)\n template_name = @entity.template.name\n\n @entry = EntryManager.initialize_entry(@entity)\n=end\n @entity = Entity.find(entity_id)\n @entry = Entry.new({:entity_id => entity_id})\n \n @context = {:display_mode => 'new' \n }\n \n template = \"/templates/predefined/#{@entity.template.name}.html.erb\"\n entry_html = render_to_string(:template=>template, \n :layout=>false,\n )\n\n \n @entry[:html] = entry_html\n @entry[:attr_values] = @entry.attr_values\n @entry[:attrs] = @entity.attrs\n\n render :json => {\n :entry => @entry\n\n }\n end", "def show\n @blog = EntryFeed.where(:id => params[:id]).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @blog }\n end\n end", "def show\n @text_entry = TextEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @text_entry }\n end\n end", "def new\n @entry = Entry.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry }\n end\n end", "def show\n @entry_type = EntryType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry_type }\n end\n end", "def show\n build_entry_comment\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry }\n end\n end", "def render_leader_entry(leader, link = nil)\n render :partial => \"leader_entry\",\n :locals => {:leader => leader,\n :link => link,\n :rowclass => (leader.current? ? \"current_entry\" : \"entry\") }\n end", "def show\n @timeentry = Timeentry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @timeentry }\n end\n end", "def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n if params['enable_highliner_jquery_plugin']\n format.html { render layout: 'users' }\n else\n format.html\n end\n format.json { render json: @entry }\n end\n end", "def show\n @feedentry = Feedentry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feedentry }\n end\n end", "def show\n @feed_entry = FeedEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed_entry }\n end\n end", "def show\n # placeholder code\n jsonapi_render_errors status: :unprocessable_entity\n # original code\n # @entry = retrieve_service.execute(name: params[:id])\n # return not_found unless @entry\n # jsonapi_render json: @entry\n end", "def entry\n id_line('ENTRY_NAME')\n end", "def show\n @project_entry = ProjectEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project_entry }\n end\n end", "def show\n @entry = @time_sheet.entries.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry }\n end\n end", "def show\n #todo: add entry check that entry belongs to current user\n @entry = Entry.find(params[:id])\n if @entry.user_id != session[:user_id]\n flash[:notice] = \"You can't edit this entry\"\n redirect_to :action => \"index\"\n else\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n end\n end\n end", "def show\n @journal_entry = JournalEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @journal_entry }\n format.xml { render :xml => @journal_entry }\n end\n end", "def show\n @markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true)\n @diary_entry = DiaryEntry.find(params[:id])\n raise \"Diary entry doesn't belong to the current user\" unless @diary_entry.user_id == current_user.id\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def show\n @log_entry = LogEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @log_entry }\n end\n end", "def load_entry\n\t\t@entry = Entry.find(params[:id])\n\tend", "def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end", "def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end", "def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end", "def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end", "def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end", "def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end", "def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end", "def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end", "def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry }\n end\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def create\n @entry = current_user.entries.build(entry_params)\n if @entry.save\n flash[:success] = \"Entry created!\"\n redirect_to root_url\n else\n @feed_items = []\n render 'static_pages/home'\n end\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def set_entry\n @entry = Entry.find(params[:id])\n end", "def show\n @entry = Entry.find(params[:id])\n @comments = @entry.comments\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n end\n end", "def show\n @journal_entry = JournalEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @journal_entry }\n end\n end", "def show\n @journal_entry = JournalEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @journal_entry }\n end\n end", "def show\n @raceentry = Raceentry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @raceentry }\n end\n end", "def show\n @time_entry = TimeEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_entry }\n end\n end", "def show\n @time_entry = TimeEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_entry }\n end\n end", "def entry\n return @text_entry\n end", "def show\n @entry = Entry.find(params[:id])\n @entry.viewed\n breadcrumbs.add \"医药招商\",entries_url\n breadcrumbs.add nil\n #breadcrumbs.add @entry.title\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry }\n end\n end", "def show\n\t @person = Entry.last\n end" ]
[ "0.73900396", "0.71054995", "0.71054995", "0.6949827", "0.6887951", "0.68305993", "0.68305993", "0.68305993", "0.68305993", "0.68305993", "0.68305993", "0.68305993", "0.68305993", "0.68305993", "0.67296773", "0.67144156", "0.6655709", "0.6655709", "0.6510501", "0.64979804", "0.64360887", "0.63235706", "0.62999153", "0.6250423", "0.6242006", "0.6235062", "0.6227674", "0.62218416", "0.61715806", "0.61715645", "0.6169413", "0.61603016", "0.61402965", "0.6123897", "0.61230785", "0.61186224", "0.61132705", "0.61062175", "0.61056715", "0.6098758", "0.60705465", "0.605462", "0.60393673", "0.60391074", "0.60383517", "0.60302806", "0.6026845", "0.60219884", "0.60003287", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.59969985", "0.5996948", "0.5985556", "0.59785646", "0.59785646", "0.59785646", "0.59785646", "0.59785646", "0.59785646", "0.59785646", "0.59785646", "0.5969376", "0.5967904", "0.5967904", "0.5962678", "0.5957867", "0.5957867", "0.5957867", "0.5954829", "0.5936663", "0.5936663", "0.5936644", "0.59359264", "0.59359264", "0.59324205", "0.59285194", "0.5918455" ]
0.64620817
20
Returns the current bundle name. Often useful for generating titles, etc.
def bundle_name; bundle.bundle_name; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bundle_name\n info_plist[\"CFBundleDisplayName\"] || info_plist[\"CFBundleName\"]\n end", "def bundle_resouce_file_name\n self.title.gsub(/\\s/,\"_\")\n end", "def app_name\n @data['CFBundleExecutable'].to_s\n end", "def bundle_id\n read('bundle_id')\n end", "def cfBundleName\n extensions[:Middlemac].options.CFBundleName\n end", "def bundle_id\n return @bundle_id\n end", "def program_name\n File.basename($0)\n end", "def full_name\n \"#{@name}-#{@version}\"\n end", "def gem_name\n \"#{@account}-#{@name}\"\n end", "def path\n @bundle_filename\n end", "def current_bundle_code\n\tcase lane_context[:PLATFORM_NAME]\n\twhen :android\n\t\tget_gradle_version_code(gradle_path: lane_context[:GRADLE_FILE])\n\twhen :ios\n\t\tget_info_plist_value(path: 'ios/AllAboutOlaf/Info.plist',\n\t\t key: 'CFBundleVersion')\n\telse\n\t\traise 'wtf'\n\tend\nend", "def name()\n basename.to_s\n end", "def full_name\n \"#{@package}.#{parameterized_name}\"\n end", "def app_name\n return File.basename(File.expand_path(root)).freeze\n end", "def bundle\n content.split('bundle ').last.split(\",\").map(&:to_i).to_s\n end", "def package_name\n # TODO: verify renamed packages\n resource['title']\n end", "def package_name\n @version ? \"#{@name}-#{@version}\" : @name\n end", "def current_bundle_version\n case lane_context[:PLATFORM_NAME]\n when :android\n get_gradle_version_name(gradle_path: lane_context[:GRADLE_FILE])\n when :ios\n get_info_plist_value(path: 'ios/AllAboutOlaf/Info.plist',\n key: 'CFBundleShortVersionString')\n else\n get_package_key(key: :version)\n end\nend", "def raw_script_name\n File.basename($0)\n end", "def name\n @module.name\n end", "def full_name\n if platform == Gem::Platform::RUBY or platform.nil? then\n \"#{name}-#{version}\".untaint\n else\n \"#{name}-#{version}-#{platform}\".untaint\n end\n end", "def application_name\n @application_name ||= t('application.name')\n end", "def script_name # not file name\n sname = fetch(:script_name)\n return sname if sname\n name = dklet_script.basename('.rb').to_s\n pname = script_path.basename.to_s\n \"#{pname}_#{name}\"\n end", "def name\n @name ||= Rails.application.class.parent_name.underscore\n end", "def full_name\n if platform == Gem::Platform::RUBY or platform.nil?\n \"#{name}-#{version}\".dup.tap(&Gem::UNTAINT)\n else\n \"#{name}-#{version}-#{platform}\".dup.tap(&Gem::UNTAINT)\n end\n end", "def app_name\n Rucola::InfoPlist.open((RUBYCOCOA_ROOT + 'config/Info.plist').to_s).app_name\n end", "def name\n\t\tmodule_info['Name']\n\tend", "def short_name\n @context.name\n end", "def app_name\n @app_name ||= Rails.app_class.module_parent_name.demodulize.underscore.dasherize\n end", "def basename\n @generator.basename\n end", "def name\n File.basename(__FILE__, '.rb')\n end", "def bundle_id\n @attributes[:bundle_id]\n end", "def bundle_id\n @attributes[:bundle_id]\n end", "def program_name\n @program_name || File.basename($0, '.*')\n end", "def package_name\n name = package_drop_last(slug_parts)\n name.empty? ? '_root_' : name\n end", "def name\n name = nil\n if root?\n name = path.to_s\n else\n name = @path.basename.to_s\n end\n return name\n end", "def intname\n @basename\n end", "def name\n File.basename(@root)\n end", "def appname\n fetch(:appname) || script_name\n end", "def bundle_code\n @attributes[:bundle_code]\n end", "def base_name\n name\n end", "def gem_name\n @gem_name ||= @source_path.sub_ext(\"\").basename.to_s\n end", "def target_bundle_identifier\n bundle_identifier = nil\n resolve_build_configuration do |build_configuration, target|\n bundle_identifier = build_configuration.resolve_build_setting(\"PRODUCT_BUNDLE_IDENTIFIER\", target)\n end\n\n bundle_identifier\n end", "def name\n @name ||= File.basename(path)\n end", "def name\n @name ||= File.basename(path)\n end", "def name()\n return self.manager.dictionary[self]\n end", "def file_name\n \"/\" + current_file.path.split('/').pop\n end", "def name\n @name ||= File.basename(Dir.pwd)\n end", "def name\n @name ||= File.basename(path)\n end", "def image_name\n @image_name || image_bundle.image_name\n end", "def name\n load! if not @loaded\n @name\n end", "def name\n @name ||= ::File.basename(@path)\n end", "def display_name\n return name unless %w(maven gradle).include?(package_manager)\n name.split(\":\").last\n end", "def name\n @name ||= self.class.non_namespaced_name\n end", "def app_name\n @app_name ||= defined_app_const_base? ? defined_app_name : File.basename(destination_root)\n end", "def name_with_version\n if self.version.nil?\n return name\n else\n return [name, version].join(':')\n end\n end", "def name\n file.basename('.rb').to_s if file\n end", "def name\n file.basename('.rb').to_s if file\n end", "def app_name\n t('descriptions.product_name').remove(' ')\n end", "def default_base_title\n Rails.application.class.to_s.split('::').first\n end", "def fully_qualified_name\n return \".#{self.package}\"\n end", "def name\n File.basename(self.path)\n end", "def full_name\n if @prefix != \"\"\n File.join(@prefix, @name)\n else\n @name\n end\n end", "def original_name # :nodoc:\n if platform == Gem::Platform::RUBY or platform.nil?\n \"#{@name}-#{@version}\"\n else\n \"#{@name}-#{@version}-#{@original_platform}\"\n end\n end", "def display_name\n @_context[:display_name]\n end", "def get_application_name\r\n root_info = get_rails_root_info\r\n root_info.split('/').last.capitalize\r\n end", "def name\n $0.split(\"/\").last\n end", "def name\n [self[:namespace], self[:short_name]].reject(&:blank?).join(Tag.namespace_separator)\n end", "def application_name\n if Rails.application.config.respond_to? :application_name\n Deprecation.warn(self, \"BlacklightHelper#application_name will no longer delegate to config.application_name in version 7.0. Set the i18n for blacklight.application_name instead\")\n return Rails.application.config.application_name\n end\n\n t('blacklight.application_name')\n end", "def base_name(suffix=nil)\n adapter.basename(suffix)\n end", "def full_name\n if namespace\n \"#{namespace}#{SEPARATOR}#{name}\"\n else\n \"#{name}\"\n end\n end", "def get_bundle_install_name(bundle_dir, binary)\n\tcurrent_dir = \"#{bundle_dir}/#{BUNDLE_MAIN_EXE_PATH}\"\n\trelative_path = Pathname.new(binary).relative_path_from(Pathname.new(current_dir)).to_s\n\trelative_path = \"@executable_path/#{relative_path}\"\n\treturn relative_path\nend", "def name\n @name ||= @project.dir.path.match(/.*\\/(.*)$/).nil? ? \"unknown\" : $1\n end", "def getName()\n\t\t\treturn @_name\n\t\tend", "def file_name\n \"#{full_name}.gem\"\n end", "def product_name_fancy\n\t\t\tif self.product\n\t\t\t\treturn self.product.name_fancy\n\t\t\telse\n\t\t\t\treturn self.product_name\n\t\t\tend\n\t\tend", "def plugin_name(path)\r\n File.basename(path)\r\n end", "def root_resource_name\n components.keys.first.to_s\n end", "def title\n current_localization.name\n end", "def package_basename(extension='.gem')\n [ package_name, version ].join('-') + extension\n end", "def name\n File.basename(@path)\n end", "def name\n File.basename(@path)\n end", "def name\n File.basename(@path)\n end", "def default_app_name\n if is_workspace\n return default_build_settings(key: \"PRODUCT_NAME\")\n else\n return app_name\n end\n end", "def version_name\n self.class.version_names.join('_').to_sym unless self.class.version_names.blank?\n end", "def my_name\n @my_name ||= self.class.name.split(\"::\").last\n end", "def basename\n @_basename ||= self.class.name.demodulize.underscore\n end", "def name\n @name ||= path.split('/').last\n end", "def product_name\n return product_presentation.name if product_presentation\n return \"\"\n end", "def get_code_name\n code_name = $0\n code_name = Pathname.new(code_name)\n code_name = code_name.basename.to_s\n return code_name\nend", "def component_module_name(opts = {})\n if component_module = component_module()\n opts[:no_namespace] ? component_module.display_name : component_module.full_module_name\n end\n end", "def app_name\n ApplicationService.application_name\n end", "def name\n if app_name = @args[:props][\"application_name\"].to_s.strip and !app_name.empty?\n return app_name\n else\n raise \"Could not figure out the input-name.\"\n end\n end", "def program_name\n Quickl.program_name\n end", "def get_policy_name_from_bundle(bundle)\n policy_name = nil\n policy_name ||= bundle.runlist_policy.policy_name if bundle.respond_to?(:runlist_policy) && bundle.runlist_policy\n policy_name\n end", "def base_name\n File.basename(file_name)\n end", "def original_filename\n File.basename(self.path)\n end", "def original_filename\n File.basename(self.path)\n end", "def original_filename\n File.basename(self.path)\n end", "def name\n @name ||= filename.split(\".\").first.sub(/^_/, \"\")\n end" ]
[ "0.79277426", "0.6981337", "0.67999613", "0.6788858", "0.67024314", "0.6643769", "0.6607597", "0.65547097", "0.6517105", "0.63893884", "0.6364047", "0.6359927", "0.63173026", "0.630701", "0.6297408", "0.62890816", "0.6267021", "0.626352", "0.62465334", "0.6233625", "0.6225294", "0.6220196", "0.62172127", "0.6215939", "0.6211499", "0.62081057", "0.6204167", "0.6178823", "0.6169978", "0.6156424", "0.6155199", "0.6151941", "0.6151941", "0.6151652", "0.61512655", "0.61393654", "0.6131777", "0.6126154", "0.6123709", "0.61069757", "0.60955566", "0.6091038", "0.60846025", "0.6066215", "0.6066215", "0.60546607", "0.60386807", "0.6034385", "0.6031528", "0.601741", "0.6016123", "0.60077626", "0.60058486", "0.6004204", "0.60032696", "0.5998237", "0.5992423", "0.5992423", "0.59784055", "0.5977388", "0.59736043", "0.59705764", "0.59597045", "0.5955031", "0.5951988", "0.59514225", "0.59308994", "0.5930333", "0.5923828", "0.590678", "0.59056264", "0.59045154", "0.59043616", "0.59029084", "0.58925873", "0.588893", "0.5887592", "0.5883249", "0.5883129", "0.5880377", "0.5878137", "0.5878137", "0.5878137", "0.5868447", "0.5861075", "0.58498895", "0.5845085", "0.5844712", "0.58368397", "0.5834798", "0.58326703", "0.5828514", "0.5822542", "0.58201057", "0.58142054", "0.58089584", "0.5807088", "0.5807088", "0.5807088", "0.5803469" ]
0.82866037
0
For Rails Compatibility. render() does not do anything useful since the new build system is nice about putting things into the right place for output.
def render; ''; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render\n perform(Environment.new).to_s\n end", "def build_html\n ApplicationController.render(partial: partial, locals: locals)\n end", "def render\n App.out.render\nend", "def render\n end", "def render( render_state )\n\t\treturn nil\n\tend", "def render; end", "def render; end", "def render; end", "def render; end", "def render; end", "def render!\n result\n end", "def render\n end", "def render\n end", "def render\n end", "def make_render_in_view exp\n make_render exp, true\n end", "def render r\n end", "def render\n sb = StringIO.new\n append_to_string_builder(sb)\n sb.string\n end", "def render\n end", "def render(*args, &block); end", "def render(*args); end", "def render(*args); end", "def rails_render(*args)\n return if rails_api_controller?\n\n rails_controller_instance.render_to_string(*args)\n rescue ActionView::MissingTemplate\n nil\n end", "def render( * )\n\t\tnil\n\tend", "def render( * )\n\t\tnil\n\tend", "def render(context, options); end", "def render!(*args); end", "def rendered=(_arg0); end", "def render\n\n end", "def render\n raise NotImplementedError\n end", "def render\n raise NotImplementedError\n end", "def render(_, _)\n self.class.run(@filename, @source)\n end", "def rendered; end", "def render\n\n\t\t\tcontent = render_object.render\n\n\t\t\tif params[:output_file]\n\t\t\t\tcreate_output_file(content)\n\t\t\telse\n\t\t\t\tputs content\n\t\t\tend\n\n\t\tend", "def render_result\n layout = @render_args[:layout]\n view = @render_args[:view]\n if layout.kind_of? Symbol # this handles the layout(:none)\n view.result(binding)\n else\n @view[:timestamp] = \"<!-- rendered: #{Time.now()} / env: #{rack_env} -->\"\n @view[:body] = view.result(binding)\n # layout = @layout if layout.nil? # this handles the layout(:some_other_layout) case for formats\n layout.result(binding)\n end\n end", "def render opts = {}\n renderer.render opts\n end", "def render\n # To be implemented.\n end", "def _render_\n document.to_s\n end", "def render(view, locals, buffer = nil, add_to_stack: true, &block)\n instrument_render_template do\n compile!(view)\n if buffer\n view._run(method_name, self, locals, buffer, add_to_stack: add_to_stack, has_strict_locals: strict_locals?, &block)\n nil\n else\n view._run(method_name, self, locals, OutputBuffer.new, add_to_stack: add_to_stack, has_strict_locals: strict_locals?, &block)&.to_s\n end\n end\n rescue => e\n handle_render_error(view, e)\n end", "def render\n perform(Environment.new).cssize.to_s\n end", "def render(options=nil, deprecated_status_or_extra_options=nil, &block)\n if ::Rails::VERSION::STRING >= '2.0.0' && deprecated_status_or_extra_options.nil?\n deprecated_status_or_extra_options = {}\n end\n \n unless block_given?\n unless integrate_views?\n if @template.respond_to?(:finder)\n (class << @template.finder; self; end).class_eval do\n define_method :file_exists? do; true; end\n end\n else\n (class << @template; self; end).class_eval do\n define_method :file_exists? do; true; end\n end\n end\n (class << @template; self; end).class_eval do\n define_method :render_file do |*args|\n @first_render ||= args[0] unless args[0] =~ /^layouts/\n end\n \n define_method :pick_template do |*args|\n @_first_render ||= args[0] unless args[0] =~ /^layouts/\n PickedTemplate.new\n end\n end\n end\n end\n\n if matching_message_expectation_exists(options)\n expect_render_mock_proxy.render(options, &block)\n @performed_render = true\n else\n if matching_stub_exists(options)\n @performed_render = true\n else\n super(options, deprecated_status_or_extra_options, &block)\n end\n end\n end", "def render\n raise NotImplementedError.new \"Please override 'render' in your \"+\n \"concrete implementation\"\n end", "def render_result\n layout = @render_args[:layout]\n view = @render_args[:view]\n if layout.kind_of? Symbol # this handles the layout(:none)\n view.result(binding)\n else\n @view[:timestamp] = \"<!-- server: #{@port} / rendered: #{Time.now()} / env: #{rack_env} -->\"\n @view[:body] = view.result(binding)\n # layout = @layout if layout.nil? # this handles the layout(:some_other_layout) case for formats\n layout.result(binding)\n end\n end", "def render!; raise NotImplementedError end", "def render\n content = output_capture(@block) do\n instance_exec( *@args, &@block )\n end\n content_wrapped = output_capture() { wrap( content ) }\n output_concat content_wrapped\n end", "def render(args={})\n return if @redirect\n @render_nothing = args[:nothing] # TODO hack to block automatic method templates\n json = args[:json]\n action = args[:action]\n html = args[:html]\n content = args[:content_type]\n partial = args[:partial]\n # xxx hack to let me fake scope to other controllers without loading\n temp = @handlerpath\n @handlerpath = args[:controller] if args[:controller]\n @content_type = content if content\n @current_layout = args[:layout] if args[:layout]\n write html if html\n @content_type = 'text/plain' if !content && json\n write json if json\n @render_nothing = true if json\n @rendered_template = true if json\n @current_layout = nil if json\n @rendered_template = true if action\n render_rhtml [\"#{action}.rhtml\"] if action\n # TODO hack end to return scope to current controller\n @handlerpath = temp\n end", "def render(context, _empty_hash_wtf)\n self.class.run(@filename, @source, context)\n end", "def render\n Log.dev(\"Action: #{self}\")\n stack do\n if should_cache?\n # Ignore cache if there is flash session data as the response probably\n # expects to include it, making it unique for this user and request.\n if Global.no_cache_flash && !Current.session.flash.empty?\n Log.debug(\"Action caching ignored as session flash data is present.\")\n uncached_render\n else\n cached_render\n end\n else\n uncached_render\n end\n end\n end", "def render(template_name)\n if already_built_response? \n raise \"DoubleRenderError\"\n else \n controller_name = self.class.to_s.underscore \n dir = File.join(\"views\",controller_name, \"#{template_name}.html.erb\")\n # debugger\n content = File.read(dir).split(\"\\n\")\n content.map! do | statement | \n start_point = /<%/ =~ statement\n # debugger\n if start_point.nil? \n statement\n else \n front_part = statement[0...start_point]\n # returning = \n # start_point += statement[start_point+2] == \"=\" ? 2 : 1\n end_point = /%>/ =~ statement \n end_point += 1\n rear_part = statement[end_point+2..-1]\n front_part.to_s + ERB.new(statement[start_point..end_point]).result(binding) + rear_part.to_s\n end \n end \n render_content(content)\n end \n end", "def _normalize_render(*args, &block); end", "def render\n raise NotImplementedError, \"#{self.class} must implement a `#render` method to format its output.\"\n end", "def render\n raise NotImplementedError, \"#{self.class} must implement a `#render` method to format its output.\"\n end", "def render\n return nil\n end", "def render\n raise NotImplementedError, 'this should be overridden by concrete sub-class'\n end", "def render(context)\n # Sanitize the code inside the block\n resolve_code = super.to_s.gsub(/\\A(\\n|\\r)+|(\\n|\\r)+\\z/, \"\")\n \n # Invoke Rouge to format our code\n formatted_code = rouge_resolve(resolve_code)\n \n # Output the formatted code with the proper HTML tags\n to_html_code(formatted_code)\n end", "def render(view)\n # Since only one command is executed per thread, we can store the view to\n # render as a thread-local variable.\n raise \"The render method should be called at most once per command\" if Thread.current[:render_view]\n Thread.current[:render_view] = view.to_s\n return nil\n end", "def render(*args)\n super *args\n end", "def render(*args)\n end", "def render(options = T.unsafe(nil), locals = T.unsafe(nil), &block); end", "def render(filename, content)\n if renderer = renderer_for(filename)\n renderer.call content\n else\n content\n end\n end", "def render_to_string(*args, &block); end", "def render\n Vedeu.renderers.render(output) if Vedeu.ready?\n end", "def render(scope = T.unsafe(nil), locals = T.unsafe(nil)); end", "def render(erb)\n erb.result(binding)\n end", "def render\n content\n end", "def render\n content\n end", "def render\n content\n end", "def render_to_body(options = T.unsafe(nil)); end", "def render\n raise NotImplementedError, \"Subclasses must implement a render method\"\n end", "def render(*_arg0); end", "def render(view, locals, buffer = T.unsafe(nil), add_to_stack: T.unsafe(nil), &block); end", "def render!\n render :file => template_path\n end", "def render\n content\n end", "def render(*args, &block)\n\t options = _normalize_render(*args, &block)\n\t self.response_body = render_to_body(options)\n\t _process_format(rendered_format, options) if rendered_format\n\t self.response_body\n\t end", "def render(output)\n output = output.to_s.strip\n # or should this use a Template so we can eliminate the block args?\n output = @render.call(output) if @render\n output\n end", "def render(&block) #:nodoc:\r\n instance_eval(&block)\r\n @output_buffer\r\n end", "def render(*args, &block)\n options = args.last.is_a?(Hash) ? args.pop : {}\n @response.status = options.delete(:status) || 200\n layout = @layouts[options.delete(:layout) || :default]\n assigns = { :request => request, :response => response, :params => params, :session => session }\n @content = args.last.is_a?(String) ? args.last : Markaby::Builder.new(assigns, self, &(block || @views[args.last])).to_s\n @content = Markaby::Builder.new(assigns, self, &layout).to_s if layout\n @response.headers.merge!(options)\n @response.body = @content\n end", "def render(*args, &block)\n captured = helpers.capture do\n helpers.concat(helpers.render(*args, &block))\n helpers.output_buffer.to_s\n end\n rawtext(captured)\n end", "def render_calls; end", "def _render_one(entry)\n @entry = entry\n @filename = @entry.filename\n\n # avoid double render of layout path\n return if @entry.source_path == @layout_path\n\n # render. Result goes into @content_for_resources\n input = File.read(@entry.source_path)\n \n # render using either erb or haml\n case File.extname(@entry.source_path)\n when /\\.rhtml$/, /\\.html.erb$/\n @content_for_resources += eval(Erubis::Eruby.new.convert(input))\n when /\\.haml$/, /\\.html.haml$/\n require 'haml'\n @content_for_resources += Haml::Engine.new(input).to_html(self)\n end\n\n @filename =nil\n @entry = nil\n end", "def rendered\n @_rendered ||= ( persisted? ) ? Regulate::Git::Interface.find_rendered(id) : build_rendered_html\n @_rendered\n end", "def render(options = {})\n raise double_render! if rendered?\n @render_opts = options\n end", "def render(scope = T.unsafe(nil), locals = T.unsafe(nil), &block); end", "def render(anEnvironment, theLocals, aTransformer, aLevel)\n return '' unless guard_applies?(anEnvironment, theLocals)\n \n return snippet.render(anEnvironment, theLocals, aTransformer, aLevel)\n end", "def _render_template(options); end", "def _render_template(options); end", "def cached_render_file\n rendered = uncached_render\n\n global_epath = Global.public_root/self.controller.mapping/extended_path\n FileUtils.mkdir_p(File.dirname(global_epath))\n File.open(global_epath, 'w+') {|fp| fp.print(rendered) }\n\n rendered\n end", "def render\n render_background\n\n render_heat_maps\n\n render_star\n render_target\n render_hills\n render_walls\n\n render_paths\n end", "def render(context, locals)\n @context = context\n @pathname = context.pathname\n @directory = File.dirname(@pathname)\n\n @header = data[HEADER_PATTERN, 0] || \"\"\n @body = $' || data\n # Ensure body ends in a new line\n @body += \"\\n\" if @body != \"\" && @body !~ /\\n\\Z/m\n\n @included_pathnames = []\n\n @result = \"\"\n @result.force_encoding(body.encoding)\n\n @has_written_body = false\n\n process_directives\n @body = process_imports(@body, @context, @directory)\n @body = process_stylesheets(@body, @directory)\n @body = process_scripts(@body, @directory)\n process_source\n\n @result\n end", "def render_to_body(options); end", "def display\n puts render\n end", "def render(obj = Object.new, locals = {})\n output = template.result(obj.instance_eval { binding })\n (view == 'document' || view == 'embedded') ? output.gsub(BLANK_LINES_PATTERN, '').gsub(LINE_FEED_ENTITY, \"\\n\") : output\n end", "def render(view, locals, buffer=nil, &block)\n mod = view.is_a?(Deface.template_class) ? Deface.template_class : view.singleton_class\n\n if @compiled && !mod.instance_methods.include?(method_name.to_sym)\n @compiled = false\n @source = refresh(view).source\n end\n buffer.nil? ? super(view, locals, buffer, &block) : super(view, locals, **buffer, &block)\n end", "def render(props)\n # HTML.\n end", "def render_to_string(*)\n if self.response_body = super\n string = \"\"\n self.response_body.each { |r| string << r }\n string\n end\n ensure\n self.response_body = nil\n end", "def render_to_string(*args, &block)\n options = _normalize_render(*args, &block)\n render_to_body(options)\n end", "def render\n render_with_markaby\n end", "def render()\n # WARNING! NO NEED TO UNDERSTAND THIS\n self.action = calling_method = caller[0].split(\"`\").pop.gsub(\"'\", \"\")\n template = File.read(view_filename)\n eruby = Erubis::Eruby.new(template)\n eruby.result(binding())\n end", "def render(options = {}) \n return if @view and !options[:force] # Avoid double rendering, if we have already attached a view\n \n if options == {} # default rendering\n render(:file => default_template_name)\n\n elsif action_name = options[:action]\n result = render(:file => default_template_name(action_name.to_s))\n\n elsif options[:file]\n file = options[:file]\n if file =~ /^\\// # Render from view root\n @view = render_for_file(File.join(\"app\", \"views\", \"#{file}.xml.builder\"))\n else\n @view = render_for_file(view_path(file)) \n end\n\n elsif options[:nothing]\n @view = Skates::Base::View.new()\n end\n end", "def call(env)\n renderer.render(env, middleware.call(env))\n end", "def render_document; end" ]
[ "0.71758294", "0.6982254", "0.69216454", "0.6897247", "0.6892187", "0.6874957", "0.6874957", "0.6874957", "0.6874957", "0.6874957", "0.6836229", "0.6834731", "0.6834731", "0.6834731", "0.6834661", "0.6754122", "0.67250836", "0.6720979", "0.6703739", "0.66666704", "0.66666704", "0.666564", "0.6664394", "0.6664394", "0.6657715", "0.6648922", "0.6648116", "0.6643856", "0.66428417", "0.66409856", "0.66333294", "0.66145176", "0.6596981", "0.6579544", "0.65744853", "0.65679187", "0.654664", "0.6542545", "0.6521055", "0.64796585", "0.6453137", "0.6429962", "0.6423033", "0.6422609", "0.64176476", "0.64027977", "0.6399939", "0.6395238", "0.6379039", "0.63669807", "0.63669807", "0.6364553", "0.6329633", "0.6319869", "0.63169116", "0.6311393", "0.6309298", "0.6303479", "0.62904817", "0.62868047", "0.62856996", "0.6284695", "0.62685883", "0.6265291", "0.6265291", "0.6265291", "0.62584263", "0.6251532", "0.6251463", "0.6248593", "0.6231592", "0.622661", "0.6209001", "0.62073004", "0.6201259", "0.618267", "0.61705166", "0.61674845", "0.6166247", "0.6163973", "0.61622727", "0.6160171", "0.61338973", "0.61276835", "0.61276835", "0.6117018", "0.61139184", "0.61135244", "0.6111763", "0.61044264", "0.610086", "0.60990477", "0.6097609", "0.60917264", "0.6088545", "0.6088462", "0.6073624", "0.60639286", "0.60614055", "0.6060098" ]
0.63399833
52
e.x.) "tasksindex" => "task" e.x.) "RailsAdmin::Engine" => "rails_amin/engine"
def to_tag_name tag_name = if @is_route_engine @request.gsub('::', '/').underscore else @request.split('#').first.singularize end tag_name = tag_name.split('/').last unless use_tag_namespace tag_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index_template\n :index\n end", "def index_template\n :index\n end", "def setting_index\n end", "def index_admin\n @events = Event.all.order('start_at ASC')\n end", "def index\n @admin_admins = Admin.all\n\n @grid = grid_class.new(grid_params) do |scope|\n scope.page(params[:page]).per(10)\n end\n @index_path = request.path\n# render 'admin/base/index'\n end", "def resource_index_locator\n self.class.name.sub(/Controller$/, '').split('::').map(&:underscore).map(&:to_sym)\n end", "def index\n # Replace TaskAdmin with User if we want SuperAdmin to manage all users\n @users = TaskAdmin.all\n end", "def index\n @title=t(\"admin.base.index.title\")\n end", "def find_index_class(symbol_or_class)\n\n\n\n case symbol_or_class\n\n\n\n when Symbol\n\n\n\n ::ActiveAdmin::Views.const_get(\"IndexAs\" + symbol_or_class.to_s.camelcase)\n\n\n\n when Class\n\n\n\n symbol_or_class\n\n\n\n end\n\n\n\n end", "def ta_index\n end", "def index\n @tab = :admins\n @entities = Entity.all\n end", "def index(options = {}, &block)\n options[:as] ||= :table\n config.set_page_presenter :index, ActiveAdmin::PagePresenter.new(options, &block)\n end", "def index\n\t\t\"#{self}.index\"\n\tend", "def active_admin_resource_for(klass)\n\n\n\n if respond_to? :active_admin_namespace\n\n\n\n active_admin_namespace.resource_for klass\n\n\n\n end\n\n\n\n end", "def index\n @tasks = @list.tasks.where(\"type = ?\",\"TaskTemp\").where.not(\"estado = ?\",\"expirada\").order(:prioridad)\n end", "def index\n set_tasks\n if @role === 'admin'\n @tasks = Task.all\n end\n if @role === 'merchant'\n @tasks = Task.where(merchant: spree_current_user.merchant_id)\n end\n end", "def model_index_path(name, options = {}) \n eval \"#{name}_path(options)\"\n end", "def model_index_path(name, options = {}) \n eval \"#{name}_path(options)\"\n end", "def index_type\n name\n end", "def index\n @tasks = Task.all \n end", "def index\n # @process_lts = ProcessLt.where([get_query_string])\n index_admin\n end", "def routes(context={})\n \n routes = [{:path => '/admin/worker-jobs',\n :regular_expression => /^\\/admin\\/worker-jobs/, \n :title => 'Delayed jobs', \n :description => 'Query delayed jobs',\n :fit => 1,\n :module => :system }]\n \n end", "def index\n @taskas = Taska.all\n end", "def index\n @task_tables = TaskTable.all\n end", "def mount_engine\n route(\"mount MaintenanceTasks::Engine => \\\"/maintenance_tasks\\\"\")\n end", "def index_for_id klass\n klass.model_name.plural\n end", "def index\n @tasks = Task.all.order( 'starttime DESC' )\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @tasks = Task.all\n end", "def index\n @admin_ruby_name_methods = Admin::RubyNameMethod.all\n end", "def index_view\n 'list'\n end", "def index\n add_breadcrumb :index, :index\n @admin_apps = initialize_grid(App, per_page: 20)\n end", "def index_name\n models.map { |m| m.index_name }\n end", "def index_partial_for(o)\n \"#{o.class.name.underscore}s/index\"\n end", "def index\n @task_managers = TaskManager.all\n end", "def index\n # GET /tasks\n @tasks = Task.all\n end", "def index\n @task_types = TaskType.all\n end", "def index\n @tasks = Tasks::List.call(params: task_search_params, user: current_user).model\n @tasks = @tasks.page(params[:page]).order(created_at: :desc)\n end", "def read_index\n all_tasks = @model.read\n @view.show_index(all_tasks)\n\tend", "def models\n [::AdminSet.to_class_uri]\n end", "def index\n @tasks = (current_user.admin? ? Task.all : current_user.tasks)\n @error = nil\n if params[:name].present?\n resp = Task.where(\"name ilike '%#{params[:name]}%'\")\n if resp.present? \n if !current_user.admin?\n resp = resp.where(:user_id => current_user.id)\n end\n @tasks = resp \n end\n if resp.blank?\n @error = \"No Task Present with \\'#{params[:name]}\\' name\"\n end\n end \n end", "def index\n @admin = Admin.all\n end", "def index\n @admin_n_admins = Admin::NAdmin.all\n end", "def set_eadmin_task\n @eadmin_task = EadminTask.find(params[:id])\n end", "def appindex\n\n end", "def index\n @admin_admins = Admin::Admin.page(params[:page]).per(15).load\n end", "def site\n AutoAdmin::AutoAdminConfiguration.site\n end", "def index\n @tasks = Task.find(:all, :order => \"name asc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tasks }\n end\n end", "def index\n @api_tasks = Api::Task.all\n end", "def acts_as_lesson_plan_item\n acts_as :lesson_plan_item, class_name: Course::LessonPlan::Item.name\n end", "def admin\n #TODO\n end", "def index\n @complex_tasks = ComplexTask.all\n end", "def admin_logic\n end", "def nav\n 'nav_admin'\n end", "def require_admin\n end", "def tasks_or_templates\n \"task_templates\"\n end", "def index\n @task_configs = TaskConfig.all\n end", "def engine\n SettingMaster.engine\n end", "def index\n respond_to do |format|\n format.html {}\n format.js {}\n end \n @search = Task.search do \n fulltext params[:search] \n end\n @searchresult = @search.results\n @task = Task.new\n @tasks = Task.all\n @count = @tasks.count\n @order_by = [\"priority\", \"postpone\", \"content\"].include?(params[:order_by]) ? params[:order_by] : \"priority\"\n @tasks=Task.order_tasks(@order_by, 'DESC') \n end", "def index\n @task_applications = TaskApplication.all\n end", "def index\n @tab = :admins\n @users = User.all\n end", "def index\n @admin_products = Admin::Product.all\n end", "def index\n @tasklists = Tasklist.all\n end", "def index\n @tasks = Task.order(\"date DESC\").limit(30)\n end", "def index\n @task_items = Task::Item.all\n end", "def index\n @task_lists = TaskList.all\n end", "def index\n if !current_user.admin then\n redirect_back fallback_location: root_path\n end\n @tasks = Task.all\n end", "def index; @index; end", "def require_index(name); end", "def require_index(name); end", "def index\n @user = current_user\n @tasks = @user.tasks.rank(:row_order)\n @label_list = Label.all\n @task = current_user.tasks.new\n @sort = nil\n if params[:task]\n selection = params.dig(:task, :keyword)\n # @tasks = Task.sort(selection)\n # @tasks = @tasks.where(user_id: current_user)\n @tasks = Task.where(user_id: current_user).order_by_key(selection)\n @sort = params[:task][:keyword]\n end\n end", "def my_index\n authorize! :read, Task\n @tasks = Task.where(:user_id => current_user.id).order(sort_column + \" \" + sort_direction).page(params[:page]).per(20)\n\n render \"index\"\n end", "def index\n @task_sets = TaskSet.all\n end", "def index\n @admin_functions = Admin::Function.all\n end", "def index_type(env)\n @index_type\n end", "def appctrl_index_assist( model )\n\n # Set up some default sort and pagination data.\n\n default_sort = -1 # \"-1\" => \"unknown\"\n default_direction = model::DEFAULT_SORT_DIRECTION.downcase\n default_entries = 10\n default_page = 1\n\n # Attempt to read user preferences for sorting and pagination in index\n # views for the given model. Note the heavy use of \"try()\" to tolerate\n # 'nil' values propagated through, e.g. due to no logged in user, or\n # a user with no control panel (not that this ought to ever happen).\n\n prefs_prefix = \"sorting.#{ model.name.downcase }.\"\n cp = @current_user.try( :control_panel )\n cp_sort = cp.try( :get_preference, \"#{ prefs_prefix }sort\" )\n cp_direction = cp.try( :get_preference, \"#{ prefs_prefix }direction\" )\n cp_entries = cp.try( :get_preference, \"#{ prefs_prefix }entries\" )\n\n # For each one, try to read from the parameters; or fall back to the user\n # settings; or fall back to the defaults. If the value so determined is\n # different from the user's current setting, then update that setting.\n\n sort = params[ :sort ].try( :to_i ) || cp_sort || default_sort\n cp.try( :set_preference, \"#{ prefs_prefix }sort\", sort ) unless ( cp_sort == sort )\n\n direction = params[ :direction ] || cp_direction || default_direction\n cp.try( :set_preference, \"#{ prefs_prefix }direction\", direction ) unless ( cp_direction == direction )\n\n entries = params[ :entries ].try( :to_i ) || cp_entries || default_entries\n entries = default_entries if ( entries <= 0 or entries > 500 )\n cp.try( :set_preference, \"#{ prefs_prefix }entries\", entries ) unless ( cp_entries == entries )\n\n # Establish a page number, then write the final determined values back into\n # the parameters hash as views or plugins may refer to these directly.\n\n page = params[ :page ].try( :to_i ) || default_page\n\n params[ :sort ] = sort.to_s\n params[ :direction ] = direction\n params[ :entries ] = entries.to_s\n params[ :page ] = page.to_s\n\n if ( [email protected] ).include?( sort )\n\n # Valid sort order requested\n\n unless ( @columns[ sort ][ :sort_by ].nil? )\n order = @columns[ sort ][ :sort_by ].dup\n else\n order = @columns[ sort ][ :value_method ].to_s.dup\n end\n\n else\n\n # Default sort order - try to match DEFAULT_SORT_COLUMN against one of\n # the numbered columns.\n\n order = model::DEFAULT_SORT_COLUMN.dup\n\n @columns.each_index do | index |\n column = @columns[ index ]\n\n if ( column[ :value_method ].to_s == order or column[ :sort_by ].to_s == order )\n params[ :sort ] = index.to_s\n break\n end\n end\n end\n\n if ( direction == 'desc' )\n order << ' DESC'\n else\n order << ' ASC'\n end\n\n return { :page => page, :per_page => entries, :order => order }\n end", "def index\n @taskks = Taskk.all\n end", "def definition; Mrowka::Tasks[self.type.to_sym]; end", "def index\n @exercise_tasks = ExerciseTask.all\n end", "def index\n # @admins = admin.all\n @admins = Admin.order(:nome)\n end", "def index\n authorize! :read, Task\n @tasks = Task.order(sort_column + \" \" + sort_direction).page(params[:page]).per(20)\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end" ]
[ "0.60740155", "0.60740155", "0.59443456", "0.59009147", "0.5796762", "0.5791534", "0.5790433", "0.5785003", "0.5777919", "0.5754115", "0.57011503", "0.56744", "0.5641266", "0.56237626", "0.5613647", "0.5605421", "0.5600719", "0.5600719", "0.5583787", "0.55728", "0.55494463", "0.5540547", "0.55301875", "0.55189466", "0.55033696", "0.5485942", "0.54705876", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5467726", "0.5466708", "0.5455986", "0.5454158", "0.54483116", "0.544732", "0.54439193", "0.5383657", "0.5375527", "0.53737855", "0.5371466", "0.5370263", "0.53626865", "0.5352584", "0.5351915", "0.53500766", "0.53337944", "0.53291243", "0.5323959", "0.53176856", "0.5308745", "0.5299567", "0.5299086", "0.5298822", "0.5295634", "0.5285957", "0.52827287", "0.5275236", "0.5275033", "0.5273352", "0.5270212", "0.52652407", "0.5263092", "0.5261899", "0.52554387", "0.5250467", "0.5247451", "0.5233798", "0.52211845", "0.5215162", "0.52115256", "0.52115256", "0.5196753", "0.5194667", "0.5193988", "0.51935005", "0.5189109", "0.5187273", "0.51797867", "0.517712", "0.5175506", "0.517458", "0.5172838" ]
0.0
-1
GET /periods GET /periods.json
def index @periods = @organism.periods.order(:close_date) respond_to do |format| format.html # index.html.erb format.json { render json: @periods } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_periods\n @periods = current_user.periods.all.order(created_at: :desc)\n render json: @periods\n end", "def index\n @periods = Period.all\n end", "def index\n periods = current_user.school.periods.all\n\n render json: periods\n end", "def periods\n @periods ||= @data['properties']['periods'].map { |row|\n ::WeatherSage::Weather::Period.new(@ctx, row)\n }\n end", "def get_inactive_periods\n @periods = current_user.periods.where(is_active: false).order(created_at: :desc)\n render json: @periods\n end", "def show\n @period = Period.find(params[:id])\n\n render json: @period\n end", "def get_periods(id, starts: nil, ends: nil, threshold:, operation:)\n params = {:start => starts, :end => ends, :threshold => threshold, :op => operation}\n params.delete_if { |k, v| v.nil? }\n @client.http_get(\"/#{@resource}/#{id}/periods?\"+URI.encode_www_form(params))\n end", "def show\n period = current_user.school.periods.find(params[:id])\n render json: period\n end", "def period(period, options = {})\n get(\"periods/#{period}\", options).pop\n end", "def index\n @time_periods = TimePeriod.all\n end", "def index\r\n @product_periods = ProductPeriod.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @product_periods }\r\n end\r\n end", "def schedule_periods\n\t\t@periods = Period.all\n\tend", "def index\n @registration_periods = RegistrationPeriod.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @registration_periods }\n end\n end", "def periods( num )\n @ma.fetch_periods( num )\n end", "def index\n @api_v1_frequency_periods = Api::V1::FrequencyPeriod.all\n end", "def index\n @pay_periods = PayPeriod.all\n end", "def index\n @pay_periods = PayPeriod.all\n end", "def show\n @tb_period = TbPeriod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tb_period }\n end\n end", "def index\n @authorization_periods = AuthorizationPeriod.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @authorization_periods }\n end\n end", "def index\n @vacation_periods = VacationPeriod.all\n end", "def all_periods\n res = Array.new\n res.concat periods_as_admin\n res.concat assignments.map{|a| a.period}\n res.concat groups_as_coach.map{|g| g.period}\n #res.concat teams_as_leader.map{|t| t.period}\n return res.uniq\n end", "def index\n @teaching_periods = TeachingPeriod.all\n end", "def index\n @periods = Period.find(:all, :include => { :talks => :users })\n @periods_by_time_and_scene = Hash.new\n for p in @periods\n @periods_by_time_and_scene[p.time_id] ||= Hash.new\n @periods_by_time_and_scene[p.time_id][p.scene_id] = p \n end\n\n @time_ids = @periods.collect { |p| p.time_id }.sort.uniq\n \n @edit = params[:edit] && admin?\n @all_talks = Talk.all_pending_and_approved if @edit\n @all_talks.sort!{|t1,t2|t1.id <=> t2.id}\n\n respond_to do |format|\n format.html {render :layout => 'plain' }# index.html.erb\n format.xml { render :xml => @periods }\n end\n end", "def index\n @work_periods = WorkPeriod.all\n end", "def show\n @title = \"Show Resources Periods\"\n @resource_period = ResourcePeriod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @resource_period }\n end\n end", "def index\n @receipt_periods = ReceiptPeriod.all\n end", "def index\n @schedule_cohort_periods = ScheduleCohortPeriod.all\n end", "def getAllPeriods()\n aggregateQuery = [\n @dsObj.groupByPeriods(),\n {:$sort => {\"_id.fiscal_year\" => -1, \"_id.fiscal_quarter\" => -1, \"_id.fiscal_month\" => -1, \"_id.fiscal_week\" => -1}}\n ]\n aggregateCursor = @bookingDumpColl.aggregate(aggregateQuery)\n\n yearArray = []; quarterArray = []; monthArray = []; weekArray = [];\n periodsArray = [] \n periodDict = {}\n\n aggregateCursor.each do |doc|\n subDoc = doc[:_id]\n yearArray << subDoc[:fiscal_year]\n quarterArray << subDoc[:fiscal_quarter]\n monthArray << subDoc[:fiscal_month]\n weekArray << subDoc[:fiscal_week]\n periodDict = {\n :periods => {\n :year => subDoc[:fiscal_year],\n :quarter => subDoc[:fiscal_quarter],\n :month => subDoc[:fiscal_month],\n :week => subDoc[:fiscal_week]\n }\n }\n periodsArray << periodDict\n end\n yearArray = yearArray.uniq; yearArray = yearArray.sort\n quarterArray = quarterArray.uniq; quarterArray = quarterArray.sort\n monthArray = monthArray.uniq; monthArray = monthArray.sort\n weekArray = weekArray.uniq; weekArray = weekArray.sort\n\n arrayHash = {\n :yArray => yearArray,\n :qArray => quarterArray,\n :mArray => monthArray,\n :wArray => weekArray,\n :pArray => periodsArray\n }\n return arrayHash\n \n end", "def get_analytics_reporting_timeperiods_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: AnalyticsApi.get_analytics_reporting_timeperiods ...\"\n end\n \n # resource path\n local_var_path = \"/api/v2/analytics/reporting/timeperiods\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<String>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AnalyticsApi#get_analytics_reporting_timeperiods\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def check_for_active_periods\n # puts \"answer #{ @active_period.count() > 0 }\"\n render json: { 'activePeriod': @active_period.count() > 0 }\n end", "def show\n @period = Period.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @period }\n end\n end", "def show\n @period = Period.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @period }\n end\n end", "def check_active_period\n render json: @active_period\n end", "def index\n @scholarship_periods = ScholarshipPeriod.all\n end", "def create_period\n periods_checked = current_user.periods.active.count\n puts \"The user has #{periods_checked} active periods, trying to create a #{params[:nduration].to_i} days period\"\n if periods_checked == 0\n puts \"The user hasn't active periods\"\n @period = current_user.periods.new(is_active: true, is_updated: false, duration: params[:nduration].to_i, start_date: Date.today.to_s, end_date: (Date.today+params[:nduration].to_i).to_s)\n puts @period\n if @period.save\n render json: @period, status: :created, location: @period\n else\n render json: @period.errors, status: :unprocessable_entity\n end\n else\n puts \"The user has active periods\"\n # render json: @period.errors, status: :unprocessable_entity\n render json: { status: 'ERROR', message: \"The user has an active period\"}, status: :unprocessable_entity\n end\n end", "def show\n @periodismo = Periodismo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @periodismo }\n end\n end", "def periods(options = {})\n #reset_first_period\n #reset_last_period\n\n #number_of_buffer_periods=4\n\n #Period.range(\n # self.first_period.find_preceding(number_of_buffer_periods).last,\n # self.last_period.find_following(number_of_buffer_periods).last\n #)\n Period.range(self.first_period, self.last_period)\n end", "def period\n return @period\n end", "def index\n @dis_doseperiods = DisDoseperiod.all\n end", "def actual_periods(length)\n from = Date.today\n to = from + length\n periods.select do |p|\n from < p.end_date && p.start_date <= to\n end\n end", "def index\n @klasses = Klass.paginate(:page => params[:page], per_page: 30)\n @number = Klass.count\n\n respond_to do |format|\n format.html\n format.json { render :json => Klass.all.to_json(include: :period) }\n end\n end", "def periods_params\n params.require(:period).permit(:name, :comment, :start_date, :end_date, :budget_id)\n end", "def dates\n render json: @standings\n end", "def show\r\n @product_period = ProductPeriod.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @product_period }\r\n end\r\n end", "def intervals\n rest.get instrument_path('activeIntervals')\n end", "def periods\n @periods ||= HTMLScanner.new(thead).all(\"th\").map { |e| e.to_s.strip_html.squish }\n end", "def get_periods(first_start, first_end) \n\t\tperiods = []\n\n\t\tnot_ends = \n\t\t\t(@until.is_a? Fixnum) ?\n\t\t\tlambda {|i,d| i < @until} :\n\t\t\tlambda {|i,d| d < @until}\n\n\t\tduration = first_end - first_start\n\t\tcurrent_start = first_start\n\n\t\ti = 0\n\t\twhile not_ends.call(i, current_start)\n\t\t\tperiods << [current_start, current_start + duration]\n\n\t\t\tcurrent_start += @period_duration\n\t\t\ti +=1\n\t\tend\n\n\t\tperiods\n\tend", "def show\n @free_periods = @vending_machine.free_periods.sort {|p,q| p.start_time.hour <=> q.start_time.hour}\n end", "def index\n @child_development_periods = ChildDevelopmentPeriod.all\n end", "def show\n @period = Period.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @period.to_xml }\n end\n end", "def returns(periodKey)\n self.class.get(url(\"liabilities\"), headers: @headers, query: @query )\n end", "def show\n @holiday_song_period = HolidaySongPeriod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @holiday_song_period }\n end\n end", "def get_active_period\n # puts 'ejecutando get_active_period'\n @active_period = current_user.periods.active\n # puts 'get_active_period ejecutado'\n end", "def period_params\n params.require(:period).permit(:name, :start_at, :end_at, :school_id)\n end", "def periods\n \"#{period}s\".to_sym\n end", "def index\n page_number = params[:page] ? params[:page][:number] : 1\n per_page = params[:per_page] ? params[:per_page] : 10\n\n @standings = Standing.paginate(page: page_number, per_page: per_page)\n\n render json: @standings\n end", "def period\n integer_from(\"sf:period\")\n end", "def show\n @interval = Interval.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interval }\n end\n end", "def set_period\n @period = Period.find(params[:id])\n end", "def set_period\n @period = Period.find(params[:id])\n end", "def set_period\n @period = Period.find(params[:id])\n end", "def index\n @breadcrumbs = [[t(:wage_periods), wage_periods_path],\n [@wage_period.name, wage_period_path(@wage_period.id)],\n [t(:wages)]]\n @wage_periods = current_organization.wage_periods.order('id')\n if !params[:wage_period_id] && @wage_periods.count > 0\n params[:wage_period_id] = @wage_periods.first.id\n end\n @wages = current_organization.wages.where('wage_period_id=?', params[:wage_period_id])\n @wages = @wages.page(params[:page]).decorate\n end", "def match_periods\n periods = {}\n periods.merge!(match_year)\n periods.merge!(match_quarter)\n periods.merge!(match_month)\n periods.merge!(match_week)\n periods\n end", "def index\n @reporting_periods = ReportingPeriod.order(date: :desc)\n .includes(:full_reports).page params[:page]\n @data = ::Api::Charts::ReportingPeriod.new(@reporting_periods)\n .reporting_periods_cost_data\n end", "def create\n @period = Period.new(params[:period])\n\n if @period.save\n render json: @period, status: :created, location: @period\n else\n render json: @period.errors, status: :unprocessable_entity\n end\n end", "def index\n ends = End.find_each\n render json: ends\n end", "def index\n streaks = Streak.active.all\n render_jsonapi(streaks)\n end", "def index\n period = params[:period]\n if period.present?\n if period == \"day\"\n @attribute_measures = @attribute.attribute_measures.where(\"created_at >= ?\", Date.today.beginning_of_day)\n elsif period == \"week\"\n #@attribute_measures = @attribute.attribute_measures.where(created_at: Date.today.all_week)\n @attribute_measures = @attribute.attribute_measures.find_by_sql(\"SELECT created_at as created_at, ROUND(AVG(value),2) as value FROM attribute_measures WHERE (created_at BETWEEN '#{1.week.ago}' AND '#{Time.now}') GROUP BY date(created_at), hour(created_at)\")\n elsif period == \"month\"\n #@attribute_measures = @attribute.attribute_measures.where(created_at: Date.today.all_month)\n @attribute_measures = @attribute.attribute_measures.find_by_sql(\"SELECT created_at as created_at, ROUND(AVG(value),2) as value FROM attribute_measures WHERE (created_at BETWEEN '#{1.month.ago}' AND '#{Time.now}') GROUP BY date(created_at)\")\n elsif period == \"year\"\n #@attribute_measures = @attribute.attribute_measures.where(:created_at => Date.today.all_year).order(:created_at).group(\"date(created_at)\").average(:value)\n @attribute_measures = @attribute.attribute_measures.find_by_sql(\"SELECT created_at as created_at, ROUND(AVG(value),2) as value FROM attribute_measures WHERE (created_at BETWEEN '#{1.year.ago}' AND '#{Time.now}') GROUP BY date(created_at)\")\n else\n @attribute_measures = @attribute.attribute_measures.all\n end\n else\n @attribute_measures = @attribute.attribute_measures.all\n end\n\n render json: @attribute_measures.to_json(only:[:value,:created_at])\n end", "def index\n @periods = Period.all\n @all_scholarships = Array.new\n @periods.each do |p|\n @all_scholarships << {\"sesiune\" => p, \"burse\" => Domain.where(:period_id => p.id)}\n end\n end", "def get_period\n result = case @params[:schedule]\n when 'daily' then 'days'\n when 'weekly' then 'weeks'\n when 'monthly' then 'months'\n else 'years'\n end\n\n return result\n end", "def period; end", "def period; end", "def period; end", "def period_params\n params.require(:period).permit(:start, :end, :buget, :activ, :nr_stud, :min_salary)\n end", "def set_time_period\n @time_period = TimePeriod.find(params[:id])\n rescue ActiveRecord::RecordNotFound => e\n render json: e.message.to_json, status: :not_found\n end", "def period_params\n params.require(:period).permit(:first_day, :last_day, :holiday_id, :periodable_id, :periodable_type)\n end", "def index\n @sightings = Sighting.where(date: params[:start_date]..params[:end_date])\n render json: @sightings\n end", "def period_params\n params.require(:period).permit(:is_active, :is_updated, :duration, :start_date, :end_date)\n end", "def period(period_content)\n if period_content[\"startDate\"] && period_content[\"endDate\"]\n return {\"start_date\" => Date.parse(period_content[\"startDate\"][0][\"content\"]), \"end_date\" => Date.parse(period_content[\"endDate\"][0][\"content\"])}\n elsif period_content[\"instant\"]\n return Date.parse(period_content[\"instant\"][0][\"content\"])\n elsif period_content[\"forever\"]\n return Context::PERIOD_FOREVER\n end\n end", "def period=(value)\n @period = value\n end", "def index\n @schedule_entries = ScheduleEntry.all\n current_date = Date.today\n monday = current_date.monday\n dates_this_week = [monday, monday.next, monday.next.next, monday.next.next.next, monday.next.next.next.next]\n @grouped_periods = Period.where(:date => dates_this_week).group_by {|period| period.num}.values\n end", "def update\n period = current_user.school.periods.find(params[:id])\n\n if period.update(period_params)\n render json: period, status: :accepted\n else\n render json: {errors: period.errors}, status: :unprocessable_entity\n end\n end", "def index\n @periodo_para_ingresars = PeriodoParaIngresar.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @periodo_para_ingresars }\n end\n end", "def index\n @time = Time.new\n @prev_time = @time - 1.month\n @next_time = @time + 1.month\n @months = [@prev_time, @time, @next_time]\n @month_time_format = \"%B %Y\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @budgets }\n end\n end", "def representatives(period)\n fetch \"eksport/representanter/?StortingsPeriodeId=#{period}\"\n end", "def hours\n render json: Pings::Selector.new.hours(params)\n end", "def show\n @authorization_period = AuthorizationPeriod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @authorization_period }\n end\n end", "def index\n @biodata = Biodatum.all\n end", "def index\n @timesheets = Timesheet.all\n render json: @timesheets\n end", "def period_params\n params.require(:period).permit(:start_date, :end_date, :user_id)\n end", "def index\n @incidents = apply_scopes(Incident).order(\"occured_on\").page(params[:page]).per(50)\n @location_groups = LocationGroup.all\n\n if params[:location] && params[:location] > \"\"\n location = Location.find(params[:location])\n @location_name = location.name\n end\n\n @start_date = params[:by_period].try(:[], :start_date).try(:to_date) ||\n Incident.default_period_range.first\n @end_date = params[:by_period].try(:[], :end_date).try(:to_date) ||\n Incident.default_period_range.end\n @incident_types = Incident.uniq.order(\"incident_type\").pluck(:incident_type)\n logger.debug @incident_types\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @incidents }\n end\n end", "def retrieve_date_range\n @free_period = false\n @from, @to = nil, nil\n\n if params[:period_type] == '1' || (params[:period_type].nil? && !params[:period].nil?)\n case params[:period].to_s\n when 'today'\n @from = @to = Date.today\n when 'yesterday'\n @from = @to = Date.today - 1\n when 'current_week'\n @from = Date.today - (Date.today.cwday - 1)%7\n @to = @from + 6\n when 'last_week'\n @from = Date.today - 7 - (Date.today.cwday - 1)%7\n @to = @from + 6\n when '7_days'\n @from = Date.today - 7\n @to = Date.today\n when 'current_month'\n @from = Date.civil(Date.today.year, Date.today.month, 1)\n @to = (@from >> 1) - 1\n when 'last_month'\n @from = Date.civil(Date.today.year, Date.today.month, 1) << 1\n @to = (@from >> 1) - 1\n when '30_days'\n @from = Date.today - 30\n @to = Date.today\n when 'current_year'\n @from = Date.civil(Date.today.year, 1, 1)\n @to = Date.civil(Date.today.year, 12, 31)\n end\n elsif params[:period_type] == '2' || (params[:period_type].nil? && (!params[:from].nil? || !params[:to].nil?))\n begin; @from = params[:from].to_s.to_date unless params[:from].blank?; rescue; end\n begin; @to = params[:to].to_s.to_date unless params[:to].blank?; rescue; end\n @free_period = true\n else\n # default\n end\n \n @from, @to = @to, @from if @from && @to && @from > @to\n\n end", "def new\n @tb_period = TbPeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tb_period }\n end\n end", "def create_grading_periods(interval, year, ed_org_id)\n grading_periods = []\n grading_periods << {\"type\" => :END_OF_YEAR, \"year\" => year, \"interval\" => interval, \"ed_org_id\" => ed_org_id}\n grading_periods\n end", "def company_onethings(start_date,period,interval)\n\t\tbegin\n\t url = URI.parse(Rails.application.secrets[:api_endpoints]['onething']['url_all_company'])\n\t\t url_params = {\"period\" => period, \"start_date\" => start_date, \"interval\" => interval}\n\t\t path = \"#{url.path}?#{url_params.collect { |k,v| \"#{k}=#{CGI::escape(v.to_s)}\"}.join('&')}\"\n\t\t request = Net::HTTP::Get.new(path) \n\t\t response = Net::HTTP.start(url.host, url.port, :use_ssl => false, :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http| \n\t\t http.request(request)\n\t\t end \n\t\t json_data = JSON.parse(response.body) rescue nil\n\t\t if !json_data.present?\n\t\t \treturn {}\n\t\t else\n\t\t return json_data\n\t\t end\n\t rescue => e\n\t \treturn {:message => 'Error in fetchng API data. Please try again.'}\t\n\t end\n\tend", "def period_params\n params.require(:period).permit(:number, :code, :explanation, :start_date, :end_date)\n end", "def period\n\t\t\t\t5\n\t\t\tend", "def show\n @periodo_academico = PeriodoAcademico.find(params[:id])\n\n render json: @periodo_academico\n end", "def retrieve_date_range\n\t\t@free_period = false\n\t\t@from, @to = nil, nil\n\t\tperiod_type = params[:period_type]\n\t\tperiod = params[:period]\n\t\tfromdate = params[:from]\n\t\ttodate = params[:to]\n\n\t\tif (period_type == '1' || (period_type.nil? && !period.nil?)) \n\t\t case period.to_s\n\t\t when 'current_month'\n\t\t\t@from = Date.civil(Date.today.year, Date.today.month, 1)\n\t\t\t@to = (@from >> 1) - 1\n\t\t when 'last_month'\n\t\t\t@from = Date.civil(Date.today.year, Date.today.month, 1) << 1\n\t\t\t@to = (@from >> 1) - 1\n\t\t end\n\t\telsif period_type == '2' || (period_type.nil? && (!fromdate.nil? || !todate.nil?))\n\t\t begin; @from = Date.civil((fromdate.to_s.to_date).year,(fromdate.to_s.to_date).month, 1) unless fromdate.blank?; rescue; end\n\t\t begin; @to = (@from >> 1) - 1 unless @from.blank?; rescue; end\n\t\t if @from.blank?\n\t\t\t@from = Date.civil(Date.today.year, Date.today.month, 1)\n\t\t\t@to = (@from >> 1) - 1\n\t\t end\n\t\t @free_period = true\n\t\telse\n\t\t # default\n\t\t # 'current_month'\t\t\n\t\t\t@from = Date.civil(Date.today.year, Date.today.month, 1)\n\t\t\t@to = (@from >> 1) - 1\n\t\tend \n\t\t\n\t\t@from, @to = @to, @from if @from && @to && @from > @to\n\n\t end", "def create\n period = current_user.school.periods.create(period_params)\n\n if period.save\n render json: period, status: :created, location: period\n else\n render json: {errors: period.errors}, status: :unprocessable_entity\n end\n end" ]
[ "0.7931133", "0.75391394", "0.7499614", "0.7338183", "0.73185486", "0.7263721", "0.72523004", "0.7083454", "0.6967688", "0.691698", "0.6834991", "0.6755399", "0.6590099", "0.65424144", "0.6511148", "0.6462379", "0.6462379", "0.6404114", "0.6399585", "0.63783365", "0.63536614", "0.6300231", "0.622495", "0.6200614", "0.6170636", "0.6163111", "0.6122033", "0.6078348", "0.6074603", "0.5992489", "0.5958061", "0.5958061", "0.5947721", "0.59024817", "0.59023225", "0.5886212", "0.5867502", "0.58368576", "0.5836717", "0.58362836", "0.5834601", "0.5818794", "0.5817275", "0.5811679", "0.57993865", "0.579525", "0.57942677", "0.57878727", "0.57556945", "0.5748038", "0.5742352", "0.57402", "0.57351565", "0.57173073", "0.56990117", "0.5675803", "0.56141305", "0.56045926", "0.5591172", "0.5591172", "0.5591172", "0.5588697", "0.55776817", "0.5564875", "0.5549965", "0.554585", "0.5542916", "0.552357", "0.55021536", "0.54943055", "0.5490963", "0.5490963", "0.5490963", "0.5486803", "0.5477553", "0.5465939", "0.54598373", "0.54569584", "0.545479", "0.5453597", "0.5452838", "0.54524195", "0.54502183", "0.54315996", "0.5429276", "0.54260594", "0.54175407", "0.54174805", "0.5411909", "0.5406956", "0.54060185", "0.54057753", "0.5402827", "0.5401575", "0.5397856", "0.5388142", "0.5374542", "0.53737736", "0.5368459", "0.536613" ]
0.6983398
8
GET /periods/new GET /periods/new.json
def new if @organism.periods.any? @disable_start_date = true start_date = (@organism.periods.order(:close_date).last.close_date) +1 # begin_year and end_year limit the select in the the view @begin_year = start_date.year @end_year = @begin_year + 2 # else @disable_start_date = false @begin_year = @end_year = nil start_date = Date.today.beginning_of_year # on propose une date d'ouverture par défaut end close_date = start_date.years_since(1)-1 # et une date de clôture probable @period = @organism.periods.new(:start_date=>start_date, :close_date=>close_date) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @title = \"New Resources Periods\"\n @resource_period = ResourcePeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @resource_period }\n end\n end", "def new\n @tb_period = TbPeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tb_period }\n end\n end", "def new\n @period = Period.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @period }\n end\n end", "def new\n @periodismo = Periodismo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @periodismo }\n end\n end", "def create\n @period = Period.new(params[:period])\n\n if @period.save\n render json: @period, status: :created, location: @period\n else\n render json: @period.errors, status: :unprocessable_entity\n end\n end", "def new\n @interval = Interval.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interval }\n end\n end", "def new\n @period = @cursus.periods.build\n\n respond_to do |format|\n format.html { render :layout => false }\n format.xml { render :xml => @period }\n end\n end", "def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @registration_period }\n end\n end", "def create\n period = current_user.school.periods.create(period_params)\n\n if period.save\n render json: period, status: :created, location: period\n else\n render json: {errors: period.errors}, status: :unprocessable_entity\n end\n end", "def create_period\n periods_checked = current_user.periods.active.count\n puts \"The user has #{periods_checked} active periods, trying to create a #{params[:nduration].to_i} days period\"\n if periods_checked == 0\n puts \"The user hasn't active periods\"\n @period = current_user.periods.new(is_active: true, is_updated: false, duration: params[:nduration].to_i, start_date: Date.today.to_s, end_date: (Date.today+params[:nduration].to_i).to_s)\n puts @period\n if @period.save\n render json: @period, status: :created, location: @period\n else\n render json: @period.errors, status: :unprocessable_entity\n end\n else\n puts \"The user has active periods\"\n # render json: @period.errors, status: :unprocessable_entity\n render json: { status: 'ERROR', message: \"The user has an active period\"}, status: :unprocessable_entity\n end\n end", "def create_new_period(period)\n JSON.generate(period)\n File.open(\"./files/periods/#{period[:name]}.json\", \"w\") do |f|\n f.write(period.to_json)\n end\nend", "def new\n @workday = Workday.new\n 2.times do\n @workday.periods.build\n end\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @workday }\n end\n end", "def new\n @holiday_song_period = HolidaySongPeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @holiday_song_period }\n end\n end", "def new\n @new_policy = NewPolicy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_policy }\n end\n end", "def new\n @sleep = Sleep.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @sleep }\n end\n end", "def create\n @resource_period = ResourcePeriod.new(params[:resource_period])\n\n respond_to do |format|\n if @resource_period.save\n format.html { redirect_to(@resource_period, :notice => 'Resource period was successfully created.') }\n format.json { render :json => @resource_period, :status => :created, :location => @resource_period }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @resource_period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @time_period = TimePeriod.new(time_period_params)\n\n if @time_period.save\n render :show, status: :created, location: @time_period\n else\n render json: @time_period.errors, status: :unprocessable_entity\n end\n end", "def new\n @historical = Historical.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @historical }\n end\n end", "def create\n @period = Period.new(params[:period])\n\n respond_to do |format|\n if @period.save\n flash[:notice] = _('%s was successfully created.', Period.human_name)\n format.html { redirect_to period_url(@period) }\n format.xml { head :created, :location => period_url(@period) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @period.errors.to_xml }\n end\n end\n end", "def new\n @periodos = Periodo.all.collect{|p|[\"#{t p.inicio.strftime(\"%B\")} - #{t p.fim.strftime(\"%B\")}\",p.id]}\n @requisicao = Requisicao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @requisicao }\n end\n end", "def new\n @authorization_period = AuthorizationPeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @authorization_period }\n end\n end", "def create\n @period = Period.new(period_params)\n\n respond_to do |format|\n if @period.save\n format.html { redirect_to periods_path, notice: 'Periode Telah Dibuat.' }\n format.json { render :show, status: :created, location: @period }\n else\n format.html { render :new }\n format.json { render json: @period.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @period = Period.new(params[:period])\n\n respond_to do |format|\n if @period.save\n flash[:notice] = 'Period was successfully created.'\n format.html { redirect_to(@period) }\n format.xml { render :xml => @period, :status => :created, :location => @period }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @periodo_para_ingresar = PeriodoParaIngresar.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @periodo_para_ingresar }\n end\n end", "def new\n fetch_data\n @payment = Payment.new(:payment_date => Date.today)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @payment }\n end\n end", "def new\n @quantile_period = QuantilePeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quantile_period }\n end\n end", "def get_periods\n @periods = current_user.periods.all.order(created_at: :desc)\n render json: @periods\n end", "def new\n @activity = Activity.new\n @series = get_series('activities')\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @activity }\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 create\n @tb_period = TbPeriod.new(params[:tb_period])\n\n respond_to do |format|\n if @tb_period.save\n format.html { redirect_to @tb_period, notice: 'Tb period was successfully created.' }\n format.json { render json: @tb_period, status: :created, location: @tb_period }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tb_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @planned_time = PlannedTime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @planned_time }\n end\n end", "def show\n @period = Period.find(params[:id])\n\n render json: @period\n end", "def new\n @moment = Moment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @moment }\n end\n end", "def new\n \n @project = Project.new\n @orientadores = User.find_all_by_role(\"Orientador\")\n \n @periodos = Duedate.find(:all, :conditions => ['orientation_start <= ? AND orientation_end >= ?', Date.today, Date.today])\n @periodo = @periodos[0]\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n \n \n \n\n \n end", "def new\n @observation = Observation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @observation }\n end\n end", "def new\n @observation = Observation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @observation }\n end\n end", "def new\n @entry = Entry.new(dob: Date.new(Date.today.year - 18, 1, 1))\n get_events\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end", "def new\n @workperiod = Workperiod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @workperiod }\n end\n end", "def new\n @trading_strategy = TradingStrategy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trading_strategy }\n end\n end", "def new\n @arrival_range = ArrivalRange.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @arrival_range }\n end\n end", "def new\n @pay_period = PayPeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pay_period }\n end\n end", "def new\n @holding = Holding.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holding }\n end\n end", "def new\n @holding = Holding.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holding }\n end\n end", "def new\n @lease = Lease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lease }\n end\n end", "def new\n @points_history = PointsHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @points_history }\n end\n end", "def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @time_frame }\n end\n end", "def new\n \n #timestamp={{FellAsleepAt}}&total_sleep={{TotalTimeSleptInSeconds}}&deep={{TimeInDeepSleepSeconds}}&light={{TimeInLightSleepSeconds}}&awake={{TimeAwakeSeconds}}\n \n json_hash = Hash.new\n \n @sleep = json_hash\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sleep }\n end\n end", "def new\n @except = Except.new\n @policy = Policy.find(:all)\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @except }\n end\n end", "def new\n @historial_odt = HistorialOdt.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @historial_odt }\n end\n end", "def new\n @annual_stat = AnnualStat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @annual_stat }\n end\n end", "def new\n @lost = Lost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost }\n end\n end", "def new\n @nursing_time = NursingTime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nursing_time }\n end\n end", "def new\n @slot = Slot.new\n\n @slots = Slot.opening_hours.where(:company_id => current_user.company.id)\n @available_days = get_available_days(@slots)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @slot }\n end\n end", "def new\n @date = Date.new params[:y].to_i, params[:m].to_i, params[:d].to_i\n @title = \"Add time entry for #{@date}\"\n @timesheet = Timesheet.new :day => @date, :hours => 8\n @accounts = Account.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @timesheet }\n end\n end", "def new\n @timeline = Timeline.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @timeline }\n end\n end", "def new\n @time_gap = TimeGap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @time_gap }\n end\n end", "def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stat }\n end\n end", "def new\n @periodista = Periodista.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @periodista }\n end\n end", "def new\n @atom.hours = 24\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @atom }\n end\n end", "def new\n @decision = Decision.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @decision }\n end\n end", "def new\n @budget = Budget.new\n @budget.year = Time.new.year\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @budget }\n end\n end", "def new\n load_dependents\n @training_calendar = TrainingCalendar.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @training_calendar }\n end\n end", "def new\n @salary_range = SalaryRange.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @salary_range }\n end\n end", "def new\n @absence = Absence.new\n @title = \"New Absence\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @absence }\n end\n end", "def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @stat }\n end\n end", "def new\n @weekly_expectation = WeeklyExpectation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @weekly_expectation }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cohort }\n end\n end", "def new\n @time_balance = TimeBalance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @time_balance }\n end\n end", "def new\n @present = Present.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @present }\n end\n\n end", "def new\n @pst = Pst.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @pst }\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 @fundamentals_history = FundamentalsHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fundamentals_history }\n end\n end", "def new\n @time_slot = TimeSlot.new\n @recurrence_array = []\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @time_slot }\n end\n end", "def new\n @patent = Patent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patent }\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 @trading_strategy_set = TradingStrategySet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trading_strategy_set }\n end\n end", "def new\n @dailyStanding = DailyStanding.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @dailyStanding }\n end\n end", "def new\n @series = Series.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @series }\n end\n end", "def new\n @historial = Historial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @historial }\n end\n end", "def new\n @financial = Financial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @financial }\n end\n end", "def new\n @prioridade = Prioridade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prioridade }\n end\n end", "def new\n @potd = Potd.new\n @action = \"Create\"\n @active_school_day = SchoolDay.find(params[:day]) unless params[:day].nil? || params[:day].empty?\n load_prev_and_next_day\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @potd }\n end\n end", "def new\n @closing_day = ClosingDay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @closing_day }\n end\n end", "def new\n @finance = Finance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @finance }\n end\n end", "def new\n @time_section = TimeSection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @time_section }\n end\n end", "def create\n @period = Period.new(period_params)\n\n respond_to do |format|\n if @period.save\n format.html { redirect_to @period.school, notice: 'Period was successfully created.' }\n format.json { render :show, status: :created, location: @period.school }\n else\n format.html { render :new }\n format.json { render json: @period.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trial }\n end\n end", "def new\n @withdrawal = Withdrawal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @withdrawal }\n end\n end", "def new(options) \n Client.get(\"/patterns/new\", :query => options)\n end", "def new\n @status = Status.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @status }\n end\n end", "def new\n @series = Series.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @series }\n end\n end", "def new\n @patient_history = PatientHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patient_history }\n end\n end", "def new\n @polling_session = PollingSession.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @polling_session }\n end\n end", "def new\n @ongoing = Ongoing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ongoing }\n end\n end", "def new\n @politicalcommittee = Politicalcommittee.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @politicalcommittee }\n end\n end", "def new\n @get = Get.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @get }\n end\n end", "def new\n @page = 'newdoll'\n @doll = current_user.dolls.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @doll }\n end\n end", "def new\n @active_stat = ActiveStat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @active_stat }\n end\n end", "def new\n @time_point = TimePoint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @time_point }\n end\n end", "def new\n @strategy = Strategy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @strategy }\n end\n end" ]
[ "0.74636674", "0.72604084", "0.7087081", "0.69765055", "0.6967836", "0.694958", "0.68680185", "0.6729341", "0.66939074", "0.6691118", "0.6603186", "0.65806526", "0.6570101", "0.65423864", "0.6514642", "0.651029", "0.650848", "0.6495663", "0.6461202", "0.6446872", "0.6403545", "0.63747185", "0.6348939", "0.63165593", "0.62927425", "0.62922317", "0.6289518", "0.6260388", "0.62597704", "0.6257641", "0.6244693", "0.6242393", "0.62069786", "0.61993235", "0.6197073", "0.6197073", "0.61899704", "0.6184058", "0.61822903", "0.616052", "0.6130733", "0.6127193", "0.6127193", "0.6126615", "0.61150897", "0.6100744", "0.6097962", "0.6097141", "0.6084922", "0.6082834", "0.6080479", "0.60723746", "0.6067483", "0.6066041", "0.6064045", "0.60573363", "0.60459334", "0.60432374", "0.60421497", "0.60299546", "0.60214096", "0.60181427", "0.601206", "0.6008002", "0.599819", "0.59921235", "0.5992119", "0.5991467", "0.5986162", "0.5982424", "0.59818506", "0.59818506", "0.59779525", "0.59777284", "0.5976713", "0.59735537", "0.5970465", "0.59619546", "0.59596056", "0.5948946", "0.5948432", "0.59472716", "0.59454095", "0.59450823", "0.5945065", "0.59406203", "0.59252006", "0.59234107", "0.59220535", "0.5916161", "0.5914992", "0.5913071", "0.59110224", "0.59103763", "0.5902544", "0.5901769", "0.5901292", "0.58978075", "0.58910674", "0.5890887", "0.5890218" ]
0.0
-1
DELETE /periods/1 DELETE /periods/1.json
def destroy @period = Period.find(params[:id]) if @period.destroy session[:period] = @organism.periods.any? ? @organism.periods.order(:close_date).last.id : nil flash[:notice] = 'L\'exercice a été détruit ; vous avez changé d\'exercice' end respond_to do |format| format.html do redirect_to admin_organism_periods_url(@organism) end format.json { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @time_period.destroy\n format.json { head :no_content }\n end", "def destroy\n @period = Period.find(params[:id])\n @period.destroy\n\n head :no_content\n end", "def destroy\n @tb_period = TbPeriod.find(params[:id])\n @tb_period.destroy\n\n respond_to do |format|\n format.html { redirect_to tb_periods_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @period.destroy\n\n head :no_content\n end", "def destroy\n @period = Period.find(params[:id])\n @period.destroy\n\n respond_to do |format|\n format.html { redirect_to(periods_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @resource_period = ResourcePeriod.find(params[:id])\n @resource_period.destroy\n\n respond_to do |format|\n format.html { redirect_to(resource_periods_url) }\n format.json { head :ok }\n end\n end", "def destroy\n @period = Period.find(params[:id])\n @period.destroy\n\n respond_to do |format|\n format.html { redirect_to periods_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @period.destroy\n respond_to do |format|\n format.html { redirect_to periods_url, notice: 'Periode Telah Dihapus.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_frequency_period.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_frequency_periods_url, notice: 'Frequency period was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @schedule_cohort_period.destroy\n respond_to do |format|\n format.html { redirect_to schedule_cohort_periods_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @periodismo = Periodismo.find(params[:id])\n @periodismo.destroy\n\n respond_to do |format|\n format.html { redirect_to periodismos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @periodic.destroy\n respond_to do |format|\n format.html { redirect_to periodics_url, notice: 'Periodic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @vacation_period.destroy\n respond_to do |format|\n format.html { redirect_to vacation_periods_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @study_period.destroy\n respond_to do |format|\n format.html { redirect_to study_year_study_periods_path(current_user.current_year) }\n format.json { head :no_content }\n end\n end", "def destroy\n @periodic.destroy\n respond_to do |format|\n format.html { redirect_to periodics_url, notice: 'Periódico excluido com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @period.destroy\n respond_to do |format|\n format.html { redirect_to @period.school, notice: 'Period was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @quantile_period = QuantilePeriod.find(params[:id])\n @quantile_period.destroy\n\n respond_to do |format|\n format.html { redirect_to quantile_periods_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @period = Period.find(params[:id])\n @period.destroy\n\n respond_to do |format|\n format.html { redirect_to( cursus_periods_path(@cursus) ) }\n format.xml { head :ok }\n end\n end", "def destroy\n @periods_group.destroy\n respond_to do |format|\n format.html { redirect_to company_periods_groups_path(@company), notice: 'Periods group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @registration_period.destroy\n\n respond_to do |format|\n format.html { redirect_to registration_periods_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @doseperiod.destroy\n respond_to do |format|\n format.html { redirect_to doseperiods_url, notice: 'Combination dose was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @holiday_song_period = HolidaySongPeriod.find(params[:id])\n @holiday_song_period.destroy\n\n respond_to do |format|\n format.html { redirect_to holiday_song_periods_url }\n format.json { head :ok }\n end\n end", "def destroy\n @dis_doseperiod.destroy\n respond_to do |format|\n format.html { redirect_to dis_doseperiods_url, notice: 'Dis doseperiod was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @historial_odt = HistorialOdt.find(params[:id])\n @historial_odt.destroy\n\n respond_to do |format|\n format.html { redirect_to historial_odts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pay_period.destroy\n respond_to do |format|\n format.html { redirect_to pay_periods_url, notice: 'Pay period was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @stock_interval.destroy\n respond_to do |format|\n format.html { redirect_to stock_intervals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @interval = Interval.find(params[:id])\n @interval.destroy\n\n respond_to do |format|\n format.html { redirect_to intervals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pay_period = PayPeriod.find(params[:id])\n @pay_period.destroy\n\n respond_to do |format|\n format.html { redirect_to(pay_periods_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @time_series.destroy\n\n respond_to do |format|\n format.html { redirect_to time_series_index_url(@owner), flash: {success: t('app.msgs.success_deleted', :obj => t('mongoid.models.time_series.one'))} }\n format.json { head :no_content }\n end\n end", "def destroy\n @periodista = Periodista.find(params[:id])\n @periodista.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_periodistas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @reporting_period.destroy\n respond_to do |format|\n format.html { redirect_to reporting_periods_url, notice: \"Reporting period was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @duration.destroy\n\n head :no_content\n end", "def destroy\n @receipt_period.destroy\n respond_to do |format|\n format.html { redirect_to receipt_periods_url, notice: 'Receipt period was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @periodicity.destroy\n respond_to do |format|\n format.html { redirect_to periodicities_url, notice: 'Periodicity was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @teaching_period.destroy\n respond_to do |format|\n format.html { redirect_to teaching_periods_url, notice: 'Teaching period was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n# @chart = Chart.find(params[:id])\n @chart.destroy\n\n respond_to do |format|\n format.html { redirect_to charts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @historical = Historical.find(params[:id])\n @historical.destroy\n\n respond_to do |format|\n format.html { redirect_to historicals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @timechart = Timechart.find(params[:id])\n @timechart.destroy\n\n respond_to do |format|\n format.html { redirect_to timecharts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @weekly_expectation = WeeklyExpectation.find(params[:id])\n @weekly_expectation.destroy\n\n respond_to do |format|\n format.html { redirect_to weekly_expectations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @rescue_time_chart.destroy\n respond_to do |format|\n format.html { redirect_to rescue_time_charts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @interval.destroy\n respond_to do |format|\n format.html { redirect_to intervals_url, notice: 'Interval was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @scholarship_period.destroy\n respond_to do |format|\n format.html { redirect_to scholarship_periods_url, notice: 'Период степендии успешно удален.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @period_milk_production.destroy\n respond_to do |format|\n format.html { redirect_to period_milk_productions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workperiod = Workperiod.find(params[:id])\n @workperiod.destroy\n\n respond_to do |format|\n format.html { redirect_to(workperiods_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @sleep = Sleep.find(params[:id])\n @sleep.destroy\n\n respond_to do |format|\n format.html { redirect_to sleeps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_expense.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_expenses_url, notice: 'Expense was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @daily_step.destroy\n respond_to do |format|\n format.html { redirect_to daily_steps_url, notice: 'Daily step was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @daily_data_payment.destroy\n respond_to do |format|\n format.html { redirect_to daily_data_payments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @datapoint.destroy\n respond_to do |format|\n format.html { redirect_to datapoints_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sleep_datum.destroy\n respond_to do |format|\n format.html { redirect_to sleep_data_url, notice: 'Sleep datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @duration_frequency = DurationFrequency.find(params[:id])\n @duration_frequency.destroy\n\n respond_to do |format|\n format.html { redirect_to duration_frequencies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @child_development_period.destroy\n respond_to do |format|\n format.html { redirect_to child_development_periods_url, notice: 'Child development period was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @periodo_academico = PeriodoAcademico.find(params[:id])\n @periodo_academico.destroy\n\n head :no_content\n end", "def destroy\n @daily_horoscope = DailyHoroscope.find(params[:id])\n @daily_horoscope.destroy\n\n respond_to do |format|\n format.html { redirect_to daily_horoscopes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lifespan = Lifespan.find(params[:id])\n @lifespan.destroy\n\n respond_to do |format|\n format.html { redirect_to lifespans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @status_ativ = StatusAtiv.find(params[:id])\n @status_ativ.destroy\n\n respond_to do |format|\n format.html { redirect_to status_ativs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @historial = Historial.find(params[:id])\n @historial.destroy\n\n respond_to do |format|\n format.html { redirect_to historials_url }\n format.json { head :ok }\n end\n end", "def delete\n render json: Company.delete(params[\"id\"])\n end", "def destroy\n @timeline = Timeline.find(params[:id])\n @timeline.destroy\n\n respond_to do |format|\n format.html { redirect_to timelines_url }\n format.json { head :no_content }\n end\n end", "def destroy\n Audit.find(params[:id]).destroy\n head :no_content\n end", "def destroy\n @datum = Datum.find(params[:id])\n @datum.destroy\n\n respond_to do |format|\n format.html { redirect_to data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @datum = Datum.find(params[:id])\n @datum.destroy\n\n respond_to do |format|\n format.html { redirect_to data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @timeline.destroy\n respond_to do |format|\n format.html { redirect_to timelines_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @biodatum.destroy\n respond_to do |format|\n format.html { redirect_to biodata_url, notice: \"Biodatum was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @trading_time_frame = TradingTimeFrame.find(params[:id])\n @trading_time_frame.destroy\n\n respond_to do |format|\n format.html { redirect_to trading_time_frames_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 @moment = Moment.find(params[:id])\n @moment.destroy\n\n respond_to do |format|\n format.html { redirect_to moments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dis_duration.destroy\n respond_to do |format|\n format.html { redirect_to dis_durations_url, notice: 'Dis duration was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def destroy\n \t#chart = Chart.find(params[:chart_id])\n \tchart = Chart.where(\"id = ? AND user_id = ?\", params[:chart_id], current_user.id).limit(1)[0]\n \tdata_set = chart.data_sets.find(params[:id])\n \tdata_set.destroy\n\n respond_with(data_set) do |format|\n format.json { render json: { success: data_set.destroyed? } }\n end\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def destroy\n @series_statement.destroy\n\n respond_to do |format|\n format.html { redirect_to series_statements_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @appointment.destroy\n head 204\n end", "def destroy\n @titletime.destroy\n respond_to do |format|\n format.html { redirect_to titletimes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @patient_condition = PatientCondition.find(params[:id])\n @patient_condition.destroy\n\n respond_to do |format|\n format.html { redirect_to patient_conditions_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Post.delete(params[\"id\"])\n end", "def destroy\n @absent.destroy\n\n respond_to do |format|\n format.html { redirect_to absents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_section = TimeSection.find(params[:id])\n @time_section.destroy\n\n respond_to do |format|\n format.html { redirect_to time_sections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @daily_happiness.destroy\n respond_to do |format|\n format.html { redirect_to daily_happinesses_url, notice: 'Daily happiness was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @line = Line.find(params[:id])\n @line.destroy\n\n respond_to do |format|\n format.html { redirect_to budget_path(@line.budget) }\n format.json { head :no_content }\n end\n end", "def destroy\n @assumption.destroy\n respond_to do |format|\n format.html { redirect_to assumptions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_gap = TimeGap.find(params[:id])\n @time_gap.destroy\n\n respond_to do |format|\n format.html { redirect_to time_gaps_url }\n format.json { head :ok }\n end\n end", "def destroy\n @wait = Wait.find(params[:id])\n @wait.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @stage_duration = StageDuration.find(params[:id])\n @stage_duration.destroy\n\n respond_to do |format|\n format.html { redirect_to stage_durations_url }\n format.json { head :no_content }\n end\n end", "def delete\n request(:delete)\n end", "def destroy\n @sleep = current_user.sleeps.find(params[:id])\n @sleep.destroy\n\n respond_to do |format|\n format.html { redirect_to sleeps_url }\n format.json { head :ok }\n end\n end", "def destroy\n @dailyStanding = DailyStanding.find(params[:id])\n @dailyStanding.destroy\n\n respond_to do |format|\n format.html { redirect_to dailyStanding_url }\n format.json { head :ok }\n end\n end", "def destroy\n @time_off_request = TimeOffRequest.find(params[:id])\n @time_off_request.destroy\n \n respond_to do |format|\n format.html { redirect_to admin_time_off_requests_url}\n format.json { head :ok }\n end\n end", "def destroy\n @daw_periodo_acad.destroy\n respond_to do |format|\n format.html { redirect_to daw_periodo_acads_url, notice: 'Daw periodo acad was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @theory_day.destroy\n respond_to do |format|\n format.html { redirect_to theory_days_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @essay = Essay.find(params[:id])\n @essay.destroy\n\n respond_to do |format|\n format.html { redirect_to assignment_essays_path(params[:assignment_id]) }\n format.json { head :no_content }\n end\n end", "def delete\n api_client.delete(url)\n end", "def destroy\n @time_frame.destroy\n\n respond_to do |format|\n format.html { redirect_to time_frames_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @chart = Chart.find(params[:id])\n @chart.destroy\n respond_with(@chart)\n end", "def destroy\n @historic.destroy\n respond_to do |format|\n format.html { redirect_to historics_url, notice: 'Historic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.7818458", "0.7555096", "0.74889266", "0.7486217", "0.74291295", "0.7370233", "0.73162484", "0.7293146", "0.7238291", "0.7164498", "0.700519", "0.6993836", "0.6993655", "0.6932407", "0.6929588", "0.6929204", "0.6921115", "0.6902328", "0.6872384", "0.68497676", "0.6844296", "0.6819253", "0.6810954", "0.68105155", "0.68060017", "0.6798841", "0.67566675", "0.67483854", "0.6732011", "0.6714246", "0.66640633", "0.66339344", "0.6601237", "0.65891093", "0.6581838", "0.6579148", "0.65598506", "0.6548133", "0.65270615", "0.6498684", "0.6490593", "0.6486696", "0.6480673", "0.6472761", "0.6467729", "0.6461246", "0.6449387", "0.644723", "0.6443997", "0.6443588", "0.6438966", "0.643036", "0.64274985", "0.64247733", "0.6412664", "0.6408152", "0.63984394", "0.6396008", "0.639514", "0.6393307", "0.63912624", "0.63773173", "0.63773173", "0.6367011", "0.6358786", "0.6357343", "0.6357044", "0.6357044", "0.6357044", "0.6357044", "0.6344657", "0.633671", "0.6333121", "0.6314393", "0.6311162", "0.630577", "0.63040215", "0.62982655", "0.62916505", "0.6289432", "0.6287102", "0.6284797", "0.6281121", "0.62803805", "0.6272021", "0.62678856", "0.6267756", "0.6266564", "0.6266219", "0.6260155", "0.62599653", "0.6259762", "0.6258697", "0.6257369", "0.62557435", "0.6253991", "0.6249647", "0.6248061", "0.6247907", "0.62470025" ]
0.6689559
30
OpenSSL verify callback used by initialize when optional callback argument isn't set.
def verify_callback(_, cert) pem = cert.current_cert.public_key.to_pem sha256 = OpenSSL::Digest::SHA256.new hash = sha256.digest(pem).unpack("H*") hash[0].casecmp(@hash).zero? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verify_callback=(verify_callback); end", "def verify_callback=(verify_callback); end", "def verify_callback; end", "def verify_callback; end", "def register_verify_callback(connection)\n connection.verify_callback = self\n end", "def verify_callback= verify_callback\n @agent.verify_callback = verify_callback\n end", "def tls_verify=(_arg0); end", "def verify_callback\n @agent.verify_callback\n end", "def default_verify_callback(is_ok, ctx)\n if $DEBUG\n puts \"#{ is_ok ? 'ok' : 'ng' }: #{ctx.current_cert.subject}\"\n end\n if !is_ok\n depth = ctx.error_depth\n code = ctx.error\n msg = ctx.error_string\n STDERR.puts \"at depth #{depth} - #{code}: #{msg}\"\n end\n is_ok\n end", "def sample_verify_callback(is_ok, ctx)\n unless is_ok\n depth = ctx.error_depth\n code = ctx.error\n msg = ctx.error_string\n STDERR.puts \"at depth #{depth} - #{code}: #{msg}\" if $DEBUG\n return false\n end\n\n cert = ctx.current_cert\n self_signed = false\n ca = false\n pathlen = nil\n server_auth = true\n self_signed = (cert.subject.cmp(cert.issuer) == 0)\n\n # Check extensions whatever its criticality is. (sample)\n cert.extensions.each do |ex|\n case ex.oid\n when 'basicConstraints'\n /CA:(TRUE|FALSE), pathlen:(\\d+)/ =~ ex.value\n ca = ($1 == 'TRUE')\n pathlen = $2.to_i\n when 'keyUsage'\n usage = ex.value.split(/\\s*,\\s*/)\n ca = usage.include?('Certificate Sign')\n server_auth = usage.include?('Key Encipherment')\n when 'extendedKeyUsage'\n usage = ex.value.split(/\\s*,\\s*/)\n server_auth = usage.include?('Netscape Server Gated Crypto')\n when 'nsCertType'\n usage = ex.value.split(/\\s*,\\s*/)\n ca = usage.include?('SSL CA')\n server_auth = usage.include?('SSL Server')\n end\n end\n\n if self_signed\n STDERR.puts 'self signing CA' if $DEBUG\n return true\n elsif ca\n STDERR.puts 'middle level CA' if $DEBUG\n return true\n elsif server_auth\n STDERR.puts 'for server authentication' if $DEBUG\n return true\n end\n\n return false\n end", "def tls_verify; end", "def ssl_verify; @opts[:ssl_verify]; end", "def sample_verify_callback(is_ok, ctx)\n unless is_ok\n depth = ctx.error_depth\n code = ctx.error\n msg = ctx.error_string\n warn(\"at depth #{depth} - #{code}: #{msg}\") if $DEBUG\n return false\n end\n\n cert = ctx.current_cert\n self_signed = false\n ca = false\n pathlen = nil\n server_auth = true\n self_signed = (cert.subject.cmp(cert.issuer) == 0)\n\n # Check extensions whatever its criticality is. (sample)\n cert.extensions.each do |ex|\n case ex.oid\n when 'basicConstraints'\n /CA:(TRUE|FALSE), pathlen:(\\d+)/ =~ ex.value\n ca = ($1 == 'TRUE')\n pathlen = $2.to_i\n when 'keyUsage'\n usage = ex.value.split(/\\s*,\\s*/)\n ca = usage.include?('Certificate Sign')\n server_auth = usage.include?('Key Encipherment')\n when 'extendedKeyUsage'\n usage = ex.value.split(/\\s*,\\s*/)\n server_auth = usage.include?('Netscape Server Gated Crypto')\n when 'nsCertType'\n usage = ex.value.split(/\\s*,\\s*/)\n ca = usage.include?('SSL CA')\n server_auth = usage.include?('SSL Server')\n end\n end\n\n if self_signed\n warn('self signing CA') if $DEBUG\n return true\n elsif ca\n warn('middle level CA') if $DEBUG\n return true\n elsif server_auth\n warn('for server authentication') if $DEBUG\n return true\n end\n\n return false\n end", "def default_verify_callback(is_ok, ctx)\n if $DEBUG\n if is_ok\n warn(\"ok: #{ctx.current_cert.subject.to_s.dump}\")\n else\n warn(\"ng: #{ctx.current_cert.subject.to_s.dump} at depth #{ctx.error_depth} - #{ctx.error}: #{ctx.error_string} in #{ctx.chain.inspect}\")\n end\n warn(ctx.current_cert.to_text)\n warn(ctx.current_cert.to_pem)\n end\n if !is_ok\n depth = ctx.error_depth\n code = ctx.error\n msg = ctx.error_string\n warn(\"at depth #{depth} - #{code}: #{msg}\") if $DEBUG\n end\n is_ok\n end", "def ssl_verify(mode)\n @ssl_verify = mode\n end", "def verify(*args, **options)\n verified(*args, **options) || raise(InvalidSignature)\n end", "def ssl_verify\n @ssl_verify || true\n end", "def ssh_do_verify(sig, data, options = T.unsafe(nil)); end", "def ssh_do_verify(sig, data, options = T.unsafe(nil)); end", "def ssh_do_verify(sig, data, options = T.unsafe(nil)); end", "def set_verification\n if provider_class.require_verify?\n self.require_verify = true\n self.verified = false\n end\n end", "def verify_none\n #$log.debug(\"Disabling peer validation\")\n self.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end", "def initialize\n @verify_certificates = true\n end", "def set_ssl_verify(ssl_verify)\n if ssl_verify == false\n @ssl_verify = false\n else\n @ssl_verify = true\n end\n end", "def verify_peer\n #$log.debug(\"Enabling peer verification\")\n self.verify_mode = OpenSSL::SSL::VERIFY_PEER\n end", "def verify(cert)\n @transport.verify_cb(cert) == true ? 1 : 0\n end", "def openssl_verify_mode\n case verify_mode\n when :none then OpenSSL::SSL::VERIFY_NONE\n when :peer then OpenSSL::SSL::VERIFY_PEER\n when :fail_if_no_peer_cert then OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT\n when :client_once then OpenSSL::SSL::VERIFY_CLIENT_ONCE\n end\n end", "def verify_key; end", "def verify_key; end", "def verify_ssl\n true\n end", "def ssl_verify_peer(cert)\n return true\n end", "def init_ssl(opt)\n @ssl_init_http = opt['ssl_init_http']\n @ssl_verify = opt['ssl_verify']\n\n if cb = opt['ssl_init']\n cb.call(self, opt)\n elsif @verify_ssl\n # set verify mode, create cert store\n @ssl_verify_mode = OpenSSL::SSL::VERIFY_PEER\n @ssl_store = OpenSSL::X509::Store.new\n\n # add path to certificate store\n # TODO: documentation, at least in method definition\n cert_path = opt['ssl_cert_path'] ||\n ENV['RUBILICIOUS_SSL_CERT_DIR'] ||\n ENV['SSL_CERT_DIR'] ||\n OpenSSL::X509::DEFAULT_CERT_DIR\n @ssl_store.add_path(cert_path)\n else\n # disable SSL verification by default\n @ssl_verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n end", "def verify()\n # TODO\n end", "def verify_mode=(verify_mode); end", "def verify_mode=(verify_mode); end", "def default_validator_callback\n @default_validator_callback ||= proc do |challenge|\n expect(challenge[:result].execution_result.exitstatus).to eq(0)\n end\n end", "def verify(api_key = nil)\n raise ConfigurationError, \"You must provide an API key to verify\" if api_key.nil? && self.api_key.nil?\n perform(:verify, { :providerkey => provider_key, :apikey => api_key || self.api_key }, :get, Success)\n end", "def verify\n end", "def verify\n transition_to(:verify)\n end", "def verify\n transition_to(:verify)\n end", "def verify_mode=(mode)\n unless VERIFY_MODES.include? mode\n raise ArgumentError, \"Invalid SSL verify mode #{mode.inspect}\\n\" +\n \"Please specify one of #{VERIFY_MODES.inspect}\"\n end\n\n @verify_mode = mode\n end", "def callback\n self.oaw_callback(params[:oauth_verifier], params[:oauth_token])\n end", "def initialize(verify_settings)\n self.verify_settings = verify_settings\n end", "def configure_ssl(builder)\n builder.ssl.verify = @service.validate_cert? if validate_certs?\n @logger.debug(\"#{self.class.name} ssl.verify is #{builder.ssl.verify}\")\n end", "def drop_ssl_verify_peer\n before = OpenSSL::SSL::VERIFY_PEER\n OpenSSL::SSL.send(:remove_const, 'VERIFY_PEER')\n OpenSSL::SSL.const_set('VERIFY_PEER', OpenSSL::SSL::VERIFY_NONE)\n yield\n OpenSSL::SSL.send(:remove_const, 'VERIFY_PEER')\n OpenSSL::SSL.const_set('VERIFY_PEER', before)\n end", "def post_init\n start_tls(\n :verify_peer => true,\n :private_key_file => key_file,\n :cert_chain_file => crt_file\n )\n end", "def enable_ssl_verification\n true\n end", "def ssl_check_peer_state\n super\n end", "def post_initialize(**args)\n args[:profile].nil? && (@profile = Yasst::Profiles::OpenSSL.new) ||\n (@profile = args[:profile])\n validate_passphrase(@passphrase)\n end", "def verify_mode\n @verify_mode ||= :peer\n end", "def verify_signatures?; end", "def verify!\n verify\n rescue InvalidDigest, InvalidSignedValue => e\n raise InvalidSignature, e.message\n end", "def verify!\n verify\n rescue InvalidDigest, InvalidSignedValue => e\n raise InvalidSignature, e.message\n end", "def verify_ssl_settings\n @client.instance_variable_get(:@verify_ssl)\n end", "def ssl_verify_peer(cert)\n cert = OpenSSL::X509::Certificate.new cert\n\n #cert.verify cert.public_key\n true\n end", "def verify_mode; end", "def verify_mode; end", "def verify_mode; end", "def verified_handler\n @verified_handler\n end", "def ensure_cb\n @ensure_cb ||= (@failure_cb || lambda { |error| raise \"#{error.code.name}: #{error.message}\" })\n end", "def initialize_verifier\n @verifier = AlexaVerifier::Verifier.new\n end", "def verify\n\n end", "def verify\r\n self.verified = true\r\n end", "def openssl_opt_from_string(val)\n case val\n when 'VERIFY_NONE'\n OpenSSL::SSL::VERIFY_NONE\n when 'VERIFY_PEER'\n OpenSSL::SSL::VERIFY_PEER\n when 'VERIFY_FAIL_IF_NO_PEER_CERT'\n OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT\n when 'VERIFY_CLIENT_ONCE'\n OpenSSL::SSL::VERIFY_CLIENT_ONCE\n else\n val\n end\n end", "def verified_request?; end", "def certificate_verification_state\n super\n end", "def verify(obj)\n Proxy.new(obj, :_verify)\n end", "def setVerifySslCertificates(value)\n @fields['verify_ssl_certificates'] = value\n self\n end", "def setVerifySslCertificates(value)\n @fields['verify_ssl_certificates'] = value\n self\n end", "def ssl_verify\n if ENV[\"CHEF_API_SSL_VERIFY\"].nil? && config[\"CHEF_API_SSL_VERIFY\"].nil?\n true\n else\n %w{t y}.include?(ENV[\"CHEF_API_SSL_VERIFY\"].downcase[0]) || config[\"CHEF_API_SSL_VERIFY\"]\n end\n end", "def verify_cert(ca_root_bundle = CA_ROOT_BUNDLE)\n $log.debug(\"Verifying certificate\")\n ca_root_bundle = CA_ROOT_BUNDLE unless(ca_root_bundle)\n unless (File.exist?(ca_root_bundle) && File.file?(ca_root_bundle))\n return ResultContainer.new(false, \"Invalid certificate file #{ca_root_bundle}\")\n end\n\n self.use_ssl = true\n enable_validations\n self.ca_file = ca_root_bundle\n begin\n self.start do |x|\n x.peer_cert\n return ResultContainer.new(true, x.peer_cert)\n end\n rescue => ex\n return ResultContainer.new(false, ex)\n end\n end", "def user_verified=(_arg0); end", "def generate\n\n verify_cert_hash = get_ssl_cert_hash(datastore['StagerVerifySSLCert'],\n datastore['HandlerSSLCert'])\n\n super(\n ssl: true,\n verify_cert_hash: verify_cert_hash\n )\n end", "def verify_signature\n @req.verify(public_key)\n end", "def verify_aud=(_arg0); end", "def verify_aud=(_arg0); end", "def setup_connection(connection)\n if ssl_certificates_are_present?\n connection.cert_store = @ssl_host.ssl_store\n connection.ca_file = @ssl_configuration.ca_auth_file\n connection.cert = @ssl_host.certificate.content\n connection.key = @ssl_host.key.content\n connection.verify_mode = OpenSSL::SSL::VERIFY_PEER\n connection.verify_callback = self\n else\n connection.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n end", "def post_init\n return unless @network.secure?\n\n verify_peer = (@network.options[:ssl_no_verify] ? false : true)\n start_tls verify_peer: verify_peer\n end", "def enable_ssl(verify = OpenSSL::SSL::VERIFY_PEER, certs = nil, \n port = SSL_PORT)\n @usessl = true\n @verify = verify\n @certs = certs\n @port = port\n end", "def verify_sub; end", "def verify_sub; end", "def initialize(callback)\n @callback = callback\n end", "def with_openssl(code, **opts)\n assert_separately([\"-ropenssl\"], <<~\"end;\", **opts)\n #{code}\n end;\n end", "def verify\n end", "def verify_ssl?\n Bubblebath::Configuration.instance.verify_ssl == nil ? true : Bubblebath::Configuration.instance.verify_ssl\n end", "def verify_authenticity!\n unless params[:verifyToken] == google_account.verification_secret\n raise VerificationError.new(\"received: #{params[:verifyToken]}\")\n end\n end", "def verify\n # nothing to do here, so just return\n end", "def verified?\n verification_code.nil?\n end", "def verify(id)\n Verify.new(request(:get, \"verify/#{id}\"))\n end", "def verify_connection!(uri); end", "def verify!(executable, *args, &block); end", "def verification_init\n self.verification_code = ActiveSupport::SecureRandom.hex(20)\n self.active = 0\n end", "def verify_mode=(_arg0); end", "def verified?\n (@verified_key ||= verify_api_key) != :false\n end", "def verify(data)\n send_command(:verify, data.respond_to?(:to_base64) ? data.to_base64 : data.to_s)\n read_response rescue false\n end", "def verify(name)\n unless cert = Puppet::SSL::Certificate.find(name)\n raise ArgumentError, \"Could not find a certificate for %s\" % name\n end\n store = OpenSSL::X509::Store.new\n store.add_file Puppet[:cacert]\n store.add_crl crl.content if self.crl\n store.purpose = OpenSSL::X509::PURPOSE_SSL_CLIENT\n store.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL|OpenSSL::X509::V_FLAG_CRL_CHECK if Puppet.settings[:certificate_revocation]\n\n unless store.verify(cert.content)\n raise CertificateVerificationError.new(store.error), store.error_string\n end\n end", "def user_verification=(_arg0); end", "def set_ssl_check_peer_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end", "def verify!\n self.update_attribute(:status, VERIFIED)\n end", "def verify(state) ; end" ]
[ "0.7699949", "0.7699949", "0.73474926", "0.73474926", "0.7141537", "0.70659053", "0.70443606", "0.6714693", "0.6688273", "0.65700954", "0.65411067", "0.6484199", "0.6443551", "0.6388104", "0.62961584", "0.61143875", "0.60836494", "0.59283555", "0.59283555", "0.59283555", "0.5904683", "0.590314", "0.5885817", "0.5869598", "0.5858889", "0.5845328", "0.5801885", "0.57432854", "0.57432854", "0.569732", "0.56495565", "0.5618525", "0.5611138", "0.5597937", "0.5597937", "0.5595532", "0.55942017", "0.5538504", "0.55365497", "0.55365497", "0.54916185", "0.54755837", "0.54688394", "0.54599", "0.54577106", "0.5453132", "0.54426974", "0.5419522", "0.5414325", "0.540928", "0.53958386", "0.5391152", "0.5391152", "0.5390897", "0.5378753", "0.5375127", "0.5375127", "0.5375127", "0.53566104", "0.5349909", "0.53365535", "0.53225935", "0.52839553", "0.52707076", "0.52378213", "0.5236842", "0.52039903", "0.5202237", "0.5202237", "0.51994336", "0.51756597", "0.51663035", "0.5163711", "0.5160231", "0.5156579", "0.5156579", "0.5154486", "0.51333714", "0.5129738", "0.5123268", "0.5123268", "0.5111668", "0.5108718", "0.5098385", "0.50958484", "0.50945884", "0.5092623", "0.5082682", "0.5072738", "0.50628006", "0.505864", "0.50500274", "0.50436777", "0.5040847", "0.5034757", "0.503448", "0.50300795", "0.50288224", "0.50233334", "0.5022741" ]
0.63852626
14
Sends the login packet with specific password. Read the result with `read`. Warning: Strongly disencouraged. Use tokens instead, when possible.
def login_with_password(bot, name, password) send Common::Login.new(bot, name, password, nil) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login(options, password = nil) # :yield: recvdata\n login_prompt = /[Ll]ogin[: ]*\\z/n\n password_prompt = /[Pp]ass(?:word|phrase)[: ]*\\z/n\n if options.kind_of?(Hash)\n username = options[\"Name\"]\n password = options[\"Password\"]\n login_prompt = options[\"LoginPrompt\"] if options[\"LoginPrompt\"]\n password_prompt = options[\"PasswordPrompt\"] if options[\"PasswordPrompt\"]\n else\n username = options\n end\n\n if block_given?\n line = waitfor(login_prompt){|c| yield c }\n if password\n line += cmd({\"String\" => username,\n \"Match\" => password_prompt}){|c| yield c }\n line += cmd(password){|c| yield c }\n else\n line += cmd(username){|c| yield c }\n end\n else\n line = waitfor(login_prompt)\n if password\n line += cmd({\"String\" => username,\n \"Match\" => password_prompt})\n line += cmd(password)\n else\n line += cmd(username)\n end\n end\n line\n end", "def login(s, username = DEFAULT_FROM_USERNAME)\n out = [MESSAGE_LOGIN, username].pack(\"Ia*\")\n s.write(out)\n receive_code(s, 0x00001001, \"login\")\nend", "def login\n receive_until_token(@login_token)\n enter_login unless @logged_in\n if @password # if password was passed, else try without password\n receive_until_token(@password_token)\n enter_password unless @logged_in\n end\n receive_until_token(@prompt)\n @logger.info(\"logged in\") if @logger\n end", "def login (username=\"alien\", password=\"password\")\n\t\tif @connected\n\t\t\tbegin\n\t\t\t\[email protected] \"#{username}\\r\\n\"\n\t\t\t\treceive()\n\t\t\t\[email protected] \"#{password}\\r\\n\"\n\t\t\t\ts = receive()\n\t\t\t\t\n\t\t\t\tif s.include? \"Error:\"\n\t\t\t\t\terr_msg = s.scan(/(Error: )(.*)/).flatten[1]\n\t\t\t\t\tclose()\n\t\t\t\t\traise \"Trouble logging in. \" << err_msg\n\t\t\t\t\t@connected = false\n\t\t\t\tend\n\t\t\trescue\n\t\t\t\traise\n\t\t\tend\n\t\tend\n\n\t\treturn @connected\n\tend", "def login_password(password)\n password.strip!\n\n begin\n player = $manager.load_player(@login_name, password)\n rescue MUDError::UnknownCharacter\n output \"That character does not appear to exist.\"\n show_server_menu\n return\n rescue MUDError::BadPassword\n output \"Incorrect password.\"\n @password_attempts += 1\n if @password_attempts > 3\n output \"Too many incorrect passwords.\"\n close\n end\n login_name(@login_name)\n return\n rescue MUDError::CharacterAlreadyLoaded\n output \"Character is already logged in.\"\n show_server_menu\n return\n end\n\n if player.nil?\n output \"An error occurred when loading this character: #{@login_name.inspect}\"\n show_server_menu\n return\n end\n\n @word_wrap = player.word_wrap\n player.set_connection(self)\n $manager.add_object(player)\n\n @player = player\n\n File.open(\"logs/player.log\", \"a\") { |f| f.puts \"#{Time.now} - #{@player.name} logged in from #{@ip_address}.\" }\n\n log \"#{@player.name} logged in from #{@ip_address}\"\n\n if @player.name.downcase == ServerConfig.admin.downcase\n @player.instance_variable_set(:@admin, true)\n end\n\n if File.exist? \"motd.txt\"\n @player.output(\"News:\\n\" << File.read(\"motd.txt\"))\n end\n end", "def login\n\t\[email protected] 'Email address:'\n\t\temail = @INSTREAM.gets.chomp\n\t\[email protected] 'Password:'\n\t\tbegin\n\t\t\t%x{stty -echo}\n\t\t\tpass = @INSTREAM.gets.chomp\n\t\t\[email protected]\n\t\tensure\n\t\t\t%x{stty echo}\n\t\tend\n\t\tdologin(email,pass)\n\tend", "def auth(password)\n establish_connection\n\n @packet = RCon::Packet::Source.new\n @packet.auth(password)\n\n @socket.print @packet.to_s\n # on auth, one junk packet is sent\n rpacket = nil\n 2.times { rpacket = build_response_packet }\n\n if rpacket.command_type != RCon::Packet::Source::RESPONSE_AUTH\n raise RCon::NetworkException.new(\"error authenticating: #{rpacket.command_type}\")\n end\n\n @authed = true\n if @return_packets\n return rpacket\n else\n return true\n end\n end", "def auth(password)\n establish_connection\n\n @packet = RCon::Packet::Source.new\n @packet.auth(password)\n\n @socket.print @packet.to_s\n rpacket = nil\n rpacket = build_response_packet\n\n if rpacket.command_type != RCon::Packet::Source::RESPONSE_AUTH\n raise RCon::NetworkException.new(\"error authenticating: #{rpacket.command_type}\")\n end\n\n @authed = true\n if @return_packets\n return rpacket\n else\n return true\n end\n end", "def login!(passwd = nil)\n self.password = passwd || self.password\n response = client.login(username.to_s, password.to_s)\n apply_attributes! response.result\n self.session_token.present?\n end", "def login(name, channel, password)\n @name = name\n @ch = channel\n @ch_pw = password\n @IRCsocket.write(\"PASS *\\n\")\n @IRCsocket.write(\"NICK #{@name}\\n\")\n @IRCsocket.write(\"USER #{@name} 8 * :#{@name}\\n\")\n @IRCsocket.write(\"JOIN #{@ch} #{@ch_pw}\\n\")\n end", "def pap_login(username,password)\n if (!username.kind_of?(String))\n raise ArgumentError, \"Expected String for username, but #{username.class} provided.\"\n end\n\n if (!password.kind_of?(String))\n raise ArgumentError, \"Expected String for password, but #{password.class} provided.\"\n end\n\n # open a socket to the server\n socket = open_socket()\n\n # make start packet\n header = TacacsPlus::TacacsHeader.new\n if (@session_id)\n header.session_id = @session_id\n else\n header.randomize_session_id!\n end\n header.minor_version_one!\n body = TacacsPlus::AuthenticationStart.new\n body.action_login!\n body.authen_type_pap!\n body.priv_lvl = 1\n body.user = username\n body.data = password\n\n session = ClientSession.new()\n session.request = PacketStruct.new(header,body)\n session.type = :authentication\n session.getuser = username\n session.getpass = password\n\n # process server dialog\n attempt = process_response(session, socket)\n\n return(attempt)\n end", "def login\n response = client.call :login, :message => { :username => username, :password => password }\n response.body[:login_response][:result]\n end", "def pass(password)\n @socket << \"PASS #{password}\"\n end", "def login\n username.set 'tomsmith'\n password.set 'SuperSecretPassword!'\n end", "def login(user, password)\n\[email protected]('String' => \"login #{user} #{password}\\r\",'Match' => /error id=0 msg=ok\\n/, 'Timeout' => 3)\nend", "def ascii_login_and_enable(session,new_body)\n authen_start = session.authen_start\n authen_cont = session.authen_cont\n\n if (!session.reply.body) # no previous conversation has taken place\n if (authen_start.body.user_len == 0)\n # request username\n new_body.status_getuser!\n new_body.server_msg = @tacacs_daemon.login_prompt\n else\n # request password\n session.getuser = authen_start.body.user\n new_body.status_getpass!\n new_body.flag_noecho!\n new_body.server_msg = @tacacs_daemon.password_prompt\n end\n\n else # make sure we got what we asked for in last reply\n if (session.reply.body.status_getuser?)\n if (authen_cont.body.user_msg_len != 0)\n # request password\n session.getuser = authen_cont.body.user_msg\n new_body.status_getpass!\n new_body.flag_noecho!\n new_body.server_msg = @tacacs_daemon.password_prompt\n\n else\n # fail\n new_body.status_fail!\n new_body.server_msg = \"Username requested but none provided.\"\n end\n\n elsif (session.reply.body.status_getpass?)\n if (authen_cont.body.user_msg_len != 0)\n # determine pass/fail status\n username = session.getuser\n password = authen_cont.body.user_msg\n pass_fail = authenticate(username, password, session.authen_start)\n\n # set reply based on pass_fail\n if (pass_fail[:pass])\n new_body.status_pass!\n else\n new_body.status_fail!\n new_body.server_msg = pass_fail[:msg]\n end\n\n else\n # fail\n new_body.status_fail!\n new_body.server_msg = \"Password requested but none provided.\"\n end\n\n else\n # all other statuses are in error, so some sort of internal error must have occured\n new_body.status_error!\n new_body.server_msg = \"Internal Server Error. Unexpected status for ASCII login/enable: #{session.reply.body.status}\"\n @tacacs_daemon.log(:erro,['msg_type=Authentication', \"message=#{new_body.server_msg}\", \"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n\n end\n end\n\n return(nil)\n end", "def login_command(state)\n transport.connection(state)\n transport.login_command\n end", "def connect_login(global = true)\n pop2sock = connect(global)\n\n\n if !(user and pass)\n print_status(\"No username and password were supplied, unable to login\")\n return false\n end\n\n print_status(\"Authenticating as #{user} with password #{pass}...\")\n res = raw_send_recv(\"HELO #{user} #{pass}\\r\\n\")\n\n if (res !~ /messages/)\n print_status(\"Authentication failed\")\n return false\n end\n\n print_status(\"Messages: #{res}\")\n return true\n end", "def login(username, password)\n if password == 'test'\n print username, 'ALLOWED'\n else\n print username, 'DENIED'\n end\nend", "def login(uname, password, params = {})\n params = { :cmd => 'login', :uname => uname, :password => password }.merge(params)\n send_request(params)\n end", "def enter_password\n @logger.info(\"enter password\") if @logger\n enter_command(@password)\n @logged_in = true\n end", "def send_salty_password( socket, salted_password )\n socket.puts salted_password\n socket.flush\n auth_message = socket.gets.chomp\n return auth_message\n end", "def login(user,pass)\n enter_text(user_field, user)\n enter_text(pass_field, pass)\n sleep 1\n # wait_for_login_done\n end", "def pap_login(session,new_body)\n authen_start = session.authen_start\n\n if (!authen_start.header.minor_version_one?) # pap login requires minor version 1\n new_body.status_fail!\n new_body.server_msg = \"Client sent malformed packet to server for PAP login. \" +\n \"Minor version should be 1 but was #{authen_start.header.minor_version}.\"\n @tacacs_daemon.log(:error,['msg_type=Authentication', \"message=#{new_body.server_msg}\",\"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n elsif (authen_start.body.user_len != 0 && authen_start.body.data_len != 0)\n # determine pass/fail status\n username = authen_start.body.user\n pass_fail = authenticate(username, authen_start.body.data, authen_start)\n if (pass_fail[:pass])\n new_body.status_pass!\n else\n new_body.status_fail!\n new_body.server_msg = pass_fail[:msg]\n end\n\n else\n new_body.status_fail!\n new_body.server_msg = \"Client requested PAP login without providing both username and password.\"\n @tacacs_daemon.log(:debug,['msg_type=Authentication', \"message=#{new_body.server_msg}\",\"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n end\n\n return(nil)\n end", "def pass(msg) # :yields: password\n return \"530 Password is incorrect\" if msg != 'password'\n thread[:pass] = msg\n \"230 Logged in successfully\"\n end", "def login opts={}\n opts = @telnet_options.merge opts\n\n # don't log in if username is not set\n if opts[:username].nil?\n @logged_in = Time.now\n return\n end\n\n begin\n output = waitfor opts[:login_prompt]\n\n if opts[:password]\n # login with username and password\n output << cmd(opts[:username], prompt: opts[:password_prompt])\n output << cmd(opts[:password], hide: true)\n else\n # login with username only\n output << cmd(opts[:username])\n end\n rescue Timeout::Error\n e = LoginFailed.new(\"Timed out while expecting some kind of prompt.\")\n e.set_backtrace $!.backtrace\n raise e\n end\n\n @logged_in = Time.now\n output\n end", "def negotiate_password(socket)\n packet = [0x01, options[:user].length, options[:user],\n options[:password].length, options[:password]].pack(\"CCA*CA*\")\n socket.send packet, 0\n\n version, status = socket.recv(2).unpack(\"CC\")\n\n if status != SUCCESS\n socket.close\n raise UnauthorizedError, \"could not authorize user\"\n end\n end", "def login\n puts 'Vui long dang nhap'\n puts 'Username: '\n $user_name = gets.chomp.to_s\n puts 'Password'\n $pass_word = gets.chomp.to_s\nend", "def login_command\n raise ActionFailed, \"Remote login is not supported in this transport.\"\n end", "def login(user = \"anonymous\", passwd = nil, acct = nil)\n if user == \"anonymous\" and passwd == nil\n passwd = getaddress\n end\n\n resp = \"\"\n synchronize do\n\t resp = sendcmd('USER ' + user)\n\t if resp[0] == ?3\n\t resp = sendcmd('PASS ' + passwd)\n end\n end\n\n @welcome = resp\n\n end", "def login(luser, password)\n @sid = @connection.call(\"auth.login\", luser, password)\n end", "def login(password)\n authenticate(password) && set_token && save! && token\n end", "def login(username:, password:)\n if password == 'test'\n print username, 'ALLOWED'\n else\n print username, 'DENIED'\n end\nend", "def login user, password\n @username = user\n @ctx.login user, password\n end", "def login(login, password)\n raise NotImplementedError\n end", "def login\n login = KonoEppLogin.new( tag, password )\n\n # FIXME: Order matters\n login.version = version\n login.lang = lang\n\n login.services = services\n login.extensions = extensions\n\n send_command( login )\n end", "def login\n $log.debug \"Logging in\" \n `./nplogin #{@@username} #{@@password}`\n end", "def chap_login(session,new_body)\n authen_start = session.authen_start\n new_body.server_msg = \"Username or password incorrect.\"\n\n if (!authen_start.header.minor_version_one?) # requires minor version 1\n new_body.status_fail!\n new_body.server_msg = \"Client sent malformed packet to server for CHAP login. \" +\n \"Minor version in TACACS+ header should be 1 but was #{authen_start.header.minor_version}.\"\n @tacacs_daemon.log(:error,['msg_type=Authentication', \"message=#{new_body.server_msg}\",\"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n elsif (authen_start.body.user_len != 0 && authen_start.body.data_len != 0)\n # get ppp_id, challenge, and response. ppp_id = 1 octet, response = 16 octets, challenge = remainder\n challenge_len = authen_start.body.data_len - 17\n ppp_id = authen_start.body.data[0].chr\n challenge = authen_start.body.data[1,challenge_len]\n response = authen_start.body.data[challenge_len+1, authen_start.body.data_len-1]\n\n username = authen_start.body.user\n user = @tacacs_daemon.users(username) if (username)\n if (user && user.login_password)\n if (Digest::MD5.digest(ppp_id + user.login_password + challenge) == response)\n if (user.login_password_expired?)\n new_body.status_fail!\n new_body.server_msg = @tacacs_daemon.password_expired_prompt\n elsif (user.login_acl)\n match_results = user.login_acl.match(@peeraddr)\n if ( match_results[:permit] )\n new_body.status_pass!\n new_body.server_msg = \"\"\n else\n new_body.status_fail!\n new_body.server_msg = \"Authentication denied due to ACL restrictions on user.\"\n @tacacs_daemon.log(:info,['msg_type=Authentication', 'message=User attempted CHAP login to restricted device.',\"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n end\n\n elsif (@tacacs_daemon.default_policy == :deny)\n new_body.status_fail!\n new_body.server_msg = \"Authentication denied due to ACL restrictions on user.\"\n @tacacs_daemon.log(:info,['msg_type=Authentication', 'message=CHAP login denied due to default policy.',\"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n\n else\n @tacacs_daemon.log(:info,['msg_type=Authentication', 'message=CHAP login permitted due to default policy.',\"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n new_body.status_pass!\n new_body.server_msg = \"\"\n end\n else\n new_body.status_fail!\n end\n else\n new_body.status_fail!\n end\n\n else\n new_body.status_fail!\n new_body.server_msg = \"Client requested CHAP login without providing both username and password.\"\n @tacacs_daemon.log(:warn,['msg_type=Authentication', \"message=#{new_body.server_msg}\",\"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n end\n\n if (new_body.status_pass?)\n @tacacs_daemon.log(:warn,['msg_type=Authentication', 'message=Authentication successful.',\"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n end\n\n return(nil)\n end", "def login(try_password)\n pass = Password.new(self.password.encode('ascii-8bit'))\n return pass == try_password\n end", "def login\n response = @client.call(:login,\n cookies: @auth_cookie,\n message: {\n username: @username, \n password: decrypt(@password)\n })\n\n @auth_cookie = response.http.cookies if @auth_cookie.nil?\n @login_token = response.hash[:envelope][:body][:login_response][:login_result]\n response\n end", "def send_credentials\n dputs __method__.to_s\n login_req = setup_http_request($ident, @cookie, {:arg => [$CONF['user'], CGI.escape($CONF['pass'])]})\n res = @http.request(login_req)\n get_cookie(res)\n end", "def receive_plain_auth user, password\n true\n end", "def receive_plain_auth user, password\n true\n end", "def get_password host,username\n print \"Password for \"+username+\"@\"+host+\": \"\n system \"stty -echo\"\n pw = gets.delete(\"\\n\")\n system \"stty echo\"\n puts\n pw\n end", "def login\n username = find_username\n password = find_password\n\n Log.info(\"Logging in as #{username}... \", newline: false)\n\n conn = Faraday.new(url: \"https://redacted.ch/\")\n response = conn.post do |request|\n request.url \"login.php\"\n request.headers[\"User-Agent\"] = RedactedBetter.user_agent\n request.body = { username: username, password: password }\n end\n\n handle_login_response(response)\n rescue Faraday::TimeoutError\n Log.error(\"Logging in timed out. Perhaps Redacted is down?\")\n false\n end", "def pass(passwd)\n send_msg(\"PASS #{passwd}\")\n end", "def login(username,password,quick=false)\n if (!username.kind_of?(String))\n raise ArgumentError, \"Expected String for username, but #{username.class} provided.\"\n end\n\n if (!password.kind_of?(String))\n raise ArgumentError, \"Expected String for password, but #{password.class} provided.\"\n end\n\n\n # open a socket to the server\n socket = open_socket()\n\n # make start packet\n header = TacacsPlus::TacacsHeader.new\n if (@session_id)\n header.session_id = @session_id\n else\n header.randomize_session_id!\n end\n body = TacacsPlus::AuthenticationStart.new\n body.action_login!\n body.authen_type_ascii!\n body.priv_lvl = 1\n body.user = username if (quick)\n\n session = ClientSession.new()\n session.request = PacketStruct.new(header,body)\n session.type = :authentication\n session.getuser = username\n session.getpass = password\n\n # process server dialog\n attempt = process_response(session, socket)\n\n return(attempt)\n end", "def login(username, password)\n self.username.set username\n self.password.set password\n log_in.click\n end", "def do_login(user, pass)\n vprint_status(\"#{rhost}:#{rport} - Trying username:'#{user.inspect}' with password:'#{pass.inspect}'\")\n begin\n res = send_request_cgi(\n {\n 'uri' => \"/doms/login/processLogin.php\",\n 'method' => 'GET',\n 'vars_get' =>\n {\n 'login' => user,\n 'passwd' => pass,\n 'tzOffset' => '-25200',\n 'tzString' => 'Thur+May+05+1983+05:05:00+GMT+0700+'\n }\n })\n\n if res.nil?\n print_error(\"#{rhost}:#{rport} - Connection timed out\")\n return :abort\n end\n\n check_key = \"The user has logged in successfully.\"\n\n key = JSON.parse(res.body)[\"statusString\"]\n\n if (not res or key != \"#{check_key}\")\n vprint_error(\"#{rhost}:#{rport} - FAILED LOGIN. '#{user.inspect}' : '#{pass.inspect}' with code #{res.code}\")\n return :skip_pass\n else\n print_good(\"#{rhost}:#{rport} - SUCCESSFUL LOGIN. '#{user.inspect}' : '#{pass.inspect}'\")\n report_cred(\n ip: rhost,\n port: rport,\n service_name: 'SevOne Network Performance Management System Application',\n user: user,\n password: pass,\n proof: key\n )\n return :next_user\n end\n\n rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError, ::Errno::EPIPE\n print_error(\"#{rhost}:#{rport} - HTTP Connection Failed, Aborting\")\n return :abort\n end\n end", "def login(username, pwd)\n user = @server.proxy('User')\n logged_in_user_response = user.login({'login' => username, 'password' => pwd})\n #puts \"\\nlogged in user id = \" + logged_in_user_response['id'].to_s\n end", "def login_message(connection, nonce)\n Protocol::Query.new(\n auth_database(connection),\n Database::COMMAND,\n { authenticate: 1, user: user.name, nonce: nonce, key: user.auth_key(nonce) },\n limit: -1\n )\n end", "def login(user_id, password)\n LoginInfo.new(call(CMD_LOGIN % [user_id, password]))\n end", "def login\n raise SocketError, \"Socket must be opened before logging in\" if !@socket or @socket.closed?\n\n xml = new_epp_request\n\n xml.root << command = Node.new(\"command\")\n command << login = Node.new(\"login\")\n\n login << Node.new(\"clID\", tag)\n login << Node.new(\"pw\", password)\n\n login << options = Node.new(\"options\")\n\n options << Node.new(\"version\", version)\n options << Node.new(\"lang\", lang)\n\n login << services = Node.new(\"svcs\")\n\n services << Node.new(\"objURI\", \"urn:ietf:params:xml:ns:domain-1.0\")\n services << Node.new(\"objURI\", \"urn:ietf:params:xml:ns:contact-1.0\")\n services << Node.new(\"objURI\", \"urn:ietf:params:xml:ns:host-1.0\")\n\n services << extensions_container = Node.new(\"svcExtension\") unless extensions.empty?\n\n for uri in extensions\n extensions_container << Node.new(\"extURI\", uri)\n end\n\n command << Node.new(\"clTRID\", SecureRandom.uuid)\n\n response = Hpricot::XML(send_request(xml.to_s))\n\n handle_response(response)\n end", "def process_plain_auth(user, password)\n if receive_plain_auth(user, password)\n reply 235, \"authentication ok\"\n @state << :auth\n else\n reply 535, \"invalid authentication\"\n end\n end", "def login(connection)\n nonce = connection.dispatch([ nonce_message(connection) ]).documents[0]\n reply = connection.dispatch([ login_message(connection, nonce[Auth::NONCE]) ])\n raise Unauthorized.new(user) if reply.documents[0]['ok'] == 0\n reply\n end", "def login\n # check if file credential exists\n if File.file?(@@credentials_file)\n puts 'Credentials file found!'.bold\n unless yes?(\"Overwrite #{@@credentials_file}? |no|\".bold.yellow)\n puts \"Aborted.\".red.bold\n exit\n end\n end\n\n # Ask for username and password, mask the password and make it\n # green if it's the correct password, red if the access was denied.\n # Aborts if the password is empty.\n puts 'Write your username and password for ' + 'RubyGems.org'.yellow.bold\n username = ask('Username:'.yellow.bold)\n password = ask('Password:'.yellow.bold, echo: false)\n (puts \"Aborted.\".red.bold; exit) if password.empty?\n\n # fakes a masked password as long as the username,\n # for style purposes only.\n masked_password = '*' * username.length\n print masked_password unless options[:show_password]\n\n begin\n Tmg.write_credentials(username, password)\n rescue RuntimeError\n puts \"\\b\" * masked_password.length + masked_password.red.bold\n puts 'Access Denied.'.red.bold\n exit\n else\n puts \"\\b\" * masked_password.length + masked_password.green.bold\n puts \"Credentials written to #{@@credentials_file}\".green.bold\n end\n end", "def login\n login_command = driver.login_command(state_file.read)\n command, *args = login_command.cmd_array\n options = login_command.options\n\n debug(\"Login command: #{command} #{args.join(' ')} (Options: #{options})\")\n Kernel.exec(command, *args, options)\n end", "def enter_login_credentials(username, password)\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n login_email_field.value = username\n login_password_field.value = password\n end", "def login(user, nick, real_name, flags=8)\n sendmsg \"USER #{user} #{flags} * :#{real_name}\"\n sendmsg \"NICK #{nick}\"\n end", "def login\n username, password = request[:username, :password]\n if check_auth(username, password)\n session[:logged_in] = true\n session[:username] = username\n inside_stack? ? answer : redirect_referrer\n else\n if defined? AUTH_ELEMENT and AUTH_ELEMENT.to_s.split.any?\n open_element = \"<#{AUTH_ELEMENT}>\"\n close_element = \"</#{AUTH_ELEMENT}>\"\n end\n %{\n #{open_element}\n <form method=\"POST\" action=\"#{Rs(:login)}\">\n <ul style=\"list-style:none;\">\n <li>Username: <input type=\"text\" name=\"username\" /></li>\n <li>Password: <input type=\"password\" name=\"password\" /></li>\n <li><input type=\"submit\" /></li>\n </ul>\n </form>\n #{close_element}\n }\n end\n end", "def evaluate_pwd(umsg,sock)\n puts \"Given password: #{umsg[1]}\"\n if @user[:role] == \"editor\"\n pwd = @@editor_pwd\n else\n pwd = @@admin_pwd\n end\n if umsg[1] === pwd\n sock.write(\"Welcome\\n\")\n @user[:status] = \"logged\"\n puts \"logged\"\n else\n sock.write(\"password:\\n\")\n end\n end", "def pass(password)\n raw \"PASS #{password}\\r\\n\"\n end", "def obtain_password\n i = o = File.open('/dev/tty', 'w+')\n\n o.print 'Password: '\n\n # store original settings\n state = `stty -F /dev/tty -g`\n\n # don't echo input\n system \"stty -F /dev/tty -echo\"\n\n p = i.gets.chomp\n\n # restore original settings\n system \"stty -F /dev/tty #{state}\"\n\n p\n end", "def login(user, password, sid = nil)\n sid ||= IDMIN + rand(IDMAX-IDMIN)\n @nurl ||= \"https://localhost:8834/\"\n post = { \"username\" => user, \"password\" => password, 'seq' => sid }\n\n response_json = nessus_request('session', post)\n\n if response_json['token']\n @token = response_json['token']\n @name = user\n @seqid = sid\n # Compatibility with XMLRPC ivar\n user_permissions = nessus_request('session', auth_header, :get)['permissions']\n @admin = ([64,128].any? {|perm| perm == user_permissions}).to_s.upcase\n return @token\n else\n raise \"Cannot authenticate to #{@nurl} as #{user} with #{password} due to #{response_json['error']}\"\n end\n\n end", "def login(username = users(:common).username, pass = \"testpassword\")\n post login_url, params: {session: {username: username, password: pass}}\n end", "def create_login_msg(pw)\r\n delim = \"\\xFF\"\r\n login_str = \"#{delim}000000#{delim}20180810213226#{delim}01#{delim}60\"\\\r\n \"#{delim}02#{delim}1111#{delim}#{pw}#{delim}AAAAA#{delim}120\"\r\n\r\n end", "def make_login user, password\n server = Configuration.SERVER\n addr = Configuration.CLIOWL_ADDRESS\n \n HttpHelper.post \"http://#{server}#{addr}/login\", { 'user' => user, 'password' => password }\n end", "def login\n open(@credentials_file, 'r').readlines.first.strip if valid_file?(@credentials_file)\n end", "def login(username, password)\n\t\t\t# url = 'https://eu.wowarmory.com/guild-bank-contents.xml?n=Rawr&r=Trollbane'\n\t\t\turl = base_url(@locale, {:secure => true}) + @@login_url\n\t\t\t\n\t\t\treq = Net::HTTP::Post.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; cookies=true;\"\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\t# Suppress \"warning: peer certificate won't be verified in this SSL session\"\n\t\t\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\t\t\thttp.use_ssl = true\n\t\t\t\n\t\t\treq.set_form_data({'accountName' => username, 'password' => password}, '&')\n\t\t\t\n\t\t\t\n\t\t\thttp.start do\n\t\t\t\tres = http.request(req)\n\t\t\t\t\n\t\t\t\ttries = 0\n\t\t\t\tresponse = case res\n\t\t\t\t\twhen Net::HTTPSuccess, Net::HTTPRedirection\n\t\t\t\t\t\tres.body\n\t\t\t\t\telse\n\t\t\t\t\t\ttries += 1\n\t\t\t\t\t\tif tries > @@max_connection_tries\n\t\t\t\t\t\t\traise Wowr::Exceptions::NetworkTimeout.new('Timed out')\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tretry\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\n\t\t\t\tdoc = Hpricot.XML(response)\n\t\t\t\t\n\t\t\t\t# error = 0 nothing provided\n\t\t\t\t# error = 1 invalid credentials\n\t\t\t\t# TODO: Detect different kinds of errors\n\t\t\t\tif (doc%'login')\n\t\t\t\t\traise Wowr::Exceptions::InvalidLoginDetails\n\t\t\t\telse\n\t\t\t\t\tcookie = nil\n\t\t\t\t\tres.header['set-cookie'].scan(/JSESSIONID=(.*?);/) {\n\t\t\t\t\t\tcookie = 'JSESSIONID=' + $1 + ';'\n\t\t\t\t\t}\n\t\t\t\t\treturn cookie\n\t\t\t\tend\n\t\t\tend\n\t\tend", "def login(username, password)\n response = post(LOGIN_SUBMIT_URL, 'fnid' => fnid, 'u' => username, 'p' => password)\n @username = username\n @password = password\n unless @cookie = response.header['set-cookie']\n raise LoginError, \"Login credentials did not work.\"\n end\n end", "def mssql_parse_login( data )\n status = data.slice!(0,1).unpack('C')[0]\n len = data.slice!(0,2).unpack('n')[0]\n\n if len > data.length + 4\n return\n end\n\n # slice of:\n # * channel, packetno, window\n # * login header\n # * client name lengt & offset\n login_hdr = data.slice!(0,4 + 36 + 4)\n\n username_offset = data.slice!(0,2).unpack('v')[0]\n username_length = data.slice!(0,2).unpack('v')[0]\n\n pw_offset = data.slice!(0,2).unpack('v')[0]\n pw_length = data.slice!(0,2).unpack('v')[0]\n\n appname_offset = data.slice!(0,2).unpack('v')[0]\n appname_length = data.slice!(0,2).unpack('v')[0]\n\n srvname_offset = data.slice!(0,2).unpack('v')[0]\n srvname_length = data.slice!(0,2).unpack('v')[0]\n\n if username_offset > 0 and pw_offset > 0\n offset = username_offset - 56\n\n user = data[offset..(offset + username_length * 2)].unpack('v*').pack('C*')\n\n offset = pw_offset - 56\n if pw_length == 0\n pass = \"<empty>\"\n else\n pass = mssql_tds_decrypt(data[offset..(offset + pw_length * 2)].unpack(\"A*\")[0])\n end\n\n offset = srvname_offset - 56\n srvname = data[offset..(offset + srvname_length * 2)].unpack('v*').pack('C*')\n BetterCap::Logger.info \"[#{'MSSQL DOWNGRADE'.green}] [#{'Username'.yellow}] #{user.yellow} | [#{'Password'.yellow}] #{pass.yellow} | [#{'Server Name'.yellow}] #{srvname.yellow}\"\n else\n BetterCap::Logger.info \"[#{'MSSQL DOWNGRADE'.yellow}] Could not parse login request for authentication credentials\"\n end\n end", "def login(p=nil)\n p=get_password if p.blank?\n set_cookies\n post :create, :password => p\n end", "def send_login_msg(login_msg, check_response = true)\r\n length = login_msg.length\r\n length += length.to_s.length\r\n login_msg = \"#{length}#{login_msg}\"\r\n\r\n connect\r\n\r\n sock.put(login_msg)\r\n response = sock.recv(10000)\r\n\r\n if check_response\r\n if (response.include? 'Zugangsdaten Falsch') && (response.length > (length - 20))\r\n print_good('Correct response received => Data send successfully')\r\n else\r\n print_warning('Wrong response received => Probably data could not be sent successfully')\r\n end\r\n end\r\n\r\n return response\r\n ensure\r\n # Every time a new Connection is required\r\n disconnect\r\n end", "def login(username, password)\n session.context.login(name, username, password)\n end", "def chap_login(username,password,ppp_id,challenge)\n if (!username.kind_of?(String))\n raise ArgumentError, \"Expected String for username, but #{username.class} provided.\"\n end\n\n if (!password.kind_of?(String))\n raise ArgumentError, \"Expected String for password, but #{password.class} provided.\"\n end\n\n if (!ppp_id.kind_of?(String))\n raise ArgumentError, \"Expected String for ppp_id, but #{ppp_id.class} provided.\"\n elsif (ppp_id.length != 1)\n raise ArgumentError, \"Expected 1-byte String for ppp_id, but was #{ppp_id.length} bytes.\"\n end\n\n if (!challenge.kind_of?(String))\n raise ArgumentError, \"Expected String for challenge, but #{challenge.class} provided.\"\n elsif (challenge.length > 255)\n raise ArgumentError, \"Challenge may not be more then 255 bytes.\"\n end\n\n # open a socket to the server\n socket = open_socket()\n\n # make start packet\n header = TacacsPlus::TacacsHeader.new\n if (@session_id)\n header.session_id = @session_id\n else\n header.randomize_session_id!\n end\n header.minor_version_one!\n body = TacacsPlus::AuthenticationStart.new\n body.action_login!\n body.authen_type_chap!\n body.priv_lvl = 1\n body.user = username\n # data should contain contat of ppp_id, challenge, and response\n body.data = ppp_id + challenge + Digest::MD5.digest(ppp_id + password + challenge)\n\n session = ClientSession.new()\n session.request = PacketStruct.new(header,body)\n session.type = :authentication\n session.getuser = username\n session.getpass = password\n\n # process server dialog\n attempt = process_response(session, socket)\n\n return(attempt)\n end", "def login(username, password)\n login_url = get(BASE_URL).match(/href=\"([^\"]+)\">login<\\/a>/)[1]\n form_html = get(BASE_URL + login_url)\n fnid = form_html.match(/<input type=hidden name=\"fnid\" value=\"([^\"]+)\"/)[1]\n response = post(LOGIN_SUBMIT_URL, 'fnid' => fnid, 'u' => username, 'p' => password)\n @username = username\n @password = password\n unless @cookie = response.header['set-cookie']\n raise LoginError, \"Login credentials did not work.\"\n end\n end", "def login\n \t\t response = @client.request :login do\n soap.body = { username: self.zconfig.user_name, password: self.zconfig.password}\n \t\t end\n \t\t response.to_hash\n \t \t self.session = response.to_hash[:login_response][:result][:session]\n end", "def login_agent(agent, login, password)\n login_request = VkMusic::Request::Login.new\n login_request.call(agent)\n login_request.send_form(login, password, agent)\n end", "def login(username, password)\n wait_until { login_btn.visible? }\n username_tb.type_text(username)\n password_tb.type_text(password)\n login_btn.click\n end", "def connect_login(global = true)\n ftpsock = connect(global)\n\n\n if !(user and pass)\n print_status(\"No username and password were supplied, unable to login\")\n return false\n end\n\n print_status(\"Authenticating as #{user} with password #{pass}...\")\n res = raw_send_recv(\"a001 LOGIN #{user} #{pass}\\r\\n\")\n\n if (res !~ /^a001 OK/)\n print_status(\"Authentication failed\")\n return false\n end\n\n return true\n end", "def login\n # If there's no connection, bail\n return if !@connected\n\n # Set the logged_in flag to false\n @logged_in = false\n \n # Send the command and read the response\n command = \"Action: Login\\r\\nUsername: \" + @username + \"\\r\\nSecret: \" + @secret + \"\\r\\n\\n\"\n response = self.send_request(command)\n \n # Check the response, set the flag, and write the log message\n @logged_in = self.check_response_status(response)\n \n if @logged_in\n @logger.success(\"Success: \" + response[:message])\n \n # The AMI immediately sends an event message after login. We don't care\n # about it, but it gets in the way of sending other commands. Read it and throw it in the log file\n self.read_response\n \n # Turn events off so we don't have to handle a bunch of asynchronous messages\n command = \"Action: Events\\r\\nEventmask: Off\\r\\n\\n\"\n response = self.send_request(command)\n \n @logger.success(\"Success: Async events turned off\") if (response[:response] == RESPONSE_SUCCESS)\n @logger.error(\"Failure: Could not turn async events off. This may cause problems\") if (response[:response] != RESPONSE_SUCCESS)\n else\n @logger.fatal(\"Error: \" + response[:message])\n end\n end", "def login\n\t\tbegin\n\t\t\tr = execute(make_xml('LoginRequest', { 'sync-id' => 0, 'password' => @password, 'user-id' => @username }))\n\t\trescue APIError\n\t\t\traise AuthenticationFailed.new(r)\n\t\tend\n\t\tif(r.success)\n\t\t\t@session_id = r.sid\n\t\t\treturn true\n\t\tend\n\tend", "def login(username, password)\n @username = username\n @password = password\n challenge, response = getchallenge\n login_vars = {\n 'username' => @username,\n 'clientversion' => CLIENT,\n 'auth_method' => 'challenge',\n 'auth_challenge' => challenge,\n 'auth_response' => response\n }\n if @mood_list == true\n login_vars['getmoods'] = 0\n elsif @mood_list.kind_of? Array\n i = @mood_list.max { |a,b| a['id'] <=> b['id'] }\n login_vars['getmoods'] = i['id']\n end\n login = self.call('LJ.XMLRPC.login', login_vars)\n @fastserver = login['fastserver'] == 1\n @usejournals = login['usejournals']\n @logged_in = true\n @next_check_ok = 0\n @friendgroups = login['friendgroups']\n if @mood_list\n if @mood_list == true\n @mood_list = login['moods']\n else\n @mood_list << login['moods']\n end\n end\n if login.has_key?('message')\n @message = login['message']\n return true\n else\n return false\n end\n rescue XMLRPC::FaultException => e\n raise LjException.new(e.faultCode, e.faultString)\n end", "def enter_password\n password = $prompt.mask(\"Please enter password:\")\n if password == self.password \n self.update(signed_in?: true)\n puts \"You are signed in!\"\n sleep (2)\n welcome\n else\n puts \"Password incorrect\"\n sign_in\n end\n end", "def password_request\n password_input = @prompt.mask(\"Please enter your password, or type quit.\")\n if password_input == @user.password\n puts \"Successful login!\"\n @user\n user_menu_runner\n #user can quit this process\n elsif password_input == \"quit\" || password_input == \"exit\"\n exit\n else\n #try again\n puts \"Sorry, incorrect password. Try again.\" # add esscape option\n password_request\n end\n end", "def login(nickname, password)\n @nickname = nickname\n @password = password\n @login_agent = Mechanize.new\n\n page = @login_agent.get(LOGIN_URI)\n\n login_form = page.forms.find { |form|\n LOGIN_URI + form.action == LOGIN_URI\n } or raise 'Cannot locate a login form'\n\n login_form.set_fields(:email => @nickname, :password => @password)\n\n page = login_form.submit\n\n login_form = page.forms.find { |form|\n LOGIN_URI + form.action == LOGIN_URI\n } and raise 'Login failed'\n\n page = @login_agent.get(ROOT_URI + \"/account/api\")\n remote_key = page.parser.xpath(\"(//table[@class='remotekey']//td[@class='value'])[2]/text()\").to_s\n\n api_login(nickname, remote_key)\n end", "def ask_password\n @display.echo_off\n print 'Enter password (6 - 20 characters): ', false, false\n @state = :new_password\n end", "def login\n\t\tnavigate(@login_path)\n\n\t\tlogin_form = find_by_xpath(@signin_xpath)\n\t\tlogin_field = find_by_id('login_field')\n\t\tpassword_field = find_by_id('password')\n\n\t\tlogin_field.send_keys(@username); sleep 1\n\t\tpassword_field.send_keys(@password); sleep 1\n\n\t\tlogin_form.click; sleep 15\n\tend", "def login\n validate_arguments!\n\n Turbot::Auth.login\n display \"Authentication successful.\"\n end", "def login\n unless (@login and @password)\n raise \"Can't log in without login and password\"\n end\n \n lform = @agent.get('https://login.yahoo.com/config/login').form('login_form')\n lform.login = @login\n lform.passwd = @password\n begin\n @agent.submit(lform, lform.buttons.first)\n rescue Exception => e\n puts \"Oops: #{e}\"\n end\n end", "def login\n make_login_call\n end", "def login!\n params = { email: email, password: pass }\n response = Faraday.get(\"#{ACCOUNT_BASE}/login\", params)\n attributes = JSON.parse(response.body)\n @token = attributes[\"adminToken\"]\n end", "def login(username, password)\n begin\n @agent.get(LOGIN_FORM_URL) do |page|\n saml_page = page.form_with(:action => LOGIN_URL) do |login|\n login.USER = username\n login.PASSWORD = password\n login.TARGET = MY_USAGE_URL\n end.submit\n token = saml_page.form_with(:action => SAML_URL).submit\n usage_page = token.form_with(:action => MY_ENERGY_USE_URL).submit\n @data_page = usage_page.link_with(:text => \"Green Button - Download my data\").click\n end\n @authenticated = true\n rescue Exception => e\n @last_exception = e\n return false\n end\n end", "def login_command(state)\n raise ActionFailed, \"Remote login is not supported in this driver.\"\n end", "def run\n begin\n pass = read_pass\n puts Vcloud::Core::Fog::Login.token_export(pass)\n rescue => e\n $stderr.puts(e)\n exit 1\n end\n end", "def post!( text, password )\n post text\n push password\n end", "def login\n #puts \"logging in with: \"+self.password\n begin\n response = self.pclient.request :login do\n #soap.body = { :username => self.username, :password => self.password }\n soap.body = '<ins0:username>'+self.username+'</ins0:username><ins0:password>'+self.password+'</ins0:password>'\n end\n rescue Savon::SOAP::Fault => fault\n raise Exception.new(fault.to_s)\n # TODO: handle incorrect password gracefully\n # if fault.to_s.include? \"INVALID_LOGIN\"\n # self.password = TextMate::UI.request_secure_string(\n # :title => \"MavensMate\", \n # :prompt => 'Your login attempt failed. Please re-enter your password',\n # :button2 => 'Cancel'\n # )\n # TextMate.exit_discard if self.password == nil\n # is_retry = true\n # login\n # else\n # raise Exception.new(fault.to_s)\n # end \n end\n \n # if is_retry == true\n # MavensMate.add_to_keychain(MavensMate.get_project_name, self.password)\n # end \n \n begin\n res = response.to_hash\n self.metadata_server_url = res[:login_response][:result][:metadata_server_url]\n self.sid = res[:login_response][:result][:session_id].to_s\n self.user_id = res[:login_response][:result][:user_id].to_s\n self.pclient.wsdl.endpoint = res[:login_response][:result][:server_url] \n rescue Exception => e\n #puts e.message \n end\n end", "def fetch(password)\r\n end", "def login(username, password)\n return @@auth_token if defined?(@@auth_token) && @@auth_token\n reset_login(username, password)\n end", "def login_to_system(username='admin', password='dirtybird')\n self.username = username\n self.password = password\n\n # Hack to work-around issue with the login_page page object\n # where the password control is not available unless we \n # resize the browser.\n\n @browser.window.resize_to(1280, 1024)\n\n login\n end" ]
[ "0.70112157", "0.6982452", "0.6946723", "0.68269336", "0.6819371", "0.65334004", "0.65069985", "0.64677", "0.643293", "0.6368533", "0.6353334", "0.6335806", "0.6329706", "0.6308235", "0.6294756", "0.6272615", "0.6231189", "0.62282807", "0.6228104", "0.6175945", "0.61559194", "0.61384577", "0.6137227", "0.61263835", "0.6124489", "0.6115016", "0.6114082", "0.6111213", "0.6110073", "0.6102396", "0.60843873", "0.6068055", "0.6032437", "0.60173374", "0.6016989", "0.60166526", "0.6015656", "0.60017484", "0.5999532", "0.5992664", "0.5987505", "0.596972", "0.596972", "0.5939544", "0.59389204", "0.59312993", "0.5906547", "0.59041756", "0.5893682", "0.58768237", "0.58703256", "0.5858566", "0.58531797", "0.5842943", "0.5836491", "0.5832745", "0.5816897", "0.58102685", "0.58051324", "0.57850605", "0.578348", "0.57764626", "0.57694286", "0.5757952", "0.5741418", "0.57396525", "0.5734926", "0.5733447", "0.5723388", "0.57143193", "0.5709271", "0.5708958", "0.57026464", "0.5701721", "0.56927365", "0.5689068", "0.5682607", "0.56806815", "0.56766343", "0.5659058", "0.56576", "0.5653436", "0.5649153", "0.56406343", "0.56326324", "0.5624607", "0.56203276", "0.5615737", "0.5610573", "0.5608355", "0.56045514", "0.56026053", "0.55975413", "0.5593019", "0.55917424", "0.5579182", "0.5572642", "0.55666363", "0.5555592", "0.5554159" ]
0.68922913
3
Sends the login packet with specific token. Read the result with `read`.
def login_with_token(bot, name, token) send Common::Login.new(bot, name, nil, token) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login\n receive_until_token(@login_token)\n enter_login unless @logged_in\n if @password # if password was passed, else try without password\n receive_until_token(@password_token)\n enter_password unless @logged_in\n end\n receive_until_token(@prompt)\n @logger.info(\"logged in\") if @logger\n end", "def login(s, username = DEFAULT_FROM_USERNAME)\n out = [MESSAGE_LOGIN, username].pack(\"Ia*\")\n s.write(out)\n receive_code(s, 0x00001001, \"login\")\nend", "def send_login_msg(login_msg, check_response = true)\r\n length = login_msg.length\r\n length += length.to_s.length\r\n login_msg = \"#{length}#{login_msg}\"\r\n\r\n connect\r\n\r\n sock.put(login_msg)\r\n response = sock.recv(10000)\r\n\r\n if check_response\r\n if (response.include? 'Zugangsdaten Falsch') && (response.length > (length - 20))\r\n print_good('Correct response received => Data send successfully')\r\n else\r\n print_warning('Wrong response received => Probably data could not be sent successfully')\r\n end\r\n end\r\n\r\n return response\r\n ensure\r\n # Every time a new Connection is required\r\n disconnect\r\n end", "def login_command(state)\n transport.connection(state)\n transport.login_command\n end", "def login\n response = @client.call(:login,\n cookies: @auth_cookie,\n message: {\n username: @username, \n password: decrypt(@password)\n })\n\n @auth_cookie = response.http.cookies if @auth_cookie.nil?\n @login_token = response.hash[:envelope][:body][:login_response][:login_result]\n response\n end", "def login_by_token\n\n end", "def login_command\n raise ActionFailed, \"Remote login is not supported in this transport.\"\n end", "def login(connection)\n nonce = connection.dispatch([ nonce_message(connection) ]).documents[0]\n reply = connection.dispatch([ login_message(connection, nonce[Auth::NONCE]) ])\n raise Unauthorized.new(user) if reply.documents[0]['ok'] == 0\n reply\n end", "def login\n\n if params[:username] && params[:token]\n @user = token_based_login\n end\n\n if @user\n set_session_headers\n render json: { username: @user.username, auth_token: get_md5_digest(params[:username]), logged_in: true }\n else\n render json: { logged_in: false }, status: 401\n end\n end", "def login_message(connection, nonce)\n Protocol::Query.new(\n auth_database(connection),\n Database::COMMAND,\n { authenticate: 1, user: user.name, nonce: nonce, key: user.auth_key(nonce) },\n limit: -1\n )\n end", "def login\n raise SocketError, \"Socket must be opened before logging in\" if !@socket or @socket.closed?\n\n xml = new_epp_request\n\n xml.root << command = Node.new(\"command\")\n command << login = Node.new(\"login\")\n\n login << Node.new(\"clID\", tag)\n login << Node.new(\"pw\", password)\n\n login << options = Node.new(\"options\")\n\n options << Node.new(\"version\", version)\n options << Node.new(\"lang\", lang)\n\n login << services = Node.new(\"svcs\")\n\n services << Node.new(\"objURI\", \"urn:ietf:params:xml:ns:domain-1.0\")\n services << Node.new(\"objURI\", \"urn:ietf:params:xml:ns:contact-1.0\")\n services << Node.new(\"objURI\", \"urn:ietf:params:xml:ns:host-1.0\")\n\n services << extensions_container = Node.new(\"svcExtension\") unless extensions.empty?\n\n for uri in extensions\n extensions_container << Node.new(\"extURI\", uri)\n end\n\n command << Node.new(\"clTRID\", SecureRandom.uuid)\n\n response = Hpricot::XML(send_request(xml.to_s))\n\n handle_response(response)\n end", "def login\n response = client.call :login, :message => { :username => username, :password => password }\n response.body[:login_response][:result]\n end", "def login\n @rest.headers[:content_type] = \"application/json\"\n\n response = api_request { @rest[\"login\"].post({:username => @username, :password => @password}) }\n\n @rest.headers[:x_opsview_token] = response[:token]\n @rest.headers[:x_opsview_username] = @username\n\n response\n end", "def login!\n params = { email: email, password: pass }\n response = Faraday.get(\"#{ACCOUNT_BASE}/login\", params)\n attributes = JSON.parse(response.body)\n @token = attributes[\"adminToken\"]\n end", "def login_with_token(token)\n resp = redis.get(token)\n if resp\n packet = JSON.parse(resp)\n login_as(packet['user']) unless authorized?\n else\n flash[:error] = 'It looks like this token has expired.'\n redirect to('/')\n end\n end", "def login(options, password = nil) # :yield: recvdata\n login_prompt = /[Ll]ogin[: ]*\\z/n\n password_prompt = /[Pp]ass(?:word|phrase)[: ]*\\z/n\n if options.kind_of?(Hash)\n username = options[\"Name\"]\n password = options[\"Password\"]\n login_prompt = options[\"LoginPrompt\"] if options[\"LoginPrompt\"]\n password_prompt = options[\"PasswordPrompt\"] if options[\"PasswordPrompt\"]\n else\n username = options\n end\n\n if block_given?\n line = waitfor(login_prompt){|c| yield c }\n if password\n line += cmd({\"String\" => username,\n \"Match\" => password_prompt}){|c| yield c }\n line += cmd(password){|c| yield c }\n else\n line += cmd(username){|c| yield c }\n end\n else\n line = waitfor(login_prompt)\n if password\n line += cmd({\"String\" => username,\n \"Match\" => password_prompt})\n line += cmd(password)\n else\n line += cmd(username)\n end\n end\n line\n end", "def connect_login(global = true)\n pop2sock = connect(global)\n\n\n if !(user and pass)\n print_status(\"No username and password were supplied, unable to login\")\n return false\n end\n\n print_status(\"Authenticating as #{user} with password #{pass}...\")\n res = raw_send_recv(\"HELO #{user} #{pass}\\r\\n\")\n\n if (res !~ /messages/)\n print_status(\"Authentication failed\")\n return false\n end\n\n print_status(\"Messages: #{res}\")\n return true\n end", "def login (username=\"alien\", password=\"password\")\n\t\tif @connected\n\t\t\tbegin\n\t\t\t\[email protected] \"#{username}\\r\\n\"\n\t\t\t\treceive()\n\t\t\t\[email protected] \"#{password}\\r\\n\"\n\t\t\t\ts = receive()\n\t\t\t\t\n\t\t\t\tif s.include? \"Error:\"\n\t\t\t\t\terr_msg = s.scan(/(Error: )(.*)/).flatten[1]\n\t\t\t\t\tclose()\n\t\t\t\t\traise \"Trouble logging in. \" << err_msg\n\t\t\t\t\t@connected = false\n\t\t\t\tend\n\t\t\trescue\n\t\t\t\traise\n\t\t\tend\n\t\tend\n\n\t\treturn @connected\n\tend", "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 login\n # If there's no connection, bail\n return if !@connected\n\n # Set the logged_in flag to false\n @logged_in = false\n \n # Send the command and read the response\n command = \"Action: Login\\r\\nUsername: \" + @username + \"\\r\\nSecret: \" + @secret + \"\\r\\n\\n\"\n response = self.send_request(command)\n \n # Check the response, set the flag, and write the log message\n @logged_in = self.check_response_status(response)\n \n if @logged_in\n @logger.success(\"Success: \" + response[:message])\n \n # The AMI immediately sends an event message after login. We don't care\n # about it, but it gets in the way of sending other commands. Read it and throw it in the log file\n self.read_response\n \n # Turn events off so we don't have to handle a bunch of asynchronous messages\n command = \"Action: Events\\r\\nEventmask: Off\\r\\n\\n\"\n response = self.send_request(command)\n \n @logger.success(\"Success: Async events turned off\") if (response[:response] == RESPONSE_SUCCESS)\n @logger.error(\"Failure: Could not turn async events off. This may cause problems\") if (response[:response] != RESPONSE_SUCCESS)\n else\n @logger.fatal(\"Error: \" + response[:message])\n end\n end", "def run\n begin\n pass = read_pass\n puts Vcloud::Core::Fog::Login.token_export(pass)\n rescue => e\n $stderr.puts(e)\n exit 1\n end\n end", "def login!(passwd = nil)\n self.password = passwd || self.password\n response = client.login(username.to_s, password.to_s)\n apply_attributes! response.result\n self.session_token.present?\n end", "def token\n authenticate_username_password || render_unauthorized\n end", "def login\n return @token if @token or @auth_method == :api_key\n request = Request.new(\"Post\", \"#{@config[:base_url]}/user/login\")\n\n request.add_multipart_body ({\n name: @config[:username],\n pass: @config[:password],\n form_id: \"user_login\",\n op: \"Log in\",\n })\n\n response = request.perform\n @token = response['Set-Cookie'].split(\";\")[0] if response and response['Set-Cookie']\n @token\n end", "def login\n params = {\n 'method' => :post,\n 'command' => '/sessions'\n }\n\n response, headers = send_request(params)\n\n if !headers.has_key?(:x_vcloud_authorization)\n raise \"Unable to authenticate: missing x_vcloud_authorization header\"\n end\n\n @auth_key = headers[:x_vcloud_authorization]\n end", "def send\n @request = Thread.new do\n request = nil\n msg = nil\n loop {\n if !@connected\n request = register_or_login\n puts sprintf(\"msg in send: %s\\n\", msg.inspect)\n @connected = true\n else\n msg = $stdin.gets.chomp.split\n command = msg.first\n if command == 'MSG'\n puts msg.inspect\n msg = msg.slice(1, msg.length-1).join(' ')\n else\n msg = nil\n end\n request = [command, msg].to_json\n end\n @server.puts( request )\n }\n end\n end", "def check_login\n action = \"check_login\"\n url = build_url(action)\n\n # Create data for post\n data = post_data(action)\n\n # The raw should be the terminal number on success\n response = parse(ssl_post(url, data)) { |raw| { code: raw[0..6] } }\n success = response[:code] == @options[:terminal_no] ? true : false\n Response.new(\n success,\n \"\",\n response,\n authorization: \"\",\n test: test?\n )\n end", "def login\n params = {\n 'method' => :post,\n 'command' => '/sessions'\n }\n\n response, headers = send_request(params)\n\n if !headers.has_key?(:x_vcloud_authorization)\n raise \"Unable to authenticate: missing x_vcloud_authorization header\"\n end\n\n extensibility_link = response.css(\"Link[rel='down:extensibility']\")\n @extensibility = extensibility_link.first['href'] unless extensibility_link.empty?\n\n @auth_key = headers[:x_vcloud_authorization]\n end", "def login\n make_login_call\n end", "def login\n params = {\n 'method' => :post,\n 'command' => '/sessions'\n }\n\n response, headers = send_request(params)\n\n if !headers.has_key?(:x_vcloud_authorization)\n raise \"Unable to authenticate: missing x_vcloud_authorization header\"\n end\n\n @auth_key = headers[:x_vcloud_authorization]\n end", "def token\n authenticate_username_password || render_unauthorized\n end", "def login(user, nick, real_name, flags=8)\n sendmsg \"USER #{user} #{flags} * :#{real_name}\"\n sendmsg \"NICK #{nick}\"\n end", "def login!\n connect! unless connected?\n @auth_header = @connection.head(@url.path)\n end", "def login(name, channel, password)\n @name = name\n @ch = channel\n @ch_pw = password\n @IRCsocket.write(\"PASS *\\n\")\n @IRCsocket.write(\"NICK #{@name}\\n\")\n @IRCsocket.write(\"USER #{@name} 8 * :#{@name}\\n\")\n @IRCsocket.write(\"JOIN #{@ch} #{@ch_pw}\\n\")\n end", "def login\n\t\[email protected] 'Email address:'\n\t\temail = @INSTREAM.gets.chomp\n\t\[email protected] 'Password:'\n\t\tbegin\n\t\t\t%x{stty -echo}\n\t\t\tpass = @INSTREAM.gets.chomp\n\t\t\[email protected]\n\t\tensure\n\t\t\t%x{stty echo}\n\t\tend\n\t\tdologin(email,pass)\n\tend", "def login\n response = get \"server\"\n response.code == 200\n end", "def login\n response = get \"server\"\n response.code == 200\n end", "def get_login_token\n object_from_response(Code42::Token, :post, \"loginToken\")\n end", "def chap_login(session,new_body)\n authen_start = session.authen_start\n new_body.server_msg = \"Username or password incorrect.\"\n\n if (!authen_start.header.minor_version_one?) # requires minor version 1\n new_body.status_fail!\n new_body.server_msg = \"Client sent malformed packet to server for CHAP login. \" +\n \"Minor version in TACACS+ header should be 1 but was #{authen_start.header.minor_version}.\"\n @tacacs_daemon.log(:error,['msg_type=Authentication', \"message=#{new_body.server_msg}\",\"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n elsif (authen_start.body.user_len != 0 && authen_start.body.data_len != 0)\n # get ppp_id, challenge, and response. ppp_id = 1 octet, response = 16 octets, challenge = remainder\n challenge_len = authen_start.body.data_len - 17\n ppp_id = authen_start.body.data[0].chr\n challenge = authen_start.body.data[1,challenge_len]\n response = authen_start.body.data[challenge_len+1, authen_start.body.data_len-1]\n\n username = authen_start.body.user\n user = @tacacs_daemon.users(username) if (username)\n if (user && user.login_password)\n if (Digest::MD5.digest(ppp_id + user.login_password + challenge) == response)\n if (user.login_password_expired?)\n new_body.status_fail!\n new_body.server_msg = @tacacs_daemon.password_expired_prompt\n elsif (user.login_acl)\n match_results = user.login_acl.match(@peeraddr)\n if ( match_results[:permit] )\n new_body.status_pass!\n new_body.server_msg = \"\"\n else\n new_body.status_fail!\n new_body.server_msg = \"Authentication denied due to ACL restrictions on user.\"\n @tacacs_daemon.log(:info,['msg_type=Authentication', 'message=User attempted CHAP login to restricted device.',\"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n end\n\n elsif (@tacacs_daemon.default_policy == :deny)\n new_body.status_fail!\n new_body.server_msg = \"Authentication denied due to ACL restrictions on user.\"\n @tacacs_daemon.log(:info,['msg_type=Authentication', 'message=CHAP login denied due to default policy.',\"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n\n else\n @tacacs_daemon.log(:info,['msg_type=Authentication', 'message=CHAP login permitted due to default policy.',\"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n new_body.status_pass!\n new_body.server_msg = \"\"\n end\n else\n new_body.status_fail!\n end\n else\n new_body.status_fail!\n end\n\n else\n new_body.status_fail!\n new_body.server_msg = \"Client requested CHAP login without providing both username and password.\"\n @tacacs_daemon.log(:warn,['msg_type=Authentication', \"message=#{new_body.server_msg}\",\"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n end\n\n if (new_body.status_pass?)\n @tacacs_daemon.log(:warn,['msg_type=Authentication', 'message=Authentication successful.',\"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n end\n\n return(nil)\n end", "def login()\n uri = URI('http://54.252.241.122:8000/users/authenticate')\n http = Net::HTTP.new(uri.host, uri.port)\n req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')\n req.body = {email: '[email protected]', password: '*********'}.to_json\n res = http.request(req)\n tkn=JSON.parse(res.body)\n return tkn['result']['token']\nend", "def login\n login = KonoEppLogin.new( tag, password )\n\n # FIXME: Order matters\n login.version = version\n login.lang = lang\n\n login.services = services\n login.extensions = extensions\n\n send_command( login )\n end", "def send_username( socket, username )\n socket.puts username\n socket.flush\n authkey = socket.gets.chomp\n return authkey\n end", "def login(password)\n authenticate(password) && set_token && save! && token\n end", "def login\n\t\tbegin\n\t\t\tr = execute(make_xml('LoginRequest', { 'sync-id' => 0, 'password' => @password, 'user-id' => @username }))\n\t\trescue APIError\n\t\t\traise AuthenticationFailed.new(r)\n\t\tend\n\t\tif(r.success)\n\t\t\t@session_id = r.sid\n\t\t\treturn true\n\t\tend\n\tend", "def request_login(http)\r\n login_post = construct_login_request\r\n login_response = http.request(login_post)\r\n logger.debug \"Login response: #{login_response.code}, Message: #{login_response.message}, Body: #{login_response.body}\"\r\n\r\n if login_response.code == '200'\r\n logger.debug 'Successfully logged in.'\r\n\r\n json_resp = JSON.parse(login_response.body)\r\n json_resp['auth_token']\r\n else\r\n logger.debug 'Failed log in.'\r\n nil\r\n end\r\n end", "def login\n puts '--- LOGIN ---'\n puts username: params[:user][:username]\n puts password: params[:user][:password]\n # = 'escape'\n user = User.find_by(username: params[:user][:username])\n if user && user.authenticate(params[:user][:password])\n token = create_token(user.id, user.username)\n render json: {status: 200, token: token, user: user}\n else\n render json: {status: 401, message: \"Unauthorized - Login\"}\n end\n end", "def login(user, password, sid = nil)\n sid ||= IDMIN + rand(IDMAX-IDMIN)\n @nurl ||= \"https://localhost:8834/\"\n post = { \"username\" => user, \"password\" => password, 'seq' => sid }\n\n response_json = nessus_request('session', post)\n\n if response_json['token']\n @token = response_json['token']\n @name = user\n @seqid = sid\n # Compatibility with XMLRPC ivar\n user_permissions = nessus_request('session', auth_header, :get)['permissions']\n @admin = ([64,128].any? {|perm| perm == user_permissions}).to_s.upcase\n return @token\n else\n raise \"Cannot authenticate to #{@nurl} as #{user} with #{password} due to #{response_json['error']}\"\n end\n\n end", "def login(username, password)\n return @@auth_token if defined?(@@auth_token) && @@auth_token\n reset_login(username, password)\n end", "def getTokenLogin( portal_name, language, flatpack_id, multipack_id)\n params = Hash.new\n params['portal_name'] = portal_name\n params['language'] = language\n params['flatpack_id'] = flatpack_id\n params['multipack_id'] = multipack_id\n return doCurl(\"get\",\"/token/login\",params)\n end", "def login(username, pwd)\n user = @server.proxy('User')\n logged_in_user_response = user.login({'login' => username, 'password' => pwd})\n #puts \"\\nlogged in user id = \" + logged_in_user_response['id'].to_s\n end", "def login\n end", "def login; end", "def login\n res = @cloud.api.post('account/login-api', { Email: @email, ApiKey: @api_key }.to_json)\n @token = res['access_token']\n @created_at = DateTime.parse(res['.issued'])\n @expire_at = DateTime.parse(res['.expires'])\n @token\n end", "def authenticate\n nick, auth_token = AuthenticateNick.new(auth_params[:name], request).call\n response = { message: \"Logged in\", nick: nick.name, auth_token: auth_token }\n json_response(response, :created)\n end", "def login\n \t\t response = @client.request :login do\n soap.body = { username: self.zconfig.user_name, password: self.zconfig.password}\n \t\t end\n \t\t response.to_hash\n \t \t self.session = response.to_hash[:login_response][:result][:session]\n end", "def login(uname, password, params = {})\n params = { :cmd => 'login', :uname => uname, :password => password }.merge(params)\n send_request(params)\n end", "def get_login(token)\n session[:login] ||= query_login(token)\nend", "def login\n $log.debug \"Logging in\" \n `./nplogin #{@@username} #{@@password}`\n end", "def ascii_login_and_enable(session,new_body)\n authen_start = session.authen_start\n authen_cont = session.authen_cont\n\n if (!session.reply.body) # no previous conversation has taken place\n if (authen_start.body.user_len == 0)\n # request username\n new_body.status_getuser!\n new_body.server_msg = @tacacs_daemon.login_prompt\n else\n # request password\n session.getuser = authen_start.body.user\n new_body.status_getpass!\n new_body.flag_noecho!\n new_body.server_msg = @tacacs_daemon.password_prompt\n end\n\n else # make sure we got what we asked for in last reply\n if (session.reply.body.status_getuser?)\n if (authen_cont.body.user_msg_len != 0)\n # request password\n session.getuser = authen_cont.body.user_msg\n new_body.status_getpass!\n new_body.flag_noecho!\n new_body.server_msg = @tacacs_daemon.password_prompt\n\n else\n # fail\n new_body.status_fail!\n new_body.server_msg = \"Username requested but none provided.\"\n end\n\n elsif (session.reply.body.status_getpass?)\n if (authen_cont.body.user_msg_len != 0)\n # determine pass/fail status\n username = session.getuser\n password = authen_cont.body.user_msg\n pass_fail = authenticate(username, password, session.authen_start)\n\n # set reply based on pass_fail\n if (pass_fail[:pass])\n new_body.status_pass!\n else\n new_body.status_fail!\n new_body.server_msg = pass_fail[:msg]\n end\n\n else\n # fail\n new_body.status_fail!\n new_body.server_msg = \"Password requested but none provided.\"\n end\n\n else\n # all other statuses are in error, so some sort of internal error must have occured\n new_body.status_error!\n new_body.server_msg = \"Internal Server Error. Unexpected status for ASCII login/enable: #{session.reply.body.status}\"\n @tacacs_daemon.log(:erro,['msg_type=Authentication', \"message=#{new_body.server_msg}\", \"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n\n end\n end\n\n return(nil)\n end", "def send_credentials\n dputs __method__.to_s\n login_req = setup_http_request($ident, @cookie, {:arg => [$CONF['user'], CGI.escape($CONF['pass'])]})\n res = @http.request(login_req)\n get_cookie(res)\n end", "def login_0\n\n #definde needed header\n headers = {'Authorization' => \"Basic \" + @base_user_string}\n\n #Login\n response = request({:method => \"POST\", :url => @host + \"login\", :headers => headers})\n\n #Get organisation link\n @org_link = parse_content(response.body, '//Org')[0].attribute('href').to_s\n\n #Get authentication header key\n @auth_key = response.headers[:x_vcloud_authorization]\n\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n auth_token =\n AuthenticateUser.new(auth_params[:email], auth_params[:phone_number], auth_params[:password]).call\n response = { message: Message.successful_login, auth_token: auth_token }\n json_response(response)\n end", "def login(user, password)\n\[email protected]('String' => \"login #{user} #{password}\\r\",'Match' => /error id=0 msg=ok\\n/, 'Timeout' => 3)\nend", "def login_related(msg)\n if Login === msg\n if @connection.server.authenticator.allowed?(\n msg.user_name, msg.password)\n @connection.user_name = msg.user_name\n @connection.send_msg(LoginOK.new)\n @connection.room.add_connection @connection\n else\n @connection.send_msg(LoginWrong.new)\n end\n return true\n elsif not @connection.authorized?\n @connection.send_msg Kick.new(\n \"Unauthorized connections aren't allowed to send '#{msg.class}'!\")\n @connection.force_close\n return true\n end\n false\n end", "def connect!\n retrieve_auth_token unless connected?\n auth_token[:token]\n end", "def login\n content = {\n 'Email' => @username,\n 'Passwd' => @password,\n 'source' => @app_name,\n 'accountType' => 'HOSTED_OR_GOOGLE',\n 'service' => 'cl'}\n\n response = send(Addressable::URI.parse(@auth_url), :post_form, content)\n\n raise HTTPRequestFailed unless response.kind_of? Net::HTTPSuccess\n\n @token = response.body.split('=').last\n @headers = {\n 'Authorization' => \"GoogleLogin auth=#{@token}\",\n 'Content-Type' => 'application/atom+xml'\n }\n @update_header = @headers.clone\n @update_header[\"If-Match\"] = \"*\"\n end", "def login_with_token(token, secret)\n values = {\n token: token,\n secret: secret\n }\n @client.make_request :post,\n auth_path('login_token'),\n values\n end", "def login\n username, password = request[:username, :password]\n if check_auth(username, password)\n session[:logged_in] = true\n session[:username] = username\n inside_stack? ? answer : redirect_referrer\n else\n if defined? AUTH_ELEMENT and AUTH_ELEMENT.to_s.split.any?\n open_element = \"<#{AUTH_ELEMENT}>\"\n close_element = \"</#{AUTH_ELEMENT}>\"\n end\n %{\n #{open_element}\n <form method=\"POST\" action=\"#{Rs(:login)}\">\n <ul style=\"list-style:none;\">\n <li>Username: <input type=\"text\" name=\"username\" /></li>\n <li>Password: <input type=\"password\" name=\"password\" /></li>\n <li><input type=\"submit\" /></li>\n </ul>\n </form>\n #{close_element}\n }\n end\n end", "def run()\n login()\n end", "def login_with_password(bot, name, password)\n send Common::Login.new(bot, name, password, nil)\n end", "def do_login(user, pass)\n vprint_status(\"#{rhost}:#{rport} - Trying username:'#{user.inspect}' with password:'#{pass.inspect}'\")\n begin\n res = send_request_cgi(\n {\n 'uri' => \"/doms/login/processLogin.php\",\n 'method' => 'GET',\n 'vars_get' =>\n {\n 'login' => user,\n 'passwd' => pass,\n 'tzOffset' => '-25200',\n 'tzString' => 'Thur+May+05+1983+05:05:00+GMT+0700+'\n }\n })\n\n if res.nil?\n print_error(\"#{rhost}:#{rport} - Connection timed out\")\n return :abort\n end\n\n check_key = \"The user has logged in successfully.\"\n\n key = JSON.parse(res.body)[\"statusString\"]\n\n if (not res or key != \"#{check_key}\")\n vprint_error(\"#{rhost}:#{rport} - FAILED LOGIN. '#{user.inspect}' : '#{pass.inspect}' with code #{res.code}\")\n return :skip_pass\n else\n print_good(\"#{rhost}:#{rport} - SUCCESSFUL LOGIN. '#{user.inspect}' : '#{pass.inspect}'\")\n report_cred(\n ip: rhost,\n port: rport,\n service_name: 'SevOne Network Performance Management System Application',\n user: user,\n password: pass,\n proof: key\n )\n return :next_user\n end\n\n rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError, ::Errno::EPIPE\n print_error(\"#{rhost}:#{rport} - HTTP Connection Failed, Aborting\")\n return :abort\n end\n end", "def mob_login\n token_manager = API::Concerns::TokenManager.new(params[:email], params[:password], params[:access_token])\n current_user = token_manager.current_user\n if !current_user.nil?\n render json: JSON.parse(current_user.to_json).except('id', 'password', 'pass_salt', 'updated_at')\n else\n render json: JSON.parse(token_manager.token.to_json)\n end\n end", "def login_with_token\n redirect_to :action => :do_login_with_token, :token => params[:t]\n end", "def login()\n content = {\n 'Email' => @username,\n 'Passwd' => @password,\n 'source' => @app_name,\n 'accountType' => 'HOSTED_OR_GOOGLE',\n 'service' => 'cl'}\n\n response = send(Addressable::URI.parse(@auth_url), :post_form, content)\n\n raise HTTPRequestFailed unless response.kind_of? Net::HTTPSuccess\n\n @token = response.body.split('=').last\n @headers = {\n 'Authorization' => \"GoogleLogin auth=#{@token}\",\n 'Content-Type' => 'application/atom+xml'\n }\n @update_header = @headers.clone\n @update_header[\"If-Match\"] = \"*\"\n end", "def pap_login(session,new_body)\n authen_start = session.authen_start\n\n if (!authen_start.header.minor_version_one?) # pap login requires minor version 1\n new_body.status_fail!\n new_body.server_msg = \"Client sent malformed packet to server for PAP login. \" +\n \"Minor version should be 1 but was #{authen_start.header.minor_version}.\"\n @tacacs_daemon.log(:error,['msg_type=Authentication', \"message=#{new_body.server_msg}\",\"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n elsif (authen_start.body.user_len != 0 && authen_start.body.data_len != 0)\n # determine pass/fail status\n username = authen_start.body.user\n pass_fail = authenticate(username, authen_start.body.data, authen_start)\n if (pass_fail[:pass])\n new_body.status_pass!\n else\n new_body.status_fail!\n new_body.server_msg = pass_fail[:msg]\n end\n\n else\n new_body.status_fail!\n new_body.server_msg = \"Client requested PAP login without providing both username and password.\"\n @tacacs_daemon.log(:debug,['msg_type=Authentication', \"message=#{new_body.server_msg}\",\"status=#{new_body.xlate_status}\"],authen_start,@peeraddr)\n end\n\n return(nil)\n end", "def get_ulogin_data(token)\n url = URI.parse(\"http://ulogin.ru/token.php?token=#{params[:u_token]}\")\n req = Net::HTTP::Get.new(url.to_s)\n res = Net::HTTP.start(url.host, url.port) {|http| http.request(req)}\n JSON.parse res.body\n end", "def auth_agent_channel(session, channel, packet); end", "def send_token_for_valid_login_of(user)\n\t\trender json: {token: user.auth_token }\n\tend", "def login(user,pass)\n enter_text(user_field, user)\n enter_text(pass_field, pass)\n sleep 1\n # wait_for_login_done\n end", "def perform_login_on_codeporting\r\n\t\r\n\tputs \"Sending login call\"\r\n\t#WORKING\r\n\turi = URI.parse(\"https://apps.codeporting.com\")\r\n\thttp = Net::HTTP.new(uri.host, uri.port)\r\n\thttp.use_ssl = true\r\n\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\tpath = '/csharp2java/v0/UserSignin'\r\n\tdata = \"LoginName=#{$username}&Password=#{$password}\"\r\n\theaders = {\r\n\t\t'Content-Type' => 'application/x-www-form-urlencoded'\r\n\t}\r\n\tresp, data = http.post(path, data, headers)\r\n\r\n\tdoc = REXML::Document.new(data)\r\n\r\n\tretValue = \"\"\r\n\tdoc.each_element('//return') { |item| \r\n\t\tretValue = item.attributes['success']\r\n\t}\r\n\r\n\t$token = ''\r\n\tif (retValue == \"True\")\r\n\t\tdoc.each_element('//Token') { |item| \r\n\t\t$token = item.text\r\n\t\tputs $token\r\n\t\tupload_code_to_codeporting\r\n\t}\r\n\tend\r\n end", "def login\n if params[:token]==md5(params[:email].to_s+\"fuckch0p\")\n @user = User.authenticate params[:email], params[:password]\n if @user\n @r = MobileApiResponse.new\n @r.user_id = @user.id\n @r.token = md5(@user.id.to_s + \"g04ts\")\n else\n @r = MobileApiError.new 3\n end\n else\n @r = MobileApiError.new 1\n end\n render :json => @r\n end", "def call\n checksum = Digest::SHA256.hexdigest \"#{Zerodha.api_key}#{password}#{Zerodha.api_secret}\"\n uri = URI.join(Zerodha.api_uri, 'session/token')\n body = {\n 'api_key' => Zerodha.api_key,\n 'request_token' => password,\n 'checksum' => checksum\n }\n\n resp = Net::HTTP.post_form(uri, body)\n result = JSON.parse(resp.body)\n \n if resp.code == '200'\n\n self.response = Zerodha::Base::Response.new(raw: result,\n status: 200,\n payload: {\n type: 'success',\n user_id: result['data']['user_id'],\n user_token: result['data']['access_token']\n },\n messages: ['success'])\n else\n raise Trading::Errors::LoginException.new(\n type: :error,\n code: resp.code,\n description: result['message'],\n messages: result['message']\n )\n end\n # pp response.to_h\n Zerodha.logger.info response.to_h\n self\n end", "def login\n username.set 'tomsmith'\n password.set 'SuperSecretPassword!'\n end", "def token_auth(*args, &block); end", "def login(username, password, device_id, push_token = '')\n values = {\n username: username,\n password: password,\n device_id: device_id,\n push_token: push_token\n }\n\n @client.make_request :post, auth_path('login'), values\n end", "def login\n @user = User.authenticate credentials[:email], credentials[:password]\n if @user # serializer makes it easier to return json, in this case the token\n render json: @user, serializer: LoginUserSerializer, root: 'user'\n else\n head :unauthorized # if authentication case this is executed\n end\n end", "def login_by(pin, device_id, push_token)\n values = {\n pin: pin,\n device_id: device_id,\n push_token: push_token\n }\n @client.make_request :post,\n auth_path('login_pin'),\n values\n end", "def login\n login_command = driver.login_command(state_file.read)\n command, *args = login_command.cmd_array\n options = login_command.options\n\n debug(\"Login command: #{command} #{args.join(' ')} (Options: #{options})\")\n Kernel.exec(command, *args, options)\n end", "def create\n\t\tif user = User.validate_login(params[:username], params[:password])\n\t\t\tallow_token_to_be_used_only_once_for(user)\n\t\t\tsend_token_for_valid_login_of(user)\n\t\telse\n\t\t\trender_unauthorized(\"Error with your login or password\")\n\t\tend\n\tend", "def token_get()\n\t\tputs \"Here is the token \" + @token\n\tend", "def auth(password)\n establish_connection\n\n @packet = RCon::Packet::Source.new\n @packet.auth(password)\n\n @socket.print @packet.to_s\n # on auth, one junk packet is sent\n rpacket = nil\n 2.times { rpacket = build_response_packet }\n\n if rpacket.command_type != RCon::Packet::Source::RESPONSE_AUTH\n raise RCon::NetworkException.new(\"error authenticating: #{rpacket.command_type}\")\n end\n\n @authed = true\n if @return_packets\n return rpacket\n else\n return true\n end\n end" ]
[ "0.69553477", "0.6641722", "0.6189487", "0.616265", "0.614956", "0.6052216", "0.6050336", "0.60495996", "0.60450184", "0.604339", "0.60205793", "0.6011686", "0.5973795", "0.59722173", "0.59708863", "0.5964438", "0.595205", "0.59301025", "0.59217465", "0.5916443", "0.59118", "0.5905002", "0.58853424", "0.58780336", "0.58509445", "0.5845053", "0.5813236", "0.5807419", "0.5806266", "0.57747424", "0.5761185", "0.57574517", "0.5756395", "0.57210356", "0.5713904", "0.5711", "0.5711", "0.56694454", "0.5663533", "0.56498796", "0.5649686", "0.5639192", "0.5635242", "0.5630291", "0.5613654", "0.5607836", "0.5606242", "0.55925155", "0.55861676", "0.5582975", "0.5574532", "0.5572963", "0.5567122", "0.5563779", "0.5562785", "0.5557492", "0.55536455", "0.55514514", "0.55490327", "0.55458343", "0.5545154", "0.554049", "0.554049", "0.554049", "0.554049", "0.554049", "0.554049", "0.554049", "0.554049", "0.554049", "0.55372906", "0.55310607", "0.55283344", "0.55229795", "0.5519732", "0.55180705", "0.5508697", "0.55039316", "0.5492488", "0.5490596", "0.54895496", "0.54855496", "0.5479163", "0.54785115", "0.547286", "0.54722047", "0.5470411", "0.5469211", "0.54667026", "0.5463987", "0.5462553", "0.5460303", "0.5453304", "0.5453178", "0.5451323", "0.54500085", "0.54486775", "0.5444051", "0.5441757", "0.5435805" ]
0.66610795
1
Transmit a packet over the connection
def send(packet) id = Common.packet_to_id(packet) data = [id, [packet.to_a]].to_msgpack @stream.write Common.encode_u16(data.length) @stream.write data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_tcp packet, destination_address\n\t\t\ttcp = TCPSocket.new(destination_address, @tcp_port)\n\t\t\ttcp.write(packet.to_str)\n\t\t\ttcp.close\n\t\tend", "def send(eiscp_packet)\n sock = TCPSocket.new @host, @port\n sock.puts eiscp_packet\n sock.close\n end", "def push packet\n begin\n @socket_server.write packet\n rescue Errno::ECONNRESET => e\n p e.message\n close\n reset_connection\n rescue Errno::EPIPE => e\n p e.message\n close\n reset_connection\n rescue Errno::ECONNREFUSED => e\n p e.message\n close\n reset_connection\n end\n end", "def send_packet(payload); end", "def transmit packets, delay: 0.1\r\n Ionian::Socket.new host: \"#{SOUNDWEB_IP}:#{SOUNDWEB_PORT}\" do |socket|\r\n packets.each do |packet|\r\n socket.write packet.pack(packet.map { 'C' }.join)\r\n socket.flush\r\n sleep delay\r\n end\r\n end\r\nend", "def transmit(command, options={})\n client.connection.transmit(command, **options)\n end", "def send_packet(type, *args)\n data = Net::SSH::Buffer.from(*args)\n msg = Net::SSH::Buffer.from(:long, data.length+1, :byte, type, :raw, data)\n channel.send_data(msg.to_s)\n end", "def send_packet(packet)\n @log.info \"Send DHCP #{@type.to_s.upcase} message to #{@hwaddr}.\"\n @socket.send(packet, 0, IPAddr.new(Config::SERVER_SUBNET).to_range.to_a.pop.to_s, Config::CLIENT_DHCP_PORT)\n end", "def send_packet( type, data=nil )\n buffer = @buffers.writer\n buffer.write_long( ( data ? data.length : 0 ) + 1 )\n buffer.write_byte type.to_i\n buffer.write data.to_s if data\n @socket.send buffer.to_s, 0\n end", "def send_packet(type, *args); end", "def send_packet()\n puts \"INFO: start to connecting to server\"\n begin \n @sock = TCPSocket.open(@@ip, @@port)\n rescue Exception => e\n\n puts \"ERROR: connection to server failed\"\n puts e.message\n puts e.backtrace.inspect\n return\n end\n \n puts \"Info: connection established \"\n begin\n xmlfile = File.new(\"#{@requestfile}\") \n if xmlfile\n puts \"open file : \" + \"#{@requestfile}\" + \" sucessfullly\"\n end\n rescue Exception => e\n puts \"ERROR: not existing request file: \" + \"#{@requestfile}\";\n puts e.message\n puts e.backtrace.inspect\n return\n end\n \n packet = \"\"\n while line = xmlfile.gets\n packet = packet + line.chomp \n end\n\n packet = packet + \"\\r\\n\"\n puts \"#{packet}\"\n\n @sock.write(packet)\n puts \"INFO: sending packet done\"\n end", "def packet_out(packet)\n packet.from_mac = @mac_address\n Log.puts \"#{@host.name}/#{@name} sending #{packet}\" if @trace\n @out_chan << packet if @out_chan\n end", "def send_packet(data_packet)\n connect if @socket.nil? || @socket.closed?\n\n super\n end", "def _transmit(used_socket, command, headers = {}, body = '')\n\n # p [ \"wirewrite\" ]\n # _dump_callstack()\n\n if @protocol >= Stomp::SPL_11 && command != Stomp::CMD_CONNECT\n headers = _encodeHeaders(headers)\n end\n @transmit_semaphore.synchronize do\n # Handle nil body\n body = '' if body.nil?\n # The content-length should be expressed in bytes.\n # Ruby 1.8: String#length => # of bytes; Ruby 1.9: String#length => # of characters\n # With Unicode strings, # of bytes != # of characters. So, use String#bytesize when available.\n body_length_bytes = body.respond_to?(:bytesize) ? body.bytesize : body.length\n\n # ActiveMQ interprets every message as a BinaryMessage\n # if content_length header is included.\n # Using :suppress_content_length => true will suppress this behaviour\n # and ActiveMQ will interpret the message as a TextMessage.\n # For more information refer to http://juretta.com/log/2009/05/24/activemq-jms-stomp/\n # Lets send this header in the message, so it can maintain state when using unreceive\n headers[:'content-length'] = \"#{body_length_bytes}\" unless headers[:suppress_content_length]\n headers[:'content-type'] = \"text/plain; charset=UTF-8\" unless headers[:'content-type'] || headers[:suppress_content_type]\n _wire_write(used_socket,command)\n headers.each do |k,v|\n if v.is_a?(Array)\n v.each do |e|\n _wire_write(used_socket,\"#{k}:#{e}\")\n end\n else\n _wire_write(used_socket,\"#{k}:#{v}\")\n end\n end\n _wire_write(used_socket,\"\")\n if body != ''\n if headers[:suppress_content_length]\n if tz = body.index(\"\\00\")\n used_socket.write body[0..tz-1]\n else\n used_socket.write body\n end\n else\n used_socket.write body\n end\n end\n used_socket.write \"\\0\"\n used_socket.flush if autoflush\n\n if @protocol >= Stomp::SPL_11\n @ls = Time.now.to_f if @hbs\n end\n\n end\n end", "def sendPacket(socket, port, packet, *networkIP)\n if(networkIP.size == 0)\n socket.send(packet, 0, packet.destIP.to_s, port)\n else\n socket.send(packet, 0, networkIP[0], port)\n end\nend", "def send_data(packet)\n if @status == :open\n data = JSON.dump(packet)\n @mutex.synchronize do\n @wscon.send(data)\n end\n return true\n end\n return false\n end", "def transmit(command, headers = {}, body = '')\n # The transmit may fail so we may need to retry.\n while true\n begin\n used_socket = socket()\n _transmit(used_socket, command, headers, body)\n return\n rescue Stomp::Error::MaxReconnectAttempts => e\n _ = e\n raise\n rescue\n @failure = $!\n raise unless @reliable\n errstr = \"transmit to #{@host} failed: #{$!}\\n\"\n unless slog(:on_miscerr, log_params, \"es_trans: \" + errstr)\n $stderr.print errstr\n end\n # !!! This loop initiates a re-connect !!!\n _reconn_prep()\n end\n end\n end", "def transmit_packet(packet, options={})\n # Default options\n options = {\n cache: false\n }.merge(options)\n\n packet = packet.as_json.deep_symbolize_keys\n\n if validate_packet(packet, options)\n if options[:cache]==true\n if update_cache(packet)\n transmit packet\n end\n else\n transmit packet\n end\n end\n end", "def send data\n data = [data.bytesize, *data.bytes].pack 'NC*'\n\n @socket.send data, 0\n end", "def send(data)\n @socket.send(data, SEND_FLAGS)\n end", "def xmit\n if @lag.zero?\n if @to_server\n $fake_server_port.on_packet_receive(CONNECTION_ID, @data, @channel)\n else\n $fake_client_conn.on_packet(@data, @channel)\n end\n true\n else\n @lag -= 1\n false\n end\n end", "def send_data(socket, data)\n begin\n socket.write([data.length].pack(PACKET_HEADER_FORMAT))\n socket.write(data)\n rescue Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE, Errno::ENOTCONN\n on_disconnect(socket)\n end\n end", "def send_packet(op_code, data)\n if @encoding == :etf\n send_etf_packet(op_code, data)\n else\n send_json_packet(op_code, data)\n end\n end", "def transmit(bytes)\n @transmitter.value = bytes\n end", "def send( data )\n # Final text data header:\n header = 0b10000001\n\n # Payload size to use (data will always be unmasked):\n size = \"#{data}\".size\n\n # Standard payload:\n if size < 126 then\n @connection.write [ header, size, \"#{data}\" ].pack \"C2A#{size}\"\n\n # 16-bit extended payload:\n elsif size <= 65535 then\n bytes = [ size ].pack( \"S\" ).unpack( \"C2\" ).reverse.map( &:to_i )\n @connection.write [ header, 126, *bytes, \"#{data}\" ]\n .pack \"C4A#{size}\"\n\n # 64-bit extended payload:\n else\n bytes = [ size ].pack( \"S\" ).unpack( \"C8\" ).reverse.map( &:to_i )\n @connection.write [ header, 127, *bytes, \"#{data}\" ]\n .pack \"C10A#{size}\"\n end\n end", "def send(a)\n\t\[email protected] a\n\tend", "def send_tcp message\n @sender.send_tcp message, @ip\n end", "def transmit(client_id, message, reliable = false, channel = ChannelManager::CHAT)\n @server.send_packet(client_id, message, reliable, channel)\n end", "def send_msg(data, connection)\n # TODO\n end", "def send_data_packet( data )\n # overhead is ( byte.length + id.length + strlen.length ) = 9\n data, data_to_return = split_data_for_packet( data.to_s, 9 )\n @window_size -= data.length\n\n msg = @buffers.writer\n msg.write_byte CHANNEL_DATA\n msg.write_long @remote_id\n msg.write_string data\n @connection.send_message msg\n\n data_to_return\n end", "def send_msg(data, connection)\n connection.send_msg(data)\n end", "def sendData(identKey,srcIP,dstIP,srcPort,dstPort,payload)\n\tudpPacket = udpConstruct(identKey,srcIP,srcPort,$dstIP,dstPort,payload)\n\tudpPacket.to_w # Sent\n\tprint \"Data Sent\\n\"\nend", "def send_message( message )\n if @logger.debug?\n @logger.debug \"sending message >>#{message.to_s.inspect}<<\"\n end\n\n @packet_sender.send message\n end", "def send_msg(data, connection)\n # TODO\n end", "def send_data(data)\n \n return nil if @connection.nil? or data.nil? or data.empty? \n \n begin\n @connection.send(data, 0)\n puts \"#{self.class} send to #{@tcp_ip}:#{@tcp_port} this: #{data.to_hex}\" if $debug\n rescue\n @connection = nil\n return nil\n end\n \n end", "def push(packet); end", "def send_message(data, flag, host, port)\n\t\tsocket = UDPSocket.new\n\t\tserialized = Marshal.dump(data)\n\t\tsocket.send serialized, flag, host, port\n\t\tsocket.close\n\t\tputs \"Sending #{data} to #{host}:#{port}\"\n\t\tsleep(0.025)\n\tend", "def connect_device port\n @transmitter.connect port\n end", "def transmit(data, via: T.unsafe(nil)); end", "def send(data)\n @conn.send serialize data\n end", "def send(message)\n socket.send(message, 0, address, port)\n end", "def send( text )\n checkConnection()\n @conn.write( text + EOL )\n end", "def send( text )\n checkConnection()\n @conn.write( text + EOL )\n end", "def send(data, opt={:type => :text})\n puts \"send ***************\"\n return if !@handshaked or @closed\n puts \"after send************\"\n type = opt[:type]\n frame = ::WebSocket::Frame::Outgoing::Client.new(:data => data, :type => type, :version => @handshake.version)\n begin\n @socket.write frame.to_s\n rescue Errno::EPIPE => e\n @pipe_broken = true\n emit :__close, e\n end\n end", "def transmit(data, via: nil) # :doc:\n logger.debug do\n status = \"#{self.class.name} transmitting #{data.inspect.truncate(300)}\"\n status += \" (via #{via})\" if via\n status\n end\n\n payload = { channel_class: self.class.name, data: data, via: via }\n ActiveSupport::Notifications.instrument(\"transmit.action_cable\", payload) do\n connection.transmit identifier: @identifier, message: data\n end\n end", "def send_packets_on_wire(packets)\n packets.each { |pkt| pkt.to_w(@iface) }\n end", "def tcp_send(command, body = nil)\n @seq += 1\n header = {\n 'Command' => command.to_s.gsub('_', '-'),\n 'Seq' => seq\n }\n\n buff = MessagePack::Packer.new\n buff.write(header)\n buff.write(body) unless body.nil?\n\n res = socket.write(buff.to_str) unless buff.to_str.empty?\n @requests[seq] = { header: header, ack?: false }\n seq\n end", "def request_success(packet); end", "def send_raw(data)\n # puts \"Sending data\"\n # puts_data(data)\n write(data)\n end", "def send_line(line)\n @socket.write(line.to_s + \"\\r\\n\")\n @socket.flush\n end", "def send( payload )\n @mutex.synchronize do\n # force the payload into a string\n payload = @compressor.compress( payload.to_s )\n\n # the length of the packet, minus the padding\n actual_length = 4 + payload.length + 1\n\n # compute the padding length\n padding_length = @cipher.block_size -\n ( actual_length % @cipher.block_size )\n padding_length += @cipher.block_size if padding_length < 4\n\n # compute the packet length (sans the length field itself)\n packet_length = payload.length + padding_length + 1\n\n if packet_length < 16\n padding_length += @cipher.block_size\n packet_length = payload.length + padding_length + 1\n end\n\n padding = Array.new( padding_length ) { rand(256) }.pack(\"C*\")\n\n unencrypted_data = [ packet_length, padding_length, payload,\n padding ].pack( \"NCA*A*\" )\n mac = compute_hmac( unencrypted_data )\n\n encrypted_data = @cipher.update( unencrypted_data ) << @cipher.final\n message = encrypted_data + mac\n @socket.send message, 0\n\n increment_sequence_number\n end\n end", "def perform_write(command)\n @tcp_socket.send(command.to_bytes.pack('C*'), 0)\n end", "def write_interface(data)\n\n puts connected?\n write_interface_base(data)\n port = 10 # TC PORT\n\t #Prio SRC DST DP SP RES HXRC\n header = \"%02b%05b%05b%06b%06b00000000\"\n Logger.instance.info(data)\n if data.length > 0\n # Get CSP header and data\n hdr = header % [1, @node.ord, @remote.ord, port, rand(11...64)]\n\n # print(\"con:\", hdr, hex(int(hdr, 2)))\n # print(\"con:\", parse_csp(hex(int(hdr, 2))), data)\n\n # Build CSP message\n hdr_b = hdr.scan(/......../).reverse\n hdr = hdr_b.map { |x| x.to_i(2).chr }\n\n #puts hdr\n # print(\"con:\", hdr_b, [\"{:02x}\".format(int(i, 2)) for i in hdr_b])\n #hdr = bytearray([int(i,2) for i in hdr_b])\n #hdr = hdr_b.join(', ')\n #puts hdr\n #print(\"Node: \", @node.chr, \" Hdr: \", hdr)\n #print(\"Data: \",data)\n\n\n #data_clean=data_cleaner(data)\n msg = [@remote.chr] + hdr + data.split(\"\")\n\n #msg = bytearray([node,]) + hdr + bytearray(data, \"ascii\")\n #print(\"con:\", msg)\n @write_socket.send_string(msg.join)\n\n end\n\n #sleep(0.25)\n end", "def write(s)\n @port.write(s)\n sleep(@wait_after_send / 1000.0) if @wait_after_send\n end", "def packets_handler(id, data, channel)\n\t# show who sent the packet, the data inside and the channel used\n\tputs \"packet from [peer #{id}] -> [#{data}] - [#{channel}]\" \n\t# answer sending the same data to the client (client ID, data, reliable or not, channel ID)\n\[email protected]_packet(id, data, true, channel)\nend", "def send str\n\n @send_buffer.push [Time.now.to_i + @send_buffer_delay, str] if @send_buffer_delay > 0\n\n begin\n if @send_buffer_delay > 0\n Protocol.write @client, (@send_buffer.shift)[1], :debug => 5 if Time.now.to_i >= (@send_buffer.first)[0]\n else\n Protocol.write @client, str, :debug => 5\n end\n false\n rescue Exception=>e\n puts \"!D connection terminated: #{e}\" if Config.debug\n true\n end\n end", "def _send_request(connection, req_bytes)\r\n\t\tconnection.print([req_bytes.size].pack('N') + req_bytes)\r\n\t\t@request_count += 1\r\n end", "def send\n Chain.send_transaction(hex)\n end", "def write(buffer)\n if @socket\n @socket.write(buffer)\n end\n end", "def connect(t, p, r)\n @socket << \"CONNECT #{t} #{p} #{r}\"\n end", "def send_line(line)\n connect unless connected?\n warn \"-> #{line}\" if @options[:debug]\n @socket.write(line.to_s + \"\\n\")\n @socket.flush\n self\n end", "def peer_send(peer,message)\r\n\t\t\tpeer.socket.puts(message)\r\n\t\tend", "def send_message(message)\n socket.enqueue_packet(message)\n end", "def send_etf_packet(op_code, data)\n LOGGER.debug { \"Sending #{OPCODES[op_code]} #{data}\" }\n payload = { op: op_code, d: data }\n @websocket.send_binary(Vox::ETF.encode(payload))\n end", "def send_raw(data)\n socket.send_raw data\n end", "def send(str)\r\n @socket.write(str + 0.chr)\r\n end", "def send_raw(data)\n raise ::Pwnlib::Errors::EndOfTubeError if @conn.nil?\n\n data.gsub!(context.newline, \"\\r\\n\") if @convert_newlines\n begin\n @conn.write(data)\n rescue RubySerial::Error\n close\n raise ::Pwnlib::Errors::EndOfTubeError\n end\n end", "def send_request(request)\n\n #send the request packet over the serial line\n write(request.with_checksum())\n\n #if this packet expects a response\n unless request.response_format.nil?\n #read the response\n raw_response = read.force_encoding('UTF-8')\n\n #force it into the proper format\n response = request.response_format.new(raw_response)\n\n unless response.valid?\n raise BadResponseError.new(\"A response from the scanner failed its checksum- was #{response.checksum.inspect}, should have been #{response.computed_checksum.inspect}.\\n #{response.inspect}\")\n end\n\n response\n end\n\n end", "def send(data)\n debug [:send, data]\n send_data(\"\\x00#{data}\\xff\")\n end", "def send(data)\n debug [:send, data]\n send_data(\"\\x00#{data}\\xff\")\n end", "def write(data, timeout = -1)\n data = data.to_s\n logger.trace('#write ==> sending', data) if defined?(SemanticLogger::Logger) && logger.is_a?(SemanticLogger::Logger)\n start_time = Time.now\n bytes_sent =\n begin\n super(data)\n rescue SystemCallError => exception\n logger.warn \"#write Connection failure: #{exception.class}: #{exception.message}\"\n close if close_on_error\n raise Net::TCPClient::ConnectionFailure.new(\"Send Connection failure: #{exception.class}: #{exception.message}\", address.to_s, exception)\n rescue Exception\n # Close the connection on any other exception since the connection\n # will now be in an inconsistent state\n close if close_on_error\n raise\n end\n if defined?(SemanticLogger::Logger) && logger.is_a?(SemanticLogger::Logger)\n logger.benchmark_debug(\"#write ==> #{bytes_sent} bytes\", duration: (Time.now - start_time))\n else\n logger.debug(\"#write ==> #{bytes_sent} bytes. #{'%.1f' % (Time.now - start_time)}ms\")\n end\n end", "def write(data)\n #@sock.write(data)\n\tputs \"channel data: #{str2hex(data)}\"\n end", "def send(msg)\n @socket.puts msg\n puts '<< ' << msg\n end", "def report_packet\n self.report('packet_report')\n end", "def send_data( data )\n\t\tjson = data.to_json\n\t\tbytes = json.bytesize\n\t\tputs \"SEND %3i bytes to %s: %s\" % [bytes,name,json] if $DEBUG\n\t\tunless @socket.closed?\n\t\t\[email protected] [bytes].pack('n')\n\t\t\tunless @socket.closed?\n\t\t\t\[email protected](json) == bytes\n\t\t\tend\n\t\tend\n\tend", "def tcp_send(command, body = nil)\n @seq += 1\n header = {\n 'Command' => command.to_s.gsub('_', '-'),\n 'Seq' => seq\n }\n Log.info(\"#{__method__}|Header: #{header.inspect}\")\n buff = MessagePack::Buffer.new\n buff << header.to_msgpack\n buff << body.to_msgpack unless body.nil?\n res = socket.send(buff.to_str, 0)\n Log.info(\"#{__method__}|Res: #{res.inspect}\")\n @requests[seq] = { header: header, ack?: false }\n seq\n end", "def send_recv(eiscp_packet)\n sock = TCPSocket.new @host, @port\n sock.puts eiscp_packet\n return Receiver.recv(sock, 0.5)\n end", "def send(socket)\n @socket = socket\n if @type\n\tsend_packet(create_packet)\n else\n\[email protected] \"Reply for #{@received_type.to_s.upcase} not implemented yet.\"\n\ttrue\n end\n end", "def send(message)\n\t\tbegin\n\t\t\[email protected]_message(message)\n\t\trescue IOException, NativeException\n\t\t\traise IOError, 'Failed to send message to USAR server'\n\t\tend\n\tend", "def push(packet)\n socket.queue_packet(packet)\n process_waiting\n end", "def putc(c)\n @port.write(c)\n sleep(@wait_after_send / 1000.0) if @wait_after_send\n end", "def send_with_reply( type, data=nil )\n send_packet type, data\n read_packet\n end", "def write(rawmsg)\r\n @connection.send(rawmsg)\r\n end", "def write( message )\n bytes_written = -1\n begin\n client = TCPSocket.new( @ip_address, @port )\n print_bytes( message )\n bytes_written = client.write message.pack( 'C*' )\n client.close\n rescue Exception => e\n @logger.write1 \"MoxaSerialPort::#{__method__}:: caught exception: #{e.message}\"\n end\n return bytes_written\n end", "def channel_open(packet); end", "def enqueue_packet(payload)\n # try to compress the packet\n payload = client.compress(payload)\n\n # the length of the packet, minus the padding\n actual_length = 4 + payload.bytesize + 1\n\n # compute the padding length\n padding_length = client.block_size - (actual_length % client.block_size)\n padding_length += client.block_size if padding_length < 4\n\n # compute the packet length (sans the length field itself)\n packet_length = payload.bytesize + padding_length + 1\n\n if packet_length < 16\n padding_length += client.block_size\n packet_length = payload.bytesize + padding_length + 1\n end\n\n padding = Array.new(padding_length) { rand(256) }.pack(\"C*\")\n\n unencrypted_data = [packet_length, padding_length, payload, padding].pack(\"NCA*A*\")\n mac = client.hmac.digest([client.sequence_number, unencrypted_data].pack(\"NA*\"))\n\n encrypted_data = client.update_cipher(unencrypted_data) << client.final_cipher\n message = \"#{encrypted_data}#{mac}\"\n\n debug { \"queueing packet nr #{client.sequence_number} type #{payload.getbyte(0)} len #{packet_length}\" }\n\n client.increment(packet_length)\n direct_write(message)\n\n self\n end", "def send_request(req, t = -1)\n connect(t)\n conn.put(req.to_s)\n end", "def enqueue_packet(payload); end", "def b_rdt_send message\n puts 'B Sending Data Unreliably...'\n packet = Packet.new\n packet.payload = message.data\n b_udt_send packet\nend", "def write(data)\n begin\n @socket.sync = false\n if data.nil?\n write_timeout([0, 0, @seq].pack(\"CvC\"), @opts[:write_timeout])\n @seq = (@seq + 1) % 256\n else\n data = StringIO.new data if data.is_a? String\n while d = data.read(MAX_PACKET_LENGTH)\n write_timeout([d.length%256, d.length/256, @seq].pack(\"CvC\")+d, @opts[:write_timeout])\n @seq = (@seq + 1) % 256\n end\n end\n @socket.sync = true\n @socket.flush\n rescue Errno::EPIPE\n @socket.close rescue nil\n raise ClientError::ServerGoneError, 'MySQL server has gone away'\n rescue Errno::ETIMEDOUT\n raise ClientError, \"write timeout\"\n end\n end", "def send_to_phone(ip_addr, data)\r\n\ts = TCPSocket.open(ip_addr, 5050)\r\n\ts.puts data\r\n\ts.close\r\nend", "def process_packet(packet)\n if packet.class == MQTT::Packet::Connack and packet.return_code == 0\n @state = :connected\n end\n\n @gateway_handler.relay_from_server(self, packet)\n end", "def send_data(data)\n log.debug(\"Sent stanza:\\t\\tfrom=#{@local_addr}\\tto=#{@remote_addr}\\n#{data}\\n\")\n super\n end", "def send_challenge socket, challenge, dist='\\5\\5'\n tag = 'n'\n flags = DFLAG_EXTENDED_REFERENCES | DFLAG_EXTENDED_PIDS_PORTS\n flags = e_four_bytes_big(flags)\n challenge = e_four_bytes_big(challenge)\n debug (\"writing challenge: #{challenge} to #{@remote_node.full_name}\")\n socket.write_packet_2(tag+dist+flags+challenge+@local_node.full_name)\n end", "def send(request)\n # clear socket\n puts \"flushing socket\" if @debug\n @socket.flush\n\n puts \"sending request: #{request.inspect}\" if @debug\n response = ''\n @socket.puts request.bencode\n\n while r = @socket.recv(1024)\n response << r\n break if r.length < 1024\n end\n\n puts \"bencoded reply: #{response.inspect}\" if @debug\n response = response.bdecode\n\n puts \"bdecoded reply: #{response.inspect}\" if @debug\n response\n end", "def send(data, flags = 0)\r\n SocketError.check if (ret = Winsock.send(@fd, data, data.size, flags)) == -1\r\n ret\r\n end", "def send(request)\n # Translate path so that underscores are converted to minuses\n # Don't change the original input value\n request.path = request.path.gsub('_', '-')\n request.tag = 0\n data = request.serialize_to_string\n # An additional header is added to the request indicating the size of the request\n head = [data.length].pack(\"N\")\n logger.trace('Sending') {request.to_hash}\n @socket.write(head+data)\n end", "def send_message(message)\n @socket.write(message)\n @socket.write(\"\\004\")\n end", "def send\n if @accepted then\n # Calculate content length before sending\n \n @headers << \"Content-Length: #{@buffer.length}\\r\\n\"\n \n if !@content_type then\n @headers << \"Content-Type: text/html\\r\\n\"\n end\n\n # Send our data and close the connection\n @server.puts @headers\n @server.puts \"\\r\\n\"\n @server.puts @buffer\n @server.close\n else\n puts \"[Rsws] ERROR: Trying to send response without first accepting it\"\n end\n end", "def send msg\n rencoded = REncode.dump([msg]).pack('C*')\n #rencoded = [193, 196, 1, 139, 100, 97, 101, 109, 111, 110, 46, 105, 110, 102, 111, 192, 102].pack('C*')\n compressed = Zlib::Deflate.deflate(rencoded)\n raw = compressed.bytes\n\n # all commented out stuff is for version 4, which we do not yet support\n # Store length as a signed integer (using 4 bytes), network byte order\n # header = [raw.length].pack('N').bytes\n\n #every message begins with an ASCII 'D'\n # header.insert(0, 'D'.ord)\n\n # header_str = header.pack('C*')\n message_str = raw.pack('C*')\n\n # puts \"Writing header:\"\n # p header_str.bytes\n # puts\n # puts \"Writing message:\"\n # p rencoded.bytes\n # puts\n\n\n # @con.write(header_str)\n @con.write(message_str)\n @con.flush\n\n nil\n end" ]
[ "0.6931033", "0.6879451", "0.6878823", "0.68696177", "0.6833697", "0.6794317", "0.6688148", "0.6671266", "0.6655429", "0.6640634", "0.66332614", "0.66228616", "0.65831417", "0.6357997", "0.63476944", "0.6291733", "0.6265326", "0.62641543", "0.6235007", "0.6228221", "0.6206566", "0.61944294", "0.6193015", "0.6169374", "0.6105107", "0.6098865", "0.6081298", "0.60581684", "0.6054987", "0.6031196", "0.5998258", "0.59869486", "0.5986912", "0.59634864", "0.5944547", "0.59332395", "0.592115", "0.59051496", "0.5901379", "0.5871018", "0.58685446", "0.5854064", "0.5854064", "0.5794155", "0.5792174", "0.57894045", "0.57462114", "0.572928", "0.57228285", "0.56845117", "0.56728154", "0.5667675", "0.56669533", "0.56656796", "0.56370467", "0.5632852", "0.56319696", "0.56296116", "0.5626847", "0.56261647", "0.56251943", "0.55903655", "0.5581516", "0.5579168", "0.55756813", "0.5571981", "0.55632764", "0.5561351", "0.5555623", "0.5555623", "0.55499375", "0.55450064", "0.55369747", "0.5534994", "0.55309594", "0.5528917", "0.5524529", "0.55069643", "0.5485666", "0.5449335", "0.54452354", "0.5440503", "0.54024076", "0.5388334", "0.5382543", "0.53792775", "0.53787863", "0.53785765", "0.53776395", "0.53765815", "0.53719956", "0.53692156", "0.5352485", "0.5347079", "0.53443944", "0.53352463", "0.5309238", "0.5307765", "0.53059316", "0.53018826" ]
0.7017103
0
Read a packet from the connection
def read() size_a = @stream.read 2 size = Common.decode_u16(size_a) data = @stream.read size data = MessagePack.unpack data class_ = Common.packet_from_id data[0] class_.new *data[1][0] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_packet\n length = @socket.read( 4 ).unpack( \"N\" ).first - 1\n type = @socket.read( 1 ).unpack( \"C\" ).first\n reader = @buffers.reader( @socket.read( length ) )\n return type, reader\n end", "def read_packet; end", "def read\n\n raise \"Interface not connected for read: #{@name}\" unless connected? && read_allowed?\n begin\n\n return get_packet\n rescue Exception => err\n\n Logger.instance.error(\"Error reading from interface : #{@name}\")\n disconnect()\n raise err\n end\n end", "def read\n @socket.read(1)\n end", "def read\n @socket.gets\n end", "def read()\r\n return @socket.read(1)\r\n end", "def read()\n data = @sock.recv(8192)\n return data\n end", "def read\n ensure_connected do |socket|\n Protocol::Reply.deserialize(socket)\n end\n end", "def receive_packet\n\t\treturn parser.recv(self.sock)\n\tend", "def read_packet_2 tag=nil\n len = self.read_two_bytes_big\n read_len len, tag\n end", "def read_packet(sock, timeout=nil)\n hostport = @client.get_hostport_for_socket(sock)\n if not hostport\n raise RuntimeError, \"Client doesn't know host/port for socket \" +\n sock.inspect\n end\n type, data = Util.read_response(sock, timeout)\n case type\n when :job_created\n handle_job_created(hostport, data)\n when :work_complete\n handle_work_complete(hostport, data)\n when :work_fail\n handle_work_fail(hostport, data)\n when :work_status\n handle_work_status(hostport, data)\n else\n Util.log \"Got #{type.to_s} from #{hostport}\"\n end\n nil\n end", "def read; @connection.readline end", "def readbyte\n map_exceptions do\n @socket.readbyte\n end\n end", "def read( bytes_to_read )\n begin\n client = TCPSocket.new( @ip_address, @port )\n read_bytes = client.read( bytes_to_read )\n puts \"Read #{read_bytes.length}:\"\n print_bytes( read_bytes )\n return read_bytes\n rescue Errno::ETIMEDOUT\n return -1\n end\n end", "def read_response(timeout=nil)\n end_time = Time.now.to_f + timeout if timeout\n head = timed_recv(socket, 12, timeout)\n magic, type, len = head.unpack('a4NN')\n raise ProtocolError, \"Invalid magic '#{magic}'\" unless magic == \"\\0RES\"\n buf = len > 0 ?\n timed_recv(socket, len, timeout ? end_time - Time.now.to_f : nil) : ''\n type = Packet::COMMANDS[type]\n raise ProtocolError, \"Invalid packet type #{type}\" unless type\n [type, buf]\n end", "def read\n read_object(read_byte)\n end", "def read_reply\n @socket.readline.chomp\n end", "def read_and_unpack_byte\n byte = @sock.read(1)\n raise SocketReadError if byte.nil?\n byte = byte.unpack('C')[0]\n end", "def get\n socket.readline\n end", "def read_frame\n byte = read_and_unpack_byte\n fin = (byte & 0b10000000) == 0b10000000\n rsv1 = byte & 0b01000000\n rsv2 = byte & 0b00100000\n rsv3 = byte & 0b00010000\n opcode = byte & 0b00001111\n\n @logger.debug \"unexpected value: rsv1: #{rsv1}\" unless rsv1 == 0\n @logger.debug \"unexpected value: rsv2: #{rsv2}\" unless rsv2 == 0\n @logger.debug \"unexpected value: rsv3: #{rsv3}\" unless rsv3 == 0\n\n byte = read_and_unpack_byte\n mask = (byte & 0b10000000) == 0b10000000\n lenflag = byte & 0b01111111\n\n # if len <= 125, this is the length\n # if len == 126, length is encoded on next two bytes\n # if len == 127, length is encoded on next eight bytes\n len = case lenflag\n when 126 # 2 bytes\n bytes = @sock.read(2)\n len = bytes.unpack(\"n\")[0]\n when 127 # 8 bytes\n bytes = @sock.read(8)\n len = bytes.unpack(\"Q\")[0]\n else\n lenflag\n end\n\n if mask then\n masking_key = @sock.read(4).unpack(\"C*\")\n end\n\n payload = @sock.read(len)\n payload = apply_mask(payload, masking_key) if mask\n\n return fin, opcode, mask, len, masking_key, payload\n end", "def read_message(socket)\n unless (buffer = socket.read(4)) && (buffer.size == 4)\n raise InvalidResponse, 'unexpected EOF'\n end\n\n length = buffer.unpack1('N')\n begin\n str = socket.read length\n message = Riemann::Message.decode str\n rescue StandardError\n puts \"Message was #{str.inspect}\"\n raise\n end\n\n unless message.ok\n puts 'Failed'\n raise ServerError, message.error\n end\n\n message\n end", "def getPacket(socket)\n\tpacket = Packet.new\n\tsize = 128\n\tbegin\n\t\tpacket = Packet.new(socket.recvfrom_nonblock(size)[0])\n\trescue Errno::EAGAIN\n\t\tIO.select([socket])\n\t\tretry\n\tend\n\treturn packet\nend", "def blocking_read\n raise RuntimeError, \"RAWIP: blocking_read: Not connected!\" unless connected?\n begin\n loop do\n data, sender = @rsock.recvfrom(8192)\n port, host = Socket.unpack_sockaddr_in(sender)\n #Assume a 20 byte IP header (yuck!)\n return data[20..-1] if host == @dest # only queue packets from our peer\n end\n rescue\n destroy_connection\n raise RuntimeError, \"RAWIP: blocking_read: Couldn't read from socket! (#{$!})\"\n end\n end", "def read_message\n\t\traise \"Server is not yet started\" unless self.started?\n\t\theader = self.reader.read( 5 ) or raise \"Server aborted.\"\n\t\tchannel, bytes = header.unpack( HEADER_TEMPLATE )\n\t\tself.log.debug \"Read channel %p message (%d bytes)\" % [ channel, bytes ]\n\n\t\t# Input requested; return the requested length as the message\n\t\tif channel == 'I' || channel == 'L'\n\t\t\treturn channel, bytes\n\t\tend\n\n\t\tself.log.debug \"Reading %d more bytes of the message\" % [ bytes ]\n\t\tmessage = self.reader.read( bytes ) unless bytes.zero?\n\t\tself.log.debug { \" read message: %p\" % [ message ] }\n\t\treturn channel, message\n\tend", "def read(length=4096,buffer='')\n @socket.read(length,buffer)\n end", "def recv(*args)\n data = recv_raw(*args)\n Packet.decode(data)\n rescue\n end", "def _receive(read_socket, connread = false)\n # p [ \"ioscheck\", @iosto, connread ]\n # _dump_callstack()\n # drdbg = true\n drdbg = false\n @read_semaphore.synchronize do\n line = nil\n if connread\n begin\n Timeout::timeout(@connread_timeout, Stomp::Error::ConnectReadTimeout) do\n line = _init_line_read(read_socket)\n end\n rescue Stomp::Error::ConnectReadTimeout => ex\n if @reliable\n _reconn_prep()\n end\n raise ex\n end\n else\n p [ \"CONR01\" ] if drdbg\n _dump_callstack() if drdbg\n line = _init_line_read(read_socket)\n end\n #\n p [ \"nilcheck\", line.nil? ] if drdbg\n return nil if line.nil?\n #An extra \\n at the beginning of the frame, possibly not caught by is_ready?\n line = '' if line == \"\\n\"\n if line == HAND_SHAKE_DATA\n raise Stomp::Error::HandShakeDetectedError\n end\n p [ \"wiredatain_01A\", line, Time.now ] if drdbg\n line = _normalize_line_end(line) if @protocol >= Stomp::SPL_12\n p [ \"wiredatain_01B\", line, Time.now ] if drdbg\n # Reads the beginning of the message until it runs into a empty line\n message_header = ''\n begin\n message_header += line\n p [ \"wiredatain_02A\", line, Time.now ] if drdbg\n unless connread || @ssl\n raise Stomp::Error::ReceiveTimeout unless IO.select([read_socket], nil, nil, @iosto)\n end\n p [ \"wiredatain_02B\", line, Time.now ] if drdbg\n line = _interruptible_gets(read_socket)\n p [ \"wiredatain_02C\", line ] if drdbg\n raise if line.nil?\n line = _normalize_line_end(line) if @protocol >= Stomp::SPL_12\n p [ \"wiredatain_02D\", line ] if drdbg\n end until line =~ /^\\s?\\n$/\n p [ \"wiredatain_03A\" ] if drdbg\n # Checks if it includes content_length header\n content_length = message_header.match(/content-length\\s?:\\s?(\\d+)\\s?\\n/)\n message_body = ''\n\n p [ \"wiredatain_03B\", content_length ] if drdbg\n # If content_length is present, read the specified amount of bytes\n if content_length\n unless connread || @ssl\n raise Stomp::Error::ReceiveTimeout unless IO.select([read_socket], nil, nil, @iosto)\n end\n p [ \"CL01\" ] if drdbg\n message_body = read_socket.read content_length[1].to_i\n unless connread || @ssl\n raise Stomp::Error::ReceiveTimeout unless IO.select([read_socket], nil, nil, @iosto)\n end\n raise Stomp::Error::InvalidMessageLength unless parse_char(read_socket.getc) == \"\\0\"\n # Else read the rest of the message until the first \\0\n else\n unless connread || @ssl\n raise Stomp::Error::ReceiveTimeout unless IO.select([read_socket], nil, nil, @iosto)\n end\n p [ \"NOCL01\" ] if drdbg\n message_body = read_socket.readline(\"\\0\")\n message_body.chop!\n end\n\n p [ \"wiredatain_04\" ] if drdbg\n # If the buffer isn't empty, reads trailing new lines.\n #\n # Note: experiments with JRuby seem to show that socket.ready? never\n # returns true. It appears that in cases where Ruby returns true\n # that JRuby returns a Fixnum. We attempt to adjust for this\n # in the _is_ready? method.\n #\n # Note 2: the draining of new lines must be done _after_ a message\n # is read. Do _not_ leave them on the wire and attempt to drain them\n # at the start of the next read. Attempting to do that breaks the\n # asynchronous nature of the 'poll' method.\n p [ \"wiredatain_05_prep\", \"isr\", _is_ready?(read_socket) ] if drdbg\n while _is_ready?(read_socket)\n unless connread || @ssl\n raise Stomp::Error::ReceiveTimeout unless IO.select([read_socket], nil, nil, @iosto)\n end\n p [ \"WHIR01\" ] if drdbg\n last_char = read_socket.getc\n break unless last_char\n if parse_char(last_char) != \"\\n\"\n read_socket.ungetc(last_char)\n break\n end\n end\n p [ \"wiredatain_05A\" ] if drdbg\n if @protocol >= Stomp::SPL_11\n @lr = Time.now.to_f if @hbr\n end\n # Adds the excluded \\n and \\0 and tries to create a new message with it\n p [ \"wiredatain_05B\" ] if drdbg\n msg = Message.new(message_header + \"\\n\" + message_body + \"\\0\", @protocol >= Stomp::SPL_11)\n p [ \"wiredatain_06\", msg.command, msg.headers ] if drdbg\n #\n if @protocol >= Stomp::SPL_11 && msg.command != Stomp::CMD_CONNECTED\n msg.headers = _decodeHeaders(msg.headers)\n end\n p [ \"wiredatain_99\", msg.command, msg.headers ] if drdbg\n msg\n end\n end", "def getPacket(socket)\n\tpacket = Packet.new\n\tsize = 2048 + 6\n\tbegin\n\t\tpacket = Packet.new(socket.recvfrom_nonblock(size)[0])\n\trescue Errno::EAGAIN\n\t\tIO.select([socket])\n\t\tretry\n\tend\n\n\treturn packet\nend", "def pull(io)\n lenbytes = io.read LEN_BYTES\n\n # this showed up in early testing ...\n raise \"BUG! - read from a pipe should never EOF\" if lenbytes.nil?\n\n cmdlen = lenbytes.unpack(LEN_PACK)[0]\n packet = io.read cmdlen\n if packet.bytesize == cmdlen\n Marshal.load packet\n else\n raise \"Corrupt/truncated packet!: #{packet.inspect}\"\n end\n end", "def read_byte; end", "def read timeout = DEFAULT_READ_TIMEOUT\n return @responses.shift unless @responses.empty?\n\n results = select([ @socket ], nil, nil, timeout)\n\n @buff += @socket.recv(4 * 1024) if (results and results[0].include? @socket) # results nil on timeout\n\n if @buff =~ /^(.*\\r\\n)(.*)$/m # network responses can split at odd boundries; check for completed messages ending with \\r\\n.\n @buff = $2 # save potential partial response for later..\n @responses += $1.split(/\\r\\n/) # and sock away all of the completed responses\n end\n\n @responses.shift # return next queued message or nil if we've timed out\n end", "def read( can_repeat )\n # Read the first byte containing final and opcode flags:\n byte = get_byte\n final = byte[ 0 ].to_i\n opcode = byte[ 4..7 ].to_i 2\n\n # Read the second byte containing the masked flag and payload size:\n byte = get_byte\n masked = byte[ 0 ].to_i\n payload_size = byte[ 1..7 ].to_i 2\n\n # If payload size is 126 or 127, we gotta use the extended payload size:\n if 126 == payload_size then\n payload_size = 2.times.map { get_byte }.join( \"\" ).to_i 2\n elsif 127 == payload_size then\n payload_size = 8.times.map { get_byte }.join( \"\" ).to_i 2\n end\n\n # Support variables:\n mask = nil\n\n # If the data is masked, get the mask:\n if masked then\n mask = 4.times.map { @connection.getbyte }\n end\n\n # Get the data:\n data = payload_size.times.map { @connection.getbyte }\n\n # Unmask the data if needed:\n if masked then\n data = data.each_with_index.map { |byte, i| byte ^ mask[ i % 4 ] }\n end\n\n # If the message wasn't final and we can repeat, read the next one(s):\n if 0 == final and can_repeat then\n c_type = nil\n c_data = nil\n\n # Keep reading until we'll get a final continuated result:\n while c_type != :cont_1 do\n c_type, c_data = read false\n data += c_data\n end \n end\n\n # Conditional return:\n case opcode\n # Continuation data:\n when 0\n return :\"cont_#{final}\", data\n\n # Textual data:\n when 1\n return :text, data.pack( \"C*\" ).force_encoding( \"utf-8\" )\n\n # Binary data:\n when 2\n return :binary, data\n\n # Close connection:\n when 8\n return :closed, nil\n\n # Pong request:\n when 9\n pong\n return :ping, nil\n\n # Every other case:\n else\n return opcode, data\n end\n end", "def reply\n bytes_read = receive_packet 1400\n is_compressed = false\n\n if @buffer.long == 0xFFFFFFFE\n split_packets = []\n begin\n # Parsing of split packet headers\n request_id = @buffer.long\n is_compressed = ((request_id & 0x80000000) != 0)\n packet_count = @buffer.byte\n packet_number = @buffer.byte + 1\n\n if is_compressed\n @buffer.long\n packet_checksum = @buffer.long\n else\n @buffer.short\n end\n\n # Caching of split packet data\n split_packets[packet_number - 1] = @buffer.get\n\n puts \"Received packet #{packet_number} of #{packet_count} for request ##{request_id}\" if $DEBUG\n\n # Receiving the next packet\n if split_packets.size < packet_count\n begin\n bytes_read = receive_packet\n rescue TimeoutException\n bytes_read = 0\n end\n else\n bytes_read = 0\n end\n end while bytes_read > 0 && @buffer.long == 0xFFFFFFFE\n\n if is_compressed\n packet = SteamPacketFactory.reassemble_packet(split_packets, true, packet_checksum)\n else\n packet = SteamPacketFactory.reassemble_packet(split_packets)\n end\n else\n packet = SteamPacketFactory.packet_from_data(@buffer.get)\n end\n\n if is_compressed\n puts \"Got compressed reply of type \\\"#{packet.class.to_s}\\\".\" if $DEBUG\n else\n puts \"Got reply of type \\\"#{packet.class.to_s}\\\".\" if $DEBUG\n end\n\n packet\n end", "def next_message\n socket.get_packet\n end", "def read(serializer)\n return serializer.de(@socket) if @socket\n \n # assert: @socket is still nil, because no connection could be made. \n # Try to make one\n loop do\n try_connect\n return serializer.de(@socket) if @socket\n sleep 0.01\n end\n end", "def reply\n receive_packet 1400\n\n if @buffer.long == 0xFFFFFFFE\n split_packets = []\n begin\n request_id = @buffer.long\n packet_number_and_count = @buffer.getbyte\n packet_count = packet_number_and_count & 0xF\n packet_number = (packet_number_and_count >> 4) + 1\n\n split_packets[packet_number - 1] = @buffer.get\n\n log.debug \"Received packet #{packet_number} of #{packet_count} for request ##{request_id}\"\n\n if split_packets.size < packet_count\n begin\n bytes_read = receive_packet\n rescue SteamCondenser::Error::Timeout\n bytes_read = 0\n end\n else\n bytes_read = 0\n end\n end while bytes_read > 0 && @buffer.long == 0xFFFFFFFE\n\n packet = SteamCondenser::Servers::Packets::SteamPacketFactory.reassemble_packet(split_packets)\n else\n packet = SteamCondenser::Servers::Packets::SteamPacketFactory.packet_from_data(@buffer.get)\n end\n\n log.debug \"Got reply of type \\\"#{packet.class.to_s}\\\".\"\n\n packet\n end", "def read\r\n status, answer, msg = @connection.read\r\n if status == :error\r\n raise answer\r\n else\r\n return [status, answer, msg]\r\n end\r\n end", "def read\n # Buffer for holding the received data. With sockets there is no\n # guarantee that you will receive the full message in a single\n # call to recv(). Accordingly, you have to have a buffer that\n # holds the partial data which is appended to on every recv\n # until you have a full message.\n buffer = ''\n #reader = BufferedReader.new(InputStreamReader.new(socket.get_input_stream))\n loop do\n # receive at most 8192 bytes, which is a mostly arbitrary\n # value that should work well\n chunk = socket.get_chunk\n # a zero-length chunk means the connection was closed\n if chunk == nil || chunk == '' || chunk == -1\n puts \"Lost connection\"\n @socket.close\n close\n break\n end\n\n # we use a single \\x000 (i.e., null) as a messag eterminator,\n # so we look for one in the chunk. If there is one, then that\n # gives us a complete message and we can process it. If not,\n # we wait for more data on the socket.\n if chunk == 0\n begin\n msg = YAML.load(buffer)\n rescue ArgumentError\n msg = nil\n puts \"Bad YAML recieved by #{self.class}\"\n end\n handle_msg(msg) if msg\n buffer = ''\n else\n begin\n buffer << chunk\n rescue\n puts $!\n end\n end\n end\n\n # Called when the socket connection is lost.\n def close\n end\n\n # Returns the socket object to be used in other operations. Must\n # be implemented by modules that include Communicator.\n def socket\n throw Exception(\"socket must be implemented\")\n end\n\n # Handles a message that's been received. Must be implemented by\n # moduels that include Communicator.\n def handle_msg msg\n throw Exception(\"handle_msg must be implemented\")\n end\n end", "def read\n @mutex.synchronize {\n if(!@reading)\n @reading = 1\n begin\n str = @sock.gets\n rescue\n end\n\n @reading = nil\n return str\n else\n return nil\n end\n }\n end", "def sysread( length )\n\t\tresult = self.recvfrom( length )\n\t\treturn result[0]\n\tend", "def read_from_wire\n len = nil\n while (len = recv_bytes(4).from_fbbe) == 0\n @time[:recv] = Time.now\n# rt_debug \"* hey, a keepalive!\"\n end\n\n id = recv_bytes(1)[0]\n\n if Message::WIRE_IDS[id] == :piece # add a block\n len -= 9\n m = Message.from_wire_form(id, recv_bytes(8))\n b = Block.new(m.index, m.begin, len)\n while len > 0\n thislen = [BUFSIZE, len].min\n b.add_chunk recv_bytes(thislen)\n len -= thislen\n end\n @time[:recv] = @time[:recv_block] = Time.now\n b\n else # add a message\n m = Message.from_wire_form(id, recv_bytes(len - 1))\n# rt_debug \"input: read message #{m}\"\n @time[:recv] = Time.now\n m\n end\n end", "def read\n data = @handle.availableData\n return data\n end", "def retrieve_data\r\n response = ''\r\n while next_line_readable?\r\n response = @socket.gets.chop\r\n puts response\r\n end\r\n response #returns last valid line\r\n end", "def read\n @buffer\n end", "def read\n # Obtain the \"pkt-len\"\n prefix = @input.read(4)\n\n unless prefix && prefix[/^[0-9a-f]{4}/]\n raise ProtocolError, \"invalid pkt-line prefix: #{prefix.inspect}\" \n end\n\n length = Integer(prefix, 16)\n return nil if length.zero?\n raise LengthError, \"length prefix too long\" if length > PKT_LINE_MAX\n raise LengthError, \"length prefix is malformed\" if length < 4\n\n @input.read(length - 4) || \"\"\n end", "def read(offset, len)\n _isource.read(offset, len)\n end", "def read(length=16384, timeout=nil)\n data = \"\"\n data.force_encoding(\"BINARY\") if data.respond_to?(:force_encoding)\n have_pushback = !@pushback_buffer.empty?\n if have_pushback\n data << @pushback_buffer\n @pushback_buffer = \"\"\n # We have data 'now' so don't wait.\n timeout = 0\n end\n\n if readable?(timeout)\n begin\n # Read at most 'length' data, so read less from the socket\n # We'll read less than 'length' if the pushback buffer has\n # data in it already.\n @socket.sysread(length - data.length, @read_buffer)\n data << @read_buffer\n return data\n rescue EOFError => e\n @socket.close\n @connected = false\n raise e\n end\n else\n if have_pushback\n return data\n else\n raise ReadTimeout.new\n end\n end\n end", "def read_line\n line = @socket.readline.chomp\n warn \"<- #{line}\" if @options[:debug]\n line\n end", "def read\n @serial_port.read()\n end", "def read(net_record)\n # Detects the type of record received from AC based on the size\n case net_record[:bytesize]\n when 408\n handle_handshake_response(net_record)\n when 328\n handle_rtcarinfo(net_record)\n when 212\n handle_rtlap(net_record)\n else\n nil\n end\n end", "def read clen, dest, ignore_eof = false\n temp_dest = inflate_adapter(dest)\n\n @socket.read clen, temp_dest, ignore_eof\n end", "def read\n ssl_socket.gets\n end", "def recv_raw(numbytes)\n raise ::Pwnlib::Errors::EndOfTubeError if @conn.nil?\n\n @serial_timer.countdown do\n data = ''\n begin\n while @serial_timer.active?\n data += @conn.read(numbytes - data.length)\n break unless data.empty?\n\n sleep 0.1\n end\n # XXX(JonathanBeverley): should we reverse @convert_newlines here?\n return data\n rescue RubySerial::Error\n close\n raise ::Pwnlib::Errors::EndOfTubeError\n end\n end\n end", "def read(byte_count)\n buffer = @current_io.read(byte_count)\n if !buffer\n select_next_io\n @current_io.read(byte_count)\n else\n buffer\n end\n end", "def read_message(s)\n if buffer = s.read(4) and buffer.size == 4\n length = buffer.unpack('N').first\n begin\n str = s.read length\n message = UState::Message.decode str\n rescue => e\n puts \"Message was #{str.inspect}\"\n raise\n end\n \n unless message.ok\n puts \"Failed\"\n raise ServerError, message.error\n end\n \n message\n else\n raise InvalidResponse, \"unexpected EOF\"\n end\n end", "def get\n @mutex.synchronize do\n # get the first block of data\n if @log.debug?\n @log.debug \"reading #{@cipher.block_size} bytes from socket...\"\n end\n\n data = read( @cipher.block_size )\n\n # decipher it\n reader = @buffers.reader( @cipher.update( data ) )\n\n # determine the packet length and how many bytes remain to be read\n packet_length = reader.read_long\n remaining_to_read = packet_length + 4 - @cipher.block_size\n if @log.debug?\n @log.debug \"packet length(#{packet_length}) \" +\n \"remaining(#{remaining_to_read})\"\n end\n\n # read the remainder of the packet and decrypt it.\n data = read( remaining_to_read )\n\n # get the hmac from the tail of the packet (if one exists), and\n # then validate it.\n hmac = @hmac.mac_length > 0 ? read( @hmac.mac_length ) : \"\"\n\n reader.append @cipher.update( data ) unless data.empty?\n reader.append @cipher.final\n\n padding_length = reader.read_byte\n\n payload = reader.read( packet_length - padding_length - 1 )\n padding = reader.read( padding_length ) if padding_length > 0\n\n my_computed_hmac = compute_hmac( reader.content )\n raise Net::SSH::Exception, \"corrupted mac detected\" if hmac != my_computed_hmac\n\n # decompress the payload\n payload = @decompressor.decompress( payload )\n\n increment_sequence_number\n\n buffer = @buffers.reader( payload )\n @log.debug \"received: #{buffer.content.inspect}\" if @log.debug?\n\n return buffer\n end\n end", "def read_message(s)\n if buffer = s.read(4) and buffer.size == 4\n length = buffer.unpack('N').first\n begin\n str = s.read length\n message = Riemann::Message.decode str\n rescue => e\n puts \"Message was #{str.inspect}\"\n raise\n end\n\n unless message.ok\n puts \"Failed\"\n raise ServerError, message.error\n end\n\n message\n else\n raise InvalidResponse, \"unexpected EOF\"\n end\n end", "def read_from_socket maxlen\n socket.read_nonblock maxlen\n rescue IO::WaitReadable\n :wait_readable\n end", "def capture_dump_read(intf, len=16384)\n request = Packet.create_request(COMMAND_ID_SNIFFER_CAPTURE_DUMP_READ)\n request.add_tlv(TLV_TYPE_SNIFFER_INTERFACE_ID, intf.to_i)\n request.add_tlv(TLV_TYPE_SNIFFER_BYTE_COUNT, len.to_i)\n response = client.send_request(request, 3600)\n {\n :bytes => response.get_tlv_value(TLV_TYPE_SNIFFER_BYTE_COUNT),\n :data => response.get_tlv_value(TLV_TYPE_SNIFFER_PACKET)\n }\n end", "def reply\n receive_packet 1400\n is_compressed = false\n packet_checksum = 0\n\n if @buffer.long == 0xFFFFFFFE\n split_packets = []\n begin\n request_id = @buffer.long\n is_compressed = ((request_id & 0x80000000) != 0)\n packet_count = @buffer.getbyte\n packet_number = @buffer.getbyte + 1\n\n if is_compressed\n @buffer.long\n packet_checksum = @buffer.long\n else\n @buffer.short\n end\n\n split_packets[packet_number - 1] = @buffer.get\n\n log.debug \"Received packet #{packet_number} of #{packet_count} for request ##{request_id}\"\n\n bytes_read = 0\n if split_packets.size < packet_count\n begin\n bytes_read = receive_packet\n rescue SteamCondenser::Error::Timeout\n end\n end\n end while bytes_read > 0 && @buffer.long == 0xFFFFFFFE\n\n packet = SteamCondenser::Servers::Packets::SteamPacketFactory.reassemble_packet(split_packets, is_compressed, packet_checksum)\n else\n packet = SteamCondenser::Servers::Packets::SteamPacketFactory.packet_from_data(@buffer.get)\n end\n\n if log.debug?\n packet_class = packet.class.name[/[^:]*\\z/]\n if is_compressed\n log.debug \"Got compressed reply of type \\\"#{packet_class}\\\".\"\n else\n log.debug \"Got reply of type \\\"#{packet_class}\\\".\"\n end\n end\n\n packet\n end", "def read() end", "def get_data(header,buff)\n server = TCPSocket.open('localhost', 2020)\n server.write buff\n resp = server.read(6)\n method = resp.unpack('v')[0]\n size = resp.unpack('V')[0].to_i\n protobuf = server.read(size)\n return method, protobuf\nend", "def get_packet\n\t\t\t\tfirst_number = read(1).unpack(\"C\")[0]\n\t\t\t\t# get the 'mask' property\n\t\t\t\tpacket_mask = first_number >> 6\n\t\t\t\t# get the 'frame1' property\n\t\t\t\tframe_number = first_number & 0x3F\n\t\t\t\tif frame_number == 0\n\t\t\t\t\t# if frame1 is equal to 0 then 'frame' is equal to 'frame2'\n\t\t\t\t\tframe_number = read(1).unpack(\"C\")[0]\n\t\t\t\telsif frame_number == 1\n\t\t\t\t\t# if frame1 is equal to 1 then 'frame' is equal to 'frame3'\n\t\t\t\t\tframe_number = read(2).unpack(\"n\")[0]\n\t\t\t\tend\n\t\t\t\t# init a 'frame stream' if it doesn't exist yet\n\t\t\t\tif ! @frames_in.has_key? frame_number\n\t\t\t\t\t@frames_in[frame_number] = Frame.new(0,0,0,0)\n\t\t\t\t\tif packet_mask != 0\n\t\t\t\t\t\traise StandardError, \"packet error\"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t# for logging purpose\n\t\t\t\t@bytes_in += 1\n\t\t\t\t\n\t\t\t\t# reads the 'time', 'datasize', 'rtmpdatatype' and 'streamid' properties from the socket\n\t\t\t\t# and put them into the 'frame stream' archive\n\t\t\t\t\n\t\t\t\tcase packet_mask\n\t\t\t\twhen 0\n\t\t\t\t\t@frames_in[frame_number].timer = getMediumInt()\n\t\t\t\t\t@frames_in[frame_number].size = getMediumInt()\n\t\t\t\t\t@frames_in[frame_number].data_type = read(1).unpack(\"C\")[0]\n\t\t\t\t\t@frames_in[frame_number].obj = read(4).unpack(\"N\")[0]\n\t\t\t\t\t@bytes_in += 11\n\t\t\t\twhen 1\n\t\t\t\t\t@frames_in[frame_number].timer = getMediumInt()\n\t\t\t\t\t@frames_in[frame_number].size = getMediumInt()\n\t\t\t\t\t@frames_in[frame_number].data_type = read(1).unpack(\"C\")[0]\n\t\t\t\t\t@bytes_in += 7\n\t\t\t\twhen 2\n\t\t\t\t\t@frames_in[frame_number].timer = getMediumInt()\n\t\t\t\t\t@bytes_in += 3\n\t\t\t\twhen 3\n\t\t\t\t\n\t\t\t\telse\n\t\t\t\t\n\t\t\t\tend\n\t\t\t\t# fix the CONNECTION_PACKET bug when its size is larger than 128 bytes (see caution 4.4.6)\n\t\t\t\tif ! @connected\n\t\t\t\t\tdata_length = @frames_in[frame_number].size\n\t\t\t\t\n\t\t\t\t\tif data_length < 129\n\t\t\t\t\t\tdata = read(data_length)\n\t\t\t\t\telsif data_length == 129\n\t\t\t\t\t\tdata = read(data_length+1)\n\t\t\t\t\t\tdata = data[0..-2]\n\t\t\t\t\telse data_length > 129\n\t\t\t\t\t\tdata = read(data_length+1)\n\t\t\t\t\t\tdata = data[0..127] << data[129..-1]\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tdata = read(@frames_in[frame_number].size)\n\t\t\t\tend\n\t\t\t\t# for logging purpose\n\t\t\t\t@bytes_in += data.length\n\t\t\t\t@msg_in += 1\n\t\t\t\t# return a RTMP_PACKET with all its properties (implicit ones included)\n\t\t\t\treturn RTMPPacket.new(\tframe_number,\n\t\t\t\t\t\t\t@frames_in[frame_number].timer,\n\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\t@frames_in[frame_number].data_type,\n\t\t\t\t\t\t\t@frames_in[frame_number].obj)\n\t\tend", "def getline\n return @socket.gets\n end", "def read\n @io.write(?r) # Read command\n sleep(0.1) until [email protected]?\n\n @io.readbyte\n end", "def read_berp\n length = @socket.read(4).unpack('N').first\n data = @socket.read(length)\n @encoding ? BERT.decode(data, @encoding) : BERT.decode(data)\n end", "def read_data\n\t\tbegin\n\t\t\treturn if @socket.closed?\n\t\t\tbytes = @socket.read(2)\n\t\t\traise IOError.new(\"no byte header\") unless bytes && bytes.bytesize==2\n\t\t\tbytes = bytes.unpack('n').first\n\t\t\treturn if @socket.closed?\n\t\t\tjson = @socket.read(bytes)\n\t\t\tputs \"RECV %3i bytes from %s: %s\" % [bytes,name,json] if $DEBUG\n\t\t\traise IOError.new(\"not enough JSON data\") unless json && json.bytesize==bytes\n\t\t\tJSON.parse(\"[#{json}]\",symbolize_names:true)[0]\n\t\trescue JSON::ParserError => e\n\t\t\twarn \"Failed to parse JSON response: #{json.inspect}; #{e}\"\n\t\trescue IOError => e\n\t\t\[email protected]\n\t\tend\n\tend", "def read(length = bytes_remaining)\n value = @data.byteslice(@pos, length)\n @pos += length\n value\n end", "def read\n serial_port.read_nonblock(4096)\n rescue EOFError\n end", "def read_content\n # read content if content is being sent\n if @content_length && @content_length > 0\n @content = @socket.read(@content_length)\n end\n end", "def blocking_read\r\n raise RuntimeError, \"CONN_UDP: blocking_read: Not connected!\" unless connected?\r\n begin\r\n [email protected](8192)[0]\r\n return nil if data.empty?\r\n data\r\n rescue\r\n destroy_connection\r\n raise RuntimeError, \"CONN_UDP: blocking_read: Couldn't read from socket! (#{$!})\"\r\n end\r\n end", "def receive(opts={})\n\t\ttimeout = opts.fetch(:timeout, 40).to_i\n\t\twait_for_null = opts.fetch(:wait_for_null, true)\n\t\t\n\t\tresponse = \"\"\n\t\t\n\t\t# Wait for data to become available on the socket\n\t\tres = select([@sock], nil, nil, timeout)\n\t\tif (res == nil)\n\t\t\traise \"Timeout waiting for reader response.\" if @raise_errors\n\t\tend\n\t\t\n\t\tif (wait_for_null)\n\t\t\tbegin\n\t\t\t\ttimeout(timeout) {\n\t\t\t\t\tresponse = @sock.gets(\"\\0\")\n\t\t\t\t}\n\t\t\trescue Timeout::Error\n\t\t\t\traise \"Timeout waiting for reader response.\" if @raise_errors\n\t\t\tend\n\t\t\t\n\t\t\tresponse.strip!\n\t\t\t\n\t\t\tif response.include? \"Error\"\n\t\t\t\traise response if @raise_errors\n\t\t\tend\n\t\t\t\n\t\t\t# If this is a response to a Quit command, the reader will close the socket. \n\t\t\t# If there is an active connection, the reader will reject our attempt to connect.\n\t\t\t# Either way, we're not connected anymore...\n\t\t\tif (response.include? \"Goodbye!\")\n\t\t\t\tclose(false)\n\t\t\tend\n\t\t\t\n\t\t\treturn response\n\t\telse\n\t\t\t# Simply try to read up to 1 kB and return it (no timeout)\n\t\t\treturn @sock.recv(1024)\n\t\tend\n\tend", "def read(timeout = nil)\n wait_for_data(timeout) if timeout\n MsgVersion.new{ @socket.read msg_version.bytesize }.validate!\n size = MsgSize.new{ @socket.decode msg_size, msg_size.bytes }.validate!.value\n return MsgBody.new{ @socket.decode msg_body, size }.validate!.value\n end", "def get(timeout=nil)\n data, saddr, sport = recvfrom(65535, timeout)\n return data\n end", "def decode\n state = :normal\n decoded = buffer.reduce [] do |acc, byte|\n case state\n when :normal\n if byte == 0x7d\n state = :special\n else\n acc << byte\n end\n when :special\n state = :normal\n acc << (byte ^ 0x20)\n end\n acc\n end\n Packet.new decoded\n end", "def socket_get\n\t\t\t\tline = @socket.gets.chomp\n\t\t\t\tdebug(\"<<< \" + line)\n\t\t\t\treturn line\n\t\t\tend", "def read\n connection.open(full_remote_path).read\n end", "def read_message! bytes, state=nil\n begin\n do_read_message! bytes, state\n rescue\n nil\n end\n end", "def read(offset, how_much)\n @stream.read(how_much)\n end", "def read(offset, how_much)\n @stream.read(how_much)\n end", "def _receive_response(connection)\r\n\t\tsize_bytes = connection.recv(4)\r\n\t\tsize = size_bytes.unpack('N')\r\n\r\n\t\tif size[0] == 0\r\n\t\t\treturn ''\r\n end\r\n\r\n\t\treturn connection.recv(size[0]) \r\n end", "def recv\n data = String.new\n data << @socket.gets until data.match(/\\r\\n$/)\n Parser.parse(data)\n end", "def read_message bytes, state=nil\n read_message! bytes.dup, state\n end", "def send_recv(eiscp_packet)\n sock = TCPSocket.new @host, @port\n sock.puts eiscp_packet\n return Receiver.recv(sock, 0.5)\n end", "def read_all(socket)\n total_bytes = socket.recv(4).unpack(\"V\")[0]\n if total_bytes and total_bytes > 0\n socket.recv(total_bytes)\n else\n ''\n end\n end", "def read()\n return @reader.call(@address)\n end", "def recv(sock)\n\t\tif (self.hdr_length_left > 0)\n\t\t\tbuf = sock.read(self.hdr_length_left)\n\n\t\t\tif (buf)\n\t\t\t\tself.raw << buf\n\n\t\t\t\tself.hdr_length_left -= buf.length\n\t\t\telse\n\t\t\t\traise EOFError\n\t\t\tend\n\n\t\t\t# If we've finished reading the header, set the\n\t\t\t# payload length left to the number of bytes\n\t\t\t# specified in the length\n\t\t\tif (self.hdr_length_left == 0)\n\t\t\t\tself.payload_length_left = raw.unpack(\"N\")[0] - 8\n\t\t\tend\n\t\telsif (self.payload_length_left > 0)\n\t\t\tbuf = sock.read(self.payload_length_left)\n\n\t\t\tif (buf)\n\t\t\t\tself.raw << buf\n\n\t\t\t\tself.payload_length_left -= buf.length\n\t\t\telse\n\t\t\t\traise EOFError\n\t\t\tend\n\t\tend\n\n\t\t# If we've finished reading the entire packet\n\t\tif ((self.hdr_length_left == 0) &&\n\t\t (self.payload_length_left == 0))\n\n\t\t\t# Create a typeless packet\n\t\t\tpacket = Packet.new(0)\n\n\t\t\t# TODO: cipher decryption\n\t\t\tif (cipher)\n\t\t\tend\n\n\t\t\t# Serialize the packet from the raw buffer\n\t\t\tpacket.from_r(self.raw)\n\n\t\t\t# Reset our state\n\t\t\treset\n\n\t\t\treturn packet\n\t\tend\n\tend", "def fetch(length)\n # This callback should be set just once, yielding with the parsed message\n @driver.on(:message) { |msg| yield(msg.data.pack('C*')) } if @driver.listeners(:message).length.zero?\n\n data = @sock.read_nonblock(length) # Read from the socket\n @driver.parse(data) # Parse the incoming data, run the callback from above\n end", "def receive\n begin\n paylaod_length = Protocol::Common::DataTypes::Uint32.decode(@io_in)\n rescue NoMethodError\n nil\n else\n payload = @io_in.read(paylaod_length)\n if payload.nil? || payload.bytesize != paylaod_length\n nil\n else\n payload\n end\n end\n end", "def read\n return irc_to_kcode(@recvmsg.pop)\n end", "def read(length)\n handle_socket_errors { super }\n end", "def serve(socket)\n size = socket.recvfrom(3)\n payload = socket.recvfrom(size)\n payload.bdecode\n puts payload[0]\n end", "def receive_data\n if @socket\n # udp receive\n @socket.recvfrom(1024)\n else\n # tcp receive\n sleep 0.1\n if $received_data\n $received_data.shift\n else\n fail 'no data'\n end\n end\n end", "def readbyte\n end", "def read_byte\n read('C', 1)\n end", "def read(bytes)\n @reader.read_nonblock(bytes)\n rescue Errno::EAGAIN\n # it simply means that there's nothing in\n # the output buffer.\n rescue Errno::EIO => msg\n @pid = nil\n rescue EOFError => msg\n @pid = nil\n end", "def read_line_from(socket)\n if read = socket.gets\n read.chomp\n end\nend", "def read_line_from(socket)\n if read = socket.gets\n read.chomp\n end\nend", "def parseDataPacket(bytes)\n return 0 if bytes.size < 5\n (id, nodeid, len) = bytes.unpack('CCC')\n return 0 if bytes.size < len + 4\n @client.handleData(nodeid, bytes.slice(3,len))\n return len + 4\n end", "def read(data, options = {})\n # Check for an encrpyted packet\n if data[2] == \"\\x09\"\n header = Header.new\n header.read(data)\n if header.request_type == RequestTypes[:secure_wrapper]\n\n # Was easier to just grab the raw string data\n nonce = data[8..23] # Timestamp + Serial Number + Tag\n mac_nonce = nonce + [header.wrapper.encrypted_frame.length].pack('n')\n\n cmac = CMAC.new(options[:key])\n if cmac.valid_message?(header.wrapper.cmac, message)\n # Init the AES encryption\n ccm = OpenSSL::CCM.new('AES', options[:key], 16)\n enc_nonce = nonce + \"\\x01\" # with a counter also appended\n\n # Extract the plain text datagram\n plaintext = ccm.decrypt(header.wrapper.encrypted_frame, enc_nonce)\n ResponseDatagram.new(plaintext, @options.merge(options))\n else\n raise 'KNX message failed security checks'\n end\n end\n else\n ResponseDatagram.new(data, @options.merge(options))\n end\n end" ]
[ "0.81583774", "0.8128841", "0.79864657", "0.718664", "0.7078291", "0.70767456", "0.69758976", "0.684859", "0.68352664", "0.67587477", "0.67497087", "0.6661749", "0.64809483", "0.64631426", "0.6461521", "0.6394127", "0.6344144", "0.6285171", "0.6279428", "0.6259725", "0.62315935", "0.618156", "0.61557615", "0.61364186", "0.6107559", "0.6103512", "0.6097384", "0.60960966", "0.60877156", "0.60702956", "0.60640484", "0.6050298", "0.60295796", "0.6029279", "0.60193485", "0.6011407", "0.60076505", "0.599963", "0.5983431", "0.5978976", "0.5960385", "0.59573746", "0.5954332", "0.5952908", "0.59410304", "0.5940709", "0.59316725", "0.5912093", "0.5906556", "0.59002495", "0.58872926", "0.587808", "0.58739436", "0.58666015", "0.5863844", "0.5855266", "0.5849851", "0.5844077", "0.5840704", "0.5803935", "0.57987344", "0.57897955", "0.5789694", "0.57854545", "0.5775607", "0.57637143", "0.576238", "0.57514286", "0.5739521", "0.5736933", "0.57233834", "0.5722405", "0.5720037", "0.57192236", "0.5718752", "0.569434", "0.5691127", "0.5686828", "0.56797624", "0.56769246", "0.56751436", "0.56706965", "0.566405", "0.5661026", "0.56586826", "0.5655182", "0.5651741", "0.5649995", "0.5646396", "0.5615861", "0.56155497", "0.5611176", "0.5606246", "0.5605145", "0.5587866", "0.5587208", "0.5586132", "0.5586132", "0.5585691", "0.557941" ]
0.67256093
11
Fires up the gateway session's event loop within a thread, so that it can run in the background. The loop will run for as long as the gateway remains active.
def initiate_event_loop! @active = true @thread = Thread.new do while @active @session_mutex.synchronize do @session.process(@loop_wait) end Thread.pass end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initiate_event_loop!\n @active = true\n\n @thread = Thread.new do\n while @active\n @session_mutex.synchronize do\n @session.process(@loop_wait)\n end\n Thread.pass\n end\n end\n end", "def serving_loop\n Thread.new { socket_loop }\n @manager.management_loop\n end", "def run_event_loop\n while true\n event = @event_queue.pop\n @worker_pool.dispatch event\n \n if @stopped\n Thread.stop;\n return\n end\n end\n end", "def run\n Thread.start do\n begin\n while true\n main_loop\n end\n ensure\n @protocol.close if @protocol\n end\n end\n end", "def run_socket_thread\n @thread ||= Thread.new { run_socket_loop }\n end", "def run_loop\n end", "def start_driver\n loop_thread = Thread.new { loop }\n start_listener\n loop_thread.kill!\n end", "def run\n @logger.info 'Running'\n @thread_status = :running\n\n register_self_with_zk\n register_callbacks\n watch\n loop do\n queue_event = @queue.pop\n GracefulTrap.critical_section(%w(INT TERM), @logger) do\n process_queue_event(\n queue_event[:type],\n queue_event[:value],\n queue_event[:meta]\n )\n end\n end\n @thread_status = :stopped\n end", "def wake_event_loop!\n super\n end", "def wake_event_loop!\n super\n end", "def go\n while(true)\n process_event(wait_for_event)\n end\n end", "def start\n @client.ping\n @state.set :run\n @thread ||= Thread.new{ work_loop }\n end", "def lights_start_loop_subscribe!\n Helpers.thread { lights_start_loop_subscribe }\n rescue => e\n Helpers.before_retry(e)\n retry\n end", "def start()\n @state = RUNNING\n @loop.wakeup() unless @loop.nil?\n end", "def run_async\n # Handle heartbeats\n @heartbeat_interval = 1\n @heartbeat_active = false\n @heartbeat_thread = Thread.new do\n Thread.current[:discordrb_name] = 'heartbeat'\n loop do\n if @heartbeat_active\n send_heartbeat\n sleep @heartbeat_interval\n else\n sleep 1\n end\n end\n end\n\n @ws_thread = Thread.new do\n Thread.current[:discordrb_name] = 'websocket'\n\n # Initialize falloff so we wait for more time before reconnecting each time\n @falloff = 1.0\n\n loop do\n @should_reconnect = true\n websocket_connect\n\n break unless @should_reconnect\n\n if @reconnect_url\n # We got an op 7! Don't wait before reconnecting\n LOGGER.info('Got an op 7, reconnecting right away')\n else\n wait_for_reconnect\n end\n\n # Restart the loop, i. e. reconnect\n end\n\n LOGGER.warn('The WS loop exited! Not sure if this is a good thing')\n end\n\n debug('WS thread created! Now waiting for confirmation that everything worked')\n sleep(0.5) until @ws_success\n debug('Confirmation received! Exiting run.')\n end", "def execute_in_main_thread(&block)\n EventMachine.schedule(&block)\n end", "def run_async\n @ws_thread = Thread.new do\n Thread.current[:discordrb_name] = 'websocket'\n connect_loop\n LOGGER.warn('The WS loop exited! Not sure if this is a good thing')\n end\n\n LOGGER.debug('WS thread created! Now waiting for confirmation that everything worked')\n loop do\n sleep(0.5)\n\n if @ws_success\n LOGGER.debug('Confirmation received! Exiting run.')\n break\n end\n\n if @should_reconnect == false\n LOGGER.debug('Reconnection flag was unset. Exiting run.')\n break\n end\n end\n end", "def dispatch_events!\n loop do\n event = @event_queue.pop\n\n callbacks.each do |callback|\n Thread.new do\n callback.call event\n end\n end\n end\n end", "def control_loop\n if stopping?\n unsubscribe!\n stopped!\n else\n attempt_recovery if paused?\n sleep(3)\n end\n end", "def run\n loop do\n tick\n sleep settings.service.polling_interval\n end\n end", "def run\n loop do\n tick\n sleep settings.service.polling_interval\n end\n end", "def loop(&block)\n block ||= Proc.new { pending_requests.any? }\n session.loop{Rex::ThreadSafe.sleep(0.5); block.call }\n end", "def management_loop\n kill_all_proxies\n loop do\n sync_reader_proxies\n Kernel.sleep 1\n end\n end", "def run\n Thread.new {\n loop do\n @server.update(1000)\n break if @terminate\n end\n }\n end", "def eventLoop\n @executor.executeQueuedTasks\n end", "def main_loop\n Thread.start(@protocol.accept) do |client|\n @grp.add Thread.current\n Thread.current['DRb'] = { 'client' => client ,\n 'server' => self }\n DRb.mutex.synchronize do\n client_uri = client.uri\n @exported_uri << client_uri unless @exported_uri.include?(client_uri)\n end\n loop do\n begin\n succ = false\n invoke_method = InvokeMethod.new(self, client)\n succ, result = invoke_method.perform\n if !succ && verbose\n p result\n result.backtrace.each do |x|\n puts x\n end\n end\n client.send_reply(succ, result) rescue nil\n ensure\n client.close unless succ\n if Thread.current['DRb']['stop_service']\n Thread.new { stop_service }\n end\n break unless succ\n end\n end\n end\n end", "def loop( &block )\n sanity_check\n @connection.loop(&block)\n end", "def event_loop\n Qwirk.logger.debug \"#{self}: Starting receive loop\"\n @start_worker_time = Time.now\n until @stopped || (config.stopped? && @impl.ready_to_stop?)\n Qwirk.logger.debug \"#{self}: Waiting for read\"\n @start_read_time = Time.now\n msg = @impl.receive_message\n if msg\n @start_processing_time = Time.now\n Qwirk.logger.debug {\"#{self}: Done waiting for read in #{@start_processing_time - @start_read_time} seconds\"}\n delta = config.timer.measure do\n @processing_mutex.synchronize do\n on_message(msg)\n @impl.acknowledge_message(msg)\n end\n end\n Qwirk.logger.info {\"#{self}::on_message (#{'%.1f' % delta}ms)\"} if self.config.log_times\n Qwirk.logger.flush if Qwirk.logger.respond_to?(:flush)\n end\n end\n Qwirk.logger.info \"#{self}: Exiting\"\n rescue Exception => e\n @status = \"Terminated: #{e.message}\"\n Qwirk.logger.error \"#{self}: Exception, thread terminating: #{e.message}\\n\\t#{e.backtrace.join(\"\\n\\t\")}\"\n ensure\n @status = 'Stopped'\n Qwirk.logger.flush if Qwirk.logger.respond_to?(:flush)\n config.worker_stopped(self)\n end", "def broadcast_worker_loop\n Thread.new do\n begin\n while @running\n broadcast\n sleep(@broadcast_worker_delay)\n end\n rescue => e\n logger.error \"Broadcast worker error:\"\n logger.error e\n retry\n end\n end\n end", "def foreground\n connect\n loop do\n run(@config[:interval], @config[:concurrency])\n end\nend", "def listenForeverBlocking\r\n unless EventMachine::reactor_running?\r\n debug \"running SINGLE THREAD!\"\r\n EM::run {\r\n EM::PeriodicTimer.new(300, proc { debug 'listener 300s ping'}) # this is actually never cancelled (yet)\r\n listenForeverLoopingOnErrorNonBlocking\r\n }\r\n debug \"listener EM done--EM.run ended\"\r\n else\r\n debug \"aww still multiple threaded [but still EM]...!\"\r\n listenForeverLoopingOnErrorNonBlocking\r\n sleep\r\n end\r\n end", "def bg_thread\n @bg_thread\n end", "def start_in_background\n Thread.start { start }\n end", "def start_thread\n @thread = @options[:sync] || Thread.new do\n begin\n loop do\n @status = :waiting_for_event\n process_event\n @event_queue.wait_for_new_event\n end\n rescue => e\n CFSM.logger.fatal \"#{e.class}: #{$!}\"\n Thread.main.raise e\n end\n end\n end", "def run\n EventMachine::run do\n @tcp = EventMachine::connect(config.server.host, config.server.port, TCPConnection)\n @tcp.client = self\n spectator_join\n end\n end", "def start\n main_loop\n end", "def activate_ssh_loop symbol\n @connections[symbol][:thread] = Thread.new(@connections[symbol]) {|c| c.loop {true}}\n end", "def run\n loop do\n break unless app_loop\n end\n end", "def run\n loop do\n Thread.start(server.accept) do |client|\n begin\n ServerThread.new(client,@job_queue).run\n rescue Exception => e\n STDERR.puts \"A server thread has encountered an exception:\"\n STDERR.puts \"--------------------------------\"\n STDERR.puts e.message\n STDERR.puts e.backtrace\n STDERR.puts \"--------------------------------\"\n end\n end\n end\n end", "def start\n Thread.new do\n loop do\n @connection.wait_for_notify do |channel|\n @actions[channel].call\n end\n end\n end\n end", "def start\n\t\t\t@thread = Thread.new do\n\t\t\t\twhile true\n\t\t\t\t\tupdate\n\t\t\t\tend\n\t\t\tend\n\t\tend", "def run!\n @thread && @thread.alive? ? @thread : start!\n end", "def sit\n\t\twhile connected?\n\t\t\tif block_given?\n\t\t\t\tyield\n\t\t\telse\n\t\t\t\tsleep(0.1)\n\t\t\tend\n\t\tend\n\tend", "def run_run_loop time = 1\n NSRunLoop.currentRunLoop.runUntilDate (Time.now + time)\nend", "def run\n capture_signals\n load_config\n\n EM.synchrony do\n connect\n start_throttle\n end\n end", "def run_server_thread; end", "def listen\n Thread.new do\n while true\n retrieve_messages\n sleep (0.1)\n end\n end\n end", "def start\n @thread = Thread.new do\n EM::WebSocket.start(ws_options) do |ws|\n ws.onopen do |handshake|\n log \"onopen: #{handshake.headers}\"\n @clients << ws\n end\n\n ws.onclose do |event|\n log \"closed: #{event}\"\n @clients.delete ws\n end\n\n ws.onmessage do |msg|\n log \"received: #{msg}\"\n end\n end\n end\n end", "def start_main_loop_thread\n current_generation = @main_loop_generation\n @main_loop_thread = create_thread_and_abort_on_exception do\n main_loop\n end\n @main_loop_thread_lock.synchronize do\n while @main_loop_generation == current_generation\n @main_loop_thread_cond.wait(@main_loop_thread_lock)\n end\n end\n end", "def listenLoop()\n x = Thread.new{\n i = 0\n while true\n i = i + 1\n puts \" \"\n print @name, \" Listen Loop Round: \", i\n puts \" \"\n jsonIN = @s.recv(65536)\n puts \" \"\n print @name, \" \", Time.now, \" has receaved a Message: \", jsonIN\n puts \" \"\n parsed = JSON.parse(jsonIN)\n if @netWorkMember\n self.respond( parsed )\n else\n puts \"Not a member of a Network hence I will not respond\"\n end\n end\n }\n end", "def start_keepalive_thread\n @keepalive.kill if @keepalive.is_a?(Thread)\n @keepalive = Thread.new do\n loop do\n sleep 10\n @ssh.send_global_request('[email protected]')\n end\n end\n end", "def start_loop\n loop do\n sleep 2\n start\n end\n rescue => e\n Torkify.logger.error { e }\n end", "def listen\n connect do\n routes.each do |queue|\n @client.subscribe(queue) do |args|\n run(queue, args)\n end\n end\n end\n while (!Thread.current[:shutdown]) do\n sleep(self.class.sleep_time)\n end\n end", "def irc_loop\n while true\n until @irc.dead_socket\n sleep 15\n @irc.handle(:irc_loop)\n Thread.pass\n end\n\n # Disconnected? Wait a little while and start up again.\n @nextserver = (@nextserver+1) % @servers.length\n sleep 30\n @irc.stop_listening\n self.connect_socket\n start_listening\n end\n end", "def capture_loop capp # :nodoc:\n capp.loop do |packet|\n enqueue_packet packet\n end\n end", "def connect_loop\n loop do\n @websocket.connect\n @websocket.thread.join\n break unless @should_reconnect.shift\n end\n end", "def listenLoop()\n x = Thread.new {\n i = 0\n while true\n i = i + 1\n puts \" \"\n print @name, \" Listen Loop Round: \", i\n puts \" \"\n jsonIN = @socket.recv(65536)\n puts \" \"\n print @name, \" \", Time.now, \" has received a Message: \", jsonIN\n puts \" \"\n parsed = JSON.parse(jsonIN)\n if @netWorkMember\n self.respond(parsed)\n else\n puts \"Not a member of a Network, No Response\"\n end\n end\n }\n end", "def dispatcher()\n require 'dispatch/dispatch'\n @dispatch = Dispatch.new\n @dispatch.start\n sleep\n end", "def background!(thread_name = nil)\n Thread.new do\n java.lang.Thread.currentThread.setName(thread_name) if thread_name\n begin\n @zk.reopen\n run\n @logger.info 'Main thread running in background'\n rescue => e\n @logger.fatal 'Unrecoverable worker exception: ', e\n @thread_status = :stopped\n end\n end\n end", "def reactor_thread\n @reactor_thread\n end", "def start_pong_loop\n Thread.new do\n loop do\n sleep 5\n # log \"pong all\"\n pong_everyone\n # log \"pong logsave\"\n save_chat_log\n end\n end\n end", "def run!\n @queue = []\n queue do\n @controller = Controller.new\n end\n catch :exit do\n while true\n tick\n FFI::NCurses.refresh\n end\n end\n rescue Exception => e\n Logger.log(e.message)\n Logger.log(e.backtrace.join(\"\\n\"))\n FFI::NCurses.clear\n FFI::NCurses.endwin\n raise\n end", "def run\n # Start the message handler\n @message_handler.start\n\n @worker_list.each { |t| t.join }\n end", "def loop_forever; end", "def dispatch event\n raise Exception.new(\"workers cannot dispatch while blocked\") if blocked?\n @event = event\n @is_running = true\n \n self.resume event\n end", "def start_thread #does this need to be its own thread?\n @@thread = Thread.new do\n self.run\n end\n end", "def run!\n start_server!\n loop do\n Thread.start(@proxy_server.accept) do |socket|\n begin\n handle_request(socket)\n rescue => e\n @logger.error(self.class) { e.message }\n @logger.error(self.class) { e.backtrace }\n ensure\n socket.close\n end\n end\n end\n end", "def run\n websocket.run\n end", "def run\n loop{\n @client = @server.accept\n @serverPool.schedule(@client)\n }\n end", "def run\n loop{\n @client = @server.accept\n @serverPool.schedule(@client)\n }\n end", "def start_queue_manager(device)\n Thread.new {\n loop {\n device.is_connected?\n sleep(0.25)\n }\n }\n end", "def running?; !!@thread end", "def start\n connect\n @last_alive = Time.now\n @listener = Thread.new do\n while true\n begin\n @last_alive = Time.now if @hub.fetch_command\n\n if Time.now > @last_alive + @keepalive_timeout\n @logger.error \"connection lost\" if @logger\n @last_alive = Time.now\n reconnect\n end\n\n rescue Exception => e\n exit if e.class == Interrupt\n puts e.message\n puts e.backtrace.join(\"\\n\")\n break\n end\n end\n end\n end", "def status_loop\n loop do\n @launcher.events.debug \"systemd: notify status\"\n begin\n @systemd.notify_status(status.to_s)\n rescue\n @launcher.events.error \"! systemd: notify status failed:\\n #{$!.to_s}\\n #{$!.backtrace.join(\"\\n \")}\"\n ensure\n sleep 1\n end\n end\n end", "def start_event_thread\n return false if @event_thread\n @event_thread = Thread.new(&method(:event_thread_body))\n end", "def run\n connect = false\n until connect do\n begin\n call { |server| @server = server ; start }\n rescue\n Waves::Logger.error e.to_s\n sleep 1\n end\n connect = true\n end\n end", "def run\n log.trace (\"run triggered\")\n while thread_current_running?\n current_time = Time.now.to_i\n\n emit() if thread_current_running?\n while thread_current_running? && Time.now.to_i <= current_time\n sleep @run_interval\n end\n end\n end", "def run\r\n catch :quit do\r\n loop do\r\n # Prepare events\r\n @event_queue.fetch_sdl_events\r\n @event_queue << @clock.tick\r\n\r\n # Handle events\r\n @event_queue.each do |event|\r\n yield event if block_given?\r\n # Stop this program if the user closes the window\r\n throw :quit if event.is_a? Rubygame::Events::QuitRequested\r\n end\r\n end\r\n end\r\n end", "def start_interrupter_thread()\r\n interrupter_tracepoint_init() if @auto_mode == :full\r\n @interrupter_thread = Thread.new() {interrupter_loop()}\r\n @interrupter_thread.priority = 1\r\n end", "def main_loop(fps = 60)\n self.fps = fps\n @ran_main_loop_p = true\n init_sync\n drive_mainloop do\n poll_event\n if block_given?\n screen.fill_rect(0, 0, screen.w, screen.h, background_color) if background_color\n yield(screen)\n end\n sync\n screen.flip\n end\n end", "def run\n Lita.logger.debug 'Slack::run started'\n sleep\n rescue Interrupt\n Lita.logger.info 'Slack::shutting down'\n end", "def run!\n start_server!\n @server_thread = Thread.new do\n loop do\n Thread.start(@server.accept) do |socket|\n begin\n handle_request(socket)\n rescue => e\n @logger.error \"#{e.class}: #{e.message}\"\n @logger.debug e.backtrace\n ensure\n closing_client = @client_mutex.synchronize do\n @clients.delete(socket)\n end\n # invoke callbacks for disconnect if there is a client to\n # disconnect\n emit(:client_disconnect, closing_client) if closing_client\n socket.close\n end\n end\n end\n end\n end", "def run\n self.stopped = false\n Marvin::Logger.info \"Starting up DRb Client\"\n DRb.start_service\n # Loop through, making sure we have a valid\n # RingFinger and then process events as they\n # appear.\n enter_loop!\n end", "def run!\n loop do\n begin\n job = Job.new(get_apps)\n job.fetch_targets!\n post_messages!(job.to_hash)\n sleep(@interval)\n rescue Errno::ECONNREFUSED => ce\n puts \"\"\n sleep(@interval)\n end\n\n end\n end", "def run_forever\n run\n sleep(10) while true\n end", "def run\n while true; async.handle_message @socket.read; end\n end", "def start\n return unless stopped?\n @stopped = false\n Thread.new do\n until stopped?\n tick\n sleep 0.01\n end\n end\n end", "def run\n Thread.new(interval, server) do |i, s|\n loop do\n s.refresh!\n sleep(i)\n end\n end\n end", "def listen\n @@em.schedule do\n EventMachine::WebSocket.run(:host => @host, :port => @port) do |ws|\n ws.onopen { }\n ws.onclose { @connection_event_handlers[:closed].each { |h| h.call self } }\n ws.onerror { |e| @connection_event_handlers[:error].each { |h| h.call self } }\n ws.onmessage { |msg| handle_message(msg, ws) }\n end\n end\n self\n end", "def loop &block\n _loop ::Dnet, :route_loop, Entry, &block\n end", "def start_watcher\n Thread.new{ loop{ watcher_cycle }}\n end", "def watchdog_loop\n @launcher.events.log \"* systemd: watchdog detected (#{@systemd.watchdog_usec}usec)\"\n\n # Ruby wants seconds, and the docs suggest notifying halfway through the\n # timeout.\n sleep_seconds = @systemd.watchdog_usec / 1000.0 / 1000.0 / 2.0\n\n loop do\n begin\n @launcher.events.debug \"systemd: notify watchdog\"\n @systemd.notify_watchdog\n rescue\n @launcher.events.error \"! systemd: notify watchdog failed:\\n #{$!.to_s}\\n #{$!.backtrace.join(\"\\n \")}\"\n ensure\n @launcher.events.debug \"systemd: sleeping #{sleep_seconds}s\"\n sleep sleep_seconds\n end\n end\n end", "def tracer_thread_runner\n while running?\n # Get a random user assigned to this server.\n user = User.where(:enable_tracer => true, :archived => false).select(:id, :connected_at).all.select do |user|\n server_rhash.hash(user.id) == server_tag && user.connected_at\n end.shuffle.first\n\n # If we found a user, schedule a tracer email.\n if user\n user.reload\n ScheduleTracerEmails.new(user, self.num_tracers).delay.run\n end\n\n light_sleep self.tracer_interval\n end\n rescue Exception => e\n Log.exception(e)\n raise e\n ensure\n Log.info(\"Stopping tracer thread.\")\n end", "def start()\n super()\n\n @@count += 1\n\n if !EM.reactor_running? and @@thread == nil\n @@thread = Thread.new do\n EM.run\n end\n\n sleep 1 until EM.reactor_running? # Make sure that EM is running\n end\n end", "def loop\n end", "def event_machine(&block)\n if EM.reactor_running?\n # logger.debug \"Reactor is running!\"\n block.call\n else\n # logger.debug \"Reactor is NOT running!\"\n Thread.new {EM.run}\n EM.next_tick(block)\n end\n end", "def event_machine(&block)\n if EM.reactor_running?\n # logger.debug \"Reactor is running!\"\n block.call\n else\n # logger.debug \"Reactor is NOT running!\"\n Thread.new {EM.run}\n EM.next_tick(block)\n end\n end", "def service_thread(&block)\n start_service\n Ricer::Thread.execute {\n begin\n yield\n ensure\n stopped_service\n end\n }\n end", "def run\n @thread = Thread.start do\n loop do\n begin\n register unless registered?\n rescue DRb::DRbConnError\n @ring_server = nil\n rescue RuntimeError => e\n raise unless e.message == 'RingNotFound'\n end\n sleep @check_every\n end\n end\n end" ]
[ "0.7530425", "0.67786705", "0.67746305", "0.6593444", "0.6338033", "0.63141614", "0.6270804", "0.6237769", "0.6219712", "0.6219712", "0.61897856", "0.6167689", "0.61242604", "0.60722846", "0.60667753", "0.6065734", "0.6058754", "0.6052629", "0.60506123", "0.6041582", "0.6041582", "0.60391754", "0.60294825", "0.6026337", "0.6025753", "0.6006488", "0.6005785", "0.59964836", "0.59861237", "0.5972062", "0.593944", "0.5932518", "0.59224814", "0.59172535", "0.58557576", "0.58415204", "0.5835101", "0.5819742", "0.58164424", "0.58156246", "0.5809365", "0.5806655", "0.57634044", "0.5732478", "0.57290864", "0.5725699", "0.5709283", "0.5705499", "0.57017297", "0.57014984", "0.56937736", "0.56860036", "0.5679174", "0.5678374", "0.56744397", "0.5670132", "0.5661786", "0.5658392", "0.5644553", "0.56435156", "0.56260854", "0.56168985", "0.56150204", "0.56123656", "0.56033224", "0.559608", "0.5591123", "0.5585771", "0.55826914", "0.55826914", "0.5579277", "0.5578602", "0.55686754", "0.5555204", "0.5548197", "0.5544561", "0.55399704", "0.5536558", "0.5534854", "0.5534679", "0.55149406", "0.5514528", "0.55109084", "0.5505453", "0.55017585", "0.5498585", "0.5493831", "0.54874015", "0.54832274", "0.5481679", "0.5477522", "0.5475832", "0.54746985", "0.54699385", "0.5466426", "0.5462978", "0.5462978", "0.545265", "0.5447079" ]
0.7528908
1
===================== Complex validations: =====================
def validate # first check whether combo fields have been selected is_valid = true if is_valid is_valid = set_drench_concentrate_status end # if is_valid # is_valid = ModelHelper::Validations.validate_combos([{:drench_line_type_code => self.drench_line_type_code}],self) # end # #now check whether fk combos combine to form valid foreign keys # if is_valid # is_valid = set_drench_station # end # if is_valid # is_valid = ModelHelper::Validations.validate_combos([{:concentrate_code => self.concentrate_code}],self) # end # #now check whether fk combos combine to form valid foreign keys # if is_valid # is_valid = set_concentrate_product # end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validation; end", "def validation; end", "def is_valid; end", "def validate\n \n \n end", "def valid?(_) true end", "def valid?(_) true end", "def validate; end", "def validate; end", "def validate; end", "def validate; end", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def validate\r\n\r\n end", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def valid; end", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def validate!; end", "def validate!; end", "def validate!; end", "def valid?; end", "def valid?; end", "def valid?; end", "def valid?; end", "def valid?; end", "def validated?; end", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def validate_params\n validate_size\n validate_mine_density\n validate_first_click\n type_specific_checks\n end", "def validate\n errors.add(:post_office, \"- must be filled for postalcode #{self.postal_code}\") if self.post_office.blank? && !self.postal_code.blank?\n errors.add(:postal_code, \"- must be filled for #{self.post_office}\") if self.postal_code.blank? && !self.post_office.blank? \n errors.add_to_base(\"- Person must have at least one phonenumber\") if (self.phone_home.blank? && self.phone_cell.blank? && self.phone_work.blank?) \n end", "def validations\n valid_page_number? if page_number\n valid_period_name? if period_param\n valid_date? if date_param\n end", "def valid?\n @errors << :title if [email protected]_a?(String) || @title.empty?\n @errors << :author if [email protected]_a?(String) || @author.empty?\n @errors << :release_date unless @release_date.is_a?(Date)\n @errors << :publisher if [email protected]_a?(String) || @publisher.empty?\n @errors << :isbn unless @isbn.is_a?(Integer) && @isbn < 10**10 && @isbn >= 10**9\n \n @errors.empty?\n end", "def validator; end", "def validate!\n # pass\n end", "def set_validations_and_filters\n validates_length_of :numero_publicacion, :in => 6..12, :allow_nil => true, :allow_blank => true\n validates_presence_of :fecha_solicitud, :numero_gaceta\n validates_format_of :numero_solicitud, :with => /^\\d+-\\d{4}/\n validates_uniqueness_of :numero_solicitud#, :scope => :parent_id\n #validates_presence_of :numero_publicacion, :numero_gaceta\n end", "def extra_validations\n success\n end", "def subclass_validations ; true ; end", "def is_valid?\n end", "def validate\n end", "def validate\n # add errors if not validate\n end", "def validate\n\n end", "def validate\n end", "def validate\n end", "def validate\n end", "def validated; end", "def custom_validations\n self.validate_baseline && validate_baseline_date && \n self.validate_trial_days && self.validates_goal_name && self.validation_due_date\n end", "def valid?\n return false if @ach_type.nil?\n return false if @routing_number.nil?\n return false if @routing_number.to_s.length > 9\n return false if @routing_number.to_s.length < 9\n return false if @routing_number !~ Regexp.new(/^[0-9]+$/)\n return false if @account_number.nil?\n return false if @account_number.to_s.length > 56\n return false if @account_number.to_s.length < 1\n return false if @account_number !~ Regexp.new(/^[0-9]+$/)\n return false if @account_type.nil?\n account_type_validator = EnumAttributeValidator.new('String', [\"C\", \"S\"])\n return false unless account_type_validator.valid?(@account_type)\n return false if !@check_number.nil? && @check_number.to_s.length > 10\n return false if !@check_number.nil? && @check_number !~ Regexp.new(/^[0-9]+$/)\n return false if @check_type.nil?\n check_type_validator = EnumAttributeValidator.new('String', [\"P\", \"C\"])\n return false unless check_type_validator.valid?(@check_type)\n return false if !@product_code.nil? && @product_code.to_s.length > 6\n return false if !@product_code.nil? && @product_code !~ Regexp.new(/^[0-9]+$/)\n return false if !@agent_id.nil? && @agent_id.to_s.length > 6\n return false if !@agent_id.nil? && @agent_id !~ Regexp.new(/(?=.*[^\\s])^[^|]+$/)\n return false if !@terminal_id.nil? && @terminal_id.to_s.length > 10\n return false if !@terminal_id.nil? && @terminal_id !~ Regexp.new(/^[0-9]+$/)\n return false if !@registration_id.nil? && @registration_id.to_s.length > 50\n return false if !@registration_id.nil? && @registration_id !~ Regexp.new(/(?=.*[^\\s])^[^|]+$/)\n release_type_validator = EnumAttributeValidator.new('String', [\"C\", \"D\", \"P\", \"T\"])\n return false unless release_type_validator.valid?(@release_type)\n vip_customer_validator = EnumAttributeValidator.new('String', [\"Y\", \"N\"])\n return false unless vip_customer_validator.valid?(@vip_customer)\n return false if @session_id.nil?\n return false if @session_id.to_s.length > 128\n return false if @session_id !~ Regexp.new(/(?=.*[^\\s])^[^|]+$/)\n return false if !@terminal_state.nil? && @terminal_state.to_s.length > 2\n return false if !@terminal_state.nil? && @terminal_state !~ Regexp.new(/^[A-Z]{2}$/)\n return false if !@terminal_city.nil? && @terminal_city.to_s.length > 16\n return false if !@terminal_city.nil? && @terminal_city !~ Regexp.new(/(?=.*[^\\s])^[^|]+$/)\n true\n end", "def valid?\n return false if @name.nil?\n return false if @name.to_s.length > 50\n return false if @prefix_suffix_option.nil?\n prefix_suffix_option_validator = EnumAttributeValidator.new('String', [\"Prefix\", \"Suffix\"])\n return false unless prefix_suffix_option_validator.valid?(@prefix_suffix_option)\n return false if !@invoice_pre_suffix.nil? && @invoice_pre_suffix.to_s.length > 5\n application_units_validator = EnumAttributeValidator.new('String', [\"Amount\", \"Hours\", \"Incidents\"])\n return false unless application_units_validator.valid?(@application_units)\n application_cycle_validator = EnumAttributeValidator.new('String', [\"Contract2Weeks\", \"Contract4Weeks\", \"ContractYear\", \"CalendarMonth\", \"CalendarQuarter\", \"CalendarWeek\", \"ContractQuarter\", \"CalendarYear\"])\n return false unless application_cycle_validator.valid?(@application_cycle)\n return false if @employee_comp_rate.nil?\n employee_comp_rate_validator = EnumAttributeValidator.new('String', [\"Actual\", \"Hourly\"])\n return false unless employee_comp_rate_validator.valid?(@employee_comp_rate)\n return false if @employee_comp_not_exceed.nil?\n employee_comp_not_exceed_validator = EnumAttributeValidator.new('String', [\"Billing\", \"Percent\", \"Amount\"])\n return false unless employee_comp_not_exceed_validator.valid?(@employee_comp_not_exceed)\n return false if @invoicing_cycle.nil?\n invoicing_cycle_validator = EnumAttributeValidator.new('String', [\"CalendarYear\", \"ContractYear\"])\n return false unless invoicing_cycle_validator.valid?(@invoicing_cycle)\n return false if !@invoice_description.nil? && @invoice_description.to_s.length > 4000\n return false if @bill_time.nil?\n bill_time_validator = EnumAttributeValidator.new('String', [\"Billable\", \"DoNotBill\", \"NoCharge\", \"NoDefault\"])\n return false unless bill_time_validator.valid?(@bill_time)\n return false if @bill_expenses.nil?\n bill_expenses_validator = EnumAttributeValidator.new('String', [\"Billable\", \"DoNotBill\", \"NoCharge\", \"NoDefault\"])\n return false unless bill_expenses_validator.valid?(@bill_expenses)\n return false if @bill_products.nil?\n bill_products_validator = EnumAttributeValidator.new('String', [\"Billable\", \"DoNotBill\", \"NoCharge\", \"NoDefault\"])\n return false unless bill_products_validator.valid?(@bill_products)\n return true\n end", "def validate\n validate_amount\n validate_game\n validate_period\n end", "def validate\n\tvalidate_unexpected_assets_not_present && validate_expected_asset_present && validate_snippet_and_description\nend", "def validate\n errors.add_to_base(\"Your Volume is to long, can only store 4 characters!\") if self.volume.to_s.length > 4\n errors.add_to_base(\"Your Number is to long, can only store 3 characters!\")if self.number.to_s.length > 3\n errors.add_to_base(\"Your Semester is to long, can only store 6 characters!\")if self.semester.to_s.length > 6\n end", "def valid?\n end", "def valid?\n end", "def valid?\n end", "def valid?\n end", "def validations\n {}\n end", "def is_valid\n\tend", "def is_valid\n\tend", "def valid?(thing); end", "def valid?(thing); end", "def test_invalid_with_empty_rule_name_or_state_or_logic\n owner = people(:valid_person)\n rule = Rule.new(:person_id => owner.id)\n assert !rule.valid?\n # The rule_name field should have validation errors\n assert rule.errors[:rule_name].any?\n # The state field should have validation errors\n assert rule.errors[:state].any?\n # The logic field should have validation errors\n assert rule.errors[:logic].any?\n end", "def validate\n end", "def validate\n end", "def validate\n end", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def validate_essential_attributes #:nodoc:\n if @month.to_i.zero? || @year.to_i.zero?\n errors.add :month, \"is required\" if @month.to_i.zero?\n errors.add :year, \"is required\" if @year.to_i.zero?\n else\n errors.add :month, \"is not a valid month\" unless valid_month?(@month)\n errors.add 'card', \"has expired\" if expired?\n errors.add :year, \"is not a valid year\" unless valid_expiry_year?(@year)\n end\n end", "def is_valid\n return true\n end", "def valid?\n @errors = []\n # check thename exists and is not empty\n if name.to_s.empty?\n @errors << {message: \"Name cannot be empty.\", variable: \"name\"}\n end\n \n # check the description exists and is not empty\n if description.to_s.empty?\n @errors << {message: \"Description cannot be empty.\", variable: \"description\"}\n end\n \n # check the description exists and is not empty\n # if studio_id.to_s.empty?\n # @errors << {message: \"Studio id cannot be empty.\", variable: \"studio_id\"}\n # elsif studio.blank?\n # @errors << {message: \"Studio id must be a member of the studios table.\", variable: \"studio_id\"}\n # end \n \n if !studio_id.valid?\n @errors += studio_id.errors\n end\n \n # check the description exists and is not empty\n # if rating_id.to_s.empty?\n # @errors << {message: \"Rating id cannot be empty.\", variable: \"rating_id\"}\n # elsif rating.blank?\n # @errors << {message: \"Rating id must be a member of the ratings table.\", variable: \"rating_id\"}\n # end\n \n if !rating_id.valid?\n @errors += rating_id.errors\n end\n # checks the number of time slots\n if length.to_s.empty?\n @errors << {message: \"Length cannot be empty.\", variable: \"length\"}\n elsif length.is_a? Integer\n if length < 1\n @errors << {message: \"Length must be greater than 0.\", variable: \"length\"}\n end\n else\n @errors << {message: \"Length must be a number.\", variable: \"length\"}\n end\n \n # returns whether @errors is empty\n @errors.empty?\n end", "def validate(options); end", "def validate\n validates_presence([:name, :phone])\n end", "def validate\n validate_resources_defined\n validates_unique(:resource_id, :message => \"ARK must point to a unique Resource\")\n validates_unique(:archival_object_id, :message => \"ARK must point to a unique Archival Object\")\n super\n end", "def validate\n valid?\n end", "def valid?()\n if( requiredFieldsPresent? )\n # check each condition, saving off error if one exists (ugh...)\n @errors << \"byr is not valid #{@args[\"byr\"]}\" if !byrValid?(@args[\"byr\"])\n @errors << \"iyr is not valid #{@args[\"iyr\"]}\" if !iyrValid?(@args[\"iyr\"])\n @errors << \"eyr is not valid #{@args[\"eyr\"]}\" if !eyrValid?(@args[\"eyr\"])\n @errors << \"hgt is not valid #{@args[\"hgt\"]}\" if !hgtValid?(@args[\"hgt\"])\n @errors << \"hcl is not valid #{@args[\"hcl\"]}\" if !hclValid?(@args[\"hcl\"])\n @errors << \"ecl is not valid #{@args[\"ecl\"]}\" if !eclValid?(@args[\"ecl\"])\n @errors << \"pid is not valid #{@args[\"pid\"]}\" if !pidValid?(@args[\"pid\"])\n end\n @errors.empty?\n end", "def validate\n validate_params\n validate_colour\n validate_coordinates\n validate_dimension\n end", "def validate(obj, type); end", "def literal_validation; end", "def literal_validation; end", "def validate_question params\n\n end", "def assert_valid\n raise ValidationError, \"no name\" unless name\n raise ValidationError, \"no version\" unless version\n raise ValidationError, \"no summary\" unless summary\n #raise ValidationError, \"no maintainer\" unless maintainer\n #raise ValidationError, \"no homepage\" unless homepage\n end", "def valid?\n type_validator = EnumAttributeValidator.new('String', [\"person\", \"business\"])\n return false unless type_validator.valid?(@type)\n return false if @country.nil?\n return false if @street.nil?\n return false if @postal_code.nil?\n return false if @city.nil?\n return false if @email.nil?\n return false if @ip.nil?\n identification_type_validator = EnumAttributeValidator.new('String', [\"DL\", \"PP\", \"ID\", \"OT\"])\n return false unless identification_type_validator.valid?(@identification_type)\n legal_entity_type_validator = EnumAttributeValidator.new('String', [\"sole_proprietorship\", \"partnership\", \"privately_owned_company\", \"publicly_owned_company\", \"government_owned_entity\", \"trust\", \"ngo\", \"club_and_society\", \"go\", \"other\", \"financial_institution\", \"mto\"])\n return false unless legal_entity_type_validator.valid?(@legal_entity_type)\n nature_of_business_validator = EnumAttributeValidator.new('String', [\"personal\", \"agriculture_and_hunting\", \"forestry\", \"fishing\", \"agricultural_by_products\", \"coal_mining\", \"oil_mining\", \"iron_ore_mining\", \"other_metal_and_diamond_mining\", \"other_mineral_mining\", \"manufacturing_of_food_drink_tobacco\", \"manufacturing_of_textiles_leather_fur_furniture\", \"manufacture_of_wooden_products_furniture\", \"manufacture_of_paper_pulp_allied_products\", \"manufacture_of_chemicals_medical_petroleum_rubber_plastic_products\", \"manufacture_of_pottery_china_glass_stone\", \"manufacture_of_iron_steel_non_ferrous_metals_basic_industries\", \"manufacture_of_metal_products_electrical_and_scientific_engineering\", \"manufacture_of_jewelry_musical_instruments_toys\", \"electricity_gas_and_water\", \"construction\", \"wholesale_trade\", \"retail_trade\", \"catering_incl_hotels\", \"transport_storage\", \"communications\", \"finance_and_holding_companies\", \"insurance\", \"business_services\", \"real_estate_development_investment\", \"central_state_governments\", \"community_services_defence_police_prisons_etc\", \"social_services_education_health_care\", \"personal_services_leisure_services\", \"personal_services_domestic_laundry_repairs\", \"personal_services_embassies_international_organisations\"])\n return false unless nature_of_business_validator.valid?(@nature_of_business)\n return false if @documents.nil?\n gender_validator = EnumAttributeValidator.new('String', [\"M\", \"F\", \"O\"])\n return false unless gender_validator.valid?(@gender)\n true\n end", "def validate\n validate_required_attributes\n Position.validate_order_type_constraints attributes\n validate_trailing_stop_constraints\n validate_stop_and_limit_constraints\n validate_guaranteed_stop_constraints\n end", "def validate\n validate_params\n validate_coordinates\n validate_colour\n validate_dimension\n end", "def validate\r\n @invalid=false\r\n end", "def validate!\n if identifier.to_s.empty?\n raise ValidationError.new(\"identifier is required\")\n else\n [image_changes.created,\n image_changes.updated,\n unit_changes.created,\n unit_changes.updated].each do |collection|\n collection.each(&:validate!)\n end\n\n true\n end\n end", "def valid?\n reset_errors\n valid_date?\n valid_user?\n valid_activity_type?\n self.errors.empty?\n end", "def valid?\n type_validator = EnumAttributeValidator.new('String', ['string', 'number', 'boolean', 'date', 'address', 'country', 'email', 'url', 'image', 'signature', 'barcode', 'combined'])\n return false unless type_validator.valid?(@type)\n image_gravity_validator = EnumAttributeValidator.new('String', ['NorthWest', 'North', 'NorthEast', 'West', 'Center', 'East', 'SouthWest', 'South', 'SouthEast'])\n return false unless image_gravity_validator.valid?(@image_gravity)\n overflow_validator = EnumAttributeValidator.new('String', ['shrink_to_fit', 'truncate'])\n return false unless overflow_validator.valid?(@overflow)\n return false if [email protected]? && @id < 0\n image_scale_type_validator = EnumAttributeValidator.new('String', ['fit', 'fill', 'stretch'])\n return false unless image_scale_type_validator.valid?(@image_scale_type)\n return false if [email protected]? && @height < 0\n v_alignment_validator = EnumAttributeValidator.new('String', ['bottom', 'center', 'top'])\n return false unless v_alignment_validator.valid?(@v_alignment)\n return false if !@shape_border_width.nil? && @shape_border_width < 0\n return false if !@comb_number_of_cells.nil? && @comb_number_of_cells < 0\n shape_type_validator = EnumAttributeValidator.new('String', ['square', 'rectangle', 'circle', 'ellipse'])\n return false unless shape_type_validator.valid?(@shape_type)\n display_type_validator = EnumAttributeValidator.new('String', ['text', 'check', 'qrcode', 'barcode', 'image', 'shape'])\n return false unless display_type_validator.valid?(@display_type)\n return false if !@multiline_lines.nil? && @multiline_lines < 0\n return false if !@font_size.nil? && @font_size < 0\n return false if [email protected]? && @page < 1\n alignment_validator = EnumAttributeValidator.new('String', ['left', 'center', 'right'])\n return false unless alignment_validator.valid?(@alignment)\n check_character_validator = EnumAttributeValidator.new('String', ['&#10003;', '&#10004;', '&#10006;', '&#10007;', '&#10008;'])\n return false unless check_character_validator.valid?(@check_character)\n return false if [email protected]? && @rotation > 3.6E+2\n return false if [email protected]? && @rotation < 0\n string_condition_type_validator = EnumAttributeValidator.new('String', ['equals', 'contains', 'starts_with', 'ends_with', 'regex'])\n return false unless string_condition_type_validator.valid?(@string_condition_type)\n return false if !@decimal_places.nil? && @decimal_places < 0\n return false if [email protected]? && @width < 0\n return false if [email protected]? && @x < 0\n return false if [email protected]? && @y < 0\n number_condition_type_validator = EnumAttributeValidator.new('String', ['equals', 'range', 'gte', 'gt', 'lte', 'lt'])\n return false unless number_condition_type_validator.valid?(@number_condition_type)\n return false if [email protected]? && @opacity > 1\n return false if [email protected]? && @opacity < 0\n true\n end", "def validate\n is_valid = true\n\n if is_valid\n is_valid = ModelHelper::Validations.validate_combos([{:order_type_id => self.order_type_id}], self)\n end\n if is_valid\n is_valid = ModelHelper::Validations.validate_combos([{:trading_partner_party_role_id => self.trading_partner_party_role_id}], self)\n end\n\n if is_valid\n is_valid = ModelHelper::Validations.validate_combos([{:customer_party_role_id => self.customer_party_role_id}], self)\n end\n end", "def validate params\n validate_params(params)\n validate_coordinates\n validate_color\n validate_dimension\n end", "def validate!\n true\n end", "def valid_params?; end", "def validate\n super \n end", "def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:short_description => self.short_description}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_organization\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:target_market_name => self.target_market_name}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_target_market\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n allowed_values = [\"CENTRALIZADO\", \"PV\"]\n if @tipo_pagamento && !allowed_values.include?(@tipo_pagamento)\n return false\n end\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def validate_attributes!\n raise TrainNumberValidationError unless valid_number?\n raise TrainTypeValidationError if type.nil? || type.empty?\n end", "def validate\n super\n errors.add(:name, \"can't be empty\") if name.blank?\n errors.add(:category_id, \"can't be empty\") if category_id.blank?\n errors.add(:price, \"can't be empty\") if price.blank?\n end", "def validate\n fail 'sub class to implement'\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:short_description => self.short_description}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_organization\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:rule_code => self.rule_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_rule\n\t end\nend", "def valid?\n return false if @id.nil?\n return false if @id !~ Regexp.new(/^psc_[a-zA-Z0-9]+$/)\n carrier_validator = EnumAttributeValidator.new('String', [\"USPS\"])\n return false unless carrier_validator.valid?(@carrier)\n return false if !@front_template_id.nil? && @front_template_id !~ Regexp.new(/^tmpl_[a-zA-Z0-9]+$/)\n return false if !@back_template_id.nil? && @back_template_id !~ Regexp.new(/^tmpl_[a-zA-Z0-9]+$/)\n return false if !@front_template_version_id.nil? && @front_template_version_id !~ Regexp.new(/^vrsn_[a-zA-Z0-9]+$/)\n return false if !@back_template_version_id.nil? && @back_template_version_id !~ Regexp.new(/^vrsn_[a-zA-Z0-9]+$/)\n object_validator = EnumAttributeValidator.new('String', [\"postcard\"])\n return false unless object_validator.valid?(@object)\n return false if @url.nil?\n return false if @url !~ Regexp.new(/^https:\\/\\/(lob-assets|lob-assets-staging)\\.com\\/(letters|postcards|bank-accounts|checks|self-mailers|cards)\\/[a-z]{3,4}_[a-z0-9]{15,16}(\\.pdf|_thumb_[a-z]+_[0-9]+\\.png)\\?(version=[a-z0-9-]*&)?expires=[0-9]{10}&signature=[a-zA-Z0-9_-]+$/)\n return false if [email protected]? && @description.to_s.length > 255\n true\n end" ]
[ "0.7434267", "0.7434267", "0.7371285", "0.7352238", "0.7347254", "0.7347254", "0.731587", "0.731587", "0.731587", "0.731587", "0.73144066", "0.7277695", "0.7239673", "0.72192556", "0.7208198", "0.71626127", "0.71588725", "0.71588725", "0.712312", "0.7085555", "0.7085555", "0.7085555", "0.7053672", "0.7053672", "0.7053672", "0.7053672", "0.7053672", "0.70528466", "0.7051958", "0.7034363", "0.7021068", "0.7010751", "0.7010644", "0.7008562", "0.7005532", "0.70004904", "0.6997927", "0.6976651", "0.6968454", "0.696755", "0.69641936", "0.69444954", "0.6929156", "0.6929156", "0.6929156", "0.6923405", "0.69167113", "0.68783706", "0.68727577", "0.68624926", "0.6862147", "0.6861054", "0.6858053", "0.6858053", "0.6858053", "0.6858053", "0.68567616", "0.68250686", "0.68250686", "0.68067944", "0.68067944", "0.6799009", "0.67615235", "0.67615235", "0.67615235", "0.6755844", "0.6738066", "0.6716031", "0.671456", "0.66995716", "0.66934884", "0.66914517", "0.66797906", "0.6678568", "0.666248", "0.6653019", "0.66517", "0.66517", "0.6645826", "0.66313076", "0.66185546", "0.6617439", "0.66152215", "0.66106075", "0.6602931", "0.6600871", "0.6595776", "0.6591505", "0.6590203", "0.65864766", "0.65734893", "0.65731525", "0.65701157", "0.6569604", "0.65684533", "0.6564793", "0.65642446", "0.6563602", "0.6563602", "0.65619564", "0.65591383" ]
0.0
-1
=========================== foreign key validations: ===========================
def set_concentrate_product concentrate_product = ConcentrateProduct.find_by_concentrate_code(self.concentrate_code) if concentrate_product != nil self.concentrate_product = concentrate_product return true else errors.add_to_base("value of field: 'concentrate_code' is invalid- it must be unique") return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_all_foreign_keys_valid!\n end", "def check_foreign_key(field)\n val = self.send(field)\n if val.is_a? ForeignKey\n add_foreign_key_message_to_errors(val)\n end\n end", "def check_add_foreign_key(*args); end", "def foreign_key_present?\n false\n end", "def foreign_key_present?\n false\n end", "def test_add_invalid_foreign_key\n @connection.add_foreign_key :astronauts, :rockets, column: \"rocket_id\", validate: false\n\n foreign_keys = @connection.foreign_keys(\"astronauts\")\n assert_equal 1, foreign_keys.size\n\n fk = foreign_keys.first\n assert_predicate fk, :validated?\n end", "def foreign_key?\n true\n end", "def all_foreign_keys_valid?\n check_all_foreign_keys_valid!\n true\n rescue ActiveRecord::StatementInvalid\n false\n end", "def supports_deferrable_foreign_key_constraints?\n true\n end", "def supports_deferrable_foreign_key_constraints?\n true\n end", "def validate_foreign_key\n # If there is a parent_id given\n unless self.read_attribute(parent_id_column).nil?\n # Parent_id must be a valid category ID\n self.write_attribute(parent_id_column, 0) if self.read_attribute(parent_id_column) > 0 && !self.class.find(self.read_attribute(parent_id_column))\n # Parent must not be itself\n self.write_attribute(parent_id_column, 0) if self.read_attribute(parent_id_column) > 0 && self.id == self.read_attribute(parent_id_column) unless self.id.blank?\n # Parent must not be a descendant of itself\n self.write_attribute(parent_id_column, 0) if self.read_attribute(parent_id_column) > 0 && self.descendants_ids(true).include?(self.read_attribute(parent_id_column))\n end\n rescue ActiveRecord::RecordNotFound\n self.write_attribute(parent_id_column, 0) # Parent was not found\n end", "def stores_foreign_key?; false; end", "def stores_foreign_key?; false; end", "def foreign_key?\n false\n end", "def check_add_foreign_key(*args)\n options = args.extract_options!\n from_table, to_table = args\n\n validate = options.fetch(:validate, true)\n if postgresql? && validate\n if StrongMigrations.safe_by_default\n safe_add_foreign_key(*args, **options)\n throw :safe\n end\n\n raise_error :add_foreign_key,\n add_foreign_key_code: command_str(\"add_foreign_key\", [from_table, to_table, options.merge(validate: false)]),\n validate_foreign_key_code: command_str(\"validate_foreign_key\", [from_table, to_table])\n end\n end", "def stores_foreign_key?; true; end", "def supports_foreign_keys?\n false\n end", "def supports_foreign_keys?\n false\n end", "def supports_foreign_keys_in_create?\n supports_foreign_keys?\n end", "def stores_foreign_key?\n false\n end", "def supports_deferrable_foreign_key_constraints?\n supports_deferrable_constraints?\n end", "def validates_presence_of_parent(foreign_key)\n after_save do |record|\n unless record.send(foreign_key)\n record.errors.add_on_blank(foreign_key)\n raise ActiveRecord::ActiveRecordError, record.errors.full_messages.to_sentence\n end\n end\n end", "def validate(record)\n if record._database_validations_fallback\n super\n else\n return unless record.public_send(foreign_key).blank? && record.public_send(association).blank?\n\n record.errors.add(association, :blank, message: :required)\n end\n end", "def foreign_key_for?(record)\n foreign_key = Array(reflection.foreign_key)\n foreign_key.all? { |key| record._has_attribute?(key) }\n end", "def foreign_key?\n @ref_table ? true : false\n end", "def foreign_key?\n options.fetch(:foreign_key, false)\n end", "def test_foreign_key_violations_on_insert_are_translated_to_specific_exception\n error = assert_raises(ActiveRecord::InvalidForeignKey) do\n insert_into_fk_test_has_fk\n end\n\n assert_not_nil error.cause\n end", "def foreign_key_check\n @foreign_key_check ||= \"#{foreign_key}_previously_changed?\" if (stores_foreign_key? && foreign_key)\n end", "def test_foreign_key_violations_on_delete_are_translated_to_specific_exception\n insert_into_fk_test_has_fk fk_id: 1\n\n error = assert_raises(ActiveRecord::InvalidForeignKey) do\n @connection.execute \"DELETE FROM fk_test_has_pk WHERE pk_id = 1\"\n end\n\n assert_not_nil error.cause\n end", "def validate\n is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:system_name => self.system_name}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_system\n\t end\n \n end", "def foreign_key_constraints_enabled?\n @disable_foreign_key_constraints != true\n end", "def foreign_keys\n @foreign_keys ||= connection.foreign_keys(table_name, \"#{name} Foreign Keys\")\n end", "def foreign_key(relation)\n detect { |attr| attr.foreign_key? && attr.target == relation }\n end", "def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_rails_error\n\t end\nend", "def is_foreign_key?\n association.present?\n end", "def test_emailers_restrict_delete\n\t\terr = assert_raises PG::ForeignKeyViolation do\n\t\t\tDB.exec(\"DELETE FROM people WHERE id=7\")\n\t\tend\n\t\tassert err.message.include? 'emailers_person_id_fkey'\n\tend", "def supports_foreign_key_parsing?\n respond_to?(:foreign_key_list)\n end", "def foreign_key_params\n params.require(:foreign_key).permit(:source_column, :source_table, :target_column, :target_table)\n end", "def foreign_key?\n index == entity.key_column && !entity.is_core\n end", "def assert_referential_integrity(hash)\n inventory_collection.fixed_foreign_keys.each do |x|\n next unless hash[x].nil?\n subject = \"#{hash} of #{inventory_collection} because of missing foreign key #{x} for \"\\\n \"#{inventory_collection.parent.class.name}:\"\\\n \"#{inventory_collection.parent.try(:id)}\"\n unless inventory_collection.assert_graph_integrity\n logger.warn(\"Referential integrity check violated, ignoring #{subject}\")\n return false\n else\n raise(\"Referential integrity check violated for #{subject}\")\n end\n end\n true\n end", "def validate_relation(klass, name, options = {})\n [name, \"#{name}?\".to_sym, \"#{name}=\".to_sym].each do |n|\n if Mongoid.destructive_fields.include?(n)\n raise Errors::InvalidRelation.new(klass, n)\n end\n end\n end", "def foreign_key\n meta(foreign_key: true)\n end", "def assert_referential_integrity(hash)\n inventory_collection.fixed_foreign_keys.each do |x|\n next unless hash[x].nil?\n\n subject = \"#{hash} of #{inventory_collection} because of missing foreign key #{x} for \"\\\n \"#{inventory_collection.parent.class.name}:\"\\\n \"#{inventory_collection.parent.try(:id)}\"\n if inventory_collection.assert_graph_integrity\n raise(\"Referential integrity check violated for #{subject}\")\n else\n logger.warn(\"Referential integrity check violated, ignoring #{subject}\")\n return false\n end\n end\n true\n end", "def validate_associations\n errors.add(:user_id, :doesnt_exist) if @user.nil?\n errors.add(:lesson_id, :doesnt_exist) if @lesson.nil?\n end", "def validate(record)\n if record._database_validations_fallback\n super\n else\n attributes.each do |attribute|\n reflection = record.class._reflect_on_association(attribute)\n\n next if reflection && record.public_send(reflection.foreign_key).present?\n\n validate_each(record, attribute, record.public_send(attribute))\n end\n end\n end", "def validates_associated_post_records; end", "def validates_associated_post_records; end", "def foreign_key_column_exists?\n !! model_class.columns.detect { |c| c.name.strip.downcase == foreign_key_column_name.strip.downcase }\n end", "def foreign_key_list(table, opts=OPTS)\n super\n rescue Sequel::DatabaseError => e\n raise unless foreign_key_error?(e)\n []\n end", "def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:mark_code => self.mark_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_mark\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:short_description => self.short_description}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_organization\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend", "def supports_foreign_tables?\n false\n end", "def supports_foreign_tables?\n false\n end", "def validate_associations\n errors.add(:user_id, :doesnt_exist) if @user.nil?\n end", "def validate_associations\n errors.add(:user_id, :doesnt_exist) if @user.nil?\n end", "def validate_associations\n errors.add(:user_id, :doesnt_exist) if @user.nil?\n end", "def validate_associations\n errors.add(:user_id, :doesnt_exist) if @user.nil?\n end", "def set_foreign_key\n @foreign_key = ForeignKey.find(params[:id])\n end", "def validate_relation_references(primary_ir)\n primary_ir.keys.each do |k|\n if primary_ir[k][:source_dsd_name]\n unless primary_ir[k][:source_structure][:dsd] == primary_ir[k][:source_dsd_name]\n raise \"#{primary_ir[k][:full_source_relation_name]} is not an implementation of #{primary_ir[k][:source_dsd_name]} as required by #{primary_ir[k][:full_relation_name]}... which is an implementation of #{primary_ir[k][:dsd]}\"\n end\n end\n end\n nil\n end", "def conventional_foreign_key?\n parent_table == naming_conventions.parent_table_for(foreign_key)\n end", "def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:artist_name => self.artist_name}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_artist\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend", "def validate_associations\n errors.add(:lesson_id, :doesnt_exist) if @lesson.nil?\n end", "def validate_table_and_pk\n if entity_type.nil?\n entity_type_pk=nil\n return\n end\n\n if entity_type_pk.nil?\n entity_type=nil\n return\n end\n\n unless entity_type_enum.include? entity_type.to_s\n errors.add :entity_type, :invalid\n return\n end\n unless entity_type_pk_enum.include? entity_type_pk.to_s\n errors.add :entity_type_pk, :invalid\n return\n end\n end", "def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:treatment_type_code => self.treatment_type_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_treatment_type\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend", "def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:short_description => self.short_description}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_organization\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:target_market_name => self.target_market_name}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_target_market\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend", "def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:short_description => self.short_description}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_organization\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:rule_code => self.rule_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_rule\n\t end\nend", "def record_foreign_keys(parent_record)\n association_foreign_keys(parent_record)\n end", "def foreign_key\n @foreign_key ||= @options[:foreign_key] ? @options[:foreign_key].to_s :\n default_foreign_key_field\n end", "def test_adding_bears_to_the_farm_with_t_dot_foreign_key_farm_dependent_nullify\n premigrate\n table = \"bears\"\n migrate table\n assert_match(/FOREIGN KEY \\(\\\"farm_id\\\"\\) REFERENCES \\\"farms\\\"\\(id\\) ON DELETE SET NULL/, schema(table))\n end", "def foreign_key_for assoc_name\n raise NotImplementedError\n end", "def foreign_key_for assoc_name\n raise NotImplementedError\n end", "def integer_exception?(field)\n foreign_key?(field) || self.send(field).blank?\n end", "def foreign_key\n association.foreign_key \n end", "def belongs_to?; false; end", "def validate_associations\n errors.add(:group_id, :doesnt_exist) if @group.nil?\n end", "def valid?\n @valid ||= begin \n relation.exists?\n true # set valid to true, if relation.exists?(model) does not throw any exception\n rescue\n false\n end\n end", "def validate\n validate_string_attributes\n @relations.map(&:validate)\n end", "def foreign_key\n @foreign_key ||= (@options[:foreign_key] || \"#{@name}_id\").to_s\n end", "def add_foreign_key_message_to_errors(val)\n if !val.valid?\n @errors += val.errors\n end\n end", "def foreign_key\n self.name + \"_id\"\n end", "def test_adding_pigs_to_the_farm_with_t_dot_references_farm_foreign_key_true\n premigrate\n table = \"pigs\"\n migrate table\n assert_match(/FOREIGN KEY \\(\\\"farm_id\\\"\\) REFERENCES \\\"farms\\\"\\(id\\)/, schema(table))\n end", "def includes_foreign_key?( key, list = nil )\n list ||= foreign_keys( key.from_table )\n list.any?{|fk| matching_foreign_keys( key, fk) }\n end", "def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:puc_type_code => self.puc_type_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_puc_type\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend", "def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:postal_address_type_code => self.postal_address_type_code},{:city => self.city},{:address1 => self.address1}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_postal_address\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:party_type_name => self.party_type_name},{:party_name => self.party_name}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_party\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend", "def belongs_to_with_foreign_key_migrations(*args)\n options = args.extract_options!\n options[:references] = nil if options[:polymorphic]\n belongs_to_without_foreign_key_migrations(*args.push(options))\n end", "def belongs_to_with_foreign_key_migrations(*args)\n options = args.extract_options!\n options[:references] = nil if options[:polymorphic]\n belongs_to_without_foreign_key_migrations(*args.push(options))\n end", "def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:commodity_code => self.commodity_code}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_commodity\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend", "def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:farm_group_code => self.farm_group_code},{:id => self.id}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_farm_group\n\t end\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:party_type_name => self.party_type_name},{:party_name => self.party_name},{:role_name => self.role_name},{:id => self.id}],self) \n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_parties_role\n\t end\n\t#validates uniqueness for this record\n\t if self.new_record? && is_valid\n\t\t validate_uniqueness\n\t end\nend", "def validate_on_create\n errors.add(:circle, \"Invalid relationship\") unless @circle && @circle.valid?\n errors.add(:host, \"Could not determine the guest host\") unless self.current_host_id\n end", "def quote_constraint_name(foreign_key)\n quote_table_name(foreign_key)\n end", "def test_adding_elephants_to_the_farm_with_t_dot_foreign_key_farm_dependent_delete\n premigrate\n table = \"elephants\"\n migrate table\n assert_match(/FOREIGN KEY \\(\\\"farm_id\\\"\\) REFERENCES \\\"farms\\\"\\(id\\) ON DELETE CASCADE/, schema(table))\n end", "def validate_relationship_hash(rel_hash)\n validation = { id: 'string', type: 'string' }\n validator = HashValidator.validate(rel_hash, validation)\n check_validation_errors(validator)\n end", "def foreign_key(*args)\n # get the name\n name = String===args[0] ? args.shift : \"fk_#{@relvar.name}_#{@relvar.foreign_keys.size}\"\n \n # get the attribute => key mapping\n raise \"Invalid foreign key definition #{args.inspect}\" unless \\\n args.size==1 and Hash===args[0] and \\\n args[0].size == 1\n mapping = args[0]\n \n # get the attributes now\n attributes = args[0].keys.flatten.collect{|a| @relvar.attribute(a, true)}\n \n # get the target now\n target = mapping.values[0]\n target = target.primary_key if Relvar === target\n raise \"Invalid foreign key #{name} for #{@relvar.name} (#{target.inspect})\" unless Key===target\n\n @relvar.add_foreign_key(name, attributes, target)\n end", "def foreign_key(separate_class_name_and_id_with_underscore = true)\n # TODO\n # Inflector.foreign_key(self, separate_class_name_and_id_with_underscore)\n end", "def remove_table_not_exist_foreign_keys\n @foreign_keys.each do |table, foreign_keys|\n foreign_keys.delete_if do |key|\n if key.is_a?(String) && key =~ /_id$/\n class_name = Prepares.model_associations.get_association_class_name(table, key[0..-4])\n class_name ? !@table_nodes[class_name.gsub('::', '').tableize] : !@table_nodes[key[0..-4].pluralize]\n end\n end\n end\n end", "def create\n @foreign_key = ForeignKey.new(foreign_key_params)\n @table = Table.find(@foreign_key.source_table)\n\n respond_to do |format|\n if @foreign_key.save\n format.html { redirect_to @table, notice: 'Foreign key was successfully created.' }\n format.json { render :show, status: :created, location: @table }\n else\n format.html { render :new }\n format.json { render json: @foreign_key.errors, status: :unprocessable_entity }\n end\n end\n end", "def validate_entity_association\n ids = [self.unit_id, self.collection_id, self.item_id].reject(&:nil?).length\n if ids > 1\n errors.add(:base, \"Instance can be associated with only one entity\")\n elsif ids == 0\n errors.add(:base, \"Instance must be associated with an entity\")\n end\n end", "def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:vessel_code => self.vessel_code}],self)\n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = set_vessel\n\t end\nend", "def reflection_to_foreign_keys!( reflection, foreign_key_list )\n reflection_to_foreign_keys( reflection ).each do |foreign_key|\n #skip if already in this list or the fk has already been uped in the db\n next if includes_foreign_key?( foreign_key, foreign_key_list ) ||\n existing_foreign_key?( foreign_key )\n foreign_key_list << foreign_key\n end\n end", "def implementation_no_master_association\n defined?(foreign_key_name) && foreign_key_name.blank?\n end", "def validate\n validate_resources_defined\n validates_unique(:resource_id, :message => \"ARK must point to a unique Resource\")\n validates_unique(:archival_object_id, :message => \"ARK must point to a unique Archival Object\")\n super\n end", "def check_associated\n if self.quote_id.present?\n errors.add(:quote_id, \"must belong to the same project\") if self.project_id != self.parent_quote.project_id\n end\n \n if self.user_id.present?\n errors.add(:user_id, \"must belong to the same account\") if self.project.account_id != self.user.account_id\n end\n \n if self.last_saved_by_id.present?\n errors.add(:last_saved_by_id, \"must belong to the same account\") if self.project.account_id != self.last_saved_by.account_id\n end\n end" ]
[ "0.7600098", "0.7280537", "0.72237355", "0.72103435", "0.72103435", "0.71699786", "0.70691454", "0.70154715", "0.6979766", "0.69792753", "0.6944212", "0.6933209", "0.6933209", "0.6887509", "0.6855989", "0.68030375", "0.6676975", "0.6676975", "0.66574645", "0.65902704", "0.6572146", "0.6454733", "0.6420942", "0.6354803", "0.6316829", "0.63063335", "0.6271883", "0.62572855", "0.6234509", "0.6206236", "0.6190251", "0.61890155", "0.6152809", "0.614713", "0.61411494", "0.6095906", "0.60748637", "0.6056707", "0.60488045", "0.60462004", "0.60293114", "0.60259277", "0.60240096", "0.60010266", "0.59927523", "0.59788233", "0.59788233", "0.5978287", "0.5924967", "0.5900873", "0.5869975", "0.5869975", "0.5864072", "0.5864072", "0.5864072", "0.5864072", "0.58357644", "0.57912695", "0.5773925", "0.5769168", "0.5742872", "0.56988484", "0.5689956", "0.56865835", "0.5686106", "0.56822646", "0.56776947", "0.56772244", "0.5636961", "0.5636961", "0.56268686", "0.5609533", "0.56017864", "0.5592872", "0.55915606", "0.55756724", "0.55753934", "0.55717534", "0.55653924", "0.55650896", "0.55473506", "0.5539885", "0.552133", "0.5515123", "0.5515123", "0.55148524", "0.54974824", "0.5495172", "0.5492293", "0.5485133", "0.54825836", "0.54521567", "0.54494554", "0.54460156", "0.54394406", "0.5430043", "0.5423758", "0.54224", "0.5419561", "0.5417893", "0.5413222" ]
0.0
-1
POST /batches/phs POST /batches/phs.xml
def update @batch = Batch.find(params[:id]) @batch.phing = true if @batch.update(batch_params) flash[:notice] = 'Batch was successfully updated.' redirect_to(no_experiment_batches_phs_path) else render :action => "edit" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def batch_xml(xml) \r\n xml.batch(:ID => 1) do\r\n xml.tag!(:bat_date, date)\r\n xml.tag!(:bat_id, batchid)\r\n xml.tag!(:site_num, facility.sitecode.rjust(5, '0'))\r\n xml.tag!(:bat_time, (batch_time.strftime(\"%H:%M:%S\") unless batch_time.blank?))\r\n xml.tag!(:chk_vol, (correspondence == true) ? 0 : checks.count)\r\n xml.tag!(:eob_vol, eobs.count)\r\n xml.tag!(:img_vol, images_count)\r\n xml.tag!(:total_pay_amt, sprintf('%.02f', total_payment.to_f))\r\n xml.tag!(:lockbox, lockbox)\r\n xml.tag!(:bank_bat_id, index_batch_number)\r\n xml.tag!(:bat_type, (correspondence == true) ? 'C' : 'P')\r\n xml.tag!(:src_file, src_file_name)\r\n xml.tag!(:process_dt, (created_at.strftime(\"%Y-%m-%d %H:%M:%S\")))\r\n xml.tag!(:rework, '0')\r\n end\r\n end", "def create\n @batch = Batch.new(batch_params)\n\n respond_to do |format|\n if @batch.save\n format.html { redirect_to @batch, notice: \"Batch was successfully created.\" }\n format.json { render :show, status: :created, location: @batch }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @batch = Batch.new(batch_params)\n\n respond_to do |format|\n if @batch.save\n format.html { redirect_to @batch, notice: 'Batch was successfully created.' }\n format.json { render :show, status: :created, location: @batch }\n else\n format.html { render :new }\n format.json { render json: @batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def processing_batches(w)\n dir = join(@basedir, DIR_PROCESSING)\n w.sftp.dir[dir, '*'].map do |entry|\n Model::Batch.new(:path => join(dir, entry.name), :state => :processing)\n end\n end", "def create\n @batch = Batch.new(params[:batch])\n\n respond_to do |format|\n if @batch.save\n format.html { redirect_to @batch, notice: 'Batch was successfully created.' }\n format.json { render json: @batch, status: :created, location: @batch }\n else\n format.html { render action: \"new\" }\n format.json { render json: @batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @batch = Batch.new(batch_params)\n\n respond_to do |format|\n if @batch.save\n format.html { redirect_to @batch, notice: 'Batch was successfully created.' }\n format.json { render action: 'show', status: :created, location: @batch }\n else\n format.html { render action: 'new' }\n format.json { render json: @batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @batch = Batch.new(batch_params)\n\n respond_to do |format|\n if @batch.save\n format.html { redirect_to @batch, notice: 'Batch was successfully created.' }\n format.json { render action: 'show', status: :created, location: @batch }\n else\n format.html { render action: 'new' }\n format.json { render json: @batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tengine_batch = Tengine::Batch.new(params[:tengine_batch])\n\n respond_to do |format|\n if @tengine_batch.save\n format.html { redirect_to @tengine_batch, notice: 'Batch was successfully created.' }\n format.json { render json: @tengine_batch, status: :created, location: @tengine_batch }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tengine_batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @batch = Batch.new(batch_params)\n team_member_ids = params[:team_member_ids]\n\n\n respond_to do |format|\n if @batch.save\n format.html { redirect_to @batch, notice: 'Batch was successfully created.' }\n format.json { render :show, status: :created, location: @batch }\n else\n format.html { render :new }\n format.json { render json: @batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @batch = Batch.new(batch_params)\n add_breadcrumb \"Batches\", batches_url\n add_breadcrumb \"New Batch\"\n respond_to do |format|\n if @batch.save\n format.html { redirect_to @batch, notice: 'Batch was successfully created.' }\n format.json { render :show, status: :created, location: @batch }\n else\n format.html { render :new }\n flash[:alert] = @batch.errors.full_messages.to_sentence\n format.json { render json: @batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @transport_batch = TransportBatch.new(params[:transport_batch])\n @prodcut_batch = ProductBatch.find(params[:product_batch_id])\n @transport_batch = TransportBatch.new\n @transport_batch.product_batch = @prodcut_batch\n # @transport_batch.start_pool_no = 100\n # @transport_batch.end_pool_no = 300\n @transport_batch.pool_totals = [12, 18, 20]\n @transport_batch.code = SecureRandom.random_number(10**6)\n array = Array.new\n 3.times {array << rand(10)}\n @transport_batch.print_unit_completes = array.to_s\n @transport_batch.state = 'initial'\n\n respond_to do |format|\n if @transport_batch.save\n Feed.create owner_type: \"transport_batch\", owner_id: @transport_batch.id, user_id: current_user.id, operation: \"create\", \n desc: \"获取运输批次文件\"\n format.html { redirect_to @prodcut_batch, notice: 'Transport batch was successfully created.' }\n else\n format.html { render action: \"new\" }\n end\n end\n end", "def create\n batch = Batch.new(batch_params)\n # Setting reference number\n batch[:reference_batch] = Faker::Code.nric\n\n # Getting all orders for purchase_channel\n orders = Order.where(\"purchase_channel = ?\", batch[:purchase_channel_batch])\n if batch.save\n # Setting batch id in orders\n orders.update(batch_id: batch[:id])\n # Changing orders status\n orders.update(status: Order.statuses['production'])\n\t\t\t\t\trender json: {status: 'SUCCESS', message: 'Saved Batch', number_of_orders_in_batch: orders.size, data: batch}, status: :ok\n\t\t\t\telse\n\t\t\t\t\trender json: {status: 'ERROR', message: 'Batch not saved', data:batch.errors}, status: :unprocessable_entity\n\t\t\t\tend\n end", "def create\n @batch = Batch.new(params[:batch])\n \n ActiveRecord::Base.transaction do\n @batch.save!\n DownloadCode.create_in_bulk!(@batch)\n end\n\n respond_to do |format|\n flash[:notice] = 'Batch was successfully created.'\n format.html { redirect_to(@batch) }\n format.xml { render :xml => @batch, :status => :created, :location => @batch }\n end\n rescue ActiveRecord::RecordInvalid\n @batch.errors.add_to_base \"There was an error creating this batch of downloads\"\n \n respond_to do |format|\n format.html { render :action => \"new\" }\n format.xml { render :xml => @batch.errors, :status => :unprocessable_entity }\n end\n end", "def create_batch\n begin\n # create the new batch\n batch = BatchJob.new\n batch.name = params[:name]\n batch.job_type = params[:type_id]\n batch.ocr_engine_id = params[:engine_id]\n batch.font_id = params[:font_id]\n batch.parameters = params[:params]\n batch.notes = params[:notes]\n batch.save!\n \n # populate it with pages from the selected works\n json_payload = ActiveSupport::JSON.decode(params[:json])\n json_payload['works'].each do | work_id |\n pages = Page.where(\"pg_work_id = ?\", work_id)\n pages.each do | page |\n job = JobQueue.new\n job.batch_id = batch.id\n job.page_id = page.pg_page_id\n job.job_status = 1\n job.work_id=work_id\n job.save!\n end\n end\n\n # get a new summary for the job queue\n status = get_job_queue_status()\n render :json => ActiveSupport::JSON.encode(status), :status => :ok \n \n rescue => e\n render :text => e.message, :status => :error\n end \n end", "def create\n @batch = Batch.new(params[:batch])\n\n respond_to do |format|\n if @batch.save\n format.html { redirect_to recipe_path(@batch.recipe_id)}\n format.json { render json: @batch, status: :created, location: @batch }\n else\n format.html { render action: \"new\" }\n format.json { render json: @batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @product_batch = ProductBatch.new(params[:product_batch])\n worksheet = Worksheet.find(params[:product_batch][:worksheet_id])\n \n game = worksheet.game\n @product_batch.state = 'initial'\n @product_batch.game = game\n \n #根据印刷单元的数量和game的参数配置,算出总的票数\n print_unit_count = params[:product_batch][:print_unit_count]\n @product_batch.ticket_count = game.poolcount_per_printunit * game.pool_size * print_unit_count.to_i\n\n respond_to do |format|\n if @product_batch.save\n Feed.create owner_type: \"product_batch\", owner_id: @product_batch.id, user_id: current_user.id, operation: \"create\", desc: \"创建生产批次\"\n format.html { redirect_to @product_batch, notice: 'Product batch was successfully created.' }\n format.json { render json: @product_batch, status: :created, location: @product_batch }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product_batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def send_batch(batch)\n return if batch.empty?\n json_package = JSON.generate(batch.map { |c| c.output_hash })\n begin\n resp = @http_client.post @solr_update_url, json_package, \"Content-type\" => \"application/json\"\n rescue StandardError => exception\n end\n\n if exception || resp.status != 200\n error_message = exception ? \n Traject::Util.exception_to_log_message(exception) : \n \"Solr response: #{resp.status}: #{resp.body}\"\n\n logger.error \"Error in Solr batch add. Will retry documents individually at performance penalty: #{error_message}\"\n \n batch.each do |c|\n send_single(c)\n end\n end\n end", "def processed_batches(w)\n dir = join(@basedir, DIR_PROCESSED)\n w.sftp.dir[dir, '*'].map do |entry|\n Model::Batch.new(:path => join(dir, entry.name), :state => :processed)\n end\n end", "def send_batch\n batch = @batch.map(&:first) # get the requests\n response = send_batch_request(batch)\n\n begin\n responses = JSON.parse(response)\n rescue\n raise Jimson::ClientError::InvalidJSON.new(json)\n end\n\n process_batch_response(responses)\n responses = @batch\n\n @batch = []\n\n responses\n end", "def batch\n shp = Shipment.new(shipment_params)\n\n job_params = {\n shipment_ids: params[:shipment_ids],\n carrier: shp.carrier,\n service: shp.ship_method,\n packaging: shp.packaging_type,\n length: shp.package_length.to_f,\n width: shp.package_width.to_f,\n height: shp.package_height.to_f,\n weight: shp.package_weight.to_f,\n require_signature: shp.require_signature,\n printer_id: params[:printer_id],\n send_email: params[:send_email] == \"1\",\n ship_date: shp.ship_date.to_s,\n user_id: session[:user_id]\n }\n\n Shipment.where(id: params[:shipment_ids]).update_all(batch_status: \"queued\", batch_status_message: \"\")\n BatchShipJob.perform_later(job_params)\n\n redirect_to action: :batch_status, shipment_ids: params[:shipment_ids].join(\".\")\n end", "def create\n @ready_for_shipment_batch = ReadyForShipmentBatch.new(params[:ready_for_shipment_batch])\n\n respond_to do |format|\n if @ready_for_shipment_batch.save\n format.html { redirect_to @ready_for_shipment_batch, notice: 'Ready for shipment batch was successfully created.' }\n format.json { render json: @ready_for_shipment_batch, status: :created, location: @ready_for_shipment_batch }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ready_for_shipment_batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @batch_file = BatchFile.new(batch_file_params)\n\n respond_to do |format|\n if @batch_file.save\n format.html { redirect_to @batch_file, notice: \"Batch file was successfully created.\" }\n format.json { render :show, status: :created, location: @batch_file }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @batch_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def send_batch(batch)\n return if batch.empty?\n\n logger.debug(\"#{self.class.name}: sending batch of #{batch.size} to Solr\")\n\n json_package = JSON.generate(batch.map { |c| c.output_hash })\n\n begin\n resp = @http_client.post solr_update_url_with_query(@solr_update_args), json_package, \"Content-type\" => \"application/json\"\n rescue StandardError => exception\n end\n\n if exception || resp.status != 200\n error_message = exception ?\n Traject::Util.exception_to_log_message(exception) :\n \"Solr response: #{resp.status}: #{resp.body}\"\n\n logger.error \"Error in Solr batch add. Will retry documents individually at performance penalty: #{error_message}\"\n\n batch.each do |c|\n send_single(c)\n end\n end\n end", "def create\n @evidence_batch = EvidenceBatch.new(params[:evidence_batch])\n\n @evidence_batch.ip_address = request.remote_ip\n\n respond_to do |format|\n if @evidence_batch.save\n format.html # create.html.haml\n format.json { render json: @evidence_batch, status: :created, location: @evidence_batch }\n else\n format.html { render action: \"new\" }\n format.json { render json: @evidence_batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def close_batch\n xml = build_batch_xml\n #puts xml\n post_xml(xml, true)\n end", "def batch_create\n @values = record_batch_params.values.reject { |p| p.values.all?(&:blank?) }\n @records = record_class.create(@values)\n\n respond_to do |format|\n if @records.all?(&:valid?)\n format.html { redirect_to url_for(action: 'index'), notice: \"#{record_class.model_name.plural.humanize} were successfully created.\" }\n format.json { render :index, status: :created }\n else\n @records = @records.fill(@records.size..BATCH_SIZE) { record_class.new }\n\n format.html { render :batch_new }\n format.json { render json: @records.map(&:errors), status: :unprocessable_entity }\n end\n end\n end", "def create\n @batch = Batch.new(params[:batch])\n @batch.user = current_user\n respond_to do |format|\n if @batch.save\n flash[:notice] = 'Batch was successfully created.'\n format.html { redirect_to(@batch) }\n format.xml { render :xml => @batch, :status => :created, :location => @batch }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @batch.errors, :status => :unprocessable_entity }\n end\n end\n end", "def batch_params\n params.require(:batch).permit(:name,\n :beer_style_id,\n :description,\n :projected_volume_in_gallons,\n :projected_alcohol_by_volume,\n :projected_original_gravity,\n :projected_final_gravity,\n :projected_secondary_transition_date,\n :projected_bottle_date,\n :projected_condition_date,\n :actual_original_gravity,\n :actual_final_gravity,\n :actual_alcohol_by_volume,\n :actual_brew_date,\n :actual_secondary_transition_date,\n :actual_bottle_date,\n :actual_condition_date,\n :color,\n :difficulty,\n :recipe_id)\n end", "def send_batch_request(batch)\n post_data = batch.to_json\n resp = RestClient.post(@url, post_data, content_type: 'application/json', user_agent: \"syncano-ruby-#{Syncano::VERSION}\")\n if resp.nil? || resp.body.nil? || resp.body.empty?\n raise Jimson::ClientError::InvalidResponse.new\n end\n\n return resp.body\n end", "def index\n @batches = Batch.all\n respond_to do |format|\n format.html {}\n format.json {\n\n data = Hash.new\n data[\"batches\"] = @batches\n return_success_response(data, \"Request Successful\", 200)\n }\n end\n end", "def batch_params\n params[:batch]\n end", "def index\n @batches = Batch.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @batches }\n end\n end", "def execute_batch(batch, options={})\n headers = {\n 'Content-Type' => \"multipart/mixed; boundary=#{batch.batch_id}\",\n 'Accept' => 'application/atom+xml,application/xml',\n 'Accept-Charset'=> 'UTF-8'\n }\n\n query = { }\n query[\"timeout\"] = options[:timeout].to_s if options[:timeout]\n\n body = batch.to_body\n response = call(:post, generate_uri('/$batch', query), body, headers, options)\n batch.parse_response(response)\n rescue => e\n raise_with_response(e, response)\n end", "def batch_params\n params.require(:batch).permit(:size, :brew_date, :bottle_date, :aog, :afg, :aabv, :aaroma, :aibu, :image, :aflavpro, :recipe_id)\n end", "def batch_params\n params.require(:batch).permit(:name,:background_type,:job_type,:job_count,:worker_count,:thread_count,:modified_run)\n end", "def create_batch urls\n function = 'batch/'\n\n post_data = {}\n post_data[:urls] = urls.join(',')\n\n request(@resource, function, nil, 'post', post_data)\n end", "def test_create_batch\n batch_upload = uploaded_file(\"#{File.expand_path(Rails.root)}/test/fixtures/batch_import.csv\")\n count = Batch.count\n post :create, {:upload => {'file' => batch_upload}, :type => 'batch'}, {:user => 15}\n new_count = Batch.count\n last_batch = Batch.find(:all).last\n assert_equal(last_batch.arrival_time, Time.parse(\"9/19/2007 21:45\"))\n assert_equal(count + 1, new_count)\n assert_redirected_to :controller => '/admin/upload', :action => 'upload', :batch => nil, :type => 'batch'\n end", "def send_batch msgs\n @ws.send encode_batch(msgs)\n end", "def write_batch_data\n data = []\n # Loop through each row of data\n @document.xpath('//Row').each do |xml_row|\n row = []\n # Loop through each column value\n @column_names.keys.each do |column|\n row.append(xml_row.xpath(column).text)\n end\n data.append(row)\n end\n\n # Write the data to a csv file\n CSV.open(csv_file_path, 'a') do |csv|\n # Add each row by row\n data.each do |row|\n csv << row\n end\n end\n end", "def create\n @batch_sampling = BatchSampling.new(params[:batch_sampling])\n @title = \"Batch Upload of Sampling Data\"\n\n respond_to do |format|\n if @batch_sampling.save\n \n id = @batch_sampling.id\n\n logger.debug \"batch_sampling ID\" + id.to_s\n\n self.parse_batch_sampling_data(id)\n\n format.html {\n flash[:notice] = 'Files have been successfully saved and new Sampling entries are created!!!'\n redirect_to :controller => \"samplings\", :action => \"index\" }\n\n format.xml { render :xml => @batch_sampling, :status => :created, :location => @batch_sampling }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @batch_sampling.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\r\n @ph_specified = PhSpecified.new(params[:ph_specified])\r\n\r\n respond_to do |format|\r\n if @ph_specified.save\r\n format.html { redirect_to(@ph_specified) }\r\n format.xml { render :xml => @ph_specified, :status => :created, :location => @ph_specified }\r\n else\r\n format.html { render :action => \"new\" }\r\n format.xml { render :xml => @ph_specified.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def process!(response_data={})\n @client.post(\"#{path}/process\", response_data)\n end", "def post(batch)\n last_response, exception = retry_with_backoff(@retries) do\n status_code, body, message = send_request(batch)\n\n should_retry = should_retry_request?(status_code, body)\n\n [Response.new(status_code, message), should_retry]\n end\n\n if exception\n logger.error(exception.message)\n exception.backtrace.each { |line| logger.error(line) }\n Response.new(-1, \"Connection error: #{exception}\")\n else\n last_response\n end\n end", "def create\n @batch = Batch.new(batch_params)\n @batch.user = current_user\n\n respond_to do |format|\n if @batch.save\n format.html { redirect_to @batch, notice: 'Batch was successfully created.' }\n format.json { render :show, status: :created, location: @batch }\n else\n format.html { render :new }\n format.json { render json: @batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def send_request(batch)\n payload = batch.to_s\n request = Net::HTTP::Post.new(@path, @headers)\n\n if self.class.stub\n logger.debug \"stubbed request to #{@path}: \" \\\n \"batch = '#{batch}'\"\n\n [200, '', 'OK']\n else\n # If `start` is not called, Ruby adds a 'Connection: close' header to\n # all requests, preventing us from reusing a connection for multiple\n # HTTP requests\n @http.start unless @http.started?\n\n response = @http.request(request, payload)\n [response.code.to_i, response.body, response.message]\n end\n end", "def batch_params\n # Инициализация параметров объекта Batch\n params.require(:batch).permit(:batch_id, :creation_date, :guid, :batch_file)\n end", "def link_to_simulation_batches(sim_ids)\n sbl = SimulationBatchList.new\n sbl.save!\n self.simulation_batch_list_id = sbl.id\n self.save!\n sim_ids.each do |s|\n rb = ReportedBatch.new\n rb.simulation_batch_id = s\n rb.simulation_batch_list_id = self.simulation_batch_list_id\n rb.save!\n end\n end", "def create\n # Сохраняем данные из загруженного файла\n # Инициализируем объект Batch с параметрами\n @batch = Batch.new(batch_params)\n # Загруженный файл\n uploaded_io = params[:batch][:batch_file]\n @file_path = \"/public/uploads/#{uploaded_io.original_filename}\"\n @xml_file = File.new(Rails.root.join('public', 'uploads', uploaded_io.original_filename))\n # Создаем новый документ XML. Выбираем интересующие нас элементы по имени/шаблону\n @xml_doc = Document.new(@xml_file)\n @root = @xml_doc.root\n @file_attribute_guid = @root.elements[\"FileAttribute/GUID\"]\n # Берем содержимое ноды\n @batch.guid = @file_attribute_guid.text\n\n # Ищем загруженный файл в базе по GUID\n @existing_batch = Batch.find_batch_by_guid(@batch.guid)\n\n if @existing_batch != nil\n # Если файл существует, не сохраняем его данные\n @guid_error = \"Batch file with GUID provided already exists in database\"\n else\n # Файл не найден в базе, обрабатываем его данные\n @batch_id_data = @root.elements[\"FileData/Batch/BatchID\"]\n @batch.batch_id = @batch_id_data.text\n @batch_creation_date_data = @root.elements[\"FileData/Batch/CreationDate\"]\n @batch.creation_date = @batch_creation_date_data.text\n @batch.batch_file = @file_path\n # Сохраняем данные загруженного файла в базу\n @batch.save\n\n # Для каждой ноды \"Invoice\" внутри \"FileData\" сохраняем её данные в соответствующую таблицу БД\n @root.elements.each(\"FileData/Invoice\") do |invoice|\n @invoice = @batch.invoices.create(\n invoice_operation_number: invoice.elements[\"InvoiceOperation/InvoiceOperationNumber\"].text,\n invoice_operation_date: invoice.elements[\"InvoiceOperation/InvoiceOperationDate\"].text,\n company_code: invoice.elements[\"InvoiceOperation/CompanyCode\"].text,\n )\n # Сохраняем Инвойс\n @invoice.save\n # Теперь повторяем то же самое для каждого товара в инвойсе\n # Выбираем ноды \"InvoiceData\" внутрни инвойса и сохраняем их данные в таблицу invoice_data_items\n invoice.elements.each(\"InvoiceData\") do |invoice_data_item|\n @invoice_data_item = @invoice.invoice_data_items.create(\n parcel_code: invoice_data_item.elements[\"ParcelCode\"].text,\n item_qty: invoice_data_item.elements[\"ItemQty\"].text,\n parcel_price: invoice_data_item.elements[\"ParcelPrice\"].text,\n )\n # Сохраняем данные в БД\n @invoice_data_item.save\n end\n end\n end\n\n respond_to do |format|\n if @existing_batch != nil\n # Если файл с данным GUID уже существует в базе, возвращаемся к списку загрузок и выводим соответствующее предупреждение\n format.html { redirect_to batches_url, alert: @guid_error }\n format.json { head :no_content }\n else\n # Если сохранение объекта Batch прошло удачно, переходим на страницу показа и показываем соответствующее сообщение\n if @batch.save\n format.html { redirect_to @batch, notice: 'Batch was successfully uploaded.' }\n format.json { render :show, status: :created, location: @batch }\n else\n # В противном случае, остаемся на странице загрузки данных и показываем сообщение об ошибке\n format.html { render :new }\n format.json { render json: @batch.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n respond_to do |format|\n if @product_batch.save\n flash[:notice] = 'ProductBatch was successfully created.'\n format.html { redirect_to(@product_batch) }\n format.xml { render :xml => @product_batch, :status => :created, :location => @product_batch }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @product_batch.errors, :status => :unprocessable_entity }\n end\n end\n end", "def batch_params\n params.require(:batch).permit(:description, :committed_at, :total_cents, :total_currency, :status)\n end", "def create\n fail = 0\n @errors = []\n @rows = []\n params[:rows].each_value do |pnum|\n num = PartNum.new(pnum)\n @rows << num\n if ! num.save\n fail = 1\n @errors << num.errors\n end\n end\n \n respond_to do |format|\n if fail == 0\n flash[:notice] = 'Part numbers was successfully created.'\n format.html { redirect_to( part_nums_path() ) }\n format.xml { render :xml => @part_num, :status => :created, :location => @part_num }\n else\n flash[:notice] = 'Part number creation failed.'\n format.html { render :action => \"new\" }\n format.xml { render :xml => @errors, :status => :unprocessable_entity }\n end\n end\n end", "def batch_new\n end", "def batch_params\n params.require(:batch).permit(:id, :date_collected, :count_total, :contributions_num, :comments)\n end", "def leadCreateSfBulk()\n Salesforce.createRecords(@salesforceBulk, 'Lead', @testDataJSON[\"AccountAssignment\"][\"GenerateLeadFromWeb\"][0][\"BuildingName\"])\n end", "def index\n @batches = Batch.all\n end", "def post_business(business, location)\n xml = Builder::XmlMarkup.new\n query = xml.tag!(\"BPMSPost\", 'Edition' => \"1.1\") {\n xml.tag!(\"Record\") {\n xml.tag!(\"Phone\", location.phone)\n xml.tag!(\"BusinessName\", location.location_name)\n xml.tag!(\"Address\", location.address)\n xml.tag!(\"City\", location.city)\n xml.tag!(\"State\", location.state)\n xml.tag!(\"Zip\", location.zip)\n xml.tag!(\"URL\", location.website_url)\n xml.tag!(\"TagLine\", location.special_offer)\n #xml.tag!(\"LogoImage\", location.logo)\n xml.tag!(\"Categories\") {\n xml.tag!(\"Category\") {\n xml.tag!(\"Type\", \"Primary\")\n xml.tag!(\"Name\", business.industry_primary)\n }\n if business.industry_alt_1.present?\n xml.tag!(\"Category\") {\n xml.tag!(\"Type\", \"Alt1\")\n xml.tag!(\"Name\", business.industry_alt_1)\n }\n end\n if business.industry_alt_2.present?\n xml.tag!(\"Category\") {\n xml.tag!(\"Type\", \"Alt2\")\n xml.tag!(\"Name\", business.industry_alt_2)\n }\n end\n }\n }\n }\n body = build_request(3700, 1510, query)\n response = send_to_localeze(body)\n xml_doc = respond_with_hash(Nokogiri::XML(response.to_xml).text)\n xml_doc['Error'] == '0' # success (returns true/false)\n end", "def create(bin_params)\n @rest.post('save', bin_params)\n end", "def create\n @batch = Batch.new(batch_params)\n authorize! :create, @batch\n if @batch.save\n render json: @batch, status: :created\n else\n render json: @batch.errors, status: :unprocessable_entity\n end\n end", "def create\n @batch = Batch.new(batch_params)\n @batch.author = current_user\n @batch.actual_brew_date = Time.now\n\n respond_to do |format|\n if @batch.save\n track_activity @batch\n format.html { redirect_to edit_user_batch_path(@batch.author, @batch), notice: 'Batch was successfully created.' }\n format.json { render :show, status: :created, location: @batch }\n else\n format.html { render :new }\n format.json { render json: @batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @batch_set = BatchSet.new(batch_set_params)\r\n @batch = Batch.find(params[:batch_id])\r\n respond_to do |format|\r\n if @batch_set.save\r\n\r\n # FOR MAILER\r\n @batch_set.batch.students.each do |student|\r\n @user = student.user\r\n UserMailer.batch_set_email(@user, @batch_set).deliver\r\n end\r\n \r\n # FOR MAILER CRONJOB\r\n # BatchSetEmailWorker.perform_async(@batch_set.id)\r\n\r\n format.html { redirect_to edit_batch_batch_set_path(@batch, @batch_set), notice: 'Batch set was successfully created.' }\r\n format.json { render :show, status: :created, location: @batch_set }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @batch_set.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def batch_upload_rows(rows, per_page=100); batch_modify_rows('put', rows, per_page); end", "def batch(request, request_options = {})\n client.post(Protocol.batch_uri(name), request.to_json, :batch, request_options)\n end", "def action_batches\r\n ActionBatchesController.instance\r\n end", "def create_batch_with_http_info(create_batch_request_body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BatchesApi.create_batch ...'\n end\n # verify the required parameter 'create_batch_request_body' is set\n if @api_client.config.client_side_validation && create_batch_request_body.nil?\n fail ArgumentError, \"Missing the required parameter 'create_batch_request_body' when calling BatchesApi.create_batch\"\n end\n # resource path\n local_var_path = '/v1/batches'\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 header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\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(create_batch_request_body) \n\n # return_type\n return_type = opts[:return_type] || 'CreateBatchResponseBody' \n\n # auth_names\n auth_names = opts[:auth_names] || ['api_key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BatchesApi#create_batch\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def api_v11_batch_post(opts = {})\n api_v11_batch_post_with_http_info(opts)\n return nil\n end", "def batch_params\n params.require(:batch).permit(:course_id, :name, :price, :start_date, :schedule, :strength, :status ,:team_member_ids => [])\n end", "def create_batch_job(job_id)\n request = Net::HTTP::Put.new(\"/jobs/#{job_id}\")\n response = http.request(request)\n handle_response({ request_method: request.method, request_path: request.path }, response)\n end", "def index\n @batches = @zone.batches\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @batches }\n end\n end", "def create\n @batch = Batch.new\n @batch.item = Item.find(params[:item_id])\n @batch.company = current_user.company if current_user.company?\n @batch.count = params[:amount].to_i\n @batch.count *= 1000 if @batch.item.have_weight\n @batch.price = params[:price].to_i\n @batch.supplier_price = params[:supplier_price].to_i\n @batch.barcode = Barcode.find_by_code params[:barcode]\n @batch.user = current_user\n respond_to do |format|\n if @batch.save\n format.json { render json: nil, status: :created }\n else\n format.json { render json: @batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def send_batch\n if @payment_initiation.valid?\n do_send_batch\n else\n raise InvalidWireTransactionError,\n \"invalid wire transfer: #{@payment_initiation.error_messages}\"\n end\n end", "def update\n @batch = Batch.find(params[:id])\n\n respond_to do |format|\n if @batch.update_attributes(params[:batch])\n format.html { redirect_to @batch, notice: 'Batch was successfully updated.' }\n format.json { respond_with_bip(@batch) }\n else\n format.html { redirect_to @batch }\n format.json { respond_with_bip(@batch) }\n end\n end\n end", "def create_upload_job_chunks(jobs, state, apikey, filename, filepath, filesize, start_response)\n jobs.each { |job|\n job[:chunks] = chunk_job(\n job, state, apikey, filename, filepath, filesize, start_response\n )\n }\n jobs\n end", "def batch_params\n params.require(:batch).permit(:job_class, :timestamps)\n end", "def index\n @batches = Batch.page(params[:page]).per(15)\n @page = params[:page] || 1\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @batches }\n end\n end", "def addLogsBatchXML(collection=\"lclsLogs\", dizList, bulk: false)\n uri = URI.parse(\"http://#{@host}:#{@port}/solr/#{collection}/update\") \n # uri = URI.parse(\"http://psmetric04:8983/solr/lclsLogs/update\") \n http = Net::HTTP.new(uri.host, uri.port)\n req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/xml')\n req.body = formatLogBatchAsXML(dizList)\n # puts req.body \n # res = http.request(req, xml: formatLogBatchAsXML(dizList) )\n res = http.request(req)\n # puts \"response: #{res.body}\"\n return [dizList.length, req.body.size, res]\n end", "def on_finish_batch; end", "def save_file_batch(files, new_obj_id)\n url = \"#{@base_url}/api/v2/files/#{new_obj_id}/create_batch\"\n resp = api_post_json(url, files.to_json)\n if resp.code != '201'\n @log.write(\"Error saving #{files.count} files #{files[0]['identifier']}...\\n\")\n @log.write(files.inspect)\n @log.write(\"\\n\" + resp.body + \"\\n\")\n #exit(1)\n end\n end", "def serialize_batch(batch)\n batch.to_json\n end", "def send_batch(batch)\n smarty_request = Request.new\n\n return if batch.empty?\n\n converted_lookups = remap_keys(batch.all_lookups)\n\n if batch.size > 1\n smarty_request.payload = @serializer.serialize(converted_lookups)\n else\n smarty_request.parameters = converted_lookups[0]\n end\n\n response = @sender.send(smarty_request)\n\n raise response.error if response.error\n\n candidates = @serializer.deserialize(response.payload)\n candidates = [] if candidates.nil?\n\n assign_candidates_to_lookups(batch, candidates)\n end", "def process\n Wavefront::Write.new({ proxy: ENDPOINT, port: 2878 },\n tags: setup_tags).write(metrics_as_points)\n update_run_number\n end", "def batch_params\n p = params.require(:batch).permit(:recipe,\n rhizome_roles_attributes: [:rhizome_id, :role_id, :_destroy])\n if p[:recipe].to_i.zero?\n p.delete(:recipe)\n else\n p[:recipe] = Recipe.find(p[:recipe].to_i)\n end\n p\n end", "def batch(serial_only=false)\n @batch_request=true\n Thread.current[:facebooker_current_batch_queue]=[]\n yield\n # Set the batch request to false so that post will execute the batch job\n @batch_request=false\n BatchRun.current_batch=Thread.current[:facebooker_current_batch_queue]\n post(\"facebook.batch.run\",:method_feed=>BatchRun.current_batch.map{|q| q.uri}.to_json,:serial_only=>serial_only.to_s)\n ensure\n @batch_request=false\n BatchRun.current_batch=nil\n end", "def submit_order()\n\tputs \"Submitting order\"\n\tdata = create_order()\n\tresponse = request_post(\"/api/order\", data)\n\tputs response.body\nend", "def post_job_content_sample(client)\n job_multipart = {\n :file => File.new($full_path),\n 'num copies' => 10\n }\n\n response = client['jobs'].post job_multipart\n\n p ''\n p 'Submit a new job'\n p response\nend", "def execute(http_options = {})\n return [] if batch_calls.empty?\n\n batch_results = []\n batch_calls.each_slice(MAX_CALLS) do |batch|\n # Turn the call args collected into what facebook expects\n args = {\"batch\" => batch_args(batch)}\n batch.each do |call|\n args.merge!(call.files || {})\n end\n\n original_api.graph_call(\"/\", args, \"post\", http_options) do |response|\n raise bad_response if response.nil?\n\n batch_results += generate_results(response, batch)\n end\n end\n\n batch_results\n end", "def list_batches_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BatchesApi.list_batches ...'\n end\n if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"page\"]\" when calling BatchesApi.list_batches, must be greater than or equal to 1.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"page_size\"]\" when calling BatchesApi.list_batches, must be greater than or equal to 1.'\n end\n\n # resource path\n local_var_path = '/v1/batches'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n query_params[:'sort_dir'] = opts[:'sort_dir'] if !opts[:'sort_dir'].nil?\n query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'ListBatchesResponseBody' \n\n # auth_names\n auth_names = opts[:auth_names] || ['api_key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BatchesApi#list_batches\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def bulk_generate\n\n end", "def batch_params\n params.require(:batch).permit(:course_id, :batch_name, :start_date,:end_date)\n end", "def create\n \n \n @batch = Batch.new(params[:batch])\n \n if not params[:batch].has_key? :title\n @batch.title = Time.now.getutc\n end\n \n cards = params[:card]\n\n respond_to do |format|\n if @batch.save\n \n for c in cards\n Card.update c[:id], :status_id=>2, :batch_id => @batch.id\n end\n \n \n format.html { redirect_to @batch, notice: 'Batch was successfully created.' }\n format.json { render json: @batch, status: :created, location: @batch }\n else\n format.html { render action: \"new\" }\n format.json { render json: @batch.errors, status: :unprocessable_entity }\n end\n end\n end", "def send_gen weights, status, parsers\n data = {\n :input => {\n :source => \"twitter\",\n :username => status.user.screen_name,\n :displayname => status.user.name,\n :userid => status.user.id_str,\n :url => \"https://twitter.com/#!/\" + status.user.screen_name + \"/status/\" + status.id_str + \"/\",\n :userimgurl => status.user.profile_image_url.gsub(/_normal/, ''),\n :raw_input => status.text,\n :text => text_score[:stripped_text],\n :metadata => nil #fix this\n }, #input\n :weights => weights, #weights\n :sentiment => {\n :text => {\n :total_score => h, #stolen from \"happiness\"\n :positive_score => nil, #fix this\n :negative_score => nil #fix this\n },\n :tweet => {\n :hash_obnoxiousess => status.entities.hashtags.length,\n :retweet => status.retweeted\n },\n :face => {\n :smiling => nil,\n :confidence => nil,\n }\n } #sentiment\n } #data\n payload = Yajl::Encoder.encode(data)\n prefs = TwitterSentiment::Prefs::Defaults.socket\n streamSock = TCPSocket.new(prefs[:host], prefs[:port])\n streamSock.write(payload)\n streamSock.close\n rescue Exception\n pp :warn, \"Failed to send payload across socket.\", :med\n end", "def create\n @process_training = ProcessTraining.new(process_training_params)\n\n respond_to do |format|\n if @process_training.save\n format.html { redirect_to @process_training, notice: 'Process training was successfully created.' }\n format.json { render :show, status: :created, location: @process_training }\n else\n format.html { render :new }\n format.json { render json: @process_training.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_batch\n @batch = Batch.find(params[:id])\n end", "def create\n authorize! :create, @manual\n @manual = new_manual\n respond_to do |format|\n if @manual.save\n format.html { redirect_to manuals_path, notice: \"#{t(:manual_transaction)} #{t(:was_successfully_created)}\" }\n # format.json { render action: 'show', status: :created, location: @manual }\n else\n init_collection\n gon.push batches: ActiveModel::Serializer::CollectionSerializer.new(@batches, each_serializer: BatchSerializer)\n format.html { render action: 'new' }\n # format.json { render json: @manual.errors, status: :unprocessable_entity }\n end\n end\n end", "def batch(*requests)\n body = requests.map do |request|\n {method: request[0], params: request[1..-1], jsonrpc: '2.0', id: SecureRandom.uuid}\n end\n parsed_response = parse_response(post(body))\n errors = parsed_response.select{|response| response[:error]}\n raise Error, errors if !errors.empty?\n parsed_response.map{|response| response[:result]}\n end", "def create\n @phbook = Phbook.new(phbook_params)\n\n respond_to do |format|\n if @phbook.save\n format.html { redirect_to @phbook, notice: 'Phbook was successfully created.' }\n format.json { render :show, status: :created, location: @phbook }\n else\n format.html { render :new }\n format.json { render json: @phbook.errors, status: :unprocessable_entity }\n end\n end\n end", "def process_batch_with_http_info(batch_id, process_batch_request_body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BatchesApi.process_batch ...'\n end\n # verify the required parameter 'batch_id' is set\n if @api_client.config.client_side_validation && batch_id.nil?\n fail ArgumentError, \"Missing the required parameter 'batch_id' when calling BatchesApi.process_batch\"\n end\n if @api_client.config.client_side_validation && batch_id.to_s.length > 25\n fail ArgumentError, 'invalid value for \"batch_id\" when calling BatchesApi.process_batch, the character length must be smaller than or equal to 25.'\n end\n\n if @api_client.config.client_side_validation && batch_id.to_s.length < 1\n fail ArgumentError, 'invalid value for \"batch_id\" when calling BatchesApi.process_batch, the character length must be great than or equal to 1.'\n end\n\n pattern = Regexp.new(/^se(-[a-z0-9]+)+$/)\n if @api_client.config.client_side_validation && batch_id !~ pattern\n fail ArgumentError, \"invalid value for 'batch_id' when calling BatchesApi.process_batch, must conform to the pattern #{pattern}.\"\n end\n\n # verify the required parameter 'process_batch_request_body' is set\n if @api_client.config.client_side_validation && process_batch_request_body.nil?\n fail ArgumentError, \"Missing the required parameter 'process_batch_request_body' when calling BatchesApi.process_batch\"\n end\n # resource path\n local_var_path = '/v1/batches/{batch_id}/process/labels'.sub('{' + 'batch_id' + '}', CGI.escape(batch_id.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(['text/plain', '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 = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(process_batch_request_body) \n\n # return_type\n return_type = opts[:return_type] || 'String' \n\n # auth_names\n auth_names = opts[:auth_names] || ['api_key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BatchesApi#process_batch\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n old_batch = Batch.where(:batch_number => batch_params[:batch_number] , :brand_id => batch_params[:brand_id]).first\n #if batch number exists, just update store and qty\n if old_batch\n @batch = old_batch\n @batch.qty = batch_params[:qty]\n @batch.recipient_store = batch_params[:recipient_store]\n @batch.add_loose_units\n else\n @batch = Batch.new(batch_params)\n end\n\n #begin\n if @batch.save\n i = Inventory.where(:brand_id => @batch.brand_id, :store_id => @batch.recipient_store).first\n @batch.loose_units||= 0\n if i.blank?\n #create inventory.\n i = Inventory.create(:brand => @batch.brand, :store_id => @batch.recipient_store, :pharm_item => @batch.brand.pharm_item)\n end\n\n i.update(:qty_last_added => (@batch.qty.to_f * @batch.brand.pack_size.to_f) + @batch.loose_units.to_i, :rate_per_unit => \"%.2f\" % (@batch.rate / @batch.brand.pack_size.to_f))\n ibatches = i.inventory_batches.where(:batch => @batch)\n if ibatches.blank?\n InventoryBatch.create(:inventory => i, :batch => @batch, :units => (@batch.qty.to_i * @batch.brand.pack_size.to_i) + @batch.loose_units.to_i)\n else\n ibatches.first.update(:units => (ibatches.first.units) + (@batch.qty.to_i* @batch.brand.pack_size.to_i) + @batch.loose_units.to_i )\n end\n\n\n redirect_to ramp_up_batches_path, :notice => \"Batch created successfully\"\n else\n redirect_to ramp_up_batches_path, :notice => \"Batch creation failed\"\n end\n #rescue => e\n # redirect_to ramp_up_batches_path, :notice => \"Batch creation failed. #{e.message}\"\n #end\n end", "def process_batch(batch)\n call([], :process_batch, batch.__calls)\n end", "def create_in_batch(events)\n @connection.request(:create_in_batch, {:events => events.map { |e| e.to_send }})\n end", "def update_batch batch\n batch.file_name = @zip_file_name\n batch.arrival_time = Time.now\n batch.facility_id = facility.id\n batch.client_id = facility.client_id\n batch.contracted_time = (Time.now + facility.tat.to_i.hours)\n batch.target_time = (Time.now + facility.tat.to_i.hours)\n batch.date = Date.today if batch.date.blank?\n batch.bank_deposit_date = Date.today if batch.bank_deposit_date.blank?\n batch.correspondence = true if type == 'CORRESP'\n return batch\n end" ]
[ "0.54971373", "0.5490543", "0.5472339", "0.54272944", "0.53963995", "0.5368414", "0.5368102", "0.5344969", "0.5323923", "0.5308458", "0.5262487", "0.5259461", "0.52356464", "0.5234911", "0.5226616", "0.5196725", "0.5195663", "0.5183887", "0.5179823", "0.5136382", "0.5106146", "0.5096696", "0.508141", "0.50710475", "0.50638384", "0.5026878", "0.5006512", "0.4981443", "0.49712986", "0.4958518", "0.49541017", "0.49509707", "0.4944882", "0.49426073", "0.49359542", "0.49347144", "0.49341127", "0.49295914", "0.4923105", "0.4922144", "0.49202484", "0.49162355", "0.48975158", "0.4883162", "0.48714578", "0.48491636", "0.48449567", "0.48119172", "0.48042932", "0.48012534", "0.4790143", "0.47650483", "0.47593236", "0.47399905", "0.47320518", "0.47281012", "0.47252446", "0.47227514", "0.46935093", "0.46908274", "0.46706182", "0.46699977", "0.46696946", "0.46508178", "0.46480528", "0.46410695", "0.46331635", "0.46226054", "0.46218163", "0.46186242", "0.4610654", "0.46087432", "0.460705", "0.46022445", "0.45941344", "0.45851016", "0.4583039", "0.45701763", "0.4556709", "0.45562318", "0.45406884", "0.4539602", "0.45371026", "0.4534614", "0.45257917", "0.45190722", "0.45106283", "0.44945657", "0.44880322", "0.4486541", "0.4484162", "0.447587", "0.44749382", "0.44736844", "0.44702166", "0.44673318", "0.4464422", "0.44527787", "0.4450828", "0.4450205" ]
0.5362797
7
Returns the desired medium
def find_medium(id) self.class.get("/media/#{id}.json?apikey=#{apikey}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def medium\n return @medium\n end", "def medium=(value)\n @medium = value\n end", "def primary_medium\n primary_source_medium = source_media.select{ |sm| sm.main }.compact.first\n primary_source_medium.medium if primary_source_medium\n end", "def medium\n filter << 'Size:Medium'\n self\n end", "def medium\n return Medium.find(medium_id);\nend", "def medium\n @request[:size] = 'medium'\n self\n end", "def set_medium\n @medium = Medium.friendly.find(params[:id])\n end", "def medium_width\n width * medium_height / height\n end", "def cover_medium_url\n images('medium').first[:src]\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def medium_photo\n main_photo.url(:medium)\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def medium\n @speed = MEDIUM\n puts \"#{@location} ceiling fan is on medium\"\n end", "def medium\n @speed = MEDIUM\n puts \"#{@location} ceiling fan is on medium\"\n end", "def display_resource(medium)\n medium.title || \"Medium ##{medium.id}\"\n end", "def type\n Medium.find(self.source.medium_id).media\n end", "def medium_height\n ht = ( SysConf.value_for('logo_medium_height') || 500 ).to_i\n height < ht ? height : ht\n end", "def medium_names\n primary_media | secondary_media | component_media\n end", "def small\n return @small\n end", "def medium\n @chart_size = 'medium'\n self\n end", "def get_size\n\t\t[\"small\", \"medium\", \"large\"].sample\n\tend", "def set_medium_type\n @medium_type = MediumType.find(params[:id])\n end", "def medium_boat?\n self.boat? ? ( boat_size == :medium ) : false\n end", "def confidence_medium?\n @json[:confidence] == 'Medium'\n end", "def set_custom_medium\n @custom_medium = CustomMedium.find(params[:id])\n end", "def create_medium\n return create_resized_pic(MEDIUM_HEIGHT, MEDIUM_WIDTH, SIZE_MEDIUM)\n end", "def mediatype; end", "def resourceType\n 'MedicinalProduct'\n end", "def presentation_unit_type_measure\n packing_material.presentation_unit_type_measure\n end", "def price\n haul == \"Medium\" ? AssignmentParameters.spill_medium : AssignmentParameters.spill_short\n end", "def medium?\n severity == 2\n end", "def detail_material\n mass * material.price_per_kg / 1000\n end", "def medium_image_path\n rails_representation_url(image.variant(resize: '500x500'), only_path: true)\n end", "def medium_image_path\n rails_representation_url(image.variant(resize_to_limit: [500, nil]), only_path: true)\n end", "def medical_use; end", "def show\n @selected_medium = SelectedMedium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @selected_medium }\n end\n end", "def mouth_size(animal)\n return \"small\" if animal == \"alligator\" || animal == \"ALLIGATOR\"\n \"wide\"\nend", "def medium_severity_count\n host_stats[:medium].to_i\n end", "def show\n @medium = Medium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @medium }\n end\n end", "def set_other_medium\n @other_medium = OtherMedium.find(params[:id])\n end", "def medium_image_tag\n image_tag medium_image_path, alt: @picture.alt_text, class: 'medium-image', title: @picture.title\n end", "def show\n @medium = Medium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medium }\n end\n end", "def show\n @medium = Medium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @medium }\n end\n end", "def get_metal_value(metal)\t\n\ts, g, i = get_single_value \n\tif (metal == \"Silver\")\n\t\treturn s\n\telsif (metal == \"Gold\")\n\t\treturn g\n\telsif (metal == \"Iron\")\n\t\treturn i\n\telse\n\t\tretun nil\n\tend\nend", "def media_content_rating_united_kingdom\n return @media_content_rating_united_kingdom\n end", "def short\n quality + number.to_s \n end", "def large_cover\n return @large_cover\n end", "def scoped_medium_types\n [primary_media.prepend('primary'), secondary_media.prepend('secondary'), component_media.prepend('component')]\n end", "def weight_class\n if @weight < 215\n \"Lightweight\"\n elsif @weight < 230\n \"Cruiserweight\"\n elsif @weight < 300\n \"Heavyweight\"\n elsif @weight > 300\n \"Super Heavyweight\"\n else\n \"Heavyweight\"\n end\n end", "def quality\n base.quality\n end", "def media_content_rating_canada\n return @media_content_rating_canada\n end", "def thumbnail_medium_url\n album_cover ? album_cover.photo.photo_url_medium : photos.size > 0 ? photos.first.photo_url_medium : nil\n end", "def show\n @keyword = Keyword.find(params[:id])\n @medium = @keyword.media.first \n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @keyword.to_xml }\n end\n end", "def size\n \n return case \n when pixels <= (16*16)\n :tiny\n when pixels <= (32*32)\n :small\n when pixels <= (64*64)\n :icon\n when pixels <= (4200..6200)\n :default\n when pixels <= (128*128)\n :medium\n when pixels <= (256*256)\n :large\n when pixels <= (512*512)\n :huge\n else\n :silly\n end\n \n end", "def mouth_size(animal)\n animal.downcase == 'alligator' ? 'small' : 'wide'\nend", "def mediatype\n media_type\n end", "def mediatype\n\t\treturn \"%s/%s\" % [ self.type || '*', self.subtype || '*' ]\n\tend", "def getMediumInt\n\t\t\tnum_array = read(3).unpack(\"C*\")\n\t\t\tnum = num_array[0]<< 16 ^ num_array[1]<< 8 ^ num_array[2]\n\t\t\treturn num\n\t\tend", "def medium_tags\n h = {medium_type: scoped_medium_types}\n end", "def mile_setting\n\t\t@setting = Setting.first\n\tend", "def find_case_media\n\t\t@case_medium = CaseMedium.find(params[:id])\n\tend", "def medium_params\n params.require(:medium).permit(:mediable_id, :mediable_type, :url, :kind)\n end", "def large\n @medium = Medium.find(params[:id]) \n respond_to do |format|\n format.html { render :template => 'pictures/large' }# large.rhtml\n end\n end", "def set_solution_medium\n @solution_medium = SolutionMedium.find(params[:id])\n end", "def set_medium_category\n @medium_category = MediumCategory.find(params[:id])\n end", "def find_by_type(medium, *args)\n path = \"medium/#{medium}\"\n Rdigg.fetch(path, @@type, args)\n end", "def set_campaign_medium\n @campaign_medium = CampaignMedium.find(params[:id])\n end", "def presentation_unit_type_measurement\n packing_material.presentation_unit_type_measurement\n end", "def set_artist_medium\n @artist_medium = ArtistMedia.find(params[:id])\n end", "def large\n if image.on_storage?\n variant(1200)\n else\n relevant_assets_cache.select { |item| item.width <= 1200 }.sort_by(&:width).last.url\n end\n end", "def medium_risks\n\t\t\t\t\twhere(:severity => 2).where(:rollup_finding => false)\n\t\t\t\tend", "def update!(**args)\n @medium = args[:medium] if args.key?(:medium)\n end", "def update!(**args)\n @medium = args[:medium] if args.key?(:medium)\n end", "def find_state(medium)\n State.find_by(medium: medium, user: current_user)\n end", "def to_medium(id)\n { medium: {\n recording_id: id,\n media_type: format,\n size: @rf['filesize'],\n encrypted: @rf['encrypted']\n } }\n end", "def imgur_medium(url)\n\t\turl.match(@@picsize_regex) do |match|\n\t\t\t\"http://i.imgur.com/\"+match[1]+\"m\"+\".\"+match[3]\n\t\tend\n\tend", "def resourceType\n 'Medication'\n end", "def mass\n (detail[:area] * material.thickness * material.density / 1000).ceil\n end", "def show\n medium_id = params[:medium_id]\n @medium = nil\n if !medium_id.blank?\n begin\n @medium = Medium.find(medium_id)\n rescue ActiveRecord::RecordNotFound\n @medium = nil\n end\n end\n @place = Place.find(params[:id]) \n @pictures = @place.media(:type => 'Picture').limit(Medium::COLS * Medium::PREVIEW_ROWS)\n @videos = @place.media(:type => 'Video').limit(Medium::COLS * Medium::PREVIEW_ROWS)\n @documents = @place.media(:type => 'Document').limit(Medium::COLS * Medium::PREVIEW_ROWS)\n render_media\n end", "def resourceType\n 'MedicinalProductContraindication'\n end", "def show\n @admin_social_medium = Admin::SocialMedium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_social_medium }\n end\n end", "def read_medium(signed = false, mut = :STD, order = :BIG)\n val = 0\n case order\n when :BIG\n val |= read_byte(signed) << 16\n val |= read_byte(signed) << 8\n val |= read_byte(signed, mut)\n when :MIDDLE\n val |= read_byte(signed) << 8\n val |= read_byte(signed)\n val |= read_byte(signed) << 16\n when :LITTLE\n val |= read_byte(signed, mut)\n val |= read_byte(signed) << 8\n val |= read_byte(signed) << 16\n end\n val\n end", "def magnification\n 1300\n end", "def calculate_size(a_size)\n\tres = 0\n\tif(a_size == \"small\")\n\t\tres = 1\n\telsif(a_size == \"medium\")\n\t\tres = 2\t\n\telsif(a_size == \"large\")\n\t\tres = 3\t\n\tend\n\tres\n end", "def school_mascot_image\n school.mascot_image\n end", "def autosizedRatedHighSpeedSensibleHeatRatio\n\n return self.model.getAutosizedValue(self, 'Design Size Rated High Speed Sensible Heat Ratio', '')\n \n end", "def set_backup_medium\n @backup_medium = BackupMedium.find(params[:id])\n end", "def weight\n return nil if mass.nil?\n mass / 1000.0\n end", "def update\n @medium = Medium.find(params[:id])\n\n respond_to do |format|\n if @medium.update_attributes(params[:medium])\n format.html { redirect_to media_path(:admin => \"snickers\"), notice: 'Medium was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def med\n info 'os10_lldp_interface::med'\n begin\n @lldp_interface_med = @lldp_intf[:'lldp-med-cfg'] || {}\n return @lldp_interface_med[:'med-enable'] || ''\n rescue Exception => e\n err 'Exception in med'\n err e.message\n err e.backtrace[0]\n raise\n end\n end", "def full_size\n @medium = Medium.find(params[:id]) \n respond_to do |format|\n format.html { render :partial => 'pictures/full_size' }# large.rhtml\n end\n end", "def resolution\n if width >= 3800 || height >= 2100 # close to 3860 x 2160\n \"HQ\"\n elsif width >= 1900 || height >= 1000 # close to 1920 x 1080\n \"1080p\"\n elsif width >= 1200 || height >= 700 # close to 1280 x 720\n \"720p\"\n else\n \"SD\"\n end\n end", "def get_preferred_swimmer_level_id\n swimmer_level_type ? swimmer_level_type.id : 0\n end", "def set_accepted_medium\n @accepted_medium = AcceptedMedium.find(params[:id])\n end", "def medium_params\n params.require(:medium).permit(:title, :runtime, :genre, :platform, :director, :cast, :release_date, :critic_rating, :audience_rating, :foreign, :summary, :trailer_link, :movie_link, :rotten_id, :poster_link, :watched, :hassan_rating, :own)\n end" ]
[ "0.84721154", "0.7718283", "0.7604308", "0.7036388", "0.6958076", "0.6820252", "0.67902035", "0.67851937", "0.6578693", "0.65340817", "0.65340817", "0.65340817", "0.653344", "0.6506953", "0.646823", "0.646823", "0.6459873", "0.64381135", "0.64381135", "0.6429245", "0.6358977", "0.6303024", "0.6281923", "0.6196197", "0.61823523", "0.61800647", "0.6157803", "0.6113136", "0.6082078", "0.60756326", "0.60478336", "0.6015757", "0.5973811", "0.5959392", "0.5932901", "0.5930025", "0.5926887", "0.59261465", "0.58966213", "0.5892538", "0.5888399", "0.58532757", "0.5850058", "0.5842746", "0.5831458", "0.5822638", "0.581717", "0.581717", "0.579107", "0.5778587", "0.577603", "0.57703745", "0.5757783", "0.57569927", "0.5753485", "0.57509685", "0.57481855", "0.57348514", "0.57187533", "0.57184994", "0.57040226", "0.5698623", "0.5695699", "0.56946486", "0.5673377", "0.56584454", "0.5654387", "0.56496084", "0.564266", "0.5642138", "0.56381786", "0.5623987", "0.5607376", "0.56066906", "0.5603578", "0.56003773", "0.559537", "0.559537", "0.55934876", "0.5574457", "0.5569704", "0.55593807", "0.5543494", "0.55346686", "0.5532889", "0.552949", "0.5526615", "0.55163366", "0.54966307", "0.5482289", "0.5480186", "0.54589754", "0.54537064", "0.54521304", "0.5447078", "0.5443055", "0.54427546", "0.54353565", "0.5431224", "0.5428666" ]
0.5717418
60
Returns the desired oauth
def find_oauth_by_medium(id) self.class.get("/media/#{id}/oauth.json?apikey=#{apikey}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def auth_oauth\n @attributes[:auth_oauth]\n end", "def oauth_consumer\n @oauth_consumer\n end", "def oauth_authentication; end", "def auth\r\n OAuth2\r\n end", "def find_oauth_access_token\n end", "def oauth?\n type == 'OAuth'\n end", "def oauth_version\n oauth_merged_params[:oauth_version] || \"1.0\"\n end", "def oauth_url\n @oauth_url || File.join(host, \"oauth20/token\")\n end", "def auth_oauth_custom\n @attributes[:auth_oauth_custom]\n end", "def oauth\n login_at(auth_params[:provider])\n end", "def oauth\n login_at(auth_params[:provider])\n end", "def oauth_url\n 'https://geoloqi.com/oauth/authorize'\n end", "def oauth\n if (!@oauth || !@oauth[:token] || !@oauth[:consumer_key]) &&\n @headers['Authorization'].to_s =~ /^OAuth\\s/\n\n @oauth =\n SimpleOAuth::Header.parse(@headers['Authorization']).\n merge(@oauth || {})\n end\n\n @oauth\n end", "def oauth(options = {})\n @oauth ||= ApiFactory.new 'Authorizations', options\n end", "def oauth_url_authorize\n return \"#{$SETTINGS[:oauth_server_url_authorize]}?response_type=code&client_id=#{$SETTINGS[:oauth_client_id]}&scope=ALL&redirect_uri=#{oauth_redirect_uri}\" \n end", "def o_auth_authorization\r\n OAuthAuthorizationController.instance\r\n end", "def oauth\n {\n consumer_key: @consumer_key,\n consumer_secret: @consumer_secret,\n token: @token,\n token_secret: @token_secret\n }\n end", "def oauth_token\n @json['oauthToken']\n end", "def get_user_auth_url\n @oauth_token = request_oauth_token\n return @authorize_url + \"?oauth_token=\" + @oauth_token[\"oauth_token\"]\n rescue\n puts $! if @@verbose\n return nil\n end", "def oauth\n Auth.new(params[:uid], params[:oauth_token], action_name)\n end", "def oauth_token\n read_attribute(oauth_token_field)\n end", "def use_oauth\n\t\t\t\n\t\tend", "def openid_oauth(value = nil)\n rw_config(:openid_oauth, value, false)\n end", "def using_oauth?\n oauth_request? || oauth_response? || stored_oauth_token_and_secret?\n end", "def oauth?; stripe_account_type == 'oauth'; end", "def oauth_instance name = nil\n oauth = Rack::OAuth.get(oauth_request_env, nil)\n raise \"Couldn't find Rack::OAuth instance with name #{ name }\" unless oauth\n oauth\n end", "def token\n oauth_merged_params[:oauth_token]\n end", "def oauth_url(response_type = 'code')\n # The Redirect URI must be the same as registered with Put.io\n PUTIO_BASE_URL + \"/oauth2/authenticate?client_id=%i&response_type=%s&redirect_uri=%s\" % [@client_id, response_type, @redirect_uri]\n end", "def oauth_instance name = nil\n oauth = Rack::OAuth.get(oauth_request_env, nil)\n raise \"Couldn't find Rack::OAuth instance with name #{ name }\" unless oauth\n oauth\n end", "def oauth?\n oauth_consumer_key && oauth_consumer_secret\n end", "def rack_oauth!(name)\n oauth_instance(name).get_access_token!(oauth_request_env)\n end", "def oauth_callback_url\n end", "def oauth #:nodoc:\n @oauth ||= Bountybase.config.twitter[Bountybase.instance] ||\n begin\n E \"Cannot find twitter configuration for\", Bountybase.instance\n raise \"Cannot find twitter configuration\"\n end\n end", "def get_oauth_url\n params = {}\n url = @url\n\n if url.include?(\"?\")\n parsed_url = URI::parse(url)\n CGI::parse(parsed_url.query).each do |key, value|\n params[key] = value[0]\n end\n params = Hash[params.sort]\n\n url = parsed_url.to_s.gsub(/\\?.*/, \"\")\n end\n\n nonce_lifetime = 15 * 60 # Woocommerce keeps nonces for 15 minutes\n\n params[\"oauth_consumer_key\"] = @consumer_key\n params[\"oauth_nonce\"] = Digest::SHA1.hexdigest((Time.new.to_f % nonce_lifetime + (Process.pid * nonce_lifetime)).to_s)\n params[\"oauth_signature_method\"] = @signature_method\n params[\"oauth_timestamp\"] = Time.new.to_i\n params[\"oauth_signature\"] = CGI::escape(generate_oauth_signature(params, url))\n\n query_string = URI.encode_www_form(params)\n\n \"#{url}?#{query_string}\"\n end", "def oauth_options\n {\n consumer_key: client_id,\n consumer_secret: client_secret,\n token: access_token,\n token_secret: access_token_secret\n }\n end", "def oauth_token\n @oauth_token ||= begin\n # Bearer tokens according to http://tools.ietf.org/html/draft-ietf-oauth-v2-bearer-03\n authorization_header = request.env['HTTP_AUTHORIZATION']\n if authorization_header =~ /^\\s*Bearer\\s+(.*)/\n token_string = $1\n else\n token_string = params[:oauth_token]\n token_string ||= params[:access_token] # Legacy parameter\n end\n if token_string\n token = Token.where(:access_token => token_string).\n all(:include => :user).first\n if token.nil? or token.expired?\n logger.error(\"Invalid OAuth token\")\n headers['WWW-Authenticate'] = %(Bearer error=\"invalid_token\")\n halt 403, 'Invalid OAuth token'\n end\n token\n end\n end\n end", "def oauth_params\n @oauth_params ||= request.env[\"omniauth.auth\"]\n end", "def url\n File.join(DigitalRiver.config.oauth_url)\n end", "def oauth_url\n url = <<-URL\n https://www.facebook.com/dialog/oauth/\n ?client_id=#{Network::Facebook.app_id}\n &redirect_uri=#{URI.escape(\"#{root_url}auth/facebook/?r=#{redirect_for(request.referer)}\")}\n &scope=#{Network::Facebook.scope}\n URL\n url.gsub(/\\s+/, '')\n end", "def current_user_with_oauth\n current_user_without_oauth || current_oauth_user\n end", "def oauth\n teapot_q\n end", "def url\n File.join(DigitalRiver.config.oauth_url)\n end", "def oauth2callback\n @g_cal_api.oauth2callback\n end", "def oauth\n ::OAuth::Consumer.new(Config.consumer_key, Config.consumer_secret, :site => \"https://api.twitter.com\")\n end", "def oauth_uri(provider=\"FACEBOOK\")\n dest= session[\"return_to\"] || request.env[\"REQUEST_URI\"] || \"/\"\n \"#{oauth_uri_left_part}/account/oauth_start?provider=#{CGI.escape(provider)}&dest_left=#{CGI.escape(request_uri_left_part)}&dest_path=#{CGI.escape(dest)}\"\n end", "def authenticating_with_oauth?\n correct_request_class? && using_oauth?\n end", "def parse_oauth_options\n {\n :request_token_url => full_oauth_url_for(:request_token, :api_host),\n :access_token_url => full_oauth_url_for(:access_token, :api_host),\n :authorize_url => full_oauth_url_for(:authorize, :auth_host),\n :site => @consumer_options[:site] || @consumer_options[:api_host] || DEFAULT_OAUTH_OPTIONS[:api_host]\n }\n end", "def consumer_key\n oauth_merged_params[:oauth_consumer_key]\n end", "def oauth\n request_token = @oauth_consumer.get_request_token\n authorize_url = request_token.authorize_url(:oauth_consumer_key => \n Netflix::Client.consumer_key)\n Launchy.open(authorize_url)\n puts \"Go to browser, a page has been opened to establish oauth\"\n printf \"Pin from Netflix:\"\n pin = gets.chomp\n access_token = request_token.get_access_token(:oauth_verifier => pin)\n end", "def oauth_client\n if @oauth_client\n @oauth_client\n else\n conn ||= Faraday::Connection.new \\\n :url => \"https://api.gowalla.com\",\n :headers => default_headers\n\n oauth= OAuth2::Client.new(api_key, api_secret, oauth_options = {\n :site => 'https://api.gowalla.com',\n :authorize_url => 'https://gowalla.com/api/oauth/new',\n :access_token_url => 'https://gowalla.com/api/oauth/token'\n })\n oauth.connection = conn\n oauth\n end\n end", "def config\n Simple::OAuth2.config\n end", "def signin\n oauth_authorize\n end", "def provider_type\n provider.to_s.gsub(\"oauth2\", \"\").try(:titleize)\n end", "def auth_scheme; end", "def oauth_hash\n {\n :consumer_key => consumer_key || Bountybase.config.twitter_app[\"consumer_key\"],\n :consumer_secret => consumer_secret || Bountybase.config.twitter_app[\"consumer_secret\"],\n :oauth_token => oauth_token,\n :oauth_token_secret => oauth_secret\n }\n end", "def oauth\n session[:return_to_url] = params[:redirect_after_login] if params[:redirect_after_login]\n login_at(auth_params[:provider])\n end", "def provider\n authorization.provider\n end", "def auth_settings\n {\n 'auth' =>\n {\n type: 'oauth2',\n in: 'header',\n key: 'Authorization',\n value: \"Bearer #{access_token}\"\n },\n }\n end", "def oauth_token_secret\n @json['oauthTokenSecret']\n end", "def authorization_url\n uri = URI(OAUTH_URL)\n uri.query = {\n client_id: client_id,\n redirect_uri: redirect_uri,\n scope: scope_url,\n response_type: 'code',\n access_type: 'offline'\n }.to_param\n\n uri.to_s\n end", "def authenticate!(type = :portal)\n load_consumer_config(type) if oauth_consumer.nil?\n\n @oauth_request = oauth_consumer.get_request_token\n @oauth_authorize_url = oauth_request.authorize_url\n\n @oauth_consumer.instance_eval do\n # The token request reponse is scoped only in the token_request method, but I need to get access to the response\n # headers so that I can pull back the Content-Location header and get the authenticated user URI\n def token_request(http_method, path, token = nil, request_options = {}, *arguments)\n @tr_response = request(http_method, path, token, request_options, *arguments)\n case @tr_response.code.to_i\n\n when (200..299)\n if block_given?\n yield @tr_response.body\n else\n # symbolize keys\n # TODO this could be considered unexpected behavior; symbols or not?\n # TODO this also drops subsequent values from multi-valued keys\n CGI.parse(@tr_response.body).inject({}) do |h,(k,v)|\n h[k.strip.to_sym] = v.first\n h[k.strip] = v.first\n h\n end\n end\n when (300..399)\n # this is a redirect\n @tr_response.error!\n when (400..499)\n raise OAuth::Unauthorized, @tr_response\n else\n @tr_response.error!\n end\n end\n \n # The HTTP response from token_request\n def token_request_response\n @tr_response\n end\n end\n \n oauth_authorize_url\n end", "def oauth_login oauth\n method = ::AuthMethod.by_provider_data oauth.provider_data\n\n if !method\n user = find_by_email(oauth.email) || create_from_oauth(oauth)\n\n if user.respond_to? :add_auth_method\n method = user.add_auth_method oauth.provider_data\n else\n method = user.auth_methods.create! oauth.provider_data\n end\n end\n\n method.create_token access_token: oauth.access_token\n end", "def oauth_access_token\n session[:access_token]\n end", "def oauth_client\n @oauth_client ||= OAuth2::Client.new @app_key, @app_secret, site: @workxp_site do |stack|\n stack.request :multipart\n stack.request :url_encoded\n stack.adapter :net_http\n end\n end", "def authorize_request\n if basic_auth.values.all?\n [:basic_auth, @username, @password]\n else\n [:desk_oauth, oauth]\n end\n end", "def oauth_required\n head oauth.no_access! unless oauth.authenticated?\n end", "def oauth_auth_header(method, uri, params = {})\n if !authenticated?\n auth = 'Basic ' + [@api_key + ':' + @api_secret].pack('m').chomp(\"\\n\")\n else\n auth = 'Bearer ' + @access_token\n end\n auth\n end", "def get_access_token name = nil\n oauth_instance(name).get_access_token(oauth_request_env)\n end", "def get_authorization_url\n client = Octokit::Client.new\n client.authorize_url(CLIENT_ID, scope: 'public_repo read:org')\n end", "def get_consumer\n OAuth::Consumer.new(ENV[\"EVERNOTE_CONSUMER_KEY\"], ENV[\"EVERNOTE_SECRET\"], {\n :site => ENV[\"EVERNOTE_URL\"],\n :request_token_path => \"/oauth\",\n :access_token_path => \"/oauth\",\n :authorize_path => \"/OAuth.action\"\n })\n end", "def get_access_token\n @oauth_access_token = oauth_request.get_access_token\n @authenticated_user_uri = oauth_consumer.token_request_response[\"Content-Location\"]\n end", "def oauth_response?\n !oauth_response.nil? && auth_session? && auth_session[:auth_request_class] == self.class.name && auth_session[:auth_method] == \"oauth\"\n end", "def authorization_url\n\t\t@client ||= api_client()\n\t\[email protected]_uri.to_s\n\tend", "def access_token\n @access_token ||= begin\n if oauth_options[:oauth_verifier]\n request_token.get_access_token(:oauth_verifier => oauth_options[:oauth_verifier])\n else\n request_token.get_access_token\n end\n end\n end", "def oauth_callback_url\n url_for :action => \"list\"\n end", "def oauth_provider_humanized\n case provider\n when 'google' then 'Google'\n when 'github' then 'GitHub'\n end\n end", "def twitter\n \toauth.authorize_from_access(oauth_token, oauth_secret)\n\t @twitter ||= Twitter::Base.new(oauth)\n end", "def authorization_mode; end", "def oauth!(key = :consumer_key, token = :token, secret = :token_secret, consumer_secret = :consumer_secret)\n @authenticates = :oauth\n @credentials = [key, token, secret, consumer_secret]\n end", "def use_oauth_for_url?(url)\n Tim::ImageFactory::Base.use_oauth? and\n url.include?(Tim::ImageFactory::Base.config[:site])\n end", "def authorized_twitter\n oauth = Twitter::OAuth.new($configure[:twitter][:ctoken], $configure[:twitter][:csecret])\n # Request OAuth authentication if there are no access token yet\n unless($configure[:twitter][:atoken] && $configure[:twitter][:asecret])\n rtoken = oauth.request_token\n puts \"Open next url, authorize this application: #{rtoken.authorize_url}\"\n puts \"Then, enter PIN code:\"\n pin = STDIN.gets.chomp\n # Authrize request token using PIN code (this is required for an application which type is \"Client\")\n atoken = OAuth::RequestToken.new(oauth.consumer, rtoken.token, rtoken.secret).get_access_token(:oauth_verifier => pin)\n # Save access token\n $configure[:twitter][:atoken] = atoken.token\n $configure[:twitter][:asecret] = atoken.secret\n end\n oauth.authorize_from_access($configure[:twitter][:atoken], $configure[:twitter][:asecret])\n # Create Twitter client instance with OAuth\n Twitter::Base.new(oauth)\nend", "def get_authurl\n\t\tlogger.debug \"D, #{__method__.to_s}\"\n\t\tparams = {\n \"client_id\" => @client_id,\n \"response_type\" => \"code\",\n \"redirect_uri\" => @redirect_uri,\n \"prompt\" => \"consent\"\n }\n auth_uri = URI::Generic.new(\"https\", nil, @auth_url, nil, nil, \"authorize\", \n \t\t\t\t\t\t\t nil, nil, nil)\n auth_uri.query = URI.encode_www_form(params)\n logger.debug \"D, #{__method__.to_s}, #{auth_uri.to_s}\"\n return auth_uri.to_s\n\tend", "def connection_for_application\n oauth_client.client_credentials.get_token\n end", "def oauth_data\n {\n consumer_key: CONSUMER_KEY,\n consumer_secret: CONSUMER_SECRET,\n token: session[:token],\n token_secret: session[:secret],\n realm_id: session[:realm_id]\n }\n end", "def authorize_url\n request_token.authorize_url\n end", "def token_url\n \"#{sk_url}/oauth/token\"\n end", "def access_token\n OAuth::AccessToken.new(consumer, oauth_token, oauth_token_secret)\n end", "def oauth_with(&blk)\n @oauth_with = blk if blk\n @oauth_with\n end", "def oauth_redirect_uri\n uri = URI.parse(request.url)\n uri.path = '/sk_auth/callback'\n uri.query = nil\n uri.to_s\n end", "def get_authorize_url\n return get_request_token.authorize_url\n end", "def http_auth?; end", "def oauth_handshake\r\n request_proxy = OAuth::RequestProxy.proxy request\r\n\r\n if request_proxy.signature.present?\r\n if request_proxy.token.present?\r\n oauth_required\r\n # 3-legged. Authorized user is current_token.user...\r\n else\r\n verify_oauth_consumer_signature\r\n # 2-legged. Authorized current_client_application?\r\n if @current_client_application\r\n @allow_private_access = @current_client_application.allow_private_access?\r\n @allow_write_access = @current_client_application.allow_write_access?\r\n end\r\n end\r\n elsif request_proxy.consumer_key.present?\r\n if @current_client_application = ClientApplication.\r\n find_by_key(request_proxy.consumer_key)\r\n # 1-legged. For JavaScript widgetry.\r\n @allow_private_access = false\r\n else\r\n invalid_oauth_response :unauthorized, \"Using Invalid Consumer Key\"\r\n false\r\n end\r\n else\r\n invalid_oauth_response :bad_request, \"Missing Required Consumer Key\"\r\n false\r\n end\r\n end", "def get_token (params)\n client = OAuth2::Client.new(params[:APP_ID], params[:APP_SECRET], :site => params[:OAUTH_URL])\n\n begin\n token = client.password.get_token(params[:USER_EMAIL], params[:USER_PASSWD], :scope => params[:SCOPE]).token\n rescue => e\n puts \"Error: Can't get oauth token, check credentials for '#{params[:NAME]}'\"\n puts \"#{e.message}\"\n abort \"Aborting script\"\n end\n return token\nend", "def get_request_token( oauth_callback = TWOAUTH_CALLBACK )\n\t\tself.consumer.get_request_token( :oauth_callback => oauth_callback )\n\tend", "def oauth\n redirect_to \"#{root_path}auth/#{Setting['omniauth']['provider']}\"\n end", "def build_auth_url\n URI.parse(\"https://www.dropbox.com/oauth2/authorize\").tap do |uri|\n uri.query = URI.encode_www_form(\n client_id: DROPBOX_APP_KEY,\n redirect_uri: SHOTTY_CALLBACK_URL,\n response_type: :code,\n state: csrf_token,\n )\n end\nend", "def oauth\n if params[:code]\n token_response = get_user_tokens(params[:code])\n signup_or_login(token_response)\n end\n\n render json: params\n end", "def add_oauth(req, consumer, atok, asec)\r\n access_token = OAuth::AccessToken.new(consumer, atok, asec)\r\n consumer.sign!(req, access_token)\r\nend", "def oauth_instance(name)\n instance = Rack::OAuth.get(oauth_request_env, name)\n if instance.nil?\n raise Rack::OAuthError, \"Couldn't find Rack::OAuth instance with name #{name}\"\n end\n instance\n end", "def request_oauth_token\n request_token_hash = {\n \"oauth_consumer_key\" => \"#{@consumer_key}\",\n \"oauth_signature_method\" => \"HMAC-SHA1\",\n \"oauth_timestamp\" => timestamp,\n \"oauth_nonce\" => nonce,\n \"oauth_version\" => \"1.0\",\n \"oauth_callback\" => \"oob\",\n }\n\n # set signature\n request_token_hash[\"oauth_signature\"] = generate_oauth_signature(generate_signature_base_string(\"POST\", @request_token_url, request_token_hash))\n\n # post with auth header\n result = MyHttp.post(@request_token_url, nil, {\n \"Authorization\" => \"OAuth #{generate_auth_header(request_token_hash)}\",\n })\n\n auth_token_string = result.body.strip\n if result.is_a? Net::HTTPSuccess\n return string_param_to_hash(auth_token_string)\n else\n status = result.code\n return nil\n end\n end", "def scim_oauth_access_token\n @attributes[:scim_oauth_access_token]\n end" ]
[ "0.81503874", "0.77859336", "0.77722704", "0.7691317", "0.7483402", "0.7400398", "0.734623", "0.73410296", "0.72678876", "0.7202432", "0.7202432", "0.7197423", "0.71471417", "0.7140177", "0.7138968", "0.71261394", "0.7121639", "0.7121254", "0.70985574", "0.70602036", "0.7033743", "0.70308226", "0.70174795", "0.69886875", "0.6976329", "0.691687", "0.68894553", "0.68507445", "0.68425614", "0.6840778", "0.6817599", "0.68084896", "0.67978287", "0.67898977", "0.67798066", "0.67655575", "0.67595303", "0.6749702", "0.6738074", "0.67356724", "0.67298144", "0.67067564", "0.6684991", "0.66600937", "0.66591245", "0.66349465", "0.6630935", "0.66210055", "0.6620122", "0.6601224", "0.65894926", "0.6584923", "0.6531897", "0.6516574", "0.6515763", "0.6513392", "0.6497179", "0.6449701", "0.64329743", "0.64298135", "0.6428618", "0.64183253", "0.64073455", "0.63809", "0.6367365", "0.6347213", "0.6332958", "0.6320432", "0.6317967", "0.6315547", "0.6313686", "0.63109297", "0.63083273", "0.6302794", "0.6298175", "0.6283026", "0.62829655", "0.62782294", "0.6271245", "0.62710726", "0.6267916", "0.6267395", "0.62574476", "0.6255228", "0.62447464", "0.62382585", "0.62333727", "0.6216731", "0.6216425", "0.6212349", "0.620943", "0.6208697", "0.620671", "0.6205602", "0.62023276", "0.6197422", "0.61968476", "0.6196148", "0.6191511", "0.6191456", "0.6190408" ]
0.0
-1
Returns the oauthcallbacks related to the medium
def find_oauth_callback_by_medium(*args) raise ArgumentError.new('The method `find_oauth_callback_by_medium` requires 2 arguments(medium-id and oauth-token)') if args.size != 2 self.class.get("/media/#{args[0]}/oauth_callback.json?apikey=#{apikey}", :query => {:oauth_verifier => args[-1]}) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def oauth_consumer\n @oauth_consumer\n end", "def oauth_authentication; end", "def oauth2callback\n @g_cal_api.oauth2callback\n end", "def oauth_callback_url\n end", "def o_auth_authorization\r\n OAuthAuthorizationController.instance\r\n end", "def find_oauth_access_token\n end", "def oauth_callback_url\n url_for :action => \"list\"\n end", "def oauth2_permission_scopes\n return @oauth2_permission_scopes\n end", "def find_oauth_by_medium(id)\n self.class.get(\"/media/#{id}/oauth.json?apikey=#{apikey}\")\n end", "def oauth\n {\n consumer_key: @consumer_key,\n consumer_secret: @consumer_secret,\n token: @token,\n token_secret: @token_secret\n }\n end", "def get_callbacks(callback_type)\n Array(options[callback_type])\n end", "def callbacks\n @callbacks ||= {}\n end", "def facebook\n handle_oauth\n end", "def exchange_oauth_tokens\n end", "def auth_oauth\n @attributes[:auth_oauth]\n end", "def get_consumer\n ::OAuth::Consumer.new(@key, @secret, @configuration)\n end", "def oauth_data\n {\n consumer_key: CONSUMER_KEY,\n consumer_secret: CONSUMER_SECRET,\n token: session[:token],\n token_secret: session[:secret],\n realm_id: session[:realm_id]\n }\n end", "def request_callbacks\n @request_callbacks ||= []\n end", "def oauth_hash\n {\n :consumer_key => consumer_key || Bountybase.config.twitter_app[\"consumer_key\"],\n :consumer_secret => consumer_secret || Bountybase.config.twitter_app[\"consumer_secret\"],\n :oauth_token => oauth_token,\n :oauth_token_secret => oauth_secret\n }\n end", "def oauth_options\n {\n consumer_key: client_id,\n consumer_secret: client_secret,\n token: access_token,\n token_secret: access_token_secret\n }\n end", "def callback\n self.oaw_callback(params[:oauth_verifier], params[:oauth_token])\n end", "def google\n process_oauth_callback\n end", "def callbacks\n callbacks = @callbacks || []\n callbacks |= superclass.callbacks if superclass.respond_to?(:callbacks)\n return callbacks\n end", "def oauth_services(user = nil)\n @oauth_services ||= OAUTH_CREDENTIALS.keys-oauth_consumer_tokens(user).collect{ |c| c.class.service_name }\n end", "def auth\r\n OAuth2\r\n end", "def oauth_consumer_tokens(user)\n if user.blank?\n @all_oauth_consumer_tokens ||= ConsumerToken.all\n else\n @oauth_consumer_tokens ||= ConsumerToken.all(:conditions => { :user_id => user.id })\n end\n end", "def oauth_data\n {\n consumer_key: @consumer_key,\n consumer_secret: @consumer_secret,\n token: @token,\n token_secret: @token_secret\n }\n end", "def scopes_for(token)\n token = token.github_oauth_token if token.respond_to? :github_oauth_token\n scopes = GH.with(token: token.to_s) { GH.head('user') }.headers['x-oauth-scopes'] if token.present?\n scopes &&= scopes.gsub(/\\s/,'').split(',')\n Array(scopes).sort\n rescue GH::Error\n []\n end", "def get_linkedin_consumer(permission_type = 3)\n \n case permission_type\n when 1 # Full profile WITH connections\n configuration = { :site => 'https://api.linkedin.com',\n :authorize_path => '/uas/oauth/authenticate',\n :request_token_path => '/uas/oauth/requestToken?scope=r_fullprofile+r_emailaddress+r_network+r_contactinfo+rw_groups',\n :access_token_path => '/uas/oauth/accessToken' }\n \n when 2 # Full profile WITHOUT connections\n configuration = { :site => 'https://api.linkedin.com',\n :authorize_path => '/uas/oauth/authenticate',\n :request_token_path => '/uas/oauth/requestToken?scope=r_fullprofile+r_emailaddress+r_contactinfo+rw_groups',\n :access_token_path => '/uas/oauth/accessToken' }\n \n when 3 # GROUPS (with Full profile)\n configuration = { :site => 'https://api.linkedin.com',\n :authorize_path => '/uas/oauth/authenticate',\n :request_token_path => '/uas/oauth/requestToken?scope=r_fullprofile+r_emailaddress+r_contactinfo+rw_groups+rw_nus',\n :access_token_path => '/uas/oauth/accessToken' }\n end\n \n OAuth::Consumer.new(LINKEDIN_API_KEY, LINKEDIN_API_SECRET, configuration)\n \n end", "def oauth_token\n @json['oauthToken']\n end", "def consumer\n @consumer ||= OAuth::ConsumerWithHyvesExtension.new(key, secret, oauth_options)\n end", "def config\n Simple::OAuth2.config\n end", "def oauth\n teapot_q\n end", "def use_oauth\n\t\t\t\n\t\tend", "def oauth_params\n @oauth_params ||= request.env[\"omniauth.auth\"]\n end", "def oauth\n ::OAuth::Consumer.new(Config.consumer_key, Config.consumer_secret, :site => \"https://api.twitter.com\")\n end", "def oauth\n if (!@oauth || !@oauth[:token] || !@oauth[:consumer_key]) &&\n @headers['Authorization'].to_s =~ /^OAuth\\s/\n\n @oauth =\n SimpleOAuth::Header.parse(@headers['Authorization']).\n merge(@oauth || {})\n end\n\n @oauth\n end", "def connection_handlers\n @connection_handlers ||= [\n proc do |conn|\n conn.request :json\n if @oauth2\n conn.request :oauth2, @oauth2.token, :token_type => @oauth2.token_type\n end\n end,\n proc do |conn|\n if @logging\n conn.response :logger, nil, :bodies => (@logging.casecmp('DEBUG') == 0)\n end\n conn.response :json, :content_type => /\\bjson$/\n end,\n proc{|conn| conn.adapter Faraday.default_adapter }\n ]\n end", "def authorize_scopes\n @authorize_scopes ||= (env['omniauth.params']['scope'] || authorize_params['scope']).split(' ')\n end", "def oauth_client\n if @oauth_client\n @oauth_client\n else\n conn ||= Faraday::Connection.new \\\n :url => \"https://api.gowalla.com\",\n :headers => default_headers\n\n oauth= OAuth2::Client.new(api_key, api_secret, oauth_options = {\n :site => 'https://api.gowalla.com',\n :authorize_url => 'https://gowalla.com/api/oauth/new',\n :access_token_url => 'https://gowalla.com/api/oauth/token'\n })\n oauth.connection = conn\n oauth\n end\n end", "def get_consumer\n OAuth::Consumer.new(ENV[\"EVERNOTE_CONSUMER_KEY\"], ENV[\"EVERNOTE_SECRET\"], {\n :site => ENV[\"EVERNOTE_URL\"],\n :request_token_path => \"/oauth\",\n :access_token_path => \"/oauth\",\n :authorize_path => \"/OAuth.action\"\n })\n end", "def get_callbacks( channel )\n cbs = Array.new\n # First, fetch all the channel-specific callbacks...\n cbs.concat(@channels[channel]) if @channels.has_key? channel\n # ...then fetch the callbacks the channel matches\n cbs.concat(get_wildcard_callbacks(channel))\n cbs\n end", "def oauth\n login_at(auth_params[:provider])\n end", "def oauth\n login_at(auth_params[:provider])\n end", "def connection_handlers\n @connection_handlers ||= [\n proc do |conn|\n conn.request :json\n if @oauth2\n conn.request :oauth2, @oauth2.token, :token_type => @oauth2.token_type\n end\n end,\n proc do |conn|\n if @logging\n conn.response :logger, nil, :bodies => (@logging.casecmp('DEBUG') == 0)\n end\n conn.response :json, :content_type => /\\bjson$/\n end,\n proc{|conn| conn.adapter Faraday.default_adapter }\n ]\n end", "def get_callbacks\n {\n :config => Proc.new { |c| call_config(c) },\n :machine => Proc.new { |m| call_machine(m) },\n }\nend", "def get_request_token( oauth_callback = TWOAUTH_CALLBACK )\n\t\tself.consumer.get_request_token( :oauth_callback => oauth_callback )\n\tend", "def auth_policies\n []\n end", "def oauth_client\n @oauth_client ||= OAuth2::Client.new @app_key, @app_secret, site: @workxp_site do |stack|\n stack.request :multipart\n stack.request :url_encoded\n stack.adapter :net_http\n end\n end", "def oauth_with(&blk)\n @oauth_with = blk if blk\n @oauth_with\n end", "def github\n process_oauth_callback\n end", "def get_consumer\n ::OAuth::Consumer.new(@key, @secret, @configuration)\n end", "def oauth_token\n read_attribute(oauth_token_field)\n end", "def consumer_key\n oauth_merged_params[:oauth_consumer_key]\n end", "def consumer\n @consumer ||= begin\n options = {\n :site => \"https://www.google.com\",\n :request_token_path => \"/accounts/OAuthGetRequestToken\",\n :access_token_path => \"/accounts/OAuthGetAccessToken\",\n :authorize_path=> \"/accounts/OAuthAuthorizeToken\"\n }\n \n OAuth::Consumer.new('lfmp.heroku.com', 'EqH7lROs9KwfSU3QnFpkd8tX', options)\n end\n end", "def consumer\n OAuth::Consumer.new(consumer_key, consumer_secret, :site => endpoint)\n end", "def api_connectors\n return @api_connectors\n end", "def connection_for_application\n oauth_client.client_credentials.get_token\n end", "def list_callbacks(opts = {})\n data, _status_code, _headers = list_callbacks_with_http_info(opts)\n data\n end", "def get_access\n path = '/v3/oauth/authorize'\n data = \"consumer_key=#{Consumer_key}&code=#{Token}\"\n return pocket_api(path,data)\nend", "def oauth2_authenticatable(routes, mapping)\n \n database_authenticatable(routes, mapping)\n routes.oauth_callback ::Devise.oauth2_callback_path, :controller => 'sessions', :action => 'oauth_callback'\n end", "def scopes\n @scopes ||= config[:scopes] || []\n end", "def policy_scopes; end", "def get_request_token(consumer, callback)\n request_token = consumer.get_request_token({\n :scope => 'http://orkut.gmodules.com/social/rest',\n :oauth_callback => callback},\n :scope => 'http://orkut.gmodules.com/social')\n end", "def oauth_callback\n at = Marshal.load(session[:qb_request_token]).get_access_token(:oauth_verifier => params[:oauth_verifier])\n \n #There can only be one...\n Qbo.destroy_all\n\n # Save the authentication information \n qbo = Qbo.new\n qbo.qb_token = at.token\n qbo.qb_secret = at.secret\n qbo.token_expires_at = 6.months.from_now.utc\n qbo.reconnect_token_at = 5.months.from_now.utc\n qbo.company_id = params['realmId']\n if qbo.save!\n redirect_to qbo_sync_path, :flash => { :notice => \"Successfully connected to Quickbooks\" }\n else\n redirect_to plugin_settings_path(:redmine_qbo), :flash => { :error => \"Error\" }\n end\n end", "def find_by_oauth2_method\n self.class.find_by_oauth2_method\n end", "def oauth(options = {})\n @oauth ||= ApiFactory.new 'Authorizations', options\n end", "def signin\n oauth_authorize\n end", "def oauth_headers\n @oauth_headers ||= parse_oauth_headers\n end", "def parse_oauth_options\n {\n :request_token_url => full_oauth_url_for(:request_token, :api_host),\n :access_token_url => full_oauth_url_for(:access_token, :api_host),\n :authorize_url => full_oauth_url_for(:authorize, :auth_host),\n :site => @consumer_options[:site] || @consumer_options[:api_host] || DEFAULT_OAUTH_OPTIONS[:api_host]\n }\n end", "def oauth_callback(params)\n update! psp_credentials: payment_provider.get_access_token(params)\n end", "def oauth?\n type == 'OAuth'\n end", "def oauth_authorize\n redirect_to facebook_client.authorize(oauth_callback_url)\n end", "def oauth_url_authorize\n return \"#{$SETTINGS[:oauth_server_url_authorize]}?response_type=code&client_id=#{$SETTINGS[:oauth_client_id]}&scope=ALL&redirect_uri=#{oauth_redirect_uri}\" \n end", "def callback_url\n auth_endpoint_callback_url(org: @organization.id)\n end", "def consumer\n @consumer ||= OAuth::Consumer.new(\n config[:consumer_key],\n config[:consumer_secret],\n :site => base_url\n )\n end", "def oauth2_controller\n is_auth_session? ? controller : session_class.controller\n end", "def twitter\n handle_oauth\n end", "def index\n presenters = ProviderOAuthFlowPresenter.wrap(self_authentication_providers, request, request.host)\n respond_with(presenters)\n end", "def index\n presenters = OAuthFlowPresenter.wrap(authentication_providers, request)\n respond_with(presenters)\n end", "def access_token\n OAuth::AccessToken.new(consumer, oauth_token, oauth_token_secret)\n end", "def get_tokens\n\t\tresource = \"/oauth/access_token\"\n\t\t\n\t\tbegin\n\t\t\tresponse = @connection.post resource do |request|\n\t\t\t\trequest.params['client_id'] = @api_key\n\t\t\t\trequest.params['client_secret'] = @secret_key\n\t\t\t\trequest.params['grant_type'] = @grant_type\n\t\t\t\trequest.params['scope'] = @scope\n\t\t\tend\n\t\t\t\n\t\t\tresult = process_response(response)\n\t\t\t\n\t\t\tif result[:access_token].nil? || result[:refresh_token].nil?\n\t\t\t\traise RuntimeError, \"Unable to complete oauth: #{response[:error]}\"\n\t\t\telse \n\t\t\t\t@access_token = result[:access_token]\n\t\t\t\t@refresh_token = result[:refresh_token]\n\t\t\tend\n\t\trescue => e\n\t\t\traise RuntimeError, e.to_s\n\t\tend\n\tend", "def token\n oauth_merged_params[:oauth_token]\n end", "def get_auth_tokens(code)\n oauth_client = TwitchOAuth2::Client.new(\n client_id: 'YOUR_CLIENT_ID',\n client_secret: 'YOUR_CLIENT_SECRET',\n scopes: [\"channel:manage:broadcast\"]\n )\n\n puts oauth_client.token(token_type: :user, code: code)\nend", "def consumer\n @consumer ||= OAuth::Consumer.new(\n @consumer_key,\n @consumer_secret,\n { :site=> self.class.site }\n )\n end", "def scopes\n self.class.scopes\n end", "def authorize_url\n polymorphic_url([ @workspace, :twitter_account ], :action => 'authorize')\n end", "def callbacks_for(type)\n if superclass.respond_to?(:callbacks_for)\n matching_callbacks = superclass.callbacks_for(type)\n else\n matching_callbacks = []\n end\n matching_callbacks += callbacks[type.to_sym] if callbacks[type.to_sym]\n matching_callbacks\n end", "def get_oauth_clients(opts = {})\n data, _status_code, _headers = get_oauth_clients_with_http_info(opts)\n return data\n end", "def well_known\n render json: {\n authorization_endpoint: \"#{root_url}oauth/authorize\",\n token_endpoint: \"#{root_url}oauth/token\",\n introspection_endpoint: \"#{root_url}oauth/introspect\",\n revocation_endpoint: \"#{root_url}oauth/revoke\",\n scopes_supported: ['user/*.read', 'user/*.write', 'user/*.*'],\n capabilities: ['launch-standalone']\n }\n end", "def oauth #:nodoc:\n @oauth ||= Bountybase.config.twitter[Bountybase.instance] ||\n begin\n E \"Cannot find twitter configuration for\", Bountybase.instance\n raise \"Cannot find twitter configuration\"\n end\n end", "def pull_profiles\n \tprofiles_from_api = self.client.profiles\n\t\tprofiles_array = []\n\t\tprofiles_from_api.each do |p|\n\t\t\tif p.service == \"twitter\"\n\t\t\t\tprofiles_array << p\n\t\t\tend\n\t\tend\n\t\tprofiles_array\n end", "def get_authorize_url\n return get_request_token.authorize_url\n end", "def consumer\n @consumer ||= ::OAuth::Consumer.new(@api_key, @api_secret, @consumer_options)\n end", "def oauth\n session[:return_to_url] = params[:redirect_after_login] if params[:redirect_after_login]\n login_at(auth_params[:provider])\n end", "def google_oauth2\n youtube_connect\n end", "def oauth_github_flow\n case params[:step]\n when 1\n oauth_github_flow_authorize\n when 2\n oauth_github_flow_access_token\n else\n raise \"Unsupported OAuth step\"\n end\n end", "def consumer\n @consumer = OAuth::Consumer.new session[:consumer_key], session[:consumer_secret], :site => MISO_SITE\nend", "def enabled\n @callbacks.keys\n end", "def callback\n @discogs = Discogs::Wrapper.new(\"Test OAuth\")\n request_token = session[:request_token]\n verifier = params[:oauth_verifier]\n access_token = @discogs.authenticate(request_token, verifier)\n \n session[:request_token] = nil\n session[:access_token] = access_token\n \n @discogs.access_token = access_token\n \n # You can now perform authenticated requests.\n end" ]
[ "0.6826894", "0.62099934", "0.6203541", "0.6184351", "0.61107403", "0.6026236", "0.60022473", "0.59500957", "0.58422506", "0.5841418", "0.57753676", "0.5766988", "0.5646613", "0.5638174", "0.5589162", "0.55856544", "0.5574597", "0.5561552", "0.5557374", "0.55456096", "0.5545299", "0.55434966", "0.55341005", "0.55225354", "0.54992324", "0.5494867", "0.54874897", "0.54836", "0.54741096", "0.5459166", "0.5457166", "0.54424983", "0.543558", "0.5434815", "0.5423908", "0.54049706", "0.5400739", "0.5398624", "0.53897166", "0.53885055", "0.53784055", "0.5360874", "0.5359484", "0.5359484", "0.53580517", "0.5342798", "0.53317314", "0.53099155", "0.53086895", "0.5293456", "0.5288093", "0.527985", "0.52723175", "0.52711666", "0.52678925", "0.52574044", "0.5249058", "0.52368796", "0.5233451", "0.52234834", "0.52223593", "0.520215", "0.51851827", "0.51695186", "0.5165225", "0.5157492", "0.5145779", "0.5144726", "0.5135365", "0.512068", "0.51137507", "0.5110593", "0.51084006", "0.5104294", "0.5101256", "0.5083239", "0.50708234", "0.50702333", "0.5053155", "0.50447714", "0.50431496", "0.5017082", "0.50109076", "0.5008492", "0.50083226", "0.5007245", "0.5006199", "0.5002427", "0.49789956", "0.49777055", "0.49768153", "0.4975482", "0.49746615", "0.49604556", "0.49564517", "0.49548063", "0.49514163", "0.4947086", "0.49431843", "0.49371767" ]
0.6446529
1
Creates a new medium
def create_medium(options={}) self.class.post("/media.json?apikey=#{apikey}", :query => { :medium => options }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @medium = Medium.new(medium_params)\n\n respond_to do |format|\n if @medium.save\n format.html { redirect_to @medium, notice: 'Medium was successfully created.' }\n format.json { render :show, status: :created, location: @medium }\n else\n format.html { render :new }\n format.json { render json: @medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @medium = Medium.new(medium_params)\n\n respond_to do |format|\n if @medium.save\n format.html { redirect_to @medium, notice: 'Medium was successfully created.' }\n format.json { render :show, status: :created, location: @medium }\n else\n format.html { render :new }\n format.json { render json: @medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @medium = Medium.new(medium_params)\n\n respond_to do |format|\n if @medium.save\n format.html { redirect_to @medium, notice: \"Medium was successfully created.\" }\n format.json { render :show, status: :created, location: @medium }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @medium = Medium.new(medium_params)\n \n respond_to do |format|\n if @medium.save\n format.html { redirect_to add_path, notice: 'Medium was successfully created.' }\n format.json { render action: 'add', status: :created, location: @medium }\n else\n format.html { render action: 'add' }\n format.html { render action: 'new' }\n format.json { render json: @medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_medium(params)\n self.media.create(message_sid: params[\"MessageSid\"], ext: params[\"MediaContentType0\"].split(\"/\")[1], media_type: params[\"MediaContentType0\"].split(\"/\")[0], url: params[\"MediaUrl0\"])\n end", "def create\n @other_medium = OtherMedium.new(other_medium_params)\n\n respond_to do |format|\n if @other_medium.save\n format.html { redirect_to @other_medium, notice: 'Other medium was successfully created.' }\n format.json { render :show, status: :created, location: @other_medium }\n else\n format.html { render :new }\n format.json { render json: @other_medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @custom_medium = CustomMedium.new(custom_medium_params)\n\n respond_to do |format|\n if @custom_medium.save\n format.html { redirect_to @custom_medium, notice: 'Custom medium was successfully created.' }\n format.json { render :show, status: :created, location: @custom_medium }\n else\n format.html { render :new }\n format.json { render json: @custom_medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n service_result = Organizers::BuildJoinTableObjects.call(medium_params, 'medium', :create)\n @medium = service_result.main_object\n\n if service_result.failure?\n render json: {errors: errors_as_array_hash(service_result.message)}, status: :unprocessable_entity\n else\n render :show, status: :created, location: @medium\n end\n end", "def create\n @medium = Media.new(params[:medium])\n\n respond_to do |format|\n if @medium.save\n format.html { redirect_to(@medium, :notice => 'Media was successfully created.') }\n format.xml { render :xml => @medium, :status => :created, :location => @medium }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @medium.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @multimedia = find_media\n @medium = @multimedia.media.build(params[:medium])\n\n respond_to do |format|\n if @medium.save\n format.html { redirect_to @multimedia, notice: 'Medium was successfully created.' }\n #format.json { render json: @medium, status: :created, location: @medium }\n else\n render :action => 'new'\n # format.html { render action: \"new\" }\n # format.json { render json: @medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @space = Space.find(params[:space_id])\n @medium = @space.media.create(medium_params)\n \n if @medium.save\n redirect_to space_media_path(@space)\n else\n # redirect_to new_space_medium_path(@space)\n render :new\n end\n\n # @medium = Medium.new(medium_params)\n\n # respond_to do |format|\n # if @medium.save\n # format.html { redirect_to @medium, notice: 'Medium was successfully created.' }\n # format.json { render :show, status: :created, location: @medium }\n # else\n # format.html { render :new }\n # format.json { render json: @medium.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n @socialmedium = Socialmedium.new(params[:socialmedium])\n\n respond_to do |format|\n if @socialmedium.save\n format.html { redirect_to @socialmedium, notice: 'Socialmedium was successfully created.' }\n format.json { render json: @socialmedium, status: :created, location: @socialmedium }\n else\n format.html { render action: \"new\" }\n format.json { render json: @socialmedium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @backup_medium = BackupMedium.new(backup_medium_params)\n\n respond_to do |format|\n if @backup_medium.save\n format.html { redirect_to @backup_medium, notice: 'Backup medium was successfully created.' }\n format.json { render :show, status: :created, location: @backup_medium }\n else\n format.html { render :new }\n format.json { render json: @backup_medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @medium = Medium.new(params[:medium])\n\n respond_to do |format|\n if @medium.save\n if @medium.moves.present?\n format.html { redirect_to @medium.moves.first, notice: 'Medium was successfully created.' }\n else\n format.html { redirect_to @medium, notice: 'Medium was successfully created.' }\n end\n\n format.json { render json: @medium, status: :created, location: @medium }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params.permit!\n @security_case_medium = SecurityCaseMedium.new(params[:security_case_medium])\n\n respond_to do |format|\n if @security_case_medium.save\n format.html { redirect_to(@security_case_medium, :notice => 'Security case medium was successfully created.') }\n format.xml { render :xml => @security_case_medium, :status => :created, :location => @security_case_medium }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @security_case_medium.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @medium_category = MediumCategory.new(medium_category_params)\n\n respond_to do |format|\n if @medium_category.save\n format.html { redirect_to @medium_category, notice: 'Medium category was successfully created.' }\n format.json { render :show, status: :created, location: @medium_category }\n else\n format.html { render :new }\n format.json { render json: @medium_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_media(attachment)\n \t\tmedium = Medium.new()\n \t\tmedium.attachment = attachment\n \t\tmedium.user = self\n \t\tmedium.title = attachment.original_filename\n \t\tmedium.save!\n\tend", "def new\n\t\t#Generate uuid for majorpost\n\t\tgenerate_uuid!\n\t\t@majorpost = Majorpost.new(\n\t\t\t\tuser_id: @user.id,\n\t\t\t\tuuid: @uuid\n\t\t\t)\n\t\t@upload_url = '/content/artworks/medium_editor_upload_artwork/'[email protected]\n\tend", "def create\n puts 'FILE PARAMETERS ----'\n puts params[:file]\n puts params\n puts 'END PARAMS ---- '\n @medium = Medium.create_with_file_user_id_item_key_and_local_key(params[:file], params[:medium][:user_id], params[:medium][:item_local_key], params[:medium][:local_key])\n\n respond_to do |format|\n if @medium\n format.html { redirect_to @medium, notice: 'Medium was successfully created.' }\n format.json { render json: @medium }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admin_social_medium = Admin::SocialMedium.new(params[:admin_social_medium])\n\n respond_to do |format|\n if @admin_social_medium.save\n format.html { redirect_to admin_suppliers_url }\n format.json { render json: @admin_social_medium, status: :created, location: @admin_social_medium }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_social_medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_medium\n return create_resized_pic(MEDIUM_HEIGHT, MEDIUM_WIDTH, SIZE_MEDIUM)\n end", "def create\n\n # If it's an image place it into the content directory and create a new url\n if( params[:medium][:category] == \"image\")\n tmp = params[:my_file];\n directory = 'content'\n newFileName = String(Time.now.to_i) + File.extname(tmp.original_filename);\n newFilePath = Rails.root.join('public', directory, newFileName)\n File.open(newFilePath, 'w') { |file|\n file.write(tmp.read)\n }\n # Remove the attribute from params and set the url\n params[:medium].delete('my_file');\n params[:medium][:url] = directory + \"/\" + newFileName;\n end\n\n @medium = Medium.new( params[:medium])\n\n respond_to do |format|\n if @medium.save\n format.html { render :xml => @medium, :status => :created, :location => @medium }\n format.js { render :xml => @medium, :status => :created, :location => @medium }\n format.xml { render :xml => @medium, :status => :created, :location => @medium }\n else\n format.html { render :xml => @medium, :status => :created, :location => @medium }\n format.js { render :xml => @medium, :status => :created, :location => @medium }\n format.xml { render :xml => @medium, :status => :created, :location => @medium }\n end\n end\n end", "def create\n @medium = Medium.new(params[:medium])\n @medium.member = current_member\n\n respond_to do |format|\n if @medium.save\n @activity = current_member.create_activity(@medium, 'created')\n format.html { redirect_to profile_media_path(current_member) }\n format.json { render json: @medium, status: :created, location: @medium }\n format.js\n else\n format.html { redirect_to profile_media_new_path(current_member) }\n format.json { render json: @medium.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def create\n @artist_medium = ArtistMedia.new(artist_medium_params)\n\n respond_to do |format|\n if @artist_medium.save\n format.html { redirect_to @artist_medium, notice: 'Artist was successfully created.' }\n format.json { render :show, status: :created, location: @artist_medium }\n else\n format.html { render :new }\n format.json { render json: @artist_medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def createMedia(nameStr, descriptionStr, projectStr)\n s = Sample.creator(\n {\n sample_type_id: SampleType.find_by_name(\"Media\").id,\n description: descriptionStr,\n name: nameStr, \n project: projectStr\n }, User.find(1) )\n end", "def create\n @medium_body_part = MediumBodyPart.new(params[:medium_body_part])\n\n respond_to do |format|\n if @medium_body_part.save\n format.html { redirect_to @medium_body_part, notice: 'Medium body part was successfully created.' }\n format.json { render json: @medium_body_part, status: :created, location: @medium_body_part }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medium_body_part.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @medium_dungeon = MediumDungeon.new(params[:medium_dungeon])\n\n respond_to do |format|\n if @medium_dungeon.save\n format.html { redirect_to @medium_dungeon, notice: 'Medium dungeon was successfully created.' }\n format.json { render json: @medium_dungeon, status: :created, location: @medium_dungeon }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medium_dungeon.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def new\n @medium = current_member.medium.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medium }\n end\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def create\n @contact_medium_type = ContactMediumType.new(contact_medium_type_params)\n\n respond_to do |format|\n if @contact_medium_type.save\n format.html { redirect_to @contact_medium_type, notice: 'Contact medium type was successfully created.' }\n format.json { render action: 'show', status: :created, location: @contact_medium_type }\n else\n format.html { render action: 'new' }\n format.json { render json: @contact_medium_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def new\n @medium = Medium.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @medium }\n end\n end", "def new\n @medium = Medium.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medium }\n end\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def medium_params\n params.require(:medium).permit(:id, :title, :original_title, :name, :original_name, :first_air_date, :profile_path, :release_date, :overview, :poster_path, :popularity, :media_type, :created_at, :updated_at)\n end", "def set_medium\n @medium = Medium.friendly.find(params[:id])\n end", "def medium_params\n params.require(:medium).permit(:name)\n end", "def new\n if params[:medium].present?\n @medium = Medium.new(medium_params)\n @rotten = RottenMovie.find(:id => @medium.rotten_id)\n else @medium = Medium.new\n @medium.title = params['title']\n end\n end", "def create\n \n end", "def create\n MediaCategory.create\n\n redirect_to admin_medias_path\n end", "def create\n @medium_status_mod = MediumStatusMod.new(params[:medium_status_mod])\n\n respond_to do |format|\n if @medium_status_mod.save\n format.html { redirect_to @medium_status_mod, notice: 'Medium status mod was successfully created.' }\n format.json { render json: @medium_status_mod, status: :created, location: @medium_status_mod }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medium_status_mod.errors, status: :unprocessable_entity }\n end\n end\n end", "def medium_params\n params.require(:medium).permit(:subject, :description, :medium_url)\n end", "def create\n @medium_mission = MediumMission.new(params[:medium_mission])\n\n respond_to do |format|\n if @medium_mission.save\n format.html { redirect_to @medium_mission, notice: 'Medium mission was successfully created.' }\n format.json { render json: @medium_mission, status: :created, location: @medium_mission }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medium_mission.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @medal = Medal.new(params[:medal])\n\n respond_to do |format|\n if @medal.save\n format.html { redirect_to(@medal, :notice => 'Medal was successfully created.') }\n format.xml { render :xml => @medal, :status => :created, :location => @medal }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @medal.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n params_medium = params.require(:medium).permit(:recording_note, :resource_type_id, :taken_on,\n :capture_device_model_id, :quality_type_id, :private_note, web_address_attributes: [:parent_resource_id, :url])\n web_address_params = params_medium.delete('web_address_attributes')\n @medium = OnlineResource.new(params_medium)\n @medium.ingest_taken_on(params_medium)\n respond_to do |format|\n if @medium.save && @medium.create_web_address(web_address_params)\n format.html { redirect_to @medium, :notice => 'Online resource was successfully created.' }\n format.json { render :json => @medium, :status => :created, :location => @medium }\n else\n @quality_types = QualityType.order('id')\n @resource_types = Topic.find(2636).children\n format.html { render :action => \"new\" }\n format.json { render :json => @medium.errors, :status => :unprocessable_entity }\n end\n end\n end", "def medium_params\n params.require(:medium).permit(:mediable_id, :mediable_type, :url, :kind)\n end", "def medium=(value)\n @medium = value\n end", "def create\n @medalha = Medalha.new(medalha_params)\n\n respond_to do |format|\n if @medalha.save\n format.html { redirect_to @medalha, notice: 'Medalha was successfully created.' }\n format.json { render :show, status: :created, location: @medalha }\n else\n format.html { render :new }\n format.json { render json: @medalha.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @campaign_medium = CampaignMedium.find_or_create_by(campaign_medium_params) # = CampaignMedium.new(campaign_medium_params)\n @campaign_medium = CampaignMedium.where(campaign_medium_params)\n\n if @campaign_medium.empty?\n @campaign_medium = CampaignMedium.new(campaign_medium_params)\n @campaign_medium.user = current_user\n respond_to do |format|\n if @campaign_medium.save\n format.html { redirect_to @campaign_medium, notice: 'Campaign medium was successfully created.' }\n format.json { render :show, status: :created, location: @campaign_medium }\n else\n format.html { render :new }\n @campaign_medium = CampaignMedium.new(campaign_medium_params)\n format.json { render json: @campaign_medium.errors, status: :unprocessable_entity }\n end\n end\n else\n @campaign_medium = @campaign_medium.first\n respond_to do |format|\n format.html { redirect_to @campaign_medium, notice: 'Campaign medium was successfully created.' }\n format.json { render :show, status: :created, location: @campaign_medium }\n end\n end\n end", "def create\n \t\n end", "def create\n @medium_trial = MediumTrial.new(params[:medium_trial])\n\n respond_to do |format|\n if @medium_trial.save\n format.html { redirect_to @medium_trial, notice: 'Medium trial was successfully created.' }\n format.json { render json: @medium_trial, status: :created, location: @medium_trial }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medium_trial.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_medium_type\n @medium_type = MediumType.find(params[:id])\n end", "def create\n \n end", "def create\n megam_rest.post_promos(to_hash) #WONT BE USED AS OF NOW\n end", "def create\n @medal = Medal.new(medal_params)\n\n respond_to do |format|\n if @medal.save\n format.html { redirect_to @medal, notice: 'Medal was successfully created.' }\n format.json { render :show, status: :created, location: @medal }\n else\n format.html { render :new }\n format.json { render json: @medal.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @medium_road = MediumRoad.new(params[:medium_road])\n\n respond_to do |format|\n if @medium_road.save\n format.html { redirect_to @medium_road, notice: 'Medium road was successfully created.' }\n format.json { render json: @medium_road, status: :created, location: @medium_road }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medium_road.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @medium_squad = MediumSquad.new(params[:medium_squad])\n\n respond_to do |format|\n if @medium_squad.save\n format.html { redirect_to @medium_squad, notice: 'Medium squad was successfully created.' }\n format.json { render json: @medium_squad, status: :created, location: @medium_squad }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medium_squad.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @title = @medium.titles.new(title_params)\n @title.creator = current_user.person\n respond_to do |format|\n if @title.save\n flash[:notice] = ts('new.successful', :what => Title.model_name.human.capitalize)\n format.html { redirect_to edit_medium_url(@medium, :anchor => 'titles') }\n format.xml { render :xml => @title, :status => :created, :location => medium_title_url(@medium, @title) }\n else\n @languages = ComplexScripts::Language.order('title')\n format.html { render :action => \"new\" }\n format.xml { render :xml => @title.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_avatar\n puts 'FILE PARAMETERS ----'\n puts params[:file]\n puts 'END PARAMS ---- '\n @medium = Medium.create_with_file_and_user_id(params[:file], params[:medium][:user_id])\n user = User.find_by_id(params[:medium][:user_id])\n if user\n user.update_attribute(:medium_id, @medium.id)\n end\n\n respond_to do |format|\n if @medium\n format.html { redirect_to @medium, notice: 'Medium was successfully created.' }\n format.json { render json: @medium }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def medium_params\n params.require(:medium).permit(:title, :runtime, :genre, :platform, :director, :cast, :release_date, :critic_rating, :audience_rating, :foreign, :summary, :trailer_link, :movie_link, :rotten_id, :poster_link, :watched, :hassan_rating, :own)\n end", "def create\n @unidade_medida = UnidadeMedida.new(params[:unidade_medida])\n\n respond_to do |format|\n if @unidade_medida.save\n format.html { redirect_to @unidade_medida, notice: 'Unidade medida foi criado com sucesso.' }\n format.json { render json: @unidade_medida, status: :created, location: @unidade_medida }\n else\n format.html { render action: \"new\" }\n format.json { render json: @unidade_medida.errors, status: :unprocessable_entity }\n end\n end\n end", "def newProgramme()\n @media_operation = :create\n end", "def create\r\n end", "def medium_params\n params.require(:medium).permit(:id, :name, :description, :globally_visible, :user_ids_who_can_view, :user_id, :image, :generic, categories: %i(id name))\n end", "def create\n end", "def create\n end", "def create\n end", "def create\n \tnew_creature = params.require(:creature).permit(:name, :description)\n \tcreature = Creature.create(new_creature)\n \tredirect_to \"/creatures/#{creature.id}\"\n end", "def create\n @medidor = Medidor.new(params[:medidor])\n\n respond_to do |format|\n if @medidor.save\n format.html { redirect_to(@medidor, :notice => 'Medidor was successfully created.') }\n format.xml { render :xml => @medidor, :status => :created, :location => @medidor }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @medidor.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n\t\t# Initialize the Case Media Form\n\t\t@case_medium = CaseMedium.new\n\t\t# Initialize the Case Media with Case Media attachments\n\t\t@case_media_attachments = @case_medium.case_media_attachments.build\n\tend", "def create\n @medio = Medio.new(params[:medio])\n\n respond_to do |format|\n if @medio.save\n flash[:notice] = 'Medio was successfully created.'\n format.html { redirect_to(@medio) }\n format.xml { render :xml => @medio, :status => :created, :location => @medio }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @medio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n end", "def set_custom_medium\n @custom_medium = CustomMedium.find(params[:id])\n end", "def create(atts = {})\n rec = self.new(atts)\n rec.save && rec\n end", "def medium_params\n params.require(:medium).permit(:url);\n end", "def new\n @quality_types = QualityType.order('id')\n @resource_types = Topic.find(2636).children\n @medium = OnlineResource.new(:resource_type_id => 2677)\n @medium.build_web_address\n respond_to do |format|\n format.html # new.html.erb\n end\n end", "def create\n @dishtype = Dishtype.new(dishtype_params)\n\n respond_to do |format|\n if @dishtype.save\n format.html { redirect_to @dishtype, notice: 'Dishtype was successfully created.' }\n format.json { render action: 'show', status: :created, location: @dishtype }\n else\n format.html { render action: 'new' }\n format.json { render json: @dishtype.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n end", "def create\n @medio = Medio.new(params[:medio])\n\n respond_to do |format|\n if @medio.save\n format.html { redirect_to @medio, :notice => 'Medio was successfully created.' }\n format.json { render :json => @medio, :status => :created, :location => @medio }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @medio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def medium_params\n params.require(:medium).permit(:id_media, :user, :text, :image_url, :approve_state, :show_state, :social_net_origin, :media_created_at)\n end", "def create\n @medida = Medida.new(params[:medida])\n\n respond_to do |format|\n if @medida.save\n format.html { redirect_to(@medida, :notice => 'Medida was successfully created.') }\n format.xml { render :xml => @medida, :status => :created, :location => @medida }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @medida.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @medidor = Medidor.new(medidor_params)\n\n respond_to do |format|\n if @medidor.save\n format.html { redirect_to @medidor, notice: 'Medidor was successfully created.' }\n format.json { render :show, status: :created, location: @medidor }\n else\n format.html { render :new }\n format.json { render json: @medidor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @med = Med.new(med_params)\n @med.user = current_user\n\n respond_to do |format|\n if @med.save\n format.html { redirect_to meds_path, notice: 'Med was successfully created.' }\n format.json { render :show, status: :created, location: @med }\n else\n format.html { render :new }\n format.json { render json: @med.errors, status: :unprocessable_entity }\n end\n end\n end", "def create; end", "def create; end", "def create; end", "def create; end", "def create\n @medrecord = Medrecord.new(params[:medrecord])\n\n respond_to do |format|\n if @medrecord.save\n format.html { redirect_to @medrecord, notice: 'Medrecord was successfully created.' }\n format.json { render json: @medrecord, status: :created, location: @medrecord }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medrecord.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n\r\n\r\n end", "def create_new_exercise(exercise, muscle_group)\n Exercise.create(name: exercise, muscle_group: muscle_group)\n puts \"Thank you for sharing!\"\n end", "def create\n megam_rest.post_node(to_hash)\n end", "def create\n @media_profile = MediaProfile.new(params[:media_profile])\n\n respond_to do |format|\n if @media_profile.save\n flash[:notice] = 'MediaProfile was successfully created.'\n format.html { redirect_to(@media_profile) }\n format.xml { render :xml => @media_profile, :status => :created, :location => @media_profile }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @media_profile.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @med_inst = MedInst.new(params[:med_inst])\n\n respond_to do |format|\n if @med_inst.save\n flash[:notice] = '1件のレコードが新規に作成されました(医療機関)'\n format.html { redirect_to(@med_inst) }\n format.xml { render :xml => @med_inst, :status => :created, :location => @med_inst }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @med_inst.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @media_type = MediaType.new(params[:media_type])\n\n respond_to do |format|\n if @media_type.save\n format.html { redirect_to @media_type, notice: 'Media type was successfully created.' }\n format.json { render json: @media_type, status: :created, location: @media_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @media_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @medium_research_allotment = MediumResearchAllotment.new(params[:medium_research_allotment])\n\n respond_to do |format|\n if @medium_research_allotment.save\n format.html { redirect_to @medium_research_allotment, notice: 'Medium research allotment was successfully created.' }\n format.json { render json: @medium_research_allotment, status: :created, location: @medium_research_allotment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @medium_research_allotment.errors, status: :unprocessable_entity }\n end\n end\n end", "def custom_medium_params\n params.require(:custom_medium).permit(:type, :general_medias_id)\n end" ]
[ "0.7795342", "0.7795342", "0.77414906", "0.7645764", "0.7528351", "0.74472284", "0.7328954", "0.73088735", "0.7297219", "0.72354144", "0.72110885", "0.7087005", "0.6997907", "0.6957633", "0.68900746", "0.68021196", "0.675453", "0.6712656", "0.66928697", "0.6653775", "0.6585108", "0.65470207", "0.6522269", "0.64964086", "0.64816785", "0.64785844", "0.64368814", "0.64095795", "0.64095795", "0.64095795", "0.6403313", "0.63780296", "0.63780296", "0.6369479", "0.636528", "0.63340527", "0.6317565", "0.6284399", "0.6283745", "0.627615", "0.6259758", "0.62520087", "0.6249972", "0.62180996", "0.6195508", "0.61951154", "0.61878484", "0.6171852", "0.616953", "0.6145858", "0.61248446", "0.61195546", "0.6109623", "0.6108211", "0.60885936", "0.6060007", "0.60516065", "0.6038901", "0.60302246", "0.6020949", "0.6008846", "0.6002013", "0.59824896", "0.597988", "0.5976878", "0.59679645", "0.5945991", "0.5943001", "0.59331447", "0.59331447", "0.59331447", "0.5927436", "0.5922868", "0.5917317", "0.59144545", "0.59135985", "0.5905877", "0.59035933", "0.5897613", "0.5895812", "0.5891691", "0.58819824", "0.58809775", "0.5875833", "0.5873038", "0.58712053", "0.5871033", "0.585814", "0.585814", "0.585814", "0.585814", "0.58572435", "0.5839308", "0.58318955", "0.5824542", "0.5823709", "0.5818946", "0.5817037", "0.581553", "0.5812753" ]
0.7259082
9
Updates the desired medium
def update_medium(id, options={}) self.class.put("/media/#{id}.json?apikey=#{apikey}", :query => {:medium => options}, :body => {}) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update!(**args)\n @medium = args[:medium] if args.key?(:medium)\n end", "def update!(**args)\n @medium = args[:medium] if args.key?(:medium)\n end", "def update\n update_medium\n end", "def update\n @medium = Medium.find(params[:id])\n\n respond_to do |format|\n if @medium.update_attributes(params[:medium])\n format.html { redirect_to media_path(:admin => \"snickers\"), notice: 'Medium was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def medium=(value)\n @medium = value\n end", "def update\n respond_to do |format|\n if @custom_medium.update(custom_medium_params)\n format.html { redirect_to @custom_medium, notice: 'Custom medium was successfully updated.' }\n format.json { render :show, status: :ok, location: @custom_medium }\n else\n format.html { render :edit }\n format.json { render json: @custom_medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @medium.update(medium_params)\n format.html { redirect_to @medium, notice: 'Medium was successfully updated.' }\n format.json { render :show, status: :ok, location: @medium }\n else\n format.html { render :edit }\n format.json { render json: @medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @medium.update(medium_params)\n format.html { redirect_to @medium, notice: 'Medium was successfully updated.' }\n format.json { render :show, status: :ok, location: @medium }\n else\n format.html { render :edit }\n format.json { render json: @medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @medium.update(medium_params)\n format.html { redirect_to @medium, notice: \"Medium was successfully updated.\" }\n format.json { render :show, status: :ok, location: @medium }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @medium = Medium.find(params[:id])\n\n respond_to do |format|\n if @medium.update_attributes(params[:medium])\n format.html { redirect_to @medium, :notice => 'Medium was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @medium.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @medium = Medium.find(params[:id])\n\n respond_to do |format|\n if @medium.update_attributes(params[:medium])\n format.html { redirect_to(@medium, :notice => 'Medium was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @medium.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @medium.update(medium_params)\n format.html { redirect_to @medium, notice: 'Medium was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def update\n respond_to do |format|\n if @other_medium.update(other_medium_params)\n format.html { redirect_to @other_medium, notice: 'Other medium was successfully updated.' }\n format.json { render :show, status: :ok, location: @other_medium }\n else\n format.html { render :edit }\n format.json { render json: @other_medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_medium\n @medium = Medium.friendly.find(params[:id])\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def set_medium\n @medium = Medium.find(params[:id])\n end", "def update\n @medium = Media.find(params[:id])\n\n respond_to do |format|\n if @medium.update_attributes(params[:medium])\n format.html { redirect_to(@medium, :notice => 'Media was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @medium.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @admin_social_medium = Admin::SocialMedium.find(params[:id])\n\n respond_to do |format|\n if @admin_social_medium.update_attributes(params[:admin_social_medium])\n format.html { redirect_to admin_suppliers_url }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_social_medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @medium = Medium.find(params[:id])\n @medium.update_attributes(medium_params)\n\n redirect_to space_medium_path(@space, @medium)\n return\n # respond_to do |format|\n # if @medium.update(medium_params)\n # format.html { redirect_to @medium, notice: 'Medium was successfully updated.' }\n # format.json { render :show, status: :ok, location: @medium }\n # else\n # format.html { render :edit }\n # format.json { render json: @medium.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def set_custom_medium\n @custom_medium = CustomMedium.find(params[:id])\n end", "def update\n respond_to do |format|\n if @campaign_medium.update(campaign_medium_params)\n format.html { redirect_to @campaign_medium, notice: 'Campaign medium was successfully updated.' }\n format.json { render :show, status: :ok, location: @campaign_medium }\n else\n format.html { render :edit }\n format.json { render json: @campaign_medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @medium = Medium.find(params[:id])\n @medium.update_attributes(params[:medium])\n @parent = @medium.multimedia\n respond_to do |format|\n format.html { render edit_medium(@medium) }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @backup_medium.update(backup_medium_params)\n format.html { redirect_to @backup_medium, notice: 'Backup medium was successfully updated.' }\n format.json { render :show, status: :ok, location: @backup_medium }\n else\n format.html { render :edit }\n format.json { render json: @backup_medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_other_medium\n @other_medium = OtherMedium.find(params[:id])\n end", "def update\n\n respond_to do |format|\n if @medium.update_attributes(params[:medium])\n format.html { redirect_to @medium }\n format.json { head :no_content }\n format.js { render :js => \"window.location.href = ('#{medium_path(@medium)}');\"}\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medium.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def medium\n @request[:size] = 'medium'\n self\n end", "def set_medium_type\n @medium_type = MediumType.find(params[:id])\n end", "def update\n @socialmedium = Socialmedium.find(params[:id])\n\n respond_to do |format|\n if @socialmedium.update_attributes(params[:socialmedium])\n format.html { redirect_to @socialmedium, notice: 'Socialmedium was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @socialmedium.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @medium = Medium.find(params[:id])\n\n respond_to do |format|\n if @medium.update_attributes(params[:medium])\n if @medium.moves.present?\n format.html { redirect_to @medium.moves.first, notice: 'Medium was successfully updated.' }\n else\n format.html { redirect_to @medium, notice: 'Medium was successfully updated.' }\n end\n\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @medium_category.update(medium_category_params)\n format.html { redirect_to @medium_category, notice: 'Medium category was successfully updated.' }\n format.json { render :show, status: :ok, location: @medium_category }\n else\n format.html { render :edit }\n format.json { render json: @medium_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n params.permit!\n @security_case_medium = SecurityCaseMedium.find(params[:id])\n\n respond_to do |format|\n if @security_case_medium.update_attributes(params[:security_case_medium])\n format.html { redirect_to(@security_case_medium, :notice => 'Security case medium was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @security_case_medium.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @medium = Medium.find(params[:id])\n params_medium = params.require(:medium).permit(:recording_note, :resource_type_id, :photographer_id, :taken_on, :partial_taken_on, :capture_device_model_id,\n :quality_type_id, :private_note, :rotation, web_address_attributes: [:parent_resource_id, :url])\n respond_to do |format|\n params_web_address = params_medium.delete(:web_address_attributes)\n @medium.attributes = params_medium\n @medium.web_address.attributes = params_web_address if !params_web_address.nil?\n @medium.ingest_taken_on(params_medium)\n is_picture = @medium.instance_of? Picture\n redo_thumbs = @medium.rotation_changed? if is_picture\n if @medium.save # @medium.update_attributes(params[:medium])\n @medium.update_thumbnails if is_picture && redo_thumbs\n flash[:notice] = ts('edit.successful', :what => Medium.model_name.human.capitalize)\n format.html { redirect_to medium_url(@medium) }\n format.xml { head :ok }\n else\n format.html do\n @capture_device_models = CaptureDeviceMaker.all.order('title').collect{|maker| maker.capture_device_models}.flatten\n @media_publisher = MediaPublisher.all\n @photographers = AuthenticatedSystem::Person.all.order('fullname')\n @quality_types = QualityType.all.order('id')\n @recording_orientations = RecordingOrientation.all.order('title')\n @resource_types = Topic.find(2636).children\n @root_topics = Topic.roots \n render :action => 'edit'\n end\n format.xml { render :xml => @medium.errors.to_xml }\n end\n end\n end", "def update\n respond_to do |format|\n if @artist_medium.update(artist_medium_params)\n format.html { redirect_to @artist_medium, notice: 'Artist was successfully updated.' }\n format.json { render :show, status: :ok, location: @artist_medium }\n else\n format.html { render :edit }\n format.json { render json: @artist_medium.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_solution_medium\n @solution_medium = SolutionMedium.find(params[:id])\n end", "def set_medium_category\n @medium_category = MediumCategory.find(params[:id])\n end", "def update!(**args)\n @medium_type = args[:medium_type] if args.key?(:medium_type)\n @self_phone = args[:self_phone] if args.key?(:self_phone)\n end", "def medium_params\n params.require(:medium).permit(:mediable_id, :mediable_type, :url, :kind)\n end", "def set_campaign_medium\n @campaign_medium = CampaignMedium.find(params[:id])\n end", "def update\n respond_to do |format|\n if @contact_medium_type.update(contact_medium_type_params)\n format.html { redirect_to @contact_medium_type, notice: 'Contact medium type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @contact_medium_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_accepted_medium\n @accepted_medium = AcceptedMedium.find(params[:id])\n end", "def updateProgramme()\n @media_operation = :update\n end", "def update\n @medium_dungeon = MediumDungeon.find(params[:id])\n\n respond_to do |format|\n if @medium_dungeon.update_attributes(params[:medium_dungeon])\n format.html { redirect_to @medium_dungeon, notice: 'Medium dungeon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medium_dungeon.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_backup_medium\n @backup_medium = BackupMedium.find(params[:id])\n end", "def set_social_medium\n @social_medium = SocialMedium.find(params[:id])\n end", "def medium\n return @medium\n end", "def update\n @small_post = @club.small_posts.find(params[:id])\n\n respond_to do |format|\n if @small_post.update_attributes(params[:small_post])\n flash[:notice] = 'SmallPost was successfully updated.'\n format.html { redirect_to admin_club_large_posts_path(@club) }\n format.xml { head :ok }\n else\n @page_title = \"Editing Small Post\"\n @site_section = \"admin\"\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @small_post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @medium_status_mod = MediumStatusMod.find(params[:id])\n\n respond_to do |format|\n if @medium_status_mod.update_attributes(params[:medium_status_mod])\n format.html { redirect_to @medium_status_mod, notice: 'Medium status mod was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medium_status_mod.errors, status: :unprocessable_entity }\n end\n end\n end", "def medium\n filter << 'Size:Medium'\n self\n end", "def set_artist_medium\n @artist_medium = ArtistMedia.find(params[:id])\n end", "def medium_params\n params.require(:medium).permit(:title, :runtime, :genre, :platform, :director, :cast, :release_date, :critic_rating, :audience_rating, :foreign, :summary, :trailer_link, :movie_link, :rotten_id, :poster_link, :watched, :hassan_rating, :own)\n end", "def medium_params\n params.require(:medium).permit(:id, :title, :original_title, :name, :original_name, :first_air_date, :profile_path, :release_date, :overview, :poster_path, :popularity, :media_type, :created_at, :updated_at)\n end", "def update\n @medium_trial = MediumTrial.find(params[:id])\n\n respond_to do |format|\n if @medium_trial.update_attributes(params[:medium_trial])\n format.html { redirect_to @medium_trial, notice: 'Medium trial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medium_trial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @medium_squad = MediumSquad.find(params[:id])\n\n respond_to do |format|\n if @medium_squad.update_attributes(params[:medium_squad])\n format.html { redirect_to @medium_squad, notice: 'Medium squad was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medium_squad.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @medium_body_part = MediumBodyPart.find(params[:id])\n\n respond_to do |format|\n if @medium_body_part.update_attributes(params[:medium_body_part])\n format.html { redirect_to @medium_body_part, notice: 'Medium body part was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medium_body_part.errors, status: :unprocessable_entity }\n end\n end\n end", "def medium_params\n params.require(:medium).permit(:url);\n end", "def update\n @medium_map_cell = MediumMapCell.find(params[:id])\n\n respond_to do |format|\n if @medium_map_cell.update_attributes(params[:medium_map_cell])\n format.html { redirect_to @medium_map_cell, notice: 'Medium map cell was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medium_map_cell.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_challenge_medium\n @challenge_medium = ChallengeMedium.find(params[:id])\n end", "def medium_params\n params.require(:medium).permit(:id_media, :user, :text, :image_url, :approve_state, :show_state, :social_net_origin, :media_created_at)\n end", "def medium_params\n params.require(:medium).permit(:name)\n end", "def medium_params\n params.require(:medium).permit(:subject, :description, :medium_url)\n end", "def medium\n return Medium.find(medium_id);\nend", "def update\n respond_to do |format|\n if @med.update(med_params)\n format.html { redirect_to @med, notice: 'Med was successfully updated.' }\n format.json { render :show, status: :ok, location: @med }\n else\n format.html { render :edit }\n format.json { render json: @med.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\tparams[:case_medium][:owner_id] = devise_current_user.id.to_s\n\t\t# Updating the case media attachments accordin to the case media\n\t\tif @case_medium.update(case_media_params)\n\t\t # After update redirect ot the case page\n\t\t redirect_to edit_case_case_medium_path(@surgery_case,@case_medium)\n\t\telse\n\t\t\t# If more than 10 images then that is navigate the same page\n\t\t\tredirect_to edit_case_case_medium_path(@surgery_case,@case_medium)\n\t\t\t# if image is not uploaded then that showing the flash notice\n\t\t\tflash[:notice] = \"Cannot upload more than 10 images at one go\"\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @media_interest.update_attributes(params[:media_interest])\n format.html { redirect_to @media_interest, :notice => 'Интересот на медиумот е успешно ажуриран.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @media_interest.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @medal = Medal.find(params[:id])\n\n respond_to do |format|\n if @medal.update_attributes(params[:medal])\n format.html { redirect_to(@medal, :notice => 'Medal was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @medal.errors, :status => :unprocessable_entity }\n end\n end\n end", "def medium_params\n params.require(:medium).permit(:id, :name, :description, :globally_visible, :user_ids_who_can_view, :user_id, :image, :generic, categories: %i(id name))\n end", "def update\n respond_to do |format|\n if @medal.update(medal_params)\n format.html { redirect_to @medal, notice: 'Medal was successfully updated.' }\n format.json { render :show, status: :ok, location: @medal }\n else\n format.html { render :edit }\n format.json { render json: @medal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @quality = args[:quality] if args.key?(:quality)\n end", "def update!(**args)\n @quality = args[:quality] if args.key?(:quality)\n end", "def update\n if can?(:>=, \"5\")\n params[:kit_media_type][:compartment_layout] = params[:kit_media_type][:compartment_layout].to_json\n @kit_media_type = Kitting::KitMediaType.find(params[:id])\n respond_to do |format|\n if @kit_media_type.update_attributes(params[:kit_media_type])\n format.html { redirect_to @kit_media_type, notice: 'Kit media type is updated successfully.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kit_media_type.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to main_app.unauthorized_url\n end\n end", "def other_medium_params\n params.require(:other_medium).permit(:name, :price, :code, :brand, :brandmodel, :mediatype, :capacity, :maxspeedsupported, :quantity, :features, :packaging, :other)\n end", "def set_contact_medium_type\n @contact_medium_type = ContactMediumType.find(params[:id])\n end", "def update\n respond_to do |format|\n if @med.update(med_params)\n format.html { redirect_to meds_path, notice: 'Med was successfully updated.' }\n format.json { render :show, status: :ok, location: @med }\n else\n format.html { render :edit }\n format.json { render json: @med.errors, status: :unprocessable_entity }\n end\n end\n end", "def medium\n @chart_size = 'medium'\n self\n end", "def custom_medium_params\n params.require(:custom_medium).permit(:type, :general_medias_id)\n end", "def update_medals\n Medal.transaction do\n updated_medals = fetch_medals\n existing_medals = {}\n \n self.medals.each { |medal| existing_medals[[medal.medal_name_id, medal.playlist_type]] = medal }\n \n updated_medals.each { |medal|\n if existing_medal = existing_medals[[ medal[:medal_name_id], medal[:playlist_type] ]]\n existing_medal.update_attribute(:quantity, medal[:quantity])\n else\n Medal.create({:medal_name_id => medal[:medal_name_id], :quantity => medal[:quantity], :gamertag_id => self.id, :playlist_type => medal[:playlist_type]})\n end\n }\n \n end\n end", "def update\n @mostsmallskillcategory = Mostsmallskillcategory.find(params[:id])\n\n respond_to do |format|\n if @mostsmallskillcategory.update_attributes(params[:mostsmallskillcategory])\n format.html { redirect_to @mostsmallskillcategory, notice: 'Mostsmallskillcategory was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mostsmallskillcategory.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @medium_research_allotment = MediumResearchAllotment.find(params[:id])\n\n respond_to do |format|\n if @medium_research_allotment.update_attributes(params[:medium_research_allotment])\n format.html { redirect_to @medium_research_allotment, notice: 'Medium research allotment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medium_research_allotment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @medium_road = MediumRoad.find(params[:id])\n\n respond_to do |format|\n if @medium_road.update_attributes(params[:medium_road])\n format.html { redirect_to @medium_road, notice: 'Medium road was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medium_road.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @small_category.update(small_category_params)\n format.html { redirect_to @small_category, notice: 'Small category was successfully updated.' }\n format.json { render :show, status: :ok, location: @small_category }\n else\n format.html { render :edit }\n format.json { render json: @small_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @medalha.update(medalha_params)\n format.html { redirect_to @medalha, notice: 'Medalha was successfully updated.' }\n format.json { render :show, status: :ok, location: @medalha }\n else\n format.html { render :edit }\n format.json { render json: @medalha.errors, status: :unprocessable_entity }\n end\n end\n end", "def medium\n @speed = MEDIUM\n puts \"#{@location} ceiling fan is on medium\"\n end", "def medium\n @speed = MEDIUM\n puts \"#{@location} ceiling fan is on medium\"\n end", "def promotion(piece, type)\r\n piece.update_attributes(piece_type: type)\r\n return piece\r\nend", "def update\n @medium_mission = MediumMission.find(params[:id])\n\n respond_to do |format|\n if @medium_mission.update_attributes(params[:medium_mission])\n format.html { redirect_to @medium_mission, notice: 'Medium mission was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medium_mission.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admin_media_type.update(admin_media_type_params)\n format.html { redirect_to @admin_media_type, notice: 'Media type was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_media_type }\n else\n format.html { render :edit }\n format.json { render json: @admin_media_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @miniature.update(miniature_params)\n format.html { redirect_to @miniature, notice: 'Miniature was successfully updated.' }\n format.json { render :show, status: :ok, location: @miniature }\n else\n format.html { render :edit }\n format.json { render json: @miniature.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @average_set_description_quality = args[:average_set_description_quality] if args.key?(:average_set_description_quality)\n @average_set_navigation_usefulness = args[:average_set_navigation_usefulness] if args.key?(:average_set_navigation_usefulness)\n end", "def campaign_medium_params\n params.require(:campaign_medium).permit(:medium)\n end", "def update\n @mostsmallitemcategory = Mostsmallitemcategory.find(params[:id])\n\n respond_to do |format|\n if @mostsmallitemcategory.update_attributes(params[:mostsmallitemcategory])\n format.html { redirect_to @mostsmallitemcategory, notice: 'Mostsmallitemcategory was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mostsmallitemcategory.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_eventsmedium\n @eventsmedium = Eventsmedium.find(params[:id])\n end", "def category_medium_params\n params.require(:category_medium).permit(:category_id,:medium_id)\n end", "def set_medium_of_performance\n @medium_of_performance = MediumOfPerformance.find(params[:id])\n authorize @medium_of_performance\n end", "def update_quality(item)\n item.quality = 0 if item.quality < 0\n item.quality = 50 if item.quality > 50\n end", "def update\n @mostsmallresource = Mostsmallresource.find(params[:id])\n\n respond_to do |format|\n if @mostsmallresource.update_attributes(params[:mostsmallresource])\n format.html { redirect_to @mostsmallresource, notice: 'Mostsmallresource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mostsmallresource.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7968474", "0.7968474", "0.77928287", "0.75788325", "0.743611", "0.74160534", "0.7362387", "0.7362387", "0.73233086", "0.72820574", "0.72622573", "0.71883327", "0.7176715", "0.71720606", "0.71720606", "0.71720606", "0.7123768", "0.7064551", "0.7056599", "0.7056599", "0.70086426", "0.698885", "0.6841009", "0.6814288", "0.67968386", "0.6769041", "0.674719", "0.67325264", "0.6710819", "0.67100394", "0.66911733", "0.66058236", "0.6604291", "0.654017", "0.64474696", "0.6370591", "0.6341252", "0.6326541", "0.6273982", "0.6208241", "0.61855817", "0.61812544", "0.61753595", "0.61726224", "0.6143752", "0.60757446", "0.6066864", "0.6048411", "0.6030442", "0.60129035", "0.6009961", "0.5999996", "0.59776545", "0.5961434", "0.59461224", "0.59452754", "0.5943495", "0.59276927", "0.5895019", "0.5887467", "0.58749515", "0.58537775", "0.5838378", "0.5785562", "0.5780324", "0.57775307", "0.5761397", "0.57540876", "0.57524604", "0.5747388", "0.5733975", "0.5729779", "0.5723178", "0.5723178", "0.5709075", "0.5686473", "0.56824976", "0.56518626", "0.56512", "0.5650016", "0.5632574", "0.5627369", "0.5620091", "0.5619575", "0.5619212", "0.5615016", "0.5613491", "0.5613491", "0.5612676", "0.56122375", "0.56061715", "0.5603286", "0.5583475", "0.558169", "0.5569664", "0.55652714", "0.55627954", "0.5554149", "0.55529046", "0.5545407" ]
0.68427664
22
GET /critical_success_factors GET /critical_success_factors.json
def index @critical_success_factors = CriticalSuccessFactor.all respond_to do |format| format.html # index.html.erb format.json { render json: @critical_success_factors } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @critical_factors = CriticalFactor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @critical_factors }\n end\n end", "def show\n @critical_success_factor = CriticalSuccessFactor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critical_success_factor }\n end\n end", "def show\n @critical_factor = CriticalFactor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critical_factor }\n end\n end", "def index\n @critical_success_factor_types = CriticalSuccessFactorType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @critical_success_factor_types }\n end\n end", "def new\n @critical_success_factor = CriticalSuccessFactor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_success_factor }\n end\n end", "def new\n @critical_factor = CriticalFactor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_factor }\n end\n end", "def show\n @critical_success_factor_type = CriticalSuccessFactorType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critical_success_factor_type }\n end\n end", "def create\n @critical_success_factor = CriticalSuccessFactor.new(params[:critical_success_factor])\n @critical_success_factor.user = current_user\n @critical_success_factor.confidential = false\n\n respond_to do |format|\n if @critical_success_factor.save\n format.html { redirect_to @critical_success_factor, notice: 'Critical success factor was successfully created.' }\n format.json { render json: @critical_success_factor, status: :created, location: @critical_success_factor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @critical_success_factor.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @critical_success_factor_type = CriticalSuccessFactorType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_success_factor_type }\n end\n end", "def create\n @critical_factor = CriticalFactor.new(params[:critical_factor])\n @critical_factor.user = current_user\n @critical_factor.confidential = false\n\n\n respond_to do |format|\n if @critical_factor.save\n format.html { redirect_to @critical_factor, notice: 'Critical factor was successfully created.'}\n format.json { render json: @critical_factor, status: :created, location: @critical_factor }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @critical_factor.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @critical_success_factor = CriticalSuccessFactor.find(params[:id])\n @critical_success_factor.destroy\n\n respond_to do |format|\n format.html { redirect_to critical_success_factors_url }\n format.json { head :no_content }\n end\n end", "def update\n @critical_success_factor = CriticalSuccessFactor.find(params[:id])\n\n respond_to do |format|\n if @critical_success_factor.update_attributes(params[:critical_success_factor])\n format.html { redirect_to @critical_success_factor, notice: 'Critical success factor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @critical_success_factor.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @critical_factor = CriticalFactor.find(params[:id])\n @critical_factor.destroy\n\n respond_to do |format|\n format.html { redirect_to critical_factors_url }\n format.json { head :no_content }\n end\n end", "def faculties\n @faculties = Faculty.where(university_id: params[:university_id]).order(:name)\n @courses = []\n respond_to do |format|\n format.json { render json: @faculties }\n end\n end", "def update\n @critical_factor = CriticalFactor.find(params[:id])\n\n respond_to do |format|\n if @critical_factor.update_attributes(params[:critical_factor])\n format.html { redirect_to @critical_factor, notice: 'Critical factor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @critical_factor.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @criticals = Critical.all\n end", "def index\n @stage_certainty_factors = StageCertaintyFactor.all\n end", "def index\n @faculties = Faculty.all\n json_response(@faculties)\n end", "def api_request\n url = URI.parse(\"https://catfact.ninja/fact\")\n response = Net::HTTP.get_response(url)\n JSON.parse(response.body)[\"fact\"]\n end", "def index\n @code_factors = CodeFactor.all(:order => \"id DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @code_factors }\n format.json { \n\t \t@returns = []\n\t \t@code_factors.each do |code_factor|\n\t \t\t@returns << mapping_to_hash(code_factor, CodeFactor.json_mapping_table)\n\t\tend \n\t \trender :json => @returns\n\t }\n end\n end", "def create\n @critical = Critical.new(critical_params)\n\n respond_to do |format|\n if @critical.save\n format.html { redirect_to @critical, notice: 'Critical was successfully created.' }\n format.json { render :show, status: :created, location: @critical }\n else\n format.html { render :new }\n format.json { render json: @critical.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @socio_cultural_factors = SocioCulturalFactor.all\n end", "def index\n @technological_factors = TechnologicalFactor.all\n end", "def courses\n @courses = Course.where(faculty_id: params[:faculty_id]).order(:name)\n respond_to do |format|\n format.json { render json: @courses }\n end\n end", "def index\n @form_factors = FormFactor.all\n end", "def destroy\n @critical_success_factor_type = CriticalSuccessFactorType.find(params[:id])\n @critical_success_factor_type.destroy\n\n respond_to do |format|\n format.html { redirect_to critical_success_factor_types_url }\n format.json { head :no_content }\n end\n end", "def index\n if params[:problems].blank?\n @cases = Case.all\n else\n @cases = Case.as(:c).where('c.stock <= 1').pluck(:c)\n @cases.map!{|c| {\n id: c.id,\n name: c.name,\n stock: c.stock\n }}\n\n @cases.sort_by! {:name}\n\n render json: @cases\n end\n end", "def index\n @constituency = Parliament::Utils::Helpers::FilterHelper.filter(@request, 'ConstituencyGroup').first\n end", "def index\n @certainties = Certainty.all\n end", "def guardian_factors\n get(guardian_factors_path)\n end", "def index\n @control_list_factors = ControlListFactor.unscoped.all\n end", "def show\n @factor = Factor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @factor }\n end\n end", "def index\n professors = Professor.includes(:courses).all\n\n render json: professors.to_json(include: :courses)\n end", "def show\n @factors_user = FactorsUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @factors_user }\n end\n end", "def cuadrant\n # We expect a :criteria hash to tell us what to report on\n render :text => 'Internal error: missing criteria', :status => 500 and return unless params[:criteria]\n @green_list = StudentResponse.green_list(params[:criteria])\n @orange_list = StudentResponse.orange_list(params[:criteria])\n @yellow_list = StudentResponse.yellow_list(params[:criteria])\n @red_list = StudentResponse.red_list(params[:criteria])\n end", "def get_part_by_category\n @categorys = PartsController::PartService.get_part_by_category(params[:param]);\n respond_to do |format|\n format.json { render json: @categorys }\n end \n end", "def index\n @frontend_critics = Frontend::Critic.all\n \n \n end", "def index\n @challenges = Challenge.user(current_user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end", "def proficiency\n h = {}\n subjects = current_user.scheme.subjects\n if request.xhr?\n if params[:subject_id]\n subjects = Subject.where(id:params[:subject_id]) unless params[:subject_id].blank?\n end\n end \n subjects.each do |sub|\n sub.units.each do |u|\n if u.reports.exists? \n accuracy = ((u.reports.where(user_id:current_user.id).total_correct.to_f/u.reports.where(user_id:current_user.id).total_questions.to_f).to_f*100).round(2)\n attended = ((u.reports.where(user_id:current_user.id).total_attended.to_f/u.reports.where(user_id:current_user.id).total_questions.to_f).to_f*100).round(2)\n data = []\n u.reports.where(user_id:current_user.id).each do |report|\n l1 = (report.l1_attended.to_f/(report.l1_total.to_f.nonzero? || 1 ))*100\n l2 = (report.l2_attended.to_f/(report.l2_total.to_f.nonzero? || 1 ))*100\n l3 = (report.l3_attended.to_f/(report.l3_total.to_f.nonzero? || 1 ))*100\n data << (report.l1_attended.to_f/report.l1_total.to_f)*100 + (report.l2_attended.to_f/report.l2_total.to_f)*10 + (report.l3_attended.to_f/report.l3_total.to_f)\n end\n strategy = average(data)\n h[u.name] = [attended, accuracy, strategy]\n else\n h[u.name] = [0,0,0]\n end\n end\n end\n @hash = h.sort_by {|k,v| v}.reverse! \n end", "def index\n @success_criterions = SuccessCriterion.all\n end", "def index\n @user_challenges = current_user.user_challenges.includes(:challenge)\n\n js progress: current_user.complete_challenges.count / Challenge.count.to_f * 100\n end", "def test_canvas_api_studenta_courses\n refute_nil @w\n request_url = \"/courses?as_user_id=sis_login_id:studenta\"\n result_as_json = run_and_get_json_result(request_url)\n assert_operator result_as_json.length, \">=\", 1, \"got some classes back\"\n end", "def fetch_critical_chain_interaction_status\n\n @api_response_data[result_type] = CacheManagement::CriticalChainInteractionStatus.\n new([@critical_chain_interaction_log_id]).fetch[@critical_chain_interaction_log_id]\n\n success\n\n end", "def index\n @ice_classs =IceClass.all\n render :json => {:successful=>true, :total=>@ice_classs.length, :data=> @ice_classs }\n end", "def index\n @courses = Course.all\n render json: @courses, status: :ok\n end", "def test_canvas_api_studenta_courses\n refute_nil @w\n request_url = \"/courses?as_user_id=sis_login_id:studenta\"\n result_as_json = run_and_get_ruby_result(request_url)\n assert_operator result_as_json.length, \">=\", 1, \"got some classes back\"\n end", "def attempts\n @course_ids = current_user_or_anonymous_user.challenge_responses.select(:course_id).group(:course_id).map(&:course_id).compact\n\n render json: @course_ids\n end", "def index\n #@courses = @curriculum.courses\n\n @courses = ScopedCourse.where(:curriculum_id => @curriculum.id)\n .joins(:course_descriptions)\n .where([\"course_descriptions.locale = ?\", I18n.locale]).includes(:strict_prereqs)\n# .joins(<<-SQL\n# INNER JOIN course_descriptions\n# ON competence_nodes.abstract_course_id = course_descriptions.abstract_course_id\n# SQL\n# )\n\n respond_to do |format|\n #format.html # index.html.erb\n format.json do\n render :json => @courses.select(<<-SQL\n competence_nodes.id,\n competence_nodes.course_code,\n course_descriptions.name AS translated_name\n SQL\n ).to_json(:methods => :strict_prereq_ids, :root => true)\n end\n end\n end", "def show\n @compromise = Compromise.find(params[:id])\n\n render json: @compromise\n end", "def show\n @critical_question = CriticalQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critical_question }\n end\n end", "def index\n @challenges = Challenge.order(:id)\n .includes(:user)\n .page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end", "def index\n render jsonapi: Seances::UseCases::FetchAll.new.call\n end", "def show\n @patient_risk_factor = PatientRiskFactor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @patient_risk_factor }\n end\n end", "def index\n @given_circumstances = GivenCircumstance.all\n render json: @given_circumstances\n end", "def index\n begin\n case\n when params[:semester_id]\n @courses = Semester.find(params[:semester_id]).courses\n when params[:teacher_id]\n check_token(params[:teacher_id], params[:token], true)\n @courses = User.find(params[:teacher_id]).real_teaching_courses\n when params[:student_id]\n check_token(params[:student_id])\n @courses = Course.none\n User.find(params[:student_id]).participations.each do |participation|\n @courses <<= participation.course if ROLE_STUDENT == participation.role\n end\n when params[:assistant_id]\n check_token(params[:assistant_id])\n @courses = Course.none\n User.find(params[:assistant_id]).participations.each do |participation|\n @courses <<= participation.course if ROLE_ASSISTANT == participation.role\n end\n else\n json_failed\n end\n rescue ActiveRecord::RecordNotFound\n json_failed(REASON_RESOURCE_NOT_FOUND)\n end\n end", "def retrieve_attempted\n\t\trender json: @@contests_attempted_shared\n\tend", "def prime_factors num\n\tfactors = []\n\ttest_value = 2\n\twhile num > 1 do\n\t\twhile num % test_value == 0 do\n\t\t\tfactors.push num\n\t\t\tnum = num / test_value\n\t\tend\n\t\ttest_value += 1\n\tend\n\treturn factors\nend", "def index\n @health_levels = HealthLevel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @health_levels }\n end\n end", "def show\n json_response(@faculty)\n end", "def index\n @undergraduate_majors = UndergraduateMajor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @undergraduate_majors }\n end\n end", "def critical_params\n params.require(:critical).permit(:result_id, :karuta_id, :field_id)\n end", "def index\n @attempt_categories = AttemptCategory.where course:@course\n end", "def get_subjects\n if params[:c].present?\n sc_id = params[:c].to_i\n subjects = Subject.joins(:school_cycle_has_subjects).where(\"school_cycle_id = ?\", sc_id)\n msg = { \"success\": \"true\", \"subjects\": subjects }\n else\n msg = { \"success\": false, \"subjects\": 0 }\n end\n\n render json: msg\n end", "def index\n @incidentcategories = Incidentcategory.all\n json_response(@incidentcategories)\n end", "def create\n @critical_success_factor_type = CriticalSuccessFactorType.new(params[:critical_success_factor_type])\n\n respond_to do |format|\n if @critical_success_factor_type.save\n format.html { redirect_to @critical_success_factor_type, notice: 'Tipo de Factor Crítico registrado correctamente.' }\n format.json { render json: @critical_success_factor_type, status: :created, location: @critical_success_factor_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @critical_success_factor_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n response = HTTParty.get(\"https://casa-core.herokuapp.com/api/units\", :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n @units = JSON.parse(response.body)\n return @units\n end", "def index\n @clusters = []\n @project = Project.where(:key => params[:project_key]).first\n\n get_cluster_data() \n render :partial => 'index'\n end", "def index\n @facilities = Facility.all\n respond_with @facilities\n end", "def index\n respond_to do |format|\n format.html {\n @disabilities = Disability.sorted.is_active\n @categories = QuestionCategory.all_main\n }\n format.json { render json: QuestionPairingDisabilitiesDatatable.new(view_context, params[:is_certified], params[:type], params[:category]) }\n end\n end", "def fetch_complaints\n user = AdminUser.find(get_logged_in_user_id)\n if user.designation == \"supervisor\"\n new_complaints = ComplaintStatus.where(admin_user_id: user.id, status: \"pending\")\n pending_complaints = {}\n completed_complaints = ComplaintStatus.where(admin_user_id: user.id, status: \"completed\")\n elsif user.designation == \"ward officer\"\n ward = WardOffice.find(user.municipal_id)\n new_complaints = ComplaintStatus.where(admin_user_id: user.id)\n pending_complaints = ComplaintStatus.where(district_office_id: ward.district_office_id, ward_office_id: user.municipal_id,\n status: \"pending\")\n completed_complaints = ComplaintStatus.where(district_office_id: ward.district_office_id, ward_office_id: user.municipal_id,\n status: \"completed\")\n elsif user.designation == \"district officer\"\n new_complaints = ComplaintStatus.where(admin_user_id: user.id, status: \"new\")\n pending_complaints = ComplaintStatus.where(district_office_id: user.municipal_id, status: \"pending\")\n completed_complaints = ComplaintStatus.where(district_office_id: user.municipal_id, status: \"completed\")\n end\n render json: {new_complaint: new_complaints, pending_complaint: pending_complaints, completed_complaint: completed_complaints}\n end", "def show\n render json: @faculty\n end", "def prime_factors(num)\n facts = []\n\n (1..num).each do |i|\n if num % i == 0 && prime?(i)\n facts << i\n end\n end\n \n return facts\nend", "def index\n @cloth_measures = ClothMeasure.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cloth_measures }\n end\n end", "def index\n \n @evaluation = Evaluation.find_by(user_id: params[:user_id], study_case_id: params[:study_case_id])\n\n if @evaluation.present?\n render :show\n else\n render json: nil\n end\n \n end", "def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end", "def index\n @users = User.where(:listed => 1)\n if current_closed_challenge.present?\n @entries = Entry.where(:challenge_id => current_closed_challenge.id).limit(3)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Entry.all }\n end\n else\n respond_to do |format|\n format.html { render \"challenges/about\" }\n format.json { render json: Entry.all }\n end\n end\n end", "def index\n @labs = Lab.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @labs }\n end\n end", "def index\n @labs = Lab.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @labs }\n end\n end", "def index\n @competencies = Competency.all\n respond_to do |format|\n format.json { render json: @competencies }\n end\n end", "def index\n # @faculties = Faculty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Oj.dump(@faculties, mode: :compat) }\n end\n end", "def fetch\n http_request(url) do |body|\n incidents = JSON.parse body\n\n counts = {}\n total = incidents[\"resourceSets\"].first[\"estimatedTotal\"]\n resources = incidents[\"resourceSets\"].first[\"resources\"]\n resources.each do |resource|\n severity = resource[\"severity\"]\n counts[severity] = (counts.fetch severity, 0) + 1\n end\n\n @data = {}\n counts.each do |severity, count|\n @data[severity_label(severity)] = count\n end\n end\n end", "def index\n @team_challenges = TeamChallenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @team_challenges }\n end\n end", "def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render json: @challenges }\n end\n end", "def fetch_cdi_value\n token = get_financial_data_token\n if token\n\t\t\tactual_date = \"#{Date.current.year}-#{Date.current.month}-#{Date.current.day}\"\n\t\t\tif Cdi.all.count > 0\n\t\t\t\tlast_cdi_date = Cdi.last.date_tax + 1\n\t\t\telse\n\t\t\t\tlast_cdi_date = '2010-01-01'\n\t\t\tend\n uri = URI.parse(\"https://api.financialdata.io/v1/indices/CDI/serie?dataInicio=#{last_cdi_date}&dataFim=#{actual_date}\")\n header = {'Content-Type': 'application/json', 'Authorization': \"Bearer #{token}\"}\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new(uri.request_uri, header)\n response = http.request(request)\n return JSON.parse(response.read_body) \n end\n end", "def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end", "def index\n @disciplines = Discipline.paginate(:page => params[:page], per_page: 30)\n @number = Discipline.count\n respond_to do |format|\n format.html\n format.json { render :json => Discipline.all.to_json(include: :department) }\n end\n end", "def update\n respond_to do |format|\n if @critical.update(critical_params)\n format.html { redirect_to @critical, notice: 'Critical was successfully updated.' }\n format.json { render :show, status: :ok, location: @critical }\n else\n format.html { render :edit }\n format.json { render json: @critical.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_dashboards\n begin\n @msg = { status: STATUS_SUCCESS, doctor_lists: Doctor.get_lists, patient_lists: Patient.get_lists, appointments: Appointment.get_lists, message: SUCCESS_MESSAGE, token: request.headers[:Authorization].split(\"Token token=\").last, user: current_user.email }\n rescue Exception => e\n @msg = { status: STATUS_ERROR, message: CREDENTIAL_ERROR_MSG, token: request.headers[:Authorization].split(\"Token token=\").last, user: current_user.email }\n end\n render json: @msg\n end", "def index\n @classification_fund_sets = ClassificationFund.fetch_data\n end", "def index\n begin\n conditions = [\"club_id = ?\",@club.id]\n @courses = Course.find(:all, :order => 'id', :conditions => conditions)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n rescue\n render :layout => 'error', :template => 'errors/error'\n end\n end", "def show\n @chiropractic_compliance = ChiropracticCompliance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chiropractic_compliance }\n end\n end", "def index\n if params[:status]\n @tickets = Ticket.where(status: params[:status])\n else\n @tickets = Ticket.all\n @tickets_waiting = Ticket.where(status:\"waiting\")\n @tickets_resolved = Ticket.where(status:\"resolved\")\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tickets }\n end\n end", "def index\n @preference_criteria = PreferenceCriterium.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @preference_criteria }\n end\n end", "def foodcritic_evaluation\n require_evaluation_params\n\n create_metric(\n @cookbook_version,\n QualityMetric.foodcritic_metric,\n params[:foodcritic_failure],\n params[:foodcritic_feedback]\n )\n\n head 200\n end", "def critical! opts = nil\n NOCH.evaluate_for \"critical\", opts\n end", "def get_forms\n @course = Course.find(params[:course_id])\n @forms = @course.professor_forms\n render json: @forms\n end", "def create\n @faculties = Faculty.create!(faculty_params)\n json_response(@faculties, :created)\n end", "def index\n courses = Course.includes(:professors).includes(:ratings).all\n\n render json: courses.to_json(include: [:professors, :ratings])\n end", "def request_counter\n unfulfilled = Request.where(status: 0)\n fulfilled = Request.where(status: 1)\n if unfulfilled && fulfilled\n render json: {\n status: 'success',\n message: 'Your requests counter result',\n data: {\n unfulfilled: unfulfilled.length(),\n fulfilled: fulfilled.length()\n }\n },\n status: :ok\n else\n render status: :unprocessable_entity\n end\n end", "def index\n @care_plans = CarePlan.all\n render json: @care_plans\n end" ]
[ "0.7542314", "0.7035276", "0.68878484", "0.68253", "0.67529523", "0.6357071", "0.6354711", "0.6312489", "0.6142595", "0.61006904", "0.5948285", "0.5894403", "0.5838905", "0.57365304", "0.57193136", "0.56475127", "0.56422484", "0.5605748", "0.5488379", "0.546513", "0.5338059", "0.53195226", "0.53172314", "0.5295027", "0.52914447", "0.5254661", "0.5252986", "0.5231084", "0.5212918", "0.520351", "0.51852095", "0.51616347", "0.5158441", "0.5140865", "0.5114925", "0.5105963", "0.5082049", "0.50619715", "0.50600344", "0.50562084", "0.50557244", "0.50515324", "0.5046555", "0.50445265", "0.5037318", "0.50215507", "0.5019035", "0.5007906", "0.50056803", "0.50031066", "0.5000823", "0.49978396", "0.49969533", "0.49876982", "0.49864975", "0.4980027", "0.49797818", "0.49759087", "0.4971365", "0.49661022", "0.4962851", "0.4953386", "0.4946629", "0.49450645", "0.49436337", "0.4938915", "0.49380136", "0.4923049", "0.4919433", "0.4917212", "0.49163872", "0.49114087", "0.49106178", "0.4906821", "0.49052745", "0.48918584", "0.48877758", "0.48877758", "0.48867092", "0.48840764", "0.4881825", "0.48816273", "0.48813605", "0.48778838", "0.48772746", "0.48767948", "0.48698404", "0.48685774", "0.48668963", "0.4855375", "0.48507163", "0.48489225", "0.48467818", "0.4841985", "0.48385474", "0.4833536", "0.48162928", "0.48136064", "0.48084384", "0.48016962" ]
0.7713718
0
GET /critical_success_factors/1 GET /critical_success_factors/1.json
def show @critical_success_factor = CriticalSuccessFactor.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @critical_success_factor } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n\n @critical_success_factors = CriticalSuccessFactor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @critical_success_factors }\n end\n end", "def index\n @critical_factors = CriticalFactor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @critical_factors }\n end\n end", "def show\n @critical_factor = CriticalFactor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critical_factor }\n end\n end", "def new\n @critical_success_factor = CriticalSuccessFactor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_success_factor }\n end\n end", "def index\n @critical_success_factor_types = CriticalSuccessFactorType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @critical_success_factor_types }\n end\n end", "def show\n @critical_success_factor_type = CriticalSuccessFactorType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critical_success_factor_type }\n end\n end", "def new\n @critical_factor = CriticalFactor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_factor }\n end\n end", "def new\n @critical_success_factor_type = CriticalSuccessFactorType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_success_factor_type }\n end\n end", "def create\n @critical_success_factor = CriticalSuccessFactor.new(params[:critical_success_factor])\n @critical_success_factor.user = current_user\n @critical_success_factor.confidential = false\n\n respond_to do |format|\n if @critical_success_factor.save\n format.html { redirect_to @critical_success_factor, notice: 'Critical success factor was successfully created.' }\n format.json { render json: @critical_success_factor, status: :created, location: @critical_success_factor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @critical_success_factor.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @critical_success_factor = CriticalSuccessFactor.find(params[:id])\n @critical_success_factor.destroy\n\n respond_to do |format|\n format.html { redirect_to critical_success_factors_url }\n format.json { head :no_content }\n end\n end", "def update\n @critical_success_factor = CriticalSuccessFactor.find(params[:id])\n\n respond_to do |format|\n if @critical_success_factor.update_attributes(params[:critical_success_factor])\n format.html { redirect_to @critical_success_factor, notice: 'Critical success factor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @critical_success_factor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @critical_factor = CriticalFactor.new(params[:critical_factor])\n @critical_factor.user = current_user\n @critical_factor.confidential = false\n\n\n respond_to do |format|\n if @critical_factor.save\n format.html { redirect_to @critical_factor, notice: 'Critical factor was successfully created.'}\n format.json { render json: @critical_factor, status: :created, location: @critical_factor }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @critical_factor.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @critical_factor = CriticalFactor.find(params[:id])\n @critical_factor.destroy\n\n respond_to do |format|\n format.html { redirect_to critical_factors_url }\n format.json { head :no_content }\n end\n end", "def update\n @critical_factor = CriticalFactor.find(params[:id])\n\n respond_to do |format|\n if @critical_factor.update_attributes(params[:critical_factor])\n format.html { redirect_to @critical_factor, notice: 'Critical factor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @critical_factor.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @faculties = Faculty.all\n json_response(@faculties)\n end", "def faculties\n @faculties = Faculty.where(university_id: params[:university_id]).order(:name)\n @courses = []\n respond_to do |format|\n format.json { render json: @faculties }\n end\n end", "def api_request\n url = URI.parse(\"https://catfact.ninja/fact\")\n response = Net::HTTP.get_response(url)\n JSON.parse(response.body)[\"fact\"]\n end", "def index\n @criticals = Critical.all\n end", "def show\n @factor = Factor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @factor }\n end\n end", "def show\n @compromise = Compromise.find(params[:id])\n\n render json: @compromise\n end", "def create\n @critical = Critical.new(critical_params)\n\n respond_to do |format|\n if @critical.save\n format.html { redirect_to @critical, notice: 'Critical was successfully created.' }\n format.json { render :show, status: :created, location: @critical }\n else\n format.html { render :new }\n format.json { render json: @critical.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @critical_success_factor_type = CriticalSuccessFactorType.find(params[:id])\n @critical_success_factor_type.destroy\n\n respond_to do |format|\n format.html { redirect_to critical_success_factor_types_url }\n format.json { head :no_content }\n end\n end", "def index\n @code_factors = CodeFactor.all(:order => \"id DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @code_factors }\n format.json { \n\t \t@returns = []\n\t \t@code_factors.each do |code_factor|\n\t \t\t@returns << mapping_to_hash(code_factor, CodeFactor.json_mapping_table)\n\t\tend \n\t \trender :json => @returns\n\t }\n end\n end", "def index\n @constituency = Parliament::Utils::Helpers::FilterHelper.filter(@request, 'ConstituencyGroup').first\n end", "def show\n @patient_risk_factor = PatientRiskFactor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @patient_risk_factor }\n end\n end", "def show\n @critical_question = CriticalQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critical_question }\n end\n end", "def index\n @stage_certainty_factors = StageCertaintyFactor.all\n end", "def show\n @factors_user = FactorsUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @factors_user }\n end\n end", "def index\n if params[:problems].blank?\n @cases = Case.all\n else\n @cases = Case.as(:c).where('c.stock <= 1').pluck(:c)\n @cases.map!{|c| {\n id: c.id,\n name: c.name,\n stock: c.stock\n }}\n\n @cases.sort_by! {:name}\n\n render json: @cases\n end\n end", "def retrieve_attempted\n\t\trender json: @@contests_attempted_shared\n\tend", "def show\n @chiropractic_compliance = ChiropracticCompliance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chiropractic_compliance }\n end\n end", "def courses\n @courses = Course.where(faculty_id: params[:faculty_id]).order(:name)\n respond_to do |format|\n format.json { render json: @courses }\n end\n end", "def get_part_by_category\n @categorys = PartsController::PartService.get_part_by_category(params[:param]);\n respond_to do |format|\n format.json { render json: @categorys }\n end \n end", "def create\n @critical_success_factor_type = CriticalSuccessFactorType.new(params[:critical_success_factor_type])\n\n respond_to do |format|\n if @critical_success_factor_type.save\n format.html { redirect_to @critical_success_factor_type, notice: 'Tipo de Factor Crítico registrado correctamente.' }\n format.json { render json: @critical_success_factor_type, status: :created, location: @critical_success_factor_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @critical_success_factor_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @compromise = Compromise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @compromise }\n end\n end", "def show\n json_response(@faculty)\n end", "def index\n @ice_classs =IceClass.all\n render :json => {:successful=>true, :total=>@ice_classs.length, :data=> @ice_classs }\n end", "def index\n professors = Professor.includes(:courses).all\n\n render json: professors.to_json(include: :courses)\n end", "def fetch_cdi_value\n token = get_financial_data_token\n if token\n\t\t\tactual_date = \"#{Date.current.year}-#{Date.current.month}-#{Date.current.day}\"\n\t\t\tif Cdi.all.count > 0\n\t\t\t\tlast_cdi_date = Cdi.last.date_tax + 1\n\t\t\telse\n\t\t\t\tlast_cdi_date = '2010-01-01'\n\t\t\tend\n uri = URI.parse(\"https://api.financialdata.io/v1/indices/CDI/serie?dataInicio=#{last_cdi_date}&dataFim=#{actual_date}\")\n header = {'Content-Type': 'application/json', 'Authorization': \"Bearer #{token}\"}\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new(uri.request_uri, header)\n response = http.request(request)\n return JSON.parse(response.read_body) \n end\n end", "def index\n @given_circumstances = GivenCircumstance.all\n render json: @given_circumstances\n end", "def index\n @cloth_measures = ClothMeasure.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cloth_measures }\n end\n end", "def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end", "def test_canvas_api_studenta_courses\n refute_nil @w\n request_url = \"/courses?as_user_id=sis_login_id:studenta\"\n result_as_json = run_and_get_json_result(request_url)\n assert_operator result_as_json.length, \">=\", 1, \"got some classes back\"\n end", "def index\n @clusters = []\n @project = Project.where(:key => params[:project_key]).first\n\n get_cluster_data() \n render :partial => 'index'\n end", "def index\n @success_criterions = SuccessCriterion.all\n end", "def show\n render json: @course, status: :found\n end", "def index\n render jsonapi: Seances::UseCases::FetchAll.new.call\n end", "def fetch\n http_request(url) do |body|\n incidents = JSON.parse body\n\n counts = {}\n total = incidents[\"resourceSets\"].first[\"estimatedTotal\"]\n resources = incidents[\"resourceSets\"].first[\"resources\"]\n resources.each do |resource|\n severity = resource[\"severity\"]\n counts[severity] = (counts.fetch severity, 0) + 1\n end\n\n @data = {}\n counts.each do |severity, count|\n @data[severity_label(severity)] = count\n end\n end\n end", "def index\n @socio_cultural_factors = SocioCulturalFactor.all\n end", "def index\n @undergraduate_majors = UndergraduateMajor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @undergraduate_majors }\n end\n end", "def index\n \n @evaluation = Evaluation.find_by(user_id: params[:user_id], study_case_id: params[:study_case_id])\n\n if @evaluation.present?\n render :show\n else\n render json: nil\n end\n \n end", "def show\n render json: @faculty\n end", "def test_canvas_api_studenta_courses\n refute_nil @w\n request_url = \"/courses?as_user_id=sis_login_id:studenta\"\n result_as_json = run_and_get_ruby_result(request_url)\n assert_operator result_as_json.length, \">=\", 1, \"got some classes back\"\n end", "def index\n @courses = Course.all\n render json: @courses, status: :ok\n end", "def fetch_critical_chain_interaction_status\n\n @api_response_data[result_type] = CacheManagement::CriticalChainInteractionStatus.\n new([@critical_chain_interaction_log_id]).fetch[@critical_chain_interaction_log_id]\n\n success\n\n end", "def index\n @challenges = Challenge.user(current_user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end", "def index\n @certainties = Certainty.all\n end", "def index\n @competencies = Competency.all\n respond_to do |format|\n format.json { render json: @competencies }\n end\n end", "def index\n @technological_factors = TechnologicalFactor.all\n end", "def new\n @factor = Factor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @factor }\n end\n end", "def health\n render json: { status: 'OK' }\n end", "def index\n @health_levels = HealthLevel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @health_levels }\n end\n end", "def index\n @labs = Lab.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @labs }\n end\n end", "def index\n @labs = Lab.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @labs }\n end\n end", "def new\n @patient_risk_factor = PatientRiskFactor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patient_risk_factor }\n end\n end", "def index\n response = HTTParty.get(\"https://casa-core.herokuapp.com/api/units\", :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n @units = JSON.parse(response.body)\n return @units\n end", "def show\n @clinicalsection = Clinicalsection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clinicalsection }\n end\n end", "def show_complaint_by_id\n complaint = Complaint.find(params[:id])\n if complaint\n render json: complaint, methods: [:status]\n else\n render json: {status: \"error\", error_message: \"complaint not found\"}\n end\n end", "def index\n @majors = majors\n respond_to do |format|\n format.json{\n return render json: ret\n }\n end\n end", "def show\n @criterion = Criterion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @criterion }\n end\n end", "def index\n #@courses = @curriculum.courses\n\n @courses = ScopedCourse.where(:curriculum_id => @curriculum.id)\n .joins(:course_descriptions)\n .where([\"course_descriptions.locale = ?\", I18n.locale]).includes(:strict_prereqs)\n# .joins(<<-SQL\n# INNER JOIN course_descriptions\n# ON competence_nodes.abstract_course_id = course_descriptions.abstract_course_id\n# SQL\n# )\n\n respond_to do |format|\n #format.html # index.html.erb\n format.json do\n render :json => @courses.select(<<-SQL\n competence_nodes.id,\n competence_nodes.course_code,\n course_descriptions.name AS translated_name\n SQL\n ).to_json(:methods => :strict_prereq_ids, :root => true)\n end\n end\n end", "def index\n @care_plans = CarePlan.all\n render json: @care_plans\n end", "def index\n # @faculties = Faculty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Oj.dump(@faculties, mode: :compat) }\n end\n end", "def update\n @critical_success_factor_type = CriticalSuccessFactorType.find(params[:id])\n\n respond_to do |format|\n if @critical_success_factor_type.update_attributes(params[:critical_success_factor_type])\n format.html { redirect_to @critical_success_factor_type, notice: 'Tipo de Factor Crítico actualizado correctamente' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @critical_success_factor_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @form_factors = FormFactor.all\n end", "def index\n @incidentcategories = Incidentcategory.all\n json_response(@incidentcategories)\n end", "def index\n get_data\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @unit_of_measures }\n format.js\n end\n end", "def request_counter\n unfulfilled = Request.where(status: 0)\n fulfilled = Request.where(status: 1)\n if unfulfilled && fulfilled\n render json: {\n status: 'success',\n message: 'Your requests counter result',\n data: {\n unfulfilled: unfulfilled.length(),\n fulfilled: fulfilled.length()\n }\n },\n status: :ok\n else\n render status: :unprocessable_entity\n end\n end", "def get_subjects\n if params[:c].present?\n sc_id = params[:c].to_i\n subjects = Subject.joins(:school_cycle_has_subjects).where(\"school_cycle_id = ?\", sc_id)\n msg = { \"success\": \"true\", \"subjects\": subjects }\n else\n msg = { \"success\": false, \"subjects\": 0 }\n end\n\n render json: msg\n end", "def new\n @critical_question = CriticalQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_question }\n end\n end", "def render_health_json\n render :text => @results.values.to_json, :status => health_response_code\n end", "def index\n @challenges = Challenge.order(:id)\n .includes(:user)\n .page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end", "def update\n respond_to do |format|\n if @critical.update(critical_params)\n format.html { redirect_to @critical, notice: 'Critical was successfully updated.' }\n format.json { render :show, status: :ok, location: @critical }\n else\n format.html { render :edit }\n format.json { render json: @critical.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @contests = Contest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contests }\n end\n end", "def show\n @evaluable_competency = EvaluableCompetency.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluable_competency }\n end\n end", "def index\n @disciplines = Discipline.paginate(:page => params[:page], per_page: 30)\n @number = Discipline.count\n respond_to do |format|\n format.html\n format.json { render :json => Discipline.all.to_json(include: :department) }\n end\n end", "def index\n @contests = Contest.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contests }\n end\n end", "def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end", "def index\n @user_challenges = current_user.user_challenges.includes(:challenge)\n\n js progress: current_user.complete_challenges.count / Challenge.count.to_f * 100\n end", "def show\n @kf_course_index = Kf::CourseIndex.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kf_course_index }\n end\n end", "def index\n @frontend_critics = Frontend::Critic.all\n \n \n end", "def index\n @matrix = CourseMatrix.find(params[:course_matrix_id])\n @matrix_disciplines = MatrixDiscipline.where(:matrix_id => @matrix.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @matrix_disciplines }\n end\n end", "def index\n if params[:status]\n @tickets = Ticket.where(status: params[:status])\n else\n @tickets = Ticket.all\n @tickets_waiting = Ticket.where(status:\"waiting\")\n @tickets_resolved = Ticket.where(status:\"resolved\")\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tickets }\n end\n end", "def index\n @disciplines = Discipline.all\n #respond_to do |format|\n # format.json { render json: @disciplines, status: :ok }\n #end\n #render json: @disciplines, status: :ok\n respond_with @disciplines\n end", "def index\n @team_challenges = TeamChallenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @team_challenges }\n end\n end", "def create\n @faculties = Faculty.create!(faculty_params)\n json_response(@faculties, :created)\n end", "def full_level_progression_response\n return api_response(\"level-progression\")\n end", "def index\n @course_statuses = CourseStatus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @course_statuses }\n end\n end", "def show \n counter=Counter.find(params[:id])\n render json:{status: 'SUCCESS', message: 'Loaded Counter by ID', data:counter},status: :ok\n end", "def index\n @preference_criteria = PreferenceCriterium.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @preference_criteria }\n end\n end" ]
[ "0.7760992", "0.7490721", "0.71550596", "0.70704776", "0.6976947", "0.681886", "0.6579742", "0.6507896", "0.6408299", "0.6123977", "0.6086433", "0.60767424", "0.59294486", "0.57923096", "0.5729273", "0.56938595", "0.56392246", "0.56218475", "0.5566322", "0.55270743", "0.55025977", "0.5502067", "0.5501433", "0.54898584", "0.5452456", "0.54191726", "0.53517133", "0.5350759", "0.53277344", "0.5314482", "0.5281296", "0.5270114", "0.52591354", "0.525877", "0.5253831", "0.5239049", "0.52197117", "0.52124965", "0.52123654", "0.5211853", "0.5210833", "0.52105963", "0.5210211", "0.5205609", "0.5203355", "0.518388", "0.5176781", "0.5176642", "0.51720905", "0.5171872", "0.516503", "0.5157604", "0.5153166", "0.51492614", "0.5148057", "0.51465005", "0.5146185", "0.5143163", "0.5142313", "0.5138171", "0.51352704", "0.5130983", "0.5128677", "0.5128677", "0.51276344", "0.5126648", "0.5104078", "0.50929135", "0.5092067", "0.5089683", "0.5087111", "0.50870454", "0.50834864", "0.5082854", "0.5082219", "0.50809383", "0.5065678", "0.5064008", "0.50595033", "0.50565976", "0.5051833", "0.5048917", "0.50463086", "0.50460887", "0.50457", "0.5040495", "0.5039366", "0.50385416", "0.5035218", "0.5033514", "0.50296956", "0.502934", "0.50267583", "0.5019962", "0.5015744", "0.50111264", "0.50109935", "0.50024045", "0.49996975", "0.49957347" ]
0.74050236
2
GET /critical_success_factors/new GET /critical_success_factors/new.json
def new @critical_success_factor = CriticalSuccessFactor.new respond_to do |format| format.html # new.html.erb format.json { render json: @critical_success_factor } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @critical_factor = CriticalFactor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_factor }\n end\n end", "def new\n @critical_success_factor_type = CriticalSuccessFactorType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_success_factor_type }\n end\n end", "def create\n @critical_success_factor = CriticalSuccessFactor.new(params[:critical_success_factor])\n @critical_success_factor.user = current_user\n @critical_success_factor.confidential = false\n\n respond_to do |format|\n if @critical_success_factor.save\n format.html { redirect_to @critical_success_factor, notice: 'Critical success factor was successfully created.' }\n format.json { render json: @critical_success_factor, status: :created, location: @critical_success_factor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @critical_success_factor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @critical_factor = CriticalFactor.new(params[:critical_factor])\n @critical_factor.user = current_user\n @critical_factor.confidential = false\n\n\n respond_to do |format|\n if @critical_factor.save\n format.html { redirect_to @critical_factor, notice: 'Critical factor was successfully created.'}\n format.json { render json: @critical_factor, status: :created, location: @critical_factor }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @critical_factor.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @factor = Factor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @factor }\n end\n end", "def create\n @critical_success_factor_type = CriticalSuccessFactorType.new(params[:critical_success_factor_type])\n\n respond_to do |format|\n if @critical_success_factor_type.save\n format.html { redirect_to @critical_success_factor_type, notice: 'Tipo de Factor Crítico registrado correctamente.' }\n format.json { render json: @critical_success_factor_type, status: :created, location: @critical_success_factor_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @critical_success_factor_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @critical = Critical.new(critical_params)\n\n respond_to do |format|\n if @critical.save\n format.html { redirect_to @critical, notice: 'Critical was successfully created.' }\n format.json { render :show, status: :created, location: @critical }\n else\n format.html { render :new }\n format.json { render json: @critical.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @risk_classification = RiskClassification.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @risk_classification }\n end\n end", "def new\n @critical_question = CriticalQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critical_question }\n end\n end", "def new\n @patient_risk_factor = PatientRiskFactor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patient_risk_factor }\n end\n end", "def new\n @threshold = Threshold.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @threshold }\n end\n end", "def new\n @class_taken = ClassTaken.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @class_taken }\n end\n end", "def new\n @criterion = Criterion.new\n render json: @criterion\n end", "def index\n\n @critical_success_factors = CriticalSuccessFactor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @critical_success_factors }\n end\n end", "def new\n @criterion = Criterion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @criterion }\n end\n end", "def new\n @compromise = Compromise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @compromise }\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 @classified = Classified.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @classified }\n end\n end", "def create\n @factor = Factor.new(params[:factor])\n\n respond_to do |format|\n if @factor.save\n format.html { redirect_to @factor, notice: 'Factor was successfully created.' }\n format.json { render json: @factor, status: :created, factor: @factor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @factor.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @preceed = Preceed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @preceed }\n end\n end", "def new\n @fact = fact_type.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fact }\n end\n end", "def new\n @complexity = Complexity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @complexity }\n end\n end", "def create\n @patient_risk_factor = PatientRiskFactor.new(params[:patient_risk_factor])\n\n respond_to do |format|\n if @patient_risk_factor.save\n format.html { redirect_to @patient_risk_factor, :notice => 'Patient risk factor was successfully created.' }\n format.json { render json: @patient_risk_factor, status: :created, location: @patient_risk_factor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @patient_risk_factor.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @lab = Lab.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lab }\n end\n end", "def new\n @lab = Lab.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lab }\n end\n end", "def new\n @uni_major = UniMajor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @uni_major }\n end\n end", "def index\n @critical_factors = CriticalFactor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @critical_factors }\n end\n end", "def new\n @chiropractic_compliance = ChiropracticCompliance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @chiropractic_compliance }\n end\n end", "def new\n @facility = Facility.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @facility }\n end\n end", "def new\n @facility_total = FacilityTotal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @facility_total }\n end\n end", "def new\n @faculty_notice = FacultyNotice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @faculty_notice }\n end\n end", "def new\n @title = 'New Clinical Specialty'\n @description = 'Add a new clinical specialty'\n @clinicalsection = Clinicalsection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clinicalsection }\n end\n end", "def new\n @proficiency = Proficiency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @proficiency }\n end\n end", "def new\n @cluster = Cluster.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cluster }\n end\n end", "def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trial }\n end\n end", "def new\n @training_level = TrainingLevel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @training_level }\n end\n end", "def new\n @undergraduate_major = UndergraduateMajor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @undergraduate_major }\n end\n end", "def new\n @clasp = Clasp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clasp }\n end\n end", "def create\n @faculties = Faculty.create!(faculty_params)\n json_response(@faculties, :created)\n end", "def new\n @risk_level = RiskLevel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @risk_level }\n end\n end", "def new\n @ci = Ci.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ci }\n end\n end", "def show\n @critical_success_factor = CriticalSuccessFactor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critical_success_factor }\n end\n end", "def new\n @civil_status = CivilStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @civil_status }\n end\n end", "def new\n @classtable = Classtable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @classtable }\n end\n end", "def new\n @major = Major.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @major }\n end\n end", "def new\n @critic = Critic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critic }\n end\n end", "def new\n @categories = Category.where(validity: true)\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @decision = Decision.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @decision }\n end\n end", "def new\n @needed_good = NeededGood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @needed_good }\n end\n end", "def new\n @slab = Slab.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @slab }\n end\n end", "def new\n @requirement_priority = RequirementPriority.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @requirement_priority }\n end\n end", "def new\n @course_status = CourseStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @course_status }\n end\n end", "def new\n @when_factor = WhenFactor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @when_factor }\n end\n end", "def create\n @factors_user = FactorsUser.new(params[:factors_user])\n\n respond_to do |format|\n if @factors_user.save\n format.html { redirect_to \"/factors_users/new?factor_id=#{@factors_user.factor_id + 1}\", notice: 'Factors user was successfully created.' }\n format.json { render json: @factors_user, status: :created, location: @factors_user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @factors_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @contribution = Contribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contribution }\n end\n end", "def new\n @ticket = Ticket.new(sprint: Sprint.current!)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ticket }\n end\n end", "def new\n @evaluationstatus = Evaluationstatus.new\n @title = 'New Evaluation Status'\n @description = 'Add a new evaluation status to the system'\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @evaluationstatus }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @health_level }\n end\n end", "def new\n @breadcrumb = 'create'\n @ticket_priority = TicketPriority.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ticket_priority }\n end\n end", "def new\n @challenge = Challenge.new\n add_breadcrumb 'new', @challenge\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @challenge }\n end\n end", "def new\n @competency = Competency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competency }\n end\n end", "def new\n @evaluable_competency = EvaluableCompetency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @evaluable_competency }\n end\n end", "def new\n @clinical_course = ClinicalCourse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clinical_course }\n end\n end", "def create\n @form_factor = FormFactor.new(form_factor_params)\n\n respond_to do |format|\n if @form_factor.save\n format.html { redirect_to @form_factor, notice: 'Form factor was successfully created.' }\n format.json { render :show, status: :created, location: @form_factor }\n else\n format.html { render :new }\n format.json { render json: @form_factor.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @medium_trial = MediumTrial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medium_trial }\n end\n end", "def create\n @technological_factor = TechnologicalFactor.new(technological_factor_params)\n\n respond_to do |format|\n if @technological_factor.save\n format.html { redirect_to @technological_factor, notice: 'Technological factor was successfully created.' }\n format.json { render :show, status: :created, location: @technological_factor }\n else\n format.html { render :new }\n format.json { render json: @technological_factor.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @factors_user = FactorsUser.new\n \n if (params.has_key? :factor_id and params[:factor_id].to_i > 0)\n this_factor = Factor.where(\"id >= #{params[:factor_id]} and show_in_survey = true\").order(\"id asc\").first\n else\n this_factor = Factor.first\n end\n \n if this_factor.present?\n @factor_id = this_factor.id\n else \n respond_to do |format|\n format.html { redirect_to \"/factors_users\", notice: 'Survey completed.' and return }\n end\n end \n\n @user_id = User.last.id\n #@last_factors_user_id = FactorsUser.last.id\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @factors_user }\n end\n end", "def new\n @complaint = Complaint.new\n\n render json: @complaint\n end", "def show\n @critical_factor = CriticalFactor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critical_factor }\n end\n end", "def new\n @request_status = RequestStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request_status }\n end\n end", "def new\n @accuracy = Accuracy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @accuracy }\n end\n end", "def new\n @faculty_update = FacultyUpdate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @faculty_update }\n end\n end", "def new\n @lab_method = LabMethod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lab_method }\n end\n end", "def new\n @lab_name = LabName.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lab_name }\n end\n end", "def new\n @contacter = Contacter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contacter }\n end\n end", "def new\n @tickets_count = Helpdesk::Ticket.where(:requester_id => helpdesk_user.id).active.count\n @ticket = Helpdesk::Ticket.new\n @ticket.status = Helpdesk::Ticket::STATUSES[0][0]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ticket }\n end\n end", "def new\n puts @category.inspect\n @internal = @category.internals.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @internal }\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 @control_list_factor = ControlListFactor.new(control_list_factor_params)\n\n respond_to do |format|\n if @control_list_factor.save\n format.html { redirect_to control_list_factors_path, notice: '' }\n format.json { render :show, status: :created, location: @control_list_factor }\n else\n format.html { render :new }\n format.json { render json: @control_list_factor.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @important_issue = ImportantIssue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @important_issue }\n end\n end", "def new\n @precinct = Precinct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @precinct }\n end\n end", "def new\n @level_category = LevelCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level_category }\n end\n end", "def new\n @civilization = Civilization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @civilization }\n end\n end", "def create\n @when_factor = WhenFactor.new(params[:when_factor])\n\n respond_to do |format|\n if @when_factor.save\n format.html { redirect_to(@when_factor, :notice => 'WhenFactor was successfully created.') }\n format.xml { render :xml => @when_factor, :status => :created, :location => @when_factor }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @when_factor.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n add_breadcrumb \"nueva\", :new_contest_path\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contest }\n end\n end", "def new\n @status = Status.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @status }\n end\n end", "def new\n @prob = Prob.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prob }\n end\n end", "def new\n @constitution = Constitution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @constitution }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @certification }\n end\n end", "def new\n @kickoff = Kickoff.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kickoff }\n end\n end", "def new\n @part_three_predict = PartThreePredict.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @part_three_predict }\n end\n end", "def new\n @fact = Fact.new\n @restriction = @fact.build_restriction\n @feature = @restriction.build_feature\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fact }\n end\n end", "def new\n @patentcase = Patentcase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @patentcase }\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\n @competency_pertenece_evaluation = CompetencyPerteneceEvaluation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competency_pertenece_evaluation }\n end\n end", "def new\n @normal_issue = NormalIssue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @normal_issue }\n end\n end", "def new\n @prime = Prime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prime }\n end\n end", "def create\n @critical_question = CriticalQuestion.new(params[:critical_question])\n\n respond_to do |format|\n if @critical_question.save\n format.html { redirect_to @critical_question, notice: 'Critical question was successfully created.' }\n format.json { render json: @critical_question, status: :created, location: @critical_question }\n else\n format.html { render action: \"new\" }\n format.json { render json: @critical_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @kf_status = Kf::Status.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kf_status }\n end\n end", "def new\n @lab_course = LabCourse.new\n @id = params[:lab_eval_project_id]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lab_course }\n end\n end" ]
[ "0.8038973", "0.7913525", "0.74515563", "0.7220769", "0.69315344", "0.6803707", "0.6773709", "0.6693067", "0.6659558", "0.6656785", "0.6559581", "0.6552675", "0.6540636", "0.65270823", "0.6507469", "0.64759463", "0.64443916", "0.6435019", "0.6427685", "0.64134604", "0.6408607", "0.6405973", "0.63887423", "0.63755727", "0.63755727", "0.6368385", "0.63627267", "0.6358089", "0.6336236", "0.6334023", "0.63299483", "0.63217795", "0.6316046", "0.63149107", "0.63068163", "0.6304194", "0.63035357", "0.6301059", "0.62993014", "0.6293111", "0.62852824", "0.62585765", "0.6256932", "0.62513757", "0.6248481", "0.6243935", "0.6222058", "0.6221013", "0.62200636", "0.62187564", "0.6216409", "0.6205598", "0.61957175", "0.618956", "0.61783177", "0.6178257", "0.6170578", "0.6167611", "0.6157495", "0.6157317", "0.6156848", "0.61555153", "0.6154777", "0.61520886", "0.61379415", "0.61328316", "0.6130785", "0.6129365", "0.6128516", "0.6127208", "0.61268485", "0.6125768", "0.6125006", "0.61217016", "0.6117421", "0.61173636", "0.61163276", "0.6114269", "0.61097944", "0.6100389", "0.6090974", "0.60890263", "0.60885066", "0.6088392", "0.608815", "0.6081555", "0.6079402", "0.6074653", "0.6073498", "0.60722417", "0.60704595", "0.60690933", "0.6068527", "0.60681105", "0.6066116", "0.60650253", "0.60630566", "0.60565567", "0.6054639", "0.6053214" ]
0.8251769
0