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 |
|---|---|---|---|---|---|---|
=> Performs the actual delivery, in this case, execute SQL query. | def execute
Services::Slog.debug({:message => "File write for #{@template[:identifier]}", :module => "FileTemplate", :task => "execute", :extra => {:template => @template[:identifier], :payload => @template[:payload]}})
case @template[:payload][:method]
when 'create'
begin
@template.users.each do |user|
File.open("data/users/#{user.id}/#{@template[:payload][:uri]}", "w+") { |file| file.write("\n") }
response = { :status => "200", :message => "File created.", :id => @template[:payload][:uri]}
unless @template[:payload][:content].nil? then
File.open("data/users/#{user.id}/#{@template[:payload][:uri]}", "w+") { |file| file.write(@template[:payload][:content]) }
end
end
rescue Exception => e
Services::Slog.exception e
response = { :status => "400", :message => "Method not is unsupported, #{e}" }
end
when 'append'
begin
@template.users.each do |user|
unless @template[:payload][:content].nil? then
File.open(Dir.pwd + "/data/users/#{user.id}/#{@template[:payload][:uri]}", "a+") { |file| file.write(@template[:payload][:content]) }
end
end
response = { :status => "200", :message => "Content appended to file", :id => @template[:payload][:uri]}
rescue Exception => e
response = { :status => "403", :message => "Error processing file, #{e}" }
Services::Slog.exception e
end
end
response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute\n # build the query string\n # run the query\n # return the results\n end",
"def execute(sql)\n @db.send(:_execute, self, sql, :log=>false) \n end",
"def fire\n PassiveRecord::Adapter.execute to_sql\n end",
"def execute\n puts DB_MSG\n logger.in... | [
"0.6484707",
"0.6457021",
"0.6444935",
"0.63843334",
"0.6334572",
"0.6324416",
"0.6320572",
"0.63105834",
"0.63105834",
"0.62771714",
"0.62771714",
"0.62713575",
"0.62713575",
"0.6256952",
"0.6256952",
"0.62532973",
"0.618436",
"0.61814773",
"0.6164388",
"0.61377543",
"0.6123... | 0.0 | -1 |
handle_asynchronously :execute => Validates the server connection properties | def validate_properties
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_connection; end",
"def wait_connection; end",
"def validate\n case lock_config.type\n when :while_executing\n validate_server\n when :until_executing\n validate_client\n else\n validate_client\n validate_server\n end\n\n loc... | [
"0.60965",
"0.60965",
"0.5951227",
"0.5951227",
"0.58922195",
"0.58428776",
"0.58404356",
"0.5826276",
"0.5822596",
"0.56954604",
"0.56752837",
"0.55837333",
"0.5557472",
"0.5419751",
"0.5419751",
"0.5412843",
"0.5410829",
"0.53987336",
"0.5376315",
"0.537118",
"0.5314318",
... | 0.0 | -1 |
Set a random variate as the arrival rate. | def with_arrival_rate(species, *args)
@arrival_rate = RandomVariate.send(species, *args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_rand()\n rdm = Random.new()\n @step = rdm.rand(1..10) * 100\n @rate = rdm.rand(1.2..3.0) \n end",
"def random= rnd\n @sampling.random = rnd\n end",
"def random= rnd \n @random = rnd\n @codon.random = rnd\n end",
"def random= rnd \n @random = rnd\n @codon.rando... | [
"0.7482969",
"0.6874706",
"0.6385189",
"0.6385189",
"0.6219564",
"0.5987749",
"0.59391564",
"0.5915967",
"0.58853525",
"0.5838061",
"0.5833849",
"0.5826422",
"0.5779618",
"0.57551825",
"0.57127553",
"0.5711869",
"0.57027256",
"0.56578696",
"0.56396675",
"0.5619194",
"0.560149... | 0.76901466 | 0 |
Have an item arrive from the population. | def arrive!
raise(DSQ::PopulationError, "You can not produce an arrival while the Population is waiting.", caller) if waiting?
@waiting = true
return Item.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pick_up(item)\n @items.push(item) unless items_weight + item.weight > CAPACITY\n @equipped_weapon = item if item.is_a?(Weapon) \n if item.is_a?(BoxOfBolts) \n item.feed(self) if self.health <= 80\n end\n end",
"def pick_up(item)\n return false if items_weight + item.weight > MAX_WEIGHT\... | [
"0.64498615",
"0.6302443",
"0.6135156",
"0.6074962",
"0.60643816",
"0.6026765",
"0.5939954",
"0.5905071",
"0.58802426",
"0.58473086",
"0.56653774",
"0.56487507",
"0.5631647",
"0.5574348",
"0.5568417",
"0.554843",
"0.55342615",
"0.5510227",
"0.5491626",
"0.54584455",
"0.545451... | 0.7662382 | 0 |
logic for computer opponent turn | def opponent_turn
#set variables
game = Game.find(self.game_id)
player = Player.find(game.players.last)
draw_card = Card.where(player_id: -2).first
opponent_cards = Card.where(player_id: self.id)
possible_plays = []
colors = ["blue", "green", "red", "yellow"]
#determine eligible cards in hand.
opponent_cards.each do |card|
if card.color == draw_card.color || card.number == draw_card.number || (card.card_action != nil && card.card_action == draw_card.card_action)
possible_plays.push(card)
end
end
#starts decision logic for card to play, otherwise draws a card and looks for possible plays
if possible_plays.any?
#discard current draw pile card
draw_card.player_id = -1
draw_card.save
#determines card to be played, sets card to be the new draw pile card
selected_card = possible_plays.sample
selected_card.player_id = -2
selected_card.save
#determines if card has special action, and executes action if it does.
if selected_card.card_action != nil
if selected_card.card_action === "skip" || selected_card.card_action === "reverse"
self.opponent_turn
elsif selected_card.card_action === "draw"
draw_two = Card.where(player_id: 0).sample(2)
draw_two.each do |card|
card.player_id = game.players.first.id
card.save
end
self.opponent_turn
elsif selected_card.card_action === "draw_four"
draw_four = Card.where(player_id: 0).sample(4)
draw_four.each do |card|
card.player_id = player.id
card.save
end
self.opponent_turn
elsif selected_card.card_action === "wild_color"
selected_card.color = colors.sample
selected_card.save
end
else
#switches current turn once card has been selected and played
if game.current_turn = self.id
game.current_turn = player.id
game.save
else
game.current_turn = self.id
game.save
end
end
else
#draws a card from the draw pile and repeats opponent_turn process.
drawn_card = Card.where(player_id: 0).sample
drawn_card.player_id = self.id
drawn_card.save
self.opponent_turn
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comp_turn\n index = computer_index\n if valid_move?(index)\n move(index, current_player)\n display_board\n else\n comp_turn\n end\n end",
"def take_turn(turn_value)\n turn = turn_value\n \n if turn.even? \n @player_human.move(@board)\n puts drawgrid ... | [
"0.73104227",
"0.73022056",
"0.72968125",
"0.72750026",
"0.7273715",
"0.7207768",
"0.7198235",
"0.7098426",
"0.70648116",
"0.706345",
"0.7059881",
"0.70439935",
"0.70095736",
"0.7007997",
"0.69978464",
"0.6997129",
"0.6993902",
"0.69902956",
"0.69716644",
"0.6966897",
"0.6962... | 0.6878854 | 36 |
FIXME: Does this have to be public only for testing? | def call
if event.command? && command_aliases.include?(event.command)
handle_command
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def implementation; end",
"def implementation; end",
"def probers; end",
"def internal; end",
"def schubert; end",
"def spec; end",
"def spec; end",
"def refutal()\n end",
"def custom; end",... | [
"0.8048059",
"0.6682607",
"0.6682607",
"0.6682607",
"0.6682607",
"0.64419425",
"0.64419425",
"0.6383329",
"0.6349201",
"0.61786866",
"0.61642635",
"0.61642635",
"0.61604035",
"0.6029651",
"0.6029651",
"0.6011552",
"0.6004158",
"0.5971093",
"0.5963488",
"0.5958499",
"0.5942054... | 0.0 | -1 |
Send an email after the app has been redeployed | def redeploy
setup_email @@to_emails
@subject = "[#{Rails.env.titleize}] BestDebates redeployed (#{Time.now.to_s})"
@body = @subject
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_email(email)\n email.deliver_now\n end",
"def email_notification\n return unless app.emailable? && should_email?\n Mailer.err_notification(self).deliver_now\n rescue => e\n HoptoadNotifier.notify(e)\n end",
"def notify\n @greeting = \"Just a test\"\n mail(to: \"cneumann@marsmo... | [
"0.69222033",
"0.69193697",
"0.6883864",
"0.67806935",
"0.6772746",
"0.67186886",
"0.6695353",
"0.6639254",
"0.66225237",
"0.6608702",
"0.65947366",
"0.65700966",
"0.6558848",
"0.6553054",
"0.65474105",
"0.6541321",
"0.6539925",
"0.6535232",
"0.65346843",
"0.6533135",
"0.6517... | 0.815746 | 0 |
Reccomendation Engine call this method to get reccomened events for a user | def reccomend_me
event_list = score_events.keys
event_list.first 5
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_events()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}/#{id}/events\"))[0]\n end",
"def get_events\n # events created by this user\n @my_events = User.find(current_user.id).event_attendants.where('owner = 1')\n\n # events this user has joined\n @joined_... | [
"0.74442786",
"0.7333088",
"0.7140724",
"0.7032516",
"0.6814834",
"0.66587687",
"0.6624568",
"0.66055655",
"0.6588455",
"0.65193635",
"0.6412673",
"0.6395039",
"0.6389037",
"0.6338103",
"0.6305406",
"0.62867707",
"0.62426466",
"0.6239953",
"0.622422",
"0.62102956",
"0.6206227... | 0.0 | -1 |
These methods check a users favourites against events | def score_assign(hash_item, event_attribute)
score = 0
if hash_item[0] == event_attribute
score = 3
elsif hash_item[1] == event_attribute
score = 2
elsif hash_item[2] == event_attribute
score = 1
else
score = 0
end
return score
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def favorited? subject\n has_event? 'favorite', subject\n end",
"def favorite_check user, img\n user.favorites.each do |fav|\n if fav.image_id == img.id\n return true\n end\n end\n\n return false\n end",
"def favorite_check\n @check = @fav_list.include?(@sele... | [
"0.73230517",
"0.7102202",
"0.70043004",
"0.6876272",
"0.6835686",
"0.6784405",
"0.6717347",
"0.6671581",
"0.66344184",
"0.6633944",
"0.6630775",
"0.66226006",
"0.66087705",
"0.6602614",
"0.65947956",
"0.6567841",
"0.6550224",
"0.6512397",
"0.65115446",
"0.64876044",
"0.64866... | 0.0 | -1 |
These methods determin a users favourites | def get_positive_reviews
all_reviews = Review.where(user_id: self.id)
all_reviews.select{|review|review.rating > Review.rating_range.max/2 }
return all_reviews
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def favourite_for(user)\n favourites.find_by_user_id user\n end",
"def favourites\n\t\t\t\t@user = User.find_by(:facebook_id => params[:id_facebook])\n\t\t\t\t@favourites = Favourite.where(\"user_id = #{@user.id}\")\n\t\t\tend",
"def favorite_for(user)\n favs.find_by(user_id: user)\n end",
"def favou... | [
"0.8291975",
"0.8196138",
"0.7981185",
"0.78090817",
"0.7680613",
"0.76201487",
"0.7603004",
"0.7586964",
"0.75681126",
"0.75540704",
"0.7491768",
"0.7450617",
"0.74397266",
"0.7421324",
"0.7392482",
"0.7365073",
"0.7341544",
"0.7306291",
"0.7289223",
"0.7289153",
"0.7270413"... | 0.0 | -1 |
GET /setquestionlinks GET /setquestionlinks.json | def index
@setquestionlinks = Setquestionlink.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_setquestionlink\n @setquestionlink = Setquestionlink.find(params[:id])\n end",
"def setquestionlink_params\n params.require(:setquestionlink).permit(:set_id, :question_id, :follower_id)\n end",
"def questions\n self.class.get(\"/2.2/questions\", @options)\n end",
"def linking\n ... | [
"0.69735473",
"0.6266377",
"0.6213912",
"0.602999",
"0.5992899",
"0.59813577",
"0.59813577",
"0.59813577",
"0.58711857",
"0.5832766",
"0.58084995",
"0.57767934",
"0.5749406",
"0.57004195",
"0.55756235",
"0.55699885",
"0.55546534",
"0.55438536",
"0.5517849",
"0.5510561",
"0.55... | 0.70140237 | 0 |
GET /setquestionlinks/1 GET /setquestionlinks/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @setquestionlinks = Setquestionlink.all\n end",
"def set_setquestionlink\n @setquestionlink = Setquestionlink.find(params[:id])\n end",
"def show\n @link = @question.links.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :... | [
"0.7166114",
"0.6863481",
"0.628137",
"0.62547857",
"0.61867523",
"0.60610974",
"0.6055582",
"0.598421",
"0.59757656",
"0.59519494",
"0.59046316",
"0.58382237",
"0.5787392",
"0.5782397",
"0.57762593",
"0.57317454",
"0.5722005",
"0.56735",
"0.5667848",
"0.5666463",
"0.5651339"... | 0.0 | -1 |
POST /setquestionlinks POST /setquestionlinks.json | def create
@setquestionlink = Setquestionlink.new(setquestionlink_params)
respond_to do |format|
if @setquestionlink.save
format.html { redirect_to @setquestionlink, notice: 'Setquestionlink was successfully created.' }
format.json { render action: 'show', status: :created, location: @setquestionlink }
else
format.html { render action: 'new' }
format.json { render json: @setquestionlink.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_setquestionlink\n @setquestionlink = Setquestionlink.find(params[:id])\n end",
"def setquestionlink_params\n params.require(:setquestionlink).permit(:set_id, :question_id, :follower_id)\n end",
"def linking\n result = @test.link_questions(test_params)\n if result\n retu... | [
"0.67572373",
"0.6736333",
"0.63254124",
"0.61655813",
"0.60271597",
"0.595839",
"0.589026",
"0.5860594",
"0.57420707",
"0.5684831",
"0.5682414",
"0.5682414",
"0.5682414",
"0.5622895",
"0.5622895",
"0.5491111",
"0.54285145",
"0.54269165",
"0.5355125",
"0.535366",
"0.52777493"... | 0.67061853 | 2 |
PATCH/PUT /setquestionlinks/1 PATCH/PUT /setquestionlinks/1.json | def update
respond_to do |format|
if @setquestionlink.update(setquestionlink_params)
format.html { redirect_to @setquestionlink, notice: 'Setquestionlink was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @setquestionlink.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @question.update(question_params)\n @question_link = QuizQuestion.find_by_id(@question.questionid)\n @question_link.update(:points => params[:points])\n @quiz = Quiz.find_by_id(@question_link.quizid)\n format.html { redirect_to admin_quiz... | [
"0.650731",
"0.64011365",
"0.6293118",
"0.6172139",
"0.6054418",
"0.59332246",
"0.58732957",
"0.5834798",
"0.58216316",
"0.5812505",
"0.579367",
"0.5769157",
"0.576753",
"0.574778",
"0.5744626",
"0.5710741",
"0.5659557",
"0.56441414",
"0.56336343",
"0.56285787",
"0.5614193",
... | 0.69223136 | 0 |
DELETE /setquestionlinks/1 DELETE /setquestionlinks/1.json | def destroy
@setquestionlink.destroy
respond_to do |format|
format.html { redirect_to setquestionlinks_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @questionset = Questionset.find(params[:id])\n @questionset.destroy\n\n respond_to do |format|\n format.html { redirect_to questionsets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question_link = QuizQuestion.find_by_id(@question.questionid)\n ... | [
"0.6963999",
"0.6888334",
"0.68757546",
"0.6780139",
"0.67669904",
"0.67380655",
"0.6661244",
"0.6661244",
"0.6659347",
"0.6642675",
"0.6605192",
"0.66041017",
"0.6569903",
"0.65624434",
"0.65621936",
"0.65567404",
"0.6549401",
"0.65439034",
"0.6537834",
"0.65244365",
"0.6522... | 0.77665687 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_setquestionlink
@setquestionlink = Setquestionlink.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 setquestionlink_params
params.require(:setquestionlink).permit(:set_id, :question_id, :follower_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"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 |
Set the response status code and header | def redirect_to(url)
raise DoubleRenderError if already_built_response?
res.header['location'] = url
res.status = 302
@already_built_response = true
session.store_session(res)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status(code)\n @response.status = code\n end",
"def send_headers response_code\n end",
"def status(code)\n response.status = code\n end",
"def set_status_code\n if self.status_code.nil?\n self.status_code = \"200\"\n end\n end",
"def response_status(kind)\n response.... | [
"0.794432",
"0.78250635",
"0.78158605",
"0.757165",
"0.74761254",
"0.73475385",
"0.7225574",
"0.7152764",
"0.71213555",
"0.70445",
"0.6923586",
"0.6883578",
"0.68797094",
"0.68797094",
"0.687684",
"0.68444437",
"0.678412",
"0.6782564",
"0.6771085",
"0.6747486",
"0.67410016",
... | 0.0 | -1 |
Populate the response with content. Set the response's content type to the given type. Raise an error if the developer tries to double render. | def render_content(content, content_type)
raise DoubleRenderError if already_built_response?
res['Content-Type'] = content_type
res.body = [content]
@already_built_response = true
session.store_session(res)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_content(content, type)\n if already_built_response?\n raise\n else\n res.content_type = type\n res.body = content\n end\n @already_built_response = true\n @session.store_session(res) if @session\n @flash.store_flash(res) if @flash\n end",
"def ren... | [
"0.8146179",
"0.7987508",
"0.785869",
"0.77699715",
"0.76790184",
"0.76619387",
"0.7649412",
"0.7580971",
"0.75760704",
"0.7572346",
"0.7454495",
"0.74275774",
"0.7408022",
"0.740662",
"0.7404474",
"0.7379969",
"0.73241127",
"0.7267427",
"0.72407204",
"0.71585613",
"0.7132146... | 0.7687297 | 4 |
use ERB and binding to evaluate templates pass the rendered html to render_content | def render(template_name)
body_string = ''
File.open("./app/views/#{controller_name}/#{template_name}.html.erb", 'r') do |f|
f.each_line do |line|
body_string += line
end
end
content = ERB.new(body_string).result(binding)
render_content(content, 'text/html')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render(template_content, hash)\n # create a new binding class\n cls = Class.new do\n hash.each do |key, value|\n define_method key.to_sym do\n value\n end\n end\n # expose binding\n define_method :bind do\n binding\... | [
"0.7646404",
"0.76125425",
"0.7591347",
"0.7374052",
"0.73263925",
"0.7276289",
"0.7255913",
"0.7232309",
"0.71527356",
"0.71158195",
"0.7076924",
"0.6994016",
"0.68743503",
"0.68199754",
"0.6756906",
"0.67545015",
"0.67199045",
"0.6633789",
"0.6626088",
"0.6587733",
"0.65574... | 0.0 | -1 |
method exposing a `Session` object | def session
@session ||= Puffs::Session.new(req)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def session; @session; end",
"def session; @session; end",
"def session; @session; end",
"def session; end",
"def session; end",
"def session; end",
"def session; end",
"def session\n end",
"def set_session\n \n end",
"def session() request.session end",
"def session\n Session.instanc... | [
"0.8364511",
"0.8364511",
"0.8364511",
"0.8179335",
"0.8179335",
"0.8179335",
"0.8179335",
"0.8128919",
"0.77721834",
"0.7755513",
"0.7718514",
"0.7702571",
"0.7700292",
"0.7694374",
"0.7663696",
"0.7596194",
"0.7523161",
"0.7523161",
"0.7523161",
"0.7523161",
"0.7523161",
... | 0.7221985 | 38 |
use this with the router to call action_name (:index, :show, :create...) | def invoke_action(name)
send(name)
render(name) unless already_built_response?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invoke_action(name)\n end",
"def invoke_action(name)\n end",
"def invoke_action(name)\n end",
"def index\r\n list\r\n render_action 'list'\r\n end",
"def route_index; end",
"def index\n list\n render_action 'list'\n end",
"def method_for_action(action_name); end",
"def action\n ... | [
"0.734207",
"0.734207",
"0.7341121",
"0.7079497",
"0.70227414",
"0.696795",
"0.6943637",
"0.6920887",
"0.69136906",
"0.6890334",
"0.68671626",
"0.6824139",
"0.6813997",
"0.6774912",
"0.67631173",
"0.6758284",
"0.67041564",
"0.6686834",
"0.6681827",
"0.6678034",
"0.665475",
... | 0.6446989 | 54 |
This augments the time_ago_in_words method adding the word. Usage: time_ago_in_words_with_word(object.created_at) | def time_ago_in_words_with_word(date, word = "ago")
"#{time_ago_in_words(date)} #{word}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_ago_in_words(from_time, options = T.unsafe(nil)); end",
"def time_ago_in_words(from_time, options = {})\n distance_of_time_in_words(from_time, Time.now, options)\n end",
"def decorated_time_ago_in_words(a_datetime, options = {})\n options = {\n :suffix => ' ago',\n ... | [
"0.6873405",
"0.6716613",
"0.6665151",
"0.64654344",
"0.6441428",
"0.6214084",
"0.6205446",
"0.619888",
"0.6182077",
"0.6182077",
"0.6179274",
"0.61708957",
"0.6169517",
"0.61432236",
"0.605542",
"0.60362446",
"0.6005615",
"0.59549993",
"0.59066886",
"0.5905385",
"0.5843815",... | 0.84902066 | 0 |
GET /lists GET /lists.json | def index
@lists = List.includes(:items).not_deleted
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lists\n response = rest(\"get\", \"lists\")\n\n return response[\"lists\"]\n end",
"def get_list(list_id)\n rest(\"get\", \"lists/#{list_id}\")\n end",
"def index\n @lists = current_user.lists\n #@lists = List.all\n render json: @lists\n end",
"def index\n @lists = L... | [
"0.80919707",
"0.7942851",
"0.78779286",
"0.7858385",
"0.7814817",
"0.77347493",
"0.7703373",
"0.7641295",
"0.76274574",
"0.74937147",
"0.7423371",
"0.7332808",
"0.72778344",
"0.7242392",
"0.7241362",
"0.72268915",
"0.7203747",
"0.72001815",
"0.71932775",
"0.7186917",
"0.7130... | 0.0 | -1 |
GET /lists/1 GET /lists/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_list(list_id)\n rest(\"get\", \"lists/#{list_id}\")\n end",
"def get_list(user, list)\n get(\"/#{user}/lists/#{list}.json\")\n end",
"def index\n @list_items = List.find(params[:list_id]).list_items\n\n render json: @list_items\n end",
"def show\n @list = current_project.lists.f... | [
"0.8099958",
"0.7619997",
"0.761726",
"0.75235164",
"0.7344148",
"0.73051035",
"0.7288008",
"0.72827184",
"0.7276825",
"0.7225588",
"0.7191228",
"0.7191228",
"0.7191228",
"0.7191228",
"0.7183411",
"0.70508593",
"0.6998307",
"0.6960058",
"0.69095707",
"0.68436193",
"0.6841866"... | 0.0 | -1 |
POST /lists POST /lists.json | def create
@list = List.new(list_params)
respond_to do |format|
if @list.save
@lists = List.not_deleted
format.js
else
format.js { render json: @list.errors}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_list(params={})\n @obj.post('create-list', @auth.merge(params))\n end",
"def create_list(name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"post\", \"lists\", data)\n end",
"def create\n @list = List.create!(list_params)\n json_response(@list, :created)... | [
"0.7744856",
"0.7644541",
"0.76097417",
"0.74585795",
"0.72567004",
"0.71968704",
"0.7191225",
"0.7155085",
"0.7108538",
"0.70642173",
"0.7063542",
"0.7063542",
"0.7029331",
"0.7013641",
"0.69427305",
"0.69293773",
"0.68952435",
"0.68616366",
"0.6841231",
"0.67964596",
"0.679... | 0.670565 | 27 |
PATCH/PUT /lists/1 PATCH/PUT /lists/1.json | def update
respond_to do |format|
if @list.update(list_params)
@lists = List.not_deleted
format.js
else
format.js { render json: @list.errors }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_list(list_id, name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"patch\", \"lists/#{list_id}\", data)\n end",
"def update_list(id, list)\n record \"/todos/update_list/#{id}\", :list => list\n end",
"def update\n item = @list.list_items.find(params[:id])\n\n ... | [
"0.76281315",
"0.72378355",
"0.7139185",
"0.7117268",
"0.7117268",
"0.71083647",
"0.7101187",
"0.7068508",
"0.7049937",
"0.7049937",
"0.7041945",
"0.70404303",
"0.70156926",
"0.7011639",
"0.6980567",
"0.69750524",
"0.69516975",
"0.69339174",
"0.6919702",
"0.6919702",
"0.69197... | 0.64220107 | 70 |
Use callbacks to share common setup or constraints between actions. | def set_list
@list = List.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 list_params
params.require(:list).permit(:title, :description, :is_deleted)
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 |
The original purpose of this method is to split paragraphs, but our formatter only works on paragraphs that have been presplit. Therefore, we just need to wrap the fragments in a singleelement array (representing a single paragraph) and return them. | def array_paragraphs fragments
[fragments]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commontator_split_paragraphs(text)\n return [] if text.blank?\n\n text.to_str.gsub(/\\r\\n?/, \"\\n\").gsub(/>\\s*</, \">\\n<\").split(/\\s*\\n\\s*/).reject(&:blank?)\n end",
"def split_paragraphs(input)\n return input.split(/\\n[ ]*\\n+/)\n end",
"def paragraphs\n raw_content['blocks'].m... | [
"0.73228526",
"0.69568443",
"0.68156433",
"0.66130614",
"0.66045976",
"0.6547042",
"0.6535568",
"0.6340202",
"0.631831",
"0.63062954",
"0.6305194",
"0.62608624",
"0.6233127",
"0.62245244",
"0.62051034",
"0.60753375",
"0.60259336",
"0.5894058",
"0.58859515",
"0.5849876",
"0.58... | 0.76590174 | 0 |
This overrides the Objectmethod method to return the mocked method when the mocked method is being requested. For methods that aren't being tested, this method returns a proc that will raise an error when called. This is to assure that only the mocked grpc method is being called. | def method(symbol)
return @mock_method if symbol == @expected_symbol
# The requested method is not being tested, raise if it called.
proc do
raise "The method #{symbol} was unexpectedly called during the " \
"test for #{@expected_symbol}."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_grpc_method(grpc_method_object)\n owner = grpc_method_object.owner\n\n return VALUE_UNKNOWN unless owner.instance_variable_defined?(:@rpc_descs)\n\n method, = owner.rpc_descs.find do |k, _|\n ::GRPC::GenericService.underscore(k.to_s) == grpc_method_... | [
"0.64457124",
"0.6171477",
"0.60373497",
"0.5810495",
"0.5791451",
"0.5789105",
"0.57454157",
"0.57454157",
"0.57354605",
"0.5730633",
"0.5715325",
"0.56850415",
"0.5657544",
"0.5643667",
"0.5631561",
"0.5602212",
"0.5585709",
"0.55815446",
"0.55812424",
"0.5562895",
"0.55435... | 0.6131511 | 33 |
check if sim start cmd for :go is not empty and does not raise anything | def test_start_simulation_manager_cmd_pass
record = mock 'record' do
stubs(:sm_uuid).returns('sm_uuid')
stubs(:absolute_log_path).returns('some.log')
end
configuration = mock 'configuration' do
stubs(:simulation_manager_version).returns(:go)
end
Rails.stubs(:configuration).returns(configuration)
refute_empty ShellBasedInfrastructure.start_simulation_manager_cmd(record).to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_command?\n exit_code == 127\n end",
"def check_mandatory!\n if options.work_dir.nil?\n kill \"missing file operand\"\n end\n if options.contents_template.nil?\n kill \"could not find contents template\"\n end\n end",
"def gui?; !ENV.fetch('O... | [
"0.6099718",
"0.60924816",
"0.6087318",
"0.6087318",
"0.6025161",
"0.6014837",
"0.5957551",
"0.5918315",
"0.5908224",
"0.5871625",
"0.5871625",
"0.5831465",
"0.58070993",
"0.58023465",
"0.57863414",
"0.57767653",
"0.5760262",
"0.5750627",
"0.5748957",
"0.57487154",
"0.5740913... | 0.0 | -1 |
GET /fights GET /fights.json | def index
@fights = Fight.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @fights.to_json( :include => { :field_initial => { :only => [:name] }, :field_actual => { :only => [:name] }, :category => { :only => [:name] }, :competitor_blue => { :only => [:last_name, :lot_number] }, :competitor_red => { :only => [:last_name, :lot_number] }, :competitor_winner => { :only => [:last_name, :lot_number] }, :previous_fight_blue => { :only => [:id, :number], :include => { :field_initial => { :only => [:name] } } }, :previous_fight_red => { :only => [:id, :number], :include => { :field_initial => { :only => [:name] } } } } ) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @sightings = Sighting.all\n render json: @sightings\n end",
"def index\n sighting = Sighting.all \n render json: SightingSerializer.new(sighting)\n end",
"def index\n @sights = Sight.all\n end",
"def index\n weathers = Weather.all\n render json: weathers, status: 200\n en... | [
"0.6651269",
"0.65643734",
"0.63894165",
"0.63314337",
"0.62656564",
"0.625256",
"0.6227823",
"0.6223828",
"0.616158",
"0.61259735",
"0.6120008",
"0.60488063",
"0.6023225",
"0.60102725",
"0.59912914",
"0.59912914",
"0.59912914",
"0.59901905",
"0.59883356",
"0.5947745",
"0.592... | 0.7035565 | 0 |
GET /fights/1 GET /fights/1.json | def show
@fight = Fight.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @fight.to_json( :include => { :field_initial => { :only => [:name] }, :field_actual => { :only => [:name] }, :category => { :only => [:name] }, :competitor_blue => { :only => [:last_name, :lot_number] }, :competitor_red => { :only => [:last_name, :lot_number] }, :competitor_winner => { :only => [:last_name, :lot_number] }, :previous_fight_blue => { :only => [:id, :number], :include => { :field_initial => { :only => [:name] } } }, :previous_fight_red => { :only => [:id, :number], :include => { :field_initial => { :only => [:name] } } } } ) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @fights = Fight.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fights.to_json( :include => { :field_initial => { :only => [:name] }, :field_actual => { :only => [:name] }, :category => { :only => [:name] }, :competitor_blue => { :only => [:la... | [
"0.70095485",
"0.6533609",
"0.65071505",
"0.6401412",
"0.63334215",
"0.6271122",
"0.62679684",
"0.6233991",
"0.62037486",
"0.619952",
"0.6173076",
"0.61530405",
"0.61510235",
"0.6127835",
"0.6112146",
"0.6088976",
"0.6088542",
"0.60851306",
"0.6060658",
"0.6056948",
"0.604621... | 0.6052971 | 20 |
GET /fights/new GET /fights/new.json | def new
@fight = Fight.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @fight }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @lost = Lost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost }\n end\n end",
"def new\n @monkey = Monkey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @monkey }\n end\n end"... | [
"0.7030712",
"0.7021597",
"0.6974574",
"0.6974574",
"0.69495076",
"0.69316745",
"0.6917321",
"0.6896696",
"0.68397576",
"0.68370587",
"0.6789301",
"0.6782575",
"0.6782575",
"0.67797285",
"0.6779193",
"0.67569363",
"0.6754984",
"0.6748451",
"0.67399144",
"0.67399144",
"0.67363... | 0.7278106 | 0 |
POST /fights POST /fights.json | def create
@fight = Fight.new(params[:fight])
respond_to do |format|
if @fight.save
format.html { redirect_to @fight, notice: 'Fight was successfully created.' }
format.json { render json: @fight, status: :created, location: @fight }
else
format.html { render action: "new" }
format.json { render json: @fight.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n \t@fight = current_user.fights.new(fights_params)\n \t@fight.save\n end",
"def create\n @sighting = Sighting.new(sighting_params)\n\n if @sighting.save\n render json: @sighting, status: :created, location: @sighting\n else\n render json: @sighting.errors, status: :unprocessable... | [
"0.6211402",
"0.5950801",
"0.5901964",
"0.5782905",
"0.5782905",
"0.57813686",
"0.57232535",
"0.56772625",
"0.55970687",
"0.55663216",
"0.55048555",
"0.54854095",
"0.5468592",
"0.5458998",
"0.5438364",
"0.54374874",
"0.5434274",
"0.5370728",
"0.5363863",
"0.5355054",
"0.52754... | 0.5726397 | 7 |
PUT /fights/1 PUT /fights/1.json | def update
@fight = Fight.find(params[:id])
secret = '9f8urg90$u3#92u8rh_gu(rfhi8rj*fih'
begin
client = SocketIO.connect("http://localhost:8190") do
after_start do
obj = { :secret => secret, :action => 'fight', :info => { :status => 'changed' } }
emit("tournament-ruby", obj)
disconnect
end
end
rescue
end
respond_to do |format|
if @fight.update_attributes(params[:fight])
format.html { redirect_to @fight, notice: 'Fight was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @fight.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @night.update(night_params)\n format.html { redirect_to @night, notice: 'Night was successfully updated.' }\n format.json { render :show, status: :ok, location: @night }\n else\n format.html { render :edit }\n format.json { render js... | [
"0.6134244",
"0.6085238",
"0.6036257",
"0.60358",
"0.60113335",
"0.59941125",
"0.5949152",
"0.59457344",
"0.59446096",
"0.594367",
"0.592413",
"0.5893067",
"0.5877779",
"0.584548",
"0.5828102",
"0.580922",
"0.57866484",
"0.5784725",
"0.57731503",
"0.5772634",
"0.57618284",
... | 0.5670569 | 29 |
DELETE /fights/1 DELETE /fights/1.json | def destroy
@fight = Fight.find(params[:id])
@fight.destroy
respond_to do |format|
format.html { redirect_to fights_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end",
"def destroy\n @zombie_sighting = ZombieSighting.find(params[:id])\n @zombie_sighting.destroy\n\n respond_to do |format|\n format.html { redirect_to zombie_sightin... | [
"0.67872876",
"0.663105",
"0.66075027",
"0.6560254",
"0.655833",
"0.6547218",
"0.6525059",
"0.647082",
"0.647082",
"0.64679986",
"0.6448931",
"0.64354324",
"0.6430899",
"0.63960874",
"0.6367838",
"0.6362299",
"0.6353046",
"0.63466626",
"0.6343381",
"0.6334513",
"0.63334584",
... | 0.67727333 | 2 |
has_many :toppings has_many :ingredients | def name
object.pizza.name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ingredients\n RecipeIngrediant.all.select do |recing|\n recing.recipe == self\n end\n #map to ing\n\n end",
"def recipe_ingredients\n RecipeIngredient.all.select{|ingredient| ingredient.recipe == self}\n end",
"def ingredients\n recipes = RecipeIngredient.all.selec... | [
"0.67954785",
"0.6722225",
"0.6694667",
"0.66650546",
"0.6654405",
"0.6651302",
"0.66500986",
"0.66500986",
"0.6647862",
"0.66351056",
"0.66241735",
"0.66158843",
"0.66080177",
"0.6574358",
"0.6501355",
"0.649157",
"0.6479837",
"0.6477694",
"0.6473498",
"0.64070636",
"0.64031... | 0.0 | -1 |
GET /boat_cover_image_names/1 GET /boat_cover_image_names/1.xml | def show
@boat_cover_image_name = BoatCoverImageName.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @boat_cover_image_name }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @boat_cover_image_name = BoatCoverImageName.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @boat_cover_image_name }\n end\n end",
"def index\n @images = @owner.images\n\n respond_to do |format|\n format.html # index.html.erb\n ... | [
"0.61741",
"0.6130531",
"0.608153",
"0.5915386",
"0.5885076",
"0.58273035",
"0.57866883",
"0.5785827",
"0.5710268",
"0.57056856",
"0.5697743",
"0.5679736",
"0.5677093",
"0.56736875",
"0.56021994",
"0.55927217",
"0.55758494",
"0.55662775",
"0.556135",
"0.55586725",
"0.5551429"... | 0.70808667 | 0 |
GET /boat_cover_image_names/new GET /boat_cover_image_names/new.xml | def new
@boat_cover_image_name = BoatCoverImageName.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @boat_cover_image_name }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @boat_cover_image_name = BoatCoverImageName.new(params[:boat_cover_image_name])\n\n respond_to do |format|\n if @boat_cover_image_name.save\n format.html { redirect_to(@boat_cover_image_name, :notice => 'Boat cover image name was successfully created.') }\n format.xml { rende... | [
"0.6475556",
"0.6365224",
"0.6238099",
"0.622856",
"0.6220146",
"0.6219128",
"0.6204947",
"0.6203994",
"0.6184958",
"0.6152978",
"0.61082494",
"0.6080564",
"0.6034241",
"0.60305494",
"0.6013691",
"0.60003203",
"0.5992225",
"0.5980198",
"0.5968671",
"0.5957194",
"0.59418637",
... | 0.7314431 | 0 |
POST /boat_cover_image_names POST /boat_cover_image_names.xml | def create
@boat_cover_image_name = BoatCoverImageName.new(params[:boat_cover_image_name])
respond_to do |format|
if @boat_cover_image_name.save
format.html { redirect_to(@boat_cover_image_name, :notice => 'Boat cover image name was successfully created.') }
format.xml { render :xml => @boat_cover_image_name, :status => :created, :location => @boat_cover_image_name }
else
format.html { render :action => "new" }
format.xml { render :xml => @boat_cover_image_name.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def element\n image_name_list = get_image_name_list ORIGINALS_PATH\n image_name_list.each { |image_name| post(image_name) }\n end",
"def create\n\n if current_user.nil?\n redirect_to '/'\n end\n\n if(params[\"labels\"].nil?)\n respond_to do |format|\n format.html { redirect_to ... | [
"0.6304909",
"0.57786286",
"0.5602623",
"0.5442955",
"0.5386451",
"0.53202754",
"0.53161",
"0.53149563",
"0.5314771",
"0.5312919",
"0.52604645",
"0.52012485",
"0.51891476",
"0.51670563",
"0.51473266",
"0.51471937",
"0.5112985",
"0.5053737",
"0.5048726",
"0.503603",
"0.5021333... | 0.60576284 | 1 |
PUT /boat_cover_image_names/1 PUT /boat_cover_image_names/1.xml | def update
@boat_cover_image_name = BoatCoverImageName.find(params[:id])
respond_to do |format|
if @boat_cover_image_name.update_attributes(params[:boat_cover_image_name])
format.html { redirect_to(@boat_cover_image_name, :notice => 'Boat cover image name was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @boat_cover_image_name.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def element\n image_name_list = get_image_name_list ORIGINALS_PATH\n image_name_list.each { |image_name| post(image_name) }\n end",
"def update_name(new_name)\n ensure_uri\n response = @client.rest_put(@data['uri'], 'body' => { 'name' => new_name, 'type' => 'ArtifactsBundle' })\n ... | [
"0.5914679",
"0.57832354",
"0.57542044",
"0.57173985",
"0.5712535",
"0.5701966",
"0.5660945",
"0.5644109",
"0.56324434",
"0.56069905",
"0.55642056",
"0.55498123",
"0.55268365",
"0.55126375",
"0.55109483",
"0.5488373",
"0.5486406",
"0.547351",
"0.5460264",
"0.5406619",
"0.5388... | 0.6910563 | 0 |
DELETE /boat_cover_image_names/1 DELETE /boat_cover_image_names/1.xml | def destroy
@boat_cover_image_name = BoatCoverImageName.find(params[:id])
@boat_cover_image_name.destroy
respond_to do |format|
format.html { redirect_to(boat_cover_image_names_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_image(image_name)\n File.delete(image_name)\n end",
"def destroy\n @image_set = ImageSet.find(params[:id])\n @image_set.destroy\n\n respond_to do |format|\n format.html { redirect_to(image_sets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @image_attrib... | [
"0.64489484",
"0.64245534",
"0.6408109",
"0.6368009",
"0.6359287",
"0.6358299",
"0.6331929",
"0.63240045",
"0.63153064",
"0.63109964",
"0.62553686",
"0.6252914",
"0.62257165",
"0.62122345",
"0.62119615",
"0.62054014",
"0.620228",
"0.6194242",
"0.6176118",
"0.6159196",
"0.6152... | 0.7561677 | 0 |
return values of 2, nil, "Joe", 'four', nil | def multiply (x,y)
return x * y
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(n)\n if ! n\n return ''\n elsif n['family'] and n['given']\n return n['family'] + ', ' + n['given']\n elsif n['family']\n return n['family']\n else\n return n['given']\n end\nend",
"def first_second_and_third_students\n STUDENT_NAMES[0..2]\nend",
"def get_first_and_last_name\n if ... | [
"0.59068733",
"0.57873094",
"0.5721404",
"0.5703749",
"0.56736416",
"0.56347275",
"0.5618578",
"0.56125754",
"0.5579377",
"0.55680484",
"0.5562964",
"0.5561588",
"0.5557634",
"0.5545423",
"0.5530187",
"0.552261",
"0.5480288",
"0.54648334",
"0.5462712",
"0.54555017",
"0.539087... | 0.0 | -1 |
GET /subscription_lists GET /subscription_lists.json | def index
@subscription_lists = SubscriptionList.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_subscription\n response = Faraday.get(@subscription_api_url)\n response_json = JSON.parse(response.body)\n fix_response(response_json)\n end",
"def list_subscriptions(user)\n get(\"/#{user}/lists/subscriptions.json\")\n end",
"def find_subscriber_list(attributes)\n query_s... | [
"0.77005607",
"0.7324029",
"0.72297305",
"0.72297305",
"0.6923813",
"0.6921102",
"0.69118005",
"0.68067193",
"0.6754073",
"0.6748711",
"0.6720072",
"0.67076004",
"0.66942346",
"0.66927594",
"0.66211605",
"0.66161394",
"0.66109455",
"0.6605383",
"0.6571495",
"0.6538525",
"0.65... | 0.75479186 | 1 |
GET /subscription_lists/1 GET /subscription_lists/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @subscription_lists = SubscriptionList.all\n end",
"def show\n @list_subscription = ListSubscription.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @list_subscription }\n end\n end",
"def list_subscription\n respo... | [
"0.7450691",
"0.7405138",
"0.7309067",
"0.7055717",
"0.69659877",
"0.69659877",
"0.693317",
"0.688747",
"0.6885521",
"0.68203974",
"0.675009",
"0.6644347",
"0.66364133",
"0.6614293",
"0.65854365",
"0.64656943",
"0.6442921",
"0.6400824",
"0.63947463",
"0.6386045",
"0.63426596"... | 0.0 | -1 |
POST /subscription_lists POST /subscription_lists.json | def create
# TODO switch on "rule" value, and use the proper value in the Where
puts "\n\n\n\n\n\n\n\n\nThese are the params: #{params.inspect}"
puts "\n\n\n\n\nThis is subscription_list_params object: #{subscription_list_params.inspect}\n\n\nand its class #{subscription_list_params.class}\n\n\n\n"
#@subscription_list = SubscriptionList.new(subscription_list_params)
@subscription_list = SubscriptionList.new(subscription_list_params[:subscription_list])
# TODO add a Where according to the rule
# e.g. @subscription_lists = SubscriptionList.where(:id => params[:subscriptions])
@subscription_list.students = get_students_from_rule_param
set_proper_rule_type_from_params(@subscription_list)
puts "\n\n\n\n\n@subscription_list.students: #{@subscription_list.students.inspect}\n\n\nand its class #{@subscription_list.students.class}\n\n\n\n"
respond_to do |format|
if @subscription_list.save
format.html { redirect_to @subscription_list, notice: 'La Lista de Entrega se creó exitosamente.' }
format.json { render :show, status: :created, location: @subscription_list }
else
format.html { render :new }
format.json { render json: @subscription_list.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @list_subscription = ListSubscription.new(params[:list_subscription])\n\n respond_to do |format|\n if @list_subscription.save\n format.html { redirect_to @list_subscription, notice: 'List subscription was successfully created.' }\n format.json { render json: @list_subscription... | [
"0.72809124",
"0.7136452",
"0.6987748",
"0.69212216",
"0.6605192",
"0.6509733",
"0.64841884",
"0.64368695",
"0.6413358",
"0.64022726",
"0.6362346",
"0.6295419",
"0.6265836",
"0.6245115",
"0.62223595",
"0.62115437",
"0.618352",
"0.61101943",
"0.60940987",
"0.6081141",
"0.60725... | 0.5850062 | 44 |
PATCH/PUT /subscription_lists/1 PATCH/PUT /subscription_lists/1.json | def update
@subscription_list.students = get_students_from_rule_param
set_proper_rule_type_from_params(@subscription_list)
respond_to do |format|
#if @subscription_list.update(subscription_list_params)
if @subscription_list.update(subscription_list_params[:subscription_list])
format.html { redirect_to @subscription_list, notice: 'La Lista de Entrega se actualizó exitosamente.' }
format.json { render :show, status: :ok, location: @subscription_list }
else
format.html { render :edit }
format.json { render json: @subscription_list.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @list_subscription = ListSubscription.find(params[:id])\n\n respond_to do |format|\n if @list_subscription.update_attributes(params[:list_subscription])\n format.html { redirect_to @list_subscription, notice: 'List subscription was successfully updated.' }\n format.json { head... | [
"0.7307792",
"0.6945016",
"0.6517418",
"0.6487615",
"0.6450037",
"0.63820535",
"0.63067204",
"0.6305354",
"0.6294411",
"0.62411064",
"0.62286615",
"0.61959815",
"0.61923337",
"0.61919904",
"0.61875784",
"0.61309505",
"0.6123276",
"0.6118765",
"0.61113006",
"0.6107",
"0.6107",... | 0.65668875 | 2 |
DELETE /subscription_lists/1 DELETE /subscription_lists/1.json | def destroy
@subscription_list.destroy
respond_to do |format|
format.html { redirect_to subscription_lists_url, notice: 'La Lista de Entrega se borró exitosamente.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @list_subscription = ListSubscription.find(params[:id])\n @list_subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to list_subscriptions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription.destroy\n\n respond_to do |... | [
"0.7853924",
"0.71697277",
"0.7140043",
"0.7051224",
"0.7051224",
"0.7051224",
"0.7051224",
"0.7049974",
"0.7047578",
"0.70414",
"0.70308095",
"0.702332",
"0.69912016",
"0.6960443",
"0.6941727",
"0.6935252",
"0.69055337",
"0.69049627",
"0.69047254",
"0.6895843",
"0.6895843",
... | 0.7789424 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_subscription_list
@subscription_list = SubscriptionList.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 subscription_list_params
#params[:subscription_list].permit(:name, :description)
#params.permit(:careers, :years, :subjects).permit(subscription_list: [ :name, :description ])
#params.permit(:careers).require(:subscription_list).permit(:name, :description)
params.permit! # So far, no strong params here...
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 |
Create a new SpanContext | def initialize(tid, sid, level = 1, baggage = {})
@trace_id = tid
@span_id = sid
@level = Integer(level || 1)
@baggage = baggage || {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trace_context\n TraceContextData.new trace_id, @span_id, trace_options\n end",
"def non_recording_span(span_context)\n Span.new(span_context: span_context)\n end",
"def trace_context\n ensure_exists!\n trace.trace_context.with span_id: span_id\n end",
"def cre... | [
"0.70198977",
"0.69962186",
"0.6922547",
"0.68260103",
"0.6736814",
"0.66864425",
"0.65917724",
"0.6553084",
"0.62761396",
"0.6188183",
"0.6167505",
"0.6085077",
"0.6034239",
"0.5998214",
"0.5996701",
"0.5931383",
"0.5901731",
"0.58537287",
"0.5774807",
"0.57116485",
"0.56825... | 0.5431274 | 33 |
Runs the RPC server until a SIGINT signal. | def run
raise 'Server has shutdown.' unless @server
@server.run_till_terminated
@server = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run!\n CarrotRpc.connect\n\n signal.trap\n\n pid.check\n daemonize && suppress_output if daemonize?\n pid.ensure_written\n\n # Initialize the servers. Set logger.\n run_servers\n stop_servers(signal.wait)\n end",
"def handle_interrupt\n system \"SIGINT received, starting shutdown\... | [
"0.6743719",
"0.6282611",
"0.6260028",
"0.623745",
"0.6153226",
"0.60285866",
"0.60183835",
"0.60058933",
"0.5991355",
"0.5962793",
"0.59567213",
"0.5938346",
"0.5879837",
"0.58623683",
"0.58566815",
"0.5824581",
"0.5816113",
"0.58004975",
"0.5793054",
"0.5787713",
"0.5782777... | 0.66912156 | 1 |
override hash when overriding eql? | def hash
[schema, name].hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(other)\n super || @hash == other.hash\n end",
"def ==(other)\n self.to_hash == other.to_hash\n end",
"def eql?(arg)\n self.hash == arg.hash\n end",
"def ==(other)\n self.hash == other.hash\n end",
"def == other\n return @hash == other.hash if other.class <= Blobject\n ... | [
"0.76206",
"0.748876",
"0.7298575",
"0.7271604",
"0.72301817",
"0.7225668",
"0.71948093",
"0.71900725",
"0.71563125",
"0.71161807",
"0.7084123",
"0.7081286",
"0.7043062",
"0.7043062",
"0.7007731",
"0.69957525",
"0.69773",
"0.69773",
"0.69574386",
"0.69182867",
"0.69069564",
... | 0.0 | -1 |
while i < collection.length movies = collection[i] if !result[movies[:studio]] result[movies[:studio]] = movies[:worldwide_gross] else result[movies[:studio]] += movies[:worldwide_gross] end i +=1 end | def consolidate_cart(cart)
# [{:item => "AVOCADO", :price => 3.00, :clearance => true },
# {:item => "AVOCADO", :price => 3.00, :clearance => true },
# {:item => "KALE", :price => 3.00, :clearance => false}]
new_cart = []
i = 0
while i < cart.length do
new_cart_item = find_item_by_name_in_collection(cart[i][:item], new_cart)
if new_cart_item != nil
new_cart_item[:count] += 1
else
new_cart_item = {
:item=> cart[i][:item],
:price => cart[i][:price],
:clearance => cart[i][:clearance],
:count => 1
}
new_cart << new_cart_item
end
i+=1
end
new_cart
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gross_per_studio(collection)\n new_hash = {}\n counter = 0 \n while counter < collection.length do \n studio_name = collection[counter][:studio]\n ww_gross = collection[counter][:worldwide_gross]\n if !new_hash[studio_name]\n new_hash[studio_name] = ww_gross\n else \n new_hash[studio_name] += ww_g... | [
"0.73348093",
"0.7177914",
"0.711617",
"0.7020996",
"0.69970393",
"0.6975766",
"0.6974969",
"0.6963125",
"0.6941712",
"0.69295835",
"0.69197947",
"0.6905626",
"0.68811136",
"0.687753",
"0.68746066",
"0.686954",
"0.68607235",
"0.68484443",
"0.6826044",
"0.6823911",
"0.68063176... | 0.58235735 | 70 |
Consult README for inputs and outputs REMEMBER: This returns a new Array that represents the cart. Don't merely change `cart` (i.e. mutate) it. It's easier to return a new thing. | def apply_coupons(cart, coupons)
i = 0
while i<coupons.length
cart_item = find_item_by_name_in_collection(coupons[i][:item], cart)
couponed_item_name = "#{coupons[i][:item]} W/COUPON"
cart_item_with_coupon = find_item_by_name_in_collection(couponed_item_name, cart)
if cart_item && cart_item[:count] >= coupons[i][:num]
if cart_item_with_coupon
cart_item_with_coupon[:count] += coupons[i][:num ]
cart_item -= coupons[i][:num]
else
cart_item_with_coupon =
{ :item=>couponed_item_name,
:price=>coupons[i][:cost] / coupons[i][:num],
:count => coupons[i][:num],
:clearance=>cart_item[:clearance]
}
cart << cart_item_with_coupon
cart_item[:count] -= coupons[i][:num]
end
end
i += 1
end
cart
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def consolidate_cart(cart)\n # Consult README for inputs and outputs\n #\n # REMEMBER: This returns a new Array that represents the cart. Don't merely\n # change `cart` (i.e. mutate) it. It's easier to return a new thing.\n new_cart = []\n counter = 0\n\n while counter < cart.length\n new_item = find_i... | [
"0.71819156",
"0.71223277",
"0.6858337",
"0.6845903",
"0.67749083",
"0.676538",
"0.6528557",
"0.6528557",
"0.6528557",
"0.6528557",
"0.65179825",
"0.64994276",
"0.6447973",
"0.644747",
"0.6442914",
"0.6411282",
"0.6360142",
"0.6357091",
"0.634503",
"0.62993217",
"0.6292563",
... | 0.0 | -1 |
Consult README for inputs and outputs REMEMBER: This method should update cart | def checkout(cart, coupons)
i=0
total=0
total_cart = consolidate_cart(cart)
apply_coupons(total_cart, coupons)
apply_clearance(total_cart)
while i < total_cart.length do
total += total_cart[i][:price] * total_cart[i][:count]
i += 1
end
if total >= 100
total *= 9/10.to_f
end
total.round(2)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cart\n # Calculate price\n # Warn: Need to update cart price every time items changed in cart for the safe side\n update_total_price_and_quantity_in_cart\n @cart = get_current_cart\n \n # prepare coupons\n @available_coupons = get_available_coupons(@cart) \n end",
"def update_cart\n ... | [
"0.76693606",
"0.7292008",
"0.7246855",
"0.7243659",
"0.7121665",
"0.70870227",
"0.7067355",
"0.7052658",
"0.70241874",
"0.6979406",
"0.69738674",
"0.6955815",
"0.6949921",
"0.6945123",
"0.6908599",
"0.69085234",
"0.6898777",
"0.686617",
"0.6845554",
"0.68366593",
"0.683327",... | 0.0 | -1 |
the creation of a custom node definition or use the 'default' node definition. ==== Attributes +master_certname+ Certificate name of Puppet master. +manifest+ A Puppet manifest to inject into the node definition. +node_def_name+ A node definition pattern or name. ==== Returns +string+ A combined manifest with node definition containing input manifest ==== Examples site_pp = create_site_pp("puppetmaster", '', node_def_name='agent') | def create_site_pp(master_certname, manifest='', node_def_name='default')
default_def = <<-MANIFEST
node default {
}
MANIFEST
node_def = <<-MANIFEST
node #{node_def_name} {
#{manifest}
}
MANIFEST
if node_def_name != 'default'
node_def = "#{default_def}\n#{node_def}"
end
site_pp = <<-MANIFEST
filebucket { 'main':
server => '#{master_certname}',
path => false,
}
File { backup => 'main' }
#{node_def}
MANIFEST
return site_pp
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_site_pp(master_host, opts = {})\n opts[:manifest] ||= ''\n opts[:node_def_name] ||= 'default'\n master_certname = on(master_host, puppet('config print certname')).stdout.rstrip\n\n default_def = <<-MANIFEST\nnode default {\n}\nMANIFEST\n\n node_def = <<-MANIFEST\nnode #{opts[:no... | [
"0.7470808",
"0.72417575",
"0.6050029",
"0.6050029",
"0.582662",
"0.5364564",
"0.5363732",
"0.5279123",
"0.5262483",
"0.5093455",
"0.50499946",
"0.5011684",
"0.4840369",
"0.47749773",
"0.47224563",
"0.46902674",
"0.46900573",
"0.46787798",
"0.46635938",
"0.4632619",
"0.462915... | 0.7306205 | 1 |
Read a Puppet manifest file and inject the content into a "default" node definition. (Used mostly to overide site.pp) ==== Attributes +manifest_path+ The file path to target manifest. +master_certname+ Certificate name of Puppet master. ==== Returns +string+ A combined manifest with node definition containg input manifest ==== Examples site_pp = create_node_manifest("/tmp/test.pp", "master") | def create_node_manifest(manifest_path, master_certname, node_def_name='default')
manifest = File.read(manifest_path)
site_pp = <<-MANIFEST
filebucket { 'main':
server => '#{master_certname}',
path => false,
}
File { backup => 'main' }
node default {
#{manifest}
}
MANIFEST
return site_pp
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_site_pp(master_host, opts = {})\n opts[:manifest] ||= ''\n opts[:node_def_name] ||= 'default'\n master_certname = on(master_host, puppet('config print certname')).stdout.rstrip\n\n default_def = <<-MANIFEST\nnode default {\n}\nMANIFEST\n\n node_def = <<-MANIFEST\nnode #{opts[:no... | [
"0.69561505",
"0.6935098",
"0.6582124",
"0.62504935",
"0.62504935",
"0.62267864",
"0.6063514",
"0.605106",
"0.56757796",
"0.5502658",
"0.54138565",
"0.53964466",
"0.5343424",
"0.52187884",
"0.517615",
"0.50771815",
"0.50681776",
"0.5059875",
"0.50534964",
"0.5045868",
"0.5024... | 0.77165544 | 0 |
Set mode, owner and group on a remote path. ==== Attributes +host+ The remote host containing the target path. +path+ The path to set mode, user and group upon. +mode+ The desired mode to set on the path in as a string. +owner+ The owner to set on the path. (Puppet user if not specified.) +group+ The group to set on the path. (Puppet group if not specified.) ==== Returns nil ==== Examples set_perms_on_remote(master, "/tmp/test/site.pp", "777") | def set_perms_on_remote(host, path, mode, owner=nil, group=nil)
if (owner.nil?)
owner = on(host, puppet('config', 'print', 'user')).stdout.rstrip
end
if (group.nil?)
group = on(host, puppet('config', 'print', 'group')).stdout.rstrip
end
on(host, "chmod -R #{mode} #{path}")
on(host, "chown -R #{owner}:#{group} #{path}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_perms_on_remote(host, path, mode, opts = {})\n opts[:owner] ||= on(host, puppet('config print user')).stdout.rstrip\n opts[:group] ||= on(host, puppet('config print group')).stdout.rstrip\n\n on(host, \"chmod -R #{mode} #{path}\")\n on(host, \"chown -R #{opts[:owner]}:#{opts[:group]} #{... | [
"0.853508",
"0.62313455",
"0.6067766",
"0.58636713",
"0.5812962",
"0.5807897",
"0.57689315",
"0.5756103",
"0.5750437",
"0.57163846",
"0.5713541",
"0.5635026",
"0.5621682",
"0.558019",
"0.5562776",
"0.5513096",
"0.54989916",
"0.5477864",
"0.54386497",
"0.5429715",
"0.53882444"... | 0.8571411 | 0 |
Inject temporary "site.pp" onto target host. This will also create a "modules" folder in the target remote directory. ==== Attributes +master+ The target master for injection. +site_pp_path+ A path on the remote host into which the site.pp will be injected. +manifest+ The manifest content to inject into "site.pp" to the host target path. ==== Returns nil ==== Examples site_pp = inject_site_pp(master, "/tmp/test/site.pp", manifest) | def inject_site_pp(master, site_pp_path, manifest)
site_pp_dir = File.dirname(site_pp_path)
create_remote_file(master, site_pp_path, manifest)
set_perms_on_remote(master, site_pp_dir, "777")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inject_site_pp(master_host, site_pp_path, manifest)\n site_pp_dir = File.dirname(site_pp_path)\n create_remote_file(master_host, site_pp_path, manifest)\n\n set_perms_on_remote(master_host, site_pp_dir, '0744')\n end",
"def inject_site_pp(master_host, site_pp_path, manifest)\n site_pp_... | [
"0.8374873",
"0.8358925",
"0.6207552",
"0.6191572",
"0.6177562",
"0.6177562",
"0.60841703",
"0.5300444",
"0.52765256",
"0.51313573",
"0.50357187",
"0.50072366",
"0.47951895",
"0.47606674",
"0.47088793",
"0.46950063",
"0.4690981",
"0.46466935",
"0.46059483",
"0.45476407",
"0.4... | 0.82689875 | 2 |
Create a temporary directory environment and inject a "site.pp" for the target environment. ==== Attributes +master+ The master on which to create a new Puppet environment. +env_root_path+ The base path on the master that contains all environments. +env_seed_name+ The seed name to use for generating an environment name. +manifest+ The manifest content to inject into "site.pp" of the newly created environment. ==== Returns +string+ The environment name that was generated. ==== Examples temp_env_name = create_temp_dir_env(master, "/tmp/test/site.pp", "stuff", manifest) | def create_temp_dir_env(master, env_root_path, env_seed_name, manifest)
env_name = "#{env_seed_name}" + rand(36**16).to_s(36)
env_path = "#{env_root_path}/#{env_name}"
env_site_pp_path = "#{env_path}/manifests/site.pp"
on(master, "mkdir -p #{env_path}/manifests #{env_path}/modules")
set_perms_on_remote(master, env_path, "777")
inject_site_pp(master, env_site_pp_path, manifest)
return env_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mk_tmp_environment(environment)\n # add the tmp_environment to a set to ensure no collisions\n @@tmp_environment_set ||= Set.new\n deadman = 100; loop_num = 0\n while @@tmp_environment_set.include?(tmp_environment = environment.downcase + '_' + random_string) do\n break if ... | [
"0.62542784",
"0.60449564",
"0.57045144",
"0.56640023",
"0.5639595",
"0.56154525",
"0.5581251",
"0.5462933",
"0.53894436",
"0.5296564",
"0.527444",
"0.5107344",
"0.51043284",
"0.5100353",
"0.5087843",
"0.4992919",
"0.49681512",
"0.49661678",
"0.49555176",
"0.49258938",
"0.491... | 0.8519662 | 0 |
A method for building attribute string | def mk_attr_str **attr_map
attr_map.map{|k,v|" #{k}='#{v}'"}.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buildAttrString(attributes)\r\n str = \"\"\r\n\r\n attributes.each do |key, val|\r\n str += \" #{key}='#{val}'\"\r\n end # attributes.each\r\n\r\n puts \"attrib str: #{str}\" if $DEBUG\r\n str\r\n end",
"def attributes_string\n\t\t\t#note that underscores are converted to hyphens. Quotes... | [
"0.7914002",
"0.75023293",
"0.7355576",
"0.7305694",
"0.7254207",
"0.7232861",
"0.7195633",
"0.71831703",
"0.70630234",
"0.6961891",
"0.69222146",
"0.6919757",
"0.6909795",
"0.68599856",
"0.6849177",
"0.68178535",
"0.66554976",
"0.66554976",
"0.66554976",
"0.66519",
"0.663722... | 0.7885479 | 1 |
A method for building inline tag string | def tag_inline tagname, value, **attr_map
attr_str = mk_attr_str(attr_map)
"<#{tagname}#{attr_str}>#{value}</div>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inline_tags; end",
"def _gestalt_build_tag(name, attr = {}, text = [])\n @out << \"<#{name}\"\n @out << attr.map{|(k,v)| %[ #{k}=\"#{_gestalt_escape_entities(v)}\"] }.join\n if text != [] or block_given?\n @out << \">\"\n @out << _gestalt_escape_entities([text].join)\n if ... | [
"0.7471103",
"0.69979167",
"0.6410485",
"0.63333434",
"0.63280934",
"0.63246924",
"0.6314425",
"0.6307209",
"0.6238538",
"0.62183344",
"0.61661804",
"0.61649233",
"0.60918224",
"0.6033075",
"0.6022059",
"0.6015177",
"0.59945685",
"0.5990561",
"0.5985831",
"0.5982855",
"0.5981... | 0.7233123 | 1 |
A method for building inline div string with class attribute | def div_inline value, role
tag_inline('div', value, class: role)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def div_with_opts(opts, &block)\n class_list = opts[:classes]\n if class_list.instance_of?(Array) && class_list.size > 0\n class_list.reject! { |c| c.blank? }\n class_list = class_list.join(\" \")\n end\n content = with_output_buffer(&block)\n content_tag(:div, content, :class => class_lis... | [
"0.6959277",
"0.69079596",
"0.6722711",
"0.6668557",
"0.6538182",
"0.64266914",
"0.6351896",
"0.62614477",
"0.6241365",
"0.61993265",
"0.6178322",
"0.61711556",
"0.6168415",
"0.61362976",
"0.61201686",
"0.60939145",
"0.60395265",
"0.5968912",
"0.59623134",
"0.59617704",
"0.59... | 0.6323583 | 7 |
A method for indent array | def a_indent arr, level=1
[arr].flatten.map{|e|"#{SP*level}#{e}"}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indent()\n #This is a stub, used for indexing\n end",
"def indent; end",
"def indent; end",
"def indent; end",
"def indent; end",
"def indent; end",
"def indent!(num = nil, i_char = ' ')\n collect! do |array_element|\n array_element.indent!(num, i_char)\n ... | [
"0.75906587",
"0.73141754",
"0.73141754",
"0.73141754",
"0.73141754",
"0.73141754",
"0.7088003",
"0.70174116",
"0.68575186",
"0.6846909",
"0.65792507",
"0.65792507",
"0.6575111",
"0.6570298",
"0.65055305",
"0.6497884",
"0.6476519",
"0.63873273",
"0.63038856",
"0.63005126",
"0... | 0.793145 | 0 |
A method for building block level tag string array with class attribute | def tag_block tagname, children, **attr_map
ch = a_indent(children)
attr_str = mk_attr_str(attr_map)
["<#{tagname}#{attr_str}>", ch, "</div>"].flatten
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tag_class_list\n tags = self.tags.collect{|tag| tag.slug}\n tags.join(\" \")\n end",
"def attribute *array\n return self if guard *array\n r = self.clone\n a = array.flatten\n n_full_pairs, n_unpaired = a.length.divmod 2\n (1..n_full_pairs + n_unpaired).each do |i|\n r ... | [
"0.6022381",
"0.5720883",
"0.5706275",
"0.57003766",
"0.56544256",
"0.55647165",
"0.5539287",
"0.5517255",
"0.54926705",
"0.5465932",
"0.5458295",
"0.5454011",
"0.5447236",
"0.540648",
"0.53982335",
"0.5350301",
"0.5341292",
"0.53264374",
"0.52685076",
"0.523331",
"0.5214022"... | 0.5765087 | 1 |
A method for building block level div string array | def div_block children, role
tag_block('div', children, class: role)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_div_tags(number_of_tags)\n matched_div_tags = []\n generate_div_tags_from_prefix(number_of_tags, number_of_tags, \"\", matched_div_tags)\n matched_div_tags\nend",
"def _block(color, text, size)\n\t\t\"#{_fmt(:white, '[')}#{_fmt(color, text, size)}#{_fmt(:white, ']')}\"\n\tend",
"def blockinate(... | [
"0.6050492",
"0.5981912",
"0.5906518",
"0.5906518",
"0.5831002",
"0.57794255",
"0.5705502",
"0.5645055",
"0.56410474",
"0.5599016",
"0.5565931",
"0.5537886",
"0.55085135",
"0.5503204",
"0.5479593",
"0.5477923",
"0.5460344",
"0.54287136",
"0.5415869",
"0.5384484",
"0.53627443"... | 0.52135354 | 38 |
A method for building pair from value/role pair | def build_pair_div value_pair, role_pair
value_pair.zip(role_pair).map{|v,r|div_inline(v,r)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mk_pair_role rpair, plural=false\n suffix = plural ? 's' : ''\n \"#{rpair.join(UBAR)}_pair#{suffix}\"\n end",
"def build_pair_div_wrap value_pair, role_pair\n pairs = build_pair_div(value_pair, role_pair)\n pair_role = mk_pair_role(role_pair)\n div_block(pairs, pair_role)\n end",
"def buil... | [
"0.6371081",
"0.6001294",
"0.5729544",
"0.55660665",
"0.54193795",
"0.5290515",
"0.523177",
"0.51891524",
"0.51863986",
"0.51336324",
"0.5084742",
"0.5064395",
"0.5058741",
"0.50543714",
"0.5050385",
"0.504562",
"0.5023633",
"0.49930632",
"0.49166766",
"0.48977584",
"0.488931... | 0.5686944 | 3 |
A method for building pair role | def mk_pair_role rpair, plural=false
suffix = plural ? 's' : ''
"#{rpair.join(UBAR)}_pair#{suffix}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_role \n if self.role_ids.empty? \n self.role_ids = [2] \n end\n end",
"def setup_role \n if self.role_ids.empty? \n self.role_ids = [2] \n end\n end",
"def setup_role \n if self.role_ids.empty? \n self.role_ids = [2] \n end\n end",
"def generate_membe... | [
"0.62585205",
"0.62585205",
"0.62585205",
"0.62133557",
"0.6185055",
"0.61586076",
"0.6136967",
"0.6100749",
"0.60865206",
"0.60797864",
"0.60781956",
"0.60495305",
"0.6003415",
"0.596219",
"0.596219",
"0.5944483",
"0.59308213",
"0.5923134",
"0.59135056",
"0.58353037",
"0.582... | 0.6964274 | 0 |
A method for building pair from value/role pair with wrapper | def build_pair_div_wrap value_pair, role_pair
pairs = build_pair_div(value_pair, role_pair)
pair_role = mk_pair_role(role_pair)
div_block(pairs, pair_role)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mk_pair_role rpair, plural=false\n suffix = plural ? 's' : ''\n \"#{rpair.join(UBAR)}_pair#{suffix}\"\n end",
"def build_pairs_div value_pairs, role_pair\n pairs = value_pairs.map{|pair|build_pair_div_wrap(pair, role_pair)}\n pairs_role = mk_pair_role(role_pair, true)\n div_block(pairs, pairs... | [
"0.59162253",
"0.5388208",
"0.53568834",
"0.533363",
"0.5213542",
"0.5195389",
"0.5173027",
"0.5168893",
"0.5117218",
"0.5106408",
"0.5083076",
"0.50314116",
"0.502287",
"0.5006043",
"0.49951914",
"0.4966905",
"0.49592146",
"0.49050304",
"0.48869196",
"0.4883868",
"0.487864",... | 0.6228006 | 0 |
A method for building pairs from value/role pairs | def build_pairs_div value_pairs, role_pair
pairs = value_pairs.map{|pair|build_pair_div_wrap(pair, role_pair)}
pairs_role = mk_pair_role(role_pair, true)
div_block(pairs, pairs_role)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_pair_div value_pair, role_pair\n value_pair.zip(role_pair).map{|v,r|div_inline(v,r)}\n end",
"def name_and_role\n instructors.map do |instructors_hash|\n {instructors_hash[:name] => instructors_hash[:role]}\n end\nend",
"def build_pair_div_wrap value_pair, role_pair\n pairs = build... | [
"0.5974998",
"0.5954997",
"0.5874744",
"0.58200455",
"0.57611865",
"0.56762534",
"0.5483481",
"0.5413726",
"0.5370455",
"0.52961326",
"0.52205336",
"0.52002585",
"0.5186629",
"0.51411694",
"0.5134376",
"0.51082295",
"0.50833225",
"0.5066729",
"0.50467646",
"0.5042951",
"0.500... | 0.61040854 | 0 |
A method for building pairs from value pairs string and role pairs | def build_pairs_div_from_lines value_pair_lines, role_pair, rsep=CR, csep=BAR
value_pairs = value_pair_lines.split(rsep).map{|row|row.split(csep, 2)}
build_pairs_div(value_pairs, role_pair)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mk_pair_role rpair, plural=false\n suffix = plural ? 's' : ''\n \"#{rpair.join(UBAR)}_pair#{suffix}\"\n end",
"def build_pair *args\n args = args.to_a unless args.respond_to? :each_slice\n args.each_slice(2).map{|name,var| \"#{name} [#{var}]\" }.join(' ')\n end",
"def name_and_role\n ... | [
"0.60146636",
"0.5943397",
"0.575267",
"0.572605",
"0.5680257",
"0.5564565",
"0.54091346",
"0.5340504",
"0.5201145",
"0.5159632",
"0.5139727",
"0.5118471",
"0.5089516",
"0.50125086",
"0.49925682",
"0.49638548",
"0.4951681",
"0.4946927",
"0.49455205",
"0.4930701",
"0.4896652",... | 0.5503896 | 6 |
GET /travel_agent_profiles/1 GET /travel_agent_profiles/1.json | def show
@travel_agent_profile = TravelAgentProfile.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @travel_agent_profile }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_default_profile \n get(\"/profiles.json/default\")\nend",
"def profiles \n personid = params[:id]\n @response = JSON.parse(current_user.access_token.token.get('/api/v0/aspects/profiles?ids=['+params[:id]+']'))\n respond_to do |format|\n format.html\n format.json {render :json... | [
"0.67646885",
"0.65680057",
"0.6463444",
"0.64419246",
"0.62984014",
"0.62984014",
"0.6297298",
"0.6274834",
"0.61767066",
"0.61541593",
"0.6136203",
"0.6127489",
"0.6036603",
"0.6014449",
"0.5978605",
"0.5976262",
"0.59742224",
"0.59692156",
"0.5951449",
"0.58936715",
"0.588... | 0.7006424 | 0 |
GET /travel_agent_profiles/new GET /travel_agent_profiles/new.json | def new
@travel_agent_profile = TravelAgentProfile.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @travel_agent_profile }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @travel_agent_profile = TravelAgentProfile.new(params[:travel_agent_profile])\n\n respond_to do |format|\n if @travel_agent_profile.save\n format.html { redirect_to @travel_agent_profile, notice: 'Travel agent profile was successfully created.' }\n format.json { render json: @... | [
"0.74394727",
"0.70630705",
"0.7032297",
"0.7032297",
"0.7032297",
"0.7032297",
"0.7032297",
"0.7032297",
"0.7032297",
"0.7032297",
"0.7032297",
"0.7027311",
"0.7001514",
"0.69660693",
"0.69137156",
"0.6883795",
"0.6868704",
"0.6868704",
"0.6868704",
"0.6841565",
"0.68229765"... | 0.7776194 | 0 |
POST /travel_agent_profiles POST /travel_agent_profiles.json | def create
@travel_agent_profile = TravelAgentProfile.new(params[:travel_agent_profile])
respond_to do |format|
if @travel_agent_profile.save
format.html { redirect_to @travel_agent_profile, notice: 'Travel agent profile was successfully created.' }
format.json { render json: @travel_agent_profile, status: :created, location: @travel_agent_profile }
else
format.html { render action: "new" }
format.json { render json: @travel_agent_profile.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validator_captive_portal(args = {}) \n post(\"/profiles.json/captiveportal/\", args)\nend",
"def new\n @travel_agent_profile = TravelAgentProfile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @travel_agent_profile }\n end\n end",
"def create\n ... | [
"0.6113214",
"0.6041963",
"0.60397077",
"0.5972854",
"0.593784",
"0.59138227",
"0.58222824",
"0.5807287",
"0.5774494",
"0.5762147",
"0.57022905",
"0.5675208",
"0.56469494",
"0.56468195",
"0.56266755",
"0.56224835",
"0.56202805",
"0.5592046",
"0.5587152",
"0.5580588",
"0.55687... | 0.7092358 | 0 |
PUT /travel_agent_profiles/1 PUT /travel_agent_profiles/1.json | def update
@travel_agent_profile = TravelAgentProfile.find(params[:id])
respond_to do |format|
if @travel_agent_profile.update_attributes(params[:travel_agent_profile])
format.html { redirect_to @travel_agent_profile, notice: 'Travel agent profile was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @travel_agent_profile.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assign_default_profile(args = {}) \n put(\"/profiles.json/#{args[:profileId]}/default\", args)\nend",
"def update_profile(body={})\n perform_post(\"/account/update_profile.json\", :body => body)\nend",
"def create\n @travel_agent_profile = TravelAgentProfile.new(params[:travel_agent_profile])\n\n re... | [
"0.6809385",
"0.65529245",
"0.6258866",
"0.6257898",
"0.6222667",
"0.6146836",
"0.6144338",
"0.5987374",
"0.5947935",
"0.59297425",
"0.58937323",
"0.5876602",
"0.5825414",
"0.57946503",
"0.577177",
"0.576238",
"0.5761962",
"0.5757594",
"0.5747021",
"0.57361066",
"0.56923133",... | 0.69785553 | 0 |
DELETE /travel_agent_profiles/1 DELETE /travel_agent_profiles/1.json | def destroy
@travel_agent_profile = TravelAgentProfile.find(params[:id])
@travel_agent_profile.destroy
respond_to do |format|
format.html { redirect_to travel_agent_profiles_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @meetup_profile = MeetupProfile.find(params[:id])\n @meetup_profile.destroy\n\n respond_to do |format|\n format.html { redirect_to request.referer }\n format.json { head :no_content }\n end\n end",
"def clear_default_profile \n put(\"/profiles.json/default/clear\")\nend",
"... | [
"0.67685544",
"0.676346",
"0.67612046",
"0.67481005",
"0.67427397",
"0.67247474",
"0.6685766",
"0.66673857",
"0.66657686",
"0.6653946",
"0.6629549",
"0.6627992",
"0.66132647",
"0.6612785",
"0.6612785",
"0.6582248",
"0.6581526",
"0.6581526",
"0.6581526",
"0.6575101",
"0.657510... | 0.7679896 | 0 |
Turns an array into a frequency hash, sorted by the most frequently occurring elements | def analyze_data(ary)
frequency = count_frequency(ary)
sort_hash(frequency)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def freq(array)\n hash = Hash.new(0)\n array.each{|key| hash[key] += 1}\n hash\nend",
"def count_freq(array)\n array.each_with_object(Hash.new(0)) { |obj, counts| counts[obj] += 1 }\n end",
"def mode(array)\n freq_hash = Hash.new(0)\n #hash_array = Hash[array.map{|x| [x,0]}]\n array.each do |ar... | [
"0.77981555",
"0.7663397",
"0.753327",
"0.75237584",
"0.74856526",
"0.7475636",
"0.74359256",
"0.73970824",
"0.73486996",
"0.73171914",
"0.72864336",
"0.7269778",
"0.72477657",
"0.7234242",
"0.72316027",
"0.722736",
"0.7224914",
"0.7210071",
"0.71697426",
"0.71290445",
"0.712... | 0.709044 | 23 |
We can only retrieve one invoice body at a time, hence Body is excluded from the query fields, but is populated using the `find` class method | def body
remote[:body] || reload.remote[:body]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invoice\n @invoice ||= Invoice.find(params[:id])\n end",
"def set_body\n @body = Body.find(params[:id])\n end",
"def invoice\n SalesEngine::Invoice.find_by_id(self.invoice_id)\n end",
"def invoice_items\n invoice_items = engine.invoice_item_repository.parse\n invoice_items.selec... | [
"0.5794716",
"0.5673328",
"0.55782247",
"0.5555924",
"0.5503112",
"0.5411917",
"0.5398467",
"0.53151846",
"0.52824",
"0.5280424",
"0.52706444",
"0.52585274",
"0.5214671",
"0.5208622",
"0.51925343",
"0.5191807",
"0.5182178",
"0.5181957",
"0.5157521",
"0.515243",
"0.51515514",
... | 0.0 | -1 |
input: string of items separated by spaces (example: "carrots apples cereal pizza") steps: Add values to each item in the list set default quantity print the list to the console [can you use one of your other methods here?] output: [what data type goes here, array or hash?] We would use a hash over here Method to add an item to a list input: item name and optional quantity steps: Add variable inside the method output: New item will be added with a new quantity Method to remove an item from the list input: Use delete to delete an item from the list steps: Use .delete to delete a specific item output: Removes any unwanted item from the list Method to update the quantity of an item input: Will take two parameters item and quantity steps: Will update items as needed output: Specific item will be updated on the list Method to print a list and make it look pretty input: Print the list to the console steps: Use p to print output: List will be printed | def create_list(items)
grocery_list_array = items.split(" ")
grocery_list = Hash.new
grocery_list_array.each {|item| grocery_list[item] = 1}
grocery_list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_item(list, item, quantity=1)\r\n# input: item name and optional quantity\r\n# steps: \r\n # Use shopping list as input\r\n # Use the item to be added as 2nd input\r\n # Use the item quantity as a 3rd input (look up whether optional input is possible)\r\n # Add the item and quantity to the shopping list... | [
"0.85272187",
"0.818455",
"0.8133308",
"0.80784243",
"0.8056772",
"0.7997297",
"0.79753566",
"0.7817071",
"0.7805368",
"0.7744283",
"0.7712055",
"0.77006155",
"0.76822174",
"0.76587677",
"0.76575917",
"0.7643096",
"0.7615407",
"0.7542262",
"0.7506298",
"0.7502542",
"0.7438476... | 0.0 | -1 |
Creates CSV report with NET and server benchmarks | def report!
# Fulfill batches array with 1 second step timestamps
#
batches = []
@min_time = Time.at(@min_time.to_f.truncate + 0.999)
batches << @min_time
(@max_time - @min_time).to_i.times {
batches << batches.last + 1.second
}
batches << batches.last + 1.second
@keys = @stats.keys.sort.each(&:to_sym)
@keys.delete(:disconnect)
CSV.open(File.expand_path("results/report.csv"), 'w') do |csv|
head = []
@keys.each_with_index {|stat_name, index| head << "N #{stat_name}"; head << stat_name; head << "Server" }
csv << ["Time"] + head + ["Connections"]
# Calculate active connections per second
net_bm = {}
net_bm_count = {}
net_bm_index = {}
serv_bm = {}
serv_bm_count = {}
serv_bm_index = {}
@keys.each { |stat_name| net_bm_index[stat_name] = 0; serv_bm_index[stat_name] = 0 }
connections_index = 0
batches.each_with_index do |batch, index|
active_connections = 0
for i in connections_index..(@connections_deltas.size - 1) do
if @connections_deltas[i][:time].to_f <= batch.to_f
active_connections += @connections_deltas[i][:delta]
else
connections_index = i
break
end
if i == @connections_deltas.size-1
connections_index = i + 1
break
end
end
@keys.each do |stat_name|
net_bm[stat_name] = 0
net_bm_count[stat_name] = 0
for i in net_bm_index[stat_name]..(@stats[stat_name].size - 1) do
if @stats[stat_name][i][:time].to_f <= batch.to_f
net_bm[stat_name] += @stats[stat_name][i][:benchmark]
net_bm_count[stat_name] += 1
else
net_bm_index[stat_name] = i
break
end
if i == @stats[stat_name].size - 1
net_bm_index[stat_name] = i + 1
break
end
end
end
@keys.each do |stat_name|
serv_bm[stat_name] = 0
serv_bm_count[stat_name] = 0
for i in serv_bm_index[stat_name]..(@server_stats[stat_name].size - 1) do
if @server_stats[stat_name][i][:time].to_f <= batch.to_f
serv_bm[stat_name] += @server_stats[stat_name][i][:benchmark]
serv_bm_count[stat_name] += 1
else
serv_bm_index[stat_name] = i
break
end
if i == @server_stats[stat_name].size - 1
serv_bm_index[stat_name] = i + 1
break
end
end
end
if index > 0
@connections << active_connections + @connections[index - 1]
else
@connections << active_connections
end
result = []
@keys.each_with_index do |stat_name, index|
net_average = 0
serv_average = 0
net_average = (net_bm[stat_name] / net_bm_count[stat_name]) if net_bm_count[stat_name] > 0
serv_average = (serv_bm[stat_name] / serv_bm_count[stat_name]) if serv_bm_count[stat_name] > 0
result += ["#{net_bm_count[stat_name]}", "%3.4f"% net_average]
result += ["%3.4f"% serv_average]
end
csv << [batch.strftime("%H:%M:%S")] + result.flatten + [@connections[index]]
end
head = []
@keys.each_with_index {|stat_name, index| head << "N #{stat_name}"; head << stat_name; head << "Server" }
csv << [" "] + head + ["Connections"]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def server_report_csv(filename)\n puts 'Creating the VMs report'\n CSV.open(\"#{filename}\", 'w') do |csv|\n csv << %w(VM_List)\n csv << %w(Host_Name LPAR_Name LPAR_State OS_Status LPAR_Health Machine_Name VM_IPaddress VM_Flavor VM_CPU VM_Memory VM_CPU_Utilization VM_CPU_Mode VM_OS VM_CPU_Pool \\\n... | [
"0.6961577",
"0.6871197",
"0.63045365",
"0.6281409",
"0.6250315",
"0.61898154",
"0.61358714",
"0.61084414",
"0.6084353",
"0.6054181",
"0.6031395",
"0.6022267",
"0.6002168",
"0.59988534",
"0.5985953",
"0.59391624",
"0.59238267",
"0.59213936",
"0.59070647",
"0.5891289",
"0.5875... | 0.69748455 | 0 |
def reduce_to_total(array, alpha = 0) THE DO WHILE DOESN'T APPEAR TO WORK, WILL EXAMINE LATER total_amount = alpha; counter = 0; loop do total_amount += array[counter]; counter = counter + 1; break if counter < array.length; end return(total_amount); end | def reduce_to_total(array, alpha = 0)
total_amount = alpha;
counter = 0;
while counter < array.length do
total_amount += array[counter];
counter = counter + 1;
end
return(total_amount);
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reduce_to_total(array)\n total = 0 \n count = 0 \n while count < array.length do\n total = total + array[count]\n count += 1\n end\n total\nend",
"def reduce_to_total(array,starting_point=0)\n total = starting_point\n counter = 0 \n while counter < array.size do \n total += array[cou... | [
"0.84213156",
"0.81451094",
"0.8005651",
"0.7984552",
"0.7935845",
"0.7935845",
"0.79302746",
"0.7877407",
"0.78555954",
"0.7849903",
"0.784916",
"0.784501",
"0.78441554",
"0.78409505",
"0.7840298",
"0.78377235",
"0.7830708",
"0.7821809",
"0.7820845",
"0.7810847",
"0.7799043"... | 0.9670998 | 0 |
def reduce_to_all_true(array) THE DO WHILE DOESN'T APPEAR TO WORK, WILL EXAMINE LATER counter = 0; loop do run following block until condition is met... return false if array[counter] == array[counter]; ...return false if any elements is a false value... return false if array[counter] == !array[counter]; ...return false if any elements is a false value... return false if array[counter]; ...return false if any elements is a false value... return false if !array[counter]; ...return false if any elements is a false value... counter += 1; ...increment counter and... break if counter < array.length; ...stop executing block if this condition is true... end true; ...however if we reach here, then all array elements are true, thus return true. end | def reduce_to_all_true(array)
counter = 0;
while counter < array.length do
return false if !array[counter];
counter += 1;
end
return(true);
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reduce_to_all_true(source_array)\n i = 0\n\n while i < source_array.length do\n if source_array[i] == false\n return false\n end\n i += 1\n end\n \n return true\nend",
"def reduce_to_all_true(array)\n if array.include? false\n false\n elsif array.each.include? true\n true\n end... | [
"0.89380896",
"0.8789797",
"0.8729243",
"0.8697152",
"0.8646781",
"0.8555913",
"0.85452944",
"0.8528212",
"0.8238819",
"0.8236844",
"0.79818934",
"0.7497042",
"0.7421525",
"0.6779499",
"0.66319364",
"0.6573199",
"0.6474536",
"0.6460325",
"0.6430437",
"0.62981606",
"0.62504196... | 0.93043333 | 0 |
Returns options for ActionController::ConditionalGetstale? | def to_h
{ etag: etag, last_modified: nil }.tap do |h|
unless last_modified_opt.nil?
h[:last_modified] = StaleOptions.time?(last_modified_opt) ? last_modified_opt : last_modified
h[:last_modified] = h[:last_modified]&.utc
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def use_conditional_get(true_or_false)\n use_etag(true_or_false)\n use_last_modified(true_or_false)\n end",
"def use_conditional_get(true_or_false)\n use_etag(true_or_false)\n use_last_modified(true_or_false)\n end",
"def options ; @options ||= get(:op... | [
"0.6222175",
"0.6222175",
"0.6169611",
"0.6101613",
"0.6051409",
"0.6051409",
"0.58947855",
"0.5884164",
"0.5840682",
"0.58124405",
"0.5787676",
"0.5730864",
"0.5695988",
"0.56161046",
"0.5603937",
"0.560068",
"0.5580195",
"0.556225",
"0.5555547",
"0.5553147",
"0.55486786",
... | 0.0 | -1 |
%var:image100x100 lang_id is not used! | def build_image_size_variables(src, lang_id, var_hash)
is_admin = var_hash[:admin_view?] == true
src.gsub(/%image[\w]*:[\w\-\"_\']+/) { |r|
resulted_value = ""
image_size_attr = /%image(\w+)/.match(r)
image_size = image_size_attr.nil? ? nil : image_size_attr[1].split("x")
image_name = /:([\w_\-\"\']+)/.match(r)[1]
image_source = Source.where(:type => SourceType::IMAGE, :name => image_name).first
image_size_specified = image_size ? true : false
image_styles_attr = " style='font-size: 10px' "
unless image_source.blank?
if image_size
image_width_attr = "width='#{image_size[0]}' "
image_height_attr = "height='#{image_size[1]}' "
image_styles_attr = " style='font-size: 10px; height:#{image_size[1]}px!important' " if is_admin
end
else
# specify height and width for alternative text visibility:
image_width_attr = " width='100px' "
image_height_attr = " height='30px' "
end
image_class = " class='changeable-image' " if is_admin
image_id = " id='#{image_source.get_id}' " if image_source && is_admin
width, height = image_source.get_image_size
if image_size
if image_size[0] != width.to_s || image_size[1] != height.to_s
image_source = nil
end
end
resulted_value = "<img #{image_id} src='#{image_source ? image_source.get_image_path : '#'}' #{image_class.to_s} #{image_width_attr.to_s} #{image_height_attr.to_s} alt='#{image_source ? image_source.name : image_name}#{image_size_attr[1] if image_size_attr}' #{image_styles_attr} data-hardsize='#{image_size_specified}'/>"
resulted_value
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_normal_image\n return \"Pictures/pcn%04d.png\" % (80 + id)\n end",
"def localized_image_filename (source)\n localized_filename = get_language_filename( source, true )\n language_filename = get_language_filename( source, false )\n if language_image_exists?(localized_filename)\n return l... | [
"0.5947765",
"0.59059095",
"0.5654585",
"0.564201",
"0.5637659",
"0.5630375",
"0.5630375",
"0.5627135",
"0.5600323",
"0.5548378",
"0.5513843",
"0.54922014",
"0.5466331",
"0.5441538",
"0.54127264",
"0.54046285",
"0.53986764",
"0.5385347",
"0.5360364",
"0.5355604",
"0.53525263"... | 0.6486931 | 0 |
TODO fragment or abstract this | def test_to_table_continous
assert_equal Fixture::CONTINOUS_TABLE, @statistic.to_table!(:continous)
assert_equal Fixture::CONTINOUS_TABLE, @statistic.result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def probers; end",
"def schubert; end",
"def implementation; end",
"def implementation; end",
"def custom; end",
"def custom; end",
"def suivre; end",
"def formation; end",
"def refutal()\n ... | [
"0.75226384",
"0.6454244",
"0.6454244",
"0.6454244",
"0.6454244",
"0.6440201",
"0.6420529",
"0.6351392",
"0.6351392",
"0.630508",
"0.630508",
"0.6296929",
"0.6283499",
"0.62103945",
"0.61070657",
"0.6071251",
"0.6071251",
"0.6060764",
"0.60297245",
"0.59779453",
"0.5962461",
... | 0.0 | -1 |
TODO fragment or abstract this | def test_to_table_discrete
assert_equal Fixture::DISCRETE_TABLE, @statistic.to_table!(:discrete)
assert_equal Fixture::DISCRETE_TABLE, @statistic.result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def probers; end",
"def schubert; end",
"def implementation; end",
"def implementation; end",
"def custom; end",
"def custom; end",
"def suivre; end",
"def formation; end",
"def refutal()\n ... | [
"0.75226384",
"0.6454244",
"0.6454244",
"0.6454244",
"0.6454244",
"0.6440201",
"0.6420529",
"0.6351392",
"0.6351392",
"0.630508",
"0.630508",
"0.6296929",
"0.6283499",
"0.62103945",
"0.61070657",
"0.6071251",
"0.6071251",
"0.6060764",
"0.60297245",
"0.59779453",
"0.5962461",
... | 0.0 | -1 |
Updates backup job tables with backup processes info | def backup_finished!(info)
bs = backup_state || build_backup_state
bs.finished! info
# Email member 1st time there is data for timeline
if bs.first_time_data_available?
# Send email in background
spawn { BackupNotifier.deliver_timeline_ready(self) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_jobs!\n @jobs.each_value do |job|\n name = job[:name]\n changes = nil\n # Search the generator for changes\n @generator[:jobs].each do |gen|\n changes = gen[name.to_sym] if gen.is_a?(Hash) && gen.keys[0] == name.to_sym\n end\n # Apply changes\n ... | [
"0.53641075",
"0.514995",
"0.5135971",
"0.50589067",
"0.50500214",
"0.501807",
"0.50043446",
"0.4994661",
"0.4969358",
"0.494651",
"0.4879462",
"0.4869844",
"0.4869844",
"0.48647133",
"0.48298055",
"0.48183316",
"0.48032683",
"0.4798184",
"0.4788128",
"0.4786424",
"0.47748014... | 0.0 | -1 |
Has this member setup their account yet? | def need_backup_setup?
backup_sources.active.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def meetup_auto_create_account?\n self.meetup_auto_create_account\n end",
"def have_account?\n false\n end",
"def member?\n @member = UserSubscription.where(account_id: self.account_id, currently_active: true)\n if !@member.blank?\n return true\n else\n return false... | [
"0.7343587",
"0.7248861",
"0.70242125",
"0.66520345",
"0.66156495",
"0.6562734",
"0.6543326",
"0.6540512",
"0.65218353",
"0.652143",
"0.65178007",
"0.6509836",
"0.64983624",
"0.6493881",
"0.6481122",
"0.64548576",
"0.6432049",
"0.64139795",
"0.64101684",
"0.6409886",
"0.63684... | 0.0 | -1 |
Returns all used categories | def all_categories
stories.map(&:category).delete_if {|c| c.nil?}.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_categories\n @mutex.synchronize do\n @categories.keys\n end\n end",
"def categories\n\t\t\t@cat_cache ||= @db.js('musicthoughts.all_categories()').map {|c| c.merge(category: c[@lang]) }\n\t\t\t@cat_cache\n\t\tend",
"def all_categories\n end",
"def categories\n category_keys.... | [
"0.8080514",
"0.7871337",
"0.77789575",
"0.7742139",
"0.76994085",
"0.7656549",
"0.76434135",
"0.76183885",
"0.76160675",
"0.76135933",
"0.75819594",
"0.75819594",
"0.75819594",
"0.75781137",
"0.75755996",
"0.75744355",
"0.7533475",
"0.7469555",
"0.7463095",
"0.74515647",
"0.... | 0.7253151 | 24 |
Returns all membercreated categories | def categories
stories.map(&:category).delete_if {|c| c.nil? or c.global}.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCategories\n @categories = []\n @categories << Category.new(name: \"All\", id: -1)\n @categories += Category.all\n end",
"def categories_list\n self.categories.collect{|c| c.name}\n end",
"def categories_list\n @categories = Category.all.collect { |p| [p.name, p.id] }\n e... | [
"0.70732063",
"0.6997297",
"0.6969978",
"0.6944401",
"0.69091105",
"0.68944246",
"0.68920505",
"0.67822933",
"0.67502624",
"0.66614443",
"0.66363066",
"0.66168374",
"0.66168374",
"0.66168374",
"0.6612657",
"0.658876",
"0.6573312",
"0.65683186",
"0.6555905",
"0.6533568",
"0.65... | 0.0 | -1 |
Returns all circles = (global + user's) | def all_circles
(circles + Circle.globals).uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users\n @circle.keySet.to_a\n end",
"def current_circle(host_id = self.current_host_id)\n if host_id and (rel = relationships.find_by_user_id(host_id))\n rel.circle\n else\n circles.first\n end\n end",
"def list_people_by_circle(params = {})\n return false unless check_requ... | [
"0.6532954",
"0.612669",
"0.58640915",
"0.5796346",
"0.5792323",
"0.5639843",
"0.5616303",
"0.5605043",
"0.5553211",
"0.5519368",
"0.547997",
"0.5476148",
"0.5463248",
"0.5450114",
"0.542147",
"0.54202247",
"0.53717935",
"0.5331097",
"0.53182536",
"0.5306966",
"0.53065443",
... | 0.7935558 | 0 |
Adds relationship for guest | def add_guest(guest, circle = guest.circle)
# Adds authorization plugin role: 'guest' of user
# guests can identify their hosts with:
# guest.is_guest_of_what => Array of Members
# and member can identify their guests with:
# member.has_guests? => true/false
# member.has_guests => Array of Guests
#
# Things to watch out for:
# g.has_role? 'guest' => false
# g.has_role? 'guest, member => ArgumentError
guest.is_guest_of self
# Adds relationship: guest + circle
relationships.create!(:guest => guest, :circle => circle)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_relationship(rel_attr); end",
"def add_guest(person)\n @guests.push(person)\n end",
"def add_guest(guest_to_be_added)\n @guests << guest_to_be_added\n end",
"def add_as_client \n Event.create( \n :event_type => 'invitation',\n :detail_i1 => guest.id,\n :user_id ... | [
"0.6899112",
"0.6477152",
"0.63384116",
"0.6084839",
"0.6051174",
"0.60344386",
"0.58669955",
"0.5799434",
"0.57757974",
"0.57613236",
"0.5701113",
"0.5688169",
"0.5688021",
"0.557391",
"0.5539246",
"0.55299026",
"0.55043316",
"0.5503145",
"0.5503145",
"0.5503145",
"0.5503145... | 0.71395254 | 0 |
Populates member profile info from facebook profile data structure Returns success if both updates succeed | def sync_with_facebook_profile(fb_user)
fb_info = FacebookUserProfile.populate(fb_user)
address_book.sync_with_facebook(fb_user, fb_info) &&
profile.sync_with_facebook(fb_user, fb_info)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_profile_info\n info = provider_class.profile_info\n self.update_attributes(info)\n end",
"def updateProfile\r\n errors ||= Array.new\r\n\t\tdataHash = {\r\n user_id: params[:user].id,\r\n asset_id: params[:asset_id],\r\n\t\t\tfname: params[:fname],\r\n\t\t\tlname: params[:lname],\r... | [
"0.69915974",
"0.68040013",
"0.65659535",
"0.6480926",
"0.63532126",
"0.63348275",
"0.6327844",
"0.6301545",
"0.6291561",
"0.62879205",
"0.6284522",
"0.623852",
"0.62377363",
"0.62341356",
"0.623156",
"0.62219757",
"0.6218091",
"0.62030363",
"0.61972296",
"0.61942303",
"0.619... | 0.6220067 | 16 |
Returns of bytes used by backup data | def s3_storage_used
bytes = contents.sum(:size)
backup_sources.gmail.each do |gmail|
bytes += gmail.backup_emails.sum(:size)
end
# TODO: move size calculations to each source
backup_sources.blog.each do |blog|
blog.feed.entries.each do |entry|
if entry.feed_content
bytes += entry.feed_content.size
end
end
end
bytes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bytes_used\n bytes_total - bytes_free\n end",
"def num_bytes\n return @num_bytes\n end",
"def total_bytes\n (wired + active + inactive + free) * pagesize\n end",
"def bytes\n members.reduce(0) { |sum, gf|... | [
"0.75247806",
"0.7246485",
"0.7090979",
"0.700487",
"0.693468",
"0.6873506",
"0.685306",
"0.68505424",
"0.68375874",
"0.6824555",
"0.6806502",
"0.6796714",
"0.6729013",
"0.668996",
"0.6667818",
"0.66670495",
"0.66430736",
"0.6638221",
"0.6628052",
"0.66216385",
"0.6593814",
... | 0.7317086 | 1 |
as a calendar DB redord | def to_ics_string
# LastNote or mhc is assumed.
if @wrapped_record.respond_to?(:to_ics_string)
result = @wrapped_record.to_ics_string
return result
end
# HTTP::Response from caldav server is assumed.
if @wrapped_record.respond_to?(:body)
return @wrapped_record.body
end
return nil # Nil or unsupport object class. XXX donot put.
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_database\n DATA[:calendars].each do |calendar|\n CalendarCoordinator::Calendar.create(calendar).save\n end\n\n calendar = CalendarCoordinator::Calendar.first\n DATA[:events].each do |event|\n calendar.add_event(event)\n end\n end",
"def calendar\n @calendars = Calendar.al... | [
"0.6424451",
"0.6241097",
"0.62382174",
"0.6193696",
"0.6118175",
"0.60520196",
"0.6018068",
"0.59020257",
"0.5891128",
"0.58765596",
"0.58763486",
"0.584211",
"0.5829215",
"0.58201945",
"0.57821494",
"0.57356244",
"0.5729992",
"0.5725412",
"0.5705762",
"0.5685538",
"0.568553... | 0.0 | -1 |
Creates a reference to a source code repository. | def initialize(url)
@url = url
freeze
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_repo\n Rugged::Repository.init_at(repo_path, :bare).tap do |repo|\n repo.remotes.create('origin', \"git@github.com:#{project.gh_path}\")\n repo.remotes.add_fetch_refspec('origin', GITHUB_PULLS_REFSPEC)\n end\n end",
"def repository!\n Repository.find_or_create... | [
"0.67636",
"0.6707248",
"0.65631646",
"0.6524786",
"0.64664716",
"0.6454301",
"0.64419556",
"0.63730633",
"0.6355509",
"0.6355509",
"0.6355509",
"0.6355509",
"0.6331307",
"0.6269762",
"0.6257461",
"0.6238533",
"0.6220375",
"0.6204888",
"0.6198514",
"0.6184207",
"0.6182776",
... | 0.0 | -1 |
Test parsing of slides from text into objects | def test_slide_parsing
presentation = Domain::Presentation.new('DE', 'Title1', 'Title2', 3, 'Section 3', '(c) 2014',
'Thomas Smits', 'java', 'Test Presentation', 'WS2014',
false, nil)
parser = Parsing::Parser.new(5, Parsing::ParserHandler.new(true))
parser.parse_lines(lines(test_text), 'testfile.md', 'java', presentation)
assert_equal('DE', presentation.slide_language)
assert_equal('Thomas Smits', presentation.author)
assert_equal('Title1', presentation.title1)
assert_equal('Title2', presentation.title2)
assert_equal('Section 3', presentation.section_name)
assert_equal(3, presentation.section_number)
assert_equal('(c) 2014', presentation.copyright)
assert_equal('java', presentation.default_language)
assert_equal('Test Presentation', presentation.description)
chapter1 = presentation.chapters[0]
assert_equal('Chapter 1', chapter1.title)
slides = chapter1.slides
check_slide(slides[0], 'Slide 1.1', false, false,
[ Domain::Text, Domain::UnorderedList, Domain::Text ],
[ 'Text before the list', '', 'Text after the list' ] ) do |e|
assert_equal('Item 1', e[1].entries[0].to_s)
assert_equal('Item 2', e[1].entries[1].to_s)
assert_equal('Item 2.1', e[1].entries[2].entries[0].to_s)
assert_equal('Item 2.2', e[1].entries[2].entries[1].to_s)
end
check_slide(slides[1], 'Slide 1.2', true, false,
[ Domain::Source ],
[ "int i = 7;\ni++;" ]) { |e| assert_equal('java', e[0].language) }
check_slide(slides[2], 'Slide 1.3', true, false,
[ Domain::Source ],
[ "int k = 9;\nk++;" ]) { |e| assert_equal('java', e[0].language) }
check_slide(slides[3], 'Slide 1.4', false, true)
check_slide(slides[4], 'Slide 1.5', false, false,
[ Domain::Quote ],
[ "Quote Line 1\nQuote Line 2" ])
check_slide(slides[5], 'Slide 1.6', false, false,
[ Domain::Important,
Domain::Question ],
[ "Important Line 1\nImportant Line 2",
"Question Line 1\nQuestion Line 2" ])
check_slide(slides[6], 'Slide 1.7', false, false,
[ Domain::Text,
Domain::Comment ],
[ 'Some text' ]) { |e| assert_equal('Comment line', e[1].elements[0].to_s) }
check_slide(slides[7], 'Slide 1.8', true, false,
[ Domain::Source,
Domain::VerticalSpace,
Domain::Source ],
[ 'int i = 0;', '', 'int k = 17;' ])
check_slide(slides[8], 'Slide 1.9', false, false,
[ Domain::OrderedList ]) do |e|
assert_equal('Item 1', e[0].entries[0].to_s)
assert_equal('Item 2', e[0].entries[1].to_s)
assert_equal('Item 2.1', e[0].entries[2].entries[0].to_s)
assert_equal('Item 2.2', e[0].entries[2].entries[1].to_s)
end
check_slide(slides[9], 'Slide 1.10', false, false,
[ Domain::Script ],
[ "alert('Javascript goes here!');" ])
chapter2 = presentation.chapters[1]
slides = chapter2.slides
assert_equal('Chapter 2', chapter2.title)
check_slide(slides[0], 'Slide 2.1', false, false,
[ Domain::HTML ],
[ '<b>Bold</b>' ])
check_slide(slides[1], 'Slide 2.2', false, false,
[ Domain::ButtonLinkPrevious,
Domain::ButtonLiveCSS,
Domain::ButtonLivePreview,
Domain::ButtonLivePreviewFloat,
Domain::Button,
Domain::ButtonWithLog,
Domain::ButtonWithLogPre ])
check_slide(slides[2], 'Slide 2.3', false, false,
[ Domain::Heading, Domain::Heading, Domain::Heading ],
[ 'Heading 3', 'Heading 4', 'Heading 5' ]) do |e|
assert_equal(3, e[0].level)
assert_equal(4, e[1].level)
assert_equal(5, e[2].level)
end
check_slide(slides[3], 'Slide 2.4', false, false,
[ Domain::Image, Domain::Image, Domain::Image ],
%w(img/file.png img/file.png img/file.png )) do |e|
assert_equal('10%', e[0].width_slide)
assert_equal('30%', e[0].width_plain)
assert_equal('', e[0].alt)
assert_equal('', e[0].title)
assert_equal('10%', e[1].width_slide)
assert_nil(e[1].width_plain)
assert_equal('', e[1].alt)
assert_equal('', e[1].title)
assert_nil(e[2].width_slide)
assert_nil(e[2].width_plain)
assert_equal('', e[2].alt)
assert_equal('', e[2].title)
assert_equal('10%', e[3].width_slide)
assert_equal('0%', e[3].width_plain)
assert_equal('10%', e[4].width_slide)
assert_equal('0', e[4].width_plain)
end
check_slide(slides[4], 'Slide 2.5', false, false,
[ Domain::Image, Domain::Image, Domain::Image ],
%w(img/file.png img/file.png img/file.png )) do |e|
assert_equal('10%', e[0].width_slide)
assert_equal('30%', e[0].width_plain)
assert_equal('', e[0].alt)
assert_equal('Title of image', e[0].title)
assert_equal('10%', e[1].width_slide)
assert_nil(e[1].width_plain)
assert_equal('', e[1].alt)
assert_equal('Title of image', e[1].title)
assert_nil(e[2].width_slide)
assert_nil(e[2].width_plain)
assert_equal('', e[2].alt)
assert_equal('Title of image', e[2].title)
end
check_slide(slides[5], 'Slide 2.6', false, false,
[ Domain::Image, Domain::Image, Domain::Image ],
%w(img/file.png img/file.png img/file.png )) do |e|
assert_equal('10%', e[0].width_slide)
assert_equal('30%', e[0].width_plain)
assert_equal('Alt title of image', e[0].alt)
assert_equal('Alt title of image', e[0].title)
assert_equal('10%', e[1].width_slide)
assert_nil(e[1].width_plain)
assert_equal('Alt title of image', e[1].alt)
assert_equal('Alt title of image', e[1].title)
assert_nil(e[2].width_slide)
assert_nil(e[2].width_plain)
assert_equal('Alt title of image', e[2].alt)
assert_equal('Alt title of image', e[2].title)
end
check_slide(slides[6], 'Slide 2.7', false, false,
[ Domain::Image, Domain::Image, Domain::Image ],
%w(img/file.png img/file.png img/file.png )) do |e|
assert_equal('10%', e[0].width_slide)
assert_equal('30%', e[0].width_plain)
assert_equal('Alt title of image', e[0].alt)
assert_equal('Title of image', e[0].title)
assert_equal('10%', e[1].width_slide)
assert_nil(e[1].width_plain)
assert_equal('Alt title of image', e[1].alt)
assert_equal('Title of image', e[1].title)
assert_nil(e[2].width_slide)
assert_nil(e[2].width_plain)
assert_equal('Alt title of image', e[2].alt)
assert_equal('Title of image', e[2].title)
end
check_slide(slides[7], 'Slide 2.8', false, false,
[ Domain::UML ]) do |e|
assert_equal('100%', e[0].width_slide)
assert_equal('70%', e[0].width_plain)
end
check_slide(slides[8], 'Slide 2.9', false, false,
[ Domain::Equation ],
[ '\sum_{i=0}^N{P(X = i)} = 1' ])
check_slide(slides[9], 'Slide 2.10', true, false,
[ Domain::Source ],
[ " 0011 3 1101 -3 0111 7\n" +
"+ 0010 + 2 + 1110 + -2 + 1011 + -5\n" +
"------ --- ------ ---- ------ ----\n" +
'= 0101 = 5 = 1011 = -5 = 0010 = 2' ],
false)
check_slide(slides[10], 'Slide 2.11', false, false,
[ Domain::UnorderedList, Domain::Text, Domain::UnorderedList ]) do |e|
assert_equal('Item 1', e[0].entries[0].to_s)
assert_equal('Item 2', e[0].entries[1].to_s)
assert_equal('Example', e[1].to_s)
assert_equal('Item 3', e[2].entries[0].to_s)
assert_equal('Item 4', e[2].entries[1].to_s)
end
check_slide(slides[11], 'Slide 2.12', false, false,
[ Domain::OrderedList, Domain::Text, Domain::OrderedList ]) do |e|
assert_equal('Item 1', e[0].entries[0].to_s)
assert_equal('Item 2', e[0].entries[1].to_s)
assert_equal(1, e[0].start_number)
assert_equal('Item 1', e[0].entries[0].to_s)
assert_equal('Item 2', e[0].entries[1].to_s)
assert_equal('Item 3', e[0].entries[2].to_s)
assert_equal('Text', e[1].to_s)
assert_equal(4, e[2].start_number)
assert_equal('Item 4', e[2].entries[0].to_s)
assert_equal('Item 5', e[2].entries[1].to_s)
assert_equal('Item 6', e[2].entries[2].to_s)
end
check_slide(slides[12], 'Slide 2.13', false, false,
[ Domain::OrderedList ]) do |e|
assert_equal(4, e[0].start_number)
assert_equal('Item 4', e[0].entries[0].to_s)
assert_equal('Item 5', e[0].entries[1].to_s)
assert_equal('Item 6', e[0].entries[2].to_s)
end
check_slide(slides[13], 'Slide 2.14', false, false,
[ Domain::OrderedList ]) do |e|
assert_equal(1, e[0].start_number)
assert_equal('Item 1', e[0].entries[0].to_s)
assert_equal('Item 2', e[0].entries[1].to_s)
assert_equal('Item 2.1', e[0].entries[2].entries[0].to_s)
assert_equal(1, e[0].entries[2].start_number)
assert_equal('Item 2.2', e[0].entries[2].entries[1].to_s)
assert_equal('Item 3', e[0].entries[3].to_s)
assert_equal('Item 4', e[0].entries[4].to_s)
end
check_slide(slides[14], 'Slide 3.1', true, false,
[ Domain::Source ],
[ "THIS IS SOURCE CODE\nAT LEAST SOME" ],
false) do |e|
assert_equal("THIS IS SOURCE CODE\nAT LEAST SOME", e[0].to_s)
assert_equal("AT LEAST SOME", e[1].to_s)
assert_equal("THIS IS SOURCE CODE\nAT LEAST SOME", e[2].to_s)
assert_equal("Java", e[2].language)
assert_equal("AT LEAST SOME", e[3].to_s)
assert_equal("Java", e[3].language)
end
check_slide(slides[15], 'Slide 4.1', false, false,
[ Domain::Text, Domain::MultipleChoiceQuestions ],
[],
false) do |e|
assert_equal(false, e[1].inline)
assert_equal("Some text", e[0].to_s)
assert_equal("A question", e[1].questions[0].text)
assert_equal(false, e[1].questions[0].correct)
assert_equal("A correct question", e[1].questions[1].text)
assert_equal(true, e[1].questions[1].correct)
assert_equal("A question", e[1].questions[2].text)
assert_equal(false, e[1].questions[2].correct)
assert_equal("Some text at the end", e[2].to_s)
end
check_slide(slides[16], 'Slide 4.2', false, false,
[ Domain::Text, Domain::MultipleChoiceQuestions ],
[],
false) do |e|
assert_equal(true, e[1].inline)
assert_equal("Some text", e[0].to_s)
assert_equal("A question", e[1].questions[0].text)
assert_equal(false, e[1].questions[0].correct)
assert_equal("A correct question", e[1].questions[1].text)
assert_equal(true, e[1].questions[1].correct)
assert_equal("A question", e[1].questions[2].text)
assert_equal(false, e[1].questions[2].correct)
assert_equal("Some text at the end", e[2].to_s)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_slide_parsing\n presentation = Domain::Presentation.new('DE', 'Title1', 'Title2', 3, 'Section 3', '(c) 2014',\n 'Thomas Smits', 'java', 'Test Presentation', 'WS2014',\n false, nil)\n\n parser = Parsing::Parser.new(... | [
"0.76218355",
"0.67831904",
"0.67454565",
"0.65442306",
"0.65136373",
"0.61860144",
"0.61226267",
"0.60944426",
"0.60568273",
"0.60059",
"0.59173757",
"0.588856",
"0.588856",
"0.588856",
"0.58847",
"0.58792",
"0.58454305",
"0.58378804",
"0.5834968",
"0.57880366",
"0.578626",
... | 0.7811514 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.