query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
returns a nonempty set of text to parse
def generate_text_resources() # get total number of games in database upper_limit = JSON.parse(get_response("games", "").body)['number_of_total_results'] # generate a random id random_id = rand(upper_limit) # get 5 descriptions! description_response = JSON.parse(get_response( "games", "offset=#{random_id}&limit=5&field_list=description,aliases").body) # let's return the one's that aren't nil nonempty_descriptions = description_response["results"].select{ |x| x["description"] != nil } if nonempty_descriptions.empty? return generate_text_resources else return nonempty_descriptions end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _find_variables(text)\n return Set.new\n end", "def search_text(text)\n sets = @schemes.map do |scheme|\n scheme.find_all(text).uniq\n end\n sets.flatten.uniq\n end", "def parse_text\r\n @text_nodes.map(&:content).join('')\r\n end", "def parse_text\r\n ...
[ "0.68518156", "0.61371046", "0.5946607", "0.5946607", "0.5911951", "0.5859962", "0.57733935", "0.56352633", "0.5615934", "0.5557757", "0.5530548", "0.54881805", "0.5483222", "0.5471739", "0.54716295", "0.546953", "0.5468436", "0.5454874", "0.54350966", "0.5432678", "0.5408534...
0.0
-1
create a word replacement game thingie from a given string
def generate_lib(string) lines = string.split("\n") # throw away extra newlines lines.reject { |l| l.empty? } lines_lib = Array.new lines.each do |line| sentences = line.split(".") sentences_lib = Array.new # turn each individual sentence into a lib sentences.each do |sentence| sentences_lib.push( MadLibber.libberfy sentence, {num_of_blanks: rand(MAX_REPLACE)}) end # combine sentences and remove some junk from the parser lines_lib.push(sentences_lib.join(". ") .gsub(/<sym><*/, "") .gsub(/<nnp><*/, "") .gsub("//SYM", "")) end return lines_lib.join("\n") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sub_word(string)\n array = string.split\n array.each do |word|\n word.gsub!(/\\bt[oo]\\b/, \"2\")\n #word.gsub!(\"too\", \"2\")\n word.gsub!(\"for\", \"4\")\n word.gsub!(\"four\", \"4\")\n word.gsub!(\"you\", \"u\")\n word.gsub!(\"at\", \"/@\")\n word.gsub...
[ "0.7338153", "0.70906484", "0.7012963", "0.69724685", "0.6851779", "0.6788132", "0.6770918", "0.67518896", "0.67518896", "0.67518896", "0.66736084", "0.6629027", "0.65968657", "0.6571498", "0.6550454", "0.6544981", "0.6544981", "0.6516059", "0.65036047", "0.6487876", "0.64877...
0.0
-1
== current_user method code ==
def current_user puts "******* current_user *******" if session[:user_id] @current_user = User.find(session[:user_id]) else @current_user = nil end puts "@current_user: #{@current_user.inspect}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_method\n current_user\n end", "def current_user\n raise NotImplementedError\n end", "def current_user\n raise NotImplementedError\n end", "def current_user_method=(null) ; end", "def current_user?\n \n end", "def current_user\n # super: don't change anything, i just wa...
[ "0.8195571", "0.7686558", "0.7686558", "0.7627156", "0.76085263", "0.7546538", "0.73984605", "0.73820835", "0.73791146", "0.73673767", "0.73622656", "0.73622656", "0.7356874", "0.7355236", "0.73355204", "0.73325926", "0.73307186", "0.73134834", "0.7305835", "0.73005205", "0.7...
0.0
-1
Check if all elements in collection are differents
def all_different? a = self.to_a.drop(1) self.each do |e| return false if a.include?(e) a.shift end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_for_inconsistency(elements)\n elements.any?{|e| e != elements.first}\n end", "def all_same?\n self.all? { |element| element == self[0] }\n end", "def all_same?\n self.all? { |element| element == self[0] }\n end", "def all_same?\n\t\t\tself.all? { |element| (element == self[0]) && (eleme...
[ "0.7378042", "0.72339404", "0.72339404", "0.6987722", "0.6958125", "0.6948739", "0.6784183", "0.6744735", "0.6637964", "0.65709877", "0.65429336", "0.6515579", "0.6494044", "0.647598", "0.6427257", "0.6401319", "0.6362827", "0.6306629", "0.6292074", "0.6238504", "0.62378824",...
0.77649045
0
builds up disjoint groups of n elements or less
def groups_of(n) g = self.take(n) return [] if g.empty? [g] + self.drop(n).groups_of(n) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sliding_groups_of(n)\n return [] if self.size < n\n [ self.take(n) ] + self.drop(1).sliding_groups_of(n)\n end", "def new_groups(array)\n new_group = []\n array.shuffle.each_slice(4){|acc| new_group << acc}\n if new_group.length > 1 && new_group.last.length <= 2\n (new_group.last.length).times do ...
[ "0.70682293", "0.69597673", "0.66962117", "0.64843446", "0.6478368", "0.64023006", "0.6402069", "0.63963705", "0.634538", "0.63412267", "0.6242774", "0.62028915", "0.61907727", "0.6166342", "0.61573833", "0.6128762", "0.6126871", "0.6070171", "0.60636103", "0.60636103", "0.60...
0.7180315
0
builds up sliding groups of exactly n elements
def sliding_groups_of(n) return [] if self.size < n [ self.take(n) ] + self.drop(1).sliding_groups_of(n) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def groups_of(n)\n g = self.take(n)\n return [] if g.empty?\n [g] + self.drop(n).groups_of(n)\n end", "def new_groups(array)\n new_group = []\n array.shuffle.each_slice(4){|acc| new_group << acc}\n if new_group.length > 1 && new_group.last.length <= 2\n (new_group.last.length).times do |i|\n n...
[ "0.7234628", "0.703372", "0.6842546", "0.66832125", "0.6631394", "0.65365267", "0.6485448", "0.64687824", "0.6455022", "0.64477324", "0.64110017", "0.640881", "0.6327658", "0.6296592", "0.628095", "0.6256073", "0.62122935", "0.61570126", "0.61570126", "0.61074513", "0.6105171...
0.8560576
0
find the position of a sequence [1,2,3,4,5,4,3,2,1].seq_index([4,3]) => 5
def seq_index(seq) self.sliding_groups_of(seq.size).index(seq) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_index_of_position(target_position, ary)\n ary.each_index do |i|\n current_position = ary[i][1]\n if current_position == target_position\n return i\n end\n end\n end", "def input_to_index(position)\n position = position.to_i - 1\n return position\nend", "def input_to_index...
[ "0.7037643", "0.69774354", "0.6913465", "0.68824005", "0.68638724", "0.6859281", "0.6854683", "0.681217", "0.68054426", "0.68027955", "0.6771829", "0.67715156", "0.6753179", "0.66085637", "0.656638", "0.65328586", "0.6524196", "0.65172803", "0.6467702", "0.6460786", "0.645877...
0.82241315
0
Takes a block predicate p(x,y) and builds an array of elements so that for any (a,b), a being before b in the list, p(a,b) holds.
def make_uniq_by(&block) result = [] self.each do |e| unless result.any?{|x| yield(x,e)} then result.push(e) end end return result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bubble_sort_by(a)\n\treturn unless block_given?\n\t(1...a.length).each do |iter|\n\t\t(0...a.length-iter).each do |index|\n\t\t\tif yield(a[index],a[index+1])>0\n\t\t\t\ta[index], a[index+1] = a[index+1],a[index]\n\t\t\tend\n\t\tend\n\tend\n\ta\nend", "def bubble_sort!(&prc)\n \n end", "def xnor_select...
[ "0.5655329", "0.56252027", "0.55485463", "0.5533577", "0.5529843", "0.5511278", "0.5510011", "0.5510011", "0.5490408", "0.5483388", "0.5418674", "0.53980505", "0.5372074", "0.5336062", "0.5325101", "0.53234327", "0.5260595", "0.5260024", "0.5256526", "0.52287084", "0.5209293"...
0.0
-1
compare 2 enumerables, and returns [ [missing] , [intersection], [added] ]
def diff_with(other, &block) m, i, a = [], [], [] u_s = self.make_uniq_by(&block) u_o = other.make_uniq_by(&block) u_s.each do |e| if u_o.find{|x| yield(e,x)} then i.push(e) # intersection else m.push(e) end # missing end u_o.each { |e| a.push(e) unless u_s.find{|x| yield(e,x)} } # added return [ m, i, a ] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def intersection(other)\n mapping_function = 'lambda{|item| [item, nil]}'\n filter_function = 'lambda{|(key, values)| values.size > 1}'\n\n self.map(mapping_function)\n .cogroup(other.map(mapping_function))\n .filter(filter_function)\n .keys\n end", "def intersection...
[ "0.6463318", "0.6434339", "0.64196086", "0.6398085", "0.6330684", "0.63111794", "0.63084733", "0.62999773", "0.62926793", "0.6285353", "0.628442", "0.6270222", "0.6247685", "0.62414056", "0.6232856", "0.623028", "0.62068194", "0.6199519", "0.6198729", "0.6179617", "0.6146464"...
0.6498081
0
Never trust parameters from the scary internet, only allow the white list through.
def material_params params.require(:material_payment_detail).permit! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
validates :set_at, presence: true validate :deadline_is_after_set_date
def is_started self.set_at < DateTime.current end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_dates\n if start_at && end_at\n errors.add(:end_at, 'should be greater than start date') if end_at <= start_at\n end\n end", "def check_deadline\n true\n end", "def deadline_valid?\n return if self.deadline.nil?\n\n \tif self.deadline < Date.today then\n \t\terrors.add(:deadli...
[ "0.6956153", "0.6946135", "0.69181985", "0.6815342", "0.67727363", "0.6757292", "0.67460567", "0.6674652", "0.6614311", "0.6614311", "0.6608941", "0.66007626", "0.65920836", "0.65629995", "0.6499735", "0.6411469", "0.63830566", "0.63658035", "0.6362172", "0.6346657", "0.63328...
0.0
-1
GET /tags/1 GET /tags1.xml
def show @tag = Tag.find(params[:id]) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @tags } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tags\n get('tags')\n end", "def index\n @tags = Tag.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tags }\n end\n end", "def index\n @tags = Tag.all\n\n respond_to do |format|\n format.html # index.html.erb\n form...
[ "0.7441045", "0.70106465", "0.69114166", "0.6769297", "0.67463416", "0.6695021", "0.6690543", "0.66051054", "0.6579541", "0.6551685", "0.64882076", "0.64621073", "0.6449327", "0.6415068", "0.6407007", "0.63841677", "0.6356695", "0.6349937", "0.63478947", "0.6347308", "0.63278...
0.6946127
2
DELETE /tag/1 DELETE /tag/1.xml
def delete @tag = Tag.find(params[:id]) @tag.destroy respond_to do |format| format.html { redirect_to(tags_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_tag tag\n delete \"tag/#{tag}\"\n end", "def delete\n validate_presence_of :name\n wrapper.delete_tag(@name) || raise(OperationFailed)\n end", "def delete(tag)\n api_client.tags.multi_delete(resource_hrefs: [api_client.get_instance.href], tags: [tag])\n end", "def destroy\...
[ "0.77442306", "0.716059", "0.7126062", "0.71187997", "0.7118112", "0.7052883", "0.7052883", "0.7052883", "0.7052883", "0.69854707", "0.6887485", "0.67956275", "0.6783363", "0.6780496", "0.66951627", "0.6687579", "0.66849405", "0.66846985", "0.66442937", "0.65794796", "0.65705...
0.74141
1
GET /volume_type_extra_specs/1 GET /volume_type_extra_specs/1.json
def show @volume_type_extra_spec = VolumeTypeExtraSpec.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @volume_type_extra_spec } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @volume_type_extra_spec = VolumeTypeExtraSpec.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @volume_type_extra_spec }\n end\n end", "def create\n @volume_type_extra_spec = VolumeTypeExtraSpec.new(params[:volume_type_extra_spec])\n\n r...
[ "0.7397906", "0.65336", "0.62086976", "0.5914503", "0.5801685", "0.5634308", "0.5448457", "0.5425391", "0.5394772", "0.52799916", "0.5259073", "0.52480763", "0.5192967", "0.5101888", "0.5081338", "0.5077154", "0.50705016", "0.5066018", "0.5012441", "0.5011579", "0.5011543", ...
0.7772873
0
GET /volume_type_extra_specs/new GET /volume_type_extra_specs/new.json
def new @volume_type_extra_spec = VolumeTypeExtraSpec.new respond_to do |format| format.html # new.html.erb format.json { render json: @volume_type_extra_spec } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @volume_type_extra_spec = VolumeTypeExtraSpec.new(params[:volume_type_extra_spec])\n\n respond_to do |format|\n if @volume_type_extra_spec.save\n format.html { redirect_to @volume_type_extra_spec, notice: 'Volume type extra spec was successfully created.' }\n format.json { ren...
[ "0.761216", "0.67376727", "0.67192155", "0.6077296", "0.60106", "0.59591234", "0.59568596", "0.59470963", "0.5935265", "0.58708817", "0.5864193", "0.5826476", "0.57915634", "0.5717848", "0.5714081", "0.56829727", "0.5679737", "0.56754816", "0.56685734", "0.5663754", "0.565735...
0.8465258
0
POST /volume_type_extra_specs POST /volume_type_extra_specs.json
def create @volume_type_extra_spec = VolumeTypeExtraSpec.new(params[:volume_type_extra_spec]) respond_to do |format| if @volume_type_extra_spec.save format.html { redirect_to @volume_type_extra_spec, notice: 'Volume type extra spec was successfully created.' } format.json { render json: @volume_type_extra_spec, status: :created, location: @volume_type_extra_spec } else format.html { render action: "new" } format.json { render json: @volume_type_extra_spec.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @volume_type_extra_spec = VolumeTypeExtraSpec.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @volume_type_extra_spec }\n end\n end", "def show\n @volume_type_extra_spec = VolumeTypeExtraSpec.find(params[:id])\n\n respond_to do |format|...
[ "0.70822537", "0.62499845", "0.6201964", "0.60505337", "0.5868523", "0.5647124", "0.55948615", "0.55827147", "0.54701483", "0.5386745", "0.53810173", "0.53691924", "0.53580326", "0.5348634", "0.53468966", "0.53343153", "0.53332937", "0.529459", "0.52892727", "0.5264735", "0.5...
0.72364885
0
PUT /volume_type_extra_specs/1 PUT /volume_type_extra_specs/1.json
def update @volume_type_extra_spec = VolumeTypeExtraSpec.find(params[:id]) respond_to do |format| if @volume_type_extra_spec.update_attributes(params[:volume_type_extra_spec]) format.html { redirect_to @volume_type_extra_spec, notice: 'Volume type extra spec was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @volume_type_extra_spec.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @volume_type_extra_spec = VolumeTypeExtraSpec.new(params[:volume_type_extra_spec])\n\n respond_to do |format|\n if @volume_type_extra_spec.save\n format.html { redirect_to @volume_type_extra_spec, notice: 'Volume type extra spec was successfully created.' }\n format.json { ren...
[ "0.6800709", "0.67319244", "0.6444574", "0.61667085", "0.545065", "0.5423889", "0.5366115", "0.5341389", "0.53084254", "0.5279852", "0.52789646", "0.52410734", "0.52309096", "0.5183477", "0.5177039", "0.51558006", "0.51536363", "0.50988793", "0.5098432", "0.50854594", "0.5066...
0.7433172
0
DELETE /volume_type_extra_specs/1 DELETE /volume_type_extra_specs/1.json
def destroy @volume_type_extra_spec = VolumeTypeExtraSpec.find(params[:id]) @volume_type_extra_spec.destroy respond_to do |format| format.html { redirect_to volume_type_extra_specs_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @volume_type = VolumeType.find(params[:id])\n @volume_type.destroy\n\n respond_to do |format|\n format.html { redirect_to volume_types_url }\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]...
[ "0.6655436", "0.6466792", "0.6397014", "0.6332519", "0.6300526", "0.62961525", "0.6283448", "0.6278895", "0.6209949", "0.6202133", "0.61194897", "0.6090132", "0.60406244", "0.60292786", "0.60286856", "0.6028363", "0.6017438", "0.5999462", "0.5995463", "0.59772295", "0.5972925...
0.8040524
0
Gets the additionalData property value. Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.
def additional_data return @additional_data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[]
[]
0.0
-1
Sets the additionalData property value. Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.
def additional_data=(value) @additional_data = value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[]
[]
0.0
-1
Gets the bitlocker property value. The bitlocker property
def bitlocker return @bitlocker end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bitlocker=(value)\n @bitlocker = value\n end", "def bit_locker_enabled\n return @bit_locker_enabled\n end", "def bit_locker_enabled=(value)\n @bit_locker_enabled = value\n end", "def current_lock_value\n lock_column_name =...
[ "0.7117406", "0.70967126", "0.62142086", "0.6014579", "0.57696897", "0.55912304", "0.55809236", "0.55676275", "0.5392867", "0.5300605", "0.52965957", "0.52716494", "0.5253595", "0.5190836", "0.51891273", "0.5180456", "0.51771677", "0.5163329", "0.5122544", "0.51087004", "0.50...
0.78894216
0
Sets the bitlocker property value. The bitlocker property
def bitlocker=(value) @bitlocker = value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bit_locker_enabled=(value)\n @bit_locker_enabled = value\n end", "def is_locked=(value)\n @is_locked = value\n end", "def bitlocker\n return @bitlocker\n end", "def lock=(value)\n doc['lock'] = value\n end", "...
[ "0.735838", "0.61879313", "0.6164912", "0.61642563", "0.5829272", "0.58162206", "0.5810234", "0.5809187", "0.5809187", "0.5759192", "0.5693898", "0.5636265", "0.55692726", "0.553268", "0.55181444", "0.54940313", "0.54911226", "0.5476573", "0.54755676", "0.5392301", "0.5390236...
0.86828667
0
Instantiates a new informationProtection and sets the default values.
def initialize() @additional_data = Hash.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize()\n super\n @odata_type = \"#microsoft.graph.windowsInformationProtection\"\n end", "def information_protection()\n return MicrosoftGraph::InformationProtection::InformationProtectionRequestBuilder.new(@path_parameters, @request_adapter)\n ...
[ "0.64512944", "0.6377435", "0.5916765", "0.5835043", "0.58183855", "0.5800214", "0.57904184", "0.5779624", "0.5703225", "0.5690581", "0.56188506", "0.5607529", "0.55830973", "0.5572645", "0.55348665", "0.55283684", "0.5477744", "0.5439377", "0.54259413", "0.54230803", "0.5409...
0.0
-1
The deserialization information for the current model
def get_field_deserializers() return { "bitlocker" => lambda {|n| @bitlocker = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Bitlocker.create_from_discriminator_value(pn) }) }, "@odata.type" => lambda {|n| @odata_type = n.get_string_value() }, "threatAssessmentRequests" => lambda {|n| @threat_assessment_requests = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::ThreatAssessmentRequest.create_from_discriminator_value(pn) }) }, } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deserialized\n @deserialized ||= @serializer.deserialize @serialized_object\n end", "def get_field_deserializers()\n return super.merge({\n \"detectionStatus\" => lambda {|n| @detection_status = n.get_enum_value(MicrosoftGraph::Models::SecurityDetectionStatus) },...
[ "0.6510328", "0.6323003", "0.6322845", "0.63094926", "0.6295323", "0.6238978", "0.6232471", "0.6215208", "0.6200003", "0.6199561", "0.6173967", "0.61738604", "0.61706495", "0.6162793", "0.6162064", "0.61581045", "0.61554873", "0.6142973", "0.61398435", "0.6137782", "0.6119926...
0.0
-1
Serializes information the current object
def serialize(writer) raise StandardError, 'writer cannot be null' if writer.nil? writer.write_object_value("bitlocker", @bitlocker) writer.write_string_value("@odata.type", @odata_type) writer.write_collection_of_object_values("threatAssessmentRequests", @threat_assessment_requests) writer.write_additional_data(@additional_data) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serialize\n end", "def serialize(object) end", "def serialize; end", "def serialize; end", "def serialize\n \n end", "def serialize\n raise NotImplementedError\n end", "def serialize\n raise NotImplementedError\n end", "def dump\r\n super + to_s\r\n end", ...
[ "0.7951372", "0.7645999", "0.7579812", "0.7579812", "0.7440032", "0.720861", "0.720861", "0.7207583", "0.7016516", "0.70007193", "0.6992252", "0.69838214", "0.69723576", "0.69666415", "0.69666415", "0.6942002", "0.69417155", "0.6933786", "0.6913977", "0.6891677", "0.68810964"...
0.0
-1
Gets the threatAssessmentRequests property value. The threatAssessmentRequests property
def threat_assessment_requests return @threat_assessment_requests end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def threat_assessment_requests=(value)\n @threat_assessment_requests = value\n end", "def assignment_requests\n return @assignment_requests\n end", "def assignment_requests=(value)\n @assignment_requests = value\n end", "def resour...
[ "0.7765481", "0.6280652", "0.600192", "0.5936017", "0.5930219", "0.5883874", "0.579523", "0.56569934", "0.5632399", "0.5513816", "0.5424495", "0.52939165", "0.527277", "0.5228447", "0.51895714", "0.5177893", "0.51691926", "0.5148204", "0.5134828", "0.5123201", "0.5099859", ...
0.8232879
0
Sets the threatAssessmentRequests property value. The threatAssessmentRequests property
def threat_assessment_requests=(value) @threat_assessment_requests = value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assignment_requests=(value)\n @assignment_requests = value\n end", "def resource_requests=(value)\n @resource_requests = value\n end", "def threat_assessment_requests\n return @threat_assessment_requests\n end", "def app_consen...
[ "0.6908566", "0.64106923", "0.629039", "0.62819856", "0.52361965", "0.5195391", "0.51923823", "0.5013602", "0.4989052", "0.49706754", "0.49219468", "0.48954946", "0.48828527", "0.48553044", "0.48395368", "0.48242202", "0.4794088", "0.47870213", "0.47834694", "0.47740534", "0....
0.85220194
0
Use callbacks to share common setup or constraints between actions.
def set_user @user = User.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.61637366", "0.60446453", "0.59452957", "0.591511", "0.58885515", "0.5834122", "0.57761765", "0.5702554", "0.5702554", "0.5652102", "0.5619581", "0.5423898", "0.5409782", "0.5409782", "0.5409782", "0.5394745", "0.53780794", "0.5356209", "0.5338898", "0.53381324", "0.5328622...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def user_params params[:user] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.6981606", "0.6784227", "0.6746523", "0.67439264", "0.67361516", "0.6593381", "0.6506166", "0.64994407", "0.6483518", "0.64797056", "0.64578557", "0.6441216", "0.63811713", "0.63773805", "0.6366333", "0.63217646", "0.6301816", "0.63009787", "0.6294436", "0.62940663", "0.629...
0.0
-1
GET /restaurants GET /restaurants.xml
def index @restaurants = Restaurant.all_by_name respond_to do |format| format.html # index.html.erb format.xml { render :xml => @restaurants } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @restaurants = Restaurant.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @restaurants }\n end\n end", "def index\n @tipo_restaurantes = TipoRestaurante.all\n\n respond_to do |format|\n format.html # index.html.erb\n for...
[ "0.74780864", "0.6835002", "0.660537", "0.65713215", "0.6486935", "0.6465658", "0.6458973", "0.6453369", "0.6447794", "0.6433716", "0.6433499", "0.64180326", "0.64176154", "0.63469523", "0.6339134", "0.6339134", "0.6339134", "0.6339134", "0.6339134", "0.6339134", "0.6339134",...
0.7317863
1
GET /restaurants/1 GET /restaurants/1.xml
def show @restaurant = Restaurant.find(params[:id]) @user_rating = @restaurant.user_rating(current_user) @average_rating = @restaurant.average_rating respond_to do |format| format.html # show.html.erb format.json { render :json => @restaurant.application_hash(current_user).to_json } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @restaurants = Restaurant.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @restaurants }\n end\n end", "def index\n @restaurants = Restaurant.all_by_name\n\n respond_to do |format|\n format.html # index.html.erb\n format...
[ "0.7312316", "0.7214", "0.66905916", "0.65636134", "0.65185714", "0.6461241", "0.64579237", "0.6369934", "0.6369934", "0.6330966", "0.6330966", "0.6330966", "0.63056296", "0.623698", "0.6215419", "0.6215419", "0.6215419", "0.6213398", "0.62103826", "0.6196184", "0.61683315", ...
0.0
-1
GET /restaurants/new GET /restaurants/new.xml
def new @restaurant = Restaurant.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @restaurant } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @restaurant_page = RestaurantPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @restaurant_page }\n end\n end", "def new\r\n @restaurant = Restaurant.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n f...
[ "0.72018874", "0.70743674", "0.7065822", "0.7065822", "0.7065822", "0.7065822", "0.7065822", "0.7038002", "0.69016874", "0.6885395", "0.6826408", "0.6821969", "0.68014574", "0.67979336", "0.6783377", "0.67745024", "0.6739561", "0.6739561", "0.67123044", "0.66988325", "0.66971...
0.76667094
1
POST /restaurants POST /restaurants.xml
def create @restaurant = Restaurant.new(params[:restaurant]) respond_to do |format| if @restaurant.save format.html { redirect_to(@restaurant, :notice => 'Restaurant was successfully created.') } format.xml { render :xml => @restaurant, :status => :created, :location => @restaurant } else format.html { render :action => 'new' } format.xml { render :xml => @restaurant.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n \t@restaurant = Restaurant.new(params[:restaurant])\n\n \trespond_to do |format|\n \t\tif @restaurant.save\n \t\t\tformat.html { redirect_to @restaurant, notice: 'Restaurant was successfully created.' }\n \t\t\tformat.json { render json: @restaurant, status: :created, location: @restaurant }\n \...
[ "0.64400935", "0.63993526", "0.638462", "0.6373262", "0.6346614", "0.6346614", "0.6346614", "0.63431096", "0.63431096", "0.63431096", "0.6338989", "0.63236225", "0.62966096", "0.6278025", "0.62597924", "0.62534636", "0.6201614", "0.61653006", "0.61399496", "0.6138817", "0.612...
0.6738056
0
PUT /restaurants/1 PUT /restaurants/1.xml
def update @restaurant = Restaurant.find(params[:id]) respond_to do |format| if @restaurant.update_attributes(params[:restaurant]) format.html { redirect_to(@restaurant, :notice => 'Restaurant was successfully updated.') } format.xml { head :ok } format.json { render :json => { :status => :ok }.to_json } else format.html { render :action => 'edit' } format.xml { render :xml => @restaurant.errors, :status => :unprocessable_entity } format.json { fail } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n json_response(@restaurant.update!(restaurant_params))\n end", "def update\n update_restaurant\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update\n @restaurant = Restaurant.fi...
[ "0.6505004", "0.6423072", "0.6231644", "0.6007114", "0.6007114", "0.6007114", "0.6007114", "0.5972717", "0.5942112", "0.59403384", "0.5925701", "0.5890036", "0.58589846", "0.58506835", "0.58438855", "0.5836132", "0.5828231", "0.57526326", "0.57526326", "0.57526326", "0.575263...
0.6291477
2
DELETE /restaurants/1 DELETE /restaurants/1.xml
def destroy @restaurant = Restaurant.find(params[:id]) @restaurant.destroy respond_to do |format| format.html { redirect_to(restaurants_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n # DELETE\n # TODO: removes a specific restaurant\n DB.execute(\"DELETE FROM restaurants WHERE id = #{@id}\")\n nil\n end", "def destroy\n\n @restaurant.delete\n\n redirect_to root_path\n end", "def destroy\n @restaurant = @restaurant.find(params[:id])\n @restaurant.destr...
[ "0.68683743", "0.675761", "0.6731963", "0.67264307", "0.67081875", "0.66977817", "0.66817325", "0.6680576", "0.6666759", "0.6638435", "0.6638435", "0.6638435", "0.6638435", "0.6638435", "0.6638435", "0.6638435", "0.6638435", "0.6570686", "0.65578055", "0.6555993", "0.6509469"...
0.7196978
1
TODO support a block (solo dentro l blocco fai il nocolor)
def set_color(bool) b = bool ? true : false deb "Setting color mode to: #{yellow bool} --> #{white b.to_s}" b = false if bool.to_s.match( /(off|false)/ ) deb "Setting color mode to: #{yellow bool} --> #{white b.to_s}" if block_given? puts "TODO!!! scolara qui" yield puts "TODO ricolora qui" end $colors_active = bool end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_block_color(x, y, z)\n 0xffeeeeee\n end", "def render_colour(&block)\n [ colour.to_s, yield, parent_colour ].join\n end", "def char_to_block c\n c = bg_white \" \" if c == \"W\" \n c = bg_red \" \" if c == \"R\" \n c = bg_green \" \" if c == \"G\" \n c = bg_yellow \" \"...
[ "0.64778554", "0.6200338", "0.6191697", "0.61166006", "0.6114236", "0.6007945", "0.5975908", "0.5975908", "0.5975908", "0.5912601", "0.5912601", "0.59088856", "0.59088856", "0.58906585", "0.58808786", "0.5870317", "0.5870317", "0.5865262", "0.586359", "0.58425957", "0.582357"...
0.0
-1
"\e[0;31m42\e[0m" > "42" \e[38;5;28mXXXX > "XXX"
def scolora(str) str.to_s. gsub(/\e\[1;33m/,''). # colori 16 gsub(/\e\[0m/,''). # colori 64k gsub(/\e\[38;\d+;\d+m/,'') # end color end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def puts_red(str)\n puts \" \\e[00;31m#{str}\\e[00m\"\nend", "def red(str)\n \"\\e[31m#{str}\\e[0m\"\nend", "def red(str)\n \"\\e[31m#{str}\\e[0m\"\nend", "def red(str)\n \"\\e[31m#{str}\\e[0m\"\nend", "def red(str)\n \"\\e[31m#{str}\\e[0m\"\nend", "def red(str)\n \"\\e[31m#{str}\\e[0m\"\nend", ...
[ "0.8164938", "0.8109721", "0.8109721", "0.8109721", "0.8109721", "0.8109721", "0.8047824", "0.8047824", "0.7942996", "0.7942996", "0.7780382", "0.7771676", "0.7771676", "0.7683664", "0.7683664", "0.7649276", "0.75572354", "0.7491701", "0.7491701", "0.7459633", "0.74348915", ...
0.7409559
21
italia: green white red ireland: green white orange france: green white orange UK: blue white red white blue google:
def _flag_nations %w{ar cc it de ie fr es en goo br po pt }.sort end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def welcome_explainer\n name = \" Legislature Information on Bills and Sponsors \"\n print ColorizedString[\"_/\\\\_\"].white.on_blue \n puts ColorizedString[name.center(name.length)].black.on_white\n print ColorizedString[\"\\\\/\\\\/\"].white.on_blue \n puts ColorizedString[\"(from Open States API...
[ "0.58828396", "0.58099174", "0.5752893", "0.57418746", "0.5736566", "0.5657857", "0.56521404", "0.55776745", "0.55747294", "0.5573374", "0.55730903", "0.5512675", "0.5428625", "0.53866047", "0.5382701", "0.5370749", "0.536549", "0.53557634", "0.5350152", "0.5336903", "0.53261...
0.49910998
77
for simmetry padding m = length / 3 6: 2 2 2 m m m REST 0 5: 2 1 2 m+1 m m+1 2 4: 1 2 1 m m+1 m 1
def flag3(str,left_color='brown',middle_color='pink',right_color='red') m = str.length / 3 remainder = str.length % 3 central_length = remainder == 1 ? m+1 : m lateral_length = remainder == 2 ? m+1 : m colora( left_color, str[ 0 .. lateral_length-1] ) + colora( middle_color, str[ lateral_length .. lateral_length+central_length-1] ) + colora( right_color, str[ lateral_length+central_length .. str.length ] ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def padding; 3; end", "def padding; end", "def padding; end", "def padding=(pad); end", "def standard_padding; 0; end", "def padding(n, c = \"\\0\")\n m = n % 4\n c * (m == 0 ? 0 : 4 - m)\n end", "def padding=(_arg0); end", "def standard_padding\n return 0\n end", "def padding_size\n ...
[ "0.7228809", "0.7092618", "0.7092618", "0.6799517", "0.65652347", "0.6392708", "0.6316994", "0.6256758", "0.60917675", "0.60581064", "0.59782857", "0.59300977", "0.59196544", "0.59165", "0.59071195", "0.59048706", "0.58945346", "0.5881639", "0.5865804", "0.5818814", "0.581881...
0.0
-1
should this work at all?!?
def to_s 'RicColor: ' + self.send(@color) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def schubert; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def suivre; end", "def formation; end", "def anchored; end", "def terpene; end", "def stderrs; end", "def weber; end", "def custom; end", "def custom;...
[ "0.72507745", "0.6745594", "0.6509047", "0.6488207", "0.6488207", "0.6488207", "0.6488207", "0.6102159", "0.6069831", "0.6055416", "0.6028819", "0.602777", "0.6005797", "0.59461635", "0.59461635", "0.59266585", "0.59178823", "0.587563", "0.5861205", "0.5857423", "0.578513", ...
0.0
-1
Check whether credentials are present
def credentials? if credentials[:access_token] true elsif credentials[:client_id] && credentials[:client_secret] true else false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_credentials?(credentials)\n !credentials[:username].to_s.empty? && !credentials[:password].to_s.empty?\n end", "def valid_credentials?\n return false if Sailpoint.config.username.blank? && Sailpoint.config.password.blank?\n\n !Sailpoint.config.hashed_credentials.blank?\n end", ...
[ "0.8130212", "0.80164087", "0.79186815", "0.7841445", "0.78204155", "0.77674896", "0.7646362", "0.7618179", "0.7576779", "0.7566232", "0.7506995", "0.7473709", "0.74090683", "0.7322166", "0.7255672", "0.7205705", "0.7190739", "0.7186252", "0.7165652", "0.71636933", "0.7163693...
0.75432163
10
POST no se ve
def create user = User.find_by_email(sessions_params[:email]) if user and user.authenticate(sessions_params[:password]) login user end redirect_to rooth_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def POST; end", "def post; end", "def post\r\n end", "def post_data; end", "def post\n end", "def post_data=(_arg0); end", "def post!\n request! :post\n end", "def raw_post; end", "def post_request(object)\n end", "def post\n request_object.post_query\n end", "def process_post\n ...
[ "0.81897926", "0.7764197", "0.77157986", "0.7596525", "0.73446786", "0.6987326", "0.69704", "0.693878", "0.6894886", "0.67281", "0.66059643", "0.6592863", "0.6573517", "0.6572344", "0.6536657", "0.6529181", "0.6510034", "0.64981735", "0.64639944", "0.64356285", "0.64005107", ...
0.0
-1
With block, execute block passing self then close Note host must be the local host, but you can pass '::1' instead for ipv6
def initialize(host='127.0.0.1') @sock = Socket.new(:INET, :STREAM) @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true) @sock.bind(Socket.sockaddr_in(0, host)) @host, @port = @sock.connect_address.ip_unpack @addr = "#{@host}:#{@port}" if block_given? begin yield self ensure close end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exec &block\n connect!\n yield self\n ensure\n disconnect!\n end", "def each_host(&block)\n hosts.each do |host|\n host.instance_exec &block\n end\n end", "def execute(options = {}, &block)\n execute_with(@hosts, options, &block)\n end", "def execute(&block)\n\tbl...
[ "0.7182437", "0.6672928", "0.6641094", "0.6445199", "0.6445199", "0.64233136", "0.64233136", "0.6383371", "0.6383317", "0.6383317", "0.6383317", "0.6361314", "0.6240076", "0.62066936", "0.62021965", "0.6200986", "0.6196203", "0.6170938", "0.61683196", "0.61462945", "0.6138764...
0.56830734
98
Pass optional extra handlers and options to the Container
def initialize(raise_errors=true) super() @raise_errors = raise_errors @errors, @connections, @sessions, @links, @messages = 5.times.collect { [] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_handler(opts={})\n end", "def setup_handler\n end", "def on(*args, &block)\n @options.push args << lambda(&block)\n end", "def add_handler(opts={})\n return if not payload_instance\n return if not handler_enabled?\n payload_instance.add_handler(opts)\n end", "def method_missing(...
[ "0.6907749", "0.5937733", "0.58612424", "0.5672098", "0.56403327", "0.5594009", "0.559196", "0.55610937", "0.5549743", "0.5530279", "0.55202234", "0.551433", "0.55048233", "0.54954624", "0.5492271", "0.5478157", "0.5445795", "0.5443701", "0.54261684", "0.54138696", "0.5393945...
0.0
-1
TODO aconway 20170815: implement in MessagingHandler
def on_error(event, endpoint) @errors.push "#{event.type}: #{endpoint.condition.name}: #{endpoint.condition.description}" raise_errors if @raise_errors end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def messaging\n end", "def process_message(message)\n end", "def process_msgs\n end", "def on_message(m)\n end", "def message_buffer; end", "def next_message; end", "def next_message; end", "def message(message) end", "def onmessage(&blk); super; end", "def handle_message(request, message...
[ "0.69491136", "0.67388403", "0.6733677", "0.6675591", "0.6667253", "0.66569066", "0.66569066", "0.6563623", "0.6535531", "0.6530238", "0.65078115", "0.64788795", "0.64788795", "0.63994694", "0.6385199", "0.63561815", "0.6355064", "0.62659925", "0.62659925", "0.6225685", "0.62...
0.0
-1
Maps shelfmarks in different classification to LibraryMapping's ordering system
def shelfmarkToOrder(shelfmark, identifier) # Library of Congress classifications # Add other LoC collections here if identifier == "lc_main" || identifier == "lc_hub" || identifier == "lc_murray" letters = shelfmark.match(/^((Folio )|(Pamph. )|(Ref. ))?[A-Z]+/)[0] if letters[0..4] == "Ref. " letters = letters[5..letters.length] end if identifier == "lc_main" subclass = LcSection.where(:letters => letters).first elsif identifier == "lc_hub" subclass = HubLcSection.where(:letters => letters).first elsif identifier == "lc_murray" subclass = MurrayLcSection.where(:letters => letters).first end if !subclass or !shelfmark.match(/(\d+)/) return -1 end token = Integer(subclass.token) digits = Integer(shelfmark.match(/(\d+)/)[0]) digits = digits.to_s.rjust(5, "0") # add prepending 0s res = Float(token.to_s + '.' + digits) return res # Dewey Decimal classifications # Add other Dewey Decimal collections here elsif identifier == "dewey_main" || identifier == "journal_main" offset = 0 # Add offsets if Folios or Pamphlets if shelfmark[0] == 'F' offset = 1 shelfmark = shelfmark[2..-1] elsif identifier == "journal_main" shelfmark = shelfmark[5..-1] elsif shelfmark[0] == 'P' offset = 2 shelfmark = shelfmark[2..-1] end shelfmark = shelfmark.gsub(/[^0-9A-Za-z]/, '') shelfmark = shelfmark.match(/^[^\d]*(\d+)/)[0] if !shelfmark return -1 end res = Float("."+shelfmark) - offset return res end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def order_clusters\n use_ary = self.look.face_map.ordered_product_role_array \n use_ary.each_with_index do |params, idx| \n set_cluster_use_order(idx + 1, *params)\n end\n end", "def consolidate_classes(original_line, list_of_classes)\n record = {\n :original_ocr => original_line,\n :a...
[ "0.5395221", "0.51209486", "0.5117386", "0.5110185", "0.50850654", "0.50850654", "0.50748366", "0.5000854", "0.49857238", "0.49496308", "0.49388567", "0.49371508", "0.49283707", "0.4872635", "0.4836811", "0.4819346", "0.48099315", "0.4791151", "0.47894883", "0.47792512", "0.4...
0.69819283
0
Whether to match files or folders with this pattern. Matches both if undefined.
def matches attributes.fetch(:matches) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def match_folder(name, patterns = '*')\n Array(patterns).any? do |pattern|\n if pattern.is_a?(String)\n File.fnmatch(pattern.downcase, name.downcase)\n elsif pattern.is_a?(Regexp)\n name =~ pattern\n else\n nil\n end\n end\n end", "def matches_p...
[ "0.6761411", "0.64691335", "0.6194085", "0.6078107", "0.6046858", "0.6041348", "0.6013773", "0.59906256", "0.598121", "0.59610564", "0.5824606", "0.58044904", "0.5789681", "0.5776302", "0.5738978", "0.56899506", "0.567177", "0.5656745", "0.5651761", "0.56387734", "0.56373453"...
0.0
-1
Additional options used during matching.
def options attributes.fetch(:options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def options(opt); end", "def options(opt); end", "def options() end", "def options(opt)\n end", "def extractable_options?; end", "def parse_additional_options(opts)\n end", "def parse_additional_options(opts)\n end", "def extractable_options?; true end", "def options; @opts end", "def pa...
[ "0.70015794", "0.7000909", "0.69232607", "0.6821578", "0.6798701", "0.671501", "0.671501", "0.6686257", "0.66294795", "0.6621236", "0.6621236", "0.6537398", "0.6537398", "0.6537398", "0.6528906", "0.64763814", "0.64763814", "0.64377165", "0.64377165", "0.64377165", "0.6437716...
0.0
-1
def test_no_bump comment = Comment.create(:do_not_bump_post => "1", :post_id => 1, :user_id => 1, :body => "hello world", :ip_addr => "127.0.0.1") assert_equal("admin", comment.author) assert_equal("hello world", comment.body) assert_nil(Post.find(1).last_commented_at) end
def test_threshold old_threshold = CONFIG["comment_threshold"] CONFIG["comment_threshold"] = 1 comment_a = Comment.create(:post_id => 1, :user_id => 1, :body => "mark 1", :ip_addr => "127.0.0.1") sleep 1 Comment.create(:post_id => 1, :user_id => 1, :body => "mark 2", :ip_addr => "127.0.0.1") assert_equal(comment_a.created_at.to_s, Post.find(1).last_commented_at.to_s) CONFIG["comment_threshold"] = old_threshold end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_add_comment_to_post\n nc = @normal_post.number_of_comments\n @normal_post.comments << @comment\n assert_equal(nc + 1, @normal_post.number_of_comments)\n end", "def test_function_create_comment_unsuccessfully\n data = {\n user_id: \"wrong_id\",\n post_id: 1,\n cont...
[ "0.7085836", "0.7032158", "0.6950207", "0.68210894", "0.6665146", "0.6569", "0.65284556", "0.6511523", "0.6466415", "0.63680035", "0.6302621", "0.6180156", "0.6156163", "0.6147225", "0.60888183", "0.60747224", "0.60459805", "0.59888107", "0.59836113", "0.5965056", "0.59380734...
0.68078226
4
Todo: Add description for test test_json_echo
def test_json_echo() # Parameters for the API call input = JSON.parse('{"uid": "1123213", "name": "Shahid"}') # Perform the API call through the SDK function result = self.class.controller.json_echo(input) # Test response code assert_equal(@response_catcher.response.status_code, 200) # Test whether the captured response is as we expected assert_not_nil(result) expected_body = JSON.parse('{"body": {"uid": "1123213", "name": "Shahid"}}') received_body = JSON.parse(@response_catcher.response.raw_body) assert(TestHelper.match_body(expected_body, received_body, check_values: true)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_json_obj\n \n end", "def json_echo(input)\n # Validate required parameters.\n validate_parameters(\n 'input' => input\n )\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/'\n _query_builder = APIHelper.append_url_with_quer...
[ "0.6856633", "0.6757802", "0.6605867", "0.65239316", "0.64053684", "0.63908887", "0.62944907", "0.62657213", "0.6249879", "0.6247412", "0.6239844", "0.6196197", "0.61949646", "0.6153653", "0.6140871", "0.6101634", "0.6101634", "0.60939026", "0.6076754", "0.6005271", "0.599850...
0.77563065
0
Todo: Add description for test test_form_echo
def test_form_echo() # Parameters for the API call input = JSON.parse('{"uid": "1123213", "name": "Shahid"}') # Perform the API call through the SDK function result = self.class.controller.form_echo(input) # Test response code assert_equal(@response_catcher.response.status_code, 200) # Test whether the captured response is as we expected assert_not_nil(result) expected_body = JSON.parse('{"body":{"input":{"uid":"1123213","name":"Shahid"}}}') received_body = JSON.parse(@response_catcher.response.raw_body) assert(TestHelper.match_body(expected_body, received_body, check_values: true)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def form; end", "def test_assert_xhtml_for_forms\r\n assert_xhtml SAMPLE_FORM, &assemble_form_example\r\n end", "def form_echo(input)\n # Validate required parameters.\n validate_parameters(\n 'input' => input\n )\n # Prepare query url.\n _query_builder = config.get_base_uri...
[ "0.68287235", "0.6644054", "0.6628246", "0.66068697", "0.6247186", "0.6244212", "0.62258273", "0.61960036", "0.6158067", "0.61299103", "0.6024746", "0.6002923", "0.599818", "0.59130687", "0.5906734", "0.58740234", "0.58671206", "0.5850778", "0.5848003", "0.5836741", "0.582174...
0.70177996
0
Todo: Add description for test test_query_echo
def test_query_echo() # dictionary for optional query parameters optional_query_parameters = {} optional_query_parameters['hello'] = 'world' # Perform the API call through the SDK function result = self.class.controller.query_echo(optional_query_parameters) # Test response code assert_equal(@response_catcher.response.status_code, 200) # Test whether the captured response is as we expected assert_not_nil(result) expected_body = JSON.parse('{"query":{"hello":"world"}}') received_body = JSON.parse(@response_catcher.response.raw_body) assert(TestHelper.match_body(expected_body, received_body, check_values: true)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def execute_query(query_type, test)\n if @per_test_insert\n query_data = translate_column_names(test['query'])\n else\n query_data = test['query']\n end\n puts ' Querying'\n\n if @verbose\n puts \" - #{query_data}\"\n end\n\n if query_type == 'count_entity'\n result = @...
[ "0.6956925", "0.66494817", "0.66321176", "0.65146047", "0.639458", "0.6308595", "0.6296868", "0.6278517", "0.6273973", "0.6242118", "0.6168635", "0.61492795", "0.6147408", "0.6144564", "0.6144564", "0.6144564", "0.6121065", "0.61039025", "0.60602313", "0.6048625", "0.6046112"...
0.7443041
0
GET /personaje_mvc3s/1 GET /personaje_mvc3s/1.xml
def show @personaje_mvc3 = PersonajeMvc3.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @personaje_mvc3 } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @personaje_sf3 = PersonajeSf3.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @personaje_sf3 }\n end\n end", "def new\n @personaje_sf3 = PersonajeSf3.new\n\n respond_to do |format|\n format.html # new.html.erb\n ...
[ "0.7105166", "0.6525821", "0.60093594", "0.5984171", "0.58895206", "0.5815556", "0.57810116", "0.57513535", "0.5740635", "0.5713122", "0.5711591", "0.570392", "0.5700069", "0.56865805", "0.5679837", "0.5676328", "0.56487006", "0.5625557", "0.5625557", "0.5625557", "0.56242406...
0.68612444
1
GET /personaje_mvc3s/new GET /personaje_mvc3s/new.xml
def new @personaje_mvc3 = PersonajeMvc3.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @personaje_mvc3 } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @personaje_sf3 = PersonajeSf3.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @personaje_sf3 }\n end\n end", "def new_nonva_porca_pupazza\n @person= Person.new\n respond_to do |format|\n format.html\n format.xml { render :x...
[ "0.759758", "0.6801712", "0.6689155", "0.66573215", "0.6480997", "0.6415503", "0.6299812", "0.627992", "0.6266312", "0.6253007", "0.62415075", "0.6241232", "0.6235298", "0.6221656", "0.62026465", "0.62026465", "0.62026465", "0.62026465", "0.62026465", "0.62026465", "0.6202646...
0.68695694
1
POST /personaje_mvc3s POST /personaje_mvc3s.xml
def create @personaje_mvc3 = PersonajeMvc3.new(params[:personaje_mvc3]) respond_to do |format| if @personaje_mvc3.save format.html { redirect_to(@personaje_mvc3, :notice => 'Personaje mvc3 was successfully created.') } format.xml { render :xml => @personaje_mvc3, :status => :created, :location => @personaje_mvc3 } else format.html { render :action => "new" } format.xml { render :xml => @personaje_mvc3.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n if autenticacion == \"admin\"\n @personaje_sf3 = PersonajeSf3.new(params[:personaje_sf3])\n\n respond_to do |format|\n if @personaje_sf3.save\n format.html { redirect_to(@personaje_sf3, :notice => 'Personaje sf3 was successfully created.') }\n format.xml { render :xml => @...
[ "0.6782418", "0.61740136", "0.6089112", "0.57847923", "0.57181877", "0.5674403", "0.5588757", "0.5583017", "0.55772835", "0.55581826", "0.55453116", "0.55189854", "0.54745746", "0.5471025", "0.5467342", "0.54635453", "0.5458088", "0.5439107", "0.54386187", "0.5423601", "0.542...
0.6850023
0
PUT /personaje_mvc3s/1 PUT /personaje_mvc3s/1.xml
def update @personaje_mvc3 = PersonajeMvc3.find(params[:id]) respond_to do |format| if @personaje_mvc3.update_attributes(params[:personaje_mvc3]) format.html { redirect_to(@personaje_mvc3, :notice => 'Personaje mvc3 was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @personaje_mvc3.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if autenticacion == \"admin\"\n @personaje_sf3 = PersonajeSf3.find(params[:id])\n\n respond_to do |format|\n if @personaje_sf3.update_attributes(params[:personaje_sf3])\n format.html { redirect_to(@personaje_sf3, :notice => 'Personaje sf3 was successfully updated.') }\n for...
[ "0.65796113", "0.61358404", "0.60440576", "0.59376746", "0.5930835", "0.588541", "0.58508945", "0.5836649", "0.57983035", "0.5794363", "0.57855594", "0.57767713", "0.57657534", "0.57657534", "0.57657534", "0.57534045", "0.5715049", "0.5713948", "0.5713948", "0.5675539", "0.56...
0.65600854
1
DELETE /personaje_mvc3s/1 DELETE /personaje_mvc3s/1.xml
def destroy @personaje_mvc3 = PersonajeMvc3.find(params[:id]) @personaje_mvc3.destroy respond_to do |format| format.html { redirect_to(personaje_mvc3s_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n if autenticacion == \"admin\"\n @personaje_sf3 = PersonajeSf3.find(params[:id])\n @personaje_sf3.destroy\n\n respond_to do |format|\n format.html { redirect_to(personaje_sf3s_url) }\n format.xml { head :ok }\n end\n end\n end", "def destroy\n @persona = Persona.find...
[ "0.7750903", "0.7062926", "0.7033511", "0.6970807", "0.69603986", "0.69122803", "0.6882526", "0.6827166", "0.68263745", "0.68209875", "0.6819689", "0.6809378", "0.68083954", "0.68026066", "0.68004096", "0.679813", "0.67979956", "0.67866766", "0.6785247", "0.67834747", "0.6775...
0.7763357
0
Validates command line arguments.
def parse_options case ARGV[1] when "-p", "-plugin" return true when "-u", "-unplug" return true else return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_arguments()\n usage unless ARGV.count > 0\nend", "def validateArgs\n if ( ! ARGV[0] || ! ARGV[1])\n abort \"must provide two version numbers. try: tagdeleter.rb --help\"\n end\n end", "def validate_args (args)\n\t# todo\nend", "def validate_argv\n if ARGV.empty? t...
[ "0.8197844", "0.776423", "0.7469175", "0.74659914", "0.7404616", "0.7397596", "0.738086", "0.73677737", "0.735901", "0.7237502", "0.7170712", "0.7163199", "0.71191156", "0.71161157", "0.7082781", "0.7076173", "0.7071507", "0.70520663", "0.70520663", "0.7035892", "0.7003149", ...
0.0
-1
Builds parameters and invokes the generator.
def execute(module_name,action) target_dir = Dir.pwd.split('/',Dir.pwd.count('/')+1).last name = target_dir.split('_').map(&:capitalize)*'' case module_name when "authentication" module_class = "::#{name}::AuthenticationApis" when "authorization" module_class = "::#{name}::AuthorizationApis" when "oauth" module_class = "::#{name}::OauthApis" end options = { :project_name => target_dir, :module_class => module_class, :module_name => module_name, :action => action} module_generator = Rammer::ModuleGenerator.new(options) module_generator.run end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build(params); end", "def generate!\n generator.invoke_all\n end", "def generate *args\n generator = generator_for *args\n generator.generate\n end", "def generate *args\n generator = generator_for *args\n generator.generate\n end", "def generators=(_arg0);...
[ "0.65316135", "0.6385835", "0.6172848", "0.6172848", "0.6077575", "0.58810574", "0.58348215", "0.58348215", "0.57840323", "0.57606804", "0.572317", "0.572317", "0.5675981", "0.5675981", "0.5584992", "0.5584147", "0.55775905", "0.5570628", "0.5556642", "0.555117", "0.55218375"...
0.0
-1
returns the active user for this session, or nil if there's no user claiming this session
def user return nil if !session[:user] @user ||= fetch_user(session[:user]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_user\n return @current_user if @current_user\n @current_user = UserFactory.resource.find(session[Casual.session_key])\n \n # If user is not active, unset session\n if UserFactory.user_not_active(@current_user)\n @current_user = nil \n session[Casual....
[ "0.7941136", "0.79250735", "0.7820586", "0.7790969", "0.7762801", "0.77214664", "0.7674655", "0.76107574", "0.757528", "0.757528", "0.757528", "0.757528", "0.7574565", "0.7557688", "0.75566536", "0.75566536", "0.75418913", "0.7503393", "0.7498617", "0.7489967", "0.7483096", ...
0.77902627
6
allows for manually setting the user
def user=(user) session[:user] = nil && return if user.nil? session[:user] = store_user(user) @user = session[:user] ? user : session[:user] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_user; end", "def set_user\r\n @user = current_user\r\n end", "def set_User(value)\n set_input(\"User\", value)\n end", "def set_User(value)\n set_input(\"User\", value)\n end", "def set_User(value)\n set_input(\"User\", value)\n end", "def set_User(value)\n...
[ "0.884554", "0.7988048", "0.7933673", "0.7933568", "0.7933568", "0.7933568", "0.7933568", "0.7933568", "0.7933568", "0.7933568", "0.7886448", "0.78858554", "0.7857343", "0.7857343", "0.7851362", "0.7833824", "0.783151", "0.783151", "0.783151", "0.783151", "0.783151", "0.783...
0.0
-1
retrieve the claimed identity and verify the claim Uses the strategies setup on Authentication executed in the context of the controller to see if it can find a user object
def authenticate(controller, opts = {}) msg = opts.delete(:message) || "Could Not Log In" user = nil # This one should find the first one that matches. It should not run antother Authentication.login_strategies.detect do |s| user = controller.instance_eval(&s) end raise Merb::Controller::Unauthenticated, msg unless user self.user = user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verify_user!\n @profile = current_user.profile\n end", "def verify_user!\n @profile = current_user.profile\n end", "def claim\n put :claim\n end", "def identify\n @user = User.new\n if omniauth = session[:omniauth]\n @provider = omniauth.provider.capitalize\n @user.app...
[ "0.64240116", "0.64240116", "0.63653487", "0.60785717", "0.60226774", "0.5970082", "0.59399945", "0.591393", "0.5909493", "0.58966464", "0.58910006", "0.5814533", "0.58113295", "0.5805497", "0.58048964", "0.5794639", "0.57928205", "0.5791193", "0.5791193", "0.5778068", "0.577...
0.0
-1
abandon the session, log out the user, and empty everything out
def abandon! @user = nil session.delete end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def abandon!\n @user = nil\n session.clear\n end", "def log_out\n reset_session\n @current_user = nil\n end", "def log_out \n session.clear\n @current_user = nil\n end", "def log_out\n\t\tforget(current_user) #call user.forget\n\t\tsession.delete(:user_id)\n\t\t@current_user = n...
[ "0.8561641", "0.81690645", "0.8136536", "0.8127235", "0.8126985", "0.8125098", "0.81151795", "0.8096387", "0.80832267", "0.80704105", "0.8059239", "0.80498874", "0.8040869", "0.803932", "0.8036292", "0.8030662", "0.8030662", "0.8030662", "0.8030662", "0.8030662", "0.80216026"...
0.84714043
2
Overwrite this method to store your user object in the session. The return value of the method will be stored
def store_user(user) raise NotImplemented end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_session\n\t\t@user_session ||= UserSession.new(session)\n\tend", "def store(user)\n @session[:user_id] = user.id\n end", "def set_session user\n session[:user_id] = user.id\n session[:user_fullname] = user.fullname\n session[:user_email] = user.email\n session[:user_access] = user.acce...
[ "0.73375297", "0.73210627", "0.7249329", "0.71718013", "0.715793", "0.71104205", "0.7088765", "0.7085986", "0.7023176", "0.7022646", "0.6988029", "0.69516814", "0.69491935", "0.6925313", "0.6925313", "0.689284", "0.68926096", "0.68849915", "0.6858435", "0.68519545", "0.683955...
0.0
-1
Overwrite this method to fetch your user from the session. The return value of this will be stored as the user object return nil to stop login
def fetch_user(session_contents = session[:user]) raise NotImplemented end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user\n return nil if !session[:user]\n @user ||= fetch_user(session[:user])\n end", "def user\n return nil if !session[:user]\n @user ||= fetch_user(session[:user])\n end", "def user\n return nil if !session[:user]\n @user ||= fetch_user(session[:user])\n end", "def...
[ "0.83908075", "0.83908075", "0.83908075", "0.8192835", "0.7944194", "0.7910337", "0.79071736", "0.7890538", "0.7845849", "0.77529323", "0.77394056", "0.76920193", "0.76673263", "0.76673263", "0.7586853", "0.75830126", "0.7537271", "0.75246996", "0.7397611", "0.73962724", "0.7...
0.72983414
27
attr reader basically does =begin def docked_bikes
def initialize @docked_bikes = [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dock bike\n add_bike bike\n end", "def dock(bike)\n fail 'Capacity full' if full?\n @bikes << bike\n end", "def dock(bike)\n# the method will 'raise' an exception stating no capacity, if\n# the @rack array is at capacity\n raise \"Dock at Capacity\" if @rack.length >= 20 \n# the bike varia...
[ "0.6078725", "0.5918768", "0.59180814", "0.58712995", "0.5849326", "0.5815576", "0.5742331", "0.57139933", "0.54943806", "0.54847604", "0.5399665", "0.5321968", "0.528248", "0.51726377", "0.5153074", "0.5090231", "0.50828683", "0.50727266", "0.5064991", "0.50525445", "0.49985...
0.6447447
0
TODO: integrate proper security after feature is done
def show @lesson = Lesson.find(params[:lesson_id]) # @subscription = @lesson.course.subscriptions.where(:user_id => current_user.id).first @exam = Exam.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def access_control\n \n end", "def authorization; end", "def private; end", "def permitted?; end", "def security_server_client\n end", "def preflight; end", "def auth\n end", "def auth\n end", "def allow_params_authentication!; end", "def credentials; end", "def credentials; end", "def...
[ "0.66476256", "0.6605024", "0.63130134", "0.6296169", "0.61369944", "0.6121121", "0.604492", "0.604492", "0.60364497", "0.6020434", "0.6020434", "0.6020434", "0.6020434", "0.6020434", "0.60187376", "0.6017606", "0.59453934", "0.59453934", "0.5940548", "0.59326595", "0.5915228...
0.0
-1
def take_exam Special action for a student taking the exam specified end
def new @lesson = Lesson.find(params[:lesson_id]) @exam = @lesson.build_exam end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def take\n @exam = current_exam(params)\n end", "def select_exam\n end", "def take_quiz\n end", "def exam\n if @errors.nil?\n redirect_to exam_score_exam_path(@exam)\n else\n @students = []\n students ||= @exam.exam_group.batch.students.all\n @students = @exam.select_subject(@...
[ "0.75079536", "0.62564415", "0.62314713", "0.5960728", "0.5929767", "0.56816924", "0.5642119", "0.56249523", "0.559476", "0.55880076", "0.5574232", "0.5558297", "0.554935", "0.5548005", "0.55462563", "0.5512406", "0.55109406", "0.5506096", "0.55038476", "0.55013615", "0.55005...
0.0
-1
Return the filter information such as whether it was a complete filtering, whether it had an offset list position, and whether no, one or multiple collection items were returned
def filter_types size_type = case @filtered_size when 0 :empty when 1 :single else :multiple end { size_type: size_type, position_type: @list_position == 1 ? :normal : :offset, fulfillment_type: @filtered_size == requested_size ? :complete : :incomplete } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filtered?\n filtered\n end", "def filters\n end", "def filters; end", "def filters; end", "def filter_prepare(current_filter = @filter, subfilter = @subfilter)\n verified_filter = @filters.assoc(current_filter) ? current_filter : @filters.first[0]\n subfilter ||= {}\n the_filter = @...
[ "0.65048796", "0.6453783", "0.64311045", "0.64311045", "0.6366", "0.6335812", "0.6334319", "0.63068956", "0.617798", "0.609317", "0.6082248", "0.60733247", "0.60443926", "0.6043807", "0.6013737", "0.600635", "0.60052806", "0.59802544", "0.59733343", "0.5968634", "0.5968634", ...
0.0
-1
Perform the filter using the specified sorting method, list size and position constraints
def filter collection = @collection collection = collection.sort_by(&@sort_method) if @sort_method collection.reverse! if (@list_order.to_sym == ORDER[:lowest]) ^ @reverse collection = collection[((@list_position) - 1)..-1] || [] collection.first(requested_size).tap do |filtered_collection| @filtered_size = filtered_collection.size end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def execute\n perform_filtration.then(&method(:sort))\n end", "def do_params_filter_and_sort scope\n do_params_sort do_params_filter scope\n end", "def sort_it(list_, n)\n # Your code goes here\nend", "def my_quick_sort(&prc)\n\n end", "def list_filter(**opt)\n # May be overridden by the s...
[ "0.5929611", "0.5852746", "0.579373", "0.5754037", "0.57467383", "0.57252854", "0.5706659", "0.5706659", "0.5695955", "0.56903446", "0.56780756", "0.5662147", "0.5555116", "0.55523306", "0.55441606", "0.550374", "0.5487668", "0.5475421", "0.5456614", "0.5456614", "0.5456614",...
0.7280326
0
Public: Builds the response for the user message. Returns a [JSON] to be send to the Slack WebSocket
def process { "type": "message", "channel": channel, "text": message }.to_json end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def message\n response.to_json\n end", "def json_response_for_slack(reply)\n response = { text: reply, link_names: 1 }\n response[:username] = ENV[\"BOT_USERNAME\"] unless ENV[\"BOT_USERNAME\"].nil?\n response[:icon_emoji] = ENV[\"BOT_ICON\"] unless ENV[\"BOT_ICON\"].nil?\n response.to_json\nend"...
[ "0.6793324", "0.67511094", "0.67511094", "0.63914025", "0.6345444", "0.62177175", "0.62170464", "0.61497116", "0.59732187", "0.5959154", "0.5911859", "0.58825344", "0.5876188", "0.5871805", "0.5869705", "0.5850006", "0.5829332", "0.58230907", "0.5821881", "0.5817302", "0.5792...
0.65405226
3
Returns agent status. Used for HTTP API and `serf query` inspection.
def status(packages: true) # When changing signature, don't forget to change samely of Master#status too {}.tap do |s| s[:name] = serf.name s[:version] = Mamiya::VERSION s[:labels] = labels s[:queues] = task_queue.status if packages s[:packages] = self.existing_packages s[:prereleases] = self.existing_prereleases s[:releases] = self.releases s[:currents] = self.currents end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def status\n self.agent.status\n end", "def agent_status(build_id, instance_id, platform, demo, level)\n # if the database has gone, reply with a fake response in order for the sync to continue\n return agent_cached_status(build_id) unless @available\n\n trace :debug, \"Asking the status of ...
[ "0.81977177", "0.6639463", "0.6504326", "0.647305", "0.64300734", "0.63366336", "0.63135237", "0.63034785", "0.62799084", "0.6259214", "0.6256507", "0.6248925", "0.62390417", "0.62390417", "0.62390417", "0.62390417", "0.6230601", "0.6228365", "0.6212803", "0.6206023", "0.6204...
0.0
-1
Returns hash with existing packages (where valid) by app name. Packages which has json and tarball is considered as valid.
def existing_packages paths_by_app = Dir[File.join(config[:packages_dir], '*', '*.{tar.gz,json}')].group_by { |path| path.split(File::SEPARATOR)[-2] } Hash[ paths_by_app.map { |app, paths| names_by_base = paths.group_by do |path| File.basename(path).sub(/\.(?:tar\.gz|json)\z/, '') end packages = names_by_base.flat_map { |base, names| names.map do |name| ( name.end_with?(".tar.gz") && names.find { |_| _.end_with?(".json") } && base ) || nil end }.compact [app, packages.sort] } ] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_packs\n config[:pack_path] ||= Chef::Config[:pack_path]\n config[:version] ||= Chef::Config[:version]\n\n # keyed by group-name-version\n pack_map = {}\n\n config[:pack_path].each do |dir|\n\n pack_file_pattern = \"#{dir}/*.rb\"\n files = Dir.glob(p...
[ "0.61030895", "0.6010612", "0.5873294", "0.58121216", "0.5734054", "0.57102907", "0.56865054", "0.5661183", "0.5660845", "0.5613811", "0.56104535", "0.5610403", "0.5584201", "0.558008", "0.5561526", "0.55531055", "0.55184716", "0.5513525", "0.54865205", "0.54485714", "0.54370...
0.7238712
0
any 2 numbers is between 1 and look_ahead. Time complexity: O(n) Space complexity: O(m) Where n = lines.length and m = look_ahead Excludes sorting, which will be nlogn.
def find_solution_count(lines, look_ahead=3) init = Struct.new(:value, :length).new init.value = 0 init.length = 1 running_lengths = Array[init] for i in 0..lines.length - 1 do current = Struct.new(:value, :length).new current.value = lines[i] current.length = running_lengths.inject(0) { |sum, item| current.value <= item.value + look_ahead ? sum += item.length : sum } running_lengths.unshift current if running_lengths.length > look_ahead running_lengths.pop end end # running_lengths contains values for 180, 179, and 178, in that order. return running_lengths[0].length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def leaders(input)\n leader = []\n temp_lead = 0\n counter = 0\n while counter < input.size\n counter2 = counter + 1\n temp_lead = input[counter]\n while counter2 < input.size && temp_lead > input[counter2]\n counter2 += 1\n end\n leader << temp_lead if counter2 == input.size\n counter +...
[ "0.56690705", "0.55610114", "0.5414998", "0.5389207", "0.53742534", "0.5366762", "0.5344312", "0.5327276", "0.53187305", "0.52834463", "0.5246838", "0.52260107", "0.5225031", "0.52193725", "0.5217632", "0.5216174", "0.52062076", "0.52062076", "0.51737237", "0.5169937", "0.516...
0.0
-1
Finds the product of the number of 1jolt difference and 3jolt difference. Time complexity: O(n) Space complexity: O(m) Where n = lines.length and m = max_jolt_diff Excludes sorting, which will be nlogn.
def find_jolt_product(lines, max_jolt_diff=3, adapter_to_device_jolts=3) diff_counts = Array.new(max_jolt_diff, 0) for i in 0..lines.length do # Account for first element. lower = i > 0 ? lines[i - 1] : 0 # Accounts for the difference between the last adapter and device. higher = i < lines.length ? lines[i] : lines[i - 1] + adapter_to_device_jolts diff = higher - lower diff_counts[diff - 1] += 1 end return diff_counts[0] * diff_counts[2] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def joltageDiff(input)\n # add my input device with rating +3\n input.append(input.max + 3)\n arr = input\n .sort\n .reverse\n \n diffs = arr\n .map.with_index{ |n, i|\n if i < arr.size - 1\n n - arr[i+1]\n end\n }\n diffs.pop # remove last element\n # puts diffs.sort\n counts ...
[ "0.6578871", "0.57768506", "0.5693115", "0.55782175", "0.5564421", "0.55354786", "0.5522051", "0.5493682", "0.547501", "0.5464374", "0.5435503", "0.5421191", "0.5411506", "0.5384883", "0.5371149", "0.5345835", "0.52724916", "0.5248962", "0.52290416", "0.5225417", "0.5197005",...
0.72973806
0
GET /prices GET /prices.json
def index @prices = Price.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prices (currency='TWD')\n get '/prices/' + currency\n end", "def all_prices\n request :public, :get, :price\n end", "def index\n @prices = Price.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @prices }\n end\n end", "...
[ "0.8056198", "0.77728736", "0.76455015", "0.7251481", "0.7028781", "0.6974626", "0.69579375", "0.69579375", "0.694588", "0.6890499", "0.68686104", "0.68132305", "0.6794858", "0.67823946", "0.6771327", "0.66729033", "0.66376877", "0.66256416", "0.65837413", "0.6557221", "0.646...
0.67018807
16
GET /prices/1 GET /prices/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prices (currency='TWD')\n get '/prices/' + currency\n end", "def index\n @prices = Price.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @prices }\n end\n end", "def all_prices\n request :public, :get, :price\n end", "...
[ "0.76203173", "0.7435321", "0.7302241", "0.7138793", "0.7138793", "0.6926717", "0.6796125", "0.6755419", "0.6725511", "0.6697241", "0.6696893", "0.6681606", "0.667593", "0.6601231", "0.6594353", "0.65883195", "0.6538268", "0.6517805", "0.65125877", "0.6507446", "0.6487578", ...
0.0
-1
POST /prices POST /prices.json
def create @price = Price.new(price_params) @price.product = @product respond_to do |format| if @price.save format.html { redirect_to @price.product, notice: 'Precio creado exitosamente.' } else format.html { render :new } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @price = @product.prices.new(price_params)\n\n respond_to do |format|\n if @price.save\n format.html { redirect_to product_path(@product), notice: 'Price was successfully created.' }\n format.json { render :show, status: :created, location: @price }\n else\n format...
[ "0.6758727", "0.6671163", "0.661703", "0.66013044", "0.65310246", "0.6393697", "0.6382712", "0.6361112", "0.6352605", "0.62328905", "0.62057966", "0.62012786", "0.6175537", "0.6149828", "0.609677", "0.6066074", "0.6056079", "0.6053568", "0.60419023", "0.6027343", "0.602302", ...
0.54206103
80
PATCH/PUT /prices/1 PATCH/PUT /prices/1.json
def update respond_to do |format| if @price.update(price_params) format.html { redirect_to @price.product, notice: 'Precio actualizado exitosamente.' } else format.html { render :edit } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @price = Price.find(params[:id])\n\n respond_to do |format|\n if @price.update_attributes(params[:price])\n format.html { redirect_to @price, notice: 'Price was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit...
[ "0.68216497", "0.6729135", "0.6702204", "0.6633407", "0.6633407", "0.6594415", "0.6531072", "0.65035135", "0.6441623", "0.6434054", "0.64236027", "0.64152265", "0.63665336", "0.63633204", "0.6347455", "0.6338369", "0.63180536", "0.6293565", "0.6284249", "0.6263684", "0.626247...
0.5871307
56
DELETE /prices/1 DELETE /prices/1.json
def destroy @price.destroy respond_to do |format| format.html { redirect_to prices_url, notice: 'Precio eliminado exitosamente.' } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @price = Price.find(params[:id])\n @price.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_prices_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @price = Price.find(params[:id])\n @price.destroy\n\n respond_to do |format|\n ...
[ "0.75029635", "0.74454015", "0.72175723", "0.7199558", "0.7190693", "0.7158472", "0.714426", "0.714426", "0.714426", "0.7101081", "0.70824283", "0.7005585", "0.70041466", "0.69793946", "0.6975782", "0.69618994", "0.6952561", "0.69241697", "0.6904918", "0.6858489", "0.68330365...
0.68321264
21
GET /clams GET /clams.json
def index @clams = Clam.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @cmms = Cmm.all\n render json: @cmms\n end", "def show\n @clasp = Clasp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clasp }\n end\n end", "def set_clam\n @clam = Clam.find(params[:id])\n end", "def ind...
[ "0.66088176", "0.6399505", "0.6377987", "0.6269678", "0.6217792", "0.5806358", "0.57943636", "0.56989384", "0.5666184", "0.5633981", "0.56253695", "0.5620389", "0.5561689", "0.556025", "0.55575716", "0.55563056", "0.5556036", "0.55519056", "0.5505128", "0.5505099", "0.5499382...
0.7269852
0
GET /clams/1 GET /clams/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @clams = Clam.all\n end", "def show\n @clasp = Clasp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clasp }\n end\n end", "def index\n @cmms = Cmm.all\n render json: @cmms\n end", "def set_clam\n @clam =...
[ "0.69163835", "0.67792", "0.6587069", "0.6472706", "0.639227", "0.63423115", "0.60645854", "0.60617274", "0.6025661", "0.60224366", "0.60079676", "0.59976274", "0.59830713", "0.5953031", "0.59174967", "0.58954585", "0.58846146", "0.5875011", "0.5857605", "0.58483875", "0.5848...
0.0
-1
POST /clams POST /clams.json
def create @clam = Clam.new(clam_params) respond_to do |format| if @clam.save format.html { flash[:success] = 'メールを送信しました.' redirect_to "/missions/inbox" } format.json { render :show, status: :created, location: @clam } else format.html { render :new } format.json { render json: @clam.errors, status: :unprocessable_entity } end end create_reuse_relationship(params[:clam][:source_id], Clam.last.id) if params[:clam][:source_id].present? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @clasp = Clasp.new(params[:clasp])\n\n respond_to do |format|\n if @clasp.save\n format.html { redirect_to @clasp, notice: 'Clasp was successfully created.' }\n format.json { render json: @clasp, status: :created, location: @clasp }\n else\n format.html { render ac...
[ "0.650671", "0.62606496", "0.6113776", "0.6104568", "0.6049967", "0.6016689", "0.58619547", "0.5825998", "0.5785408", "0.5759794", "0.5681146", "0.5657326", "0.5655585", "0.5631397", "0.56292397", "0.5607138", "0.56068885", "0.55550784", "0.551213", "0.54379183", "0.5418737",...
0.5904559
6
PATCH/PUT /clams/1 PATCH/PUT /clams/1.json
def update respond_to do |format| if @clam.update(clam_params) format.html { redirect_to @clam, notice: 'Clam was successfully updated.' } format.json { render :show, status: :ok, location: @clam } else format.html { render :edit } format.json { render json: @clam.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @clasp = Clasp.find(params[:id])\n\n respond_to do |format|\n if @clasp.update_attributes(params[:clasp])\n format.html { redirect_to @clasp, notice: 'Clasp was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n ...
[ "0.6577935", "0.6394607", "0.6378945", "0.62558395", "0.6079275", "0.60260624", "0.6024887", "0.5983209", "0.59650296", "0.5963206", "0.5928481", "0.5877679", "0.58717036", "0.5852493", "0.58506304", "0.583845", "0.58305216", "0.58244705", "0.58161896", "0.58054596", "0.57901...
0.65881836
0
DELETE /clams/1 DELETE /clams/1.json
def destroy @clam.destroy respond_to do |format| format.html { redirect_to clams_url, notice: 'Clam was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @clasp = Clasp.find(params[:id])\n @clasp.destroy\n\n respond_to do |format|\n format.html { redirect_to clasps_url }\n format.json { head :ok }\n end\n end", "def destroy\n @cla.destroy\n respond_to do |format|\n format.html { redirect_to clas_path, notice: 'Test ...
[ "0.71294117", "0.69814223", "0.69768125", "0.6953801", "0.6793311", "0.6791078", "0.6608306", "0.6607613", "0.6595707", "0.65881926", "0.6584612", "0.65655726", "0.65654504", "0.6558138", "0.65559614", "0.6550073", "0.6549789", "0.65407455", "0.65392315", "0.6537631", "0.6531...
0.7147503
0
Return clam's html template for displaying in inbox GET /clams/1/snippet
def show_snippet @clam = Clam.find(params[:id]) @clam.content_type =~ /^Resource::(.*)$/ @template = $1 ? $1.downcase : "octet_stream" render :action => "clam_snippet", :layout => false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_snippet(id)\n get(\"/snippets/#{id}\")\n end", "def show\n @snippet = @snippet.decorate\n\n respond_to do |format|\n format.html # show.html.slim\n format.json { render json: @snippet }\n end\n end", "def show\n @snippet = Snippet.find(params[:id])\n respond_with @sni...
[ "0.63273686", "0.6145729", "0.61362493", "0.60712737", "0.60287136", "0.60257083", "0.59947103", "0.59845906", "0.5974173", "0.59676003", "0.59451216", "0.59451216", "0.59082323", "0.58979404", "0.5860968", "0.5853316", "0.579265", "0.57794845", "0.57695913", "0.57386047", "0...
0.7561769
0
Use callbacks to share common setup or constraints between actions.
def set_clam @clam = Clam.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def clam_params params.require(:clam).permit(:uid, :date, :summary, {:options => ['description', 'originator', 'recipients']}, :content_type, :fixed, :mission_id, :mission_id, :description, :originator, :recipients) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69780594", "0.678054", "0.6742781", "0.67387927", "0.67346025", "0.6590683", "0.6501642", "0.6495788", "0.6479752", "0.64763314", "0.645457", "0.6437739", "0.6377168", "0.6372484", "0.6363871", "0.63179374", "0.62981373", "0.6297456", "0.62916917", "0.6290227", "0.628954",...
0.0
-1
splitting string to parts with same symbols. "11222444" > [11, 222, 444]
def convert_to_ar(str) bgn = 0 cur = str[bgn] ar = [] unless str.empty? str.length.times do |ind| next unless str[ind] != cur ar.append(str[bgn, ind - bgn]) bgn = ind cur = str[ind] end ar.append(str[bgn, str.length]) end ar end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def even_splitters(string)\n result = [] \n\n string.chars.uniq.each do |c|\n result << c if element_same_length?(string.split(c))\n end\n \n p result\nend", "def my_split(string, divider)\n array = []\n current_element = ''\n\n formatted_string = string.clone\n formatted_string.strip!\n\n formatt...
[ "0.67666036", "0.6698184", "0.65698475", "0.6446105", "0.64324844", "0.64181453", "0.6324216", "0.6248498", "0.6245715", "0.62070686", "0.61783564", "0.6168913", "0.6167241", "0.61448324", "0.6139731", "0.6124734", "0.611739", "0.61055076", "0.6092704", "0.6075379", "0.607409...
0.0
-1
creating new string from ar. [11, 222, 444] > "213234"
def ar_to_new(ar) new_str = '' ar.each do |sub| new_str += sub.length.to_s + sub[0] end new_str end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_phone_number(arr)\n string = \"(\" + arr[0..2].join + \") \" + arr[3..5].join + \"-\" + arr[6..9].join\nend", "def to_phone_number(arr)\n # your code goes here\n str = arr.join\n \"(#{str[0,3]}) #{str[3,3].to_s}-#{str[6,4]}\"\nend", "def to_phone_number(arr)\r\n # your code goes here\r\n arr = arr...
[ "0.640784", "0.6380317", "0.6362831", "0.6255781", "0.62472", "0.622919", "0.61773074", "0.6168247", "0.60726005", "0.5996286", "0.5971674", "0.5969005", "0.5941104", "0.5937995", "0.5903294", "0.5878108", "0.5833841", "0.5807383", "0.580279", "0.57735854", "0.5707413", "0....
0.7302078
0
output new string in terminal
def put next_str puts(@str) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def output(text)\n puts text\n end", "def output text\n puts text\n end", "def output(command)\n @buffer << command.gsub(/'/, '\"')\n end", "def print(text)\n @output += %(#{text}\\n)\n puts text\n end", "def shout(str)\n puts str\n end", "def stamp\n @output.write(\"#{E...
[ "0.71370983", "0.70970917", "0.70906955", "0.7024082", "0.7018702", "0.6928954", "0.6928133", "0.6850255", "0.6788053", "0.6788053", "0.67746323", "0.67746323", "0.67254126", "0.6709854", "0.67095923", "0.67093784", "0.66862214", "0.6674012", "0.6674012", "0.6672765", "0.6671...
0.610767
85
initiall create instance object, default if no arguments will be target for html
def initialize(mrg = nil) @dbg={ :hot =>nil, :stack =>nil, :parse =>nil, :constanta=>nil } #regex for w2tags @rg_tag = [ /^[ \t]*(%)([!]?[\w\-&\/:#.\[\]]+\{.*\}[=]*)!([^\n]*)\n/, /^[ \t]*(%)([!]?[\w\-&\/:#.\[\]=]+)!([^\n]*)([\n])/] #regex for function tags @rg_hot = [ /(%)([!]?[ \t\$\w\-&\/:#.\[\]%=]+\{.*\}[=]*)~([^\n]*)\n/, /(%)([!]?[ \t\$\w\-&\/:#.\[\]%=]+)~([^\n]*)\n/ ] @rgx = nil #current regular expression @mrg = mrg #another hot to include @ext = 'erb' #target extension @hot = 'hot' #source of file hot @src_path= '' #path for source file @silent = false #for test @ron = 0 #strip current source line if size it empty or not @spc = '' #current begining space of current source line @ind = ' ' #indentation size @row = 'row' #current source line @key = 'key' #key extracted from regex function @mem_hot= nil #@tg_nex will be use (for "%") if this var == nil @mem_tag= {'^'=>"%div$*!"} #get memorize of w2tag @mem_var= {'$me'=>"wharsojo"} @mem_var['$basepath'] = File.basename(File.expand_path('.')) @tg_hot = {} #{'div'=>[proc{|this|"%div$*!"},nil]} #collection of tag_hot after reading from source hot @tg_nex = {} #tag next activate on shortcut tag "%" @tg_end = [] #momorize tag end from regex function @doc_src= [] @doc_out= [] @tagr = proc do |this| @key.strip! tags_created = "<#{@key}" tags_created << " #{@mem_var["*all*"].strip}" if @mem_var["*all*"]!='' #tags_created << " #{@att}" if @att!='' if @txt=='/' tags_created << "/>\n" else tags_created << '>' @ln_end = " " if @txt=='' @tg_end.push "#{@spc}</#{@key}>#{@ln_end}" p "Stack: #{@tg_end}" if @dbg[:stack] else if @txt.gsub!(/\<$/,'') @tg_end.push "#{@spc}</#{@key}>#{@ln_end}" else @ln_end = "</#{@key}>#{@ln_end}" end if @mem_var["*code*"] && @mem_var["*code*"]!='' tags_created << @mem_var["*code*"].gsub('$*',@txt) else tags_created << @txt.gsub(/^ +/,'') #remove gsub if don't want auto trim left end end end tags_created end @skiper= [] public_methods.each do |f| send(f) if /_initialize$/ =~ (meth= f.to_s) @skiper << [$1,'_skip'].join.to_sym if /(.*)_skip$/ =~ meth end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(options) #:not-new:\n @options = options\n load_html_template\n end", "def initialize(options) #:not-new:\n @options = options\n load_html_template\n @main_page_path = nil\n end", "def initialize(object_name, method_name, template, options = {}, html_options = {}) #:nodoc:\n ...
[ "0.6946722", "0.69193226", "0.65876615", "0.6448651", "0.63538873", "0.6339903", "0.6333057", "0.62693363", "0.62693363", "0.6265896", "0.623287", "0.618592", "0.61749476", "0.61740476", "0.6156225", "0.61409605", "0.6120492", "0.61068356", "0.61060405", "0.6078718", "0.60309...
0.0
-1
it use to clean all the definition and reloading the hot file
def parse_init @tg_end = [] #momorize tag end from regex function @doc_src = [] @doc_out = [] @tg_hot = {} merge_tags @mrg ? @mrg : @ext next_tag_init end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cleanup\n sh 'rm -rf _site'\n compass('clean')\nend", "def cleanup()\n @definition.temporary_files.each do |file|\n if File.exists?(file) && File.writable?(file)\n File.delete(file)\n end\n end\n if @environment.verbose\n puts \"========== END #{@definition.name} ============...
[ "0.63742185", "0.635047", "0.62926066", "0.62150353", "0.6200282", "0.6128264", "0.612784", "0.612784", "0.612507", "0.6117002", "0.6117002", "0.6097569", "0.609737", "0.60914105", "0.6070619", "0.6070619", "0.6070619", "0.6070619", "0.6069479", "0.605689", "0.605689", "0.6...
0.0
-1
parsing from fullpath source to the fullpath target/result with the option of auto add 'initialize' and 'finalize' for source file in w2tags only fill with LF it will not translate, since behaviour for "\n\n\n".split("\n") will result in empty array if hot available it will add w2tags in:
def parsing(src,tgt,init_start=true) puts ">>#{src}" puts ">>#{tgt}" parse_init @src_path= File.dirname(src) @doc_src = read_w2tags(IO.read(src)).split("\n") @doc_src<< "%finallize" if @tg_hot['finallize' ] while (@row = @doc_src.shift) do #;p "row:#{@row}" if init_start && !(/!hot!/ =~ @row) @doc_src,@row = [[@row]+@doc_src,"%initialize"] if @tg_hot['initialize'] p "HEAD:#{init_start}" init_start = false end parse_row end if @dbg[:constanta] p "const_ " @mem_var.keys.sort.each {|k|p "#{k.ljust 10} : #{@mem_var[k]}"} end if @dbg[:hot] @tg_hot.keys.sort.each_with_index do |v,i| puts "hot keys: #{i}. #{v}" end end open(tgt,'w') do |f| @doc_out.each do |row| f << row end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_init\n @tg_end = [] #momorize tag end from regex function\n @doc_src = []\n @doc_out = []\n @tg_hot = {} \n merge_tags @mrg ? @mrg : @ext\n next_tag_init\n end", "def parse_row row=nil\n @row = row if row\n @row<<\"\\n\" #;p \"row:#{@row}\"...
[ "0.635211", "0.60455686", "0.58258444", "0.58093613", "0.58009964", "0.57870597", "0.5715578", "0.5715578", "0.56225723", "0.56049377", "0.5510034", "0.54564244", "0.54564244", "0.54564244", "0.5449863", "0.54198945", "0.53981036", "0.5312568", "0.5286736", "0.52693933", "0.5...
0.6008144
2
to test parsing on source line and return will be the result, everytime it execude, it clean up and reloading the HOT files.
def parse_line row,init=true parse_init if init dbg[:parse]= false @doc_src = read_w2tags(row).split("\n") << ",/" #@doc_src = row.delete("\r").split("\n") << ",/" while (@row= @doc_src.shift) do #;p "row:#{@row}" parse_row end @doc_out end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def p...
[ "0.63335407", "0.63335407", "0.63335407", "0.63335407", "0.63335407", "0.63335407", "0.63335407", "0.63335407", "0.63335407", "0.63335407", "0.63335407", "0.6323875", "0.63010246", "0.6299225", "0.6299225", "0.62361425", "0.6066903", "0.60522836", "0.6050214", "0.5981609", "0...
0.0
-1
the actual parsing on row, but it use for parsing the files not to test the source line, since some of the row have a command that has effect on source, result and the row will be empty, please use parse_line if you want to test interactively on IRB.
def parse_row row=nil @row = row if row @row<<"\n" #;p "row:#{@row}" p "_____> #{@row}" if @dbg[:parse] && @plt == 99 && @rmk == 99 parse_spc @ln_end = "" #imediate ends tag @row.gsub!(/\\\\/,'') #esc char \\ @row.gsub!('\}','') #esc char \} @row.gsub!('\;','') #esc char \; while (parse_all) do; end @row.gsub!('','\\') @row.gsub!('','}') @row.gsub!('',';') if @ln_end!="" @row.gsub!(/([\n\t ]*$)/,'') @row << "#{@ln_end.strip}\n" end if @row.strip!="" # responsible for generating good output p "#####> #{@row}" if @dbg[:parse] @doc_out << (@row.rstrip + "\n") #@doc_out << @row.rstrip # not working for #@doc_out << "\n" # shortcut if elsif else end @row end #parse one w2tags, result will be name of the target file created def parse_file(src,init_start=true,chk_date=false) tgt,@ext = [src[/(.+\.)w2(\w+)$/,1]<<$2,$2] return nil if !File.exist?(src) #p "src: #{src} not found..." if chk_date && File.exist?(tgt) return nil if File.mtime(src) <= File.mtime(tgt) end puts "\nParsing W2Tags File:#{src}" parsing(src,tgt,init_start) tgt end #parse multiple w2tags files, result will be array of target file created def parse_files(srcs,init_start=true) srcs.collect do |src| src.gsub!(/\n/,'') parse_file(src,init_start) end.compact end def end_tags(arr) @tg_end = @tg_end + arr end #call from proc hot before it render hots line #see in source code "w2tags.rb::read_filehot" #default behaviour for tag_nex will not execute #since @mem_hot will assigned w/o nil #assigned nil using "%!" in w2tags def chg_mem_hot(nxt) @mem_hot = nxt @mem_tag["^"] = nxt if nxt end #pop up end tags from the stack #result will be string contains end tags from stack #who's space inside each end tags > current space def multi_end(ttls) rpls = '' ttl = @tg_end.size-1 ttl = ttls-1 if ttls ttl.downto(0) do |i| sz = @tg_end[i][/^ +/].to_s.size if ttls || @spc.size <= sz send = @tg_end.pop.to_s if send.strip[0,5]=="!run!" scrpt = send.gsub("\n","\n#{@spc}").split("\n") @doc_src = scrpt[1,99]+@doc_src else spc = send[/(^[ \t]*)/,1].to_s rpls << send.gsub(/\n/,"\n#{spc}") + "\n" end end end p "End..: #{rpls.strip}" if @dbg[:parse] && rpls!= '' rpls end private # try to shift empty line create document and add current # row to source. but it means re parsing current row. def swap_last_empt_src_with_end_tg(end_tg) while @doc_out[-1] && @doc_out[-1].strip == '' @doc_out.pop end @doc_out<< "\n" if @doc_out[-1] && @doc_out[-1][-1,1] != "\n" # responsible for generating good output end_tg.shift if end_tg[0].strip=='' @doc_src = end_tg + @doc_src #; p @doc_src; p @doc_out #p "Swp..: #{@doc_src[-1]}" if @dbg[:parse] end #merging file hot based on the target extension, and target #extension it self based on source extension, example: #suppose you have source of w2tags 'index.html.w2erb' #it just like autoloading: # !hot!erb #it will search HOT files in current folder, if it not found #it will search in gem/hot and merging the HOT def merge_tags(ext) hot1 = "#{@src_path}/#{ext}.#{@hot}" hot2 = "#{W2Tags::Dir}/../hot/#{ext}.#{@hot}" filehot = hot1 if File.exist?(hot1) filehot = hot2 if File.exist?(hot2) if filehot puts '=>'+File.expand_path(filehot) if !@silent @tg_hot.merge!(W2Tags.read_filehot(filehot)) end @tg_hot end #define variable ( &var! or @var! )tobe use by parser in hot for #the next line parsing, example on w2tags: # &myvar=hello\n # ^{.myclass &myvar!} # #it will translate on the fly to: # ^{.myclass hello} # #for @var! is uniq value split by ";", example on w2tags: # @myvar=hello;world\n # @myvar=world;tags\n # ^{.myclass @myvar!} # #it will translate on the fly to: # ^{.myclass hello;world;tags} def parse_set_var if @row.gsub!( /^[ \t]*(&[\w]+)=([^\n]+)([\n])/,'') @mem_var[$1+"!"] = $2.strip elsif @row.gsub!(/^[ \t]*(@[\w]+)=([^\n]+)([\n])/,'') k,v = [$1+"!",$2.strip] #;p v #v << ';'+@mem_var[k].to_s if v[0,1]!=';' && @mem_var[k] v = (@mem_var[k].to_s + ';' + v) if v[0,1]!=';' && @mem_var[k] @mem_var[k] = v.split(';').uniq.select{|x|x!=''}.join(';') p "uniqV> #{v}" if @dbg[:parse] #&& @plt == 99 && @rmk == 99 end end #when parsing and found tag # !hot!filehot1;filehotN #it will search HOT files in current folder, if it not found it will search #in gem/hot and merging the HOT, this command can have multiple #file HOT separate with ";" def merge_hot if(/!hot! *([\w;.\/]+)([\n])/ =~ @row;@rgx = $~) hots= @rgx[1].split(';').collect {|x|x+'.'+@hot} rpl = [''] hots.each do |hot| fls = File.exist?(hot) ? hot : File.exist?(@src_path+'/'+hot) ? @src_path+'/'+hot : File.exist?(W2Tags::Dir+'/../hot/'+hot) ? W2Tags::Dir+'/../hot/'+hot : '' if fls=='' rpl << "<!--"+hot+", Not Found-->\n" else puts '=>'+File.expand_path(fls) if !@silent @tg_hot.merge!(W2Tags.read_filehot(fls)) end end @row.gsub!(@rgx.to_s,rpl.join) end end #when parsing and found tag # !inc!fileinc #it will include / replace current row from file include, and after #parser will try to get current row after merging to be evaluate def merge_w2x if(/!inc! *([\/\w\d._]+)([\n])/ =~ @row;@rgx = $~) mac = @src_path+'/'+$1 src = $~.to_s #;p mac if File.exist?(mac) pop = $~.captures.pop #new = IO.read(mac).delete("\r").gsub("\n","\n"+@spc) new = read_w2tags(IO.read(mac)) @doc_src= @row.gsub(src,new).split("\n")+@doc_src @row= @doc_src.shift+"\n" parse_spc else @row.gsub!(src,"<!--"+mac+", Not Found-->\n") nil end end end #get space (tab and spaces) on the left of the code and save it to instance #it will be use if row replace with more than one row and replacement row #must continue with current column (indent). def parse_spc @spc = @row[/(^[ \t]+)/,1].to_s #sometime result is nil @ron = @row.strip.size end #do the translation from the params inside function like: # %a par1;par2;par3 #it do following job: # * replace constanta (&var!) inside params of the function # * replace constanta (&var!) inside new line of source code # (inside instance var @new) # * replace var $0 - $9 inside var @new from params if function have # 3 params so 3 var $ will be replace from the params and if var @new # have var # more than what function params suply, it will replace with # an empty string # * if in var @new define only 1 var $ and function params got more than # 1, it will multiply the @new line with total number of lparams # to get the illustrate I'll show you with an example: # inside hot file : # >>td # <td>$0</td> # -------------------- # function call: @td(col1;col2) # will result in # -------------------- # <td>col1</td> # <td>col2</td> # * some of the replacement behaviour for var $ are : # 1. optional meaning that var $ inside [ xxx $ xxxx ] sequare bracket are # optional if not suply from params it will an emppty replacement # 2. default value meaning that var $ inside [ xxx $ left sequare bracket # are a default if not suply from params but if it suply from params it # will empty the default and relace var $ from the params # 3. execute String.method if var $ in the left got ":", example # inside hot file: # >>td # <td>:capitalize$0</td> # -------------------- # function call: @td(col1;col2) # will result in # -------------------- # <td>Col1</td> # <td>Col2</td> def get_dollar(prms,ends=nil) #prms='@0;@1;@2' from hot @mem_var.each do |k,v| #;p "#{k}, #{v}" prms.gsub!(k,v) if k[0,1]=='*' and Regexp.new("~([^~]+)~#{k}".gsub('*','\\*')) =~ @new @new.gsub!($~.to_s,(v!='' ? v : $1)) else @new.gsub!(k,v) end end prms.gsub!(/\\\\/,'') #esc char \\ prms.gsub!('\}','') #esc char \} prms.gsub!('\;','') #esc char \; prms = prms.split(';') #W2Tags::splitter(prms) new_prms = @new.scan(/\$[0-9]/).uniq new_alls = @new.scan(/\$\*/) #;p 'rpl:',new_alls,new_prms,prms @new.gsub!($1,"<%= \"#{$2}\" %>") if /(==(\$[0-9]))/ =~ @new @new.gsub!($1,"<%= #{$2} %>") if /(=(\$[0-9]))/ =~ @new if /^@[0-9]$/ =~ prms[0] rpl = prms.shift.gsub('@','$') repeat = @new repeat.gsub!('$0',prms.shift) #repeat.gsub!('$*',rpl) @new = '' prms.each_with_index do |x,i| #;p "$0 #{x} => #{repeat}" @new += repeat.gsub(rpl,x) if i+1<prms.size @new += "\n"+@spc+ends.join("\n") if ends @new += "\n"+@spc end end p "Rept1: #{@new}" if @dbg[:parse] elsif new_alls==[] && new_prms.size==1 && prms.size>1 tmp = "" rpt = @rgx.to_s.gsub(@rgx[3]+"\n","") #multi key params(class,attribute,etc) classs = rpt[/([.:#].*\{.*?\}.*?) /,1] classs = rpt[/(\{.*?\}.*?) /,1] if !classs classs = rpt[/([.:#].*?) /,1] if !classs classs.sub!(/=$/,'') if classs clsmlt = classs.to_s.split(';') clscnt = clsmlt.length clsmlt+= clscnt==1 ? clsmlt*prms.length : ['']*prms.length prms.each_with_index do |x,i| y = x.strip if /^~[-%]/ =~ y tmp<< y[1,y.length-1] tmp<< "\n#{@spc}" if i+1<prms.size else line = rpt+x #tmp<< @new.gsub(new_prms[0],x) #implement multi class params ^.d;.g canggh;bow line.gsub!(classs,clsmlt[i]) if classs tmp<< line tmp<< "\n#{@spc}" if i+1<prms.size end end p "Rept2: #{tmp}" if @dbg[:parse] @new = tmp else i = new_prms.size - 1 new_prms.sort.reverse.each do |x| while Regexp.new('\\'+x+':(\d+)') =~ "\n#{@new}" do idx = $1 src = $~.to_s rpl = idx ? prms[i].split(':')[idx.to_i].to_s.strip : '' p "Splt : #{prms[i]} => #{idx}" if @dbg[:parse] @new.gsub!(src,rpl) end rgx = '\\'+x+'\.([^~ ]+)~' #/\$0\.([^~ ]~)/ => fix: next-tag (~^) eva_v = Regexp.new(rgx) #Ex:$1.upcase~ while eva_v=~ "\n#{@new}" do src = "#{x}.#{$1}~" #p "\n#{@new} => #{src}" evl = "\"#{prms[i]}\".#{$1}" #p "====> #{evl} <==" p "Eval : #{evl}" if @dbg[:parse] rpl = prms[i] ? eval(evl).to_s : "" @new.gsub!(src,rpl) end opt_v = Regexp.new('~([^$]*)\\' +x+'([^~]*)~') def_v = Regexp.new('~([^~]+)~\\'+x) if opt_v =~ @new #;p $1 rpl = '' rpl = "#{$1.to_s}#{prms[i]}#{$2.to_s}" if prms[i] && prms[i].strip!="" @new.gsub!(opt_v,rpl) #p "options: #{rpl} >> #{@new}" elsif def_v =~ @new #;p $1 src = $~.to_s rpl = (prms[i] && prms[i].strip!="" ? prms[i] : $1) @new.gsub!(src,rpl) #p "default: #{@new}" end #p "rest: #{x} => #{prms[i].to_s}" @new.gsub!(x,prms[i].to_s) i = i -1 end @new.gsub!(/\$\*/,prms[new_prms.size,99].to_a.join(';') ) @new.gsub!(/\n\t+$/,'') #remove line if only tabs end end #pop up end tags from the stack def multi_end2(ttls) rpls = '' ttl = @tg_end.size-1 ttl = ttls-1 if ttls ttl.downto(0) do |i| sz = @tg_end[i][/^ +/].to_s.size if ttls || @spc.size <= sz send = @tg_end.pop if send.strip[0,5]=="!run!" scrpt = send.gsub("\n","\n#{@spc}").split("\n") @doc_src = scrpt[1,99]+@doc_src else spc = send[/(^[ \t]*)/,1].to_s rpls << (send.gsub("\n","\n#{spc}") + "\n") end end end p "End2 : #{rpls}" if @dbg[:parse] && rpls!= '' rpls end #command execution "-key", internally parsed to "%_key~", so both command #are the same except that command "-key" need to translate to "%_key~" and #it goes to Hot files key definition to lookup to. some of these definition # built in (for erb: %_if , %_elsif , %_else , %_end , ... etc) # -if => %_if # -li => %_li def shortcut_exec(regex) if(regex =~ @row;@rgx = $~) srcs = @rgx.to_s rplc = "#{@rgx[1]}%!_#{@rgx[2]}~ #{@rgx[3]}\n" @row.gsub!(srcs,rplc) p "reExe_ #{@row}" if @dbg[:parse] end end #command execution "=", internally parsed to "%=~", so both command #are the same except that command "=" need to translate to "%=~" and #it goes to Hot files key definition to lookup to. you can redefine it. def shortcut_equal(regex) if(regex =~ @row;@rgx = $~) srcs = @rgx.to_s rplc = "#{@rgx[1]}%!=~#{@rgx[3]}\n" @row.gsub!(srcs,rplc) p "reEqu_ #{rplc}" if @dbg[:parse] end end #this command is the selector from command # %..key.. params1;paramsN \n #ex: # %div<space>params\n or %div<\n>. #if key div fine in hot, it will translate to HOT tags, but if not #it become w2tags def get_hot_simple(regex) if regex =~ @row ;@rgx = $~ chk1= @rgx[2][-1,1] + @rgx[3][0,2].to_s chk2= @rgx[2][/"\}!/] chk3= @rgx[2][/"\}~/] # already become w2tags, ignore!!! if (/[=\}][!~][ ]?/ !~ chk1 && chk2 == nil && chk3 == nil) keys = @rgx[2].strip opts = @rgx[3] #p chk1 # FIX for: # %form#dodol{action="<%= #{aaa} %>"} <%= #{bbb} %> # <form id="dodol" action="<%= #{aaa} %>"><%= #{bbb}%></form> # when wrong splitting, fix the splitting... # assume last attribute don't have spaceses!!! ==>{opt="blah"}<== fixd = keys.split('"} ') if fixd.length>1 keys = fixd[0]+'"}' opts = fixd[1]+opts end srcs = @rgx.captures.join opts = $1 << opts if keys.gsub!(/(\/)$/,'') hots = keys.gsub(/\{.*\}$/,'').gsub(/[:#.][\w\-#.=]*$/,'') rplc = @tg_hot[hots]!=nil ? "%!#{keys}~ #{opts}" : "%!#{keys}! #{opts}" @row.gsub!(srcs,rplc) p "reHot> #{@row} << -H-O-T-" if @dbg[:parse] end end end #translation for tags with shortcut of name, id, or class and put in constants # ex: %div:name#id.class{attribute}= #will result in some of this var: # @mem_var['$$' ] => :name#id.class{attribute}== # @mem_var['$:' ] => :name # @mem_var['$#' ] => #id # @mem_var['$.' ] => .class # @mem_var['$@' ] => {attribute} # @mem_var['*:' ] => name # @mem_var['*#' ] => id # @mem_var['*.' ] => class # @mem_var['*@' ] => attribute # @mem_var['*all*' ] => name="name" id="id" class="class" # @mem_var['*name*' ] => name="name" # @mem_var['*id*' ] => id="id" # @mem_var['*class*'] => class="class" # this var will be use in parsing w2tags/hot command def nameidclass_var() #@key = keys = @rgx[2].strip.gsub(/(\{(.*)\})/,'') #greedy :) @key = keys = @key.strip.gsub(/(\{(.*)\})(=*)/,'') #greedy :) @att = $2.to_s.strip lkey = $3.to_s.strip @mem_var['$$' ]= '' @mem_var['$&' ]= '' @mem_var['$:' ]= '' @mem_var['$#' ]= '' @mem_var['$.' ]= '' @mem_var['$@' ]= $1.to_s @mem_var['$=' ]= '' @mem_var['*&' ]= '' @mem_var['*:' ]= '' @mem_var['*#' ]= '' @mem_var['*.' ]= '' @mem_var['*@' ]= @att=='' ? '' : @att+' ' @mem_var['*all*' ]= '' @mem_var['*name*' ]= '' @mem_var['*id*' ]= '' @mem_var['*class*']= '' @mem_var['*code*' ]= '' #p keys if @key.gsub!(/([:#.&=])([\/\t\w\-#.\[\]&= ]*$)/,'') keys = $1+$2 @mem_var['$$'] = keys.clone if keys.gsub!(/^:([\w\-.\[\]]*)/,'') if $1!='' @mem_var['$:' ] = ":#{$1}" @mem_var['*:' ] = $1 @mem_var['*name*' ] = "name=\"#{$1}\" " @mem_var['*all*' ]<< "name=\"#{$1}\" " end end if keys.gsub!(/^#([\w\-]*)/,'') if $1!='' @mem_var['$#' ] = "##{$1}" @mem_var['*#' ] = $1 @mem_var['*id*' ] = "id=\"#{$1}\" " @mem_var['*all*' ]<< "id=\"#{$1}\" " end end if keys.gsub!(/^\.([\w\-\.]*)/,'') if $1!='' cl = $1 cx = cl.split('.').collect {|x|x.strip}.join(' ') @mem_var['$.' ] = ".#{cl}" @mem_var['*.' ] = cx @mem_var['*class*'] = "class=\"#{cx}\" " @mem_var['*all*' ]<< "class=\"#{cx}\" " end end if keys.gsub!(/^&([\/\w\-.]*)/,'') if $1!='' @mem_var['$&' ] = "&#{$1}" @mem_var['*&' ] = $1 end end @key << keys end @mem_var['*all*'] << @mem_var['*@'] @mem_var['*att*'] = @mem_var['*@'] if @key[0,1]!='=' @key << lkey if @key.gsub!(/==+$/,'') @mem_var['*code*'] = '<%= "$*" %>' @mem_var['$@']<< "==" @mem_var['$='] = "==" elsif @key.gsub!(/=$/,'') @mem_var['*code*'] = "<%= $* %>" @mem_var['$@']<< "=" @mem_var['$='] = "=" end end end #these not really visible for end user, since user usualy see the command as #a HAML like command and translate to this HOT files. the translation usually #came from method in: # shortcut_exec # get_hot_simple #format for this command is # %...key...~..params1;paramsN..\n def parse_hot eva = '' col = @row.split('%') return false if col.size==1 (col.size-1).downto(0) do |c| eva = "%#{col[c]}" << eva @rg_hot.each do |ht| if(ht =~ eva;@rgx = $~) @key = @rgx[2] prms = @rgx[3].to_s.strip if /^\!/ =~ @key @new = (multi_end2(nil)+@spc+@rgx.to_s.gsub('%!','%')).split("\n") swap_last_empt_src_with_end_tg(@new) #@new array of src @row = '' else nameidclass_var() # Auto closing, see in "erb.hot": _elsif _else: # when last doc out is <% end %> and hot command is %_elsif or %_else # then remove the last doc out <% end %> if @doc_out[-1] and @doc_out[-1].strip=='<% end %>' @doc_out.pop if %w[else elsif].include? prms.split(' ')[0] end params_inline prms #concenation line if params end with \ @mem_var["$tag"] = @key if @tg_hot[@key] hots = @tg_hot[@key] hots[1]='' if !hots[1] #remark if not error! @new = hots[0].call(self).clone if @new.strip=="" #&& @tg_end[-1] @tg_end << "#{@spc}#{hots[1][0]}" empt = @row.gsub!(@rgx.to_s,"").strip @row = empt if empt == "" #remove if empty (only \t,\n) else @tg_end << "#{@spc}#{hots[1][0]}" if hots[1] @new.gsub!(/( *~\^.*[^\n]+)/,"^~^~^") setvar = $1 # don't parse SetMem ~^ @new.gsub!(/\n/,"\n#{@spc}") get_dollar(prms,hots[1]) @new.gsub!(/\^~\^~\^/,setvar) if setvar #restore SetMem re_indent(@rgx.to_s) end p "Func>> #{@new}" if @dbg[:parse] else @row.gsub!(@rgx.to_s,"<!-- no hot for:#{@key} -->") end end break end end break if @rgx end @rgx!=nil end def re_indent(srcs) new_rows = @row.gsub(srcs,@new).split("\n").select {|x|!(/^ *$/=~x)} while @doc_src[0] && /^ *$/ =~ @doc_src[0] #remove empty/space line @doc_src.shift end spc_row1 = (/[^ ]/ =~ new_rows[ 0]).to_i spc_last = (/[^ ]/ =~ new_rows[-1]).to_i spc_adds = spc_last - spc_row1 #p "SPACE ADD #{spc_row1} #{spc_last} #{(/[^ ]/ =~ @doc_src[0]).to_i}" #p new_rows #p [@doc_src[0]] if spc_adds > 0 idx = 0 spc = ' '*spc_adds while @doc_src[idx] && (/[^ ]/ =~ @doc_src[idx]).to_i > spc_row1 @doc_src[idx] = spc + @doc_src[idx] idx += 1 end end #@doc_src = @row.gsub(srcs,@new).split("\n")+@doc_src @doc_src = new_rows + @doc_src @row = @doc_src.shift+"\n" parse_spc end #internal use call from # get_div # get_input def get_shortcut(regex,tag) if(regex =~ @row;@rgx = $~) src = @rgx.captures.join keys= @rgx[1,2].join.strip opts= @rgx[3].to_s opts= $1 << opts if keys.gsub!(/(\/)$/,'') #tgt = "%!#{tag}#{keys}!#{opts}" tgt = "%#{tag}#{keys} #{opts}" @row.gsub!(src,tgt) p "to#{tag.capitalize[0,3]}: #{tgt}" if @dbg[:parse] end @rgx!=nil end #shortcut for # "%...div...!params", #and user no need to write # "%div" #if user supply the command with ID or CLASS. # %div#key my key features #same as: # #key my key features # # %div.okey my key features #same as: # .okey my key features def get_div( regex) get_shortcut(regex,'div') end #shortcut for # "%...input...!params", #and user no need to write # "%input" #if user supply the command with NAME # %input:wharsojo my key features #same as: # :wharsojo my key features def get_input(regex) get_shortcut(regex,'input') end #popup the closing tags when indentation are less than the previous. def auto_close if @tg_end.size>1 sz = @tg_end[-1][/^ +/].to_s.size if @spc.size <= sz ed = multi_end(nil).rstrip p "AutE:#{ed}#{@row}" if @dbg[:parse] @doc_out += [ed,(@doc_out[-1].to_s[-1,1]=="\n" ? '' : "\n"),@row] @row = '' true end end end #all regex for line will be parse in this methods return value of not nill #will try to parse the line (@row) again, if finish parsing (return nil) #it try to check the indentation to auto_close the line. def parse_all #check for skipping the block using add on module... parse_spc if @skiper.select{|f|send(f)}.length>0 p "skip > #{@row}" if @dbg[:parse] else @plt_opt= '' #rtn= true if @selector.select{|f|send(f)}.length>0 rtn = true if shortcut_exec( /(^[\t ]*)\-([\w\-&\/:#.%]*\{.*\}=*) *([^\n]*)\n/) rtn = true if shortcut_exec( /(^[\t ]*)\-([\w\-&\/:#.%=]*) *([^\n]*)\n/) rtn = true if shortcut_equal( /(^[\t ]*)=([\w\-&\/:#.%=]*) *([^\n]*)\n/) rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.\[\]]+\{.*?\}[= ]*)([^\n]*)\n/) rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.\[\]]+\{.*?\}[= ]*)()\n/) rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.\[\]%=]+ )([^\n]*)\n/) rtn = true if get_hot_simple(/^[\t ]*(%)([\$\w\-&\/:#.\[\]%=]+)()\n/) rtn = true if get_div(/^[\t ]*([#.])([\w\-&\/.]*\{.*\}[= ]*)([^\n]*)\n/) rtn = true if get_div(/^[\t ]*([#.])([\w\-&\/.]*\{.*\}[= ]*)()\n/) rtn = true if get_div(/^[\t ]*([#.])([\w\-&\/.=]* )([^\n]*)\n/) rtn = true if get_div(/^[\t ]*([#.])([\w\-&\/.=]*)()\n/) rtn = true if get_input( /^[\t ]*(:)([\w\-&\/#.]*\{.*\}[= ]*)([^\n]*)\n/) rtn = true if get_input( /^[\t ]*(:)([\w\-&\/#.]*\{.*\}[= ]*)()\n/) rtn = true if get_input( /^[\t ]*(:)([\w\-&\/#.=]* )([^\n]*)\n/) rtn = true if get_input( /^[\t ]*(:)([\w\-&\/#.=]*)()\n/) rtn = true if parse_hot rtn = true if merge_hot rtn = true if merge_w2x rtn = true if parse_set_var rtn = true if parse_set_mem rtn = true if parse_get_mem rtn = true if inline_tag rtn = true if parse_end if parse_tags rtn = nil elsif !rtn auto_close end end rtn end #remember command "^", not really use but if you want less typing you can #define this command inside HOT file for the next command to be execute like: # HOT file: # >>_tr # ~^%td # # Source file: # -tr # ^ inside td #I think its Ok. def parse_set_mem if @row.gsub!(/([ \t]*~\^)([^\n]+\n)/,'') set_mem = $2 if !global_set_mem(set_mem) p "setMem ^ => #{set_mem}" if @dbg[:parse] @mem_tag["^"]= set_mem end end end def global_set_mem(set_mem) return nil if !(/^%(\w+)([%-].+)/ =~ set_mem) @tg_nex[$1]= [0,proc { @mem_tag["^"] = $2}] end #remember command "^", not really use but if you want less typing you can #define this command inside HOT file for the next command to be execute like: # HOT file: # >>_tr # ~^%td # # Source file: # -tr # ^ inside td #I think its Ok. def parse_get_mem if(/^ *([\^*])([^ ]*) *([^\n]*)(\n)/ =~ @row;@rgx = $~) # BUG!!! %td{align="right"}= row[:price] * wowow => %td{align="right"}= row[:price] * wowow # from /([\^*])([^ ]*) *([^\n]*)(\n)/ # to /^ *([\^*])([^ ]*) *([^\n]*)(\n)/ keys,tmp,prms,opt,ends= @rgx.captures if opt=='!' opt='' @mem_hot=nil end keys.sub!('*','^') params_inline prms #concenation line if params end with \ @new = @mem_tag[keys].split(' ') @new[0] << tmp @new = @new.join(" ") << "\n" get_dollar(prms) rpl = @new #+opt.to_s+ends.to_s p "stMem> #{rpl}" if @dbg[:parse] @row.gsub!(@rgx.to_s,rpl) rows = @row.split("\n") if rows.size>1 @doc_src = rows+@doc_src @row = @doc_src.shift+"\n" end end @rgx!=nil end #it call from parse_end def get_end(regex) if(regex =~ @row;@rgx = $~) if @rgx[1]=='~' @new = '' @new = multi_end(1) if @tg_end.size>0 else case @rgx[1] when '!';@new = multi_end(nil) when ',';@new = multi_end(@tg_end.size) else ;@new = multi_end(@rgx[1].size) end end @doc_src = @row.gsub(@rgx.to_s,@new).split("\n")+@doc_src @row = '' end end #user can popup the end tags using these folowing command: # ,/ all end tags will be popup # ~/ one or multi end tags will be popup (depend on how many ~ you write) # !/ popup until the same indentation of "!/" def parse_end (get_end(/^(,)\/(\n)/) ? true : \ (get_end(/^[ \t]*(~+)\/(\n)/) ? true : \ get_end(/^[ \t]*(!)\/(\n)/))) end #parsing w2tags commands def parse_tags @rgx = nil par = [] rgs = @rg_tag.collect {|r|par << (r =~ @row);$~} if(max = par.compact.sort.pop) #have any to parse? @rgx = rgs[par.index(max)] @key = @rgx[2] @txt = @rgx[3].strip # when wrong splitting, fix the splitting... # assume last attribute don't have spaceses!!! ==>{opt="blah"}<== fixd = @key.split('"} ') if fixd.length>1 @key = fixd[0]+'"}' @txt = fixd[1]+@txt end if /^\!/ =~ @key @new = (multi_end(nil)+@rgx.to_s.gsub('%!','%')).split("\n") swap_last_empt_src_with_end_tg(@new) @row = '' p "W2Tag: try closing tag by indentation..." if @dbg[:parse] return true else params_inline @txt #concenation line if params end with \ @mem_var["$tag"] = @key nameidclass_var() srcs = @rgx.to_s.gsub!(/^[ \t]*/,'') tag_next = @tg_nex[@key] #;p "%mem_hot:#{@mem_hot}:#{@key}" tag_next[1].call if tag_next && @mem_hot==nil rplc = @tagr.call(self); @mem_var.each do |k,v| rplc.gsub!(k,v) end @row.gsub!(srcs,rplc) end p "W2Tag: #{@row}" if @dbg[:parse] end @rgx!=nil end #inline parsing #I Like (%strong.bold{banana="boys"} (%i.italic cake%)%)! #I Like <strong class="bold" banana="boys"><i class="italic">cake</i></strong>! def inline_tag() if(/\(%(.*?)%\)/ =~ @row;@rgx = $~) src = $1.split(/\(%/) txt = src.length>1 ? src.pop : src[0] tmp = txt.lstrip.split(' ') @key= tmp.shift @txt= tmp.join(" ") nameidclass_var() @key.strip! html= @mem_var["*code*"] html= html=='' ? @txt : html.gsub("$*",@txt) tags_created = "<#{@key}" tags_created << " #{@mem_var["*all*"].strip}" if @mem_var["*all*"]!='' tags_created << ">#{html}</#{@key}>" @row.gsub!("(%#{txt}%)",tags_created) p "InLin: #{@row}" if @dbg[:parse] end @rgx end #concenation line if params end with \ def params_inline prms while prms[-1,1]=='\\' do prms.gsub!(/\\$/,'') << @doc_src.shift.strip end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_line row,init=true\n parse_init if init\n dbg[:parse]= false\n @doc_src = read_w2tags(row).split(\"\\n\") << \",/\"\n #@doc_src = row.delete(\"\\r\").split(\"\\n\") << \",/\"\n while (@row= @doc_src.shift) do #;p \"row:#{@row}\"\n parse_row\n end\n @doc_out\...
[ "0.6696618", "0.649782", "0.63867056", "0.6265995", "0.6240059", "0.61824185", "0.6130217", "0.60672206", "0.6059859", "0.60384417", "0.5981409", "0.5924505", "0.59071255", "0.58915395", "0.58436614", "0.5832906", "0.582681", "0.5818609", "0.5816626", "0.57979727", "0.577835"...
0.58083093
19
when parsing and found tag !hot!filehot1;filehotN it will search HOT files in current folder, if it not found it will search in gem/hot and merging the HOT, this command can have multiple file HOT separate with ";"
def merge_hot if(/!hot! *([\w;.\/]+)([\n])/ =~ @row;@rgx = $~) hots= @rgx[1].split(';').collect {|x|x+'.'+@hot} rpl = [''] hots.each do |hot| fls = File.exist?(hot) ? hot : File.exist?(@src_path+'/'+hot) ? @src_path+'/'+hot : File.exist?(W2Tags::Dir+'/../hot/'+hot) ? W2Tags::Dir+'/../hot/'+hot : '' if fls=='' rpl << "<!--"+hot+", Not Found-->\n" else puts '=>'+File.expand_path(fls) if !@silent @tg_hot.merge!(W2Tags.read_filehot(fls)) end end @row.gsub!(@rgx.to_s,rpl.join) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_hot \n eva = ''\n col = @row.split('%')\n return false if col.size==1\n (col.size-1).downto(0) do |c|\n eva = \"%#{col[c]}\" << eva\n @rg_hot.each do |ht|\n if(ht =~ eva;@rgx = $~)\n @key = @rgx[2]\n prms = @rgx[3].to_s.strip\n ...
[ "0.63088816", "0.5507305", "0.5217698", "0.51449645", "0.51291925", "0.5047873", "0.504441", "0.50412136", "0.5028011", "0.498908", "0.49565917", "0.49470174", "0.49324185", "0.49133733", "0.49024856", "0.48963612", "0.4864894", "0.4864796", "0.48181063", "0.4814481", "0.4810...
0.7882455
0
when parsing and found tag !inc!fileinc it will include / replace current row from file include, and after parser will try to get current row after merging to be evaluate
def merge_w2x if(/!inc! *([\/\w\d._]+)([\n])/ =~ @row;@rgx = $~) mac = @src_path+'/'+$1 src = $~.to_s #;p mac if File.exist?(mac) pop = $~.captures.pop #new = IO.read(mac).delete("\r").gsub("\n","\n"+@spc) new = read_w2tags(IO.read(mac)) @doc_src= @row.gsub(src,new).split("\n")+@doc_src @row= @doc_src.shift+"\n" parse_spc else @row.gsub!(src,"<!--"+mac+", Not Found-->\n") nil end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_includeblock\n result = @src.scan(INCLUDEBLOCK_MATCH)\n result.gsub!(INCLUDEBLOCK_START, '')\n result.gsub!('(', '')\n result.gsub!(')', '')\n\n el = new_block_el(:includeblock)\n @tree.children << el\n parse_blocks(el, result)\n true\n end", ...
[ "0.5705134", "0.5684351", "0.5674003", "0.55687755", "0.55079937", "0.5454387", "0.5436251", "0.54150033", "0.5404728", "0.5401659", "0.53959256", "0.5317186", "0.53016293", "0.5300595", "0.5293739", "0.528158", "0.5265992", "0.52482504", "0.5209813", "0.51499856", "0.5149212...
0.6910927
0
get space (tab and spaces) on the left of the code and save it to instance it will be use if row replace with more than one row and replacement row must continue with current column (indent).
def parse_spc @spc = @row[/(^[ \t]+)/,1].to_s #sometime result is nil @ron = @row.strip.size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wrap_code\n wrap_lines(\"code\", /\\A\\s{4}/, remove_newlines: true)\n preserve_whitespace_within(\"code\") # already returns `self`\n end", "def indent()\n #This is a stub, used for indexing\n end", "def with_indentation(&block) # :doc:\n @indentation += 1...
[ "0.62540257", "0.5865972", "0.5642741", "0.5608082", "0.5598253", "0.5579334", "0.5575745", "0.55597615", "0.54963905", "0.5484376", "0.5443832", "0.54318047", "0.5428026", "0.5424995", "0.5424304", "0.5402947", "0.5402947", "0.5402947", "0.5402947", "0.5402947", "0.54023445"...
0.0
-1
do the translation from the params inside function like: %a par1;par2;par3 it do following job: replace constanta (&var!) inside params of the function replace constanta (&var!) inside new line of source code
def get_dollar(prms,ends=nil) #prms='@0;@1;@2' from hot @mem_var.each do |k,v| #;p "#{k}, #{v}" prms.gsub!(k,v) if k[0,1]=='*' and Regexp.new("~([^~]+)~#{k}".gsub('*','\\*')) =~ @new @new.gsub!($~.to_s,(v!='' ? v : $1)) else @new.gsub!(k,v) end end prms.gsub!(/\\\\/,'') #esc char \\ prms.gsub!('\}','') #esc char \} prms.gsub!('\;','') #esc char \; prms = prms.split(';') #W2Tags::splitter(prms) new_prms = @new.scan(/\$[0-9]/).uniq new_alls = @new.scan(/\$\*/) #;p 'rpl:',new_alls,new_prms,prms @new.gsub!($1,"<%= \"#{$2}\" %>") if /(==(\$[0-9]))/ =~ @new @new.gsub!($1,"<%= #{$2} %>") if /(=(\$[0-9]))/ =~ @new if /^@[0-9]$/ =~ prms[0] rpl = prms.shift.gsub('@','$') repeat = @new repeat.gsub!('$0',prms.shift) #repeat.gsub!('$*',rpl) @new = '' prms.each_with_index do |x,i| #;p "$0 #{x} => #{repeat}" @new += repeat.gsub(rpl,x) if i+1<prms.size @new += "\n"+@spc+ends.join("\n") if ends @new += "\n"+@spc end end p "Rept1: #{@new}" if @dbg[:parse] elsif new_alls==[] && new_prms.size==1 && prms.size>1 tmp = "" rpt = @rgx.to_s.gsub(@rgx[3]+"\n","") #multi key params(class,attribute,etc) classs = rpt[/([.:#].*\{.*?\}.*?) /,1] classs = rpt[/(\{.*?\}.*?) /,1] if !classs classs = rpt[/([.:#].*?) /,1] if !classs classs.sub!(/=$/,'') if classs clsmlt = classs.to_s.split(';') clscnt = clsmlt.length clsmlt+= clscnt==1 ? clsmlt*prms.length : ['']*prms.length prms.each_with_index do |x,i| y = x.strip if /^~[-%]/ =~ y tmp<< y[1,y.length-1] tmp<< "\n#{@spc}" if i+1<prms.size else line = rpt+x #tmp<< @new.gsub(new_prms[0],x) #implement multi class params ^.d;.g canggh;bow line.gsub!(classs,clsmlt[i]) if classs tmp<< line tmp<< "\n#{@spc}" if i+1<prms.size end end p "Rept2: #{tmp}" if @dbg[:parse] @new = tmp else i = new_prms.size - 1 new_prms.sort.reverse.each do |x| while Regexp.new('\\'+x+':(\d+)') =~ "\n#{@new}" do idx = $1 src = $~.to_s rpl = idx ? prms[i].split(':')[idx.to_i].to_s.strip : '' p "Splt : #{prms[i]} => #{idx}" if @dbg[:parse] @new.gsub!(src,rpl) end rgx = '\\'+x+'\.([^~ ]+)~' #/\$0\.([^~ ]~)/ => fix: next-tag (~^) eva_v = Regexp.new(rgx) #Ex:$1.upcase~ while eva_v=~ "\n#{@new}" do src = "#{x}.#{$1}~" #p "\n#{@new} => #{src}" evl = "\"#{prms[i]}\".#{$1}" #p "====> #{evl} <==" p "Eval : #{evl}" if @dbg[:parse] rpl = prms[i] ? eval(evl).to_s : "" @new.gsub!(src,rpl) end opt_v = Regexp.new('~([^$]*)\\' +x+'([^~]*)~') def_v = Regexp.new('~([^~]+)~\\'+x) if opt_v =~ @new #;p $1 rpl = '' rpl = "#{$1.to_s}#{prms[i]}#{$2.to_s}" if prms[i] && prms[i].strip!="" @new.gsub!(opt_v,rpl) #p "options: #{rpl} >> #{@new}" elsif def_v =~ @new #;p $1 src = $~.to_s rpl = (prms[i] && prms[i].strip!="" ? prms[i] : $1) @new.gsub!(src,rpl) #p "default: #{@new}" end #p "rest: #{x} => #{prms[i].to_s}" @new.gsub!(x,prms[i].to_s) i = i -1 end @new.gsub!(/\$\*/,prms[new_prms.size,99].to_a.join(';') ) @new.gsub!(/\n\t+$/,'') #remove line if only tabs end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lex_en_interp_string=(_arg0); end", "def lex_en_interp_string=(_arg0); end", "def lex_en_interp_string=(_arg0); end", "def insert_parameters line, parameters\n return line[:format].gsub(/{.*?}/) do |match| \n #TODO: lots of error handling\n if /{(?<index>[0-9]*):(?<format>.*)}/ =~ match\n ind...
[ "0.6027667", "0.6027667", "0.6027667", "0.5951742", "0.5933391", "0.58854514", "0.5853382", "0.58448863", "0.58243924", "0.58243924", "0.58243924", "0.58243924", "0.58243924", "0.58243924", "0.58243924", "0.58243924", "0.58243924", "0.58243924", "0.58243924", "0.58243924", "0...
0.0
-1