query
stringlengths
7
6.41k
document
stringlengths
12
28.8k
metadata
dict
negatives
sequencelengths
30
30
negative_scores
sequencelengths
30
30
document_score
stringlengths
5
10
document_rank
stringclasses
2 values
GET /attribute_layers/1 GET /attribute_layers/1.json
def show @attribute_layer = AttributeLayer.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @attribute_layer } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n # @attribute_layer = @palette.attribute_layers.find(attribute_layer_params[:id])\n end", "def index\n @attribute_layers = @palette.attribute_layers.all\n end", "def new\n @attribute_layer = AttributeLayer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attribute_layer }\n end\n end", "def create\n @attribute_layer = @palette.attribute_layers.new(attribute_layer_params)\n\n respond_to do |format|\n if @attribute_layer.save\n format.html { redirect_to [@palette, @attribute_layer], notice: 'Attribute layer was successfully created.' }\n format.json { render action: 'show', status: :created, location: @attribute_layer }\n else\n format.html { render action: 'new' }\n format.json { render json: @attribute_layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n render json: @attribute_set\n end", "def update\n @attribute_layer = AttributeLayer.find(params[:id])\n\n respond_to do |format|\n if @attribute_layer.update_attributes(params[:attribute_layer])\n format.html { redirect_to @attribute_layer, notice: 'Attribute layer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @attribute_layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @attribute_layer = AttributeLayer.find(params[:id])\n @attribute_layer.destroy\n\n respond_to do |format|\n format.html { redirect_to attribute_layers_url }\n format.json { head :no_content }\n end\n end", "def update\n # @attribute_layer = @palette.attribute_layers.find(attribute_layer_params[:id])\n respond_to do |format|\n if @attribute_layer.update(attribute_layer_params)\n format.html { redirect_to [@palette, @attribute_layer], notice: 'Attribute layer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @attribute_layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n # @attribute_layer = @palette.attribute_layers.find(attribute_layer_params[:id])\n @attribute_layer.destroy\n respond_to do |format|\n format.html { redirect_to palette_attribute_layers_url(@palette) }\n format.json { head :no_content }\n end\n end", "def layers \n self.layerlist :layersonly=>true\n end", "def index\n @attribute_sets = AttributeSet.all\n render json: @attribute_sets\n end", "def create\n @attribute_layer = AttributeLayer.new(params[:attribute_layer])\n puts \"---------------------------------------------\"\n respond_to do |format|\n if @attribute_layer.save\n format.html { redirect_to @attribute_layer, notice: 'Attribute layer was successfully created.' }\n format.json { render json: @attribute_layer, status: :created, location: @attribute_layer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attribute_layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def attribute_layer_params\n params.require(:attribute_layer).permit(:label, :palette_id)\n end", "def get_layer\n @layer = Layer.find(params[:layer_id])\n end", "def get_layer\n @layer = Layer.find(params[:layer_id])\n end", "def get_layer\n @layer = Layer.find(params[:layer_id])\n end", "def show\n #@ru = request.original_url\n @ru = request.protocol + request.host_with_port + \"/layers/#{params['id']}\"\n #@ru = params['id']\n @annotation_layer = AnnotationLayer.where(layer_id: @ru).first\n\n # replace @ru with hostUrl environment variable\n host_url_prefix = Rails.application.config.hostUrl\n\n\n #authorize! :show, @annotation_layer\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @annotation_layer.to_iiif, content_type: \"application/json\" }\n end\n end", "def show\n @attribute = Attribute.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attribute }\n end\n end", "def layers options={}\n standard_list Conjur::API.layer_asset_host, :layer, options\n end", "def show\n @attribute = Attribute.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @attribute }\n end\n end", "def get_layers\n Geoloqi::Session.new(:access_token => CONFIG[:geoloqi][:app_access_token]).get('layer/list')[:layers]\nend", "def index\n @layers = Layer.all\n end", "def show\n @taxon = Taxon.find(params[:id])\n @layers = @taxon.layers.page(page).per(25)\n @geo_contexts = @taxon.geo_contexts.page(page).per(25)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taxon }\n end\n end", "def layers\n @layers ||= GeoIQ.get(\"#{path}/layers.json\")#.parsed_response#.map {|layer| GeoIQ::Layer.new(layer.merge('map_id' => id)) }\n end", "def get_layers\n Geoloqi::Session.new(:access_token => CONFIG['geoloqi']['app_access_token']).get('layer/list')[:layers]\nend", "def api_attributes(layers)\n h = {\n id: id,\n user_id: user_id,\n container_id: container_id,\n amount: amount,\n details: details,\n created_at: created_at,\n }\n\n h\n end", "def show\n @ais_attribute = AisAttribute.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ais_attribute }\n end\n end", "def show\n @layer_filter = LayerFilter.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @layer_filter }\n format.json { render :json => @layer_filter }\n end\n end", "def show\n @layers = Layer.where(:soil_id => params[:id])\n respond_to do |format|\n\t redirect_to @layers\n format.json { render json: @layers }\n end\n end", "def show\n @layer = Layer.find(params[:id])\n areas_json = @layer.areas.map do |area|\n {area_id: area.id, polygon: area.polygon}\n end\n @result = {id: @layer.id, name: @layer.name, number_of_polygons: @layer.areas.count, areas: areas_json }\n\n base_url = \"#{request.protocol}#{request.host_with_port}\"\n permalink_hash = PermalinkController.generate_json(base_url, 'layers/show', @layer, @tolerance)\n @permalink = permalink_hash[:url]\n @data_json = permalink_hash[:data_json]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: {:layer => @layer, :data_json => @data_json, :permalink => @permalink} }\n format.topojson { render json: @layer.to_topojson }\n end\n end" ]
[ "0.708815", "0.6863708", "0.6739711", "0.6241973", "0.6240795", "0.619612", "0.6171272", "0.6137455", "0.60827386", "0.5998449", "0.59869266", "0.5977867", "0.5964081", "0.59019965", "0.59019965", "0.59019965", "0.5881812", "0.5710326", "0.5668596", "0.56614006", "0.5647556", "0.5637047", "0.56336385", "0.5626268", "0.5607878", "0.5580102", "0.5554411", "0.55535644", "0.55283046", "0.54885423" ]
0.76378375
0
GET /attribute_layers/new GET /attribute_layers/new.json
def new @attribute_layer = AttributeLayer.new respond_to do |format| format.html # new.html.erb format.json { render json: @attribute_layer } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @attribute_layer = @palette.attribute_layers.new(attribute_layer_params)\n\n respond_to do |format|\n if @attribute_layer.save\n format.html { redirect_to [@palette, @attribute_layer], notice: 'Attribute layer was successfully created.' }\n format.json { render action: 'show', status: :created, location: @attribute_layer }\n else\n format.html { render action: 'new' }\n format.json { render json: @attribute_layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @layer = Layer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @layer }\n end\n end", "def create\n @attribute_layer = AttributeLayer.new(params[:attribute_layer])\n puts \"---------------------------------------------\"\n respond_to do |format|\n if @attribute_layer.save\n format.html { redirect_to @attribute_layer, notice: 'Attribute layer was successfully created.' }\n format.json { render json: @attribute_layer, status: :created, location: @attribute_layer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attribute_layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @attribute = Attribute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attribute }\n end\n end", "def new\n @attribute = Attribute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @attribute }\n end\n end", "def create_layer(attributes = {})\n query = {:query => attributes}\n GeoIQ.post(\"#{path}/layers.json\", query)\n # GeoIQ::Layer.new(GeoIQ.post(\"#{path}/layers.json\", query).parsed_response.merge('map_id' => id))\n end", "def new\n @layer_filter = LayerFilter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @layer_filter }\n format.json { render :json => @layer_filter }\n end\n end", "def new\n @path = Path.new({:layer => @layer})\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @path }\n end\n end", "def new\n @map_layer = MapLayer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @map_layer }\n end\n end", "def new\n @ais_attribute = AisAttribute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ais_attribute }\n end\n end", "def new\n @hidden_neuron_layer = HiddenNeuronLayer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hidden_neuron_layer }\n end\n end", "def create\n @layer = Layer.new(params[:layer])\n\n respond_to do |format|\n if @layer and @layer.save\n @layers = Layer.all\n format.html { redirect_to layers_path, notice: 'Layer was successfully created.' }\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n else\n format.html { render action: \"new\" }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @attri = Attri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attri }\n end\n end", "def new\n @lift = Lift.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lift }\n end\n end", "def new\n @collection_attribute = CollectionAttribute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @collection_attribute }\n end\n end", "def new\n @point = Point.new({:layer => @layer})\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @point }\n end\n end", "def new\n @attr_val = AttrVal.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attr_val }\n end\n end", "def new\n @attribute_group = AttributeGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @attribute_group }\n end\n end", "def new\n @taxon_attribute = TaxonAttribute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @taxon_attribute }\n end\n end", "def create\n @layer = Layer.new(layer_params)\n\n respond_to do |format|\n if @layer.save\n format.html { redirect_to @layer, notice: 'Layer was successfully created.' }\n format.json { render :show, status: :created, location: @layer }\n else\n format.html { render :new }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @chef_mapping = ChefMapping.new\n @source = []\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @chef_mapping }\n end\n end", "def new\n @actattribute = Actattribute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @actattribute }\n end\n end", "def new\n @overlay = Overlay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @overlay }\n end\n end", "def new\n @attr_type = AttrType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @attr_type }\n end\n end", "def new\n @dimension = Dimension.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @dimension }\n end\n end", "def new\n @prd_attribute = PrdAttribute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prd_attribute }\n format.json { render :json => @prd_attribute }\n end\n end", "def new\n @criterion = Criterion.new\n render json: @criterion\n end", "def new\n @feature_model = FeatureModel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @feature_model }\n end\n end", "def new\n @feature = Feature.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feature }\n end\n end", "def new\n @feature = Feature.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feature }\n end\n end" ]
[ "0.74107754", "0.72874194", "0.7249065", "0.6979873", "0.69274044", "0.6707557", "0.66481906", "0.654877", "0.65133905", "0.6489432", "0.6458325", "0.6393509", "0.63915044", "0.6276942", "0.62678933", "0.62502575", "0.62313426", "0.6210743", "0.6210738", "0.61891913", "0.6162869", "0.6143319", "0.61254984", "0.612248", "0.6115546", "0.608862", "0.6077631", "0.60741794", "0.6061009", "0.6061009" ]
0.8384585
0
POST /attribute_layers POST /attribute_layers.json
def create @attribute_layer = AttributeLayer.new(params[:attribute_layer]) puts "---------------------------------------------" respond_to do |format| if @attribute_layer.save format.html { redirect_to @attribute_layer, notice: 'Attribute layer was successfully created.' } format.json { render json: @attribute_layer, status: :created, location: @attribute_layer } else format.html { render action: "new" } format.json { render json: @attribute_layer.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @attribute_layer = @palette.attribute_layers.new(attribute_layer_params)\n\n respond_to do |format|\n if @attribute_layer.save\n format.html { redirect_to [@palette, @attribute_layer], notice: 'Attribute layer was successfully created.' }\n format.json { render action: 'show', status: :created, location: @attribute_layer }\n else\n format.html { render action: 'new' }\n format.json { render json: @attribute_layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def attribute_layer_params\n params.require(:attribute_layer).permit(:label, :palette_id)\n end", "def create_layer(attributes = {})\n query = {:query => attributes}\n GeoIQ.post(\"#{path}/layers.json\", query)\n # GeoIQ::Layer.new(GeoIQ.post(\"#{path}/layers.json\", query).parsed_response.merge('map_id' => id))\n end", "def new\n @attribute_layer = AttributeLayer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attribute_layer }\n end\n end", "def create\n @layer = Layer.new(params[:layer])\n\n respond_to do |format|\n if @layer and @layer.save\n @layers = Layer.all\n format.html { redirect_to layers_path, notice: 'Layer was successfully created.' }\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n else\n format.html { render action: \"new\" }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @layerIn = JSON.parse(params.to_json)\n @layer = Hash.new\n #@ru = request.original_url\n @ru = request.original_url.split('?').first\n @ru += '/' if !@ru.end_with? '/'\n @layer['layer_id'] = @ru + SecureRandom.uuid\n @layer['layer_type'] = @layerIn['@type']\n @layer['label'] = @layerIn['label']\n @layer['motivation'] = @layerIn['motivation']\n #@layer['description'] = @layerIn['description']\n @layer['license'] = @layerIn['license']\n @layer['version'] = 1\n @annotation_layer = AnnotationLayer.new(@layer)\n\n #authorize! :create, @annotation_layer\n request.format = \"json\"\n respond_to do |format|\n if @annotation_layer.save\n format.html { redirect_to @annotation_layer, notice: 'Annotation layer was successfully created.' }\n format.json { render json: @annotation_layer.to_iiif, status: :created, location: @annotation_layer, content_type: \"application/json\" }\n else\n format.html { render action: \"new\" }\n format.json { render json: @annotation_layer.errors, status: :unprocessable_entity, content_type: \"application/json\" }\n end\n end\n end", "def destroy\n # @attribute_layer = @palette.attribute_layers.find(attribute_layer_params[:id])\n @attribute_layer.destroy\n respond_to do |format|\n format.html { redirect_to palette_attribute_layers_url(@palette) }\n format.json { head :no_content }\n end\n end", "def update\n # @attribute_layer = @palette.attribute_layers.find(attribute_layer_params[:id])\n respond_to do |format|\n if @attribute_layer.update(attribute_layer_params)\n format.html { redirect_to [@palette, @attribute_layer], notice: 'Attribute layer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @attribute_layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @layer = Layer.new(layer_params)\n\n respond_to do |format|\n if @layer.save\n format.html { redirect_to @layer, notice: 'Layer was successfully created.' }\n format.json { render :show, status: :created, location: @layer }\n else\n format.html { render :new }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @attribute_layer = AttributeLayer.find(params[:id])\n\n respond_to do |format|\n if @attribute_layer.update_attributes(params[:attribute_layer])\n format.html { redirect_to @attribute_layer, notice: 'Attribute layer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @attribute_layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @attribute_layer = AttributeLayer.find(params[:id])\n @attribute_layer.destroy\n\n respond_to do |format|\n format.html { redirect_to attribute_layers_url }\n format.json { head :no_content }\n end\n end", "def attribute_set_params\n params.require(:attribute_set).permit(:name, :legend_img_filename, :string)\n end", "def update\n @layer = Layer.find(params[:id])\n\n respond_to do |format|\n if @layer.update_attributes(params[:layer])\n @layers = Layer.all\n format.html { redirect_to @layer, notice: 'Layer was successfully updated.' }\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @image_attrib = ImageAttrib.new(image_attrib_params)\n\n if @image_attrib.save\n render :show, status: :created, location: @image_attrib\n else\n render json: @image_attrib.errors, status: :unprocessable_entity\n end\n end", "def layer_params\n params.require(:layer).permit(:name, :category_id, :url, :params, :ckan_id, style: [:color])\n end", "def index\n @attribute_layers = @palette.attribute_layers.all\n end", "def create\n @map_layer = MapLayer.new(params[:map_layer])\n\n respond_to do |format|\n if @map_layer.save\n flash[:notice] = 'Map Layer was successfully created.'\n format.html { redirect_to(@map_layer) }\n format.xml { render :xml => @map_layer, :status => :created, :location => @map_layer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @map_layer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def show\n @attribute_layer = AttributeLayer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attribute_layer }\n end\n end", "def api_attributes(layers)\n h = {\n id: id,\n user_id: user_id,\n container_id: container_id,\n amount: amount,\n details: details,\n created_at: created_at,\n }\n\n h\n end", "def create\n @attribute_set = AttributeSet.new(attribute_set_params)\n\n respond_to do |format|\n if @attribute_set.save\n format.html { redirect_to @attribute_set, notice: 'Attribute set was successfully created.' }\n format.json { render :show, status: :created, location: @attribute_set }\n else\n format.html { render :new }\n format.json { render json: @attribute_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n # @attribute_layer = @palette.attribute_layers.find(attribute_layer_params[:id])\n end", "def layer=(layer)\n end", "def create\n @hidden_neuron_layer = HiddenNeuronLayer.new(params[:hidden_neuron_layer])\n\n respond_to do |format|\n if @hidden_neuron_layer.save\n format.html { redirect_to @hidden_neuron_layer, notice: 'Hidden neuron layer was successfully created.' }\n format.json { render json: @hidden_neuron_layer, status: :created, location: @hidden_neuron_layer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @hidden_neuron_layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @attribute_list = @character.build_attribute_list(attribute_list_params)\n\n respond_to do |format|\n if @attribute_list.save\n format.html { redirect_to set_race_character_path(@character) }\n format.json { render action: 'show', status: :created, location: @attribute_list }\n else\n format.html { render action: 'new' }\n format.json { render json: @attribute_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def createLayers()\n @layers_array = import() \n end", "def create\n @exp_attribute = ExpAttribute.new(exp_attribute_params)\n\n if @exp_attribute.save\n render :show, status: :created, location: @exp_attribute\n else\n render json: @exp_attribute.errors, status: :unprocessable_entity\n end\n end", "def add_layer\n puts \"made it to PL add layer\"\n Layer.create(:name => @new_table_name, :table_name => @new_table_name, :geometric_column_name => \"the_geom\")\n end", "def new\n @layer = Layer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @layer }\n end\n end", "def add_layer\n Layer.create(:name => @new_table_name, :table_name => @new_table_name, :geometric_column_name => \"the_geom\")\n end", "def save_layers()\n @layers_array.each do |layer|\n layer.map_id = self.id\n layer.init\n layer.save!\n end\n end" ]
[ "0.7487247", "0.7067765", "0.6627036", "0.6584556", "0.64409095", "0.6434468", "0.6163704", "0.6119112", "0.6110361", "0.6081864", "0.5999241", "0.5813739", "0.5635491", "0.5634665", "0.5620239", "0.55829895", "0.55353117", "0.55306417", "0.53876394", "0.53647935", "0.53551173", "0.5347977", "0.5314142", "0.5273834", "0.5224923", "0.51754665", "0.51746845", "0.5171518", "0.5146933", "0.5140077" ]
0.7271413
1
PUT /attribute_layers/1 PUT /attribute_layers/1.json
def update @attribute_layer = AttributeLayer.find(params[:id]) respond_to do |format| if @attribute_layer.update_attributes(params[:attribute_layer]) format.html { redirect_to @attribute_layer, notice: 'Attribute layer was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @attribute_layer.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n # @attribute_layer = @palette.attribute_layers.find(attribute_layer_params[:id])\n respond_to do |format|\n if @attribute_layer.update(attribute_layer_params)\n format.html { redirect_to [@palette, @attribute_layer], notice: 'Attribute layer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @attribute_layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @layer = Layer.find(params[:id])\n\n respond_to do |format|\n if @layer.update_attributes(params[:layer])\n @layers = Layer.all\n format.html { redirect_to @layer, notice: 'Layer was successfully updated.' }\n format.json { render json: {layers: @layers.map {|layer| {id: layer.id, name:layer.name, number_of_polygons: layer.areas.count}}} }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @attribute_layer = AttributeLayer.find(params[:id])\n @attribute_layer.destroy\n\n respond_to do |format|\n format.html { redirect_to attribute_layers_url }\n format.json { head :no_content }\n end\n end", "def attribute_layer_params\n params.require(:attribute_layer).permit(:label, :palette_id)\n end", "def create\n @attribute_layer = @palette.attribute_layers.new(attribute_layer_params)\n\n respond_to do |format|\n if @attribute_layer.save\n format.html { redirect_to [@palette, @attribute_layer], notice: 'Attribute layer was successfully created.' }\n format.json { render action: 'show', status: :created, location: @attribute_layer }\n else\n format.html { render action: 'new' }\n format.json { render json: @attribute_layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @attribute_layer = AttributeLayer.new(params[:attribute_layer])\n puts \"---------------------------------------------\"\n respond_to do |format|\n if @attribute_layer.save\n format.html { redirect_to @attribute_layer, notice: 'Attribute layer was successfully created.' }\n format.json { render json: @attribute_layer, status: :created, location: @attribute_layer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attribute_layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @annotationLayerIn = params['annotationLayer']\n\n @problem = ''\n if !validate_annotationLayer(@annotationLayerIn)\n errMsg = \"Annotation Layer not valid and could not be updated: \" + @problem\n render :json => { :error => errMsg },\n :status => :unprocessable_entity\n else\n @annotationLayer = AnnotationLayer.where(layer_id: @annotationLayerIn['@id']).first\n #authorize! :update, @annotationLayer\n\n if @annotationLayer.version.nil? || @annotationLayer.version < 1\n @annotationLayer.version = 1\n end\n\n if !version_layer @annotationLayer\n errMsg = \"Annotation Layer could not be updated: \" + @problem\n render :json => { :error => errMsg },\n :status => :unprocessable_entity\n end\n\n newVersion = @annotationLayer.version + 1\n request.format = \"json\"\n respond_to do |format|\n if @annotationLayer.update_attributes(\n :layer_id => @annotationLayerIn['@id'],\n :layer_type => @annotationLayerIn['@type'],\n :label => @annotationLayerIn['label'],\n :motivation => @annotationLayerIn['motivation'],\n :license => @annotationLayerIn['license'],\n :description => @annotationLayerIn['description'],\n :version => newVersion\n )\n format.html { redirect_to @annotationLayer, notice: 'AnnotationLayer was successfully updated.' }\n format.json { render json: @annotationLayer.to_iiif, status: 200, content_type: \"application/json\" }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @annotationLayer.errors, status: :unprocessable_entity, content_type: \"application/json\" }\n end\n end\n end\n end", "def destroy\n # @attribute_layer = @palette.attribute_layers.find(attribute_layer_params[:id])\n @attribute_layer.destroy\n respond_to do |format|\n format.html { redirect_to palette_attribute_layers_url(@palette) }\n format.json { head :no_content }\n end\n end", "def show\n @attribute_layer = AttributeLayer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attribute_layer }\n end\n end", "def new\n @attribute_layer = AttributeLayer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attribute_layer }\n end\n end", "def update\n respond_to do |format|\n if @layer.update(layer_params)\n format.html { redirect_to @layer, notice: 'Layer was successfully updated.' }\n format.json { render :show, status: :ok, location: @layer }\n else\n format.html { render :edit }\n format.json { render json: @layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def put_attribute_with_http_info(attribute_id, body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: AttributesApi.put_attribute ...\"\n end\n \n \n # verify the required parameter 'attribute_id' is set\n fail ArgumentError, \"Missing the required parameter 'attribute_id' when calling AttributesApi.put_attribute\" if attribute_id.nil?\n \n \n \n \n \n \n # verify the required parameter 'body' is set\n fail ArgumentError, \"Missing the required parameter 'body' when calling AttributesApi.put_attribute\" if body.nil?\n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/attributes/{attributeId}\".sub('{format}','json').sub('{' + 'attributeId' + '}', attribute_id.to_s)\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 = @api_client.object_to_http_body(body)\n \n auth_names = ['PureCloud Auth']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Attribute')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AttributesApi#put_attribute\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def layer=(layer)\n end", "def update\n respond_to do |format|\n if @attribute_set.update(attribute_set_params)\n format.html { redirect_to @attribute_set, notice: 'Attribute set was successfully updated.' }\n format.json { render :show, status: :ok, location: @attribute_set }\n else\n format.html { render :edit }\n format.json { render json: @attribute_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_feature(feature_key, attributes)\n features[feature_key].update_attribute(attributes)\n save\n end", "def set_layer\n @layer = Layer.find(params[:id])\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update\n @attribute = Attribute.find(params[:id])\n\n respond_to do |format|\n if @attribute.update_attributes(params[:attribute])\n format.html { redirect_to @attribute, notice: 'Attribute was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @attribute.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @attribute = Attribute.find(params[:id])\n\n respond_to do |format|\n if @attribute.update_attributes(params[:attribute])\n format.html { redirect_to @attribute, :notice => 'Attribute was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @attribute.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @feature_attributions_schema_uri = args[:feature_attributions_schema_uri] if args.key?(:feature_attributions_schema_uri)\n @inputs = args[:inputs] if args.key?(:inputs)\n @latent_space_source = args[:latent_space_source] if args.key?(:latent_space_source)\n @outputs = args[:outputs] if args.key?(:outputs)\n end", "def update\n respond_to do |format|\n if @iconographic_attribute.update(iconographic_attribute_params)\n format.html { redirect_to @iconographic_attribute, notice: 'Iconographic attribute was successfully updated.' }\n format.json { render :show, status: :ok, location: @iconographic_attribute }\n else\n format.html { render :edit }\n format.json { render json: @iconographic_attribute.errors, status: :unprocessable_entity }\n end\n end\n end", "def jsonapi_update!(attributes)\n assign_jsonapi_attributes(attributes)\n save!\n end", "def update\n @lens = Lens.find(params[:id])\n attrb = select_params(lens_params)\n # linear_data is an array of Objects of Components Properties\n # that needs to be deserialized correctly\n attrb[\"linear_data\"] = JSON.parse(attrb[\"linear_data\"])\n lens = Lens.update(attrb)\n \n # @lens.update(lens_params)\n # render inline: \"<%= @lens.id %>\"\n end", "def update_attribute(request)\n flag = false\n\n vertex = Vertex.find_by_id(request.id)\n return UpdateAttributeResponse.new(false, 'Vertex id not valid') if vertex.nil?\n\n unless request.name.nil?\n vertex.name = request.name\n flag = true\n end\n unless request.time.nil?\n vertex.estimatedTime = request.time\n flag = true\n end\n\n unless request.clue.nil?\n vertex.clue = request.clue\n flag = true\n end\n unless request.description.nil?\n vertex.description = request.description\n flag = true\n end\n @response = if flag\n if vertex.save\n UpdateAttributeResponse.new(true, 'Vertex attributes updated')\n else\n UpdateAttributeResponse.new(false, 'Could not update vertex attribute')\n end\n else\n UpdateAttributeResponse.new(false, 'Incorrect vertex attributes given')\n end\n rescue StandardError => error\n puts error\n UpdateAttributeResponse.new(false, 'Error occurred while updating vertex attributes')\n end", "def attribute_set_params\n params.require(:attribute_set).permit(:name, :legend_img_filename, :string)\n end", "def update\n @collection_attribute = CollectionAttribute.find(params[:id])\n\n respond_to do |format|\n if @collection_attribute.update_attributes(params[:collection_attribute])\n flash[:notice] = 'CollectionAttribute was successfully updated.'\n format.html { redirect_to(@collection_attribute) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @collection_attribute.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @hidden_neuron_layer = HiddenNeuronLayer.find(params[:id])\n\n respond_to do |format|\n if @hidden_neuron_layer.update_attributes(params[:hidden_neuron_layer])\n format.html { redirect_to @hidden_neuron_layer, notice: 'Hidden neuron layer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hidden_neuron_layer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ais_attribute = AisAttribute.find(params[:id])\n\n respond_to do |format|\n if @ais_attribute.update_attributes(params[:ais_attribute])\n format.html { redirect_to @ais_attribute, notice: 'Record was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ais_attribute.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @layerIn = JSON.parse(params.to_json)\n @layer = Hash.new\n #@ru = request.original_url\n @ru = request.original_url.split('?').first\n @ru += '/' if !@ru.end_with? '/'\n @layer['layer_id'] = @ru + SecureRandom.uuid\n @layer['layer_type'] = @layerIn['@type']\n @layer['label'] = @layerIn['label']\n @layer['motivation'] = @layerIn['motivation']\n #@layer['description'] = @layerIn['description']\n @layer['license'] = @layerIn['license']\n @layer['version'] = 1\n @annotation_layer = AnnotationLayer.new(@layer)\n\n #authorize! :create, @annotation_layer\n request.format = \"json\"\n respond_to do |format|\n if @annotation_layer.save\n format.html { redirect_to @annotation_layer, notice: 'Annotation layer was successfully created.' }\n format.json { render json: @annotation_layer.to_iiif, status: :created, location: @annotation_layer, content_type: \"application/json\" }\n else\n format.html { render action: \"new\" }\n format.json { render json: @annotation_layer.errors, status: :unprocessable_entity, content_type: \"application/json\" }\n end\n end\n end", "def update!(**args)\n @attribute_map = args[:attribute_map] if args.key?(:attribute_map)\n @dropped_attributes_count = args[:dropped_attributes_count] if args.key?(:dropped_attributes_count)\n end" ]
[ "0.70928246", "0.61750615", "0.61469525", "0.6109116", "0.6054067", "0.6015945", "0.59012794", "0.5866781", "0.57476956", "0.57473683", "0.5736305", "0.5688928", "0.5678348", "0.56328326", "0.55455166", "0.5520123", "0.5506935", "0.5453642", "0.5444925", "0.5439787", "0.5419774", "0.5419398", "0.5399602", "0.5373308", "0.53664154", "0.53541327", "0.5346796", "0.5339826", "0.5337436", "0.53351927" ]
0.73572767
0
DELETE /attribute_layers/1 DELETE /attribute_layers/1.json
def destroy @attribute_layer = AttributeLayer.find(params[:id]) @attribute_layer.destroy respond_to do |format| format.html { redirect_to attribute_layers_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n # @attribute_layer = @palette.attribute_layers.find(attribute_layer_params[:id])\n @attribute_layer.destroy\n respond_to do |format|\n format.html { redirect_to palette_attribute_layers_url(@palette) }\n format.json { head :no_content }\n end\n end", "def destroy\n #@ru = request.original_url\n @ru = request.protocol + request.host_with_port + \"/layers/#{params['id']}\"\n @annotationLayer = AnnotationLayer.where(layer_id: @ru).first\n #authorize! :delete, @annotation_layer\n if @annotationLayer.version.nil? || @annotationLayer.version < 1\n @annotationLayer.version = 1\n end\n if !version_layer @annotationLayer\n errMsg = \"Annotation Layer could not be updated: \" + @problem\n render :json => { :error => errMsg },\n :status => :unprocessable_entity\n end\n @annotationLayer.destroy\n request.format = \"json\"\n respond_to do |format|\n format.html { redirect_to annotation_layers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @attribute = Attribute.find(params[:id])\n @attribute.destroy\n\n respond_to do |format|\n format.html { redirect_to attributes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @attribute = Attribute.find(params[:id])\n @attribute.destroy\n\n respond_to do |format|\n format.html { redirect_to attributes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @attribute_set.destroy\n respond_to do |format|\n format.html { redirect_to attribute_sets_url, notice: 'Attribute set was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @layer = Layer.find(params[:id])\n @layer.destroy\n\n respond_to do |format|\n format.html { redirect_to layers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @karyalay_attribute.destroy\n respond_to do |format|\n format.html { redirect_to karyalay_attributes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ais_attribute = AisAttribute.find(params[:id])\n @ais_attribute.destroy\n\n respond_to do |format|\n format.html { redirect_to ais_attributes_url, notice: 'Record was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @attribute_list.destroy\n respond_to do |format|\n format.html { redirect_to attribute_lists_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @collection_attribute = CollectionAttribute.find(params[:id])\n @collection_attribute.destroy\n\n respond_to do |format|\n format.html { redirect_to(collection_attributes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @attr.destroy\n respond_to do |format|\n format.html { redirect_to attrs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @iconographic_attribute.destroy\n respond_to do |format|\n format.html { redirect_to iconographic_attributes_url, notice: 'Iconographic attribute was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @taxon_attribute = TaxonAttribute.find(params[:id])\n @taxon_attribute.destroy\n\n respond_to do |format|\n format.html { redirect_to taxon_attributes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @attribute.destroy\n respond_to do |format|\n format.html { redirect_to attributes_url, notice: 'Attribute was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @layer.destroy\n respond_to do |format|\n format.html { redirect_to layers_url, notice: 'Layer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @layer_filter = LayerFilter.find(params[:id])\n @layer_filter.destroy\n\n respond_to do |format|\n format.html { redirect_to(layer_filters_url) }\n format.xml { head :ok }\n format.json { render :json => @layer_filter.attributes }\n end\n end", "def destroy\n @c_attribute.destroy\n respond_to do |format|\n format.html { redirect_to c_attributes_url, notice: 'C attribute was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @actattribute = Actattribute.find(params[:id])\n @actattribute.destroy\n\n respond_to do |format|\n format.html { redirect_to(actattributes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @attribute_display.destroy\n respond_to do |format|\n format.html { redirect_to models_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_attribute.destroy\n respond_to do |format|\n format.html { redirect_to admin_attributes_url, notice: 'Attribute was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def del_attribute_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi.del_attribute ...\"\n end\n # resource path\n local_var_path = \"/{uuid}/attribute/{key}\".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 auth_names = []\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse2004')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#del_attribute\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def destroy\n @coin_attribute = @coin.coin_attributes.find(params[:id])\n @coin_attribute.destroy\n\n respond_to do |format|\n format.html { redirect_to coin_coin_attributes_path([@coin]) }\n format.json { head :no_content }\n end\n end", "def destroy\n @attri = Attri.find(params[:id])\n @attri.destroy\n\n respond_to do |format|\n format.html { redirect_to attris_url }\n format.json { head :ok }\n end\n end", "def delete_attribute(key); end", "def destroy\n @map_layer = MapLayer.find(params[:id])\n @map_layer.destroy\n\n respond_to do |format|\n format.html { redirect_to(map_layers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @hidden_neuron_layer = HiddenNeuronLayer.find(params[:id])\n @hidden_neuron_layer.destroy\n\n respond_to do |format|\n format.html { redirect_to hidden_neuron_layers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @collectible_attribute_list.destroy\n respond_to do |format|\n format.html { redirect_to collectible_attribute_lists_url, notice: 'Collectible attribute list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n # @idp_attribute.destroy\n respond_to do |format|\n format.html { redirect_to idp_attributes_url, notice: 'IdP attribute can not be destroyed.' }\n format.json { head :no_content }\n end\n end", "def test_delete_feature()\n\t pg_lyr = create_poly_layer(@pg_ds)\n\t create_crazy_key\n\t \n\t\tpg_lyr.set_attribute_filter( \"PRFEDEA = 'CrazyKey'\" )\n\n\t feat = pg_lyr.get_next_feature()\n\t\tassert_not_nil(feat, \"Could not find feature\")\n \t pg_lyr.set_attribute_filter( \"\" )\n \t fid = feat.get_fid()\n\n assert(pg_lyr.delete_feature( fid ),\n 'DeleteFeature() method failed.' )\n\n\t\tpg_lyr.set_attribute_filter( \"PRFEDEA = 'CrazyKey'\" )\n feat = pg_lyr.get_next_feature()\n assert_nil(feat, 'DeleteFeature() seems to have had no effect.' )\n pg_lyr.set_attribute_filter(\"\")\n end", "def destroy\n @area_attribute.destroy\n respond_to do |format|\n format.html { redirect_to area_attributes_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.781373", "0.7112902", "0.69205403", "0.69205403", "0.6852056", "0.68027055", "0.6633839", "0.6602867", "0.65760803", "0.65646964", "0.6536001", "0.65137297", "0.65132", "0.6476078", "0.647183", "0.6430505", "0.63926697", "0.6387401", "0.63489807", "0.634379", "0.63427657", "0.6340654", "0.63334274", "0.6311603", "0.6309073", "0.63022584", "0.62957126", "0.6293288", "0.62857974", "0.6284814" ]
0.8094902
0
returns a list with differences between two templates
def difference(rt1, rt2) return template_tags(rt1) - template_tags(rt2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def template_difference(rt)\n return marc.all_tags.map{|e| e.tag}.uniq - template_tags(rt).uniq\n end", "def list\n templates.map{ |t| t.name }.sort_by{ |a|\n i = a.index('@')\n i ? [a[i+1..-1], a] : [a, a]\n }\n end", "def changes_from_template\n changes_from_document(template, false)\n end", "def diff_arrays(generated, expected)\n gen_result = []\n exp_result = []\n Diff::LCS.sdiff(generated, expected) do |chunk|\n case chunk.action\n when '-'\n gen_result << %(<strong>#{CGI.escape_html chunk.old_element}</strong>)\n when '+'\n exp_result << %(<strong>#{CGI.escape_html chunk.new_element}</strong>)\n when '='\n gen_result << (CGI.escape_html chunk.old_element)\n exp_result << (CGI.escape_html chunk.new_element)\n when '!'\n gen_result << %(<strong>#{CGI.escape_html chunk.old_element}</strong>)\n exp_result << %(<strong>#{CGI.escape_html chunk.new_element}</strong>)\n end\n end\n [gen_result, exp_result]\n end", "def diff_list(tag_name_list)\n exist_list = Tag.all.pluck(:name)\n tag_name_list - exist_list\n end", "def templates\n @templates ||= (\n list = []\n list.concat templates_from_project\n list.concat templates_from_remotes\n list.concat templates_from_plugins\n list.sort_by{ |t| t.name }\n )\n end", "def template_files\r\n \t[].concat(@templates)\r\n end", "def org_templates(templates: [])\n org_templates = Template.latest_version_per_org(@client.user.org).published\n custs = Template.latest_customized_version_per_org(@client.user.org).published\n return (templates + org_templates).sort_by(&:title) unless custs.any?\n\n # Remove any templates that were customized by the org, we will use their customization\n templates.reject { |t| custs.map(&:customization_of).include?(t.family_id) }\n\n (org_templates + custs + templates).sort_by(&:title)\n end", "def templates\n Dir.glob(::Webby.path('examples') / '*').sort\n end", "def template_tags(record_type)\n s = Source.new(record_type: record_type)\n e = EditorConfiguration.get_default_layout(s)\n marc_tags = e.layout_tags\n excluded_tags = e.excluded_tags_for_record_type(s)\n return marc_tags - excluded_tags\n end", "def return_resource_diffs(r1, r2)\n only_in_old = []\n (r2 - r1).each do |r|\n only_in_old << r.to_s\n end\n only_in_new = []\n (r1 - r2).each do |r|\n only_in_new << r.to_s\n end\n differences = {\n titles_only_in_old: only_in_old,\n titles_only_in_new: only_in_new\n }\n differences\n end", "def templates_from_project\n list = []\n dirs = Dir.glob(File.join(output, LOCAL_DIRECTORY, '*/'))\n dirs = dirs.uniq.map{ |d| d.chomp('/') }\n dirs.each do |dir|\n name = dir.sub(File.join(output, LOCAL_DIRECTORY)+'/', '')\n list << Template.new(name, dir, :type=>:project)\n end\n list\n end", "def templates\n file_list '{templates,puppet}/**/*.{erb,epp}'\n end", "def templates\n GitWiki.template_cache ||= Dir[\"#{ settings.views[0] }/*.liquid\"].map do |f|\n name = File.basename(f, '.liquid')\n {\n \"name\" => name,\n \"examples\" => Page.get_template(name).examples\n }\n end\n end", "def each_difference(locals, include_unmanaged, &f)\n aws = Hash[aws_resources.map { |aws| [aws.name, aws] }]\n\n if include_unmanaged\n aws.each do |name, resource|\n f.call(name, [IamDiff.unmanaged(resource)]) if !locals.include?(name)\n end\n end\n locals.each do |name, resource|\n if !aws.include?(name)\n f.call(name, [IamDiff.added(resource)])\n else\n f.call(name, resource.diff(aws[name]))\n end\n end\n end", "def templates\n # Some cheap memoiziation\n @templates ||= begin\n files = Dir.glob(template_glob)\n # Check to see what mode we are in, that'll define how we parse the file names\n if Gluttonberg.localized? or Gluttonberg.translated?\n # Figure out what regex we need\n matcher, mode = if Gluttonberg.localized?\n [/\\/#{filename}.(\\w+).([a-z-]+).(\\w+).(erb|mab|haml)/, :localized]\n elsif Gluttonberg.translated?\n [/\\/#{filename}.([a-z-]+).(\\w+).(erb|mab|haml)/, :translated]\n end\n files.inject({}) do |memo, file|\n match = file.match(matcher)\n extract_template_details(memo, mode, match) if match\n memo\n end\n else\n # For the non-localized/dialect mode, just collect the various formats\n files.inject([]) do |memo, file|\n match = file.match(/#{filename}.(\\w+).(erb|mab|haml)/)\n memo << match[1] if match\n memo\n end\n end\n end\n end", "def templates; end", "def generate_diff\n jsons = version_jsons.map { |j| pretty_json(j) }\n differ = Differ.send(diff_method, *jsons).format_as(:html)\n differ.gsub!('<ins', \"\\n<ins\") if diff_method == :diff_by_line\n @diff = sanitize(differ).html_safe\n end", "def get_differences(h1, h2)\n\t\t\t\tresults = [missed = [], mismatched = [], extra = []]\n\t\t\t\tunless h1.nil? && h2.nil?\n\t\t\t\t\th1.each do |k1, v1|\n\t\t\t\t\t\tif h2.has_key?(k1)\n\t\t\t\t\t\t\tif h2[k1] != v1\n\t\t\t\t\t\t\t\tmismatched.push(k1)\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\th2.delete(k1)\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tmissed.push(k1)\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\tunless h2.empty?\n\t\t\t\t\t\th2.each do |k2|\n\t\t\t\t\t\t\textra.push(k2)\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\treturn results\n\t\t\t\tend\n\t\t\tend", "def diff_template\n return @diff_template if defined?(@diff_template)\n diffbook = Workbook::Book.new_diff_template\n difftable = diffbook.sheet.table\n @diff_template ||= difftable\n end", "def difference(b)\n @pages.delete_if { |k, v| b.pages.include?(k) }\n self\n end", "def difference\n end", "def diff\n each_difference(local_resources, true, &@@diff)\n end", "def templates\n response = get 'templates'\n response.map{|item| Hashie::Mash.new(item)}\n end", "def variations(for_partial = false)\n all_variation_codes = I18n.available_locales.product([:html, :text])\n current_existed_variations = existed_variations(for_partial)\n existed_variation_codes = current_existed_variations.map do |template|\n [template.locale.to_sym, template.format.to_sym]\n end\n missing_variations = (all_variation_codes - existed_variation_codes).map do |locale, format|\n MailEngine::MailTemplate.new :locale => locale.to_s, :format => format.to_s\n end\n\n missing_variations + current_existed_variations\n end", "def template_options(org_id, funder_id)\n @templates = []\n\n if org_id.present? || funder_id.present?\n if funder_id.blank?\n # Load the org's template(s)\n if org_id.present?\n org = Org.find(org_id)\n @templates = Template.valid.where(published: true, org: org, customization_of: nil).to_a\n @msg = _(\"We found multiple DMP templates corresponding to the research organisation.\") if @templates.count > 1\n end\n\n else\n funder = Org.find(funder_id)\n # Load the funder's template(s)\n @templates = Template.valid.where(published: true, org: funder).to_a\n\n if org_id.present?\n org = Org.find(org_id)\n\n # Swap out any organisational cusotmizations of a funder template\n @templates.each do |tmplt|\n customization = Template.valid.find_by(published: true, org: org, customization_of: tmplt.dmptemplate_id)\n if customization.present? && tmplt.updated_at < customization.created_at\n @templates.delete(tmplt)\n @templates << customization\n end\n end\n end\n\n @msg = _(\"We found multiple DMP templates corresponding to the funder.\") if @templates.count > 1\n end\n end\n\n # If no templates were available use the generic templates\n if @templates.empty?\n @msg = _(\"Using the generic Data Management Plan\")\n @templates << Template.default\n end\n\n @templates = @templates.sort{|x,y| x.title <=> y.title } if @templates.count > 1\n end", "def templates\n wayfinder.decorated_templates\n end", "def diffed(old, new)\n differ = Differ.diff_by_line(new, old)\n differ.to_s[/\\{[^}]+\\}/][1...-1].gsub(/\\s{2,}/, '')\n end", "def template_paths(name)\r\n \t@templates.inject([]) do |list, path|\r\n \t\tfile_name = File.basename(path)\r\n \t\tfile_name[0, name.length] == name.to_s ? list << path : list\r\n \tend\r\n end", "def difffiles(fileone, filetwo, addresskeys)\n fileoneresult = String.new\n filetworesult = String.new\n arry = Array.new\n addresskeys.each do |key|\n fileoneresult = balongnvtool(fileone, key)\n filetworesult = balongnvtool(filetwo, key)\n unless fileoneresult.eql? filetworesult\n #Determine the name of the feild that has a diff\n arry.push(getdifname(fileoneresult))\n end\n end\n cleanedarry = removebandspecificaddresses(arry)\n puts cleanedarry\n return cleanedarry\n end" ]
[ "0.7825533", "0.61621785", "0.61226743", "0.6049139", "0.60303223", "0.5883453", "0.58786225", "0.57578564", "0.5737683", "0.5683475", "0.56676024", "0.5628493", "0.5593245", "0.5575563", "0.5574201", "0.55715275", "0.5569721", "0.55592567", "0.5520335", "0.5504637", "0.5502013", "0.5490673", "0.54899466", "0.54672647", "0.5441482", "0.5441373", "0.5439173", "0.54162806", "0.53996253", "0.5399143" ]
0.77025473
1
return difference between existing tags and tags of the new template
def template_difference(rt) return marc.all_tags.map{|e| e.tag}.uniq - template_tags(rt).uniq end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def difference(rt1, rt2)\n return template_tags(rt1) - template_tags(rt2)\n end", "def diff_list(tag_name_list)\n exist_list = Tag.all.pluck(:name)\n tag_name_list - exist_list\n end", "def tags_to_add\n current_tags - linked_tags\n end", "def tags_to_remove\n linked_tags - current_tags\n end", "def changes_from_template\n changes_from_document(template, false)\n end", "def template_tags(record_type)\n s = Source.new(record_type: record_type)\n e = EditorConfiguration.get_default_layout(s)\n marc_tags = e.layout_tags\n excluded_tags = e.excluded_tags_for_record_type(s)\n return marc_tags - excluded_tags\n end", "def tags_to_add\n local_tags.reject { |t, v| aws_tags.include?(t) and aws_tags[t] == v }\n end", "def tags_to_remove\n return @tags_to_remove\n end", "def tag\n old_word.tag\n end", "def genit_tags_in_template\n HtmlDocument.genit_tags_from @template\n end", "def tag(new_tag); end", "def tags\n @orig.keys\n end", "def diff_unified(text_old, text_new, label=\"--- old\\n+++ new\\n\", context=3)\n tmp_old = \"_tmp.old.#{rand()}\"\n tmp_new = \"_tmp.new.#{rand()}\"\n File.open(tmp_old, 'w') {|f| f.write(text_old) }\n File.open(tmp_new, 'w') {|f| f.write(text_new) }\n begin\n #diff = `diff -u #{tmp_old} #{tmp_new}`\n diff = `diff --unified=#{context} #{tmp_old} #{tmp_new}`\n ensure\n File.unlink(tmp_old)\n File.unlink(tmp_new)\n end\n diff.sub!(/\\A\\-\\-\\-.*\\n\\+\\+\\+.*\\n/, label.to_s)\n return diff\n end", "def tags_merger(orig, new)\n return_array = []\n orig.each { |x| return_array << x.clone }\n\n new.each do |a|\n key_found = false\n return_array.each do |r|\n if a[:Key] == r[:Key]\n r[:Value] = a[:Value]\n key_found = true\n end\n break if key_found\n end\n return_array << a unless key_found\n end\n\n return_array\nend", "def tags_to_remove\n aws_tags.reject { |t, v| local_tags.include?(t) and local_tags[t] == v }\n end", "def tags_to_add\n return @tags_to_add\n end", "def template_tag\n if @tag\n @tag\n else\n TEMPLATE_TAG\n end\n end", "def diffed(old, new)\n differ = Differ.diff_by_line(new, old)\n differ.to_s[/\\{[^}]+\\}/][1...-1].gsub(/\\s{2,}/, '')\n end", "def diff\n require \"tempfile\"\n new_file = Tempfile.new([\"new_config.\", \".yml\"])\n new_file.write(sorted_file)\n result = `git diff --no-index -- #{file} #{new_file.path}`.gsub(\n no_slash_beginning(new_file.path),\n no_slash_beginning(file)\n )\n ensure\n new_file.close\n new_file.unlink\n result\n end", "def different_tag?\n note_tags = @note.tags || []\n tag = @tag.get || []\n (note_tags - tag).size != 0 || (tag - note_tags).size != 0\n end", "def changed_tags\n @changed_values.keys.map { |key| MiniExiftool.original_tag(key) }\n end", "def tags\n self.new_record? ? '' : Tag.get_friendly_tags(self)\n end", "def update\n\n old_tags = @event.tags.pluck(:tag)\n new_tags = params[:tags].split(',')\n\n #logger.debug old_tags\n #logger.debug new_tags\n #logger.debug (old_tags - new_tags)\n #logger.debug (new_tags - old_tags)\n\n (old_tags - new_tags).each do |stag|\n @event.tags.where(tag: stag).first.destroy\n end\n\n (new_tags - old_tags).each do |stag|\n @event.tags.create(tag: stag)\n end\n\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def extractTags()\n line = @lines[@currentLine]\n re = /\\[([^\\[]+)\\]/m\n while line =~ re\n @currentBlock.addTag($~[1])\n line = line.sub(re, '')\n end\n end", "def _UNDO_setTags(iNewTags)\n # Remove Tags that are not part of the new list\n @Tags.delete_if do |iTag, iNil|\n !iNewTags.has_key?(iTag)\n end\n # Add Tags that are not part of the current list\n iNewTags.each do |iTag, iNil|\n @Tags[iTag] = nil\n end\n end", "def dedup_tags!\n tags = read_attribute(tags_field)\n tags = tags.reduce([]) do |uniques, tag|\n uniques << tag unless uniques.map(&:downcase).include?(tag.downcase)\n uniques\n end\n write_attribute(tags_field, tags)\n end", "def difference\n end", "def merge!\n other_tag = Tag.find_by_name(self.name)\n if other_tag.nil? or other_tag.id == self.id\n return self\n else\n taggings.map(&:clone).each { |t| (t.tag = other_tag) && t.save! }\n self.destroy\n return other_tag\n end\n end", "def unified_diff(text_old, text_new, label=\"--- old\\n+++ new\\n\", context=3)\n msg = \"\\\\ No newline at end of string\"\n lines_old = _text2lines(text_old, msg)\n lines_new = _text2lines(text_new, msg)\n #\n buf = \"#{label}\"\n len = 0\n prevhunk = hunk = nil\n diffs = Diff::LCS.diff(lines_old, lines_new)\n diffs.each do |diff|\n hunk = Diff::LCS::Hunk.new(lines_old, lines_new, diff, context, len)\n if hunk.overlaps?(prevhunk)\n hunk.unshift(prevhunk)\n else\n buf << prevhunk.diff(:unified) << \"\\n\"\n end if prevhunk\n len = hunk.file_length_difference\n prevhunk = hunk\n end\n buf << prevhunk.diff(:unified) << \"\\n\" if prevhunk\n return buf\n end", "def generate_diff\n jsons = version_jsons.map { |j| pretty_json(j) }\n differ = Differ.send(diff_method, *jsons).format_as(:html)\n differ.gsub!('<ins', \"\\n<ins\") if diff_method == :diff_by_line\n @diff = sanitize(differ).html_safe\n end" ]
[ "0.8013168", "0.6506995", "0.63771826", "0.6185425", "0.61215717", "0.61044395", "0.6034408", "0.5876528", "0.58526963", "0.5808123", "0.57862246", "0.577773", "0.5774749", "0.5773152", "0.5652374", "0.5642741", "0.56372523", "0.55819124", "0.55467564", "0.55306196", "0.5527752", "0.5444135", "0.54368216", "0.53854096", "0.53775907", "0.53723323", "0.534397", "0.5341433", "0.53282595", "0.5312058" ]
0.797055
1
Restore a backup tag from 599; probably never used due to template incompatibility
def restore_tags marc.by_tags("599").each do |t| new_content = t.fetch_first_by_tag("a").content if new_content =~ /=[0-9]{3}\s{2}/ tag, content = new_content.split(" ") marc.parse_marc21(tag[1..4], content) t.destroy_yourself end end self.save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def backup_tag(tag)\n marc.by_tags(tag).each do |t|\n new_599 = MarcNode.new(Source, \"599\", \"\", \"4#\")\n ip = marc.get_insert_position(\"599\")\n new_599.add(MarcNode.new(Source, \"a\", \"#{t.to_s.strip}\", nil))\n new_599.sort_alphabetically\n marc.root.children.insert(ip, new_599)\n t.destroy_yourself\n end\n end", "def change_template_to(rt)\n template_difference(rt).each do |e|\n if e == '852'\n create_holding\n else\n backup_tag(e)\n end\n end\n self.record_type = rt\n self.save\n end", "def restore; end", "def restore_archive\n end", "def restore\n end", "def restore( page )\n load page, take_snapshot: false\n end", "def restore\n parse\n end", "def fix_big5_in_source_code(src)\r\n\t\tstrbig5='<?xml encoding=\"Big5\"?>' + \"\\n\"\r\n\t\tbak = src+\".bak\"\t\r\n\t cp src, bak\r\n\t\tsf=File.new(bak, 'r')\r\n\t\tnf=File.new(src, 'w')\r\n\t\tnf << strbig5\r\n\t\tsf.each_line do |l|\r\n\t\t\tnf << l unless l == strbig5\r\n\t\tend\r\n\t\tsf.close\r\n\t\tnf.close\r\n\tend", "def restore_save version\n @body = version.body\n end", "def revert_code()\n\t\t\n\tend", "def restore\n RESTORE\n end", "def post_restore_warning\n end", "def make_backup\n @backup = editor.create_snapshot\n end", "def restore\n update(archived_at: nil)\n end", "def restore_mode; end", "def restore_mode; end", "def restore_merge_state; end", "def restore_merge_state; end", "def restore_templates\n FileUtils.rm_rf @current_templates if File.exist? @current_templates\n\n if File.exist? @old_templates\n FileUtils.mv(\n @old_templates,\n @current_templates\n )\n end\n end", "def revert_to!(version)\n revert version, :hard\n self\n end", "def revert_to!(value)\n revert_to(value)\n reset_version if saved = save\n saved\n end", "def restore_branch\n @@obj.branch(@@save_branch.pop).checkout\n end", "def backup_templates\n FileUtils.rm_rf @old_templates if File.exist? @old_templates\n\n if File.exist? @current_templates\n FileUtils.mv(\n @current_templates,\n @old_templates\n )\n end\n end", "def copy_tags_to_snapshot\n data[:copy_tags_to_snapshot]\n end", "def copy_tags_to_snapshot\n data[:copy_tags_to_snapshot]\n end", "def restore\n self.archived_at = nil\n end", "def backup\n BACKUP_MODELS.each do |obj|\n puts \"Preparing to back up #{obj}\"\n self.send(obj.to_sym)\n end \n end", "def restore(n = backup.back_size)\n # Handle negatives in consideration of #with_saved_pos.\n if n < 0\n read(-n)\n else\n backup.back(n).chars.reverse.each {|c| ungetc c}\n end\n nil\n end", "def revert!\n ::ActionView::Template.class_eval do\n alias_method :compile!, :cb_original_compile! # rubocop:disable Lint/DuplicateMethods\n undef_method :cb_patched_compile!\n end\n end", "def revert_to(version)\n revert version\n self\n end" ]
[ "0.65160346", "0.57408595", "0.56575525", "0.56227595", "0.5478151", "0.5465818", "0.5405911", "0.5238993", "0.509508", "0.5048554", "0.50258774", "0.4970628", "0.4961201", "0.49090227", "0.48997426", "0.48997426", "0.48805273", "0.48805273", "0.48541296", "0.48430324", "0.4821171", "0.4791488", "0.47911534", "0.47873792", "0.47873792", "0.476592", "0.47656834", "0.47638023", "0.4759219", "0.4755058" ]
0.5893796
1
Moving tags which are not part of the target template to a holding or to 599 as temp storage
def change_template_to(rt) template_difference(rt).each do |e| if e == '852' create_holding else backup_tag(e) end end self.record_type = rt self.save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def backup_tag(tag)\n marc.by_tags(tag).each do |t|\n new_599 = MarcNode.new(Source, \"599\", \"\", \"4#\")\n ip = marc.get_insert_position(\"599\")\n new_599.add(MarcNode.new(Source, \"a\", \"#{t.to_s.strip}\", nil))\n new_599.sort_alphabetically\n marc.root.children.insert(ip, new_599)\n t.destroy_yourself\n end\n end", "def tag_pruning tags\n pruned_tags = []\n chunks = tags.in_groups_of( (tags.count/20).to_i )\n # binding.pry\n\n chunks.each_with_index do |chunk, i|\n # binding.pry\n if chunk.first.first.ascii_only?\n tag_nodes = InstaHelper.get_tag_media_nodes(chunk.first.first)\n puts \"=========== #{tag_nodes.count} @ #{i} ================\"\n unless (DateTime.now - DateTime.strptime(tag_nodes.first[\"node\"][\"taken_at_timestamp\"].to_s,'%s')).to_i > 30\n puts \"<<<<<<<<<<<<<<< Added #{i}th tag >>>>>>>>>>>>>>>>>>\"\n pruned_tags.push chunk\n end\n end\n end\n pruned_tags.flatten.in_groups_of(2)\n end", "def genit_tags_in_template\n HtmlDocument.genit_tags_from @template\n end", "def swap(node_or_tags); end", "def swap(node_or_tags); end", "def purge_unused_tags!\n unused_tags.each do |tag|\n logger.info(\"Purging tag '#{tag}'\")\n entries_with(label: tag).each do |entry|\n payload = Protocol::Device::SetTagLabels.new(tags: id_to_tags_field(entry.tag_id), label: '')\n context.send_message(target: Target.new(site_id: entry.site_id),\n payload: payload,\n acknowledge: true)\n end\n end\n Timeout.timeout(5) do\n while !unused_tags.empty?\n sleep 0.1\n end\n end\n end", "def prepare_tags()\n\t$currentCase.create_tag(OCR_MUST)\n\t$currentCase.create_tag(OCR_IMAGES_OVER_500KB)\n\t$currentCase.create_tag(OCR_IMAGES_OVER_1MB)\n\t$currentCase.create_tag(OCR_IMAGES_OVER_5MB)\n\t$currentCase.create_tag(OCR_AVG_WORDS_01_20)\n\t$currentCase.create_tag(OCR_AVG_WORDS_21_40)\n\t$currentCase.create_tag(OCR_AVG_WORDS_41_60)\n\t$currentCase.create_tag(OCR_AVG_WORDS_61_80)\n\t$currentCase.create_tag(OCR_AVG_WORDS_81_100)\n\t$currentCase.create_tag(OCR_AVG_WORDS_101)\nend", "def preprocess___tags data\n\t\tname = 'general' \n\t\ttags_alaise = [:tag, :type]\n\t\ttags_alaise.each do | item |\n\t\t\tname = data.delete(item) if data.include?(item)\n\t\tend\n\t\tif DB[:_tags].filter(:name => name).empty?\n\t\t\tDB[:_tags].insert(:name => name) \n\t\tend\n\t\tdata[:tid] = DB[:_tags].filter(:name => name).get(:tid)\n\t\tdata\n\tend", "def set_extra_stuff\n @templates = Template.all\n @tags = tags_for('Common')\n end", "def deal_template_2(_template='')\n\t\ttemplate = _template\n\t\twhile template[/\\{\\?.*?\\?([\\n\\r]*.*?)\\}/] != nil\n\t\t\ttemplate[/\\{\\?.*?\\?([\\n\\r]*.*?)\\}/]= $1\n\t\tend\n\t\ttemplate\n\tend", "def restore_tags\n marc.by_tags(\"599\").each do |t|\n new_content = t.fetch_first_by_tag(\"a\").content\n if new_content =~ /=[0-9]{3}\\s{2}/\n tag, content = new_content.split(\" \")\n marc.parse_marc21(tag[1..4], content)\n t.destroy_yourself\n end\n end\n self.save\n end", "def sanctify_liquid_tags(head)\n modified = false\n tag_names = head.scan(LIQUID_TAG_REGEX)\n tag_names.flatten!\n tag_names.reverse_each do |tag_name|\n next unless liquid_block?(tag_name)\n next if endtag_regex_stash(tag_name).match?(head)\n\n modified = true\n head << \"\\n{% end#{tag_name} %}\"\n end\n\n print_build_warning if modified\n head\n end", "def delete_tag_if(&block); end", "def tags_to_add\n local_tags.reject { |t, v| aws_tags.include?(t) and aws_tags[t] == v }\n end", "def update_tags!(filter_boxes)\n sections_with_content.each do |s|\n section = s['mampf_section']\n content_in_section(s).each do |c|\n # if tag for content already exists, add tag to the section and course\n if c['tag_id']\n tag = Tag.find_by_id(c['tag_id'])\n next unless tag\n next unless section\n next if section.in?(tag.sections)\n tag.sections |= [section]\n tag.courses |= [@lecture.course]\n next\n end\n next unless filter_boxes[c['counter']].second\n # if checkbox for tag creation is checked, create the tag,\n # associate it with course and section\n tag = Tag.new(courses: [@lecture.course],\n sections: [section])\n tag.notions.new(title: c['description'],\n locale: @lecture.locale || I18n.default_locale)\n tag.save\n end\n end\n end", "def prepare_vm_config\n inh_tags = %i(CLUSTER_ID CLUSTER_NAME HOST_ID HOST_NAME)\n @@storage[:vm][:inh_tags] = @@storage[:vm][:tags].clone\n\n # Get inherited tags into special hash for VMs only\n @@storage[:vm][:inh_tags].keep_if do |key, value|\n inh_tags.include? key\n end\n # Remove them from original hash\n @@storage[:vm][:inh_tags].each do |key, value|\n @@storage[:vm][:tags].delete(key)\n end\n end", "def prepare_liquid_template(template)\n end", "def extractTags()\n line = @lines[@currentLine]\n re = /\\[([^\\[]+)\\]/m\n while line =~ re\n @currentBlock.addTag($~[1])\n line = line.sub(re, '')\n end\n end", "def strip_tag(*tags, &block)\n tags.each do |tag|\n gsub! Regexp.new(\"<\\s*#{tag}(?:\\s+[^>]*)*>(.*?)<\\s*\\/#{tag}\\s*>\", Regexp::IGNORECASE + Regexp:: MULTILINE) do\n if block\n \"#{$1}#{yield}\"\n else\n $1\n end\n end\n # check we don't have any malformed or nested instances left\n gsub! Regexp.new(\"<\\s*#{tag}(?:\\s+[^>]*)*>\", Regexp::IGNORECASE + Regexp:: MULTILINE), ''\n gsub! Regexp.new(\"<\\s*\\/#{tag}\\s*>\", Regexp::IGNORECASE + Regexp:: MULTILINE), ''\n end\n end", "def create_holding\n marc.by_tags(\"852\").each do |t|\n holding = Holding.new\n new_marc = MarcHolding.new(File.read(\"#{Rails.root}/config/marc/#{RISM::MARC}/holding/default.marc\"))\n new_marc.load_source false\n new_marc.each_by_tag(\"852\") {|t2| t2.destroy_yourself}\n new_852 = t.deep_copy\n new_marc.root.children.insert(new_marc.get_insert_position(\"852\"), new_852)\n new_marc.suppress_scaffold_links\n new_marc.import\n holding.marc = new_marc\n holding.source = self\n holding.suppress_reindex\n begin\n holding.save\n rescue => e\n $stderr.puts\"SplitHoldingRecords could not save holding record for #{source.id}\"\n $stderr.puts e.message.blue\n next\n end\n t.destroy_yourself\n end\n end", "def replace(node_or_tags); end", "def replace(node_or_tags); end", "def tag_clean_up\n all_tags = Tag.all\n all_modules = UniModule.all\n\n all_tags.each do |tag|\n is_used_somewhere = false\n all_modules.each do |uni_module|\n if uni_module.tags.include?(tag)\n is_used_somewhere = true\n end\n end\n if !is_used_somewhere\n logs = TagLog.all.where(:tag_id => tag.id)\n if logs.size >0\n logs.each do |log|\n log.destroy\n end\n end\n tag.destroy\n end\n end\n end", "def untag!(tags)\n original_tags = info.tags\n\n Mp3Info.open(info.file) do |mp3|\n mp3.removetag1\n mp3.removetag2\n\n original_tags.except(*tags).each do |k, v|\n mp3.tag2[k.upcase] = v\n end\n end\n end", "def prepare_files\n return if temp_files.blank?\n\n restrict_to_single_file! if pagefile?\n\n temp_files.each do |file|\n files.build(\n site: blockable.site,\n dimensions: tag.try(:dimensions),\n file: file\n )\n end\n end", "def template_tags(record_type)\n s = Source.new(record_type: record_type)\n e = EditorConfiguration.get_default_layout(s)\n marc_tags = e.layout_tags\n excluded_tags = e.excluded_tags_for_record_type(s)\n return marc_tags - excluded_tags\n end", "def tags_to_remove\n return @tags_to_remove\n end", "def teardown\n @tag = nil\n end", "def tags_to_remove\n linked_tags - current_tags\n end", "def touch_tags\n tags.each(&:touch)\n end" ]
[ "0.59977907", "0.5498224", "0.54850596", "0.54386735", "0.54386735", "0.5372725", "0.53447247", "0.5339016", "0.5325439", "0.5296333", "0.5286172", "0.5284614", "0.52667695", "0.5232261", "0.5206687", "0.5190803", "0.5152664", "0.5139368", "0.5127076", "0.5112749", "0.5083071", "0.5083071", "0.5047041", "0.50412536", "0.49996012", "0.49968436", "0.49940038", "0.4987982", "0.49869952", "0.49841127" ]
0.59868336
1
Easy method to calculate the percentage of used tags of a template
def tag_rate marc.load_source false ((marc.all_tags.map{|e| e.tag}.uniq.size.to_f / (template_tags(record_type).uniq.size.to_f * 100)) * 100).round(2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tags\n tags= Tag.find_all_with_article_counters(20)\n total= tags.inject(0) {|total,tag| total += tag[:article_counter] }\n average = total.to_f / tags.size.to_f\n sizes = tags.inject({}) {|h,tag| h[tag[:name]] = (tag[:article_counter].to_f / average); h} # create a percentage\n # apply a lower limit of 50% and an upper limit of 200%\n sizes.each {|tag,size| sizes[tag] = [[2.0/3.0, size].max, 2].min * 100}\n\n str= \"<p style=\\\"overflow:hidden\\\">\"\n tags.sort{|x,y| x[:name] <=> y[:name]}.each do |tag|\n str += \"<span style=\\\"font-size:#{sizes[tag[:name]]}%\\\"> #{link_to(tag[:name], url(:tag, tag[:name]))}</span>\"\n end\n str += \"</p>\"\n @body= str\n render\n end", "def tag_counts\n JekyllTags.tag_count.each do |tag,count|\n puts \"#{tag}: #{count}\"\n end\n end", "def tag_probability(previous_tag, current_tag)\n denom = @tag_frequencies[previous_tag]\n\n if denom.zero?\n 0\n else\n @tag_combos[\"#{previous_tag}/#{current_tag}\"] / denom.to_f\n end\n end", "def markup_percent\n return nil if trade_price.nil? || retail_price.nil? || trade_price == 0\n if tax_category.included_in_retail?\n 100 * (retail_price - trade_price_with_tax) / trade_price_with_tax\n else\n 100 * (retail_price - trade_price) / trade_price\n end\n end", "def _total # :nodoc:\n total = 0\n @tags.each do |name, hash|\n total += hash['total']\n end\n total\n end", "def word_tag_probability(word, tag)\n denom = @tag_frequencies[tag]\n\n if denom.zero?\n 0\n else\n @word_tag_combos[\"#{word}/#{tag}\"] / denom.to_f\n end\n end", "def tags_with_user_tag_counts\n\t\tuser_tags = tags.pluck(:name)\n\t\tuser_tag_list = Hash.new(0)\n\n\t\tuser_tags.each do |t|\n\t\t\tuser_tag_list[t] += 1\n\t\tend\n\n\t\ttags = treasures.tag_counts_on(:tags)\n\t\ttags.map do |t|\n\t\t\tt.taggings_count = user_tag_list[t.name]\n\t\tend\n\n\t\ttags\n\tend", "def normalized_taggings_count\n max = Tag.maximum :taggings_count # the Rails query cache will cache this\n min = Tag.minimum :taggings_count # the Rails query cache will cache this\n range = max - min\n count = self.taggings_count\n (count - min).to_f / range\n end", "def get_tag_count(document, tag)\n count = 0\n start_tag_with_attrs_pattern = \"(<\" + tag + \" ([^>]+)>)\"\n start_tag_pattern = \"<\" + tag + \">\";\n empty_tag_pattern = \"<\" + tag + \"/>\";\n start_tags_attr = document.scan(/#{start_tag_with_attrs_pattern}/i)\n start_tags = document.scan(/#{start_tag_pattern}/i)\n empty_tags = document.scan(/#{empty_tag_pattern}/i)\n count = start_tags_attr.size if start_tags_attr != nil?\n count = count + start_tags.size if start_tags != nil?\n count = count + empty_tags.size if empty_tags != nil?\n count\n end", "def percentage; end", "def tag_count\n tags.count\n end", "def tag_counts\n self.parent.tag_counts\n end", "def template_difference(rt)\n return marc.all_tags.map{|e| e.tag}.uniq - template_tags(rt).uniq\n end", "def build_tag_cloud(tags)\n max, min = 30, 10 # font size of tags\n popularity = []\n tags.each{|t| (popularity << t.popularity)}\n x = ((max - min) / popularity.uniq.length)\n for i in 0...(tags.length)\n if i != 0 && tags[i - 1].popularity.to_i > tags[i].popularity.to_i\n max=max - x # Setting font size\n end\n yield tags[i].name, max.to_s+'px'\n end\n end", "def weight_tag_name(item)\n tag_name = item[:tag_name]\n # No a heading, no weight\n return 0 unless %w(h1 h2 h3 h4 h5 h6).include?(tag_name)\n # h1: 100, h2: 90, ..., h6: 50\n 100 - (tag_name.delete('h').to_i - 1) * 10\n end", "def percentages\n @_percentages ||= words.each_with_object({}) do |word_count, hash|\n hash[word_count.first] = percentage(word_count.last)\n end\n end", "def stats\n untranslated_size = untranslated.size\n translated_size = translated.size\n fuzzy_size = fuzzy.size\n\n {\n translated: percentage(translated_size),\n untranslated: percentage(untranslated_size),\n fuzzy: percentage(fuzzy_size)\n }\n end", "def vote_percent\n Vote.percent(vote_cache)\n end", "def sort_by_tag_count\n end", "def tag_counts\n if @tag_counts.nil?\n @tag_counts = {}\n tasks.each do |task|\n task.tags.each do |tag|\n @tag_counts[tag] = (@tag_counts[tag] || 0) + 1\n end\n end\n end\n\n return @tag_counts\n end", "def score\n documented = @files.inject(0) {|sum, file| sum += file.total_documented }\n total = @files.inject(0) {|sum, file| sum += file.total_entities }\n ((documented.to_f / total) * 100).to_i\n end", "def tags_count\n self[:tags_count].to_i\n end", "def tags_count\n self[:tags_count].to_i\n end", "def build_tag_cloud(tag_cloud, style_list)\nmax, min = 0, 0\ntag_cloud.each do |tag|\nmax = tag.popularity.to_i if tag.popularity.to_i > max\nmin = tag.popularity.to_i if tag.popularity.to_i < min\nend\n\ndivisor = ((max - min) / style_list.size) + 1\n\ntag_cloud.each do |tag|\nyield tag.name, style_list[(tag.popularity.to_i - min) / divisor]\nend\nend", "def income_estimation(*tags)\n\t #debugger\n\t softotal = 0\n @sourceoffunds.each do |sof|\n if (tags.flatten.count == 0)\n softotal += sof.dollars.to_i * (sof.likelyhood.to_f / 100)\n else\n tags.flatten.each do |tag|\n if (tags.count > 0 && self.findsoftag(sof.name, tag)) \n softotal += sof.dollars.to_i * (sof.likelyhood.to_f / 100)\n break # if the tag is included, count in the sum (once)\n end\n end\n end\n end\n softotal\n end", "def semantic_coverage\n num = 0\n den = 0\n @word_list.each do |word|\n num += word.analyzed_meaning.length\n den += word.meaning.length\n end\n num/den.to_f\n end", "def tags_with_counts\n counts = Hash.new(0)\n Tag.all(:id => taggings, :select => 'word').collect(&:word).each{|val|counts[val]+=1}\n counts.sort{|a,b| a[1] <=> b[1]}.reverse\n end", "def covered_percentages; end", "def percent_of_word(word)\n @total_count = SubWordJoin.where(word: word).count\n puts @total_count\n sub_count = 0\n @sub = SubDriver.where(driver: self)\n @sub.each do |sub|\n sub_count += SubWordJoin.where(word: word, sub_driver: sub).count\n end\n\n percent = (sub_count.to_f/@total_count)*100\n return percent.round(2)\n\n end", "def macro_percentages\n \n if self.total_calories!=nil and self.protein_grams != nil and self.carbohydrate_grams!=nil and self.fat_grams!=nil\n return {:protein=>protein_grams.to_f/total_calories, :carbohydrate => carbohydrate_grams.to_f/total_calories, :fat=> fat_grams.to_f/total_calories}\n end\n\n return nil\n end" ]
[ "0.67622185", "0.62887716", "0.6198711", "0.6170837", "0.6094978", "0.60116404", "0.59656537", "0.5952613", "0.5927743", "0.5912968", "0.5907246", "0.58817786", "0.58460903", "0.581814", "0.5813026", "0.5792468", "0.57368886", "0.56930023", "0.56496304", "0.56465", "0.563096", "0.56307346", "0.56307346", "0.5621137", "0.5617298", "0.5608842", "0.5605452", "0.5601809", "0.5584387", "0.5573187" ]
0.74017155
0
There should be an error with the duration format
def should_be_wrong_on_duration_format(wrong_song = @wrong_song) validate_column_errors(wrong_song, :duration, false, 'activerecord.errors.models.song.attributes.duration.invalid_format') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_duration\n if ui_duration.present? && ui_duration&.respond_to?(:include?)\n if ui_duration == 'N/A'\n self.duration = nil\n self.ui_duration = ''\n elsif ui_duration.tr('0-9', '').length > 0 # expect there is some delimiter\n delimiter = ui_duration.tr('0-9', '').first # the typo for colon has to be consistent, 01;18/05 will fail\n ui_duration.gsub!(delimiter, ':') # whatever the non-digit was, make it a colon\n self.duration = unformatted_time(ui_duration) # expect hh:mm or hh:mm:ss format\n else\n self.duration = ui_duration.to_i # expect raw minutes format\n end\n end\n end", "def duration\n duration = @file_metadata.duration.to_s\n\n # in format like: 0:02:43 (approx)\n if duration.match /(\\d{1,2}):(\\d{1,2}):(\\d{1,2})/\n hours = $1.strip.to_i\n minutes = $2.strip.to_i\n seconds = $3.strip.to_i\n\n if hours.to_i == 0\n return sprintf(\"%02d:%02d\", minutes, seconds)\n else\n return sprintf(\"%01s:%02d:%02d\", hours, minutes, seconds)\n end\n elsif duration.match /(\\d{1,2})\\.(\\d{1,2}) s/i\n # in format like: 23.41 s (approx)\n # $1 = 23\n # $2 = 41\n seconds = $1.strip.to_i\n return sprintf(\"%02d:%02d\", 0, seconds)\n end\n end", "def four_parts_duration_validation(common_duration)\n if common_duration.length != 1\n raise HarmonicsHelper::Errors::DurationUnmatchedError.new(\"Durations are different\")\n end\n end", "def is_duration_correct?\n if duration <= 0 || (duration % 5) != 0\n errors.add(:duration, \" must be a multiple of 5 and can't be blank\")\n end\n end", "def test_invalid_durations\n for invalid_duration in [\"12:10\",\"poaiopsdf\", \"oisadfioasdiofuo\", \"123786\", \"20 past 7\", \" a while\", \"20 minutes long\"]\n @resource.duration = invalid_duration\n assert !@resource.save\n end\n \n @resource.duration = \"1:2:3\"\n assert !@resource.save\n \n @resource.duration = \"00:20:3\"\n assert !@resource.save\n \n @resource.duration = \"00:2:30\"\n assert !@resource.save\n \n @resource.duration = \":2:30\"\n assert !@resource.save\n end", "def format_duration\n if duration % 60 != 0\n \"#{duration/60} hours #{duration%60} minutes\"\n else\n \"#{duration/60} hours\"\n end\n end", "def formatted_duration\n hours = self.duration / 60\n minutes = self.duration % 60\n if minutes == 0\n \"#{hours}h\"\n else\n \"#{hours}h#{minutes}min\"\n end\n end", "def test_iso8601_parsing_wrong_patterns_with_raise\n invalid_patterns = [\"\", \"P\", \"PT\", \"P1YT\", \"T\", \"PW\", \"P1Y1W\", \"~P1Y\", \".P1Y\", \"P1.5Y0.5M\", \"P1.5Y1M\", \"P1.5MT10.5S\"]\n invalid_patterns.each do |pattern|\n assert_raise ActiveSupport::Duration::ISO8601Parser::ParsingError, pattern.inspect do\n ActiveSupport::Duration.parse(pattern)\n end\n end\n end", "def parse_duration(str)\n return nil if str.nil? || str.empty?\n parts = str.match(/^(?<h>\\d+):(?<m>\\d+) h$/)\n hours = parts[:h].to_i\n minutes = parts[:m].to_i\n hours * 3660 + minutes\n end", "def parse_duration(duration)\n\n # parses note name input\n # user should be able to say \"dotted sixteenth\" or \"quarter\" or \"triplet eighth\"\n groups = duration.to_s.match(/^((dotted|triplet)( |_))?(.*)$/)\n puts \"duration: #{duration}\" if groups.nil?\n\n d = DURATIONS.index(groups[4])\n multiplier = MULTIPLIER[groups[2].to_s.to_sym]\n #binding.pry\n\n Rational(4*(3**multiplier),(2**(multiplier+d)))\n end", "def duration(duration)\n format('%.6f', duration) if duration\n end", "def is_duration_correct?\n\t\tif duration !=nil && (duration <= 0 || (duration % 5) != 0 )\n\t\t\terrors.add(:duration, \"duration must be a positive number and a multiple of 5 !\")\n\t\tend\t\t\t\n\tend", "def duration time_string\n if time_string == 'never'\n 'never'\n else\n hour, min, sec = *time_string.split(/:/).map(&:to_i)\n (hour*60.0 + min + sec/60.0).round(2)\n end\n end", "def duration_formatted\n if self.duration.days > 0\n hours = self.duration.total / 60 / 60\n self.duration.format \"#{hours}:%M:%S\"\n else\n self.duration.format \"%H:%M:%S\"\n end\n end", "def out_of_bounds_time_format; end", "def validate_timing\n v = Float(@duration_number) rescue false\n puts \"v = #{v}\"\n if @until_radio == \"date\" && !(Float(@duration_number) rescue false)\n errors.add(:timing_duration, \"you need a duration\")\n end\n if self.kind_of_timing == \"Frequency\" && @freak_number.blank?\n errors.add(:freak_number, \"how often?\")\n end\n end", "def added_time_cannot_be_of_invalid_format\r\n errors.add(:task, \"added time has to be an integer!\") unless\r\n added_time.instance_of?(Fixnum)\r\n end", "def human_length\n if duration_in_ms\n minutes = duration_in_ms / 1000 / 60\n seconds = (duration_in_ms / 1000) - (minutes * 60)\n sprintf(\"%d:%02d\", minutes, seconds)\n else\n \"Unknown\"\n end\n end", "def nltime_duration(duration=nil)\n if duration\n @duration = duration.to_s.capitalize\n else\n @duration || self.to_s.split('::').last\n end\n end", "def duration_unit\n expr = self.timing_duration.blank? ? \"\" : self.timing_duration.split.last\n @duration_unit.nil? ? expr : @duration_unit\n end", "def parse_string(str)\n hms = DURATION_REGEXP.match(str)\n raise ArgumentError, \"The duration #{str} does not match the expected format #{DURATION_REGEXP}\" if hms.nil?\n hms.captures[0].to_i * 60 * 60 + hms.captures[1].to_i * 60 + hms.captures[2].to_i\n end", "def duration_to_seconds(duration)\n t = Time.strptime(duration, '%Hh%Mm')\n hours_spent = t.hour\n minutes_spent = t.min\n\n temp = format('%sh%sm', hours_spent, minutes_spent)\n\n if temp != duration\n error_msg = [Hash[@error => 'time object: invalid duration string']]\n return error_msg\n end\n\n # Convert duration to seconds\n return (hours_spent * 3600) + (minutes_spent * 60)\n rescue\n error_msg = [Hash[@error => 'time object: invalid duration string']]\n return error_msg\n end", "def duration=(_arg0); end", "def calculate_duration_string(duration)\n minutes = duration / 60\n seconds = duration - minutes * 60\n\n hours = minutes / 60\n minutes = minutes - hours * 60\n\n hr_string, min_string, sec_string = hours.to_s, minutes.to_s, seconds.to_s\n\n # hr_string = \"0\" + hr_string if hours < 10\n min_string = \"0\" + min_string if minutes < 10\n sec_string = \"0\" + sec_string if seconds < 10\n\n if hours === 0\n \"#{min_string} mins\"\n elsif hours === 1\n \"#{hr_string}hr #{min_string}mins\"\n else\n \"#{hr_string}hrs #{min_string}mins\"\n end\n\n end", "def duration_number\n expr = self.timing_duration.blank? ? \"\" : self.timing_duration.split.first\n @duration_number.nil? ? expr : @duration_number\n end", "def check_duration\n calculate_duration if self.duration != get_duration\n end", "def encoding_invalid?\n unless File.exists?(@output_file)\n return \"No output file created\"\n end\n\n unless encoded.valid?\n return \"Encoded file is invalid\"\n end\n\n if CONFIG[:validate_duration]\n # reavalidate duration\n precision = @options[:duration] ? 1.5 : 1.1\n desired_duration = @options[:duration] && @options[:duration] < @video.duration ? @options[:duration] : @video.duration\n\n if (encoded.duration >= (desired_duration * precision) or encoded.duration <= (desired_duration / precision))\n return \"Encoded file duration is invalid (original/specified: #{desired_duration}sec, got: #{encoded.duration}sec)\"\n end\n end\n\n false\n end", "def get_duration\n return \"#{self.duration.to_s.sub!('.', ',')} #{I18n.t(\"labels.datetime.hour_short\")}\"\n end", "def initialize(duration)\n @fraction, @fraction_padding, @seconds = parse(duration.to_s)\n end", "def duration; end" ]
[ "0.76124537", "0.7040206", "0.69137615", "0.6793205", "0.674298", "0.6724656", "0.66388893", "0.6596238", "0.6578303", "0.6570081", "0.65654135", "0.65436804", "0.65317076", "0.65108883", "0.65049297", "0.64295685", "0.6386839", "0.6353039", "0.635273", "0.63429344", "0.6261693", "0.6248121", "0.6240577", "0.6234778", "0.62345636", "0.6228276", "0.6211662", "0.62100655", "0.61993635", "0.618786" ]
0.72865766
1
There should be an error if the of song is less or equal than 0
def should_be_wrong_on_n_album_value(wrong_song = @wrong_song) validate_column_errors(wrong_song, :n_album, false, 'errors.messages.greater_than', :count=>0) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_song_length\n if self.length > 10 then\n self.errors.add(:length, \"is longer than 10 minutes...Calm down Free Bird.\")\n elsif self.length < 1 then\n self.errors.add(:length, \"is shorter than 1 minute...C'MON MAN!\")\n end\n end", "def test_room_starts_with_no_songs\n assert_equal(0, @room.song_count())\n end", "def valid_song?(song)\n if song.valid?\n true\n else\n respond(\"As sick as this track is, it's too long man. Max length is #{MAX_SONG_LENGTH} seconds.\")\n false\n end\n end", "def should_be_less_on_rating_value(wrong_song = @wrong_song)\n validate_column_errors(wrong_song, :rating, false, 'errors.messages.less_than_or_equal_to', :count=>5)\n end", "def songs_never_played\n return @tracks.find_all {|s| s.play_count == 0}\n end", "def validate_playlist_length\n errors.add(:position, :reached_maximum_in_playlist) if @virtual_classroom_lesson && @virtual_classroom_lesson.position.nil? && !self.position.nil? && VirtualClassroomLesson.where('user_id = ? AND position IS NOT NULL', @virtual_classroom_lesson.user_id).count == SETTINGS['lessons_in_playlist']\n end", "def read_album music_file\n album_artist = music_file.gets().chomp\n album_title = music_file.gets().chomp\n album_genre = music_file.gets().to_i\n tracks = read_tracks(music_file)\n if tracks.length < 15\n album = Album.new(album_title, album_artist, album_genre, tracks)\n else\n album = Null\n puts \"#{album_title} has more than 15 tracks so it has not been imported.\"\n end\n album\nend", "def test_play_random_song\n result = @room1.play_random_song\n assert_equal(true, @song_library.include?(result))\n end", "def song_count\n @song_count = 0 if @song_count.nil?\n @song_count\n end", "def number_of_songs()\n return songs.length\n end", "def number_of_songs()\n return songs.length\n end", "def music_volume=(value)\n value = value.to_i.abs\n @music_volume = value < 101 ? value : 100\n end", "def test_add_song_to_room\n @room.add_song(@song4)\n assert_equal(4,@room.songs.count)\n end", "def test_next_song\n \n \n assert true\n end", "def test_song_has_track_name\n assert_equal(\"Can't get no Satisfaction\", @song1.track_name)\n end", "def test_song_already_added_to_playlist()\n @room_1.add_song_to_playlist(@song_1)\n @room_1.add_song_to_playlist(@song_1)\n assert_equal(1, @room_1.playlist_count())\n end", "def more_songs\n get_songs\n return @page_size && @songs.count == @page_size\n end", "def valid_songs(songs)\n song_ids & songs\nend", "def song_length(user_entry)\n\t\tmsg = Array.new\n\t\t@songs.each do |song|\n\t\t\tif (user_entry != song.length)\n\t\t\t\tmsg << song\n\t\t\tend\n\t\tend\n\n\t\tif (msg.empty?)\n\t\t\tmsg = msg.to_s\n\t\t\tmsg = \"Sorry no songs with that length!\"\n\t\tend\n\t\treturn msg\n\tend", "def test_check_for_songs_added_to_list\n song = Song.new({title: \"Dancing Queen\"})\n assert_equal(0, @room1.song_list_length())\n end", "def play(songs)\n puts \"Please enter a song name or number:\"\n user_song = gets.chomp\n valid = false\n \n # Puts playing message if input is song number or part of song name\n songs.each.with_index do |song, index|\n if user_song.to_i == index + 1 || song.include?(user_song)\n puts \"Playing #{songs[index]}\"\n valid = true\n # elsif song.include?(user_song)\n # puts \"Playing #{user_song}\"\n # valid = true\n end\n end\n # If no matches, output error message\n puts \"Invalid input, please try again\" if valid == false\nend", "def tests_song_not_found\n assert_equal =\n end\n\nend", "def test_room_has_songs\n assert_equal(3,@room.songs.count)\n end", "def test_playlist_is_empty()\n assert_equal(0, @room.room_playlist())\n end", "def song_label_validation\n unless song_label == nil\n song_label.each do |label|\n errors.add(:song_label, \"\\\"#{label}\\\" is either too long or invalid\") unless label.length < 255 && LABELS.include?(label)\n end\n end\n end", "def should_be_wrong_on_duration_format(wrong_song = @wrong_song)\n validate_column_errors(wrong_song, :duration, false, 'activerecord.errors.models.song.attributes.duration.invalid_format')\n end", "def no_red_numbers\n if self.player.club.cash <= 0\n self.errors[:base] = I18n.t('training.errors.red_numbers')\n end\n end", "def remove_song\n if self.yes?\n Song.decrement_counter(:yes_count, song.id)\n else\n Song.decrement_counter(:no_count, song.id)\n end\n end", "def positive?; end", "def add_track(new_song)\n if AVAILABLE_SONGS.include?(new_song)\n @playlist << new_song\n else\n return false\n end\n end" ]
[ "0.66608953", "0.64055175", "0.6326705", "0.61138743", "0.59263784", "0.576193", "0.5731439", "0.5701372", "0.56917065", "0.56506646", "0.56506646", "0.56280804", "0.56267124", "0.5611954", "0.5594122", "0.55793935", "0.55786854", "0.5578101", "0.5564321", "0.55633056", "0.55517936", "0.5550685", "0.5533918", "0.5512295", "0.54936993", "0.5493445", "0.54840535", "0.5477863", "0.54765284", "0.54764605" ]
0.69651717
0
Have the function ABCheck(str) take the str parameter being passed and return the string true if the characters a and b are separated by exactly 3 places anywhere in the string at least once (ie. "lane borrowed" would result in true because there is exactly three characters between a and b). Otherwise return the string false.
def ABCheck(str) str =~ /a...b/ || str =~ /b...a/ ? true : false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ABCheck(str)\n str.match?(/a.{3}b/) || str.match?(/b.{3}a/)\nend", "def ABCheck(str)\n\n return \"true\" if str=~(/a...b/) or str=~(/b...a/)\n return \"false\"\n \nend", "def abCheck(str)\n\treturn false if(str.include?('a') == false || str.include?('b') == false || str.rindex('b') < str.rindex('a'))\n\treturn str.rindex('b') - str.rindex('a') == 4\n\t\nend", "def ABCheck(str)\n\n counter = 0\n str.each_char do |x|\n if(x == 'a' && counter + 4 < str.length && str.chars.to_a[counter + 4] == 'b')\n return true\n end\n counter += 1\n end\n return false \n \nend", "def ABCheck(str)\n letter_a_index = str.rindex('a')\n letter_b_index = str.rindex('b')\n number_places = letter_a_index - letter_b_index\n if number_places.abs >= 3\n puts 'true'\n else\n puts 'false'\n end\nend", "def ABcheck(str)\ncounter = 0 \nstr.each_char.do |x|\nif( x == 'a' && counter + 4 < str.length str.chars.to_a[counter + 4] =='b'\nreturn true\nend", "def ABCheck(str)\n\n i = 0\n while i < str.length\n puts str[i]\n while str[i] == 'a' && str[i + 4] == 'b' || str[i] == 'b' && str[i +4] == 'a'\n \tputs str[i]\n \treturn 'true'\n end\n i += 1\n end\n return 'false'\nend", "def ABCheck(str)\n\n new_str = str.split(\"\")\n index = 0 \n value = false\n \n while index < new_str.length\n if new_str[index] == 'a' and new_str[index+4] == 'b'\n value = true\n end\n index += 1\n end\n \n \n # code goes here\n return value \n \nend", "def ABCheck(str)\n str.scan(/a...b/) == [] ? false : true # how this method tests 'b' before 'a'? \nend", "def nice_b?(string)\n doubledouble = false\n xyx = false\n\n pairs = Set.new\n i = 1\n while doubledouble == false && i <= string.length\n pair = \"#{string[i - 1]}#{string[i]}\"\n doubledouble = pairs.include?(pair) unless doubledouble == true\n pairs.add(pair)\n\n i += 1 if string[i] == string[i - 1] && string[i] == string[i + 1]\n i += 1\n end\n\n for idx in (1..string.length)\n curr_char = string[idx - 1]\n thrd_char = string[idx + 1]\n\n xyx ||= (curr_char == thrd_char)\n\n end\n doubledouble && xyx\nend", "def balancer(str)\n str.count('(') == str.count(')')\nend", "def nearby_az(string)\n letters = string.split('')\n\nif (string.include? \"a\") && (string.include? \"z\")\n ind_a = letters.index(\"a\")\n ind_z = letters.index(\"z\")\n difference = ind_z - ind_a\n if (difference.between?(0,3))\n return true\n else\n return false\n end\nelse \n return false\nend\nend", "def yours?(str)\n str[0..1] == 'BA'\n end", "def valid?(password)\n # Does not contain i o l\n return false if password =~ /i|o|l/\n\n # Finds a straight\n return false unless password\n .split('')\n .each_cons(3)\n .find {|a| a[1] == a[0].next && a[2] == a[1].next }\n\n # Contains two different overlapping pairs\n return false unless password\n .split('')\n .slice_when{|i,j| i!=j}\n .select{|a| a.size == 2}\n .uniq\n .count >= 2\n return true\nend", "def balancer(str)\n return false unless str.count('(') == str.count(')')\n\n count = 0\n\n str.each_char do |char|\n if char == '('\n count += 1\n elsif char == ')'\n count -=1\n end\n return false if count < 0\n end \n \n true\nend", "def balancer(string)\n return false unless string.count(\"(\") == string.count(\")\")\n \n paren_count = 0\n \n string.split(\"\").each do |char|\n paren_count +=1 if char == \"(\"\n paren_count -=1 if char == \")\"\n \n return false if paren_count < 0 \n end\n \n true\n end", "def balancer(string)\n string.count(\"(\") == string.count(\")\")\nend", "def triplet_true?(str)\n str.each_char.with_index { |char, i| return true if char * 3 == str[i...i+3] }\n false\nend", "def balancer(string)\n string.count('(') == string.count(')')\nend", "def balancer(string)\n open_paren_counter = 0\n closed_paren_counter = 0\n string.chars.each do |char|\n open_paren_counter += 1 if char == \"(\"\n closed_paren_counter += 1 if char == \")\"\n return false if closed_paren_counter > open_paren_counter\n end\n return false if open_paren_counter != closed_paren_counter\n true\nend", "def one_away?(str1, str2)\n if (str1.length - str2.length).between?(0,1)\n str1_index = 0\n str2_index = 0\n errors = 0\n\n count_errors = lambda do |str1, str2|\n if str1[str1_index] == str2[str2_index]\n str1_index += 1\n str2_index += 1\n else\n if errors.zero?\n errors += 1\n else\n return false\n end\n\n if str1.length > str2.length\n str1_index += 1\n elsif str2.length > str1.length\n str2_index += 1\n else\n str1_index += 1\n str2_index += 1\n end\n end\n end\n\n [str1.length, str2.length].max.times do |k|\n return false if !count_errors.call(str1, str2)\n end\n else\n false\n end\n\n return true\nend", "def string_check(elem)\n (('a'..'z').to_a + ('A'..'Z').to_a).each { |k| return true if elem.include?(k) }\n false\n end", "def third_anagram?(str, word)\n str.chars.sort == word.chars.sort\n end", "def nearby_az(string)\n a = string.chars.find_index('a')\t\t\t# Find index of 'a'\n z = string.chars.find_index('z')\t\t\t# Find index of 'z'\n return false if a == nil || z == nil \t\t# Return false if either 'a' or 'z' doesn't exist in string\n (z-a).between?(1,3) \t\t\t\t\t\t# See if z is within 3 letters after a\nend", "def nearby_az string\n\n (0...string.length).each do |i|\n if string[i] == \"a\"\n if string[(i + 1)..(i + 3)].include?(\"z\")\n return true\n end\n end\n end\n false\nend", "def uppercase3?(string)\n #p string.scan(/[a-z]/i)\n !string.scan(/[A-Z]/).empty? && string.scan(/[A-Z]/) == string.scan(/[a-z]/i)\nend", "def pair_not_overlapping?\n !(self.match(/([a-z][a-z]).*\\1/)).nil?\n end", "def third_anagram?(str, target)\n str.split(\"\").sort == target.split(\"\").sort\nend", "def balancer(str)\n open_idx = 0\n closed_idx = 0\n\n chars = str.chars\n\n total_open = chars.count('(')\n total_closed = chars.count(')')\n\n return false if total_open != total_closed\n\n chars.each_with_index do |chr, idx|\n if chr == '('\n open_idx = idx\n elsif chr == ')'\n closed_idx = idx\n end\n return false if open_idx > closed_idx\n end\n\n open_idx < closed_idx ? true : puts(\"no parentheses in the string\")\nend", "def one_away?(string)\n return true if self == string\n if (self.length - string.length).abs > 1\n return false\n elsif (self.length - string.length).abs == 0\n string_one = self.split(\"\")\n string_two = string.split(\"\")\n counter = 0\n\n string_one.zip(string_two).each do |i, j|\n if !(i==j)\n counter +=1\n end\n end\n counter == 1 ? true : false\n else\n raise NotImplementedError\n end\n end" ]
[ "0.876359", "0.8190788", "0.8073621", "0.7719317", "0.7494464", "0.7479125", "0.7369406", "0.7226343", "0.70352924", "0.6747668", "0.6585306", "0.65542865", "0.65087175", "0.6494732", "0.6490071", "0.64835626", "0.6453357", "0.6440847", "0.64350724", "0.63982296", "0.639576", "0.63527733", "0.6344922", "0.6334783", "0.6334445", "0.6302727", "0.6296024", "0.62754714", "0.62561953", "0.6253772" ]
0.82180387
1
Have the function WordCount(str) take the str string parameter being passed and return the number of words the string contains (ie. "Never eat shredded wheat" would return 4). Words will be separated by single spaces.
def WordCount(str) str.split(" ").count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def WordCount(str)\n\twords = str.split(\" \").count\n\treturn words\nend", "def wordCounter(inputString)\n inputString.scan(/\\w+/).length\nend", "def WordCount(string)\n string.scan(/\\w+/).count\nend", "def word_count(string)\n words = string.split(/\\W+/) #split on any non-word char. Thanks Rubular.com!\n #Using \\b counts even spaces as \"words\". Using \\W counts ... as three words.\n #\\W+ splits on one or more of any non-word character\n words.length #return length\nend", "def count_words_in(the_string)\n the_words = the_string.split\n the_words.size\nend", "def WordCount(str)\n\tarr = str.split(\" \").count\nend", "def number_of_words(string)\n\tstring.split.size\nend", "def WordCount(str)\n\n # code goes here\n return str.split(\" \").length # .split.count, split(‘ ’).size\n \nend", "def number_of_words(str)\n\tcount=1\n\tstr=gets.chomp\n\tfor char in str\n\t\tif char == \" \"\n\t\t\tcount=count+1\n\t\tend\n\tend\n\tputs count\nend", "def count_words(string)\r\n string.scan(/\\w+/).each_with_object(Hash.new(0)){|w,h| h[w.downcase]+=1}\r\n end", "def WordCount(str)\n\n arr=str.split\n return arr.length\nend", "def count_words(string)\n return nil if string.nil?\n\n w = string.split(/\\b/).map {|x| x.gsub(/[\\W]+/, '').downcase}.reject {|x| x.empty?}\n Hash[w.map {|x| [x, w.select {|y| x == y}.size]}]\nend", "def word_count(string)\n string_arr = string.split \n string_arr.size \nend", "def word_count(text)\n return text.split.count\nend", "def count_words(string)\n\tputs string\n\tstring.downcase!\n\tstring = string.gsub(/\\W+/, ' ')\n\tstring = string.split(/\\b/)\n\twordhash = Hash.new\n\tstring.each do |word| \n\t\tif wordhash.has_key?(word)\n\t\t\twordhash[word] += 1\n\t\telsif word === \" \"\n\t\t\n\t\telse\n\t\t\twordhash[word] = 1\n\t\tend\n\tend\n\tputs wordhash\nend", "def word_count(str)\n count = {}\n str.split(' ').each do |word|\n word = word.downcase.gsub(/[^a-z]/, '')\n if count[word].nil?\n count[word] = 1\n else\n count[word] += 1\n end\n end\n count\n end", "def count_words(count_string)\n\t\tcount_string = count_string.to_s unless count_string.is_a? String\n\t\tunless count_string.nil?\n\t\t\tarray_elem = count_string.split(/\\s+/)\n\t\t\t@total_words += array_elem.size\n\t\tend\n\tend", "def count_words(string)\n arg = string.downcase.gsub(/[^a-z ]/,\"\")\n words = arg.split(/\\s+/)\n result = Hash.new\n words.each { |word| \n if result[word].nil? then result[word] = 1 else result[word] += 1 end\n }\n result\nend", "def word_counter\n \"This is a string\".split.size\nend", "def count_words\n string = self.squish.downcase.gsub(/[^a-z0-9\\s]/i, '')\n string = string.split(\" \")\n words = Hash.new(0)\n string.each { |x|\n words[x] +=1;\n }\n return words\n end", "def count_words(str)\n\tstr.gsub!(/[\\b[^a-zA-Z ]]/, '')\n\tarr = str.downcase.split\n\thash = Hash.new(0)\n\tarr.each { |name| hash[name] += 1 }\n\treturn hash\nend", "def count_words(string)\n\twords = Hash.new\n\t\n\tstring.downcase.scan(/[\\w]+\\b/) { |word|\n\t\tif !words.has_key?(word)\n\t\t\twords[word] = 0\n\t\tend\n\t\t\n\t\twords[word] += 1\n\t}\n\t\n\treturn words\nend", "def count_words(str)\n\tcounts = {}\n\tstr.downcase.scan(/\\b[a-z]+/).each do |word|#word is the index here\n\t\tif counts[word].nil? then\n\t\t\tcounts[word]=1\n\t\telse\n\t\t\tcounts[word] +=1\n\t\tend\n\tend\n\tputs counts\nend", "def count_words(s)\n\ts = s.downcase\n\ts.gsub!(/\\W+/,\" \")\n\ts = s.split(\" \")\n\tfreqs = Hash.new(0)\n\ts.each{ |word| freqs[word] += 1 }\n\treturn freqs\nend", "def word_sizes(str)\n word_counts = Hash.new(0)\n str.gsub(/[^a-zA-Z ]/, '').split.each { |word| word_counts[word.length] += 1 }\n word_counts\nend", "def word_count(string)\n words = string.split(\" \")\n count = Hash.new(0)\n words.each { |word| count[word] += 1}\n count\nend", "def word_sizes(str)\n counter = Hash.new(0)\n str.split.each do |word|\n counter[word.gsub(/\\W/,'').length] += 1\n end \n counter\nend", "def word_counter (string)\n array = string.split\n array.length\nend", "def word_counter(string)\n new_string = string.split\n return new_string.length\nend", "def word_counter(string)\n\n if string.empty? #== 0, suggested by Rubocop\n i_num_words = 0\n else\n new_string = string\n new_string = new_string.delete \" \"\n i_num_words = string.length - new_string.length + 1\n end\n return i_num_words\nend" ]
[ "0.89500123", "0.86187196", "0.8612002", "0.8525554", "0.8446864", "0.844616", "0.8371299", "0.8360744", "0.8358089", "0.824558", "0.8227717", "0.81846863", "0.81730646", "0.80608886", "0.8028142", "0.8014641", "0.79968244", "0.79944557", "0.7943152", "0.7879829", "0.7867023", "0.785728", "0.7851665", "0.78452766", "0.7842001", "0.78407055", "0.7835344", "0.7810803", "0.78078574", "0.77832675" ]
0.8859508
1
Have the function ExOh(str) take the str parameter being passed and return the string true if there is an equal number of x's and o's, otherwise return the string false. Only these two letters will be entered in the string, no punctuation or numbers. For example: if str is "xooxxxxooxo" then the output should return false because there are 6 x's and 5 o's.
def ExOh(str) str.scan("x").count == str.scan("o").count ? true : false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ExOh(str)\n\n return true if str.scan(/x/).size == str.scan(/o/).size\n return false \n \nend", "def XO(str)\n exes = str.downcase.count('x')\n ohs = str.downcase.count('o')\n exes == ohs ? true : false\nend", "def ExesAndOhs(string)\n \n counter_x = string.chars.count { |x| x == \"x\" || x == \"X\" }\n counter_o = string.chars.count { |x| x == \"o\" || x == \"O\"\t}\n\n counter_x == counter_o\n\nend", "def XO(str)\n p = str.downcase\n g = p.count(\"x\")\n h = p.count(\"o\")\n (g == h ? true : false)\nend", "def xo(str)\n\to_count = str.downcase.scan('o').count\n\tx_count = str.downcase.scan('x').count\n\treturn o_count == x_count ? true : false\nend", "def ExOh(str)\n str.scan('x').count == str.scan('o').count ? p(\"true\") : p(\"false\")\nend", "def ex_oh(str)\n str.downcase.scan(/x/).count == str.downcase.scan(/o/).count\nend", "def ExOh(str)\n countZ = 0 \n countO = 0 \n # code goes here\n if str.each_char do |letter|\n if letter == \"x\"\n countZ += 1\n elsif letter == \"o\"\n countO += 1\n end\n end\n \n\t#return countZ == countO ? true : false \n if countZ == countO \n return true \n else\n return false \n end\n \nend\nend", "def XO(str)\n x = str.downcase.count(\"x\")\n o = str.downcase.count(\"o\")\n x == o ? true : false\nend", "def XO(str)\n\treturn true if (str.downcase.count \"x\") == (str.downcase.count \"o\")\n\tfalse\nend", "def XO(str)\n if str.scan(/[xX]/).count == str.scan(/[oO]/).count\n true\n elsif str.scan(/[xXoO]/).count == 0\n true\n else\n false\n end\nend", "def XO(str)\n if (str.downcase.count('x') == str.downcase.count('o') )\n puts \"true\"\n return true\n else puts \"false\" \n return false\n end\nend", "def XO(str)\n puts str.downcase.count('x') == str.downcase.count('o') ? true : false\nend", "def XO(str)\n xstring_count = str.count(\"x,X\")\n ostring_count = str.count(\"o,O\")\n if xstring_count == ostring_count\n true\n else\n false\n end\nend", "def exes_and_ohs(str)\n arr = str.downcase.split(\"\")\n\n count_o = 0\n count_x = 0\n \n arr.each do |i|\n if i == \"o\"\n count_o += 1\n elsif\n i == \"x\"\n count_x += 1\n else\n return true\n end\n end\n\n return count_x == count_o\n\nend", "def XO(str)\n str.downcase.count('x') == str.downcase.count('o')\n\nend", "def XO(str)\n str.downcase.count(\"x\") === str.downcase.count(\"o\")\nend", "def XO(str)\n \n counter_1 = 0\n counter_2 = 0\n \n letters = str.downcase.split('')\n\n letters.each do |letter|\n case letter\n when 'x'\n counter_1 += 1\n when 'o'\n counter_2 += 1\n end\n end\n \n counter_1 == counter_2\n \nend", "def XO(str)\n # Method for amount of x's\n # Method for amount of o's\n # Comparison of these amounts ==> return boolean\n\n x_list = []\n o_list = []\n \n #loop through the letters, add these to an array first?\n # if current index is an x, add it to x_list\n # for x in str.length - scan through then check each letter (index)\n \n for i in 0..str.length do\n if str[i] == \"x\"or str[i] == \"X\"\n \n #Add to array\n\n x_list.push(str[i])\n end\n end\n\n for i in 0..str.length do\n if str[i] == \"o\" or str[i] == \"o\"\n\n\n #Add to array\n\n o_list.push(str[i])\n end\n end\n\n if (x_list.length == o_list.length)\n return true\n else \n return false\n\n end\n\nend", "def exes_and_ohs(input_string)\n unique_array = input_string.downcase.split('').uniq\n input_array = input_string.downcase.split('')\n if (unique_array.length == 2)\n count_1 = input_array.count(unique_array[0])\n count_2 = input_array.count(unique_array[1])\n if count_1 == count_2\n return true\n else\n return false\n end\n else \n return false\n end\nend", "def isValid(s)\n # Write your code here\n character_hash = {}\n ('a'..'z').to_a.each do |ch|\n occurences = s.count(ch)\n character_hash[ch] = occurences unless character_hash[ch]\n end\n occurances_array = character_hash.values.select{ |a| a > 0 }\n max_occurence = occurances_array.max\n min_occurence = occurances_array.min\n return 'YES' if max_occurence == min_occurence\n return 'YES' if max_occurence - min_occurence == 1 && (occurances_array.count(max_occurence) == 1 || occurances_array.count(min_occurence) == 1)\n return 'YES' if min_occurence == 1 && occurances_array.count(min_occurence) == 1 && occurances_array.uniq.count == 2\n return 'NO'\nend", "def g_happy(str)\n (str.size).times do |x|\n slice = str[x + 1..(str.size + 1)]\n if slice == \"gg\"\n return true\n end\n end\nend", "def exes_and_ohs(input)\n # Your code goes here\n arr = input.downcase.split('')\n\n if arr.uniq.count == 2 && arr.count <= 6\n puts true\n else\n puts false\n end\nend", "def g_happy(string) # if all g's are next to g's, return true\n return string.scan(/gg/).length == string.scan(/g./).length\nend", "def g_happy(str)\n i = 0\n count = 0\n str.size.times do |letter|\n if str[letter] == \"g\"\n if str[letter] != str[i + 1]\n if str[letter] != str[i - 1]\n return false\n end\n end\n else\n count += 1\n end\n i += 1\n end\n if count == str.size\n return false\n else\n return true\n end\nend", "def g_happy(str)\n i = 0\n count = 0\n str.size.times do |letter|\n if str[letter] == \"g\"\n if str[letter] != str[i + 1]\n if str[letter] != str[i - 1]\n return false\n end\n end\n else\n count += 1\n end\n i += 1\n end\n if count == str.size\n return false\n else\n return true\n end\nend", "def is_isogram(string)\n string.downcase.each_char { |char| return false if string.downcase.count(char) > 1 }\n true\nend", "def step_through_with(s)i\n # It doesn't solve the kata because it returns true even if same chars are met in diffrent part of the word. Like \"ThaT\"\n s.chars.count == s.chars.uniq.count\nend", "def repeating_letters?(str)\n # your code goes here\n str.each_char do |ch|\n if str.downcase.count(ch) > 1\n return true\n end\n end\n false\nend", "def g_happy(str)\n happy = true\n str.size.times do |n|\n if str[n] == \"g\" && str[n + 1] != \"g\" && str[n - 1] != \"g\"\n happy = false\n end\n end\n return happy\nend" ]
[ "0.86377835", "0.82319397", "0.8230648", "0.82204753", "0.8170948", "0.8158809", "0.8156606", "0.80862814", "0.80744016", "0.806264", "0.79746556", "0.7919636", "0.79123974", "0.78828144", "0.77795196", "0.775904", "0.7731061", "0.73415", "0.7263471", "0.7133726", "0.6729279", "0.67177343", "0.67135435", "0.65873224", "0.655113", "0.655113", "0.6492387", "0.6380271", "0.63774616", "0.6375473" ]
0.8597745
1
Have the function ArrayAdditionI(arr) take the array of numbers stored in arr and return the string true if any combination of numbers in the array can be added up to equal the largest number in the array, otherwise return the string false. For example: if arr contains [4, 6, 23, 10, 1, 3] the output should return true because 4 + 6 + 10 + 3 = 23. The array will not be empty, will not contain all the same elements, and may contain negative numbers.
def ArrayAdditionI(arr) largest = arr.sort!.pop (2..arr.length).each {|i| arr.combination(i).to_a.each {|x| return true if x.inject(:+) == largest}} false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def arrayAdditionI(arr)\n\tarrSum = 0\n\tlargestNum = arr.sort.pop\n\tarr.each{|x| arrSum += x if(x < largestNum) }\n\tif(arrSum >= largestNum || arr.include?(arrSum - largestNum))\n\t\treturn true\n\telse \n\t\treturn false\n\tend\nend", "def ArrayAdditionI(arr)\n i = 2\n while i < arr.length\n cs = arr.combination(i)\n sums = cs.map{|c| c.inject{|sum, n| sum += n}}\n return true if sums.include?(arr.max)\n i += 1\n end\n return false\nend", "def ArrayAdditionI(arr)\n\n # code goes here\n arr.sort!\n largest = arr.last\n sum = 0\n for i in 0..arr.length-2\n sum += arr[i]\n if sum >= largest\n return true\n break\n end\n end\n return false \n \nend", "def array_addition(arr)\n max = arr.max\n arr.delete(max)\n (2..arr.length).each do |i|\n combinations = arr.combination(i)\n combinations.each do |comb|\n if comb.inject(:+) == max\n return true\n break\n end\n end\n end\n return false\nend", "def ArrayAddition(arr)\n largest = arr.sort!.pop\n arr.inject(0) {|sum, number| sum += number} == largest ? true:false \nend", "def Superincreasing(arr)\n sum = 0\n arr.each do |num|\n return false if num <= sum\n sum += num\n end\n return true\nend", "def Superincreasing(arr)\n total = 0\n arr.each do |i|\n if i <= total\n return false\n end\n total += i\n end\n\n true\nend", "def Superincreasing(arr)\n arr.each_with_index do |num, idx|\n next if idx == 0\n return 'false' unless arr[0...idx].sum < num\n end\n 'true'\nend", "def sum_checker(array)\n# Check if the array contains at least 2 elements\n if array.length < 2\n false\n else\n# Iterate over the array to check if the array has a -num (num and -num add up to zero)\n array.each do |num|\n return true if array.include?(-num)\n end\n end\n false\nend", "def okay_two_sum?(arr, target_sum)\n\narr.sort!\n\nreturn false if arr[-1] < target_sum\n\ni = 0\ni += 1 until arr[i] > target_sum\n\nresult = []\nnew_arr = arr[0...i]\n(0...new_arr.length - 1).each do |i|\n (i+1...new_arr.length).each do |j|\n result << new_arr[i] + new_arr[j]\n end\n end\n result.include?(target_sum)\n\nend", "def okay_two_sum?(arr, num)\n arr1 = arr.sort\n i = 0\n j = arr.length - 1\n\n while i < j\n case arr[i] + arr[j] <=> num\n when -1\n i += 1\n when 0\n return true\n when 1\n j -= 1\n end\n end\n false\nend", "def okay_two_sum?(arr, target) # => [0,1,5,7] \n sorted = qs(arr)\n\n (0...sorted.length-1).each do |i|\n return true if sorted[i] + sorted[i + 1] == target\n end\n\n false\nend", "def okay_two_sum_a?(arr, target_sum)\n arr = arr.sort\n i, j = 0, arr.length - 1\n\n while i < j\n case (arr[i] + arr[j]) <=> target_sum\n when 0\n return true\n when -1\n i += 1\n when 1\n j -= 1\n end\n end\n\n false\nend", "def sum_to_n? arr, n\n\nreturn false if arr.empty? || arr.length==1\n\nfor i in 0...arr.length\n for j in 0...arr.length\n if i != j\n return true if arr[i] + arr[j] == n\n end\n end\nend\n\nreturn false\n\nend", "def sum_to_n? arr, n\n #arr.product(arr).any? {|c| sum(c) == n && c[0] != c[1] } ----1.3\n arr = arr.sort\n low = 0\n high = arr.length - 1\n while low < high\n if arr[low] + arr[high] == n\n return true\n end\n arr[low] + arr[high] < n ? low += 1 : high -= 1 \n end\n return false\nend", "def a_sum?(num, game_array)\n\tarray_of_sums = []\n\tarray_of_sums << game_array[0]\n\n\tgame_array.each_index do |i|\n\t\tgame_array.each_index do |j|\n\t\t\tunless i == j\n\t\t\t\tarray_of_sums << game_array[i] + game_array[j]\n\t\t\tend\n\t\tend\n\tend\n\tif ([num] & array_of_sums).length > 0\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def make_sum?(num, game_array) \n\tarray_of_sums = []\n\n\tgame_array.each do |i|\n\t\tarray_of_sums << i + num\n\tend\n\tif (array_of_sums & game_array).length > 0\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def okay_two_sum?(arr, target_sum)\n new_arr = arr.sort\n i = 0\n j = arr.length - 1\n while i < j \n if (arr[i] + arr[j] ) == target_sum\n return true\n elsif \n (arr[i] + arr[j] ) > target_sum\n j -= 1\n else\n i += 1\n end\n \n \n end\n false\nend", "def okay_two_sum?(arr, num)\n new_arr = arr.sort\n i1 = 0\n i2 = -1\n count = 0\n while count < arr.length - 1\n sum = new_arr[i2] + new_arr[i1]\n if sum == num\n return true\n elsif sum > num\n i2 -= 1\n else\n i1 += 1\n end\n count += 1\n end\n false\nend", "def check_array_for_sum(arr, goal)\n arr.product(arr).reject{|pair| pair.first == pair.last}.map{ |pair| pair.reduce(0, :+)}.include?(goal)\nend", "def arr_sum(arr, target)\n 0.upto(arr.size - 2) do |idx1|\n 1.upto(arr.size - 1) do |idx2|\n return true if arr[idx1] + arr[idx2] == target && idx2 > idx1\n end\n end\n false\nend", "def bad_sum?(arr, target)\n\n (0...arr.length).each do |idx|\n (idx + 1...arr.length).each do |jdx|\n return true if arr[idx] + arr[jdx] == target\n end\n end\n false\nend", "def okay_two_sum?(arr, target_sum)\n i = 0 \n j = arr.length - 1 \n arr = arr.sort \n\n while i < j \n if arr[i] + arr[j] == target_sum \n return true \n elsif arr[i] + arr[j] > target_sum\n j -= 1 \n else \n i += 1 \n end\n end\n false \nend", "def okay_two_sum?(arr, target_sum)\n sorted_arr = quick_sort(arr)\n (0...sorted_arr.length - 1).each do |i|\n return true if sorted_arr[i] + sorted_arr[i + 1] == target_sum\n end\n false\nend", "def solution(arr)\n arr_size = arr.size\n\n arr.any? { |el| el > arr_size } || arr.uniq.size < arr_size ? 0 : 1\nend", "def okay_two_sum(array, target_sum)\n array.sort\n i = 0\n j = array.length - 1\n while i < j\n case (array[i] + array[j]) <=> target_sum\n when -1\n i += 1\n when 0\n return true\n when 1\n j -= 1\n end\n end\n false\nend", "def bad_two_sum?(arr, target_sum)\n (0...arr.length - 1).each do |i|\n (i + 1..arr.length - 1).each do |j|\n return true if arr[i] + arr[j] == target_sum\n end\n end\n false\nend", "def nums(target, *array)\n\tarray.each_with_index do |a, x|\n\t\tarray.each_with_index do |b, y|\n\t\t\tif x > y\n\t\t\t\tif a + b == target\n\t\t\t\t\treturn true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\treturn false\nend", "def okay_two_sum?(arr, target_sum)\n array = arr.sort #n log n\n i1 = 0\n i2 = array.length-1\n while i1 < i2\n case array[i1] + array[i2] <=> target_sum\n when 0\n return true\n when -1\n i1 += 1\n when 1\n i2 -= 1\n end\n end\n false\nend", "def okay_two_sum?(array,target_sum)\n array_sorted = array.sort\n i = 0\n j = array.length - 1\n\n until i == j\n sum = array_sorted[i] + array_sorted[j]\n return true if sum == target_sum\n if sum < target_sum\n i += 1\n elsif sum > target_sum\n j -= 1\n end\n end\n false\nend" ]
[ "0.8442841", "0.8111648", "0.8106658", "0.81005573", "0.78581285", "0.7114421", "0.69017124", "0.6795212", "0.67081547", "0.6707958", "0.669943", "0.66427624", "0.65865076", "0.6571029", "0.657036", "0.65678585", "0.6564673", "0.65621233", "0.6552452", "0.6549897", "0.65440977", "0.65250176", "0.6519935", "0.64659375", "0.6460685", "0.64395624", "0.6430437", "0.64194137", "0.64054894", "0.63940006" ]
0.86289096
0
Have the function SwapCase(str) take the str parameter and swap the case of each character. For example: if str is "Hello World" the output should be hELLO wORLD. Let numbers and symbols stay the way they are.
def SwapCase(str) str.swapcase end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def SwapCase(str)\n\tstr.swapcase\nend", "def SwapCase(str)\n\n return str.swapcase! \n \nend", "def swap_case(str)\n str.swapcase\nend", "def swapcase(str)\n swap_chars = str.chars.map do |char|\n if char =~ /[a-z]/\n char.upcase\n elsif char =~ /[A-Z]/\n char.downcase\n else\n char\n end\n end\n swap_chars.join\nend", "def SwapCase(str)\n str.chars.map do |char|\n if (97..122).include?(char.ord)\n diff = char.ord - 'a'.ord\n ('A'.ord + diff).chr \n elsif (65..90).include?(char.ord)\n diff = char.ord - 'A'.ord\n ('a'.ord + diff).chr\n else\n char\n end\n end.join\nend", "def swapcase(str)\n str.chars.map do |char|\n if ('A'..'Z').include?(char)\n char.downcase\n elsif ('a'..'z').include?(char)\n char.upcase\n else\n char\n end\n end.join\nend", "def swapcase(str)\n str.chars.map { |chr| (/[a-z]/.match(chr))? chr.upcase : chr.downcase }.join('')\nend", "def swapcase(str)\n str.chars.map { |c| c == c.upcase ? c.downcase : c.upcase }.join\nend", "def swapcase(str)\n result_str = ''\n str.each_char do |char|\n if char.count('a-z') > 0\n result_str += char.upcase\n else\n result_str += char.downcase\n end\n end\n result_str\nend", "def swapcase(str)\n str.split(//).map do |chr|\n chr = chr.ord\n if chr.between?(65, 90)\n (chr + 32).chr\n elsif chr.between?(97, 122)\n (chr - 32).chr\n else\n chr.chr\n end\n end.join\nend", "def swapcase(str)\n str.chars.map do |el|\n if el =~ /[a-z]/\n el.upcase\n elsif el =~ /[A-Z]/\n el.downcase\n else\n el\n end\n end.join\nend", "def swapcase(str)\n uppercase = ('A'..'Z').to_a\n lowercase = ('a'..'z').to_a\n str.chars.map do |char|\n if uppercase.include?(char)\n char.downcase\n elsif lowercase.include?(char)\n char.upcase\n else\n char\n end\n end.join\nend", "def swapcase(string)\n string.split('').map { |char| char == char.upcase ? char.downcase : char.upcase }.join('')\nend", "def swapcase(str)\n arry = str.chars\n\n new_arry = arry.map do |char|\n if char =~ /[a-z]/\n char.upcase\n elsif char =~ /[A-Z]/\n char.downcase\n else\n char\n end\n end\n new_arry.join('')\nend", "def swapcase(string)\n string.chars.map do |char|\n case char\n when /[a-z]/\n char.upcase\n when /[A-Z]/\n char.downcase\n else\n char\n end\n end.join\nend", "def swapcase(str)\n res_arr = []\n str.chars.each do |chr|\n res_arr << case chr\n when ('a'..'z')\n chr.upcase\n when ('A'..'Z')\n chr.downcase\n else\n chr\n end\n end\n res_arr.join('')\nend", "def swapcase(str)\n str.chars.map do |el|\n if el == el.upcase\n el.downcase\n elsif el == el.downcase\n el.upcase\n else\n el\n end\n end.join\nend", "def swapcase(string)\n string.chars.map do |char|\n if char.match(/[a-z]/)\n char.upcase\n else\n char.downcase\n end\n end.join(\"\")\nend", "def swapcase(string)\n string.split('').map do |char|\n if char =~ /[a-z]/\n char.upcase!\n elsif char =~ /[A-Z]/\n char.downcase!\n else\n char\n end\n end.join('')\nend", "def swapcase(str)\n new_str =\n str.chars.map do |element|\n if element =~ /[a-z]/\n element.upcase\n elsif element =~ /[A-Z]/\n element.downcase\n else\n element\n end\n end\n new_str.join\nend", "def swapcase(string)\n swapped_string = string.chars.map do | char |\n if char.match(/[A-Z]/)\n char.downcase\n elsif char.match(/[a-z]/)\n char.upcase\n else\n char\n end\n end\n swapped_string.join\nend", "def swapcase(str)\ncharacters = str.chars.map do |char|\n\tif char =~ /[a-z]/\n\t\tchar.upcase\n\telsif char =~ /[A-Z]/\n\t\tchar.downcase\n\telse\n\t\tchar\n\tend\nend\ncharacters.join\nend", "def swapcase(string)\n string.chars.map do |char|\n if char.downcase == char\n char.upcase\n elsif char.upcase == char\n char.downcase\n else\n char\n end\n end.join('')\nend", "def swapcase(string)\n swapped_case = string.chars.map do |char|\n if char =~ /[a-z]/ then char.upcase\n elsif char =~ /[A-Z]/ then char.downcase\n else char.downcase\n end\n end\n swapped_case.join\nend", "def swapcase(string)\n swapped_chars = string.chars.map do |char|\n case char\n when char.upcase then char.downcase\n when char.downcase then char.upcase\n end\n end\n swapped_chars.join\nend", "def swapcase(string)\n string.chars.map { |char| char.upcase == char ? char.downcase : char.upcase }\n .join\nend", "def swapcase(string)\n string.chars.map { |c| c.upcase == c ? c.downcase : c.upcase }.join\nend", "def SwapCase(str)\n\n # code goes here\n return str \n \nend", "def swapcase(string)\n swapped_string = ''\n string.each_char do |c|\n if (97..122).cover?(c.ord)\n swapped_string += c.upcase\n else\n swapped_string += c.downcase\n end\n end\nend", "def swapcase(string)\n string.chars.map {|c| c == c.upcase ? c.downcase : c.upcase}.join\nend" ]
[ "0.8891396", "0.87227154", "0.8602987", "0.858417", "0.85441434", "0.8537297", "0.8523317", "0.85113204", "0.8501437", "0.850089", "0.84833854", "0.84632814", "0.841235", "0.83750355", "0.8373884", "0.8357406", "0.83462083", "0.83456373", "0.83374435", "0.8319049", "0.83115655", "0.8308041", "0.83005977", "0.8295877", "0.82907397", "0.8290226", "0.82801884", "0.82576156", "0.8241255", "0.82406527" ]
0.8738551
1
Have the function OffLineMinimum(strArr) take the strArr parameter being passed which will be an array of integers ranging from 1...n and the letter "E" and return the correct subset based on the following rules. The input will be in the following format: ["I","I","E","I",...,"E",...,"I"] where the I's stand for integers and the E means take out the smallest integer currently in the whole set. When finished, your program should return that new set with integers separated by commas. For example: if strArr is ["5","4","6","E","1","7","E","E","3","2"] then your program should return 4,1,5.
def OffLineMinimum(strArr) batch = [] result = [] strArr.each do |i| if i == "E" batch.sort! result << batch.shift else batch << i.to_i end end result.join(",") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def off_line_minimum(strArr)\n \nend", "def offline_min(str_arr)\n mins = []\n \n until not str_arr.include?\"E\"\n \n current = str_arr.slice(0...str_arr.index(\"E\")).map {|a| a.to_i }\n mins << current.min\n str_arr.delete_at(current.index(current.min))\n str_arr.delete_at(str_arr.index(\"E\"))\n end\n \n mins.join(',')\nend", "def getLineSubset( arr, len )\n return [] if (arr.empty? || (x = arr[0]) > len)\n return [[x]] if x == len\n ar = arr.drop(1)\n getLineSubset( ar, len-x )\n .each{ |a| a.unshift x }\n .concat getLineSubset( ar, len )\nend", "def my_min(arr)\n min = arr.first\n (0...arr.length).each do |idx1|\n (idx1...arr.length).each do |idx2|\n if (idx2 != idx1) && (arr[idx1] < arr[idx2]) && (arr[idx1] < min)\n min = arr[idx1]\n end\n\n end\n end\n min\n\nend", "def min_cut(s)\n is_pali = Array.new(s.size){Array.new(s.size, false)}\n min_cuts = Array.new(s.size)\n (0...s.size).each do |i|\n min_num = Float::INFINITY # store max val\n (0..i).each do |j|\n if s[i] == s[j] && (j + 1 >= i || is_pali[j + 1][i - 1])\n is_pali[j][i] = true\n min_num = j == 0 ? 0 : [min_num, min_cuts[j - 1] + 1].min\n end\n end\n min_cuts[i] = min_num\n end\n min_cuts[s.size - 1]\nend", "def prefix_find(array)\n\tfor i in array\n\t\tif i.size < min\n\t\t\tmin = i.size\n\t\tend\n\tend\nend", "def getMin(arr) \t\n\tminInd = 0\n\tfor i in 1..$n-1 do\n\t\tif (arr[i] < arr[minInd])\n\t\t\tminInd = i\n end \n end \n\treturn minInd\nend", "def check_list_linear(array)\n min = array.first\n array.each do |num|\n min = num if num < min\n end\n min\n end", "def min_sub_array_len(s, nums)\n # debugger\n nums.length.times do |window_size|\n (nums.length - window_size + 1).times do |window_start|\n window_arr = nums.slice(window_start,window_size + 1)\n return window_arr if window_arr.reduce(:+) == s\n end\n end\nend", "def determine_lowest(array)\n return if array.blank?\n value = CLASSIFICATIONS.length\n lowest = ''\n array.each do |cl|\n if CLASSIFICATIONS.index(cl.values.first) < value\n value = CLASSIFICATIONS.index(cl.values.first)\n lowest = cl\n end\n end\n lowest\n end", "def my_min(arr)\n min = arr[0]\n (1...arr.length).each do |i|\n if arr[i] < min\n min = arr[i]\n end\n end\n min\nend", "def str_range(str)\n # your code goes here\n str_arr = str.split(',')\n \n num_arr = str_arr.map do |el|\n el.to_i\n end\n\n sorted_num_arr = num_arr.sort\n\n sorted_num_arr[-1] - sorted_num_arr[0]\nend", "def my_min(arr) #O(n2)\n min = arr.first\n arr.each_with_index do |el_1 , i|\n (i+1...arr.length).each do |el_2|\n if arr[el_2] < el_1 && arr[el_1] < min \n min = arr[el_2]\n end \n end \n end \n min \n end", "def minimum(arr)\n m = arr.min\n m\n end", "def find_min(arr)\n min = arr.first\n (1...arr.length).each do |idx|\n min = arr[idx] if arr[idx] < min\n end\n min\nend", "def my_min(array)\n array.find do |ele|\n array.all? do |ele1|\n ele <= ele1\n end\n end\n end", "def my_min(arr)\n min = arr[0]\n (0...arr.size).each do |i1|\n (i1 + 1...arr.size).each do |i2|\n min = arr[i2] if arr[i2] < min\n end\n end\n min\nend", "def lowestnumber arr\n idx = 0 \n min = arr[0]\n while idx <= arr.length - 1\n if arr[idx] > min \n min = min\n else\n min = arr[idx]\n end\n \n idx = idx + 1\n end\n return min\nend", "def shortest_first(array_of_words)\n # TODO\nend", "def lowest_number(number_list)\n number_list.map(&:to_s)\n .permutation\n .map(&:join)\n .map(&:to_i)\n .min\nend", "def high_and_low(intArr)\r\n integerArr = intArr.split(' ')\r\n if integerArr.length >= 1\r\n highest_number = (integerArr.sort!).last\r\n lowest_number = (integerArr.sort!).first\r\n \"#{highest_number} #{lowest_number}\".to_s\r\n else\r\n \"There will always be at least one number in the input string\"\r\n end\r\nend", "def smallest(array)\nend", "def my_min_improved(arr)\n min = arr[0]\n\n arr.each do |el|\n min = el if el < min\n end\n\n return min\nend", "def str_range(str)\n # your code goes here\n arr = str.split(\",\").map(&:to_i).sort\n arr.last - arr.first\nend", "def better_my_min(array)\n smallest = array[0]\n array[1..-1].each do |el|\n smallest = el if el < smallest\n end\n smallest\nend", "def smallest_window(array, set)\n #set is a hash???\n min_win = 0\n return nil if array.length < set.count\n i = 0\n j = 0\n while i < array.length\n if contains_set?(set, array[i..j])\n i += 1\n min_win = [i,j]\n elsif j < array.length\n j += 1\n else\n break\n end\n end\n min_win\nend", "def smallest_difference_model(array)\n numbers = [array[0], array[1]]\n min_dif = (array[0] - array[1]).abs\n\n array.each_with_index do |n1, i|\n array[(i + 1)..-1].each do |n2|\n diff = (n1 - n2).abs\n\n if min_dif > diff\n numbers = [n1, n2]\n min_dif = diff\n end\n end\n end\n\n [numbers.min, numbers.max]\nend", "def my_min(array)\n\n smallest = array.first\n array.each_with_index do |el, i|\n smallest = el if el < smallest\n end\n smallest\n\nend", "def my_min2(array)\n minimum = array.first\n array.each_index do |idx|\n if array[idx] < minimum\n minimum = array[idx]\n end\n end\n minimum\nend", "def smallest array\n [array.min]\n end" ]
[ "0.7238821", "0.68244624", "0.56105584", "0.5452836", "0.5418985", "0.53876245", "0.5359936", "0.53485805", "0.534018", "0.5272546", "0.5264545", "0.5226041", "0.51923174", "0.51155317", "0.5110059", "0.5101615", "0.5100817", "0.50999737", "0.50928885", "0.5092607", "0.5090196", "0.50820035", "0.5070153", "0.5066317", "0.5058764", "0.5056666", "0.5048115", "0.5029786", "0.5028727", "0.502432" ]
0.80917203
0
Have the function ChangingSequence(arr) take the array of numbers stored in arr and return the index at which the numbers stop increasing and begin decreasing or stop decreasing and begin increasing. For example: if arr is [1, 2, 4, 6, 4, 3, 1] then your program should return 3 because 6 is the last point in the array where the numbers were increasing and the next number begins a decreasing sequence. The array will contain at least 3 numbers and it may contains only a single sequence, increasing or decreasing. If there is only a single sequence in the array, then your program should return 1. Indexing should begin with 0.
def ChangingSequence(arr) idx = 2 while idx < arr.length if arr[1] > arr[0] && arr[idx] < arr[idx-1] return idx - 1 elsif arr[1] < arr[0] && arr[idx] > arr[idx-1] return idx - 1 end idx += 1 end -1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ChangingSequence(arr)\n largest_num = arr.max if arr.max != arr.last\n smallest_num = arr.min if arr.min != arr.first\n indexed_array = arr\n index_for_output = 0\n indexed_array.size.times do |idx|\n if indexed_array[idx] == largest_num\n index_for_output = idx\n elsif indexed_array[idx] == smallest_num\n index_for_output = idx\n end\n end\n index_for_output != 0 ? index_for_output : -1\nend", "def changing_sequence(arr)\n pattern = arr[1] - arr[0]\n arr.each_cons(2).with_index do |(num1, num2), idx|\n return idx if (num2 - num1) * pattern < 0\n end\n -1\nend", "def read_sequence(arr, curr_pos)\n n = arr.length\n idx = curr_pos + 1\n (n - curr_pos - 1).times do \n if arr[idx] < arr[idx - 1]\n return idx\n end\n idx += 1\n end\n \n n\nend", "def sequence(num, arr=[])\n return arr if num == 0\n if num > 0\n arr.unshift(num)\n num -= 1\n sequence(num, arr)\n elsif num < 0\n arr << num\n num += 1\n sequence(num, arr)\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 LongestIncreasingSequence(arr)\n size = arr.size\n \n while size > 1\n sub_seq = arr.combination(size).to_a\n sub_seq.each do |seq|\n inc_seq = true\n seq.each_cons(2) { |num1, num2| break inc_seq = false unless num2 > num1 }\n return seq.size if inc_seq\n end \n size -= 1\n end\n 1\nend", "def find_element_index_consecutive(array, ele)\n index = ele - array[0]\n index = index < 0 ? array.length + index : index\n index\nend", "def arrayChange(a)\n total = 0\n a.each_with_index do |v, i|\n next if i == 0 \n if(v <= a [i-1]) \n total += (a[i-1] + 1) - a[i]\n a[i] = a[i-1] + 1\n end\n end\n total\nend", "def first_non_consecutive(arr)\n full_arr = arr[0]..arr[-1]\n\n full_arr.each { |num|\n if !arr.include?(num)\n return num + 1\n end\n }\n nil\nend", "def g_num(arr)\n\nindex = 1\n\n arr.length.times do \n\n if arr[0] >= arr[index]\n index += 1\n else\n arr[0] = arr[index]\n end\n\n end\n\np arr[0]\n\nend", "def max_sequence(arr)\n return arr.first if arr.size == 1\n return 0 if arr.all? { |num| num < 0 } || arr.empty?\n current_sum = arr.first\n maximum = arr.first\n\n arr[1..-1].each do |num|\n current_sum = 0 if current_sum < 0\n current_sum += num\n maximum = current_sum if current_sum > maximum\n end\n\n maximum\nend", "def first_non_consecutive(arr)\n arr.each_index do |i|\n return arr[i + 1] if arr[i].next != arr[i + 1]\n end\nend", "def contiguous_sequence(array)\n max_sum = array.first\n array.each_with_index do |num, idx|\n current_sum = num\n array[(idx+1)..-1].each do |num|\n current_sum += num\n max_sum = current_sum if current_sum > max_sum\n end\n end\n\n max_sum\nend", "def find_consecutive_runs(array)\n return nil unless array.is_a? Array\n return nil if array.length < 3\n\n output = []\n array.each_with_index do |item, index|\n return nil unless item.is_a?(Integer) && item > 0\n first = item\n second = array[index+1]\n third = array[index+2]\n\n unless second.nil? || third.nil?\n if (first + 1 == second) && (second + 1 == third)\n output << index\n elsif (first - 1 == second) && (second - 1 == third)\n output << index\n end\n end\n end\n\n return nil if output.length == 0\n\n output\nend", "def swap(arr)\n for i in 0..arr.length-1\n if arr[i] == i+1\n #puts \"correct position\"\n else\n a = arr[i]\n b = arr[arr[i]-1]\n arr[i] = b\n arr[a-1] = a\n puts arr.inspect\n return arr\n end\n end\n return \"correct position\"\nend", "def max_sequence(arr)\n return 0 if arr.empty?\n\n max_ending_here = max_so_far = 0\n \n arr.each do |n|\n max_ending_here = [n, max_ending_here + n].max\n max_so_far = [max_so_far, max_ending_here].max\n end\n \n max_so_far\nend", "def find_it(seq)\n count = 0\n sorted = seq.sort\n \n sorted.each_with_index do |ele, i|\n count += 1\n next_ele_not_same = sorted[i] != sorted[i+1] \n \n return ele if count.odd? && next_ele_not_same\n end\nend", "def fibonacci_index(array)\n fibonacci_sequence = create_fibonacci(array.size)\n new_array = array.select { |num| fibonacci_sequence.include?(array.index(num)) }\nend", "def first_non_consecutive(arr)\n return arr if arr.empty?\n return arr if arr.size == 1\n\n counter = 1\n loop do\n return arr[counter] if arr[counter] != arr[counter - 1].next\n\n counter += 1\n break if counter == arr.size\n end\nend", "def repeated_number_ranges(arr)\n rtn=[]\n start_idx=nil\n arr.each_with_index do |num,idx |\n nex_num=arr[idx+1]\n if num==nex_num\n start_idx=idx unless start_idx\n elsif start_idx\n rtn<<[start_idx,idx]\n start_idx=nil\n end\n end\n rtn\nend", "def repeated_number_ranges(arr)\n repeated_number_ranges = []\n index_start_end = []\n\n arr.each_with_index do |el, idx|\n if el == arr[idx + 1] && el != arr[idx - 1]\n # if == NEXT but != PREVIOUS\n index_start_end << idx\n elsif el == arr[idx - 1] && el != arr[idx + 1]\n # if == PREVIOUS but != NEXT\n index_start_end << idx\n repeated_number_ranges << index_start_end unless index_start_end.empty?\n index_start_end = [] # reinitialize temp variable as empty array\n end\n end\n\n repeated_number_ranges\nend", "def seq_index(seq)\n self.sliding_groups_of(seq.size).index(seq)\n end", "def cycle(array, step, value)\n oldIndex = array.index(value)\n newIndex = (oldIndex + step) % array.length\n return newIndex # return index not value\n end", "def max_seq(arr)\n max_so_far = 0\n max_current = 0\n arr.map do |x|\n max_current = [x, max_current + x].max\n max_so_far = [max_current, max_so_far].max\n end\n\n max_so_far\nend", "def find_shortest_seq(n)\n new_num = n/2\n i = 0\n arr = []; arr[i] = 1\n\n while(arr[i] < new_num)\n n1 = arr[i] * 2\n n2 = arr[i] + 1\n\n i += 1\n if(n1 < new_num)\n arr[i] = n1\n else\n arr[i] = n2\n end \n end\n puts arr.to_s\n if(arr[i] == n)\n puts arr.to_s\n puts i \n elsif n == (arr[i] * 2)\n arr[i + 1] = arr[i] * 2\n puts arr.to_s\n puts i + 1\n else\n arr[i + 1] = arr[i] * 2\n i += 1\n arr[i + 1] = arr[i] + 1\n puts arr.to_s\n puts i\n end \n \nend", "def sequence(num)\n\n if num > 0\n (1..num).to_a\n elsif num < 0\n (num..-1).to_a.reverse\n else\n num\n end \nend", "def max_sequence(arr)\n puts arr\n index = 0\n numIndexes = 0\n highestSum = arr.min\n \n length = arr.count\n \n highestNum = arr.max\n\n if arr != [] && highestNum < 0 \n return 0\n elsif arr == []\n return 0\n end\n \n arr.map.with_index do |n,i|\n\n for c in 0..i\n \n sum = arr.slice(c,length-i).inject(:+)\n\n if sum > highestSum\n highestSum = sum\n index = i\n numIndexes = length-i\n end\n \n end\n \n end\n \n highestSum\n \nend", "def fibonacci_sequence index\n if index == 0 || index == 1\n return index\n else\n return fibonacci_sequence(index - 2) + fibonacci_sequence(index - 1)\n end\nend", "def get_sequences_length(numbers)\n result = []\n previous = numbers[0]\n count = 1\n direction = ''\n numbers.slice(1..).each do |x|\n if x == previous\n if direction == ''\n direction = 'down'\n end\n count += 1\n elsif x < previous\n if direction == ''\n direction = 'down'\n end\n if direction == 'down'\n count += 1\n else\n result << count\n direction = 'down'\n count = 2\n end\n else\n if direction == ''\n direction = 'up'\n end\n if direction == 'up'\n count += 1\n else\n result << count\n direction = 'up'\n count = 2\n end\n end\n previous = x\n end\n result << count\n return result\nend", "def sum_consecutives(arr)\n final = []\n arr.each_with_index do |num, i|\n final << num if arr[i + 1] != arr[i] && final[-1] != arr[i]\n end\n final\nend" ]
[ "0.8275342", "0.79876053", "0.721506", "0.66025513", "0.6590161", "0.65767485", "0.6375443", "0.63282365", "0.63223684", "0.62790924", "0.61951363", "0.6145416", "0.6139534", "0.61037934", "0.6099242", "0.6085686", "0.6009556", "0.59926707", "0.5982423", "0.5978982", "0.59671843", "0.59516007", "0.594143", "0.58867913", "0.5871042", "0.58587426", "0.5837528", "0.583589", "0.58221656", "0.5819898" ]
0.8406192
0
Have the function HammingDistance(strArr) take the array of strings stored in strArr, which will only contain two strings of equal length and return the Hamming distance between them. The Hamming distance is the number of positions where the corresponding characters are different. For example: if strArr is ["coder", "codec"] then your program should return 1. The string will always be of equal length and will only contain lowercase characters from the alphabet and numbers.
def HammingDistance(strArr) hamming = 0 (0...strArr[0].length).each do |i| if strArr[0][i] != strArr[1][i] hamming += 1 end end hamming end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def HammingDistance(arr)\n first_str = arr[0].chars\n sec_str = arr[1].chars\n hamm_dis_count = []\n (0..first_str.size).each do |index|\n if first_str[index] != sec_str[index]\n hamm_dis_count << first_str[index]\n end\n end\n hamm_dis_count.size\nend", "def hamming_distance(arr)\n count = 0\n arr.first.each_char.with_index do |char, idx|\n count += 1 if char != arr.last[idx]\n end\n count\nend", "def hamming_distance(string1, string2)\n h = 0\n (0..string1.length - 1).each do |i|\n h += 1 if string1[i] != string2[i]\n end\n h\nend", "def hamming_distance str1, str2\n result = 0\n \n str1.split('').each_index do |i|\n result += 1 if str1[i] != str2[i]\n end\n\n p result\nend", "def hamming_distance(first_word, second_word)\n if first_word.length == second_word.length\n first_word = first_word.split('')\n second_word = second_word.split('')\n distance = 0\n first_word.each_with_index do |a, i|\n if a != second_word[i]\n distance += 1\n end\n end\n distance\n else\n nil\n end\nend", "def hamming(string1, string2)\n different_letter = 0\n i = 0\n while i < string1.length\n if string1[i] != string2[i]\n different_letter += 1\n end\n i += 1\n end\n \n return different_letter\nend", "def hamming_distance2(x,y)\n (x ^ y).to_s(2).split(\"\").select{|el| el == \"1\"}.length\n # or\n # (x^y).to_s(2).split('').reduce(0){|s, e| s += e.to_i}\n # or\n # (x^y).to_s(2).count(\"1\")\nend", "def hamming_distance(other)\n self_array = self.to_a\n other_array = other.to_a\n self_array.zip(other_array).reduce(0) do |hamming, symbols|\n hamming += symbols[0] == symbols[1] ? 0 : 1\n end\n end", "def hamming_distance(p, q)\n # Hamming Distance Problem: Compute the Hamming distance between two strings.\n # Input: Two strings of equal length.\n # Output: The Hamming distance between these strings.\n\n # We say that position i in k-mers p1 … pk and q1 … qk is a mismatch if p(i) ≠ q(i). \n # For example, CGAAT and CGGAC have two mismatches. \n # The number of mismatches between strings p and q is called the Hamming distance \n # between these strings and is denoted HammingDistance(p, q).\n distance = 0\n (0..(p.length - 1)).each {|i| distance += 1 if p[i] != q[i] } \n\n return distance\n end", "def anagram_distance(word1, word2)\n if word1.length != word2.length\n return -1;\n end\n\n hash = {};\n\n word1.each_char do |ch|\n hash[ch] = hash[ch].nil? ? 1 : hash[ch]+1\n end\n\n word2.each_char do |ch|\n if !hash[ch].nil? && hash[ch] > 0\n hash[ch] -=1\n end\n end\n\n hash.values.sum\nend", "def gemstones(arr)\n common_chars = ('a'..'z').to_a\n arr.each do |a|\n common_chars = common_chars & a.chars\n end\n common_chars.size\nend", "def hamming_dna(dna_1, dna_2)\n hamming = 0;\n dna_1.split(\"\").each_with_index do |v, i|\n dna_2.split(\"\")[i] != v ? hamming += 1 : hamming = hamming\n end\n hamming\nend", "def mutation(arr)\n first = arr[0]\n second = arr[1]\n count = 0\n first.downcase.split(\"\").each do |letter1|\n second.downcase.split(\"\").each do |letter2|\n if letter1 == letter2\n count += 1\n end\n end\n end\n return count\nend", "def anagram string\n mid = string.size/2 -1\n s1 = string.slice(0..mid).chars\n s2 = string.slice(mid+1..-1).chars\n freq = Hash.new(0)\n count = 0\n\n s1.each{ |key| freq[key]+=1 }\n\n s2.each do |letter|\n freq[letter] > 0 ? freq[letter] -=1 : count +=1\n end\n\n string.size.even? ? count : -1\nend", "def distance (w1, w2)\n count = 0\n #add a count for every index where the characters are different\n i = 0\n while i < w2.length\n if w1[i].downcase != w2[i].downcase\n count = count + 1\n end\n i = i + 1\n end\n count\n end", "def common_chars(arr)\n new_arr = []\n test_letters = arr[0].chars.uniq\n test_letters.each do |letter|\n count = arr[0].count(letter)\n arr.each do |word|\n temp_count = word.count(letter)\n count = temp_count if temp_count < count \n end\n new_arr += [letter] * count \n end\n new_arr\nend", "def hamming_distance(a, b)\n raise \"Unequal buffers passed.\" if a.length != b.length\n a.bytes.zip(b.bytes).map { |a, b| (a ^ b).to_s(2) }.join.count('1')\n end", "def hamm one, two\n count = 0\n uno = one.split('')\n dos = two.split('')\n i = 0\n uno.each do |x|\n if x != dos[i]\n count += 1\n end\n i += 1\n end\n puts count\nend", "def make_anagram word1, word2\n s1 = word1.chars\n s2 = word2.chars\n\n count = 0\n\n # s1.each do |x|\n # if s2.include? x\n # count +=1\n # end\n # end \n # ana = (word1.size - count)*2\n\n freq = Hash.new(0)\n s1.each do |key|\n freq.store(key, freq[key]+1)\n end\n freq\n\n s2.each do |x|\n if freq[x] != nil\n freq[x] -= 1\n end\n end\n\n freq\n\n freq.each do |key,value|\n if value != 0\n count += value.abs\n end\n end\n\n count\n\nend", "def common_characters(arr)\n target_count = arr.count\n\n hash = Hash.new(0)\n (0...target_count).each do |i|\n arr[i].split('').each do |letter|\n hash[letter] += 1\n end\n end\n\n result = []\n hash.each do |k, v|\n while v >= target_count\n if v >= target_count\n result << k\n v -= target_count\n end\n end\n end\n\n result\nend", "def hamm(x, y)\n x, y = *([x,y].map{|z| z.split(\"\")})\n x.zip(y).inject(0){|z,s| z += if s[0] == s[1] then 0 else 1 end}\nend", "def point_mutations(string1, string2)\n # keep track of the differences between the two strings\n difference = 0\n\n # Loop through the 1st string, storing each of the indexes and letters into variables\n string1.chars.each_with_index do |letter, index|\n puts \"letter: #{letter}, index: #{index}\"\n\n # if the current letter of string1 is not the same as the corresponding letter in string2, increment the difference variable by 1\n if letter != string2[index]\n difference += 1\n end\n \n end # string1\n\n puts \"The hamming distance between #{string1} and #{string2} is #{difference}.\"\n\nend", "def word_diff\n return -1 unless (@word.size % 2 == 0)\n # initialize a hash with 26 lowercase alphabet character and set count for 0\n word_hash = ('a'..'z').inject({}) {|h,c| h[c] = 0; h}\n # Increment count for first word\n len = @word.size / 2\n @word[0..len-1].split(\"\").each {|c| word_hash[c] += 1}\n # Decrement count for second word\n @word[len..len*2].split(\"\").each {|c| word_hash[c] -= 1}\n # Check how many count > 0\n count = 0\n word_hash.each {|k,v| count += 1 if v > 0}\n count\n end", "def compute(left_strand,right_strand)\n return 0 if left_strand == right_strand\n\n left_chars = left_strand.chars\n right_chars = right_strand.chars\n\n distance = 0\n\n left_chars.each_with_index do |left_char,idx|\n right_char = right_chars[idx]\n break if right_char.nil? # ignore extra length on first strand when longer\n\n distance += 1 unless left_char == right_char\n end\n\n distance\n end", "def difference_count\n difference = 0\n @str1.each_with_index do | letter, i |\n difference += 1 if @str1[i] != @str2[i]\n end\n difference\n end", "def fith_anagram?(str1, str2)\n hash = Hash.new(0)\n \n str1.each_char { |char| hash[char] += 1 }\n str2.each_char { |char| hash[char] += 1 }\n \n hash.values.all? { |v| v > 1 }\nend", "def bonus_anagram?(str1, str2)\n counts = Hash.new(0)\n\n str1.chars.each { |letter| counts[letter] += 1 }\n str2.chars.each { |letter| counts[letter] -= 1 }\n\n counts.values.all? { |value| value == 0 }\nend", "def anagrams_one_hash?(str1, str2)\n letter_count = Hash.new(0)\n str1.each_char { |char| letter_count[char] += 1 }\n str2.each_char { |char| letter_count[char] -= 1 }\n\n letter_count.each_value.all? { |val| val == 0 }\nend", "def anagrams(string, array)\n string_anagram = string.chars\n \n array.select! do |word|\n word.chars.all? do |letter|\n word.chars.count(letter) == string_anagram.count(letter)\n end\n end\n array\nend", "def anagram?(str1,str2)\r\n count = Hash.new(0)\r\n str1.each_char {|char| count[char] +=1}\r\n str2.each_char {|char| count[char] -=1}\r\n count.values.all?(0)\r\nend" ]
[ "0.89302593", "0.84099627", "0.8251154", "0.79598063", "0.7915821", "0.75948745", "0.7204176", "0.69932574", "0.6980326", "0.6947303", "0.69046456", "0.68398124", "0.6803937", "0.67208457", "0.67063504", "0.6693851", "0.66871095", "0.66397756", "0.65906096", "0.6586478", "0.6573344", "0.65617645", "0.6536977", "0.6527942", "0.64892393", "0.6457038", "0.6455247", "0.6454602", "0.6453702", "0.64430535" ]
0.90394247
0
Have the function RectangleArea(strArr) take the array of strings stored in strArr, which will only contain 4 elements and be in the form (x y) where x and y are both integers, and return the area of the rectangle formed by the 4 points on a Cartesian grid. The 4 elements will be in arbitrary order. For example: if strArr is ["(0 0)", "(3 0)", "(0 2)", "(3 2)"] then your program should return 6 because the width of the rectangle is 3 and the height is 2 and the area of a rectangle is equal to the width height.
def RectangleArea(strArr) pool = strArr.join.scan(/(-?[0-9]+)/).flatten.map{|i|i.to_i} rec_l = [pool[1], pool[3], pool[5], pool[7]].sort rec_w = [pool[0], pool[2], pool[4], pool[6]].sort length = (rec_l[-1] - rec_l[0]).abs width = (rec_w[-1] - rec_w[0]).abs length * width end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rectangle_area(str_arr)\n str_arr = str_arr.sort.map do |co_ord|\n co_ord.delete('()').split.map(&:to_i)\n end\n width = str_arr[2][0] - str_arr[0][0]\n height = str_arr[1][1] - str_arr[0][1]\n width * height\nend", "def RectangleArea(strArr)\n\n # code goes here\n return strArr \n \nend", "def area(arr)\n \n x_values = []\n y_values = []\n arr.each do |xy|\n x_values << xy.first\n y_values << xy.last\n end\n \n xmin = x_values.min\n xmax = x_values.max\n \n ymin = y_values.min\n ymax = y_values.max\n \n area = (ymax - ymin) * (xmax - xmin)\n \n area\nend", "def area_of_rectangle(width, length)\n width*length\nend", "def rectangle_area(width, height)\n area = width * height\nend", "def area_of_rect(l, w)\n return l * w\nend", "def rectangleArea(l, w)\n\t#Calculate the area\n\tl * w\nend", "def rectangleArea(h, w)\r\n h * w\r\nend", "def find_area(height, width)\n height * width\nend", "def area(length, width)\n length * width\nend", "def area; rect size; end", "def rectangleArea(width, height)\n # return width * height\n width * height\n # set end of rectangleArea function\nend", "def find_area height, width\n\theight * width\nend", "def find_area height, width \n area= height * width \n puts area \nend", "def area\n result = @length * @breadth\n puts\n puts \"area of square of length 4 should be 16 ✔\"\n puts \"area of rectangle with #{@length}, #{@breadth} should be #{result} ✔\"\n\n end", "def area(length, width)\n a = length * width\n return a\nend", "def area(length, width)\n length * width # Implicit return\nend", "def solve(input)\n left = 0 \n right = input.length - 1\n area = 0 \n while(left < right)\n if !input[left]\n left += 1\n next\n end\n if !input[right]\n right += 1\n next\n end\n height = [input[left], input[right]].min\n width = right - 1 - left\n area = [area, (height * width)].max\n if input[left] < input[right]\n left += 1\n else\n right += 1\n end\n end\n p area\nend", "def find_area height, width\n\n\theight * width\nend", "def calc_area(len, wid)\n\tarea = len * wid\n\treturn area\nend", "def find_area height, width\n area = height * width\n p area\nend", "def polygon_area(vertices)\n raise \"A polygon must have 3 or more vertices, not #{vertices.length}\" unless vertices.length >= 3\n\n area = 0\n\n # Rely on Ruby's circular array indexing for negative indices\n vertices.size.times do |idx|\n x2, y2 = vertices[idx]\n x1, y1 = vertices[idx - 1]\n area += x1 * y2 - x2 * y1\n end\n\n return area * 0.5\n end", "def getArea\n @width * @height * @length\n end", "def get_area\n\n # get the keyword value of shape\n shape = get_keyword_value(\"SHAPE\")\n\n # if the shape value is nil, or it is defined as \"NO-SHAPE\", the get_area value\n # would be defined, and would represent the get_area of the space\n if ( shape == nil || shape == \"NO-SHAPE\")\n area = get_keyword_value(\"AREA\")\n area = area.to_f\n return area\n\n # if the shape value is \"BOX\", the height and width key values are given,\n # and the get_area would be defined as their product\n elsif ( shape == \"BOX\" )\n height = get_keyword_value(\"HEIGHT\")\n width = get_keyword_value(\"WIDTH\")\n height = height.to_f\n width = width.to_f\n return height * width\n\n # if the shape value is defined as a polygon , the get_area of the polygon would\n # represent the get_area of the space\n elsif ( shape == \"POLYGON\")\n return @polygon.get_area\n else\n raise \"Error: The area could not be evaluated. Please check inputs\\n \"\n\n end\n end", "def getArea(ringNumber)\n\t((ringNumber-1)*2+1)**2\nend", "def area\n x, y, z = sides.sort\n (\n 0.25 * Math.sqrt((x + (y + c)) * (z - (x - y)) * (z + (x - y)) * (x + (y - z)))\n ).to_f.round(precision)\n end", "def get_area\n height = get_keyword_value(\"HEIGHT\")\n width = get_keyword_value(\"WIDTH\")\n \n if height == nil || width == nil\n raise \"Error: In the command #{@utype}:#{@command_name} the area could not be evaluated. Either the HEIGHT or WIDTH is invalid.\\n #{output}\"\n end\n \n height = height.to_f\n width = width.to_f\n \n return height * width\n end", "def get_area(type_area, array_point)\n if type_area == 'circle'\n area = { circle: { centerLatitude: array_point[0], centerLongitude: array_point[1], radius: array_point[2] } }\n else\n points = []\n array_point.each do |c|\n c = c.split(',')\n points << { latitude: c[0], longitude: c[1] }\n end\n area = { polygon: { vertices: points } }\n end\n area\n end", "def sq_area_max(coordinates, matrix_length)\n binding.pry\n area = matrix_length ** 2\n right = (matrix_length-1) - coordinates[0]\n left = (matrix_length - 1) - right\n top= (matrix_length-1) - coordinates[1]\n bottom= (matrix_length -1) - top\n return [top* right, top*left, bottom * right, bottom*left].max\nend", "def to_array str\n array = []\n str.split().each do |i|\n entry = i.split(\",\")\n\n width = entry[0].to_i\n height = entry[1].to_i\n\n if entry.length == 2\n array << [width, height]\n else\n ALL_MACROS[entry[2]].call(width, height, array)\n end\n end\n\n array\nend" ]
[ "0.86365765", "0.7488066", "0.7114782", "0.6585374", "0.6445318", "0.6435562", "0.63478214", "0.6234204", "0.6205837", "0.6082435", "0.60757804", "0.60726416", "0.5971879", "0.5956973", "0.59361166", "0.59360874", "0.5909885", "0.5895338", "0.58946514", "0.5873527", "0.58574986", "0.57690203", "0.5713792", "0.5639057", "0.56241053", "0.5621674", "0.56147546", "0.5601468", "0.5599371", "0.55953616" ]
0.86180985
1
Have the function BitwiseOne(strArr) take the array of strings stored in strArr, which will only contain two strings of equal length that represent binary numbers, and return a final binary string that performed the bitwise OR operation on both strings. A bitwise OR operation places a 0 in the new string where there are zeroes in both binary strings, otherwise it places a 1 in that spot. For example: if strArr is ["1001", "0100"] then your program should return the string "1101"
def BitwiseOne(strArr) result = "" first = strArr[0] second = strArr[1] idx = 0 while idx < strArr[0].length if first[idx] == "0" && second[idx] == "0" result << "0" else result << "1" end idx += 1 end result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def BitwiseOne(strArr)\n first = strArr[0]\n second = strArr[1]\n third = \"\"\n \n i = 0 \n while i < first.length\n # When i change this line to first[i] == \"0\" &&\n # second[i] == \"0\"\n # all tests passes. Why????????????????????????\n if first[i] == second[i]\n \t third << \"0\"\n else\n \t third << \"1\"\n end\n \n i += 1\n end\n third \nend", "def BitwiseTwo(strArr)\n result = strArr[0].to_i(2) & strArr[1].to_i(2)\n format(\"%0#{strArr[0].size}b\", result)\nend", "def Bitwise(arr)\n output_num = ''\n arr[0].split(//).each_with_index {|char,idx| char == arr[1][idx] ? output_num << '0' : output_num << '1'}\n output_num.to_i\nend", "def string_to_binary(str)\n zero_array = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\"]\n one_array = [\"n\" , \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n\n def check_if_in_array(check, array)\n array.each do |i|\n if check.upcase == i.upcase\n return true\n end\n end\n\n return false\n end\n\n return_word = \"\"\n\n for char in str.chars\n if check_if_in_array(char, zero_array)\n return_word = return_word + \"0\"\n elsif check_if_in_array(char, one_array)\n return_word = return_word + \"1\"\n end\n end\n\n return return_word\nend", "def bitwise_or(a, b)\n\tresult = ''\n\ta.each_char.with_index do |val, index|\n\t\tif val == '1' || b[index] == '1'\n\t\t\tresult.concat '1'\n\t\telse\n\t\t\tresult.concat '0'\n\t\tend\n\tend\n\treturn result\nend", "def boolean_to_binary(arr)\n result = ''\n i = 0\n while i < arr.length\n result << '1' if arr[i]\n result << '0' if !arr[i]\n i += 1\n end\n return result\nend", "def stringy(num, bit = 1)\n bin_arr = []\n num.times { |n| n.even? ? bin_arr << (0 + bit) : bin_arr << (1 - bit) }\n bin_arr.join\nend", "def bitwise_exclusive(a, b)\n\tresult = ''\n\ta.each_char.with_index do |val, index|\n\t\tif (val == '1' && b[index] == '0') || (val == '0' && b[index] == '1')\n\t\t\tresult.concat '1'\n\t\telse\n\t\t\tresult.concat '0'\n\t\tend\n\tend\n\treturn result\nend", "def old_boolean_to_binary(arr)\n binary = \"\"\n\n arr.each do |boolean|\n if boolean\n binary += \"1\"\n else\n binary += \"0\"\n end\n end\n\n binary\nend", "def bitwise_and(a, b)\n\tresult = ''\n\ta.each_char.with_index do |val, index|\n\t\tif val == b[index]\n\t\t\tresult.concat '1'\n\t\telse\n\t\t\tresult.concat '0'\n\t\tend\n\tend\n\treturn result\nend", "def boolean_to_binary(arr)\r\n\r\n binary = \"\"\r\n\r\n # iteration each method\r\n arr.each {|bool|\r\n if bool == true\r\n\r\n # bool true to binary 1\r\n binary << \"1\"\r\n else\r\n\r\n # bool false to binary 0\r\n binary << \"0\"\r\n end }\r\n\r\n binary\r\nend", "def stringy(num)\n binary = ''\n loop do\n binary << '1'\n break if binary.length == num\n binary << '0'\n break if binary.length == num\n end\n binary\nend", "def add_binary a, b\n return_arr = con_to_binary(a + b)\n return_arr.shift if return_arr[0] == \"0\"\n return_arr.join\nend", "def stringy(int)\n ones_and_zeros = []\n int.times do\n if ones_and_zeros.empty?\n ones_and_zeros << '1'\n elsif ones_and_zeros[-1] == '1'\n ones_and_zeros << '0'\n else\n ones_and_zeros << '1'\n end\n end\n ones_and_zeros.reduce(:+)\nend", "def stringy2(int, *zero)\n str = ''\n if zero == [0] then str += '0' else str += '1' end\n int.times do |n|\n if n > 0\n array = str.chars\n if array[n - 1] == '0' then str += '1' else str += '0' end\n end\n end\n p str\nend", "def replace_binary(str)\n str.gsub(/[01]+/) { |bin| bin.to_i(2).to_s(10) }\n end", "def replace_binary(str)\n str.gsub(/[01]+/) { |bin| bin.to_i(2).to_s(10) }\n end", "def perform_or(mask, source)\n result = \"\"\n\n (0..mask.length-1).each do |byte|\n result.concat((mask[byte] == ?0 and source[byte] == ?0) ? \"0\" : \"1\")\n end\n\n result\n end", "def stringy(number)\n number_range = (1..number)\n binary = []\n number_range.each do |num|\n if num % 2 == 1\n binary << 1\n elsif num % 2 == 0\n binary << 0\n end\n end\n binary.join(\"\")\nend", "def bitwise_not(a)\n\tresult = ''\n\ta.each_char do |val|\n\t\tif val == '1' \n\t\t\tresult.concat '0'\n\t\telse\n\t\t\tresult.concat '1'\n\t\tend\n\tend\n\treturn result\nend", "def stringy(num, b = 1)\n string = ''\n if b = 0\n num.times { |v| v.odd? ? string.concat('1') : string.concat('0') }\n return string\n else \n num.times { |v| v.odd? ? string.concat('0') : string.concat('1') }\n return string\n end \nend", "def string_to_binary(str)\n if str.('a'..'m').include?\n return \"0\"\n else\n return \"1\"\n end\nend", "def bitSetOr (a,b)\n\t\tresult = Array.new\n\t\tfor i in 0...(a.size)\n\t\t\tresult[i] = a[i] || b[i]\n\t\tend\n\t\treturn result\n\tend", "def applyMask(str, mask)\n newStr = \"\"\n (0...(str.length)).each do |i|\n if mask[i] == \"1\" \n newStr += str[i].upcase\n else\n newStr += str[i]\n end\n end\n return newStr\nend", "def stringy(int, int1 = 1)\n if int && int1 != 0\n Array.new(int) { |i| i.even? ? '1' : '0' }.join\n elsif int1 == 0\n Array.new(int) { |i| i.even? ? '0' : '1' }.join\n end\nend", "def boolean_to_binary(array)\nend", "def joinor(arr, str1 = ', ', str2 = 'or')\n case arr.size\n when 0 then ''\n when 1 then arr.first\n when 2 then arr.join(\" #{str2} \")\n else\n arr[-1] = \"#{str2} #{arr.last}\"\n arr.join(str1)\n end\nend", "def ALU1BIT(a,b,cin,binv,op1,op2) \n\tb = MUX2X1(b,binv)\n\tsUM_RESULT = ADDER(a,b,cin)\n\t#Send out an array pair of result, cout\n\treturn MUX4X1(AND(a,b),OR(a,b),sUM_RESULT[0],0,op1,op2), sUM_RESULT[1]\nend", "def translate_to_binary(array_of_hex)\n array_of_binary = []\n array_of_hex.each do |num|\n array_of_binary << sprintf(\"%b\", num).rjust(32, '0')\n end\n array_of_binary\n end", "def xor(codes, string)\n Array.new([codes.size, string.size].min) { |i| codes[i] ^ string[i].ord }.map(&:chr).join\nend" ]
[ "0.7820862", "0.77656883", "0.75368595", "0.71487653", "0.7120717", "0.65298414", "0.64599407", "0.6386743", "0.63338184", "0.6322576", "0.6283897", "0.61651385", "0.61217976", "0.60727185", "0.59535116", "0.5947428", "0.5947428", "0.5934803", "0.5882967", "0.5875591", "0.5874551", "0.58455986", "0.583077", "0.5781564", "0.57800996", "0.5767243", "0.57620525", "0.5754029", "0.57171875", "0.5707201" ]
0.8900529
0
Specifies a new pluralization rule and its replacement. The rule can either be a string or a regular expression. The replacement should always be a string that may include references to the matched data from the rule.
def plural(rule, replacement) @uncountables.delete(rule) if rule.is_a?(String) @uncountables.delete(replacement) @plurals.insert(0, [rule, replacement]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plural(rule, replacement, term: :noun)\n @plurals[term] << [Regexp.new(rule, \"i\"), replacement]\n end", "def plural(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @plurals.prepend([rule, replacement])\n end", "def plural(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @plurals.prepend([rule, replacement])\n end", "def plural_rule(singular, plural)\n @plural_rules << [singular, plural]\n end", "def singular(rule, replacement, term: :noun)\n @singulars[term] << [Regexp.new(rule, \"i\"), replacement]\n end", "def pluralization_rules\n if defined?(@pluralization_regex) && @pluralization_regex\n return [@pluralization_regex, @pluralization_hash]\n end\n @pluralization_regex = Regexp.new(\"(\" + @plural_rules.map {|s,p| s}.join(\"|\") + \")$\", \"i\")\n @pluralization_hash = Hash[*@plural_rules.flatten]\n [@pluralization_regex, @pluralization_hash]\n end", "def rule(sing, plur, term: :noun)\n plural(sing, plur, term: term)\n singular(plur, sing, term: term)\n end", "def singular(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @singulars.insert(0, [rule, replacement])\n end", "def singular(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @singulars.insert(0, [rule, replacement])\n end", "def singular(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @singulars.insert(0, [rule, replacement])\n end", "def singular(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @singulars.prepend([rule, replacement])\n end", "def singular(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @singulars.prepend([rule, replacement])\n end", "def singular_rule(singular, plural)\n @singular_rules << [singular, plural]\n end", "def plural(input)\n input.dup.en.plural\n end", "def rule(singular, plural, whole_word = false)\n singular_rule(singular, plural)\n plural_rule(singular, plural)\n word(singular, plural) if whole_word\n end", "def rule=(nu_rule)\n unless RULES.include?(nu_rule)\n str = %(\"#{nu_rule}\")\n str << ' is not one of '\n str << RULES.map(&:inspect).join(', ')\n\n raise ArgumentError, str\n end\n\n @rule = nu_rule\n end", "def add_rule(pattern, replace = nil, &proc)\n\t\t\tif replace\n\t\t\t\t@rules << @rule.new(pattern, replace)\n\t\t\telse\n\t\t\t\t@rules << @rule.new(pattern, proc)\n\t\t\tend\n\t\tend", "def new_rule(rule)\n Rule.new(rule)\n end", "def plural(word)\n # special exceptions\n return \"\" if word == \"\"\n if result = plural_of[word]\n return result.dup\n end\n result = word.dup\n regex, hash = pluralization_rules\n result.sub!(regex) {|m| hash[m]}\n plural_of[word] = result\n return result\n end", "def pluralize\n self.class.new Inflector.pluralize(self)\n end", "def pluralize\n self.class.new Inflector.pluralize(self)\n end", "def pluralize(word); end", "def human(rule, replacement)\n @humans.prepend([rule, replacement])\n end", "def human(rule, replacement)\n @humans.prepend([rule, replacement])\n end", "def pluralisation_rule\n Thread.current[:fast_gettext_pluralisation_rule] || current_repository.pluralisation_rule || lambda{|i| i!=1}\n end", "def pluralize(resource)\n resource =~ /^\\w+y$/ ? resource.sub(/y$/, 'ies') : \"#{resource}s\"\n end", "def human(rule, replacement)\n @humans.insert(0, [rule, replacement])\n end", "def human(rule, replacement)\n @humans.insert(0, [rule, replacement])\n end", "def human(rule, replacement)\n @humans.insert(0, [rule, replacement])\n end", "def expand_rule_definition definition\r\n\t\t@rules.reverse_each do |r|\r\n definition = definition.gsub \"[:#{r.type.to_s}]\", \"(#{r.definition})\"\r\n\t\tend\r\n\t\tdefinition\r\n\tend" ]
[ "0.78080434", "0.7742466", "0.7742466", "0.6821922", "0.6346475", "0.60990644", "0.60030764", "0.5988815", "0.5988815", "0.5988815", "0.5951694", "0.5951694", "0.5802258", "0.57173264", "0.5604747", "0.55871576", "0.5529318", "0.55205214", "0.5496508", "0.54935265", "0.54935265", "0.54782516", "0.5444163", "0.5444163", "0.54138124", "0.54082924", "0.53743505", "0.53743505", "0.53743505", "0.5357412" ]
0.7810321
1
Specifies a new irregular that applies to both pluralization and singularization at the same time. This can only be used for strings, not regular expressions. You simply pass the irregular in singular and plural form. Examples: irregular 'octopus', 'octopi' irregular 'person', 'people'
def irregular(singular, plural) @uncountables.delete(singular) @uncountables.delete(plural) if singular[0,1].upcase == plural[0,1].upcase plural(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + plural[1..-1]) plural(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + plural[1..-1]) singular(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + singular[1..-1]) else plural(Regexp.new("#{singular[0,1].upcase}(?i)#{singular[1..-1]}$"), plural[0,1].upcase + plural[1..-1]) plural(Regexp.new("#{singular[0,1].downcase}(?i)#{singular[1..-1]}$"), plural[0,1].downcase + plural[1..-1]) plural(Regexp.new("#{plural[0,1].upcase}(?i)#{plural[1..-1]}$"), plural[0,1].upcase + plural[1..-1]) plural(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), plural[0,1].downcase + plural[1..-1]) singular(Regexp.new("#{plural[0,1].upcase}(?i)#{plural[1..-1]}$"), singular[0,1].upcase + singular[1..-1]) singular(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), singular[0,1].downcase + singular[1..-1]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def irregular(singular, plural)\n @uncountables.delete(singular)\n @uncountables.delete(plural)\n if singular[0,1].upcase == plural[0,1].upcase\n plural(Regexp.new(\"(#{singular[0,1]})#{singular[1..-1]}$\", \"i\"), '\\1' + plural[1..-1])\n singular(Regexp.new(\"(#{plural[0,1]})#{plural[1..-1]}$\", \"i\"), '\\1' + singular[1..-1])\n else\n plural(Regexp.new(\"#{singular[0,1].upcase}(?i)#{singular[1..-1]}$\"), plural[0,1].upcase + plural[1..-1])\n plural(Regexp.new(\"#{singular[0,1].downcase}(?i)#{singular[1..-1]}$\"), plural[0,1].downcase + plural[1..-1])\n singular(Regexp.new(\"#{plural[0,1].upcase}(?i)#{plural[1..-1]}$\"), singular[0,1].upcase + singular[1..-1])\n singular(Regexp.new(\"#{plural[0,1].downcase}(?i)#{plural[1..-1]}$\"), singular[0,1].downcase + singular[1..-1])\n end\n end", "def irregular(singular, plural)\n @uncountables.delete(singular)\n @uncountables.delete(plural)\n\n s0 = singular[0]\n srest = singular[1..-1]\n\n p0 = plural[0]\n prest = plural[1..-1]\n\n if s0.upcase == p0.upcase\n plural(/(#{s0})#{srest}$/i, '\\1' + prest)\n plural(/(#{p0})#{prest}$/i, '\\1' + prest)\n\n singular(/(#{s0})#{srest}$/i, '\\1' + srest)\n singular(/(#{p0})#{prest}$/i, '\\1' + srest)\n else\n plural(/#{s0.upcase}(?i)#{srest}$/, p0.upcase + prest)\n plural(/#{s0.downcase}(?i)#{srest}$/, p0.downcase + prest)\n plural(/#{p0.upcase}(?i)#{prest}$/, p0.upcase + prest)\n plural(/#{p0.downcase}(?i)#{prest}$/, p0.downcase + prest)\n\n singular(/#{s0.upcase}(?i)#{srest}$/, s0.upcase + srest)\n singular(/#{s0.downcase}(?i)#{srest}$/, s0.downcase + srest)\n singular(/#{p0.upcase}(?i)#{prest}$/, s0.upcase + srest)\n singular(/#{p0.downcase}(?i)#{prest}$/, s0.downcase + srest)\n end\n end", "def irregular(singular, plural)\n @uncountables.delete(singular)\n @uncountables.delete(plural)\n\n s0 = singular[0]\n srest = singular[1..-1]\n\n p0 = plural[0]\n prest = plural[1..-1]\n\n if s0.upcase == p0.upcase\n plural(/(#{s0})#{srest}$/i, '\\1' + prest)\n plural(/(#{p0})#{prest}$/i, '\\1' + prest)\n\n singular(/(#{s0})#{srest}$/i, '\\1' + srest)\n singular(/(#{p0})#{prest}$/i, '\\1' + srest)\n else\n plural(/#{s0.upcase}(?i)#{srest}$/, p0.upcase + prest)\n plural(/#{s0.downcase}(?i)#{srest}$/, p0.downcase + prest)\n plural(/#{p0.upcase}(?i)#{prest}$/, p0.upcase + prest)\n plural(/#{p0.downcase}(?i)#{prest}$/, p0.downcase + prest)\n\n singular(/#{s0.upcase}(?i)#{srest}$/, s0.upcase + srest)\n singular(/#{s0.downcase}(?i)#{srest}$/, s0.downcase + srest)\n singular(/#{p0.upcase}(?i)#{prest}$/, s0.upcase + srest)\n singular(/#{p0.downcase}(?i)#{prest}$/, s0.downcase + srest)\n end\n end", "def irregular(infinitive, preterite = nil, past_participle = nil, &blk)\n if block_given?\n # create new Verb object with infinitive and &blk\n irregular = ::Verbs::Verb.new infinitive, &blk\n else\n unless preterite && past_participle\n raise ArgumentError,\n 'Standard irregular verbs must specify preterite and past participle forms'\n end\n\n # create new Verb object with infinitive, preterite and past_participle\n irregular = ::Verbs::Verb.new infinitive, preterite: preterite, past_participle: past_participle\n end\n @irregulars[infinitive] = irregular\n end", "def singular(rule, replacement, term: :noun)\n @singulars[term] << [Regexp.new(rule, \"i\"), replacement]\n end", "def plural(rule, replacement, term: :noun)\n @plurals[term] << [Regexp.new(rule, \"i\"), replacement]\n end", "def to_add\n new_numeral = self.dup\n ROMAN_CHARS.each_char do |char|\n allowed_subtrahends = lower_chars(char)[-2,2] || lower_chars(char)[-1,1] || \"N\"\n subtractive = /([#{allowed_subtrahends}]+)([#{char}])/.match(new_numeral)\n if subtractive\n new_numeral = subtractive.pre_match << ( RomanNumeral.new(subtractive[2]).minus( RomanNumeral.new(subtractive[1]) ) ) << subtractive.post_match\n end\n end\n RomanNumeral.new(new_numeral)\n end", "def to_sub\n new_numeral = self.dup.to_add.denumerate\n # First, look for second-order substitutions, like VIIII => IX\n ROMAN_CHARS.each_char do |char|\n first_order = lower_chars(char)[-1,1] || \"N\"\n second_order = lower_chars(char)[-2,1] || \"N\"\n new_numeral.sub!(/[#{first_order}][#{second_order}]{4}/, second_order << char)\n end\n # Second, look for single-order substitutions, like IIII => IV\n ROMAN_CHARS.each_char do |char|\n first_order = lower_chars(char)[-1,1] || \"N\"\n new_numeral.sub!(/[#{first_order}]{4}/, first_order << char)\n end\n RomanNumeral.new(new_numeral)\n end", "def galactic_words_to_roman # returns roman representaion \n\t\t@pattern.split.map{ |e| @@galactic_words_roman_symbol_assignments[e] }.join\n\tend", "def galactic_words_to_roman # returns roman representaion \n\t\t@pattern.split.map{ |e| @@galactic_words_roman_symbol_assignments[e] }.join\n\tend", "def initialize(regex)\n raise ArgumentError.new(Rack::AARM::DSL::Helpers::ARGUMENTS_BAD) unless regex.is_a? Regexp\n @regex = regex\n @verbs = []\n end", "def initialize(all_concepts, phrase, &block)\n refined_phrase = remove_optional_words(phrase)\n phrase.symbols.each do |symbol|\n if all_concepts[symbol].nil?\n raise InvalidConceptError.new(\"Unable to create phrase because :#{symbol} concept has not been defined.\") \n else\n concept = all_concepts[symbol]\n concepts << concept\n concept_matcher = \"(?<#{symbol}>#{concept.definition.to_regexp})\"\n refined_phrase = refined_phrase.gsub(\":#{symbol}\", concept_matcher)\n end\n end\n @original = \"^#{refined_phrase}\"\n @regex, @block = Oniguruma::ORegexp.new(@original, :options => Oniguruma::OPTION_IGNORECASE), block \n end", "def get_regular(verb)\n case verb\n when /(ch|s|sh|x|z)$/\n return verb + 'es'\n when /(ay|ey|oy|uy)$/\n return verb + 's'\n when /[^aeiou]y$/\n return verb[ 0..-2 ] + 'ies'\n else\n return verb + 's'\n end\n end", "def ancientify\n\t\troman = self\n\t\troman.gsub(\"CM\", \"DCCCC\")\n\t\troman.gsub(\"CD\", \"CCCC\")\n\t\troman.gsub(\"XC\", \"LXXXX\")\n\t\troman.gsub(\"XL\", \"XXXX\")\n\t\troman.gsub(\"IX\", \"VIIII\")\n\t\troman.gsub(\"IV\", \"IIII\")\n\tend", "def initialize( string, restrictions = [] )\n restrictions.each { |r| method( \"#{ r }=\" ).call( true ) }\n super( string )\n end", "def simple_tag_type_pluralizer(s)\n case s\n when /o\\Z/ then s.sub(/o\\Z/, \"es\")\n when /y\\Z/ then s.sub(/y\\Z/, \"ies\")\n when /ss\\Z/ then s.sub(/ss\\Z/, \"sses\")\n else\n \"#{s}s\"\n end\n end", "def plural(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @plurals.prepend([rule, replacement])\n end", "def plural(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @plurals.prepend([rule, replacement])\n end", "def plural(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @plurals.insert(0, [rule, replacement])\n end", "def plural(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @plurals.insert(0, [rule, replacement])\n end", "def plural(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @plurals.insert(0, [rule, replacement])\n end", "def inflection(text, count = nil, inflect: nil)\n if (count == 1) || INFLECT_SINGULAR.include?(inflect)\n text.to_s.singularize\n elsif count.is_a?(Integer) || INFLECT_PLURAL.include?(inflect)\n text.to_s.pluralize\n else\n text.to_s.dup\n end\n end", "def singular(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @singulars.prepend([rule, replacement])\n end", "def singular(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @singulars.prepend([rule, replacement])\n end", "def create_roman_of()\n\treturn ARABIC_TO_ROMAN unless SUBTRACTIVE\n\treturn ARABIC_TO_ROMAN.merge(SUBTRACTIVE_ROMAN)\nend", "def create_freq_regexs\n @frequency_regex = /#{word_frequency[0..10].join(\"|\")}/\n end", "def init(phrase)\n super(phrase)\n self.mode = LITERAL_MODE\n self.pieces = []\n self.pf0 = nil # plural forms without name yet\n end", "def singular(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @singulars.insert(0, [rule, replacement])\n end", "def singular(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @singulars.insert(0, [rule, replacement])\n end", "def singular(rule, replacement)\n @uncountables.delete(rule) if rule.is_a?(String)\n @uncountables.delete(replacement)\n @singulars.insert(0, [rule, replacement])\n end" ]
[ "0.7030382", "0.68373466", "0.6829547", "0.6032925", "0.533286", "0.53180796", "0.52982855", "0.5174435", "0.5102942", "0.5102942", "0.506334", "0.49950776", "0.49806598", "0.4969743", "0.49688318", "0.4962685", "0.49353704", "0.49353704", "0.4886441", "0.4886441", "0.4886441", "0.4880596", "0.48476177", "0.48476177", "0.4809282", "0.47814333", "0.4777432", "0.47726187", "0.47726187", "0.47726187" ]
0.709308
1
Yields a singleton instance of Inflector::Inflections so you can specify additional inflector rules. Example: ActiveSupport::Inflector.inflections do |inflect| inflect.uncountable "rails" end
def inflections if block_given? yield Inflections.instance else Inflections.instance end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inflections(&block)\n self.inflector = Dry::Inflector.new(&block)\n end", "def inflections(locale = :en)\n if block_given?\n yield Inflections.instance(locale)\n else\n Inflections.instance(locale)\n end\n end", "def inflections(locale = :en)\n if block_given?\n yield Inflections.instance(locale)\n else\n Inflections.instance(locale)\n end\n end", "def inflections(locale = :en)\n if block_given?\n yield Inflections.instance(locale)\n else\n Inflections.instance_or_fallback(locale)\n end\n end", "def inflector\n config.inflector\n end", "def jsonapi_inflector\n ActiveSupport::Inflector\n rescue\n Dry::Inflector.new\n end", "def inflection\n ( self[ :inflect ] || \"#{pluralize}#{gender}\" ).to_s\n end", "def inflection(text, count = nil, inflect: nil)\n if (count == 1) || INFLECT_SINGULAR.include?(inflect)\n text.to_s.singularize\n elsif count.is_a?(Integer) || INFLECT_PLURAL.include?(inflect)\n text.to_s.pluralize\n else\n text.to_s.dup\n end\n end", "def inflect_names(name) #:nodoc:\n camel = name.camelize\n under = camel.underscore\n plural = under.pluralize\n [camel, under, plural]\n end", "def with_dup\n original = MorePossessive::Inflector::Inflections.instance_variable_get(:@__instance__)\n MorePossessive::Inflector::Inflections.instance_variable_set(:@__instance__, original.dup)\n ensure\n MorePossessive::Inflector::Inflections.instance_variable_set(:@__instance__, original)\n end", "def camelize\n ActiveSupport::Inflector.camelize(self)\n end", "def deconstantize\n ActiveSupport::Inflector.deconstantize(self)\n end", "def deconstantize\n ActiveSupport::Inflector.deconstantize(self)\n end", "def inflector(header_inflector)\n @inflector = header_inflector\n end", "def classify\n ActiveSupport::Inflector.classify(self)\n end", "def inflect(infinitive, inflection, person, plurality, mood)\n send(*[inflection, infinitive, person, plurality, mood][0, method(inflection).arity + 1])\n end", "def humanize\n\t\tlower_case_and_underscored_word = self\n\t\tresult = lower_case_and_underscored_word.to_s.dup\n#\t\tinflections.humans.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }\n\t\tresult.gsub!(/_id$/, \"\")\n\t\tresult.gsub!(/_/, ' ')\n#\t\tresult.gsub(/([a-z\\d]*)/) { |match|\n#\t\t\"#{inflections.acronyms[match] || match.downcase}\"\n#\t\t}.gsub(/^\\w/) { $&.upcase }\n\tend", "def safe_constantize\n ActiveSupport::Inflector.safe_constantize(self)\n end", "def demodulize\n ActiveSupport::Inflector.demodulize(self)\n end", "def pluralize\n self.class.new Inflector.pluralize(self)\n end", "def pluralize\n self.class.new Inflector.pluralize(self)\n end", "def inflect(word,count)\n if count>1\n word.pluralize\n else\n word\n end\n end", "def upcase_first\n ActiveSupport::Inflector.upcase_first(self)\n end", "def convert_class(klass)\n ::ActiveSupport::Inflector.underscore(klass.name).gsub(\"/\", \"_\")\n end", "def singularize(locale = :en)\n ActiveSupport::Inflector.singularize(self, locale)\n end", "def singularize\n ActiveSupport::Inflector.singularize(self)\n end", "def downcase_first\n ActiveSupport::Inflector.downcase_first(self)\n end", "def humanize(lower_case_and_underscored_word)\n result = lower_case_and_underscored_word.to_s.dup\n\n inflections.humans.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }\n result.gsub(/_id$/, \"\").gsub(/_/, \" \").capitalize\n end", "def humanize(lower_case_and_underscored_word)\n result = lower_case_and_underscored_word.to_s.dup\n\n inflections.humans.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }\n result.gsub(/_id$/, \"\").gsub(/_/, \" \").capitalize\n end", "def tableize\n ActiveSupport::Inflector.tableize(self)\n end" ]
[ "0.84448296", "0.75030327", "0.75030327", "0.74915546", "0.6609839", "0.6407881", "0.6310196", "0.5966587", "0.5891092", "0.57575756", "0.5672936", "0.5591746", "0.5591746", "0.552714", "0.54611117", "0.5440463", "0.5435907", "0.5389456", "0.5340996", "0.5317171", "0.5317171", "0.52757215", "0.52581173", "0.5246387", "0.5236893", "0.521864", "0.5184125", "0.51836616", "0.51836616", "0.5183287" ]
0.81235486
1
Returns the plural form of the word in the string. Examples: "post".pluralize => "posts" "octopus".pluralize => "octopi" "sheep".pluralize => "sheep" "words".pluralize => "words" "CamelOctopus".pluralize => "CamelOctopi"
def pluralize(word) result = word.to_s.dup if word.empty? || inflections.uncountables.include?(result.downcase) result else inflections.plurals.each { |(rule, replacement)| break if result.gsub!(rule, replacement) } result end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pluralize(word); end", "def pluralize(word)\n result = word.to_s.dup\n\n if word.empty? || inflections.uncountables.include?(result.downcase)\n result\n else\n inflections.plurals.each do |(rule, replacement)| \n break if result.gsub!(rule, replacement)\n end\n result\n end\n end", "def plural(word)\n # special exceptions\n return \"\" if word == \"\"\n if result = plural_of[word]\n return result.dup\n end\n result = word.dup\n regex, hash = pluralization_rules\n result.sub!(regex) {|m| hash[m]}\n plural_of[word] = result\n return result\n end", "def plural\n return word if word.to_s.empty?\n\n find_match(Inflection.configuration.plurals[:noun]) ||\n (uncountable? && word) || find_match(Nouns.plurals) || word\n end", "def pluralize(word, term: :noun)\n case term\n when :noun, :n\n Noun[word].plural\n when :verb, :v\n Verb[word].plural\n end\n end", "def pluralize_word(singular)\n singular.respond_to?(:pluralize) ? singular.pluralize : singular + 's'\n end", "def pluralize(word, locale = :en)\n Geode::FastInflector.pluralize(word, locale)\n end", "def pluralize( name )\n warn_nyi( \"support for pluralization guides in pluralize()\" )\n return name.pluralize\n end", "def pluralize_word(count, singular, plural = nil)\n ((count == 1 || count == '1') ? singular : (plural || singular.pluralize))\n end", "def pluralize\n @name.pluralize\n end", "def pluralize(string)\n if string[-1] == 'y'\n \"#{string[0..(string.length - 2)]}ies\"\n else\n \"#{string}s\"\n end\n end", "def pluralize\n p = self[ :plural ]\n p = ! scalar? if p.nil?\n p = 's' if p == false\n p = 'p' if p == true\n p.to_s\n end", "def plural( count=2 )\n\t\tphrase = if self.respond_to?( :to_int )\n\t\t\t\tself.numwords\n\t\t\telse\n\t\t\t\tself.to_s\n\t\t\tend\n\n\t\tself.log.debug \"Pluralizing %p\" % [ phrase ]\n\t\tpre = text = post = nil\n\n\t\t# If the string has whitespace, only pluralize the middle bit, but\n\t\t# preserve the whitespace to add back to the result.\n\t\tif md = /\\A(\\s*)(.+?)(\\s*)\\Z/.match( phrase.to_s )\n\t\t\tpre, text, post = md.captures\n\t\telse\n\t\t\treturn phrase\n\t\tend\n\n\t\tplural = postprocess( text,\n\t\t\tpluralize_special_adjective(text, count) ||\n\t\t\tpluralize_special_verb(text, count) ||\n\t\t\tpluralize_noun(text, count) )\n\n\t\treturn pre + plural + post\n\tend", "def pluralize(singularStr, num)\n if num == 1\n return singularStr\n else\n if singularStr[-1] == \"s\" # singularStr[-1] returns last character of string\n return \"#{singularStr}es\"\n else\n return \"#{singularStr}s\"\n end\n end\n end", "def plural_verb( count=2 )\n\t\tphrase = self.to_s\n\t\tmd = /\\A(\\s*)(.+?)(\\s*)\\Z/.match( phrase )\n\t\tpre, word, post = md.captures\n\n\t\treturn phrase if word.nil? or word.empty?\n\n\t\tplural = postprocess( word,\n\t\t\tpluralize_special_verb(word, count) ||\n\t\t\tpluralize_general_verb(word, count) )\n\n\t\treturn pre + plural + post\n\tend", "def pluralize(count, word)\n \"#{word}#{'s' unless count.to_i == 1}\"\n end", "def make_plural\n\t\tsentence_array=Array.new\n\t\tnew_sentence_array=Array.new\n\t\tsentence_array= to_str.split(/ /)\n\t\t\t(0..sentence_array.size-1).each do |cnt|\n\t\t\t\tnew_sentence_array << sentence_array[cnt].strip.downcase.pluralize\n\t\t\tend\n\t\treturn new_sentence_array.join(\" \")\n\tend", "def plural_adjective( count=2 )\n\t\tphrase = self.to_s\n\t\tmd = /\\A(\\s*)(.+?)(\\s*)\\Z/.match( phrase )\n\t\tpre, word, post = md.captures\n\n\t\treturn phrase if word.nil? or word.empty?\n\n\t\tplural = postprocess( word, pluralize_special_adjective(word, count) || word )\n\n\t\treturn pre + plural + post\n\tend", "def pluralize(text)\n \"#{text.to_s}s\"\n end", "def pluralize(word)\n return word + \"s\" if pluralize?\n word\nend", "def pluralize(count, word)\n \"#{word}#{'s' unless count.to_f == 1}\"\n end", "def inflect(word,count)\n if count>1\n word.pluralize\n else\n word\n end\n end", "def pluralize\n self.class.new Inflector.pluralize(self)\n end", "def pluralize\n self.class.new Inflector.pluralize(self)\n end", "def plural(input)\n input.dup.en.plural\n end", "def plural_noun( count=2 )\n\t\tphrase = self.to_s\n\t\tmd = /\\A(\\s*)(.+?)(\\s*)\\Z/.match( phrase )\n\t\tpre, word, post = md.captures\n\n\t\treturn phrase if word.nil? or word.empty?\n\n\t\tplural = postprocess( word, pluralize_noun(word, count) )\n\n\t\treturn pre + plural + post\n\tend", "def pluralize\n self[-1] == 's' ? \"#{self}es\" : \"#{self}s\"\n end", "def pluralize_without_number(word)\n pluralize(2, word).split(' ')[1..-1].join(' ')\n end", "def pluralize(count, singular, plural)\n word = count == 1 ? singular : plural\n \"#{count || 0} #{word}\"\n end", "def pluralize(word, nb)\n if (nb > 1)\n return \"#{word}s\"\n else\n return \"#{word}\"\n end\nend" ]
[ "0.7946014", "0.7911394", "0.781301", "0.7726993", "0.7504775", "0.7433464", "0.7432608", "0.7393196", "0.73691964", "0.73340625", "0.7229642", "0.72228944", "0.7188824", "0.715763", "0.71571136", "0.71439284", "0.71365833", "0.70461816", "0.7046087", "0.7040973", "0.7017895", "0.70107704", "0.70002556", "0.70002556", "0.6992973", "0.69309855", "0.6890886", "0.6880136", "0.6854624", "0.68329537" ]
0.79619825
0
Create the name of a table like Rails does for models to table names. This method uses the +pluralize+ method on the last word in the string. Examples "RawScaledScorer".tableize => "raw_scaled_scorers" "egg_and_ham".tableize => "egg_and_hams" "fancyCategory".tableize => "fancy_categories"
def tableize(class_name) pluralize(underscore(class_name)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tableize(class_name)\n pluralize(underscore(class_name))\n end", "def tableize\n ActiveSupport::Inflector.tableize(self)\n end", "def tableize\n MotionSupport::Inflector.tableize(self)\n end", "def tableize\n # TODO\n # Inflector.demodulize(self)\n end", "def tableize(class_name)\n words = class_name.to_const_path.tr('/', '_').split('_')\n words[-1] = pluralize(words[-1])\n words.join('_')\n end", "def implicit_table_name\n pluralize(underscore(demodulize(name))).to_sym\n end", "def implicit_table_name\n pluralize(underscore(demodulize(name))).to_sym\n end", "def camerize(tablename)\n tablename.split(\"_\").map {|word| word.capitalize }.join(\"\")\n end", "def singular_table_name_from x\n x.to_s.tableize.singularize\n end", "def tableize(class_name)\n Geode::FastInflector.tableize(class_name)\n end", "def table_name\n self.to_s.pluralize.underscore\n end", "def model_table_name\n model_name = model_param.name\n model_class = model_name.demodulize\n model_class.tableize\n end", "def compute_table_name\n \"#{full_table_name_prefix}#{undecorated_table_name(name)}#{table_name_suffix}\"\n end", "def table_name\n self.class.name.demodulize.tableize\n end", "def undecorated_table_name(class_name = base_class.name)\n table_name = class_name.to_s.demodulize.underscore\n table_name = table_name.pluralize if pluralize_table_names\n table_name\n end", "def undecorated_table_name(class_name = base_class.name)\n table_name = Inflector.underscore(Inflector.demodulize(class_name))\n table_name = Inflector.pluralize(table_name) if pluralize_table_names\n table_name\n end", "def undecorated_table_name(class_name = class_name_of_active_record_descendant(self))\n table_name = Inflector.underscore(Inflector.demodulize(class_name))\n table_name = Inflector.pluralize(table_name) if pluralize_table_names\n return table_name\n end", "def db_table\n name = (\"evaldata_\" + term.title + \"_\" + title).strip\n name = ActiveSupport::Inflector.transliterate(name).downcase\n name.gsub(/[^a-z0-9_]+/, \"_\")\n end", "def classify(table_name)\n # strip out any leading schema name\n camelize(singularize(table_name.to_s.sub(/.*\\./, '')))\n end", "def classify(table_name)\n # strip out any leading schema name\n camelize(singularize(table_name.to_s.sub(/.*\\./, '')))\n end", "def classify(table_name)\n # strip out any leading schema name\n camelize(singularize(table_name.to_s.sub(/.*\\./, '')))\n end", "def classify(table_name)\n Geode::FastInflector.classify(table_name.to_s)\n end", "def namespaced_table_name\n [self.class.table_namespace, table_name].reject {|s| s.nil? || s.empty?}.join('-')\n end", "def t_model(record, pluralize=true, downcase=false)\n options = { }\n\n options[:count] = 2 if pluralize\n\n string = record.model_name.human options\n string = string.downcase if downcase\n string\n end", "def table_name_for(str, metadata)\n str = str.to_s.gsub(/::/, '_')\n if metadata.stores_lower_case_identifiers\n str.downcase\n elsif metadata.stores_upper_case_identifiers\n str.upcase\n else\n str\n end\n end", "def table_name=(value)\n @original_table_name = @table_name if defined?(@table_name)\n @table_name = value && value.to_s\n @quoted_table_name = nil\n end", "def to_table_format(table)\n #change to format module\n CliBuilder::Menu.modelcase(table).constantize\n end", "def name_plural() name_singular + 's' end", "def table_name_convention(a_string)\n # TODO: i dunnot know what I was thinking\n get_location\n unless String == a_string.class\n error \"Expected a String #{location}\"\n else\n unless a_string.valid_naming_convention?\n error \"#{a_string} is not a supported naming convention #{location}\"\n else\n @params[:table_name_convention] = a_string\n end\n end\n end", "def model(table)\n table.classify.constantize\n end" ]
[ "0.77947557", "0.7709205", "0.7704614", "0.7609139", "0.7597267", "0.7144776", "0.7144776", "0.7026408", "0.6959079", "0.67928153", "0.67635965", "0.6677879", "0.6660683", "0.6626601", "0.65631896", "0.65254426", "0.63863564", "0.63222194", "0.6292972", "0.6196061", "0.6196061", "0.6127896", "0.60971147", "0.6087674", "0.6037513", "0.5955086", "0.5946491", "0.59232944", "0.59207034", "0.5920292" ]
0.77983093
0
sends command to device specified by house and unit string
def send_command(house_and_unit, command) house_code, unit_code = select_code(house_and_unit) @marshaller.send(X10_PREFIX + house_code + unit_code + ADDRESS_SUFFIX) @marshaller.send(X10_PREFIX + house_code + COMMAND_CODE_TABLE[command] + COMMAND_SUFFIX) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def command room, device, state\n # @todo get the device name in here...\n device = device.to_s\n # Command structure is <transaction number>,<Command>|<Action>|<State><cr>\n if room and device and !device.empty? and state\n '666,!' + room['id'] + room['device'][device]['id'] + state + '|Turn ' + room['name'] + ' ' + device + '|' + state + ' via @pauly'\n else\n '666,!' + room['id'] + state + '|Turn ' + room['name'] + '|' + state + ' via @pauly'\n end\n end", "def on\r\n\t@controller.command(@house, @unit, :on, 0)\r\n end", "def send room = nil, device = nil, state = 'on', debug = false\n debug and ( p self.time 'send' )\n success = false\n debug and ( p 'Executing send on device: ' + device + ' in room: ' + room + ' with ' + ( state ? 'state ' + state : 'no state' ))\n\n\n # starting to optionally move some functionality out of here\n alternativeScript = self.get_config['pywaverf']\n if alternativeScript and File.exist?( alternativeScript )\n cmd = \"#{alternativeScript} \\\"#{room}\\\" \\\"#{device}\\\" \\\"#{state}\\\" \\\"#{debug}\\\"\"\n debug and ( p cmd )\n p `#{cmd}`\n debug and ( p self.time 'done python' )\n return\n end\n\n\n rooms = self.class.get_rooms self.get_config, debug\n debug and ( p self.time 'got rooms' )\n\n unless rooms[room] and state\n debug and ( p 'Missing room (' + room.to_s + ') or state (' + state.to_s + ')' );\n STDERR.puts self.usage( room );\n else\n # support for setting state for all devices in the room (recursive)\n if device == 'all'\n debug and ( p 'Processing all devices...' )\n rooms[room]['device'].each do | device_name, code |\n debug and ( p \"Device is: \" + device_name )\n self.send room, device_name, state, debug\n sleep 1\n end\n success = true\n # process single device\n elsif device and rooms[room]['device'][device]\n state = self.class.get_state state\n command = self.command rooms[room], device, state\n debug and ( p self.time 'command is ' + command )\n data = self.raw command\n debug and ( p self.time 'response is ' + data.to_s )\n success = true\n data = self.update_state room, device, state, debug\n else\n STDERR.puts self.usage( room );\n end\n end\n success\n end", "def send(inc)\n @h.usb_control_msg(0x21, 0x09, 0x02, 0x01, (message_base << inc).bytes_to_string, 0)\n end", "def send_command(command)\n SerialPort.open(self.device_path, 9600, 8, 1) do |port|\n # flush anything existing on the port\n port.flush\n flush_read_buffer(port)\n\n byte_string = command.to_bytes.pack('C*')\n\n begin\n while byte_string && byte_string.length != 0\n count = port.write_nonblock(byte_string)\n byte_string = byte_string[count,-1]\n\n port.flush\n end\n rescue IO::WaitWritable\n if IO.select([], [port], [], 5)\n retry\n else\n raise IOError, \"Timeout writing command to #{self.device_path}\"\n end\n end\n\n # wait for expected confirmation signals\n got_eot = false\n got_soh = false\n loop do\n begin\n c = port.read_nonblock(1)\n\n case c\n when \"\\x04\"\n if ! got_eot\n got_eot = true\n else\n raise IOError, \"Got EOT reply twice from #{self.device_path}\"\n end\n when \"\\x01\"\n if got_eot\n if ! got_soh\n got_soh = true\n\n break\n else\n raise IOError, \"Got SOH twice from #{self.device_path}\"\n end\n else\n raise IOError, \"Got SOH before EOT from #{self.device_path}\"\n end\n end\n rescue IO::WaitReadable\n if IO.select([port], [], [], 3)\n retry\n else\n raise IOError, \"Timeout waiting for command reply from #{self.device_path}. EOT:#{got_eot} SOH:#{got_soh}\"\n end\n end\n end\n end\n\n self\n end", "def send_command(command)\n @client.write \"#{command}\\r\\n\"\n end", "def send_command(command,args)\n puts \"Send Command #{command}: #{args}\"\n send_socket({command: command, args: args}.to_json)\n end", "def sendSimpleCommand _obj, _args\n \"_obj sendSimpleCommand _args;\" \n end", "def send_command( command )\n cmd = \"MESSAGET #{command.size}\\n#{command}\\n\"\n logger.debug( \">>> Sending cmd #{cmd.gsub( /\\n/, ' ' )}\" )\n \n out_socket.send( cmd , 0 )\n result = out_socket.recv(100)\n logger.debug( \"<<< Result ==> #{result}\" )\n result\n end", "def send_command(comd, value)\n cmd = \"#{@@uvctrl} -s '#{comd}' -- #{value}\"\n log_info(cmd)\n `#{cmd}`\n end", "def send_command_to_control(command, arg = \"\")\n Control.functions[__method__] ||= AU3_Function.new(\"ControlCommand\", 'SSSSSPI')\n buffer = \" \" * BUFFER_SIZE\n buffer.wide!\n Control.functions[__method__].call(@title.wide, @text.wide, @c_id.wide, command.wide, arg.to_s.wide, buffer, BUFFER_SIZE - 1)\n raise_unfound if AutoItX3.last_error == 1\n buffer.normal.strip\n end", "def transmit_command(command_str)\n \t puts \"sending command #{command_str}\"\n \t cmd_url = \"http://#{@host}/3?#{command_str}=I=3\"\n open cmd_url do |f|\n puts f.read\n end\n end", "def send_command(cmd)\n write cmd.chr\n end", "def send(command)\n @hub.send_command(command)\n end", "def send_command(command, *args)\n send_line([command.to_s, *args].join(' '))\n end", "def send_command_old(*args)\n # flatten the args, make sure each byte is between 0-0xFF, and send it.\n command_str = \"char-write-cmd 0x001b \" + args.flatten.map {|b| sprintf(\"%02X\", b & 0xFF)}.join\n # puts command_str\n @mip_writer.puts(command_str)\n \n # TODO: check to see if the reader has anything in the buffer, then read\n until @mip_reader.ready?\n sleep(1)\n end\n @response = @mip_reader.read_nonblock(1000)[command_str.length+1 .. -1]\n \n # return any response in packed byte format\n # pack_response(@mip_reader.read)\n end", "def sendCommand(cmprt, cmadr, cm_msg)\n cmstr = cm_msg\n @cmc_socket.send(cmstr, 0, cmadr, cmprt)\n end", "def send_command(command)\n # Enable the chip, set the DC line to COMMAND\n RPi::GPIO.set_low @cs\n RPi::GPIO.set_low @dc\n # Now send the command over the SPI line\n @spi.xfer(txdata: [command])\n # We're done, turn off CS\n RPi::GPIO.set_high @cs\n end", "def send(cmd)\n puts send_cmd(cmd)\n end", "def do_send(command, options = {})\n\t\t#logger.debug \"-- Sharp LCD, sending: #{command}\"\n\t\t\n\t\tcommand = command.clone\n\t\tcommand << 0x0D << 0x0A\n\t\t\n\t\tsend(command, options)\n\tend", "def send_command_to_device request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_send_command_to_device_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::Iot::V1::SendCommandToDeviceResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def send_to_vm(command)\n socket = UNIXSocket.new(socket_file)\n socket.puts(command)\n socket.close\n end", "def tell(command, params = {})\n msg_id = Random.new.rand(2**16)\n @connection.write({ method: command, params: params, id: msg_id }.to_json)\n end", "def message(command, *args)\r\n if @software.include?(command)\r\n if args.size > 0\r\n self.send(command, *args)\r\n else\r\n self.send(command)\r\n end\r\n end \r\n end", "def write_command(cmd, data='', synth=SYNTH_A)\n # Make sure cmd is valid\n raise \"unknown command #{cmd}\" unless LENGTH.has_key?(cmd)\n # Verify length of data to write\n if data.length != LENGTH[cmd]\n raise \"invalid data length for command #{cmd} \" +\n \"(expected #{LENGTH[cmd]}, got #{data.length})\"\n end\n # Make sure synth has no stray bits set\n synth &= (SYNTH_A|SYNTH_B)\n\n serialport do |sp|\n cmd = WR|synth|cmd unless cmd == CMD_WRITE_FLASH\n csum = Valon.generate_checksum(cmd.chr, data)\n cmd_data_csum = [cmd, data, csum].pack('CA*A')\n sp.write(cmd_data_csum)\n ack = sp.read(1).ord\n raise \"nak error (#{ack == NAK ? 'NAK' : ack.inspect})\" if ack != ACK\n end\n nil\n end", "def _send_command(command)\n # Create the console and get its id\n console = @client.call(\"console.create\")\n\n # Do an initial read / discard to pull out any info on the console\n # then write the command to the console\n @client.call(\"console.read\", console[\"id\"])\n @client.call(\"console.write\", console[\"id\"], \"#{command}\\n\")\n\n # Initial read\n output_string = \"\"\n output = @client.call(\"console.read\", console[\"id\"])\n output_string += \"#{output['data']}\"\n\n # Very very hacky. -- There should be a way to check\n # status of a call to make sure that it isn't in an error\n # state. For now, check the output for known error heuristics\n return output_string if output_string =~ /(\\[-\\]|Error)/\n\n # Read until finished\n while (!output.has_key?(\"result\")) do\n return unless output[\"busy\"]\n output_string += \"#{output['data']}\"\n output = @client.call(\"console.read\", console[\"id\"])\n return \"Error\" if output[\"result\"] == \"failure\"\n # A little bit of sleeping will prevent this infinite loop from\n # hogging up large portions of CPU time. It also adds load to the\n # msfrpc daemon as it will need to process these requests as wel..\n sleep 0.1\n end\n\n # Clean up console\n @client.call(\"console.destroy\", console[\"id\"])\n\n output_string\n end", "def command\n device = \"\"\n if @device != -1\n device = \"--device #{@device.to_s}\"\n end\n blocks = \"\"\n if @include_blocks\n blocks = \"--show_blocks\"\n end\n \"%s --size %d --duration %d --randsleep %s %s\" % [@executable, @input_size,\n @duration, blocks, device]\n end", "def call_out(reg_key, addr, i_reg, device_num)\n word = @computer.memory.read( get_mem_addr(addr, i_reg) )\n dev = @computer.get_device(device_num)\n dev.write(word)\n end", "def do_command\n _, cmd, _, atype, addr_length = @data.unpack(\"C5\")\n header_length = 0\n\n case atype\n when 1, 4 # 1: ipv4, 4 bytes / 4: ipv6, 16 bytes\n ip_length = 4 * atype\n host = IPAddr.ntop @data[4, ip_length]\n port = @data[4 + ip_length, 2].unpack('S>').first\n header_length = ip_length + 6\n when 3 # domain name\n host = @data[5, addr_length]\n port = @data[5 + addr_length, 2].unpack('S>').first\n header_length = addr_length + 7\n else\n panic :address_type_not_supported\n end\n\n case cmd\n when 1\n send_data reply_data(:success)\n @connection = EventMachine.connect(Config.remote_server_host, Config.remote_server_port, Connection)\n @connection.server = self\n @connection.send_encoded_data(\"#{host}:#{port}\")\n @connection.send_encoded_data(@data[header_length, -1])\n clear_data\n Fiber.yield\n when 2, 3 # bind, udp\n panic :command_not_supported\n else\n panic :command_not_supported\n end\n end", "def run_action_on_device action, devices, device_name\n if devices.empty?\n say \"Sorry, I couldn't find any devices by that name.\"\n return\n else\n if devices.length > 1\n # TODO Implement a way to ask the user which device he meant.\n #options = devices.map { |device| device.id }\n #device_id = ask \"Hey, I found more than one device by that name, please choose which \"\\\n # \"one you want to turn #{action}.\", options: options\n #device = devices.find {|device| device.id == device_id }\n\t# Have found multiple devices, so list them all out for debugging\n\tputs \"In taking action #{action}, found several devices that match, which are: \\n#{devices}\"\n device = devices[0]\n else\n device = devices[0]\n end\n end\n\n if action == 'on'\n device.on\n else\n device.off\n end\n say \"Turning #{action} #{device_name}.\"\n end" ]
[ "0.6718429", "0.65288377", "0.616005", "0.6111367", "0.6023167", "0.5968998", "0.59442085", "0.5939962", "0.589631", "0.5865999", "0.5840754", "0.58213866", "0.581998", "0.5792267", "0.576323", "0.5737349", "0.5736398", "0.5719393", "0.57139874", "0.5667166", "0.56522506", "0.56359494", "0.56332225", "0.5630312", "0.56249666", "0.5580525", "0.5579366", "0.55758786", "0.55612034", "0.5553389" ]
0.7755489
0
If the node's outputs were a glob, this checks the filesystem to figure out what files were actually generated. If it inherits the outputs of the child tasks, merge them into our own outputs.
def update_outputs! if @node.inherit_outputs? @outputs = Files::State.new(self.children_outputs) else # After the task has finished, we update the output states: @outputs.update! end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_rake_tasks\n @rake_tasks = outputs.map do |output, inputs|\n additional_paths = []\n inputs.each do |input|\n\n create_file_task(input.fullpath).dynamic do\n additional_paths += additional_dependencies(input)\n end\n end\n additional_paths.each { |path| create_file_task(path) }\n\n create_file_task(output.fullpath, inputs.map(&:fullpath)) do\n output.create { generate_output(inputs, output) }\n end\n end\n end", "def output_files\n get_info :output_files\n end", "def output_files\n @output_files ||= to_file(@args.output)\n end", "def link_outputs(task_full_name)\n <<~CODE\n python <<EOF\n import json\n import subprocess\n import re\n\n def sh(cmd, ignore_error=False):\n try:\n print cmd\n subprocess.check_call(cmd, shell=True)\n except subprocess.CalledProcessError as e:\n sys.exit(e.returncode)\n\n with open(\"#{CROMWELL_OUTPUTS_FILE}\") as f:\n cwloutputs = json.loads(f.read())['outputs']\n\n for oname, ovalue in cwloutputs.items():\n if ovalue is not None:\n sh(\"emit {} {}\".format(re.sub(\"#{task_full_name}.\", \"\", oname), ovalue))\n EOF\n CODE\n end", "def create_output_files\n return unless @option_output_path\n return if @collected_nodes.empty?\n @collected_nodes.each do |certname, properties|\n next if properties['settings'].empty?\n output_file = \"#{@option_output_path}/nodes/#{certname}.yaml\"\n File.write(output_file, properties['settings'].to_yaml)\n output(\"## Wrote Hiera YAML file: #{output_file}\\n\\n\")\n end\n return if @common_settings.empty?\n output_file = \"#{@option_output_path}/common.yaml\"\n File.write(output_file, @common_settings.to_yaml)\n end", "def generate_bolt_tasks(output_folder)\n target_folder = File.join(output_folder, 'tasks')\n FileUtils.mkpath target_folder\n\n generate_bolt_readme(output_folder)\n\n @config.bolt_tasks.each do |task|\n generate_file(\n name: \"Bolt task #{task.name} (json)\",\n task: task,\n template: 'templates/puppet/bolt~task.json.erb',\n output_folder: output_folder,\n out_file: File.join(target_folder, \"#{task.name}.json\")\n )\n\n generate_bolt_tasks_code(task, output_folder)\n end\n end", "def install_output\n namespace nsprefix do\n task output: [\n :\"#{nsprefix}:init\",\n :\"#{nsprefix}:refresh\"\n ] do |t|\n @before_proc.call(t.name, @tf_dir) unless @before_proc.nil?\n terraform_runner('terraform output')\n @after_proc.call(t.name, @tf_dir) unless @after_proc.nil?\n end\n task output_json: [\n :\"#{nsprefix}:init\",\n :\"#{nsprefix}:refresh\"\n ] do |t|\n @before_proc.call(t.name, @tf_dir) unless @before_proc.nil?\n terraform_runner('terraform output -json')\n @after_proc.call(t.name, @tf_dir) unless @after_proc.nil?\n end\n end\n end", "def concat\n content = \"\"\n files = []\n @opts[:files].each do |file|\n files += if single? file\n [\"#{@opts[:input_dir]}/#{file}.#{@opts[:type]}\"]\n else\n expand file\n end\n end\n files.each do |file|\n content << File.read(file)\n content << \"\\n\"\n end\n\n if @opts[:outputs]\n @opts[:outputs].each do |name|\n output = \"#{name}.#{@opts[:type]}\"\n local = content\n local = @opts[:filter].call(output, local) if @opts[:filter]\n File.open(output, \"w\"){ |f| f.write local.strip }\n UI.info \"Concatenated #{output}\"\n end\n else\n content = @opts[:filter].call(@output, content) if @opts[:filter]\n File.open(@output, \"w\"){ |f| f.write content.strip }\n UI.info \"Concatenated #{@output}\"\n end\n end", "def output_files\n @output_files ||= Fileset.new()\n end", "def output_files\n @output_files ||= Fileset.new\n end", "def output_files\n @output_files ||= Fileset.new\n end", "def run\n executor.run\n @files.map { |file| File.join(@output_dir, file.relative_file_name) }\n end", "def setup_outputs_for(input_file_path)\n file_name_without_extension = File.basename(input_file_path, '.*')\n outputs = (exporters || Tracksperanto.exporters).map do | exporter_class |\n export_name = [file_name_without_extension, exporter_class.desc_and_extension].join(\"_\")\n export_path = File.join(File.dirname(input_file_path), export_name)\n exporter_class.new(open_owned_export_file(export_path))\n end\n \n Tracksperanto::Export::Mux.new(outputs)\n end", "def purge_output\n Dir.glob dir(\"output/**/*\") do |item|\n next if File.directory? item\n File.delete item unless @touchedfiles.include? undir(item)\n end\n end", "def outputs\n @plugins.find_all { |p| p.is_a? BaseOutput }\n end", "def check_output_files\n return if @output_files.nil?\n\n flag = true\n @output_files.uniq.each do |file_path|\n unless File.exist?(file_path)\n warn \"Output file not found: #{file_path}\"\n flag = false\n end\n end\n puts 'All output file exist.' if flag\n end", "def files_from_generator_output(output, type = 'create')\n output.to_a.map { |line| line.scan(/#{type}\\s+([^\\s]+)$/).flatten.first }.compact.select { |f| File.exist?(f) and !File.directory?(f) }\nend", "def outputs\n @info.outputs.map {|path| @location + path}\n end", "def process_result\n require 'sass'\n\n if @options[:recursive]\n process_directory\n return\n end\n\n super\n input = @options[:input]\n if File.directory?(input)\n raise \"Error: '#{input.path}' is a directory (did you mean to use --recursive?)\"\n end\n output = @options[:output]\n output = input if @options[:in_place]\n process_file(input, output)\n end", "def gen_sub_directories\n @outputdir.mkpath\n end", "def generate_output(graph,outputs,namedOutputs)\r\n \r\n puts \"--- OUTPUT --------\" \r\n \r\n\r\n#------------------- aggiungo le risorse -------------------------\r\n # ciclo gli output per identificare nuove risorse IO\r\n outputs.each_with_index do |inline,i|\r\n fields = inline.split(',') \r\n found_job = fields[0].split('(').last\r\n io_resource = \"IO_\" + fields[1].chomp(')')\r\n \r\n #Se non é giá stata creata, aggiungo la risorsa al set a al grafo\r\n unless @InOut.include? io_resource\r\n graph.add_node(\"\\\"\" + io_resource + \"\\\"\",\"is_resourceIO\")\r\n puts \"aggiunta risorsa IO: \" + io_resource\r\n @InOut << io_resource\r\n end \r\n end\r\n \r\n#--------------------- aggiungo gli output ---------------------------- \r\n @Jobs.each do |current_job| \r\n # per ogni job ciclo i propri output\r\n outputs.each_with_index do |inline,i|\r\n \r\n fields = inline.split(',')\r\n found_job = fields[0].split('(').last\r\n io_resource = \"IO_\" + fields[1].chomp(')')\r\n\r\n # se il job da analizzare é uguale a quello letto => lo analizzo\r\n if current_job == found_job \r\n \r\n #aggiungo il nodo di output e il collegamento con la risorse IO \r\n output_name = found_job + \".\" + \"OUTPUT_\" + fields[1].chomp(')') \r\n \r\n graph.add_node(\"\\\"\" + output_name + \"\\\"\",\"is_output\")\r\n puts \"aggiunto output: \" + output_name\r\n \r\n graph.add_link(output_name,io_resource,\"\")\r\n puts \"aggiunto link: \" + \"\\\"\" + output_name + \"\\\"\" + \"->\" + io_resource\r\n \r\n # chiudo i nodi pendenti ( job per job) \r\n Close_ALL_pending_links(graph,current_job,output_name) \r\n end\r\n \r\n #------------------------- aggiungo i file name--------------------------------------------------------- \r\n # ci filename nomi customizzati\r\n unless namedOutputs.size == 0\r\n namedOutputs.each do |nameline| \r\n \r\n fields_nameline = nameline.split(',') \r\n if current_job == fields_nameline[0].split('(').last\r\n namedOutput = \"FILE_\" + fields[1].chomp(')') + \"File_\" + fields_nameline[1].chomp(')')\r\n \r\n graph.add_node(\"\\\"\" + namedOutput + \"\\\"\",\"is_file\")\r\n puts \"aggiunto output: \" + namedOutput\r\n \r\n graph.add_link(io_resource,namedOutput,\"\")\r\n puts \"aggiunto link: \" + \"\\\"\" + io_resource + \"\\\"\" + \"->\" + namedOutput \r\n end\r\n end \r\n end\r\n \r\n \r\n end #do outputs \r\n end # do jobs\r\n \r\n \r\n end", "def generate_output(inputs, output)\n inputs.each do |input|\n begin\n raise error (\"I need a file to compile\") if not input.respond_to?(:read)\n\n #puts \"tsc: #{input.path} \" << options.join(\" \")\n\n #Using compile_file because it gives us better error messages\n result = TypeScript::Node::compile_file(input.fullpath, options)\n if result.success?\n output.write(result.js)\n else\n raise result.stderr\n end\n rescue ExecJS::Error => error\n raise error, \"Error compiling #{input.path}. #{error.message}\"\n rescue RuntimeError => e\n raise e, \"Error compiling #{input.path}. #{e.message}\"\n end\n end\n end", "def create_output_directories\n return unless @option_output_path\n subdirectory = \"#{@option_output_path}/nodes\"\n return @option_output_path if File.directory?(@option_output_path) && File.directory?(subdirectory)\n Dir.mkdir(@option_output_path)\n output_path_error_and_exit(@option_output_path) unless File.directory?(@option_output_path)\n Dir.mkdir(subdirectory)\n output_path_error_and_exit(subdirectory) unless File.directory?(subdirectory)\n @option_output_path\n end", "def adjust_task_output_names_patterns(task) #:nodoc:\n local_name = task.params[:_cb_pipeline][\"0\"][:savename].presence\n global_name = task.params[:_cb_output_renaming_pattern].presence\n if local_name\n task.params[:_cb_output_renaming_pattern] = (local_name || \"\") # crush global name\n else\n task.params[:_cb_pipeline][\"0\"][:savename] = (global_name || \"\")\n end\n end", "def outputs\n @outputs || []\n end", "def populate_output_path(options = {})\n base = Pathname.new(@source_path).basename.to_s\n if options.empty?\n result = base\n else\n name, ext = *base.split(\".\")\n if options[:output_path].nil? || File.directory?(options[:output_path])\n tokens = \"\"\n MODULES.each do |mod|\n token = mod.filename_token(options)\n tokens += \"-#{token}\" unless token.nil?\n end\n result = options[:output_path].nil? ? \"\" : \"#{options[:output_path].to_s}/\"\n result += \"#{name}#{tokens}.#{ext}\"\n elsif !options[:output_path].nil?\n result = \"#{options[:output_path].to_s}.#{ext}\"\n end\n end\n @path = Pathname.new(result)\n end", "def generator_output\n return metadata[:generator_output] if metadata[:generator_output]\n \n metadata[:generator_output] = if genspec_subclass?\n superclass.generator_output\n else\n nil\n end\n end", "def out_base\n return @out_base if @out_base\n @out_base = File.join ::Rails.root, 'tmp', ::Rails.env, 'compile'\n @out_base = File.join @out_base, node.tree_parent unless node.tree_parent.empty?\n out_base\n end", "def generate_fastq\n\n # Generate FASTQ file list, expanding patterns if found.\n fastq_input_file_list = []\n fastq_output_prefix_list = []\n fastq_output_group_list = []\n ARGV.each do |fastq_input_file|\n if fastq_input_file =~ /[\\+\\?\\*]/\n # File is regexp: use it to do our own \"glob\".\n # If the regexp has at least one group in it, save the group match\n # in a corresponding list to use in making the output files.\n fastq_input_dir = File.dirname(fastq_input_file)\n fastq_input_patt = File.basename(fastq_input_file)\n\n Dir.entries(fastq_input_dir).sort().each do |entry|\n if entry =~ /#{fastq_input_patt}()/o\n fastq_input_file_list << entry\n if not @out_prefix.nil?\n fastq_output_prefix_list << @out_prefix\n else\n fastq_output_prefix_list << entry[0..Regexp.last_match.begin(1)-1-1] # Second -1 is for underline.\n end\n fastq_output_group_list << $1\n end\n end\n else\n if File.file? fastq_input_file\n fastq_input_file_list << fastq_input_file\n fastq_output_prefix_list << @out_prefix\n end\n end\n end\n\n die \"no FASTQ files found\" if fastq_input_file_list.length == 0\n\n STDERR.puts(\"Input files: #{fastq_input_file_list}\") if @verbose\n\n fastq_list = fastq_input_file_list.zip(fastq_output_prefix_list, fastq_output_group_list)\n fastq_list.each do |fastq_input_file, fastq_output_prefix, fastq_output_group|\n\n # If we are splitting to subfiles, reset the output sub filenames to\n # the new destination for the new input file; also reset statistics.\n if @save_subfiles\n if fastq_output_group == \"\"\n fastq_output_group_mod = fastq_output_group\n else\n fastq_output_group_mod = \"_#{fastq_output_group}\"\n end\n @pass_sub_filename = File.join(@pass_dir, \"#{fastq_output_prefix}_pf#{fastq_output_group_mod}.fastq\")\n @pass_sub_filename += \".gz\" if @compress\n @reject_sub_filename = File.join(@reject_dir, \"#{fastq_output_prefix}_reject#{fastq_output_group_mod}.fastq\")\n @reject_sub_filename += \".gz\" if @compress\n\n @stats_sub_filename = File.join(@stats_dir, \"#{fastq_output_prefix}_seq_stats#{fastq_output_group_mod}.txt\")\n @pass_sub_read_cnt = @reject_sub_read_cnt = @total_sub_read_cnt = 0\n end\n\n if @save_subfiles\n open_fastq_sub_output_files\n end\n\n # split one FASTQ file into post-filter and reject FASTQ\n STDERR.puts \"Processing #{fastq_input_file}...\" if @verbose\n fastq_input_fp = open_fastq_input(fastq_input_file)\n if fastq_input_fp.nil?\n warn \"#{fastq_input_file} is empty...skipping\"\n next\n end\n begin\n while fastq_input_fp.readline\n header_line = $_\n if header_line !~ /^@/\n STDERR.puts \"Missing header line (#{header_line})...exiting\"\n exit(-1)\n end\n\n header_fields = header_line.split(/[ _]/)\n die \"header parse error at #{fastq_input_file}:#{$INPUT_LINE_NUMBER} [#{header_fields.join(\"!\")}]\" if header_fields.size != 2\n\n sub_header_fields = header_fields[1].split(\":\",-1)\n die \"sub header parse error at #{fastq_input_file}:#{$INPUT_LINE_NUMBER} [#{header_fields.join(\":\")}(#{sub_header_fields.join(\":\")})]\" if sub_header_fields.size != 4\n\n @total_read_cnt += 1\n @total_sub_read_cnt += 1\n\n if sub_header_fields[1] == \"N\"\n out = @pass\n @pass_read_cnt += 1\n out_sub = @pass_sub\n @pass_sub_read_cnt += 1\n elsif sub_header_fields[1] == \"Y\"\n out = @reject\n @reject_read_cnt += 1\n out_sub = @reject_sub\n @reject_sub_read_cnt += 1\n else\n die \"filter field value error at #{fastq_input_file}:#{$INPUT_LINE_NUMBER}...skipping read\"\n out = nil\n end\n\n # Read the rest of the sequence.\n seq_line = fastq_input_fp.readline\n plus_line = fastq_input_fp.readline\n if plus_line !~ /^\\+/\n STDERR.puts \"Malformed FASTQ +line (#{plus_line})\"\n end\n qual_line = fastq_input_fp.readline\n\n # Output the sequence to whatever file was chosen above.\n if !out.nil?\n if not @remove_spaces\n out.print \"#{header_line}\"\n out_sub.print \"#{header_line}\" if not out_sub.nil?\n else\n out.puts header_fields.join(\"_\")\n out_sub.puts header_fields.join(\"_\") if not out_sub.nil?\n end\n out.print \"#{seq_line}\"\n out.print \"#{plus_line}\"\n out.print \"#{qual_line}\"\n if not out_sub.nil?\n out_sub.print \"#{seq_line}\"\n out_sub.print \"#{plus_line}\"\n out_sub.print \"#{qual_line}\"\n end\n end\n end # while\n\n rescue EOFError\n\n end\n\n fastq_input_fp.close()\n\n if @save_subfiles\n close_fastq_sub_output_files\n store_stats @stats_sub_filename, @pass_sub_read_cnt, @reject_sub_read_cnt, @total_sub_read_cnt\n end\n\n end # fastq_list.each\n end", "def generate_ansible_files\n \n # Helper to decide whether or not to generate/update a given file\n update = Proc.new do |fn, mtime|\n !(File.exists?(fn) && File.stat(fn).mtime >= mtime)\n true\n end\n\n Dir.glob('./templates/ansible.*').each do |template|\n\n # Get a template's last modified date\n source_mtime = File.stat(template).mtime \n\n # Get a destination's potential file name & path \n target_file = File.basename(template).split('.').slice(1...-1).join('.') \n target_paths = target_file.start_with?('inventory') ? ['inventory/'] : ['', 'plays/*/']\n\n # Walk destination path(s)\n target_paths.each do |target_path|\n \n Dir.glob(\"./ansible/#{target_path}\").each do |path|\n\n # Build a potential real path\n fn = File.join(File.expand_path(path), target_file) \n\n # Yield source (template file) & target if the target needs to be generated/updated\n yield template, fn if update.call(fn, source_mtime) && block_given?\n end\n end\n end\nend" ]
[ "0.61902183", "0.60885745", "0.6060476", "0.60425824", "0.6028378", "0.5927726", "0.5831355", "0.5787972", "0.57427794", "0.5717381", "0.5717381", "0.55824757", "0.557813", "0.55356634", "0.55004394", "0.54938304", "0.5447012", "0.539719", "0.5375322", "0.5365952", "0.5362394", "0.53489345", "0.5348113", "0.5308276", "0.5273182", "0.52714795", "0.52599376", "0.52572", "0.5253313", "0.523595" ]
0.6842185
0
this maps the collection of ownership patterns and owners to actual files
def ownerships(opts = {}) log("Calculating ownerships for #{opts.inspect}", opts) patowns = pattern_owners(codeowners_data(opts), opts) if opts[:no_git] files = files_to_own(opts) ownerships_by_ruby(patowns, files, opts) else ownerships_by_gitignore(patowns, opts) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def owners_contents\n files = applicable_owners_files\n\n return [] if files.nil?\n\n puts \"f: #{files.inspect}\"\n files.map { |f| f[:owners] }\n end", "def raw_git_owner_info(patterns)\n Tempfile.open('codeowner_patterns') do |file|\n file.write(patterns.join(\"\\n\"))\n file.rewind\n `cd #{current_repo_path} && git -c \\\"core.quotepath=off\\\" ls-files -z | xargs -0 -- git -c \\\"core.quotepath=off\\\" -c \\\"core.excludesfile=#{file.path}\\\" check-ignore --no-index -v -n`\n end\n end", "def applicable_owners_files_hash\n return @applicable_owners_files_hash if !@applicable_owners_files_hash.nil?\n\n # Make hash of (directory => [files in that directory in this commit]) pairs\n\n puts \"changed files: #{changed_files.inspect}\"\n\n affected_dirs_hash = changed_files.collect_to_reverse_hash do |file|\n File.dirname(file)\n end\n\n puts \"affected_dirs_hash: #{affected_dirs_hash.inspect}\"\n\n affected_dirs = affected_dirs_hash.keys\n\n # Make hash of owners file => [file1, file2, file3]\n res = affected_dirs.inject(Hash.new) do |hash, dir|\n owner = find_owners_file(dir)\n\n # If there's no OWNERS file for this dir, just skip it\n if owner.nil?\n return hash\n end\n\n data = {\n :owner_data => owner,\n :files => affected_dirs_hash[dir]\n }\n\n key = owner[:path]\n\n if (hash.include?(key))\n combined_data = hash[key]\n combined_data[:files] = combined_data[:files] + data[:files]\n\n hash[key] = combined_data\n else\n hash[key] = data\n end\n hash\n end \n\n @applicable_owners_files_hash = res\n end", "def raw_git_owner_info(patterns)\n Tempfile.open('codeowner_patterns') do |file|\n file.write(patterns.join(\"\\n\"))\n file.rewind\n `cd #{current_repo_path} && git ls-files | xargs -- git -c \\\"core.excludesfile=#{file.path}\\\" check-ignore --no-index -v -n`\n end\n end", "def possible_owners_files(dir)\n return [OwnersFileName] if dir == '.' || dir == '';\n\n [File.join([dir, OwnersFileName])] +\n possible_owners_files(File.dirname(dir))\n end", "def applicable_owners_files\n CACHE.cache_block('arb_commit/' + self.sha1 + '/' + 'applicable_owners_files', 0) do\n raise \"not in review repository\" unless exists_in_review_repository?\n\n affected_dirs = changed_files.map { |f| File.dirname(f) }.uniq\n \n owners_files = affected_dirs.\n map { |d| find_owners_file(d) }.\n reject { |d| d.nil? }.\n uniq\n end\n end", "def pattern_owners\n codeowner_path = search_codeowners_file\n patterns = []\n File.read(codeowner_path).split(\"\\n\").each_with_index { |line, i|\n path_owner = line.split(/\\s+@/, 2)\n if line.match(/^\\s*(?:#.*)?$/)\n patterns.push ['', ''] # Comment/empty line\n elsif path_owner.length != 2 || (path_owner[0].empty? && !path_owner[1].empty?)\n log \"Parse error line #{(i+1).to_s}: \\\"#{line}\\\"\"\n patterns.push ['', ''] # Invalid line\n else\n path_owner[1] = '@'+path_owner[1]\n patterns.push path_owner\n end\n }\n return patterns\n end", "def owners_by_key\n @owners_by_key ||= owners.group_by do |owner|\n key = owner[owner_key_name]\n key && key.to_s\n end\n end", "def repo_files\n @vault.sys.auths.select { |_,v| v.type == 'ldap' }\n .keys\n .inject([]) { |acc, elem| acc + group_files(elem) }\n end", "def files\n @files ||= lambda {\n sorted_relevant_files = []\n\n file_globs.each do |glob|\n current_glob_files = Pathname.glob(glob)\n relevant_glob_files = relevant_files & current_glob_files\n\n relevant_glob_files.map! do |file|\n File.new(path: file,\n namespaces: namespaces,\n decryption_keys: decryption_keys,\n encryption_keys: encryption_keys,\n signature_name: signature_name)\n end\n\n sorted_relevant_files += relevant_glob_files\n end\n\n sorted_relevant_files.uniq\n }.call\n end", "def manifested_files\n manifest_files.inject([]) do |acc, mf|\n files = File.open(mf) { |io|\n io.readlines.map do |line|\n _digest, path = line.chomp.split(/\\s+/, 2)\n decode_filename(path)\n end\n }\n\n (acc + files).uniq\n end\n end", "def manifested_files\n\n manifest_files.inject([]) do |acc, mf|\n\n files = open(mf) do |io|\n\n io.readlines.map do |line|\n digest, path = line.chomp.split /\\s+/, 2\n path\n end\n\n end\n\n (acc + files).uniq\n end\n\n end", "def get_file_groups globs\n \t\t pos = 1\n \t\t file_groups = { groups: [] }\n \t\t \n globs.each do |glob|\n # e.g { group1: { path: '*.*', files: [file1, file2]} }\n group_name = \"group#{pos}\"\n files_raw = Dir.glob(glob)\n\t\t\t\tfiles = files_raw.map do |f|\n\t \tURI.escape f\n end\n file_group_object = { name: group_name, path: glob, files: files , files_raw: files_raw}\n file_groups[group_name.to_sym] = file_group_object\n file_groups[:groups].push file_group_object\n pos += 1 \n end\n file_groups\n \t\tend", "def pattern_owners(codeowner_data, opts = {})\n patterns = []\n codeowner_data.split(\"\\n\").each_with_index do |line, i|\n stripped_line = line.strip\n if stripped_line == \"\" || stripped_line.start_with?(\"#\")\n patterns << ['', ''] # Comment / empty line\n\n elsif stripped_line.start_with?(\"!\")\n # unsupported per github spec\n log(\"Parse error line #{(i+1).to_s}: \\\"#{line}\\\"\", opts)\n patterns << ['', '']\n\n elsif stripped_line.match(CODEOWNER_PATTERN)\n patterns << [$1, $2]\n\n else\n log(\"Parse error line #{(i+1).to_s}: \\\"#{line}\\\"\", opts)\n patterns << ['', '']\n\n end\n end\n patterns\n end", "def files_map(files)\n files.\n map do |file|\n {\n id: file[:id],\n uid: file[:uid],\n title: file[\"title\"],\n path: file[:file_path],\n }\n end\n end", "def uname un\n @files = @files.select { |file| Etc.getpwuid( File.stat(file).uid ).name == un}\n self\n end", "def prepare_pod_groups\n file_accessors.each do |file_accessor|\n pod_name = file_accessor.spec.name\n next unless sandbox.local?(pod_name)\n root_name = Specification.root_name(pod_name)\n path = file_accessor.root\n group = pods_project.group_for_spec(root_name)\n group.set_path(path) unless group.path == path\n end\n end", "def files filename,attrib={}\n\t\tif has_attrib? filename \n\t\t\teval(send('form_files',filename))\n\t\telse\n\t\t\toptions = map('files',check_pattern(attrib,filename))\n\t\t\t(owner,group,mode) = pop_options(options,:owner,:group,:mode)\n\t\t\tbegin\n\t\t\t\t\t# p [filename,owner,group,mode,options]\n if options[:shell]\n\t\t\t\t \tCfruby::FileOps.shell_chown_mod filename,owner,group,mode,options\n else\n\t\t\t\t\t Cfruby::FileOps.chown_mod filename,owner,group,mode,options\n end\n options[:shell] = nil\n\t\t\trescue Cfruby::FileFind::FileExistError\n\t\t\t\tCfruby.controller.inform('verbose', \"Can not chmod on non-existing file #{filename}\")\n\t\t\tend\n\t\tend\n\tend", "def map_files\n file_map = {}\n entry_file = Pathname.new(map_entry)\n entry_found = false\n case @files\n when Hash\n @files.each do |path, file|\n file_map[path.to_s] = File.expand_path(file.to_s)\n entry_found = true if path.to_s==entry_file.to_s\n end\n else\n base_paths = @base_paths.collect {|path| Pathname.new(path).expand_path }\n @files.each do |fn|\n next unless fn\n relpath = strip_path(base_paths, fn) || fn\n file_map[relpath.to_s] = File.expand_path(fn.to_s)\n entry_found = true if relpath==entry_file\n end\n end\n file_map[entry_file.to_s] = File.expand_path(@entry_file.to_s) unless entry_found\n file_map\n end", "def add_file_accessors_paths_to_pods_group(file_accessor_key, group_key = nil, reflect_file_system_structure = false)\n file_accessors.flat_map do |file_accessor|\n paths = file_accessor.send(file_accessor_key)\n paths = allowable_project_paths(paths)\n next [] if paths.empty?\n\n pod_name = file_accessor.spec.name\n preserve_pod_file_structure_flag = (sandbox.local?(pod_name) || preserve_pod_file_structure) && reflect_file_system_structure\n base_path = preserve_pod_file_structure_flag ? common_path(paths) : nil\n actual_group_key = preserve_pod_file_structure_flag ? nil : group_key\n group = pods_project.group_for_spec(pod_name, actual_group_key)\n paths.map do |path|\n pods_project.add_file_reference(path, group, preserve_pod_file_structure_flag, base_path)\n end\n end\n end", "def by_owners\n @entries\n .group_by(&:owner)\n .map{|owner,certs| Group.new certs, owner: owner }\n .sort_by{|grp| [-grp.hosts_count, grp.owner.downcase] }\n end", "def files\n entries.map{ |f| FileObject[path, f] }\n end", "def collect(source_permissions = nil)\n real_path = full_path\n\n stat = collect_stat(real_path)\n @owner = stat.owner\n @group = stat.group\n @ftype = stat.ftype\n\n # We have to mask the mode, yay.\n @mode = stat.mode & 007777\n\n case stat.ftype\n when \"file\"\n @checksum = (\"{#{@checksum_type}}\") + send(\"#{@checksum_type}_file\", real_path).to_s\n when \"directory\" # Always just timestamp the directory.\n @checksum_type = \"ctime\"\n @checksum = (\"{#{@checksum_type}}\") + send(\"#{@checksum_type}_file\", path).to_s\n when \"link\"\n @destination = Puppet::FileSystem.readlink(real_path)\n @checksum = (\"{#{@checksum_type}}\") + send(\"#{@checksum_type}_file\", real_path).to_s rescue nil\n else\n raise ArgumentError, _(\"Cannot manage files of type %{file_type}\") % { file_type: stat.ftype }\n end\n end", "def [] files\n # This stores all our matches\n match_hash = {}\n\n # Go through each file, check if the file basename matches the regexp.\n files.each do |f|\n path, file = File.split(f)\n\n if (m = match_against(file))\n replacement = populate_based_on(m)\n match_hash[f] = if path == '.'\n replacement\n else\n File.join(path, replacement)\n end\n end\n end\n match_hash\n end", "def all_files_with_access\n return [] unless id.present?\n member_file_set_title_ids.sort { |x,y| x[0].upcase <=> y[0].upcase }\n end", "def content_files\n ns = descriptor_doc.find \"//M:file/M:FLocat/@xlink:href\", NS_PREFIX\n (ns.map { |n| URI.unescape n.value }).uniq\n end", "def has_valid_owners_for_all_files?\n num_owned_by_wlmaster = num_files_owned_by_user('wlmaster')\n num_owned_by_wluser = num_files_owned_by_user('wluser')\n num_total = num_files_total\n # if all the files are owned by either 'wlmaster' or 'wluser', then\n # num_total must be equal to the sum of num_owned_by_wlmaster and num_owned_by_wluser.\n # If this condition is not matched, that means, there is at least one file\n # or directory, which is not owned by either of them.\n num_total == (num_owned_by_wlmaster + num_owned_by_wluser)\n end", "def chown_files(tmpdir)\n notifying_block do\n Dir[\"#{tmpdir}/**/*\"].each do |path|\n declare_resource(::File.directory?(path) ? :directory : :file, path) do\n owner new_resource.user if new_resource.user\n group new_resource.group if new_resource.group\n end\n end\n end\n end", "def file_owned?(file, item)\n file.owner_item_type == item.class.name && file.owner_item_id == item.id\n end", "def tag_manifested_files\n tagmanifest_files.inject([]) do |acc, mf|\n files = File.open(mf) { |io|\n io.readlines.map do |line|\n _digest, path = line.chomp.split(/\\s+/, 2)\n path\n end\n }\n (acc + files).uniq\n end\n end" ]
[ "0.6481528", "0.6344063", "0.6334546", "0.6269659", "0.6266739", "0.61751676", "0.5767878", "0.5761254", "0.5613436", "0.558959", "0.55473715", "0.5522545", "0.5511881", "0.5499399", "0.5484818", "0.5464924", "0.5446044", "0.5429246", "0.5364181", "0.5350322", "0.5348318", "0.5344578", "0.53235304", "0.5287166", "0.52264386", "0.51957536", "0.5187862", "0.51517344", "0.5136751", "0.51288176" ]
0.6381984
1
helper stuff read the github file and spit out a slightly formatted list of patterns and their owners Empty/invalid/commented lines are still included in order to preserve line numbering
def pattern_owners(codeowner_data, opts = {}) patterns = [] codeowner_data.split("\n").each_with_index do |line, i| stripped_line = line.strip if stripped_line == "" || stripped_line.start_with?("#") patterns << ['', ''] # Comment / empty line elsif stripped_line.start_with?("!") # unsupported per github spec log("Parse error line #{(i+1).to_s}: \"#{line}\"", opts) patterns << ['', ''] elsif stripped_line.match(CODEOWNER_PATTERN) patterns << [$1, $2] else log("Parse error line #{(i+1).to_s}: \"#{line}\"", opts) patterns << ['', ''] end end patterns end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pattern_owners\n codeowner_path = search_codeowners_file\n patterns = []\n File.read(codeowner_path).split(\"\\n\").each_with_index { |line, i|\n path_owner = line.split(/\\s+@/, 2)\n if line.match(/^\\s*(?:#.*)?$/)\n patterns.push ['', ''] # Comment/empty line\n elsif path_owner.length != 2 || (path_owner[0].empty? && !path_owner[1].empty?)\n log \"Parse error line #{(i+1).to_s}: \\\"#{line}\\\"\"\n patterns.push ['', ''] # Invalid line\n else\n path_owner[1] = '@'+path_owner[1]\n patterns.push path_owner\n end\n }\n return patterns\n end", "def ExtractInfoFromFileContents file_contents\ndata = file_contents.split('|')\n# Remove the first line\n# Remove the project_name from data\n# Remove the line below project_name\ndata = data.drop(3)\n\n# Now, everything is in 3-tuple <key, value, \"\\n\">\ndata.shift\nproject_name = data.first\nproject_name = project_name.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\nrepo_url = data.first\nrepo_url = repo_url.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\nhead_sha = data.first\nhead_sha = head_sha.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\nnum_commits = data.first\nnum_commits = num_commits.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\nnum_merges = data.first\nnum_merges = num_merges.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\nreverts_msg = data.first\nreverts_msg = reverts_msg.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\nreverts_complete = data.first\nreverts_complete = reverts_complete.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\nreverts_partial = data.first\nreverts_partial = reverts_partial.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\ncps_complete = data.first\ncps_complete = cps_complete.gsub(/\\s+/, \"\")\ndata = data.drop(3)\n\ncps_partial = data.first\ncps_partial = cps_partial.gsub(/\\s+/, \"\")\ndata = data.drop(2)\n\nproject_name_repo_url_head_sha_combined = project_name + \"\\n\" + repo_url + \"\\n\" + head_sha\nreturn [project_name_repo_url_head_sha_combined, num_commits, num_merges, reverts_msg, reverts_complete, reverts_partial, cps_complete, cps_partial]\n\nend", "def raw_git_owner_info(patterns)\n Tempfile.open('codeowner_patterns') do |file|\n file.write(patterns.join(\"\\n\"))\n file.rewind\n `cd #{current_repo_path} && git ls-files | xargs -- git -c \\\"core.excludesfile=#{file.path}\\\" check-ignore --no-index -v -n`\n end\n end", "def raw_git_owner_info(patterns)\n Tempfile.open('codeowner_patterns') do |file|\n file.write(patterns.join(\"\\n\"))\n file.rewind\n `cd #{current_repo_path} && git -c \\\"core.quotepath=off\\\" ls-files -z | xargs -0 -- git -c \\\"core.quotepath=off\\\" -c \\\"core.excludesfile=#{file.path}\\\" check-ignore --no-index -v -n`\n end\n end", "def parse_repo\n matches = @source_url.match @github_regexp\n return unless matches\n owner = matches[:owner]\n name = matches[:name]\n \"#{owner}/#{name}\"\n end", "def comment_lines\n repository.files.map do |file|\n content = repository.read(file)\n content.to_s.lines.map do |line|\n first = line.strip[0]\n first = first.chr if first\n first == '#' ? 1 : 0\n end.sum\n end.sum\n end", "def list_repositories(file)\n repository_text = file.read\n int, varchar, function = self.int, self.varchar, self.function\n fields = [int, varchar, varchar, function, function]\n record_re = /#{'\\\\((' + fields.join( '),(' ) + ')\\\\)'}/\n results = []\n repository_text.scan(record_re) do |id_match, abbreviation_match, short_description_match, created_at_match, updated_at_match|\n id = Integer(id_match)\n abbreviation = abbreviation_match[1..-2]\n short_description = short_description_match[1..-2]\n created_at = created_at_match\n updated_at = updated_at_match\n #puts id_match, abbreviation_match, short_description_match, created_at_match, updated_at_match\n results << [id, abbreviation, short_description, created_at, updated_at]\n end\n results\n end", "def check_changelog\n current_repo = File.basename(`git remote get-url origin`.chomp, '.git').freeze\n slug_re = '([a-zA-Z]*/[a-zA-Z]*)'\n links = %r{\\[#{slug_re}?\\#([0-9]+)\\]\\(https://github.com/#{slug_re}/(issues|pull)/([0-9]+)\\)}\n links_typos = %r{https://github.com/#{slug_re}/(issue|pulls)/([0-9]+)}\n\n all_warnings = []\n inside_entry = false\n last_line_has_correct_ending = false\n\n File.readlines('CHANGELOG.md').each_with_index do |line, idx|\n line.chomp! # Remove \\n the end, it's easier for checks below\n was_inside_entry = inside_entry\n just_started_new_entry = line.start_with?('* ')\n inside_entry = true if just_started_new_entry\n inside_entry = false if /^ \\[.*\\]\\(.*\\)$/ =~ line # link-only line\n\n if was_inside_entry && !inside_entry && !last_line_has_correct_ending\n # We just ended an entry's description by starting the links, but description didn't end with '. '\n # Note: entry descriptions can be on multiple lines, hence the need to wait for the next line\n # to not be inside an entry to be able to consider the previous line as the end of entry description.\n all_warnings.concat [\n { line: idx, message: 'Line describing your entry should end with a period and 2 spaces.' }\n ]\n end\n # Store if current line has correct ending, for next iteration, so that if the next line isn't\n # part of the entry description, we can check if previous line ends description correctly.\n # Also, lines just linking to CHANGELOG to other repositories (StencilSwiftKit & Stencil mainly)\n # should be considered as not needing the '. ' ending.\n last_line_has_correct_ending = line.end_with?('. ') || line.end_with?('/CHANGELOG.md)')\n\n # Now, check that links [#nn](.../nn) have matching numbers in link title & URL\n wrong_links = line.scan(links).reject do |m|\n slug = m[0] || \"SwiftGen/#{current_repo}\"\n (slug == m[2]) && (m[1] == m[4])\n end\n all_warnings.concat Array(wrong_links.map do |m|\n link_text = \"#{m[0]}##{m[1]}\"\n link_url = \"#{m[2]}##{m[4]}\"\n { line: idx + 1, message: \"Link text is #{link_text} but links points to #{link_url}.\" }\n end)\n\n # Flag common typos in GitHub issue/PR URLs\n typo_links = line.scan(links_typos)\n all_warnings.concat Array(typo_links.map do |_|\n { line: idx + 1, message: 'This looks like a GitHub link URL with a typo. Issue links should use `/issues/123` (plural) and PR links should use `/pull/123` (singular).' }\n end)\n end\n all_warnings\nend", "def read(owners)\n lines = []\n File.open(@file_name, \"a+\").read.each_line do |line|\n if TodoParser.is_task?(line)\n task = TodoParser.parse_one(line, owners)\n lines << { \"local\" => task }\n else\n lines << line\n end\n end\n lines\n end", "def owners_contents\n files = applicable_owners_files\n\n return [] if files.nil?\n\n puts \"f: #{files.inspect}\"\n files.map { |f| f[:owners] }\n end", "def git_modified_lines(file)\n git_range_info_line_regex = /^@@ .+\\+(?<line_number>\\d+),/ \n git_modified_line_regex = /^\\+(?!\\+|\\+)/\n git_removed_line_regex = /^[-]/\n git_not_removed_line_regex = /^[^-]/\n file_info = git.diff_for_file(file)\n line_number = 0\n lines = []\n file_info.patch.split(\"\\n\").each do |line|\n starting_line_number = 0\n case line\n when git_range_info_line_regex\n starting_line_number = Regexp.last_match[:line_number].to_i\n when git_modified_line_regex\n lines << line_number\n end\n line_number += 1 if line_number > 0\n line_number = starting_line_number if line_number == 0 && starting_line_number > 0\n end\n lines\n end", "def parse_repo(contributors_url, str_prefix=\"\")\n puts \"#{str_prefix}reading: #{contributors_url}\"\n contributors_data = load_json(contributors_url)\n write(contributors_url, contributors_data)\n contributors_data.each do |contributor|\n parse_user(contributor['url'], str_prefix+\" \")\n end\n end", "def regex_process_commit(arr)\n message = \"\"\n filepaths = {}\n end_message_index = 0\n hash = Hash.new\n in_files = false # Have we gotten to the file portion yet? After the ;;; delimiter\n\n #index 5 should be the start\n #of the message\n (5..arr.size-1).each do |i|\n #add lines to message string if they are not identifers of lines we want to get later\n if not arr.fetch(i) =~ (/^git-svn-id:/) and\n not arr.fetch(i) =~ (/^Review URL:/) and\n not arr.fetch(i) =~ (/^BUG/) and\n not arr.fetch(i) =~ (/^R=/)\n\n #concat the message into 1\n #string\n message = message + \" \" + arr.fetch(i)\n else\n #get the last index of the \n #message, is it multiple\n #lines\n end_message_index = i\n break\n end\n end\n\n hash[:message] = message\n arr[5] = message\n\n #remove the multi line message since we condensed it\n (6..end_message_index).each do |i| \n arr.delete(i) \n end\n\n arr.each do |element|\n if fast_match(element, /^Review URL:/)\n @reviews_to_update[element[/(\\d)+/].to_i] = arr[0].strip\n\n elsif fast_match(element, /^BUG=/)\n hash[:bug] = element.strip.sub(\"BUG=\", \"\")\n\n elsif fast_match(element, /^;;;/)\n in_files = true\n\n elsif in_files and element.include?('|') # stats output needs to have a pipe\n # collect the filepath and churn count, store in the filepath hash\n split = element.split('|')\n filepaths[split[0].strip] = split[1].to_i\n \n end#if\n\n end#arr.each\n hash[\"filepaths\"] = filepaths\n \n\n return arr, hash\n\n end", "def parse_github_ids full_document\n full_document.gsub(/%github(\\d+)/) do\n # Also works for PRs becuase GH figures that out.\n url = \"https://github.com/calacademy-research/antcat/issues/#{$1}\"\n link_to \"GitHub ##{$1}\", url\n end\n end", "def pretty\n out = ''\n\n self.each do |line|\n out << line.line + ' : ' + line.commit + \"\\n\"\n out << ' ' + line.summary + \"\\n\"\n out << \" author:\\n\"\n out << ' ' + line.author + \"\\n\"\n out << ' ' + line.author_email + \"\\n\"\n out << ' @ ' + line.author_timestamp + \"\\n\"\n out << ' ' + line.author_timezone + \"\\n\"\n out << \"\\n\"\n out << \" committer:\\n\"\n out << ' ' + line.committer + \"\\n\"\n out << ' ' + line.committer_email + \"\\n\"\n out << ' @ ' + line.committer_timestamp + \"\\n\"\n out << ' ' + line.committer_timezone + \"\\n\"\n out << \"\\n\"\n end\n\n out\n end", "def process\n filename = \"index.markdown\"\n markdowns = {filename => []} \n state = :message\n message = [\"\\n\"]\n patch = []\n commit = nil\n (@gitlogp.split(\"\\n\")+[\"DONE\"]).each { |line|\n words=line.split\n if line.slice(0,1)==\" \" || words.length==0\n # commit messages start with 4 spaces, diff contents with 1 space\n if state==:message\n if words[0]==\"OUTPUT_FILE:\"\n filename = words[1]\n markdowns[filename] ||= []\n else\n message << \"#{line.slice(4..-1)}\"\n end\n else\n patch << \" #{line}\" if state==:patch\n end\n elsif words[0]==\"commit\" or words[0]==\"DONE\"\n if !commit.nil?\n # replace the short description line with a named link\n shortlog = message[2]\n message[2] = \"<a name='#{shortlog}'> </a>\"\n markdowns[filename] += message.map {|l|\n if l==\"SHOW_PATCH\"\n (patch+[\"{: .diff}\\n\"]).join(\"\\n\")\n else\n l\n end\n }\n series = tags[commit].slice(-2..-1)\n markdowns[filename] << \"\\n#{tags[commit]}: [view on github](#{@commit_link_base}#{commit}), [download #{series}-#{shortlog}.patch](#{@patch_link_base}/#{series}-#{shortlog}.patch)\\n{: .commit}\\n\"\n end\n \n message=[\"\\n\"]\n patch=[]\n\n commit = words[1]\n state = :message\n elsif [\"Author:\", \"Date:\", \"new\", \"index\", \"---\", \"+++\", '\\\\'].include?(words[0])\n # chomp\n elsif words[0]==\"diff\"\n state = :patch\n left = words[2].slice(2..-1)\n right = words[3].slice(2..-1)\n if left==right\n patch << \" ::: #{right}\"\n else\n patch << \" ::: #{left} -> #{right}\"\n end\n elsif words[0]==\"@@\"\n # git tries to put the function or class name after @@. This\n # works great for C diffs, but it only finds the class name in\n # Ruby, which is usually similar to the file name, Therefore\n # it's distracting cruft. Toss it.\n patch << \" #{words.slice(0,4).join(\" \")}\"\n else\n message << \"#{line.slice(4..-1)}\" if state==:message\n patch << \" #{line}\" if state==:patch \n end\n }\n output = {}\n markdowns.each do |fn, markdown|\n output[fn] = markdown.join(\"\\n\")\n Rails.logger.info(output[fn]) if respond_to? :Rails\n end\n return output\n end", "def parse(line)\n @pattern, *@owners = line.split(/\\s+/)\n @whitespace = line.split('@').first.count(' ') - 1\n @spec = parse_spec(@pattern)\n end", "def process_git_log_into_author_summary\n distribute_entries_to_authors( load_git_log_entries( path_to_git_repo ) )\n return prepare_rows_for_author_summary_csv\n end", "def get_issue_numbers_and_titles(section) \n issues_titles = []\n section.split(/\\n/).each do |line|\n issue = line[/\\* \\[#(.*?)\\]\\(/m, 1]\n title = line[/\\)\\: (.*?) - \\[@/m, 1].gsub(/\\\"/, \"\") # strip double quotations from pr titles\n issues_titles.push( { \"issue\" => issue, \"title\" => title } ) if issue && !issue.empty? && title && !title.empty?\n end \n return issues_titles\nend", "def check_format_rules(line_number, line)\n conventional_commit_conventions = [ 'feat(.*): ', 'fix(.*): ', 'chore(.*): ', 'install(.*): ', 'improvement(.*): ', 'ci(.*): ', 'ui(.*): ', 'style(.*): ' ] \n conventional_commit_check = conventional_commit_conventions.map{|x| line.match(x)}.compact\n errors = []\n if conventional_commit_check.empty?\n unless line.include?('HOTFIX')\n return errors << \"Error : Your commit message seems like not following conventional commit rules, please check your commit's convention\"\n end\n end\n errors << \"Error : Your commit message contains #{line.length} characters. Commit message should be less than 72 characters in length.\" if line.length > 72\n errors << \"Error : Your subject contains #{line.split(':')[1].length} characters. Subject should be less than 50 characters\" if line.split(':')[1].length > 50\n errors << \"Error : Commit message subject should start in Capital.\" if line.split(':')[1].lstrip[0] == line.split(':')[1].lstrip[0].downcase\n return errors\nend", "def check_gh_link(file)\n\n File.foreach(file).with_index do |line, line_num|\n\n # If the link is present, return nil so the next file can be parsed.\n return nil if line.match(GHLINKREGEX)\n\n # Return an error message if the 'edit on GitHub' link is not present by line number 7.\n if line_num == 7\n @errors << \"No edit link found in #{file}\"\n break\n end\n end\nend", "def process_git_log_into_summary\n distribute_entries_to_authors( load_git_log_entries( path_to_git_repo ) )\n return prepare_rows_for_summary_csv\n end", "def git_modified_lines(file)\n git_range_info_line_regex = /^@@ .+\\+(?<line_number>\\d+),/\n git_modified_line_regex = /^\\+(?!\\+|\\+)/\n file_info = git.diff_for_file(file)\n line_number = 0\n lines = []\n file_info.patch.split(\"\\n\").each do |line|\n starting_line_number = 0\n case line\n when git_range_info_line_regex\n starting_line_number = Regexp.last_match[:line_number].to_i\n when git_modified_line_regex\n lines << line_number\n end\n line_number += 1 if line_number.positive?\n line_number = starting_line_number if line_number.zero? && starting_line_number.positive?\n end\n lines\n end", "def filterRepositories\n\tEnumerator.new { |repos|\n\t\twhile (gets)\n\t\t\trepo = Repo.new\n\t\t\t$_.sub!(/\\(via.*?\\)/, '') # Remove 'via' annotation in line.\n\t\t\trepo.name, repo.type, repo.url = $_.split(/\\s+/)\n\t\t\t\n\t\t\trepo.score = 0\n\t\t\t\n\t\t\trepos << repo\n\t\tend\n\t}.group_by{|repo| repo.name}.values.each{|repoList|\n\t\tprintBest repoList\n\t}\nend", "def check_conflict_and_comment()\n results = check_conflict()\n\n results.each do |result|\n next if result[:mergeable]\n message = \"<p>This PR conflicts with <a href=\\\"#{result[:pull_request][:html_url]}\\\">##{result[:pull_request][:number]}</a>.</p>\"\n table = '<table><thead><tr><th width=\"100%\">File</th><th>Line</th></tr></thead><tbody>' + result[:conflicts].map do |conflict|\n file = conflict[:file]\n line = conflict[:line]\n line_link = \"#{result[:pull_request][:head][:repo][:html_url]}/blob/#{result[:pull_request][:head][:ref]}/#{file}#L#{line}\"\n \"<tr><td>#{file}</td><td><a href=\\\"#{line_link}\\\">#L#{line}</a></td></tr>\"\n end.join('') + '</tbody></table>'\n puts (message + table)\n warn(\"<div>\" + message + table + \"</div>\")\n end\n\n results\n end", "def split_file file\r\n lines = []\r\n has_error = false\r\n File.foreach(file).with_index do |line, line_num|\r\n line_content = line.strip\r\n if line_content.start_with? \"//\" or $ext == \".md\"\r\n line_content.sub!('//', '')\r\n sl = SourceLine.new(file, line_num + 1, line_content)\r\n has_error = sl.parse\r\n lines.push sl\r\n end\r\n end\r\n lines\r\n SourceFile.new(file, lines, has_error)\r\nend", "def parse_feed_file feed\n feed.each_line\n .reject { |line| blank?(line) || line[0] == '#' }\n .map { |line| parse_feed_line line}\nend", "def format_file(file)\n out = ''\n\n file.magic_numbers.each do |num|\n if @color\n val = red(num.value)\n line = yellow(num.line)\n path = pink(file.path)\n else\n val = num.value\n line = num.line\n path = file.path\n end\n\n out << \"#{path}:#{line} detected magic number #{val}\\n\"\n end\n\n out\n end", "def filter\n read = []\n @file.each do |line|\n line = line.strip\n if !line[0].nil? && (line[0] != '/') # if line is not comment or blank append to output\n line = line.split(' ')[0] # removes inline comments\n read.append(line)\n end\n end\n read\n end", "def comments_of_file(file)\n File.readlines(file).map { |s| s[2..-1].rstrip if s.start_with?('# ') }.compact\n end" ]
[ "0.697968", "0.6659487", "0.63301414", "0.6329259", "0.62027866", "0.59135514", "0.5814424", "0.5770643", "0.57456535", "0.57145345", "0.570866", "0.5644526", "0.56380725", "0.5622957", "0.5611697", "0.5600058", "0.5583383", "0.5574372", "0.5556163", "0.5526969", "0.5522296", "0.5480073", "0.5469945", "0.54680264", "0.5438088", "0.5435488", "0.54278445", "0.5412637", "0.5385862", "0.5340954" ]
0.73951983
0
To use a CODEOWNERS file, create a new file called CODEOWNERS in the root, docs/, or .github/ directory of the repository, in the branch where you'd like to add the code owners. if we have access to git, use that to figure out our current repo path and look in there for codeowners if we don't, this function will attempt to find it while walking back up the directory tree
def codeowners_data(opts = {}) if opts[:codeowner_data] return opts[:codeowner_data] elsif opts[:codeowner_path] return File.read(opts[:codeowner_path]) if File.exist?(opts[:codeowner_path]) elsif opts[:no_git] path = Dir.pwd.split(File::SEPARATOR) while !path.empty? POTENTIAL_LOCATIONS.each do |pl| current_file_path = File.join(path, pl) return File.read(current_file_path) if File.exist?(current_file_path) end path.pop end else path = current_repo_path POTENTIAL_LOCATIONS.each do |pl| current_file_path = File.join(path, pl) return File.read(current_file_path) if File.exist?(current_file_path) end end raise("[ERROR] CODEOWNERS file does not exist.") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def applicable_owners_files\n CACHE.cache_block('arb_commit/' + self.sha1 + '/' + 'applicable_owners_files', 0) do\n raise \"not in review repository\" unless exists_in_review_repository?\n\n affected_dirs = changed_files.map { |f| File.dirname(f) }.uniq\n \n owners_files = affected_dirs.\n map { |d| find_owners_file(d) }.\n reject { |d| d.nil? }.\n uniq\n end\n end", "def possible_owners_files(dir)\n return [OwnersFileName] if dir == '.' || dir == '';\n\n [File.join([dir, OwnersFileName])] +\n possible_owners_files(File.dirname(dir))\n end", "def raw_git_owner_info(patterns)\n Tempfile.open('codeowner_patterns') do |file|\n file.write(patterns.join(\"\\n\"))\n file.rewind\n `cd #{current_repo_path} && git ls-files | xargs -- git -c \\\"core.excludesfile=#{file.path}\\\" check-ignore --no-index -v -n`\n end\n end", "def pattern_owners(codeowner_data, opts = {})\n patterns = []\n codeowner_data.split(\"\\n\").each_with_index do |line, i|\n stripped_line = line.strip\n if stripped_line == \"\" || stripped_line.start_with?(\"#\")\n patterns << ['', ''] # Comment / empty line\n\n elsif stripped_line.start_with?(\"!\")\n # unsupported per github spec\n log(\"Parse error line #{(i+1).to_s}: \\\"#{line}\\\"\", opts)\n patterns << ['', '']\n\n elsif stripped_line.match(CODEOWNER_PATTERN)\n patterns << [$1, $2]\n\n else\n log(\"Parse error line #{(i+1).to_s}: \\\"#{line}\\\"\", opts)\n patterns << ['', '']\n\n end\n end\n patterns\n end", "def raw_git_owner_info(patterns)\n Tempfile.open('codeowner_patterns') do |file|\n file.write(patterns.join(\"\\n\"))\n file.rewind\n `cd #{current_repo_path} && git -c \\\"core.quotepath=off\\\" ls-files -z | xargs -0 -- git -c \\\"core.quotepath=off\\\" -c \\\"core.excludesfile=#{file.path}\\\" check-ignore --no-index -v -n`\n end\n end", "def initialize(args)\n @code_owner_file_location = args[:code_owner_file_location]\n end", "def pattern_owners\n codeowner_path = search_codeowners_file\n patterns = []\n File.read(codeowner_path).split(\"\\n\").each_with_index { |line, i|\n path_owner = line.split(/\\s+@/, 2)\n if line.match(/^\\s*(?:#.*)?$/)\n patterns.push ['', ''] # Comment/empty line\n elsif path_owner.length != 2 || (path_owner[0].empty? && !path_owner[1].empty?)\n log \"Parse error line #{(i+1).to_s}: \\\"#{line}\\\"\"\n patterns.push ['', ''] # Invalid line\n else\n path_owner[1] = '@'+path_owner[1]\n patterns.push path_owner\n end\n }\n return patterns\n end", "def owners_contents\n files = applicable_owners_files\n\n return [] if files.nil?\n\n puts \"f: #{files.inspect}\"\n files.map { |f| f[:owners] }\n end", "def ownerships(opts = {})\n log(\"Calculating ownerships for #{opts.inspect}\", opts)\n patowns = pattern_owners(codeowners_data(opts), opts)\n if opts[:no_git]\n files = files_to_own(opts)\n ownerships_by_ruby(patowns, files, opts)\n else\n ownerships_by_gitignore(patowns, opts)\n end\n end", "def applicable_owners_files_hash\n return @applicable_owners_files_hash if !@applicable_owners_files_hash.nil?\n\n # Make hash of (directory => [files in that directory in this commit]) pairs\n\n puts \"changed files: #{changed_files.inspect}\"\n\n affected_dirs_hash = changed_files.collect_to_reverse_hash do |file|\n File.dirname(file)\n end\n\n puts \"affected_dirs_hash: #{affected_dirs_hash.inspect}\"\n\n affected_dirs = affected_dirs_hash.keys\n\n # Make hash of owners file => [file1, file2, file3]\n res = affected_dirs.inject(Hash.new) do |hash, dir|\n owner = find_owners_file(dir)\n\n # If there's no OWNERS file for this dir, just skip it\n if owner.nil?\n return hash\n end\n\n data = {\n :owner_data => owner,\n :files => affected_dirs_hash[dir]\n }\n\n key = owner[:path]\n\n if (hash.include?(key))\n combined_data = hash[key]\n combined_data[:files] = combined_data[:files] + data[:files]\n\n hash[key] = combined_data\n else\n hash[key] = data\n end\n hash\n end \n\n @applicable_owners_files_hash = res\n end", "def source_repo\n \"#{@user}/#{@repo}\"\n end", "def source_code_dir\n '/usr/src'\n end", "def source_code_dir\n '/usr/src'\n end", "def owners_included; end", "def repo_dir; end", "def parse_repo\n matches = @source_url.match @github_regexp\n return unless matches\n owner = matches[:owner]\n name = matches[:name]\n \"#{owner}/#{name}\"\n end", "def owners=(value)\n @owners = value\n end", "def steal_username\n\t[\n\t\t# the user's .hgrc file for a username field\n\t\t['~/.hgrc', /^\\s*username\\s*=\\s*([\"'])?(.*)\\1$/, 2],\n\t\t# the user's .(g)vimrc for a changelog_username setting\n\t\t['~/.vimrc', /changelog_username\\s*=\\s*([\"'])?(.*)\\1$/, 2],\n\t\t['~/.gvimrc', /changelog_username\\s*=\\s*([\"'])?(.*)\\1$/, 2],\n\t].each do |fn, rx, idx|\n\t\tfile = File.expand_path fn\n\t\tif File.readable?(file) and File.read(file) =~ rx\n\t\t\tparse_options[:authors][user] = Regexp.last_match(idx).strip\n\t\t\tbreak\n\t\tend\n\tend\nend", "def view_code_for(user)\n results = {}\n puts \"Displaying code for #{user.cyan}\"\n CONFIG['project_files'].each do |file|\n if File.exists?(\"#{user}/#{CONFIG['project_name']}/#{file}\")\n puts \"Displaying #{file.yellow}\"\n code = File.open(\"#{user}/#{CONFIG['project_name']}/#{file}\").read\n puts code\n else\n puts \"No #{file} for #{user}\".red\n end\n end\n puts\n puts \"Displaying #{'git logs'.yellow}\"\n g = Git.open(\"#{user}\")\n g.log.each {|x| puts x.message}\n results['points'] = ask('How many points is this worth? ', Integer)\n results['notes'] = ask('Aditional notes: ').to_s\n results\n end", "def find_or_add_repository(filename, language_code)\n repository_id = find_repository(filename, language_code)\n if repository_id.nil?\n repository_id = add_repository(filename, language_code)\n end\n return repository_id\n end", "def collaborators\n @collaborators ||= get(\"/repos/show/#{owner.login}/#{name}/collaborators\")['collaborators'] || []\n end", "def add_template_repository_to_source_path\n if __FILE__ =~ %r{\\Ahttps?://}\n require 'tmpdir'\n\n source_paths.unshift(tempdir = Dir.mktmpdir(DIR_NAME + '-'))\n at_exit { FileUtils.remove_entry(tempdir) }\n run(\"git clone --quiet #{GITHUB_PATH.shellescape} #{tempdir.shellescape}\")\n\n if (branch = __FILE__[%r{#{DIR_NAME}/(.+)/bridgetown.automation.rb}, 1])\n Dir.chdir(tempdir) { system(\"git checkout #{branch}\") }\n @current_dir = File.expand_path(tempdir)\n end\n else\n source_paths.unshift(DIR_NAME)\n end\nend", "def path\n \"repos/#{@user}/#{name}\"\n end", "def locate(name)\n \"repositories/#{name}\"\n end", "def add_owner(owner_ID)\n if @owners[0] == nil\n @owners = [owner_ID]\n else\n @owners << owner_ID\n end\n end", "def add_owner(owner_ID)\n if @owners[0] == nil\n @owners = [owner_ID]\n else\n @owners << owner_ID\n end\n end", "def get_repos_by_orga(orga) \n\t\treturn self.fetch(\"repos?owner_name=#{orga}\")\n\tend", "def git_dir; end", "def set_code_dirs\n @directories[\"code_dirs\"] = %w(app lib).select { |dir| Dir.exist?(dir) }\n end", "def source\n \"#{source_repo}/#{source_branch}\"\n end" ]
[ "0.6246969", "0.62448615", "0.5823841", "0.58187634", "0.58045083", "0.56965464", "0.5683067", "0.56341493", "0.5535774", "0.5217722", "0.51736337", "0.5172623", "0.5172623", "0.50834656", "0.50177383", "0.498906", "0.49500358", "0.49301404", "0.4927886", "0.49202052", "0.48830625", "0.48821363", "0.48745733", "0.4873848", "0.48660597", "0.48660597", "0.4854335", "0.4846091", "0.48379534", "0.48228288" ]
0.69599557
0
POST /art_tags POST /art_tags.json
def create @art_tag = ArtTag.new(art_tag_params) respond_to do |format| if @art_tag.save format.html { redirect_to @art_tag, notice: 'Art tag was successfully created.' } format.json { render :show, status: :created, location: @art_tag } else format.html { render :new } format.json { render json: @art_tag.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tag!(params = {})\n self.post params, edge: :tags\n end", "def postEntityAdvertiserTag( gen_id, entity_id, language, tags_to_add, tags_to_remove)\n params = Hash.new\n params['gen_id'] = gen_id\n params['entity_id'] = entity_id\n params['language'] = language\n params['tags_to_add'] = tags_to_add\n params['tags_to_remove'] = tags_to_remove\n return doCurl(\"post\",\"/entity/advertiser/tag\",params)\n end", "def create\n @tag = Tag.new(tag_params)\n if @tag.save\n render json: @tag\n else\n render json: @tag.errors, status: :unprocessable_entity\n end\n end", "def update\n begin\n entity = Tagger::EntityTag.create_entity_tags(params)\n render json: { \"#{Tagger.tagged_resource}\": entity, tags: entity.tags }, status: 201\n rescue Exception => e\n render json: { error: \"Unprocessable entity\" }, status: 422\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n\n new_tags = params[:tags].split(',')\n\n new_tags.each do |stag|\n @event.tags.create(tag: stag)\n end\n\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @tag = Tag.new(tag_params)\r\n\r\n if @tag.save\r\n render json: @tag\r\n else\r\n render json: { error: \"Tag creating error\" }, status: :unprocessable_entity\r\n end\r\n end", "def create\n params[:tag_names].split(',').each do |name|\n @tag = Tag.find_or_create_by_name name.strip\n @tagging = Tagging.new(params[:tagging])\n @tagging.tag = @tag\n @tags_saved = @tagging.save\n end\n \n respond_to do |format|\n if @tags_saved\n format.html { redirect_to @tagging.taggable, notice: 'Tagged.' }\n format.json { render json: @tagging, status: :created, location: @tagging }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tagging.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n # special case for multiple tags\n tags = params[\"_json\"]\n if (tags.class.name == 'Array')\n Tag.delete_all\n puts \"this is an array\"\n success = true\n @tag = nil \n tags.each do |tag_hash|\n puts \"params are going from #{tag_hash} to #{tag_in_array_params(tag_hash)}\"\n @tag = Tag.new(tag_in_array_params(tag_hash))\n success &= @tag.save \n break unless success\n end\n respond_to do |format|\n if success\n format.json { render action: 'show', status: :created, location: @tag }\n else\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n return \n else \n puts \"class is #{tags.class}\"\n end\n \n @tag = Tag.new(tag_params)\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to @tag, notice: 'Tag was successfully created.' }\n format.json { render action: 'show', status: :created, location: @tag }\n else\n format.html { render action: 'new' }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n create_tags = params[:create_tags]\n\t@good = Good.new(params[:good])\n\t\n\tif @good.save\n\t\tif create_tags == '1'\n\t\t\tvalues = params[:good][:name].split(':')\n\t\t\tname = values[values.size-1]\n\t\t\tlasttag = values.size-2\n\t\t\tfor i in 0..lasttag\n\t\t\t\ttag_name = values[i]\n\t\t\t\ttag = Tag.find_or_create_by_name(tag_name)\n\t\t\t\ttag.save\n\t\t\t\tgt = GoodsTag.new(:tag=>tag,:good=>@good)\n\t\t\t\tgt.save\n\t\t\tend\n\t\tend\n\t respond_to do |format|\n\t\t\tformat.html { redirect_to :action=>\"index\" }\n\t\t\tformat.json { render :json => @good, :status => :created, :location => @good }\n\t\tend\n else\n\t\trespond_to do |format|\n\t\t\tformat.html { render :action => \"new\" }\n\t\t\tformat.json { render :json => @good.errors, :status => :unprocessable_entity }\n\t\tend\n end\n end", "def create_tags\n\tend", "def add_new_tag\n puts \"******* add_new_tag *******\"\n puts \" ** params: #{params.inspect}\"\n\n @post_id = params[:post_id]\n\n # == create brand new tag; add to Tags\n if params[:new_tag] != \"new\"\n\n # == check if tag already exists\n check_tag = Tag.where(tag_name: params[:new_tag])\n puts \" ** check_tag.length: #{check_tag.length.inspect}\"\n\n # == create new tag if not existing and assign to post\n if check_tag.length == 0\n @tag = Tag.create(tag_name: params[:new_tag], tag_rank: 0)\n @post_tag = PostTag.create(post_id: params[:post_id], tag_id: @tag[:id])\n puts \" ** NEW TAG @post_tag: #{@post_tag.inspect}\"\n end\n end\n\n # == assign existing tag if selected from select box (not \"ng\")\n if params[:tag_id] != \"ng\"\n\n # == check if tag already assigned to post\n check_tag = PostTag.where(post_id: params[:post_id], tag_id: params[:tag_id])\n puts \" ** check_tag.length: #{check_tag.length.inspect}\"\n\n if check_tag.length == 0\n @post_tag = PostTag.create(post_id: params[:post_id], tag_id: params[:tag_id])\n puts \" ** EXISTING TAG @post_tag: #{@post_tag.inspect}\"\n end\n end\n @post_tags = PostTag.where(post_id: params[:post_id])\n @post_tag_ids = @post_tags.map{|pt| pt.tag_id }\n @post_no_tags = Tag.where(\"id NOT IN (?)\", @post_tag_ids)\n @tags = Tag.where(id: @post_tag_ids)\n render json: { tags: @tags, post_no_tags: @post_no_tags, post_id: @post_id}\n end", "def add_tags(artist, album, tags)\n post(:session, {:method => \"album.addTags\", :artist => artist, :album => album, :tags => tags})\n end", "def generate_tags\n uri = URI.parse(\"https://api.thomsonreuters.com/permid/calais\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n post_body = []\n post_body << \"<Document><Body>\"\n # stip html\n post_body << ActionView::Base.full_sanitizer.sanitize(params[:desc])\n # no strip\n # post_body << params[:desc]\n post_body << \"</Body></Document>\"\n request = Net::HTTP::Post.new(uri.request_uri)\n request.add_field(\"Content-Type\",\"text/xml\")\n request.add_field(\"outputFormat\",\"application/json\")\n #request.add_field(\"outputFormat\",\"text/n3\") \n request.add_field(\"x-ag-access-token\",\"fY7WUM3GGCXHm9ATOhtzhrvlWX8oPo5X\")\n request.body = post_body.join\n # request[\"Content-Type\"] = \"multipart/form-data, boundary=#{BOUNDARY}\"\n\n render :json => http.request(request).body\n end", "def create_tags(article)\n tags_arr = []\n AlchemyAPI.key = @api_key\n a_entities = AlchemyAPI::EntityExtraction.new.search(text: article)\n a_entities.each { |e| tags_arr.push(e['text']) }\n # puts 'Alchemy concepts:'\n a_concepts = AlchemyAPI::ConceptTagging.new.search(text: article)\n a_concepts.each { |c| tags_arr.push(c['text']) }\n tags_arr\n rescue Exception => e\n Rails.logger.error { \"Tagging error: #{e}\" }\n end", "def create\n @post = Post.new(params[:post])\n\n if params['tag_field'] != nil\n tags_array = params['tag_field'].split(\",\")\n tags_array.each do |tag|\n @post.tags << Tag.find_or_create_by_etiqueta_and_post_id(tag.strip, @post.id)\n end\n end\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def tags\n @tags_with_count = Asset.tag_counts_on(:tags)\n \n @tags = @tags_with_count.map{|tag_hash| tag_hash = tag_hash.name }\n \n respond_to do |format|\n format.html\n format.json { render :json => @tags }\n end\n end", "def create\n #...\n params[:cat].permit(...:tag_ids: []) #allow tag_ids and expect it to be an Array\n end", "def create(tag)\n api_client.tags.multi_add(resource_hrefs: [api_client.get_instance.href], tags: [tag])\n end", "def create\n params[:product][:tag_ids] = Array.new\n params[:tags].split(\",\").each do |tag|\n tag_detail = Tag.where(\"title = ?\",tag).first\n if tag_detail.present?\n params[:product][:tag_ids] << tag_detail.id\n else\n new_tag = Tag.new(:title=>tag)\n new_tag.save\n params[:product][:tag_ids] << new_tag.id\n end\n end\n \n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_tags(artist, track, tags)\n post(:session, {:method => \"track.addTags\", :artist => artist, :track => track, :tags => tags})\n end", "def create_tags(article)\n tags_arr = []\n Indico.api_key = @api_key\n ind_keywords = Indico.keywords article\n ind_keywords.each { |k, _v| tags_arr.push(k) }\n ind_tags = Indico.text_tags article\n ind_tags_sorted = ind_tags.sort_by { |_k, v| -1.0 * v }.first(10).to_h\n ind_tags_sorted.each { |k, _v| tags_arr.push(k) }\n puts \"Indico tags:#{tags_arr}\"\n tags_arr\n rescue\n Rails.logger.error { 'Tagging error in Indico' }\n end", "def create\n @tag = Tag.new(params[:tag])\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to @tag, notice: 'Tag dodany do bazy tagów' }\n format.json { render json: @tag, status: :created, location: @tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @article = Article.new(params[:article])\n tags_str = params[:article].delete(:tag_list)\n @article.tag_list = tags_str\n \n \n respond_to do |format|\n if @article.save\n format.html { redirect_to @article, notice: 'Article was successfully created.' }\n format.json { render json: @article, status: :created, location: @article }\n else\n format.html { render action: \"new\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def postEntityTag( entity_id, tag, language)\n params = Hash.new\n params['entity_id'] = entity_id\n params['tag'] = tag\n params['language'] = language\n return doCurl(\"post\",\"/entity/tag\",params)\n end", "def create\n # parsing tags from string to array, spliting using comma and trimming\n article_params = params[:article]\n article_params[\"tags\"] = string_to_array article_params[\"tags_string\"]\n\n @article = Article.new(article_params)\n\n respond_to do |format|\n if @article.save\n format.html { redirect_to @article, notice: 'Article was successfully created.' }\n format.json { render json: @article, status: :created, location: @article }\n else\n format.html { render action: \"new\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @artist_tag = ArtistTag.new(params[:artist_tag])\n\n respond_to do |format|\n if @artist_tag.save\n format.html { redirect_to artist_tags_path, notice: 'Artist tag was successfully created.' }\n format.json { render json: @artist_tag, status: :created, location: @artist_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @artist_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def create \n @idea = Idea.new(idea_params)\n @idea.user_id = current_user.id\n @idea.save!\n if params[:idea][:tags]\n params[:idea][:tags].each do |new_tag|\n tag_title = new_tag[:title]\n tag = Tag.find_by title: tag_title\n if tag.present?\n tag.used = tag.used + 1\n tag.save!\n else\n tag = Tag.new\n tag.title = tag_title.downcase\n tag.used = 1 \n tag.save!\n end\n @idea.tags << tag\n end\n end\n Notification.generate(current_user, @idea)\n Notification.push(@idea) \n render json: @idea.to_json(include: [{user: {only: [:name, :id, :image_url]}}, {comments: {include: {user: {only: [:name, :image_url]}}}}], methods: [:voted])\n end", "def create\n @api_tag = Api::Tag.new(params[:api_tag])\n\n respond_to do |format|\n if @api_tag.save\n format.html { redirect_to @api_tag, notice: 'Tag was successfully created.' }\n format.json { render json: @api_tag, status: :created, location: @api_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @api_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tag = Tag.new(params[:tag])\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to tags_url, :notice => 'Tag was successfully created.' }\n format.json { render :json => @tag, :status => :created, :location => @tag }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @tags_of_novel = TagsOfNovel.new(params[:tags_of_novel])\n\n respond_to do |format|\n if @tags_of_novel.save\n format.html { redirect_to @tags_of_novel, notice: 'Tags of novel was successfully created.' }\n format.json { render json: @tags_of_novel, status: :created, location: @tags_of_novel }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tags_of_novel.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7240396", "0.67703766", "0.6641631", "0.65967894", "0.6569093", "0.6504169", "0.640354", "0.63740045", "0.6372033", "0.6365447", "0.6328999", "0.63249576", "0.62712634", "0.6266826", "0.6252997", "0.62510777", "0.6250392", "0.62453896", "0.62378365", "0.6221187", "0.6219527", "0.621231", "0.61943245", "0.61894494", "0.61710364", "0.61686426", "0.6161748", "0.61422366", "0.6111954", "0.6103849" ]
0.68982446
1
PATCH/PUT /art_tags/1 PATCH/PUT /art_tags/1.json
def update respond_to do |format| if @art_tag.update(art_tag_params) format.html { redirect_to @art_tag, notice: 'Art tag was successfully updated.' } format.json { render :show, status: :ok, location: @art_tag } else format.html { render :edit } format.json { render json: @art_tag.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n begin\n entity = Tagger::EntityTag.create_entity_tags(params)\n render json: { \"#{Tagger.tagged_resource}\": entity, tags: entity.tags }, status: 201\n rescue Exception => e\n render json: { error: \"Unprocessable entity\" }, status: 422\n end\n end", "def modify_tag tag\n data = {\n \"tag\" => params\n }\n temp = data[\"servers\"]\n data[\"servers\"] = { \"server\" => temp }\n\n json = JSON.generate data\n\n response = put \"tag/#{tag}\", json\n return response unless response.code == 200\n\n body = JSON.parse response.body\n body[\"tag\"]\n end", "def update\n if @tag.update(tag_params)\n render json: @tag\n else\n render json: @tag.errors, status: :unprocessable_entity\n end\n end", "def update\n update_and_respond(@tag, tag_params)\n end", "def update\n @api_tag = Api::Tag.find(params[:id])\n\n respond_to do |format|\n if @api_tag.update_attributes(params[:api_tag])\n format.html { redirect_to @api_tag, notice: 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @api_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n render json: @tag.errors unless @tag.update(tag_params)\n end", "def update\n authorize @ticket\n @ticket.tag_list.add @tags\n if @ticket.save\n render :json => @ticket.reload.tags\n else\n error!(:invalid_resource, @ticket.errors, \"Tags have not been saved\")\n end\n end", "def update\n @joke = Joke.find(params[:id])\n\n respond_to do |format|\n str_tags = params[:joke][:tags].split(',')\n @tags = str_tags.map {|tag_name|\n Tag.find_or_create_by_name(tag_name)\n }\n @joke.tags = @tags\n \n if @joke.update_attributes(params[:joke].except(:tags))\n format.html { redirect_to @joke, :notice => 'Joke was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @joke.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n # creates tag objects for photos\n tag_array = tag_params['tags'].split(',').each do |x|\n x.strip!\n end\n tag_array.each do |x| \n if Tag.find_by(name: x)\n @tag = Tag.find_by(name: x)\n else\n @tag = Tag.create(name: x)\n end\n Tagging.create(photo_id: @photo.id, tag_id: @tag.id)\n end\n\n respond_to do |format|\n if @photo.update(photo_params)\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { render :show, status: :ok, location: @photo }\n else\n format.html { render :edit }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @artist_tag = ArtistTag.find(params[:id])\n\n respond_to do |format|\n if @artist_tag.update_attributes(params[:artist_tag])\n format.html { redirect_to @artist_tag, notice: 'Artist tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @artist_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @task.tags.each { |t| t.delete}\n\n respond_to do |format|\n if @task.update(task_params)\n create_multiple_tags(task_params[\"tag\"], @task.id)\n\n format.html { redirect_to @task.list, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @entity_tag = EntityTag.find(params[:id])\n\n respond_to do |format|\n if @entity_tag.update_attributes(params[:entity_tag])\n format.html { redirect_to @entity_tag, notice: 'Entity tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entity_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tag = Tag.find(params[:id])\n respond_to do |format|\n if @tag.update(tag_params)\n format.json { render :show, status: :ok, location: @tag }\n else\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize @organization\n @organization.tag_list.add @tags\n if @organization.save\n render :json => @organization.reload.tags\n else\n error!(:invalid_resource, @organization.errors, \"Tags have not been saved\")\n end\n end", "def update\n @tag = Tag.find(params[:id])\n\n if @tag.update_attributes(params[:tag])\n render json: JSON.parse(@tag.to_json)\n else\n render json: JSON.parse(@tag.errors.to_json)\n end\n end", "def update\n\n if params[:tags].nil?\n @question.tags = []\n else\n @question.tags = Tag.find(params[:tags])\n end\n\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to admin_question_path(@question), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tags_of_novel = TagsOfNovel.find(params[:id])\n\n respond_to do |format|\n if @tags_of_novel.update_attributes(params[:tags_of_novel])\n format.html { redirect_to @tags_of_novel, notice: 'Tags of novel was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tags_of_novel.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @post = Post.find(params[:id])\n @tagarr = params[:post][\"tags_attributes\"][\"0\"][:name].split(\" \")\n puts @tagarr\n @tag = {}\n @tagarr.each_with_index do |tag,i|\n @tag[i] = {:name =>tag}\n end\n\n @tagreset = params[:post]\n @tagreset[\"tags_attributes\"] ={}\n @tagreset[\"tags_attributes\"] = @tag\n @post.tags=[]\n #puts @tagreset\n #render :layout => false\n respond_to do |format|\n if @post.update_attributes(@tagreset)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n params[:product][:tag_ids] = Array.new\n params[:tags].split(\",\").each do |tag|\n tag_detail = Tag.where(\"title = ?\",tag).first\n if tag_detail.present?\n params[:product][:tag_ids] << tag_detail.id\n else\n new_tag = Tag.new(:title=>tag)\n new_tag.save\n params[:product][:tag_ids] << new_tag.id\n end\n end\n \n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tag = Tag.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to tags_url, :notice => 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n tag = Tag.find_by_id(params[:id])\n if tag.update(params.permit(:name))\n render json: tag, status: :ok\n else\n respond_with tag.errors, status: :unprocessable_entity\n end\n end", "def update\n @tag = Tag.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to @tag, :notice => 'Tag was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @asset = Asset.find(params[:asset_id])\n @tag = @asset.tags.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to(asset_manager_asset_tags_path(@tag.asset_id), :notice => 'Tag was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => :new }\n format.xml { render :xml => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @tag = Tag.find(params[:id])\n \n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to @tag, notice: 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @tags = args[:tags] if args.key?(:tags)\n end", "def update!(**args)\n @tags = args[:tags] if args.key?(:tags)\n end", "def update\n tags = equipment_params[:tags]\n\n tags_object_collection = []\n\n tags.each do |tag|\n if tag == ''\n next\n end\n\n tag_obj = Tag.find(tag)\n\n if tag_obj != nil\n tags_object_collection.push(tag_obj)\n end\n end\n\n new_equipment_params = equipment_params.except(:tags)\n\n @equipment = Equipment.find(params[:id])\n @equipment.tags = tags_object_collection\n\n respond_to do |format|\n if @equipment.update_attributes(new_equipment_params)\n format.html { redirect_to equipment_index_path, notice: 'Equipment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @equipment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to @tag, notice: 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n \t# update tags\n \t@question.tag_with(params[:question][:tag_list])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tag = Tag.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n format.html { redirect_to @tag, notice: 'Tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6962989", "0.67886025", "0.66820383", "0.661751", "0.6571411", "0.65701026", "0.65183216", "0.64894754", "0.64203614", "0.6415638", "0.6406275", "0.63783765", "0.63159287", "0.6301376", "0.6282384", "0.6267339", "0.62638336", "0.62607497", "0.62568074", "0.6243805", "0.6225699", "0.6224552", "0.6221203", "0.62027967", "0.6195327", "0.6195327", "0.6181043", "0.61716264", "0.61596644", "0.613621" ]
0.68936586
1
DELETE /art_tags/1 DELETE /art_tags/1.json
def destroy @art_tag.destroy respond_to do |format| format.html { redirect_to art_tags_url, notice: 'Art tag was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_tag tag\n delete \"tag/#{tag}\"\n end", "def deleteEntityTag( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/tag\",params)\n end", "def delete(tag)\n api_client.tags.multi_delete(resource_hrefs: [api_client.get_instance.href], tags: [tag])\n end", "def destroy\n @api_tag = Api::Tag.find(params[:id])\n @api_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to api_tags_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n \n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :ok }\n end\n\n end", "def destroy\n # @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asset_tag = AssetTag.find(params[:id])\n @asset_tag.destroy\n render json: {}\n \n end", "def destroy\n @quotetags = Quotetags.find(params[:id])\n @quotetags.destroy\n\n respond_to do |format|\n format.html { redirect_to(quotetags_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n render json: JSON.parse({msg:\"success\"}.to_json)\n end", "def destroy\n @tags_of_novel = TagsOfNovel.find(params[:id])\n @tags_of_novel.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_of_novels_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @artist_tag = ArtistTag.find(params[:id])\n @artist_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to artist_tags_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tag = Tag.find(params[:id])\n respond_to do |format|\n if @tag.destroy\n format.json { render json: {:id => @tag.id}, status: :ok }\n else\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n get_status\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :ok }\n end\n end", "def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :ok }\n end\n end", "def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :ok }\n end\n end", "def destroy\n @tag = Tag.find(params[:id])\n\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end", "def delete()\n\n client.delete(\"/tags/#{gid}\") && true\n end", "def destroy\n @ad_tag = AdTag.find(params[:id])\n @ad_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to ad_tags_url }\n format.json { head :ok }\n end\n end", "def destroy\n @tag.destroy\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @posttag = Posttag.find(params[:id])\n @posttag.destroy\n\n respond_to do |format|\n format.html { redirect_to posttags_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @article = article_get(params[:id])\n @article.destroy\n #Rails.logger.debug \"Deleting tags #{@article.send(:taggings).destroy!}\"\n #Rails.logger.debug \"Deleting article? #{@article.destroy!}\"\n respond_with(@article)\n end", "def destroy\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tagging.destroy\n respond_to do |format|\n format.html { redirect_to taggings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n\n end", "def destroy\n @asset = Asset.find(params[:asset_id])\n @tag = @asset.tags.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(asset_manager_asset_tags_path(@asset)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @tag_collection = TagCollection.find(params[:id])\n @tag_collection.destroy\n render json: {}\n \n end", "def destroy\n @tag_ref.destroy\n respond_to do |format|\n format.html { redirect_to tag_refs_url, notice: 'Usunięto Tag z artykułu.' }\n format.json { head :no_content }\n end\n end", "def delete\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(tags_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @tagg = Tagg.find(params[:id])\n @tagg.destroy\n\n respond_to do |format|\n format.html { redirect_to taggs_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7277975", "0.72362167", "0.7211264", "0.7196518", "0.71165353", "0.7075563", "0.70714647", "0.70547533", "0.70513666", "0.7049769", "0.7034731", "0.70232165", "0.70160204", "0.7001642", "0.7001642", "0.7001642", "0.6985803", "0.6981432", "0.6969298", "0.6961142", "0.6960065", "0.6959248", "0.6953408", "0.6949585", "0.694901", "0.69486654", "0.69281006", "0.6922854", "0.69194597", "0.6883806" ]
0.73651093
0
POST /contributors POST /contributors.json
def create @contributor = Contributor.new(contributor_params) if @contributor.save render :show, status: :created, location: @contributor else render json: @contributor.errors, status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_contributors\n @hash[:contributors].each do |json_contrib|\n my_hash = json_contrib.slice('contributor_name', 'contributor_type', 'created_at', 'updated_at', 'award_number')\n @ar_resource.contributors << StashDatacite::Contributor.create(my_hash)\n # btw affiliations for contributors are not really used in Dash data, so skipping that headache, though we have some test data for it\n end\n end", "def contributors=(value)\n @contributors = value\n end", "def contributor_params\n params.require(:contributor).permit(:first_name, :last_name, :email, :password)\n end", "def contributor_params\n params.require(:contributor).permit(:name, :email, :zip)\n end", "def index\n @contributors = Contributor.all\n end", "def create\n @open_source_contributor = OpenSourceContributor.new(open_source_contributor_params)\n\n respond_to do |format|\n if @open_source_contributor.save\n format.html { redirect_to @open_source_contributor, notice: 'Open source contributor was successfully created.' }\n format.json { render :show, status: :created, location: @open_source_contributor }\n else\n format.html { render :new }\n format.json { render json: @open_source_contributor.errors, status: :unprocessable_entity }\n end\n end\n end", "def contributor_params\n params.require(:contributor).permit(:id, :contributor_name, :contributor_type, :name_identifier_id,\n :affiliation_id, :award_number, :resource_id)\n end", "def create\n if current_contributor\n redirect_to articles_path\n else\n contributor = params.require(:contributor).permit(:first_name , :last_name, :email, :password)\n @contributor = Contributor.new(contributor)\n if @contributor.valid?\n @contributor.save\n session[:contributor_id] = @contributor.id\n redirect_to articles_path\n # UserNotifier.send_signup_email(@contributor).deliver\n else\n render :new\n end\n end\n end", "def add_contributor\n end", "def contributor_params\n params.require(:contributor).permit(:company_id, :user_id)\n end", "def destroy\n @contributor.destroy\n respond_to do |format|\n format.html { redirect_to contributors_url, notice: 'Contributor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def add_authors\n text = params[:text]\n puts \"str:#{text}\"\n request = Net::HTTP::Post.new(\"/personality-api/1/add_authors.json\")\n request.basic_auth BmnPersonalityApiSkeletonRor::Application.config.user_name, BmnPersonalityApiSkeletonRor::Application.config.password\n request.set_form_data({ :text => text\n })\n logger.debug(\"request #{request}\");\n response = @http.request(request)\n render :text => response.body\n\n end", "def create\n @author = Author.new(params[:author])\n @author.user = @user\n @country = Country.find(params[:author][:country_id])\n respond_to do |format|\n if @author.save\n format.html { redirect_to country_author_path(@country.name,@author), :notice => 'Author was successfully created.' }\n format.json { render :json => @author, :status => :created, :location => @author }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @author.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @maintainer = Maintainer.new(maintainer_params)\n\n respond_to do |format|\n if @maintainer.save\n format.html { redirect_to @maintainer, notice: 'Maintainer was successfully created.' }\n format.json { render :show, status: :created, location: @maintainer }\n else\n format.html { render :new }\n format.json { render json: @maintainer.errors, status: :unprocessable_entity }\n end\n end\n end", "def deserialize_contributors(plan:, json: {})\n contributors = json.fetch(:contributor, []).map do |hash|\n Api::V2::Deserialization::Contributor.deserialize(json: hash)\n end\n plan.contributors << contributors.compact.uniq if contributors.any?\n plan\n end", "def parse_repo(contributors_url, str_prefix=\"\")\n puts \"#{str_prefix}reading: #{contributors_url}\"\n contributors_data = load_json(contributors_url)\n write(contributors_url, contributors_data)\n contributors_data.each do |contributor|\n parse_user(contributor['url'], str_prefix+\" \")\n end\n end", "def create\n @contributor_address = ContributorAddress.new(params[:contributor_address])\n\n respond_to do |format|\n if @contributor_address.save\n format.html { redirect_to @contributor_address, notice: 'Contributor address was successfully created.' }\n format.json { render json: @contributor_address, status: :created, location: @contributor_address }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contributor_address.errors, status: :unprocessable_entity }\n end\n end\n end", "def list_contributors(contributors, tutorial)\n contributors_list = []\n contributors.each do |contributor|\n contributors_list.push User.find_by_id(contributor.member_id).name\n end\n contributors_list.delete(tutorial.author.name)\n contributors_list\n end", "def set_contributor\n @contributor = Contributor.find(params[:id])\n end", "def set_contributor\n @contributor = Contributor.find(params[:id])\n end", "def set_contributor\n @contributor = Contributor.find(params[:id])\n end", "def update\n respond_to do |format|\n if @contributor.update(contributor_params)\n format.html { redirect_to @contributor, notice: 'Contributor was successfully updated.' }\n format.json { render :show, status: :ok, location: @contributor }\n else\n format.html { render :edit }\n format.json { render json: @contributor.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @references_author = References::Author.new(references_author_params)\n\n respond_to do |format|\n if @references_author.save\n format.html { redirect_to @references_author, notice: 'Author was successfully created.' }\n format.json { render action: 'show', status: :created, location: @references_author }\n else\n format.html { render action: 'new' }\n format.json { render json: @references_author.errors, status: :unprocessable_entity }\n end\n end\n end", "def open_source_contributor_params\n params.require(:open_source_contributor).permit(:first_name, :last_name, :url, :email, :gravatar_username)\n end", "def create\n Author.create(\n name: params[:name],\n dob: params[:dob],\n gender: params[:gender],\n has_pseudonym: params[:has_pseudonym])\n redirect_to '/authors'\n end", "def create\r\n @contribution = Contribution.new(contribution_params)\r\n @contribution.contributable_type = \"Book\"\r\n @contribution.person = @person\r\n\r\n respond_to do |format|\r\n if @contribution.save\r\n format.html { redirect_to person_contributions_path(@person), notice: 'Contribution was successfully created.' }\r\n format.json { render action: 'show', status: :created, location: person_contributions_path(@contribution) }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @contribution = Contribution.new(contribution_params)\n session[:contributor] = @contribution.contributor\n session[:email] = @contribution.email\n\n respond_to do |format|\n if @contribution.save\n format.html { redirect_to contributions_url, notice: '投稿しました' }\n format.json { render :index, status: :created, location: @contribution }\n else\n @contributions = Contribution.order(\"id DESC\").page params[:page]\n format.html { render :index }\n format.json { render json: @contribution.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @document = Document.new(params[:document].merge({:updated_by => current_user}))\n\n respond_to do |format|\n if @document.save\n @document.add_contributor! current_user\n format.html { redirect_to edit_admin_document_path(@document), notice: '<strong>Awesome!</strong> The document was successfully created.' }\n format.json { render json: @document, status: :created, location: @document }\n else\n format.html { render action: \"new\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n resp = Faraday.post('https://api.github.com/user/repos') do |req|\n req.body = {'name': params[:name]}.to_json\n req.headers['Authorization'] = 'token ' + session[:token]\n req.headers['Accept'] = 'application/json'\n end\n redirect_to '/'\n end", "def create\n \n# next line commented out and following line added 2 aug 17 for connecting users to people (step 17)\n# Person.create(person_params)\n current_user.people.create(person_params) # check nomster/flixter code in this area\n\n redirect_to new_person_path # change to redirect to page showing person created, maybe entire tree\n end" ]
[ "0.6670093", "0.62659705", "0.6239934", "0.6198608", "0.6186133", "0.6163758", "0.6139115", "0.6017873", "0.6003645", "0.5986704", "0.57870245", "0.5784634", "0.57396066", "0.57388324", "0.5733809", "0.57124615", "0.56854373", "0.5678733", "0.5663967", "0.5663967", "0.5663967", "0.56291", "0.5599177", "0.55860454", "0.5563542", "0.5557051", "0.5514159", "0.549808", "0.54912096", "0.5483367" ]
0.7071534
0
GET /perform_backups GET /perform_backups.json
def index @perform_backups = PerformBackup.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_backups(site_id, datum = nil)\n current_path = \"/api/v1/sites/#{site_id}/backups\"\n pb = SFRest::Pathbuilder.new\n @conn.get URI.parse(pb.build_url_query(current_path, datum)).to_s\n end", "def backups\n if args.count == 0\n list_backups\n else\n command = shift_argument\n case command\n when 'list' then list_backups\n when 'info' then backup_status\n when 'capture' then capture_backup\n when 'restore' then restore_backup\n when 'public-url' then public_url\n when 'cancel' then cancel_backup\n when 'delete' then delete_backup\n when 'schedule' then schedule_backups\n when 'unschedule' then unschedule_backups\n when 'schedules' then list_schedules\n else abort \"Unknown pg:backups command: #{command}\"\n end\n end\n end", "def list_backups request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_backups_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::Metastore::V1::ListBackupsResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def get_backups_list(backup_name)\n logger.info \"Getting the list of backups from FTP: #{worker.user_host_and_dir}\"\n @worker.get_files_list backup_name\n end", "def index\n #@backups = Backup.all\n @backups = current_user.backups\n end", "def perform_backup\n \n add_memories_to_dropbox! if has_dropbox?\n\n # Clone the repo incase something is writing to it while we are backing up\n run \"cd #{@home} && git clone --bare #{@repo} #{@repo}.mirror\"\n output=run \"backup perform --trigger=daily_backup --log-path #{@dirs[:logs ]}\"\n run \"cd #{@home} && rm -fr #{@repo}.mirror\"\n \n get_timestamp(output)\n end", "def cmd_backup argv\n setup argv\n command = @hash['command']\n name = @hash['name']\n response = @api.backup(command, name)\n msg response\n return response\n end", "def restore\n p \"Doing a restore ...\"\n params = {:instance_href => \"/api/clouds/907/instances/#{@instance2_id}\"}\n id = @test_client.backups.index(:lineage => \"ns_backup_test_lineage\").first.show.href.split(\"/\")[-1] # => to get the id\n task = @test_client.backups(:id => id).show.restore(params)\n return task\nend", "def describe_backups(d_b_instance_id, end_time, start_time, optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'DescribeBackups'\n\t\targs[:query]['DBInstanceId'] = d_b_instance_id\n\t\targs[:query]['EndTime'] = end_time\n\t\targs[:query]['StartTime'] = start_time\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :_scheme\n\t\t\traise ArgumentError, '_scheme must be http|https' unless 'http|https'.split('|').include? optional[:_scheme]\n\t\t\targs[:scheme] = optional[:_scheme]\n\t\tend\n\t\tif optional.key? :backup_id\n\t\t\targs[:query]['BackupId'] = optional[:backup_id]\n\t\tend\n\t\tif optional.key? :backup_location\n\t\t\targs[:query]['BackupLocation'] = optional[:backup_location]\n\t\tend\n\t\tif optional.key? :backup_mode\n\t\t\targs[:query]['BackupMode'] = optional[:backup_mode]\n\t\tend\n\t\tif optional.key? :backup_status\n\t\t\targs[:query]['BackupStatus'] = optional[:backup_status]\n\t\tend\n\t\tif optional.key? :owner_account\n\t\t\targs[:query]['OwnerAccount'] = optional[:owner_account]\n\t\tend\n\t\tif optional.key? :owner_id\n\t\t\targs[:query]['OwnerId'] = optional[:owner_id]\n\t\tend\n\t\tif optional.key? :page_number\n\t\t\traise ArgumentError, 'page_number must be equal or greater than 1' unless optional[:page_number] < 1\n\t\t\traise ArgumentError, 'page_number must be equal or less than 2147483647' unless optional[:page_number] > 2147483647\n\t\t\targs[:query]['PageNumber'] = optional[:page_number]\n\t\tend\n\t\tif optional.key? :page_size\n\t\t\traise ArgumentError, 'page_size must be equal or greater than 30' unless optional[:page_size] < 30\n\t\t\traise ArgumentError, 'page_size must be equal or less than 100' unless optional[:page_size] > 100\n\t\t\targs[:query]['PageSize'] = optional[:page_size]\n\t\tend\n\t\tif optional.key? :resource_owner_account\n\t\t\targs[:query]['ResourceOwnerAccount'] = optional[:resource_owner_account]\n\t\tend\n\t\tif optional.key? :resource_owner_id\n\t\t\targs[:query]['ResourceOwnerId'] = optional[:resource_owner_id]\n\t\tend\n\t\tself.run(args)\n\tend", "def create_ebs_backup(options = {})\n params = options.merge( { :commit => \"explicit\", :api_version => 1.0 } )\n STDERR.puts \"Performing RightScale API call to create a new snapshot\"\n json=nil\n SystemTimer.timeout_after(@api_snap_timeout) do\n body = RestClient.post @api_url+\"/create_ebs_backup.js\", params\n json = body.nil? ? nil: JSON.load(body)\n STDERR.puts \"CREATED_SNAPS: #{json}\"\n end\n json \n rescue Exception => e\n display_exception(e, \"create_ebs_backup(#{options.inspect})\")\n end", "def run_backups\n puts \"Starting backups...\" if options[:verbose]\n for database in database_list\n Dir.chdir(temp_directory)\n name, user, pass = database.split(\",\")\n password = pass.strip.empty? ? '' : \"-p#{pass.strip}\"\n tgz_filename = \"#{name}.#{DATE}.#{TIME}.tgz\"\n # stop the slave if necessary\n puts \"Stopping the slave...\" if options[:verbose] && options[:slave]\n `mysql -u #{user} #{password} --execute='stop slave;'` if options[:slave]\n \n # switch to the current database and backup each table\n tables = `echo 'show tables' | mysql -u #{user} #{password} #{name} | grep -v Tables_in_`\n for table in tables\n table.strip!\n puts \"Backing up table #{table}...\" if options[:verbose]\n filename = \"#{table}.#{DATE}.#{TIME}.sql\"\n `mysqldump --add-drop-table --allow-keywords -q -c -u #{user} #{password} #{name} #{table} > #{filename}`\n end\n \n # restart the slave if necessary\n puts \"Restarting the slave...\" if options[:verbose] && options[:slave]\n `mysql -u #{user} #{password} --execute='start slave;'` if options[:slave]\n \n # zip it up and move it to the backup directory\n puts \"Completed backups, zipping it up...\" if options[:verbose]\n `tar -zcvf #{backup_directory}/#{tgz_filename} *`\n puts \"Cleaning up...\" if options[:verbose]\n Dir.chdir(backup_directory)\n `rm -rf #{temp_directory}`\n \n # copy it to any remote hosts if needed\n scp_results(tgz_filename) unless scp_hosts.empty?\n puts \"And we're done!\" if options[:verbose]\n end\n end", "def backup\n run_command 'pgbackups:capture', %W(--expire #{database})\n end", "def system_backup\n\n\n end", "def execute_backup_stripe(options={})\n @disk.sync\n\n# Ensure filesystem is frozen and uses retry\n raise \"FATAL: unable to freeze lvm filesystem!\" unless @disk.freeze\n\n create_opts = {\n :lineage => options[:lineage],\n :prefix_override => options[:lineage], #Make sure we use the volume_nickname \"lineage\" as the prefix for our snaps (even if the volume has a different, perhaps more descriptive name)\n :description => \"Snapshot created by RightScale DB tools on instance #{ENV['EC2_INSTANCE_ID']}.\",\n :max_snaps => options[:max_snapshots],\n :keep_dailies => options[:keep_dailies],\n :keep_weeklies => options[:keep_weeklies],\n :keep_monthlies => options[:keep_monthlies],\n :keep_yearlies => options[:keep_yearlies],\n :devices => options[:devices].join(\",\")\n }\n create_opts[:suffix] = options[:suffix] if options[:suffix]\n\n # TODO: retry on the http requests? sounds like a good idea to me\n result = self.create_ebs_backup(create_opts)\n raise \"FATAL: unable to create snapshots!\" if result.nil?\n aws_ids = result['aws_ids']\n raise \"FATAL: result not recognized #{result}\" unless aws_ids.is_a?(Array)\n\n# Ensure filesystem is unfrozen and uses retry\n raise \"FATAL: could not unfreeze filesystem!\" unless @disk.unfreeze\n\n aws_ids.each do |snap|\n # TODO: does this http call need to be retried also? \n self.update_snapshot(snap, \"committed\")\n end\n\n # e) - Perform snapshot cleanup\n lst = self.cleanup_snapshots_stripe(options[:cleanup_prefix],{:keep_last => options[:max_snapshots], :dailies => options[:keep_dailies], :weeklies => options[:keep_weeklies], :monthlies => options[:keep_monthlies], :yearlies => options[:keep_yearlies]})\n puts \"Cleanup resulted in deleting #{lst.length} snapshots : #{lst.inspect}\"\n \n end", "def backup(id)\n server = @connection.servers.get(id)\n ssh(server,'~/backup.sh')\n server.scp_download('backup/current.tar.gz','backup.tar.gz')\n end", "def bms_backup_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VnfsApi.bms_backup ...'\n end\n # resource path\n local_var_path = '/bms/1.0.0/backup'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'backuprequest'])\n auth_names = ['oAuth2']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Backup')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VnfsApi#bms_backup\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def createBackup\n fetch(\"#{@backupUrl}\", 3000)\n $LOG.info(\"#{@name} : Backupfile created\") \n sleep 120\n end", "def create_backup\n @slice = Xen::Slice.find(params[:id])\n @slice.create_backup\n\n respond_to do |format|\n format.html { redirect_to slice_path(@slice.name)}\n format.xml { render :xml => @backups }\n end\n end", "def index\n @backup_files = BackupFile.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @backup_files }\n end\n end", "def create(name)\n p \"Doing a create ...\"\n params = {:backup => {:lineage => \"ns_backup_test_lineage\", :name => name, :volume_attachment_hrefs => [@volume_attachment_href_1, @volume_attachment_href_2]}}\n return @test_client.backups.create(params)\nend", "def available_backups\n\n backups = []\n\n objects = container.objects\n objects.each do |object_name|\n if object_name =~ OBJECT_DATE_REGEXP\n\n object_date = Date.parse($1)\n filename = file_name_from_object_name(object_name)\n backups << AvailableBackup.new(:date => object_date, :filename => filename)\n\n end\n end\n\n backups.sort { |a, b| b.date <=> a.date }\n\n end", "def bms_backup(opts = {})\n data, _status_code, _headers = bms_backup_with_http_info(opts)\n data\n end", "def bms_backup_get_with_http_info(backupuuid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VnfsApi.bms_backup_get ...'\n end\n # verify the required parameter 'backupuuid' is set\n if @api_client.config.client_side_validation && backupuuid.nil?\n fail ArgumentError, \"Missing the required parameter 'backupuuid' when calling VnfsApi.bms_backup_get\"\n end\n # resource path\n local_var_path = '/bms/1.0.0/backup/{backupuuid}'.sub('{' + 'backupuuid' + '}', backupuuid.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\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 => 'Backup')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VnfsApi#bms_backup_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @backup = current_user.backups.build(backup_params)\n @backup.user = current_user\n\n respond_to do |format|\n if @backup.save\n format.html { redirect_to backups_path, notice: 'Backup was successfully created.' }\n format.json { render action: 'show', status: :created, location: @backup }\n else\n format.html { render action: 'new' }\n format.json { render json: @backup.errors, status: :unprocessable_entity }\n end\n end\n end", "def delete_uncompressed_backups\n end", "def archive\n perform_action(:post, 'archive')\n end", "def restore\n db = resolve_db(:allow_default => true)\n to_name = db[:name]\n to_url = db[:url]\n\n backup_id = args.shift\n\n if backup_id =~ /^http(s?):\\/\\//\n from_url = backup_id\n from_name = \"EXTERNAL_BACKUP\"\n from_uri = URI.parse backup_id\n backup_id = from_uri.path.empty? ? from_uri : File.basename(from_uri.path)\n else\n if backup_id\n backup = pgbackup_client.get_backup(backup_id)\n abort(\"Backup #{backup_id} already deleted.\") if backup[\"destroyed_at\"]\n else\n backup = pgbackup_client.get_latest_backup\n to_uri = URI.parse backup[\"to_url\"]\n backup_id = File.basename(to_uri.path, '.*')\n backup_id = \"#{backup_id} (most recent)\"\n end\n\n from_url = backup[\"to_url\"]\n from_name = \"BACKUP\"\n end\n\n message = \"#{db[:pretty_name]} <---restore--- \"\n padding = \" \" * message.length\n display \"\\n#{message}#{backup_id}\"\n if backup\n display padding + \"#{backup['from_name']}\"\n display padding + \"#{backup['created_at']}\"\n display padding + \"#{backup['size']}\"\n end\n\n if confirm_command\n restore = transfer!(from_url, from_name, to_url, to_name)\n restore = poll_transfer!(restore)\n\n if restore[\"error_at\"]\n message = \" ! An error occurred and your restore did not finish.\"\n message += \"\\n ! The backup url is invalid. Use `pgbackups:url` to generate a new temporary URL.\" if restore['log'] =~ /Invalid dump format: .*: XML document text/\n abort(message)\n end\n end\n end", "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 backupAllVolumes(profile,region,daystokeep,name,json,tags)\n parsed = JSON.parse(json)\n parsed[\"Volumes\"].each do |volume|\n backupVolume(profile,region,volume[\"VolumeId\"],daystokeep,name,tags)\n end\nend", "def generate_backup\n if Export.launch_export!\n current_user.update(\n last_backup_at: Time.zone.now,\n last_backup_entry_id: current_user.last_entry_id\n )\n redirect_to backup_succeeded_path\n else\n redirect_to backup_failed_path\n end\n end" ]
[ "0.70753354", "0.69240874", "0.64683545", "0.6416198", "0.6393956", "0.6385545", "0.62964517", "0.61483026", "0.6101925", "0.60574675", "0.59670067", "0.5956557", "0.58649534", "0.5854035", "0.58430004", "0.5749153", "0.5705625", "0.57033575", "0.56589913", "0.56550735", "0.560781", "0.55889314", "0.55729973", "0.55531967", "0.55426615", "0.55424625", "0.5514241", "0.5513402", "0.5479522", "0.5445045" ]
0.7071741
1
This function returns a string that displays the current week range, based on the team's firstdayofweek setting
def get_week_string team = @user.team start_of_week = Time.now.beginning_of_week(team.start_of_week_symbol) end_of_week = Time.now.end_of_week(team.start_of_week_symbol) start_string = start_of_week.strftime("%d %b %Y") end_string = end_of_week.strftime("%d %b %Y") start_string + " - " + end_string end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def beginning_of_week; end", "def beginning_of_week; end", "def start_week\n start_date.strftime('%W').to_i\n end", "def day_of_week\n\tif @current_time.wday == 0 || @current_time.wday == 6\n\t\tweek_period = \"Weekends\"\n\telse\n\t\tweek_period = \"Weekdays\"\n\tend\nend", "def week_result_string(day)\n start_of_week = day.beginning_of_week\n # adjust if the week started in a different month\n start = (day.month == start_of_week.month ? start_of_week.day - 1 : 0)\n end_of_week = day.end_of_week\n # adjust if the week finished in a different month\n finish = (day.month == end_of_week.month ? end_of_week.day - 1 : 30)\n month_result_string(day).slice(start..finish)\n end", "def current_week\n\t\t#TODO\n\tend", "def week; end", "def day_of_week\n start_on.strftime(WEEKDAY_NAME)\n end", "def start_of_week; self - wday.days end", "def getStartOfWeek\n\t\tstart_of_week = Setting.start_of_week\n start_of_week = l(:general_first_day_of_week, :default => '1') if start_of_week.blank? \n\t\tstart_of_week = start_of_week.to_i % 7\n\tend", "def week\n self.range('week')\n end", "def showable_week( nextweek )\n discover_week( nextweek ) do | timesheet |\n ( not timesheet.nil? )\n end\n end", "def get_registration_start_week\n registration_start_date.strftime('%W').to_i\n end", "def week\n @obj.date.strftime(\"%V\")\n end", "def start_day()\n return \"#{ self.date_for( TimesheetRow::FIRST_DAY ) } (week #{ self.week_number })\"\n end", "def mweek; (5 - wday + day) / 7 end", "def start_of_week\n @start_of_week ||= (start_of_month + (7 * (week - 1)))\n end", "def week\n @week ||= (((date-start_of_month)+1)/7.0).ceil\n end", "def calendar_wdays(starting_day = 0)\n start_week = Date.today.beginning_of_week + (starting_day - 1).days # In rails week start in monday and monday.wday is 1\n (start_week...start_week+7.days).collect { |day| I18n.l(day, :format => '%A') }\n end", "def beginning_of_week\n (self - self.wday.days).midnight + 1.day\n end", "def week\n published_at.strftime('%W')\n end", "def weeks\n rows = []\n rows << name_of_month.center(20) + \" \"\n rows << \"Su Mo Tu We Th Fr Sa\" + \" \"\n days = format_dates\n (0..7).each {|num|\n fields = days[num * 7, 7]\n rows << fields.join(\" \") + \" \" if fields\n }\n if rows.last.length < 22\n rows.last << \" \" * (22 - rows.last.length)\n end\n until rows.length == 8\n rows << \" \" * 22\n end\n rows\n end", "def beginning_of_week\n Thread.current[:beginning_of_week] || beginning_of_week_default || :monday\n end", "def days_of_week_string\n dow = days_of_week_hash\n\n @days_of_week_string ||=\n (dow[:sunday] ? \"Su\" : \"\") +\n (dow[:monday] ? \"M\" : \"\") +\n (dow[:tuesday] ? \"Tu\" : \"\") +\n (dow[:wednesday] ? \"W\" : \"\") +\n (dow[:thursday] ? \"Th\" : \"\") +\n (dow[:friday] ? \"F\" : \"\") +\n (dow[:saturday] ? \"Sa\" : \"\")\n end", "def beginning_of_week=(_arg0); end", "def beginning_of_week=(_arg0); end", "def game_week\n now = DateTime.now\n all_games = NflSchedule.where(year: Date.today.year)\n .order(:start_time)\n week_started = 0\n all_games.each { |game|\n if (week_started < game.week) && (now > game.start_time)\n week_started = game.week\n end\n }\n return week_started\n end", "def current_week\n self.week.to_i\n end", "def inspect\n \"it is the \" + ordinal_list(@weeks) + \" week of the month\"\n end", "def beginning_of_fall_semester\n week = 4\n\n date = Chronic.parse(\"#{week}th thursday last august\")\n while date\n week += 1\n date = Chronic.parse(\"#{week}th thursday last august\")\n end\n\n Chronic.parse(\"#{week - 1}th thursday last august\").to_datetime\n end" ]
[ "0.7627012", "0.7627012", "0.71351403", "0.7067318", "0.70121557", "0.70016605", "0.6949517", "0.69129455", "0.6893058", "0.6886711", "0.6863883", "0.6742692", "0.6741516", "0.67184705", "0.67115337", "0.6673561", "0.666817", "0.6667355", "0.66362655", "0.6635758", "0.66327685", "0.6619408", "0.6612378", "0.6599735", "0.65744174", "0.65744174", "0.6567652", "0.65473914", "0.65407604", "0.65304494" ]
0.84764755
0
Private: Take the content and process it through Markdown. Cache it. Returns TrueClass.
def cache_markdown_content self.markdown_content = GitHub::Markdown.render(content) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_markdown\n self.data = self.class.convert_markdown(self.data)\n sanitize_html\n end", "def markdown\n @markdown ||= process_markdown!\n end", "def convert_markdown\n # self.content_html = Kramdown::Document.new(content).to_html\n self.content_html = markdown(content)\n end", "def process_markdown\n self.explanation_html = Kramdown::Document.new(explanation_md || '').to_html.gsub(/[\\r\\n]+/, '')\n end", "def content\n MarkdownService.new.render(body).html_safe \n end", "def html_markup_markdown(text); end", "def parse_markdown\n self.bio_html = markdown.render(bio_markdown)\n end", "def render_markdown\n return @render if @render\n @render = Markdown.new(:content => content, :indent => self.indent, :path => self.commit ? \"/commits/#{self.commit.id}#{self.web_path}\" : self.web_path)\n @render\n end", "def convert_markdown\n self.html_content = Raptor::Markdown.render(self.content)\n end", "def content!\n if File.exist?(file)\n markdown_to_html\n else\n @type = :empty\n \"\"\n end\n end", "def parse_markdown\n self.body_html = markdown.render(body_markdown.to_s)\n self.summary_html = markdown.render(summary_markdown.to_s)\n end", "def liquidize_markdown(content, arguments)\n # doc = BlueCloth.new(Liquid::Template.parse(content).render(arguments, :filters => [LiquidFilters], \n # :registers => {:controller => controller, :view => self, :account_site_assets => account_site_assets, :current_user => current_user}))\n doc = ::Kramdown::Document.new(Liquid::Template.parse(content).render(arguments, :filters => [LiquidFilters], \n :registers => {:controller => controller, :view => self, :account_site_assets => account_site_assets, :current_user => current_user}),\n :parse_block_html => true)\n return doc.to_html.html_safe\n end", "def html\n Markdown.render(self.content)\n end", "def html\n Markdown.render(self.content)\n end", "def html_to_markdown(content,user)\n filenumber = user.id\n filename = filenumber.to_s+\".html\"\n %x[\"touch #{filename}\"]\n File.atomic_write(\"tmp/#{filename}\") do |file|\n file.write(content)\n end\n html_content = `pandoc -f html -t markdown \"tmp/#{filename}\"`\n File.delete(\"tmp/#{filename}\")\n return html_content\n end", "def markup_file_contents(contents); end", "def render_md page, content\n markdown(content || self.body) # HACK\n end", "def render_md page, content\n markdown(content || self.body) # HACK\n end", "def preprocessMarkdownForHTML(markdown)\n output = \"\"\n inInstructions = false\n \n markdown.split(\"\\n\").each do |line|\n # parse an instructions list\n # use a dummy HTML tag so our final regex doesn't get stuck in an infinite loop replacing itself\n instructionsMatch = line.match(/^>>\\s*(.*?)$/)\n if instructionsMatch\n if not inInstructions\n output += \"<instructions>\\n\"\n end\n output += instructionsMatch[1] + \"\\n\"\n inInstructions = true\n next # don't try to parse anything else\n elsif inInstructions\n output += \"</instructions>\\n\"\n inInstructions = false\n end\n\n # parse headers and page IDs\n headerMatch = line.match(/^(#+)\\s+(.*?)\\s+@@(.*?)$/)\n if headerMatch\n headerLevel = headerMatch[1].length.to_s\n headerTitle = headerMatch[2]\n headerID = headerMatch[3]\n node = nodeWithID(headerID, $doc.toc.rootNode)\n if not node\n puts \"ERROR: Couldn't find node with ID #{headerID}\"\n exit 1\n end\n output += \"<h#{headerLevel}><a name=\\\"#{headerID}\\\">#{node.levelPrefix} #{headerTitle}</a></h#{headerLevel}>\\n\"\n next\n end\n \n # parse links to page IDs and replace with links to the real .htm file\n while 1\n linkMatch = line.match(/\\[.*?\\]\\((@@(.*?))\\)/)\n if linkMatch\n linkID = linkMatch[2]\n linkValue = linkToPageIDFrom(linkID, \"_PAGE_\") # use dummy value\n if not linkValue\n puts \"ERROR: Invalid link ID \\\"#{linkID}\\\"\"\n exit 1\n end\n line[linkMatch[1]] = linkValue\n else\n break\n end\n end\n \n # parse image and label combo\n imgLabelMatch = line.match(/!!\\[(.*?)\\]\\((.*?)\\)/)\n if imgLabelMatch\n label = imgLabelMatch[1]\n imgPath = imgLabelMatch[2]\n \n # read the image and width height to force the size on images for better loading\n # when viewing the files in the boot DVD. there are some issues where anchor jump\n # links don't always jump to the right place on the boot DVD and apparently forcing\n # the image sizes allows the pages to jump properly.\n \t\timgWidth = 0\n \t\timgHeight = 1\n \t\tbegin\n \t\t data = nil\n \t\t if (imgPath =~ /.png$/)\n \t\t data = IO.read($pagesDir + \"/\" + imgPath, 8, 16).unpack('NN')\n\t\t else\n\t\t puts \"ERROR: Unsupported image type: #{imgPath}\"\n\t\t exit 1\n\t end\n \t\t if (data)\n \t\t imgWidth = data[0]\n \t\t imgHeight = data[1]\n\t\t end\n\t\t rescue\n\t end\n imgWidthHeightAttrs = \"\"\n if imgWidth != 0 and imgHeight != 0\n imgWidthHeightAttrs = \" width=\\\"#{imgWidth}\\\" height=\\\"#{imgHeight}\\\"\"\n end\n\n output += \"<p class=\\\"imageAndLabel\\\"><img src=\\\"#{imgPath}\\\" alt=\\\"\" + CGI::escapeHTML(label) + \"\\\"#{imgWidthHeightAttrs}/><br/><em>\" + CGI::escapeHTML(label) + \"</em></p>\\n\"\n next\n end\n \n # parse warning paragraphs\n warningMatch = line.match(/^!!\\s+(.*?)$/)\n if warningMatch\n output += \"<warning>\\n\" + warningMatch[1] + \"\\n<\\/warning>\\n\"\n next\n end\n \n output += line + \"\\n\"\n end\n \n # close off an open instructions div\n if inInstructions\n output += \"</instructions>\\n\"\n end\n \n # Markdown doesn't allow processing of markup within block-level tags such as <div>, so we have to manually process the markup.\n # We call preprocessMarkdownForHTML() to properly process our custom markup within these custom block elements.\n # An extra newline is added to force a paragraph\n while 1\n instructionsMatch = output.match(/(<instructions>)(.*?)(<\\/instructions>)/m)\n if instructionsMatch\n output[instructionsMatch[1]] = \"<div class=\\\"instructions\\\">\"\n output[instructionsMatch[2]] = markdownToHTML(preprocessMarkdownForHTML(\"\\n\"+instructionsMatch[2]))\n output[instructionsMatch[3]] = \"</div>\"\n else\n break\n end\n end\n \n while 1\n warningMatch = output.match(/(<warning>)\\s*(.*?)(<\\/warning>)/m)\n if warningMatch\n output[warningMatch[1]] = \"<div class=\\\"warning\\\"><div class=\\\"warningBody\\\"><div class=\\\"warningImg\\\"></div><div class=\\\"warningContent\\\">\"\n output[warningMatch[2]] = markdownToHTML(preprocessMarkdownForHTML(\"\\n\"+warningMatch[2]))\n output[warningMatch[3]] = \"</div></div></div>\"\n else\n break\n end\n end\n \n return output\nend", "def process_markup()\n [title,content].each do |text|\n next if !text\n clear_webpage(text).scan(PTN_MARKUP).map{|e|e[0].split(PTN_ELEMENT_SEP)}.flatten.each do |element|\n #debug \"[process_markup] element: \"+element.inspect\n next if !element\n ptn = element.scan(PTN_METADATA)\n #debug \"[process_markup] ptn: \"+ptn.inspect\n if ptn.size > 0\n m[ptn[0][0].to_sym] = parse_value(ptn[0][1])\n else\n create_and_link(element, 'tag' , \"t\")\n #add_tags(element, \"m\")\n end\n end#scan\n end#each\n end", "def traite_as_markdown\n @as_markdown ||= RDiscount.new(raw_code)\n end", "def render_markdown\n return if self.markdown.nil?\n\n render_as = Redcarpet::Render::HTML\n engine = Redcarpet::Markdown.new(render_as, :autolink => true,\n :space_after_headers => true)\n self.content = engine.render(self.markdown)\n end", "def markdown content\n require \"kramdown\"\n\n content = content.\n gsub(/^``` *(\\w+)/) { \"{:lang=\\\"#$1\\\"}\\n~~~\" }.\n gsub(/^```/, '~~~')\n\n Kramdown::Document.new(content, KRAMDOWN_CONFIG).to_html\n end", "def markdown content\n require \"kramdown\"\n\n content = content.\n gsub(/^``` *(\\w+)/) { \"{:lang=\\\"#$1\\\"}\\n~~~\" }.\n gsub(/^```/, '~~~')\n\n Kramdown::Document.new(content, KRAMDOWN_CONFIG).to_html\n end", "def content \n \trenderer = SyntaxRenderer.new(optionize [\n \t:with_toc_data,\n \t#{:hard_wrap,\n \t:xhtml,\n \t:prettify\n \t])\n \n \tmarkdown = Redcarpet::Markdown.new(renderer, optionize([\n \t:fenced_code_blocks,\n \t:no_intra_emphasis,\n \t:tables,\n \t:superscript,\n \t:autolink,\n \t:strikethrough,\n \t:space_after_headers,\n \t:with_toc_data,\n \t:quote,\n \t:lax_spacing\n \t]))\n \n \treturn markdown.render(parse_links(@content)) \n\tend", "def process_markdown\n attachments.each do |att|\n # ~ magic regex ~\n self.markdown = self.markdown.sub(/\\[.+?\\]\\(.+?\\/#{att.file.id}\\/.+?\\)/) do |md_str|\n att.file_attacher.store!\n \"[#{att.file_filename}](#{att.file_url})\"\n end\n end\n self.html = Kramdown::Document.new(self.markdown || '').to_html.gsub(/[\\r\\n]+/, '')\n end", "def render_markdown(text)\n html_renderer.render(text).html_safe if text.present?\n end", "def markdown_to_text(content,user)\n filenumber = user.id\n filename = filenumber.to_s+\".txt\"\n %x[\"touch #{filename}\"]\n File.atomic_write(\"tmp/#{filename}\") do |file|\n file.write(content)\n end\n text_content = `pandoc -f markdown -t text \"tmp/#{filename}\"`\n File.delete(\"tmp/#{filename}\")\n return text_content\n end", "def print_markdown(txt)\n Markdown::Processor.instance.render(txt)\n end", "def markdownify(input); end" ]
[ "0.73491484", "0.7030425", "0.69360274", "0.68867725", "0.68225324", "0.67839766", "0.66862494", "0.6670732", "0.66018593", "0.65604454", "0.6499014", "0.6451486", "0.6431196", "0.6431196", "0.64131755", "0.6362703", "0.6353831", "0.6353831", "0.6301316", "0.62403077", "0.6212483", "0.6200003", "0.61940753", "0.61940753", "0.61938465", "0.61644304", "0.6160497", "0.6139387", "0.61262757", "0.6122561" ]
0.78009886
0
true if either of status or description or both are different
def discrepancy?(local, remote) local.status != remote['status'] || local.ad_description != remote['description'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def includes_description?\n !long_desc.empty? || !desc.empty?\n end", "def acceptable?\n status.to_sym.in? [StatusReponded]\n end", "def not_approved?\n status_map = employee_vacation_responses.map(&:status).uniq\n status_map.size == 1 && status_map.include?(\"not_approved\")\n end", "def status_description\n\t\treturn case self.status\n\t\t\twhen 'M' then 'modified'\n\t\t\twhen 'A' then 'added'\n\t\t\twhen 'R' then 'removed'\n\t\t\twhen 'C' then 'clean'\n\t\t\twhen '!' then 'missing'\n\t\t\twhen '?' then 'not tracked'\n\t\t\twhen 'I' then 'ignored'\n\t\t\telse\n\t\t\t\traise \"unknown status %p\" % [ self.status ]\n\t\t\tend\n\tend", "def draft?\n self.status == \"Draft\" || self.status == \"draft\" \n end", "def silly_fd_inconsistency(status, response)\n # FD will return 404 when updating a contact, who is an agent. So if someone from staff is\n # a ticket sender, we won't be able to update the ticket.\n return true if status == 404\n\n begin\n response = JSON.parse(response)\n\n # Freshdesk will not allow to update description if the member name contains /, \", wwww.\n # But it ALLOWS such requesters to be created in the first place.\n # Result: such requesters cannot be updated via API without chaning their name.\n return true if response['errors'].any? { |x|\n x['field'] == 'name' && x['message'] == \"/,\\\",www. not allowed in name\"\n }\n\n false\n rescue JSON::ParserError\n false\n end\n end", "def _validate_description(d)\n if d == spec.summary\n results.add_warning('description', 'The description is equal to' \\\n ' the summary.')\n end\n\n if d.strip.empty?\n results.add_error('description', 'The description is empty.')\n elsif spec.summary && d.length < spec.summary.length\n results.add_warning('description', 'The description is shorter ' \\\n 'than the summary.')\n end\n end", "def descrips_match(expected, descrips)\n begin\n expected.zip(descrips).collect {\n |x, y| (x == :anything || x == y) }.inject(true) {\n |x, y| x && y }\n rescue TypeError => te\n puts \"TypeError: #{te}\"\n end\n end", "def check_description(description)\r\n # Return error message if description is blank.\r\n return \"Description cannot be blank.\" if description == \"\"\r\n # Return error message if description is too long.\r\n if description.length > 140\r\n return \"Description was #{description.length} characters long; cannot exceed 140.\"\r\n end\r\n # Otherwise \"ok\"\r\n return \"ok\"\r\n end", "def description_presence\n return if self[:description].present?\n\n self.flag_type = self[:flag_type].try(:to_i)\n\n case self.flag_type\n when FLAG_TYPE['terms_of_use_violation']\n errors.add(:description, I18n.t(\"image_flag.missing_description_terms_of_use_violation\"))\n when FLAG_TYPE['copyright']\n errors.add(:description, I18n.t(\"image_flag.missing_description_copyright\"))\n else\n errors.add(:description, \"Unknown violation type!\")\n end\n end", "def description?\n !description.nil? && !description.empty?\n end", "def new_status?\r\n status == 'new'\r\n end", "def compare_description?(freelancer_descr, profile_descr)\n serialized_freelance_descr = freelancer_descr.chomp(\"...\").split(\" \")\n serialized_profile_descr = profile_descr.gsub(\"\\n\", \" \").split(\" \")[0..serialized_freelance_descr.size-1]\n comparision = serialized_freelance_descr - serialized_profile_descr\n if comparision.empty?\n return true\n # case if last word in short description is cutted\n elsif comparision.size == 1 and serialized_profile_descr[-1].include? serialized_freelance_descr[-1]\n return true\n end\n false\n end", "def status_changed_to_approved_and_not_deleted?\n self.status_changed_to_approved? && !self.deleted?\n end", "def ==(other)\n self.title == other.title &&\n self.date == other.date &&\n self.result_type == other.result_type &&\n self.url == other.url\n end", "def expected_status_unmet\n expected = test_case.expected_status\n got = response.status\n expected === got ? nil : \"[status] #{expected} !== #{got}\"\n end", "def status(response, expected_status_code, failure_message)\n if response.status == expected_status_code\n true\n else\n fail(\"#{failure_message}. Response: #{response.status} #{response.reason_phrase} #{response.body}\")\n end\n end", "def status(response, expected_status_code, failure_message)\n if response.status == expected_status_code\n true\n else\n fail(\"#{failure_message}. Response: #{response.status} #{response.reason_phrase} #{response.body}\")\n end\n end", "def check_status(status)\n case status.to_i\n when 1 # Valid\n true\n when 2 # Rejected\n false\n when 3 # Differed\n false\n when 4 # Test\n false\n else\n false\n end\n end", "def changed?(old_status, prop)\n (old_status == nil && self[prop] > 0) ||\n (old_status != nil && self[prop] != old_status[prop])\n end", "def changed?(olds, news) ; olds != news ; end", "def status_is_successful?\n\t\treturn self.status_category == 2\n\tend", "def check\n if @value1 == @value2\n @message = \"#{@value1} == #{@value2}\"\n true\n else\n @message = \"#{@value1} != #{@value2}\"\n false\n end\n end", "def docmp(itemA, itemB)\n itemA[:alias] != itemB[:alias] or itemA[:format] != itemB[:format]\n end", "def has_description?\n @desc && @desc.is_a?(String) && !@desc.empty?\n end", "def correct_statuses?\n [:order_status, :payment_status].each do |s|\n return false if Commission::INVALID_STATES.include?(self.send(s).gsub(/(.*\\_)/, \"\").to_sym)\n end\n true\n end", "def check_for_admin_update(updated_task)\n (self.request_number != updated_task.request_number ||\n self.description != updated_task.description ||\n self.mfg != updated_task.mfg ||\n self.mfg_num != updated_task.mfg_num ||\n self.cae_model != updated_task.cae_model ||\n self.cad_model != updated_task.cad_model ||\n self.completed != updated_task.completed ||\n self.closed != updated_task.closed ||\n self.model_types != updated_task.model_types.reverse)\n end", "def approved?\n status_map = employee_vacation_responses.map(&:status).uniq\n status_map.size == 1 && status_map.include?(\"approved\")\n end", "def has_description?\n !error.description.to_s.empty?\n end", "def description?\n !(@description.nil? || @description.empty?)\n end" ]
[ "0.62089175", "0.60525364", "0.59846336", "0.5874727", "0.58463365", "0.5844662", "0.5831774", "0.5824308", "0.58226645", "0.58162725", "0.5809268", "0.58025837", "0.58017445", "0.5786038", "0.57560974", "0.575115", "0.5747735", "0.57474184", "0.57425386", "0.5723443", "0.57160425", "0.56988287", "0.569409", "0.5691777", "0.56806535", "0.56758416", "0.5657551", "0.56426847", "0.56222856", "0.561769" ]
0.7503411
0
strips the meta data from a field so that it is no longer readable. leaves the metatags property on the object intact however field:: A Symbol corresponding to the field on this object to strip. Defaults to the description field.
def strip_readable_meta ( field = :description ) self[field].scan(LEWTLedger::MATCH_MULTIPLE_META_REGEX).each do |m| self[field].slice!(m).strip! end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strip_string_fields\n all_fields = self.get_array_of_symbolic_keys\n # stripping\n all_fields.each do |field|\n unless self[field].nil?\n if self[field].class == String\n self[field] = self[field].strip\n end\n end\n end\n end", "def clean_data( field )\n\tfield.to_s.strip\nend", "def strip_columns\n user_fields = %W(\n comment\n )\n\n user_fields.each do |field|\n next if self[field].nil?\n self[field] = self[field].strip\n end\n end", "def remove_whitespace\n self.description = self.description.strip\n end", "def strip_attributes\n self.title = self.title.try :strip\n self.url = self.url.try :strip\n self.author = self.author.try :strip\n self.content = self.content.try :strip\n self.summary = self.summary.try :strip\n self.guid = self.guid.try :strip\n end", "def sanitize_data\n self.permalink = name if permalink.blank? && name\n self.permalink = permalink.squeeze(\" \").strip.gsub(' ', '-') if permalink\n if meta_keywords.blank? && description\n self.meta_keywords = [name[0..55],\n description.\n gsub(/\\d/, \"\"). # remove non-alpha numeric\n squeeze(\" \"). # remove extra whitespace\n gsub(/<\\/?[^>]*>/, \"\"). # remove hyper text\n split(' '). # split into an array\n map{|w| w.length > 2 ? w : ''}. # remove words less than 2 characters\n join(' ').strip[0..198] # join and limit to 198 characters\n ].join(': ')\n end\n self.meta_description = [name[0..55], description.gsub(/<\\/?[^>]*>/, \"\").squeeze(\" \").strip[0..198]].join(': ') if name.present? && description.present? && meta_description.blank?\n end", "def strip(*fields)\n sanitize(*fields) { |value| value.strip }\n end", "def remove_whitespace\n self.title = self.title.strip\n self.description = self.description.strip\n end", "def strip(*value)\n @ignore_fields += value\n end", "def strip_whitespace\n self.tags = tags.gsub(/\\s+/, '')\n # self.tags = tags.strip\n self.title = title.strip\n self.description = description.strip\n # self.keywords = keywords.strip\n self.body = body.strip\n end", "def remove_quotes(field)\n field.gsub(/'/, \"\").strip if field.is_a? String\n end", "def strip(event)\n @strip.each do |field|\n value = event.get(field)\n case value\n when Array\n event.set(field, value.map{|s| s.strip})\n when String\n event.set(field, value.strip)\n end\n end\n end", "def strip_columns\n user_fields = %W(\n name\n email\n address\n )\n\n user_fields.each do |field|\n next if self[field].nil?\n self[field] = self[field].strip\n end\n end", "def trim_all_fields\n self.attributes.each{|a| a.strip! if a.class == 'String'}\n end", "def remove(field)\n self.delete(field)\n @options.delete(field)\n end", "def cleanup_newlines\n [:description, :use].each do |field|\n self[field].gsub!(/\\r\\n/, \"\\n\") if self[field]\n end\n end", "def nullify_fields\n user_fields = %W(\n comment\n )\n user_fields.each do |field|\n next if self[field].nil?\n self[field] = nil if self[field].empty?\n end\n end", "def strip_blanks\n self.title = self.title.strip\n self.code = self.code.strip\n end", "def delete_field!(field_name); end", "def strip_blanks\n self.title = self.title.strip\n self.code = self.code.strip\n self.complement_title = self.complement_title.strip\n end", "def clean_fields(fields)\n fields.map { |k, v| [k.to_s.downcase.gsub(/ |-/, '_'), v] }.to_h\n end", "def fields\n @properties.dup.delete_if{|item| item.to_s.start_with?('_sm_')}\n end", "def caprese_unalias_field(field)\n caprese_field_aliases[field = field.to_sym] || field\n end", "def remove_whitespace\n self.attributes.each { |key, value| self[key] = value.strip if value.respond_to?(:strip) }\n end", "def normalize_fields\n @fields = @fields.map do |field|\n case field\n when Symbol, String\n @properties[field]\n\n when Property, Operator\n field\n end\n end\n end", "def read_attribute_for_serialization(attribute)\n super(self.object.class.caprese_unalias_field(attribute))\n end", "def strip_blanks\n self.title = self.title.strip\n self.unit = self.unit.strip\n end", "def clear_field(field_name)\n\t\tend", "def remove_whitespace\n self.time = self.time.strip\n self.description = self.description.strip\n self.venue = self.venue.strip.downcase\n self.location = self.location.strip.downcase\n end", "def remove_field_handler(name); end" ]
[ "0.6209361", "0.5990455", "0.58668494", "0.5821879", "0.5709197", "0.56629705", "0.56134504", "0.55356014", "0.54993457", "0.54423964", "0.5404814", "0.53379333", "0.53002995", "0.52985454", "0.5289343", "0.52876955", "0.52732843", "0.5249204", "0.52403", "0.5239396", "0.5231748", "0.5228875", "0.5187087", "0.5149337", "0.5139499", "0.51316655", "0.51312894", "0.50918704", "0.50685054", "0.5067428" ]
0.78767204
0
this function extracts all tags/values from a given string. string [String]:: a string to search for meta tags in.
def parse_tags (string) tags = nil string.scan(LEWTLedger::MATCH_SINGLE_META_REGEX) { |t| if tags == nil tags = Hash.new end tag_value = parse_tag_value t[0] tag_name = parse_tag_name t[0] tags[tag_name.gsub(/\W/,"_").to_sym] = tag_value } return tags end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scan_text_for_meta(text)\r\n # break up the text with some extra newlines to make matching more likely\r\n # and strip out some tags\r\n text.gsub!(/<br/, \"\\n<br\")\r\n text.gsub!(/<p/, \"\\n<p\")\r\n text.gsub!(/<\\/?span(.*?)?>/, '')\r\n text.gsub!(/<\\/?div(.*?)?>/, '')\r\n\r\n meta = {}\r\n metapatterns = META_PATTERNS\r\n is_tag = {}\r\n [\"fandom_string\", \"pairing_string\", \"freeform_string\", \"rating_string\"].each do |c|\r\n is_tag[c.to_sym] = true\r\n end\r\n metapatterns.each do |metaname, pattern|\r\n # what this does is look for pattern: (whatever)\r\n # and then sets meta[:metaname] = whatever\r\n # eg, if it finds Author: Blah The Great it will set meta[:author] = Blah The Great\r\n metapattern = Regexp.new(\"(#{pattern})\\s*:\\s*(.*)\", Regexp::IGNORECASE)\r\n metapattern_plural = Regexp.new(\"(#{pattern.pluralize})\\s*:\\s*(.*)\", Regexp::IGNORECASE)\r\n if text.match(metapattern) || text.match(metapattern_plural)\r\n value = $2\r\n begin\r\n value = eval(\"convert_#{metaname.downcase}(value)\")\r\n rescue NameError\r\n end\r\n value = sanitize_fully(value) if is_tag[metaname]\r\n meta[metaname] = value\r\n end\r\n end\r\n return meta\r\n end", "def parse_tag_metadata_vars(meta)\n begin\n return tag unless meta\n new_tag = tag\n # Direct value metaname var\n # pattern: %V=key_name-%\n # Where 'key_name' is the key name from the metadata hash\n # directly inserts the value or nothing if nil\n direct_value = new_tag.scan(/%V=[\\w ]*-%/)\n direct_value.map! do |dv|\n {\n :var => dv,\n :key_name => dv.gsub(/%V=|-%/, \"\"),\n :value => meta[dv.gsub(/%V=|-%/, \"\")]\n }\n end\n direct_value.each do\n |dv|\n dv[:value] ||= \"\"\n new_tag = new_tag.gsub(dv[:var].to_s,dv[:value].to_s)\n end\n\n\n # Selected value metaname var\n # pattern: %R=selection_pattern:key_name-%\n # Where 'key_name' is the key name from the metadata hash\n # Where 'selection_pattern' is a Regex string for selecting a portion of the value from the key name in the metadata hash\n # directly inserts the value or nothing if nil\n selected_value = new_tag.scan(/%R=.+:[\\w]+-%/)\n selected_value.map! do |dv|\n {\n :var => dv,\n :var_string => dv.gsub(/%R=|-%/, \"\"),\n :key_name => dv.gsub(/%R=|-%/, \"\").split(\":\")[1],\n :pattern => Regexp.new(dv.gsub(/%R=|-%/, \"\").split(\":\").first)\n }\n end\n\n selected_value.each do\n |sv|\n if sv[:pattern] && sv[:key_name]\n sv[:value] = sv[:pattern].match(meta[sv[:key_name]]).to_s\n end\n sv[:value] ||= \"\"\n new_tag = new_tag.gsub(sv[:var].to_s,sv[:value].to_s)\n end\n rescue => e\n logger.error \"ERROR: #{p e}\"\n tag\n end\n new_tag\n end", "def parse_tag_metadata_vars(meta)\n begin\n return tag unless meta\n new_tag = tag\n # Direct value metaname var\n # pattern: %V=key_name-%\n # Where 'key_name' is the key name from the metadata hash\n # directly inserts the value or nothing if nil\n direct_value = new_tag.scan(/%V=[\\w ]*-%/)\n direct_value.map! do |dv|\n {\n :var => dv,\n :key_name => dv.gsub(/%V=|-%/, \"\"),\n :value => meta[dv.gsub(/%V=|-%/, \"\")]\n }\n end\n direct_value.each do\n |dv|\n dv[:value] ||= \"\"\n new_tag = new_tag.gsub(dv[:var].to_s,dv[:value].to_s)\n end\n\n\n # Selected value metaname var\n # pattern: %R=selection_pattern:key_name-%\n # Where 'key_name' is the key name from the metadata hash\n # Where 'selection_pattern' is a Regex string for selecting a portion of the value from the key name in the metadata hash\n # directly inserts the value or nothing if nil\n selected_value = new_tag.scan(/%R=.+:[\\w]+-%/)\n selected_value.map! do |dv|\n {\n :var => dv,\n :var_string => dv.gsub(/%R=|-%/, \"\"),\n :key_name => dv.gsub(/%R=|-%/, \"\").split(\":\")[1],\n :pattern => Regexp.new(dv.gsub(/%R=|-%/, \"\").split(\":\").first)\n }\n end\n\n selected_value.each do\n |sv|\n if sv[:pattern] && sv[:key_name]\n sv[:value] = sv[:pattern].match(meta[sv[:key_name]]).to_s\n end\n sv[:value] ||= \"\"\n new_tag = new_tag.gsub(sv[:var].to_s,sv[:value].to_s)\n end\n rescue => e\n logger.error \"ERROR: #{e}\"\n tag\n end\n new_tag\n end", "def parse_tags(string_tags)\n s_tags = string_tags || \"\"\n s_tags = \"untagged\" if s_tags.empty?\n return s_tags.split(/[\\s,]+/)\n .map { |t| t[0]=='#' ? t[1..-1] : t }\n .map { |t| t.downcase}\n .select { |t| t.length > 0 }\n .uniq.sort\n rescue\n return nil\n end", "def extract_metadata(markdown_string)\n metadata_results = OpenStruct.new\n return markdown_string unless markdown_string.include? \"**METADATA**\"\n result = markdown_string.split(\"**METADATA**\").map do |section|\n metadata, content = section.split(\"****\")\n parse_metadata_section(section).each do |key,results_array|\n metadata_results[key] ||= []\n metadata_results[key].concat results_array\n end\n content\n end.join(\"\\n\\n\")\n [result, metadata_results]\n end", "def charset_from_meta(string)\n\n position = 0\n attribute_list = {}\n got_pragma = false\n need_pragma = nil\n charset = nil\n length = string.length\n\n while position < length\n\n attribute, position_increment = attribute(string[position, length])\n \n position += position_increment.to_i\n\n if attribute == nil\n\n break\n\n elsif attribute_list[attribute[:attribute_name]]\n\n # Do nothing\n \n else\n\n # found a new attribute. Add it to the list\n attribute_list[attribute[:attribute_name]] = attribute[:attribute_value]\n\n if attribute[:attribute_name] == 'http-equiv'\n\n got_pragma = true\n\n elsif attribute[:attribute_name] == 'content'\n\n content_charset = charset_from_meta_content(attribute[:attribute_value])\n\n if content_charset && charset == nil\n charset = content_charset\n need_pragma = true\n end\n\n elsif attribute[:attribute_name] == 'charset'\n\n charset = attribute[:attribute_value]\n need_pragma = false\n\n end\n\n end\n\n end\n\n if need_pragma == nil || (need_pragma == true && got_pragma == false)\n [nil, position]\n else\n [charset, position]\n end\n \n end", "def parse_tag(string)\n att = {\n type: /<(\\w)/.match(string),\n classes: /class='(\\w{1, 20}).(\\w{1, 20})'/.match(string),\n id: /id='(\\w{1, 20})'/.match(string),\n name: /name='(\\w{1, 30})'/.match(string)\n }\nend", "def match_and_parse(string)\n meme = match(string)\n if meme.nil?\n return meme\n end\n bits = parse(meme, string)\n [meme, bits]\n end", "def parse_meta_tags ( field_key )\n value = self[field_key]\n tags = parse_tags value\n return tags\n end", "def parse_metadata_section(metadata_string)\n metadata_string.split(\"\\n\").reduce({}) do |result, line|\n key, val = line.split(\": \")\n if [key, val].none? { |str| str.blank? }\n result[key.strip.downcase.to_sym] = val.strip.split(\", \")\n end\n result\n end\n end", "def tags_from_string(input_string)\n tags = {}\n input_string.split(' ').each do |pair|\n pair = pair.gsub('-', ' ')\n category, name = pair.split(':')\n tags[category] = name\n end\n tags\n end", "def vars_in(string)\n rest = string\n vars = []\n while /<(?<var>\\w+)>/ =~ rest\n vars << var\n rest = $~.post_match\n end\n vars\n end", "def scan_tags(string, &block)\n raise \"No block given\" unless block_given?\n\n fragment = Nokogiri::HTML::DocumentFragment.parse string\n fragment.traverse do |node|\n yield(node.content) if node.text?\n end\n nil\n end", "def find_metadata\n MAPPING.each do |metaname, pattern|\n metapattern = Regexp.new(\"(#{pattern})\\s*:\\s*(.*)\", Regexp::IGNORECASE)\n if text.match(metapattern)\n value = $2\n if value.match(metapattern)\n value = $2\n end\n meta[metaname] = value.strip\n end\n end\n meta\n end", "def setExtractMetaTags(value)\n @fields['extract_meta_tags'] = value\n self\n end", "def parse_html(string)\n t = Tag.new\n tag = string.match(TAG_R).captures.to_s #returns an array\n t.type = tag[0]\n str_class = string.match(CLASS_R).captures #already an array\n t.classes = str_class.join.split(\" \")\n t.id = string.match(ID_R).captures[0]\n t.name = string.match(NAME_R).captures[0]\n t\n end", "def match(*strings)\n result = []\n @tags.each do |tag|\n strings.each do |string|\n if string.downcase =~ /#{tag.downcase}/\n strings.delete string\n result << tag\n break\n end\n end\n end\n return result\n end", "def autotag(string)\n return unless string\n return string unless Doing.auto_tag\n\n original = string.dup\n text = string.dup\n\n current_tags = text.scan(/@\\w+/).map { |t| t.sub(/^@/, '') }\n tagged = {\n whitelisted: [],\n synonyms: [],\n transformed: [],\n replaced: []\n }\n\n Doing.setting('autotag.whitelist').each do |tag|\n next if text =~ /@#{tag}\\b/i\n\n text.sub!(/(?<= |\\A)(#{tag.strip})(?= |\\Z)/i) do |m|\n m.downcase! unless tag =~ /[A-Z]/\n tagged[:whitelisted].push(m)\n \"@#{m}\"\n end\n end\n\n Doing.setting('autotag.synonyms').each do |tag, v|\n v.each do |word|\n word = word.wildcard_to_rx\n next unless text =~ /\\b#{word}\\b/i\n\n unless current_tags.include?(tag) || tagged[:whitelisted].include?(tag)\n tagged[:synonyms].push(tag)\n tagged[:synonyms] = tagged[:synonyms].uniq\n end\n end\n end\n\n if Doing.setting('autotag.transform')\n Doing.setting('autotag.transform').each do |tag|\n next unless tag =~ /\\S+:\\S+/\n\n if tag =~ /::/\n rx, r = tag.split(/::/)\n else\n rx, r = tag.split(/:/)\n end\n\n flag_rx = %r{/([r]+)$}\n if r =~ flag_rx\n flags = r.match(flag_rx)[1].split(//)\n r.sub!(flag_rx, '')\n end\n r.gsub!(/\\$/, '\\\\')\n rx.sub!(/^@?/, '@')\n regex = Regexp.new(\"(?<= |\\\\A)#{rx}(?= |\\\\Z)\")\n\n text.sub!(regex) do\n m = Regexp.last_match\n new_tag = r\n\n m.to_a.slice(1, m.length - 1).each_with_index do |v, idx|\n next if v.nil?\n\n new_tag.gsub!(\"\\\\#{idx + 1}\", v)\n end\n # Replace original tag if /r\n if flags&.include?('r')\n tagged[:replaced].concat(new_tag.split(/ /).map { |t| t.sub(/^@/, '') })\n new_tag.split(/ /).map { |t| t.sub(/^@?/, '@') }.join(' ')\n else\n tagged[:transformed].concat(new_tag.split(/ /).map { |t| t.sub(/^@/, '') })\n tagged[:transformed] = tagged[:transformed].uniq\n m[0]\n end\n end\n end\n end\n\n logger.debug('Autotag:', \"whitelisted tags: #{tagged[:whitelisted].log_tags}\") unless tagged[:whitelisted].empty?\n logger.debug('Autotag:', \"synonyms: #{tagged[:synonyms].log_tags}\") unless tagged[:synonyms].empty?\n logger.debug('Autotag:', \"transforms: #{tagged[:transformed].log_tags}\") unless tagged[:transformed].empty?\n logger.debug('Autotag:', \"transform replaced: #{tagged[:replaced].log_tags}\") unless tagged[:replaced].empty?\n\n tail_tags = tagged[:synonyms].concat(tagged[:transformed])\n tail_tags.sort!\n tail_tags.uniq!\n\n text.add_tags!(tail_tags) unless tail_tags.empty?\n\n if text == original\n logger.debug('Autotag:', \"no change to \\\"#{text.strip}\\\"\")\n else\n new_tags = tagged[:whitelisted].concat(tail_tags).concat(tagged[:replaced])\n logger.debug('Autotag:', \"added #{new_tags.log_tags} to \\\"#{text.strip}\\\"\")\n logger.count(:autotag, level: :info, count: 1, message: 'autotag updated %count %items')\n end\n\n text.dedup_tags\n end", "def convert_tags(string)\n if string.nil?\n []\n else\n tags = string.split(',')\n tags.map(&:strip)\n end\n end", "def get_meta_tags\n if @content_package\n\n if @content_package.meta_image_uid\n image = \"#{Settings.site_url}#{@content_package.meta_image.thumb('1200x630#').url}\"\n elsif @content_package.respond_to?(:hero_image) && @content_package.hero_image.present?\n image = \"#{Settings.site_url}#{@content_package.hero_image.thumb('1200x630#').url}\"\n end\n\n meta_title = @content_package.meta_title.presence || Settings.default_meta_title\n meta_description = @content_package.meta_description.presence || Settings.default_meta_description\n meta_keywords = @content_package.meta_keywords.presence || Settings.default_meta_keywords\n if @content_package.hide_from_robots?\n meta_hide_from_robots = \"<meta name='robots' content='noindex, nofollow' />\\n\"\n end\n\n else\n meta_title = content_for(:title) || Settings.default_meta_title\n meta_description = content_for(:description) || Settings.default_meta_description\n meta_keywords = content_for(:keywords) || Settings.default_meta_keywords\n meta_hide_from_robots = nil\n end\n\n meta_description = strip_tags CGI.unescapeHTML(meta_description.strip)\n\n meta_image = image || content_for(:meta_image) || \"#{Settings.site_url}#{asset_path(Settings.default_fb_meta_image)}\"\n\n meta_values = [meta_title, meta_description, meta_image, meta_keywords, meta_hide_from_robots]\n\n pig_meta_tags(meta_values)\n end", "def parse(tags); end", "def get_metatag(page, tag)\n page.parser.css(\"meta[name='#{tag}']\").first['content']\n end", "def parse_tag(html)\n puts \"-----------------------------------------------------------\"\n str = html.match(/<(.*)>/).captures[0]\n elements= str.scan(/[a-z]{2,5}='[\\w\\s]*'/)\n\n puts \"\\nstring is:: #{str}\"\n puts \"element is:: #{elements} \\n\"\n\n hash = {}\n hash[:type] =str.sub(elements.join(' '), \"\").strip\n \n elements.each do |info|\n clazz = info.match(/([a-z]*)=/).captures[0].to_sym\n clazz_val = info.match(/'(.*)'/).captures[0]\n\n hash[clazz] = clazz_val\n end\n\n print \"hash is:: #{hash} \\n\"\n puts \"-----------------------------------------------------------\"\n end", "def parse(string)\n @stack = [ ParseContainerTag.new { |t| Utility.array_to_s(t.contents) } ]\n tokenize(string)\n stack_up\n @stack.last.to_s\n end", "def extract_meta\n end", "def extract_variables_from_string(string)\n string.split(/ /).map do |defintion|\n match = defintion.match STRING_REG_EX\n next nil unless match\n\n { match[1] => match[2] }\n end.reject(&:nil?)\n end", "def meta_tags(hash)\n meta_information.merge!(hash)\n end", "def parse_provides(string)\n ret = []\n # ['atk = 1.12.2-1.fc6', 'libatk-1.0.so.0']\n string.split(\", \").each do |seg|\n # 'atk = 1.12.2-1.fc6'\n if seg =~ /^'(.*)'$/\n ret << RPMProvide.parse($1)\n end\n end\n\n ret\n end", "def parse(s)\n s = clean(s)\n\n words = s.split(' ')\n\n result = []\n\n while !words.empty?\n if words[0] =~ URL_REGEX\n # <url> <text>\n result << {url: read_url(words), text: trim_to_nil(read_text(words))}\n else\n # <text> <url> [<accessed note>]\n entry = read_text(words)\n url = read_url(words)\n accessed_note = read_accessed_note(words)\n if accessed_note\n entry += ' ' + accessed_note\n end\n\n result << {url: url, text: trim_to_nil(entry)}\n end\n end\n\n result\n end", "def meta name, contents\n Tagz.tag :meta, :name => name, :contents => contents \n end" ]
[ "0.67412686", "0.6407475", "0.64054745", "0.6187387", "0.6183463", "0.6060359", "0.6004481", "0.59469825", "0.5937417", "0.5888159", "0.5878244", "0.58709806", "0.58258337", "0.58206016", "0.57157516", "0.5715501", "0.5693958", "0.5677439", "0.56761503", "0.5663385", "0.5651921", "0.56345123", "0.563333", "0.5614043", "0.56104535", "0.55670226", "0.5561577", "0.5510947", "0.5508557", "0.5489907" ]
0.77468455
0
parses the name of a tag and returns it as a symbol to be used as a hash key tag [string] a string containing the a singular meta tag.
def parse_tag_name( tag ) match_name = /[^=]*/ m = tag.match(match_name) return m[0] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tagname_symbol\n @tagname\n end", "def tag_name\n @tag_name ||= name && name.to_s.split(\"::\")[-1].downcase\n end", "def to_sym\n self.tag\n end", "def tag(name)\n tags[name.to_s] if tags\n end", "def _tag_name\n @tag_name\n end", "def tag_name\n return @tag_name\n end", "def tag(name); end", "def tagname\n @tagname.id2name\n end", "def extract_tag_name(tag)\n match = /\\A<\\/?(#{@@name})/.match(tag)\n return match[1] if match\n raise \"Cannot find tag name in tag: #{tag}\"\n end", "def name\n tag.name\n end", "def name\n tag['name'].gsub(/\\[\\]$/, '')\n end", "def tag_name; end", "def tag_name; end", "def tag_name; end", "def tag tag_name\n find_element :tag_name, tag_name\n end", "def tagname\n @node[0].gsub(/[^a-zA-Z]/, \"\")\n end", "def getmetaname\n return @metaname.to_sym\n end", "def tag_name\n self.class.name.downcase.match(/[^:]+$/)[0]\n end", "def [](name)\n @meta_tags[name]\n end", "def tag(string); end", "def parse_tag_with_name(tag_name, text); end", "def tag_name=(_arg0); end", "def find_name_tag(tags)\n name_tag = tags.find { |tag| tag[:key] == \"Name\" }\n name_tag ? name_tag[:value] : nil\n end", "def use_tag(tag_name)\n raw \"_#{tag_name}\"\n end", "def name\n _name = nil\n self.tags.each do |x|\n if x.tkey == \"name\"\n _name = x.tvalue\n end\n end\n _name\n end", "def [](tag)\n to_h[tag.to_sym]\n end", "def tagging_raw_handle\n name\n end", "def tagging_raw_handle\n name\n end", "def tag(tag); end", "def tag(tag); end" ]
[ "0.7576155", "0.7013119", "0.6987753", "0.6986859", "0.6956297", "0.68972677", "0.68659246", "0.6808434", "0.6807889", "0.68038976", "0.67593277", "0.670867", "0.670867", "0.670867", "0.6696054", "0.6580402", "0.6563046", "0.6538821", "0.6517697", "0.6462939", "0.6445415", "0.64348596", "0.6416085", "0.64132017", "0.64077705", "0.63481474", "0.63470596", "0.63470596", "0.62350744", "0.62350744" ]
0.71047175
1
extracts a mathematical expression from a single tag format: Num +/ Num string:: the string to extract the fraction from
def extract_fraction ( string ) match_fraction = /(\d{1,})([\/\+])(\d{1,})+/ # m = string.match(match_fraction)[0] m = string.match(match_fraction) value = nil if m != nil value = Rational m[0] end return value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eval_expression(expression)\n if expression.count(\"a-zA-Z\") > 0\n result = \"Incorrect expression or Number\"\n else\n expression = expression.gsub('/', '*1.0/') if expression.include?(\"/\")\n result = eval(expression).round(2)\n end\n result\n end", "def calculate str\n ast = parse_expr(str)[1]\n puts ast.to_s\n evaluate_tree(ast)\n end", "def parse(expr)\n tokens = expr.chomp.strip.split('+')\n tokens.map(&:to_f).inject(:+)\n end", "def calculate_str(st)\n first_num = ''\n operator = ''\n second_num = ''\n \n characters = st.chars\n \n characters.each do |char|\n if char.match?(/[0-9]/) or char.eql?('.')\n if operator == ''\n first_num << char\n else\n second_num << char\n end\n elsif char.match?(/(\\+|-|\\*|\\/)/)\n operator << char \n else\n next\n end\n end\n result = eval first_num + operator + second_num\n result.round.to_i.to_s\nend", "def mystery_math(str)\n str.gsub(/[+-]|\\*|\\//, '?')\nend", "def mystery_math(str)\n str.sub(/[+-]|\\*|\\//, '?')\nend", "def factor\n case\n when scan(/\\(/) then expr.tap { scan(/\\)/) }\n else number\n end\n end", "def exp(str); end", "def exp(str); end", "def eval_math(string)\n number_stack = []\n operator_stack = []\n tokens = string.split(\" \")\n tokens.each_with_index do |n, i|\n if n == \"*\" \n number_stack << number_stack.pop.to_i * tokens[i+1].to_i\n tokens.delete_at(i+1)\n elsif n == \"/\" \n number_stack << number_stack.pop.to_i / tokens[i+1].to_i\n tokens.delete_at(i+1)\n elsif ['+','-'].include? n\n operator_stack << n\n else\n number_stack << n\n end\n puts \"evaling n: #{n}, number_stack #{number_stack} operator_stack #{operator_stack}\"\n end\n result = 0\n operator_stack.each do |o|\n if o == '+'\n number_stack[0] = number_stack.first.to_i + number_stack.delete_at(1).to_i\n end\n if o == '-'\n number_stack[0] = number_stack.first.to_i - number_stack.delete_at(1).to_i\n end\n end\n\n return number_stack[0]\n\nend", "def frac_to_float(str)\n numerator, denominator = str.split(\"/\").map(&:to_f)\n denominator ||= 1\n numerator/denominator\n end", "def fraction_calculator fraction_one, fraction_two, operator\n num_one = Rational(fraction_one)\n num_two = Rational(fraction_two)\n \n final_result = case operator\n when '/' then num_one / num_two\n when '*' then num_one * num_two\n when '+' then num_one + num_two\n when '-' then num_one - num_two\n end\n\n String(final_result)\n\n print String(final_result)\n\nend", "def MultiplicativeExpr(path, parsed); end", "def collapse(expression)\n expression.gsub!(/^\\(|\\)$/,'') if expression.match(/^\\(.*\\)$/)\n while expression.index('(')\n inner_range = expression.rindex('(')..expression.index(')')\n expression[inner_range] = collapse(expression[inner_range])\n end\n\n integer, fraction = expression.split(/\\+/)\n num, denom = Math.simplify_fraction(fraction).split('/').map(&:to_i)\n Math.reduce_fraction \"#{num + integer.to_i * denom}/#{denom}\"\nend", "def parse_expression(expr); end", "def math_eval(str)\n # iterate over string values\n # perhaps utilize a queue till you hit a symbol?\n # left operand and right operand (do we care about order of operations?)\n copy = str\n total = 0\n tokens = []\n\n copy.chars.each_with_index do |ch, idx|\n if ch == '*' || ch == '/' || ch == '+' || ch == '-'\n divided = str.split(ch)\n tokens << divided.shift.to_i\n tokens << ch\n copy = divided\n end\n if idx == copy.length - 1\n tokens << copy\n end\n # break if ch.match(/()+\\-*/) && operator != ''\n # operator = ch.match(/()+\\-*/)\n # left_operand = ch if ch.match(/0-9/) && operator == ''\n # right_operand += ch if ch.match(/0-9/) && operator != ''\n end\n return tokens\n\n p \"operator: #{operator}, left_operand: #{left_operand}, right_operand: #{right_operand}\"\n return left_operand.to_i if operator == ''\n return left_operand.to_i + right_operand.to_i if operator == '+'\n return left_operand.to_i - right_operand.to_i if operator == '-'\n return left_operand.to_i / right_operand.to_i if operator == '/'\n return left_operand.to_i * right_operand.to_i if operator == '*'\nend", "def mystery_math(str)\n str.gsub(%r{[+\\-*/]},\"?\")\nend", "def detect_exp(str)\n \n node = nil\n exp = str.slice!(/^[0-9]+/)\n\n if exp != nil # is digit\n node = Node.new(exp)\n str = str.sub(/#{exp}/,\"\")\n else\n # check if is operator\n exp = @grammar.search(str)\n node = exp[1]\n str = exp[0]\n #if (exp != nil)\n # exp = exp[:out]\n # node = Node.new(exp, Type::OPERATOR)\n #end\n end\n\n\n\n return [str, node]\n\n end", "def evaluate(exp)\n\twhile x = exp =~ /[\\*\\/]/\n\t\tres = 0\n\t\tcase exp[x]\n\t\twhen '*'\n\t\t\tk, p = x-1, \"\"\n\t\t\tnum1, num2 = 0, 0\n\t\t\twhile k >= 0\n\t\t\t\tif exp[k] != '*' && exp[k] != '/' && exp[k] != '+' && exp[k] != '-'\n\t\t\t\t\tp += exp[k]\n\t\t\t\t\tk -= 1\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tnum1 = p.reverse.to_i\n\t\t\tk, p = x+1, \"\"\n\t\t\twhile k < exp.length\n\t\t\t\tif exp[k] != '*' && exp[k] != '/' && exp[k] != '+' && exp[k] != '-'\n\t\t\t\t\tp += exp[k]\n\t\t\t\t\tk += 1\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tnum2 = p.to_i\n\t\t\tres = num1 * num2\n\t\t\tres = res.to_s\n\t\t\texp = exp.sub(/\\d*\\*\\d*/, res)\n\t\twhen '/'\n\t\t\tk, p = x-1, \"\"\n\t\t\tnum1, num2 = 0, 0\n\t\t\twhile k >= 0\n\t\t\t\tif exp[k] != '*' && exp[k] != '/' && exp[k] != '+' && exp[k] != '-'\n\t\t\t\t\tp += exp[k]\n\t\t\t\t\tk -= 1\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tnum1 = p.reverse.to_i\n\t\t\tk, p = x+1, \"\"\n\t\t\twhile k < exp.length\n\t\t\t\tif exp[k] != '*' && exp[k] != '/' && exp[k] != '+' && exp[k] != '-'\n\t\t\t\t\tp += exp[k]\n\t\t\t\t\tk += 1\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tnum2 = p.to_i\n\t\t\tres = num1 / num2\n\t\t\tres = res.to_s\n\t\t\texp = exp.sub(/\\d*\\/\\d*/, res)\n\t\tend\n\tend\n\twhile x = exp =~ /[\\+\\-]/\n\t\tres = 0\n\t\tcase exp[x]\n\t\twhen '+'\n\t\t\tk, p = x-1, \"\"\n\t\t\tnum1, num2 = 0, 0\n\t\t\twhile k >= 0\n\t\t\t\tif exp[k] != '*' && exp[k] != '/' && exp[k] != '+' && exp[k] != '-'\n\t\t\t\t\tp += exp[k]\n\t\t\t\t\tk -= 1\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tnum1 = p.reverse.to_i\n\t\t\tk, p = x+1, \"\"\n\t\t\twhile k < exp.length\n\t\t\t\tif exp[k] != '*' && exp[k] != '/' && exp[k] != '+' && exp[k] != '-'\n\t\t\t\t\tp += exp[k]\n\t\t\t\t\tk += 1\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tnum2 = p.to_i\n\t\t\tres = num1 + num2\n\t\t\tres = res.to_s\n\t\t\texp = exp.sub(/\\d*\\+\\d*/, res)\n\t\twhen '-'\n\t\t\tk, p = x-1, \"\"\n\t\t\tnum1, num2 = 0, 0\n\t\t\twhile k >= 0\n\t\t\t\tif exp[k] != '*' && exp[k] != '/' && exp[k] != '+' && exp[k] != '-'\n\t\t\t\t\tp += exp[k]\n\t\t\t\t\tk -= 1\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tnum1 = p.reverse.to_i\n\t\t\tk, p = x+1, \"\"\n\t\t\twhile k < exp.length\n\t\t\t\tif exp[k] != '*' && exp[k] != '/' && exp[k] != '+' && exp[k] != '-'\n\t\t\t\t\tp += exp[k]\n\t\t\t\t\tk += 1\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tnum2 = p.to_i\n\t\t\tres = num1 - num2\n\t\t\tres = res.to_s\n\t\t\texp = exp.sub(/\\d*\\-\\d*/, res)\n\t\tend\n\tend\n\texp\nend", "def mixed_fraction(string)\n improper = Rational(*(string.split('/').map(&:to_i)))\n integer = improper.to_i\n fraction = improper - integer\n \n return \"#{integer}\" if (fraction).numerator == 0\n return \"#{fraction}\" if integer == 0\n \"#{integer} #{fraction.abs}\"\nend", "def do_math(math)\n case math\n when PARENTHESES_CAPTURE_RX # match parentheses\n math = math.gsub(PARENTHESES_CAPTURE_RX) do |match|\n do_math($1)\n end\n\n do_math(math)\n when /^#{NUMBER_RX}(?:#{SIGN_RX}#{NUMBER_RX})+$/\n solve_math(math)\n when /^#{NUMBER_RX}$/\n math.to_f\n when /^#{SIGN_RX}$/\n math\n else\n raise \"Invalid math expression: #{math}\"\n end\n end", "def parse_decimal_part(str)\n map = if str.index('割')\n Numeja::JA_割合用小数\n else\n Numeja::JA_小数\n end\n keys = map.keys()\n keys.reduce(0) do |t, ja_digit|\n index = str.index(ja_digit)\n break t if index.nil?\n unit = str.slice!(0, index)\n str.slice!(0, 1)\n t += (unit.to_f * map[ja_digit])\n t\n end\n end", "def fraction_to_float(fraction)\n return 0.0 if fraction == \"0\"\n sign = PDG::single_character(fraction) == \"+\" ? 1.0 : -1.0\n sign * Rational(*(fraction[1..-1].split(\"/\").map(&:to_i))).to_f\n end", "def mystery_math(string)\n string.sub(/[+\\-*\\/]/, '?')\nend", "def mysterious_math(string)\n string.gsub(/[+\\-*\\/]/, '?')\nend", "def mysterious_math(string)\n string.gsub(/[+\\-*\\/]/, '?')\nend", "def parse_inline_math; end", "def parse_percentage_expression\n regex = /(?<percentage>-?[\\d.]+)% (?<operator>(off?|on)) (?<expr>.*$)/\n match = @expression.match(regex)\n\n if match\n operator = match.named_captures[\"operator\"]\n percentage = match.named_captures[\"percentage\"]\n expr = match.named_captures[\"expr\"]\n\n percentage_expr = \"#{expr} * #{percentage.to_f/100}\"\n\n case operator\n when 'of'\n @expression = percentage_expr\n when 'off'\n @expression = \"#{expr} - (#{percentage_expr})\"\n when 'on'\n @expression = \"#{expr} + (#{percentage_expr})\"\n end\n end\n end", "def mystery_math(text)\n puts text.sub(/[+\\-*\\/]/, '?')\nend", "def mystery_math(string)\n string.sub(/[\\+\\-\\*\\/]/, '?')\nend" ]
[ "0.6410246", "0.62995255", "0.6243231", "0.622659", "0.6140983", "0.6134576", "0.61240894", "0.61015075", "0.61015075", "0.6077909", "0.6067399", "0.6062985", "0.6049504", "0.60353273", "0.5989603", "0.5976603", "0.59293586", "0.5923835", "0.5917157", "0.5911231", "0.5881463", "0.5866193", "0.5828885", "0.58207506", "0.5759348", "0.5759348", "0.5748573", "0.5747819", "0.5694582", "0.569205" ]
0.73577005
0
GET /areas GET /areas.xml
def index @areas = Area.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @areas } format.json {render :json => @areas} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @area = Area.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @area }\n end\n end", "def show\n @area = Area.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @area }\n end\n end", "def show\n @area = Area.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @area }\n end\n end", "def index\n @areas = Area.with_ordered_countries\n respond_with(@areas)\n end", "def index\n @areas = Area.all\n end", "def show\n @area = Area.find(params[:id]) \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @area }\n end\n end", "def show\n @breadcrumb = 'read'\n @area = Area.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @area }\n end\n end", "def get_areas\n area_lists = @page.search('ul.list-balloon__list-col')\n\n areas = []\n if area_lists.length > 1\n area_lists.each do |area_list|\n a_tags = area_list.search('a')\n a_tags.each do |a|\n areas.push({\n name: a.text,\n uri: a.attribute('href').value\n })\n end\n end\n else\n a_tags = area_lists.search('a')\n a_tags.each do |a|\n areas.push({\n name: a.text,\n uri: a.attribute('href').value\n })\n end\n end\n\n areas\n end", "def show\r\n @area = Area.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @area }\r\n end\r\n end", "def index\n @core_areas = Core::Area.find_mine(params).paginate(page: params[:page])\n\n respond_to do |format|\n format.html {}\n format.json {}\n end\n end", "def show\n @area = Area.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @area }\n end\n end", "def index\r\n @domain = Domain.find(params[:domain_id])\r\n @areas = Area.includes(:domain).includes(:filter_type_property).\r\n includes(:interval_property).includes(:language_code_property).\r\n where(domain_id: @domain.id).rank(\"row_order\").page(params[:page]).per(@@page_size)\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @areas }\r\n end\r\n end", "def index\n @amenities = Amenity.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @amenities }\n end\n end", "def show\n @test_area = TestArea.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @test_area }\n end\n end", "def index\n @group_areas = GroupArea.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @group_areas }\n end\n end", "def index\n @area_attributes = AreaAttribute.all\n end", "def show\n set_user_and_user_areas\n @searched_areas << Area.find(params[:area][:id])\n render :index\n end", "def show\n @tarea = Tarea.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tarea }\n end\n end", "def getRoutes\n # [[\"MTA NYCT_B65\", \"B65\", \"Downtown Brooklyn - Crown Heights\", \"via Bergen St & Dean St\"]...]\n url = \"http://bustime.mta.info/api/where/routes-for-agency/MTA%20NYCT.xml?key=#{APIKEY}\"\n xml_str = Net::HTTP.get URI(url)\n xml = Nokogiri::XML(xml_str)\n xml.css(\"response data list route\").to_a.map{|rte| [rte.css('id').text, rte.css('shortName').text, rte.css('longName').text, rte.css('description').text]}\nend", "def show\n @carea = Carea.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @carea }\n end\n end", "def show\n @area = Area.find(params[:id])\n respond_with(@area)\n end", "def mountain_area_sitelist\n query('txt/wxfcs/mountainarea/json/sitelist')\n end", "def index\n @survey_areas = SurveyArea.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @survey_areas }\n end\n end", "def index\n @areas = Area.all\n @target_users = User.where(User.arel_table[:location].not_eq nil)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @areas }\n end\n end", "def show\n @area_type = AreaType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @area_type }\n end\n end", "def index\n @areas_skills = AreasSkill.all\n end", "def show\n @projectarea = Projectarea.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @projectarea }\n end\n end", "def index\n @userareas = Userarea.all\n @users = User.all\n @areas = Area.all\n end", "def areas\n @area = Area.new(geo_json: params.to_json)\n if @area.save\n json_response([id: @area.id], :created, :geo_json_recieved)\n else\n json_response(nil, :error, :db_error)\n end\n end", "def locations\n get('locations')\n end" ]
[ "0.6694957", "0.6694957", "0.668683", "0.6678448", "0.6648974", "0.6624093", "0.64477986", "0.6316839", "0.6204598", "0.61896354", "0.6177351", "0.6122083", "0.61079425", "0.60862327", "0.60821307", "0.60779876", "0.60776937", "0.60476613", "0.60455006", "0.6039731", "0.6029421", "0.60035646", "0.5941082", "0.59129775", "0.5908687", "0.58966905", "0.58683825", "0.5858555", "0.58554953", "0.5823523" ]
0.72328097
0
GET /areas/new GET /areas/new.xml
def new @area = Area.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @area } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @area = Area.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @area }\n end\n end", "def new\n @area = Area.new\n @other_areas = Area.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @area }\n end\n end", "def new\n @area = Area.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @area }\n end\n end", "def new\n @area = Area.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @area }\n end\n end", "def new\n @projectarea = Projectarea.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @projectarea }\n end\n end", "def new\n @course = Course.new()\n @areas = Area.find(:all)\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course }\n end\n end", "def new\n @area_type = AreaType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @area_type }\n end\n end", "def create\n @area = Area.new(params[:area])\n\n respond_to do |format|\n if @area.save\n flash[:notice] = 'Area was successfully created.'\n format.html { redirect_to(@area) }\n format.xml { render :xml => @area, :status => :created, :location => @area }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @area.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @omatsuri }\n end\n end", "def new\n @openmapa = Openmapa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @openmapa }\n end\n end", "def new\n @breadcrumb = 'create'\n @area = Area.new\n @departments = departments_dropdown\n @workers = workers_dropdown\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @area }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end", "def new\n @carea = Carea.new\n @cgenerales = Cgeneral.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @carea }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @location }\n end\n end", "def new\n @subject_area = SubjectArea.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @subject_area }\n end\n end", "def new\n @geoname = Geoname.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @geoname }\n end\n end", "def new\n @location = Location.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @location_region }\n end\n end", "def new\n @area_of_law = AreaOfLaw.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: admin_areas_of_law_path(@area_of_law) }\n end\n end", "def new\n @route = Route.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @route }\n end\n end", "def new\n @route = Route.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @route }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @factor_reconocimiento = FactorReconocimiento.new(:area_id=>params[:area_id]) \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @factor_reconocimiento }\n end\n end", "def new\n @localmap = Localmap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @localmap }\n end\n end" ]
[ "0.76568425", "0.7175821", "0.70477766", "0.70477766", "0.70362586", "0.70019346", "0.6818052", "0.67239827", "0.67076266", "0.6675978", "0.66484386", "0.6646048", "0.66091365", "0.65835524", "0.6563556", "0.65548724", "0.65456337", "0.65450054", "0.6543472", "0.653868", "0.653868", "0.65220726", "0.6521586", "0.6521586", "0.6521586", "0.6521586", "0.6521586", "0.6521586", "0.6499645", "0.6461315" ]
0.7650926
1
PUT /areas/1 PUT /areas/1.xml
def update @area = Area.find(params[:id]) respond_to do |format| if @area.update_attributes(params[:area]) flash[:notice] = 'Area was successfully updated.' format.html { redirect_to(@area) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @area.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @area = Area.find(params[:id])\n \n respond_to do |format|\n if @area.update_attributes(params[:area])\n flash[:notice] = 'Area actualizado correctamente.'\n format.html { redirect_to(@area) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @area.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @area = Area.find(params[:id])\n\n respond_to do |format|\n if @area.update_attributes(params[:area])\n #format.html { redirect_to(@area, :notice => \"#{@area.to_s} was successfully updated.\") }\n format.html { redirect_to(locations_url, :notice => \"#{@area.to_s} was successfully updated.\") }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @area.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @area = Area.find(params[:id])\n\n respond_to do |format|\n if @area.update_attributes(params[:area])\n format.html { redirect_to @area, notice: 'Area was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @area = Area.find(params[:id])\n\n respond_to do |format|\n if @area.update_attributes(params[:area])\n format.html { redirect_to @area, notice: 'Area was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @area = Area.find(params[:id])\n\n respond_to do |format|\n if @area.update_attributes(params[:area])\n format.html { redirect_to @area, notice: 'Area was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def update\n @map_area = MapArea.find(params[:id])\n respond_to do |format|\n if @map_area.update_attributes(params[:map_area])\n flash[:notice] = 'MapArea was successfully updated.'\n format.html { redirect_to map_areas_path }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @map_area.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @map_area = MapArea.find(params[:id])\n respond_to do |format|\n if @map_area.update_attributes(params[:map_area])\n flash[:notice] = 'MapArea was successfully updated.'\n format.html { redirect_to map_areas_path }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @map_area.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\r\n @area = Area.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @area.update_attributes(params[:area])\r\n format.html { redirect_to areas_url(domain_id: @area.domain_id), notice: 'Area was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @area.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @area_type = AreaType.find(params[:id])\n\n respond_to do |format|\n if @area_type.update_attributes(params[:area_type])\n format.html { redirect_to @area_type, notice: 'Area type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @area_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @area_attribute.update(area_attribute_params)\n format.html { redirect_to @area_attribute, notice: 'Area attribute was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @area_attribute.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n begin\n @area = Area.find(params[:id])\n @area.update_attributes(params[:area])\n\n flash[:notice] = t(:success_updated, :id => @area.id)\n redirect_to(areas_url)\n rescue => e\n# flash[:error] = t(:error_default, :message => e.message)\n render :action => :edit\n end\n end", "def update\n if params[:recursos][:status] == '1'\n @count = count_of_resource\n save_multiples_recursos\n end\n respond_to do |format|\n if @area.update(area_params)\n format.html { redirect_to @area, notice: 'El Área fue modificada éxitosamente.' }\n format.json { render :show, status: :ok, location: @area }\n else\n format.html { render :edit }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @area.update_attributes(area_params)\n flash[:notice] = \"#{@area.name} has been updated.\"\n redirect_to @area\n else\n render :action => 'edit'\n end\n end", "def set_area\n @area = Area.find(params[:area_id])\n end", "def set_area\n @area = Area.find_by_id(params[:id])\n if @area.blank?\n json_response(nil, :unprocessable_entity, :invalid_id)\n end\n end", "def update\n @survey_area = SurveyArea.find(params[:id])\n\n respond_to do |format|\n if @survey_area.update_attributes(params[:survey_area])\n format.html { redirect_to @survey_area, notice: 'Survey area was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey_area.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n @area.skus = params[:area][:skus]\n if @area.update area_params\n format.html { redirect_to admin_areas_path, notice: 'Area was successfully updated.' }\n format.json { render :show, status: :ok, location: @area }\n else\n format.html { render :edit }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tarea = Tarea.find(params[:id])\n\n respond_to do |format|\n if @tarea.update_attributes(params[:tarea])\n flash[:notice] = 'Tarea actualizado correctamente.'\n format.html { redirect_to(@tarea.cargo) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tarea.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_area\n @area = Area.find(params[:id])\n end", "def set_area\n @area = Area.find(params[:id])\n end", "def set_area\n @area = Area.find(params[:id])\n end", "def set_area\n @area = Area.find(params[:id])\n end", "def update_location(params)\n @client.put(\"#{path}/location\", nil, params, \"Content-Type\" => \"application/json\")\n end", "def update\n @interest_area = InterestArea.find(params[:id])\n\n respond_to do |format|\n if @interest_area.update_attributes(params[:interest_area])\n format.html { redirect_to @interest_area, notice: 'Interest area was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interest_area.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @carea = Carea.find(params[:id])\n\n respond_to do |format|\n if @carea.update_attributes(params[:carea])\n format.html { redirect_to(@carea, :notice => 'Carea was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @carea.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @breadcrumb = 'update'\n @area = Area.find(params[:id])\n @area.updated_by = current_user.id if !current_user.nil?\n\n respond_to do |format|\n if @area.update_attributes(params[:area])\n format.html { redirect_to @area,\n notice: (crud_notice('updated', @area) + \"#{undo_link(@area)}\").html_safe }\n format.json { head :no_content }\n else\n @departments = departments_dropdown\n @workers = @area.department.blank? ? workers_dropdown : workers_by_department(@area.department)\n format.html { render action: \"edit\" }\n format.json { render json: @area.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @projectarea = Projectarea.find(params[:id])\n\n respond_to do |format|\n if @projectarea.update_attributes(params[:projectarea])\n flash[:notice] = 'Projectarea was successfully updated.'\n format.html { redirect_to(@projectarea) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @projectarea.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tarea.update(tarea_params)\n format.html { redirect_to @tarea, notice: 'Tarea was successfully updated.' }\n format.json { render :show, status: :ok, location: @tarea }\n else\n format.html { render :edit }\n format.json { render json: @tarea.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_area\n @area = Area.find(params[:id])\n end" ]
[ "0.6410856", "0.6384846", "0.63053644", "0.63053644", "0.63053644", "0.61739045", "0.6122322", "0.6122322", "0.59582716", "0.5875499", "0.5841774", "0.57423276", "0.5738485", "0.5698895", "0.56285596", "0.5619221", "0.5589899", "0.5578848", "0.5577936", "0.55620617", "0.5464764", "0.5464764", "0.5464764", "0.5449888", "0.5449707", "0.5442562", "0.5441261", "0.5411944", "0.5389887", "0.5379302" ]
0.6549098
0
def jasper send_doc_xml(xml, '/records/record', 'directorio', 'Directorio',
def jasper param=Hash.new {|k, v| k[v] = {:tipo=>"",:valor=>""}} param["PDIRECCION"]={:tipo=>"String", :valor=>"DIRECCION DE INFORMATICA"} param["PDEPARTAMENTO"]={:tipo=>"String", :valor=>"DEPARTAMENTO DE BASE DE DATOS"} send_doc_xml(xml,'/records/record', 'directorio','Directorio',param,'pdf') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_request( xml )\n write( xml )\n read\n end", "def send_xml(filename, xml)\n send_data xml,\n filename: filename,\n type: 'text/xml; charset=UTF-8;',\n disposition: 'attachment;'\n end", "def storeRecord\n @doc[:xml_display] = @xml.to_xml\n end", "def storeRecord\n @doc[:xml_display] = @xml.to_xml\n end", "def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end", "def records_as_xml( quantity = 1 )\n addr_arr = self.records(quantity)\n XmlSimple.xml_out( { :address => addr_arr },\n { :NoAttr=>true, :RootName=>:emailing,\n :XmlDeclaration=>true } )\n end", "def doc_xml(xml)\r\n primary_output_files.each_with_index do |output, i|\r\n xml.doc(:ID => i + 1) do\r\n xml.tag!(:batch_attrib, 1)\r\n xml.tag!(:doc_cont_cd, doc_cont_cd(output))\r\n xml.tag!(:subtype_cd, 'PLN')\r\n xml.tag!(:filename, output.file_name)\r\n xml.tag!(:file_size, output.file_size)\r\n end\r\n end\r\n xml\r\n end", "def send_xml(xml)\n connection.ProcessRequest(session, xml)\n rescue => e\n puts \"ERROR processing request:\\n#{xml}\"\n raise # Reraises the original error, only this way we got the xml output\n end", "def send_doc\n tpl = Template.find(params[\"template_id\"])\n tpl.load(params[:id])\n \n Notification.deliver_order_email(self, tpl)\n Notification.deliver_order_fax(self, tpl)\n \n log = OrderLog.create({\n :order_id => params[:id],\n :subject => 'notification',\n :msg => 'Sent order-document \"' + tpl.label + '\"',\n :account_id => self.current_user.account.id,\n :order_log_type_id => OrderLogType.find_by_name('notification').id \n })\n \n res = RResponse.new\n res.add_action(RAction.new({\n :component_id => 'order-log-' + params[:id],\n :success => true,\n :data => {:log => log.to_a}\n }))\n res.success = true\n res.msg = 'Transmitted document \"' + tpl.label + '\"'\n respond(res)\n end", "def xml\n\t\theaders[\"Content-Type\"] = \"text/xml; charset=utf-8\"\n\t\trender :layout => false\n\tend", "def send(xml)\n msg = <<EOL\n<?xml version=\"1.0\"?>\n<?qbxml version=\"#{QBXML_VERSION}\"?>\n<QBXML>\n <QBXMLMsgsRq onError=\"continueOnError\">\n #{xml}</QBXMLMsgsRq>\n</QBXML>\nEOL\n puts msg\n @soap_client.ProcessRequest(@ticket, xml)\n end", "def _to_xml(xml)\n end", "def records_as_xml( quantity = 1 )\n addr_arr = self.records(quantity).collect { |a| a.to_hash }\n XmlSimple.xml_out( { :address => addr_arr },\n { :NoAttr=>true,\n :RootName=>:mailing,\n :XmlDeclaration=>true } )\n end", "def xml; end", "def pacscl_xml\n document = Blacklight.default_index.search(q: \"id:#{params[:id]}\")&.dig(\"response\", \"docs\")&.first\n document = SolrDocument.new(document)\n document.suppress_xml_containers!\n respond_to do |format|\n format.xml do\n render xml: document.export_as_xml\n end\n end\n end", "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 tran_xml(xml, index, job, batch, transaction_set_count) \n if !payer.blank? && !payer.status.blank? && (!payer.gateway.blank? || !payer.gateway_temp.blank?)\n gateway = payer.status.upcase == 'MAPPED' ? payer.gateway : (payer.gateway_temp || 'HLSC')\n payid = payer.payer_identifier(micr_line_information)\n footnote_indicator = (payer.footnote_indicator ? 1 : 0)\n else raise 'Invalid Payer'\n puts \"Payer record for check number #{check_number} is incomplete or invalid\"\n log.error \"Payer record for check number #{check_number} is incomplete or invalid\"\n end\n\n payee_name ||= batch.facility.name.to_s.strip\n xml.tran(:ID => index + 1) do\n xml.tag!(:batch_attrib, 1)\n xml.tag!(:gateway, gateway)\n xml.tag!(:pay_id, payid)\n xml.tag!(:payee_nm, (payee_name.slice(0, 25) if !payee_name.blank?))\n xml.tag!(:aba_num, (micr_line_information.aba_routing_number if micr_line_information))\n xml.tag!(:chk_act, (micr_line_information.payer_account_number if micr_line_information))\n xml.tag!(:chk_num, check_number)\n xml.tag!(:chk_amt, sprintf('%.02f', check_amount.to_f))\n xml.tag!(:eob_id, (index + 1))\n xml.tag!(:tid, job.transaction_number)\n xml.tag!(:rework, '0')\n xml.tag!(:payer_footnote_based, (footnote_indicator || 0))\n xml.tag!(:worklist_status_cd, '')\n xml.tag!(:transaction_receipt_dt, (batch.date.strftime(\"%Y-%m-%d\") unless batch.date.blank?))\n xml.tag!(:hlsc_file_nm, batch.src_file_name)\n xml.tag!(:show_on_worklist, '0')\n xml.tag!(:transaction_guid, guid)\n end\n transaction_set_count += 1\n end", "def generate_xml_report(servers)\n\t\t\txmlstring = \"\"\n\t\t\tdoc = Document.new xmlstring\n\t\t\tdoc << XMLDecl.new\n\t\t\tdocroot = doc.add_element('ServerMonitor')\n\t\t\txslt_text = 'type=\"text/xsl\" href=\"servermonitor.xsl\"'\n\t\t\txslt = Instruction.new(\"xml-stylesheet\", xslt_text)\n\t\t\troot = doc.root\n\t\t\troot.previous_sibling = xslt\n\t\t\tdocroot = add_report_xml(docroot,servers)\n\t\t\tdoc.to_s\n\t\tend", "def playback(record_name)\n recorded = File.read(\"./data/stanzas/#{record_name}.xml\")\n\n xml = REXML::Document.new('<root>' + recorded + '</root>')\n\n xml.root.elements.each do |stanza|\n stanza.attributes['to'] = @jid.to_s\n\n @session.send_raw(stanza)\n end\n end", "def send_xml(xml)\n if xml.is_a? Nokogiri::XML::NodeSet\n xml.each do |element|\n send_chunk(element.to_s)\n end\n else\n send_chunk(xml.to_s)\n end\n end", "def attach_xml\n attach(:xml, xml)\n end", "def export_xml\n @quo= Quotation.all\n send_data @quo.as_json.to_xml.to_s\n end", "def create_doc\n\t\theaders = {:content_type => 'application/xml'}\n\t\turi = CGI.escape(\"/\" + rand(2).to_s() + \"/\" + rand(10).to_s() + \"/\" + rand(1000000).to_s() + \".xml\")\n\t\tresponse = @resource[\"/documents/\" + uri].put('<stuff xmlns=\"stuff\">' + uri + '</stuff>', headers)\n\t\treturn uri\n\tend", "def generate_xml_request\n tax_receipt = generate_tax_receipt\n @certificate.certifica tax_receipt\n @key.sella tax_receipt\n tax_receipt.to_xml\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.TrackRequest(:xmlns => \"http://fedex.com/ws/track/v5\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n # add_request_timestamp(xml)\n add_track_request(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def create_doc(doc_records)\n puts \"create_doc Not implemented\"\n end", "def make_xml_request( opts={} )\n\t\topts = TEST_XML_REQUEST_OPTS.merge( opts )\n\t\theaders = normalize_headers( opts, TEST_XML_HEADERS )\n\t\theaders.delete( 'URI' ) # XML requests don't have one\n\n\t\tMongrel2.log.debug \"XML request, headers = %p, opts = %p\" % [ headers, opts ]\n\n\t\theaderstring = TNetstring.dump( Yajl::Encoder.encode(headers) )\n\t\tbodystring = TNetstring.dump( opts[:body] || \"#{TEST_XML_PATH} />\" )\n\n\t\t# UUID ID PATH SIZE:HEADERS,SIZE:BODY,\n\t\treturn \"%s %d %s %s%s\" % [\n\t\t\topts[:uuid],\n\t\t\topts[:id],\n\t\t\topts[:path],\n\t\t\theaderstring,\n\t\t\tbodystring,\n\t\t]\n\tend", "def render_xml\n end", "def create_xml_report(directory)\n # TODO: check for valid ctsa report data\n file_path = \"#{directory}/#{Time.now.to_i}.xml\"\n doc = REXML::Document.new\n doc.add_element(ReportBuilder.new(grant_number, reporting_year, attachments))\n doc.write(\"\",2)\n File.open(file_path, 'w') { |f| f.write(doc.to_s) }\n add_report_xml_to_attachments(file_path)\n file_path\n end", "def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/loan/v1\")\n end" ]
[ "0.62114716", "0.60725754", "0.5960064", "0.5960064", "0.59567064", "0.59205145", "0.58485335", "0.5790174", "0.5708926", "0.566242", "0.56293", "0.56049407", "0.55978394", "0.55817145", "0.5574788", "0.556254", "0.5521902", "0.55146384", "0.5438292", "0.5437214", "0.5432905", "0.5403207", "0.53820145", "0.5356115", "0.53264064", "0.531839", "0.53159857", "0.53034115", "0.53021276", "0.5290825" ]
0.75981283
0
Visualize real time tweet locations to given output dir.
def visualize_real_time_topics(auth, topics, output_dir = "plots") rserve_setup @output_dir = output_dir FileUtils.mkdir_p output_dir @buffer = Array.new @client = Twitter::Streaming::Client.new do |config| config.consumer_key = auth[:consumer_key] config.consumer_secret = auth[:consumer_secret] config.access_token = auth[:access_token] config.access_token_secret = auth[:access_token_secret] end stream = Thread.new { listen_for_tweets(topics) } @plot_index = 0 # Visualize while streaming while stream.alive? @plot_index += 1 if plot_tweet_locations sleep PLOT_DELAY end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_results(generated_files: true)\n @end_time = Time.now\n tree = if generated_files\n [' ',\n \"Generated files: #{@out_dir}\",\n ' ',\n TTY::Tree.new(@out_dir).render]\n else\n ''\n end\n puts\n puts TTY::Box.frame(\"Start : #{@start_time}\",\n \"End : #{@end_time}\",\n \"Time : #{@end_time - @start_time} sec\",\n *tree,\n title: { top_left: \" #{self.class.name} \" },\n width: TTY::Screen.width, padding: 1)\n end", "def visualize_historical_topics(auth, query, num_results = 100,\n output_dir = \"plots\")\n rserve_setup\n @output_dir = output_dir\n FileUtils.mkdir_p output_dir\n @buffer = Array.new\n @client = Twitter::REST::Client.new do |config|\n config.consumer_key = auth[:consumer_key]\n config.consumer_secret = auth[:consumer_secret]\n config.access_token = auth[:access_token]\n config.access_token_secret = auth[:access_token_secret]\n end\n \n @plot_index = 0\n max_id = 0\n # Keep requesting until the number of tweets have been found.\n while @buffer.length < num_results do\n options = \n {\n count: 100\n }\n options[:max_id] = max_id if max_id > 0\n begin\n result = @client.search(query, options)\n result.each do |tweet|\n # Stop if all tweets are registered.\n break if @buffer.length >= num_results\n \n if tweet.is_a?(Twitter::Tweet) and not tweet.place.nil?\n @buffer << { tweet: tweet, ttl: tweet.created_at + TWEET_LIFE_TIME }\n # Print status\n print \"#{@buffer.length}/#{num_results}\\r\"\n $stdout.flush\n end\n end\n rescue Twitter::Error::TooManyRequests\n print \"Rate limit exceeded. Sleeping...\\r\"\n $stdout.flush\n sleep(30)\n end\n # Set new max id\n max_id = @buffer.last[:tweet].id if not @buffer.last.nil?\n end\n \n puts \"Exporting...\"\n # Visualize\n len = @buffer.length\n @buffer.each_with_index do |tweet,i|\n @plot_index += 1 if plot_tweet_locations(tweet[:tweet].created_at)\n print \"#{i}/#{len} \\r\"\n $stdout.flush\n end\n end", "def plot_tweet_locations(to_time = Time.now)\n\n # Remove old elements from buffer\n while !@buffer.empty? and @buffer.first[:ttl] < Time.now do\n @buffer.shift\n end\n return false if @buffer.empty?\n\n data = Hash[:lat, Array.new(0), :long, Array.new(0)]\n @buffer.each do |tweet|\n data[:lat] << tweet[:tweet].place.bounding_box.coordinates[0][0][0]\n data[:long] << tweet[:tweet].place.bounding_box.coordinates[0][0][1]\n end\n\n df = Rserve::DataFrame.new(data)\n @rserve.command( df: df ) do \n %Q{\n ggsave('#{File.join(@output_dir, \"world_#{@plot_index}.png\")}',\n plotworld(df, #{POINT_SIZE}, #{POINT_ALPHA}),\n width=#{OUTPUT_WIDTH},\n height=#{OUTPUT_HEIGHT}\n )\n }\n end\n return true\n end", "def print_timeline(tweets)\n \ttweets.each do |tweet| File.open(\"tweet.txt\", 'w') {|f| f.write(tweet[\"text\"]) } end\nend", "def show\n set_up_twitter\n\n get_last_tweet\n get_five_last_tweets\n end", "def run\n @logger.debug \"LastId is \" + @last_id.to_s\n tweets = collect_tweets\n\n @generator.generate_rss_file tweets unless tweets.instance_of? NilClass\n\n # the last thing we do:\n @config.write\n @logger.info \"....and we are done.\\n\\n\"\n end", "def display_timeline\n timeline_search_results = []\n TWITTER.home_timeline.each do |tweet|\n timeline_search_results << [tweet.user.name, tweet.text]\n # binding.pry\n end\n timeline_search_results\n end", "def render\n\t\tputs \"Lista de tweets\"\n\t\t\n\t\t#listamos los tweets\n\t\tif tweets.empty?\n\t\t\tputs \"No hay tweets para mostrar\"\n\t\telse\n\t\t\t@tweets.each do |tweet|\n\t\t\t\tputs \"*\"*10\n\t\t\t\tputs tweet.message\n\t\t\t\tputs tweet.time.to_s\n\t\t\tend\n\t\tend\n\n\tend", "def display_new_retweets\n\t@curr_top = @top_after_new_stream\n\tclear_screen\n\tputs \"\"\n\tputs \"*\"*50\n\tputs \"TOP RETWEETS IN LAST #{@user_defined_window} MINUTE(S)\"\n\tputs \"*\"*50\n\tputs \"\"\n\t@curr_top.each do |retweet|\n\t\ttext = @tweet_db[retweet[0]][:original].text.gsub(/\\n/,\" \")\n\t\tcount = retweet[1]\n\t\tputs \"Retweet Count: #{count} Text: #{text}\"\n\tend\nend", "def print_tweets(tweets)\n\t\ttweets.each{ |tweet|\n\t\t\tprint_tweet(tweet)\n\t\t}\n\tend", "def print_tweets(tweets)\n\t\ttweets.each{ |tweet|\n\t\t\tprint_tweet(tweet)\n\t\t}\n\tend", "def tweet\n\t#gets what the last value was from the timeline\n\tlast = $client_twitter.user_timeline()[0].text.match('([0-9])+').string.to_i\n\t#calculates the new value\n\tnext_square = next_number(last)\n\t#these four numbers produce swastikas, so let's just not post those. I'm comfortable getting done 8 hours early for that\n\tif next_square == 28928495 || next_square == 32632615 || next_square == 921816 || next_square == 4625936\n\t\tnext_square = next_number(next_square)\n\tend\n\t#draws the square and saves the file name\n\tfile_name = draw_grid(next_square)\n\t#gets the text of the tweet\n\tnew_tweet = generate_tweet(next_square)\n\t#opens the file and posts\n\tFile.open(file_name) do |f|\n\t\t$client_twitter.update_with_media(new_tweet, f)\n\tend\n\t#deletes the file so it doesn't clutter up the place\n\tFile.delete(file_name)\n\t#And we're done!\n\tputs \"Posted to twitter\"\nend", "def show\n @all_tweets = set_tweet_collection.tweets\n end", "def index\n puts(\"Total tweets: #{Tweet.count}\")\n @tweets = Tweet.all\n @tweets.each do |tweet|\n puts( \"#{tweet.zombie}: #{tweet.status}\")\n end\n\n @tweets\n end", "def run\n @files.each do |file|\n generate_tracklist(file)\n end\n end", "def print_timeline(response)\n \n tweets = response[\"statuses\"]\n \n for tweet in tweets\n puts tweet[\"user\"][\"screen_name\"]\n puts tweet[\"text\"]\n end\n \nend", "def recent_tweets(count)\n start(\"/recent/tweets/#{count}\")\n end", "def output(path)\n if @first_pass\n @first_pass = false\n FileUtils.rm_rf path if clean_first\n end\n FileUtils.mkdir_p path\n \n if quick_mode\n posts.chop! 20\n end\n @stats.reset\n \n unless metadata.nil? || !metadata['static'].is_a?(Array)\n stats.record(:site, :static) do\n for dir in metadata['static']\n FileUtils.cp_r File.join(source_dir, dir), File.join(path, dir)\n end\n end\n end\n \n before = Time.now\n Dir.chdir(path) do\n stats.record(:site, :pages) do\n pages.each do |name, page|\n FileUtils.mkdir_p page.output_dir unless File.directory?(page.output_dir)\n if check_mtime\n if File.file?(page.output_path) && File.mtime(page.output_path) > page.source_mtime\n next\n end\n page.load\n end\n File.open(page.output_path, 'w') { |f| f.write page.render }\n end\n end\n \n stats.record(:site, :posts) do\n posts.each do |post|\n FileUtils.mkdir_p post.output_dir unless File.directory?(post.output_dir)\n if check_mtime\n if File.file?(post.output_path) && File.mtime(post.output_path) > post.source_mtime\n next\n end\n post.load\n end\n File.open(post.output_path, 'w') { |f| f.write post.render }\n end\n end\n \n stats.record(:site, :stylesheets) do\n unless stylesheets.nil?\n stylesheets.each do |name, stylesheet|\n FileUtils.mkdir_p stylesheet.output_dir unless File.directory?(stylesheet.output_dir)\n if check_mtime\n if File.file?(stylesheet.output_path) && File.mtime(stylesheet.output_path) > stylesheet.source_mtime\n next\n end\n stylesheet.load\n end\n File.open(stylesheet.output_path, 'w') { |f| f.write stylesheet.render }\n end\n end\n end\n \n stats.record(:site, :indices) do\n unless year_index.nil? && month_index.nil? && day_index.nil?\n posts.each_index do |dir|\n posts = self.posts.from(dir)\n Dir.chdir(dir) do\n context = dir.split('/').collect { |c| c.to_i }\n date_index = case context.length\n when 1\n year_index\n when 2\n month_index\n when 3\n day_index\n else\n nil\n end\n date_index.posts = posts\n date_index.context = Time.local *context\n File.open('index.html', 'w') { |f| f.write date_index.render }\n end\n end\n end\n \n unless tag_index.nil?\n tags.each do |tag|\n tag_index.context = tag.name\n tag_index.posts = tag\n FileUtils.mkdir_p tag.output_dir\n File.open(tag.output_path, 'w') { |f| f.write tag_index.render }\n end\n end\n end\n end\n \n self.stats.display if show_statistics\n end", "def share_location_on_twitter options={}\n if from_twitter?\n\n c_id = id\n c_id = \"4f696467043bac0001000002\" if Rails.env != \"production\"\n\n oauth = providers.where(provider: \"twitter\").first\n \n status_msg = self.swap_stat\n status_msg.gsub! /you/, \"me\" \n status_msg = \"On @myradddar! #{status_msg} http://www.radddar.com/#{c_id}\"\n\n Twitter.configure do |config|\n config.consumer_key = ENV[\"RDR_TWITTER_KEY\"]\n config.consumer_secret = ENV[\"RDR_TWITTER_SECRET\"]\n config.oauth_token = oauth[:token]\n config.oauth_token_secret = oauth[:secret]\n end\n\n client = Twitter::Client.new\n client.update(status_msg,{\n lat: self.loc[0],\n long: self.loc[1],\n }) rescue nil\n\n end\n end", "def generate_tweet_plot\n tweets = FeedEntry.mark_isolates(self.retweet_ids,self)\n \n Gnuplot.open do |gp|\n Gnuplot::Plot.new(gp) do |plot|\n plot.terminal \"svg\"\n plot.output id.to_s + \".svg\"\n plot.data = []\n r = Hash.new\n s = Hash.new\n i = Hash.new\n origin_date = DateTime.parse(FeedEntry.find(id).published_at.to_s)\n tweets.each do |tweet| \n hour_diff = (DateTime.parse(tweet[:published_at])-origin_date).hours.to_i\n if (person = Person.find_by_username(tweet[:person])) != nil\n if person.friends_ids.include?(self.person.twitter_id)\t\n r[hour_diff] == nil ? r[hour_diff] = tweet[:followers_count] : r[hour_diff] += tweet[:followers_count] \n elsif tweet[:isolate_status] == \"isolate\"\n i[hour_diff] == nil ? i[hour_diff] = tweet[:followers_count] : r[hour_diff] += tweet[:followers_count] \n else\n s[hour_diff] == nil ? s[hour_diff] = tweet[:followers_count] : s[hour_diff] += tweet[:followers_count] \n end\n end\n end\n x = []\n y = []\n x1 = []\n y1 = []\n x2 = []\n y2 = []\n total = 0\n values = {}\n i.sort.each do |e|\n if e[0] < 2*(x1.inject(0.0){|sum, el| sum + el }/x2.size) || x2.size < 5\n total += e[1]\n x2 << e[0]\n y2 << total\n end\n end\n s.sort.each do |e| \n if e[0] < 2*(x1.inject(0.0){|sum, el| sum + el }/x1.size) || x1.size < 5\n total += e[1]\n x1 << e[0]\n y1 << total\n end\n end\n r.sort.each do |e| \n if e[0] < 2*(x.inject(0.0){|sum, el| sum + el }/x.size) || x.size < 5\n total += e[1] \n x << e[0]\n y << total\n end\n end\n values[:ego_retweets] = [x,y]\n values[:ego2_retweets] = [x1,y1]\n values[:isolate_retweets] = [x2,y2]\n values.each do |k,v|\n plot.data << Gnuplot::DataSet.new([v[0],v[1]]){|ds|\n ds.with = \"linespoints\"\n ds.title = k\n }\n end\n end\n end \n end", "def index\n @tw_stats = TwStat.all\n end", "def print_timeline(tweets)\n # ADD CODE TO ITERATE THROUGH EACH TWEET AND PRINT ITS TEXT\n tweets.each do |tweet| puts tweet['text'] end\n \n\nend", "def timeline\n config = create_or_find_config\n \n timeline = :friends\n timeline = ARGV.shift.intern if ARGV.size > 0 && Twitter::Base.timelines.include?(ARGV[0].intern)\n \n puts\n Twitter::Base.new(config['email'], config['password']).timeline(timeline).each do |s|\n puts \"#{s.text}\\n-- #{s.user.name} at #{s.created_at}\"\n puts\n end\n end", "def print_twitter_search(tweets)\n #puts JSON.pretty_generate(tweet)\n tweets.each do |tweet|\n puts tweet[\"text\"] \n end \n end", "def get_tweets \n search_tweets.each do |tweet|\n #Can I add location data here?\n if Tweet.find_by_t_id(tweet.id.to_s).nil?\n t = Tweet.new(:t_id => tweet.id.to_s, :text => tweet.text, :user => tweet.from_user, :timestamp => tweet.created_at)\n t.save\n note_relateds(t.derive_hashtags)\n end\n end\n self.update_numtweets\n end", "def show\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = ENV[\"TWITTER_CONSUMER_KEY\"]\n config.consumer_secret = ENV[\"TWITTER_CONSUMER_SECRET\"]\n config.access_token = ENV[\"TWITTER_ACCESS_TOKEN\"]\n config.access_token_secret = ENV[\"TWITTER_ACCESS_TOKEN_SECRET\"]\n end\n\n begin\n timelines = client.user_timeline(@club.twitter_id)\n @tweets = []\n rescue\n end\n\n if timelines.present?\n timelines.each do |timeline_tweet|\n tweet = client.status(timeline_tweet.id)\n @tweets << tweet.text\n end\n end\n end", "def tweet!\n TWITTER.update(\"#{title.truncate(75)} - #{tweet_users}\\n\\nhttp://beta.briefideas.org/ideas/#{sha}\")\n self.update_columns(:tweeted => true)\n end", "def after_run\n check_output_files\n show_results\n end", "def weather_report(location)\n\n # Fetch weather\n weatherboy = Weatherboy.new(location)\n w = weatherboy.current\n Mac::TTS.say(\"The current weather in Atherton is #{w.temp_f} degrees and #{w.weather}\", :victoria)\n sleep(0.5)\n\nend", "def stream\n #kills all tweet streaming processes\n #system \"pkill -f stream_tweets\"\n\n #invokes rake task for streaming tweets for 2 different brands\n system \"rake stream_tweets BRAND1=#{@battle.brand1} BRAND2=#{@battle.brand2} BATTLE_ID=#{@battle.id} &\"\n end" ]
[ "0.60087085", "0.59309494", "0.5828771", "0.5811919", "0.57917863", "0.56043845", "0.55675924", "0.55351996", "0.5484866", "0.54670066", "0.54670066", "0.54403", "0.52702457", "0.5256494", "0.5229374", "0.5229109", "0.5224105", "0.520672", "0.5196536", "0.5191142", "0.5188054", "0.51800615", "0.51638687", "0.5162831", "0.5062061", "0.50423515", "0.50395197", "0.5014114", "0.49846607", "0.49812856" ]
0.6256422
0
Visualize locations of historical tweets of topic.
def visualize_historical_topics(auth, query, num_results = 100, output_dir = "plots") rserve_setup @output_dir = output_dir FileUtils.mkdir_p output_dir @buffer = Array.new @client = Twitter::REST::Client.new do |config| config.consumer_key = auth[:consumer_key] config.consumer_secret = auth[:consumer_secret] config.access_token = auth[:access_token] config.access_token_secret = auth[:access_token_secret] end @plot_index = 0 max_id = 0 # Keep requesting until the number of tweets have been found. while @buffer.length < num_results do options = { count: 100 } options[:max_id] = max_id if max_id > 0 begin result = @client.search(query, options) result.each do |tweet| # Stop if all tweets are registered. break if @buffer.length >= num_results if tweet.is_a?(Twitter::Tweet) and not tweet.place.nil? @buffer << { tweet: tweet, ttl: tweet.created_at + TWEET_LIFE_TIME } # Print status print "#{@buffer.length}/#{num_results}\r" $stdout.flush end end rescue Twitter::Error::TooManyRequests print "Rate limit exceeded. Sleeping...\r" $stdout.flush sleep(30) end # Set new max id max_id = @buffer.last[:tweet].id if not @buffer.last.nil? end puts "Exporting..." # Visualize len = @buffer.length @buffer.each_with_index do |tweet,i| @plot_index += 1 if plot_tweet_locations(tweet[:tweet].created_at) print "#{i}/#{len} \r" $stdout.flush end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n set_up_twitter\n\n get_last_tweet\n get_five_last_tweets\n end", "def display_timeline\n timeline_search_results = []\n TWITTER.home_timeline.each do |tweet|\n timeline_search_results << [tweet.user.name, tweet.text]\n # binding.pry\n end\n timeline_search_results\n end", "def visualize_real_time_topics(auth, topics, output_dir = \"plots\")\n rserve_setup\n @output_dir = output_dir\n FileUtils.mkdir_p output_dir\n @buffer = Array.new\n @client = Twitter::Streaming::Client.new do |config|\n config.consumer_key = auth[:consumer_key]\n config.consumer_secret = auth[:consumer_secret]\n config.access_token = auth[:access_token]\n config.access_token_secret = auth[:access_token_secret]\n end\n \n stream = Thread.new { listen_for_tweets(topics) }\n @plot_index = 0\n # Visualize while streaming\n while stream.alive?\n @plot_index += 1 if plot_tweet_locations\n sleep PLOT_DELAY\n end\n end", "def display_new_retweets\n\t@curr_top = @top_after_new_stream\n\tclear_screen\n\tputs \"\"\n\tputs \"*\"*50\n\tputs \"TOP RETWEETS IN LAST #{@user_defined_window} MINUTE(S)\"\n\tputs \"*\"*50\n\tputs \"\"\n\t@curr_top.each do |retweet|\n\t\ttext = @tweet_db[retweet[0]][:original].text.gsub(/\\n/,\" \")\n\t\tcount = retweet[1]\n\t\tputs \"Retweet Count: #{count} Text: #{text}\"\n\tend\nend", "def show\n\t\treferenced = @topic.tweets.count(:distinct)\n\t\tusers = @topic.tweets.user.count(:distinct)\n\t\trender json: show_json(@topic, referenced, users)\n\tend", "def show\n @all_tweets = set_tweet_collection.tweets\n end", "def timeline\n tweets = []\n following.merge(my_info).each do |nick,url|\n tweets.concat timeline_for_user(nick,url)\n end\n tweeets = tweets[-timeline_limit, timeline_limit].sort_by { |h| h[:date] }\n (timeline_sort == 'descending') ? tweets.reverse : tweets\nend", "def recent_tweets(count)\n start(\"/recent/tweets/#{count}\")\n end", "def timeline\n timeline = tweets.map { |tweet| tweet }\n all_following.each do |user|\n timeline += user.tweets.map { |tweet| tweet }\n end\n timeline.sort_by!(&:created_at).reverse\n end", "def timeline\n twitter.home_timeline\n end", "def show_recent_posts(keyword, hours = 4)\n\tclient = Twitter::REST::Client.new(TWITTER)\n\tputs past = Time.now - (60*60*hours)\n\ttweets = Array.new\n\tclient.search(keyword).each do |tweet|\n\t\tif tweet.created_at >= past\n\t\t\tp tweet.created_at.class.name\n\t\t\ttweets.push timestamp: tweet.created_at, retweet_count: tweet.retweet_count, favorite_count: tweet.favorite_count, url: tweet.uri.to_s, text: tweet.text\n\t\telse\n\t\t\treturn tweets\n\t\tend\n\tend\nend", "def feeds_with_top_tweets\n\n end", "def print_timeline(tweets)\n # ADD CODE TO ITERATE THROUGH EACH TWEET AND PRINT ITS TEXT\n tweets.each do |tweet| puts tweet['text'] end\n \n\nend", "def timeline\n configure\n # Twitter.home_timeline returns a list of Twitter::Status\n # We can get the body of a Twitter::Status by writing status.text,\n # The poster's real name via status.user.name\n # and the poster's screen name via status.user.screen_name\n Twitter.home_timeline.map { |item|\n twitter_id = item.id.to_s\n if not Tweet.find_by_twitter_id twitter_id # Avoid saving duplicates\n Tweet.create! :text => Twitter::Autolink.auto_link(item.text),\n :tweeter => item.user.name,\n :tweeter_screen_name => item.user.screen_name,\n :published_at => item.created_at,\n :twitter_id => twitter_id,\n :user => @user\n end\n }.compact\n end", "def index\n puts(\"Total tweets: #{Tweet.count}\")\n @tweets = Tweet.all\n @tweets.each do |tweet|\n puts( \"#{tweet.zombie}: #{tweet.status}\")\n end\n\n @tweets\n end", "def show_tweets\n @user = get_user_or_current_user(params[:id])\n @tweets = Tweet.where(:user_id => @user.id).order(created_at: :desc)\n end", "def on_timeline(tweet)\n end", "def index\n @user = current_user\n @edits = Edit.includes(:User).includes(:category).order(created_at: 'desc')\n @articles = TwitterDatum.all.order(created_at: 'desc')\n @ed = EditsTwitter.all.order(created_at: 'desc')\n @categories = Category.all\n #今日の日付が取れないので昨日+1で対応\n @trends = Trend.where('updated_at > ?', DateTime.yesterday+1).order(created_at: 'desc')\n end", "def print_timeline(response)\n \n tweets = response[\"statuses\"]\n \n for tweet in tweets\n puts tweet[\"user\"][\"screen_name\"]\n puts tweet[\"text\"]\n end\n \nend", "def trending_topics\n result = http_get(\"/services/data/v#{self.version}/chatter/topics/trending\")\n result = JSON.parse(result.body)\n result[\"topics\"].collect { |topic| topic[\"name\"] }\n end", "def timeline\n config = create_or_find_config\n \n timeline = :friends\n timeline = ARGV.shift.intern if ARGV.size > 0 && Twitter::Base.timelines.include?(ARGV[0].intern)\n \n puts\n Twitter::Base.new(config['email'], config['password']).timeline(timeline).each do |s|\n puts \"#{s.text}\\n-- #{s.user.name} at #{s.created_at}\"\n puts\n end\n end", "def show\n @watcher = Watcher.includes(:tweets).friendly.find(params[:id])\n @statuses = Status.all\n respond_to do |format|\n format.html { render :show, offset: params[:offset]}\n format.json { render json: @watcher.tweets }\n end\n end", "def recent_tweets\n @_recent_tweets ||= timeline.each_with_object([]) do |tweet, memo|\n age_of_tweet_in_days = (Time.now.to_date - tweet.created_at.to_date).to_i\n memo << tweet if age_of_tweet_in_days <= 7\n end\n end", "def index\n @tweets = Tweet.all.order(created_at: :desc)\n end", "def show\n @tweets = @usuario.tweets\n end", "def show\n client = Twitter::REST::Client.new do |config|\n config.consumer_key = Settings.twitter_key\n config.consumer_secret = Settings.twitter_secret\n config.access_token = session[:oauth_token]\n config.access_token_secret = session[:oauth_token_secret]\n end\n\n start_words = client.search(\"from:#{current_user.name} #{@track.start_word}\")\n end_words = client.search(\"from:#{current_user.name} #{@track.end_word}\")\n\n latest_record = @track.records.order('start_time DESC').first\n if latest_record\n latest_start_time = latest_record.start_time\n end\n\n start_words.zip(end_words).each do |start_word, end_word|\n start_time = start_word.created_at\n end_time = end_word.created_at\n \n if !end_time\n break\n end\n\n if latest_start_time && start_time <= latest_start_time\n break\n end\n\n @record = @track.records.build(start_time: start_time, end_time: end_time)\n @record.save \n end\n\n end", "def print_timeline(tweets)\n tweets.each do |tweet|\n count = 0\n if count < 10\n puts tweet[\"text\"]\n puts\n count += 1\n end\n end\nend", "def list_tweets\n tweets\n end", "def print_timeline(tweets)\n \n puts tweets [0][\"user\"][\"screen_name\"]\n puts tweets [0][\"text\"]\n\n \n\nend", "def index\n @tweets = Tweet.all\n @user = current_user\n @recent_tweets = Tweet.order(created_at: :desc).limit(10)\n @pop_tweets = Tweet.order(likes_count: :desc).limit(10)\n @tweet = Tweet.new\n #@users # 基於測試規格,必須講定變數名稱,請用此變數中存放關注人數 Top 10 的使用者資料\n end" ]
[ "0.66060793", "0.65736413", "0.6358143", "0.6330129", "0.6183507", "0.6151924", "0.61120796", "0.60805863", "0.60325646", "0.60261446", "0.5902962", "0.58634603", "0.58480746", "0.58227384", "0.5756547", "0.5752943", "0.5735585", "0.57340425", "0.56957614", "0.5679816", "0.5658183", "0.5653052", "0.56452817", "0.5639004", "0.5630145", "0.562662", "0.56236136", "0.5599251", "0.5594429", "0.5589506" ]
0.6827585
0
Connects to rserve and sets it working directory.
def rserve_setup # Connect to Rserve and verify connection @rserve = Rserve::Simpler.new v = @rserve.eval("R.version.string"); puts "Connected to #{v.as_string}" # Set working directory. @rserve.eval("setwd('#{Dir.pwd}')") contents = File.read('plot.R') @rserve.eval(contents) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def working_directory=(directory)\n @link.WorkingDirectory = directory.tr('/', \"\\\\\")\n end", "def run\n @active_connections = 0\n @mutex = Mutex.new\n\n logger.info \"Starting server on #{server_configuration.bind}\"\n\n establish_socket_server\n write_pidfile\n setup_signal_traps\n select_loop\n end", "def run\n connect\n end", "def run\n srv = if self.path\n UNIXServer.new(path)\n else\n TCPServer.new(host, port)\n end\n\n loop do\n io = accept_connection(srv)\n\n begin\n data = receive_data(io)\n send_data(io, handle_data(io, data)) if data\n rescue\n raise 'Connection reset by peer' if config[:debug] && io.closed?\n ensure\n io.close rescue nil\n GC.start if config[:run_gc_per_request]\n end\n end\n end", "def start\n server.synchronize do\n fail 'server is already running' if started?\n fail 'provide server address' if cfg.address.nil?\n\n FileUtils.mkdir_p(server.runsv_dir)\n run = File.join(server.runsv_dir, 'run')\n\n ErbTemplate.render_to('runsv', {\n name: server.name,\n address: cfg.address,\n netif: cfg.netif,\n }, run)\n\n File.chmod(0755, run)\n File.symlink(server.runsv_dir, service_link)\n end\n end", "def start\n @pid = Process.fork do\n if (@options.rack) \n # NOTE: This does not support command-line setting of repo!\n opts = { :server => :webrick, :host => @host, :port => @port}\n PlanR::Application::LocalHttpd::WebApp.run!( repo, opts ) \n else\n # rack doesn't do the one thing we need it to: \n # pass WebApp instantiation arguments to Webrick.mount\n opts = { :BindAddress => @host, :Port => @port}\n @webrick = ::WEBrick::HTTPServer.new(opts)\n @webrick.mount \"/\", Servlet,\n [ PlanR::Application::LocalHttpd::WebApp, \n @options ]\n @webrick.start\n end\n end\n\n trap('INT') { Process.kill 'INT', @pid }\n trap('TERM') { Process.kill 'INT', @pid }\n\n self\n end", "def runserver!(host: '127.0.0.1', port: '3456')\n configure!(mode: :server, target: :development)\n status = 0 # running: 0, reload: 1, exit: 2\n # spawn a thread to watch the status flag and trigger a reload or exit\n monitor = Thread.new do\n sleep 0.1 while status.zero?\n # Shutdown the server, wait for it to finish and then wait a tick\n Rack::Handler::WEBrick.shutdown\n sleep 0.1\n # Use ps to get the command that the user executed, and use Kernel.exec\n # to execute the command, replacing the current process.\n # Basically restart everything.\n Kernel.exec(`ps #{$PID} -o command`.split(\"\\n\").last) if status == 1\n end\n\n # trap ctrl-c and set status flag\n trap('SIGINT') do\n if status == 1\n status = 2 # ctrl-c hit twice or more, set status to exit\n elsif status.zero?\n # ctrl-c hit once, notify user and set status to reload\n puts \"\\nReloading the server, hit ctrl-c twice to exit\\n\"\n status = 1\n end\n end\n\n puts \"\\nStarting Dev server, hit ctrl-c once to reload, twice to exit\\n\"\n require 'webrick/accesslog'\n access_log = [[$stderr, WEBrick::AccessLog::COMMON_LOG_FORMAT]]\n Rack::Handler::WEBrick.run(self, Host: host, Port: port, AccessLog: access_log)\n monitor.join # let the monitor thread finish its work\n end", "def start_server\n begin\n require 'webrick'\n rescue LoadError\n abort \"webrick is not found. You may need to `gem install webrick` to install webrick.\"\n end\n\n server = WEBrick::HTTPServer.new :Port => @server\n\n extra_doc_dirs = @stores.map {|s| s.type == :extra ? s.path : nil}.compact\n\n server.mount '/', RDoc::Servlet, nil, extra_doc_dirs\n\n trap 'INT' do server.shutdown end\n trap 'TERM' do server.shutdown end\n\n server.start\n end", "def work_dir=(path)\n path << '/' unless path.end_with?('/')\n @work_dir = path\n end", "def start\n return if @vim_started\n return unless @gtk_socket\n @vim_started = true\n listen\n fork do\n #exec %Q[#{Executable} --servername #{@vim_server_name} --socketid #{@gtk_socket.id} -nb:localhost:#{port}:#{Password} -S #{extras_source_path}]\n exec %Q[#{Executable} --servername #{@vim_server_name} --socketid #{@gtk_socket.id} -S #{extras_source_path}]\n end\n self\n end", "def run\n @active_connections = 0\n @mutex = Mutex.new\n\n logger.info \"Starting server on #{server_configuration.bind}\"\n\n # Set up each listener and add it to an array ready for the event loop\n @active_descriptors = []\n @active_descriptors << establish_socket_server\n @active_descriptors << establish_file_descriptor_server\n @active_descriptors << setup_signal_traps\n\n write_pidfile\n\n # Enter the main loop\n select_loop\n end", "def initialize(opts = {})\n @host = opts[:host] || @@rserve[:host] || DEF_RSERVE_HOST\n @port = opts[:port] || @@rserve[:port] || DEF_RSERVE_PORT\n @connection_state = :unknown\n\n @is_processing = false\n @last_eval_line = nil\n\n @process_queue = []\n @version = nil\n @version_cbk = nil\n\n si = File.read(File.join(File.dirname(__FILE__), 'session_init.R'))\n eval(si) do |state, msg|\n if state == :ok\n @version = msg.to_ruby\n @version_cbk.call(version) if @version_cbk\n @version_cbk = nil\n #puts \"IIINIT> #{@version}\"\n else\n error \"Couldn't initialize RServe - #{msg}\"\n end\n end\n\n debug \"Attempting to connect to Rserve\"\n EventMachine::connect @host, @port, RServConnection do |c|\n @connection = c\n @protocol = Protocol.new(c)\n c.on_new_state do |state|\n debug \"Connection state: \", state\n @connection_state = state\n _process_queue\n end\n end\n end", "def main\n #basePath = \"d:\\\\web\"\n basePath = ENV['PWD'] + '/test/functional/tmp/repo'\n #server = TCPServer.new('XXX.XXX.XXX.XXX', 9090)\n server = TCPServer.new('127.0.0.1', 9090)\n #logfile = basePath + \"\\\\log.txt\"\n logfile = basePath + \"/log.txt\"\n $log = File.open(logfile, \"w+\")\n\n puts \"basePath = #{basePath}\"\n puts \"logfile = #{logfile}\"\n\n loop do\n session = server.accept\n request = session.gets\n logStr = \"#{session.peeraddr[2]} (#{session.peeraddr[3]})\\n\"\n logStr += Time.now.localtime.strftime(\"%Y/%m/%d %H:%M:%S\")\n logStr += \"\\n#{request}\"\n logger(logStr)\n \n Thread.start(session, request) do |session, request|\n HttpServer.new(session, request, basePath).serve()\n end\n\n end\n log.close\nend", "def command_pwd\n # Respond with absolute path for this client\n puts \"Sending #{@directory.path}\"\n @client.puts @directory.path\n end", "def current_working_directory; @rye_current_working_directory; 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 setup\n config = self.config\n host = config['app']['host']\n port = config['app']['port']\n @url_base = \"http://#{host}:#{port}\"\n\n # Extract test pcaps and indexes\n FileUtils.rm_rf '/tmp/pcapr_local_test'\n test_tar = File.join(File.expand_path(File.dirname(__FILE__)), 'test.tgz')\n if File.exist? test_tar\n puts `tar -C /tmp/ -xzf #{test_tar}`\n end\n\n # Recreate test database.\n begin\n couch = config['couch']\n RestClient.delete \"#{couch['uri']}/#{couch['database']}\"\n rescue RestClient::ResourceNotFound\n end\n db = PcaprLocal.get_db config\n\n # And restore it from datafile.\n if self.datafile\n load_docs self.datafile, db\n end\n\n # Start server.\n config_file = Tempfile.new \"config\"\n config_file.print config.to_json\n config_file.flush\n @pid = fork do \n Process.setpgid $$, $$\n exec \"#{PcaprLocal::ROOT}/bin/startpcapr -f #{config_file.path} -d\" \n end\n\n # And wait for it to be ready.\n wait_for_server host, port\n end", "def setconn(conn)\r\n @conn = conn\r\n load_dir(nil)\r\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 [](fpath=nil)\n if fpath.nil? || fpath.index('/') == 0\n @rye_current_working_directory = fpath\n else\n # Append to non-absolute paths\n if @rye_current_working_directory\n newpath = File.join(@rye_current_working_directory, fpath)\n @rye_current_working_directory = newpath\n else\n @rye_current_working_directory = fpath\n end\n end\n debug \"CWD: #{@rye_current_working_directory}\"\n self\n end", "def rel_init\n if ENV.has_key? \"LOG_TO_CONSOLE\"\n puts \"Logging to console\"\n else\n log = File.open(\"/home/pstickne/el4rlog\", \"w+\")\n log.sync = true\n STDERR.reopen(log)\n end\n\n STDOUT.sync = true\n # require 'stringio'\n # prevent side-effects\n # io_out = ::STDOUT\n # Object.class_eval {remove_const :STDOUT}\n # ::STDOUT = StringIO.new\n \n $server = Rel::Server.new(STDIN, STDOUT, STDERR)\n $server.start\nend", "def remote_dir\n @remote_dir ||= configuration[:copy_remote_dir] || \"/tmp\"\n end", "def remote_dir\n @remote_dir ||= configuration[:copy_remote_dir] || \"/tmp\"\n end", "def chdir=(dir)\n @chdir = dir.to_s\n end", "def server(servr)\n clone(:server=>servr)\n end", "def initialize path = \"#{Dir.tmpdir}/live-rb\" \n raise Exception.new(\"Another session sems to be running: #{path}\") if File.exist? path\n puts Notice.new(\"Live Session: #{path}\")\n\n %x{mkfifo #{path}}\n @pipe, @path, @key_bindings = File.open(path, 'r+'), path, {}\n\n begin\n new_context and key_listen and run!\n ensure\n File.delete(path) if File.exists? path\n end\n end", "def start_server\n erl = CliRunner.open 'skirmish_server', 'erl', /\\d>/, /Eshell/\n erl << \"code:add_path(\\\"#{server_dir}/ebin\\\").\" >> /true/\n erl << \"application:start(skirmish_server).\" >> /ok/\n @automation_server = erl\n log.info(\"Automation#start_server\") { \"server started\" }\n end", "def set_workdir(filename)\n @workdir = File.dirname(filename)\n end", "def working_directory(v)\n @options[:working_directory] = v\n end", "def server(port = 9319)\r\n puts \"- Starting server on port: #{port}\"\r\n\r\n $servers[port] = WEBrick::HTTPServer.new(:Port => port) if $servers[port].nil?\r\n server = $servers[port]\r\n $mounts.keys.each{|url|\r\n server.unmount(url)\r\n server.mount(url, $mounts[url][0], *$mounts[url][1])\r\n }\r\n $mounts.clear\r\n\r\n Thread.new { server.start unless server.status == :Running }\r\nend" ]
[ "0.5622574", "0.5610432", "0.56008565", "0.5549133", "0.55180097", "0.5501794", "0.54801846", "0.54790545", "0.5463042", "0.5452361", "0.5446953", "0.5343728", "0.53413576", "0.53349644", "0.53312236", "0.53299475", "0.53201616", "0.5282503", "0.52662665", "0.5259591", "0.5252943", "0.523819", "0.5237688", "0.52370954", "0.5236221", "0.5235868", "0.52248985", "0.5213602", "0.5212452", "0.52078784" ]
0.6436405
0
Plots tweet locations. Returns true if plot created, otherwise false.
def plot_tweet_locations(to_time = Time.now) # Remove old elements from buffer while !@buffer.empty? and @buffer.first[:ttl] < Time.now do @buffer.shift end return false if @buffer.empty? data = Hash[:lat, Array.new(0), :long, Array.new(0)] @buffer.each do |tweet| data[:lat] << tweet[:tweet].place.bounding_box.coordinates[0][0][0] data[:long] << tweet[:tweet].place.bounding_box.coordinates[0][0][1] end df = Rserve::DataFrame.new(data) @rserve.command( df: df ) do %Q{ ggsave('#{File.join(@output_dir, "world_#{@plot_index}.png")}', plotworld(df, #{POINT_SIZE}, #{POINT_ALPHA}), width=#{OUTPUT_WIDTH}, height=#{OUTPUT_HEIGHT} ) } end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_tweet_plot\n tweets = FeedEntry.mark_isolates(self.retweet_ids,self)\n \n Gnuplot.open do |gp|\n Gnuplot::Plot.new(gp) do |plot|\n plot.terminal \"svg\"\n plot.output id.to_s + \".svg\"\n plot.data = []\n r = Hash.new\n s = Hash.new\n i = Hash.new\n origin_date = DateTime.parse(FeedEntry.find(id).published_at.to_s)\n tweets.each do |tweet| \n hour_diff = (DateTime.parse(tweet[:published_at])-origin_date).hours.to_i\n if (person = Person.find_by_username(tweet[:person])) != nil\n if person.friends_ids.include?(self.person.twitter_id)\t\n r[hour_diff] == nil ? r[hour_diff] = tweet[:followers_count] : r[hour_diff] += tweet[:followers_count] \n elsif tweet[:isolate_status] == \"isolate\"\n i[hour_diff] == nil ? i[hour_diff] = tweet[:followers_count] : r[hour_diff] += tweet[:followers_count] \n else\n s[hour_diff] == nil ? s[hour_diff] = tweet[:followers_count] : s[hour_diff] += tweet[:followers_count] \n end\n end\n end\n x = []\n y = []\n x1 = []\n y1 = []\n x2 = []\n y2 = []\n total = 0\n values = {}\n i.sort.each do |e|\n if e[0] < 2*(x1.inject(0.0){|sum, el| sum + el }/x2.size) || x2.size < 5\n total += e[1]\n x2 << e[0]\n y2 << total\n end\n end\n s.sort.each do |e| \n if e[0] < 2*(x1.inject(0.0){|sum, el| sum + el }/x1.size) || x1.size < 5\n total += e[1]\n x1 << e[0]\n y1 << total\n end\n end\n r.sort.each do |e| \n if e[0] < 2*(x.inject(0.0){|sum, el| sum + el }/x.size) || x.size < 5\n total += e[1] \n x << e[0]\n y << total\n end\n end\n values[:ego_retweets] = [x,y]\n values[:ego2_retweets] = [x1,y1]\n values[:isolate_retweets] = [x2,y2]\n values.each do |k,v|\n plot.data << Gnuplot::DataSet.new([v[0],v[1]]){|ds|\n ds.with = \"linespoints\"\n ds.title = k\n }\n end\n end\n end \n end", "def should_appear_on_map?\n data['visibility'] == 'PUBLIC' && timeslots.any?\n end", "def share_to_twitter?\n self.tweet_id == TWSharing::Underway\n end", "def visualize_real_time_topics(auth, topics, output_dir = \"plots\")\n rserve_setup\n @output_dir = output_dir\n FileUtils.mkdir_p output_dir\n @buffer = Array.new\n @client = Twitter::Streaming::Client.new do |config|\n config.consumer_key = auth[:consumer_key]\n config.consumer_secret = auth[:consumer_secret]\n config.access_token = auth[:access_token]\n config.access_token_secret = auth[:access_token_secret]\n end\n \n stream = Thread.new { listen_for_tweets(topics) }\n @plot_index = 0\n # Visualize while streaming\n while stream.alive?\n @plot_index += 1 if plot_tweet_locations\n sleep PLOT_DELAY\n end\n end", "def visualize_historical_topics(auth, query, num_results = 100,\n output_dir = \"plots\")\n rserve_setup\n @output_dir = output_dir\n FileUtils.mkdir_p output_dir\n @buffer = Array.new\n @client = Twitter::REST::Client.new do |config|\n config.consumer_key = auth[:consumer_key]\n config.consumer_secret = auth[:consumer_secret]\n config.access_token = auth[:access_token]\n config.access_token_secret = auth[:access_token_secret]\n end\n \n @plot_index = 0\n max_id = 0\n # Keep requesting until the number of tweets have been found.\n while @buffer.length < num_results do\n options = \n {\n count: 100\n }\n options[:max_id] = max_id if max_id > 0\n begin\n result = @client.search(query, options)\n result.each do |tweet|\n # Stop if all tweets are registered.\n break if @buffer.length >= num_results\n \n if tweet.is_a?(Twitter::Tweet) and not tweet.place.nil?\n @buffer << { tweet: tweet, ttl: tweet.created_at + TWEET_LIFE_TIME }\n # Print status\n print \"#{@buffer.length}/#{num_results}\\r\"\n $stdout.flush\n end\n end\n rescue Twitter::Error::TooManyRequests\n print \"Rate limit exceeded. Sleeping...\\r\"\n $stdout.flush\n sleep(30)\n end\n # Set new max id\n max_id = @buffer.last[:tweet].id if not @buffer.last.nil?\n end\n \n puts \"Exporting...\"\n # Visualize\n len = @buffer.length\n @buffer.each_with_index do |tweet,i|\n @plot_index += 1 if plot_tweet_locations(tweet[:tweet].created_at)\n print \"#{i}/#{len} \\r\"\n $stdout.flush\n end\n end", "def valid_tweet(tweet)\n\t\t@url = tweet.text\n\n\t\tif @url.include? \"#radio\"\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend", "def favorited_tweet?(tweet)\n favorite_tweets.include? tweet\n end", "def is_tweet?\n type == 'TweetMessage'\n end", "def share_location_on_twitter options={}\n if from_twitter?\n\n c_id = id\n c_id = \"4f696467043bac0001000002\" if Rails.env != \"production\"\n\n oauth = providers.where(provider: \"twitter\").first\n \n status_msg = self.swap_stat\n status_msg.gsub! /you/, \"me\" \n status_msg = \"On @myradddar! #{status_msg} http://www.radddar.com/#{c_id}\"\n\n Twitter.configure do |config|\n config.consumer_key = ENV[\"RDR_TWITTER_KEY\"]\n config.consumer_secret = ENV[\"RDR_TWITTER_SECRET\"]\n config.oauth_token = oauth[:token]\n config.oauth_token_secret = oauth[:secret]\n end\n\n client = Twitter::Client.new\n client.update(status_msg,{\n lat: self.loc[0],\n long: self.loc[1],\n }) rescue nil\n\n end\n end", "def plot_summary_size?\n make_plot = false\n @groups.each do |g|\n if g.has_overall_sample_size?\n make_plot = true\n break\n end\n end\n return make_plot\n end", "def connected_to_twitter?\n twitter_token && twitter_secret\n end", "def in_subplot? player\n !subplots_featuring(player).empty?\n end", "def plot(clusters, show_centroids = true)\n # Graph output by running gnuplot pipe\n Gnuplot.open do |gp|\n # Start a new plot\n Gnuplot::Plot.new(gp) do |plot|\n # Plot each cluster's points\n clusters.each do |cluster|\n # Collect all x and y coords for this cluster\n x = cluster.points.map { |p| p[0] }\n y = cluster.points.map { |p| p[1] }\n\n # Plot w/o a title (clutters things up)\n plot.data << Gnuplot::DataSet.new([x, y]) do |ds|\n ds.notitle\n end\n\n next unless show_centroids\n\n # Centroid point as bigger black points\n x = [cluster.centroid.x]\n y = [cluster.centroid.y]\n\n plot.data << Gnuplot::DataSet.new([x, y]) do |ds|\n ds.notitle\n ds.linecolor = '000000'\n ds.linewidth = 3\n end\n end\n end\n end\nend", "def create\n @tweet = current_user.tweets.create(params[:tweet])\n respond_with(@tweet, :location => tweet_url(@tweet))\n end", "def graph?\n show?\n end", "def graph?\n show?\n end", "def plot_pheno_avg?\n make_plot = false\n @groups.each do |g|\n if g.has_pheno_avg?\n make_plot = true\n break\n end\n end\n return make_plot\n end", "def print_tweets(tweets)\n\t\ttweets.each{ |tweet|\n\t\t\tprint_tweet(tweet)\n\t\t}\n\tend", "def print_tweets(tweets)\n\t\ttweets.each{ |tweet|\n\t\t\tprint_tweet(tweet)\n\t\t}\n\tend", "def twitter_register_enabled?\n Figaro.env.respond_to?(:twitter_key) && Figaro.env.respond_to?(:twitter_secret)\n end", "def shows_user_location?\n self.showsUserLocation\n end", "def twitter?\n false\n end", "def bubbles?\n false\n end", "def draw_person_map(locations_for_same_time)\n if locations_for_same_time.empty?\n return\n end\n\n # Create a 2D array and then draw from that array\n array = Array.new(SIZE_OF_WORLD) {Array.new(SIZE_OF_WORLD, \" \")}\n locations_for_same_time.each do |location|\n array[location.x][location.y] = location.person\n end\n\n x = 0\n y = 0\n puts \"#{cyan(' 0123456789')} #{blue('t = ')}#{locations_for_same_time[0].time}\"\n (0..9).each do |y|\n puts \"#{cyan(y.to_s)}#{array[0][y]}#{array[1][y]}#{array[2][y]}#{array[3][y]}#{array[4][y]}#{array[5][y]}#{array[6][y]}#{array[7][y]}#{array[8][y]}#{array[9][y]}\"\n end\n puts \" \"\nend", "def visualizer_set?\n !@visualizer.nil?\n end", "def filter_tweets_with_urls tweets_array\n tweets_with_urls = []\n tweets_array.each do |tweets|\n tweets.each do |tweet|\n # TODO remove this, just for debugging\n# tweet.urls.each do |url|\n# p url.display_url\n# end\n tweets_with_urls << tweet unless tweet.urls.empty?\n end\n end\n tweets_with_urls\n end", "def scatter_plot\n print_csv_results\n FileUtils.mkdir_p(%w(gnuplot plots))\n erb(\"templates/scatter_plot.gp.erb\", \"gnuplot/scatter_plot.gp\", {:config => @config})\n system(\"#{@config[\"path_gnuplot\"] || \"gnuplot\"} gnuplot/scatter_plot.gp\")\n puts \"Draw a scatter_plot.#{@config[\"output_format\"] || \"png\"} in plots!\"\n FileUtils.rm_rf(%w(gnuplot data))\n end", "def exist?\n !render_lines.nil?\n end", "def create\n signin_apikey\n \n if session[:user_id] != nil\n @tweet = Tweet.new(tweet_params)\n @tweet.author = User.find(session[:user_id]).email.split('@')[0].strip\n @tweet.user_id = User.find(session[:user_id]).id\n if !@tweet.url.blank?\n if !is_url(@tweet.url)\n respond_to do |format|\n format.json { render json: \"Invalid url!\".to_json, status: 400 }\n end\n return\n end\n @tweet.url = @tweet.url.sub \"https://\", \"\"\n @tweet.url = @tweet.url.sub \"www.\", \"\"\n @urlsplit = @tweet.url.split(\"/\")\n @urlsplit.each do |suburl|\n if suburl.include?(\".\")\n @tweet.shorturl = suburl\n end\n end\n end\n @tweet2 = Tweet.find_by url: @tweet.url\n if (@tweet.content.blank? && !@tweet.url.blank?)\n respond_to do |format|\n if @tweet.title.blank?\n format.html { redirect_to new_tweet_path, alert: 'Please try again.' }\n format.json { render json: \"Title property cannot be blank\".to_json, status: 400 }\n elsif (@tweet2 != nil)\n format.html { redirect_to '/tweets/' + @tweet2.id.to_s }\n msg = \"The URL already exists\"\n format.json { render json: msg.to_json , status: 400, location: @tweet }\n elsif @tweet.save\n format.html { redirect_to '/tweets', notice: 'Tweet was successfully created.' }\n format.json { render json: @tweet, status: 201 }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n elsif (@tweet.url.blank? && !@tweet.content.blank?)\n @tweet.ask = true\n respond_to do |format|\n if @tweet.title.blank?\n format.html { redirect_to new_tweet_path, alert: 'Please try again.' }\n format.json { render json: \"Title property cannot be blank\".to_json, status: 400 }\n elsif @tweet.save\n format.html { redirect_to '/tweets', notice: 'Tweet was successfully created.' }\n format.json { render json: @tweet, status: 201 }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n else\n @comment_text=@tweet.content\n @tweet.content=nil\n @tweet.ask = false\n \n if @tweet.save\n Comment.create(contribution: @tweet.id, text: @comment_text, escomment: true, comment_id: nil, user: @tweet.user_id)\n render :json => @tweet.attributes.merge( )\n end\n end\n else\n respond_to do |format|\n format.json { render json: {message: 'Unauthorized, you don\\'t have a valid api_key' }, status: 401 }\n end\n end\n end", "def show\n x = @plot.user.x\n y = @plot.user.y\n puts x\n puts y\n \n end" ]
[ "0.6096057", "0.51900303", "0.50184697", "0.5011648", "0.5001993", "0.4931558", "0.49234962", "0.48768905", "0.47698054", "0.47612417", "0.46937764", "0.46230945", "0.46100405", "0.4591894", "0.45870614", "0.45870614", "0.45781988", "0.4556874", "0.4556874", "0.45514578", "0.45439625", "0.45361704", "0.45290306", "0.45285875", "0.44981855", "0.44762766", "0.44751936", "0.44710016", "0.44699207", "0.4455361" ]
0.7296215
0
GET /parametrages GET /parametrages.json
def index @parametrages = Parametrage.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def values(params = {})\n @client.get(\"#{path}/values\", params)\n end", "def params\n @json['params']\n end", "def index\n @parametros = Parametro.all\n end", "def get_all()\n @params\n end", "def index\n @tp_parameters = TpParameter.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tp_parameters }\n end\n end", "def show\n\t\t@param_refs = ParamRef.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json {render json: @param_refs}\n\t\tend\n\tend", "def parameters\n @parameters = json['parameters'] || []\n @parameters.to_a.sort!\n @tag_title = 'Parameters'\n erb(:parameters)\nend", "def show\n @parameter = Parameter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @parameter }\n end\n end", "def show\n @parameter = Parameter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @parameter }\n end\n end", "def get_params(api, params)\n url2json(:GET, \"#{@endpoint}#{api}\", params)\n end", "def parameters\n data[:parameters]\n end", "def get_param(name, property)\n raise('wrong type: String required') unless name.is_a?(String)\n raise('wrong value: name must be valid') unless !name.nil? && !name.empty?\n raise('wrong type: String required') unless property.is_a?(String)\n raise('wrong value: property must be valid') unless !property.nil? && !property.empty?\n\n r = @client.post({\n 'action' => 'getparam',\n 'object' => 'htpl',\n 'values' => '%s;%s' % [name, property],\n }.to_json)\n\n JSON.parse(r)['result']\n end", "def index\n @parameters = Parameter.where(user_id: nil)\n @parameter = Parameter.new\n\n respond_to do |format|\n format.html { render layout: 'aq2' }\n format.json { render json: @parameters }\n end\n\n end", "def index\n @parameters = Parameter.all\n end", "def get_params\n\n return @params.map { |p| \n Param.new(\n name,\n @params[name].get_data(\"value\"),\n @params[name].get_data(\"type\"),\n true\n ) \n }\n end", "def get_params\n params.fetch(:get, {})\n end", "def prueba_json_params\n params[:prueba_json]\n end", "def query_parameters\n request.GET\n end", "def get_parameters\r\n @parameters\r\n end", "def json_get(path, params={})\n json_request(:get, path, params)\n end", "def show\n @tp_parameter = TpParameter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tp_parameter }\n end\n end", "def get_prop(values)\n cmd = \"{\\\"id\\\":1,\\\"method\\\":\\\"get_prop\\\",\\\"params\\\":[#{values}]}\\r\\n\"\n request(cmd)\n end", "def get_parameters; end", "def get_parameters; end", "def getParameters()\n printDebugMessage('getParameters', 'Begin', 1)\n xmlDoc = restRequest(baseUrl + '/parameters/')\n doc = REXML::Document.new(xmlDoc)\n printDebugMessage('getParameters', 'End', 1)\n return doc.root.elements['//parameters']\n end", "def index\n @pluto_environment_variables = collection\n\n respond_to do |format|\n format.json { render json: @pluto_environment_variables }\n end\n end", "def values_search(params)\n @client.get(\"#{path}/values/search\", nil, params, \"Content-Type\" => \"application/json\")\n end", "def params\n @parameters\n end", "def params\n @params ||= {}\n end", "def params\n @params ||= {}\n end" ]
[ "0.66662294", "0.6638993", "0.6508276", "0.642957", "0.641588", "0.6404685", "0.6349463", "0.6323128", "0.6323128", "0.62029046", "0.6192506", "0.6192359", "0.61921984", "0.61859995", "0.61613876", "0.61472714", "0.6138496", "0.6128719", "0.60555184", "0.59976965", "0.5976248", "0.59616077", "0.59577477", "0.59577477", "0.59230185", "0.59197974", "0.58907676", "0.5887636", "0.5877234", "0.5877234" ]
0.6660616
1
POST /parametrages POST /parametrages.json
def create @parametrage = Parametrage.new(parametrage_params) respond_to do |format| if @parametrage.save format.html { redirect_to @parametrage, notice: 'Parametrage was successfully created.' } format.json { render :show, status: :created, location: @parametrage } else format.html { render :new } format.json { render json: @parametrage.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prueba_json_params\n params[:prueba_json]\n end", "def create\n @parametro = Parametro.new(parametro_params)\n @parametro.observacion = @parametro.multiparametro('Ingresa 1', 'Ingresa 2', 'Ingresa 3')\n respond_to do |format|\n if @parametro.save\n format.html { redirect_to @parametro, notice: \"Parametro was successfully created.\" }\n format.json { render :show, status: :created, location: @parametro }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @parametro.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_params\n postParams = params\n end", "def json_params\n params.require(:json).permit(:type, :data)\n end", "def post_params\n ActiveModelSerializers::Deserialization.jsonapi_parse!(params, only: [:content] )\n end", "def post(path, data = {})\n request 'POST', path, body: data.to_json\n end", "def create\n ps = params[:val] || { p1: params[:p1], p2: params[:p2], p3: params[:p3], p4: params[:p4], p5: params[:p5],\n p6: params[:p6], p7: params[:p7], p8: params[:p8], p9: params[:p9] }\n @val = Val.new(ps)\n\n respond_to do |format|\n if @val.save\n format.html { redirect_to @val, notice: 'Successfully created.' }\n format.json { render json: @val, status: :created, location: @val }\n else\n format.html { render action: \"new\" }\n format.json { render json: @val.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(data = {})\n call data, method: :post\n end", "def standard_analysis_parameters\n parameter :analysis_job_id, 'Requested analysis job id (in path/route)', required: true\n parameter :audio_recording_id, 'Requested audio recording id (in path/route)', required: true\n parameter :results_path, 'Result file path', required: true\n\n let(:raw_post) { params.to_json }\nend", "def test_params\n ActiveModelSerializers::Deserialization.jsonapi_parse(params)\n #params.require(:data).require(:attributes).permit(:name, :state, :feature_id)\n end", "def POST; end", "def post_data; end", "def parametro_params\n params.require(:parametro).permit(:descripcion, :observacion)\n end", "def datum_params\n params.require(:datum).permit(:name, :value)\n end", "def create\n @valued_pre_parameter = ValuedPreParameter.new(valued_pre_parameter_params)\n\n respond_to do |format|\n if @valued_pre_parameter.save\n format.html { redirect_to @valued_pre_parameter, notice: 'Valued pre parameter was successfully created.' }\n format.json { render :show, status: :created, location: @valued_pre_parameter }\n else\n format.html { render :new }\n format.json { render json: @valued_pre_parameter.errors, status: :unprocessable_entity }\n end\n end\n end", "def variable_params\n params.require(:variable).permit(:name, :description, :value)\n end", "def variable_params\n params.require(:variable).permit(:value)\n end", "def create\n @parameters_value = ParametersValue.new(parameters_value_params)\n\n respond_to do |format|\n if @parameters_value.save\n format.html { redirect_to @parameters_value, notice: 'Parameters value ha sido creado.' }\n format.json { render :show, status: :created, location: @parameters_value }\n else\n format.html { render :new }\n format.json { render json: @parameters_value.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_api(path, params={}, headers={})\n headers.merge!('CONTENT_TYPE' => \"application/json\")\n post path, params, headers\nend", "def post_params(method, params)\n p = params ? params.clone : {}\n p.delete :post\n sign_params(method, p)\n \n # since we're using Net::HTTP.post_form to do the call,\n # CGI escape is already done for us, so, no escape here\n # p.keys.each { |k| p[k] = CGI.escape(p[k].to_s) } \n p\n end", "def create\n @objetovalparametro = Objetovalparametro.new(objetovalparametro_params)\n\n respond_to do |format|\n if @objetovalparametro.save\n format.html { redirect_to @objetovalparametro, notice: 'Objetovalparametro was successfully created.' }\n format.json { render :show, status: :created, location: @objetovalparametro }\n else\n format.html { render :new }\n format.json { render json: @objetovalparametro.errors, status: :unprocessable_entity }\n end\n end\n end", "def parametrage_params\n params.require(:parametrage).permit(:libelle, :typeParam)\n end", "def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end", "def post(params = nil)\n request.method = :post\n execute(params)\n end", "def post_data(action, parameters = {})\n action == 'auth' ? parameters.to_s : parameters.to_json\n end", "def objetovalparametro_params\n params.require(:objetovalparametro).permit(:objeto_id, :valparametro_id)\n end", "def post_parameters\n request.POST\n end", "def post(path, parameters = {})\n request(:post, path, parameters)\n end", "def pautum_params\n params.require(:pautum).permit(:titulo, :data, :status)\n end", "def create\n\t\t@param_ref = ParamRef.new(params[:param_ref])\n\n\t\tif @param_ref.save\n\t\t\trender json: @param_ref, status: :created, location: @param_ref\n\t\telse\n\t\t\trender json: @param_ref.errors, status: :unprocessable_entity\n\t\tend\n\tend" ]
[ "0.62984025", "0.6262985", "0.6085754", "0.604669", "0.60322213", "0.5973994", "0.59584236", "0.5921536", "0.591264", "0.58757645", "0.5862191", "0.5828073", "0.5820941", "0.5813594", "0.5805147", "0.5788846", "0.57858294", "0.5779461", "0.5768407", "0.57639176", "0.57525283", "0.5724708", "0.57238495", "0.571874", "0.57136434", "0.5709828", "0.56977445", "0.56923836", "0.5665197", "0.5661585" ]
0.63578707
0
PATCH/PUT /parametrages/1 PATCH/PUT /parametrages/1.json
def update respond_to do |format| if @parametrage.update(parametrage_params) format.html { redirect_to @parametrage, notice: 'Parametrage was successfully updated.' } format.json { render :show, status: :ok, location: @parametrage } else format.html { render :edit } format.json { render json: @parametrage.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update\n respond_to do |format|\n if @parametro.update(parametro_params)\n format.html { redirect_to @parametro, notice: \"Parametro was successfully updated.\" }\n format.json { render :show, status: :ok, location: @parametro }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @parametro.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def update_params\n raise(\"missing update_params stub!\")\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def update\n @parameter = Parameter.find(params[:id])\n\n respond_to do |format|\n if @parameter.update_attributes(params[:parameter])\n format.html { redirect_to parameters_path, notice: 'Parameter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @parameter.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, data, params = {}, request_options = {})\n request(:patch, path, data, params)\n end", "def update\n @core_status_parametrizacao = Core::StatusParametrizacao.find(params[:id])\n\n respond_to do |format|\n if @core_status_parametrizacao.update_attributes(params[:core_status_parametrizacao])\n format.html { redirect_to @core_status_parametrizacao, notice: 'Status parametrizacao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @core_status_parametrizacao.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end", "def update\n @parametro = Parametro.find(params[:id])\n @parametro.parametrizable_id = params[:parametro][:parametrizable_id]\n params[:parametro][:valor] = params[:parametro][:parametrizable_id] if params[:parametro][:parametrizable_id]\n respond_to do |format|\n if @parametro.update_attributes(params[:parametro])\n flash[:notice] = 'Parametro actualizado correctamente.'\n format.html { redirect_to(@parametro) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @parametro.errors, :status => :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def update\n respond_to do |format|\n if @objetovalparametro.update(objetovalparametro_params)\n format.html { redirect_to @objetovalparametro, notice: 'Objetovalparametro was successfully updated.' }\n format.json { render :show, status: :ok, location: @objetovalparametro }\n else\n format.html { render :edit }\n format.json { render json: @objetovalparametro.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @parametro = Parametro.find(params[:id])\n\n respond_to do |format|\n if @parametro.update_attributes(params[:parametro])\n flash[:notice] = 'Parametro was successfully updated.'\n format.html { redirect_to(@parametro) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @parametro.errors, :status => :unprocessable_entity }\n end\n end\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end", "def update\n\t\t@param_ref = ParamRef.find(params[:id])\n\n\t\tif @param_ref.update_attributes(params[:param_ref])\n\t\t\thead :no_content\n\t\telse\n\t\t\trender json: @param_ref.errors, status: :unprocessable_entity\n\t\tend\n\tend", "def update2\n if params.has_key?(\"chef_value\")\n @chef_value.update(chef_value_params(params[\"chef_value\"]))\n else\n params[\"chef_values\"].each do |chef_value|\n if chef_value[\"value\"] != \"\"\n @chef_value.update(chef_value_params(chef_value))\n end\n end\n end\n respond_to do |format|\n if @chef_value.update(chef_value_params)\n format.html { redirect_to @chef_value, notice: 'Chef value was successfully updated.' }\n format.json { render :show, status: :ok, location: @chef_value }\n else\n format.html { render :edit }\n format.json { render json: @chef_value.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(path)\n output { patch(path, params) }\n end", "def update_params\n raise 'Sovrascrivi in figli'\n end", "def patch(path, params)\n time(\"PATCH #{path}\") { Cloudflarer.new.patch(path, params) }\n end", "def update\n respond_to do |format|\n if @parameters_value.update(parameters_value_params)\n format.html { redirect_to @parameters_value, notice: 'Parameters value ha sido actualizado.' }\n format.json { render :show, status: :ok, location: @parameters_value }\n else\n format.html { render :edit }\n format.json { render json: @parameters_value.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n \n \n respond_to do |format|\n if @parameter_detail.update(parameter_detail_params)\n format.html { redirect_to @parameter, notice: 'Parameter detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @parameter }\n else\n format.html { render :edit }\n format.json { render json: @parameter.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @paramunold.update(paramunold_params)\n format.html { redirect_to @paramunold, notice: 'Paramunold was successfully updated.' }\n format.json { render :show, status: :ok, location: @paramunold }\n else\n format.html { render :edit }\n format.json { render json: @paramunold.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_params\n resource_params\n end", "def patch(path, body_params = {})\n debug_log \"PATCH #{@host}#{path} body:#{body_params}\"\n headers = { 'Content-Type' => 'application/json' }\n res = connection.run_request :put, path, body_params.to_json, headers\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end", "def update!(**args)\n @parameters = args[:parameters] if args.key?(:parameters)\n end", "def update\n @param_value = ParamValue.find(params[:id])\n\n respond_to do |format|\n if @param_value.update_attributes(params[:param_value])\n format.html { redirect_to(@param_value, :notice => 'ParamValue was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @param_value.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.6598373", "0.6313709", "0.62666947", "0.61980593", "0.61980593", "0.6181181", "0.61338323", "0.61323875", "0.6096609", "0.6079762", "0.6059919", "0.6029709", "0.6029135", "0.60154754", "0.59763885", "0.59666", "0.59666", "0.59512085", "0.59491557", "0.59350383", "0.59252834", "0.5923239", "0.5896187", "0.58747697", "0.5852159", "0.5843014", "0.58171564", "0.58122754", "0.5809501", "0.5788292" ]
0.6647301
0
DELETE /parametrages/1 DELETE /parametrages/1.json
def destroy @parametrage.destroy respond_to do |format| format.html { redirect_to parametrages_url, notice: 'Parametrage was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @parameter = Parameter.find(params[:id])\n @parameter.destroy\n\n respond_to do |format|\n format.html { redirect_to parameters_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @core_status_parametrizacao = Core::StatusParametrizacao.find(params[:id])\n @core_status_parametrizacao.destroy\n\n respond_to do |format|\n format.html { redirect_to core_status_parametrizacaos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @parametro.destroy\n respond_to do |format|\n format.html { redirect_to parametros_url, notice: \"Parametro was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete(data)\n params = self.params\n data['delete']['parameters'].each { |p|\n params.delete(p) if params.has_key?(p)\n }\n write(params)\n data['delete']['parameters']\n end", "def destroy\n @parametro = Parametro.find(params[:id])\n @parametro.destroy\n\n respond_to do |format|\n format.html { redirect_to(parametros_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @command_parameter = CommandParameter.find(params[:id])\n @command_parameter.destroy\n\n respond_to do |format|\n format.html { redirect_to command_parameters_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @param_value = ParamValue.find(params[:id])\n @param_value.destroy\n\n respond_to do |format|\n format.html { redirect_to(param_values_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @parameter_detail.destroy\n \n respond_to do |format|\n format.html { redirect_to parameter_url, notice: 'Parameter detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\t@param_ref = ParamRef.find(params[:id])\n\t\t@param_ref.destroy\n\n\t\thead :no_content\n\tend", "def destroy\n @tp_parameter = TpParameter.find(params[:id])\n @tp_parameter.destroy\n\n respond_to do |format|\n format.html { redirect_to tp_parameters_url }\n format.json { head :ok }\n end\n end", "def delete(path, params)\n parse_response @client[path].delete(:params => params)\n end", "def destroy\n @objetovalparametro.destroy\n respond_to do |format|\n format.html { redirect_to objetovalparametros_url, notice: 'Objetovalparametro was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @parameters_value.destroy\n respond_to do |format|\n format.html { redirect_to parameters_values_url, notice: 'Parameters value ha sido eliminado.' }\n format.json { head :no_content }\n end\n end", "def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end", "def destroy\n @valued_pre_parameter.destroy\n respond_to do |format|\n format.html { redirect_to valued_pre_parameters_url, notice: 'Valued pre parameter was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete(path, params)\n request(:delete, path, {})\n end", "def destroy(params = {})\n client.delete(\"#{endpoint(params)}/#{attributes[:id]}\")\n end", "def delete(params = {})\n Client.current.delete(resource_url, params)\n end", "def destroy\n @exp_paramater = ExpParamater.find(params[:id])\n @exp_paramater.destroy\n\n respond_to do |format|\n format.html { redirect_to exp_paramaters_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @decision_parameter = DecisionParameter.find(params[:id])\n @decision_parameter.destroy\n\n respond_to do |format|\n format.html { redirect_to decision_parameters_url }\n format.json { head :ok }\n end\n end", "def destroy\n @eco_parameter.destroy\n\n respond_to do |format|\n format.html { redirect_to(eco_parameters_url) }\n format.xml { head :ok }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @common_param = CommonParam.find(params[:id])\n @common_param.destroy\n\n respond_to do |format|\n format.html { redirect_to(common_params_url) }\n format.xml { head :ok }\n end\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end" ]
[ "0.71572995", "0.71520627", "0.70152825", "0.6979409", "0.69372916", "0.6863571", "0.68584454", "0.685587", "0.6842345", "0.6804088", "0.6782214", "0.6652317", "0.6646298", "0.6625906", "0.6597523", "0.65884364", "0.65848094", "0.65722555", "0.65619135", "0.6560774", "0.65577734", "0.6537472", "0.65102845", "0.64901215", "0.6477019", "0.6477019", "0.6477019", "0.6477019", "0.6477019", "0.6477019" ]
0.7324612
0
This is used internally to process the the question and parameters that sent to the question.
def process_question(question_with_parameters) parsed_elements = question_with_parameters.scan(GROUP_REGEX) @question = parsed_elements.first.first # After the target, question type, question, and answer length has been determined # look at all the single quoted items to find the list of parameters if there are any @parameters = Array(parsed_elements[1..-1].flatten) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_question\n\t\t#There are two types of Questions - One which starts with 'how many Credits is ' and the other is 'how much is' \n\t\tif @line.start_with? \"how many Credits is \"\n\t\t\tmain_question_part = @line.split(\"how many Credits is \")[1] #e.g from how many Credits is glob prok Silver ? gets glob prok Silver ?\n\t\t\tgalatic_literals = Translation.translate_question(main_question_part) #e.g from glob prok Silver gets glob prok\n\t\t\ttrademetal = TradeMetal.get_trade_metal(main_question_part) #e.g from glob prok Silver gets Silver\n\t\t\tif trademetal && galatic_literals\n\t\t\t\ttrademetal_price_credit = (galatic_literals.galactic_words_to_numeral * trademetal.unit_price).to_i\n\t\t\t\tputs \"#{galatic_literals} #{trademetal.coin_name} is #{trademetal_price_credit} Credits\"\n\t\t\t\treturn\n\t\t\tend\n\t\telsif @line.start_with? \"how much is \"\n\t\t\tmain_question_part = @line.split(\"how much is \")[1] #e.g from how much is pish tegj glob glob ? gets pish tegj glob glob ?\n\t\t\tgalatic_literals = Translation.translate_question(main_question_part) #e.g from pish tegj glob glob ? gets pish tegj glob glob\n\t\t\tif galatic_literals\n\t\t\t\tconversion_value = galatic_literals.galactic_words_to_numeral\n\t\t\t\tputs \"#{galatic_literals} is #{conversion_value}\"\n\t\t\t\treturn\n\t\t\tend\n\t\tend\n\t\tthrow_away_meaningless_line\n\tend", "def question_params\n params.require(:question).permit(:text, :option_a, :option_b, :option_c, :option_d, :started, :finished, :answer, :poll_centre_id)\n end", "def question_response_params\n p = params.require(:question_response).permit(:response, :subject, :responder, :question)\n p[:subject] = Entity.find(p[:subject])\n p[:responder] = Member.find(p[:responder])\n p[:question] = Question.find(p[:question])\n p\n end", "def question_params\n params.require(:question).permit(:title, :body)\n #require returns question array\n #of everything being posted, work with the questions part, and allow these two things to be submitted\n end", "def argumentative_question_params\n params.require(:argumentative_question).permit(:question,:answer1, :answer2, :answer3, :answer4, :argument1, :argument2, :argument3 , :argument4 , :correct_answer , :correct_argument , :feedback_wrong_argument, :feedback_wrong , critical_thinking_list: [], subject_list: [])\n end", "def perform(user, questions)\n \n end", "def question_params\n params.fetch(:question, {})\n end", "def ask\n @question = params[:question]\n end", "def process_question\n #There are two types of Questions - One which starts with 'how many Credits is ' and the other is 'how much is' \n if @line.start_with? \"how many Credits is \"\n main_question_part = @line.split(\"how many Credits is \")[1] #e.g from how many Credits is glob prok Silver ? gets glob prok Silver ?\n galatic_literals = Translation.translate_question(main_question_part) #e.g from glob prok Silver gets glob prok\n trademetal = TradeMetal.get_trade_metal(main_question_part) #e.g from glob prok Silver gets Silver\n if trademetal && galatic_literals\n trademetal_price_credit = (galatic_literals.galactic_words_to_numeral * trademetal.unit_price).to_i\n puts \"#{galatic_literals} #{trademetal.coin_name} is #{trademetal_price_credit} Credits\"\n return\n end\n elsif @line.start_with? \"how much is \"\n main_question_part = @line.split(\"how much is \")[1] #e.g from how much is pish tegj glob glob ? gets pish tegj glob glob ?\n galatic_literals = Translation.translate_question(main_question_part) #e.g from pish tegj glob glob ? gets pish tegj glob glob\n if galatic_literals\n conversion_value = galatic_literals.galactic_words_to_numeral\n puts \"#{galatic_literals} is #{conversion_value}\"\n return\n end\n end\n throw_away_meaningless_line\n end", "def initialize(sender,question_with_parameters)\n @sender = sender\n process_question(question_with_parameters)\n end", "def quiz_params\n paramspermit(:answer)\n end", "def process cmd, owner\n debug { \"got: #{cmd} from: #{owner}\" }\n filters = {}\n clear_questions\n\n case cmd\n when /^#{HELP_CMD}\\s*$/i\n cmd_info\n\n when /^(?:|#{REGISTER_CMD})(?:|\\:\\s+)\\s*([^\\?]+\\?)\\s*$/i\n question = $1\n register_question(question, owner)\n # should attempt to answer the question, if we know it already, else say: \"I know nothing about #{question}\"\n\n when /^(?:|#{ANSWER_CMD})(?:|\\:\\s+)\\s*([\\d]+)\\s+(.+\\.)\\s*$/i\n filters[:id] = $1; answer = $2\n answer_question answer, owner, filters\n\n when /^(?:|#{SHOW_CMD})(?:|\\:\\s+)\\s*([\\d]+|(?:#{Q_TYPES.join(\"|\")})+(?:|\\s+([\\w]+)))(?:|\\s+(#{ANSWERS_TOO}))\\s*$/i\n first_val = $1; second_val = $2; third_val = $3\n debug { \"fv: #{first_val.inspect}; sv: #{second_val.inspect}; tv: #{third_val}\" }\n if (first_val[/^\\d+$/])\n filters[:id] = first_val\n else\n q_status = first_val\n whose = (MINE == second_val) ? owner : second_val\n end\n ans = (third_val || ANSWERS_TOO == second_val) ? true : false\n filters[:answers_too] = ans\n filters[:owner] = sanitize_filename(whose) if authorized.member?(whose)\n filters[:status] = (Q_TYPES - [ALL_QSTATUS]).member?(q_status) ? q_status : \"*\"\n show_questions filters\n\n when /^#{CLOSE_CMD}(?:|\\:)\\s+([\\d]+)/i\n filters[:id] = $1\n close_question filters\n\n else\n [UNKNOWN_CMD]\n\n end\n end", "def postprocess_question(question)\n unless @_question_postprocessors.nil?\n @_question_postprocessors.each do |postprocessor|\n postprocessor.call(question)\n end\n end\n question\n end", "def validate_question params\n\n end", "def interpret(question)\n #\n # accept everything:\n # no statement interpretation here, just ok\n #\n answer = nil\n\n reply answer_o(answer)\n end", "def question_params\n params.require(:question).permit(:title, :title_attr, :answer, :analysis, :analysis_att, :analysis_url, :question_type, :active, :optionCount, :answer_count, :first_correct_count, :questionA, :questionA_attr, :questionB, :questionB_attr, :questionC, :questionC_attr, :questionD, :questionD_attr, :questionE, :questionE_attr, :questionF, :questionF_attr, :position,\n :paper_id,:platform_type,:remove_title_attr,:remove_questionA_attr,:remove_questionB_attr,:remove_questionC_attr,:remove_questionD_attr,:remove_questionE_attr,:remove_questionF_attr,:remove_analysis_att, :difficulty_degree, :knowledge_point, :answered, :title_url, :title_url_show_type, :analysis_url_show_type)\n end", "def question_params\n\t\t\tparams.require(:question).permit(:title, :content,:question_id, :input, :output, :i_data, \n\t\t\t\t:o_data, :question_level, :input_text, :output_text, :sample_input, :sample_output, :image, :for_contest)\n\t\tend", "def question_params\n params.require(:question).permit(:position, :prompt, :response_type, :response_required)\n end", "def question_params\n # params.require(:tst).permit(:name, :description, :status, :contributors)\n params.require(:question).permit(:name, :description, :status, :hint, :image_url, :explanation, :kind, :correct_response, :pause_at)\n end", "def prapor_quest; end", "def question_params\n params.require(:question).permit(:qst, :execute_if_real)\n end", "def question_params\n params.fetch(:answer_option, {})\n end", "def survey_response_params\n params[:survey_response][:user_id] = current_user.id\n params[:survey_response][:survey_form_id] = @survey_form.id\n parse_user_response \n puts \" params Here - #{params}\" \n params.require(:survey_response).permit(:survey_form_id, :user_id, :time_to_answer, answers_attributes: [:question_id, :survey_response_id, :answer_data]) \n end", "def question_params\n params.require(:question).permit(:id, :user_id, :question, :explanation, :tags, :hint, :worth, :active, :qtype, :test_id)\n end", "def parse_question\n question = params[:text]\n\n # Extract address from message\n address =\n if question[0..20]&.downcase == \"what's the weather in\"\n question[21..-1]\n elsif question[0..9]&.downcase == 'weather in'\n question[10..-1]\n elsif question[-7..-1]&.downcase == 'weather'\n question[0..-8]\n else\n ''\n end.strip\n\n # Return current weather or let user know we cannot determine address\n if address.empty?\n 'Hmm, I am not sure if I understand this question.'\n else\n weather(address)\n end\nend", "def commonquestion_params\n params.require(:commonquestion).permit(:commonquestion_id, :question_text, :options, :answer_option_number, :question_id, :parttype_id, :questiontype_id)\n end", "def question_params\n if user_signed_in? and current_user.admin?\n params.require(:question).permit(:title, :content, {:legislator_ids => []}, {:keyword_ids => []},\n :user_id, :ivod_url, :committee_id, :meeting_description, :date, :comment, :published)\n else\n params.require(:question).permit(:title, :content, {:legislator_ids => []}, {:keyword_ids => []},\n :user_id, :ivod_url, :committee_id, :meeting_description, :date, :comment)\n end\n end", "def question_params\n params.require(:question).permit(:statement, :real_answer, :fake_answer, :quiz_id)\n end", "def answer_params\n params[:answer]\n end", "def answer_params\n params[:answer]\n end" ]
[ "0.6226992", "0.6220192", "0.61548465", "0.6121073", "0.6084718", "0.6075611", "0.60524905", "0.60308796", "0.60302967", "0.6000497", "0.5998383", "0.5968966", "0.5968036", "0.59661555", "0.59481835", "0.5892453", "0.58848804", "0.58846444", "0.58800733", "0.58441514", "0.5799182", "0.5796308", "0.5770699", "0.57686883", "0.57593805", "0.57527626", "0.574638", "0.5733731", "0.57323545", "0.57323545" ]
0.73944557
0
Flushes all messages to the Kafka brokers. Depending on the value of `required_acks` used when initializing the producer, this call may block until the specified number of replicas have acknowledged the writes. The `timeout` setting places an upper bound on the amount of time the call will block before failing.
def flush messages_for_broker = {} @buffered_messages.each do |message| broker = @broker_pool.get_leader(message.topic, message.partition) messages_for_broker[broker] ||= [] messages_for_broker[broker] << message end messages_for_broker.each do |broker, messages| @logger.info "Sending #{messages.count} messages to broker #{broker}" message_set = MessageSet.new(messages) response = broker.produce( messages_for_topics: message_set.to_h, required_acks: @required_acks, timeout: @timeout * 1000, # Kafka expects the timeout in milliseconds. ) if response response.topics.each do |topic_info| topic_info.partitions.each do |partition_info| Protocol.handle_error(partition_info.error_code) end end end end @buffered_messages.clear nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def force_flush(timeout: nil)\n writer.force_flush(timeout: timeout) if writer.respond_to? :force_flush\n Export::SUCCESS\n end", "def flush( queue_name )\n # It can take a long time to flush all of the messages\n # on a server, so we'll set the read timeout to something\n # much higher than usual.\n connection.with_additional_read_timeout(60) do\n req = KJess::Request::Flush.new( :queue_name => queue_name )\n resp = send_recv( req )\n return KJess::Response::End === resp\n end\n end", "def flush_all\n # It can take a long time to flush all of the messages\n # on a server, so we'll set the read timeout to something\n # much higher than usual.\n connection.with_additional_read_timeout(60) do\n resp = send_recv( KJess::Request::FlushAll.new )\n return KJess::Response::End === resp\n end\n end", "def flush(timeout=60)\n # Schedule sending a PING, and block until we receive PONG back,\n # or raise a timeout in case the response is past the deadline.\n pong = @pongs.new_cond\n @pongs.synchronize do\n @pongs << pong\n\n # Flush once pong future has been prepared\n @pending_queue << PING_REQUEST\n @flush_queue << :ping\n with_nats_timeout(timeout) do\n pong.wait(timeout)\n end\n end\n end", "def flush(allow_reconnect = false)\n queue_metric('flush', nil, {\n :synchronous => true,\n :allow_reconnect => allow_reconnect\n }) if running?\n end", "def flush\n send_batch( Traject::Util.drain_queue(@batched_queue) )\n end", "def flush\n check_return_code(\n Lib.memcached_flush(@struct, IGNORED)\n )\n rescue => e\n tries ||= 0\n raise unless tries < options[:exception_retry_limit] && should_retry(e)\n tries += 1\n retry\n end", "def poll_ack_timeouts\n # perform resends if necessary\n if not @acks.empty? and Time.now - @last_ack_check > @ack_interval\n @logger.debug \"Checking unacked messages #{@acks.inspect}\"\n @acks.each_pair do |key, msg|\n msg.envelope.incr_resend # record the fact that this is a resend\n _send(msg)\n end\n @last_ack_check = Time.now\n end\n end", "def flush\n while !@queue.empty? || @consumer.is_requesting?\n sleep(0.1)\n end\n end", "def flush(events, close=false)\n @sqs_queue.batch_send(events)\n end", "def flush!\n clear!.each do | message |\n @transport.send_message(message)\n end\n self\n end", "def flush\n Thread.exclusive do\n while !output_queue.empty? do\n write_message(output_queue.pop)\n end\n end\n end", "def deferred_write(delay, *raw_messages)\n if !@topic\n raise 'No topic specified. Either specify a topic when instantiating the Producer or use write_to_topic.'\n end\n if delay < 0.0\n raise \"Delay can't be negative, use a positive float.\"\n end\n\n deferred_write_to_topic(@topic, delay, *raw_messages)\n end", "def flush!\n # a publisher might be uninitialized until the first event is published\n return unless topic.async_publisher\n\n topic.async_publisher.stop.wait!\n end", "def put_messages()\n #\n for i in 1..@max_msgs do\n message = \"Go Sox #{i}!\"\n @@log.debug \"#{message}\"\n @client.publish(@queue_name, message, \n {\"persistent\" => true, \"client-id\" => @client_id, \n \"reply-to\" => @queue_name} )\n end\n @client.close\n @@log.debug(\"queue_put completes\")\n end", "def flusher_loop\n loop do\n # Blocks waiting for the flusher to be kicked...\n @flush_queue.pop\n\n should_bail = synchronize do\n @status != CONNECTED || @status == CONNECTING\n end\n return if should_bail\n\n # Skip in case nothing remains pending already.\n next if @pending_queue.empty?\n\n # FIXME: should limit how many commands to take at once\n # since producers could be adding as many as possible\n # until reaching the max pending queue size.\n cmds = []\n cmds << @pending_queue.pop until @pending_queue.empty?\n begin\n @io.write(cmds.join) unless cmds.empty?\n rescue => e\n synchronize do\n @last_err = e\n @err_cb.call(e) if @err_cb\n end\n\n process_op_error(e)\n return\n end if @io\n\n synchronize do\n @pending_size = 0\n end\n end\n end", "def pause(topic, partition, timeout: nil, max_timeout: nil, exponential_backoff: false)\n if max_timeout && !exponential_backoff\n raise ArgumentError, \"`max_timeout` only makes sense when `exponential_backoff` is enabled\"\n end\n\n pause_for(topic, partition).pause!(\n timeout: timeout,\n max_timeout: max_timeout,\n exponential_backoff: exponential_backoff,\n )\n end", "def flushQueue() \n done=0\n while (!@data.empty?) do\n done=done+1\n @sender_plugin.send_data(@data.pop)\n end\n @@log.info \"Flushed \"+done.to_s\n end", "def timeouts_exceeded\n @reactor.log(:warn, \"#{self.class}, Client exceeded allowable [#{@max_broker_timeouts}] timeout failures; reopening socket to Broker!\")\n\n # active requests that haven't timed out & failed will still have the old\n # client ID; we need to restart those requests with the new ID\n @broker_timeouts = 0\n reopen_broker_connection\n end", "def poll(timeout)\n time_poll ||= TimeTrackers::Poll.new(timeout)\n\n return nil if time_poll.exceeded?\n\n time_poll.start\n\n @kafka.poll(timeout)\n rescue ::Rdkafka::RdkafkaError => e\n # We return nil, so we do not restart until running the whole loop\n # This allows us to run revocation jobs and other things and we will pick up new work\n # next time after dispatching all the things that are needed\n #\n # If we would retry here, the client reset would become transparent and we would not have\n # a chance to take any actions\n case e.code\n when :max_poll_exceeded # -147\n reset\n return nil\n when :transport # -195\n reset\n return nil\n when :rebalance_in_progress # -27\n reset\n return nil\n when :not_coordinator # 16\n reset\n return nil\n when :network_exception # 13\n reset\n return nil\n when :unknown_topic_or_part\n # This is expected and temporary until rdkafka catches up with metadata\n return nil\n end\n\n raise if time_poll.attempts > MAX_POLL_RETRIES\n raise unless time_poll.retryable?\n\n time_poll.checkpoint\n time_poll.backoff\n\n # On unknown errors we do our best to retry and handle them before raising\n retry\n end", "def flush()\n wakeup()\n @tasks.each_value { |t| t.flush() }\n while busy?\n sleep(0.2)\n end\n end", "def send_topic_acknowledge(msg, headers, timeout=60)\n #m=StompMessage::Message.new('stomp_BILLING', msg)\n open_connection\n s=rand*30 # scott - used to be 1000 but seem to create connections on activemq\n # open new topic to listen to reply...\n # was this but jms seems to blow up receipt_topic=\"/topic/receipt/client#{s.to_i}\"\n receipt_topic=\"/topic/rcpt_client#{s.to_i}\"\n receipt_flag = false\n # internal_conn = Stomp::Connection.open '', '', self.host, self.port, false \n self.conn.subscribe( receipt_topic, { :ack =>\"client\" }) {|msg|\n begin\n Timeout::timeout(timeout) {\n self.conn.acknowledge(msg,msg.headers)\n \t msg2= msg.body\n \t yield msg2\n }\n rescue Exception => e\n puts \"exception #{e.message}\"\n # raise \"timeout\" \n ensure\n receipt_flag=true\n self.conn.unsubscribe receipt_topic \n end \n }\n \n \n more_headers= {'persistent'=>'false', 'reply-to' => \"#{receipt_topic}\" }\n more_headers.merge headers\n self.conn.send(self.topic, msg.to_xml, more_headers ) \n Thread.new { sleep(timeout+1)\n puts \"calling unsubscribe on #{receipt_topic}\" if !receipt_flag\n self.conn.unsubscribe receipt_topic if !receipt_flag\n } \n end", "def flush\n @queue.clear\n end", "def graceful_shutdown\n while reap_dead_workers(\"shutdown\") > 0\n logger.error \"Waiting for #{@workers.list.length} requests to finish, could take #{@timeout + @throttle} seconds.\"\n sleep @timeout / 10\n end\n end", "def async_producer(delivery_interval: 0, delivery_threshold: 0, max_queue_size: 1000, max_retries: -1, retry_backoff: 0, **options)\n producer(**options)\n end", "def drain\n # run the jobs in a separate thread so assumptions of synchronous\n # jobs are caught in test mode.\n consumer.drain\n end", "def sync_all(timeout = -1, dispose = false)\n DRMAA.synchronize([ ALL_JOBS ], timeout, dispose)\n end", "def graceful_shutdown(timeout: true)\n @stopping = true\n\n Thread.new do\n GrpcKit.logger.debug('graceful shutdown')\n @mutex.synchronize { @sessions.each(&:drain) }\n\n begin\n sec = timeout ? @shutdown_timeout : 0\n Timeout.timeout(sec) do\n sleep 1 until @sessions.empty?\n end\n rescue Timeout::Error => _\n GrpcKit.logger.error(\"Graceful shutdown is timeout (#{@shutdown_timeout}sec). Perform shutdown forceibly\")\n shutdown_sessions\n end\n end\n end", "def flush()\n wakeup()\n @flows.each_value { |f| f.flush() }\n while busy?\n sleep(0.2)\n end\n end", "def flush( name )\n return unless meter = delete( name )\n meter.add_with_retry\n end" ]
[ "0.57876164", "0.5282538", "0.5279535", "0.5270456", "0.49578023", "0.49291092", "0.48671773", "0.482185", "0.47933996", "0.47818503", "0.47560918", "0.47422543", "0.47337854", "0.4705692", "0.46751207", "0.46090877", "0.45957473", "0.45793983", "0.45344672", "0.45344484", "0.4528053", "0.4484724", "0.4483627", "0.44815704", "0.44479996", "0.44306812", "0.44237706", "0.4417761", "0.44022512", "0.43930385" ]
0.62779224
0
Declare a set function for a pair of dtypes
def dtypes_set_function dtype_i, dtype_j str = <<SETFN static void #{dtypes_function_name(:set, dtype_i, dtype_j)}(size_t n, char* p1, size_t i1, char* p2, size_t i2) { for (; n > 0; --n) { #{dtypes_assign(dtype_i, dtype_j)} p1 += i1; p2 += i2; } } SETFN end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_qualifier_keys( set ); end", "def FXMAPTYPES(typelo, typehi, func)\n addMapEntry(MKUINT(MINKEY, typelo), MKUINT(MAXKEY, typehi), func)\n end", "def set(values); end", "def create_setters\n schema_fields.keys.each do |key|\n self.class.send(:define_method, \"#{key.to_s}=\".to_sym) do |value| \n @data[key] = value #get_value key, value\n end\n end\n end", "def infer_set(o)\n if o.instance_of?(Array)\n infer_set_Array(o)\n elsif o.instance_of?(Hash)\n infer_set_Hash(o)\n elsif o.instance_of?(SemanticPuppet::Version)\n infer_set_Version(o)\n else\n infer(o)\n end\n end", "def types(types); end", "def set_types(column_types)\n raise NotImplementedError.new\n end", "def add_set(name, type)\n Set.new(name, type(type)).tap do |column|\n @data_columns << add_column(column)\n end\n end", "def value_types=(_arg0); end", "def sets\n end", "def format_sets(type, string)\n case type\n when :date\n [ date_format_set, datetime_format_set ]\n when :datetime\n if string.length < 11\n [ date_format_set, datetime_format_set ]\n else\n [ datetime_format_set, date_format_set ]\n end\n when :time\n if string.length < 11\n [ time_format_set ]\n else\n [ datetime_format_set, time_format_set ]\n end\n else\n if string.length < 11\n [ date_format_set, time_format_set, datetime_format_set ]\n else\n [ datetime_format_set, date_format_set, time_format_set ]\n end\n end\n end", "def dtypes_binary_functions_matrix func\n ary = []\n DTYPES.each do |i|\n next if i[:enum] == :NM_TYPES\n bry = []\n DTYPES.each do |j|\n next if j[:enum] == :NM_TYPES\n bry << dtypes_function_name(func, i,j)\n end\n ary << \"{ \" + bry.join(\", \") + \" }\"\n end\n ary\n end", "def mset(*args); end", "def mset(*)\n raise CannotDistribute, :mset\n end", "def type_literal_generic_set(column)\n type_literal_generic_string(column)\n end", "def attr_set_ub1(attr_type, attr_value)\n #This is a stub, used for indexing\n end", "def process_set(match, function, type_table)\n name = match[1]\n array_index = match[3]\n value = match[4]\n\n # Error checking:\n unless function.is_a? Function\n raise \"Can only set variables inside functions\"\n end\n\n var_list = function.var_list\n unless var_list.include?(name)\n raise \"Undeclared variable '#{name}'\"\n end\n\n var = function.var_list.get(name)\n if array_index != nil and (not var.is_array?)\n raise \"Cannot use array index on non-array variable\"\n end\n\n # Parse value and create instruction\n ident_list = function.ident_list\n value_expression = process_expression(value, ident_list, type_table)\n\n var_type = var.type\n if array_index\n var_type = var.type.element_type\n end\n\n unless value_expression.type.castable?(var_type)\n raise \"Cannot convert expression type #{value_expression.type.to_s} \" +\n \"to variable type #{var_type.to_s}\"\n end\n\n instruction = SetVariableInstruction.new(var, value_expression, function)\n\n # The variable is being used as an array, add array index to instruction\n if array_index\n index_expression = process_expression(array_index, ident_list,\n type_table)\n instruction.array_index = index_expression\n\n unless index_expression.type.castable?(WORD_TYPE)\n raise \"Cannot convert array index #{index_expression.type.to_s} \" +\n \"to word type\"\n end\n end\n\n function.add_instruction(instruction)\n return true\nend", "def expression_set(type, string)\n case type\n when :date\n date_expressions\n when :time\n time_expressions\n when :datetime\n # gives a speed-up for date string as datetime attributes\n if string.length < 11\n date_expressions + datetime_expressions\n else\n datetime_expressions + date_expressions\n end\n end\n end", "def mset(*_arg0); end", "def sunion(*keys); end", "def test_set_unmatched_type\n set = SetVariableEval.new(@bool_var, @int_lit)\n assert_raise TypeError do\n set.eval\n end\n end", "def const_set(p0, p1) end", "def argument_types=(*value)\n end", "def schema_multirange_type(db_type)\n :multirange\n end", "def codepoints(*features)\n features = setify(*features)\n @sets[features] || (raise FeatureError, \"No such set #{features.inspect}\")\n end", "def make_set(x,y,z)\n return [x,y,z]\n end", "def |(other_set)\n super(CharSet.new(other_set))\n end", "def attr_set_ub2(attr_type, attr_value)\n #This is a stub, used for indexing\n end", "def coerce(first, second)\n @map[[first.class, second.class]].call(first, second)\n end", "def FXMAPFUNCS(type, keylo, keyhi, func)\n addMapEntry(MKUINT(keylo, type), MKUINT(keyhi, type), func)\n end" ]
[ "0.5259052", "0.5134491", "0.5080035", "0.506463", "0.50546515", "0.50309443", "0.49844247", "0.49504444", "0.49197853", "0.4915668", "0.49132717", "0.49034014", "0.4896863", "0.48899552", "0.4842843", "0.4837773", "0.4833141", "0.48084515", "0.47671697", "0.47671595", "0.47416273", "0.47302473", "0.4729323", "0.4678981", "0.46636742", "0.4660603", "0.4645829", "0.4642724", "0.4622264", "0.46204364" ]
0.7226789
0
Takes a list of declarations and cleans it for insertion in a header file. Removes inline keyword Removes static functions Removes variable names
def process_declarations declarations declarations.map do |d| process_declaration d end.compact end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_declaration declaration\n tokens = declaration.split(' ')\n\n return nil if tokens.include?('static')\n declaration = tokens.delete_if { |t| t == 'inline'}.join(' ')\n\n tokens = declaration.split('(')\n arg_list = tokens.last.split(')').first\n\n # Remove variable names\n args = arg_list.split(',')\n args = args.map do |arg|\n arg_tokens = arg.strip.split(' ')\n arg_tokens[0...arg_tokens.size-1].join(' ')\n end\n\n tokens[tokens.size-1] = args.join(',') + ')'\n\n tokens.join('(') + \";\"\n end", "def consume_declarations(input = T.unsafe(nil), options = T.unsafe(nil)); end", "def decls; end", "def decls; end", "def decls; end", "def decls; end", "def create_parsed_header(functions, typedefs = nil)\n parsed_header = {\n :includes => nil,\n :functions => [],\n :typedefs => []\n }\n\n # Add the typedefs.\n if typedefs\n typedefs.each do |typedef|\n parsed_header[:typedefs] << typedef\n end\n end\n\n # Add the functions.\n if functions\n functions.each do |function|\n # Build the array of arguments.\n args = []\n if function.key?(:args)\n function[:args].each do |arg|\n args << {\n :type => arg\n }\n end\n end\n parsed_header[:functions] << {\n :name => function[:name],\n :modifier => \"\",\n :return => {\n :type => function[:return_type],\n :name => \"cmock_to_return\",\n :ptr? => false,\n :const? => false,\n :str => \"void cmock_to_return\",\n :void? => true\n },\n :var_arg => nil,\n :args_string => \"void\",\n :args => args,\n :args_call => \"\",\n :contains_ptr? => false\n }\n end\n end\n parsed_header\nend", "def declarations; end", "def remove_commented_out_lines\n @body.gsub!(%r{//.*rb_define_}, '//')\n end", "def remove_commented_out_lines\n @content = @content.gsub(%r%//.*rb_define_%, '//')\n end", "def source_decls; end", "def alignUndefineDefine(theLines)\n\n\ttheLines.each_with_index do |theLine, theIndex|\n\n\t\ttheText = theLine[:text];\n\t\tif (theText =~ /^\\s*#undef /)\n\n\t\t\tmatchText = theText.sub('#undef', '#define');\n\t\t\tnextText = theLines[theIndex + 1][:text];\n\n\t\t\tif (nextText.start_with?(matchText))\n\t\t\t\ttheLine[:text].sub!('#undef', '#undef ');\n\t\t\tend\n\t\tend\n\tend\n\nend", "def create_cmock_style_parsed_header(functions, typedefs = nil)\n parsed_header = {\n :includes => nil,\n :functions => [],\n :typedefs => []\n }\n\n # Add the typedefs.\n if typedefs\n typedefs.each do |typedef|\n parsed_header[:typedefs] << typedef\n end\n end\n\n # Add the functions.\n if functions\n functions.each do |function|\n # Build the array of arguments.\n args = []\n if function.key?(:args)\n function[:args].each do |arg|\n args << {\n :type => arg\n }\n end\n end\n parsed_header[:functions] << {\n :name => function[:name],\n :modifier => \"\",\n :return => {\n :type => function[:return_type],\n :name => \"cmock_to_return\",\n :ptr? => false,\n :const? => false,\n :str => \"void cmock_to_return\",\n :void? => true\n },\n :var_arg => nil,\n :args_string => \"void\",\n :args => args,\n :args_call => \"\",\n :contains_ptr? => false\n }\n end\n end\n parsed_header\nend", "def create_cmock_style_parsed_header(functions, typedefs = nil)\n parsed_header = {\n :includes => nil,\n :functions => [],\n :typedefs => []\n }\n\n # Add the typedefs.\n if typedefs\n typedefs.each do |typedef|\n parsed_header[:typedefs] << typedef\n end\n end\n\n # Add the functions.\n if functions\n functions.each do |function|\n # Build the array of arguments.\n args = []\n if function.key?(:args)\n function[:args].each do |arg|\n args << {\n :type => arg\n }\n end\n end\n parsed_header[:functions] << {\n :name => function[:name],\n :modifier => \"\",\n :return => {\n :type => function[:return_type],\n :name => \"cmock_to_return\",\n :ptr? => false,\n :const? => false,\n :str => \"void cmock_to_return\",\n :void? => true\n },\n :var_arg => nil,\n :args_string => \"void\",\n :args => args,\n :args_call => \"\",\n :contains_ptr? => false\n }\n end\n end\n parsed_header\nend", "def split_definition(raw_def)\r\n # TODO: your implementation here\r\n i = 0\r\n while (i < raw_def.size)\r\n raw_def[i].gsub! /\\s\\n/, \"\\n\"\r\n raw_def[i].gsub! /\\n+/, \"\\n\"\r\n raw_def[i].gsub! /\\t/, ''\r\n i += 1\r\n end\r\n x = 0\r\n newArr = []\r\n mod_def = []\r\n until x >= raw_def.size do\r\n if (raw_def[x][0] == \"\\n\")\r\n mod_def[x] = raw_def[x][1..-1]\r\n else\r\n mod_def[x] = raw_def[x]\r\n end\r\n newArr[x] = mod_def[x].split(/\\t?\\s?;\\s?\\n?/)\r\n x += 1\r\n end\r\n\r\n j = 0\r\n while (j < newArr.size)\r\n newArr[j].unshift(newArr[j][0][0..newArr[j][0].index(\">\")].gsub(/\\s*/, \"\"))\r\n if newArr[j][0] == \"<blank>\"\r\n newArr[j][1] = \"\";\r\n else\r\n newArr[j][1] = newArr[j][1][newArr[j][1].index(\">\") + 2..-1]\r\n end\r\n j += 1\r\n end\r\n\r\n k = 0\r\n while (k < newArr.size)\r\n l = 0\r\n while (l < newArr[k].size)\r\n newArr[k][l].gsub! /\\n+/, ' '\r\n l += 1\r\n end\r\n k += 1\r\n end\r\n\r\n return newArr\r\nend", "def split_definition(raw_def)\n # removes extra newlines\n tokens = raw_def.strip.split(\"\\n\")\n tokens2 = tokens.map {|element| element.delete(\";\").strip}\nend", "def parse_definition_list; end", "def header\n source_code.gsub /\\n^[^#].*/m, ''\n end", "def fix_variable_declaration_order(file)\n # Spinner needs to be moved after Buttons\n # since it depends on $btn-default-bg\n #\n # also spinner-btn-hover-bg needs to be\n # before spinner-up-btn-border\n if file.include? 'Spinner'\n lines = file.split \"\\n\"\n spinner_start = lines.index {|l| l =~ /Spinner/}\n spinner_end = lines.index {|l| l =~ /Pagination/} - 1\n buttons_end = lines.index {|l| l =~ /Navs/} - 1\n\n (spinner_end - spinner_start).times do\n lines.insert(buttons_end, lines.delete_at(spinner_start))\n end\n\n spinner_btn_bg = lines.index {|l| l =~ /spinner-btn-bg:/}-1\n 3.times do\n lines.insert(spinner_btn_bg+5, lines.delete_at(spinner_btn_bg))\n end\n\n file = lines.join(\"\\n\")\n end\n file\n end", "def handle_ifdefs_in(body)\n body.gsub(/^#ifdef HAVE_PROTOTYPES.*?#else.*?\\n(.*?)#endif.*?\\n/m, '\\1')\n end", "def merge_declarations! \n !parser and return\n\n @order = 0\n @declarations ||= {}\n\n parser.selector_declarations do |sel, decl|\n add_declaration!(decl)\n end \n end", "def remove_trailing_spaces(source)\n for_outstrings_of(source) do |str|\n str.gsub! /\\s+/im, ' '\n str.gsub! /\\s*(=|\\+|\\-|<|>|\\?|\\|\\||&&|\\!|\\{|\\}|,|\\)|\\(|;|\\]|\\[|:|\\*|\\/)\\s*/im, '\\1'\n str.gsub! /;(\\]|\\)|\\}|\\.|\\?|:)/, '\\1' # removing wrong added semicolons\n str.gsub /([^\\d\\w_\\$]typeof)\\s+([\\w\\d\\$_]+)/, '\\1(\\2)'\n end\n end", "def remove_listlibrary_headers str\n # Lots of messages have Message-Id headers added;\n # Date headers were added to 3 in ruby-list, 2 in chipy\n # 3 messages in ruby-list have Date headers added\n # 2 messages in chipy have Date headers added\n while str =~ /^X-ListLibrary-Added-Header: (.*)$/\n header = $1 # Thanks, Perl\n header.sub!('\\n','') # yes, remove a literal \\n that yaml didn't parse\n str.sub!(/^#{header}: .*\\n/, '')\n str.sub!(/^X-ListLibrary-Added-Header: .*\\n/, '')\n end\n str\nend", "def get_all_functions src_file\n code = IO.readlines(src_file)\n functions = []\n puts src_file\n code.each do |line|\n /^\\s*def\\s+([^\\s\\(]+)\\s?.*/ =~ line\n functions << $1 if $1\n end \n functions\n end", "def extract_declares!\n # Ensure there is a name.\n self.force_name!\n # The extracted declares.\n decls = []\n # Extract the inners.\n self.each_inner {|inner| decls << inner }\n decls.each {|inner| self.delete_inner!(inner) }\n # Renames them with the current level.\n decls.each do |inner|\n former = inner.name\n self.extend_name!(inner)\n self.replace_names_subs!(former,inner.name)\n end\n # Returns the extracted declares.\n return decls\n end", "def parse_declaration(input = T.unsafe(nil)); end", "def extract_declares!\n # Ensure there is a name.\n self.force_name!\n # The extracted declares.\n decls = []\n # Extract the types.\n types = []\n self.each_type {|type| types << type }\n types.each {|type| self.delete_type!(type) }\n # Renames them with the current level.\n types.each do |type|\n former = type.name\n self.extend_name!(type)\n self.replace_names_subs!(former,type.name)\n end\n # Adds the types\n decls << types\n # Extract the systemTs.\n systemTs = []\n self.each_systemT {|systemT| systemTs << systemT }\n systemTs.each {|systemT| self.delete_systemT!(systemT) }\n # Renames them with the current level.\n systemTs.each do |systemT|\n former = systemT.name\n self.extend_name!(systemT)\n self.replace_names_subs!(former,systemT.name)\n end\n # Adds the systemTs\n decls << systemTs\n # Extract the inners.\n inners = []\n self.each_inner {|inner| inners << inner }\n inners.each {|inner| self.delete_inner!(inner) }\n # Renames them with the current level.\n inners.each do |inner|\n former = inner.name\n self.extend_name!(inner)\n self.replace_names_subs!(former,inner.name)\n end\n # Adds the inners\n decls << inners\n # Extract the systemIs\n systemIs = []\n self.each_systemI {|systemI| systemIs << systemI }\n systemIs.each {|systemI| self.delete_systemI!(systemI) }\n # Renames them with the current level.\n systemIs.each do |systemI|\n former = systemI.name\n self.extend_name!(systemI)\n self.replace_names_subs!(former,systemI.name)\n end\n # Adds the systemIs\n decls << systemIs\n # Returns the extracted declares.\n return decls\n end", "def convert!\n # Fonts and headings\n semanticize_font_styles!\n semanticize_headings!\n\n # Tables\n remove_paragraphs_from_tables!\n semanticize_table_headers!\n\n # list items\n remove_paragraphs_from_list_items!\n remove_unicode_bullets_from_list_items!\n remove_whitespace_from_list_items!\n remove_numbering_from_list_items!\n end", "def handle_ifdefs_in(body)\n body.gsub(/^#ifdef HAVE_PROTOTYPES.*?#else.*?\\n(.*?)#endif.*?\\n/m) { $1 }\n end", "def remove_sourcemap_declaration(source)\n # Doing an rstrip() is essential here - otherwise we disturb the line counts\n # in the source maps (line offsets in the concatenated source)\n source.gsub(SOURCEMAP_LINE_RE, '').rstrip\n end" ]
[ "0.6632059", "0.5461924", "0.54266375", "0.54266375", "0.54266375", "0.54266375", "0.53643423", "0.5319585", "0.5277111", "0.5266107", "0.5245171", "0.5243462", "0.5238946", "0.5238946", "0.5228421", "0.52026165", "0.52004236", "0.5199896", "0.5177197", "0.5175378", "0.5153895", "0.5152967", "0.51208097", "0.5099499", "0.5099308", "0.5085369", "0.50812614", "0.506584", "0.506434", "0.5047608" ]
0.6214326
1
Helper for process_declarations that works on a single function prototype. Removes variable names Removes inline keyword Returns nil if declaration is static, otherwise returns corrected prototype
def process_declaration declaration tokens = declaration.split(' ') return nil if tokens.include?('static') declaration = tokens.delete_if { |t| t == 'inline'}.join(' ') tokens = declaration.split('(') arg_list = tokens.last.split(')').first # Remove variable names args = arg_list.split(',') args = args.map do |arg| arg_tokens = arg.strip.split(' ') arg_tokens[0...arg_tokens.size-1].join(' ') end tokens[tokens.size-1] = args.join(',') + ')' tokens.join('(') + ";" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split_function_name(line)\n /(\\s*def\\s*)(\\S[^\\(]*)(\\(.*)/.match(line)\nend", "def consume_declaration(input = T.unsafe(nil)); end", "def detect_function(d)\n if d[:body] =~ /[;\\{]/\n d[:type] = :file\n d[:decl] = \"\"\n\n proto = d[:body].split(/[;\\{]/, 2).first.strip\n if proto[-1] == ?)\n (proto.length - 1).downto(0) do |p|\n tail = proto[p .. -1]\n if tail.count(\")\") == tail.count(\"(\")\n if proto[0..p] =~ /(\\w+)\\(\\z/\n d[:name] = $1\n d[:type] = :function\n d[:decl] = proto\n end\n break\n end\n end\n end\n end\n end", "def declaration\n return class_declaration if match?(:class)\n return function_declaration('function') if match?(:fun)\n return var_declaration if match?(:var)\n return statement\n rescue Ringo::Errors::ParseError => error\n synchronize\n return nil\n end", "def render_function_declaration(stream)\n render_function_header(stream) if @render_interface\n render_declaration_specifier(stream)\n if inline?\n render_function_definition(stream)\n else\n stream << prototype << ';'\n end\n end", "def remove_name_classifications(proto_record)\n proto_record[:full_name] = proto_record[:full_name].sub(/\\s-\\s[A-Z\\s]*/, '')\n end", "def remove_name_classifications(proto_record)\n proto_record[:full_name] = proto_record[:full_name].sub(/\\s-\\s[A-Z\\s]*/, \"\")\n end", "def signature\n relevant_object.signature.gsub(/^(def\\ )/, '')\n end", "def parse_function(d)\n d[:args] = []\n\n rval, argline = d[:decl].split(/\\s*#{Regexp.quote(d[:name])}\\(\\s*/, 2)\n\n # clean up rval if it is like \"extern static int\" or \"GIT_EXTERN(int)\"\n while rval =~ /[A-Za-z0-9_]+\\(([^\\)]+)\\)$/i\n rval = $1\n end\n rval.gsub!(/extern|static/, '')\n rval.strip!\n d[:return] = { :type => rval }\n\n # we removed the opening parenthesis, which this is expecting\n argline = '(' + argline\n # clean up argline\n argline = argline.slice(1..-2) while argline[0] == ?( && argline[-1] == ?)\n d[:argline] = argline.strip\n d[:args] = []\n left = 0\n\n # parse argline\n (0 .. argline.length).each do |i|\n next unless argline[i] == ?, || argline.length == i\n\n s = argline.slice(left .. i)\n next unless s.count(\"(\") == s.count(\")\")\n\n s.chop! if argline[i] == ?,\n s.strip!\n\n if s =~ /\\(\\s*\\*\\s*(\\w+)\\s*\\)\\s*\\(/\n argname = $1\n d[:args] << {\n :name => argname,\n :type => s.sub(/\\s*#{Regexp.quote(argname)}\\s*/, '').strip\n }\n elsif s =~ /\\W(\\w+)$/\n argname = $1\n d[:args] << {\n :name => argname,\n :type => s[0 ... - argname.length].strip,\n }\n else\n # argline is probably something like \"(void)\"\n end\n\n left = i + 1\n end\n\n # parse comments\n if d[:rawComments] =~ /\\@(param|return)/i\n d[:args].each do |arg|\n param_comment = /\\@param\\s+#{Regexp.quote(arg[:name])}/.match(d[:rawComments])\n if param_comment\n after = param_comment.post_match\n end_comment = after.index(/(?:@param|@return|\\Z)/)\n arg[:comment] = after[0 ... end_comment].strip.gsub(/\\s+/, ' ')\n end\n end\n\n return_comment = /\\@return\\s+/.match(d[:rawComments])\n if return_comment\n after = return_comment.post_match\n d[:return][:comment] = after[0 ... after.index(/(?:@param|\\Z)/)].strip.gsub(/\\s+/, ' ')\n end\n else\n # support for TomDoc params\n end\n\n # add in inline parameter comments\n if d[:inlines] # array of [param line]/[comment] pairs\n d[:inlines].each do |inl|\n d[:args].find do |arg|\n if inl[0] =~ /\\b#{Regexp.quote(arg[:name])}$/\n arg[:comment] += \"\\n#{inl[1]}\"\n end\n end\n end\n end\n\n # generate function signature\n d[:sig] = d[:args].map { |a| a[:type].to_s }.join('::')\n\n # pull off function description\n if d[:rawComments] =~ /^\\s*(public|internal|deprecated):/i\n # support for TomDoc description\n else\n desc, comments = d[:rawComments].split(\"\\n\\n\", 2)\n d[:description] = desc.strip\n d[:comments] = comments || \"\"\n params_start = d[:comments].index(/\\s?\\@(?:param|return)/)\n d[:comments] = d[:comments].slice(0, params_start) if params_start\n end\n end", "def parse_declaration(input = T.unsafe(nil)); end", "def var_decl(type, name)\n if entry = get_entry(type)\n entry[:ctype].gsub(\"%s\", name.to_s)\n # FIXME type.to_s\n elsif type.to_s.include?(\"%s\")\n type.gsub(\"%s\", name.to_s)\n else\n \"#{type} #{name}\"\n end\n end", "def declaration=(_arg0); end", "def preprocess_statement(statement)\n #log_debug(\"preprocess\") {statement.inspect}\n\n # Pre-fetch pnames, to fill prefixes\n get_pname(statement.subject)\n get_pname(statement.predicate)\n get_pname(statement.object)\n get_pname(statement.object.datatype) if statement.object.literal? && statement.object.datatype\n end", "def remove_trailing_spaces(source)\n for_outstrings_of(source) do |str|\n str.gsub! /\\s+/im, ' '\n str.gsub! /\\s*(=|\\+|\\-|<|>|\\?|\\|\\||&&|\\!|\\{|\\}|,|\\)|\\(|;|\\]|\\[|:|\\*|\\/)\\s*/im, '\\1'\n str.gsub! /;(\\]|\\)|\\}|\\.|\\?|:)/, '\\1' # removing wrong added semicolons\n str.gsub /([^\\d\\w_\\$]typeof)\\s+([\\w\\d\\$_]+)/, '\\1(\\2)'\n end\n end", "def consume_declarations(input = T.unsafe(nil), options = T.unsafe(nil)); end", "def compile_defun(scope, name, args, body)\n f = Function.new(args, body,scope)\n name = clean_method_name(name)\n\n # add function to the global list of functions defined so far\n @global_functions[name] = f\n\n # a function is referenced by its name (in assembly this is a label).\n # wherever we encounter that name, we really need the adress of the label.\n # so we mark the function with an adress type.\n return [:addr, clean_method_name(name)]\n end", "def xxxtest_function_prototype_on_more_than_one_line\r\n length = initialize_length(\r\n <<-EOD\r\n func_prototype(\r\n int myCat,\r\n boolean huh\r\n );\r\n EOD\r\n )\r\n assert_equal(nil, length.counts['func_prototype'])\r\n assert_equal(5, length.counts['global'])\r\n end", "def extract_method_name_without_arguments(line)\n name = extract_method_name(line)\n name.include?('(') ? name.split('(')[0] : name.split(' ')[0]\n end", "def split_definition(raw_def)\n # TODO: your implementation here\n\n #breaks down the non-terminal and the elements for the non-terminal\n raw_def = raw_def.map {|x| x.sub(/>/, '>;')}\n raw_def = raw_def.map{|x| x.strip}\n raw_def = raw_def.map{|x| x.split(/;/).flatten.map{|y| y.strip}}\n raw_def = raw_def.map{|x| x.map{|x| x.strip}}\n\nend", "def compile_defun(scope, name, args, body)\n if scope.is_a?(ClassScope) # Ugly. Create a default \"register_function\" or something. Have it return the global name\n\n # since we have a class scope,\n # we also pass the class scope to the function, since it's actually a method.\n f = Function.new([:self]+args, body, scope) # \"self\" is \"faked\" as an argument to class methods.\n\n @e.comment(\"method #{name}\")\n\n cleaned = clean_method_name(name)\n fname = \"__method_#{scope.name}_#{cleaned}\"\n scope.set_vtable_entry(name, fname, f)\n @e.load_address(fname)\n @e.with_register do |reg|\n @e.movl(scope.name.to_s, reg)\n v = scope.vtable[name]\n @e.addl(v.offset*Emitter::PTR_SIZE, reg) if v.offset > 0\n @e.save_to_indirect(@e.result_value, reg)\n end\n name = fname\n else\n # function isn't within a class (which would mean, it's a method)\n # so it must be global\n f = Function.new(args, body)\n name = clean_method_name(name)\n end\n\n # add function to the global list of functions defined so far\n @global_functions[name] = f\n\n # a function is referenced by its name (in assembly this is a label).\n # wherever we encounter that name, we really need the adress of the label.\n # so we mark the function with an adress type.\n return [:addr, clean_method_name(name)]\n end", "def get_program_declarations_aux(text, functions_dict, global_vars, local_vars, var_references, globals_exist)\n\tchanged = false\n\n\ttext.gsub!(/\\r\\n?/, \"\\n\")\n\taribtrary_count = 0\n\tin_function = false\n\tprev_line = nil\n\tlast_real_line = nil\n\tscopeno = -1\n\tmax_scope = -1\n\tfirst_function = true\n\tfunc_name = \"\"\n\tallVariableTypes = Array.new\n\tbadAssignments = Hash.new\n\n\tsetup_variable_types(allVariableTypes, local_vars, global_vars)\n\tallVariableTypes = allVariableTypes + get_all_class_names(text)\n\t\n\tif globals_exist\n\t\tscopeno = 1\n\telse\n\t\tscopeno = 0\n\tend\n\n\tmax_scope = scopeno\n\n\ttext.split(\"\\n\").each_with_index do |line, ind|\n\n\t\t# If empty line or commented, continue\n\t\tif line.strip.length == 0 or line =~ /[\\t ]*#.+$/\n\t\t\tnext\n\n\t\t# Test for function with multiple arguments\n\t\telsif lineIsParamsFunctionStart(line)\n\t\t\tif in_function == true\n\t\t\t\tret_type = parse_for_type(last_real_line, local_vars, global_vars, func_name, functions_dict, var_references)\n\t\t\t\tif ret_type != nil\n\t\t\t\t\tfunctions_dict[func_name].return_type = ret_type\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tif not first_function\n\t\t\t\tscopeno = max_scope + 1\n\t\t\telse\n\t\t\t\tfirst_function = false\n\t\t\t\tscopeno = max_scope\n\t\t\tend\n\n\t\t\tin_function = true\n\n\t\t\tline.scan(/([A-Za-z]{1}[A-Za-z0-9_]*) *= *\\(/) do |m|\n\t\t\t\tfunc_name = m[0]\n\t\t\t\tif not functions_dict.keys.include?(func_name)\n\t\t\t\t\tchanged = true\n\t\t\t\t\tlocal_vars[func_name] = Hash.new\n\t\t\t\t\tfunctions_dict[func_name] = FunctionDeclaration.new(func_name, ind, scopeno)\n\t\t\t\tend\n\t\t\tend\n\t\t\tif functions_dict[func_name].initialized\n\t\t\t\t# Func exists\n\t\t\telse\n\t\t\t\tline[func_name.length...-1].scan(/([A-Za-z]{1}[A-Za-z0-9_]* *:- *[A-Za-z]{1}[A-Za-z0-9_]*,? *|[A-Za-z]{1}[A-Za-z0-9_]*,? *)/) do |m|\n\t\t\t\t\ta = m[0].scan(/([A-Za-z]{1}[A-Za-z0-9_]*)/)\n\t\t\t\t\t\n\t\t\t\t\tif a.length > 1\n\t\t\t\t\t\tlocal_vars[func_name][a[0][0]] = TypeDeclaredVar.new(a[0][0], a[1][0], func_name, ind, scopeno)\n\t\t\t\t\t\tfunctions_dict[func_name].args << FunctionParameter.new(a[0][0], a[1][0])\n\t\t\t\t\telse\n\t\t\t\t\t\tlocal_vars[func_name][a[0][0]] = TypeDeclaredVar.new(a[0][0], \"T'-#{aribtrary_count}\", func_name, ind, scopeno)\n\t\t\t\t\t\tfunctions_dict[func_name].args << FunctionParameter.new(a[0][0], \"T'-#{aribtrary_count}\")\n\t\t\t\t\t\taribtrary_count += 1\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tfunctions_dict[func_name].initialized = true\n\t\t\tend\n\n\t\t# Test for functions without any arguments\n\t\telsif lineIsNoParamsFunctionStart(line)\n\t\t\tif in_function == true\n\t\t\t\tret_type = parse_for_type(last_real_line, local_vars, global_vars, func_name, functions_dict, var_references)\n\t\t\t\tif ret_type != nil\n\t\t\t\t\tfunctions_dict[func_name].return_type = ret_type\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tif not first_function\n\t\t\t\tscopeno = max_scope + 1\n\t\t\telse\n\t\t\t\tfirst_function = false\n\t\t\t\tscopeno = max_scope\n\t\t\tend\n\n\t\t\tin_function = true\n\n\t\t\tline.scan(/[A-Za-z]{1}[A-Za-z0-9_]*/) do |m|\n\t\t\t\tfunc_name = m[0]\n\t\t\t\tif not functions_dict.keys.include?(func_name)\n\t\t\t\t\tlocal_vars[func_name] = Hash.new\n\t\t\t\t\tchanged = true\n\t\t\t\t\tfunctions_dict[func_name] = FunctionDeclaration.new(func_name, ind, scopeno)\n\t\t\t\t\tfunctions_dict[func_name].args << FunctionParameter.new(\"\", \"unit\")\n\t\t\t\tend\n\t\t\tend\n\n\t\t# If exited scope and previous line is not null, parse\n\t\telsif prev_line != nil and count_tabs_at_start(line) == 0 and count_tabs_at_start(prev_line) > 0\n\t\t\t# puts line\n\t\t\tret_type = parse_for_type(last_real_line, local_vars, global_vars, func_name, functions_dict, var_references)\n\t\t\tif ret_type != nil\n\t\t\t\tfunctions_dict[func_name].return_type = ret_type\n\t\t\tend\n\t\t\tin_function = false\n\t\t\tscopeno = 0\n\n\t\t\tdeclarations = get_line_declarations(line, allVariableTypes)\n\t\t\tdeclarations.each_pair do |name, type|\n\t\t\t\tif not global_vars.keys.include?(name) and not allVariableTypes.include?(name)\n\t\t\t\t\tglobal_vars[name] = TypeDeclaredVar.new(name, type, \"\", ind, 0)\n\t\t\t\t\tfix_references_types(var_references, name, 0, type, local_vars, global_vars, functions_dict)\n\t\t\t\t\tchanged = true\n\t\t\t\tend\n\t\t\t\tupdate_relevant_global_references(var_references, name, ind, type)\n\t\t\tend\n\n\t\t\tif declarations.size == 0 # If no declarations found, search for used variables.\n\t\t\t\t# Check if this is a '=' line and forward declarations if found.\n\t\t\t\tcheck_equals_statement = global_parse_for_type(line, global_vars, var_references, functions_dict)\n\t\t\t\tif check_equals_statement != nil\n\t\t\t\t\t\tassigned_name = check_equals_statement[0]\n\t\t\t\t\t\tfound_type = check_equals_statement[1]\n\t\t\t\t\t\tassigned_to = check_equals_statement[2]\n\t\t\t\t\t\tt1 = global_vars[assigned_name]\n\t\t\t\t\t\tt2 = global_vars[assigned_to]\n\t\t\t\t\t\tbadAssign = false\n\t\t\t\t\t\tif global_vars[assigned_name] != nil and global_vars[assigned_to] != nil\n\t\t\t\t\t\t\tt1 = t1.declared_type\n\t\t\t\t\t\t\tt2 = t2.declared_type\n\t\t\t\t\t\t\tif not isArbitraryType(t1) and not isArbitraryType(t2) and t1 != t2\n\t\t\t\t\t\t\t\tbadAssignments[ind] = BadAssignment.new(ind, line, assigned_name, t1, assigned_to, t2)\n\t\t\t\t\t\t\t\tbadAssign = true\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tt1 = nil\n\t\t\t\t\t\t\tt2 = nil\n\t\t\t\t\t\t\tvar_references.each do |ref|\n\t\t\t\t\t\t\t\tif ref.name == assigned_name and ref.kind == \"global\"\n\t\t\t\t\t\t\t\t\tt1 = ref.declared_type\n\t\t\t\t\t\t\t\telsif ref.name == assigned_to and ref.kind == \"global\"\n\t\t\t\t\t\t\t\t\tt2 = ref.declared_type\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tif not isArbitraryType(t1) and not isArbitraryType(t2) and t1 != t2\n\t\t\t\t\t\t\t\tbadAssignments[ind] = BadAssignment.new(ind, line, assigned_name, t1, assigned_to, t2)\n\t\t\t\t\t\t\t\tbadAssign = true\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif not badAssign\n\t\t\t\t\t\t\tvar_references.each do |ref|\n\t\t\t\t\t\t\t\tif ref.kind == \"global\" and ref.name == assigned_name and (ref.declared_type == nil or isArbitraryType(ref.declared_type))\n\t\t\t\t\t\t\t\t\tref.declared_type = found_type\n\t\t\t\t\t\t\t\t\tif found_type != nil and not isArbitraryType(found_type)\n\t\t\t\t\t\t\t\t\t\tchanged = true\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\tvars = get_line_variables(line, allVariableTypes)\n\t\t\t\tvars.each do |var|\n\t\t\t\t\tplaces = get_variable_columns(line, var)\n\t\t\t\t\tplaces.each do |pl|\n\t\t\t\t\t\tref = nil\n\t\t\t\t\t\tif global_vars.keys.include?(var)\n\t\t\t\t\t\t\tref = VariableReference.new(var, global_vars[var].lineno, ind, global_vars[var].declared_type, \"global\", 0, \"\", pl)\n\t\t\t\t\t\telsif functions_dict.keys.include?(var)\n\t\t\t\t\t\t\tref = VariableReference.new(var, functions_dict[var].lineno, ind, nil, \"func\", 0, \"\", pl)\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tpossible_type = find_type_in_references(var_references, var, 0)\n\t\t\t\t\t\t\tif check_equals_statement != nil and found_type != nil and assigned_name == var\n\t\t\t\t\t\t\t\tref = VariableReference.new(var, -2, ind, found_type, \"global\", 0, \"\", pl)\n\t\t\t\t\t\t\telsif possible_type != nil\n\t\t\t\t\t\t\t\tref = VariableReference.new(var, -2, ind, possible_type, \"global\", 0, \"\", pl)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tref = VariableReference.new(var, -2, ind, \"T'-#{aribtrary_count}\", \"global\", 0, \"\", pl)\n\t\t\t\t\t\t\t\taribtrary_count += 1\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif add_variable_reference(var_references, ref)\n\t\t\t\t\t\t\tchanged = true\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t# Otherwise, we're in a regular function line (or global line) \n\t\t# and want to search for declarations\n\t\telse\n\t\t\tif in_function == true\n\t\t\t\tdeclarations = get_line_declarations(line, allVariableTypes)\n\t\t\t\tdeclarations.each_pair do |name, type|\n\t\t\t\t\tif local_vars[func_name][name] == nil or isArbitraryType(local_vars[func_name][name].declared_type)\n\t\t\t\t\t\tchanged = true\n\t\t\t\t\tend\n\t\t\t\t\tlocal_vars[func_name][name] = TypeDeclaredVar.new(name, type, func_name, ind, scopeno)\n\t\t\t\t\tvar_references.each do |varRef|\n\t\t\t\t\t\tif varRef.scope == scopeno and varRef.name == name and isArbitraryType(varRef.declared_type)\n\t\t\t\t\t\t\tvarRef.declared_type = type\n\t\t\t\t\t\t\tvarRef.line_declared = ind\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# Check if one of the declared vars is also a parameter, and if so, update the function.\n\t\t\t\tdeclarations.each_pair do |name, type|\n\t\t\t\t\tfunctions_dict[func_name].args.each do |arg|\n\t\t\t\t\t\tif arg.name == name and isArbitraryType(arg.type)\n\t\t\t\t\t\t\targ.type = type\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tif declarations.size == 0\n\t\t\t\t\t# Check if line has '=' statement\n\t\t\t\t\tcheck_equals_statement = local_parse_for_type(line, local_vars, func_name, var_references, scopeno, functions_dict, ind)\n\t\t\t\t\tif check_equals_statement != nil\n\t\t\t\t\t\tassigned_name = check_equals_statement[0]\n\t\t\t\t\t\tfound_type = check_equals_statement[1]\n\t\t\t\t\t\tassigned_to = check_equals_statement[2]\n\t\t\t\t\t\tt1 = local_vars[func_name][assigned_name]\n\t\t\t\t\t\tt2 = local_vars[func_name][assigned_to]\n\t\t\t\t\t\tbadAssign = false\n\t\t\t\t\t\tif t1 != nil and t2 != nil and not isArbitraryType(local_vars[func_name][assigned_name].declared_type) and not isArbitraryType(local_vars[func_name][assigned_to].declared_type)\n\t\t\t\t\t\t\tt1 = t1.declared_type\n\t\t\t\t\t\t\tt2 = t2.declared_type\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif not isArbitraryType(t1) and not isArbitraryType(t2) and t1 != t2\n\t\t\t\t\t\t\t\tbadAssignments[ind] = BadAssignment.new(ind, line, assigned_name, t1, assigned_to, t2)\n\t\t\t\t\t\t\t\tbadAssign = true\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tt1 = nil\n\t\t\t\t\t\t\tt2 = nil\n\t\t\t\t\t\t\tvar_references.each do |ref|\n\t\t\t\t\t\t\t\tif ref.name == assigned_name and ref.func_name == func_name\n\t\t\t\t\t\t\t\t\tt1 = ref.declared_type\n\t\t\t\t\t\t\t\telsif ref.name == assigned_to and ref.func_name == func_name\n\t\t\t\t\t\t\t\t\tt2 = ref.declared_type\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tif not isArbitraryType(t1) and not isArbitraryType(t2) and t1 != t2\n\t\t\t\t\t\t\t\tbadAssignments[ind] = BadAssignment.new(ind, line, assigned_name, t1, assigned_to, t2)\n\t\t\t\t\t\t\t\tbadAssign = true\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif not badAssign\n\t\t\t\t\t\t\tvar_references.each do |ref|\n\t\t\t\t\t\t\t\tif ref.kind == \"local\" and ref.name == assigned_name and ref.func_name == func_name and isArbitraryType(ref.declared_type)\n\t\t\t\t\t\t\t\t\tref.declared_type = found_type\n\t\t\t\t\t\t\t\t\tcurrent_function_args = functions_dict[func_name].args\n\t\t\t\t\t\t\t\t\tcurrent_function_args.each do |arg|\n\t\t\t\t\t\t\t\t\t\tif arg.name == assigned_name and isArbitraryType(arg.type)\n\t\t\t\t\t\t\t\t\t\t\targ.type = found_type\n\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\tif found_type != nil and not isArbitraryType(found_type)\n\t\t\t\t\t\t\t\t\t\tchanged = true\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\t# Identify all vars in line, and if found in dictionary, print a \"reference\".\n\t\t\t\t\tcurrent_scope = local_vars[func_name]\n\t\t\t\t\tvars = get_line_variables(line, allVariableTypes)\n\t\t\t\t\tvars.each do |var|\n\t\t\t\t\t\tplaces = get_variable_columns(line, var)\n\t\t\t\t\t\tplaces.each do |pl|\n\t\t\t\t\t\t\tif current_scope.keys.include?(var)\n\t\t\t\t\t\t\t\tif current_scope[var].declared_type != \"\"\n\t\t\t\t\t\t\t\t\tref = VariableReference.new(var, current_scope[var].lineno, ind, current_scope[var].declared_type, \"local\", scopeno, func_name, pl)\n\t\t\t\t\t\t\t\t\tif add_variable_reference(var_references, ref)\n\t\t\t\t\t\t\t\t\t\tchanged = true\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\telsif global_vars.keys.include?(var)\n\t\t\t\t\t\t\t\tif global_vars[var].declared_type != \"\"\n\t\t\t\t\t\t\t\t\tref = VariableReference.new(var, global_vars[var].lineno, ind, global_vars[var].declared_type, \"global\", 0, \"\", pl)\n\t\t\t\t\t\t\t\t\tif add_variable_reference(var_references, ref)\n\t\t\t\t\t\t\t\t\t\tchanged = true\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\telsif functions_dict.keys.include?(var)\n\t\t\t\t\t\t\t\tref = VariableReference.new(var, functions_dict[var].lineno, ind, nil, \"func\", 0, \"\", pl)\n\t\t\t\t\t\t\t\tif add_variable_reference(var_references, ref)\n\t\t\t\t\t\t\t\t\tchanged = true\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tneed = true\n\t\t\t\t\t\t\t\tvar_references.each do |ref|\n\t\t\t\t\t\t\t\t\tif ref.name == var and ref.kind == \"global\"\n\t\t\t\t\t\t\t\t\t\tneed = false\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tif need\n\t\t\t\t\t\t\t\t\tcurrent_scope[var] = TypeDeclaredVar.new(var, \"T'-#{aribtrary_count}\", func_name, -2, scopeno)\n\t\t\t\t\t\t\t\t\tref = VariableReference.new(var, -2, ind, \"T'-#{aribtrary_count}\", \"local\", scopeno, func_name, pl)\n\t\t\t\t\t\t\t\t\tif add_variable_reference(var_references, ref)\n\t\t\t\t\t\t\t\t\t\tchanged = true\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\taribtrary_count += 1\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tdeclarations = get_line_declarations(line, allVariableTypes)\n\t\t\t\tdeclarations.each_pair do |name, type|\n\t\t\t\t\t# puts \"#{name} :- #{type}\"\n\t\t\t\t\tif not global_vars.include?(name) and not allVariableTypes.include?(name)\n\t\t\t\t\t\tglobal_vars[name] = TypeDeclaredVar.new(name, type, \"\", ind, scopeno)\n\t\t\t\t\t\tfix_references_types(var_references, name, 0, type, local_vars, global_vars, functions_dict)\n\t\t\t\t\t\tchanged = true\n\t\t\t\t\tend\n\t\t\t\t\tupdate_relevant_global_references(var_references, name, ind, type)\n\t\t\t\tend\n\n\t\t\t\tif declarations.size == 0 # If no declarations found, search for used variables.\n\t\t\t\t\t# Check if this is a '=' line and forward declarations if found.\n\t\t\t\t\tfound_type = nil\n\t\t\t\t\tassigned_name = nil\n\t\t\t\t\tcheck_equals_statement = nil\n\t\t\t\t\tcheck_equals_statement = global_parse_for_type(line, global_vars, var_references, functions_dict)\n\t\t\t\t\tif check_equals_statement != nil\n\t\t\t\t\t\tassigned_name = check_equals_statement[0]\n\t\t\t\t\t\tfound_type = check_equals_statement[1]\n\t\t\t\t\t\tassigned_to = check_equals_statement[2]\n\t\t\t\t\t\tt1 = global_vars[assigned_name]\n\t\t\t\t\t\tt2 = global_vars[assigned_to]\n\t\t\t\t\t\tbadAssign = false\n\t\t\t\t\t\tif global_vars[assigned_name] != nil and global_vars[assigned_to] != nil\n\t\t\t\t\t\t\tt1 = t1.declared_type\n\t\t\t\t\t\t\tt2 = t2.declared_type\n\t\t\t\t\t\t\tif not isArbitraryType(t1) and not isArbitraryType(t2) and t1 != t2\n\t\t\t\t\t\t\t\tbadAssignments[ind] = BadAssignment.new(ind, line, assigned_name, t1, assigned_to, t2)\n\t\t\t\t\t\t\t\tbadAssign = true\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tt1 = nil\n\t\t\t\t\t\t\tt2 = nil\n\t\t\t\t\t\t\tvar_references.each do |ref|\n\t\t\t\t\t\t\t\tif ref.name == assigned_name and ref.kind == \"global\"\n\t\t\t\t\t\t\t\t\tt1 = ref.declared_type\n\t\t\t\t\t\t\t\telsif ref.name == assigned_to and ref.kind == \"global\"\n\t\t\t\t\t\t\t\t\tt2 = ref.declared_type\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tif not isArbitraryType(t1) and not isArbitraryType(t2) and t1 != t2\n\t\t\t\t\t\t\t\tbadAssignments[ind] = BadAssignment.new(ind, line, assigned_name, t1, assigned_to, t2)\n\t\t\t\t\t\t\t\tbadAssign = true\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif not badAssign\n\t\t\t\t\t\t\tvar_references.each do |ref|\n\t\t\t\t\t\t\t\tif ref.kind == \"global\" and ref.name == assigned_name and (ref.declared_type == nil or isArbitraryType(ref.declared_type))\n\t\t\t\t\t\t\t\t\tref.declared_type = found_type\n\t\t\t\t\t\t\t\t\tif found_type != nil and not isArbitraryType(found_type)\n\t\t\t\t\t\t\t\t\t\tchanged = true\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\tvars = get_line_variables(line, allVariableTypes)\n\t\t\t\t\tvars.each do |var|\n\t\t\t\t\t\tplaces = get_variable_columns(line, var)\n\t\t\t\t\t\tplaces.each do |pl|\n\t\t\t\t\t\t\tref = nil\n\t\t\t\t\t\t\tif global_vars.keys.include?(var)\n\t\t\t\t\t\t\t\tref = VariableReference.new(var, global_vars[var].lineno, ind, global_vars[var].declared_type, \"global\", 0, \"\", pl)\n\t\t\t\t\t\t\telsif functions_dict.keys.include?(var)\n\t\t\t\t\t\t\t\tref = VariableReference.new(var, functions_dict[var].lineno, ind, nil, \"func\", 0, \"\", pl)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tif line.include? \"class \"\n\t\t\t\t\t\t\t\t\tcls_name = line[5..-1][/[A-Z]+[A-Za-z]/]\n\t\t\t\t\t\t\t\t\tallVariableTypes << cls_name\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tpossible_type = find_type_in_references(var_references, var, 0)\n\t\t\t\t\t\t\t\t\tif check_equals_statement != nil and found_type != nil and assigned_name == var\n\t\t\t\t\t\t\t\t\t\t# puts \"111 #{var} :- #{found_type}\"\n\t\t\t\t\t\t\t\t\t\tref = VariableReference.new(var, -2, ind, found_type, \"global\", 0, \"\", pl)\n\t\t\t\t\t\t\t\t\telsif possible_type != nil\n\t\t\t\t\t\t\t\t\t\tref = VariableReference.new(var, -2, ind, possible_type, \"global\", 0, \"\", pl)\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\tref = VariableReference.new(var, -2, ind, \"T'-#{aribtrary_count}\", \"global\", 0, \"\", pl)\n\t\t\t\t\t\t\t\t\t\taribtrary_count += 1\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tif add_variable_reference(var_references, ref)\n\t\t\t\t\t\t\t\tchanged = true\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\tend\n\t\tend\n\t\t# puts \"#{scopeno} : #{line}\"\n\t\tif scopeno >= max_scope\n\t\t\tmax_scope = scopeno\n\t\tend\n\t\tprev_line = line\n\t\tif not line.include? \":-\"\n\t\t\tlast_real_line = line\n\t\tend\n\t\t# puts \"Variable References:\"\n\t\t# var_references.each do |data|\n\t\t# \tif data.declared_type == nil\n\t\t# \t\tdata.declared_type = \"func\"\n\t\t# \tend\n\t\t# \tif data.inferred_type == \"\"\n\t\t# \t\tdata.inferred_type = \"?\"\n\t\t# \tend\n\t\t# \tputs \"\\tline #{data.line_found+1} column #{data.column_found}: \\\"#{data.name}\\\", #{data.kind} [declared: line #{data.line_declared+1}, as #{data.declared_type}], type #{data.inferred_type}, scope #{data.scope}\"\n\t\t# end\n\tend\n\n\t# If exited program with a \"leftover\" line remaining, test it.\n\tif prev_line != nil and count_tabs_at_start(prev_line) > 0\n\t\tret_type = parse_for_type(last_real_line, local_vars, global_vars, func_name, functions_dict, var_references)\n\t\tfunctions_dict[func_name].return_type = ret_type\n\tend\n\n\t# Remove any types that were accidentally added to local_vars:\n\tlocal_vars.each_pair do |funcName, funcVars|\n\t\tfuncVars.each_pair do |varName, varData|\n\t\t\tif allVariableTypes.include? varName\n\t\t\t\tlocal_vars[funcName].delete(varName)\n\t\t\tend\n\t\tend\n\tend\n\n\tglobal_vars.each do |name, var|\n\t\tif allVariableTypes.include? name\n\t\t\tglobal_vars.delete(name)\n\t\tend\n\tend \n\n\tvar_references.reject! { |ref| allVariableTypes.include? ref.name }\n\n\t# var_references.each do |data|\n\t# \tif data.declared_type == nil\n\t# \t\tdata.declared_type = \"func\"\n\t# \tend\n\t# \tputs \"\\tline #{data.line_found+1}: \\\"#{data.name}\\\", #{data.kind} [declared: line #{data.line_declared+1}, as #{data.declared_type}] (#{data.func_name})\"\n\t# end\n\t# puts \"-----------------------------\"\n\treturn [functions_dict, global_vars, local_vars, var_references, changed, badAssignments]\nend", "def declaration; end", "def ruby_simplifier (sexp,var)\n \t#print \"\\n\\nruby_simplifier(\"\n \t#print sexp\n \t#puts \")\\n\\n\"\n\n if sexp and var and sexp[0] === :call and sexp[1] and sexp[1][0] === :lvar \\\n and sexp[1][1] === var then\n \t@@vars.add sexp[2]\n \t[:lvar, \"?\" + sexp[2].to_s]\n elsif sexp and sexp[0] === :call and sexp[1] and sexp[1][0] === :self then\n\t@@vars.add sexp[2]\n\t[:self, \"?\" + sexp[2].to_s]\n elsif sexp and sexp[0] === :call and sexp[1] and sexp[1][0] === :ivar and sexp[1][1] == :@attributes then\n\t@@vars.add sexp[3][1][1]\n\t[:ivar, \"?\" + sexp[3][1][1]]\n else\n \tsexp\n end\n end", "def singularize_name(name, head)\n if head.respond_to?(:singularize)\n singularized_head = head.singularize\n if singularized_head.size==0\n singularized_head=head\n end\n name.sub(/\\b#{Regexp.quote(head)}\\b/, singularized_head)\n else\n name\n end\n end", "def unmangle src, args = {}\n # all Borland mangled names start with '@' character.\n return src if !src || src.empty? || src[0] != '@'\n\n # check for Microsoft compatible fastcall names, which are of the form:\n # @funcName@<one or more digits indicating size of all parameters>\n return src if src =~ /\\A@.*@\\d+\\Z/\n\n # unmangle args? defaulting to true\n doArgs = args.fetch(:args, true)\n\n @vtbl_flags = []\n @kind = 0\n @source_string = ''\n @source = StringPtr.new(@source_string)\n @result = ''\n @target = StringPtr.new(@result)\n\n #return UM_ERROR if src.size > 254\n @hashstart =\n case src.size\n when 254 # old hash for bcc version 0x600 and earlier\n 250\n when 253 # new hash for bcc version 0x610 and later\n 231\n else\n MAXBUFFLEN\n end\n\n @savechar = 0\n\n src = src[1..-1] # skip initial '@'\n\n# ZZZ XXX not sure if it's needed now\n# if src[/[a-z]/]\n# # contains lowercase letters => not Pascal\n# # b/c Pascal names can not contain lowercase letters\n# else\n# # Pascal, convert uppercase Pascal names to lowercase\n# src.downcase!\n# end\n\n # This is at LEAST a member name, if not a fully mangled template\n # or function name. So, begin outputting the subnames. We set up\n # the pointers in globals so that we don't have to pass\n # everything around all the time.\n\n @kind = UM_UNKNOWN\n @source_string = src\n @source = StringPtr.new(@source_string)\n @prevqual = @qualend = @base_name = @base_end = nil\n @set_qual = true\n\n # Start outputting the qualifier names and the base name.\n\n @namebase = @target.dup\n\n copy_name(0)\n @set_qual = false\n @base_end = @target.dup\n\n if (@kind & UM_KINDMASK) == UM_TPDSC || (@kind & UM_SPECMASK) != 0\n p = strchr(@namebase, ' ')\n assert(p)\n @namebase = p + 1\n end\n\n if [UM_CONSTRUCTOR,UM_DESTRUCTOR].include?( @kind & UM_KINDMASK )\n copy_char('~') if @kind & UM_KINDMASK == UM_DESTRUCTOR\n\n if @qualend\n start = @prevqual ? (@prevqual+2) : @namebase.dup\n len = @qualend - start\n copy_string(start, len)\n else\n # It's a bcc-created static constructor??\n # give it a name.\n copy_string(\"unknown\")\n end\n end\n\n # If there's a function argument list, copy it over in expanded\n # form.\n\n if input() == ARGLIST && doArgs # function args\n c = advance()\n assert(c == 'q' || c == 'x' || c == 'w')\n\n # Output the function parameters, and return type in the case\n # of template function specializations.\n\n @set_qual = false\n @adjust_quals = true\n\n copy_type(@namebase, 0)\n\n if ((@kind & UM_KINDMASK) == UM_UNKNOWN)\n @kind |= UM_FUNCTION\n end\n\n elsif ((@kind & UM_KINDMASK) == UM_UNKNOWN)\n @kind |= UM_DATA\n elsif @vtbl_flags.any?\n copy_string(\" (\" + @vtbl_flags.join(\", \") + \")\")\n end\n\n # Put some finishing touches on the @kind of this entity.\n\n if (@qualend)\n @kind |= UM_QUALIFIED\n end\n\n # trim unwanted result tail, if any\n @target[0..-1] = ''\n\n # If the user wanted the qualifier and base name saved, then do it now.\n\n # TODO\n# if (@kind & UM_ERRMASK) == 0\n# if @qualend\n# len = @qualend - @namebase\n# @qualP = @namebase[0, len]\n# end\n#\n# if @base_name\n# len = @base_end - @base_name\n# @baseP = @base_name[0, len]\n# end\n# end\n\n # move '__fastcall' to start of the string if its found in middle of string\n pos = @result.index(\" __fastcall \")\n if pos && pos != 0\n @result = \"__fastcall \" + @result.sub(\"__fastcall \", \"\")\n end\n\n # sometimes const args are marked \"const const\",\n # original tdump.exe tool also have this bug\n @result.gsub! \"const const \", \"const \"\n\n # doArgs implicitly includes calling convention, but '__tpdsc__' is always\n # returned by original code, so strip it here if doArgs == false\n unless doArgs\n @result.sub! /\\A__tpdsc__ /,''\n end\n\n # copy IDA syntax for class ctor/dtor:\n # was: Classes::TThread::operator `class destructor`()\n # now: Classes::TThread::`class destructor`()\n @result.sub! '::operator `class', '::`class'\n\n @result\n end", "def handle_ifdefs_in(body)\n body.gsub(/^#ifdef HAVE_PROTOTYPES.*?#else.*?\\n(.*?)#endif.*?\\n/m) { $1 }\n end", "def render_declaration_specifier(stream)\n # The inline specifier is not a part of C89 yet descent compilers do inlining at will\n # given the function definition is available at the function call\n stream << 'static ' if inline?\n end", "def definition_for_owner(line)\n if line =~ /\\Adef (?:.*?\\.)?#{Regexp.escape(method.original_name)}(?=[\\(\\s;]|$)/\n \"def #{method.original_name}#{$'}\"\n else\n raise CommandError, \"Could not find original `def #{method.original_name}` line to patch.\"\n end\n end", "def untrace_var(*rest) end", "def remove_const(sym) end" ]
[ "0.52369106", "0.52021605", "0.51711315", "0.5165953", "0.51296794", "0.51277936", "0.5084219", "0.5027348", "0.5021174", "0.50051385", "0.4998555", "0.49187663", "0.49090204", "0.49020508", "0.48797026", "0.48459277", "0.4845182", "0.48037097", "0.47820604", "0.4779445", "0.47415847", "0.473926", "0.4739243", "0.473843", "0.47138885", "0.4694996", "0.46919253", "0.46908358", "0.46813288", "0.46765932" ]
0.6804525
0
A list that provides details about the pending maintenance actions for the resource.
def pending_maintenance_action_details data.pending_maintenance_action_details end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_maintenance(opts = {})\n data, _status_code, _headers = list_maintenance_with_http_info(opts)\n return data\n end", "def index\n @maintenances = Maintenance.not_expired\n end", "def action_list\n case\n when no_servers_or_positive_balance? then clear_notifications\n when before_shutdown_warnings? then before_shutdown_actions\n when perform_shutdown? then shutdown_servers_actions\n when before_destroy_warnings? then before_destroy_actions\n when perform_destroy? then destroy_servers_actions\n else no_actions\n end\n end", "def index\n @maintenance_requests = MaintenanceRequest.all\n end", "def index\n permission_denied if !is_adm?\n @maintenance_requests = MaintenanceRequest.where(\"app_status = 0\")\n end", "def get_maintenances()\n results = @zabbix.raw_api(\"maintenance.get\", {\"output\" => \"extend\", \"selectHosts\" => \"extend\", \"selectGroups\" => \"extend\"} )\n pp results\n end", "def actions\n return [] unless sipity_entity && current_ability && (current_ability.current_user.admin? || state != 'pending_deletion')\n\n actions = Hyrax::Workflow::PermissionQuery.scope_permitted_workflow_actions_available_for_current_state(entity: sipity_entity, user: current_ability.current_user)\n actions.map { |action| [action.name, action_label(action)] }\n end", "def index\n @device_maintenances = DeviceMaintenance.all\n end", "def maintenances\n @project = Project.find(params[:id])\n @trackers = @project.trackers\n @issue_categories = @project.issue_categories\n @versions = @project.versions\n @issue_statuses = IssueStatus.all\n @issue_priorities = Enumeration.find_all_by_opt(\"IPRI\")\n result = {'trackers' => @trackers, 'statuses' => @issue_statuses, 'versions' => @versions,\n 'categories' => @issue_categories, 'priorities' => @issue_priorities}\n\n respond_to do |format|\n format.html\n format.xml { render :xml => result, :status => :ok}\n format.json { render :json => result }\n end\n\n end", "def maintenance_list(statuspage_id)\n request :method => :get,\n :url => @url + 'maintenance/list/' + statuspage_id\n end", "def maintenance_actions\n\t\t\tif is_mortgaged?\n\t\t\t\t\t\tif @owner.decide(:consider_unmortgage, property: self).is_yes? and @owner.balance > cost\n\t\t\t\t\t\t\tunmortgage!\n\t\t\t\t\t\tend\n\t\t\tend\n\t\t\tsuper\n\t\tend", "def maintenance_status\n get \"/setup/api/maintenance\", password_hash\n end", "def index\n @maintenance_types = MaintenanceType.all\n end", "def available_actions\n ret = {}\n @jira.available_actions(self[:key]).each{|q| ret[q['id']] = q['name']}\n ret\n end", "def resource_actions\n return @resource_actions\n end", "def resource_actions\n return @resource_actions\n end", "def resource_actions\n @resource_actions ||= []\n end", "def maintenance\n end", "def actions\n return [] unless sipity_entity && current_ability\n actions = Hyrax::Workflow::PermissionQuery.scope_permitted_workflow_actions_available_for_current_state(entity: sipity_entity, user: current_ability.current_user)\n actions.map { |action| [action.name, action_label(action)] }\n end", "def list_maintenance_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MaintenanceApi.list_maintenance ...\"\n end\n if @api_client.config.client_side_validation && opts[:'type'] && !['all', 'past', 'non-expired'].include?(opts[:'type'])\n fail ArgumentError, 'invalid value for \"type\", must be one of all, past, non-expired'\n end\n # resource path\n local_var_path = \"/v1/maintenance\"\n\n # query parameters\n query_params = {}\n query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['GenieKey']\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 => 'ListMaintenanceResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MaintenanceApi#list_maintenance\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def maintenance_options\n data[:maintenance_options]\n end", "def list\n List.from_response client.get(\"/actions/#{action_id}/list\")\n end", "def index\n @due_actions = DueAction.all\n end", "def resources_actions\n @resources_actions ||= []\n end", "def index\n @maintenance_parts = MaintenancePart.all\n end", "def default_actions\n [\n Constants.TASK_ACTIONS.ADD_ADMIN_ACTION.to_h,\n Constants.TASK_ACTIONS.CANCEL_AND_RETURN_TASK.to_h\n ]\n end", "def actions\n %w[credit]\n end", "def maintenance_help\n puts \"Valid maintenance types are:\"\n Spinneret::Maintenance.constants.each { |cls| puts \" #{cls.to_s}\" }\n puts \"Note that capitalization *is* important and that Opportunistic is\"\n puts \"note a valid maintenance mode by itself.\"\nend", "def index\n @maintenances = @vehicle.maintenances.order('date desc').page(params[:page])\n end", "def index\n @schedule_actions = ScheduleAction.all\n end" ]
[ "0.69377005", "0.67883795", "0.6785492", "0.648623", "0.64184266", "0.6387241", "0.6299356", "0.6151939", "0.61399925", "0.6052113", "0.59828323", "0.59791803", "0.59536475", "0.59138256", "0.5895699", "0.5895699", "0.58566976", "0.5855374", "0.58221895", "0.5815838", "0.5753541", "0.572704", "0.57155097", "0.5691215", "0.56786937", "0.55548793", "0.55457926", "0.55265003", "0.55211294", "0.5519026" ]
0.7492023
0
Override this method to define your query
def query; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query\n super\n end", "def initialize\n super(\"query\")\n end", "def query\n end", "def query(_tql)\n raise NotImplementedError.new\n end", "def to_query(_model)\n raise 'subclasses should implement this method.'\n end", "def query\n @operation = :query\n self\n end", "def query(query_definition)\n return\n end", "def initial_query; end", "def _query(*params)\n fail 'not implemented'\n end", "def query\n self\n end", "def query\n self\n end", "def method_missing(method_name, *args, &block)\n if Query.instance_methods(false).include?(method_name)\n Query.new(self).send(method_name, *args, &block)\n else\n super\n end\n end", "def query\n get_query_object\n end", "def make_query\n run_callbacks :make_query do\n self.scope.search(get_query_params)\n end\n end", "def query\n return @query\n end", "def query\n return @query\n end", "def query\n return @query\n end", "def query_full\n query = @initial_query.dup\n\n # restrict to select columns\n query = query_projection(query)\n\n #filter\n query = query_filter(query)\n\n # sorting\n query = query_sort(query)\n\n # paging\n query_paging(query)\n end", "def query\n @query ||= search.query\n end", "def define_query\n name = @name\n klass.send :define_method, \"#{name}?\" do\n send(\"#{name}_value\").present? &&\n send(\"#{name}_unit\").present?\n end\n end", "def raw_query\n @raw_query\n end", "def find(query); end", "def find(query); end", "def query\n\t\tQuery.new(\"true\")\n\tend", "def query(query)\n check_reader\n\n Query.new(self, @reader, query)\n end", "def search(query); end", "def process_query(query)\n # Nothing in default\n end", "def remote_query\n raise \"You must override `remote_query' in your class\"\n end", "def add_general_query\n fields = [\n \"creators.name^5\",\n \"title^7\",\n \"endnotes\",\n \"notes\",\n \"summary\",\n \"tags.name\",\n \"series.title\"\n ]\n query_string = options[:q]\n return if query_string.blank?\n body.must(\n :query_string,\n fields: fields,\n query: query_string\n )\n end", "def initialize\n @query_fields = nil \n @query_params = {}\n \n @sql_like = 'LIKE'\n \n if ActiveRecord::Base.connected? and ActiveRecord::Base.connection.adapter_name.downcase == 'postgresql'\n @sql_like = 'ILIKE'\n end\n end" ]
[ "0.83135086", "0.77335954", "0.76337665", "0.7523034", "0.73779196", "0.73275566", "0.7017944", "0.7001741", "0.6972929", "0.6870267", "0.6870267", "0.67949146", "0.6773889", "0.6746119", "0.6713775", "0.6713775", "0.6713775", "0.6713747", "0.67085385", "0.6668631", "0.6659817", "0.66525936", "0.66525936", "0.6635188", "0.6624086", "0.66189617", "0.65907675", "0.6574582", "0.657036", "0.656574" ]
0.7828738
1
Create the torrent after the site is built
def after_build(builder) torrent = Torrent.new options.tracker torrent.defaultdir = options.name torrent.set_private if options.private # Move to build_dir so it's not added to the torrent within_build_path do app.sitemap.resources.each do |file| # We decode the path because it can have spaces (%20) and stuff torrent.add_file URI.decode(file.path) builder.say_status 'to torrent', URI.decode(file.path) end torrent.write_torrent options.file end builder.say_status :create, File.join(app.config.build_dir, options.file) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_locally\n write_file(@description, @news_name)\n write_file(@poster_file, @poster_name)\n end", "def add_torrent(info)\r\n hash = { \"torrent-file\"=>info[0], \"file-dir\"=>info[1], \"download-dir\"=>info[2] }\r\n @torrents[\"torrent#{@torrents.length}\"] = hash\r\n @file_descriptor.seek(0, IO::SEEK_SET)\r\n @file_descriptor.write(@torrents.to_yaml)\r\n end", "def create\n create_hiera_template\n create_manifests_node\n create_node_checkpoint\n end", "def create_locally\n write_file(@video_file, @video_name)\n write_file(@poster_file, @poster_name)\n end", "def execute!\n make_web_directory\n generate_universe\n generate_html\n print_success_message\n end", "def generate\n verify_path\n \n self.layouts.each {|layout| layout.write_file}\n self.pages.each {|page| page.write_file}\n \n Webby.site.content_dir = self.content_dir\n Webby.site.layout_dir = self.layout_dir\n Webby.site.template_dir = self.template_dir\n Webby.site.output_dir = self.output_dir\n \n Merb.logger.debug \"content_dir: #{Webby.site.content_dir}\"\n Merb.logger.debug \"layout_dir: #{Webby.site.layout_dir}\"\n Merb.logger.debug \"template_dir: #{Webby.site.template_dir}\"\n Merb.logger.debug \"output_dir: #{Webby.site.output_dir}\"\n \n # Use directory => '.' option to generate the site in output_dir\n Webby.site.page_defaults = {'layout' => self.default_layout.relative_path,\n 'directory' => '.',\n 'collision' => :force}\n \n Merb.logger.debug \"page_defaults: #{Webby.site.page_defaults}\" \n # returns nil if success \n # Webby::Builder.run\n Webby::Builder.run :rebuild => true\n end", "def process\n\t\t\t\tbegin\n\t\t\t\t\t@site_name = self.args.join\n\t\t\t\t\tFileUtils.mkdir @site_name\n\t\t\t\t\tFileUtils.cp_r Dir.glob(File.expand_path('../../../new_site', __FILE__) + '/*'), File.join(self.source, @site_name)\n\t\t\t\t\tFileUtils.mkdir_p File.join(self.source, @site_name, \"media\")\n\t\t\t\t\tFileUtils.mkdir_p File.join(self.source, @site_name, \"pages\")\n\t\t\t\t\tFileUtils.mkdir_p File.join(self.source, @site_name, \"media/images\")\n\t\t\t\t\tFileUtils.mkdir_p File.join(self.source, @site_name, \"media/videos\")\n\t\t\t\t\tFileUtils.mkdir_p File.join(self.source, @site_name, \"media/sounds\")\n\t\t\t\t\tFileUtils.mkdir_p File.join(self.source, @site_name, \"includes\")\n\t\t\t\t\tFileUtils.mkdir_p File.join(self.source, @site_name, \"plugins\")\n\t\t\t\t\tFileUtils.mkdir_p File.join(self.source, @site_name, \"extras\")\n\t\t\t\t\tdefault_page\n\n\t\t\t\t\tp \"#{@site_name} created.\"\n\t\t\t\trescue Exception => e\n\t\t\t\t\tp e\n\t\t\t\tend\n\t\t\tend", "def generate(site)\n begin\n Dir.mkdir('scripts') unless Dir.exists?('scripts')\n Dir.mkdir('_data') unless Dir.exists?('_data')\n Dir.mkdir('_data/jailRoster') unless Dir.exists?('_data/jailRoster')\n rescue Exception => msg\n puts \"Error creating directories\"\n puts msg\n end\n\n begin\n # open('scripts/PrecinctInfo.js', 'w') do |file|\n # file << open('http://www.canyonco.org/CanyonCounty/Webparts/Elections/js/PrecinctInfo.js?v2').read\n # end\n\n open('_data/arrests.json', 'w') do |file|\n file << open('http://api.canyonco.org/Sheriff/CurrentArrest').read\n end\n\n open('_data/jailList.json', 'w') do |file|\n file << open('http://api.canyonco.org/Sheriff/JailList').read\n end \n rescue Exception => msg\n puts \"Error downloading content\"\n puts msg\n end\n end", "def save_locally(dir)\n FileUtils.mkdir_p(dir) unless File.exists? dir\n \n # remove HTML BASE tag if it exists\n @contents.xpath('//base').each { |t| t.remove }\n # remove head tag\n @contents.xpath('//head').each { |t| t.remove }\n # remove link tags\n @contents.xpath('//link').each { |t| t.remove }\n # remove script tags\n @contents.xpath('//script').each { |t| t.remove }\n # remove comments\n @contents.xpath('//comment()').each { |t| t.remove }\n # remove mediawiki meta tag\n @contents.xpath('//meta').each { |t| t.remove if t['name'] == \"generator\" }\n # remove sitesub h3 tag\n @contents.xpath('//h3').each { |t| t.remove if t['id'] == \"siteSub\" }\n\n # get lastmod/viewcount values\n @contents.xpath('//li').each do |t|\n if t['id'] == \"lastmod\"\n @lastmod = t.text.strip\n end\n if t['id'] == \"viewcount\"\n @viewcount = t.text.strip\n end\n end\n\n # remove unneeded divs\n @contents.xpath('//div').each do |t|\n t.remove if t['id'] == \"column-one\"\n t.remove if t['id'] == \"footer\"\n t.remove if t['id'] == \"catlinks\"\n t.remove if t['id'] == \"contentSub\"\n t.remove if t['id'] == \"jump-to-nav\"\n t.remove if t['class'] == \"printfooter\"\n t.remove if t['class'] == \"visualClear\"\n end\n\n if @main_page == true\n save_path = File.join(dir, \"index\")\n title = 'Dublin Core Metadata Initiative Media-Wiki Archive'\n else\n save_path = File.join(dir, File.basename(uri.to_s))\n title = File.basename(uri.to_s).gsub(\"_\", \" \")\n end\n save_path += '.html' if save_path !~ /\\.((html?)|(txt))$/\n File.open(save_path, 'w') { |f| f.write(\"<!DOCTYPE html>\\n<html>\\n<head>\\n<meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html; charset=UTF-8\\\">\\n<meta http-equiv=\\\"Content-Language\\\" content=\\\"en-us\\\">\\n<title>#{title}</title>\\n</head>\\n<body>\\n<p><b>This is an archived MediaWiki page.</b><br />#{@lastmod}<br />#{@viewcount}</p>\\n#{@contents.xpath('//div[@id=\"bodyContent\"]').to_html}\\n</body>\\n</html>\") }\n # File.open(save_path, 'w') { |f| f.write(\"---\\nlayout: page\\ntitle: #{title}\\n---\\n\\n#{@contents.xpath('//div[@id=\"bodyContent\"]').to_html}\") }\n end", "def create_site\n files = site_files\n\n # in update mode we only want to update the tasks directory\n if options[:update]\n FileUtils.mkdir_p site unless pretend?\n mkdir 'tasks'\n files['tasks'].sort.each {|file| cp file}\n else\n dirs = files.keys.concat %w[content layouts lib tasks templates]\n dirs.sort!\n dirs.uniq!\n\n # create the directories first\n dirs.each do |dir|\n next if dir =~ %r/^output\\/.*$/\n mkdir dir\n end\n\n # and the create the files under each directory\n dirs.each do |dir|\n next if dir =~ %r/^output(\\/.*)?$/\n files[dir].sort.each {|file| cp file}\n end\n end\n end", "def download\n create_agent\n login\n fetch_feed\n create_catalog\n download_catalog\n end", "def run( args )\n parse args\n create_site\n end", "def make_rss_feed\n require 'rss/maker'\n fname = Wiki_path + \"/rss-temp\"\n rss_entries = Marshal::load(File.read(fname))\n\n version = \"2.0\" # [\"0.9\", \"1.0\", \"2.0\"]\n\n content = RSS::Maker.make(version) do |m|\n m.channel.title = Wiki_title\n m.channel.link = Internet_path\n m.channel.description = Wiki_desc\n m.items.do_sort = true # sort items by date\n \n rss_entries.each do |entry|\n i = m.items.new_item\n i.title = entry[:title]\n i.link = entry[:link]\n i.date = entry[:date]\n i.description = entry[:description]\n end\n end\n\n File.write(Wiki_path + \"/data/media/pages.xml\", content) \nend", "def create_site(params={name:random_string})\n\t\tnew_site = site[:new]\n\t\tparams[:site] = params[:name]\n\t\tnew_site[:params].merge!(params)\n\t\tnew_site[:params][:address] = append_ftp_value(new_site[:params][:address],new_site[:params][:ftp_type])\n\t\tpost(new_site)\n\tend", "def create\n @scraping_page = ScrapingPage.new(scraping_page_params)\n\n #--- Set url and new mechanize ---#\n url = @scraping_page.page_url\n uri = URI.parse(url) # ex) https://example.com/ -> set \"example.com\"\n agent = Mechanize.new\n page = agent.get(url)\n\n #--- Set title ---#\n title = page.title if page.respond_to?(:title) # For undefiend page.title method error (ex: RSS or missing title meta tag WebSite).\n title = \"#{title} #{uri.host}\"\n @scraping_page.title = title\n\n #--- Set charset ---#\n @scraping_page.charset = set_charset(page.body)\n\n #--- Obey robots.txt ---#\n robotex = Robotex.new \"Crawler\"\n @scraping_page.is_robots_allowed = robotex.allowed?(url)\n\n #--- Set scraping HTML file name ---#\n @scraping_page.directory_path = create_directory(url) # concerns/file_savable.rb\n\n respond_to do |format|\n if @scraping_page.save\n format.html { redirect_to @scraping_page, notice: 'Scraping page was successfully created.' }\n format.json { render :show, status: :created, location: @scraping_page }\n else\n format.html { render :new }\n format.json { render json: @scraping_page.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tour = Tour.new(params[:tour])\n @tour.create_permalink\n\n respond_to do |format|\n if @tour.save\n flash[:notice] = 'Tour was successfully created.'\n format.html { redirect_to(@tour) }\n format.xml { render :xml => @tour, :status => :created, :location => @tour }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tour.errors, :status => :unprocessable_entity }\n end\n end\n end", "def setup\r\n setup_wiki\r\n setup_host_map\r\n setup_host\r\n end", "def create(p)\n puts \"Creating page #{p}\"\n Dir.mkdir p unless File.exists? p\n Content.new(\"#{@dir}\", @extension).page p\n end", "def run\n super\n\n entity_name = _get_entity_name\n opt_create_entities = _get_option(\"create_entities\")\n \n # Make sure the key is set\n api_key = _get_task_config(\"publicwww_api_key\")\n\n # special case google analytics, as we can find interesting things by not \n # sending the last bit of the key\n if entity_name =~ /^ua-.*$/i\n entity_name = entity_name.split(\"-\")[0..-2].join(\"-\")\n _log \"Dropping trailing part of google user agent: #{entity_name}\"\n end\n\n\n # Craft the UniqueToken search URL to export\n query_url = \"https://publicwww.com/websites/%22#{entity_name}-%22/?export=urls&key=#{api_key}\"\n \n # Download the xport\n download = http_get_body(query_url)\n \n # read the file results\n download.split(\"\\n\").each do |found_url|\n _create_entity(\"Uri\" , \"name\" => found_url) if opt_create_entities\n end\n\n # store links as an extended detail\n _set_entity_detail(\"public_www_results\", { entity_name => download.split(\"\\n\")[1..30] } )\n\n end", "def generate(site)\n end", "def initialize \n @root =\"http://web.archive.org/web/20030820233527/\" +\n \"http://bytravelers.com/journal/entry\" # Initialize the variables. The root of the URL to the cached copy of the site is here. \n @agent = Mechanize.new\n end", "def generate(site)\n @site = site\n @site.config[\"time\"] = Time.new\n unless feed_exists?\n write\n @site.keep_files ||= []\n @site.keep_files << path\n end\n end", "def create_static_artifacts!(working_path)\n super(working_path)\n end", "def build\n site.process\n end", "def to_torrent\n content = {\n 'announce' => announce,\n 'announce-list' => announce_list,\n 'creation date' => creation_date.to_i,\n 'comment' => comment,\n 'created by' => created_by,\n 'encoding' => encoding,\n 'info' => {\n 'piece length' => piece_length,\n 'pieces' => Base64.decode64(pieces).force_encoding('UTF-8'),\n 'private' => private,\n 'name' => name\n }\n }\n content['info'].merge!(\n if is_file?\n file = files.first\n {\n 'length' => file.length,\n 'md5sum' => file.md5sum,\n }\n else\n {\n 'files' => files.map do |f|\n TorrentFile::ATTRIBUTES\n .select { |e| f.send(e).present? }\n .inject({}) { |hsh, e| hsh[e] = f.send(e); hsh }\n end\n }\n end\n )\n\n content.bencode\n end", "def build_site(page_count, sitebuildtime, url, sitemap_url)\n # write all the HTML pages to files and build the site map\n sitemap = %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset\n xmlns=\"#{sitemap_url}\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"#{sitemap_url}\n #{sitemap_url}/sitemap.xsd\">\n <url>\n <loc>#{url}</loc>\n <lastmod>#{sitebuildtime}</lastmod>\n <priority>1.00</priority>\n </url>)\n (0..page_count).map do |i|\n file = File.open(\"index#{ii(i)}.html\", 'w')\n file.write(instance_variable_get(\"@page#{ii(i)}\"))\n file.close\n sitemap += %(\n <url>\n <loc>#{url}index#{ii(i)}.html</loc>\n <lastmod>#{sitebuildtime}</lastmod>\n <priority>0.80</priority>\n </url>)\n end\n sitemap += '\n</urlset>'\n file = File.open('sitemap.xml', 'w')\n file.write(sitemap)\n file.close\n file = File.open('robots.txt', 'w')\n file.write(\"Sitemap: #{url}sitemap.xml\")\n file.close\nend", "def build_site(config_options)\n t = Time.now\n display_folder_paths(config_options)\n if config_options[\"unpublished\"]\n Bridgetown.logger.info \"Unpublished mode:\",\n \"enabled. Processing documents marked unpublished\"\n end\n Bridgetown.logger.info \"Generating…\"\n @site.process\n Bridgetown.logger.info \"Done! 🎉\", \"#{\"Completed\".bold.green} in less than \" \\\n \"#{(Time.now - t).ceil(2)} seconds.\"\n\n return unless config_options[:using_puma]\n\n require \"socket\"\n external_ip = Socket.ip_address_list.find do |ai|\n ai.ipv4? && !ai.ipv4_loopback?\n end&.ip_address\n scheme = config_options.bind&.split(\"://\")&.first == \"ssl\" ? \"https\" : \"http\"\n port = config_options.bind&.split(\":\")&.last || ENV[\"BRIDGETOWN_PORT\"] || 4000\n Bridgetown.logger.info \"\"\n Bridgetown.logger.info \"Now serving at:\", \"#{scheme}://localhost:#{port}\".magenta\n Bridgetown.logger.info \"\", \"#{scheme}://#{external_ip}:#{port}\".magenta if external_ip\n Bridgetown.logger.info \"\"\n end", "def create_sitemap\n end", "def create_project(tx)\n Installer.copy(tx, \"#{@service_dir}/pieces/public\", get_path(:web))\n true\n end", "def create!\n new_file = \"#{next_number}-#{strip_title}.md\"\n @path = File.join(@dir, new_file)\n File.open(@path, 'w') do |file|\n file.write initial_content\n end\n\n new_file\n end" ]
[ "0.614721", "0.6045362", "0.5801728", "0.5796103", "0.5751159", "0.5571135", "0.5521312", "0.5498561", "0.5456376", "0.5406971", "0.53939956", "0.5380164", "0.5379817", "0.53789026", "0.5361563", "0.5351798", "0.53282934", "0.5321348", "0.531415", "0.5311328", "0.53026813", "0.5285306", "0.52841175", "0.52815175", "0.5267546", "0.5265573", "0.5262784", "0.525252", "0.52315634", "0.52210546" ]
0.6911082
0
Move to build dir for the block
def within_build_path(&block) Dir.chdir app.config.build_dir do yield end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_build_step(&block)\n\t\t\t@project.post_build_steps << [block, Dir.pwd]\n\t\tend", "def build_working_dir(&block)\n file_name =\n if block.respond_to?(:source_location)\n block.source_location[0]\n else\n eval(\"__FILE__\", block.binding)\n end\n\n @working_dir = File.expand_path(\n File.join(File.dirname(file_name), \"generated\"))\n end", "def in_build\n source_dir, build_dir = find_dirs\n FileUtils.mkdir_p(build_dir) unless File.directory?(build_dir)\n Dir.chdir build_dir do\n yield(source_dir)\n end\nend", "def build_dir\n @build_dir ||= File.join(Crate.project.build_dir, name )\n end", "def prep_build\n stdout.out_success(\"\\nPreparing build dir at: '#{settings['build_dir']}'\")\n stdout.verbose(\"Removing build dir at: #{settings['build_dir']}\")\n FileUtils.rm_rf(settings['build_dir'])\n # create the build dir\n stdout.verbose(\"Creating build dir at: #{settings['build_dir']}\")\n FileUtils.mkdir(settings['build_dir'])\n end", "def build_archive # @location == LOCATION(group, user, mtime, experiment_id)\n restore_dir = Dir.pwd\n @mount_dir ||= ::ArchiveRoot\n FileUtils.mkdir_p(File.join(@mount_dir, @location))\n Dir.chdir(File.join(@mount_dir, @location))\n # cp the config file from the higher level down\n @@build_directories.each do |dir|\n FileUtils.mkdir dir unless Dir.exist?(dir)\n end\n Dir.chdir(restore_dir)\n # Find a config file and move it down to this directory... right?\n end", "def there(&block)\n Dir.chdir File.join(@repo.dir, @path), &block\n end", "def there(&block)\n Dir.chdir @repo.dir, &block\n end", "def build_to_temp_dir\n @builder.build_project\n\n # Copy build files to temporary directory\n @task.shell.mute do\n @task.directory @project.build_path, ::File.join(@project.package_path, @package_name), :force => true\n end\n end", "def compile\n tmpdir = Dir.mktmpdir\n Dir.chdir(tmpdir) do |source_dir, build_dir|\n yield source_dir, @build_dir\n end\n\n puts \"Packaging the following files/dirs:\"\n pipe \"ls #{@build_dir}\"\n ensure\n if ENV['DEBUG']\n puts \"Source dir: #{tmpdir}\"\n else\n FileUtils.rm_rf(tmpdir)\n end\n end", "def after_build(builder)\n torrent = Torrent.new options.tracker\n\n torrent.defaultdir = options.name\n torrent.set_private if options.private\n\n # Move to build_dir so it's not added to the torrent\n within_build_path do\n app.sitemap.resources.each do |file|\n # We decode the path because it can have spaces (%20) and stuff\n torrent.add_file URI.decode(file.path)\n builder.say_status 'to torrent', URI.decode(file.path)\n end\n\n torrent.write_torrent options.file\n end\n\n builder.say_status :create, File.join(app.config.build_dir, options.file)\n end", "def build_directory\n File.expand_path(config['build_directory'])\n end", "def destination_rel_dir\n replace_build_path(super)\n end", "def prepare\n if not File.exists?(OBS_BUILD_DIR)\n FileUtils.mkdir_p OBS_BUILD_DIR\n end\n cleanup\n end", "def move_dirs\n \n end", "def build()\n \n #check dir exists, if not, make it\n if(!File.exists?(@path))\n Dir.mkdir(@path)\n end\n \n #build directory structure\n puts 'Building directory structure'\n build_skeleton(@template.directory_structure)\n \n #execute build tasks\n puts 'Running build tasks'\n execute_tasks(@template.tasks,@template.path)\n \n puts 'Skeleton built'\n \n end", "def run_dir\n run_base + \"/g4.#{geant_version}_cms_#{cmssw_version}/#{build_type}/CMSSW_#{cmssw_version}/src\"\n end", "def build_here\n cp_a File.join(root_dir, \"test\", \"setup\", \"#{name}.svn.gz\"), \".\"\n\n puts `gzip -f -d #{name}.svn.gz`\n raise unless $? == 0\n puts `svnadmin create #{name}`\n raise unless $? == 0\n puts `svnadmin load #{name} < #{name}.svn`\n raise unless $? == 0\n end", "def build!\n build_to self[:build_path]\n end", "def build_dir\n File.expand_path(\"#{Config.build_dir}/#{project.name}\")\n end", "def build_archive_dir\n out = config_source['build-archive-dir']\n out = nil if (out != nil && out.downcase == 'none')\n out = FilePath.new(out) unless out.nil?\n out\n end", "def jump_to(path, &block)\n Dir.chdir(test_content_dirs(path), &block)\nend", "def create_source_tree2\n if !File.exist?(@sourceDir2)\n FileUtils.rm_rf(@sourceDir2)\n FileUtils.cp_r(@sourceDir,@sourceDir2)\n end\n # Remove any existing repository file\n FileUtils.rm_rf(@repoFile2)\n end", "def build_target_path\n File.join(destination, configuration[:build_target_path])\n end", "def build!\n test_git!\n\n file_list = Dir.glob(\"#{@source}*\").sort # Pull the file list before creating the target directory\n\n setup_target\n\n add_runner\n\n file_list.each do |infile_name|\n rewrite_animation_frame infile_name\n create_commit infile_name\n end\n end", "def prepare(module_name, version)\n return if @target.directory?\n\n begin\n @target.mkpath\n Puppet.notice _(\"Created target directory %{dir}\") % { dir: @target }\n rescue SystemCallError => orig_error\n raise converted_to_friendly_error(module_name, version, orig_error)\n end\n end", "def stage!\n build_to self[:staging_path]\n end", "def chdir(&block)\n Dir.chdir(ROOT.join(name), &block)\n end", "def setup_skeleton\r\n self.destination_root = File.join(path, name)\r\n @class_name = name.classify\r\n @guid = UUIDTools::UUID.timestamp_create.to_s\r\n directory(\"base_app/\", self.destination_root)\r\n copy_file File.join(self.destination_root, \"blend_solution.sln\"), File.join(self.destination_root, \"#{@class_name}.sln\")\r\n copy_file File.join(self.destination_root, \"src\", \"ironnails_controls.csproj\"), File.join(self.destination_root, \"src\", \"#{@class_name}.Controls.csproj\")\r\n remove_file File.join(self.destination_root, \"blend_solution.sln\")\r\n remove_file File.join(self.destination_root, \"src\", \"ironnails_controls.csproj\")\r\n\r\n store_component_config('.components')\r\n end", "def output_dir(vm_name, build_type)\n unless build_type == 'base'\n File.join('./output/', \"#{vm_name}-virtualbox\")\n else\n File.join('./output/', \"#{vm_name}-base-virtualbox\")\n end\nend" ]
[ "0.6473651", "0.63888645", "0.6380053", "0.6232129", "0.6231429", "0.6183314", "0.61091894", "0.6024885", "0.58681", "0.57284164", "0.57081604", "0.5706366", "0.56836075", "0.5674697", "0.5668901", "0.5667944", "0.55256456", "0.55207163", "0.54514784", "0.5449114", "0.54415774", "0.54362476", "0.5428877", "0.5424482", "0.54187703", "0.54123855", "0.5402664", "0.53716075", "0.531386", "0.53092307" ]
0.67182255
0
Returns the 'components' object for a supported/unsupported scanner's report
def build_components_object info = @scan_report.to_h.fetch(:info) return [] unless info[:dependencies] components = [] info[:dependencies].each do |dependency| components << parse_dependency(dependency) end components end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def available_components\n @available_components ||= {}\n end", "def components\r\n params = {\r\n method: :get,\r\n url: '/report/components',\r\n params: {\r\n reportUUID: @uuid\r\n }\r\n }\r\n @session.request(params).perform!\r\n end", "def components\n @components ||= self.class.registered_components.inject({}){ |res, name| res.merge(name.to_sym => send(COMPONENT_METHOD_NAME % name)) }\n end", "def components\n @components ||= self.class.registered_components.inject({}){ |res, name| res.merge(name.to_sym => send(COMPONENT_METHOD_NAME % name)) }\n end", "def available_components\n components = []\n @components.each_key do |k|\n components << k if @components[k].registered?\n end\n components\n end", "def load_components\n\t\t\t\treturn @data['components'].map do |componentstr|\n\t\t\t\t\tcomponent = componentstr.to_sym\n\t\t\t\t\tif (Instances::Components.constants.include? component)\n\t\t\t\t\t\tnext [component, Instances::Components.const_get(component).new]\n\t\t\t\t\telse\n\t\t\t\t\t\t## Component doesn't exist, display warning\n\t\t\t\t\t\tinstance_type = get_instance_type_classname\n\t\t\t\t\t\tclassname = get_classname\n\t\t\t\t\t\tlog \"WARNING: #{instance_type} '#{classname}' tried to load Component '#{componentstr}' which doesn't exist.\"\n\t\t\t\t\t\tnext nil\n\t\t\t\t\tend\n\t\t\t\tend .reject { |x| !x } .to_h if (@data['components'])\n\t\t\tend", "def component_types; @component_types; end", "def gather_components(category)\n component_list = Array.new\n config = self.config[category]\n\n # Throw out false values\n config.keys.reject {|i| self[i].class == FalseClass}.each do |comp_name|\n # Special cases for now...\n next if comp_name.match(\"startup_sequence\")\n next if comp_name.match(\"hid\")\n\n # Make sure our corresponding component actually exists. \n comp_template = Component.find_by_name_and_category(comp_name, category)\n if !comp_template\n raise BuildError.new(message: \"sketch component not found: #{comp_name}\")\n end\n \n # If our particular item is a hash or array, we assume it has\n # nested attributes.\n if config[comp_name].class == Hash || config[comp_name].class == Array\n context = config[comp_name]\n else\n # Find if our value is a blob referring to another component\n context = config\n component = Component.find_by_name_and_category(config[comp_name], \"blob\")\n if !component.nil?\n context = {comp_name => component.global}\n end\n end\n component_list.push(return_segments(comp_template, context))\n end\n\n # Special case for this one for now\n seq = context = nil\n startup_seq = config['startup_sequence']\n if startup_seq\n if startup_seq.present?\n seq = Component.find_by_name(\"startup_sequence\")\n component_list.push(return_segments(seq, context))\n elsif Component.find_by_name(startup_seq)\n if Component.find_by_name(startup_seq).category == \"pattern\"\n seq = Component.find_by_name(\"startup_pattern\")\n context = startup_seq\n component_list.push(return_segments(seq, context))\n # TODO: if we're running a pattern at startup make sure the pattern\n # itself is actually included.\n end\n end\n end\n component_list\n end", "def components\n @components ||= enabled_components.map { |component| component.new(@context) }\n end", "def converter(scan_report)\n adapter = \"Cyclonedx::#{scan_report.scanner_name}\"\n begin\n converter = Object.const_get(adapter).new(scan_report)\n converter.config = @config\n rescue NameError\n converter = Cyclonedx::Base.new(scan_report, @config)\n end\n converter.build_components_object\n end", "def component_options\n COMPONENTS.map do |name, data|\n [data[:desc], name.to_s]\n end\n end", "def components\n\t\t\t@components ||= []\n\t\tend", "def getComponentTestSpecs\n return {\n :InstallParameters => [ '--install', 'SlaveProduct', '--product', 'DummyProduct', '--as', 'RegProduct' ],\n :InstallParametersShort => [ '-i', 'SlaveProduct', '-r', 'DummyProduct', '-s', 'RegProduct' ],\n :ComponentName => 'RegProduct',\n :ComponentInstallInfo => {\n :Description => 'This Slave Product is used for regression purposes only.',\n :Author => 'muriel@x-aeon.com',\n :Product => 'DummyProduct',\n :Type => 'Slave'\n },\n :RepositoryNormal => 'Dummy/SlaveClientInstalled',\n :RepositoryInstalled => 'Dummy/SlaveProductInstalled',\n :RepositoryConfigured => 'Dummy/SlaveProductConfigured',\n :ProviderEnv => {\n :WEACESlaveInfoURL => 'http://weacemethod.sourceforge.net'\n }\n }\n end", "def components\n\t\t\t\treturn @components.values unless (@components.nil?)\n\t\t\t\treturn nil\n\t\t\tend", "def set_scanner\n @obj = Rho::Barcode.enumerate\n #Alert.show_popup(@params.to_json.to_s)\n if @params['scanner_type']\n @obj.each do |scannerObj|\n $scanner = scannerObj if scannerObj.scannerType == @params['scanner_type']\n end\n end\n\n if @params['scanner_name']\n @obj.each do |scannerObj|\n $scanner = scannerObj if scannerObj.friendlyName == @params['scanner_name']\n end \n end\n end", "def find_available_components(component_descr, component_type, valid_from, valid_until, non_valid_component_uuids = [], nof_requested_components = 1, authorizer)\n debug \"central find_all_available_components: descr: '#{component_descr.inspect}', from: '#{valid_from}', until: '#{valid_until}'\"\n raise 'Method not implemented because the Central Manager just need to pass the same requisition to the other' \\\n ' brokers and create the concatenated results'\n end", "def components\n @source.components\n end", "def components\n @source.components\n end", "def components\n @source.components\n end", "def components\n @source.components\n end", "def find_available_components(component_descr, component_type, valid_from, valid_until, non_valid_component_uuids = [], nof_requested_components = 1, authorizer)\n debug \"find_all_available_components: descr: '#{component_descr.inspect}', from: '#{valid_from}', until: '#{valid_until}'\"\n component_descr[:account_id] = _get_nil_account.id\n components = find_all_resources(component_descr, component_type, authorizer)\n components.shuffle! # this randomizes the result\n\n output = []\n components.each do |comp|\n next if non_valid_component_uuids.include?(comp.uuid)\n output << comp if @scheduler.component_available?(comp, valid_from, valid_until)\n break if output.size >= nof_requested_components\n end\n\n raise UnavailableResourceException if output.size < nof_requested_components\n output\n end", "def components\n return @components\n end", "def components\n components = Backlogjp.base._command \"getComponents\", self.id\n components.map {|hash| Component.new(hash)}\n end", "def find_comps\n\t\tcomps.each do |c|\n\t\t\tc.comp_tag + ' '\n\t\tend\n\tend", "def components\n arr = Arrays.new(@nb) { [] }\n (0...@component.size).each { |v| arr[@component[v]] << v }\n end", "def components\n arr = Arrays.new(@nb) { [] }\n (0...@component.size).each { |v| arr[@component[v]] << v }\n end", "def get_dell_chassis_info\n ENV['PATH'] = \"#{ENV['PATH']}:/opt/dell/srvadmin/bin/\"\n chassis = {}\n result = nil\n begin\n #result = `omreport modularenclosure -fmt ssv`\n #result.split(\"\\n\").each do |line|\n # if line =~ /Service Tag/\n # chassis[:service_tag] = line.split(\";\")[1].strip\n # break\n # end\n #end\n timeout(5) do\n result = `omreport chassis info -fmt ssv`\n end\n result.split(\"\\n\").each do |line|\n if line =~ /Server Module Location;Slot (\\d+)/\n chassis[:slot_num] = $1.to_i\n elsif line =~ /Chassis Service Tag/\n chassis[:service_tag] = line.split(\";\")[1].strip\n end\n end\n # if no slot_number then the blade isn't really in a chassis/blade enclosure\n # such as the case with Dell PowerEdge 1950\n return {} if chassis[:slot_num].nil?\n rescue Timeout::Error\n warn \"Timed out when trying to run omreport\"\n rescue\n warn \"Failed to run/parse Dell's omreport command\"\n end\n return chassis\n end", "def details\n @specs = WatirNokogiri::Document.new(specs_element.html).table\n\n {\n screen: spec(Constants::PRODUCT_PAGE[:specs][:screen]),\n sensor: spec(Constants::PRODUCT_PAGE[:specs][:sensor]),\n megapixels: spec(Constants::PRODUCT_PAGE[:specs][:megapixels])\n }\n end", "def notifiers\n supported = Notifier.supported\n Notifier.connect(notify: true, silent: true)\n detected = Notifier.detected\n Notifier.disconnect\n\n detected_names = detected.map { |item| item[:name] }\n\n final_rows = supported.each_with_object([]) do |(name, _), rows|\n available = detected_names.include?(name) ? \"✔\" : \"✘\"\n\n notifier = detected.detect { |n| n[:name] == name }\n used = notifier ? \"✔\" : \"✘\"\n\n options = notifier ? notifier[:options] : {}\n\n if options.empty?\n rows << :split\n _add_row(rows, name, available, used, \"\", \"\")\n else\n options.each_with_index do |(option, value), index|\n if index.zero?\n rows << :split\n _add_row(rows, name, available, used, option.to_s, value.inspect)\n else\n _add_row(rows, \"\", \"\", \"\", option.to_s, value.inspect)\n end\n end\n end\n\n rows\n end\n\n Formatador.display_compact_table(\n final_rows.drop(1),\n %i(Name Available Used Option Value)\n )\n end", "def get_named_components()\n r = Hash.new\n names = get_component_names\n names.each { |n|\n begin\n r[n] = get_component_any(n)\n rescue\n end\n }\n return r\nend" ]
[ "0.6074879", "0.57135725", "0.56114036", "0.56114036", "0.5501453", "0.5483188", "0.54390734", "0.53063494", "0.5201584", "0.5133518", "0.50706005", "0.5060667", "0.5060483", "0.5024374", "0.5001388", "0.49968192", "0.49118775", "0.49118775", "0.49118775", "0.49118775", "0.49053717", "0.48842382", "0.48791805", "0.48606712", "0.48524395", "0.48524395", "0.48466608", "0.4817144", "0.47903666", "0.47893006" ]
0.6637152
0
The gamemode of the HighScore ===== Presentation This is the class' constructor, it only gives the variables their value taken from the parameters. ===== Attributes +idDiff+ The id of the Difficulty of the HighScore +player+ The Player of the HighScore +score+ The score of the HighScore +idMode+ The id of the Gamemode of the HighScore ===== How to Use To create a new HighScore : highScore = HighScore.new(1,1,5000,3)
def initialize(idDiff, player, score, idMode) @id_difficulty_highScores, @player_highScores = idDiff, player @score_highScores, @id_gamemode_highScores = score, idMode end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(id, name)\n @id_gamemode,@name_gamemode = id, name\n end", "def initialize\n\t\t@mult = 1.1\n @name = 'High Low'\n @min = 1\n @game_money = $player.wallet.amount #game_money\n @game_bet = 0\n\tend", "def game_score(score)\n end", "def set_high_score\n @high_score = HighScore.find(params[:id])\n end", "def start_high_low\n new_game = High_Low.new(@player)\n new_game.high_low_game\n puts 'Leaving High-Low Table'\nend", "def set_high_score\n @high_score = HighScore.find(params[:id])\n end", "def define(game_mode:, difficulty:, order_to_attack:)\n if order_to_attack.negative? || order_to_attack > 1\n raise ArgumentError, '0 is first, 1 is second'\n end\n\n @board = Board.new(board_size: 3)\n @stat = GameState.new(order_to_attack)\n @order_to_attack = order_to_attack\n @difficulty = difficulty\n @judge = GameRule.new(game_board: @board.board)\n @game_mode = game_mode\n create_game_with_game_mode(game_mode)\nend", "def game_mode; end", "def set_hscore\n @hscore = Hscore.find(params[:id])\n end", "def set_highscore\n @highscore = Highscore.find(params[:id])\n end", "def show\n @game = Game.find(params[:id])\n @score = Score.new\n end", "def initialize\n @score = 0; #inicializa el puntaje en 0\n end", "def initialize(player_num)\n @player_num = player_num\n @score = 0\n end", "def game\n\n\t# console - list databases: psql -l\n\t# console - access database: psql rick_rampage_development\n\t# database - list tables: \\d \n\t# database - display table: select * from <table_name>;\n\n \t# all high scores assigned to @scores variable\n\t@high_scores = Score.order('points DESC').limit(5).all\n\n\t# last score of the current player assigned to the @score variable\n\t#@score = Score.where(:user_id => current_user.id).first\n\n\t# best rank\n\t@scores_from_top = Score.order('points DESC, created_at DESC').all\n\n\t# worst rank\n\t@scores_from_bottom = Score.order('points ASC, created_at DESC').all\n\n\t@scores_length = @scores_from_bottom.length;\n\n\t#current_user.nil? ? Score.none : current_user.scores.last\n\t\n\tcurrent_user.nil? ? Score.none : @my_latest_score = Score.where(:user_id => current_user.id).order('created_at DESC').first\n\n\tcurrent_user.nil? ? Score.none : @my_avg_score = Score.where(:user_id => current_user.id).order('created_at DESC').average('points').to_i\n\n\t# last rank of the current player assigned to the @rank variable\n\n\t#@rank = Score.order('points DESC').first.points.inspect\n\t#@rank = Score.where(:user_id => current_user.id)\n\n end", "def set_gamescore\n @gamescore = Gamescore.find(params[:id])\n end", "def newgame\n # unless @stats_mode == true\n # puts \"\\n=========================================================\"\n # end\n \n @players = Array.new\n @frame_scores = Array.new\n @game_scores = Array.new\n \n @player = 1\n @frame_no = 1\n @roll_type = 1\n @pins_remaining = 10\nend", "def initialize(player, coregame, gfx_res)\r\n super(player, coregame, gfx_res)\r\n # logger\r\n @log = Log4r::Logger[\"coregame_log\"]\r\n # cards in current player\r\n @cards_on_hand = []\r\n # points hash using player name as key, with array of card label\r\n @points_segno = {}\r\n # card played on table\r\n @card_played = []\r\n # array of players\r\n @players = nil\r\n # alg level \r\n @level_alg = :dummy #:master #:dummy\r\n # deck info for points and rank\r\n @deck_info = GamesDeckInfo.new\r\n @deck_info.build_deck_spazzino\r\n # opponents names \r\n @opp_names = []\r\n # team mate \r\n @team_mates = []\r\n # target points\r\n @target_points = @core_game.game_opt[:target_points]\r\n # cards on deck\r\n @num_cards_on_deck = 0\r\n # cards on table\r\n @table_cards = []\r\n # predifined game\r\n @action_queue = []\r\n # num of cards on hand \r\n @num_cards_on_hand = 3\r\n @log = Log4r::Logger.new(\"coregame_log::AlgCpuSpazzino\") \r\n end", "def initialize(player, coregame, gfx_res)\r\n super(player, coregame, gfx_res)\r\n # logger\r\n @log = Log4r::Logger.new(\"coregame_log::AlgCpuMariazza\")\r\n # cards in current player\r\n @cards_on_hand = []\r\n # points hash using player name as key, with array of card label\r\n @points_segno = {}\r\n # card played on table\r\n @card_played = []\r\n # array of players\r\n @players = nil\r\n # alg level \r\n @level_alg = :master #:dummy\r\n # briscola\r\n @briscola = nil\r\n # deck info for points and rank\r\n @deck_info = GamesDeckInfo.new\r\n @deck_info.build_deck_briscola\r\n # opponents names \r\n @opp_names = []\r\n # team mate \r\n @team_mates = []\r\n # target points\r\n @target_points = @core_game.game_opt[:target_points_segno]\r\n # mariazza available on suite\r\n @mariazz_on_suite = {}\r\n # strotti available on suite\r\n @strozzi_on_suite = {}\r\n # store commands when usign delay player\r\n @command_decl_avail = []\r\n # points pendings because declared as second\r\n @pending_points = 0\r\n @card_played_req = false\r\n end", "def set_mode(mode)\n\t\tbegin\n\t\t\t@mode = [mode.type, mode.width, mode.height, mode.mines]\n\t\trescue NoMethodError\n\t\t\t@mode = mode\n\t\tend\n\t\t@scores[@game_name] = {} if @scores[@game_name].nil?\n\t\t@scores[@game_name][@mode] = [] if @scores[@game_name][mode].nil?\n\tend", "def initialize(player1, player2)\n @player1 = player1\n @player2 = player2\n @p1_score = 0\n @p2_score = 0\n end", "def initialize\n @mode = game_set_mode\n @turn_obj = Turn.new\n @solution_obj = Solution.new\n @human_solution_obj = HumanSolution.new\n @computer_solve_obj = ComputerSolver.new\n end", "def hscore_params\n params.require(:hscore).permit(:game, :score)\n end", "def initialize_score\n\n self.score = 3\n\n end", "def initialize\n\t\t@scores = {\n\t\t\ttime: nil,\n\t\t\tpoints: 0,\n\t\t\tkills: 0\n\t\t}\n\t\t@start_time = nil\n\t\t@font = RESOURCES[:fonts][:score]\n\t\t@text_padding = SETTINGS.score :text_padding\n\t\t@colors = SETTINGS.score :colors\n\t\t@z_indexes = SETTINGS.score :z_indexes\n\t\t@background_size = SETTINGS.score :background_size\n\tend", "def high_score_params\n params.require(:high_score).permit(:game, :score)\n end", "def initialize_score(player)\n\n player.score = 3\n\nend", "def highscore_params\n params.require(:highscore).permit(:name, :score, :quote_attr, :quote_id, :opponent_name, :victory, :challenger, :challengee)\n end", "def score_hand\n\n end", "def new\n @score = Score.new\n end", "def initialize hp, *params\n super params\n @hp = hp.abs\n @hp = @hp > MAX_HITPOINT ? MAX_HITPOINT : @hp \n end" ]
[ "0.6501723", "0.6165515", "0.61601603", "0.61308026", "0.61065686", "0.6096823", "0.608935", "0.60407454", "0.601565", "0.59946513", "0.5993365", "0.59889495", "0.59747374", "0.5966681", "0.5957694", "0.58965176", "0.5872978", "0.58109224", "0.57563645", "0.57481015", "0.5740986", "0.5711391", "0.57053626", "0.56616414", "0.56494164", "0.560301", "0.56014895", "0.5595158", "0.55939364", "0.5589143" ]
0.78483534
0
+api_key+:: your skycore api key (string) +shortcode+:: shortcode you want to send from (string or number) +debug+:: print debug logs to stdout (bool, default is false)
def initialize(api_key, shortcode, debug=false) @api_key = api_key @shortcode = shortcode @debug = debug end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def return_shortcode(shortcode)\n if request.accept?('application/json') || request.accept?('application/vnd.api+json')\n response.headers['Content-Type'] = 'application/vnd.api+json'\n JSONAPI::Serializer.serialize(shortcode).to_json\n else\n shortcode.name + ' (' + shortcode.destination + ') '\n end\n end", "def create_dedicatedshortcode_viewshortcode(shortcode)\r\n # Prepare query url.\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/dedicatedshortcode/viewshortcode.json'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # Prepare form parameters.\r\n _parameters = {\r\n 'Shortcode' => shortcode\r\n }\r\n _parameters = APIHelper.form_encode_parameters(_parameters)\r\n\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n parameters: _parameters\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n\r\n # Return appropriate response type.\r\n _context.response.raw_body\r\n end", "def create_shortcode_viewshortcode(shortcode)\r\n # Prepare query url.\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/shortcode/viewshortcode.json'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # Prepare form parameters.\r\n _parameters = {\r\n 'Shortcode' => shortcode\r\n }\r\n _parameters = APIHelper.form_encode_parameters(_parameters)\r\n\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n parameters: _parameters\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n\r\n # Return appropriate response type.\r\n _context.response.raw_body\r\n end", "def debug!\n @client.debug_dev = STDOUT\n end", "def print_debug(s)\n config = BeEF::Core::Configuration.instance\n if config.get('beef.debug') || BeEF::Core::Console::CommandLine.parse[:verbose]\n puts Time.now.localtime.strftime(\"[%k:%M:%S]\")+'[>]'.yellow+' '+s.to_s\n end\nend", "def debug(s)\n\t#puts \"DEBUG: #{s}\"\nend", "def create_dedicatedshortcode_updateshortcode(options = {})\r\n # Prepare query url.\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/dedicatedshortcode/updateshortcode.json'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # Prepare form parameters.\r\n _parameters = {\r\n 'Shortcode' => options['shortcode'],\r\n 'FriendlyName' => options['friendly_name'],\r\n 'CallbackMethod' => options['callback_method'],\r\n 'CallbackUrl' => options['callback_url'],\r\n 'FallbackMethod' => options['fallback_method'],\r\n 'FallbackUrl' => options['fallback_url']\r\n }\r\n _parameters = APIHelper.form_encode_parameters(_parameters)\r\n\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n parameters: _parameters\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n\r\n # Return appropriate response type.\r\n _context.response.raw_body\r\n end", "def debug(stuff)\n puts \"DEBUG: #{stuff}\"\nend", "def debug(*text)\n if configuration.debug\n channel.write(\"command\" => \"debug\", \"text\" => text.join, \"on\" => on)\n end\n end", "def short_url\n return \"#{CrateAPI::Base::SHORT_URL}\" % [\"#{@short_code}\"]\n end", "def debug_on(debug=true)\n ap \"Debugging is ON\"\n @debug = debug\n end", "def debug!(value = true)\n if options.key?(:trace) && options[:trace] != false\n Vedeu.log(\"Configuration::API debug: true\")\n\n options[:debug] = true\n\n else\n Vedeu.log(\"Configuration::API debug: #{value}\")\n\n options[:debug] = value\n\n end\n end", "def debug(message)\n Hiera.debug(\"[cloudformation_backend]: #{message}\")\n end", "def echo(value)\n puts \"#{ApiSettings::API_ECHO_PREFIX}#{value.to_s}#{ApiSettings::API_CMD_SUFFIX}\"\nend", "def debug(msg)\n #puts msg\n end", "def debug(message)\n puts message if debug?\n end", "def generate_url\n api_key = WavecellOtpAndSms.configuration.api_key\n sub_account = WavecellOtpAndSms.configuration.sub_account\n puts `curl -X POST https://api.wavecell.com/sms/v1/#{sub_account}/single -H \"Authorization: Bearer #{api_key}\" -H \"Content-Type: application/json\" -d $'{ \"source\": \"#{source}\", \"destination\": \"+63#{destination}\", \"text\": \"#{text}\", \"encoding\": \"#{encoding}\" }'`\n end", "def debug string\n puts string if $DEBUG\nend", "def debug(info)\n puts(info) if @debug\n end", "def debug\n\t\t\texec_parsed_action('debug', [], false)\n\t\tend", "def dprint(str)\n if ANSIBLE_DEBUG\n print str\n end\nend", "def shodan_test\n\n if API_SHODAN.empty?\n puts \"[+] Set your api key ! \\n get a free on at [ https://www.shodan.io/ ]\"\n end\n\n client = Shodanz.client.new(key: @api)\n url_api_shodan = \"https://api.shodan.io/api-info?key=#{@api}\"\n\n ## verify shodancreds\n uri = URI.parse(url_api_shodan)\n response = Net::HTTP.get_response(uri)\n if response.code != \"200\"\n puts \"[+] Something is wrong with your api key shodan \\n\".red\n puts \"[-] Error api key => #{response.code}\".red\n end\n end", "def debug_print(returnedData, debug=\"false\")\n if debug == \"true\" then\n puts \"\\r\\n[DEBUG]\\r\\n\"\n pp(returnedData) \n end\nend", "def api_key; @opts[:api_key]; end", "def debug(msg)\n $tftplog.debug('tftp+') { msg }\nend", "def debug(message)\n warn \"==== VLO DEBUG: \" + message if ENV[\"VLO_DEBUG\"] == 'true'\nend", "def admin_debug m, num\n return m.reply \"\u00030,1Debugging mode must be enabled.\" unless Constants.const['bot']['debug'].to_i == 1\n return m.reply \"\u00030,1You must be a channel op to use this command.\" unless m.channel.opped? m.user\n channel = escape m.channel.to_s\n debug_start channel, num #debug\n end", "def debug_log( arg )\r\n print('DEBUG: ')\r\n puts (arg)\r\nend", "def debug(message) ; @log.debug(message) ; end", "def send_key(code)\n ping player_url+\"/application/sendKey?code=#{CGI::escape(code.to_s)}&#{plex_token}\"\n end" ]
[ "0.6124084", "0.5868977", "0.57447684", "0.57390755", "0.5711361", "0.5703179", "0.56831974", "0.56508917", "0.557465", "0.5522519", "0.54976374", "0.54963815", "0.5449971", "0.5401922", "0.5394662", "0.5352558", "0.53431267", "0.5341074", "0.5309259", "0.5282919", "0.5260981", "0.52374935", "0.5220346", "0.5193529", "0.51864135", "0.51859665", "0.518054", "0.516335", "0.5159562", "0.51363075" ]
0.71520764
0
send saved MMS on Skycore servers, send it later +to+:: Phone number with leading +1 (String) +mms_id+:: MMS ID (string), can be grabbed from +save_mms+(...)['MMSID'] +fallback_text+:: SMS fallback text content (will be sent if no MMS is available). Required even if provided in +save_mms+ (only skycore knows why) +options+:: Hash of nonrequired options +options[operator_id]+:: Provide operator id (Number) +options[subject]+:: Override saved subject (String) +options[content]+:: Override saved content (String)
def send_saved_mms(to, mms_id, fallback_text, options={}) operator_id = options[:operator_id] subject = options[:subject] content = options[:content] do_request builder.build_send_saved_mms(@shortcode, to, mms_id, fallback_text, operator_id, subject, content) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_send_saved_mms(from, to, mms_id, fallbacksmstext, operator_id, subject=nil, content=nil)\n x = Builder::XmlMarkup.new\n x.instruct!\n x.REQUEST {\n x.ACTION \"sendSavedMMS\"\n x.API_KEY @api_key\n x.MMSID mms_id\n x.TO to\n x.FALLBACKSMSTEXT fallbacksmstext\n x.OPERATORID(operator_id) if operator_id\n x.FROM from\n x.CUSTOMSUBJECT(subject) if subject\n if content\n x.CUSTOMTEXT {\n x.VALUE content\n x.SLIDE 1\n }\n end\n }\n end", "def send_sms(sms, options={})\n send_to_phone(sms.phone_number, sms.actual_message, options)\n end", "def send(txt, to, options = {})\n options.default = nil\n api_request(\"sendSms.php\", {\n txt: txt,\n to: to,\n idGroup: options[:idGroup],\n source: options[:source],\n flash: options[:flash],\n dateTimeSend: options[:dateTimeSend],\n onlydelivery: options[:onlydelivery],\n use_alfasource: options[:use_alfasource],\n discountID: options[:discountID],\n channel: options[:channel]\n })\n end", "def send_sms number, message, opts={}\r\n wait =!(opts[:nowait] || false)\r\n encode = opts[:encode] || :ascii\r\n sender = opts[:sender] || false\r\n datetime = opts[:date] || false\r\n\r\n case encode\r\n when :binary || :base64\r\n encode = 'B'\r\n when :unicode\r\n encode = 'U'\r\n else # :ascii\r\n encode = ''\r\n end\r\n\r\n if sender\r\n sender = \"#{sender} \"\r\n custom = 'F'\r\n else\r\n custom = ''\r\n end\r\n\r\n if datetime\r\n datetime = \"#{datetime} \"\r\n date = 'D'\r\n else\r\n date = ''\r\n end\r\n\r\n cmd_raw \"#{date}#{custom}#{encode}SUBMIT\", \"#{datetime}#{sender}#{number} #{message}\"\r\n\r\n if wait\r\n wait_for last_label\r\n return false if @response_cmd.eql? 'NOOK'\r\n return \"#{@response_args[0]}.#{@response_args[1]}\".to_f\r\n end\r\n end", "def build_save_mms(subject, text, fallback_text, attachments)\n api_key = @api_key\n\n x = Builder::XmlMarkup.new\n x.instruct!\n x.REQUEST {\n x.ACTION \"saveMMS\"\n x.API_KEY api_key\n x.NAME \"tatango_test\"\n x.FALLBACKSMSTEXT fallback_text\n x.SUBJECT subject if subject\n x.SLIDE {\n x.TEXT text\n attachments.each do |attachment|\n x.tag!(attachment[:type]) do\n x.URL attachment[:url]\n end\n end\n }\n }\n end", "def deliver_message(options)\n self.sms_service_provider||= default_service_provider\n\n # set the actual message if it differs; not a before_save to reduce the\n # overhead of checking for all commits\n self.actual_message = substituted_draft_message\n\n result = (self.sms_service_provider).send_sms(self)\n self.unique_id = result[:unique_id] if result.is_a?(Hash)\n \n result\n end", "def send_twilio_mms\n # Get your Account Sid and Auth Token from twilio.com/user/account\n\n account_sid = 'add your account sid'\n auth_token = 'add your auth token'\n\n # set up a client to talk to the Twilio REST API\n client = Twilio::REST::Client.new account_sid, auth_token\n\n\n mms_message_body = \"name:#{self.contact.name}\"\n mms_message_body += \"\" #quick way to create spacing inbetween txt lines\n mms_message_body += \"phone: #{self.contact.phone_number}\"\n mms_message_body += \"\" #quick way to create spacing inbetween txt lines\n mms_message_body += \"#{self.message}\"\n end", "def send_sms(sms_vo, opts = {})\n data, _status_code, _headers = send_sms_with_http_info(sms_vo, opts)\n data\n end", "def sms\n @response, @documents = get_solr_response_for_field_values(SolrDocument.unique_key,params[:id])\n if request.post?\n url_gen_params = {:host => request.host_with_port, :protocol => request.protocol}\n tinyPass = request.protocol + request.host_with_port + catalog_path(params['id'])\n tiny = tiny_url(tinyPass)\n if params[:to]\n phone_num = params[:to].gsub(/[^\\d]/, '')\n unless params[:carrier].blank?\n if phone_num.length != 10\n flash[:error] = I18n.t('blacklight.sms.errors.to.invalid', :to => params[:to])\n else\n email = RecordMailer.sms_record(@documents, {:to => phone_num, :carrier => params[:carrier], :callnumber => params[:callnumber], :location => params[:location], :tiny => tiny}, url_gen_params)\n end\n\n else\n flash[:error] = I18n.t('blacklight.sms.errors.carrier.blank')\n end\n else\n flash[:error] = I18n.t('blacklight.sms.errors.to.blank')\n end\n\n unless flash[:error]\n email.deliver\n flash[:success] = \"Text sent\"\n redirect_to catalog_path(params['id']) unless request.xhr?\n end\n end\n unless !request.xhr? && flash[:success]\n respond_to do |format|\n format.js { render :layout => false }\n format.html\n end\n end\n end", "def text(options, params, object_name, format=\"\")\n body = \"\"\n if format.empty?\n outgoing_text_option = @account.outgoing_text_options.where(:name => object_name).first\n # Find the format string from fields that were passed.\n body = outgoing_text_option.build_text(object_name, params)\n else\n body = format\n end\n\n from_phone_number = options[:from_phone_number]\n phone_number = options[:phone_number]\n\n begin\n twilio_account.sms.messages.create(:from => from_phone_number, :to => phone_number, :body => body)\n rescue\n Rails.logger.error \"Unable to send SMS...: #{$!.message}\"\n Rails.logger.error $!.backtrace.join(\"\\n\")\n raise\n end\n ::SmsExtension::Message.create(:from => from_phone_number, :to => phone_number, :body => body)\n end", "def send_sms(message)\n api_response = \"\"\n if !self.mobile.blank?\n txtlocal = Txtlocal.find_by_sms_type(Txtlocal::GROUP_CHAT)\n if !txtlocal.nil?\n txtlocal.message_contents = message\n api_response = txtlocal.send_sms(self.mobile)\n end\n else\n api_response = \"You have not provided any mobile number. Please go to your 'Account' to set up a mobile number\"\n end\n return api_response\n end", "def send_sms(params)\n self.current_params = params\n response = send_request(params)\n smart_response(response.parsed_response)\n end", "def sms(number, message, sec=SMS_SEND_TIMEOUT)\n @logger.log(\"Sending message.\")\n\n msg = ATPhone::SMS::Message.new(message, number)\n \n # Turn on text mode\n send(\"AT+CMGF=1\")\n # Specify number\n raw_send(\"AT+CMGS=\\\"#{msg.number}\\\"\\r\")\n # send message\n raw_send(msg.text + EOM, sec)\n end", "def sms(options = {})\r\n return @_message if @_sms_was_called && options.blank?\r\n\r\n m = @_message\r\n\r\n # Call all the procs (if any)\r\n default_values = {}\r\n self.class.default.each do |k,v|\r\n default_values[k] = v.is_a?(Proc) ? instance_eval(&v) : v\r\n end\r\n\r\n # Handle defaults\r\n options = options.reverse_merge(default_values)\r\n\r\n # Set configure delivery behavior\r\n wrap_delivery_behavior!(options.delete(:delivery_method), options.delete(:delivery_method_options))\r\n\r\n # Assign all options except body, template_name, and template_path\r\n assignable = options.except(:body, :template_name, :template_path)\r\n assignable.each { |k, v| m[k] = v }\r\n\r\n # Render the templates and blocks\r\n m.body = response(options)\r\n @_sms_was_called = true\r\n\r\n m\r\n end", "def send_sms(cmatch, tstamp, number, expiration)\n\n # Primary provider\n #\n nexmo_reponse = begin\n nexmo = Nexmo::Client.new('371f3e5d', 'e3218b70')\n token_url = create_token_url(cmatch, tstamp)\n record_token(cmatch, tstamp, expiration)\n sms_primary_response = nexmo.send_message({\n from: '13059298586',\n to: number,\n text: cmatch\n })\n json :sms_status => \"sent\",\n :token => cmatch,\n :token_url => token_url,\n :phone_number => number,\n :token_generated => tstamp,\n :token_expires => tstamp + expiration\n rescue\n send_sms_twilio(cmatch, tstamp, number, expiration)\n end\nend", "def send_sms_with_http_info(sms_vo, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SMSApi.send_sms ...'\n end\n # verify the required parameter 'sms_vo' is set\n if @api_client.config.client_side_validation && sms_vo.nil?\n fail ArgumentError, \"Missing the required parameter 'sms_vo' when calling SMSApi.send_sms\"\n end\n # resource path\n local_var_path = '/sms'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(sms_vo)\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'SMSResponseVO')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SMSApi#send_sms\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def send_sms(to_phone_number, message)\n # message = {to:, from:, body: \"Hello\\n\\nWorld\"}\n # binding.pry\n @@client.messages.create(\n from: @@from,\n to: to_phone_number,\n body: message\n )\n end", "def send_sms(*args)\n\t\tbegin\n\t\t\tsend_sms!(*args)\n\t\t\treturn true\n\t\t\n\t\t# something went wrong\n\t\trescue Gsm::Error\n\t\t\treturn false\n\t\tend\n\tend", "def send(p)\n options = {} \n\n p.each do |k,v|\n\n case k\n when :reply_path\n # Automatically request delivery receipt if reply path is set\n options[sym_to_param(:confirm_delivery)] = 'on'\n options[sym_to_param(k)] = v\n when :scheduled_for\n # Set timestamp correctly for :scheduled_for\n options[sym_to_param(k)] = v.strftime('%Y%m%d%H%M%S')\n else\n options[sym_to_param(k)] = v\n end\n\n end\n\n res = self.class.post('/submit_sm', :basic_auth => @auth, :body => JSON.dump(options))\n\n responses = []\n res['sms'].each do |r|\n responses << Dialogue::Toolkit::Sms::Response.new(r)\n end\n\n responses\n end", "def sendSMS(to, body = \"No body was send for this message.\", media = nil)\n\naccount_sid = $accountsid\nauth_token = $authtoken\n@client = Twilio::REST::Client.new(account_sid, auth_token)\n\nif media\n message = @client.messages.create(\n body: body,\n from: $phone,\n media_url: [media],\n to: to\n)\nelse\n message = @client.messages.create(\n body: body,\n from: $phone,\n to: to\n)\nend\nreturn message.sid\nend", "def sms_perform(object_instance, options={})\n account = ::SmsExtension::Account.first\n consumer = AP::SmsExtension::Sms::Consumer.new(account)\n options = HashWithIndifferentAccess.new(options)\n options[:phone_number] ||= account.phone_number\n options[:outgoing_message_format] ||= account.outgoing_message_format\n options[:from_phone_number] ||= (!account.from_phone_number.blank? ? account.from_phone_number : ENV['SMS_EXTENSION_TWILIO_FROM_SMS_NUMBER'])\n\n consumer.text(options, object_instance.attributes, object_instance.class.name, options[:outgoing_message_format])\n end", "def perform (msg, to_phone, from_phone=ENV['ST_MAIN_NO'], type=SMS, next_sequence={})\n if type == MMS\n # send MMS to user\n begin\n mms(msg, to_phone, from_phone, next_sequence)\n\n rescue Twilio::REST::RequestError => e\n puts \"we've encountered a Twilio error.\"\n # TODO: describe the ramifications\n email_admins(\"Twilio Error\", \"Status: #{Time.now.to_s}\\nFailed MMS send, #{e.inspect}, \\nphone_number: #{to_phone}.\")\n Sidekiq.logger.warn e\n end\n else # SMS\n begin\n sms(msg, to_phone, from_phone, next_sequence)\n\n rescue Twilio::REST::RequestError => e\n puts \"we've encountered a Twilio error.\"\n # TODO: describe the ramifications\n email_admins(\"Twilio Error\", \"Status: #{Time.now.to_s}\\nFailed SMS send, #{e.inspect}, \\nphone_number: #{to_phone}.\")\n Sidekiq.logger.warn e\n end\n end\n end", "def deliver_sms(params)\n#puts \"**** Message#deliver_sms; params=#{params}\"\n sms_gateway = params[:sms_gateway]\n phone_number_array = @contact_info.map {|c| c[:phone]}.compact.uniq\n phone_numbers = phone_number_array.join(',')\n assemble_sms()\n#puts \"**** sms_gateway.deliver #{sms_gateway} w #{phone_numbers}: #{sms_only}\"\n #******* CONNECT TO GATEWAY AND DELIVER MESSAGES \n gateway_reply = \n sms_gateway.deliver(phone_numbers, sms_only)\n#puts \"**** gateway_reply=#{gateway_reply}\"\n #******* PROCESS GATEWAY REPLY (INITIAL STATUSES OF SENT MESSAGES) \n gtw_msg_id = nil\n if phone_number_array.size == 1\n # SINGLE PHONE NUMBER \n if gateway_reply =~ /ID: (\\w+)/\n gtw_msg_id = $1\n gtw_msg_id = gateway_reply[4..99] # Temporary workaround as $1 doesn't work on Heroku\n msg_status = MessagesHelper::MsgSentToGateway\n else\n gtw_msg_id = gateway_reply # Will include error message\n msg_status = MessagesHelper::MsgError\n end\n # Mark the message to this member as being sent\n self.sent_messages[0].update_attributes(:gateway_message_id => gtw_msg_id, \n :msg_status => msg_status)\n else\n # MULTIPLE PHONE NUMBERS\n # Get the Clickatell reply and parse into array of hash like {:id=>'asebi9xxke...', :phone => '2345552228372'}\n#puts \"**** gateway_reply=#{gateway_reply}\"\n msg_statuses = gateway_reply.split(\"\\n\").map do |s|\n if s =~ /ID:\\s+(\\w+)\\s+To:\\s+([0-9]+)/\n {:id => $1, :phone => $2} \n else\n {:id => nil, :phone => nil, :error => s}\n end\n end\n # Make array to associate members with their numbers\n @member_phones = self.members.map {|m| {:phone => m.primary_phone, :member => m} }\n # Update the sent_message records to indicate which have been accepted at Gateway \n msg_statuses.each do |s|\n#puts \"**** s[:id]=#{s[:id]}, s[:phone]=#{s[:phone]}\"\n if s[:id] && s[:phone]\n # Find the right member by matching phone numbers\n member = @member_phones.find{|m| m[:phone]==s[:phone]}[:member]\n # Find the right sent_message by matching member & message\n sent_message = SentMessage.where(:member_id=>member.id, :message_id=>self.id).first\n # Update the sent_message\n sent_message.update_attributes(\n :gateway_message_id => s[:id], \n :msg_status=> MessagesHelper::MsgSentToGateway\n )\n end\n end\n # Any sent_messages not now marked with gateway_message_id and msg_status must have errors\n sent_messages.each do |m| \n m.update_attributes(:msg_status=> MessagesHelper::MsgError) if m.msg_status.nil?\n end\n end\n end", "def set_sms_send\n @sms_send = SmsSend.find(params[:id])\n end", "def set_sms_send\n @sms_send = SmsSend.find(params[:id])\n end", "def send_sms (text, receiver, logger) \r\n sms = Skuby::Gateway.send_sms text, receiver\r\n\r\n if sms.success? \r\n response = { status: sms.status, \r\n text: text, \r\n receiver: receiver, \r\n remaining_sms: sms.remaining_sms\r\n }\r\n response.merge! sms_id: sms.sms_id if sms.sms_id?\r\n\r\n logger.debug \"SMS SENT: #{response.to_s}\"\r\n\r\n else\r\n response = { status: sms.status, \r\n error_code: sms.error_code, \r\n error_message: sms.error_message, \r\n text: text, \r\n receiver: receiver\r\n }\r\n response.merge! sms_id: sms.sms_id if sms.sms_id?\r\n\r\n logger.error \"SMS SENT: #{response.to_s}\" \r\n end\r\n\r\n sms.success?\r\nend", "def send_sms(content, tonumber)\n tonumber = format(tonumber);\n \tbegin\n @client.messages.create({\n \t :from => @from_number,\n \t :to => tonumber,\n \t :body => content,\n })\n rescue Twilio::REST::RequestError => e\n message = I18n.t(\"errors.sms_not_sent\")\n rescue NoMethodError => e\n message = I18n.t(\"errors.sms_not_sent\")\n else\n message = I18n.t(\"notice.success\")\n end\n\n return message\n\n end", "def immnSendMMS(addresses, opts={})\n url = \"#{@fqdn}#{SERVICE_URL}\"\n\n addresses = CloudService.format_addresses(addresses)\n\n attachments = (opts[:attachments] || opts[:attachment])\n text = (opts[:text] || opts[:message])\n group = (opts[:group] || false)\n subject = opts[:subject]\n\n payload = { :addresses => addresses }\n payload[:text] = text unless text.to_s.empty?\n payload[:subject] = subject unless subject.to_s.empty?\n\n boundary = CloudService.generateBoundary\n\n if (group && addresses.count > 1)\n payload[:isGroup] = true \n else\n payload[:isGroup] = false\n end\n\n part_headers = {\n \"Content-Type\" => \"application/json; charset=UTF-8\",\n \"Content-Disposition\" => 'form-data; name=\"root-fields\"',\n \"Content-ID\" => \"<startpart>\"\n }\n\n json_payload = {\n :headers => part_headers,\n :data => { :messageRequest => payload }.to_json\n }\n\n parts = [json_payload]\n\n count = 0\n if attachments \n Array(attachments).each do |attach|\n if attach && !attach.empty? \n data = File.open(attach, 'rb') { |io| io.read }\n mime = CloudService.getMimeType(attach);\n filename = attach.split(\"/\")[-1]\n\n part_headers = {\n \"Content-Disposition\" => %(attachment; name=\"file#{count}\"; filename=\"#{filename}\"),\n \"Content-Type\" => %(#{mime}; charset=\"binary\"),\n \"Content-ID\" => \"#{count}\",\n \"Content-Transfer-Encoding\" => \"binary\",\n }\n\n file_payload = {\n :headers => part_headers,\n :data => data.to_s\n }\n\n count += 1\n parts << file_payload\n end\n end\n end\n\n multipart = CloudService.generateMultiPart(boundary, parts)\n\n content_type = %{multipart/related; type=\"application/json\"; start=\"<startpart>\"; boundary=\"#{boundary}\"}\n\n headers = {\n :Content_Type => content_type,\n :Accept => 'application/json',\n }\n\n begin\n response = self.post(url, multipart, headers)\n rescue RestClient::Exception => e\n raise(ServiceException, e.response || e.message, e.backtrace)\n end\n Model::IMMNResponse.createFromJson(response)\n end", "def sms number, message\n response = @connection.cmd \"String\" =>\"sms send #{number} #{message}\", \"Match\" => /OK|KO:(.*)/, \"Timeout\" => 5\n if response.chomp == \"OK\"\n true\n else\n raise response.chomp.sub \"KO:\",''\n end\n end", "def send_now(mnobj = nil, recipient_sms_numbers: nil, generated_text: nil, importance: nil, logger: nil)\n logger ||= Rails.logger\n\n importance ||= self.class.importance\n\n resp = []\n if recipient_sms_numbers\n logger.info 'Sending sms to a defined set of recipients'\n elsif mnobj\n logger.info \"Sending sms for #{mnobj.id}\"\n else\n raise FphsException, 'No message notification or recipient list set for SMS send'\n end\n\n recipient_sms_numbers ||= mnobj.recipient_sms_numbers\n generated_text ||= mnobj.generated_text\n\n raise FphsException, 'No recipients to SMS' unless recipient_sms_numbers&.present?\n\n recipient_sms_numbers.each do |sms_number|\n val = PhoneValidation.validate_sms_number_format sms_number, no_exception: true\n\n if val\n res = send_sms sms_number, generated_text, importance\n resp << { aws_sns_sms_message_id: res.message_id } if res\n else\n resp << { error: BadFormatMsg }\n end\n end\n\n resp.to_json\n end" ]
[ "0.7504088", "0.6535704", "0.65137106", "0.61389536", "0.607703", "0.6050291", "0.59626323", "0.5943984", "0.5939706", "0.5939093", "0.588992", "0.5882967", "0.5850821", "0.5822323", "0.5809111", "0.5742818", "0.5717446", "0.5698843", "0.5690335", "0.56792825", "0.5639355", "0.56377363", "0.56377316", "0.56233793", "0.56233793", "0.5615823", "0.55917364", "0.5584366", "0.5581444", "0.55658835" ]
0.8444671
0
This function extract the data from given url to csv file and returns true if success else if the url contains no more data it returns false
def extractDataFromURL(starturl, csv) #To set SSL certificate #system('set SSL_CERT_FILE=C:/RailsInstaller/cacert.pem') outputArr = Array.new begin file = open(starturl) doc = Nokogiri::HTML(file) do # handle doc page = Nokogiri::HTML(open(starturl)) dataString = page.css('p').inner_html.to_s begin # res = JSON.parse(string) data = JSON.parse(dataString) rescue JSON::ParserError => e # string was not valid puts "LEAVING AS ERROR IN PARSING" break end #grid_layout contains useful data as an Array total_items = data["totalCount"] dataArray = data["grid_layout"] if(dataArray.empty?) outputArr[0] = false outpurArr[1] = total_items return outputArr end dataArray.each do |currentitem| starttimestamp = Time.now #We extract the url of product page and find all data from that page producturl = currentitem["url"] #To set SSL certificate #system('set SSL_CERT_FILE=C:/RailsInstaller/cacert.pem') productpage = Nokogiri::HTML(open(producturl)) productString = productpage.css('p').inner_html.to_s begin productdata = JSON.parse(productString) rescue JSON::ParserError => e # string was not valid puts "LEAVING AS ERROR IN PARSING" break end remoteurl = productdata["shareurl"] titleofproduct = productdata["productName"] #for app take data from currentitem, for web take data from productdata #images = productdata["image_url"] images = currentitem["image_url"] strikeprice = productdata["actual_price"] lowestprice = productdata["offer_price"] currbrand = productdata["brand"] product_id = productdata["product_id"] productattributes = productdata["long_rich_desc"][0]["attributes"].to_a attributeslength = productattributes.size attributes = Array.new itr = 0 while itr<attributeslength attributes << "#{productattributes[itr][0]}:#{productattributes[itr][1]}" itr += 1 end endtimestamp = Time.now csv << [starttimestamp, remoteurl, titleofproduct, images, attributes, strikeprice, lowestprice , currbrand, "kurta", "paytm", product_id, endtimestamp] csv << [nil] puts "starttimestamp : #{starttimestamp}" puts "remoteurl : #{remoteurl}" puts "titleofproduct : #{titleofproduct}" puts "images : #{images}" puts "attributes : #{attributes}" puts "strikeprice : #{strikeprice}" puts "lowestprice : #{lowestprice}" puts "currbrand : #{currbrand}" puts "category : tshirt" puts "store : paytm" puts "product_id : #{product_id}" puts "endtimestamp : #{endtimestamp}" puts '-------------------------------------------------------' puts #sleep(rand(1..3)) end outputArr[0] = true outputArr[1] = total_items #sleep(50) return outputArr end rescue OpenURI::HTTPError => e if e.message == '404 Not Found' outputArr[0] = true outputArr[1] = total_items return outputArr # handle 404 error else raise e outputArr[0] = true outputArr[1] = total_items return outputArr end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def csv_from_url\n debug \"Get CSV from url: '#{@resource[:url]}'\"\n begin\n csv = Net::HTTP.get URI.parse @resource[:url]\n return unless csv\n return if csv.empty?\n csv\n rescue\n nil\n end\n end", "def get_metadata(csv_url, id)\n begin\n open(csv_url) do |u|\n csv_file_name = File.basename(csv_url)\n csv_file_path = \"#{@config.output_dir}/#{csv_file_name}\"\n unless File.exists?(csv_file_path)\n File.open(csv_file_path, 'wb') { |f| f.write(u.read) }\n end\n CSV.read(csv_file_path, 'r:bom|utf-8', headers: true).each do |row|\n if row.header?(\"Identifier\")\n if row.field(\"Identifier\") == id\n return row.field(\"Title\"), row.field(\"Description\")\n end\n else\n puts \"No Identifier header found\"\n return\n end\n end\n puts \"No matching Identifier found\"\n end\n rescue\n puts \"No CSV file found\"\n end\nend", "def csv_data\n case\n when google_key || url then Curl::Easy.perform(uri).body_str\n when file then File.open(uri).read\n end\n end", "def insert_record(csv, link_name, link_path, protocol, host_url)\n url = URI.parse(\"#{protocol}://#{host_url}#{link_path}\")\n response = open(url.to_s)\n result = [] << fetch_link_name(link_name) <<\n \"#{protocol}://#{host_url}#{link_path}\" <<\n check_status(response.status.first) << response.status.first\n csv << result\n end", "def go_through_all_the_lines(url)\n list = CSV.read(url)\nend", "def ok_to_extract?(remote_url)\n true\n end", "def process(url)\n p \"requesting...#{url}\"\n raw = Timeout.timeout(TIMEOUT) { Nokogiri::HTML(open(url)) }\n result = raw.xpath(\"//meta[@name='keywords']/@content\").first.value\n CSV.open('./data/townwork-result.csv', 'ab') { |csv| csv << [url, result] }\n end", "def getMinivanTestFile(url)\n\tarray_of_records = []\n\tinput_csv = open(url)\n\twhile !input_csv.eof?\n\t\tline = input_csv.readline.delete(\"\\n\")\n\t\tarray_of_records.push(line.split(',')[1..-1])\n\tend\n\treturn array_of_records\nend", "def download_data_file(url, directory, destination_filename)\n filepath = \"#{directory}/#{destination_filename}\"\n puts \">> Downloading #{filepath}...\"\n IO.copy_stream(open(url), filepath)\n\n Zip::File.open(filepath) do |zip_file|\n data_file = zip_file.glob('*.csv').first\n filepath = \"#{directory}/#{data_file.name}\"\n puts \">> Extracting #{filepath}...\"\n data_file.extract(filepath)\n end\nend", "def test_read_csv_file\n assert oldsize = Redirection.count\n Redirection.read_google_csv(File.open(@test_data_dir + \"google_not_found.csv\"))\n assert_equal 4, Redirection.count - oldsize\n assert Redirection.find_by_uri(\"/computing/cvinfo\")\n assert Redirection.find_by_uri(\"/computing/cvinfo.html\")\n assert_equal 1, Redirection.find_all_by_uri(\"/index\").size\n end", "def parse(url,result_file)\r\n html = Curl.get(url)\r\n doc = Nokogiri::HTML(html.body_str)\r\n #take img link\r\n img_link = \"\"\r\n doc.xpath('//*[@id = \"view_full_size\"]/img').each do |img_block|\r\n img_link = img_block.attribute('src').text\r\n end\r\n #take full name of product\r\n full = \"\"\r\n doc.xpath('//*[@class = \"breadcrumb\"]/*').each do |full_name|\r\n full = full_name.search('span.navigation_page').text\r\n end\r\n #Parse content of Petsonic in CSV\r\n CSV.open(result_file,\"a\", {:col_sep => \";\"}) do |wr|\r\n doc.xpath('//*[@class = \"attribute_radio_list\"]/*' ).each do |row|\r\n first_element = doc.at_xpath('//*[@class = \"product_main_name\"]/*').text + \" \" + full + \" - \" + row.search('span.radio_label').text.strip\r\n second_element = row.search('span.price_comb').text.strip\r\n wr << [first_element, second_element, img_link]\r\n end\r\n end #end of Parse to CSV\r\nend", "def fetch_from_url(url)\n codes = extract_codes(url)\n\n return false if codes.none?\n fetch_from_code(codes.last)\n end", "def parse_csv\n\t\tbegin\n\t\t\tif params[:shortened_url][:csv_file].present?\n\t\t\t\t@shortened_urls = []\n\t\t\t\tCSV.parse(params[:shortened_url][:csv_file].read, :headers => true).each do |row|\n\t\t\t\t\tresponse = ShortenedUrl.generate_short_url(row['URL'])\n\t\t\t\t\t@shortened_urls << {original_url: row['URL'], short_url: response[:short_url]}\n\t\t\t\tend\n\t\t\t\trespond_to do |format|\n\t\t\t\t\tformat.html {render 'csv_data.html.erb'}\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tredirect_to upload_csv_shorten_urls_path\n\t\t\tend\n\t\trescue\n\t\t\tredirect_to :back\n\t\tend\n\tend", "def valid_url?(url)\n resp = Curl.get url\n\n if resp.body_str.include? @invalid_text\n return false\n else\n return true\n end\nend", "def read_url(upload)\n url = upload.url\n matrix = []\n CSV.new(open(url)).each {|line| matrix.push(line)}\n # open(url).each {|line| matrix.push(line.split(',')}\n return matrix\n end", "def file_exists? url\n if url.match(/^http/)\n localfile = remote_url_to_local url\n else\n localfile = url\n end\n remotefile = local_to_remote localfile\n begin\n localfile_size = File.size localfile\n remotefile_size = ftp.size remotefile\n # puts \"#{localfile}: #{localfile_size}\"\n # puts \"#{remotefile}: #{remotefile_size}\"\n if remotefile_size == localfile_size\n url\n else\n nil\n end\n rescue Exception=>ex\n # puts ex.message\n nil\n end\n end", "def check_for_url(url)\n array = read_articles\n\n if array.any? {|article| article[\"url\"] == url}\n false\n else\n true\n end\nend", "def download(url, filename, outputFolder)\r\n loadStatus = true\r\n begin\r\n Net::HTTP.start(url) { |http|\r\n t= Time.now\r\n filedate = t.strftime(\"%m%d%Y\")\r\n\t\tif url == \"downloads.cms.gov\"\r\n\t\t\tresp = http.get(\"/medicare/#{filename}\")\r\n\t\telse\r\n\t\t\tresp = http.get(\"/download/#{filename}\")\r\n\t\tend\r\n\r\n open(\"#{outputFolder}#{filedate}#{filename}\", \"wb\") { |file|\r\n file.write(resp.body)\r\n }\r\n }\r\n\r\n puts \"download of #{filename} complete\"\r\n rescue Exception=>e\r\n loadStatus = false\r\n end\r\n return loadStatus\r\nend", "def scraped?\n !url.blank?\n end", "def csv(section = 'main', q='google',date='ytd',geo='')\n trend_params = {\"graph\"=>\"all_csv\", \"sa\" => \"N\"}\n trend_params[\"q\"] = q\n trend_params[\"date\"] = date\n if !geo || geo != ''\n trend_params[\"geo\"] = geo\n end\n\n data = @client.get_content(URI.parse(@url_Export), trend_params)\n # empty to return all data\n if section == ''\n return CSV.parse(data)\n end\n # split data into sections\n segments = data.split(\"\\n\\n\\n\")\n if section == 'main'\n section = ['Week', 'Year', 'Day','Month']\n else\n section = [section]\n end\n\n for x in segments do\n if section.include? x.split(',')[0].strip\n maindata = CSV.parse(x)\n return maindata\n end\n end\n end", "def get_da_urls (doc,comment_url)\n doc.search('table tbody tr').each do |tr|\n # Columns in table\n # Show Number Submitted Details\n tds = tr.search('td')\n\n break if tds[0].inner_text =~ /no records/\n\n h = tds.map{|td| td.inner_html}\n\n puts h\n info_url = 'https://pdonline.toowoombarc.qld.gov.au/Masterview/Modules/ApplicationMaster/' + tds[0].at('a')['href'].strip\n puts info_url\n descParts = h[3].split('<br>')\n record = {\n 'info_url' => info_url,\n 'comment_url' => comment_url,\n 'council_reference' => clean_whitespace(h[1]),\n 'date_received' => Date.strptime(clean_whitespace(h[2]), '%d/%m/%Y').to_s,\n # TODO: Some DAs have multiple addresses, we're just getting the first :(\n 'address' => clean_whitespace(descParts[0]),\n 'description' => clean_whitespace(descParts[1]),\n 'date_scraped' => Date.today.to_s\n }\n\n if (ScraperWiki.select(\"* from data where `council_reference`='#{record['council_reference']}'\").empty? rescue true)\n ScraperWiki.save_sqlite(['council_reference'], record)\n else\n puts \"Skipping already saved record \" + record['council_reference']\n end\n end\nend", "def extract_table_from_results_csv(csv_path)\n # ensure the expected result csv file exists\n raise \"File not found: #{csv_path}\" unless File.file?(csv_path)\n\n # create a csv file with the headings and last 2 rows\n output_path = csv_path.gsub(\".csv\", \".scale_extract.csv\")\n csv_name = File.basename(csv_path)\n result_name = csv_name.gsub(\".csv\", \"\")\n puts \"processing csv: #{csv_name}\"\n\n # TODO: extract into a separate method?\n contents = File.readlines(csv_path)\n\n # only include runs that didn't fail on the first iteration\n if contents.length > 2\n File.open(output_path, \"w\") do |f|\n f << contents[0]\n f << contents[-2]\n f << contents[-1]\n end\n\n # add the 2nd to last line to the success summary\n update_summary_csv(@summary_csv_path_success, \"#{result_name},#{contents[-2]}\")\n\n # add the last line to the fail summary\n update_summary_csv(@summary_csv_path_fail, \"#{result_name},#{contents[-1]}\")\n\n # csv2html\n csv2html(output_path)\n\n # table\n table = extract_table_from_csv2html_output(\"#{output_path}.html\")\n\n else\n puts \"This run failed on the first iteration; ignoring...\"\n puts\n table = nil\n end\n\n table\nend", "def retrieve_url(url)\n uri = URI::parse(url)\n http = Net::HTTP.new(uri.host, uri.port).start\n res = http.get(url,HEADERS)\n http.finish\n return res\n rescue Timeout::Error\n return false\n end", "def csv\n @resource[:count].times do |retry_number|\n csv = get_csv\n return csv if csv\n debug \"Could not get CSV. Retry: '#{retry_number}'\"\n sleep @resource[:step]\n end\n fail \"Could not get CSV after #{@resource[:count] * @resource[:step]} seconds!\"\n end", "def getlist(url)\n @url = url\n doc = Nokogiri::HTML(open(@url))\n # @fileset = doc.css(\"td a\")[1..-1]\n @fileset = doc.css(\"td a\")[1,1] #revert to above after testing\n @fileset.each do |item|\n @docname = item.text\n puts \"Downloading #{@docname}\"\n # download the zip files\n download(@url, @docname, \"/vagrant/src/ruby/JobSearch/nuvi/download/\")\n # unzip(@docname, @downloadpath)\n @zipcount += 1\n end\n @zipcount == @fileset.length ? (puts \"Retrieved #{@zipcount} zip files.\") : (puts \"missed a few\")\nend", "def fetch_csv_from_ftp(type='*')\n puts 'Connecting to FTP...'\n local_files = [] #Successfully downloaded files\n ftp = Net::FTP.open(FTP_HOST, FTP_USR, FTP_PASS)\n begin\n puts 'Connected'\n ftp.chdir(INCOMING_PATH)\n #We only fetch files with suffix that match today\n puts 'Checking for update...'\n filenames = ftp.nlst(\"#{FILE_PREFIX}_#{type}_#{Time.now.strftime(\"%d%m%Y\")}*\")\n\n unless filenames.count.zero?\n filenames.each{ |filename| \n puts \"Fetching #{filename} ...\"\n ftp.getbinaryfile(filename,\"#{RAILS_ROOT}/tmp/#{filename}\")\n local_files += [\"#{RAILS_ROOT}/tmp/#{filename}\"]\n }\n else\n puts 'Sorry, there is no new updates'\n end\n ensure\n ftp.close unless ftp.nil?\n puts 'Disconnected'\n end\n local_files\nend", "def fetch_url_data(url)\n open(url).read\n end", "def fetch_url_data(url)\n open(url).read\n end", "def valid_data?\n not_blank = (params[:upload_file] != \"\")\n is_csv = (params[:upload_file].content_type == \"text/csv\")\n\n not_blank && is_csv\n end", "def download_files(url, path)\n client = RightSupport::Net::HTTPClient.new\n response = client.get(url, :timeout => 10)\n File.open(path, \"wb\") { |file| file.write(response) } unless response.empty?\n File.exists?(path)\n rescue Exception => e\n Log.error(\"#{e.class.name}: #{e.message} - #{e.backtrace.first}\")\n false\n end" ]
[ "0.68930197", "0.6159754", "0.61181456", "0.6089054", "0.60357493", "0.5955257", "0.5869278", "0.5851416", "0.580596", "0.5693323", "0.5652554", "0.5629089", "0.5591768", "0.5553653", "0.5551898", "0.5501297", "0.54916185", "0.5451879", "0.5447685", "0.53867745", "0.5384309", "0.53744173", "0.5367142", "0.53418005", "0.53387", "0.5321563", "0.53198624", "0.53198624", "0.53136706", "0.53123236" ]
0.65732294
1
find sum of squares of array of numbers
def sum_of_squares inject(0) do |sum, elem| sum + (elem ** 2) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_of_squares(array)\n array.each.map{|num total += num*num}.reduce(:+) #is like fold_left. reduce works on array or collection of enumerables\nend", "def sum_square_array(arr)\n arr.reduce(:+) ** 2\nend", "def sum_of_squares(numbers)\n numbers.map { |x| x * x }.reduce(0) { |acc, x| acc + x }\nend", "def sum_of_squares values\n values.collect { |v| v**2 }.reduce(:+)\nend", "def squareSum(numbers)\n numbers.map { |n| n*n}.reduce(:+)\nend", "def squareSum(numbers)\n numbers.map { |i| i ** 2 }.reduce(:+)\nend", "def sum_of_the_squares\n sum = 0\n (1..self).each do |n|\n sum += n**2\n end\n sum\n end", "def sum_of_squares\n self.inject(0) { |sos, n| sos + n**2 }\n end", "def sum_of_squares\n sum(square(sequence))\n end", "def squareSum(numbers)\n numbers.map { |n| n*n }.reduce(:+)\nend", "def sum_of_squares\n range.reduce { |a, e| a + e**2 }\n end", "def sum_squares(n)\nsums = [] \n for i in (1..n)\n i_squared = i**2\n sums.push i_squared \n end\n p sums.reduce(:+)\nend", "def square_sum(numbers)\n squares = numbers.map{|number| number * number}\n squares.reduce(0){|num, sum| num + sum}\nend", "def square_of_sums\n square(sum(sequence))\n end", "def squareSum(numbers) \r\n numbers.map{|num| num ** 2}.sum \r\n \r\nend", "def square_of_sum(array, proc_square, proc_sum)\n\tproc_square.call(proc_sum.call(array))\nend", "def sum_of_squares\n @range.sum { |n| n**2 }\n end", "def squareSum(numbers)\n numbers.reduce(0){|sum, x| sum + (x ** 2)}\nend", "def sum_of_squares\n @number_range.sum {|n| n**2}\n end", "def square_of_sum (my_array, proc_square, proc_sum)\n sum = proc_sum.call(my_array)\n proc_square.call(sum)\n end", "def square_sum\n self.inject(0.0){|accum, i| accum +i**2 }\n end", "def squareSum(numbers)\n\n # Create an empty array to store our sum in\n sum = []\n # Assign our total variable to 0 so we can return this at the end with the\n # sum total\n total = 0\n\n # Iterate through the array given in the argument, squaring each number passed\n # in, and then appending that to our new array sum\n numbers.each do |n|\n sum << (n * n)\n end\n\n # Now that we have our new array with the squared digits, we can iterate through\n # and add each elemtn together to our new variable total.\n sum.each do |el|\n total += el\n end\n\n # Return the total of each squared number from the original array\n total\nend", "def sum_of_squares(numbers)\n result = []\n sum = []\n numbers.map do |number|\n result = number*number\n sum.push result\nend\nsum.sum\nend", "def compute_squares(array)\n arrayFinal = []\n array.each do |element|\n arrayFinal << element * element\n end\n return arrayFinal\nend", "def sum_of_squares n\n (n**3)/3 + (n**2)/2 + n/6 \nend", "def square_of_sums\n return (@n * (@n + 1) / 2)**2\n end", "def square_of_sum(vals)\n vals.reduce(:+) ** 2\nend", "def sum_of_squares\n return @n * (@n + 1) * (2 * @n + 1) / 6\n end", "def sum_of_squares\n end", "def sum_of_squares(n)\n sum = 0\n (1..n).each {|i| sum = sum + (i*i)}\n sum\n end" ]
[ "0.8258856", "0.8082352", "0.79921716", "0.7902999", "0.78904045", "0.78805125", "0.787128", "0.78691", "0.7857537", "0.7838961", "0.7793936", "0.7753166", "0.77516305", "0.7738297", "0.77158284", "0.7705763", "0.76667553", "0.7646278", "0.7622576", "0.7600961", "0.75935155", "0.75896686", "0.75713414", "0.75708526", "0.7528732", "0.7517632", "0.7500628", "0.75000787", "0.7482585", "0.74768317" ]
0.8241846
1
helper method to initialize every nonstore cup with four stones each
def place_stones # iterate through array and place 4 stones in all cups, except player stores @cups.each_with_index do |cup, idx| unless (idx == 6 || idx == 13) 4.times do cup << :stone end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def place_stones\n # helper method to #initialize every non-store cup with four stones each\n #non-store: 0-5, store, 7-13, store\n cups.each_index do |i|\n cups[i] = :stone,:stone,:stone,:stone if i < 6 || i.between?(7,12)\n end\n end", "def initialize(name1, name2)\n @player_1_name = name1\n @player_2_name = name2\n\n # there are 14 cups in the Mancala board.\n # each cup can store a number of stones\n @cups = Array.new(14){Array.new}\n\n # fills the non-store cups with four stones\n @cups.each_with_index do |cup, idx|\n # we do not add 4 stones to index 6 and 13\n unless idx == 6 || idx == 13\n 4.times{cup << :stone}\n end\n end\n end", "def create_initial_pieces\n WHITE_INITIAL_POSITIONS.each do |position|\n @white_pieces << CheckerPiece.new(self, position, :white)\n end\n BLACK_INITIAL_POSITIONS.each do |position|\n @black_pieces << CheckerPiece.new(self, position, :black)\n end\n end", "def initial_piece_placements\n self.grid.each_with_index do |row, row_idx|\n row.each_with_index do |cell, cell_idx|\n pos = [row_idx, cell_idx]\n if pos.all? {|coord| coord.even?} || pos.all? {|coord| coord.odd?}\n if row_idx < 3\n self[pos] = Piece.new(self, pos, :white)\n elsif row_idx >= 5\n self[pos] = Piece.new(self, pos, :black)\n end\n end\n end\n end\n end", "def initialize(name1, name2)\n @cups = Array.new(14) { Array.new(0) }\n @name1, @name2 = name1, name2\n place_stones\n end", "def initialize\n @piece_count = 0\n\n @grid = []\n (0..6).each do |col|\n @grid[col] = []\n (0..5).each do |row|\n @grid[col][row] = \"-\"\n end\n end\n end", "def initialize(setup)\n @grid = Array.new(8) { Array.new(8, nil)}\n\n if setup\n setup_pieces\n end\n end", "def build_pieces\n (1..8).each do |i|\n Pawn.new(2, i, \"white\") \n end\n Rook.new(1, 1, \"white\")\n Knight.new(1, 2, \"white\")\n Bishop.new(1, 3, \"white\")\n Queen.new(1, 4, \"white\")\n King.new(1, 5, \"white\")\n Bishop.new(1, 6, \"white\")\n Knight.new(1, 7, \"white\")\n Rook.new(1, 8, \"white\")\n (1..8).each do |i|\n Pawn.new(7, i, \"black\") \n end\n Rook.new(8, 1, \"black\")\n Knight.new(8, 2, \"black\")\n Bishop.new(8, 3, \"black\")\n Queen.new(8, 4, \"black\")\n King.new(8, 5, \"black\")\n Bishop.new(8, 6, \"black\")\n Knight.new(8, 7, \"black\")\n Rook.new(8, 8, \"black\")\n end", "def generateCoups\n\t\t@coups = []\n\t\trand(2).times do\n\t\t\t@coups.push(COUPS.sample)\n\t\tend\n\t\t@coups\n\tend", "def setup( )\n\t\t\t(\"a\"..\"h\").each do |f|\n\t\t\t\t@squares[\"#{f}2\"] = Chess::Pawn.new(self, \"#{f}2\", :white)\n\t\t\t\t@squares[\"#{f}7\"] = Chess::Pawn.new(self, \"#{f}7\", :black)\n\t\t\tend\n\t\t\t[\"a\", \"h\"].each do |f|\n\t\t\t\t@squares[\"#{f}1\"] = Chess::Rook.new(self, \"#{f}1\", :white)\n\t\t\t\t@squares[\"#{f}8\"] = Chess::Rook.new(self, \"#{f}8\", :black)\n\t\t\tend\n\t\t\t[\"b\", \"g\"].each do |f|\n\t\t\t\t@squares[\"#{f}1\"] = Chess::Knight.new(self, \"#{f}1\", :white)\n\t\t\t\t@squares[\"#{f}8\"] = Chess::Knight.new(self, \"#{f}8\", :black)\n\t\t\tend\n\t\t\t[\"c\", \"f\"].each do |f|\n\t\t\t\t@squares[\"#{f}1\"] = Chess::Bishop.new(self, \"#{f}1\", :white)\n\t\t\t\t@squares[\"#{f}8\"] = Chess::Bishop.new(self, \"#{f}8\", :black)\n\t\t\tend\n\t\t\t@squares[\"d1\"] = Chess::Queen.new(self, \"d1\", :white)\n\t\t\t@squares[\"d8\"] = Chess::Queen.new(self, \"d8\", :black)\n\t\t\t@squares[\"e1\"] = Chess::King.new(self, \"e1\", :white)\n\t\t\t@squares[\"e8\"] = Chess::King.new(self, \"e8\", :black)\n\t\tend", "def initialize #if module this method could be set_board\n @row_a = [\"A\"] + [\" \"]* 8\n @row_b = [\"B\"] + [\" \"]* 8\n @row_c = [\"C\"] + [\" \"]* 8\n @row_d = [\"D\"] + [\" \"]* 8\n empty_board\n two_unit_valid_places\n three_unit_valid_places\n end", "def initialize\n @config = Outpost::Config.setup\n @squares = Outpost::Squares::Create.squares self\n reset_cycled_colors\n @pieces = Outpost::Piece::Create.pieces self\n setup_pieces\n end", "def initialize(empty = false)\n @white_points = []\n @black_points = []\n return if empty\n\n @board = []\n 8.times do\n col = []\n 8.times do\n col << SPOT_OPEN\n end\n @board << col\n end\n\n # Add the starting pieces\n mark(3, 3, SPOT_WHITE)\n mark(4, 3, SPOT_BLACK)\n mark(4, 4, SPOT_WHITE)\n mark(3, 4, SPOT_BLACK)\n end", "def setup\n setup_major_pieces\n setup_pawns\n end", "def initialize number, num_of_mc_in_each_floor, num_of_sc_in_each_floor\n\t\t\t#floor::area instead of independent area\n\n\t\t\t\n\t\t\t#this can be modularized\n @areas = Array.new\n\n\t\t\t@number = number\n\t\t\t# @name = \"Floor \" + number.to_s\n\t\t\t\n\t\t\t(0...num_of_mc_in_each_floor).each do |mc|\n\t \t\tmain_corridor = Main_Corridor.new(\"Floor \"+@number.to_s+\" mc \"+(mc+1).to_s, AreaType::MC)\n\t \t\t@areas << main_corridor \n\t\t\tend\n\t\t\t(0...num_of_sc_in_each_floor).each do |sc|\n\t\t\t\tsub_corridor = Sub_Corridor.new(\"Floor \"+@number.to_s+\" sc \"+(sc+1).to_s, AreaType::SC)\n\t \t\t@areas << sub_corridor\n\t\t\tend\n\n\t\t\t@allowed_power_consumption = num_of_mc_in_each_floor * 15 + num_of_sc_in_each_floor * 10\n\t\tend", "def initialize\n @board = (0...8).map { [nil] * 8 }\n populate_board\n\n\tend", "def make_sequence\n 4.times do\n self.sequence << COLORS.sample\n end\n end", "def initializePesos\r\n \t@cantNeuronas.times do\r\n\t patron = @patrones[rand(@patrones.count-1)]\r\n @neuronas << {:class=>rand(@cantClases), :pesos => initPesos}\r\n\tend\r\n end", "def generate_corridors()\n\t\t(0..width).each do |i|\n\t\t\t(0..height).each do |j|\n\t\t\t\tif i.odd? && j.odd? && @cells[i][j].type == Cell::UNALLOCATED\n\t\t\t\t\tcarve_corridors(i,j,nil)\n @corridor_seeds << @cells[i][j]\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def set_pieces\n # white pieces\n (1..8).each do |index|\n Pawn.create(game_id: id, x_position: index, y_position: 2, color: 'white', active: true)\n end\n Rook.create(game_id: id, x_position: 1, y_position: 1, color: 'white', active: true)\n Knight.create(game_id: id, x_position: 2, y_position: 1, color: 'white', active: true)\n Bishop.create(game_id: id, x_position: 3, y_position: 1, color: 'white', active: true)\n Queen.create(game_id: id, x_position: 4, y_position: 1, color: 'white', active: true)\n King.create(game_id: id, x_position: 5, y_position: 1, color: 'white', active: true)\n Bishop.create(game_id: id, x_position: 6, y_position: 1, color: 'white', active: true)\n Knight.create(game_id: id, x_position: 7, y_position: 1, color: 'white', active: true)\n Rook.create(game_id: id, x_position: 8, y_position: 1, color: 'white', active: true)\n # black pieces\n (1..8).each do |index|\n Pawn.create(game_id: id, x_position: index, y_position: 7, color: 'black', active: true)\n end\n Rook.create(game_id: id, x_position: 1, y_position: 8, color: 'black', active: true)\n Knight.create(game_id: id, x_position: 2, y_position: 8, color: 'black', active: true)\n Bishop.create(game_id: id, x_position: 3, y_position: 8, color: 'black', active: true)\n Queen.create(game_id: id, x_position: 4, y_position: 8, color: 'black', active: true)\n King.create(game_id: id, x_position: 5, y_position: 8, color: 'black', active: true)\n Bishop.create(game_id: id, x_position: 6, y_position: 8, color: 'black', active: true)\n Knight.create(game_id: id, x_position: 7, y_position: 8, color: 'black', active: true)\n Rook.create(game_id: id, x_position: 8, y_position: 8, color: 'black', active: true)\n end", "def initialize_set\n @set = Array.new()\n (0000..5555).each do |i|\n gtg = true\n i.to_s.split('').each do |j|\n gtg = false if j.to_i > 5 || j.to_i < 0\n end\n if gtg\n str = \"\"\n i.to_s.rjust(4, \"0\").split('').each { |k| str += @colors[k.to_i] }\n @set.push(str)\n end\n end\n end", "def initialize\n @grid = []\n (0..5).each do |row|\n @grid[row] = []\n (0..6).each do |col|\n @grid[row][col] = \"_ \"\n end\n end\n end", "def generateCoups\n\tcoups = []\n\trand(2).times do\n\t\tcoups.push(COUPS.sample)\n\tend\n\tcoups\nend", "def board_setup\n\t\tinitial_position = [\"rook\", \"knight\", \"bishop\", \"queen\", \"king\", \"bishop\", \"knight\", \"rook\"]\n\t\tspecial_position = [8,1]\n\t\tpawn_position = [7,2]\n\t\tinitial_color = [\"black\",\"white\"]\n\t\ti = 0\n\t\tx = 0\n\t\t#loops through ranks 8 and 1 setting each class piece in his corresponding position.\n\t\tspecial_position.each do |num|\n\t\t\t(\"a\"..\"h\").each do |letter|\n\t\t\t\t@board[letter+num.to_s].name = initial_position[i]\n\t\t\t\t@board[letter+num.to_s].color = initial_color[x]\n\t\t\t\ti += 1\n\t\t\tend\n\t\t\ti = 0\n\t\t\tx += 1\n\t\tend\n\n\t\ty = 0\n\t\t#loos through ranks 7 and 2 setting the pawn's pieces in his corresponding position.\n\t\tpawn_position.each do |num|\n\t\t\t(\"a\"..\"h\").each do |letter|\n\t\t\t\t@board[letter+num.to_s].name = \"pawn\"\n\t\t\t\t@board[letter+num.to_s].color = initial_color[y]\n\t\t\tend\n\t\t\ty += 1\n\t\tend\n\tend", "def generateCoups\n\tcoups = []\n\trand(2).times do\n\t\tcoups.push(COUPS.sample)\nend\n coups\nend", "def test_2_initialize\n #TO DO :\n #Quand la classe s'initialize, elle doit créer 9 instances BoardCases\n #Ces instances sont rangées dans une array qui est l'attr_accessor de la classe\n#####################################################\n# Creation de mon board hash avec chacune des valeurs empty\n @board = [\" \", \" \",\" \",\n \" \", \" \", \" \",\n \" \",\" \", \" \"]\n\n# Rappel de chacune des valeurs via leur index: pour initialiser à chaque tour\n\n end", "def test_init\n #@board[0][5].piece = Bishop.new(@board[0][5], \"♗\", \"white\")\n @board[0][4].piece = King.new(@board[0][4], \"♔\", 'white')\n\n @board[7][4].piece = Queen.new(@board[7][4], \"♛\", \"black\" )\n @board[7][3].piece = Rook.new(@board[7][3], \"♜\", \"black\")\n @board[7][5].piece = Rook.new(@board[7][5], \"♜\", \"black\")\n end", "def populate_caves\n for row_i in 1...@height - 1\n for column_i in 1...@width - 1\n if @map[row_i][column_i] == @FLOOR\n union_adjacent_square(row_i, column_i)\n end\n end\n end\n\n @disjoinset.split_sets()\n end", "def initialize(seeds)\n @grid = Array.new(9) { Array.new(9, nil) }\n @rows = {}\n @columns = {}\n @squares = {}\n 1.upto(9) do |i|\n @rows[i] = Hash.new(false)\n @columns[i] = Hash.new(false)\n @squares[i] = Hash.new(false)\n end\n seed_board(seeds)\n end", "def fill_train(train)\n 120.times { train.board(active_passenger, station) }\n end" ]
[ "0.7306267", "0.6425018", "0.6195315", "0.6099121", "0.6095636", "0.6053886", "0.604493", "0.6035354", "0.5922095", "0.5867079", "0.5810461", "0.57877344", "0.5763426", "0.5752549", "0.5746629", "0.5712919", "0.57026935", "0.569856", "0.5691848", "0.5682647", "0.5675142", "0.5673388", "0.56685954", "0.56566477", "0.5640061", "0.56361204", "0.560898", "0.5605164", "0.55993813", "0.55959576" ]
0.64710253
1
return name of winner with most stones in respective cup, :draw otherwise
def winner count1, count2 = @cups[6].count, @cups[13].count if count1 > count2 @name1 elsif count2 > count1 @name2 else :draw end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def winner\n $the_win_comb = { flash_straight: flash_straight, for_of_kind: four_of_kind, full_house: full_house,\n flush: flush, straight: straight, three: three, two_pair: two_pair,\n one_pair: one_pair, high_card: high_card }\n puts \"\\n The highest winner combinations and cards are - \"\n $the_win_comb.each { |comb, ans| return puts comb.upcase, $the_win_comb[comb], ' ' unless ans.nil?}\n end", "def determine_winner\n \tif self.won?(@player_symbol) then\n \t\t@over = true\n \treturn \"Player\" \n \tend\n \tif self.won?(@computer_symbol) then\n \t\t@over = true\n \t return \"Computer\" \n \tend\n \tif self.open_spots.count == 0 then\n \t\t@over = true\n \t\treturn \"Draw\"\n \tend\n return \"\" \n end", "def winner\n\t\ts = {}\n\t\t@vPlayers.each {|player|\n\t\t\ts[player.name.to_s] = player.score.totalScore\n\t\t}\n\t\tmax = s.values.max\n\t\tname = s.select{|k, v| v == max}.keys\n\t\tscore = s.select{|k, v| v == max}.values\n\t\t\n\t\tprint \"The winner is \" + name[0].to_s + \" with a total score of \" + score[0].to_s\n\t\tputs \"\",\"\"\n\t\t\n\tend", "def who_is_winner(pieces_position_list)\n representation = create_representation(pieces_position_list)\n\n diagonal = get_diagonal(representation)\n on_row = by_row(representation)\n on_column = by_column(representation)\n\n [diagonal, on_column, on_row].select { |x| x != 'Draw' }.first\nend", "def winner\n tie_string = \"\"\n @players.each do |player|\n if @position[player] == @length\n tie_string << \"#{player}\"\n end\n end\n\n if tie_string.length > 1\n return \"no one\"\n else\n return tie_string[0]\n end\n\n end", "def wins\n win_arr = self.win_array\n \"#{self.full_name} has #{win_arr.length} wins.\"\n end", "def detect_winner(brd)\n WINNING_LINES.each do |line|\n if brd.values_at(*line).count(PLAYER_MARKER) == 3\n return 'Player'\n elsif brd.values_at(*line).count(COMPUTER_MARKER) == 3\n return 'Computer'\n end\n end\n nil\nend", "def winner\n players.sort.last\n end", "def most_points_scored()\n points = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if player[:points] > points\n points = player[:points]\n result = player[:player_name]\n\n end\n end\n end\n end\n end\n result\nend", "def winner\n big_p = 1\n \n marks = self.unrolled\n @@All_Runs.each do |run|\n #p = product of all the slots\n p = run.map {|i| marks[i]}.inject(:*)\n return :x if p == 8\n return :o if p == 1\n big_p *= p\n end\n \n return (big_p == 0) ? nil : :cat\n end", "def winner \n if won? \n turn_count.even? ? \"O\" : \"X\"\n end \n end", "def winningest_coach(seasonasstring) # coach name in game team stats\n #per season, get list of all coaches - given by arg\n #per coach, find all games played by that coach\n #then count of all games won / count of all games played\n #find highest\n #return name of coach found in 114\n end", "def most_points_scored\n most_points = 0\n leading_scorer = \"\"\n\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n if player[:points] > most_points\n most_points = player[:points]\n leading_scorer = player[:player_name]\n end\n end\n end\n return leading_scorer\nend", "def winner_count\n end", "def overall_winner_message()\n if @score_count.get_determine_set_winner() == 1\n return \"#{@player.get_name()} won the set of games with a score of #{@score_count.get_games_won()} vs. #{@score_count.get_other_games_won()}. Both players tied #{@score_count.get_games_tied} time(s).\"\n\n elsif @score_count.get_determine_set_winner() == 2\n return \"#{@player.get_other_name()} won the set of games with a score of #{@score_count.get_other_games_won()} vs. #{@score_count.get_games_won()}. Both players tied #{@score_count.get_games_tied} time(s).\"\n \n else @score_count.get_determine_set_winner() == 0\n return \"It was a tie, guys. You're both just super duper.\"\n end\n end", "def most_points_scored\n big_score_player = player_collection.reduce { |memo, next_player|\n memo[:points] > next_player[:points] ? memo : next_player; \n }\n big_score_player[:player_name];\nend", "def winner\n @player_positions.max_by{|player, position| position}[0]\n end", "def show_winner()\n\t\tif player1_count() > player2_count\n\t\t\treturn @player1 \n\t\telsif player2_count() > player1_count\n\t\t\treturn @player2\n\t\telse \n\t\t\treturn nil \n\t\tend\n\tend", "def winner\n @board.sort_by {|player, board_position| board_position}.last.first\n end", "def player_with_most(stat)\n value = nil\n owner = nil\n players.each do |player, stats|\n if value == nil || stats[stat] > value\n value = stats[stat]\n owner = player\n end\n end\n owner\nend", "def detect_winner(brd)\n Board::WINNING_LINES.each do |line|\n if brd.position_values[line[0]] == Board::PLAYER_MARKER &&\n brd.position_values[line[1]] == Board::PLAYER_MARKER &&\n brd.position_values[line[2]] == Board::PLAYER_MARKER\n return 'Player'\n elsif brd.position_values[line[0]] == Board::CPU_MARKER &&\n brd.position_values[line[1]] == Board::CPU_MARKER &&\n brd.position_values[line[2]] == Board::CPU_MARKER\n return 'CPU'\n end\n end\n nil\n end", "def winningest_team\n @teams.max_by { |team| team.total_win_percentage }.team_name\n end", "def most_points_scored\n points = 0\n result = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if points < stats[:points]\n points = stats[:points]\n result = name\n end\n end\n end\n result\nend", "def most_points_scored\n most_points = 0 \n name = nil\n game_hash.each { |keys, values|\n i = 0\n while i < game_hash[keys][:players].length do \n if game_hash[keys][:players][i][:points] > most_points\n most_points = game_hash[keys][:players][i][:points]\n name = game_hash[keys][:players][i][:player_name]\n end\n i += 1\n end\n }\n name\n # binding.pry\nend", "def calculate_winner players\n\n sorted_cards = @card_list.sort # sort cards in 'poker' order\n players.each_with_index {|player, i|\n if sorted_cards[-1] == player.get_last_card_played\n @last_winner=player.name\n end\n }\n # Switched off this observation for the moment\n #changed\n #notify_observers(sorted_cards[-1].to_string)\n\n if sorted_cards[-1].to_string_other.include?(\"FIVE\") then\n changed\n notify_observers(@last_winner,sorted_cards[-1].to_string)\n end\n\n sorted_cards[-1] # return best card\n end", "def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend", "def print_winner\n if @winner == :c\n return \"Sorry, cat game.\"\n else\n if @player1.mark == @winner\n return \"Congratulations! \" + @player1.name + \" wins!\"\n elsif @player2.mark == @winner and @player2.type == 'human'\n return \"Congratulations! \" + @player2.name + \" wins!\"\n elsif @player2.mark == @winner and @player2.type == 'computer'\n #1 player, 'O' won. Do not congratulate player on computer victory.\n return \"Sorry, \" + player2.name + \" wins.\"\n end\n end\n end", "def winner(board)\n # returns X when X won, O when O won and nill when there is no winner\n if (draw?(board) || !full?(board)) && !won?(board)\n return nil\n elsif (board[won?(board)[0]] == \"X\")\n return \"X\"\n elsif (board[won?(board)[0]] == \"O\")\n return \"O\"\n end\nend", "def most_points_scored\n stat_by_player = collect_stat_by_name(:points)\n player_with_max_stat = find_max_stat_by_player(stat_by_player)\n player_with_max_stat\nend", "def most_points(game)\nmax_points = 0\nmax_points_player = \"\"\ngame.each do |team, team_contents|\n team_contents[:roster].each do |player, player_contents| \n if player_contents[:points] == max_points\n max_points_player = max_points_player + \" and #{player_contents[:player_name]}\"\n elsif player_contents[:points] > max_points\n max_points = player_contents[:points]\n max_points_player = player_contents[:player_name]\n end\n end\nend\nputs \"#{max_points_player} scored #{max_points}\"\nend" ]
[ "0.69315696", "0.6544136", "0.65327466", "0.6383339", "0.6350693", "0.62933767", "0.62247336", "0.61688673", "0.6163639", "0.61479205", "0.6112319", "0.6101422", "0.60942054", "0.6091604", "0.6091074", "0.6084351", "0.6077207", "0.60764015", "0.6073439", "0.6059641", "0.60533065", "0.60443413", "0.60370046", "0.6023992", "0.6020483", "0.6020086", "0.60169697", "0.6005966", "0.6004968", "0.59958327" ]
0.7892122
0
Initializer Method params: x,y,w,h: parameters for parent GameObject initializer solid: parameter that determines upon creation whether the character is in solid form or not. Event tiks are set to 0 by default recoil frames by default is 35 frames, e.g. the character recoils for 35 frames. Invincibility frames is set to 0 by default. Dying frames is set to 20 by default, eg. the dying animation of a char lasts 20 frames. floater is set to false by default. Only flying enemies should have this set to true.
def initialize(x, y, w, h, solid) super(x, y, w, h) @event_tiks = 0 @recoil_frames = 35 @recoil_magnitude = 4 @inv_frames = 0 @dying_frames = 20 @solid = solid @floater = false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(animation, pos, health, weapon)\n super(animation, pos)\n @health = health\n @weapon = weapon\n @invincibility = 0\n end", "def initialize(**args)\n @position = Position.new(args.fetch(:x, 0), args.fetch(:y, 0), args.fetch(:z, 0))\n @velocity = Velocity.new(args.fetch(:vx, 0), args.fetch(:vy, 0), args.fetch(:vz, 0))\n @acceleration = Acceleration.new(args.fetch(:ax, 0), args.fetch(:ay, 0), args.fetch(:az, 0))\n @foresight = args.fetch(:foresight, [1, 0, 0.5, 0.5, 0, 0])\n @color = args[:color]\n @color ||= '#1199bb'\n end", "def init(character)\r\n @character = character\r\n dispose_shadow\r\n @bush_depth_sprite.visible = false\r\n @bush_depth = 0\r\n init_add_z_shadow\r\n init_zoom\r\n @tile_id = 0\r\n @character_name = nil\r\n @pattern = 0\r\n @direction = 0\r\n update\r\n end", "def initialize\r\n\t super(0,Graphics.height-WIN_HEIGHT,Graphics.width,WIN_HEIGHT)\r\n\t @x, @y, @i = 10, 50, 0\r\n\t @party_size = $game_party.all_members.size\r\n contents.font.size = FONT_SIZE\r\n\t self.back_opacity = WIN_OPACITY\r\n self.opacity = FRAME_OPACITY\r\n @actor_hp = []\r\n @actor_mp = []\r\n\t fhiz_hud\r\n\t check_visible\r\n end", "def initialize(viewport, character = nil)\r\n super(viewport)\r\n @bush_depth_sprite = Sprite.new(viewport)\r\n @bush_depth_sprite.opacity = 128\r\n @height = 0\r\n init(character)\r\n end", "def initialize(parent)\n\t\t#-- Class :\n\t\t@enemy = parent.enemy\n\t\t@spaceship = parent\n\t\t\n\t\t#-- Images :\n\t\t@bullet = super(parent.window, \"sprites/blast.png\", false)\n\t\t\n\t\t#-- Variables :\n\t\t@y_bullet = @spaceship.y_player\n\t\t@x_bullet = @spaceship.x_player + @spaceship.width / 3\n\t\t@yreal = [@y_bullet, (@y_bullet+@bullet.height)]\n\t\t@xreal = [@x_bullet, (@x_bullet+@bullet.width)]\n\tend", "def initialize(name_to_update,life_points_to_update=10)\n @name = name_to_update\n @life_points = life_points_to_update\n @degat = 0 # j'initialise une variable de classe degat afin de m'en servir dans toute la classe\n @weapon_level = 1\n end", "def initialize (window, x, y)\n # Establishes a sprite for the palyer\n @image = Gosu::Image.new(window, \"media/Starfighter.bmp\", false)\n # Initializes the x,y and last position\n @x, @y = x, y\n @lastPosX = @lastPosY = @lastShot = 0\n # Initializes x-y-velocity\n @vel_x = @vel_y = 0\n # Stores instance of window\n @window = window\n # Establishes constant velocity for x and y directions\n @VELOCITY = 3\n # Boolean which measures if the ship is dead or not\n @isKill = false\n end", "def initialize(text, text_height, font_name, z=0)\n\t\t@text = text\n\t\t@text_height = text_height\n\t\t@font_name = font_name\n\n\t\t@z = z\n\n\t\t@x = 0\n\t\t@y = 0\n\n\t\t@text_colour = Gosu::Color::WHITE\n\t\t@background_colour = Gosu::Color::BLACK\n\n\t\t@bg_height = text_height + 2\n\tend", "def initialize args\n\n # Build the scrolling backdrop - for now, the backdrop is split in half because of Reasons.\n divide = args.grid.center_x.div( BACKDROP_WIDTH ) * BACKDROP_WIDTH\n @backdropl_spr = AhnSprite.new \"backdrop\", divide, args.grid.h\n 0.step( args.grid.h, BACKDROP_HEIGHT ).each do |row|\n 0.step( ( divide ) + BACKDROP_WIDTH, BACKDROP_WIDTH ).each do |col|\n @backdropl_spr.sprites << { x: col, y: row, w: BACKDROP_WIDTH, h: BACKDROP_HEIGHT, path: \"sprites/backdrop.png\" }\n end\n end\n @backdropl_spr.x = 0\n\n @backdropr_spr = AhnSprite.new \"backdrop\", args.grid.w - divide, args.grid.h\n 0.step( args.grid.h, BACKDROP_HEIGHT ).each do |row|\n 0.step( ( args.grid.w - divide ) + BACKDROP_WIDTH, BACKDROP_WIDTH ).each do |col|\n @backdropr_spr.sprites << { x: col, y: row, w: BACKDROP_WIDTH, h: BACKDROP_HEIGHT, path: \"sprites/backdrop.png\" }\n end\n end\n @backdropr_spr.x = divide\n\n # Set up the world; leave the player empty, update will spawn him/her\n @player = nil\n @lives = 3\n @player_bullets = []\n\n # Remember the epoch we started at, to trigger enemies at the right time\n @epoch = args.state.tick_count\n @enemy_idx = 0\n @enemy = []\n @enemy_bullets = []\n\n end", "def initialize settings={:width => 20, :height => 20, :color => [255, 255, 255], :angle => 0, :zoom => 1, :aa => false}\n\t\t\ts = {:width => 20, :height => 20, :color => [255, 255, 255], :angle => 0, :zoom => 1, :aa => false}.merge!(settings)\n\t\t\tsuper s\n\t\t\t@surface = Rubygame::Surface.new [@width, @height]\n\t\t\tUtil.hash_to_var(s, [:color, :zoom, :aa, :angle], self)\n\t\t\t@surface.fill @color\n\t\tend", "def initialize(text, options = {}) \r\n if text.is_a? Hash\r\n options = text\r\n text = nil\r\n end\r\n \r\n # We remove the :size param so it doesn't get to GameObject where it means something else\r\n @size = options.delete(:size) || options.delete(:height) || @@size || 15\r\n \r\n options = {:rotation_center => :top_left}.merge(options) \r\n \r\n super(options)\r\n \r\n @text = text || options[:text] || \"-No text specified-\"\r\n @font = options[:font] || @@font || Gosu::default_font_name()\r\n @line_spacing = options[:line_spacing] || 1\r\n @align = options[:align] || :left\r\n @max_width = options[:max_width]\r\n @padding = options[:padding] || @@padding\r\n\r\n @gosu_font = Gosu::Font[@font, @size]\r\n create_image unless @image\r\n\r\n if options[:background]\r\n @background = GameObject.new(:image => options[:background])\r\n @background.attributes = self.attributes\r\n @background.color = Color::WHITE\r\n @background.zorder -= 1\r\n @background.x -= @padding\r\n @background.y -= @padding\r\n @background.width = self.width + @padding * 2\r\n @background.height = self.height + @padding * 2\r\n end\r\n \r\n self.height = options[:height] if options[:height]\r\n end", "def initialize (name, life_points, weapon_level)\n @life_points = 100\n @weapon_level = weapon_level = 1\n super(name,life_points) #on récupère les attributs de la classe Player\n end", "def initialize\n @solid = false\n @score = 0\n @damage = 0\n # @display = \"<c=808080>.</c>\"\n @display = \"grass\"\n @message = \"Fwffffwwww\"\n @sound = nil\n end", "def initialize settings={:x => 0, :y => 0, :width => 0, :height => 0, :life => 1, :depth => 0}\n\t\t\ts = {:x => 0, :y => 0, :width => 0, :height => 0, :life => 1, :depth => 0}.merge! settings\n\t\t\tUtil.hash_to_var(s, [:x, :y, :width, :height, :life, :depth], self)\n\t\t\t@@game.add self\n\t\tend", "def initialize(viewport, battler = nil)\n super(viewport)\n change\n @old = Graphics.frame_count # For the delay method\n @goingup = true # Increasing animation? (if @rm2k_mode is true)\n @once = false # Is the animation only played once?\n @animated = true # Used to stop animation when @once is true\n self.opacity = 0\n @index = 0\n @pattern_b = 0\n @counter_b = 0\n @trans_sprite = Sprite.new\n @trans_sprite.opacity = 0\n @bar_hp_sprite = Sprite.new\n @bar_hp_sprite.bitmap = Bitmap.new(64, 10)\n @bar_sp_sprite = Sprite.new\n @bar_sp_sprite.bitmap = Bitmap.new(64, 10)\n @color1 = Color.new(0, 0, 0, 192)\n @color2 = Color.new(255, 255, 192, 192)\n @color3 = Color.new(0, 0, 0, 192)\n @color4 = Color.new(64, 0, 0, 192)\n @old_hp = -1\n @old_sp = -1\n @battler = battler\n @battler_visible = false\n @first = true\n @pattern = 0\n if $target_index == nil\n $target_index = 0\n end\n @battler.is_a?(Game_Enemy) ? enemy_pose(0, 1) : pose(0, 1)\nend", "def initialize(name, degats, weaponType, durabilite, durabiliteMax, projectiles)\n super(name, 1, 200, 200, 450, 450)\n\n @degats = degats\n @weaponType = weaponType\n @durabilite = durabilite\n @durabiliteMax = durabiliteMax\n @projectiles = projectiles\n end", "def initialize(x, y, args)\n speed_values = args.state.speed_values\n @x_vel = speed_values[rand(speed_values.length)]\n @y_vel = speed_values[rand(speed_values.length)]\n @truex = x - @x_vel\n @truey = y - @y_vel\n @w = 10\n @h = 10\n @x = x - (@w / 2)\n @y = y - (@h / 2)\n @r = 255\n @g = 255\n @b = 255\n @a = 2558\n @path = 'sprites/black.png'\n args.outputs.static_sprites << self\n end", "def setup\n\t\tsuper\n\t\t@x = 400\n\t\t@y = 300\n\t\t#@image = Gosu::Image[\"Ship.png\"]\n\t\t self.input = {\n\t\t \tholding_left: :left,\n\t\t \tholding_right: :right,\n\t\t \tholding_up: :up,\n\t\t \tholding_down: :down,\n\t\t \tspace: :fire\n\t\t }\n\t\t@speed = 10\n\t\t@angle = 0\n\t\t@animation = Chingu::Animation.new(:file => \"flame_48x48.bmp\")\n\t\t@animation.frame_names = { :still =>0..1, :up =>2..5, :fire =>6..7}\n# :still =>0..1, :fire =>6..7, :up =>2..5\n\t\t@frame_name = :still\n\t\t@last_x, @last_y = @x, @y\n\tend", "def initialize(name) # je recrée un initialize et je fais appel aux caractéristiques de la classe mère avec super\n super(name)\n\n @life_points = 100 # j'ajoute les caractéristiques propres au joueur humain\n @weapon_level = 1\n end", "def initialize(args)\n\n # Remember our args reference\n @args = args\n\n # Our default location will be in the middle of the screen\n @x = @args.grid.center_x\n @y = @args.grid.center_y\n\n # Set up our base parameters\n @turn_speed = 4\n @vector_x = 0\n @vector_y = 0\n @delta_v = 0\n @peak_velocity = 0\n @target_velocity = 0\n @fired = false\n\n # The size is set to the basic size of the player ship.\n @w = 64\n @h = 64\n @angle = 180\n @target_angle = 0\n\n end", "def initialize(char, damage, color, critical = false)\n # set coordinates\n @x, @y = char.real_x / 4 + 16, char.real_y / 4 + 16\n # set damage text value\n @damage = (damage.is_a?(Numeric) ? damage.abs.to_s : damage.to_s)\n # set color and critical flag\n @color, @critical = color, critical\n # create dummy bitmap\n bitmap = Bitmap.new(1, 1)\n # set font\n bitmap.font.name = Cache::FontNameDamage\n # set font size\n bitmap.font.size = Cache::FontSizeDamage\n # get size rectangle\n size_rect = bitmap.text_size(@damage)\n # get text width and height\n @width, @height = (size_rect.width + 4) / 2 * 2, size_rect.height\n @width = 1 if @width < 1\n @height = 1 if @height < 1\n end", "def initialize(x=0, y=0, type=nil)\n @x = 0\n @y = 0\n @z = 0\n @image = nil\n @blending = :default\n @alpha = 1.0\n @angle = 0\n @index = 0\n @radius = 0\n @size = 1.0\n \n @die = false\n \n # Adds this new sprite to its sprite list\n Game.sprite_collection.add(self) \n end", "def initialize(animation, pos, damage, id, destroy_proc, velocity = Vector.new(x: 0, y: 0))\n super(animation, pos)\n @damage = damage\n @id = id\n @velocity = velocity\n @destroy_proc = destroy_proc\n end", "def initialize\n\t\t@health_info = { previous_health: PLAYER_MAX_HEALTH, heal_amount: 0 }\n\t\t@@look_comfort = 0\n\t\t@look = []\n\tend", "def initialize(name)\n super(name)\n @weapon_level = 1\n @life_points = 100\n end", "def initialize (x, y, char, color)\n @x = x\n @y = y\n @char = char\n @color = color\n end", "def initialize(window)\n @window = window\n @color = Gosu::Color::BLACK\n\n @a = CP::Vec2.new(0,0)\n @b = CP::Vec2.new(SCREEN_WIDTH - (PADDING * 2), 0)\n\n # CHIPMUNK BODY\n @body = CP::Body.new(INFINITY, INFINITY)\n @body.p = CP::Vec2.new(PADDING, SCREEN_HEIGHT - PADDING)\n @body.v = CP::Vec2.new(0, 0)\n\n # CHIPMUNK SHAPE\n @shape = CP::Shape::Segment.new(@body,\n @a,\n @b,\n 1)\n @shape.e = 0\n @shape.u = 1\n\n # STATIC SO THAT THE GRAVITY OF THE SPACE DOESN'T HAVE ITS WAY\n @window.space.add_static_shape(@shape)\n\n end", "def initialize (name) #que le nom en entrée\n\t\t@life_points = 100\n\t\t@weapon_level = 1 #integer\n\tend", "def initialize(start, w, h, generation_frame, game)\n super(start, w, h, generation_frame, game)\n end" ]
[ "0.6326617", "0.62241375", "0.6052062", "0.60055333", "0.60047036", "0.5959816", "0.58974123", "0.5884391", "0.58756435", "0.5874231", "0.58519", "0.5793427", "0.5768155", "0.5767563", "0.5766023", "0.57587063", "0.57482404", "0.5741189", "0.57279825", "0.571827", "0.57181233", "0.5703493", "0.56835973", "0.56606233", "0.5651873", "0.5647971", "0.5643013", "0.564051", "0.56224185", "0.56085044" ]
0.72491264
0
Changes the direction the char is facing. Similar to change_state params: dir: The dir of the new direction.
def change_dir(dir) @face_dir = dir @sprite.change_dir(dir) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_direction(dir)\n @direction = dir unless @turned\n @turned = true\n end", "def turn(dir, val)\n\ti_now = $directions.index($direction)\n\ti_change = dir == \"R\" ? (val / 90 * 1) : (val / 90 * -1)\n\ti_new = (i_now + i_change) % 4\n\t$direction = $directions[i_new]\nend", "def set_direction(d)\r\n @direction = d if !@direction_fix && d != 0\r\n @stop_count = 0\r\n end", "def turn dir\n self.a = (a + dir).degrees if dir\n end", "def set_direction(d)\r\r\n if !@direction_fix && d != 0\r\r\n @direction = d\r\r\n if d % 2 != 0 && (!$imported[\"CXJ-AnimEx\"] || !@has_diagonal)\r\r\n @direction+= 1\r\r\n @direction-= 2 if d > 5\r\r\n @direction = 10 - direction if d > 2 && d < 8\r\r\n end\r\r\n end\r\r\n @stop_count = 0\r\r\n end", "def get_direction\n return (@dir || @character.direction)\n end", "def change_direction\n @move_x = -@move_x\n @speed = -@speed\n end", "def change_direction\n if @movement_direction == @directions.fetch(\"forward\")\n @movement_direction = @directions.fetch(\"backward\")\n else\n @movement_direction = @directions.fetch(\"forward\")\n end\n end", "def turn(direction)\n\t\tcase direction.upcase\n\t\twhen 'R'\n\t\t\t@orientation = (@orientation + 1) % 4\n\t\twhen 'L'\n\t\t\t@orientation = (@orientation - 1) % 4\n\t\tend\n\tend", "def dir(direction)\n if direction == \"f\"\n return \"left\"\n elsif direction == \"g\"\n return \"center\"\n elsif direction == \"h\"\n return \"right\"\n elsif direction == \"c\"\n return \"away\"\n else\n return \"invalid\"\n end\n end", "def update_direction!\n direction.place!(command.arguments[:direction])\n end", "def chdir=(dir)\n @chdir = dir.to_s\n end", "def move(dir)\n return case (player.restriction == 3 ? 10 - dir : dir)\n when 1 then player.move_lower_left\n when 2 then player.move_down\n when 3 then player.move_lower_right\n when 4 then player.move_left\n when 6 then player.move_right\n when 7 then player.move_upper_left\n when 8 then player.move_up\n when 9 then player.move_upper_right\n end\n end", "def direction=(value)\n @direction = value\n end", "def chdir(dir=nil)\n @chdir = dir.to_s if dir\n @chdir\n end", "def update_player_movement\r\n # Move player in the direction the directional button is being pressed\r\n case Input.dir4\r\n when 2\r\n move_down\r\n when 4\r\n move_left\r\n when 6\r\n move_right\r\n when 8\r\n move_up\r\n end\r\n end", "def do_v(s); s[:direction] = 'down'; end", "def move(dir)\n old_pos = @pos\n\n case dir\n when 'U'\n @pos -= @sides if @pos > @sides\n when 'R'\n @pos += 1 if @pos % @sides != 0\n when 'D'\n @pos += @sides if @pos <= @sides ** 2 - @sides\n when 'L'\n @pos -= 1 if (@pos - 1) % @sides != 0\n else\n raise ParseError, \"Invalid input: #{dir}\"\n end\n\n @pos = old_pos if pos.eql? ' '\n end", "def turn(by: 90)\n next_direction_index = DIRECTIONS.find_index(@facing) + (by / 90).to_i\n @facing = DIRECTIONS[next_direction_index % 4]\n end", "def direction(direction_arg = nil)\n return current.direction if direction_arg.nil?\n\n current.direction = direction_arg\n\n self\n end", "def turn direction\n return unless placed?\n direction = case\n when direction.to_s.match(/^l(?:eft)?$/i); -1\n when direction.to_s.match(/^r(?:ight)?$/i); +1\n else; nil\n end\n # The modulus is to make sure we stay within the 0-4 array boundary\n @f = (@f + direction) % DIRECTIONS.size if direction\n report\n end", "def turn_toward(character)\n # calculate differences in x and y\n dx, dy = @real_x - character.real_x, @real_y - character.real_y\n # determines where to turn according to the x and y differences\n if dx < 0 && dx.abs >= dy.abs # character is right\n turn_right\n elsif dx > 0 && dx.abs >= dy.abs # character is left\n turn_left\n elsif dy < 0 # character is down\n turn_down\n elsif dy > 0 # character is up\n turn_up\n end\n end", "def turn_robot(name, direction)\n\t\ttarget_robot = find_robot_by_name(name)\n\t\t#switch in case we want different directions in the future, like turn around \n\t\tif target_robot != nil\n\t\t\ti = @facings.find_index(target_robot.facing)\n\t\t\tcase direction\n\t\t\twhen \"LEFT\"\n\t\t\t\ti -= 1\n\t\t\twhen \"RIGHT\"\n\t\t\t\ti += 1\n\t\t\telse\n\t\t\t\tputs \"invalid command: invalid direction\"\n\t\t\tend\n\t\t\tnew_facing = @facings[(i) % @facings.length]\n\t\t\ttarget_robot.facing = new_facing\t\n\t\tend\n\tend", "def turn(direction_wanted)\n if direction_wanted == \"right\"\n puts \"The #{@color} #{@model} turned right.\"\n else direction_wanted == \"left\"\n puts \"The #{@color} #{@model} turned left.\"\n end\n end", "def turnLeft\n case @currentDir\n when :north\n @currentDir = :west\n when :south\n @currentDir = :east\n when :east\n @currentDir = :north\n when :west\n @currentDir = :south\n end\n end", "def direction=(direction)\n validator = EnumAttributeValidator.new('String', ['FromCorner1', 'FromCorner2', 'FromCorner3', 'FromCorner4', 'FromCenter', 'NotDefined'])\n unless validator.valid?(direction)\n fail ArgumentError, 'invalid value for \"direction\", must be one of #{validator.allowable_values}.'\n end\n @direction = direction\n end", "def move(direction)\n @old = @pos\n @pos += direction\n end", "def as(dir=:out)\n @direction = dir.to_s\n GPIO.write \"gpio#{@number}/direction\", @direction\n end", "def letter_direction\n just_walk_forward = sign_in_direction(direction)\n return direction unless finished?(just_walk_forward)\n crossroads_direction\n end", "def turn(t)\n\t\tcardinal = [\"N\", \"E\", \"S\", \"W\"]\n\t\tpos = cardinal.index(@direction)\n\t\tif t == \"L\"\n\t\t\tpos -= 1\n\t\telsif t == \"R\"\n\t\t\tpos += 1\n\t\tend\n\t\t@direction = cardinal[pos % 4]\n\tend" ]
[ "0.75093424", "0.66219294", "0.65599877", "0.65560925", "0.6474414", "0.6449539", "0.6338762", "0.6326416", "0.63213956", "0.62699646", "0.6260746", "0.6245424", "0.61796993", "0.61643946", "0.6115455", "0.60408527", "0.6032176", "0.602567", "0.6016946", "0.5976615", "0.5950885", "0.5932281", "0.5863586", "0.58422357", "0.5808941", "0.58084685", "0.5803167", "0.5800115", "0.575317", "0.57482535" ]
0.68976337
1
Defines the behaviour of the character when it is impacted. params: away_from: x,y coordinates that specify the point of origin of the attack. attack_dmg: the damage to be subtracted from the character's remaining health Damage is subtracted from current health. An angle with respect to x,y axis is calculated between this char's hitbox and the coordinates given in the argument Recoil speed in x and y is calculated using the former discussed angle and the recoil magnitude attribute State is changed to recoiling. This determines many things. Event Tiks is set equals to the recoil_frames or 18 if the char must die.
def impacted(away_from, attack_dmg) @current_hp -= attack_dmg @vect_angle = Gosu.angle(away_from[0], away_from[1], @hb.x, @hb.y) @vect_v = @recoil_magnitude change_state(GameStates::States::RECOILING) @event_tiks = @current_hp > 0 ? @recoil_frames : 18 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attack_effect(attacker)\n # Clear critical flag\n self.critical = false\n # First hit detection\n hit_result = (rand(100) < attacker.hit)\n # If hit occurs\n if hit_result == true\n # Calculate basic damage\n atk = [attacker.atk - self.pdef / 2, 0].max\n self.damage = atk * (20 + attacker.str) / 20\n # Element correction\n self.damage *= elements_correct(attacker.element_set)\n self.damage /= 100\n # If damage value is strictly positive\n if self.damage > 0\n # Critical correction\n if rand(100) < 4 * attacker.dex / self.agi\n self.damage *= 2\n self.critical = true\n end\n # Guard correction\n if self.guarding?\n self.damage /= 2\n end\n end\n # Dispersion\n if self.damage.abs > 0\n amp = [self.damage.abs * 15 / 100, 1].max\n self.damage += rand(amp+1) + rand(amp+1) - amp\n end\n # Second hit detection\n eva = 8 * self.agi / attacker.dex + self.eva\n hit = self.damage < 0 ? 100 : 100 - eva\n hit = self.cant_evade? ? 100 : hit\n hit_result = (rand(100) < hit)\n end\n # If hit occurs\n if hit_result == true\n # State Removed by Shock\n remove_states_shock\n # Substract damage from HP\n self.hp -= self.damage\n # State change\n @state_changed = false\n states_plus(attacker.plus_state_set)\n states_minus(attacker.minus_state_set)\n # When missing\n else\n # Set damage to \"Miss\"\n self.damage = \"Miss\"\n # Clear critical flag\n self.critical = false\n end\n # End Method\n return true\n end", "def command_attack\n BattleManager.actor.input.set_attack\n select_target_selection\n end", "def attack_process(ch)\n # temporary variable\n ai = ch.ai\n # determine whether actor or enemy for easier reference\n if ch.is_a?(Map_Actor)\n # decide target group\n group = ((ch != $game_player && ch.restriction == 3)) ?\n ai.positive : ai.negative\n # determine range\n d = Weapons.range(ch.battler.weapon_id)\n d = 1 if d < 1\n # determine type\n type = Weapons.type(ch.battler.weapon_id)\n # determine charge\n charge = Weapons.charge(ch.battler.weapon_id)\n # determine projectile speed\n projectile_speed = Weapons.projectile_speed(ch.battler.weapon_id)\n else\n # determine target group depending on confusion\n group = (ch.restriction == 3 ? ai.positive : ai.negative)\n # determine range\n d = Enemies.range(ch.battler_id)\n d = 1 if d < 1\n # determine type\n type = Enemies.type(ch.battler_id)\n # determine charge\n charge = Enemies.charge(ch.battler_id)\n # determine charge\n charge[0] = BlizzABS::CHARGEMove if charge[0] == BlizzABS::CHARGETrigger\n # determine projectile speed\n projectile_speed = Weapons.projectile_speed(ch.battler_id)\n end\n # if item shooting type\n if type == BOW_ARROW\n # temporary variable\n ids = Weapons.consume(ch.battler.weapon_id)\n # if no more items\n if !ids.include?(ch.battler.item) ||\n $game_party.item_number(ch.battler.item) == 0\n # can't use\n return false\n end\n end\n # if not charging already\n if charge[0] != CHARGENone && !ch.charging?\n # setup charging\n ch.setup_charge(ch, charge)\n # not used yet\n return false\n end\n # create affection area depending on attack type\n case type\n when SWORD, SPEAR, FLAIL # sword attack\n # get attack affection area\n area = $BlizzABS.util.get_attack_area(ch, d, type)\n when BOOMERANG # returning projectile attack\n # decide spriteset\n spriteset = ch.is_a?(Map_Actor) ?\n BlizzABS::SPRProjWeapon + ch.battler.weapon_id.to_s :\n BlizzABS::SPRProjEnemy + ch.battler_id.to_s\n # create returning projectile\n proj = Map_Projectile.new(spriteset, ch, 0, d, projectile_speed,\n REMReturning, group)\n when BOW # projectile attack\n # decide spriteset\n spriteset = ch.is_a?(Map_Actor) ?\n BlizzABS::SPRProjWeapon + ch.battler.weapon_id.to_s :\n BlizzABS::SPRProjEnemy + ch.battler_id.to_s\n # create returning projectile\n proj = Map_Projectile.new(spriteset, ch, 0, d, projectile_speed,\n REMNormal, group)\n when BOW_ARROW # item consuming projectile\n # remove one item from inventory\n $game_party.lose_item(ch.battler.item, 1)\n # temporary variable\n item = $data_items[ch.battler.item]\n # get item explosion data\n explode = Items.type(item.id)\n # if explosion exists\n if explode[1] != EXPLNone\n # fix the missing explosion animation error\n explode[2] = 0 if explode[2] == nil\n # create projectile from exploding item with weapon attack effect\n proj = Map_Projectile.new(BlizzABS::SPRProjItem + item.id.to_s, ch,\n item.id, d, projectile_speed, REMShotItem, group, false,\n explode[1, 3])\n else\n # create projectile from item with weapon attack effect\n proj = Map_Projectile.new(BlizzABS::SPRProjItem + item.id.to_s, ch,\n item.id, d, projectile_speed, REMShotItem, group)\n end\n when SHURIKEN # self consuming weapon\n # temporary variable\n weapon = $data_weapons[ch.battler.weapon_id]\n # unequip last weapon if no more weapons in inventory\n ch.battler.equip(0, 0) if $game_party.weapon_number(weapon.id) == 0\n # remove one weapon from inventory\n $game_party.lose_weapon(weapon.id, 1)\n # self shooting weapon, create projectile from weapon\n proj = Map_Projectile.new(BlizzABS::SPRProjWeapon + weapon.id.to_s, ch,\n weapon.id, d, projectile_speed, REMShotWeapon, group)\n end\n # if projectile fired\n if proj != nil\n # add projectile to buffer\n $BlizzABS.cache.remotes.push(proj)\n # used\n return true\n end\n # iterate through all battlers\n ($game_map.battlers + $BlizzABS.battlers).each {|battler|\n # if target can be hit considering all conditions\n if battler.battler != nil && group.include?(battler.ai.group) &&\n !battler.battler.dead? && @util.intersection(area,\n Rect.new(battler.real_x / 4, battler.real_y / 4, 32, 32))\n # execute attack\n battler.attack_effect(ch, ch.battler)\n # clear damage displays\n battler.battler.damage, battler.battler.damage_pop = nil, false\n end}\n # enemies were attacked\n return true\n end", "def attack(player)\n player.receive_damage\n end", "def attack_effect_base_damage(attacker)\r\n atk = [attacker.atk - self.pdef / 2, 0].max\r\n self.damage = atk * (20 + attacker.str) / 20\r\n end", "def decide_target(char, dmg, heal, neutral, attack, defend, escape)\n # temporary variables\n x, y, ai = char.x, char.y, char.ai\n # get alignment setup\n negative, positive = ai.negative, ai.positive\n # invert setup if confused\n negative, positive = positive, negative if char.restriction == 3\n # initialize arrays\n allies, enemies = [char], []\n # if enemy\n if char.is_a?(Map_Enemy)\n # find all allies and all enemies in memory\n ai.memory.each_key {|b|\n allies.push(b) if positive.include?(b.ai.group)\n enemies.push(b) if negative.include?(b.ai.group)}\n # if actor\n elsif char.is_a?(Map_Actor)\n # find all allies and all enemies in sight\n ai.sight.each {|b|\n allies.push(b) if positive.include?(b.ai.group)\n enemies.push(b) if negative.include?(b.ai.group)}\n end\n # find all allies who need healing\n to_heal = allies.find_all {|b| b.valid? && b.battler.hp < b.battler.maxhp}\n # if decided to heal\n if (heal.size > 0 && to_heal.size > 0 && (ai.healer || rand(3) == 0) &&\n rand(5) == 0)\n # find all skills that heal all allies\n allheal = heal.find_all {|id|\n $data_skills[id].scope == 2 || $data_skills[id].scope == 4 ||\n $data_skills[id].scope == 6}\n # test again flag\n test_again = true\n # if more than 1 ally who needs healing exists and allheal skills exist\n if to_heal.size > 1 && allheal.size > 0\n # initialize data\n decided, now, new = nil, [], []\n # iterate through all all-healing skills\n allheal.each {|id|\n # fake Blizz-ABS action setup\n ai.act.set(Skills.range(id), ACTSkill, id, Skills.type(id)[0],\n ai.delay_time)\n # all allies who can be targeted by this skill\n new = to_heal.find_all {|b| $BlizzABS.can_execute?(char, b, ai.act)}\n # if not decided yet\n if decided == nil\n # decide this skill and those allies\n decided, now = id, new\n # 50% chance\n elsif rand(2) == 0\n # intialize damage counters\n dmg1 = dmg2 = 0\n # sum up all damage for last decided targets\n now.each {|b| dmg1 += b.battler.maxhp - b.battler.hp}\n # sum up all damage for new targets\n new.each {|b| dmg2 += b.battler.maxhp - b.battler.hp}\n # decide this skill if it contains battlers with more damaged HP\n decided, now = id, new if dmg2 > dmg1\n # if more battlers would be affected by this skill\n elsif new.size > now.size\n # decide this skill and those allies\n decided, now = id, new\n end}\n # if more than one battler can be healed\n if now.size > 1\n # setup Blizz-ABS action\n ai.act.set(Skills.range(decided), ACTSkill, decided,\n Skills.type(decided)[0], ai.delay_time / 2)\n # don't test for one battler\n test_again = false\n end\n end\n # if should test for one battler\n if test_again\n # find all skills that heal one ally\n oneheal = heal.find_all {|id|\n $data_skills[id].scope == 1 || $data_skills[id].scope == 3 ||\n $data_skills[id].scope == 5}\n # if any skill exists\n if oneheal.size > 0\n # decided action\n decided = oneheal[rand(oneheal.size)]\n # decided target\n ai.target = to_heal[rand(to_heal.size)]\n else\n # decided action\n decided = heal[rand(heal.size)]\n end\n # stop execution if no skill decided\n return false if decided == nil\n # setup Blizz-ABS action\n ai.act.set(Skills.range(decided), ACTSkill, decided,\n Skills.type(decided)[0], ai.delay_time / 2)\n end\n # confirm execution\n return true\n end\n # not decided to escape yet\n escaping = false\n # if able to run away\n if escape && rand(5) == 0\n # if observation attribute is active\n if ai.observe && char.restriction != 3\n # iterate through all enemies\n enemies.each {|b|\n # if actor\n if b.is_a?(Map_Actor) && ai.observation[b.battler] != nil\n # get damage per second rate\n dps = get_observation(b.battler, ai.observation[b.battler].clone)\n # 20% chance or damage per second-distance rate high enough\n if rand(5) == 0 || dps * 128 / Math.hypot(b.real_x-\n char.real_x, b.real_y-char.real_y) > char.battler.hp / 2\n # set this battler as escape reference\n ai.target = b\n # running away\n escaping = true\n # abort iteration\n break\n end\n end}\n # 20% chance\n elsif rand(5) == 0\n # initialize minimum range\n min = nil\n # iterate through all enemies\n enemies.each {|b|\n # if closer than anybody else\n if (b.is_a?(Map_Actor) && (min == nil ||\n Math.hypot(b.real_x-char.real_x, b.real_y-char.real_y) < min))\n # set this battler as escape reference\n ai.target = b\n # set new minimum range\n min = Math.hypot(b.real_x-char.real_x, b.real_y-char.real_y)\n # running away\n escaping = true\n # abort iteration\n break\n end}\n end\n end\n # if decided to escape\n if escaping\n # set AI state\n ai.state = Escape\n # set action data\n ai.act.set(ai.view_range - 1, ACTEscape, 0, 0, 80)\n # confirm execution\n return true\n end\n # not decided to defend yet\n defending = false\n # if able to defend\n if defend && rand(5) == 0\n # probability factor if higher if defensive and reset defend flag\n factor = rand(ai.defensive ? 10 : 30)\n # if decided to defend\n if char.battler.hp * 100 / char.battler.maxhp < factor\n # if observation attribute is active\n if ai.observe && char.restriction != 3\n # iterate through all enemies\n enemies.each {|b|\n # if actor\n if b.is_a?(Map_Actor) && ai.observation[b.battler] != nil\n # get damage per second rate\n dps = get_observation(b.battler,\n ai.observation[b.battler].clone)\n # 20% chance or damage per second-distance rate high enough\n if rand(5) == 0 || dps * 128 / Math.hypot(b.real_x-\n char.real_x, b.real_y-char.real_y) > char.battler.hp / 3\n # defending\n defending = true\n # abort iteration\n break\n end\n end}\n # 33% chance\n elsif enemies.size > 0 && rand(5) == 0\n # decided to defend\n defending = true\n end\n end\n end\n # if decided to defend\n if defending\n # set AI state\n ai.state = Defend\n # target the closest enemy\n ai.target = enemies.min {|a, b|\n Math.hypot(x-b.x, y-b.y) <=> Math.hypot(x-a.x, y-a.y)}\n # turn toward the target if target exists and not being force moved\n char.turn_toward(ai.target) if ai.target != nil && char.move_type != 3\n # use defend action\n char.use_defend\n # set action data\n ai.act.set(3, ACTDefend, 0, 0, rand(31) + 70)\n # confirm execution\n return true\n end\n # number of skills\n skill_number = dmg.size + heal.size + neutral.size\n # if able to attack and chosen to attack\n if attack && (skill_number == 0 || rand(skill_number) == 0)\n # if enemy\n if char.is_a?(Map_Enemy)\n # set AI state\n ai.state = Ready\n # setup Blizz-ABS action\n ai.act.set(Enemies.range(char.battler_id), ACTAttack, 0,\n Enemies.type(char.battler_id), ai.delay_time)\n # if observing attribute and not confused\n if ai.observe && char.restriction != 3\n # decide a target based upon observation experience\n observation_target(char, ai, enemies)\n end\n # if actor\n elsif char.is_a?(Map_Actor)\n # set AI state\n ai.state = Ready\n # setup Blizz-ABS action\n ai.act.set(Weapons.range(char.battler.weapon_id), ACTAttack, 0,\n Weapons.type(char.battler.weapon_id), ai.delay_time)\n end\n # if no target exists\n if ai.target == nil || !ai.target.valid?\n # get any enemy\n ai.target = enemies[rand(enemies.size)]\n end\n # confirm execution\n return true\n end\n # decide a random skill action\n decided = (dmg + neutral)[rand(dmg.size + neutral.size)]\n # if action exists\n if decided != nil\n # if observing\n if ai.observe && char.restriction != 3\n # decide a target based upon observation experience\n observation_target(char, ai, enemies)\n end\n # if no target was decided\n if ai.target == nil || !ai.target.valid?\n # if targeting enemies\n if $data_skills[decided].scope == 0 ||\n $data_skills[decided].scope == 1 ||\n $data_skills[decided].scope == 2\n # select a random enemy target\n ai.target = enemies[rand(enemies.size)]\n else\n # select a random ally target\n ai.target = allies[rand(allies.size)]\n end\n end\n end\n # stop execution if no target selected\n return false if ai.target == nil || !ai.target.valid?\n # setup Blizz-ABS action\n ai.act.set(Skills.range(decided), ACTSkill, decided,\n Skills.type(decided)[0], ai.delay_time)\n # confirm execution\n return true\n end", "def attack_effect(attacker)\r\n # Setup Attack Effect\r\n attack_effect_setup\r\n # First Hit Detection\r\n hit_result = attack_effect_first_hit_result(attacker)\r\n # If hit occurs\r\n if hit_result\r\n # Calculate Basic Damage\r\n attack_effect_base_damage(attacker)\r\n # Element Correction\r\n attack_effect_element_correction(attacker)\r\n # If damage value is strictly positive\r\n if self.damage > 0\r\n # Critical correction\r\n attack_effect_critical_correction(attacker)\r\n # Guard correction\r\n attack_effect_guard_correction\r\n end\r\n # Dispersion\r\n attack_effect_dispersion\r\n # Second Hit Detection\r\n hit_result = attack_effect_second_hit_result(attacker)\r\n end\r\n # If hit occurs\r\n if hit_result\r\n # State Removed by Shock\r\n remove_states_shock\r\n # Substract damage from HP\r\n attack_effect_damage\r\n # State change\r\n @state_changed = false\r\n states_plus(attacker.plus_state_set)\r\n states_minus(attacker.minus_state_set)\r\n # When missing\r\n else\r\n # Apply Miss Results\r\n attack_effect_miss\r\n end\r\n # End Method\r\n return true\r\n end", "def calculate_hit(move, attacker, defender)\n type = move_type(move)\n base_pwr = move_power(move)\n atk_mul = attack_multiplier(type, defender.type.prim, defender.type.sec)\n stab = (type == attacker.type.prim || type == attacker.type.sec) ? 1.5 : 1\n\n # TODO: Critical hits.\n cr = 1\n\n atk_bonus = attack_bonus(attacker.level)\n def_bonus = defense_bonus(defender.level)\n\n r = rand(85...100) / 100.0\n mod = stab * atk_mul * cr * r\n # base_dmg = (((attacker.level * 2 / 5.0 + 2) *\n # base_pwr * atk_bonus / 50 / def_bonus + 2) *\n # cr * r / 100 * stab * atk_mul)\n base_dmg = ((2 * attacker.level + 10) / 250.0 *\n (atk_bonus / def_bonus) * base_pwr + 2) * mod\n\n # TOOD: Check levitate, fire absorb, water absorb, volt absorb,\n # sap sipper, etc.\n return 0 if immune_from_ability?(move, defender)\n\n # Handle wonderguard mode.\n return 0 unless atk_mul > 1 if @modes.include?(:wonderguard)\n\n base_dmg.round\n end", "def attack_effect_damage\r\n self.hp -= self.damage\r\n end", "def hit\n self.damage = damage + 1\n check_boat\n end", "def attacks(player_to_attack)\n puts \"#{@name} attaque #{player_to_attack.name}\"\n damage = compute_damage\n puts \"infligue #{damage} point de degat\"\n puts \"\"\n player_to_attack.get_damage(damage)\n end", "def setup_damage\n return if item_in_use.nil?\n item = copy(item_in_use) \n # Copy item. In case if you want to modify anything\n \n # ----- Evaluate skill ------- #\n if @acts[1].is_a?(String) # Change formula? No prob ~\n item.damage.formula = @acts[1]\n elsif @acts[1].is_a?(Integer) # Skill link? No prob ~\n item = $data_skills[@acts[1]]\n elsif @acts[1].is_a?(Float) # Rescale damage? No prob ~\n item.damage.formula = \"(#{item.damage.formula}) * #{@acts[1]}\"\n end\n \n # ------- Check target scope ------- #\n if area_flag && target_array\n # Damage to all targets ~\n target_array.uniq.each do |target|\n get_scene.tsbs_invoke_item(target, item, self)\n # Check animation guard\n if !item.ignore_anim_guard? && item.parallel_anim?\n target.anim_guard = target.anim_guard_id\n target.anim_guard_mirror = target.flip\n end\n end\n elsif target\n # Damage to single target\n get_scene.tsbs_invoke_item(target, item, self)\n # Check animation guard\n if !item.ignore_anim_guard? && item.parallel_anim?\n target.anim_guard = target.anim_guard_id\n target.anim_guard_mirror = target.flip\n end\n end\n end", "def receive_damage\n @hit_points-= 10\n end", "def take_damage(damage)\n @hp -= damage\n @alive = (@hp > 0) ### false if hp is o or smaller\n $game_map.events[@id].animation_id = 7 ### sword animation -> change to dynamic\n @damage_num.set_visible\n @damage_num.set_damage_text(damage)\n @damage_num.update_now\n \n ### if dead, change switches so that enemy events corpse is shown\n if !@alive then\n $game_switches[21+@index] = false\n $game_switches[61+@index] = true\n end\n end", "def gotAttack(damage)\r\n @hitpoint -= damage\r\n end", "def dmg( d_type, dmg, ap, srpe_att, char_att )\n d = dmg\n\n # surprise attacks do more damage\n if srpe_att\n d = d * 1.5\n end\n\n # when you see it coming, there is a chance that you get to evade part of the damage\n if !srpe_att && (rand(100) + 1 < @c_evade)\n d = d / 1.25; # consider redesigning this feature, the original value was way to strong, temp reducing the divider\n end\n\n # modify damage based on your resistances to the different types\n case d_type\n when :standard\n d -= @c_class == 'Knight' ? 10 : 0 # Warriors get a special resistance to standard damage\n when :magic\n d -= @c_class == 'Wizard' ? 10 : 1 # Magi get a special resistance to magic damage\n when :earth\n d -= 1\n when :fire\n d -= 1\n when :water\n d -= 1\n when :wind\n d -= 1\n when :shadow\n d -= @c_class == 'Shinobi' ? 10 : 1 # Rogue get a special resistance to shadow damage\n when :ice\n d -= 1\n when :lightning\n d -= 1\n when :dark\n d -= 1\n when :light\n d -= 1\n when :psionic\n d -= 1\n else\n d -= 0\n end\n\n # modify damage based on armor worn\n if @armor == 'Leather'\n unless srpe_att # characters don't get to use armor values when surprise attacked\n d -= (2 - ap)\n end\n elsif @armor == 'Chain mail'\n unless srpe_att # characters don't get to use armor values when surprise attacked\n d -= (6 - ap)\n end\n elsif @armor == 'Full Plate'\n unless srpe_att # characters don't get to use armor values when surprise attacked\n d -= (12 - ap)\n end\n end\n\n # make sure we don't give them hp when they block it\n if d < 0\n d = 0;\n end\n\n # apply the damage\n @c_hp = @c_hp - d\n\n # display results\n if d == 0\n puts 'You suffered no damage from the attack, way to go!'\n elsif @c_hp <= 0\n @c_lvl -= 1\n puts \"You #{ @c_name } have perished. You respawn back at town square but have suffered loss in level. You are now level #{ @c_lvl }\"\n else\n puts \"You have suffered #{ d } wounds and now have #{ @c_hp } health left\"\n end\n\n # NOTE: this is becoming to painful, removing until we figure out\n # how to handle all the different combos for the counter attack\n # if @c_hp > 0 && !srpe_att && (rand(100) + 1 < @c_counter)\n # if @c_class == 'Knight' && @weapon == 'Short Sword'\n # char_att.dmg(:physical, rand(10) + 2, 0, false)\n # end\n # if @c_class == 'Knight' && @weapon == 'Longsword'\n # char_att.dmg(:physical, rand(20) + 2, 0, false)\n # end\n # if @c_class == 'Knight' && @weapon == 'Battle Axe'\n # char_att.dmg(:physical, rand(11) + 10, 0, false)\n # end\n # if @c_class == 'Wizard' && @weapon == 'Fireball'\n # char_att.dmg(:fire, rand(10) + 6, 0, false)\n # end\n # if @c_class == 'Wizard' && @weapon == 'Ice Spikes'\n # char_att.dmg(:ice, rand(10) + 6, 0, false)\n # end\n # if @c_class == 'Wizard' && @weapon == 'Crushing Grasp'\n # char_att.dmg(:magic, rand(10) + 6, 0, false)\n # end\n # if @c_class == 'Shinobi' && @weapon == 'Tanto'\n # char_att.dmg(:magic, rand(6) + 6, 6, false)\n # end\n # if @c_class == 'Shinobi' && @weapon == 'Ninjato'\n # char_att.dmg(:magic, rand(12) + 6, 3, false)\n # end\n # end\n end", "def hit( damage )\n p_up = rand( charisma )\n if p_up % 9 == 7\n @life += p_up / 4\n puts \"[#{ self.class } magick powers up #{ p_up }!]\"\n end\n @life -= damage\n puts \"[#{ self.class } has died.]\" if @life <= 0\n end", "def attacks(enemy)\n puts \"#{@name} attaque #{enemy.name}\"\n damage = compute_damage\n puts \"il lui inflige #{damage} points de dommages\"\n enemy.gets_damage(damage)\n end", "def call_ct_battle(can_escape, enemies, start_pos, end_pos, escape_pos, actors_pos, can_lose = false, troop = 1)\n set_enemies(enemies)\n return if @enemy_party.empty?\n $game_temp.battle_can_escape = can_escape\n $game_temp.battle_can_lose = can_lose\n $game_temp.lock_map_postions = true\n $game_player.straighten\n $game_temp.battle_calling = $game_temp.menu_calling = $game_temp.menu_beep = false\n $game_temp.end_pos = end_pos\n $game_temp.escape_pos = escape_pos\n $game_temp.start_pos = start_pos\n set_screen_postion(start_pos)\n set_actor_postions(actors_pos)\n set_enemy_postions\n get_end_ecape_positions(end_pos, escape_pos)\n $game_temp.battle_settings = [$game_temp.enemy_troop, troop, @end_pos, @escape_pos]\n $scene = Scene_Battle.new\n @in_ct_battle = $game_temp.hide_windows = true\n prepare_for_battle\n end", "def attack(offender, defender, fight_time)\n if defender.health > 0 && offender.is_dead == false\n defender.health = defender.health - offender.power\n if defender.health < 0\n defender.health = 0\n end\n elsif defender.health > 0 && offender.is_dead == true\n nil\n elsif\n defender.is_dead = true\n defender.health = 0\n end\n if fight_time > offender.stamina && offender.power > 1\n offender.power = offender.power - 1\n offender.is_tired = true\n end\n fighters = {offender: offender, defende: defender}\nend", "def confirm_attack\n @active_battler.current_action.set_attack\n process_action\n @windows[Win_Status].clear_dmg_preview\n if (@active_battler != nil)\n @active_battler.perf_action = true\n end\n @windows[Menu_Actor].setup(@active_battler)\n actor_menu_open\n clear_tr_sprites\n end", "def gotAttack(damage)\r\n @@probsDeflects = Array['deflect', 'deflect', 'deflect', 'deflect', 'deflect',\r\n 'deflect', 'deflect', 'deflect', 'got hit', 'got hit' ]\r\n\r\n @@probs = @@probsDeflects[rand(0..9)]\r\n if @role.upcase == \"HERO\"\r\n if @@probs == 'deflect'\r\n puts \"#{@name} deflects the attack.\"\r\n @hitpoint += damage\r\n end\r\n end\r\n @hitpoint -= damage\r\n end", "def take_damage(damage)\n @hitpoint -= damage\n end", "def execute_action_attack\n # Call a custom battle method\n ty_execute_action_attack\n # Call the original battle method if still attacking\n if @active_battler.action.kind == 0\n ty_ammo_requirements_attack\n end\n end", "def hit!(enemy)\n unless invincible?\n $window.audio_manager.play! :hurt\n hp!(0 - enemy.damage)\n invincible!(InvincibleTime)\n enemy.damage!(enemy.damage)\n end\n \n enemy.jump_back!\n end", "def setup_damage\n return unless PONY::ERRNO::check_sequence(current_act)\n target = current_action_targets\n item = @acts[1].is_a?(Numeric) ? $data_skills[@acts[1]] : @acts[1]\n temp_action = Game_Action.new(self, target, item)\n temp_aciton.reassign_item(temp_action.get_symbol_item)\n return if item.nil? || item.is_a?(Symbol)\n BattleManager.invoke_action(temp_action)\n end", "def perform_damage_effect\n end", "def perform_damage_effect\n end", "def take_damage(damage)\n damage_taken = 0\n dodge_roll = rand((self.agility + ((self.dodgeFlag && 1 || 0) * DODGE_ACTIVATE_VALUE)) .. DODGE_RANGE_UPPER)\n if !dodge_roll.between?(DODGE_RANGE_LOWER, DODGE_RANGE_UPPER)\n damage_taken = damage - (damage * (self.defense / 100.0)).to_i\n self.health -= damage_taken\n self.dodgeFlag = false;\n self.save\n end\n damage_taken\n end", "def taking_damage_action\n if @warrior.feel(:backward).empty? && @health < 10\n @warrior.walk!(:backward)\n elsif @warrior.feel.empty?\n @warrior.walk!\n elsif @warrior.feel.enemy?\n @warrior.attack!\n end\n end" ]
[ "0.54997903", "0.52660763", "0.5204878", "0.5204857", "0.5199827", "0.5167765", "0.5163949", "0.5157595", "0.5140228", "0.5104614", "0.5058402", "0.50374657", "0.5016156", "0.5015596", "0.49472263", "0.49467564", "0.4932828", "0.48924303", "0.48895365", "0.4884655", "0.4861455", "0.4845943", "0.48024854", "0.47984585", "0.47831005", "0.47787657", "0.4776789", "0.4776789", "0.47766918", "0.47716245" ]
0.7607196
0
Overrides parent class update method. This override only implements unclipping functionality. It calls basic move function. Each 4 global frames, the character attepts to unclip from other game objects. This action is not performed if the the char is either dying or attacking, or if it has invincibility frames. It subtracts event tiks. If event tiks reaches 0, the char's state changes to IDLE, unless current_hp is 0 or below, in which case the char enters dying state.
def update move if $WINDOW.global_frame_counter%4 == 0 && !(dying? || attacking?) && @inv_frames <= 0 unclip end @event_tiks -=1 unless @event_tiks <= 0 if recoiling? && @vect_v > 0 fraction_event_tiks = @event_tiks.to_f/@recoil_frames.to_f fraction_bigger_than = 1.00/3.00 if fraction_event_tiks < fraction_bigger_than @vect_v = 0 end end if @event_tiks <= 0 && @current_hp <=0 change_state(GameStates::States::DYING) @event_tiks = @dying_frames end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if idle?\n if Gosu.distance(@hb.x,@hb.y,$WINDOW.player.hb.x, $WINDOW.player.hb.y) < 150\n # If distance is 150 or less, behaviour changes to approaching\n change_state(GameStates::States::WALKING)\n @vect_v = 1\n @vect_angle = Gosu.angle(@hb.x, @hb.y, $WINDOW.player.hb.x, $WINDOW.player.hb.y)\n end\n elsif walking?\n # While walking, wolf tries to approach the main character\n @vect_angle = Gosu.angle(@hb.x, @hb.y, $WINDOW.player.hb.x, $WINDOW.player.hb.y)\n if @una_check_tiks <= 0\n # When next attack check counter reaches 0, wolf can attack.\n dieroll = Random.rand\n if dieroll <= ATTACK_PROBABILITY\n # If random is within attack probability, the wolf changes behaviour to attack\n change_state(GameStates::States::ATTACKING)\n @event_tiks =60\n @vect_v = 0\n else\n #If random is not within attack probability, next attack check counter is reset to 30.\n @una_check_tiks = 30\n end\n end\n check_change_dir\n elsif attacking?\n # If attacking, wolf waits for a little while, then charges in a straight line. Then waits a little while.\n if @event_tiks > 20\n check_change_dir\n elsif @event_tiks == 20\n @vect_angle = Gosu.angle(@hb.x, @hb.y, $WINDOW.player.hb.x, $WINDOW.player.hb.y)\n @vect_v = 3.5\n elsif @event_tiks == 10\n @venct_v = 0\n elsif @event_tiks <= 0\n change_state(GameStates::States::IDLE)\n @una_check_tiks = 100\n end\n end\n\n if normal? && $WINDOW.player.inv_frames <= 0 && !$WINDOW.player.recoiling? && @hb.check_brute_collision($WINDOW.player.hb)\n # If it connects with player, player is set to impacted.\n $WINDOW.player.impacted(@hb.center, @attack_dmg)\n end\n\n if !idle? && Gosu.distance(@hb.x,@hb.y,$WINDOW.player.hb.x, $WINDOW.player.hb.y) > 250\n #If distance surpasses 250, the wolf turns back to idle.\n change_state(GameStates:States::IDLE)\n end\n\n super\n @una_check_tiks -= 1 unless idle? || @una_check_tiks <= 0\n end", "def update\n # Branch with jumping, moving, and stopping\n if jumping?\n update_jump\n elsif moving?\n update_move\n else\n update_stop\n end\n \n # This is really the only thing that I changed in Update.\n \n # If Anime Speed has been set for Event\n if @anime_speed and @anime_speed.is_a?(Numeric)\n # Update Animations Based on Anime Speed instead of Move Speed\n anime_speed_update\n # Anime Speed Not Set, use Default Method\n else\n # This is the section that controls a Character's Animations. It\n # should be present in some form in ALL other replacements of the\n # update method. If you are attempting to Edit another script, this\n # part is what belongs in the Else Statement.\n \n # If animation count exceeds maximum value\n # * Maximum value is move speed * 1 taken from basic value 18\n if @anime_count > 18 - @move_speed * 2\n # If stop animation is OFF when stopping\n if not @step_anime and @stop_count > 0\n # Return to original pattern\n @pattern = @original_pattern\n # If stop animation is ON when moving\n else\n # Update pattern\n @pattern = (@pattern + 1) % 4\n end\n # Clear animation count\n @anime_count = 0\n end\n end\n \n # The code below here is Default and doesnt need to be changed.\n \n # If waiting\n if @wait_count > 0\n # Reduce wait count\n @wait_count -= 1\n return\n end\n # If move route is forced\n if @move_route_forcing\n # Custom move\n move_type_custom\n return\n end\n # When waiting for event execution or locked\n if @starting or lock?\n # Not moving by self\n return\n end\n # If stop count exceeds a certain value (computed from move frequency)\n if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)\n # Branch by move type\n case @move_type\n when 1 # Random\n move_type_random\n when 2 # Approach\n move_type_toward_player\n when 3 # Custom\n move_type_custom\n end\n end\n end", "def update_control\n # get pixel movement rate\n pix = $BlizzABS.pixel\n # reset move speed\n player.move_speed = player.normal_speed\n # reset spriteset name\n player.character_name = player.character_name_org\n # if allowed to change speed\n unless $game_system.map_interpreter.running? ||\n player.move_route_forcing || $game_temp.message_window_showing\n # if run button works and running\n if $game_system.running_button && Input.press?(Input::Run)\n # set running speed\n player.move_speed = Config::RUN_SPEED\n # if sneak button works and sneaking\n elsif $game_system.sneaking_button && Input.press?(Input::Sneak) ||\n Config::SNEAK_SPEED > 0 && Config::SNEAK_ON_CHARGE && player.charging?\n # set sneaking speed\n player.move_speed = Config::SNEAK_SPEED\n end\n end\n # if battler exists and either dead or select triggered\n if player.battler != nil && ($game_system.select_button &&\n Input.trigger?(Input::Select) || player.battler.dead?)\n # switch to next valid actor\n switch_leader\n end \n # setup sprite animation\n player.sprite_animation_setup\n # update action\n player.update_action\n # if allowed to turn and pressed turning button or defending\n if ((player.ai.act.defend? && player.attacked == 0) ||\n $game_system.turn_button && Input.press?(Input::Turn)) &&\n !player.moving? && !$game_system.map_interpreter.running? &&\n !player.move_route_forcing && !$game_temp.message_window_showing\n # get input depending on confusion\n input = (player.restriction == 3 ? 10 - Input.dir4 : Input.dir4)\n # depending on input turn\n case input\n when 2 then player.turn_down\n when 4 then player.turn_left\n when 6 then player.turn_right\n when 8 then player.turn_up\n end\n # updates any attacked action\n player.update_attacked\n # abort method\n return nil\n end\n # updates any attacked action\n player.update_attacked\n # if acting\n if player.in_action > 0\n # decrease action counter if in_action is greater than 0\n player.in_action -= 1 if player.in_action > 0\n # return data\n return [player.moving?, player.real_x, player.real_y]\n end\n # if allowed to move\n unless $game_system.map_interpreter.running? ||\n player.move_route_forcing || $game_temp.message_window_showing\n # if jump button was pressed and not already jumping\n if $game_system.jumping_button && Input.trigger?(Input::Jump) &&\n !player.jumping? && player.restriction < 4\n # set to jump\n @memory_jump = true\n end\n # if not moving\n unless player.moving?\n # get jumping range\n range = Config::JUMPING\n # if jumping turned on and not jumping and jumped\n if range > 0 && !player.jumping? && @memory_jump\n # if sneaking or running is possible\n if Config::RUN_SPEED > 0 || Config::SNEAK_SPEED > 0\n # get difference between current speed and normal speed\n dplus = player.move_speed - player.normal_speed\n else\n # difference is 0\n dplus = 0\n end\n # get direction\n direction = $game_system._8_way ? Input.dir8 : Input.dir4\n # set jumping direction\n x, y = Cache::DirOffsets[direction]\n # jump into direction with considering running/sneaking\n player.jump(x*range + x*dplus, y*range + y*dplus, direction)\n # if not already jumping\n elsif !player.jumping?\n # move\n move($game_system._8_way ? Input.dir8 : Input.dir4)\n # allow idle if no movement\n player.idle_allowed = !player.moving?\n end\n # not jumping anymore\n @memory_jump = false\n end\n end\n # return data\n return [player.moving?, player.real_x, player.real_y]\n end", "def update\n\t\tif @player_moved\n\t\t\t@prawn.swimming = true\n\t\telse\n\t\t\tdrift \n\t\t\t@prawn.swimming = false\n\t\tend\n\n\t\tif !@moved_y_axis && !is_plane\n\t\t\tstabilise\n\t\t\t@has_moved = true\n\t\tend\n\n\t\tcheck_bounds\n\n\t\t@prawn.update\n\t\t@player_moved = @moved_y_axis = false\n\tend", "def update\n # if not allowed to act\n if !$game_temp.in_battle || $game_player.jumping? ||\n $game_player.freeze_action || $game_player.move_route_forcing ||\n $game_player.in_action > 0 && !$game_player.ai.act.defend? ||\n !$game_player.valid?\n # freeze battle controls\n return\n end\n # stop update if defending\n return if update_defend\n # if defending before\n if $game_player.ai.act.defend?\n # override defending reset\n $game_player.ai.act.set\n # reset action\n $game_player.reset_action\n # reset sprites\n $game_player.reset_sprites\n end\n # stop update if attacking\n return if update_attack\n # stop update if using skill\n return if update_skill\n # stop update if using item\n return if update_item\n end", "def update\n\n getTimer\n\n createNPCMap(@actualChars)\n\n if ((Gosu::button_down? Gosu::KbLeft or Gosu::button_down? Gosu::GpLeft) and canMoveX?(@character.get_x)) then\n @character.move_left\n end\n if ((Gosu::button_down? Gosu::KbRight or Gosu::button_down? Gosu::GpRight) and canMoveX?(@character.get_x)) then\n @character.move_right\n end\n if ((Gosu::button_down? Gosu::KbUp or Gosu::button_down? Gosu::GpUp)) then\n @character.move_up\n end\n if ((Gosu::button_down? Gosu::KbDown or Gosu::button_down? Gosu::GpDown)) then\n @character.move_down\n end\n\n end", "def update\n super\n $game_chrono.update\n @window_gameDescription.update() unless @window_gameDescription == nil\n @inPauseMode = false\n #sleep(0.5)\n if @spriteGem1 != nil && @spriteGem1.moving && @spriteCursor1 != nil && @spriteGem2 != nil && @spriteCursor2 != nil \n update_switch2Gem()\n elsif( @spriteGems != nil ) #&& @spriteGems[6].moving )\n#~ for y in 0...BOARD_MAX_Y\n#~ #@spriteGems[y].update\n#~ # if( isUpdating == false )\n#~ # sleep(2)\n#~ # end\n#~ end\n end\n if( @isHeroAttacking == true && @HeroAttackZone != nil )\n \n if ( @HeroAttackZone.update )\n @inPauseMode = true \n #@HeroAttackZone.doAnimation( 1, false )\n # @HeroAttackZone.start_animation($data_animations[1], false)\n else\n @inPauseMode = false \n @HeroAttackZone = nil\n end \n end\n \n end", "def update\n \n unless @state == :paused\n # Update player\n # TODO externalize this part PlayerCtrl\n if @player.is_alive? or @player.resurrecting?\n @player.move_left if button_down? Gosu::Button::KbLeft or button_down? Gosu::Button::GpLeft\n @player.move_right if button_down? Gosu::Button::KbRight or button_down? Gosu::Button::GpRight\n @player.accelerate if button_down? Gosu::Button::KbUp or button_down? Gosu::Button::GpUp\n @player.brake if button_down? Gosu::Button::KbDown or button_down? Gosu::Button::GpDown\n @player.shoot if button_down? Gosu::Button::KbZ or button_down? Gosu::GpButton0\n end\n @player.update\n \n # Check touching bullets\n @bullets.reject! { |b| b.touch? @ennemies }\n @e_bullets.reject! { |b| b.touch? @player }\n \n # Update bullets and ennemies\n # Remove all objects whose update method returns false. \n @bullets.reject! { |o| o.update == false }\n @e_bullets.reject! { |o| o.update == false }\n @ennemies.reject! { |e| e.update == false }\n @bonuses.reject! { |b| b.update == false }\n @particles.reject! { |p| p.update == false }\n \n #@gl_background.scroll\n \n # Generate new ennemies\n @finished = @w_generator.update\n end\n \n end", "def update_moving(data)\n # if control update was not aborted\n if data != nil\n # get data\n moved, x, y = data\n # if moved down\n if player.real_y > y && player.real_y - $game_map.display_y > CY\n # scroll screen down\n $game_map.scroll_down(player.real_y - y)\n end\n # if moved left\n if player.real_x < x && player.real_x - $game_map.display_x < CX\n # scroll screen left\n $game_map.scroll_left(x - player.real_x)\n end\n # if moved right\n if player.real_x > x && player.real_x - $game_map.display_x > CX\n # scroll screen right\n $game_map.scroll_right(player.real_x - x)\n end\n # if moved up\n if player.real_y < y && player.real_y - $game_map.display_y < CY\n # scroll screen up\n $game_map.scroll_up(y - player.real_y)\n end\n # if not moving\n unless player.moving?\n # if last moving, not activated, not override and countdown\n if moved && !check_event_trigger_here(Cache::TouchTrigger) &&\n !($DEBUG && Input.press?(Input::CTRL)) && @encounter_count > 0\n # set battle-encounter countdown\n @encounter_count -= 2 ** (5 - $game_system.pixel_rate)\n @encounter_count = 0 if @encounter_count < 0\n end\n # if pressed C button\n if Input.trigger?(Input::C)\n # check event here\n check_event_trigger_here(Cache::PressTrigger)\n # check event there\n check_event_trigger_there(Cache::BasicTrigger)\n end\n end\n end\n # update each other actor except the player\n ($BlizzABS.battlers - [player]).each {|actor| actor.update}\n end", "def update\r\n\r\n # Left-Arrow button pressed\r\n if $window.button_down?(Gosu::KbLeft) then\r\n\r\n # Sanity check, make sure this can grab the needed tile\r\n if ![1,2].include?(get_tile_info(@player.get_x,\r\n @player.get_y,\r\n :left)) then\r\n\r\n # Call the move_left function\r\n @player.move_left\r\n\r\n end\r\n end\r\n\r\n # Right-Arrow button pressed\r\n if $window.button_down?(Gosu::KbRight) then\r\n\r\n # Sanity check, make sure this can grab the needed tile\r\n if ![1,2].include?(get_tile_info(@player.get_x,\r\n @player.get_y,\r\n :right)) then\r\n\r\n # Call the move_right function\r\n @player.move_right\r\n\r\n end \r\n end\r\n\r\n # Update the player object\r\n @player.update\r\n\r\n # Functionalize the list of entities\r\n @entities.each{|en| \r\n en.update\r\n\r\n # Compare the player coords with the entity coords, in the event\r\n # the player has reached an item / entity location\r\n dist = Gosu::distance(@player.get_x,\r\n @player.get_y(:center),\r\n en.get_x,\r\n en.get_y)\r\n\r\n # Player closely approaches an entity...\r\n if dist < 20 then\r\n\r\n # get_score() returns a -1 in the event of invulnerability\r\n if en.get_score < 0 then\r\n @player.invulnerable\r\n @entities.delete(en)\r\n\r\n # Otherwise add this to the score and remove the item from\r\n # the map\r\n else\r\n @score += en.get_score\r\n @entities.delete(en)\r\n end\r\n end\r\n }\r\n\r\n # Handle the player falling when the down sprite is being used\r\n if [0,2,4].include?(get_tile_info(@player.get_x, @player.get_y,:down)) then\r\n\r\n # Call the fall() routine\r\n @player.fall \r\n\r\n # Handle the player respawn event\r\n if get_tile_info(@player.get_x, @player.get_y,:down) == 4 then\r\n @player.respawn\r\n end\r\n\r\n # Otherwise the the acceleration back to 0, since the player has\r\n # safely hit the ground\r\n else\r\n @player.reset_acceleration\r\n end\r\n\r\n # While jumping, move the player upwards\r\n while ![0,2].include?(get_tile_info(@player.get_x,\r\n @player.get_y - 1,\r\n :down)) do\r\n\r\n # Call the move_up() function\r\n @player.move_up\r\n end\r\n\r\n # Check if the player is current jumping\r\n if @player.is_jumping? then\r\n\r\n # Determine if the up sprite is being used\r\n if get_tile_info(@player.get_x, @player.get_y,:up) != 0 then\r\n\r\n # In which case, reset the jump event, since it has\r\n # already occurred\r\n @player.reset_jump\r\n end\r\n end\r\n\r\n # Check if the player is \"down and facing right\"\r\n if get_tile_info(@player.get_x, @player.get_y,:down) == 5 then\r\n @player.slide_left\r\n\r\n # Check if the player is \"down and facing left\"\r\n elsif get_tile_info(@player.get_x, @player.get_y,:down) == 6 then\r\n @player.slide_right\r\n end\r\n\r\n # Check if the player is inside of a hidden location\r\n if in_hidden_entrance then\r\n\r\n # Initialize the hidden tiles array\r\n @hidden_tiles = []\r\n\r\n # Cycle thru the y coords ...\r\n for y in 0...@level[1].size\r\n\r\n # ... and the x coords\r\n for x in 0...@level[1][y].size\r\n\r\n # Set the current X / Y coords\r\n curx = (x * 16) + 8\r\n cury = (y * 16) + 8\r\n\r\n # Determine the distance between the player and the\r\n # current location\r\n dist = Gosu::distance(@player.get_x,\r\n @player.get_y(:center),\r\n curx,\r\n cury)\r\n\r\n # Append the current location to the hidden tiles array\r\n if dist < 32 then\r\n @hidden_tiles << [x,y]\r\n end\r\n end\r\n end\r\n\r\n # Empty the hidden tiles array since the player is not in a hidden\r\n # location\r\n else\r\n @hidden_tiles = []\r\n end\r\n\r\n # Set the camera coords\r\n @camera_x = [[@player.get_x - 320, 0].max,\r\n @level[0][0].size * 16 - 640].min\r\n\r\n @camera_y = [[@player.get_y - 240, 0].max,\r\n @level[0].size * 16 - 480].min\r\n end", "def update\n accelerate(0, 1) if should_fall?\n move\n end", "def update\n\n # Check if the player is colliding with a deadly tile. If so: Lose!\n if Position.collide?(@active_tile, @player)\n timer = Time.new\n until Time.now - timer > 3\n @player.move(:none)\n end\n Game.lose_level\n Game.lose_life\n new_level\n end\n\n # Periodically activate a deadly tile in order of decreasing rarity\n if @player.direction != :none\n if Time.now - @enemy_timer > Settings.enemy_spawn_rate\n eligable_tiles = []\n Grid.tiles.each do |tile|\n if !@target.include?(tile.contents) &&\n tile.is_deadly == false &&\n tile.contents != :empty &&\n tile.contents != \" \"\n eligable_tiles << tile.contents\n end\n end\n @enemy_tile = Grid.characters.detect{|tile| eligable_tiles.include? (tile)}\n Grid.tiles.each do |tile|\n tile.is_deadly = true if tile.contents == @enemy_tile\n end\n @enemy_timer = Time.new\n end\n end\n\n # Align the player's position to the closest tile on the grid\n if Position.within_bounds?(@player)\n @player.x, @player.y = @player.x.round_to(Settings.tile_size), @player.y.round_to(Settings.tile_size)\n end\n\n # Wrap the player around the screen if they reach the edge\n Position.wrap(@player)\n\n # Respond to Keypresses\n if button_down? KbEscape\n close\n puts \"You reached level #{Game.current_level}. Goodbye!\"\n exit\n end\n Moving.parts.each {|part| part.move :none if button_down? KbSpace}\n @player.move(:left) if button_down?(KbLeft) && Position.within_bounds?(@player) && (@player.direction != :right)\n @player.move(:right) if button_down?(KbRight) && Position.within_bounds?(@player) && (@player.direction != :left)\n @player.move(:up) if button_down?(KbUp) && Position.within_bounds?(@player) && (@player.direction != :down)\n @player.move(:down) if button_down?(KbDown) && Position.within_bounds?(@player) && (@player.direction != :up)\n\n # Move all the movable objects in the game\n @player.move(@player.direction)\n Moving.all_move\n \n # Update the player's location on the grid\n if Position.within_bounds?(@player)\n @active_tile = Grid.tiles\n .find {|tile| tile.x == @player.x\n .round_to(Settings.tile_size) && tile.y == @player.y\n .round_to(Settings.tile_size)}\n end\n\n # Have the invisible spacer tile track the player's position\n @head.x, @head.y, @head.direction = @player.path.last[0], @player.path.last[1], @player.path.last[2] \n \n # Update all the tail sections so the previous location of the section in front\n # becomes their current location\n Moving.parts.each_with_index do |section, index|\n section.path << [section.x.round_to(Settings.tile_size), section.y.round_to(Settings.tile_size), section.direction]\n leader = Moving.parts[index-1].path.last if index > 0\n section.x, section.y, section.direction = leader[0], leader[1], leader[2] if index > 0\n section.path.drop(1) if section.path.size > @message.size + 1\n end\n \n # If the player moves over a target tile create a new tail section\n if @active_tile.is_edible\n lastpath = Moving.parts.last.path.last\n image = Image.from_text(@active_tile.contents, Settings.tile_size, options={font: Settings.font, bold: true})\n Tail.new(lastpath[0], lastpath[1], lastpath[2], image)\n @completed << @active_tile.contents.to_s\n Grid.subtract_character(@active_tile.contents)\n @active_tile.contents = :empty\n @target = @target.drop(1)\n Grid.tiles.each {|tile| tile.is_edible = false}\n end\n\n # Set the target letter\n Grid.tiles.each {|tile| tile.is_edible = true if tile.contents == @target[0]}\n\n # Check if the player has collected all the target letters and in the case that\n # they have, check if they have arrived at the mailbox. If so: Level up!\n if @message.join(\"\") == @completed\n if @active_tile.y.between?(Settings.margin_bottom + Settings.tile_size / 2, Settings.margin_bottom + Settings.tile_size * 2) &&\n @active_tile.x.between?(Settings.margin_left, Settings.margin_left + Settings.tile_size)\n @player.move(:none)\n sleep 2\n Game.add_life\n new_level\n end\n end\n end", "def update\n # increase frame counter\n @time += 1\n # update movement\n update_move\n # update input\n update_input\n # update commands\n update_command\n # update character\n update_character\n # end combo if reached end of commands\n @ended = true if @commands.size == 0\n end", "def update\n if @board.recheck\n #@board.compact_pieces\n @board.clear_matches\n elsif @board.pieces_removed != 0\n adjust_score(@board.pieces_removed)\n @board.pieces_removed = 0 \n #end game if no legal moves left \n if not @board.any_moves?\n stop_anim\n stop_update\n stop_timer\n @game_over = true\n draw\n $app.alert(\"Game over: no more moves\")\n end \n end\n #end game if out of time\n if @time_remaining && (@time_remaining < 0)\n stop_anim\n stop_update\n stop_timer\n @game_over = true\n draw\n $app.alert(\"Game over: out of time.\") \n end\n end", "def update\n if @last_move != nil\n if button_down?(Gosu::KbRight) || button_down?(Gosu::KbLeft) || button_down?(Gosu::KbUp) || button_down?(Gosu::KbDown)\n if Gosu::milliseconds - @last_move_time > 90\n @last_move_time = Gosu::milliseconds\n @game.state.command(@last_move)\n end\n else\n @last_move = nil\n end\n end\n end", "def update args\n\n # Keep the backdrop scrolling, always...\n @backdropl_spr.source_x += 2\n if @backdropl_spr.source_x > BACKDROP_WIDTH \n @backdropl_spr.source_x = 0\n end\n @backdropr_spr.source_x = @backdropl_spr.source_x\n\n\n # Check to see if the player needs creating\n if @player.nil? && @lives.positive?\n @player = Player.new args\n end\n\n\n # Also, spawn any enemies that are due\n while ( @enemy_idx < @@enemies.length ) && ( args.state.tick_count >= ( @epoch + @@enemies[@enemy_idx][:spawn] ) ) do\n @enemy << Enemy.new( @@enemies[@enemy_idx] )\n @enemy_idx += 1\n end\n\n\n # User input; see if we're moving first off\n horizontal = 0\n vertical = 0\n if args.inputs.keyboard.key_held.up || args.inputs.keyboard.key_held.w || args.inputs.controller_one.key_held.up\n vertical = 1\n end\n if args.inputs.keyboard.key_held.down || args.inputs.keyboard.key_held.s || args.inputs.controller_one.key_held.down\n vertical = -1\n end\n if args.inputs.keyboard.key_held.right || args.inputs.keyboard.key_held.d || args.inputs.controller_one.key_held.right\n horizontal = 1\n end\n if args.inputs.keyboard.key_held.left || args.inputs.keyboard.key_held.a || args.inputs.controller_one.key_held.left\n horizontal = -1\n end\n @player.move horizontal, vertical\n\n\n # If the player is firing, fire the current weapon they have\n if @player_bullets.empty? && ( args.inputs.keyboard.key_held.space || args.inputs.controller_one.key_held.a )\n @player_bullets.concat( @player.fire )\n end\n\n\n # Update the position of any player bullets\n @player_bullets.each { |bullet| bullet.update args }\n\n\n # Allow each enemy to move\n @enemy.each { |ship| ship.move }\n\n\n # Decide if any enemies get to shoot\n\n\n # And update all of their bullets, too\n @enemy_bullets.each { |bullet| bullet.update args }\n\n\n # And purge any bullets now out of scope\n @player_bullets.delete_if { |bullet| bullet.outofbounds? args.grid }\n @enemy_bullets.delete_if { |bullet| bullet.outofbounds? args.grid }\n\n \n # Check to see if any player bullets collided with any enemies\n @player_bullets.each do | bullet |\n\n # Check against each enemy\n @enemy.each do | ship |\n if bullet.collides? ship\n args.outputs.debug << [ 100, 100, \"HIT!\", 5, 1, 255, 0, 0 ].label\n end\n end\n \n end\n\n\n # Everything is fine, stick with this world!\n true\n\n end", "def update\n moving = moving?\n # Executes the animation when turning\n if @turncount\n @turncount -= 1\n if @turncount == 0\n @turncount = nil\n @sprite.src_rect.x += @sprite.src_rect.width\n @sprite.src_rect.x = 0 if @sprite.src_rect.x >= @sprite.bitmap.width\n end\n end\n @sprite.z = @sprite.y + 31\n # Executes the animation when moving against an impassable tile\n if @fake_anim\n @fake_anim -= 1 if @fake_anim > 0\n if @fake_anim == 0\n @sprite.src_rect.x += @sprite.src_rect.width\n play = false\n if @sprite.src_rect.x.to_f / @sprite.bitmap.width * 4 % 2 == 1\n play = true\n end\n @sprite.src_rect.x = 0 if @sprite.src_rect.x >= @sprite.bitmap.width\n if @stop_fake_anim\n @fake_anim = nil\n @stop_fake_anim = false\n @sprite.src_rect.x += @sprite.src_rect.width if (@sprite.src_rect.x.to_f / @sprite.bitmap.width * 4) % 2 != 0\n @sprite.src_rect.x = 0 if @sprite.src_rect.x >= @sprite.bitmap.width\n else\n @fake_anim = 16\n Audio.se_play(\"audio/se/wallbump.wav\") if play\n end\n end\n end\n # Starts and stops the slower animation when moving against an impasasble tile\n if @oldfake_move != @game_player.fake_move\n if !@game_player.fake_move\n @stop_fake_anim = true\n else\n @fake_anim = 0\n @stop_fake_anim = false\n end\n end\n # Changes the sprite's bitmap if the player's graphic changed\n if @game_player.graphic_name != @oldgraphic\n frame_x = @sprite.src_rect.x.to_f / @sprite.bitmap.width * 4\n frame_y = @sprite.src_rect.y.to_f / @sprite.bitmap.height * 4\n @sprite.set_bitmap(\"gfx/characters/\" + @game_player.graphic_name)\n @sprite.src_rect.width = @sprite.bitmap.width / 4\n @sprite.src_rect.height = @sprite.bitmap.height / 4\n @sprite.ox = @sprite.src_rect.width / 2\n @sprite.oy = @sprite.src_rect.height\n @sprite.src_rect.x = frame_x * @sprite.src_rect.width\n @sprite.src_rect.y = frame_y * @sprite.src_rect.height\n end\n # Add horizontal movement to the move queue\n if @game_player.global_x != @oldx && !@skip_movement\n @xdist << 32 * (@game_player.global_x - @oldx)\n @xtrav << 0\n @xloc << @game_player.global_x\n h = {}\n if @xstart[0]\n @xstart.last.each_key { |k| h[k] = @xstart.last[k] - @xdist.last }\n else\n $visuals.maps.each_key { |k| h[k] = $visuals.maps[k].real_x }\n end\n @xstart << h\n anims = []\n pos = @game_player.global_x - @oldx > 0\n aframes = 2\n (aframes * (@game_player.global_x - @oldx).abs).times { |i| anims << (32.0 / aframes) * i * (pos ? 1 : -1) }\n @anim << anims\n if @xtrav.size == 1\n @sprite.src_rect.x += @sprite.src_rect.width if (@sprite.src_rect.x.to_f / @sprite.bitmap.width * 4) % 2 != 0\n @sprite.src_rect.x = 0 if @sprite.src_rect.x >= @sprite.bitmap.width\n end\n @fake_anim = nil\n @stop_fake_anim = false\n end\n # Add vertical movement to the move queue\n if @game_player.global_y != @oldy && !@skip_movement\n @ydist << 32 * (@game_player.global_y - @oldy)\n @ytrav << 0\n @yloc << @game_player.global_y\n h = {}\n if @ystart[0]\n @ystart.last.each_key { |k| h[k] = @ystart.last[k] - @ydist.last }\n else\n $visuals.maps.each_key { |k| h[k] = $visuals.maps[k].real_y }\n end\n @ystart << h\n anims = []\n pos = @game_player.global_y - @oldy > 0\n aframes = 2\n (aframes * (@game_player.global_y - @oldy).abs).times { |i| anims << (32.0 / aframes) * i * (pos ? 1 : -1) }\n @anim << anims\n if @ytrav.size == 1\n @sprite.src_rect.x += @sprite.src_rect.width if (@sprite.src_rect.x.to_f / @sprite.bitmap.width * 4) % 2 != 0\n @sprite.src_rect.x = 0 if @sprite.src_rect.x >= @sprite.bitmap.width\n end\n @fake_anim = nil\n @stop_fake_anim = false\n end\n # Executes the horizontal movement\n if @xtrav[0] && @xdist[0]\n if @xtrav[0].abs < @xdist[0].abs\n dist = @game_player.speed * (@xdist[0] < 0 ? -1 : 1)\n oldtrav = @xtrav[0]\n @xtrav[0] += dist\n @xtrav[0] = @xdist[0] < 0 ? [@xtrav[0], @xdist[0]].max : [@xtrav[0], @xdist[0]].min\n if @anim[0].size > 0 && (@xdist[0] > 0 && @xtrav[0] > @anim[0][0] || @xdist[0] < 0 && @xtrav[0] < @anim[0][0])\n @sprite.src_rect.x += @sprite.src_rect.width\n @sprite.src_rect.x = 0 if @sprite.src_rect.x >= @sprite.bitmap.width\n @anim[0].delete_at(0)\n end\n $visuals.maps.values.each { |m| m.real_x = @xstart[0][m.id] - @xtrav[0] }\n $visuals.map_renderer.move_x(@xtrav[0] - oldtrav)\n else # Movement completed\n @xtrav.delete_at(0)\n @xdist.delete_at(0)\n @xstart.delete_at(0)\n x = @xloc[0]\n y = @yloc[0] || @game_player.global_y\n SystemEvent.trigger(:taken_step, *$game.map.global_to_local(x, y))\n @xloc.delete_at(0)\n @anim.delete_at(0)\n end\n end\n # Executes the vertical movement\n if @ytrav[0] && @ydist[0]\n if @ytrav[0].abs < @ydist[0].abs\n dist = @game_player.speed * (@ydist[0] < 0 ? -1 : 1)\n oldtrav = @ytrav[0]\n @ytrav[0] += dist\n @ytrav[0] = @ydist[0] < 0 ? [@ytrav[0], @ydist[0]].max : [@ytrav[0], @ydist[0]].min\n if @anim[0].size > 0 && (@ydist[0] > 0 && @ytrav[0] > @anim[0][0] || @ydist[0] < 0 && @ytrav[0] < @anim[0][0])\n @sprite.src_rect.x += @sprite.src_rect.width\n @sprite.src_rect.x = 0 if @sprite.src_rect.x >= @sprite.bitmap.width\n @anim[0].delete_at(0)\n end\n $visuals.maps.values.each { |m| m.real_y = @ystart[0][m.id] - @ytrav[0] }\n $visuals.map_renderer.move_y(@ytrav[0] - oldtrav)\n else\n @ytrav.delete_at(0)\n @ydist.delete_at(0)\n @ystart.delete_at(0)\n x = @xloc[0] || @game_player.global_x\n y = @yloc[0]\n SystemEvent.trigger(:taken_step, *$game.map.global_to_local(x, y))\n @yloc.delete_at(0)\n @anim.delete_at(0)\n end\n end\n # Stores old values for comparison in the next #update call\n @oldx = @game_player.global_x\n @oldy = @game_player.global_y\n @oldgraphic = @game_player.graphic_name\n @oldfake_move = @game_player.fake_move\n @skip_movement = false if @skip_movement\n end", "def update\n super\n if BattleManager.in_turn?\n process_event\n process_action\n end\n BattleManager.judge_win_loss unless BattleManager.victory_phase?\n if BattleManager.victory_phase?\n if @victory_score.done and @victory_score.active\n sfx = CP::VICTORY::IMAGE_SFX\n vol = CP::VICTORY::SFX_VOL\n pit = CP::VICTORY::SFX_PIT\n RPG::SE.new(sfx, vol, pit).play unless sfx.nil?\n @victory_score.active = false\n @victory_item.active = true\n end\n end\n end", "def update\n space.fall(self) if should_fall?\n move\n end", "def update\n if dash?\n unless $game_temp.syn_state == \"idle\"\n set_graphic(@character_name + StandWalkRun::Run_sprite_suffix) if StandWalkRun::Use_run_sprite\n @run_points -= 1\n @move_speed = StandWalkRun::Run_speed\n syn_player_update\n end\n else\n @move_speed = StandWalkRun::Walk_speed\n $game_temp.syn_state == \"\"\n syn_player_update\n end\n end", "def update\n if !@parent.active?\n @pauseScreen.applyOn(@parent)\n end\n if @game.currentGuess.grid==@game.correction && @tutoEnd\n @victoryScreen.applyOn(@parent,0,true)\n @game.delete_observers\n end\n end", "def class_update\n if can_drop_bomb? and closest_target\n drop_bomb if on_top_of?(closest_target)\n if facing_right_of?(closest_target)\n turn_left\n end\n if facing_left_of?(closest_target)\n turn_right\n end\n end\n go_forward\n loop_position\n end", "def update_battler_pose\n if POSE_HASH[\"Walk\"].include?(@pose+1) \n @character.set_pose('wait') unless @character.moving?\n elsif !LOOP_TYPE.include?(@pose+1)\n @character.set_pose('wait')\n elsif POSE_HASH[\"Dead\"].include?(@pose+1) \n if !@character.dead?\n @character.set_pose('wait')\n @character.collapsed = false\n end\n elsif POSE_HASH[\"Near Death\"].include?(@pose+1) and \n get_near_death_value <= (@character.hp_rate)\n @character.set_pose('wait')\n end\n # Set defend pose if current_actions is defend type\n if @character.pose? == POSE_HASH[\"Wait\"] and @character.guard?\n @character.set_pose(\"defend\")\n end\n nd_val = get_near_death_value\n # If waiting or defending, but near death, set near death pose\n if (POSE_HASH[\"Wait\"]+ POSE_HASH[\"Defend\"]).include?(@character.pose?+1) and\n nd_val > (@character.hp_rate)\n if !@character.death_state?\n @character.set_pose(\"danger\") \n elsif @character.death_state? && !@character.will_collapse?\n @character.set_pose(\"collapse\") \n end\n end\n \n if (bat.result != nil)\n #damage showing??\n if bat.result.hp_damage > 0 || bat.result.mp_damage > 0\n #set pain pose\n @character.set_pose(\"pain\")\n elsif bat.result.hp_damage < 0 || bat.result.mp_damage < 0\n #set heal pose\n @character.set_pose(\"heal\")\n end\n end\n # Update pose variable\n if @pose != @character.pose?\n @pose = @character.pose?\n @pose_started = false\n update_frame_index_array #for pose change\n end\n #--------------------------------------------------------------\n # Get frame index\n #--------------------------------------------------------------\n if !@pose_started\n update_sound_association\n @pose_started = true\n end\n end", "def update\n super\n if @_whiten_duration > 0\n @_whiten_duration -= 1\n self.color.alpha = 128 - (16 - @_whiten_duration) * 10\n end\n if @_appear_duration > 0\n @_appear_duration -= 1\n self.opacity = (16 - @_appear_duration) * 16\n end\n if @_escape_duration > 0\n @_escape_duration -= 1\n self.opacity = 256 - (32 - @_escape_duration) * 10\n end\n if @_collapse_duration > 0\n @_collapse_duration -= 1\n self.opacity = 256 - (48 - @_collapse_duration) * 6\n end\n if @_damage_duration > 0\n @_damage_duration -= 1\n case @_damage_duration\n when 38..39\n @_damage_sprite.y -= 4\n when 36..37\n @_damage_sprite.y -= 2\n when 34..35\n @_damage_sprite.y += 2\n when 28..33\n @_damage_sprite.y += 4\n end\n @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32\n if @_damage_duration == 0\n dispose_damage\n end\n end\n if @_animation != nil and (Graphics.frame_count % 2 == 0)\n @_animation_duration -= 1\n update_animation\n end\n if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)\n update_loop_animation\n @_loop_animation_index += 1\n @_loop_animation_index %= @_loop_animation.frame_max\n end\n if @_blink\n @_blink_count = (@_blink_count + 1) % 32\n if @_blink_count < 16\n alpha = (16 - @_blink_count) * 6\n else\n alpha = (@_blink_count - 16) * 6\n end\n self.color.set(255, 255, 255, alpha)\n end\n @@_animations.clear\n end", "def update\r\n super if @_animation || @_loop_animation\r\n # Check if the graphic info where updated\r\n update_graphics if @character_name != @character.character_name || @tile_id != @character.tile_id\r\n\r\n return unless update_position\r\n\r\n update_pattern if @tile_id == 0\r\n\r\n self.bush_depth = @character.bush_depth\r\n self.opacity = (@character.transparent ? 0 : @character.opacity)\r\n\r\n update_load_animation if @character.animation_id != 0\r\n update_bush_depth if @bush_depth > 0\r\n update_shadow if @shadow\r\n end", "def update args\n\n\t\t# Normalise the mouse position to the board origin\n\t\tmouse_x = ( ( args.inputs.mouse.x - @board_x ) / @cell_size ).floor\n\t\tmouse_y = ( ( args.inputs.mouse.y - @board_y ) / @cell_size ).floor\n\n\t\t# Handle if there's been a click, if we're still playing\n\t\tif !@victorious && ( @burniation == -1 ) && args.inputs.mouse.click\n\n\t\t\t# Save me some typing later on... ;-)\n\t\t\tcell_idx = (mouse_y*@width) + mouse_x\n\n\t\t\t# The user can do one of three things; click left, click right,\n\t\t\t# or click both. Somwhow we have to handle all of this!\n\t\t\tif mouse_x.between?( 0, @width-1 ) && mouse_y.between?( 0, @height-1 ) && args.inputs.mouse.button_left && args.inputs.mouse.button_right\n\n\t\t\t\t# Clear around an already-cleared cell\n\t\t\t\tif @cell_status[cell_idx] == :status_revealed\n\t\t\t\t\tuncover mouse_y, mouse_x, true\n\t\t\t\tend\n\n\t\t\t# If the user wants to add a gold pile to a covered cell, that's easy\n\t\t\telsif args.inputs.mouse.button_right\n\n\t\t\t\t# Needs to be on the board, and over a covered cell\n\t\t\t\tif mouse_x.between?( 0, @width-1 ) && mouse_y.between?( 0, @height-1 ) && @cell_status[cell_idx] != :status_revealed\n\n\t\t\t\t\t# We maintain a list of gold pile co-ordinates, and just toggle\n\t\t\t\t\t@cell_status[cell_idx] = ( @cell_status[cell_idx] == :status_gold ) ? :status_covered : :status_gold\n\n\t\t\t\tend\n\n\t\t\t# If the user clicks on the board, work out where.\n\t\t\telsif args.inputs.mouse.button_left\n\n\t\t\t\t# Obviously can only act if they're over the board\n\t\t\t\tif mouse_x.between?( 0, @width-1 ) && mouse_y.between?( 0, @height-1 )\n\n\t\t\t\t\t# If this is the first cell, spawn dragons!\n\t\t\t\t\tif !@spawned\n\t\t\t\t\t\tspawn_dragons mouse_y, mouse_x\n\t\t\t\t\tend\n\n\t\t\t\t\t# And then simply uncover the cell here\n\t\t\t\t\tuncover mouse_y, mouse_x\n\n\t\t\t\tend\n\n\t\t\tend\n\n\t\t\t# Redraw the board\n\t\t\trender_board\n\n\t\tend\n\n\n\t\t# Check to see if they clicked on the restart button instead\n\t\tif args.inputs.mouse.x.between?( @label_x, @label_x + @label_width ) &&\n\t\t args.inputs.mouse.y.between?( @label_restart_y, @label_restart_y + @size_restart.y )\n\n\t\t\t# If the mouse is clicked down, we've clicked the button\n\t\t \tif args.inputs.mouse.down\n\t\t \t\t@restart_clicked = true\n\t\t \tend\n\n\t\t \tif @restart_clicked && args.inputs.mouse.up\n\t\t \t\t@restart_clicked = false\n\t\t \t\tsize\n\t\t \t\trender_board\n\t\t \tend\n\n\t\tend\n\n\t\t# Now check for end conditions; have we flagged all the dragons we seek?\n\t\tif ( @spawned ) && ( !@victorious) && ( @burniation == -1 ) &&\n\t\t ( @cell_status.count( :status_gold ) == @dragon_count )\n\n\t\t\t# Then automagically reveal all non-flagged cells\n\t\t\t@end_tick = args.tick_count\n\t\t\t@victorious = true\n\t\t\t@cell_status.map! { |cell|\n\t\t\t\tcell == :status_covered ? :status_revealed : cell\n\t\t\t}\n\n\t\t\t# Redraw the board\n\t\t\trender_board\n\n\t\tend\n\n\t\t# Have we revealed a dragon?!\n\t\tif @burniation == -1\n\t\t\t@dragons.each_with_index { |dragon, index|\n\t\t\t\tif ( dragon == DRAGON ) && ( @cell_status[index] == :status_revealed )\n\t\t\t\t\t@burniation = index\n\t\t\t\t\t@victorious = false\n\t\t\t\t\t@end_tick = args.tick_count\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\n\tend", "def on_input\n @movement.each do |entity|\n entity[:movement]= nil\n end\n\n @player[:action]= case @window.active_input\n when \"h\" then [:move, Vector[-1, 0]]\n when \"j\" then [:move, Vector[ 0, 1]]\n when \"k\" then [:move, Vector[ 0, -1]]\n when \"l\" then [:move, Vector[ 1, 0]]\n when \"y\" then [:move, Vector[-1, -1]]\n when \"b\" then [:move, Vector[-1, 1]]\n when \"u\" then [:move, Vector[ 1, -1]]\n when \"n\" then [:move, Vector[ 1, 1]]\n when \"g\" then [:draw_card]\n when \"f\" then [:play_weapon]\n when \"d\" then [:play_spell]\n when \"s\" then [:play_item]\n when \"a\" then [:replace_item]\n when \"q\" then throw(:game_end)\n else\n return\n end\n\n @ai_method.each do |entity|\n entity[:action] = self.send(entity[:ai_method], entity)\n end\n\n @action.each do |entity|\n action, *args = entity[:action]\n next if action.nil?\n\n self.send(action, entity, *args)\n entity[:action]= nil\n end\n\n @movement.each do |entity|\n next if entity[:movement].nil?\n\n oldpos = entity[:position]\n newpos = entity[:position] + entity[:movement]\n\n next if out_of_bounds?(newpos)\n\n entities_at_pos = @map[:index][newpos]\n obstructed = entities_at_pos.any? do |entity|\n entity[:obstructing] == true\n end\n next if obstructed\n\n b = entity[:position]\n m = entity[:movement] / 5.0\n points = 6.times.map { |t| (b + (m*t)) }\n\n entity[:position]= newpos\n entity[:movement]= nil\n entity[:tween_points]= points\n @map[:index][oldpos].delete(entity)\n @map[:index][newpos].push(entity)\n end\n\n @animating = true\n end", "def update\n\n #Print player current life and life total to formatted string\n @life_text.text = sprintf(\"%03d/%03d\", @player.health, 100)\n\n #Print rubies gathered and rubies total to formatted string\n @score_text.text = sprintf(\"%03d/%03d\", @player.rubies_gathered, @rubies_total)\n\n #Victory! Stop timers\n if @player.state == :won then\n stop_timers()\n end\n\n #Print time limit and kill player if time has run out\n if @time_limit <= 0 && @player.state != :dead\n stop_timers()\n @player.take_damage(100)\n else\n #Print time remaining\n @time_text.text = sprintf(\"%02d:%02d\", @time_limit/60, @time_limit - (@time_limit/60)*60)\n end\n\n end", "def input_update_movement_controls\n if $program.holding?(:alt)\n speed = @speed / 2.0\n elsif $program.holding?(:shift) && $program.holding?(:ctrl)\n speed = @speed * 10\n elsif $program.holding?(:shift) || $program.holding?(:ctrl)\n speed = @speed * 4\n else\n speed = @speed\n end\n #--------------------------------------\n # Left Right X axis, Camera Position\n if $program.holding?(:move_left)\n @z -= speed\n elsif $program.holding?(:move_right)\n @z += speed\n #--------------------------------------\n # Up Down Y axis, Camera Position\n elsif $program.holding?(:move_up)\n @x -= speed\n elsif $program.holding?(:move_down)\n @x += speed\n #--------------------------------------\n # Vertical Hight change, Camera Position\n # more of a 'turn' then a straif type movment...\n elsif $program.holding?(:move_jump)\n @y -= speed\n elsif $program.holding?(:move_crouch)\n @y += speed\n #--------------------------------------\n end\n end", "def update_one_player\n # if moving up\n if Input.press?(Input::UP)\n self.y -= 4 unless self.y <= 0\n end\n # if moving down\n if Input.press?(Input::DOWN)\n self.y += 4 unless self.ey >= 480\n end\n end" ]
[ "0.67446184", "0.62284464", "0.62221855", "0.6132903", "0.6115018", "0.6105459", "0.60806507", "0.6061137", "0.60456353", "0.6041559", "0.60351086", "0.59274536", "0.5920768", "0.58887434", "0.58744407", "0.5837045", "0.5804349", "0.57737523", "0.5771884", "0.57691765", "0.57534826", "0.57258236", "0.5709689", "0.5703155", "0.5678456", "0.5663363", "0.5649319", "0.5635566", "0.56169915", "0.561223" ]
0.7588233
0
Main movement method. It uses velocity attributes to determine whether the char can move in both axes. Changes the position of the hitbox in x and y if it can.
def move if @vect_acc > 0 || @vect_acc < 0 if (@vect_acc > 0 && @vect_v < @max_v) || (@vect_acc < 0 && @vect_v > @max_v) @vect_v += @vect_acc else @vect_v = @max_v @vect_acc = 0 end end vel_x = Gosu.offset_x(@vect_angle, @vect_v) vel_y = Gosu.offset_y(@vect_angle, @vect_v) can_move_x = true can_move_y = true new_hitbox = HitBox.new(@hb.x+vel_x, @hb.y, @hb.w, @hb.h) $WINDOW.current_map.solid_tiles.each do |tile| if tile.hb.check_brute_collision(new_hitbox) can_move_x = false end end new_hitbox = HitBox.new(@hb.x, @hb.y+vel_y, @hb.w, @hb.h) $WINDOW.current_map.solid_tiles.each do |tile| if tile.hb.check_brute_collision(new_hitbox) can_move_y = false end end @hb.y += vel_y if can_move_x || @floater @hb.x += vel_x if can_move_y || @floater end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move\n # Stores change in x and y position based off of vel and current x,y\n newX = @x + @vel_x\n newY = @y + @vel_y\n # Prevents ship from exiting bounds in x along the ship's edge\n if newX >= @image.width and newX <= @window.width-@image.width then\n @x += @vel_x\n end\n # Prevents ship from exiting bounds in y along the ship's edge\n if newY >= @image.height and newY <= @window.height-@image.height then\n @y += @vel_y\n end\n # Slows down the ship if no new input is given\n # Lower values for tighter controls\n @vel_x *= 0.50\n @vel_y *= 0.50\n end", "def move\r\n # Move bullet fired by the Spaceship up the screen \r\n if @type == 'good'\r\n @y -= @SPEED\r\n # Move bullet fired by the Aliens down the screen \r\n elsif @type == 'evil'\r\n @y += @SPEED\r\n end\r\n end", "def move\n #we're modifying the ship's coordinates based on the velocity calculated in the accelerate method (which is called when we hit 'Up')\n @x += @velocity_x\n @y += @velocity_y\n #we use these to slow down the speed, acting like a friction\n #calculates the rate of acceleration \n @velocity_x *= FRICTION\n @velocity_y *= FRICTION\n # we add conditionals to delimt the edge of the window\n if @x > @window.width - @radius\n @velocity_x = 0\n @x = @window.width - @radius \n end\n if @x < @radius\n @velocity_x = 0\n @x = @radius\n end\n if @y > @window.height - @radius\n @velocity_y = 0\n @y = @window.height - @radius\n end\n end", "def move\n move_by get_incremental_position_for_velocity if (any_velocity?)\n decrease_velocity\n @has_increased_velocity_for = {\n x: false,\n y: false\n }\n @velocity_deltatime.update\n end", "def move\n if $window.button_down?(Gosu::KbD)\n @facing = :right\n @x += speed unless out_of_bounds?(@x + speed, @y)\n end\n \n if $window.button_down?(Gosu::KbA)\n @facing = :left\n @x -= speed unless out_of_bounds?(@x - speed, @y)\n end\n \n if $window.button_down?(Gosu::KbW)\n @facing = :up\n @y -= speed unless out_of_bounds?(@x, @y - speed)\n end\n \n if $window.button_down?(Gosu::KbS)\n @facing = :down\n @y += speed unless out_of_bounds?(@x, @y + speed)\n end\n \n sprinting?\n end", "def move\n if @x + @x_vel < 0\n net_move = (-2 * @x) - @x_vel\n @x += net_move\n @truex += net_move\n @x_vel = -@x_vel\n elsif @x + @x_vel > (1280 - @w)\n net_move = (2 * (1280 - @w - @x)) - @x_vel \n @x += net_move\n @truex += net_move\n @x_vel = -@x_vel\n else\n @truex += @x_vel\n @x += @x_vel\n end\n\n if @y + @y_vel < 0\n net_move = (-2 * @y) - @y_vel\n @y += net_move\n @truey += net_move\n @y_vel = -@y_vel\n elsif @y + @y_vel > (720 - @h)\n net_move = (2 * (720 - @h - @y)) - @y_vel \n @y += net_move\n @truey += net_move\n @y_vel = -@y_vel\n else\n @truey += @y_vel\n @y += @y_vel\n end\n end", "def move\n self.speed += random_vector(0.5)\n self.position.x -= window.current_speed/4\n bounce_off_border_y\n on_hitting_x { destroy!; return }\n end", "def update\n\n getTimer\n\n createNPCMap(@actualChars)\n\n if ((Gosu::button_down? Gosu::KbLeft or Gosu::button_down? Gosu::GpLeft) and canMoveX?(@character.get_x)) then\n @character.move_left\n end\n if ((Gosu::button_down? Gosu::KbRight or Gosu::button_down? Gosu::GpRight) and canMoveX?(@character.get_x)) then\n @character.move_right\n end\n if ((Gosu::button_down? Gosu::KbUp or Gosu::button_down? Gosu::GpUp)) then\n @character.move_up\n end\n if ((Gosu::button_down? Gosu::KbDown or Gosu::button_down? Gosu::GpDown)) then\n @character.move_down\n end\n\n end", "def move!\n\t\tbounce! until !will_bounce? #TODO add surroundedness checking\n\t\t@x += @@target_coords[@direction][:dx]\n\t\t@y += @@target_coords[@direction][:dy]\n\tend", "def move_position\n @x += @velocity_x\n @y += @velocity_y\n end", "def update\n updateTime\n if (@x - @spawnX).abs > 50\n @velX *= -1\n end\n tryMove\n collidesWithPlayer\n end", "def move\n # Force evaluation of both update_x and update_y (no short-circuit)\n # If we're moving faster horizontally, do that first\n # Otherwise do the vertical move first\n moved = @space.process_moving_entity(self) do\n if @x_vel.abs > @y_vel.abs then move_x; move_y\n else move_y; move_x\n end\n end\n\n # Didn't move? Might be time to go to sleep\n @moving = false if !moved && sleep_now?\n\n moved\n end", "def move\n\t\t@x += 0\n\t\t@y += @vel\n\tend", "def update\n if idle?\n if Gosu.distance(@hb.x,@hb.y,$WINDOW.player.hb.x, $WINDOW.player.hb.y) < 150\n # If distance is 150 or less, behaviour changes to approaching\n change_state(GameStates::States::WALKING)\n @vect_v = 1\n @vect_angle = Gosu.angle(@hb.x, @hb.y, $WINDOW.player.hb.x, $WINDOW.player.hb.y)\n end\n elsif walking?\n # While walking, wolf tries to approach the main character\n @vect_angle = Gosu.angle(@hb.x, @hb.y, $WINDOW.player.hb.x, $WINDOW.player.hb.y)\n if @una_check_tiks <= 0\n # When next attack check counter reaches 0, wolf can attack.\n dieroll = Random.rand\n if dieroll <= ATTACK_PROBABILITY\n # If random is within attack probability, the wolf changes behaviour to attack\n change_state(GameStates::States::ATTACKING)\n @event_tiks =60\n @vect_v = 0\n else\n #If random is not within attack probability, next attack check counter is reset to 30.\n @una_check_tiks = 30\n end\n end\n check_change_dir\n elsif attacking?\n # If attacking, wolf waits for a little while, then charges in a straight line. Then waits a little while.\n if @event_tiks > 20\n check_change_dir\n elsif @event_tiks == 20\n @vect_angle = Gosu.angle(@hb.x, @hb.y, $WINDOW.player.hb.x, $WINDOW.player.hb.y)\n @vect_v = 3.5\n elsif @event_tiks == 10\n @venct_v = 0\n elsif @event_tiks <= 0\n change_state(GameStates::States::IDLE)\n @una_check_tiks = 100\n end\n end\n\n if normal? && $WINDOW.player.inv_frames <= 0 && !$WINDOW.player.recoiling? && @hb.check_brute_collision($WINDOW.player.hb)\n # If it connects with player, player is set to impacted.\n $WINDOW.player.impacted(@hb.center, @attack_dmg)\n end\n\n if !idle? && Gosu.distance(@hb.x,@hb.y,$WINDOW.player.hb.x, $WINDOW.player.hb.y) > 250\n #If distance surpasses 250, the wolf turns back to idle.\n change_state(GameStates:States::IDLE)\n end\n\n super\n @una_check_tiks -= 1 unless idle? || @una_check_tiks <= 0\n end", "def move\n # Force evaluation of both update_x and update_y (no short-circuit)\n # If we're moving faster horizontally, do that first\n # Otherwise do the vertical move first\n moved = @space.process_moving_entity(self) do\n if @x_vel.abs > @y_vel.abs then move_x; move_y\n else move_y; move_x\n end\n end\n\n # Didn't move? Might be time to go to sleep\n if !moved && sleep_now?\n puts \"#{self} going to sleep...\"\n @moving = false\n end\n end", "def update_pos( dt )\n x = @rect.centerx\n y = @rect.centery\n\n x += @velocity.x * dt\n y += @velocity.y * dt\n\n # Wrap the screen\n screen = @game.screen\n x = 0 if x > screen.w\n x = screen.w if x < 0\n y = 0 if y > screen.h\n y = screen.h if y < 0\n\n @rect.center = [x, y]\n end", "def update\n # Compute the passage of time.\n @new = Gosu.milliseconds\n @old ||= @new\n delta = @new - @old\n @old = @new\n\n #Update for gravity.\n @vy += @gravity\n\n # Compute the drag\n @vx *= @drag\n @vy *= @drag\n\n # Compute the new proposed position.\n @x += @vx * delta\n @y += @vy * delta\n\n # Compute the boundary limits.\n top = @y\n bottom = @y + @ball.height\n left = @x\n right = @x + @ball.width\n\n # Check for collision with the left and right walls.\n if left < 0\n @vx *= -1\n @x = -left\n elsif right > self.width\n @vx *= -1\n @x -= 2 * (right-self.width)\n end\n\n # Check for collision with the top and bottom walls.\n if top < 0\n @vy *= -1\n @y = -top\n elsif bottom > self.height\n @vy *= -1\n @y -= 2 * (bottom-self.height)\n end\n end", "def move\r\n @x += @velx\r\n @y += @vely\r\n\r\n #To introduce friction to the player so that it can slow down\r\n @velx *= FRICTION\r\n @vely *= FRICTION\r\n\r\n #To stop the player from moving out of the left of the window\r\n if @x > @window.width - @radius\r\n @velx = 0\r\n @x = @window.width - @radius\r\n end\r\n\r\n #To stop the player from moving out of the right of the window\r\n if @x < @radius\r\n @velx = 0\r\n @x = @radius\r\n end\r\n\r\n #To stop the player from moving out of the bottom of the window\r\n if @y > @window.height - @radius\r\n @vely = 0\r\n @y = @window.height - @radius\r\n end\r\n end", "def move\n @x = (@x + @x_velocity) % Window.width\n @y = (@y + @y_velocity) % Window.height\nend", "def input_update_movement_controls\n if $program.holding?(:alt)\n speed = @speed / 2.0\n elsif $program.holding?(:shift) && $program.holding?(:ctrl)\n speed = @speed * 10\n elsif $program.holding?(:shift) || $program.holding?(:ctrl)\n speed = @speed * 4\n else\n speed = @speed\n end\n #--------------------------------------\n # Left Right X axis, Camera Position\n if $program.holding?(:move_left)\n @z -= speed\n elsif $program.holding?(:move_right)\n @z += speed\n #--------------------------------------\n # Up Down Y axis, Camera Position\n elsif $program.holding?(:move_up)\n @x -= speed\n elsif $program.holding?(:move_down)\n @x += speed\n #--------------------------------------\n # Vertical Hight change, Camera Position\n # more of a 'turn' then a straif type movment...\n elsif $program.holding?(:move_jump)\n @y -= speed\n elsif $program.holding?(:move_crouch)\n @y += speed\n #--------------------------------------\n end\n end", "def move\n\t\t# move 5px to the left\n\t @x = @x - 5\n\t # move up or down based on the Y velocity\n\t @y = @y + @vy\n\tend", "def move(x, y)\n if y != 0\n @y += y\n bounce if game_state.first_terrain_collision(self)\n end\n \n if x != 0\n @x += x\n turn if game_state.first_terrain_collision(self)\n end\n end", "def move()\n #first it checks if it is on an edge\n if (\n @model.x >= Window.width-@size ||\n @model.x <= 0 ||\n @model.y >= Window.height-@size ||\n @model.y <= 0\n )\n #if the bullet is on the edge then it will die\n self.kill()\n end\n #this moves the bullet by the velocity of the bullet\n @pos.x += @vel.x\n @pos.y += @vel.y\n #moves the bullets model\n @model.x = @pos.x\n @model.y = @pos.y\n end", "def update_move\n self.x = screen_x\n self.y = screen_y\n update_move_arch if @type == Arched\n end", "def do_x_move\n puts \"doing x move from #{@pos.inspect}\"\n along_1 = [@pos[0], @pos[1] + @y_move]\n # in the right column or direct move impassable\n if @y_moved == @y_dist or impassable?(along_1)\n #move up or down\n if @go_up\n if passable?(up_1)\n move_up\n elsif passable?(down_1)\n move_down\n else\n if at_dead_end?(@pos)\n do_dead_end_move\n else\n do_y_move\n end\n end\n else\n if passable?(down_1)\n move_down\n elsif passable?(up_1)\n move_up\n else\n if at_dead_end?(@pos)\n do_dead_end_move\n else\n do_y_move\n end\n end\n end\n else\n if passable?(along_1)\n @x_moved += @x_move\n @pos = along_1\n @visited << @pos\n @moved += 1\n else\n do_y_move\n end\n end\n end", "def move_toward_character(character)\r\r\n sx = distance_x_from(character.x)\r\r\n sy = distance_y_from(character.y)\r\r\n if sx.abs > sy.abs\r\r\n if passable?(@x, @y, (sx > 0 ? 4 : 6))\r\r\n @move_poll+= [[sx > 0 ? 4 : 6, true]] * (32.0 / CXJ::FREE_MOVEMENT::PIXELS_PER_STEP).ceil\r\r\n else\r\r\n @move_poll+= [[sy > 0 ? 8 : 2, true]] * (32.0 / CXJ::FREE_MOVEMENT::PIXELS_PER_STEP).ceil\r\r\n end\r\r\n elsif sy != 0\r\r\n if passable?(@x, @y, (sy > 0 ? 8 : 2))\r\r\n @move_poll+= [[sy > 0 ? 8 : 2, true]] * (32.0 / CXJ::FREE_MOVEMENT::PIXELS_PER_STEP).ceil\r\r\n else\r\r\n @move_poll+= [[sx > 0 ? 4 : 6, true]] * (32.0 / CXJ::FREE_MOVEMENT::PIXELS_PER_STEP).ceil\r\r\n end\r\r\n end\r\r\n end", "def move\n return unless placed?\n # no need to use a loop since the length is only 2\n new_x = @pos_x + @direction[:x]\n new_y = @pos_y + @direction[:y]\n\n return unless valid_position?(new_x, new_y)\n set_position(new_x, new_y)\n end", "def standard_move\n pos.set(x,y)\n tar = move_towards_player\n sep = seperate_from_enemies\n sep.scalar(5.5, '*')\n tar.scalar(4.0, '*')\n apply_force(sep)\n apply_force(tar)\n if acc.x == 0 and acc.y == 0\n return\n else\n vel.add(acc)\n vel.limit(speed)\n end\n pos.add(vel)\n @x = pos.x\n @y = pos.y\n acc.scalar(0, '*')\n end", "def move(direction)\n @x += @velocity if direction == :right\n @x -= @velocity if direction == :left\n end", "def move_by_velocity_if_valid\n # Consider refactoring Display to be in instance of an object instead of a static class\n return [] if velocity == [0,0]\n head = @positions.first\n tail = @positions.last\n new_y = velocity.first + head.first\n new_x = velocity.last + head.last\n\n tile_traversable = Display.instance_variable_get(:@tiles)[new_y][new_x].traversable\n collision_with_tail = @positions.include? [new_y, new_x]\n\n if tile_traversable && !collision_with_tail\n Display.draw tail.first, tail.last, ' '\n @positions.unshift [ new_y, new_x]\n Display.draw @positions.first.first, @positions.first.last, char\n return @positions.pop\n end\n\n return false\n end" ]
[ "0.6591101", "0.6453561", "0.64401066", "0.6427868", "0.63903475", "0.6370232", "0.63332045", "0.6321681", "0.6316446", "0.62195945", "0.6170025", "0.61566436", "0.61468846", "0.61147296", "0.6086998", "0.60427916", "0.60236484", "0.60165644", "0.5990124", "0.59567267", "0.593017", "0.592271", "0.59140927", "0.5879468", "0.58722925", "0.584813", "0.58474994", "0.58280617", "0.5812197", "0.57836187" ]
0.6518357
1
Schedule a tweet to be sent.
def schedule_tweet(text, datetime) scheduler = Rufus::Scheduler.new job = scheduler.schedule datetime do puts "beep" send_tweet(text) end puts "Job trigger time: #{job.time}\n" puts "Running Jobs: #{scheduler.running_jobs}\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_tweets\n\n\t\ttweets = TweetQueue.all\n\n\t\ttweets.each do |tweet|\n\n\t\t\ttext \t\t\t= tweet.text\n\n\t\t\ttweet_source \t= {:id => tweet.source}\n\n\t\t\tnew_tweet = reply(text, tweet_source)\n\n\t\t\tunless new_tweet.is_unique?\n\t\t\t\trandom_suffix = random_chars(2)\n\t\t\t\tnew_tweet = reply(text + random_suffix, tweet_source)\n\t\t\t\tdebug \"Duplicate tweet id detected; adding random emoji\"\n\t\t\tend\n\n\t\t\tstore_id_of new_tweet\n\n\t\t\ttweet.destroy\n\t\t\tdebug \"Outgoing Tweet: #{new_tweet.text}\"\n\n\t\tend # tweets.each\n\n\tend", "def save_tweet(params)\n @tweet=self.tweets.new(params)\n @tweet.save\n schedule_tweet(@tweet)\n end", "def post_tweet\n # @tweets << tweet: violates SST\n Tweet.new('tweet message', self)\n end", "def tweet(title)\n unless @twitter_client.nil?\n\n # Make sure the title is short enough\n if title.length > 80\n title = title[0,80]\n end\n if @dj_tweeting\n @twitter_client.update(\"Now playing on #DuaneFM: #{title} http://bit.ly/1ErYiZr #hewitt\")\n end\n\n end\n end", "def tweet_creation(tweet)\n @tweet = tweet\n\n set_attachments\n\n mail(to: tweet.influencer.user.email, subject: \"Notificaciones @ Social Target - Recibiste una propuesta para un nuevo tweet\")\n end", "def notify_twitter\n $twitter_client.update(tweet_content)\n end", "def tweet\n\treturn \"Tweet Tweet Twitter\"\nend", "def tweet\r\n\treturn \"tweet tweet tweet\"\r\n\tend", "def send_tweet(screenshot)\n log \"sending screenshot\"\n sarcasm = [\n \"Here is my latest selfie!\",\n \"I see sweaty people\",\n \"MEATSWEATS\"\n ]\n tweet = twitter_client.update_with_media(sarcasm.sample, screenshot)\n log \"completed with #{tweet.url}\"\n tweet\n end", "def schedule\n run_callbacks :schedule do\n perform_async\n end\n end", "def send_schedule\n team = Team.find(params[:id])\n authorize! :manage, team\n\n # used to send out the schedule.\n # now removed, as we send out weekly schedules instead/updates within 7 days\n\n render json: { schedule_sent: true }\n end", "def deliver_tweets(tweets=nil)\n exit unless tweets\n chained_tweets = \"\"\n tweets.each {|tweet| chained_tweets += \"#{tweet.id} #{tweet.text} \\n\"}\n msg = \"Subject: New tweets on #{Time.now} for #{@account_name}\\n\\n#{chained_tweets}\"\n smtp = Net::SMTP.new 'smtp.gmail.com', 587\n smtp.enable_starttls\n smtp.start(\"gmail.com\", @account['credentials']['email_address'], @account['credentials']['email_password'], :login) do\n smtp.send_message(msg, @account['credentials']['email_address'], @account['deliver_to'])\n end\n end", "def tweet\n return \"chirp chirp\"\n end", "def tweet!\n TWITTER.update(\"#{title.truncate(75)} - #{tweet_users}\\n\\nhttp://beta.briefideas.org/ideas/#{sha}\")\n self.update_columns(:tweeted => true)\n end", "def twitt\n if PLANETOID_CONF[:twitter][:entries][:send_twitts] && self.published > self.feed.created_at\n twit=Twitter::Base.new(Twitter::HTTPAuth.new(PLANETOID_CONF[:twitter][:user], PLANETOID_CONF[:twitter][:password]))\n twit.update \"#{PLANETOID_CONF[:twitter][:entries][:prefix]} #{self.title[0..150]} #{self.url}\"\n end\n end", "def postTweet(status)\n\t\t\t@client.update(status)\n\t\tend", "def Clockwork\n puts \"testing clockwork!\"\n every(30.seconds, 'Send Messages') {\n rake 'scheduler:send_messages'\n mail(:to => \"swamy@ostryalabs.com\", subject: 'hello')\n }\n \nend", "def send_twitter_message!(sendto, subject, message)\n send_message({:sendto => sendto, :subject => subject, :message => message})\n end", "def send_all_texts\n\n #heroku scheduler runs rake task to check DB every 10 minutes, not every minute like whenever gem. Logic has to account for that range of time.\n if (Time.now - 10.minutes) <= self.time && self.time <= Time.now + 10.minutes && sent == false\n self.sent = true\n self.save\n self.twilio_text\n else\n end\n\n end", "def tweet_creation_to_admin(tweet)\n @tweet = tweet\n\n set_attachments\n\n @screen_name = tweet.influencer.user.twitter_screen_name\n\n case APP_CONFIG['app_country']\n when 'AR'\n mail(to: 'sebastian@socialtarget.net', subject: \"Notificaciones @ Social Target - @#{@screen_name} recibió una propuesto de Tweet\")\n when 'CO'\n mail(to: 'sebastian@socialtarget.net', subject: \"Notificaciones @ Social Target - @#{@screen_name} recibió una propuesto de Tweet\")\n when 'MX'\n mail(to: 'sebastian@socialtarget.net', subject: \"Notificaciones @ Social Target - @#{@screen_name} recibió una propuesto de Tweet\")\n end\n\n end", "def post_tweet(message)\n Tweet.new(message, self)\n end", "def tweet(tweet)\n\t\tclient = Twitter::REST::Client.new do |config|\n\t\tconfig.consumer_key = Rails.application.config.twitter_key\n\t\tconfig.consumer_secret = Rails.application.config.twitter_secret\n\t\tconfig.access_token = oauth_token\n\t\tconfig.access_token_secret = oauth_secret\n\tend\n\tclient.update(tweet)\n\tend", "def record_tweet(tweet_name, time)\n \n end", "def tweet\n\t#gets what the last value was from the timeline\n\tlast = $client_twitter.user_timeline()[0].text.match('([0-9])+').string.to_i\n\t#calculates the new value\n\tnext_square = next_number(last)\n\t#these four numbers produce swastikas, so let's just not post those. I'm comfortable getting done 8 hours early for that\n\tif next_square == 28928495 || next_square == 32632615 || next_square == 921816 || next_square == 4625936\n\t\tnext_square = next_number(next_square)\n\tend\n\t#draws the square and saves the file name\n\tfile_name = draw_grid(next_square)\n\t#gets the text of the tweet\n\tnew_tweet = generate_tweet(next_square)\n\t#opens the file and posts\n\tFile.open(file_name) do |f|\n\t\t$client_twitter.update_with_media(new_tweet, f)\n\tend\n\t#deletes the file so it doesn't clutter up the place\n\tFile.delete(file_name)\n\t#And we're done!\n\tputs \"Posted to twitter\"\nend", "def stream\n #kills all tweet streaming processes\n #system \"pkill -f stream_tweets\"\n\n #invokes rake task for streaming tweets for 2 different brands\n system \"rake stream_tweets BRAND1=#{@battle.brand1} BRAND2=#{@battle.brand2} BATTLE_ID=#{@battle.id} &\"\n end", "def perform\n @newsletter = create_newsletter\n send_emails\n end", "def post_tweet(message)\n Tweet.new(message, self) # I am myself\n end", "def send_tweet(message)\n token = \"1OwtA6XFzgT3DER5GZglnQ\"\n secret = \"TmUsK5uiAT3JlqWA5bWPcWCp0sI8VB0TX4ODwvAixk\"\n\t\t atoken = \"199604836-WvWb2u4hixibybjN9fWGqiNrzQp0BYpibswh7uXP\"\n\t\t\t asecret = \"47KStSmHJ5Fhn74XWvMmfDW3UdqGV0l2jm9KxsZpauE\"\n\n\t\t\t\t\t oauth = Twitter::OAuth.new(token, secret)\n\t\t\t\t\t\t\t\t oauth.authorize_from_access(atoken, asecret)\n\n\t\t\t\t\t\t\t\t\t\t\t client = Twitter::Base.new(oauth)\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t client.inspect\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t client.update(message)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t end", "def schedule(time, callback); end", "def perform\n publish_scheduled\n end" ]
[ "0.6544477", "0.6528381", "0.63009185", "0.6137791", "0.60728383", "0.5993537", "0.59636927", "0.594522", "0.58838606", "0.5879793", "0.5798995", "0.57737833", "0.574672", "0.574082", "0.57346183", "0.5732521", "0.5711112", "0.56945837", "0.56826913", "0.56745887", "0.56738377", "0.5672308", "0.566222", "0.56518024", "0.56364673", "0.56175625", "0.56066173", "0.5605313", "0.5602268", "0.55995935" ]
0.7658251
0
Initiate database maintenance tasks to improve database performance and consistency. A restart will be initiated in order to put the product into maintenance mode while the tasks are run. It will then restart automatically.
def db_maintenance(clean_up = false, compress = false, reindex = false) return unless compress || clean_up || reindex parameters = { 'cmd' => 'startMaintenance', 'targetTask' => 'dbMaintenance' } parameters['cleanup'] = 1 if clean_up parameters['compress'] = 1 if compress parameters['reindex'] = 1 if reindex xml = AJAX.form_post(self, '/admin/global/maintenance/maintCmd.txml', parameters) if !!(xml =~ /succeded="true"/) _maintenance_restart end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def migrate\n with_maintenance do\n backup if backup?\n run_migration\n restart\n end\n end", "def activate_maintenance_mode\n return unless maintenance && pending_migrations?\n callback(:activate_maintenance_mode) do\n notify(:activate_maintenance_mode)\n heroku.app_maintenance_on\n end\n end", "def start_maintenance\n return true if maint_mode?\n\n Instance.running_for_profile(self).map {|i| i.stop}\n maint_mode = true\n self.save!\n sleep 2\n\n self.start_instance\n end", "def task\n describe_task \"database\" do\n run \"bootstrap:cold\"\n end\n end", "def install_migrations\n rake(\"maintenance_tasks:install:migrations\")\n rake(\"db:migrate\")\n end", "def start\n migration_task.update!(:state => 'migrate')\n handover_to_automate\n queue_signal(:poll_automate_state_machine)\n end", "def define\r\n\t\tdatabase_names.call().collect do |database_name|\r\n\t\t\tnamespace database_name do\r\n\t\t\t\ttasks[:names].collect do |task_name|\r\n\t\t\t\t\tdesc \"#{task_name.to_s.capitalize} the #{database_name} database\"\r\n\t\t\t\t\ttask task_name => tasks[:dependencies] do\r\n\t\t\t\t\t\ttasks[:action].call(task_name, database_name)\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\t\t\r\n\t\t\t\tadd_tasks_for(:import, import, database_name)\r\n\t\t\t\tadd_tasks_for(:export, export, database_name)\r\n\t\t\tend\r\n\t\tend\r\n\t\t\r\n\t\tself\r\n\tend", "def maintenance\n end", "def restart()\n stopwatch = Stopwatch.new\n event(\"Pre\")\n if agree(\"Should all the databases be cleared? <%= color('[y/n]', :bold) %>\")\n self.clean_db()\n system( \"vagrant reload --provision\" ) \n else\n system( \"vagrant reload\" )\n end\n event(\"Post\")\n stopwatch.end(\"restarted in:\")\n end", "def install_sequence\n stop\n \n backup_database\n install_pre_hook\n pre_migrate_database\n copy_files\n freeze_rails\n create_default_config_files\n fix_permissions\n create_directories\n create_initial_database\n set_initial_port_number\n expand_template_files\n \n migrate\n install_post_hook\n save\n \n run_rails_tests\n \n start\n end", "def init\n if !response_service.admin_view?\n render json: { popup: 'Must be an admin to initialize the database!!' }\n elsif Rails.env.production?\n render json: { popup: 'Can\\'t initialize the production database!!' }\n else\n Answer.delete_all\n Authentication.delete_all\n Expression.delete_all\n Finder.delete_all\n List.delete_all\n Rcpref.delete_all\n Recipe.delete_all\n ImageReference.delete_all\n Referent.delete_all\n Referment.delete_all\n ReferentRelation.delete_all\n ResultsCache.delete_all\n Scraper.clear_all\n Site.delete_all\n TagSelection.delete_all\n Tag.delete_all\n TagOwner.delete_all\n Tagging.delete_all\n TagsCache.delete_all\n Tagset.delete_all\n # User.delete_all\n # UserRelation.delete_all\n Vote.delete_all\n sql = 'DELETE FROM delayed_jobs;'\n ActiveRecord::Base.connection.execute(sql)\n render json: { popup: 'Database is initialized and ready for scraping.' }\n end\n end", "def start\n DB.reset\n DB.configure do |config|\n config.parse(@options[:config])\n config.logger = logger\n end\n\n GRACEFUL_SHUTDOWN_SIGNALS.each { |signal| trap(signal) { stop } }\n ROTATION_SIGNALS.each { |signal| trap(signal) { Worker.reopen_files } }\n\n preload\n\n loop do\n runtime = Benchmark.realtime { perform }\n sleep(@interval - runtime) if runtime < @interval && !stop?\n\n break if stop?\n end\n end", "def action_deploy\n set_state\n notifying_block do\n write_config\n run_syncdb\n run_migrate\n run_collectstatic\n end\n end", "def maintenance\n @maintenance ||= Maintenance.new(self)\n end", "def pre_send_announcement\n super\n FileUtils.mkdir_p(@base_dir) if @base_dir\n start_db\n @capacity_lock.synchronize do\n ProvisionedService.all.each do |instance|\n @capacity -= capacity_unit\n end\n end\n end", "def migrate\n puts 'Migrating DBs on containers'\n puts Open3.capture3(\"pushd #{dot_futureadvisor} 2>&1; ./bin/dev restart 2>&1; popd 2>&1\")\n end", "def deactivate_maintenance_mode\n return unless pending_migrations?\n callback(:deactivate_maintenance_mode) do\n notify(:deactivate_maintenance_mode)\n heroku.app_maintenance_off\n end\n end", "def dbmigrate!\n ActiveRecord::Base.establish_connection(PuppetHerald.database.spec)\n ActiveRecord::Migrator.up 'db/migrate'\n ActiveRecord::Base.clear_active_connections!\n nil\n end", "def prepare_replication\n exclude_rubyrep_tables\n\n puts \"Verifying RubyRep tables\"\n ensure_infrastructure\n\n call_after_infrastructure_setup_handler\n\n puts \"Checking for and removing rubyrep triggers from unconfigured tables\"\n restore_unconfigured_tables\n\n puts \"Verifying rubyrep triggers of configured tables\"\n unsynced_table_pairs = []\n table_pairs = session.sort_table_pairs(session.configured_table_pairs)\n table_pairs.each do |table_pair|\n table_options = options(table_pair[:left])\n ensure_sequence_setup table_pair,\n table_options[:sequence_increment],\n table_options[:left_sequence_offset],\n table_options[:right_sequence_offset]\n\n unsynced = false\n [:left, :right].each do |database|\n next if session.configuration.send(database)[:mode] == :slave\n if !trigger_exists? database, table_pair[database]\n create_trigger database, table_pair[database]\n unsynced = true\n elsif !sync_complete? database, table_pair[database]\n unsynced = true\n end\n end\n if unsynced and table_options[:initial_sync]\n unsynced_table_pairs << table_pair\n end\n end\n unsynced_table_specs = unsynced_table_pairs.map do |table_pair|\n \"#{table_pair[:left]}, #{table_pair[:right]}\"\n end\n\n # Initialize heartbeat file\n RR.heartbeat(session.configuration.options[:heartbeat_file])\n\n unless session.configuration.options[:no_sync] || unsynced_table_specs.empty?\n puts \"Executing initial table syncs\"\n runner = SyncRunner.new\n runner.session = session\n runner.options = {:table_specs => unsynced_table_specs, :heartbeat_file => session.configuration.options[:heartbeat_file]}\n runner.execute\n end\n\n puts \"Starting replication\"\n end", "def run_replications\n # Add fresh schedule\n old_shedule = @schedule\n @schedule = {}\n @active = false\n\n old_shedule.each_value do |conn|\n conn.start\n end\n end", "def default_deploy\n setup\n update_repo_tag\n push_repo\n maintenance_mode do\n run_migrations\n app_restart\n end\n warm_instance\n teardown\n end", "def run_update_tasks\n begin\n Student.update_risk_levels!\n Student.update_recent_student_assessments\n Homeroom.destroy_empty_homerooms\n rescue => error\n ErrorMailer.error_report(error).deliver_now if Rails.env.production?\n raise error\n end\n end", "def define_tasks\n # Run the command on the local system\n def run(cmd)\n Kernel.system(cmd.runnable)\n end\n # Basic setup action\n def setup_application\n @options ||= PoolParty.options(ARGV.dup)\n end\n \n # Require the poolparty specific tasks\n compiled_rakefile\n \n desc \"Reload the static variables\"\n task :reload do\n reload!\n end\n true\n end", "def deploy\n\t# This task is typiclly run after the site is updated but before the server is restarted.\n\tcall 'migrate'\nend", "def run_predeploy\n super do\n update_task_revision\n\n begin\n @deploy_config.predeploy_commands.each { |command| run_command(command) }\n ensure\n EcsManager.deregister_last_n_tasks_definitions(family, 1)\n end\n end\n end", "def initial_setup\n CORE.each { |c| c.auto_migrate! }\n end", "def perform_background_tasks\n self.check_clipboard\n self.check_resolvers\n self.check_downloads\n self.check_captchas\n self.refresh_task_table\n self.update_download_buttons\n end", "def drb_restart!\n Vedeu.bind(:_drb_restart_) { Vedeu::Distributed::Server.restart }\n end", "def setup_before_restart\n tcs_static = node['thecollegesound']['static_root']\n tcs_app = File.join(node['thecollegesound']['app_root'], 'current')\n\n # -- Link statics (css, js, basic images)\n # FIXME: Consolidate the image directories\n ['css', 'js', 'images', 'icons', 'img'].each do |dir|\n link \"#{tcs_static}/static/#{dir}\" do\n to \"#{tcs_app}/collegesound/static/#{dir}\"\n end\n end\n\n # -- Link templates\n link \"#{tcs_static}/templates\" do\n to \"#{tcs_app}/collegesound/templates\"\n end\n\n # -- Install the package\n bash 'install_package' do\n user 'root'\n cwd tcs_app\n code 'python setup.py install'\n end\n\n # -- Run migration\n bash 'run_migration' do\n user 'root'\n cwd \"#{tcs_app}/collegesound\"\n code <<-EOH\n python manage.py convert_to_south main\n python manage.py migrate main\n EOH\n end\nend", "def run_reboot_checks\n # one simple check we can do is the backup. Backup can fail if anything is amiss\n @servers.each do |server|\n run_script(\"do_backup\", server)\n end\n end" ]
[ "0.6513386", "0.61461323", "0.60578", "0.6046109", "0.60122", "0.59266293", "0.59058344", "0.58713937", "0.57442755", "0.56489", "0.56429374", "0.5546217", "0.55311877", "0.55229783", "0.5510383", "0.5493323", "0.54874796", "0.548211", "0.54308677", "0.54237986", "0.54083395", "0.5404302", "0.53830105", "0.53349", "0.5332271", "0.53225785", "0.5312485", "0.53119695", "0.53031284", "0.53019875" ]
0.68558705
0
set Special Feature Opt in value
def set_special_feature_opt_in(id, val) if id < 1 || id > IABConsentString::GDPRConstantsV2::Core::SPECIAL_FEATURE_OPT_INS_SIZE raise "Invalid id number", caller end @special_feature_opt_in[id - 1] = val end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def feature=(value)\n @feature = value\n end", "def special=(value)\n @special = value\n end", "def update_value(name, value)\n feature = features.find_or_create_by!(name: name)\n\n feature.update_attributes(value: value, enabled: true)\n end", "def set_value(feature_id, value, extract = \"\", author=nil) \n feature_value = get_feature_value(feature_id) \n feature_value.set_value(value, self, extract, author)\n end", "def on_set_specific_options(scopetta_opt)\r\n @game_opt[:vale_napola] = scopetta_opt[:vale_napola][:val] if scopetta_opt[:vale_napola]\r\n @log.debug(\"Core scopetta options #{@game_opt.inspect}\")\r\n end", "def special=(isSpecial)\n if isSpecial == true or isSpecial == \"true\" or isSpecial == 1\n self.override = true\n elsif isSpecial == false or isSpecial == \"false\" or isSpecial == 0\n self.override = false\n end\n end", "def set_feature\n choice = Choice.find(params[:id])\n feature = Feature.find(params[:feature_id])\n question.create_choices_for_feature(current_user, feature)\n choice.update_attribute(:feature, feature)\n redirect_to edit_question_path(question)\n end", "def update!(**args)\n @feature = args[:feature] if args.key?(:feature)\n @new_restriction = args[:new_restriction] if args.key?(:new_restriction)\n end", "def add(feature)\n @set[feature] = true\n end", "def feature(name)\n @feature_name = name\n end", "def feature(name)\n @feature_name = name\n end", "def update!(**args)\n @feature = args[:feature] if args.key?(:feature)\n end", "def set_feature\n @feature = Feature.find( params[ :id ])\n end", "def set_feature_flag\n @feature_flag = FeatureFlag.find(params[:id])\n end", "def set(opt,val)\n if opt.is_a?(Symbol)\n setopt(sym2curl(opt), val)\n else\n setopt(opt.to_i, val)\n end\n end", "def update!(**args)\n @feature_name = args[:feature_name] if args.key?(:feature_name)\n @in_range_bitstream = args[:in_range_bitstream] if args.key?(:in_range_bitstream)\n @out_of_range_bitstream = args[:out_of_range_bitstream] if args.key?(:out_of_range_bitstream)\n end", "def set_value(opt = {})\n fail 'the value must exists !' if opt == {}\n # click @element_id\n url=@session_url + \"/element/#{@element_id}/value\"\n click=post(url,opt.to_json)\n return click\n end", "def change_feature_value(feature, value)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n ft_new_value = self.generate_feature_value_randomly\n if (ft_new_value == value)\n Log.logger.debug(\"#{feature} already turned #{value}.\")\n else\n Log.logger.debug(\"Changing the #{feature} value to #{ft_new_value}. This feature is currently #{value}.\")\n feature_value_path = feature_value_path_selector(feature)\n wait.until { @browser.find_element(:xpath => feature_value_path) }.click\n feature_value_path = feature_value_path_selector(feature)\n ft_value = wait.until { @browser.find_element(:xpath => feature_value_path) }.text\n if(ft_new_value != ft_value)\n Log.logger.debug(\"#{feature} value failed to change from #{value} to #{ft_new_value}.\")\n end\n end\n return ft_new_value\n end", "def update_option(opt, val)\n @options[opt] = val\n end", "def set_fusion_value(options)\n exists = check_fusion_vm_exists(options)\n fusion_vmx_file = get_fusion_vm_vmx_file(options)\n if exists == true\n message = \"Information:\\tSetting Parameter \"+options['param']+\" for \"+options['name']+\" to \"+options['value']\n command = \"'#{options['vmrun']}' writeVariable '#{fusion_vmx_file}' runtimeConfig '#{options['param']}' '#{options['value']}'\"\n execute_command(options,message,command)\n else\n handle_output(options,\"Warning:\\t#{options['vmapp']} VM #{options['name']} does not exist\")\n quit(options)\n end\n return\nend", "def specialist_setting\n\tend", "def optimize=(value)\n set_attr(:optimize, value ? 2 : 1)\n @optimize = value\n end", "def vash_munge_value(val); self.class.munge_option_value(val); end", "def logical_test=(value)\n @logical_test = value\n end", "def set_EffectiveOn(value)\n set_input(\"EffectiveOn\", value)\n end", "def default_set(v)\n (sigmoid(v) * 2) - 1\n end", "def set_opt(opt, default)\n if opt\n opt\n else\n default\n end\n end", "def set_opt10075\n @opt10075 = Opt10075.find(params[:id])\n end", "def cut_factor=(factor)\r\n end", "def set_double(attr, val); end" ]
[ "0.66683173", "0.61738145", "0.59808034", "0.58793277", "0.58260924", "0.5741606", "0.5729639", "0.5678882", "0.5607109", "0.5598351", "0.5598351", "0.5586773", "0.55488664", "0.55260205", "0.55124485", "0.55065054", "0.54579073", "0.5431121", "0.5430567", "0.54077566", "0.5389123", "0.53838795", "0.5372164", "0.53564", "0.535233", "0.534931", "0.5345299", "0.53357166", "0.5335524", "0.5332903" ]
0.74218655
0
set Purpose Consented value
def set_purposes_consented(id, val) if id < 1 || id > IABConsentString::GDPRConstantsV2::Core::PURPOSES_CONSENT_SIZE raise "Invalid id number", caller end @purposes_consented[id - 1] = val end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_purpose=(value)\n @user_purpose = value\n end", "def groups_set_purpose(params = {})\n fail ArgumentError, \"Required arguments 'channel' missing\" if params['channel'].nil?\n fail ArgumentError, \"Required arguments 'pupose' missing\" if params['purpos'].nil?\n response = @session.do_post \"#{SCOPE}.setPurpose\", params\n Slack.parse_response(response)\n end", "def set_remark(text)\n @remark = text\n end", "def sent_cc_me=(value)\n @sent_cc_me = value\n end", "def change_email_settings\n if request.post?\n account = getAccount()\n value = params[:account][:special_offers].to_i\n account.update_attribute(\"special_offers\", value)\n \n flash[:notice] = \"Changes Saved.\"\n redirect_to :action=>'account', :controller=>'go'\n else\n redirect_to :action=>'account', :controller=>'go'\n end \n end", "def purpose(desc)\n args_def.purpose = desc\n end", "def user_consenting=(_arg0); end", "def set_beneficiary\n @beneficiary = current_user.beneficiary\n end", "def sent_only_to_me=(value)\n @sent_only_to_me = value\n end", "def sent_to_or_cc_me=(value)\n @sent_to_or_cc_me = value\n end", "def vital=(value)\n @peer.vital = value\n end", "def set_benefit\n @benefit = Benefit.find(params[:id])\n end", "def set_benefit\n @benefit = Benefit.find(params[:id])\n end", "def purpose(*purpose)\n purpose.any? ? @purpose = purpose[0] : @purpose\n end", "def edit_privacy_confirmation(user)\n @user = user\n\n mail(\n # from: 'codetest1980@gmail.com',\n from: 'lifeabroadjapan@gmail.com',\n to: @user.email,\n subject: 'Privacy setting was changed (Med+)'\n )\n end", "def set_benefit\r\n @benefit = Benefit.find(params[:id])\r\n end", "def sent_to_me=(value)\n @sent_to_me = value\n end", "def assign_canned_subject\n self.subject = canned_subject\n end", "def set_contact_email email\n contact_email_tb.type_text email\n end", "def set_biomarker_purpose\n @biomarker_purpose = BiomarkerPurpose.find(params[:id])\n end", "def set_subject(subject)\n\t\tend", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def mark_as_issued(name, company, date = Date.today)\n self.issued_quantity = self.quantity_received\n self.issued_to_name = name\n self.issued_to_company = company\n self.issued_date = date\n end", "def withAllowedPurposeIds(allowedPurposeIds)\n if allowedPurposeIds.nil?\n raise \"Argument allowedPurposeIds is null\"\n end\n allowedPurposeIds.each do |purposeId|\n if purposeId < 0 || purposeId > IABConsentString::GDPRConstants::PURPOSES_SIZE\n raise \"Invalid purpose ID found\"\n end\n end\n @allowedPurposes = allowedPurposeIds;\n self\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end", "def set_Subject(value)\n set_input(\"Subject\", value)\n end" ]
[ "0.6401911", "0.6066534", "0.5668373", "0.56554306", "0.5607924", "0.5594656", "0.5583838", "0.55551726", "0.5509452", "0.5498592", "0.5494943", "0.54699486", "0.54699486", "0.54693997", "0.54591084", "0.5449131", "0.54359925", "0.5431524", "0.54033935", "0.539021", "0.53865373", "0.53616565", "0.5361441", "0.5296981", "0.52883625", "0.5286029", "0.5286029", "0.5286029", "0.5286029", "0.5286029" ]
0.64696234
0
init Vendor consent according to range value
def init_vendor_consent(ranged:) @vendor_consent = VendorSectionBuilder.build(is_ranged_encoding: ranged) @vendor_consent end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_vendor_legitimate_interest(ranged:)\n @vendor_legitimate_interest = VendorSectionBuilder.build(is_ranged_encoding: ranged)\n @vendor_legitimate_interest\n end", "def build\n if @consentRecordCreated.nil?\n raise IABConsentString::Error::VendorConsentCreateError, \"consentRecordCreated must be set\", caller\n end\n if @consentRecordLastUpdated.nil?\n raise IABConsentString::Error::VendorConsentCreateError, \"consentRecordLastUpdated must be set\", caller\n end\n if @consentLanguage.nil?\n raise IABConsentString::Error::VendorConsentCreateError, \"consentLanguage must be set\", caller\n end\n\n if @vendorListVersion.nil? || @vendorListVersion <=0\n raise IABConsentString::Error::VendorConsentCreateError, \"Invalid value for vendorListVersion:\" + @vendorListVersion.to_s, caller\n end\n\n if @maxVendorId.nil? || @maxVendorId<=0\n raise IABConsentString::Error::VendorConsentCreateError, \"Invalid value for maxVendorId:\" + @maxVendorId.to_s, caller\n end\n\n # For range encoding, check if each range entry is valid\n if @vendorEncodingType == IABConsentString::GDPRConstants::VENDOR_ENCODING_RANGE\n if @rangeEntries.nil?\n raise IABConsentString::Error::VendorConsentCreateError, \"Range entries must be set\", caller\n end\n @rangeEntries.each do |rangeEntry|\n if !rangeEntry.valid(@maxVendorId)\n raise IABConsentString::Error::VendorConsentCreateError, \"Invalid range entries found\", caller\n end\n end\n end\n\n # Calculate size of bit buffer in bits\n bitBufferSizeInBits = 0\n if (@vendorEncodingType == IABConsentString::GDPRConstants::VENDOR_ENCODING_RANGE)\n rangeEntrySectionSize = 0\n @rangeEntries.each do |rangeEntry|\n rangeEntrySectionSize += rangeEntry.size\n end\n bitBufferSizeInBits = IABConsentString::GDPRConstants::RANGE_ENTRY_OFFSET + rangeEntrySectionSize\n else\n bitBufferSizeInBits = IABConsentString::GDPRConstants::VENDOR_BITFIELD_OFFSET + @maxVendorId\n end\n\n # Create new bit buffer\n bitsFit = (bitBufferSizeInBits % 8) == 0\n str = \"\"\n for i in (0...(bitBufferSizeInBits / 8 + (bitsFit ? 0 : 1))) do\n str << 0b00000000\n end\n bits = IABConsentString::Bits.new(str.bytes.to_a)\n\n # Set fields in bit buffer\n bits.setInt(IABConsentString::GDPRConstants::VERSION_BIT_OFFSET, IABConsentString::GDPRConstants::VERSION_BIT_SIZE, VERSION)\n bits.setDateTimeToEpochDeciseconds(IABConsentString::GDPRConstants::CREATED_BIT_OFFSET, IABConsentString::GDPRConstants::CREATED_BIT_SIZE, @consentRecordCreated)\n bits.setDateTimeToEpochDeciseconds(IABConsentString::GDPRConstants::UPDATED_BIT_OFFSET, IABConsentString::GDPRConstants::UPDATED_BIT_SIZE, @consentRecordLastUpdated)\n bits.setInt(IABConsentString::GDPRConstants::CMP_ID_OFFSET, IABConsentString::GDPRConstants::CMP_ID_SIZE, @cmpId)\n bits.setInt(IABConsentString::GDPRConstants::CMP_VERSION_OFFSET, IABConsentString::GDPRConstants::CMP_VERSION_SIZE, @cmpVersion)\n bits.setInt(IABConsentString::GDPRConstants::CONSENT_SCREEN_SIZE_OFFSET, IABConsentString::GDPRConstants::CONSENT_SCREEN_SIZE, @consentScreenId)\n bits.setSixBitString(IABConsentString::GDPRConstants::CONSENT_LANGUAGE_OFFSET, IABConsentString::GDPRConstants::CONSENT_LANGUAGE_SIZE, @consentLanguage)\n bits.setInt(IABConsentString::GDPRConstants::VENDOR_LIST_VERSION_OFFSET, IABConsentString::GDPRConstants::VENDOR_LIST_VERSION_SIZE, @vendorListVersion)\n\n # Set purposes bits\n for i in (0...IABConsentString::GDPRConstants::PURPOSES_SIZE) do\n if (@allowedPurposes.include?(i+1))\n bits.setBit(IABConsentString::GDPRConstants::PURPOSES_OFFSET + i)\n else\n bits.unsetBit(IABConsentString::GDPRConstants::PURPOSES_OFFSET + i)\n end\n end\n\n bits.setInt(IABConsentString::GDPRConstants::MAX_VENDOR_ID_OFFSET, IABConsentString::GDPRConstants::MAX_VENDOR_ID_SIZE, @maxVendorId)\n bits.setInt(IABConsentString::GDPRConstants::ENCODING_TYPE_OFFSET, IABConsentString::GDPRConstants::ENCODING_TYPE_SIZE, @vendorEncodingType)\n\n # Set the bit field or range sections\n if (@vendorEncodingType == IABConsentString::GDPRConstants::VENDOR_ENCODING_RANGE)\n # Range encoding\n if (@defaultConsent)\n bits.setBit(IABConsentString::GDPRConstants::DEFAULT_CONSENT_OFFSET)\n else\n bits.unsetBit(IABConsentString::GDPRConstants::DEFAULT_CONSENT_OFFSET)\n end\n bits.setInt(IABConsentString::GDPRConstants::NUM_ENTRIES_OFFSET, IABConsentString::GDPRConstants::NUM_ENTRIES_SIZE, @rangeEntries.size)\n\n currentOffset = IABConsentString::GDPRConstants::RANGE_ENTRY_OFFSET\n\n @rangeEntries.each do |rangeEntry|\n currentOffset = rangeEntry.appendTo(bits, currentOffset)\n end\n else\n # Bit field encoding\n for i in (0...@maxVendorId) do\n if @vendorsBitField.include?(i+1)\n bits.setBit(IABConsentString::GDPRConstants::VENDOR_BITFIELD_OFFSET+i)\n else\n bits.unsetBit(IABConsentString::GDPRConstants::VENDOR_BITFIELD_OFFSET+i)\n end\n end\n end\n\n IABConsentString::Consent::Implementation::V1::ByteBufferBackedVendorConsent.new(bits)\n end", "def user_consenting=(_arg0); end", "def initialize()\n super\n @odata_type = \"#microsoft.graph.iPv6Range\"\n end", "def initialize(range)\n\t\t@secret_number = generate_secret_number(range.to_a)\n\tend", "def initialize(lower_limit, upper_limit, range_lower, range_upper)\n super(lower_limit, upper_limit)\n @range_lower = range_lower\n @range_upper = range_upper\n\n raise \"Invalid lower range value: #{@range_lower}\" unless is_value_within_limits?(@range_lower)\n raise \"Invalid upper range value: #{@range_upper}\" unless is_value_within_limits?(@range_upper)\n raise \"Lower limit must be less than or equal to the upper limit\" if @range_lower > @range_upper\n end", "def user_consenting; end", "def initialize()\n super\n @odata_type = \"#microsoft.graph.iPv6CidrRange\"\n end", "def consent_eng\n @consent_eng ||= Participants::Consent.new(locale: 'english')\nend", "def vco_range=(minmax_mhz)\n data = [minmax_mhz.first, minmax_mhz.last].pack('S>2')\n write_command(CMD_FREQ_RANGE, data)\n end", "def vco_range\n read_command(CMD_FREQ_RANGE).unpack('S>2')\n end", "def getAllowedVendorIds()\n (1..self.getMaxVendorId()).select { |i| self.isVendorConsented(i) }\n end", "def initialize()\n super\n @odata_type = \"#microsoft.graph.deviceEnrollmentPlatformRestrictionsConfiguration\"\n end", "def SetRange(range)\n @range=range\n end", "def consent_type=(value)\n @consent_type = value\n end", "def subset range\n new = Signal.new(:data => @data[range], :sample_rate => @sample_rate)\n new.instance_variable_set(:@frequency_domain, @frequency_domain)\n return new\n end", "def declare_beg_range\n\t\t@beg_range = @beg_range.to_date \n\t\t@end_range = @end_range.to_date \n\tend", "def set_VendorDistrict(value)\n set_input(\"VendorDistrict\", value)\n end", "def initialize(min_value_range, max_value_range, min_output, max_output, round)\n @min_value_range = min_value_range\n @max_value_range = max_value_range\n @min_output = min_output\n @max_output = max_output\n @round = round\n end", "def range=(range)\n @range = range\n end", "def min_range=(range)\n @min_range = [0, range].max\n @max_range = [@min_range, @max_range].max\n end", "def access_consent=(value)\n @access_consent = value\n end", "def range=(range)\n @range = range\n end", "def user_consenting?; end", "def initialize(attack, min_range, max_range, splash=[1.0], energy_cost=1)\n @min_range = 0\n @max_range = 0\n\n self.attack = attack\n self.min_range = min_range\n self.max_range = max_range\n\n @splash = splash\n\n self.energy_cost = energy_cost\n end", "def report_range=(value)\n @report_range = value\n end", "def price_setter(min, max)\n price_range = []\n (min..max).step(5) { |x| price_range.push(x) }\n return price_range.sample\nend", "def set_usr_vendor_property\n @user_contact = UsrContact.find(current_usr_contact )\n end", "def set_range_rate\n @range_rate = RangeRate.find(params[:id])\n end", "def consent\n send_data(gen_pdf(params[:wedgetail]), :filename => \"consent.pdf\", :type => \"application/pdf\")\n end" ]
[ "0.62207997", "0.61558634", "0.58162725", "0.5690112", "0.5652602", "0.5549055", "0.5469205", "0.5468732", "0.54210603", "0.53975964", "0.5340758", "0.5329352", "0.5260276", "0.5228253", "0.52104425", "0.5159229", "0.515277", "0.5138129", "0.50888515", "0.5086473", "0.5078575", "0.50620043", "0.50505835", "0.503943", "0.5016609", "0.5014626", "0.49855748", "0.4978885", "0.49722743", "0.49692476" ]
0.7899879
0
init Vendor legitimate interest according to range value
def init_vendor_legitimate_interest(ranged:) @vendor_legitimate_interest = VendorSectionBuilder.build(is_ranged_encoding: ranged) @vendor_legitimate_interest end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def price_setter(min, max)\n price_range = []\n (min..max).step(5) { |x| price_range.push(x) }\n return price_range.sample\nend", "def initialize(balance, account_holder_name)\n @interest_rate = 1.00001\n @balance = balance\n @account_holder_name = account_holder_name\n end", "def gain_interest\n interest_amount = (@balance * @interest_rate) / 100\n @balance = interest_amount + @balance\n end", "def initialize(min_value_range, max_value_range, min_output, max_output, round)\n @min_value_range = min_value_range\n @max_value_range = max_value_range\n @min_output = min_output\n @max_output = max_output\n @round = round\n end", "def interest(amount)\n if amount <= 1000\n 0.04 * amount\n elsif amount <= 5000\n 0.045 * amount\n else\n 0.05 * amount\n end\nend", "def range\n @fuel * MILES_PER_GALLON\n end", "def initialize(attack, min_range, max_range, splash=[1.0], energy_cost=1)\n @min_range = 0\n @max_range = 0\n\n self.attack = attack\n self.min_range = min_range\n self.max_range = max_range\n\n @splash = splash\n\n self.energy_cost = energy_cost\n end", "def interest\n return (@capital / 100) * @rate\n end", "def gain_interest\n @balance *= (1 + @interest_rate)\n end", "def initialize\n @rate = 0.90\n end", "def initial_cut_values\n end", "def range\n @fuel_capacity * @fuel_efficiency\n end", "def initialize()\n super\n @odata_type = \"#microsoft.graph.iPv6Range\"\n end", "def initialize(range)\n\t\t@secret_number = generate_secret_number(range.to_a)\n\tend", "def initialize\n\t\t@mult = 1.1\n @name = 'High Low'\n @min = 1\n @game_money = $player.wallet.amount #game_money\n @game_bet = 0\n\tend", "def range_weighting\n if @range.include?(25, 50)\n @weight_1 = 3\n elsif @range.include?(75, 100, 150)\n @weight_1 = 2\n else\n @weight_1 = 1\n end\n end", "def test_raw_range_1\r\n r = GerbilCharts::Models::RawRange.new\r\n\r\n \t[10,20,10,0,0,1001,19920,882991.22].each do |v|\r\n\t\tr.update v\r\n\tend\r\n\r\n\tr.min_max do |mn,mx|\r\n \tassert mn==0\r\n\t\tassert mx==882991.22\r\n\tend\r\n end", "def initialize\n @rate = 0.10\n end", "def add_interest(rate)\n @interest = @balance * (rate/100)\n return @interest\n end", "def gain_interest\n # Assuming 2% interest rate would be entered as 2,\n # Divide rate by 100, to create 0.02 -- then\n # Add 1, to create 1.02 -- then\n # Multiply @balance by 1.02\n\n interest_div = @interest_rate / 100.0 # changes 2 to 0.02\n\n interest_add = interest_div + 1 # changes 0.02 to 1.02\n\n @balance = @balance * interest_add\n\n puts \"Your money accumulated interest. Now your balance is $#{ @balance }.\"\n end", "def interest_part(balance, interest_rate)\n balance*(interest_rate/100)\n end", "def add_interest(rate)\n super(rate)\n end", "def initialize(args)\n @old_loan_amount = args[:old_loan_amount].to_f\n @periods = args[:periods].to_f\n @new_interest_rate = args[:new_interest_rate].to_f / 12\n @new_interest_rate_cash_out = args[:new_interest_rate_cash_out] / 12\n @lender_credit = args[:lender_credit].to_f\n @lender_credit_cashout = args[:lender_credit_cashout].to_f\n @estimated_closing_costs = args[:estimated_closing_costs].to_f\n @estimated_closing_costs_cash_out = args[:estimated_closing_costs_cash_out].to_f\n @current_home_value = args[:current_home_value].to_f\n @original_loan_date = args[:original_loan_date]\n @old_interest_rate = args[:old_interest_rate] / 12\n @start_due_date = (Time.zone.now + 2.months).beginning_of_month\n end", "def initialize(raw_range)\n super()\n @rmin=round_min(raw_range.rmin) if not raw_range.rmin.nil?\n @rmax=round_max(raw_range.rmax) if not raw_range.rmax.nil?\n @lmax=label_step if not raw_range.rmax.nil?\n end", "def initialize(min, max, value)\n @min = Osmosis.rational(min)\n @max = Osmosis.rational(max)\n @value = Osmosis.rational(value)\n end", "def set_rating_range range = nil\n raterange = case range\n when Array\n arr = range.sort\n Range.new arr.first, arr.last\n when Range\n range\n when nil\n (1..5)\n else\n raise ArgumentError, \"Must be a range, was: #{range}\"\n end\n\n (class << self; self; end).send(:define_method, :rating_range) do\n raterange\n end\n end", "def anticipated_interest(rate, periods)\n\t\t (1 - (( 1 / ( rate.to_f + 1 )) ** (1.0 / periods)))\n\t\tend", "def initialize(starting_balance)\n @balance = starting_balance\n end", "def initialize\n # Call function to generate the account number\n account_number_gen\n # Initialize instance variables\n @checking_account_balance = 0\n @saving_account_balance = 0\n @@total_accounts += 1\n @interest_rate = 0.01\n end", "def initialize(params={})\n super\n\n @current_angle = 0\n additional_params = params.fetch(:additional_params, {})\n min_max = additional_params.fetch(:range, {:min => 30, :max => 150})\n @angle_range = Range.new(min_max[:min],min_max[:max])\n end" ]
[ "0.62678915", "0.62436646", "0.60862696", "0.5999548", "0.5952319", "0.59145355", "0.5897231", "0.588389", "0.5871673", "0.5869507", "0.5796249", "0.5785077", "0.5765298", "0.5759728", "0.5718096", "0.57127565", "0.56963086", "0.5674858", "0.56551707", "0.56513184", "0.56332713", "0.56243384", "0.56205827", "0.56180024", "0.56103045", "0.5600438", "0.5596149", "0.5594888", "0.55932826", "0.5591649" ]
0.69512194
0
Returns top five tags for a program. First retrives tags, sorts them. Reverses list so goes in decreasing order then returns first five
def tfivetags tag_array = self.tags sort_array = tag_array.sort!{|a,b| a.reputation_for(:votes) <=> b.reputation_for(:votes)} sort_array.reverse! topfive = sort_array.take(5) topfive end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def top_n(n = 10)\n logger.info(\"Top #{n} tags requested\")\n tags = @stream_parser.hash_store.fresh_tags(@config[:tag_ttl])\n HashtagExtractor.extract_tags!(tags, n, @config[:case_sensitive])\n end", "def top_tags()\n get(:standard, {:method => \"tag.getTopTags\"})\n end", "def top_5\n count = @sentence.blips.group(:body).distinct.count\n percent = count.each {|k, v| count[k] = v / @sentence.blips_count.to_f }\n statistics = percent.sort_by { |k, v| v }.reverse[0..4].flatten.each { |k, v| puts \"#{k}: #{v}\" }\n end", "def top_expert_tags(number)\n ret = self.expertises.where(\"expert_score > 0\").order(expert_score: :desc)\n return ret if number.nil? || number < 1\n ret.limit number\n end", "def top_ten\n sorted = @person_array.sort { |a, b| a.awesomeness <=> b.awesomeness }\n sorted.reverse!\n return sorted[0..9] if sorted.size >= 10\n return sorted\n end", "def top_5_teams\n team_names = []\n teams = UserTeam.all.collect{|team| team.team_id}\n most_common_value = teams.uniq.sort_by{ |i| teams.count( i ) }.reverse[0..4]\n most_common_value.each do |team|\n team_names << get_team_name_by_id(Team.find(team).api_team_id)\n end\n team_names\nend", "def get_keywords(top_n)\n @weighted_keywords.sort_by {|_key, value| value}.reverse[1..top_n]\n end", "def sort_by_tag_count\n end", "def get_top_tags( params )\n xml = LastFM.get( \"track.getTopTags\", params )\n xml.find('toptags/tag').map do |tag|\n LastFM::Tag.from_xml( tag )\n end\n end", "def most_popular_tags(options = {})\n if all_tags = Tag.by_pseud(self).by_type(options[:categories]).canonical\n tags_with_count = {}\n all_tags.uniq.each do |tag|\n tags_with_count[tag] = all_tags.find_all{|t| t == tag}.size\n end\n all_tags = tags_with_count.to_a.sort {|x,y| y.last <=> x.last }\n options[:limit].blank? ? all_tags : all_tags[0..(options[:limit]-1)]\n end\n end", "def get_top_by_tag(tags, options={})\n api_response = @api_client.make_api_request(:GET, \"artist/byTag/top\", {:tags => tags}, options)\n @api_client.artist_digestor.nested_list_from_xml(api_response.content.tagged_results, :tagged_item, :tagged_results)\n end", "def top_tags\n lfm_path = \"artist.getTopTags&artist=#{@name}\"\n lfm_data = LastFm::fetch_data(lfm_path)\n return Tag.create_from_hash(Hash.from_xml(lfm_data)['lfm']['toptags']['tag']) \n end", "def top_three_recipes \n a = recipes.sort_by do |i| \n i.rating \n end \n a[-3..-1]\n end", "def top_three_recipes\n recipes_sorted_by_rating.reverse[0..2]\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 most_explored_tags(topic, tag_groups = [], limit = 5)\n # Take 5 mostly visited places\n most_visited = self.checkins.by_topic(topic.id).most.all(:limit => 5)\n most_visited_tags = sort_tags(tag_groups, most_visited.collect(&:restaurant)) \n\n # Take 5 mostly reviewed and loved places\n most_loved = self.reviews.by_topic(topic.id).most.all(:limit => 5) \n most_loved_tags = sort_tags(tag_groups, most_loved.collect(&:restaurant))\n \n # Take 5 recently explored places\n recent_explored = self.restaurants.by_topic(topic.id).recent.all(:limit => 5) \n recent_explored_tags = sort_tags(tag_groups, recent_explored)\n \n # Merge all tags (5 + 5 + 5) = 15 (At most)\n # Remove duplicates and pick 5 based on their frequencies\n (most_visited_tags + most_loved_tags + recent_explored_tags).sort_by{|a| a.last}.reverse.collect{|a| a.first}.uniq[0..4]\n end", "def top_5_leagues\n league_names = []\n leagues = UserLeague.all.collect{|league| league.league_id}\n most_common_value = leagues.uniq.sort_by{ |i| leagues.count( i ) }.reverse[0..4]\n most_common_value.each do |league|\n league_names << get_league_name_by_id(League.find(league).api_league_id)\n end\n league_names\nend", "def top_five(db)\r\n\t \tputs \"\\t -- Top Five -- \"\r\n\t \tputs \" - - Title - - Rating - - Comments - - \"\r\n\t\tmovie = db.execute(\"SELECT * FROM movies WHERE rating = 10 ORDER BY title ASC LIMIT 5\")\r\n\t\tmovie.each do |mov|\r\n\t\t\tprintf \" * %-13s| %-4s| %-5s\\n\", \"#{mov['title']}\", \"#{mov['rating']}\", \"#{mov['comments']}\"\r\n\t\tend\r\n\t\tputs\"-\"*60\r\n\tend", "def most_popular_tags(options = {})\n all_tags = []\n if options[:categories].blank?\n all_tags = self.tags + self.bookmark_tags\n else\n type_tags = []\n options[:categories].each do |type_name|\n type_tags << type_name.constantize.all\n end\n all_tags = [self.tags + self.bookmark_tags].flatten & type_tags.flatten\n end\n tags_with_count = {}\n all_tags.uniq.each do |tag|\n tags_with_count[tag] = all_tags.find_all{|t| t == tag}.size\n end\n all_tags = tags_with_count.to_a.sort {|x,y| y.last <=> x.last }\n popular_tags = options[:limit].blank? ? all_tags.collect {|pair| pair.first} : all_tags.collect {|pair| pair.first}[0..(options[:limit]-1)]\n end", "def top_templates\n cached = Rails.cache.read(\"top_five\")\n return cached unless cached.nil?\n\n end_date = Date.today\n start_date = (end_date - 90)\n ids = Plan.group(:template_id)\n .where(created_at: start_date..end_date)\n .order(\"count_id DESC\")\n .count(:id).keys\n\n top_five = Template.where(id: ids[0..4])\n .pluck(:title)\n cache_content(\"top_five\", top_five)\n top_five\n end", "def sorted_tags\n get_tags.sort_by {|k,v| v}.reverse.unshift [\"All items\", self.items.count]\n end", "def top_three_recipes\n self.recipes.sort_by {|info| info.rating}.pop(3)\n end", "def select_top_five\n ed1_ed2_merged = @ed1.merge(@ed2)\n top5_words = ed1_ed2_merged.sort_by{|k,v| -v}.first 5\n top5_words = Hash[*top5_words.flatten]\n final_list = Hash.new{}\n # If the typed_word isnt in the dictionary, replace 5th suggestion by typed_word \n if !working_dictionary.has_key?( @typed_name )\n top5_words.each_with_index { |(k,v),index|\n if index == (top5_words.length-1)\n final_list[@typed_name] = v*0.5\n else\n final_list[k] = v\n end\n }\n top5_words = final_list\n end\n @suggestion = top5_words\n return top5_words #Hash of words and corresponding score \n end", "def top_ten\n reverse_sort = self.sort.reverse\n return reverse_sort[0, 10]\n end", "def sort_by_tag_count_with_random_buckets\n end", "def getTop10AwesomePeeps\n @persons.sort!\n return @persons[-10..-1]\n end", "def get_top_tags( params )\n LastFM.get( \"chart.getTopTags\", params )\n end", "def top_three_recipes\n top_three = RecipeCard.all.select {|atr| atr.user == self}\n top_three.sort_by {|atr| atr.rating}.reverse\n top_three[0..2]\n end", "def five_recent_posts\n self.posts.sort_by(&:created_at).reverse.take(5)\n end", "def top_three_recipes\n my_recipes = self.recipe_cards\n my_recipes.sort{|a, b| b.rating <=> a.rating }.slice(0,3)\n end" ]
[ "0.70803016", "0.6474015", "0.64369416", "0.6420536", "0.62647617", "0.62500423", "0.6235832", "0.6220248", "0.62010163", "0.61992556", "0.61738396", "0.61587393", "0.6123773", "0.6121619", "0.6097213", "0.6092094", "0.60601467", "0.6058775", "0.6041148", "0.6008493", "0.6008493", "0.599758", "0.5996194", "0.5984044", "0.5975001", "0.59691924", "0.59570944", "0.59475297", "0.59334093", "0.59237736" ]
0.7779505
0
GET /dbconnections GET /dbconnections.json
def index @dbconnections = Dbconnection.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_user_connections\n request(Route.new(:GET, '/users/@me/connections'))\n end", "def index\n @connections = Connection.all(:include => :user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @connections }\n end\n end", "def index\n @connections = Connection.all\n end", "def index\n @connections = Connection.all\n end", "def connections(id={}, options={})\n options = parse_id(id, options)\n path = \"#{profile_path(options, false)}/connections\"\n get(path, options)\n end", "def connections\n\t\t# Find degree\n\t\tif params.has_key? 'degree'\n\t\t\tdegree = params['degree']\n\t\telse\n\t\t\tdegree = 1\n\t\tend\n\n\t\t# Get user id from the params\n\t\tuser_id = params[:user_id]\n\n\t\t# Get connections from graph\n\t\tconnections = { 1 => [{\"user\" => {id: 3}}] }\n\n\t\t# Get demos from couch\n\t\tdemographics = { 1 => 'asdljasd' }\n\n\t\t# Build JSON\n\t\trender json: connections_json(user_id, connections, demographics)\n\tend", "def connections_get(opts = {})\n data, _status_code, _headers = connections_get_with_http_info(opts)\n data\n end", "def connections\n @connections ||= {}\n end", "def connections\n @connections ||= {}\n end", "def db_info\n @conn.query({url_path: \"#{database}\", method: :get})\n end", "def connections\n attributes[:connections]\n end", "def connections(token)\n request(\n __method__,\n :get,\n \"#{api_base}/users/@me/connections\",\n Authorization: token\n )\n end", "def databases\n CouchRest.get \"#{@uri}/_all_dbs\"\n end", "def connections\n @_connections ||= {}\n end", "def connections\n @connections ||= []\n end", "def for_user(user_id)\n request(:get, \"/users/#{user_id}/connections\")\n end", "def all_dbs\n @conn.query({url_path: \"_all_dbs\", method: :get})\n end", "def find(id)\n request(:get, \"/connections/#{id}\")\n end", "def connection\n @db = Connection.client\nend", "def mget\n begin \n params.reject! {|key, value| ['controller', 'action', 'format'].include?(key)}\n @connections = []\n params.each do |key, value|\n @connections << {key: value, value: to_obj($redis.get(value)), ttl: $redis.ttl(value)}\n end \n rescue => e\n @connections = {status: 500, message: e.message }\n end \n\n respond_to do |format|\n format.json { render json: @connections }\n end\n end", "def databases\n get '_all_dbs'\n end", "def index\n @project_connections = ProjectConnection.all\n end", "def managed_connections\n @@managed_connections\n end", "def index\n @restconnections = Restconnection.all\n end", "def show\n @conn = current_user.conns.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @conn }\n end\n end", "def index\n @http_connections = HttpConnection.all\n end", "def show\n @connection = Connection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @connection }\n end\n end", "def connections_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConnectionsApi.connections_get ...'\n end\n # resource path\n local_var_path = '/connections'\n\n # query parameters\n query_params = {}\n query_params[:'expand'] = opts[:'expand'] if !opts[:'expand'].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/x-www-form-urlencoded'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse2009')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConnectionsApi#connections_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def connections\n @connection_pool\n end", "def available_connections(server=:default)\n @available_connections[server]\n end" ]
[ "0.68958914", "0.68502414", "0.6650843", "0.6650843", "0.66237944", "0.6618898", "0.66081554", "0.6596076", "0.6533316", "0.650765", "0.64756715", "0.6439214", "0.64370644", "0.62797177", "0.6266524", "0.62462723", "0.6208384", "0.61986357", "0.61429733", "0.6122683", "0.6113693", "0.6068133", "0.6049977", "0.6048331", "0.6018671", "0.60128456", "0.5928054", "0.58936125", "0.58880603", "0.5879799" ]
0.702668
0
PATCH/PUT /dbconnections/1 PATCH/PUT /dbconnections/1.json
def update respond_to do |format| if @dbconnection.update(dbconnection_params) format.html { redirect_to @dbconnection, notice: 'Dbconnection was successfully updated.' } format.json { render :show, status: :ok, location: @dbconnection } else format.html { render :edit } format.json { render json: @dbconnection.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @conn = current_user.conns.find(params[:id])\n\n respond_to do |format|\n if @conn.update_attributes(params[:conn])\n format.html { redirect_to @conn, notice: 'Conn was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @conn.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_database(options = {})\n throw ArgumentError.new('Required arguments :database_id missing') if options.dig(:database_id).nil?\n patch(\"databases/#{options[:database_id]}\", options.except(:database_id))\n end", "def update\n @connection = Connection.find(params[:id])\n\n respond_to do |format|\n if @connection.update_attributes(params[:connection])\n redirect_path = param(:redirect, edit_connection_path(@connection))\n\n format.html { redirect_to redirect_path, notice: 'Connection was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @connection.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_connection(connection_id, body)\n raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?\n path = \"#{connections_path}/#{connection_id}\"\n patch(path, body)\n end", "def update_db(struct)\n File.write('app/services/db/database.json', JSON.generate(struct))\n end", "def update\n respond_to do |format|\n if @connection.update(connection_params)\n format.html { redirect_to @connection, notice: \"Connection was successfully updated.\" }\n format.json { render :show, status: :ok, location: @connection }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @connection.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @connection_attributes = args[:connection_attributes] if args.key?(:connection_attributes)\n @database_service = args[:database_service] if args.key?(:database_service)\n @hostname = args[:hostname] if args.key?(:hostname)\n @password = args[:password] if args.key?(:password)\n @port = args[:port] if args.key?(:port)\n @username = args[:username] if args.key?(:username)\n end", "def update\n @database = Database.find(params[:id])\n load_parameter_groups\n \n respond_to do |format|\n if @database.update_attributes(params[:database])\n format.html { redirect_to @database, notice: 'Database was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @database.errors, status: :unprocessable_entity }\n end\n end\n end", "def connections_id_put(id, opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: ConnectionApi#connections_id_put ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling connections_id_put\" if id.nil?\n \n # resource path\n path = \"/connections/{id}\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'access_token'] = opts[:'access_token'] if opts[:'access_token']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'body'])\n \n\n auth_names = ['quantimodo_oauth2']\n result = @api_client.call_api(:PUT, 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 => 'inline_response_200_2')\n if Configuration.debugging\n Configuration.logger.debug \"API called: ConnectionApi#connections_id_put. Result: #{result.inspect}\"\n end\n return result\n end", "def update\n @database = Database.find(params[:id])\n respond_to do |format|\n if @database.update_attributes(params[:database])\n format.html { redirect_to @database, notice: 'Database was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @database.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @database = Database.find(params[:id])\n\n respond_to do |format|\n if @database.update_attributes(params[:database])\n format.html { redirect_to @database, :notice=> 'Database was successfully updated.' }\n format.json { render :head => :no_content }\n else\n format.html { render :action=> \"edit\" }\n format.json { render :json=> @database.errors, :status=> :unprocessable_entity }\n end\n end\n end", "def update\n @connection = Connection.find(params[:id])\n @connection.confirmed = true\n respond_to do |format|\n if @connection.update_attributes(params[:connection])\n format.html { redirect_to @connection, notice: 'Connection was successfully accepted.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @connection.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(database_id:, name:)\n path = '/databases/{databaseId}'\n .gsub('{databaseId}', database_id)\n\n if database_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"databaseId\"')\n end\n\n if name.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"name\"')\n end\n\n params = {\n name: name,\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'PUT',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::Database\n )\n end", "def update\n respond_to do |format|\n if @database.update(database_params)\n format.html { redirect_to admin_database_path(@database.id), success: I18n.t('admin.databases.controllers.update') }\n format.json { render :show, status: :ok, location: admin_database_path(@database) }\n else\n format.html { render :edit }\n format.json { render json: @database.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, @db_name\n respond_to do |format|\n if @db_name.update(db_name_params)\n format.html { redirect_to @db_name, notice: 'Database name was successfully updated.' }\n format.json { render :show, status: :ok, location: @db_name }\n else\n format.html { render :edit }\n format.json { render json: @db_name.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @mysql_rdbms = args[:mysql_rdbms] if args.key?(:mysql_rdbms)\n @oracle_rdbms = args[:oracle_rdbms] if args.key?(:oracle_rdbms)\n @postgresql_rdbms = args[:postgresql_rdbms] if args.key?(:postgresql_rdbms)\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def set_dbconnection\n @dbconnection = Dbconnection.find(params[:id])\n end", "def update\n @bdatabase = Bdatabase.find(params[:id])\n\n respond_to do |format|\n if @bdatabase.update_attributes(params[:bdatabase])\n format.html { redirect_to @bdatabase, notice: 'Bdatabase was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bdatabase.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_db_connection\n @db_connection = DbConnection.find(params[:db_connection_id])\n end", "def update!(**args)\n @bigquery_connection_spec = args[:bigquery_connection_spec] if args.key?(:bigquery_connection_spec)\n end", "def update_db\n require \"#{File.dirname(__FILE__)}/../conf/db_schema.rb\"\n Knj::Db::Revision.new.init_db(\"debug\" => false, \"db\" => @db, \"schema\" => Openall_time_applet::DB_SCHEMA)\n end", "def update!(**args)\n @postgresql_schemas = args[:postgresql_schemas] if args.key?(:postgresql_schemas)\n end", "def update!(**args)\n @json_schemas = args[:json_schemas] if args.key?(:json_schemas)\n @schema = args[:schema] if args.key?(:schema)\n end", "def update\n @network_connection = NetworkConnection.find(params[:id])\n\n respond_to do |format|\n if @network_connection.update_attributes(params[:network_connection])\n format.html { redirect_to @network_connection, :notice => 'Network connection was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @network_connection.errors, :status => :unprocessable_entity }\n end\n end\n end", "def reconcile_db_with_cluster\n rcs.each_value { |pods| pods.each_value { |pod| handle_pod_update(pod) } }\n end", "def update\n respond_to do |format|\n if @database.update(database_params)\n format.html { redirect_to @database, notice: 'Database was successfully updated.' }\n format.json { render action: 'show', status: :ok, location: @database }\n else\n format.html { render action: 'edit' }\n format.json { render json: @database.errors, status: :unprocessable_entity }\n end\n end\n end", "def sync_agi_fields_to_rds\n # you can only modify when the rds instances is available\n if state == 'available' and any_field_out_of_sync?\n rds_server = {\n :password => password,\n :allocated_storage => instance_storage,\n :multi_az => multi_az,\n :flavor_id => instance_class,\n :security_group_names => [self.security_group_name],\n# :security_group_names => ['dont-exist'], # this will produce a 422 from agifog\n }.reject!{|k,v| v.blank? }\n begin\n if database_client.update_attributes(rds_server)\n self.state = 'modifying'\n else\n self.state = 'error syncing'\n self.save\n end\n rescue\n database_client.errors.add(:base, \"It failed to update the attributes. #{rds_server.inspect}\")\n self.state = 'error syncing'\n self.save\n end\n \n database_client\n end\n end", "def update\n @schema = Schema.find(params[:id])\n\n respond_to do |format|\n if @schema.update_attributes(params[:schema])\n format.html { redirect_to @schema, :notice => 'Schema was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @schema.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @database = args[:database] if args.key?(:database)\n @name = args[:name] if args.key?(:name)\n @schema = args[:schema] if args.key?(:schema)\n end" ]
[ "0.6033953", "0.5773262", "0.5735879", "0.56939596", "0.5654367", "0.5561882", "0.54948896", "0.545159", "0.5427412", "0.542106", "0.54195255", "0.541788", "0.5337477", "0.5295491", "0.52849114", "0.52576256", "0.52550906", "0.52419597", "0.5218335", "0.5184007", "0.5178461", "0.51529014", "0.5147808", "0.51082265", "0.51061904", "0.510588", "0.5087607", "0.507517", "0.50720716", "0.506845" ]
0.60701644
0
DELETE /dbconnections/1 DELETE /dbconnections/1.json
def destroy @dbconnection.destroy respond_to do |format| format.html { redirect_to dbconnections_url, notice: 'Dbconnection was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @database = Database.find(params[:id])\n path = @database.path\n delete = %x[rm -R #{path}]\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @connection.destroy\n respond_to do |format|\n format.html { redirect_to connections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @connection = Connection.find(params[:id])\n @connection.destroy\n\n respond_to do |format|\n format.html { redirect_to connections_url }\n format.json { head :ok }\n end\n end", "def destroy\n @connection = Connection.find(params[:id])\n @connection.destroy\n\n respond_to do |format|\n format.html { redirect_to connections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @connection = Connection.find(params[:id])\n @connection.destroy\n\n respond_to do |format|\n format.html { redirect_to connections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @conn = current_user.conns.find(params[:id])\n @conn.destroy\n\n respond_to do |format|\n format.html { redirect_to conns_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @database = Database.find(params[:id])\n if @database.started\n @database_client = RdsServer.find(@database.name)\n @database_client.destroy\n end\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :ok }\n end\n end", "def destroy\n @database.destroy\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end", "def delete_db_post\n # Tell the user\n puts \"> Tar bort aliaset från databasen\".green\n\n # Connect to the database\n conn = PG.connect( dbname: DB_DATABASE_NAME, user: DB_USER, password: DB_PASSWORD )\n\n # Delete the account\n res = conn.exec \"DELETE FROM #{DB_ALIAS_TABLE} WHERE address = '#{$alias}' AND userid = '#{$email}'\" unless $simulate\n\n # Close the connection\n conn.close\nend", "def delete()\n db = PG connect( {dbname: 'bounty_hunter',\n host: 'localhost'\n })\n sql = 'DELETE from bounty_hunter'\n db.prepare('delete_one', sql)\n db.exec_prepared('delete_one', value)\n db.close()\nend", "def delete(name)\n @connections.delete(name)\n end", "def destroy\n @connection.destroy\n respond_to do |format|\n format.html { redirect_to connections_url, notice: \"Connection was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete_db_post account\n # Tell the user\n puts \"> Tar bort kontot från databasen\".green\n\n # Connect to the database\n conn = PG.connect( dbname: DB_DATABASE_NAME, user: DB_USER, password: DB_PASSWORD )\n\n # Delete the account\n res = conn.exec \"DELETE FROM #{DB_ACCOUNTS_TABLE} WHERE userid = '#{account['userid']}'\" unless $simulate\n\n # Close the connection\n conn.close\nend", "def destroy\n @users_db.destroy\n respond_to do |format|\n format.html { redirect_to users_dbs_url, notice: 'Users db was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @bdatabase = Bdatabase.find(params[:id])\n @bdatabase.destroy\n\n respond_to do |format|\n format.html { redirect_to bdatabases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @database = Database.find(params[:id])\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json {render :head => :no_content }\n end\n end", "def destroy\n @testdb = Testdb.find(params[:id])\n @testdb.destroy\n\n respond_to do |format|\n format.html { redirect_to testdbs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reference_database = ReferenceDatabase.find(params[:id])\n @reference_database.destroy\n\n respond_to do |format|\n format.html { redirect_to reference_databases_url }\n format.json { head :no_content }\n end\n end", "def delete(options={})\n connection.delete(\"/\", @name)\n end", "def destroy\n @database.destroy\n respond_to do |format|\n format.html { redirect_to databases_url, notice: 'La base de données à bien été supprimée.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @database.destroy\n respond_to do |format|\n format.html { redirect_to admin_databases_url, success: I18n.t('admin.databases.controllers.delete') }\n format.json { head :no_content }\n end\n end", "def delete *args, &block\n res = @conn.delete *args, &block\n handle res, parse: false\n end", "def delete(path)\n make_call(mk_conn(path), :delete)\n end", "def delete()\n db = PG.connect({ dbname: 'Music_Collection', host: 'localhost'})\n sql = \n \"\n DELETE FROM Music_Collection where id = #{@id};\n \"\n db.exec(sql)\n db.close()\nend", "def destroy\n @ad_crawling_db.destroy\n respond_to do |format|\n format.html { redirect_to ad_crawling_dbs_url, notice: 'Ad crawling db was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @database = Database.find(params[:id])\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to(databases_url) }\n end\n end", "def destroy\n @network_connection = NetworkConnection.find(params[:id])\n @network_connection.destroy\n\n respond_to do |format|\n format.html { redirect_to network_connections_url }\n format.json { head :ok }\n end\n end", "def delete_database\n options = {\n :query => {\n 'ZOHO_ACTION' => 'DELETEDATABASE',\n 'ZOHO_DATABASE_NAME' => database_name,\n }\n }\n send_request get_user_uri, 'post', options\n end", "def delete(database_id:)\n path = '/databases/{databaseId}'\n .gsub('{databaseId}', database_id)\n\n if database_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"databaseId\"')\n end\n\n params = {\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'DELETE',\n path: path,\n headers: headers,\n params: params,\n )\n end", "def delete_connection(connection_id)\n raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?\n path = \"#{connections_path}/#{connection_id}\"\n delete(path)\n end" ]
[ "0.69439733", "0.69002515", "0.6897783", "0.6878138", "0.6878138", "0.687534", "0.66737294", "0.664973", "0.66385597", "0.6609321", "0.66073114", "0.6604616", "0.6591177", "0.6538945", "0.65093905", "0.65041196", "0.64475095", "0.6403054", "0.63999814", "0.6395681", "0.6386844", "0.6352042", "0.63489914", "0.6331876", "0.63015753", "0.6290991", "0.6287606", "0.6287019", "0.6280896", "0.62762874" ]
0.7241203
0
Updates all rows that match the filters Fusion tables API allows to update one row (or the full table) per query.
def update(filters, properties, context) properties_query = properties.map{|k,v| "'#{k}' = '#{v}'"}.join(', ') row_ids = query_row_ids(filters) row_ids.each do |row_id| body = "sql=UPDATE #{@id} SET #{properties_query} WHERE ROWID = '#{row_id}'" connector.post "https://www.googleapis.com/fusiontables/v2/query", body end row_ids.count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update fields, primaryFilter = nil, orFilter = nil, andFilter = nil, notFilter = nil\n\t\tfields.delete_if {|key, value| !@validFields.include? key}\n\n\t\tif fields.count > 0\n\t\t\tbegin\n\t\t\t\tquery = \"UPDATE #{@table} SET\"\n\t\t\t\tfields.each {|key, value| query += \" #{key}='#{value}',\"}\n\t\t\t\ttimestamp = Time.now\n\t\t\t\tquery += \"updated='#{timestamp}'\"\n\n\t\t\t\tif primaryFilter\n\t\t\t\t\tquery += \" WHERE #{primaryFilter[0]}='#{primaryFilter[1]}'\"\n\n\t\t\t\t\tif orFilter\n\t\t\t\t\t\torFilter.each {|key, value| query += \" OR #{key}='#{value}'\"}\n\t\t\t\t\tend\n\n\t\t\t\t\tif andFilter\n\t\t\t\t\t\tandFilter.each {|key, value| query += \" AND #{key}='#{value}'\"}\n\t\t\t\t\tend\n\n\t\t\t\t\tif notFilter\n\t\t\t\t\t\tnotFilter.each {|key, value| query += \" AND NOT #{key}='#{value}'\"}\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t@dbh.query query\n\t\t\t\ttrue\n\t\t\trescue => e\n\t\t\t\tputs \"Error: #{e.error}\"\n\t\t\t\tfalse\n\t\t\tend\n\t\tend\n\tend", "def update\n @filter = Filter.find(params[:id])\n \n where = Hash.new\n columns = []\n params.each do |param, value|\n if (param.include?('with_')) && (!value.nil?)\n where[param] = value\n end \n \n if (param.include?('column_')) && (!value.nil?)\n columns << \"#{value}\"\n end\n end\n\n @filter.where = where \n @filter.columns = \"'#{columns.join(\",\")}'\"\n\n respond_to do |format|\n if @filter.update_attributes(params[:filter])\n format.html { redirect_to(filters_path, :notice => 'Project was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @filter.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_all(table, table_hash, values = {}, conditions = {})\n\t\t\t ctx = 0\n\t\t\t\tlen = table.length - 1\n\t\t\t\t\n\t\t\t\tfor i in 0..len\n\t\t\t\t\tupdate = true\n\t\t\t\t\t\n\t\t\t\t\tconditions.each do |key, val|\n\t\t\t\t\t\tif (table[i][table_hash[key]] != val)\n\t\t\t\t\t\t\tupdate = false\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\tif (update)\n\t\t\t\t\t\tvalues.each do |field, val|\n\t\t\t\t\t\t\ttable[i][table_hash[field]] = val\n\t\t\t\t\t\tend\n\t\t\t\t\t\tctx = ctx + 1\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn ctx\n\t\t\tend", "def update_many(filter, update, options = nil)\n result = native.update_many(filter, update, options || {})\n update_result(result)\n end", "def update(*updates, &select_cond)\r\n raise ArgumentError, \"Must specify select condition code \" + \\\r\n \"block. To update all records, use #update_all instead.\" if \\\r\n select_cond.nil?\r\n\r\n # Update the header variables.\r\n update_header_vars\r\n\r\n # Get all records that match the selection criteria and\r\n # return them in an array.\r\n result_set = get_matches(:update, @field_names, select_cond)\r\n\r\n # If updates is empty, this means that the user must have specified\r\n # the updates in KBResultSet#set, i.e.\r\n # tbl.update {|r| r.recno == 1}.set(:name => 'Bob')\r\n return result_set if updates.empty?\r\n\r\n # Call KBTable#set and pass it the records to be updated and the\r\n # updated criteria.\r\n set(result_set, updates)\r\n end", "def update!(**args)\n @row_filter_applied = args[:row_filter_applied] if args.key?(:row_filter_applied)\n @sampling_percent = args[:sampling_percent] if args.key?(:sampling_percent)\n end", "def update!(**args)\n @column_filter_applied = args[:column_filter_applied] if args.key?(:column_filter_applied)\n @row_filter_applied = args[:row_filter_applied] if args.key?(:row_filter_applied)\n @sampling_percent = args[:sampling_percent] if args.key?(:sampling_percent)\n end", "def update data, table, condition = {}\n sql = \"update #{table} set\"\n data.each do |k,v|\n v = v.to_json if v.is_a?(Hash)\n if !!v == v\n sql = \"#{sql} #{k}=#{v},\"\n else\n sql = \"#{sql} #{k}='#{v}',\"\n end\n end\n sql = sql[0..-2] + \" where\"\n condition.each do |k,v|\n sql = \"#{sql} #{k} = '#{v}' and\"\n end\n query(sql[0..-4])\n end", "def update\n @report_request = ReportRequest.find(params[:report_request][:id])\n @fields = params[:field_filter]\n\n @fields.each do |k, v|\n field_filter = @report_request.field_filter(k.to_i)\n field_filter.update_attributes(v)\n end\n \n respond_to do |format|\n format.html\n format.xml { head :ok }\n end\n end", "def update!(**args)\n @exclude_fields = args[:exclude_fields] if args.key?(:exclude_fields)\n @include_fields = args[:include_fields] if args.key?(:include_fields)\n @post_scan_actions = args[:post_scan_actions] if args.key?(:post_scan_actions)\n @row_filter = args[:row_filter] if args.key?(:row_filter)\n @sampling_percent = args[:sampling_percent] if args.key?(:sampling_percent)\n end", "def update\n @filter = current_user.queries.find(params[:query_id]).filters.find(params[:id])\n @query = current_user.queries.find(params[:query_id])\n\n respond_to do |format|\n if @filter.update_attributes(params[:filter])\n format.html { redirect_to @query, notice: 'Filter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @filter.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @filter = args[:filter] if args.key?(:filter)\n @match = args[:match] if args.key?(:match)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @filter_created = args[:filter_created] if args.key?(:filter_created)\n @filter_deleted = args[:filter_deleted] if args.key?(:filter_deleted)\n @filter_id = args[:filter_id] if args.key?(:filter_id)\n end", "def update!(**args)\n @results_table = args[:results_table] if args.key?(:results_table)\n end", "def update!(**args)\n @results_table = args[:results_table] if args.key?(:results_table)\n end", "def update!(**args)\n @column_headers = args[:column_headers] if args.key?(:column_headers)\n @contains_sampled_data = args[:contains_sampled_data] if args.key?(:contains_sampled_data)\n @data_last_refreshed = args[:data_last_refreshed] if args.key?(:data_last_refreshed)\n @data_table = args[:data_table] if args.key?(:data_table)\n @id = args[:id] if args.key?(:id)\n @items_per_page = args[:items_per_page] if args.key?(:items_per_page)\n @kind = args[:kind] if args.key?(:kind)\n @next_link = args[:next_link] if args.key?(:next_link)\n @previous_link = args[:previous_link] if args.key?(:previous_link)\n @profile_info = args[:profile_info] if args.key?(:profile_info)\n @query = args[:query] if args.key?(:query)\n @rows = args[:rows] if args.key?(:rows)\n @sample_size = args[:sample_size] if args.key?(:sample_size)\n @sample_space = args[:sample_space] if args.key?(:sample_space)\n @self_link = args[:self_link] if args.key?(:self_link)\n @total_results = args[:total_results] if args.key?(:total_results)\n @totals_for_all_results = args[:totals_for_all_results] if args.key?(:totals_for_all_results)\n end", "def update!(**args)\n @delete_all_data_from_table = args[:delete_all_data_from_table] if args.key?(:delete_all_data_from_table)\n @row_key_prefix = args[:row_key_prefix] if args.key?(:row_key_prefix)\n end", "def process_updates(table_name, field, rows)\n ActiveRecord::Base.transaction do\n mass_import(rows)\n mass_update(table_name, field)\n end\n end", "def update!(**args)\n @custom_column_headers = args[:custom_column_headers] if args.key?(:custom_column_headers)\n @field_mask = args[:field_mask] if args.key?(:field_mask)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @results = args[:results] if args.key?(:results)\n @summary_row = args[:summary_row] if args.key?(:summary_row)\n @total_results_count = args[:total_results_count] if args.key?(:total_results_count)\n end", "def update!(**args)\n @post_scan_actions = args[:post_scan_actions] if args.key?(:post_scan_actions)\n @row_filter = args[:row_filter] if args.key?(:row_filter)\n @rules = args[:rules] if args.key?(:rules)\n @sampling_percent = args[:sampling_percent] if args.key?(:sampling_percent)\n end", "def call(_obj, args, _ctx)\n\n update_table = Table.find(args[:table_id])\n return update_table if update_table.update_attributes(name: args[:name], quantity: args[:quantity])\n GraphQL::ExecutionError.new(\"invalid data\")\n end", "def update!(**args)\n @filter = args[:filter] if args.key?(:filter)\n @force = args[:force] if args.key?(:force)\n end", "def update!(**args)\n @filter = args[:filter] if args.key?(:filter)\n @force = args[:force] if args.key?(:force)\n end", "def update!(**args)\n @filter = args[:filter] if args.key?(:filter)\n @force = args[:force] if args.key?(:force)\n end", "def update!(**args)\n @filter = args[:filter] if args.key?(:filter)\n @force = args[:force] if args.key?(:force)\n end", "def update!(**args)\n @filter = args[:filter] if args.key?(:filter)\n end", "def update!(**args)\n @filter = args[:filter] if args.key?(:filter)\n end", "def set(recs, data)\r\n # If updates are not in the form of a Proc, convert updates, which\r\n # could be an array, a hash, or a Struct into a common format (i.e.\r\n # hash).\r\n update_rec = convert_input_data(data) unless data.is_a?(Proc)\r\n\r\n updated_recs = []\r\n\r\n # For each one of the recs that matched the update query, apply the\r\n # updates to it and write it back to the database table.\r\n recs.each do |rec|\r\n temp_rec = rec.dup\r\n\r\n if data.is_a?(Proc)\r\n begin\r\n data.call(temp_rec)\r\n rescue NoMethodError\r\n raise 'Invalid field name in code block: %s' % $!\r\n end\r\n else\r\n @field_names.each { |fn| temp_rec[fn] = update_rec.fetch(fn,\r\n temp_rec.send(fn)) }\r\n end\r\n\r\n # Is the user trying to change something they shouldn't?\r\n raise 'Cannot update recno field!' unless \\\r\n rec.recno == temp_rec.recno\r\n raise 'Cannot update internal fpos field!' unless \\\r\n rec.fpos == temp_rec.fpos\r\n raise 'Cannot update internal line_length field!' unless \\\r\n rec.line_length == temp_rec.line_length\r\n\r\n # Are the data types of the updates correct?\r\n validate_input(temp_rec)\r\n\r\n check_required_fields(temp_rec)\r\n\r\n check_against_input_for_specials(temp_rec)\r\n\r\n # Apply updates to the record and add it to an array holding\r\n # updated records. We need the fpos and line_length because\r\n # the engine will use them to determine where to write the\r\n # update and whether the updated record will fit in the old\r\n # record's spot.\r\n updated_recs << { :rec => @field_names.zip(@field_types\r\n ).collect { |fn, ft| convert_to_encoded_string(ft,\r\n temp_rec.send(fn)) }, :fpos => rec.fpos,\r\n :line_length => rec.line_length }\r\n \r\n\r\n # Update any associated blob/memo fields.\r\n temp_rec.each { |r| r.write_to_file if r.is_a?(KBMemo) } if \\\r\n @field_types.include?(:Memo)\r\n temp_rec.each { |r| r.write_to_file if r.is_a?(KBBlob) } if \\\r\n @field_types.include?(:Blob)\r\n end\r\n\r\n # Take all of the update records and write them back out to the\r\n # table's file.\r\n @db.engine.update_records(self, updated_recs)\r\n\r\n # Return the number of records updated.\r\n return recs.size\r\n end", "def update!(**args)\n @custom_property_filter = args[:custom_property_filter] if args.key?(:custom_property_filter)\n @custom_weights_metadata = args[:custom_weights_metadata] if args.key?(:custom_weights_metadata)\n @document_creator_filter = args[:document_creator_filter] if args.key?(:document_creator_filter)\n @document_name_filter = args[:document_name_filter] if args.key?(:document_name_filter)\n @document_schema_names = args[:document_schema_names] if args.key?(:document_schema_names)\n @file_type_filter = args[:file_type_filter] if args.key?(:file_type_filter)\n @folder_name_filter = args[:folder_name_filter] if args.key?(:folder_name_filter)\n @is_nl_query = args[:is_nl_query] if args.key?(:is_nl_query)\n @property_filter = args[:property_filter] if args.key?(:property_filter)\n @query = args[:query] if args.key?(:query)\n @query_context = args[:query_context] if args.key?(:query_context)\n @time_filters = args[:time_filters] if args.key?(:time_filters)\n end", "def update!(**args)\n @filters = args[:filters] if args.key?(:filters)\n @histogram_query = args[:histogram_query] if args.key?(:histogram_query)\n @require_precise_result_size = args[:require_precise_result_size] if args.key?(:require_precise_result_size)\n end" ]
[ "0.67211056", "0.63926464", "0.61972994", "0.61657256", "0.61490434", "0.6070133", "0.6061933", "0.6048157", "0.60130066", "0.5968238", "0.5954518", "0.5895627", "0.5850135", "0.58406407", "0.58406407", "0.5833867", "0.58309954", "0.58128476", "0.5805329", "0.57926303", "0.5783038", "0.5748468", "0.5748468", "0.5748468", "0.5748468", "0.57469934", "0.5746352", "0.5744422", "0.5731622", "0.573006" ]
0.75811315
0
Deletes all rows that match the filters Fusion tables API allows to delete one row (or the full table) per query.
def delete(filters, user) if filters.empty? body = "sql=DELETE FROM #{@id}" connector.post "https://www.googleapis.com/fusiontables/v2/query", body else row_ids = query_row_ids(filters) row_ids.each do |row_id| body = "sql=DELETE FROM #{@id} WHERE ROWID = '#{row_id}';" connector.post "https://www.googleapis.com/fusiontables/v2/query", body end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_all_rows\n scan.each do |row|\n delete_row(row['key'])\n end\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_all(table)\n\t\t\t\ttable.clear\n\t\t\tend", "def flush_records!(filter)\n raise ArgumentError, \"filter cannot be empty\" if filter.blank?\n\n where(filter).delete_all\n end", "def delete_all(condition=nil)\n if condition\n query(\"DELETE FROM #{SmartSession::SqlSession.table_name} WHERE #{condition}\")\n else\n query(\"DELETE FROM #{SmartSession::SqlSession.table_name}\")\n end\n end", "def delete_rows(t, rows)\n case rows\n when Integer\n t.delete rows\n when Array\n mode = t.mode\n t.by_row!\n\n will_delete = rows.map{|n| t[n]}\n t.delete_if do |row|\n will_delete.find do |del_row|\n del_row == row\n end\n end\n\n set_mode!(mode, t)\n else\n throw \"Unsupported type '#{rows.class}' in skiprows.\"\n end\n end", "def delete(table, ids) # abstract\n end", "def delete options\n table = DB.from(@table)\n \n if options[:where]\n result = table.where(options[:where]).delete\n else\n result = table.where(:id => options[:id]).delete\n end\n \n # invalidate a cached range\n @@_cached_range = nil\n \n return true if result == 1\n false\n end", "def batch_delete_rows(rows, per_page=100)\n begin\n batch_modify_rows('delete', rows, per_page)\n rescue VeritableError => e\n if (not e.respond_to?(:http_code)) or (not (e.http_code == \"404 Resource Not Found\"))\n raise e\n end\n end\n end", "def delete_all!\n delete(query: \"*:*\")\n end", "def delete_records where: {} , **args\n\t\tif args[:all] == true \n\t\t\twhere = {}\n\t\telse\n\t\t\twhere.merge!(args) if where.is_a?(Hash)\n\t\t\treturn 0 if where.empty?\n\t\tend\n orientdb.delete_records( self, where: where ).count\n\tend", "def delete_all\n records.clear\n end", "def delete_all\n klass.delete_all(:conditions => selector)\n end", "def delete_all\n begin\n db.execute \"TRUNCATE TABLE #{table}\"\n\n rescue SQLite3::Exception => e\n puts \"Database Exception occured\"\n puts e\n \n ensure\n db.close if db\n end\n end", "def delete\n %w[\n hathi_isbn\n hathi_issn\n hathi_lccn\n hathi_oclc\n hathi_title\n hathi_enumc\n hathi_pubdate\n hathi_publisher\n hathi_sudoc\n hathi_related\n hathi_gd\n ].each do |tablename|\n sql = \"DELETE FROM #{tablename}\";\n q = @conn.prepare(sql);\n puts sql;\n q.execute();\n end\nend", "def delete(table, where)\n self.query(@args[:db].delete(table, where, :return_sql => true))\n return nil\n end", "def delete_all\n solr.delete_by_query('*:*')\n solr.commit\n end", "def db_remove\n \"DELETE\" + from_table_where + sql_match_conditions\n end", "def delete_all(conditions = \"\")\n collection.remove(XGen::SQL::Parser.parse_where(conditions, true) || {})\n end", "def delete table, keys = [], transaction_id: nil\n commit transaction_id: transaction_id do |c|\n c.delete table, keys\n end\n end", "def delete\n\n DB.execute(\"DELETE FROM #{table_name} WHERE id = #{@id};\")\n end", "def delete_entries(entries)\n delete_all(:id => entries)\n end", "def delete_from_table(table, ids)\n return if ids.blank?\n @logger.info(\"Deleting #{ids.size} records from #{table}\")\n groups = ids.to_a.in_groups_of(10000)\n groups.each_with_index do |group, i|\n sleep(0.5) if i > 0 # throttle so we don't kill the DB\n delete_query = <<-SQL\n DELETE FROM `#{table}` WHERE `id` IN (#{group.compact.join(',')})\n SQL\n ActiveRecord::Base.connection.delete(delete_query)\n end\n\n @logger.info(\"Finished deleting from #{table}\")\n end", "def purge_in_batches!\n scope = model\n scope = scope.where(@table.conditions) if @table.conditions\n\n instrumentation_name = 'next_batch.db_purger'\n start_instrumentation(instrumentation_name)\n\n scope.find_in_batches(batch_size: @table.batch_size) do |batch|\n finish_instrumentation(\n instrumentation_name,\n table_name: @table.name,\n num_records: batch.size\n )\n\n batch = ActiveSupport::Notifications.instrument('search_filter.db_purger',\n table_name: @table.name,\n num_records: batch.size) do |payload|\n records_selected = @table.search_proc.call(batch)\n payload[:num_records_selected] = records_selected.size\n records_selected\n end\n\n if batch.empty?\n start_instrumentation(instrumentation_name)\n next\n end\n\n purge_nested_tables(batch) if @table.nested_tables?\n delete_records(batch)\n\n start_instrumentation(instrumentation_name)\n end\n\n finish_instrumentation(\n instrumentation_name,\n table_name: @table.name,\n num_records: 0,\n num_selected: 0\n )\n end", "def delete_all\n delete_if { |b| true }\n end", "def delete_all(conditions = nil)\n sql = \"DELETE FROM #{table_name} \"\n add_conditions!(sql, conditions)\n connection.delete(sql, \"#{name} Delete all\")\n end", "def delete_records(table_name, condition)\n raise \"implement in subclass\"\n end", "def delete(table, table_hash, conditions = {})\n\t\t\t\tlen = table.length - 1\n\n\t\t\t\tlen.downto(0) { |i|\n\t\t\t\t del = true\n\t\t\t\t \n\t\t\t\t\tconditions.each do |key, val|\n\t\t\t\t\t\tif (table[i][table_hash[key]] != val)\n\t\t\t\t\t\t\tdel = false\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n \n\t\t\t\t\tif (del)\n\t\t\t\t\t\ttable.delete_at(i)\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\tend", "def deleteAll\n Record.destroy_all()\n redirect_to(records_path)\n end", "def delete_entries(entries)\n all(:id => entries.map(&:id)).destroy!\n end" ]
[ "0.68353295", "0.6697708", "0.6664171", "0.65398586", "0.63981646", "0.629781", "0.61911917", "0.6163794", "0.616038", "0.61579424", "0.6157443", "0.6136011", "0.6101532", "0.6075276", "0.60449356", "0.6029529", "0.6002066", "0.60008585", "0.59819615", "0.59475535", "0.5941973", "0.59310764", "0.58801514", "0.5880136", "0.5857272", "0.5854786", "0.5851989", "0.5847917", "0.58450705", "0.58118814" ]
0.79908174
0
Public Methods Loaders Registers a loader to the registry.
def add_loader(loader) @loaders << loader end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loader(&block)\n loader_class.class_eval(&block)\n\n self\n end", "def initialize(loader)\n @loader = loader\n end", "def initialize(loader)\n @loader = loader\n end", "def loader; end", "def add_loader(ext, loader)\n ext = \".#{ext}\" unless ext =~ /^\\./\n @loaders[ext] = loader\n end", "def asigna_loader\n nombre_loader = self.class.name.demodulize.downcase\n self.loader = Soulmate::Loader.new(nombre_loader)\n Rails.logger.debug \"[DEBUG] - Loader: #{loader.inspect}\"\n end", "def loader\n\t\t@loader ||= self.class.get_loader\n\tend", "def define_loader(klass)\n self\n end", "def initialize(parent_loader, loaders, module_name, path, loader_name, loadables = LOADABLE_KINDS)\n super\n @path_index = Set.new\n end", "def define_loader_for(name)\n define_method(\"full_#{name}\") do\n if send(\"has_loaded_#{name}?\")\n instance_variable_get(\"@#{name}\")\n else\n instance_variable_set(\"@#{name}_load_state\", true)\n instance_variable_set(\"@#{name}\", load_associated(name))\n end\n end\n end", "def loader\n @loader ||= self.respond_to?(:load) ? self : instantiate(self.class.get_loader)\n end", "def instance_loader(type)\n @autoloaders[type.intern]\n end", "def initialize(parent_loader, loaders, module_name, path, loader_name, loadables)\n super(parent_loader, loader_name, loaders.environment)\n\n raise ArgumentError, 'path based loader cannot be instantiated without a path' if path.nil? || path.empty?\n\n @module_name = module_name\n @path = path\n @smart_paths = LoaderPaths::SmartPaths.new(self)\n @loaders = loaders\n @loadables = loadables\n unless (loadables - LOADABLE_KINDS).empty?\n #TRANSLATORS 'loadables' is a variable containing loadable modules and should not be translated\n raise ArgumentError, _('given loadables are not of supported loadable kind')\n end\n loaders.add_loader_by_name(self)\n end", "def loaders\n @loaders ||= profile.loaders\n end", "def loader(dump)\n loader_class.new(self, dump)\n end", "def add(location)\n $LOAD_MANAGER.add(location)\n end", "def loader\n render plain: 'loaderio-8fd226ca0551bbb679e5234f2b165e72'\n end", "def eager_load_all\n Registry.loaders.each(&:eager_load)\n end", "def loading(path)\n load_map[path] = Thread.current unless load_map.key? path\n end", "def load_all\n @internal_loader.load_all(self)\n end", "def add_lazy_loader(loader, attributes=nil)\n # guard against invalid call\n if identifier.nil? then raise ValidationError.new(\"Cannot add lazy loader to an unfetched domain object: #{self}\") end\n # the attributes to lazy-load\n attributes ||= loadable_attributes\n return if attributes.empty?\n # define the reader and writer method overrides for the missing attributes\n pas = attributes.select { |pa| inject_lazy_loader(pa) }\n logger.debug { \"Lazy loader added to #{qp} attributes #{pas.to_series}.\" } unless pas.empty?\n end", "def get_loader(name)\n @loaders.each do |loader|\n return loader if loader.name == name\n end\n end", "def loader\n @loader ||= Knife::Core::ObjectLoader.new(DataBagItem, ui)\n end", "def remove_loader(loader)\n @loaders.delete(loader)\n end", "def loader(**options)\n branch loader: options\n end", "def load_all\n @leagues = @loader.load unless @loader.nil?\n end", "def loader=( new_loader )\n\t\tif new_loader.is_a?( Arrow::Config::Loader )\n\t\t\t@loader = new_loader\n\t\telse\n\t\t\t@loader = self.class.get_loader( new_loader )\n\t\tend\n\tend", "def load!\n class_names.each { |name| self[name] }\n end", "def autoloaders; end", "def load_manager\n $LOAD_MANAGER\n end" ]
[ "0.67400885", "0.6655346", "0.66453356", "0.66352314", "0.65428376", "0.6492528", "0.64635295", "0.6419205", "0.63150716", "0.62103194", "0.61982584", "0.6175811", "0.6127616", "0.61166793", "0.6102317", "0.602925", "0.5972352", "0.58875895", "0.5853569", "0.5842131", "0.5837752", "0.57695895", "0.5758115", "0.5754267", "0.57446414", "0.57302415", "0.5688284", "0.5593681", "0.5593067", "0.55742073" ]
0.76817465
0
Unregisters a loader from the registry.
def remove_loader(loader) @loaders.delete(loader) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unregister\n Registry.unregister_loader(self)\n ExplicitNamespace.unregister_loader(self)\n end", "def unload(inst)\n # If the reference count drops to zero, remove it from the list of\n # loaded plugins. This will indirectly call the cleanup method on the\n # plugin.\n if (inst.deref == true)\n delete(inst)\n end\n end", "def unregister(path)\n\t\t\t\tpath = path.to_sym\n\t\t\t\tif @@registry[path]\n\t\t\t\t\t@@registry_count[path] -= 1\n\t\t\t\t\tif @@registry_count[path] <= 0\n\t\t\t\t\t\tsub = @@registry.delete(path)\n\t\t\t\t\t\tsub.unsubscribe\n\t\t\t\t\t\t@@registry_count.delete(path)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend", "def unregister\n @is_registered = false\n self\n end", "def unload\n Unit.unload(self.label)\n end", "def registry_unloadkey(key)\n if session_has_registry_ext\n meterpreter_registry_unloadkey(key)\n else\n shell_registry_unloadkey(key)\n end\n end", "def unload!(path)\n component_wrap = ComponentWrap.from_path(self, path)\n if component_wrap\n info \"Unloading: #{component_wrap.raw_component.name} from #{path}\"\n component_wrap.unload!\n @loaded_components.delete(component_wrap)\n end\n end", "def unload name\n raise \"Cannot unload: No such script #{name}\" unless @scripts.key? name\n\n @scripts[name].die if @scripts[name].respond_to? \"die\"\n\n Events.dispatch_for @scripts[name], :unloading\n\n Events.delete_for @scripts[name]\n URL.delete_for @scripts[name] if defined? MODULE_LOADED_URL_HANDLER\n RegexHandlerManager.delete_for @scripts[name] if defined? MODULE_LOADED_REGEX_HANDLER\n\n @scripts[name].unregister_script\n @scripts[name].unregister_commands\n @scripts[name].unregister_events\n\n @scripts.delete name\n end", "def un_load\n\n NSLog('Whatever hasn\\'t been unloaded and could be better be now!')\n NSLog('We probably don\\'t need this now that we\\'re using RubyMotion and it\\'s awesome!')\n\n end", "def unregister(symbol); end", "def shell_registry_unloadkey(key)\n key = normalize_key(key)\n shell_registry_cmd_result(\"unload \\\"#{key}\\\"\")\n end", "def unload name\n raise \"Cannot unload: No such script #{name}\" unless @scripts.has_key? name\n\n @scripts[name].die if @scripts[name].respond_to? \"die\"\n\n @scripts[name].unregister_script\n @scripts[name].unregister_commands\n @scripts[name].unregister_events\n\n @scripts.delete name\n end", "def exit_load\n load_stack.pop\n end", "def unregister(slice_module)\n if (slice = self[slice_module]) && self.paths.delete(module_name = slice.name)\n slice.loadable_files.each { |file| Merb::Slices::Loader.remove_classes_in_file file }\n Object.send(:remove_const, module_name)\n unless Object.const_defined?(module_name)\n Merb.logger.info!(\"Unregistered slice #{module_name}\")\n Merb::Slices::Loader.reload_router!\n end\n end\n end", "def unregister(*args, &block)\n h = Unobservable.handler_for(*args, &block)\n index = @handlers.index(h)\n if index\n @handlers.slice!(index)\n return h\n else\n return nil\n end\n end", "def pop_reg reg\n @fisk.pop reg.to_register\n end", "def unregister_type\n types_list.delete self\n end", "def loaded(path)\n load_map.delete path\n end", "def unload!\n cache.save if @__cache\n __send__ :unloaded if respond_to? :unloaded\n\n @__cache = nil\n end", "def unregister(const)\n @@extensions.delete(const)\n end", "def del_reg(id)\n _registers.delete(id)\n end", "def unregister_bundle_processor(mime_type, klass)\n expire_index!\n\n if klass.is_a?(String) || klass.is_a?(Symbol)\n klass = @bundle_processors[mime_type].detect { |cls|\n cls.respond_to?(:name) &&\n cls.name == \"Sprockets::Processor (#{klass})\"\n }\n end\n\n @bundle_processors[mime_type].delete(klass)\n end", "def unregister_processor(*args)\n unregister_preprocessor(*args)\n end", "def unload\n mutex.synchronize do\n # We are going to keep track of the files that were required by our\n # autoloads to later remove them from $LOADED_FEATURES, thus making them\n # loadable by Kernel#require again.\n #\n # Directories are not stored in $LOADED_FEATURES, keeping track of files\n # is enough.\n unloaded_files = Set.new\n\n autoloads.each do |abspath, (parent, cname)|\n if parent.autoload?(cname)\n unload_autoload(parent, cname)\n else\n # Could happen if loaded with require_relative. That is unsupported,\n # and the constant path would escape unloadable_cpath? This is just\n # defensive code to clean things up as much as we are able to.\n unload_cref(parent, cname)\n unloaded_files.add(abspath) if ruby?(abspath)\n end\n end\n\n to_unload.each do |cpath, (abspath, (parent, cname))|\n # We have to check cdef? in this condition. Reason is, constants whose\n # file does not define them have to be kept in to_unload as explained\n # in the implementation of on_file_autoloaded.\n #\n # If the constant is not defined, on_unload should not be triggered\n # for it.\n if !on_unload_callbacks.empty? && cdef?(parent, cname)\n value = parent.const_get(cname)\n run_on_unload_callbacks(cpath, value, abspath)\n end\n\n unload_cref(parent, cname)\n unloaded_files.add(abspath) if ruby?(abspath)\n end\n\n unless unloaded_files.empty?\n # Bootsnap decorates Kernel#require to speed it up using a cache and\n # this optimization does not check if $LOADED_FEATURES has the file.\n #\n # To make it aware of changes, the gem defines singleton methods in\n # $LOADED_FEATURES:\n #\n # https://github.com/Shopify/bootsnap/blob/master/lib/bootsnap/load_path_cache/core_ext/loaded_features.rb\n #\n # Rails applications may depend on bootsnap, so for unloading to work\n # in that setting it is preferable that we restrict our API choice to\n # one of those methods.\n $LOADED_FEATURES.reject! { |file| unloaded_files.member?(file) }\n end\n\n autoloads.clear\n autoloaded_dirs.clear\n to_unload.clear\n lazy_subdirs.clear\n\n Registry.on_unload(self)\n ExplicitNamespace.unregister_loader(self)\n\n @setup = false\n @eager_loaded = false\n end\n end", "def stop_dynamic_loader!\n DynamicLoader.stop\n end", "def unregister(listener)\n listeners.delete(listener)\n end", "def unloading_dup\n d = dup\n d.unload!\n yield d if block_given?\n d\n end", "def unregister(object)\n\t\t\t@registered.delete(object)\n\t\tend", "def stop_registering_extension\n @register_path = nil\n end", "def unsave_module(valid_uni_module)\n uni_modules.delete(valid_uni_module)\n end" ]
[ "0.79804766", "0.6385771", "0.6305873", "0.6180569", "0.61622334", "0.61418617", "0.6128877", "0.6099131", "0.59948003", "0.59900427", "0.59773886", "0.59738815", "0.59472746", "0.590709", "0.583442", "0.5818676", "0.58116984", "0.57818645", "0.5780053", "0.5765094", "0.5738797", "0.5694572", "0.56517226", "0.56340265", "0.5632888", "0.5629823", "0.5573468", "0.55679065", "0.55557567", "0.55014753" ]
0.7927151
1
Retrieves a registered loader by name.
def get_loader(name) @loaders.each do |loader| return loader if loader.name == name end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def instance_loader(type)\n @autoloaders[type.intern]\n end", "def loader\n @loader ||= self.respond_to?(:load) ? self : instantiate(self.class.get_loader)\n end", "def define_loader_for(name)\n define_method(\"full_#{name}\") do\n if send(\"has_loaded_#{name}?\")\n instance_variable_get(\"@#{name}\")\n else\n instance_variable_set(\"@#{name}_load_state\", true)\n instance_variable_set(\"@#{name}\", load_associated(name))\n end\n end\n end", "def loader\n\t\t@loader ||= self.class.get_loader\n\tend", "def loaded_instance(type, name)\n name = name.intern\n return nil unless instances = instance_hash(type)\n unless instances.include? name\n if instance_loader(type).load(name)\n unless instances.include? name\n Puppet.warning(\n \"Loaded #{type} file for #{name} but #{type} was not defined\"\n )\n return nil\n end\n else\n return nil\n end\n end\n instances[name]\n end", "def for_gem\n called_from = caller_locations(1, 1).first.path\n Registry.loader_for_gem(called_from)\n end", "def load(name)\n Kernel.load name\nend", "def get(name)\n name.downcase!\n parts = name.split('::')\n name = name.to_sym\n\n @mutex.synchronize do\n object = @objects[name]\n unless object || @objects.include?(name)\n @directories.each do |directory|\n path = File.join(directory, @subdir, *parts) + '.rb'\n next unless File.exists?(path)\n object = load_file(parts.last, path)\n break\n end\n # Set even if not found to record misses\n @objects[name] = object\n end\n object\n end\n end", "def loader\n config.loader || container.config.loader\n end", "def loader\n config.loader || container.config.loader\n end", "def get(name)\n name = camelize(name) if name.downcase == name\n begin\n Object.const_get(name)\n rescue NameError\n nil\n end\n end", "def get(name)\n @registry.fetch(name)\n rescue KeyError\n raise UndeclaredNameError, \"config value '#{name}' never loaded\"\n end", "def []( name )\r\n result = @resources[name]\r\n\r\n if result.nil?\r\n result = autoload(name)\r\n if result\r\n self[name] = result\r\n result.name = name\r\n end\r\n end\r\n\r\n return result\r\n end", "def find(typed_name)\n # This loader is tailored to only find entries in the current runtime\n return nil unless typed_name.name_authority == Pcore::RUNTIME_NAME_AUTHORITY\n\n # Assume it is a global name, and that all parts of the name should be used when looking up\n name_parts = typed_name.name_parts\n\n # Certain types and names can be disqualified up front\n if name_parts.size > 1\n # The name is in a name space.\n\n # Then entity cannot possible be in this module unless the name starts with the module name.\n # Note:\n # * If \"module\" represents a \"global component\", the module_name is nil and cannot match which is\n # ok since such a \"module\" cannot have namespaced content).\n # * If this loader is allowed to have namespaced content, the module_name can be set to NAMESPACE_WILDCARD `*`\n #\n return nil unless name_parts[0] == module_name || module_name == NAMESPACE_WILDCARD\n else\n # The name is in the global name space.\n\n case typed_name.type\n when :function, :resource_type, :resource_type_pp\n # Can be defined in module using a global name. No action required\n\n when :plan\n if !global?\n # Global name must be the name of the module\n return nil unless name_parts[0] == module_name\n\n # Look for the special 'init' plan.\n origin, smart_path = find_existing_path(init_plan_name)\n return smart_path.nil? ? nil : instantiate(smart_path, typed_name, origin)\n end\n\n when :task\n if !global?\n # Global name must be the name of the module\n return nil unless name_parts[0] == module_name\n\n # Look for the special 'init' Task\n origin, smart_path = find_existing_path(init_task_name)\n return smart_path.nil? ? nil : instantiate(smart_path, typed_name, origin)\n end\n\n when :type\n if !global?\n # Global name must be the name of the module\n unless name_parts[0] == module_name || module_name == NAMESPACE_WILDCARD\n # Check for ruby defined data type in global namespace before giving up\n origin, smart_path = find_existing_path(typed_name)\n return smart_path.is_a?(LoaderPaths::DataTypePath) ? instantiate(smart_path, typed_name, origin) : nil\n end\n\n # Look for the special 'init_typeset' TypeSet\n origin, smart_path = find_existing_path(init_typeset_name)\n return nil if smart_path.nil?\n\n value = smart_path.instantiator.create(self, typed_name, origin, get_contents(origin))\n if value.is_a?(Types::PTypeSetType)\n # cache the entry and return it\n return set_entry(typed_name, value, origin)\n end\n\n # TRANSLATORS 'TypeSet' should not be translated\n raise ArgumentError, _(\"The code loaded from %{origin} does not define the TypeSet '%{module_name}'\") %\n { origin: origin, module_name: name_parts[0].capitalize }\n end\n else\n # anything else cannot possibly be in this module\n # TODO: should not be allowed anyway... may have to revisit this decision\n return nil\n end\n end\n\n # Get the paths that actually exist in this module (they are lazily processed once and cached).\n # The result is an array (that may be empty).\n # Find the file to instantiate, and instantiate the entity if file is found\n origin, smart_path = find_existing_path(typed_name)\n return instantiate(smart_path, typed_name, origin) unless smart_path.nil?\n\n return nil unless typed_name.type == :type && typed_name.qualified?\n\n # Search for TypeSet using parent name\n ts_name = typed_name.parent\n while ts_name\n # Do not traverse parents here. This search must be confined to this loader\n tse = get_entry(ts_name)\n tse = find(ts_name) if tse.nil? || tse.value.nil?\n if tse && (ts = tse.value).is_a?(Types::PTypeSetType)\n # The TypeSet might be unresolved at this point. If so, it must be resolved using\n # this loader. That in turn, adds all contained types to this loader.\n ts.resolve(self)\n te = get_entry(typed_name)\n return te unless te.nil?\n end\n ts_name = ts_name.parent\n end\n nil\n end", "def private_loader\n # The system loader has a nil module_name and it does not have a private_loader as there are no functions\n # that can only by called by puppet runtime - if so, it acts as the private loader directly.\n @private_loader ||= (global? ? self : @loaders.private_loader_for_module(module_name))\n end", "def get_const_by_name(name)\n consts = name.split(\"::\")\n obj = Object\n begin\n consts.each{|const| \n obj = obj.const_get(const)\n }\n rescue\n Log.logger_for(:configuration).error(\"No such class defined: #{name}\")\n end\n return obj\n end", "def get(name)\n module_name = /^#{name.to_s.dup.delete('_')}(?:helper)?$/i\n\n options.namespaces.each do |namespace|\n found = namespace.constants.grep(module_name).first\n return namespace.const_get(found) if found\n end\n\n nil\n end", "def through_name\n @loader.name\n end", "def get_loader_for_value(value)\n value\n end", "def try_load_object(name, cache_path)\n obj = Registry.at(name)\n cache_object(name, cache_path) if obj && cache_path\n obj\n end", "def fetch(name)\n load_cache(name)\n end", "def by_name( name )\n available.each { |addon| return addon if addon['filename'] == name }\n return nil\n end", "def fetch(plugin_name)\n list.find {|plugin| plugin.name == plugin_name}.tap do |plugin|\n raise Plugin::NotFound.new plugin_name if plugin.nil?\n end\n end", "def load\n require \"#{so_name}\" or raise LoadError, \"require on #{so_name} failed\"\n end", "def find_by_name(name)\n Discovery.find_by_name(name)\n end", "def load(name, env = default_environment)\n # This block autoloads appropriate file each time a missing macro is\n # requested from hash.\n path = name.split('::').join('/')\n load_from_file(name, path, env)\n end", "def find_module_named(name)\n find_class_or_module(name)\n end", "def get(name)\n name = camelize(name) if name.downcase == name\n begin\n const_get(name)\n rescue NameError\n nil\n end\n end", "def find_module_named name\n @modules_hash[name]\n end", "def lookup(name)\n begin\n eval(sanitize(name));\n rescue NameError\n return nil\n end\n end" ]
[ "0.6491453", "0.6277739", "0.62534773", "0.6160453", "0.6097052", "0.60919476", "0.6048855", "0.602023", "0.59505093", "0.59505093", "0.5916483", "0.58296984", "0.57348585", "0.5702326", "0.5702288", "0.56461203", "0.5641021", "0.56112236", "0.5593635", "0.55371994", "0.5534152", "0.55223066", "0.55106497", "0.5508798", "0.5493278", "0.54820216", "0.5475199", "0.5463492", "0.54631746", "0.5452992" ]
0.89939505
0
Notifiers Registers a notifier to the registry.
def add_notifier(notifier) @notifiers << notifier end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def notifiers\n @config.notifiers.map do |klass_name, options|\n require \"fyi/notifiers/#{klass_name}\"\n klass = constantize \"Fyi::Notifier::#{klass_name.capitalize}\"\n klass.send :new, options\n end\n end", "def set_notifier\n @notifier = Notifier.find(params[:id])\n end", "def notify_with(notifier)\n @default_notifier = notifier\n end", "def notify_subscribers\n NotificationSubscription.notify(self)\n end", "def notify_by(name, &block)\n @notifiers << get_class_from_scope(Notifier, name).new(self, &block)\n end", "def notify_by(name, &block)\n @notifiers << get_class_from_scope(Notifier, name).new(self, &block)\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 notifier\n @notifier ||= MList::Manager::Notifier.new\n end", "def notify(item)\n @notifiers.each do |notifier|\n notifier.notify(item)\n end\n self\n end", "def recipients(notifier_name)\n raise Noticent::InvalidScope, \"payload #{@payload.klass} doesn't have a #{notifier_name} method\" unless @payload.respond_to? notifier_name\n\n @payload.send(notifier_name)\n end", "def create\n @notifier = Notifier.new(notifier_params)\n\n respond_to do |format|\n if @notifier.save\n format.html { redirect_to @notifier, notice: 'Notifier was successfully created.' }\n format.json { render :show, status: :created, location: @notifier }\n else\n format.html { render :new }\n format.json { render json: @notifier.errors, status: :unprocessable_entity }\n end\n end\n end", "def remove_notifier(notifier)\n @notifiers.delete(notifier)\n end", "def notifiers\n _evaluate_guardfile\n\n merged_notifiers = ::Guard::Notifier::NOTIFIERS.inject(:merge)\n final_rows = merged_notifiers.each_with_object([]) do |definition, rows|\n\n name = definition[0]\n clazz = definition[1]\n available = clazz.available?(silent: true) ? \"✔\" : \"✘\"\n notifier = ::Guard::Notifier.notifiers.detect { |n| n[:name] == name }\n used = notifier ? \"✔\" : \"✘\"\n\n options = _merge_options(clazz, notifier)\n options.delete(:silent)\n\n if options.empty?\n rows << :split\n _add_row(rows, name, available, used, \"\", \"\")\n else\n options.each_with_index do |(option, value), index|\n if index == 0\n rows << :split\n _add_row(rows, name, available, used, option.to_s, value.inspect)\n else\n _add_row(rows, \"\", \"\", \"\", option.to_s, value.inspect)\n end\n end\n end\n\n rows\n end\n\n Formatador.display_compact_table(\n final_rows.drop(1),\n [:Name, :Available, :Used, :Option, :Value]\n )\n end", "def index\n @notifiers = Notifier.all\n end", "def notify(interests, data = {})\n Request.new(\n @pusher_client,\n :post,\n url(\"/notifications\"),\n {},\n payload(interests, data)\n ).send_sync\n end", "def notify_subscribers\n NotifierJob.perform_later(self)\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 delete_notifier(name)\n @notifiers.delete(name) if defined? @notifiers\n end", "def notify!(notification)\n raise \"Notifier #{self.class} does not respond to notify!\"\n end", "def notifier\n {\n :name => \"crashlog\",\n :version => CrashLog::VERSION,\n :language => 'Ruby'\n }\n end", "def register_observer(observer)\n unless @@delivery_notification_observers.include?(observer)\n @@delivery_notification_observers << observer\n end\n end", "def register(*tracker)\n @trackers += tracker\n end", "def notify\n @subscribers.each { |ident, (block,obj)| block.call(obj) }\n end", "def registered\n @@registry_lock.synchronize { @@registry.keys }\n end", "def notify(*args)\n subscribers.values.each { |subscriber| subscriber.call(*args) }\n end", "def register_observer(observer, cmd_name=nil)\n codes= []\n if cmd_name\n codes << Protocol.find_cmd_by_name(cmd_name).code\n else\n codes+= CMDS_BY_CODE.keys\n end\n codes.each {|code|\n list= @observers[code]\n if list.nil?\n @observers[code]= list= []\n end\n list.push(observer)\n }\n end", "def notify(step, options = {})\n notifiers.each do |notifier|\n notifier.notify(step, default_payload.merge(options))\n end\n end", "def notify\n if reports.any?\n self.class.notifiers.each do |notifier, options|\n # .dup is NOT reliable\n options_copy = Marshal.load(Marshal.dump(options))\n notifier.new(options_copy).notify(self)\n end\n end\n end", "def notify_subscribers\n NewAnswerNotificationMailer.notify_subscribers\n end", "def notificable(notificable_params = {})\n @notification = {\n :emails => notificable_params[:emails].join(';'),\n :message => notificable_params[:message]\n }\n end" ]
[ "0.6517459", "0.57836074", "0.5659098", "0.55722415", "0.5369292", "0.5369292", "0.5358543", "0.5326557", "0.529803", "0.52226776", "0.5163124", "0.51469606", "0.51254463", "0.50604784", "0.5057388", "0.50343305", "0.5029732", "0.50215644", "0.4974399", "0.4966373", "0.49495623", "0.49158657", "0.4913149", "0.49093688", "0.49086088", "0.48967603", "0.48936108", "0.48865235", "0.4880425", "0.48706493" ]
0.7425675
0
Unregisters a notifier from the registry.
def remove_notifier(notifier) @notifiers.delete(notifier) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_notifier(name)\n @notifiers.delete(name) if defined? @notifiers\n end", "def unsubscribe\n unregister\n end", "def unregister(path)\n\t\t\t\tpath = path.to_sym\n\t\t\t\tif @@registry[path]\n\t\t\t\t\t@@registry_count[path] -= 1\n\t\t\t\t\tif @@registry_count[path] <= 0\n\t\t\t\t\t\tsub = @@registry.delete(path)\n\t\t\t\t\t\tsub.unsubscribe\n\t\t\t\t\t\t@@registry_count.delete(path)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend", "def unregister\n @is_registered = false\n self\n end", "def unregister(*args, &block)\n h = Unobservable.handler_for(*args, &block)\n index = @handlers.index(h)\n if index\n @handlers.slice!(index)\n return h\n else\n return nil\n end\n end", "def unregister\n client.post('/v1/push/deregister', body: {\n uuid: user_id, device_id: id, push_type: type\n })\n end", "def remove_registration\n reg = Iq.new_register\n reg.to = jid.domain\n reg.query.add(REXML::Element.new('remove'))\n send_with_id(reg)\n end", "def unsubscribe(cls)\n @subscribers.delete(name)\n end", "def unsubscribe(key)\n @lock.synchronize do\n @handlers.clear\n @@name2inst.delete_if { |k, v| k == id.to_sym || k == address.to_sym}\n end\n end", "def un_register\n unless @unregistered\n @unregistered = true\n RightLinkLog.info(\"SEND [un_register]\")\n @amq.fanout('registration', :no_declare => @options[:secure]).publish(@serializer.dump(UnRegister.new(@identity)))\n end\n true\n end", "def unregister_observer(observer, cmd_name)\n cmd= Protocol.find_cmd_by_name(cmd_name)\n list= @observers[cmd.code]\n list.delete(observer) unless list.nil?\n end", "def unregister(const)\n @@extensions.delete(const)\n end", "def unconfigure\n root_notifier.unconfigure\n end", "def clear_notifier!\n self.notifier = nil\n self.root_notifier = nil\n end", "def unRegisterChecker( id )\n @availableCheckers.delete_if{ |x| x.id == id}\n end", "def unregister(listener)\n listeners.delete(listener)\n end", "def pop_reg reg\n @fisk.pop reg.to_register\n end", "def unsubscribe(ident)\n @subscribers.delete(ident)\n end", "def unregister(symbol); end", "def reset_notifier!\n notifier.reset!\n end", "def deregister(fd:)\n delete_from_selector(fd: fd)\n delete_callbacks(fd: fd)\n end", "def unregister(object)\n\t\t\t@registered.delete(object)\n\t\tend", "def unregister(uuid)\n execute_prlctl('unregister', uuid)\n end", "def unregister(event_type, body, opts = {})\n data, _status_code, _headers = unregister_with_http_info(event_type, body, opts)\n return data\n end", "def del_reg(id)\n _registers.delete(id)\n end", "def unsubscribe(aSubscriber)\n subscribers.delete_if { |entry| entry == aSubscriber }\n end", "def deregister(url)\n callback = Proc.new{ |_hslp, err, _cookie| }\n\n begin\n cookie = FFI::MemoryPointer.new(:void)\n result = SLPDereg(@handle, url, callback, cookie)\n raise Error, \"SLPDereg(): #{result}\" if result != :SLP_OK\n ensure\n cookie.free unless cookie.null?\n end\n\n url\n end", "def unregister\n puts \"APN::Device.unregister\"\n http_delete(\"/api/device_tokens/#{self.token}\")\n end", "def unregister_type\n types_list.delete self\n end", "def remove(instance)\n @registry.each_with_index do |item, i|\n if item.to_h == instance.to_h\n @registry.delete_at(i)\n end\n end\n sync\n end" ]
[ "0.6864771", "0.66803724", "0.65434325", "0.63821834", "0.63774484", "0.62238204", "0.616131", "0.6089258", "0.60660404", "0.60162586", "0.5981106", "0.59701985", "0.59491014", "0.5944469", "0.58144486", "0.58073014", "0.5800538", "0.5798176", "0.5797892", "0.57778096", "0.577367", "0.5764739", "0.57644993", "0.5753541", "0.57178706", "0.56723654", "0.56706285", "0.56645274", "0.5652717", "0.5634701" ]
0.72812676
0
Retrieves a registered notifier by name.
def get_notifier(name) @notifiers.each do |notifier| return notifier if notifier.name == name end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def notifier\n @notifier ||= MList::Manager::Notifier.new\n end", "def notif_for name\n name = name.to_s\n const = \"KAX#{name.camelize}Notification\"\n Kernel.const_defined?(const) ? Kernel.const_get(const) : name\n end", "def notify_by(name, &block)\n @notifiers << get_class_from_scope(Notifier, name).new(self, &block)\n end", "def notify_by(name, &block)\n @notifiers << get_class_from_scope(Notifier, name).new(self, &block)\n end", "def notif_for name\n name = name.to_s\n const = \"KAX#{name.camelize}Notification\"\n Object.const_defined?(const) ? Object.const_get(const) : name\n end", "def delete_notifier(name)\n @notifiers.delete(name) if defined? @notifiers\n end", "def lookup(name)\n @registry.fetch(name) { raise CheckNotRegistered, \"Check '#{name}' is not registered\" }\n end", "def notify_by(name, &block)\n @notifiers << Backup::Notifier.const_get(\n last_constant(name)\n ).new(&block)\n end", "def watcher(name)\n watchers.find { |watcher| watcher.name == name }\n end", "def find_by_name(name)\n Discovery.find_by_name(name)\n end", "def [](name)\n @@registry_lock.synchronize do\n @@registry[name.to_sym]\n end\n end", "def channel(name)\n arn = self.fetch(name)\n region = arn.split(':')[3]\n notifier_builder.new(region: region).topics[arn]\n end", "def find_by_name(name)\n service = DNSSD::Service.browse(self::MDNS_TYPE)\n service.each(self::MDNS_TIMEOUT).each do |browse_reply|\n resolve_reply = resolve(browse_reply)\n\n if resolve_reply.text_record[\"name\"] == name\n return Printer.new(get_address(resolve_reply), resolve_reply.text_record)\n end\n end\n\n nil\n ensure\n service.stop if service\n end", "def slack_notifier\n @notifier ||= SlackNotifier.new\n @notifier\n end", "def get(name)\n @registry.fetch(name)\n rescue KeyError\n raise UndeclaredNameError, \"config value '#{name}' never loaded\"\n end", "def notifier_name(value = nil)\n if value.nil?\n mailer_name\n else\n self.mailer_name = value\n end\n end", "def [](name=nil)\n # We lazy load the default because we want to be able to specify the \n # default after the registry has been initialized since initialization of \n # the registry happens on startup.\n key = name || configured_default\n entry = @registry[ key ]\n if entry != nil\n return entry \n elsif key == configured_default\n return register_default\n end\n end", "def find_by_name( name )\n\t\t\tnamed_message = nil\n\t\t\t@messages.values.each do |message|\n\t\t\t\tif message.descriptor.name == name\n\t\t\t\t\tnamed_message = message\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn named_message\n\t\tend", "def by_name( name )\n available.each { |addon| return addon if addon['filename'] == name }\n return nil\n end", "def notifier\n {\n :name => \"crashlog\",\n :version => CrashLog::VERSION,\n :language => 'Ruby'\n }\n end", "def find_metric(name)\n @metrics.detect{|m| m.name == name }\n end", "def [](name)\n _registry[name.to_sym]\n end", "def get_existing_monitor_by_name(mon_name)\n get_monitors.each do |mon|\n return mon if mon['name'] == mon_name\n end\n nil\n end", "def notifier_type\n options[:notifier_type]\n end", "def set_notifier\n @notifier = Notifier.find(params[:id])\n end", "def get(name)\n lookup(key(name.to_s))\n end", "def find(name)\n @users.fetch(name)\n end", "def get(name)\n self._list.detect { |entry| entry.name == name.to_sym }\n end", "def get(name)\n check_name!(name)\n scan\n\n synchronize do\n @tracker[name] || Set.new\n end\n end", "def notifier_name\n self.class.to_s.sub('Backup::', '')\n end" ]
[ "0.61560583", "0.61394876", "0.61320806", "0.61320806", "0.61311597", "0.60392195", "0.59348094", "0.5931856", "0.5877341", "0.5843106", "0.575624", "0.56607133", "0.5548981", "0.552931", "0.5512185", "0.5496076", "0.54640543", "0.5454341", "0.54377395", "0.5423276", "0.5378549", "0.5357256", "0.5338116", "0.531244", "0.5286829", "0.5274457", "0.5263473", "0.52231956", "0.5212278", "0.52111" ]
0.8765794
0
Test various cases for report_browser_status.
def test_report_browser_status self.request = TestRequest.new( :method => :get, :request_uri => '/foo/bar?var=val' ) self.session = {} @session_working = false @js = false str = report_browser_status assert_equal(nil, str) @session_working = true @js = false str = report_browser_status assert(str.match(/<script/)) @js = true str = report_browser_status assert(str.match(/<noscript/)) session[:js_override] = :off str = report_browser_status assert_equal(nil, str) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_browser_status\n self.request = TestRequest.new(\n :env => { 'HTTP_USER_AGENT' => NS5 }\n )\n self.params = {}\n self.session = {}\n self.cookies = {}\n\n # Start fresh -- nothing should be working yet.\n browser_status\n assert(session[:_working])\n assert_equal('1', cookies[:_enabled])\n assert(!@session_working)\n assert(!@cookies_enabled)\n assert(!@js)\n assert(@ua[:ns])\n assert(@ua[:ns5])\n assert_equal(5.0, @ua_version)\n\n # If working, it would now redirect with \"_js=on\".\n # (Change ua, too, for kicks.)\n self.request.env['HTTP_USER_AGENT'] = IE7\n self.params[:_js] = 'on'\n\n browser_status\n assert(@session_working)\n assert(@cookies_enabled)\n assert(@js)\n assert(@ua[:ie])\n assert(@ua[:ie7])\n assert_equal(7.0, @ua_version)\n end", "def test_Browser_003_BrowserTypes\n\n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_Browser_003_BrowserTypes\")\n puts2(\"#######################\")\n\n #$VERBOSE = true\n #$DEBUG = true\n\n #sAskURL = \"http://ask.com\"\n sBingURL = \"http://www.bing.com\"\n sGoogleURL = \"http://google.com\"\n #sBlankURL = \"about:blank\"\n\n # Define an empty array\n aSupportedBrowsers = []\n\n # Determine the current OS\n sCurrentOS = \"\"\n if(is_win?)\n #sCurrentOS = \"windows\"\n puts2(\"OS = Windows\")\n if(is_win?(10))\n aSupportedBrowsers = [\"Firefox\", \"Chrome\", \"Internet Explorer\", \"Edge\"]\n else\n aSupportedBrowsers = [\"Firefox\", \"Chrome\", \"Internet Explorer\"]\n end\n elsif(is_osx?)\n #sCurrentOS = \"osx\"\n puts2(\"OS = OSX\")\n aSupportedBrowsers = [\"Firefox\", \"Chrome\", \"Safari\"]\n elsif(is_linux?)\n #sCurrentOS = \"linux\"\n puts2(\"OS = Linux\")\n aSupportedBrowsers = [\"Firefox\", \"Chrome\"]\n end\n\n puts2(\"Supported browsers = \" + aSupportedBrowsers.to_s)\n\n # Loop thru each browser\n aSupportedBrowsers.each { |sBrowserName|\n\n # Start a browser\n oBrowser = start_browser(sBrowserName)\n\n #puts2(\"\\nIs a Global browser running: \" + is_global_browser_running?.to_s + \"\\n\\n\")\n\n sCurrentURL = oBrowser.url\n puts2(\"Current URL: \" + sCurrentURL)\n\n puts2(\"\\nBrowser type...\")\n puts2(\"\\tis_chrome? = \" + oBrowser.is_chrome?.to_s)\n puts2(\"\\tis_edge? = \" + oBrowser.is_edge?.to_s)\n puts2(\"\\tis_firefox? = \" + oBrowser.is_firefox?.to_s)\n puts2(\"\\tis_ie? = \" + oBrowser.is_ie?.to_s)\n puts2(\"\\tis_opera? = \" + oBrowser.is_opera?.to_s)\n puts2(\"\\tis_safari? = \" + oBrowser.is_safari?.to_s)\n\n oBrowser.display_info()\n\n # The #browser.version method is not supported for Edge\n if(oBrowser.is_edge?)\n puts2(\"SKIPPED - #browser.version method is not supported for Edge\")\n else\n sBrowserVersion = oBrowser.version.to_s\n puts2(\"Browser's full version = \" + sBrowserVersion)\n sBrowserMajorVersion = sBrowserVersion.prefix(\".\")\n puts2(\"Browser's major version = \" + sBrowserMajorVersion)\n end\n\n if(oBrowser.is_chrome?)\n puts2(\"Chrome \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_chrome?((sBrowserMajorVersion.to_i - 1)).to_s)\n puts2(\"Chrome \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_chrome?(sBrowserMajorVersion.to_i).to_s)\n puts2(\"Chrome \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_chrome?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n if(oBrowser.is_edge?)\n puts2(\"SKIPPED - For Edge\")\n #puts2(\"Edge \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_edge?((sBrowserMajorVersion.to_i - 1)).to_s)\n #puts2(\"Edge \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_edge?(sBrowserMajorVersion.to_i).to_s)\n #puts2(\"Edge \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_edge?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n if(oBrowser.is_firefox?)\n puts2(\"Firefox \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_firefox?((sBrowserMajorVersion.to_i - 1)).to_s)\n puts2(\"Firefox \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_firefox?(sBrowserMajorVersion.to_i).to_s)\n puts2(\"Firefox \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_firefox?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n if(oBrowser.is_ie?)\n puts2(\"IE \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_ie?((sBrowserMajorVersion.to_i - 1)).to_s)\n puts2(\"IE \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_ie?(sBrowserMajorVersion.to_i).to_s)\n puts2(\"IE \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_ie?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n if(oBrowser.is_opera?)\n puts2(\"Opera \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_opera?((sBrowserMajorVersion.to_i - 1)).to_s)\n puts2(\"Opera \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_opera?(sBrowserMajorVersion.to_i).to_s)\n puts2(\"Opera \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_opera?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n if(oBrowser.is_safari?)\n puts2(\"Safari \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_safari?((sBrowserMajorVersion.to_i - 1)).to_s)\n puts2(\"Safari \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_safari?(sBrowserMajorVersion.to_i).to_s)\n puts2(\"Safari \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_safari?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n\n # Access a URL\n puts2(\"\\nBrowser - Set URL = \" + sBingURL)\n oBrowser.goto(sBingURL)\n sleep(10) # Placeholder delay to figure out why a new IE fails at this point, and what can be waited on.\n puts2(\"\\tURL = \" + oBrowser.url)\n puts2(\"\\tBrowser name = \" + oBrowser.name.to_s)\n\n puts2(\"Misc. browser methods...\")\n puts2(\"\\tBrowser status = '\" + oBrowser.status.to_s + \"'\")\n puts2(\"\\tBrowser ready_state = \" + oBrowser.ready_state.to_s)\n puts2(\"\\tWindow current = \" + oBrowser.window.current?.to_s)\n puts2(\"\\tBrowse refresh...\")\n oBrowser.refresh\n\n # Start with browser in it's current size\n puts2(\"\\tBrowser is at it's initial size & position\")\n oBrowser.display_info()\n\n puts2(\"\\nMaximize browser\")\n oBrowser.window.maximize\n oBrowser.display_info()\n\n puts2(\"Resize the window to 640x480\")\n oBrowser.window.resize_to(640,480)\n oBrowser.display_info()\n\n puts2(\"Move the window to 100x100\")\n oBrowser.window.move_to(100,100)\n oBrowser.display_info()\n\n iWindowWidth = 1024\n puts2(\"Resize the window to its max height but specified width (\" + iWindowWidth.to_s + \")\")\n oBrowser.window.move_to(100,10) # w,h\n oBrowser.display_info()\n\n puts2(\"Maximize window...\")\n oBrowser.window.maximize\n oBrowser.display_info()\n\n puts2(\"Max height & specified width...\")\n iHeight = oBrowser.window.size.height\n oBrowser.window.resize_to(iWindowWidth,iHeight)\n oBrowser.display_info()\n\n puts2(\"\\nLoad a different URL \" + sGoogleURL)\n oBrowser.goto(sGoogleURL)\n puts(\"\\tURL = \" + oBrowser.url)\n puts(\"\\tTitle = \" + oBrowser.title)\n\n puts2(\"Use the browser's 'back' button...\")\n if(oBrowser.is_safari?)\n puts2(\"\\tSKIPPED - Safari Browser's back operation not supported.\")\n oBrowser.goto(sBingURL)\n sleep(1)\n else\n oBrowser.back\n puts(\"\\tURL = \" + oBrowser.url)\n puts(\"\\tTitle = \" + oBrowser.title)\n end\n\n puts2(\"Use the browser's 'forward' button...\")\n if(oBrowser.is_safari?)\n puts2(\"\\tSKIPPED - Safari Browser's forward operation not supported.\")\n oBrowser.goto(sGoogleURL)\n sleep(1)\n else\n oBrowser.forward\n puts(\"\\tURL = \" + oBrowser.url)\n puts(\"\\tTitle = \" + oBrowser.title)\n end\n\n puts2(\"Focus the cursor on 1st div...\")\n oBrowser.div(:id, \"searchform\").focus\n sleep(1)\n\n puts2(\"Hover the cursor on 1st div...\")\n if(oBrowser.is_safari?)\n puts2(\"\\tSKIPPED - Safari Browser does not appear to support hover\")\n else\n oBrowser.div(:id, \"searchform\").hover\n sleep(1)\n end\n\n puts2(\"Click the cursor on 1st div...\")\n oBrowser.div(:id, \"searchform\").click\n sleep(1)\n\n puts2(\"\\nAbout to close the current browser\")\n puts2(\"\\tDoes browser exist? = \" + oBrowser.exists?.to_s)\n puts2(\"\\tDoes window exist? = \" + oBrowser.window.exists?.to_s)\n puts2(\"Close the browser...\")\n oBrowser.close\n puts2(\" Does browser exist? = \" + oBrowser.exists?.to_s)\n #puts2(\" Does window exist? = \" + oBrowser.window.exists?.to_s) # Can't check on window if its closed.\n\n puts2(\"\\n##### Next browser...\")\n\n } # END - Loop thru each browser\n\n rescue => e\n\n puts2(\"*** ERROR and Backtrace: \" + e.message + \"\\n\" + e.backtrace.join(\"\\n\"), \"ERROR\")\n\n if(oBrowser.exists? == true)\n oBrowser.display_info()\n else\n puts(\"No existing browser found\")\n end\n\n # Force any open browsers to exit\n kill_browsers()\n\n # Raise the error with a custom message after the rest of the rescue actions\n raise(\"*** TESTCASE - test_Browser_003_LocalBrowsers\")\n\n ensure\n\n #end # Start browser types\n\n end", "def report_test_result success, msg\n if(success)\n print_success msg\n else\n print_error msg\n end\nend", "def runTest(browser)\n puts \"Step 2: At step description here\"\n #Do shit here\n #....\n puts \"Step 3: ....\"\n #Do more shit here\n #....\n\n puts \"Expected Result:\"\n puts \"Result that we expect to happen.\"\n\n if true #Test passed condition here\n self.passed = true\n puts \"TEST PASSED. Add some description/details here\"\n else #Test failed condition here\n self.passed = false\n puts \"TEST FAILED. Show what we have screwed up\"\n end\n end", "def test_0_before\n\t\t$report = Report.new()\n \t\t$testReport = $report.createReport($REPORT)\n\n\t\t$browser = Watir::Browser.new\n\t\t$current=\"\"\n\tend", "def visit_url(url)\n url_link = url\n begin\n linked_page = url_link.click\n rescue Exception => e\n puts \"\\033[37m#{e.inspect}\\033[0m\\n\"\n linked_page = @page\n end\n #initialize vars for return\n server_status_delivery = true\n determined_server = \"determined_server_default\"\n server_status = \"server_status_default\"\n check_for_key = \"page-wrap\"\n determined_server = check_header(linked_page)\n # check if page contain something\n if linked_page.body.include?(check_for_key)\n server_status_delivery = get_status(linked_page)\n else\n raise (\"page of #{linked_page.uri.to_s} do not include #{check_for_key}\")\n end\n server_status = \"#{determined_server}:#{server_status_delivery}\"\n return server_status\n end", "def reportiumAssert(message, status)\n params = {\n :message => message,\n :status => status\n }\n executeScript($ASSERT_COMMAND, params)\n end", "def test_changeStatus\n Common.login(Users::USER_EMAIL, Users::PASSWORD)\n Common.goToTab(HomePage::REQUISITION_TAB_LINK_XPATH)\n test = [{\"displayed\" =>RequisitionsHomePage::REQUISITIONS_PAGE_FIRST_ENTRY_SELECT_XPATH},\n {\"click\" => RequisitionsHomePage::REQUISITIONS_PAGE_FIRST_ENTRY_SELECT_XPATH},\n {\"click\" => RequisitionsHomePage::REQUISITIONS_PAGE_BTN_CHANGE_STATUS_JOBS_XPATH},\n {\"displayed\" => RequisitionsChangeStatus::REQUISITIONS_CHANGE_STATUS_NEW_STATUS_XPATH},\n {\"set_text\" => RequisitionsChangeStatus::REQUISITIONS_CHANGE_STATUS_NEW_STATUS_XPATH, \"text\" => RequisitionsChangeStatus::REQUISITION_NEW_STATUS_TEXT},\n {\"click\" => RequisitionsChangeStatus::REQUISITIONS_CHANGE_STATUS_BTN_UPDATE_STATUS_XPATH}]\n Common.main(test)\n assert $wait.until {\n $browser.find_element(:xpath, RequisitionsChangeStatus::BACK_TO_LIST_BUTTON_SUCCESS_PAGE_XPATH).displayed?\n } \nend", "def main\n \n puts \"starting virtual browser\"\n \n #Creates headless virtual browser and pulls page\n browser = Watir::Browser.new :chrome, headless: true\n browser.goto 'https://am-i-eligible.covid19vaccine.health.ny.gov'\n \n puts \"page loaded - waiting 15 seconds for javascript\"\n \n sleep 15\n \n puts \"checking...\"\n \n #Finds appropriate table on webpage\n results = browser.table(:id => 'statePods_table').hashes\n \n #Searches table for noted site locations, then calls checkAvailable()\n results.each { |x|\n if x.to_s.include? \"Jones Beach\"\n checkAvailable(x.to_s, \"Jones Beach\")\n elsif x.to_s.include? \"SUNY Stony Brook\"\n checkAvailable(x.to_s, \"SUNY Stony Brook\")\n end\n }\n \n browser.close\nend", "def send_status_report\n\t\treport = {\n\t\t\tversion: Assemblage::VERSION,\n\t\t\tstatus: self.status,\n\t\t\tuptime: self.uptime\n\t\t}\n\n\t\tmessage = Assemblage::Protocol.encode( :status_report, report )\n\n\t\tself.send_message( message )\n\tend", "def test_Browser_001_is_browser_installed()\n\n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_Browser_001_is_browser_installed\")\n puts2(\"#######################\")\n\n puts2(\"\\n\\nTest - is_chrome64_installed?()\")\n puts2(\"is_chrome64_installed? = \" + is_chrome64_installed?().to_s)\n\n puts2(\"\\n\\nTest - is_firefox64_installed?()\")\n puts2(\"is_firefox64_installed? = \" + is_firefox64_installed?().to_s)\n\n end", "def test_current_browsers_detected\n for browser in CURRENT_BROWSERS\n @request.user_agent = browser\n assert ! @page.legacy_browser?\n end\n end", "def test_changeStatusValidation\n Common.login(Users::USER_EMAIL, Users::PASSWORD)\n Common.goToTab(HomePage::REQUISITION_TAB_LINK_XPATH)\n test = [{\"displayed\" =>RequisitionsHomePage::REQUISITIONS_PAGE_FIRST_ENTRY_SELECT_XPATH},\n {\"click\" => RequisitionsHomePage::REQUISITIONS_PAGE_FIRST_ENTRY_SELECT_XPATH},\n {\"click\" => RequisitionsHomePage::REQUISITIONS_PAGE_BTN_CHANGE_STATUS_JOBS_XPATH},\n {\"displayed\" => RequisitionsChangeStatus::REQUISITIONS_CHANGE_STATUS_NEW_STATUS_XPATH},\n {\"click\" => RequisitionsChangeStatus::REQUISITIONS_CHANGE_STATUS_BTN_UPDATE_STATUS_XPATH}]\n Common.main(test)\n assert $wait.until {\n $browser.find_element(:xpath, RequisitionsChangeStatus::ERROR_STATUS_MUST_BE_SELECTED).displayed?\n }\nend", "def check_status\n response = do_request(build_status_xml())\n status_elem = REXML::XPath.first(response,'/webthumb/jobStatus/status')\n @status = (status_elem.text || '').downcase == 'complete' ? STATUS_PICKUP : STATUS_PROCESSING\n \n if pickup?\n \n if status_elem\n @completion_time = status_elem.attributes['completionTime']\n @pickup_url = status_elem.attributes['pickup']\n @browser_width = (status_elem.attributes['browserWidth'] || \"0\").to_i\n @browser_height = (status_elem.attributes['browserHeight'] || \"0\").to_i \n end\n end\n @status\n end", "def report\n\t\t\tputs \"Tests: #{@ok} ok, #{@fail} failures.\"\n\t\t\tif (@fail > 0)\n\t\t\t\tputs \"*** THERE WERE FAILURES *** \"\n\t\t\telse \n\t\t\t\tputs \"*** ALL TESTS PASSED ***\"\n\t\t\tend\n\t\tend", "def wait_for_browser\r\n # NOTE: no need any more\r\n end", "def report()\n print \"\\n\"\n $asserts.each do |err, str, iso, e|\n print(err);\n print_assertion_string(str, iso)\n if e\n print(\" => \")\n print(e.message)\n end\n print(\"\\n\")\n end\n\n $total_test = $ok_test.+($ko_test)\n print('Total: ')\n print($total_test)\n print(\"\\n\")\n\n print(' OK: ')\n print($ok_test)\n print(\"\\n\")\n print(' KO: ')\n print($ko_test)\n print(\"\\n\")\n print('Crash: ')\n print($kill_test)\n print(\"\\n\")\n\n if Object.const_defined?(:Time)\n print(' Time: ')\n print(Time.now - $test_start)\n print(\" seconds\\n\")\n end\nend", "def test_Browser_001_DisplayWatirEnv\n\n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_Browser_001_DisplayWatirEnv\")\n puts2(\"#######################\")\n\n puts2(\"\\n\\nTest - display_watir_env\")\n display_watir_env()\n\n end", "def test_on_current_browsers\n for current_browser in CURRENT_BROWSERS\n @request.user_agent = current_browser\n get :index\n assert_response :success\n assert_select 'img[src*=painless_test.png]'\n end\n end", "def report_status(m)\n if @@active\n m.reply \"Google RSS: On\"\n else\n m.reply \"Google RSS: Off\"\n end\n end", "def test_status_green_on_502\n Excon.stub({method: :get}, {body: '<doctype', status: 502})\n\n authorize 'user', 'password'\n assert_output( /502 override/,'') { get '/status' }\n last_response.body.must_equal 'green'\n end", "def progress(status)\n #For each SUT\n $sut.each do |ip, sut|\n #We check the status that we determined earlier,\n #depending on it we call the progress functions\n if status[ip]['status'] == 'Autotest'\n autotestprogress(status, sut, ip)\n elsif status[ip]['status'] == 'Stability'\n stabilityprogress(status, sut, ip)\n elsif status[ip]['status'] == 'CanWakeupTest'\n status[ip]['progress'] == 'Not implemented'\n elsif status[ip]['status'] == 'Manual'\n #If the test is manual, we just say it is not implemented yet. Do not know if it ever will,\n #because it is kind of impossible to know where manual test results will be saved.\n status[ip]['progress'] = 'Not implemented'\n elsif status[ip]['status'] == \"Idle\"\n latest = `ls -td #{$autotestpath}#{sut[:name]}*/ | head -n 1`[0...-1]\n latest = `ls -td #{latest}2017*/ | head -n 1`[0...-1]\n failed = `find #{latest} -name *TestRun.txt`[0...-1]\n if failed == '' && latest != ''\n status[ip]['progress'] = \"Last test failed to proceed\"\n status[ip]['progresscolor'] = \"color:red;\"\n else\n #Idle will be shown as empty in progress tab\n status[ip]['progress'] = ' '\n status[ip]['progresscolor'] = \"color:white;\"\n end\n end\n end\nend", "def report()\n print \"\\n\"\n\n $asserts.each do |msg|\n puts msg\n end\n\n $total_test = $ok_test.+($ko_test)\n print('Total: ')\n print($total_test)\n print(\"\\n\")\n\n print(' OK: ')\n print($ok_test)\n print(\"\\n\")\n print(' KO: ')\n print($ko_test)\n print(\"\\n\")\n print('Crash: ')\n print($kill_test)\n print(\"\\n\")\n\n if Object.const_defined?(:Time)\n print(' Time: ')\n print(Time.now - $test_start)\n print(\" seconds\\n\")\n end\nend", "def report()\n print \"\\n\"\n\n $asserts.each do |msg|\n puts msg\n end\n\n $total_test = $ok_test.+($ko_test)\n print('Total: ')\n print($total_test)\n print(\"\\n\")\n\n print(' OK: ')\n print($ok_test)\n print(\"\\n\")\n print(' KO: ')\n print($ko_test)\n print(\"\\n\")\n print('Crash: ')\n print($kill_test)\n print(\"\\n\")\n\n if Object.const_defined?(:Time)\n print(' Time: ')\n print(Time.now - $test_start)\n print(\" seconds\\n\")\n end\nend", "def test_browser_mode!\r\n @browser_mode = BrowserMode::Test\r\n end", "def receive_test\n setup_http\n\n if update_status?\n receive_test_status\n else\n simple_failure(\"Nothing happened\")\n end\n end", "def print_congifugartion\n puts \"Configuration : \"+$driver.execute_script(\"return navigator.userAgent;\")\n puts \"Date and Time : #{Time.now}\"\nend", "def page_status\n @status = \"OK\"\n @status = \"ERR\" if self.response_code > 399\n end", "def report_test_results(test_name, results)\n status = true\n message = \"\"\n for result in results\n # print (\"Status: \"+result[0].to_s+\"\\n\")\n status = (status && result[0])\n if (result[1].is_a?(Array))\n for m in result[1]\n message += m.to_s + \"\\n\\t\"\n end\n else\n message += result[1] + \"; \"\n end\n end\n\n report_test_result(test_name, status, message)\nend", "def invisible_testFailure(cg, cgi, state)\n true\nend" ]
[ "0.677851", "0.59251076", "0.591444", "0.59052956", "0.58726656", "0.57455033", "0.5734798", "0.56618977", "0.56167364", "0.56065315", "0.560427", "0.5589711", "0.5580433", "0.5525521", "0.54906625", "0.54722005", "0.5461144", "0.5443544", "0.5440786", "0.54317516", "0.5426514", "0.54152495", "0.541208", "0.541208", "0.5400755", "0.53855264", "0.53778225", "0.5374979", "0.53687316", "0.53344285" ]
0.7066436
0
Test various cases for browser_status filter.
def test_browser_status self.request = TestRequest.new( :env => { 'HTTP_USER_AGENT' => NS5 } ) self.params = {} self.session = {} self.cookies = {} # Start fresh -- nothing should be working yet. browser_status assert(session[:_working]) assert_equal('1', cookies[:_enabled]) assert(!@session_working) assert(!@cookies_enabled) assert(!@js) assert(@ua[:ns]) assert(@ua[:ns5]) assert_equal(5.0, @ua_version) # If working, it would now redirect with "_js=on". # (Change ua, too, for kicks.) self.request.env['HTTP_USER_AGENT'] = IE7 self.params[:_js] = 'on' browser_status assert(@session_working) assert(@cookies_enabled) assert(@js) assert(@ua[:ie]) assert(@ua[:ie7]) assert_equal(7.0, @ua_version) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_report_browser_status\n self.request = TestRequest.new(\n :method => :get,\n :request_uri => '/foo/bar?var=val'\n )\n self.session = {}\n\n @session_working = false\n @js = false\n str = report_browser_status\n assert_equal(nil, str)\n\n @session_working = true\n @js = false\n str = report_browser_status\n assert(str.match(/<script/))\n\n @js = true\n str = report_browser_status\n assert(str.match(/<noscript/))\n\n session[:js_override] = :off\n str = report_browser_status\n assert_equal(nil, str)\n end", "def check_status(status)\n case status.to_i\n when 1 # Valid\n true\n when 2 # Rejected\n false\n when 3 # Differed\n false\n when 4 # Test\n false\n else\n false\n end\n end", "def check_web_status(hsh)\n status = 'invalid' if hsh[:web_neg]&.include?('error')\n\n if hsh[:url] && hsh[:url_f] && status.nil?\n status = hsh[:url] != hsh[:url_f] ? 'formatted' : 'unchanged'\n end\n\n hsh[:web_status] = status if status.present?\n hsh\n end", "def service_status(code, response_time = nil, status)\n case\n when code == \"200\" && response_time <= 0.4\n status = \"GREEN\"\n puts \"#{status}\"\n when code == \"200\" && response_time > 0.4\n status = \"ORANGE\"\n puts \"#{status}\"\n when code != \"200\"\n status = \"RED\"\n puts \"#{status}\"\n else\n status = \"CHECK SERVICE URL\"\n puts \"#{status}\"\n end\n end", "def sanger_phenotyping_css_class_for_test(status_desc)\n case status_desc\n when \"Test complete and data\\/resources available\" then \"completed_data_available\"\n when \"Test complete and considered interesting\" then \"significant_difference\"\n when \"Test complete but not considered interesting\" then \"no_significant_difference\"\n when \"Early indication of possible phenotype\" then \"early_indication_of_possible_phenotype\"\n when /^Test not performed or applicable/i then \"not_applicable\"\n when \"Test abandoned\" then \"test_abandoned\"\n else \"test_pending\"\n end\nend", "def test_Browser_003_BrowserTypes\n\n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_Browser_003_BrowserTypes\")\n puts2(\"#######################\")\n\n #$VERBOSE = true\n #$DEBUG = true\n\n #sAskURL = \"http://ask.com\"\n sBingURL = \"http://www.bing.com\"\n sGoogleURL = \"http://google.com\"\n #sBlankURL = \"about:blank\"\n\n # Define an empty array\n aSupportedBrowsers = []\n\n # Determine the current OS\n sCurrentOS = \"\"\n if(is_win?)\n #sCurrentOS = \"windows\"\n puts2(\"OS = Windows\")\n if(is_win?(10))\n aSupportedBrowsers = [\"Firefox\", \"Chrome\", \"Internet Explorer\", \"Edge\"]\n else\n aSupportedBrowsers = [\"Firefox\", \"Chrome\", \"Internet Explorer\"]\n end\n elsif(is_osx?)\n #sCurrentOS = \"osx\"\n puts2(\"OS = OSX\")\n aSupportedBrowsers = [\"Firefox\", \"Chrome\", \"Safari\"]\n elsif(is_linux?)\n #sCurrentOS = \"linux\"\n puts2(\"OS = Linux\")\n aSupportedBrowsers = [\"Firefox\", \"Chrome\"]\n end\n\n puts2(\"Supported browsers = \" + aSupportedBrowsers.to_s)\n\n # Loop thru each browser\n aSupportedBrowsers.each { |sBrowserName|\n\n # Start a browser\n oBrowser = start_browser(sBrowserName)\n\n #puts2(\"\\nIs a Global browser running: \" + is_global_browser_running?.to_s + \"\\n\\n\")\n\n sCurrentURL = oBrowser.url\n puts2(\"Current URL: \" + sCurrentURL)\n\n puts2(\"\\nBrowser type...\")\n puts2(\"\\tis_chrome? = \" + oBrowser.is_chrome?.to_s)\n puts2(\"\\tis_edge? = \" + oBrowser.is_edge?.to_s)\n puts2(\"\\tis_firefox? = \" + oBrowser.is_firefox?.to_s)\n puts2(\"\\tis_ie? = \" + oBrowser.is_ie?.to_s)\n puts2(\"\\tis_opera? = \" + oBrowser.is_opera?.to_s)\n puts2(\"\\tis_safari? = \" + oBrowser.is_safari?.to_s)\n\n oBrowser.display_info()\n\n # The #browser.version method is not supported for Edge\n if(oBrowser.is_edge?)\n puts2(\"SKIPPED - #browser.version method is not supported for Edge\")\n else\n sBrowserVersion = oBrowser.version.to_s\n puts2(\"Browser's full version = \" + sBrowserVersion)\n sBrowserMajorVersion = sBrowserVersion.prefix(\".\")\n puts2(\"Browser's major version = \" + sBrowserMajorVersion)\n end\n\n if(oBrowser.is_chrome?)\n puts2(\"Chrome \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_chrome?((sBrowserMajorVersion.to_i - 1)).to_s)\n puts2(\"Chrome \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_chrome?(sBrowserMajorVersion.to_i).to_s)\n puts2(\"Chrome \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_chrome?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n if(oBrowser.is_edge?)\n puts2(\"SKIPPED - For Edge\")\n #puts2(\"Edge \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_edge?((sBrowserMajorVersion.to_i - 1)).to_s)\n #puts2(\"Edge \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_edge?(sBrowserMajorVersion.to_i).to_s)\n #puts2(\"Edge \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_edge?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n if(oBrowser.is_firefox?)\n puts2(\"Firefox \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_firefox?((sBrowserMajorVersion.to_i - 1)).to_s)\n puts2(\"Firefox \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_firefox?(sBrowserMajorVersion.to_i).to_s)\n puts2(\"Firefox \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_firefox?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n if(oBrowser.is_ie?)\n puts2(\"IE \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_ie?((sBrowserMajorVersion.to_i - 1)).to_s)\n puts2(\"IE \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_ie?(sBrowserMajorVersion.to_i).to_s)\n puts2(\"IE \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_ie?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n if(oBrowser.is_opera?)\n puts2(\"Opera \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_opera?((sBrowserMajorVersion.to_i - 1)).to_s)\n puts2(\"Opera \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_opera?(sBrowserMajorVersion.to_i).to_s)\n puts2(\"Opera \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_opera?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n if(oBrowser.is_safari?)\n puts2(\"Safari \" + (sBrowserMajorVersion.to_i - 1).to_s + \".x browser?: \" + oBrowser.is_safari?((sBrowserMajorVersion.to_i - 1)).to_s)\n puts2(\"Safari \" + sBrowserMajorVersion + \".x browser?: \" + oBrowser.is_safari?(sBrowserMajorVersion.to_i).to_s)\n puts2(\"Safari \" + (sBrowserMajorVersion.to_i + 1).to_s + \".x browser?: \" + oBrowser.is_safari?((sBrowserMajorVersion.to_i + 1)).to_s)\n end\n\n # Access a URL\n puts2(\"\\nBrowser - Set URL = \" + sBingURL)\n oBrowser.goto(sBingURL)\n sleep(10) # Placeholder delay to figure out why a new IE fails at this point, and what can be waited on.\n puts2(\"\\tURL = \" + oBrowser.url)\n puts2(\"\\tBrowser name = \" + oBrowser.name.to_s)\n\n puts2(\"Misc. browser methods...\")\n puts2(\"\\tBrowser status = '\" + oBrowser.status.to_s + \"'\")\n puts2(\"\\tBrowser ready_state = \" + oBrowser.ready_state.to_s)\n puts2(\"\\tWindow current = \" + oBrowser.window.current?.to_s)\n puts2(\"\\tBrowse refresh...\")\n oBrowser.refresh\n\n # Start with browser in it's current size\n puts2(\"\\tBrowser is at it's initial size & position\")\n oBrowser.display_info()\n\n puts2(\"\\nMaximize browser\")\n oBrowser.window.maximize\n oBrowser.display_info()\n\n puts2(\"Resize the window to 640x480\")\n oBrowser.window.resize_to(640,480)\n oBrowser.display_info()\n\n puts2(\"Move the window to 100x100\")\n oBrowser.window.move_to(100,100)\n oBrowser.display_info()\n\n iWindowWidth = 1024\n puts2(\"Resize the window to its max height but specified width (\" + iWindowWidth.to_s + \")\")\n oBrowser.window.move_to(100,10) # w,h\n oBrowser.display_info()\n\n puts2(\"Maximize window...\")\n oBrowser.window.maximize\n oBrowser.display_info()\n\n puts2(\"Max height & specified width...\")\n iHeight = oBrowser.window.size.height\n oBrowser.window.resize_to(iWindowWidth,iHeight)\n oBrowser.display_info()\n\n puts2(\"\\nLoad a different URL \" + sGoogleURL)\n oBrowser.goto(sGoogleURL)\n puts(\"\\tURL = \" + oBrowser.url)\n puts(\"\\tTitle = \" + oBrowser.title)\n\n puts2(\"Use the browser's 'back' button...\")\n if(oBrowser.is_safari?)\n puts2(\"\\tSKIPPED - Safari Browser's back operation not supported.\")\n oBrowser.goto(sBingURL)\n sleep(1)\n else\n oBrowser.back\n puts(\"\\tURL = \" + oBrowser.url)\n puts(\"\\tTitle = \" + oBrowser.title)\n end\n\n puts2(\"Use the browser's 'forward' button...\")\n if(oBrowser.is_safari?)\n puts2(\"\\tSKIPPED - Safari Browser's forward operation not supported.\")\n oBrowser.goto(sGoogleURL)\n sleep(1)\n else\n oBrowser.forward\n puts(\"\\tURL = \" + oBrowser.url)\n puts(\"\\tTitle = \" + oBrowser.title)\n end\n\n puts2(\"Focus the cursor on 1st div...\")\n oBrowser.div(:id, \"searchform\").focus\n sleep(1)\n\n puts2(\"Hover the cursor on 1st div...\")\n if(oBrowser.is_safari?)\n puts2(\"\\tSKIPPED - Safari Browser does not appear to support hover\")\n else\n oBrowser.div(:id, \"searchform\").hover\n sleep(1)\n end\n\n puts2(\"Click the cursor on 1st div...\")\n oBrowser.div(:id, \"searchform\").click\n sleep(1)\n\n puts2(\"\\nAbout to close the current browser\")\n puts2(\"\\tDoes browser exist? = \" + oBrowser.exists?.to_s)\n puts2(\"\\tDoes window exist? = \" + oBrowser.window.exists?.to_s)\n puts2(\"Close the browser...\")\n oBrowser.close\n puts2(\" Does browser exist? = \" + oBrowser.exists?.to_s)\n #puts2(\" Does window exist? = \" + oBrowser.window.exists?.to_s) # Can't check on window if its closed.\n\n puts2(\"\\n##### Next browser...\")\n\n } # END - Loop thru each browser\n\n rescue => e\n\n puts2(\"*** ERROR and Backtrace: \" + e.message + \"\\n\" + e.backtrace.join(\"\\n\"), \"ERROR\")\n\n if(oBrowser.exists? == true)\n oBrowser.display_info()\n else\n puts(\"No existing browser found\")\n end\n\n # Force any open browsers to exit\n kill_browsers()\n\n # Raise the error with a custom message after the rest of the rescue actions\n raise(\"*** TESTCASE - test_Browser_003_LocalBrowsers\")\n\n ensure\n\n #end # Start browser types\n\n end", "def check_status(status)\n return 'Alive' if status.eql?('200')\n 'Dead'\n end", "def test_browser_mode?\r\n @browser_mode == BrowserMode::Test\r\n end", "def test_default_http_status_codes\n assert(BasicController.http_status_codes == HTTP_STATUS_CODES, \"Default http_status_codes is incorrect\")\n end", "def handle_status?(request, status, error_message)\n should_continue = true\n\n error_string = \"Error: #{error_message.nil? ? 'N/A' : error_message}\"\n case status\n when 'ZERO_RESULTS'\n puts \"No results for request #{request}.\"\n when 'OVER_QUERY_LIMIT'\n # over query limit for the day\n puts \"Query limit reached. Exiting.\"\n should_continue = false\n when 'REQUEST_DENIED'\n puts \"Request #{request} was denied. #{error_string}\"\n when 'INVALID_REQUEST'\n puts \"Request #{request} is invalid. #{error_string}\"\n when 'UNKNOWN_ERROR'\n puts \"Unknown error occured for request #{request}. #{error_string}\"\n end\n\n return should_continue\nend", "def test_browser_mode!\r\n @browser_mode = BrowserMode::Test\r\n end", "def test_on_current_browsers\n for current_browser in CURRENT_BROWSERS\n @request.user_agent = current_browser\n get :index\n assert_response :success\n assert_select 'img[src*=painless_test.png]'\n end\n end", "def test_status_green_on_502\n Excon.stub({method: :get}, {body: '<doctype', status: 502})\n\n authorize 'user', 'password'\n assert_output( /502 override/,'') { get '/status' }\n last_response.body.must_equal 'green'\n end", "def test_changeStatusValidation\n Common.login(Users::USER_EMAIL, Users::PASSWORD)\n Common.goToTab(HomePage::REQUISITION_TAB_LINK_XPATH)\n test = [{\"displayed\" =>RequisitionsHomePage::REQUISITIONS_PAGE_FIRST_ENTRY_SELECT_XPATH},\n {\"click\" => RequisitionsHomePage::REQUISITIONS_PAGE_FIRST_ENTRY_SELECT_XPATH},\n {\"click\" => RequisitionsHomePage::REQUISITIONS_PAGE_BTN_CHANGE_STATUS_JOBS_XPATH},\n {\"displayed\" => RequisitionsChangeStatus::REQUISITIONS_CHANGE_STATUS_NEW_STATUS_XPATH},\n {\"click\" => RequisitionsChangeStatus::REQUISITIONS_CHANGE_STATUS_BTN_UPDATE_STATUS_XPATH}]\n Common.main(test)\n assert $wait.until {\n $browser.find_element(:xpath, RequisitionsChangeStatus::ERROR_STATUS_MUST_BE_SELECTED).displayed?\n }\nend", "def page_status\n @status = \"OK\"\n @status = \"ERR\" if self.response_code > 399\n end", "def determine_status_color( status )\n case status\n when 'pending' then return '#cea61b'\n when 'error' then return '#bd2c00'\n when 'success' then return '#6cc644'\n end\nend", "def test_key_containing_status\n server_run app: ->(env) { [200, {'Teapot-Status' => 'Boiling'}, []] }\n data = send_http_and_read \"GET / HTTP/1.0\\r\\n\\r\\n\"\n\n assert_match(/HTTP\\/1.0 200 OK\\r\\nTeapot-Status: Boiling\\r\\nContent-Length: 0\\r\\n\\r\\n/, data)\n end", "def browsers_only\n if !valid_browser?(request.user_agent) or valid_robot?(request.user_agent)\n respond_to do |format|\n format.html { render :file => \"public/401.html\", :status => :unauthorized }\n format.xml do\n headers[\"Status\"] = \"Unauthorized\"\n render :text => \"You appear to be a robot. No robots are allowed to access this page.\", :status => '401 Unauthorized'\n end\n end\n end\n end", "def check_browser_type(platform, browser_type)\n if platform == 'desktop'\n if !%w(ff ie chrome safari opera).include? browser_type\n print_error_desktop\n end\n else\n if !%w(native chrome safari).include? browser_type\n print_error_mobile\n end\n end\nend", "def test_current_browsers_detected\n for browser in CURRENT_BROWSERS\n @request.user_agent = browser\n assert ! @page.legacy_browser?\n end\n end", "def receive_test\n setup_http\n\n if update_status?\n receive_test_status\n else\n simple_failure(\"Nothing happened\")\n end\n end", "def status(*) end", "def good_browser?(agent = /Firefox|Safari|Chrome/)\n request.env['HTTP_USER_AGENT'] =~ agent\n end", "def status_ok?\n [1, 6, 7, 8, 9].include?(status)\n end", "def test_changeStatus\n Common.login(Users::USER_EMAIL, Users::PASSWORD)\n Common.goToTab(HomePage::REQUISITION_TAB_LINK_XPATH)\n test = [{\"displayed\" =>RequisitionsHomePage::REQUISITIONS_PAGE_FIRST_ENTRY_SELECT_XPATH},\n {\"click\" => RequisitionsHomePage::REQUISITIONS_PAGE_FIRST_ENTRY_SELECT_XPATH},\n {\"click\" => RequisitionsHomePage::REQUISITIONS_PAGE_BTN_CHANGE_STATUS_JOBS_XPATH},\n {\"displayed\" => RequisitionsChangeStatus::REQUISITIONS_CHANGE_STATUS_NEW_STATUS_XPATH},\n {\"set_text\" => RequisitionsChangeStatus::REQUISITIONS_CHANGE_STATUS_NEW_STATUS_XPATH, \"text\" => RequisitionsChangeStatus::REQUISITION_NEW_STATUS_TEXT},\n {\"click\" => RequisitionsChangeStatus::REQUISITIONS_CHANGE_STATUS_BTN_UPDATE_STATUS_XPATH}]\n Common.main(test)\n assert $wait.until {\n $browser.find_element(:xpath, RequisitionsChangeStatus::BACK_TO_LIST_BUTTON_SUCCESS_PAGE_XPATH).displayed?\n } \nend", "def test_status_key\n assert_ignore_header(\"Status\", \"500\")\n end", "def debug_header_status(status)\n status = status.to_i\n # Make this actually useful by explaining why each header appears.\n if $_1xx.include? status\n Logger.log(\"Response code: #{status}. Response type: Informational.\")\n elsif $_2xx.include? status\n Logger.log(\"Response code: #{status}. Response type: Success.\")\n elsif $_3xx.include? status\n Logger.log(\"Response code: #{status}. Response type: Redirection.\")\n elsif $_4xx.include? status\n Logger.log(\"Response code: #{status}. Response type: Client error.\")\n else\n Logger.log(\"Response code: #{status} does not have a valid response type.\")\n end\nend", "def get_status_text(status)\n return \"Failed\" if status.upcase == 'DOWN'\n return \"Passed\" if status.upcase == 'UP'\n\n return \"Unknown\"\nend", "def test_truth\n assert_kind_of Status, @status\n end", "def get_status_filter_check(status)\n params[:statuses] ? params[:statuses].keys.include?(status) : true\n end" ]
[ "0.6431533", "0.59971607", "0.5802718", "0.5790735", "0.5675141", "0.56633186", "0.5659382", "0.5593694", "0.55619895", "0.5532173", "0.55248356", "0.5513145", "0.55096835", "0.5471565", "0.54444563", "0.5438939", "0.5371447", "0.53672355", "0.5358583", "0.5354061", "0.5350077", "0.5346877", "0.5340733", "0.533222", "0.5314836", "0.526357", "0.5259348", "0.52523005", "0.52501583", "0.5241479" ]
0.6721254
0
_mapping_ must exist as a mapping of a registered id.
def reverse_get mapping (@map.rassoc(mapping) || (raise "#{mapping} is not a mapping of a registered id"))[0] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def define_mapping\n # no additional parameters\n nil\n end", "def set_mapping\n @mapping = Mapping.find(params[:id])\n end", "def set_task_mapping\n @project_task_mapping = ProjectTaskMapping.find_by_id(params[:id])\n if @project_task_mapping\n else\n \trender json: { valid: false}, status: 404\n end\n end", "def get id\n @map[id] || (raise \"#{id} not registered\")\n end", "def mapped?\n\t @mapping ? true : false\n end", "def map\n unless params[:id].nil?\n return not_found unless map = Map[params[:id].to_i]\n ok map.to_a\n else\n not_found\n end\n end", "def mapping_name_is_valid?(mapping_name)\n mapping_name.class == Symbol\n end", "def mapping; end", "def mapping; end", "def assert_mapping_exists(response, type, message=\"mapping expected to exist, but doesn't\")\n mapping =\n if response.has_key?(\"mappings\")\n response[\"mappings\"][type]\n else\n response[type]\n end\n refute_nil mapping, message\n end", "def identifier_map(id, name, id_map)\n if !id_map.include? id\n id_map[id] = name\n end \nend", "def set_game_mapping\n @game_mapping = GameMapping.find(params[:id])\n end", "def [] id\n @map[id] ||= next_mapping\n end", "def set_item_mapping\n @item_mapping = ItemMapping.find(params[:id])\n end", "def registered?(id)\n @definitions.has_key? id\n end", "def mapping_identity\n interfaces.first[\"id\"]\n end", "def define_mapping\n fail NotImplementedError, \" Error: the subclass #{self.class} needs \" \\\n \"to implement the method: define_mapping from its base class\".red\n end", "def known_invalid_idref(mapkey, oldid)\n\treturn false;\n\t# \treturn ( ((mapkey==:version or mapkey==:fixfor) and oldid==21907 or oldid==21881 or oldid==21743) or\n\t# \t\t\t(mapkey==:version and (oldid==21240 or oldid==21743)) or \n\t# \t\t\t(mapkey==:issuestatus and (oldid==2 or oldid==-3)) or\n\t# \t\t\t(mapkey==:resolution and oldid==6)\n\t# \t )\nend", "def isMapping\n @refType.kind_of?(DataMetaDom::Mapping) && !@refType.kind_of?(DataMetaDom::BitSet)\n end", "def id_locked?(id_to_check)\n @con.hexists(\"#{@lock_map_key}_h\", id_to_check)\n end", "def must_be_unique\n errors.add(:failed, I18n.t('room_type_master_rate_mappings.create.message.already_exist')) if\n !RoomTypeMasterRateMapping.find_by_pool_id_and_room_type_id(self.pool_id, self.room_type_id).blank?\n end", "def id_mapping_types\n @id_mapping_types ||= extract_classes_with_true(:track_imported_ids, configuration)\n end", "def set_user_mapping\n @user_mapping = UserMapping.find(params[:id])\n end", "def same_map?\r\n @map_id == $game_map.map_id\r\n end", "def has_mappings()\n return @mappings.has_data()\n end", "def initialize(mapping)\n @mapping = mapping\n end", "def set_map_id\n @map_id = $game_map.map_id\n end", "def mapping(name)\n mappings.find{ |mapping| mapping.name == name }\n end", "def mapping_is_valid?(mapping)\n # lets make sure mapping and keys exist first\n if mapping && mapping.keys.length > 0\n # Lets checks if keys are valid\n mapping.each do |key, value|\n if key && key.class == Symbol\n if (key == :mapping)\n mapping[key].each do |coin_name, coin_value|\n return false if !(coin_name &&\n ( coin_name.is_a?(Symbol) || coin_name.is_a?(String) ) &&\n coin_value &&\n coin_value.is_a?(Integer) &&\n coin_value > 0)\n end\n end\n else\n return false\n end\n end\n end\n return true\n end", "def test_mapping_is_exhaustive\n unsupported = [:bytes, :limit_definition, :log_level, :weighted_values, :int_range]\n\n supported = PrefabProto::ConfigValue.descriptor.entries.reject do |entry|\n unsupported.include?(entry.name.to_sym)\n end.map(&:number)\n\n mapped = Prefab::ContextShape::MAPPING.values.uniq\n\n unless mapped == supported\n raise \"ContextShape MAPPING needs update: #{mapped} != #{supported}\"\n end\n end" ]
[ "0.67337865", "0.64740795", "0.62678725", "0.6216677", "0.6092073", "0.60772824", "0.5884115", "0.58802444", "0.58802444", "0.5810123", "0.5805825", "0.57462746", "0.5706361", "0.5704102", "0.5644253", "0.5635851", "0.5610589", "0.56083786", "0.560725", "0.55648845", "0.55639285", "0.5553082", "0.5552867", "0.555215", "0.5544848", "0.5502315", "0.55013716", "0.5493221", "0.5490906", "0.5484109" ]
0.67259693
1
DELETE /courses/1 DELETE /courses/1.json
def destroy @course.destroy respond_to do |format| format.html { redirect_to courses_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :ok }\n end\n end", "def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @Course = Course__c.find(params[:id])\n @Course.destroy\n\n respond_to do |format|\n format.html { redirect_to Courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @course = Course.find(params[:id])\r\n @course.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to courses_path }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n course_name = @course.course_id\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course ' + course_name + ' was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to coursees_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @study_course = StudyCourse.find(params[:id])\n @study_course.destroy\n\n respond_to do |format|\n format.html { redirect_to study_courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to my_created_courses_path, notice: 'Course was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n puts \"WTF I GOT HERE\"\n @course = Course.find(params[:id])\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_path, notice: 'Course was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Kurs je uspješno izbrisan. ' }\n format.json { head :no_content }\n end\n end", "def destroy\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Curso destruído com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @lab_course = LabCourse.find(params[:id])\n @lab_course.destroy\n\n respond_to do |format|\n format.html { redirect_to lab_courses_url }\n format.json { head :no_content }\n end\n end", "def delete_course_by_id(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/courses/#{org_unit_id}\" # setup user path\n # ap path\n _delete(path)\n puts '[+] Course data deleted successfully'.green\nend", "def destroy\n @path_course.destroy\n respond_to do |format|\n format.html { redirect_to path_courses_url, notice: 'Path course was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @novanet_course.destroy\n respond_to do |format|\n format.html { redirect_to novanet_courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_course.destroy\n respond_to do |format|\n format.html { redirect_to admin_courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @course = Course.find(params[:id])\n @course.delete\n end" ]
[ "0.77230847", "0.76962376", "0.7696043", "0.7696043", "0.7696043", "0.7696043", "0.7696043", "0.7696043", "0.7696043", "0.7696043", "0.7696043", "0.7696043", "0.7696043", "0.76494783", "0.76408905", "0.7619815", "0.7609345", "0.7590714", "0.75764287", "0.75692135", "0.75462914", "0.75420517", "0.75322306", "0.7522291", "0.75156885", "0.7509708", "0.7489476", "0.7485458", "0.74687713", "0.74641526" ]
0.77079666
1